Skip to content

Commit d4d0fa5

Browse files
committed
fix problem backing up
1 parent f558381 commit d4d0fa5

File tree

7 files changed

+1576
-1536
lines changed

7 files changed

+1576
-1536
lines changed

FlashpointSecurePlayer/FlashpointSecurePlayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private async Task ActivateModificationsAsync(string commandLine, ErrorDelegate
116116
ProgressManager.CurrentGoal.Start(7);
117117

118118
try {
119-
await DownloadEXEConfiguration(ModificationsName).ConfigureAwait(true);
119+
await DownloadFlashpointSecurePlayerSection(ModificationsName).ConfigureAwait(true);
120120
ModificationsElement modificationsElement = null;
121121

122122
try {

FlashpointSecurePlayer/FlashpointSecurePlayer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<Compile Include="Modifications.cs" />
9292
<Compile Include="ProgressManager.cs" />
9393
<Compile Include="RunAsAdministrator.cs" />
94+
<Compile Include="Shared.cs" />
9495
<Compile Include="SingleInstance.cs" />
9596
<Compile Include="ProcessSync.cs" />
9697
<Compile Include="RegistryBackups.cs" />

FlashpointSecurePlayer/Program.cs

Lines changed: 1 addition & 1524 deletions
Large diffs are not rendered by default.

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.9.0")]
37-
[assembly: AssemblyFileVersion("1.0.9.0")]
36+
[assembly: AssemblyVersion("1.1.0.0")]
37+
[assembly: AssemblyFileVersion("1.1.0.0")]
3838
[assembly: NeutralResourcesLanguage("en")]
3939

FlashpointSecurePlayer/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Flashpoint Secure Player 1.0.9
1+
# Flashpoint Secure Player 1.1.0
22
This player 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)
@@ -241,7 +241,7 @@ Here is a `modifications` element which temporarily changes the Unity directory.
241241
</modification>
242242
```
243243

244-
The `type` attribute of the `registryBackup` element specifies whether the element represents a `KEY` or `VALUE`. If not specified, the default is `KEY`. The `keyName` and `valueName` attributes specify the location of the registry key and value. The `valueKind` attribute specifies the kind of value that will be set. Currently, only `String` (REG_SZ) is supported. If the `type` attribute is `KEY`, the `valueName`, `value`, and `valueKind` attributes are ignored.
244+
The `type` attribute of the `registryBackup` element specifies whether the element represents a `KEY` or `VALUE`. If not specified, the default is `KEY`. The `keyName` and `valueName` attributes specify the location of the registry key and value. The `valueKind` attribute specifies the kind of value that will be set. If the `type` attribute is `KEY`, the `valueName`, `value`, and `valueKind` attributes are ignored.
245245

246246
There is no way to delete a registry key or value, only set them. The player may set a `_deleted` attribute, which is for internal use by the player only, and is ignored outside of the active configuration file (see the section about [Crash Recovery](#crash-recovery) below.)
247247

@@ -335,9 +335,7 @@ You may notice that because the Flashpoint Secure Player is effectively capable
335335
- ActiveX/unregisterAll.bat
336336

337337
# Planned Features
338-
- Currently, only the registry value kind of String (REG_SZ) is supported. Other value kinds such as Binary (REG_BINARY) and MultiStrings (REG_MULTI_SZ) will be supported in a future version.
339338
- Currently, there is no way to edit configuration files other than manually, and a generic "configuration file failed to load" error occurs when there is a syntax error. It would be nice to have a seperate visual editor for configuration files.
340-
- Generally speaking, more specific error reporting would be nice.
341339
- Old CPU Simulator integration?
342340

343341
# Questions And Answers

FlashpointSecurePlayer/RegistryBackups.cs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,11 @@ private object GetValueInRegistryView(string keyName, string valueName, Registry
446446
return null;
447447
}
448448

449+
object value = null;
450+
449451
try {
450452
try {
451-
return registryKey.GetValue(valueName, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
453+
value = registryKey.GetValue(valueName, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
452454
} catch (ArgumentNullException) {
453455
// value name is null
454456
return null;
@@ -465,6 +467,19 @@ private object GetValueInRegistryView(string keyName, string valueName, Registry
465467
// we don't have read rights to the key
466468
throw new SecurityException("The user cannot read from the value " + valueName + ".");
467469
}
470+
471+
RegistryValueKind? valueKind = GetValueKindInRegistryView(keyName, valueName, registryView);
472+
473+
switch (valueKind) {
474+
case RegistryValueKind.Binary:
475+
value = Convert.ToBase64String(value as byte[]);
476+
break;
477+
case RegistryValueKind.MultiString:
478+
value = String.Join("\0", value as string[]);
479+
break;
480+
}
481+
482+
return value;
468483
} finally {
469484
if (registryKey != null) {
470485
registryKey.Close();
@@ -476,19 +491,33 @@ private void SetValueInRegistryView(string keyName, string valueName, object val
476491
RegistryKey registryKey = CreateKeyInRegistryView(keyName, RegistryKeyPermissionCheck.ReadWriteSubTree, registryView);
477492

478493
try {
494+
switch (valueKind) {
495+
case RegistryValueKind.Binary:
496+
value = Convert.FromBase64String(value as string);
497+
break;
498+
case RegistryValueKind.MultiString:
499+
try {
500+
value = (value as string).Split('\0');
501+
} catch (NullReferenceException) {
502+
// value is not a string
503+
throw new ArgumentException("The value " + valueName + " is not a string.");
504+
}
505+
break;
506+
}
507+
479508
try {
480509
registryKey.SetValue(valueName, value, valueKind);
481510
} catch (NullReferenceException) {
482511
// registry key is null
483-
throw new ArgumentException("The key " + keyName + " is null.");
512+
throw new ArgumentException("The value " + valueName + " is null.");
484513
} catch (ObjectDisposedException) {
485514
// key is closed (could not be opened)
486-
throw new ArgumentException("The key " + keyName + " is closed.");
515+
throw new ArgumentException("The value " + valueName + " is closed.");
487516
} catch (IOException) {
488517
// key represents a root node
489-
throw new ArgumentException("The key " + keyName + " represents a root node.");
518+
throw new ArgumentException("The value " + valueName + " represents a root node.");
490519
} catch (UnauthorizedAccessException) {
491-
throw new SecurityException("The key " + keyName + " cannot be accessed by the user.");
520+
throw new SecurityException("The value " + valueName + " cannot be accessed by the user.");
492521
}
493522
} finally {
494523
if (registryKey != null) {
@@ -925,6 +954,10 @@ public async Task StopImportAsync() {
925954
case TYPE.VALUE:
926955
try {
927956
SetValueInRegistryView(keyName, registryBackupElement.ValueName, RemoveVariablesFromLengthenedValue(registryBackupElement.Value), registryBackupElement.ValueKind.GetValueOrDefault(), registryView);
957+
} catch (FormatException) {
958+
// value marked for deletion
959+
Deactivate();
960+
throw new RegistryBackupFailedException("The value " + registryBackupElement.ValueName + " must be Base64.");
928961
} catch (InvalidOperationException) {
929962
// value marked for deletion
930963
Deactivate();

0 commit comments

Comments
 (0)