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>
<ItemGroup> <ItemGroup>
<ContentWithTargetPath Include="patterns.yaml"> <ContentWithTargetPath Include="Patterns/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>%(Filename)%(Extension)</TargetPath> <TargetPath>Patterns/%(RecursiveDir)/%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath> </ContentWithTargetPath>
</ItemGroup> </ItemGroup>

View File

@ -11,17 +11,29 @@ using YamlDotNet.Serialization.NamingConventions;
if (args.Length < 1) 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 Environment.Exit(22); // EINVAL
} }
var deserializer = new DeserializerBuilder() var deserializer = new DeserializerBuilder()
.WithNamingConvention(LowerCaseNamingConvention.Instance) .WithNamingConvention(LowerCaseNamingConvention.Instance)
.Build(); .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 = var patches =
deserializer.Deserialize<Pattern[]>( deserializer.Deserialize<Pattern[]>(
File.ReadAllText("patterns.yaml")); File.ReadAllText(patternsFile));
var binary = File.ReadAllBytes(args[0]); var binary = File.ReadAllBytes(exeFile);
var scanner = new Scanner(binary); var scanner = new Scanner(binary);
var exportedPatches = new List<BemaniPatcherPatch>(); var exportedPatches = new List<BemaniPatcherPatch>();
@ -70,7 +82,7 @@ foreach (var patch in patches)
} }
// max track count patch // max track count patch
if (Path.GetFileName(args[0]) == "chusanApp.exe") if (exeFileName == "chusanApp.exe")
{ {
var offset = scanner var offset = scanner
.FindPatterns([ .FindPatterns([

View File

@ -8,11 +8,13 @@ Does not do any patch validation for now.
## Usage ## Usage
```sh ```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 If a patterns file is not specified, the program defaults to
repo for example) and outputs BemaniPatcher-compatible patches finding a file named `[file].yaml` under its `Patterns`
to `patches.json`. 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/) [How to find signatures](https://reloaded-project.github.io/Reloaded-II/CheatSheet/SignatureScanning/)