crazy person

This commit is contained in:
pozm 2024-02-19 18:27:05 +00:00
parent 994eedf40c
commit cf2a8f23c4
No known key found for this signature in database
GPG Key ID: 5AB655AFC8AAA822
2 changed files with 14 additions and 13 deletions

View File

@ -14,9 +14,11 @@ static_detour! {
pub static OpenAndParse: unsafe extern "fastcall" fn(*const i32, *const i32, *const u8, bool) -> (); pub static OpenAndParse: unsafe extern "fastcall" fn(*const i32, *const i32, *const u8, bool) -> ();
} }
const SIGS: [&str; 2] = [ const SIGS: [&str; 4] = [
// call into open_and_parse // call into open_and_parse
"E8 ? ? ? ? 85 C0 0F 84 ? ? ? ? 49 8B 8C 24 ? ? ? ?", // 4.x (4.2.1) "E8 ? ? ? ? 85 C0 0F 84 ? ? ? ? 49 8B 8C 24 ? ? ? ?", // 4.x (4.2.1)
"E8 ? ? ? ? 89 44 24 50 83 7C 24 ? ? 0F 84 ? ? ? ? 48 8B 44 24 ?", // 3.5.1
"E8 ? ? ? ? 89 44 24 50 83 7C 24 ? ? 0F 84 ? ? ? ? 48 8B 44 24 ?", // 3.5.1
"E8 ? ? ? ? 8B D8 85 C0 0F 84 ? ? ? ? 49 8B 04 24", // 3.x "E8 ? ? ? ? 8B D8 85 C0 0F 84 ? ? ? ? 49 8B 04 24", // 3.x
]; ];
#[repr(u8)] #[repr(u8)]
@ -28,13 +30,11 @@ fn find_sig_addr(sig_type: usize) -> Result<*const c_void, SigErrors> {
let proc = Process::this_process(); let proc = Process::this_process();
let modd = proc.get_base_module().unwrap(); let modd = proc.get_base_module().unwrap();
let sig = SIGS let sig = SIGS.get(sig_type).ok_or(SigErrors::NotFound)?;
.get(sig_type as usize)
.ok_or_else(|| SigErrors::NotFound)?;
let addr = modd let addr = modd
.scan(sig) .scan(sig)
.map_err(|_| SigErrors::NotFound)? .map_err(|_| SigErrors::NotFound)?
.ok_or_else(|| SigErrors::NotFound)? as isize; .ok_or(SigErrors::NotFound)? as isize;
println!("sig found: {:x} ", addr); println!("sig found: {:x} ", addr);
let ptr_to_fn = (addr as usize + size_of::<u8>()) as *const u8; let ptr_to_fn = (addr as usize + size_of::<u8>()) as *const u8;
let mut addr_offset = [0; 4]; let mut addr_offset = [0; 4];

View File

@ -142,13 +142,14 @@ pub unsafe fn spawn_and_inject(proc: &str) -> anyhow::Result<[u8; 32]> {
}; };
let game_ver = check_gd_ver(pth)?; let game_ver = check_gd_ver(pth)?;
println!("gamever = {game_ver}"); println!("gamever = {game_ver}");
let sig_id = match game_ver let sig_id = match &game_ver
.chars() .chars().collect::<Vec<char>>()[..]
.next() // .next()
.ok_or(anyhow::anyhow!("unable to check gd version"))? // .ok_or(anyhow::anyhow!("unable to check gd version"))?
{ {
'4' => 0u32, ['4',..] => 0u32,
'3' => 1u32, ['3','.','6',..] => 2u32,
['3',..] => 1u32,
_ => return Err(anyhow::anyhow!("invalid godot version")), _ => return Err(anyhow::anyhow!("invalid godot version")),
}; };