Skip to content

Commit c75e994

Browse files
committed
Signature scanning
1 parent 547205a commit c75e994

File tree

4 files changed

+47
-34
lines changed

4 files changed

+47
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
/src/libDEBUG.rs

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ edition = "2024"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
asr = { git = "https://github.com/LiveSplit/asr", features = ["derive"] }
10-
11-
# Bytemuck can be used to define structs that are being read from the game's process.
12-
#bytemuck = { version = "1", features = ["derive", "min_const_generics"] }
9+
asr = { git = "https://github.com/LiveSplit/asr", features = ["derive", "signature"] }
10+
#dlmalloc = { version = "0.2.8", features = ["global"] }
11+
#itoa = { version = "1", default-features = false }
1312

1413
[lib]
1514
crate-type = ["cdylib"]

src/lib.rs

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
)]
1212

1313
use asr::{
14-
Address, Process,
14+
Address32, Process,
1515
file_format::pe,
1616
future::{next_tick, retry},
1717
settings::{Gui, Map},
1818
string::ArrayCString,
1919
timer::{self, TimerState},
20-
watcher::Watcher
20+
watcher::Watcher,
21+
signature::Signature
2122
};
2223

2324
asr::async_main!(stable);
@@ -45,40 +46,45 @@ struct Watchers {
4546
}
4647

4748
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
5556
}
5657

58+
//asr::print_message(&format!("{:#x}", syncPtr));
5759
impl Memory {
5860
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+
5969
let baseModule = retry(|| process.get_module_address("SniperElite.exe")).await;
6070
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()
8288
}
8389
}
8490
}

0 commit comments

Comments
 (0)