|
11 | 11 | )] |
12 | 12 |
|
13 | 13 | use asr::{ |
14 | | - Address, Process, |
| 14 | + Address32, Process, |
15 | 15 | file_format::pe, |
16 | 16 | future::{next_tick, retry}, |
17 | 17 | settings::{Gui, Map}, |
18 | 18 | string::ArrayCString, |
19 | 19 | timer::{self, TimerState}, |
20 | | - watcher::Watcher |
| 20 | + watcher::Watcher, |
| 21 | + signature::Signature |
21 | 22 | }; |
22 | 23 |
|
23 | 24 | asr::async_main!(stable); |
@@ -45,40 +46,45 @@ struct Watchers { |
45 | 46 | } |
46 | 47 |
|
47 | 48 | struct Memory { |
48 | | - start: Address, |
49 | | - load: Address, |
50 | | - level: Address, |
51 | | - warRecord: Address, |
52 | | - briefing: Address, |
53 | | - mc: Address, |
54 | | - fps: Address |
| 49 | + start: Address32, |
| 50 | + load: Address32, |
| 51 | + level: Address32, |
| 52 | + warRecord: Address32, |
| 53 | + briefing: Address32, |
| 54 | + mc: Address32, |
| 55 | + fps: Address32 |
55 | 56 | } |
56 | 57 |
|
| 58 | +//asr::print_message(&format!("{:#x}", syncPtr)); |
57 | 59 | impl Memory { |
58 | 60 | async fn init(process: &Process) -> Self { |
| 61 | + const startSIG: Signature<86> = Signature::new("a3 ?? ?? ?? ?? c7 05 ?? ?? ?? ?? ?? ?? ?? ?? c7 05 ?? ?? ?? ?? ?? ?? ?? ?? c6 05 ?? ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? c3 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 8b 54 24"); |
| 62 | + const loadSIG: Signature<11> = Signature::new("a0 ?? ?? ?? ?? 84 c0 74 ?? 56 be"); |
| 63 | + const levelSIG: Signature<8> = Signature::new("8a 88 ?? ?? ?? ?? 88 88"); |
| 64 | + const warRecordSIG: Signature<8> = Signature::new("88 15 ?? ?? ?? ?? 8a 10"); |
| 65 | + const briefingSIG: Signature<19> = Signature::new("c6 05 ?? ?? ?? ?? ?? 89 1d ?? ?? ?? ?? e8 ?? ?? ?? ?? 68"); |
| 66 | + const mcSIG: Signature<51> = Signature::new("a2 ?? ?? ?? ?? a2 ?? ?? ?? ?? a2 ?? ?? ?? ?? a2 ?? ?? ?? ?? a2 ?? ?? ?? ?? a2 ?? ?? ?? ?? a2 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? a3 ?? ?? ?? ?? c3"); |
| 67 | + const framerateSIG: Signature<18> = Signature::new("c7 05 ?? ?? ?? ?? ?? ?? ?? ?? d9 05 ?? ?? ?? ?? d8 35"); |
| 68 | + |
59 | 69 | let baseModule = retry(|| process.get_module_address("SniperElite.exe")).await; |
60 | 70 | let baseModuleSize = retry(|| pe::read_size_of_image(process, baseModule)).await; |
61 | | - //asr::print_message(&format!("{}", baseModuleSize)); |
62 | | - |
63 | | - match baseModuleSize { |
64 | | - 3805184 => Self { |
65 | | - start: baseModule + 0x2DB89C, |
66 | | - load: baseModule + 0x320D25, |
67 | | - level: baseModule + 0x380CE5, |
68 | | - warRecord: baseModule + 0x394D28, |
69 | | - briefing: baseModule + 0x333F91, |
70 | | - mc: baseModule + 0x32B040, |
71 | | - fps: baseModule + 0x2E60D0 |
72 | | - }, |
73 | | - _ => Self { |
74 | | - start: baseModule + 0x35DAD4, |
75 | | - load: baseModule + 0x3A35A9, |
76 | | - level: baseModule + 0x418EED, |
77 | | - warRecord: baseModule + 0x418AA8, |
78 | | - briefing: baseModule + 0x3B7299, |
79 | | - mc: baseModule + 0x3AE2E0, |
80 | | - fps: baseModule + 0x368390 |
81 | | - } |
| 71 | + |
| 72 | + let startScan = startSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 1; |
| 73 | + let loadScan = loadSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 1; |
| 74 | + let levelScan = levelSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 2; |
| 75 | + let warRecordScan = warRecordSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 2; |
| 76 | + let briefingScan = briefingSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 2; |
| 77 | + let mcScan = mcSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 1; |
| 78 | + let framerateScan = framerateSIG.scan_process_range(process, (baseModule, baseModuleSize.into())).unwrap() + 2; |
| 79 | + |
| 80 | + Self { |
| 81 | + start: process.read::<u32>(startScan).unwrap().into(), |
| 82 | + load: process.read::<u32>(loadScan).unwrap().into(), |
| 83 | + level: (process.read::<u32>(levelScan).unwrap() + 0xD).into(), |
| 84 | + warRecord: process.read::<u32>(warRecordScan).unwrap().into(), |
| 85 | + briefing: process.read::<u32>(briefingScan).unwrap().into(), |
| 86 | + mc: process.read::<u32>(mcScan).unwrap().into(), |
| 87 | + fps: process.read::<u32>(framerateScan).unwrap().into() |
82 | 88 | } |
83 | 89 | } |
84 | 90 | } |
|
0 commit comments