Skip to content

Commit dfd1bf3

Browse files
committed
Added patch to re-enable Dynamic Resources
1 parent 6aaeb20 commit dfd1bf3

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

patcher/HitmanPatcher.Core/AOBScanner.cs

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public static bool TryGetHitmanVersionByScanning(Process process,
6868
tasks =>
6969
tasks.Select(task => task.Result)
7070
.Where(x => x != null));
71+
72+
Task<IEnumerable<Patch[]>> getDynresEnablePatches =
73+
Task.Factory.ContinueWhenAll(new Task<Patch[]>[]
74+
{
75+
findDynresEnable(exeData),
76+
},
77+
tasks =>
78+
tasks.Select(task => task.Result)
79+
.Where(x => x != null));
7180

7281

7382
Task<IEnumerable<Patch[]>>[] alltasks =
@@ -76,7 +85,7 @@ public static bool TryGetHitmanVersionByScanning(Process process,
7685
getProtocolPatches, getDynresForceofflinePatches
7786
};
7887
// ReSharper disable once CoVariantArrayConversion
79-
Task.WaitAll(alltasks);
88+
Task.WaitAll([..alltasks, getDynresEnablePatches]);
8089

8190
bench.Stop();
8291
#if DEBUG
@@ -96,7 +105,8 @@ public static bool TryGetHitmanVersionByScanning(Process process,
96105
Note("AuthHeader2", getAuthheadPatches.Result.First()[1]);
97106
Note("ConfigDomain", getConfigdomainPatches.Result.First()[0]);
98107
Note("Protocol", getProtocolPatches.Result.First()[0]);
99-
Note("DynamicResources", getDynresForceofflinePatches.Result.First()[0]);
108+
Note("DynamicResources->ForceOffline", getDynresForceofflinePatches.Result.First()[0]);
109+
Note("DynamicResources->Enable", getDynresEnablePatches.Result.FirstOrDefault()?[0]);
100110
#endif
101111

102112
result = new HitmanVersion()
@@ -106,7 +116,9 @@ public static bool TryGetHitmanVersionByScanning(Process process,
106116
configdomain = getConfigdomainPatches.Result.First(),
107117
protocol = getProtocolPatches.Result.First(),
108118
dynres_noforceoffline =
109-
getDynresForceofflinePatches.Result.First()
119+
getDynresForceofflinePatches.Result.First(),
120+
dynres_enable =
121+
getDynresEnablePatches.Result.FirstOrDefault() ?? []
110122
};
111123

112124
return true;
@@ -117,6 +129,13 @@ public static bool TryGetHitmanVersionByScanning(Process process,
117129
#if DEBUG
118130
private static void Note(string name, Patch patch)
119131
{
132+
if (patch == null)
133+
{
134+
Compositions.Logger.log($"{name}: n/a");
135+
136+
return;
137+
}
138+
120139
Compositions.Logger.log($"{name}: {patch.offset:X} {BitConverter.ToString(patch.original).Replace("-", string.Empty)} {BitConverter.ToString(patch.patch).Replace("-", string.Empty)}");
121140
}
122141
#endif
@@ -528,6 +547,31 @@ private static Task<Patch[]> findDynresForceoffline(byte[] data)
528547

529548
#endregion
530549

550+
#region dynres_enable
551+
552+
private static Task<Patch[]> findDynresEnable(byte[] data)
553+
{
554+
return Task.Factory.ContinueWhenAll(new[]
555+
{
556+
Task.Factory.StartNew(() => findPattern(data, 0x4, "ba502e23f1488d0d")) // 3.210
557+
.ContinueWith(task =>
558+
task.Result.Select(addr => addr + 0x22 + BitConverter.ToInt32(data, addr + 0x1A)).ToArray()),
559+
}, tasks =>
560+
{
561+
IEnumerable<int> offsets =
562+
tasks.SelectMany(task => task.Result);
563+
if (offsets.Count() != 1)
564+
return null;
565+
return new[]
566+
{
567+
new Patch(offsets.First(), "01", "00",
568+
MemProtection.PAGE_EXECUTE_READWRITE)
569+
};
570+
});
571+
}
572+
573+
#endregion
574+
531575
private static int[] findPattern(byte[] data, byte alignment,
532576
string pattern)
533577
{

patcher/HitmanPatcher.Core/HitmanVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public Patch(int offset, string original, string patch, MemProtection defaultPro
3434

3535
public class HitmanVersion
3636
{
37-
public Patch[] certpin, authheader, configdomain, protocol, dynres_noforceoffline;
37+
public Patch[] certpin, authheader, configdomain, protocol, dynres_noforceoffline, dynres_enable;
3838

3939
private static Dictionary<uint, string> timestampMap = new Dictionary<uint, string>();
4040

patcher/HitmanPatcher.Core/MemoryPatcher.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ public static bool Patch(Process process, Options patchOptions)
184184
{
185185
patches.AddRange(v.protocol);
186186
}
187+
if (patchOptions.EnableDynamicResources)
188+
{
189+
patches.AddRange(v.dynres_enable);
190+
}
187191
if (patchOptions.DisableForceOfflineOnFailedDynamicResources)
188192
{
189193
patches.AddRange(v.dynres_noforceoffline);
@@ -275,6 +279,7 @@ public struct Options
275279
public bool SetCustomConfigDomain;
276280
public string CustomConfigDomain;
277281
public bool UseHttp;
282+
public bool EnableDynamicResources;
278283
public bool DisableForceOfflineOnFailedDynamicResources;
279284
}
280285

patcher/HitmanPatcher.Core/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public Settings()
2222
DisableCertPinning = true,
2323
AlwaysSendAuthHeader = true,
2424
SetCustomConfigDomain = true,
25+
EnableDynamicResources = true,
2526
DisableForceOfflineOnFailedDynamicResources = true,
2627
};
2728
darkModeEnabled = false;

patcher/HitmanPatcher/OptionsForm.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public Settings Settings
5959
{
6060
CustomConfigDomain = customDomain,
6161
UseHttp = checkBoxHttp.Checked,
62+
EnableDynamicResources = true,
6263
DisableForceOfflineOnFailedDynamicResources = dynResources.Checked,
6364
DisableCertPinning = true,
6465
SetCustomConfigDomain = true,

0 commit comments

Comments
 (0)