forked from tylearymf/UniHacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
58 lines (50 loc) · 1.94 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Diagnostics;
using System.IO;
using Avalonia;
using Avalonia.ReactiveUI;
namespace UniHacker
{
internal class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
//Test();
Language.Init();
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
static void Test()
{
#if DEBUG
var versionName = PlatformUtils.TryGetVersionOfUnity("D:/Unity");
var stopwatch = new Stopwatch();
stopwatch.Start();
Debug.WriteLine($"Start Search Pattern.");
var filePath = "D:/Unity";
var version = "2022.1.21";
var architecture = MachineArchitecture.GetArchitectureType(filePath);
var patchInfo = UnityPatchInfos.FindPatchInfo(version, architecture);
var fileBytes = File.ReadAllBytes(filePath);
var darkIndexes = BoyerMooreSearcher.FindPattern(patchInfo.DarkPattern, fileBytes);
var lightIndexes = BoyerMooreSearcher.FindPattern(patchInfo.LightPattern, fileBytes);
stopwatch.Stop();
Debug.WriteLine($"Search Pattern Finish. {stopwatch.ElapsedMilliseconds}");
if (darkIndexes.Count == patchInfo.DarkPattern.Count)
Console.Beep();
if (lightIndexes.Count == patchInfo.LightPattern.Count)
Console.Beep();
throw new Exception();
#endif
}
}
}