-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathProgram.cs
More file actions
26 lines (18 loc) · 961 Bytes
/
Program.cs
File metadata and controls
26 lines (18 loc) · 961 Bytes
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
using System.Diagnostics;
using System.Runtime.InteropServices;
using Hat;
using Hat.Extensions;
Console.WriteLine("libhat tests\n");
Console.WriteLine("scanning in memory buffer:");
var randomBytes = new byte[0x10000];
new Random().NextBytes(randomBytes);
var pattern = randomBytes.AsSpan().Slice(0x1000, 0x10).ToArray().AsPattern();
var scanner = new Scanner(Marshal.UnsafeAddrOfPinnedArrayElement(randomBytes, 0), (uint)randomBytes.Length);
var result = scanner.FindPattern(pattern);
if (result != null) Console.WriteLine($"found pattern at 0x{result.Address:X}");
Console.WriteLine("\nscanning in module:");
var modulePattern = new Pattern("48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 81 EC");
var module = Process.GetCurrentProcess().MainModule!;
var moduleScanner = new Scanner(module);
var moduleResult = moduleScanner.FindPattern(modulePattern);
if (moduleResult != null) Console.WriteLine($"found pattern at 0x{moduleResult.Address:X}");