Organize patterns and shit

This commit is contained in:
beerpsi 2024-04-12 04:40:48 +07:00
parent 65ad4bb7b5
commit 8438ed9bf6
5 changed files with 27 additions and 13 deletions

View File

@ -15,9 +15,9 @@
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="patterns.yaml">
<ContentWithTargetPath Include="Patterns/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>%(Filename)%(Extension)</TargetPath>
<TargetPath>Patterns/%(RecursiveDir)/%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>

View File

@ -11,17 +11,29 @@ using YamlDotNet.Serialization.NamingConventions;
if (args.Length < 1)
{
Console.WriteLine($"Usage: {Environment.ProcessPath} <PATH TO EXE>");
Console.WriteLine($"Usage: {Environment.ProcessPath} <PATH TO EXE> [PATH TO PATTERNS]");
Environment.Exit(22); // EINVAL
}
var deserializer = new DeserializerBuilder()
.WithNamingConvention(LowerCaseNamingConvention.Instance)
.Build();
var exeFile = args[0];
var exeFileName = Path.GetFileName(exeFile);
var patternsFile = args.Length >= 2
? args[1]
: Path.Join("Patterns", Path.GetFileNameWithoutExtension(exeFile) + ".yaml");
if (!Path.Exists(patternsFile))
{
Console.WriteLine($"[ERROR] Could not find patterns file {patternsFile}. Nothing to search for.");
Environment.Exit(1);
}
var patches =
deserializer.Deserialize<Pattern[]>(
File.ReadAllText("patterns.yaml"));
var binary = File.ReadAllBytes(args[0]);
File.ReadAllText(patternsFile));
var binary = File.ReadAllBytes(exeFile);
var scanner = new Scanner(binary);
var exportedPatches = new List<BemaniPatcherPatch>();
@ -70,7 +82,7 @@ foreach (var patch in patches)
}
// max track count patch
if (Path.GetFileName(args[0]) == "chusanApp.exe")
if (exeFileName == "chusanApp.exe")
{
var offset = scanner
.FindPatterns([

View File

@ -8,11 +8,13 @@ Does not do any patch validation for now.
## Usage
```sh
./CHUNITHM-Patch-Finder <PATH TO EXE>
./CHUNITHM-Patch-Finder <PATH TO EXE> [PATH TO PATTERNS]
```
The program expects a file called `patterns.yaml` (see files in
repo for example) and outputs BemaniPatcher-compatible patches
to `patches.json`.
If a patterns file is not specified, the program defaults to
finding a file named `[file].yaml` under its `Patterns`
directory.
The output is in a format compatible with [BemaniPatcher](https://github.com/mon/BemaniPatcher).
[How to find signatures](https://reloaded-project.github.io/Reloaded-II/CheatSheet/SignatureScanning/)