mirror of
https://gitea.tendokyu.moe/beerpsi/CHUNITHM-Patch-Finder.git
synced 2024-11-23 23:31:03 +01:00
Print offsets in hex
This commit is contained in:
parent
1fd50bf108
commit
8ea025ca79
@ -9,6 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Reloaded.Memory.Sigscan" Version="3.1.8" />
|
<PackageReference Include="Reloaded.Memory.Sigscan" Version="3.1.8" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
18
Converters/HexNumberJsonConverter.cs
Normal file
18
Converters/HexNumberJsonConverter.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace CHUNITHM_Patch_Finder.Converters;
|
||||||
|
|
||||||
|
public class HexNumberJsonConverter : JsonConverter<int>
|
||||||
|
{
|
||||||
|
public override bool CanRead => false;
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, int value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
writer.WriteRawValue($"0x{value:X2}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int ReadJson(JsonReader reader, Type objectType, int existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
14
Models/BemaniPatcherNumberPatch.cs
Normal file
14
Models/BemaniPatcherNumberPatch.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace CHUNITHM_Patch_Finder.Models;
|
||||||
|
|
||||||
|
public class BemaniPatcherNumberPatch : BemaniPatcherPatch
|
||||||
|
{
|
||||||
|
public override string Type => "number";
|
||||||
|
|
||||||
|
public required int Offset { get; set; }
|
||||||
|
|
||||||
|
public required int Size { get; set; }
|
||||||
|
|
||||||
|
public required int Min { get; set; }
|
||||||
|
|
||||||
|
public required int Max { get; set; }
|
||||||
|
}
|
13
Models/BemaniPatcherPatch.cs
Normal file
13
Models/BemaniPatcherPatch.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace CHUNITHM_Patch_Finder.Models;
|
||||||
|
|
||||||
|
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public abstract class BemaniPatcherPatch
|
||||||
|
{
|
||||||
|
[JsonProperty(Order = -2)]
|
||||||
|
public abstract string? Type { get; }
|
||||||
|
|
||||||
|
[JsonProperty(Order = -2)]
|
||||||
|
public required string Name { get; set; }
|
||||||
|
}
|
12
Models/BemaniPatcherStandardPatch.cs
Normal file
12
Models/BemaniPatcherStandardPatch.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace CHUNITHM_Patch_Finder.Models;
|
||||||
|
|
||||||
|
public class BemaniPatcherStandardPatch : BemaniPatcherPatch
|
||||||
|
{
|
||||||
|
public override string? Type => null;
|
||||||
|
|
||||||
|
public string? Tooltip { get; set; } = null;
|
||||||
|
|
||||||
|
public string? Danger { get; set; } = null;
|
||||||
|
|
||||||
|
public List<BemaniPatcherStandardPatchEntry> Patches { get; set; } = [];
|
||||||
|
}
|
10
Models/BemaniPatcherStandardPatchEntry.cs
Normal file
10
Models/BemaniPatcherStandardPatchEntry.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace CHUNITHM_Patch_Finder.Models;
|
||||||
|
|
||||||
|
public class BemaniPatcherStandardPatchEntry
|
||||||
|
{
|
||||||
|
public required int Offset { get; set; }
|
||||||
|
|
||||||
|
public required int[] Off { get; set; }
|
||||||
|
|
||||||
|
public required int[] On { get; set; }
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace CHUNITHM_Patch_Finder;
|
namespace CHUNITHM_Patch_Finder.Models;
|
||||||
|
|
||||||
public record Pattern
|
public record Pattern
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace CHUNITHM_Patch_Finder;
|
namespace CHUNITHM_Patch_Finder.Models;
|
||||||
|
|
||||||
public record PatternPatch
|
public record PatternPatch
|
||||||
{
|
{
|
87
Program.cs
87
Program.cs
@ -1,8 +1,9 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
using System.Text.Json;
|
using CHUNITHM_Patch_Finder.Converters;
|
||||||
using System.Text.Json.Nodes;
|
using CHUNITHM_Patch_Finder.Models;
|
||||||
using CHUNITHM_Patch_Finder;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
using Reloaded.Memory.Sigscan;
|
using Reloaded.Memory.Sigscan;
|
||||||
using Reloaded.Memory.Sigscan.Definitions.Structs;
|
using Reloaded.Memory.Sigscan.Definitions.Structs;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
@ -22,7 +23,7 @@ var patches =
|
|||||||
File.ReadAllText("patterns.yaml"));
|
File.ReadAllText("patterns.yaml"));
|
||||||
var binary = File.ReadAllBytes(args[0]);
|
var binary = File.ReadAllBytes(args[0]);
|
||||||
var scanner = new Scanner(binary);
|
var scanner = new Scanner(binary);
|
||||||
var exportedPatches = new JsonArray();
|
var exportedPatches = new List<BemaniPatcherPatch>();
|
||||||
|
|
||||||
// Other patches
|
// Other patches
|
||||||
foreach (var patch in patches)
|
foreach (var patch in patches)
|
||||||
@ -45,42 +46,25 @@ foreach (var patch in patches)
|
|||||||
Console.WriteLine($"No offset found for patch {patch.Name}");
|
Console.WriteLine($"No offset found for patch {patch.Name}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var patchObject = new JsonObject()
|
var patchObject = new BemaniPatcherStandardPatch
|
||||||
{
|
{
|
||||||
{ "name", patch.Name },
|
Name = patch.Name,
|
||||||
};
|
Tooltip = patch.Tooltip,
|
||||||
|
Danger = patch.Danger,
|
||||||
if (patch.Tooltip != null)
|
Patches = patch.Patches.Select(p =>
|
||||||
patchObject.Add("tooltip", patch.Tooltip);
|
|
||||||
else if (patch.Danger != null)
|
|
||||||
patchObject.Add("danger", patch.Danger);
|
|
||||||
|
|
||||||
var patchArray = new JsonArray();
|
|
||||||
|
|
||||||
foreach (var p in patch.Patches)
|
|
||||||
{
|
|
||||||
var signature = (p.Signature ?? patch.Signature)!;
|
|
||||||
var off = new JsonArray();
|
|
||||||
var on = new JsonArray();
|
|
||||||
|
|
||||||
foreach (var b in p.Off)
|
|
||||||
off.Add(b);
|
|
||||||
|
|
||||||
foreach (var b in p.On)
|
|
||||||
on.Add(b);
|
|
||||||
|
|
||||||
var pObject = new JsonObject()
|
|
||||||
{
|
{
|
||||||
{ "offset", matches[signature].Offset + p.Offset },
|
var signature = (p.Signature ?? patch.Signature)!;
|
||||||
{ "off", off },
|
|
||||||
{ "on", on },
|
return new BemaniPatcherStandardPatchEntry
|
||||||
};
|
{
|
||||||
|
Offset = matches[signature].Offset + p.Offset,
|
||||||
patchArray.Add(pObject);
|
Off = p.Off,
|
||||||
}
|
On = p.On,
|
||||||
|
};
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
patchObject.Add("patches", patchArray);
|
|
||||||
exportedPatches.Add(patchObject);
|
exportedPatches.Add(patchObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,15 +84,14 @@ if (Path.GetFileName(args[0]) == "chusanApp.exe")
|
|||||||
var trackCountAddress = offset.Offset + 5 + trackCountRelativeAddress;
|
var trackCountAddress = offset.Offset + 5 + trackCountRelativeAddress;
|
||||||
|
|
||||||
Console.WriteLine($"Found track count function at {trackCountAddress:X}");
|
Console.WriteLine($"Found track count function at {trackCountAddress:X}");
|
||||||
|
|
||||||
var patch = new JsonObject
|
var patch = new BemaniPatcherNumberPatch
|
||||||
{
|
{
|
||||||
{ "type", "number" },
|
Name = "Maximum tracks",
|
||||||
{ "name", "Maximum tracks" },
|
Offset = trackCountAddress + 1,
|
||||||
{ "offset", trackCountAddress + 1 },
|
Size = 4,
|
||||||
{ "size", 4 },
|
Min = 3,
|
||||||
{ "min", 3 },
|
Max = 12,
|
||||||
{ "max", 12 }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exportedPatches.Add(patch);
|
exportedPatches.Add(patch);
|
||||||
@ -119,12 +102,18 @@ if (Path.GetFileName(args[0]) == "chusanApp.exe")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
ContractResolver = new DefaultContractResolver
|
||||||
|
{
|
||||||
|
NamingStrategy = new CamelCaseNamingStrategy(),
|
||||||
|
},
|
||||||
|
Converters = [new HexNumberJsonConverter()],
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
};
|
||||||
|
|
||||||
File.WriteAllText(
|
File.WriteAllText(
|
||||||
"patches.json",
|
"patches.json",
|
||||||
JsonSerializer.Serialize(exportedPatches, new JsonSerializerOptions(JsonSerializerOptions.Default)
|
JsonConvert.SerializeObject(exportedPatches, settings));
|
||||||
{
|
|
||||||
WriteIndented = true
|
|
||||||
}));
|
|
||||||
|
|
||||||
Console.WriteLine("Wrote patches to patches.json");
|
Console.WriteLine("Wrote patches to patches.json");
|
@ -17,6 +17,7 @@
|
|||||||
off: [0x01]
|
off: [0x01]
|
||||||
on: [0x00]
|
on: [0x00]
|
||||||
- name: "Force 2 channel audio output"
|
- name: "Force 2 channel audio output"
|
||||||
|
tooltip: "May cause bass overload"
|
||||||
signature: "56 E8 ?? ?? ?? ?? 83 C4 04 85 C0 ?? ?? 68 ?? ?? ?? ?? E8 ?? ?? ?? ??"
|
signature: "56 E8 ?? ?? ?? ?? 83 C4 04 85 C0 ?? ?? 68 ?? ?? ?? ?? E8 ?? ?? ?? ??"
|
||||||
patches:
|
patches:
|
||||||
- offset: 0x0B
|
- offset: 0x0B
|
||||||
@ -67,17 +68,16 @@
|
|||||||
- offset: 0x0D
|
- offset: 0x0D
|
||||||
off: [0x01]
|
off: [0x01]
|
||||||
on: [0x00]
|
on: [0x00]
|
||||||
- name: "Disable 1080p check"
|
- name: "Bypass 1080p/120Hz monitor check"
|
||||||
signature: "81 BC 24 B8 02 00 00 80 07 00 00 75 1F 81 BC 24 BC 02 00 00 38 04 00 00 75 12"
|
patches:
|
||||||
patches:
|
# 1080p check
|
||||||
- offset: 0x00
|
- signature: "81 BC 24 B8 02 00 00 80 07 00 00 75 1F 81 BC 24 BC 02 00 00 38 04 00 00 75 12"
|
||||||
|
offset: 0x00
|
||||||
off: [0x81, 0xBC, 0x24, 0xB8, 0x02, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x75, 0x1F, 0x81, 0xBC, 0x24, 0xBC, 0x02, 0x00, 0x00, 0x38, 0x04, 0x00, 0x00, 0x75, 0x12]
|
off: [0x81, 0xBC, 0x24, 0xB8, 0x02, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x75, 0x1F, 0x81, 0xBC, 0x24, 0xBC, 0x02, 0x00, 0x00, 0x38, 0x04, 0x00, 0x00, 0x75, 0x12]
|
||||||
on: [0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90]
|
on: [0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90]
|
||||||
- name: "Force 120Hz check"
|
# 120Hz check
|
||||||
tooltip: "Check to make the 120Hz check always pass (do not use with CVT mode)"
|
- signature: "50 56 6A 00 FF D7 ?? ?? 74 3F"
|
||||||
signature: "50 56 6A 00 FF D7 ?? ?? 74 3F"
|
offset: 0x06
|
||||||
patches:
|
|
||||||
- offset: 0x06
|
|
||||||
off: [0x85, 0xC0]
|
off: [0x85, 0xC0]
|
||||||
on: [0xEB, 0x30]
|
on: [0xEB, 0x30]
|
||||||
- name: "Bypass LED board check"
|
- name: "Bypass LED board check"
|
||||||
|
Loading…
Reference in New Issue
Block a user