Skip to content

Commit e1940b4

Browse files
committed
updated README to mention new Java, rename RegistryBackup class to RegistryBackups for consistency, restart application when __COMPAT_LAYERS used in Server Mode
1 parent 0cd3520 commit e1940b4

8 files changed

Lines changed: 65 additions & 51 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ mono_crash.*
3131
#[Oo]bj/
3232
#[Ll]og/
3333
#[Ll]ogs/
34+
Debug.zip
35+
Release.zip
3436

3537
# Visual Studio 2015/2017 cache/options directory
3638
.vs/

FlashpointSecurePlayer/EnvironmentVariables.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
namespace FlashpointSecurePlayer {
1515
class EnvironmentVariables : Modifications {
16+
const string COMPATIBILITY_LAYER = "__COMPAT_LAYER";
17+
1618
public EnvironmentVariables(Form Form) : base(Form) { }
1719

18-
new public void Activate(string name) {
20+
public void Activate(string name, string server, string applicationMutexName) {
1921
base.Activate(name);
2022
ModificationsElement modificationsElement = GetModificationsElement(true, Name);
2123
EnvironmentVariablesElement environmentVariablesElement = null;
@@ -27,15 +29,28 @@ public EnvironmentVariables(Form Form) : base(Form) { }
2729
throw new EnvironmentVariablesFailedException();
2830
}
2931

32+
string compatibilityLayer = null;
33+
3034
try {
31-
Environment.SetEnvironmentVariable(environmentVariablesElement.Name, RemoveVariablesFromValue(environmentVariablesElement.Value) as string);
32-
} catch (ArgumentNullException) {
35+
compatibilityLayer = Environment.GetEnvironmentVariable(COMPATIBILITY_LAYER);
36+
} catch (ArgumentException) {
3337
throw new EnvironmentVariablesFailedException();
38+
} catch (SecurityException) {
39+
throw new TaskRequiresElevationException();
40+
}
41+
42+
try {
43+
Environment.SetEnvironmentVariable(environmentVariablesElement.Name, RemoveVariablesFromValue(environmentVariablesElement.Value) as string);
3444
} catch (ArgumentException) {
3545
throw new EnvironmentVariablesFailedException();
3646
} catch (SecurityException) {
3747
throw new TaskRequiresElevationException();
3848
}
49+
50+
if (environmentVariablesElement.Name == COMPATIBILITY_LAYER && String.IsNullOrEmpty(compatibilityLayer) && !String.IsNullOrEmpty(server)) {
51+
RestartApplication(false, Form, applicationMutexName);
52+
throw new InvalidModificationException();
53+
}
3954
}
4055
}
4156

@@ -58,8 +73,6 @@ public EnvironmentVariables(Form Form) : base(Form) { }
5873

5974
try {
6075
Environment.SetEnvironmentVariable(environmentVariablesElement.Name, null);
61-
} catch (ArgumentNullException) {
62-
throw new EnvironmentVariablesFailedException();
6376
} catch (ArgumentException) {
6477
throw new EnvironmentVariablesFailedException();
6578
} catch (SecurityException) {

FlashpointSecurePlayer/FlashpointSecurePlayer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public partial class FlashpointSecurePlayer : Form {
2525
private readonly ModeTemplates ModeTemplates;
2626
private readonly EnvironmentVariables EnvironmentVariables;
2727
private readonly DownloadsBefore DownloadsBefore;
28-
private readonly RegistryBackup RegistryBackup;
28+
private readonly RegistryBackups RegistryBackup;
2929
private readonly SingleInstance SingleInstance;
3030
string ModificationsName = ACTIVE_EXE_CONFIGURATION_NAME;
3131
bool RunAsAdministratorModification = false;
@@ -42,7 +42,7 @@ public FlashpointSecurePlayer() {
4242
ModeTemplates = new ModeTemplates(this);
4343
EnvironmentVariables = new EnvironmentVariables(this);
4444
DownloadsBefore = new DownloadsBefore(this);
45-
RegistryBackup = new RegistryBackup(this);
45+
RegistryBackup = new RegistryBackups(this);
4646
SingleInstance = new SingleInstance(this);
4747
}
4848

@@ -181,7 +181,7 @@ private async Task ActivateModificationsAsync(string commandLine, ErrorDelegate
181181

182182
if (modificationsElement.EnvironmentVariables.Count > 0) {
183183
try {
184-
EnvironmentVariables.Activate(ModificationsName);
184+
EnvironmentVariables.Activate(ModificationsName, Server, APPLICATION_MUTEX_NAME);
185185
} catch (EnvironmentVariablesFailedException) {
186186
errorDelegate(Properties.Resources.EnvironmentVariablesFailed);
187187
} catch (System.Configuration.ConfigurationErrorsException) {

FlashpointSecurePlayer/FlashpointSecurePlayer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<Compile Include="RunAsAdministrator.cs" />
9393
<Compile Include="SingleInstance.cs" />
9494
<Compile Include="ProcessSync.cs" />
95-
<Compile Include="RegistryBackup.cs" />
95+
<Compile Include="RegistryBackups.cs" />
9696
<Compile Include="Server.cs">
9797
<SubType>Form</SubType>
9898
</Compile>

FlashpointSecurePlayer/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,10 @@ public DownloadBeforeElementCollection DownloadsBefore {
546546

547547
public class RegistryBackupElementCollection : ModificationsConfigurationElementCollection {
548548
public class RegistryBackupElement : ConfigurationElement {
549-
[ConfigurationProperty("type", DefaultValue = RegistryBackup.TYPE.KEY, IsRequired = false)]
550-
public RegistryBackup.TYPE Type {
549+
[ConfigurationProperty("type", DefaultValue = global::FlashpointSecurePlayer.RegistryBackups.TYPE.KEY, IsRequired = false)]
550+
public RegistryBackups.TYPE Type {
551551
get {
552-
return (RegistryBackup.TYPE)base["type"];
552+
return (RegistryBackups.TYPE)base["type"];
553553
}
554554

555555
set {

FlashpointSecurePlayer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("1.0.1.0")]
37-
[assembly: AssemblyFileVersion("1.0.1.0")]
36+
[assembly: AssemblyVersion("1.0.2.0")]
37+
[assembly: AssemblyFileVersion("1.0.2.0")]
3838
[assembly: NeutralResourcesLanguage("en")]
3939

FlashpointSecurePlayer/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Flashpoint Secure Player 1.0.1
1+
# Flashpoint Secure Player 1.0.2
22
This application attempts to solve common compatibility or portability issues posed by browser plugins on Windows for the purpose of playback in BlueMaxima's Flashpoint.
33

44
It is compatible with Windows 7, Windows 8, Windows 8.1 and Windows 10, and requires .NET Framework 4.5. If you are on Windows 8.1 or Windows 10, or if you are on Windows 7/8 and have updates enabled, you already have .NET Framework 4.5. Otherwise, you may [download .NET Framework 4.5.](http://www.microsoft.com/en-us/download/details.aspx?id=30653)
@@ -9,7 +9,7 @@ It is driven by a model consisting of two concepts: Modes and Modifications. The
99

1010
Presently, there are three Modes (ActiveX Mode, Server Mode, and Software Mode) and six Modifications (Run As Administrator, Mode Templates, Environment Variables, Downloads Before, Registry Backups, and Single Instance.)
1111

12-
This application has bugs. Help me find them! See the [Known Issues](#known-issues) below, and if you've found a bug that isn't listed, report anything unusual as an issue.
12+
This application has bugs. Help me find them! If you've found a bug, report anything unusual as an issue.
1313

1414
# Modes
1515
The Mode determines what action Flashpoint Secure Player will perform after all of the Modifications are made. For example, the end goal may be to open a browser, or a specific software. The Mode to use is not optional. If it is not set, an error will occur. Modes are exclusive - there may only be one set at a time.
@@ -154,7 +154,7 @@ With the "Miniclip" Modification Name specified, all URLs passed into Server Mod
154154

155155
The Software Mode Template works identically to the Server Mode Template in that it provides the ability to replace the command line passed in with regexes. The Software Mode Template also has an additional attribute, `hideWindow`, which causes the window of the software to be hidden. This is ideal for hiding console windows for softwares that have them.
156156

157-
For example, a practical use of the Software Mode Template would be to create a `modification` element that always ensures the use of important Java options.
157+
For example, a practical use of the Software Mode Template would be to create a `modification` element that always ensures the use of important Java options. Note that this example is simplified from the real Java configuration file for the purpose of demonstration.
158158

159159
```
160160
<modification name="java">
@@ -354,9 +354,6 @@ You may notice that because the Flashpoint Secure Player is effectively capable
354354
- Generally speaking, more specific error reporting would be nice.
355355
- Old CPU Simulator integration?
356356

357-
# <a name="known-issues"></a>Known Issues
358-
- The compatibility layers have no effect when using Server Mode.
359-
360357
# Questions And Answers
361358
**Is there is Linux version?**
362359

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
using static FlashpointSecurePlayer.Shared.FlashpointSecurePlayerSection.ModificationsElementCollection.ModificationsElement.RegistryBackupElementCollection;
2424

2525
namespace FlashpointSecurePlayer {
26-
public class RegistryBackup : Modifications {
26+
public class RegistryBackups : Modifications {
2727
// https://social.msdn.microsoft.com/Forums/vstudio/en-US/0f3557ee-16bd-4a36-a4f3-00efbeae9b0d/app-config-multiple-sections-in-sectiongroup-with-same-name?forum=csharpgeneral
2828

2929
private class WOW64Key {
@@ -179,9 +179,9 @@ private Dictionary<string, List<WOW64Key>> WOW64KeyLists {
179179
}
180180
}
181181

182-
public RegistryBackup(Form Form) : base(Form) { }
182+
public RegistryBackups(Form Form) : base(Form) { }
183183

184-
~RegistryBackup() {
184+
~RegistryBackups() {
185185
if (ImportStarted) {
186186
try {
187187
StopImport();
@@ -559,7 +559,30 @@ private void DeleteValueInRegistryView(string keyName, string valueName, Registr
559559

560560
// this function deals with this utter trashfire
561561
// https://docs.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys#redirected-shared-and-reflected-keys-under-wow64
562-
private string GetRedirectedKeyValueName(string keyValueName) {
562+
private string GetRedirectedKeyValueName(string keyValueName, BINARY_TYPE binaryType) {
563+
// does our OS use WOW64?
564+
string windowsVersionName = GetWindowsVersionName(false, false, true);
565+
566+
if (windowsVersionName != "Windows Vista 64-bit" &&
567+
windowsVersionName != "Windows Server 2008 64-bit" &&
568+
windowsVersionName != "Windows 7 64-bit" &&
569+
windowsVersionName != "Windows Server 2008 R2 64-bit" &&
570+
windowsVersionName != "Windows 8 64-bit" &&
571+
windowsVersionName != "Windows Server 2012 64-bit" &&
572+
windowsVersionName != "Windows 8.1 64-bit" &&
573+
windowsVersionName != "Windows Server 2012 R2 64-bit" &&
574+
windowsVersionName != "Windows 10 64-bit" &&
575+
windowsVersionName != "Windows Server 2016 64-bit") {
576+
// no
577+
return keyValueName;
578+
}
579+
580+
// is the binary 32-bit?
581+
if (binaryType == BINARY_TYPE.SCS_64BIT_BINARY) {
582+
// no
583+
return keyValueName;
584+
}
585+
563586
// can be empty for default value, but not null
564587
if (keyValueName == null) {
565588
return keyValueName;
@@ -578,7 +601,7 @@ private string GetRedirectedKeyValueName(string keyValueName) {
578601
List<WOW64Key> wow64KeyList = WOW64KeyLists[keyValueNameSplit[0]];
579602
WOW64Key.EFFECT effect = WOW64Key.EFFECT.SHARED;
580603
List<string> effectExceptionValueNames = new List<string>();
581-
string windowsVersionName = GetWindowsVersionName(false, false, false);
604+
windowsVersionName = GetWindowsVersionName(false, false, false);
582605
bool removeWOW64Subkey = false;
583606

584607
for (int i = 0;i < wow64KeyList.Count;i++) {
@@ -1123,11 +1146,7 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
11231146

11241147
if (safeKeyHandle == 0) {
11251148
// we don't need to queue it, we can just add the key right here
1126-
registryBackupElement.KeyName = GetKeyValueNameFromKernelRegistryString(registryBackupElement.KeyName);
1127-
1128-
if (modificationsElement.RegistryBackups.BinaryType != BINARY_TYPE.SCS_64BIT_BINARY) {
1129-
registryBackupElement.KeyName = GetRedirectedKeyValueName(registryBackupElement.KeyName);
1130-
}
1149+
registryBackupElement.KeyName = GetRedirectedKeyValueName(GetKeyValueNameFromKernelRegistryString(registryBackupElement.KeyName), modificationsElement.RegistryBackups.BinaryType);
11311150

11321151
registryBackupElement.ValueKind = GetValueKindInRegistryView(registryBackupElement.KeyName, registryBackupElement.ValueName, registryView);
11331152
value = null;
@@ -1167,11 +1186,7 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
11671186
// need to deal with KCB
11681187
// well, we already know the base key name from before, so we can wrap this up now
11691188
if (KCBModificationKeyNames.ContainsKey(safeKeyHandle)) {
1170-
registryBackupElement.KeyName = GetKeyValueNameFromKernelRegistryString(KCBModificationKeyNames[safeKeyHandle] + "\\" + registryBackupElement.KeyName);
1171-
1172-
if (modificationsElement.RegistryBackups.BinaryType != BINARY_TYPE.SCS_64BIT_BINARY) {
1173-
registryBackupElement.KeyName = GetRedirectedKeyValueName(registryBackupElement.KeyName);
1174-
}
1189+
registryBackupElement.KeyName = GetRedirectedKeyValueName(GetKeyValueNameFromKernelRegistryString(KCBModificationKeyNames[safeKeyHandle] + "\\" + registryBackupElement.KeyName), modificationsElement.RegistryBackups.BinaryType);
11751190

11761191
registryBackupElement.ValueKind = GetValueKindInRegistryView(registryBackupElement.KeyName, registryBackupElement.ValueName, registryView);
11771192
value = null;
@@ -1249,11 +1264,7 @@ private void ModificationRemoved(RegistryTraceData registryTraceData) {
12491264
ulong safeKeyHandle = registryTraceData.KeyHandle & 0x00000000FFFFFFFF;
12501265

12511266
if (safeKeyHandle == 0) {
1252-
registryBackupElement.KeyName = GetKeyValueNameFromKernelRegistryString(registryBackupElement.KeyName);
1253-
1254-
if (modificationsElement.RegistryBackups.BinaryType != BINARY_TYPE.SCS_64BIT_BINARY) {
1255-
registryBackupElement.KeyName = GetRedirectedKeyValueName(registryBackupElement.KeyName);
1256-
}
1267+
registryBackupElement.KeyName = GetRedirectedKeyValueName(GetKeyValueNameFromKernelRegistryString(registryBackupElement.KeyName), modificationsElement.RegistryBackups.BinaryType);
12571268

12581269
// key was deleted - don't need to find its value, just enough info for the name
12591270
modificationsElement.RegistryBackups.Remove(registryBackupElement.Name);
@@ -1263,11 +1274,7 @@ private void ModificationRemoved(RegistryTraceData registryTraceData) {
12631274

12641275
if (KCBModificationKeyNames.ContainsKey(safeKeyHandle)) {
12651276
// we have info from the handle already to get the name
1266-
registryBackupElement.KeyName = GetKeyValueNameFromKernelRegistryString(KCBModificationKeyNames[safeKeyHandle] + "\\" + registryBackupElement.KeyName);
1267-
1268-
if (modificationsElement.RegistryBackups.BinaryType != BINARY_TYPE.SCS_64BIT_BINARY) {
1269-
registryBackupElement.KeyName = GetRedirectedKeyValueName(registryBackupElement.KeyName);
1270-
}
1277+
registryBackupElement.KeyName = GetRedirectedKeyValueName(GetKeyValueNameFromKernelRegistryString(KCBModificationKeyNames[safeKeyHandle] + "\\" + registryBackupElement.KeyName), modificationsElement.RegistryBackups.BinaryType);
12711278

12721279
modificationsElement.RegistryBackups.Remove(registryBackupElement.Name);
12731280
//SetModificationsElement(modificationsElement, Name);
@@ -1347,12 +1354,7 @@ private void KCBStopped(RegistryTraceData registryTraceData) {
13471354

13481355
// add its BaseKeyName
13491356
registryBackupElement = queuedModification.Value;
1350-
registryBackupElement.KeyName = GetKeyValueNameFromKernelRegistryString(registryTraceData.KeyName + "\\" + registryBackupElement.KeyName);
1351-
1352-
if (modificationsElement.RegistryBackups.BinaryType != BINARY_TYPE.SCS_64BIT_BINARY) {
1353-
registryBackupElement.KeyName = GetRedirectedKeyValueName(registryBackupElement.KeyName);
1354-
}
1355-
1357+
registryBackupElement.KeyName = GetRedirectedKeyValueName(GetKeyValueNameFromKernelRegistryString(registryTraceData.KeyName + "\\" + registryBackupElement.KeyName), modificationsElement.RegistryBackups.BinaryType);
13561358
registryBackupElement.ValueKind = GetValueKindInRegistryView(registryBackupElement.KeyName, registryBackupElement.ValueName, registryView);
13571359
value = null;
13581360

0 commit comments

Comments
 (0)