1
mirror of https://github.com/thepeacockproject/Peacock synced 2024-11-29 09:15:11 +01:00
Peacock/patcher/HitmanVersion.cs
Reece Dunham 6245e91624 Initial commit
Co-authored-by: Tino Roivanen <tino.roivanen98@gmail.com>
Co-authored-by: Govert de Gans <grappigegovert@hotmail.com>
Co-authored-by: Gray Olson <gray@grayolson.com>
Co-authored-by: Alexandre Sanchez <alex73630@gmail.com>
Co-authored-by: Anthony Fuller <24512050+anthonyfuller@users.noreply.github.com>
Co-authored-by: atampy25 <24306974+atampy25@users.noreply.github.com>
Co-authored-by: David <davidstulemeijer@gmail.com>
Co-authored-by: c0derMo <c0dermo@users.noreply.github.com>
Co-authored-by: Jeevat Singh <jeevatt.singh@gmail.com>
Signed-off-by: Reece Dunham <me@rdil.rocks>
2022-10-19 21:33:45 -04:00

94 lines
3.0 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text;
using HitmanPatcher.PatchDefinitions;
namespace HitmanPatcher
{
public class Patch
{
public static readonly byte[] http = Encoding.ASCII.GetBytes("http://{0}\0").ToArray();
public static readonly byte[] https = Encoding.ASCII.GetBytes("https://{0}\0").ToArray();
public readonly int offset;
public readonly byte[] original, patch;
public readonly string customPatch;
public readonly MemProtection defaultProtection;
public Patch(int offset, byte[] original, byte[] patch, MemProtection defaultProtection, string customPatch = "")
{
this.offset = offset;
this.original = original;
this.patch = patch;
this.defaultProtection = defaultProtection;
this.customPatch = customPatch;
}
public Patch(int offset, string original, string patch, MemProtection defaultProtection, string customPatch = "")
: this(offset, SoapHexBinary.Parse(original).Value, SoapHexBinary.Parse(patch).Value, defaultProtection, customPatch)
{
}
}
public class HitmanVersion
{
public Patch[] certpin, authheader, configdomain, protocol, dynres_noforceoffline;
private static Dictionary<uint, string> timestampMap = new Dictionary<uint, string>();
private static Dictionary<string, HitmanVersion> versionMap = new Dictionary<string, HitmanVersion>();
public static readonly HitmanVersion NotFound = new HitmanVersion();
public static void AddVersion(string name, uint timestamp, HitmanVersion patchVersions)
{
timestampMap.Add(timestamp, name);
versionMap.Add(name, patchVersions);
}
private static string VersionStringFromTimestamp(uint timestamp)
{
if (!timestampMap.TryGetValue(timestamp, out string result))
{
result = "unknown";
}
return result;
}
public static HitmanVersion GetVersion(uint timestamp)
{
string versionString = VersionStringFromTimestamp(timestamp);
if (versionMap.TryGetValue(versionString, out HitmanVersion version))
{
return version;
}
return NotFound;
}
static HitmanVersion()
{
v1_12.AddVersions();
v1_15.AddVersions();
v1_16.AddVersions();
v2_13.AddVersions();
v2_71.AddVersions();
v2_72.AddVersions();
v3_10.AddVersions();
v3_11.AddVersions();
v3_20.AddVersions();
v3_30.AddVersions();
v3_40.AddVersions();
v3_50.AddVersions();
v3_70.AddVersions();
v3_100.AddVersions();
v3_110.AddVersions();
v3_120.AddVersions();
vScpc.AddVersions();
}
}
}