Skip to content

Commit

Permalink
Fixed the savegame.unencrypted path once again
Browse files Browse the repository at this point in the history
  • Loading branch information
John committed Mar 31, 2020
1 parent 72d9e73 commit 3c6fef0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
41 changes: 40 additions & 1 deletion DoomEternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,44 @@ public static void EnumerateSaves() {
}
}
}
}

public static byte[] FarmHash_Hash32(byte[] data) {
uint size = (uint)data.Length;
if (size > 0x18) {
uint v3 = 5 * (Utilities.rotl(0x1B873593 * Utilities.rotl(0xCC9E2D51 * BitConverter.ToUInt32(data, (int)(size - 0x10)), 0xF) ^ 5 * (Utilities.rotl(size ^ 0x1B873593 * Utilities.rotl(0xCC9E2D51 * BitConverter.ToUInt32(data, (int)(size - 4)), 0xF), 0xD) - 0x52250EC), 0xD) - 0x52250EC);
uint v4 = 5 * (Utilities.rotl(0x1B873593 * Utilities.rotl(0xCC9E2D51 * BitConverter.ToUInt32(data, (int)(size - 0xC)), 0xF) ^ 5 * (Utilities.rotl(0xCC9E2D51 * size ^ 0x1B873593 * Utilities.rotl(0xCC9E2D51 * BitConverter.ToUInt32(data, (int)(size - 8)), 0xF), 0xD) - 0x52250EC), 0xD) - 0x52250EC);

uint v5 = (size - 1) / 20;

uint v6 = Utilities.rotl(0xCC9E2D51 * size + 0x1B873593 * Utilities.rotl(0xCC9E2D51 * BitConverter.ToUInt32(data, (int)(size - 0x14)), 0xF), 0xD) + 0x71;

int offset = 8;
for (uint i = v5; i > 0; i--) {
uint v8 = BitConverter.ToUInt32(data, offset + 4);
uint v9 = BitConverter.ToUInt32(data, offset - 8);
uint v10 = BitConverter.ToUInt32(data, offset);
uint v11 = BitConverter.ToUInt32(data, offset + 8);
uint v12 = BitConverter.ToUInt32(data, offset - 4);
offset += 20;
uint v13 = Utilities.rotl((v9 + v3) ^ 0x1B873593 * Utilities.rotl(0xCC9E2D51 * v8, 0xF), 0xD);
v3 = v13 - 0x19AB949C + v11 + 4 * v13;
uint v14 = Utilities.rotl((v12 + v4) ^ 0x1B873593 * Utilities.rotl(0xCC9E2D51 * v10, 0xF), 0xD);
uint v15 = v14 - 0x19AB949C + v9 + 4 * v14;
uint v16 = Utilities.rotl((v10 + v6) ^ 0x1B873593 * Utilities.rotl(0x100193A1 * v11 - 0x3361D2AF * v12, 0xF), 0xD);
v6 = v15 + v16 + v8 + 4 * (v16 - 0x66AE527);
v4 = v6 + v15;
}

uint cksm = 0xCC9E2D51 * Utilities.rotl(5 * Utilities.rotl(0xCC9E2D51 * (Utilities.rotl(0xCC9E2D51 * Utilities.rotr(v6, 0xB), 0xF) + Utilities.rotl(5 * (Utilities.rotl(v3 - 0x3361D2AF * Utilities.rotl(0xCC9E2D51 * Utilities.rotr(v4, 0xB), 0xF), 0xD) - 0x52250EC), 0xF)), 0xD) - 0x19AB949C, 0xF);
byte[] cksmBytes = BitConverter.GetBytes(cksm);
Array.Reverse(cksmBytes);
return cksmBytes;
} else if (size > 0xC)
return null;
else if (size > 4)
return null;
else
return null;
}
}
}
2 changes: 1 addition & 1 deletion DoomEternalSavePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DoomEternalSavePath(string id, DoomEternalSavePlatform platform, bool enc

if (Identifier == "savegame.unencrypted") {
Encrypted = false;
FullPath = Path.Combine(BnetSavePath, "savegame.unencrypted", Environment.UserName);
FullPath = Path.Combine(BnetSavePath + ".unencrypted", Environment.UserName);
} else if (platform == DoomEternalSavePlatform.BethesdaNet)
FullPath = Path.Combine(BnetSavePath, Identifier);
else if (platform == DoomEternalSavePlatform.Steam)
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.1")]
[assembly: AssemblyFileVersion("1.3.0.1")]
[assembly: AssemblyVersion("1.3.0.2")]
[assembly: AssemblyFileVersion("1.3.0.2")]
4 changes: 4 additions & 0 deletions Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace DOOMSaveManager
{
public static class Utilities
{
public static uint rotl(uint n, int d) => (n << d) | (n >> (32 - d));

public static uint rotr(uint n, int d) => (n >> d) | (n << (32 - d));

public static string GetSteamPath() {
using (var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Valve\Steam")) {
return (string)reg.GetValue("InstallPath", null);
Expand Down

0 comments on commit 3c6fef0

Please sign in to comment.