From cf2a8f23c4c771efe00440429b6180fd5b44db8d Mon Sep 17 00:00:00 2001 From: pozm <44528100+pozm@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:27:05 +0000 Subject: [PATCH] crazy person --- gdkeinj/src/lib.rs | 14 +++++++------- src/lib.rs | 13 +++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gdkeinj/src/lib.rs b/gdkeinj/src/lib.rs index e1534da..72b4042 100644 --- a/gdkeinj/src/lib.rs +++ b/gdkeinj/src/lib.rs @@ -14,10 +14,12 @@ static_detour! { 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 - "E8 ? ? ? ? 85 C0 0F 84 ? ? ? ? 49 8B 8C 24 ? ? ? ?", // 4.x (4.2.1) - "E8 ? ? ? ? 8B D8 85 C0 0F 84 ? ? ? ? 49 8B 04 24", // 3.x + "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 ]; #[repr(u8)] #[derive(Debug)] @@ -28,13 +30,11 @@ fn find_sig_addr(sig_type: usize) -> Result<*const c_void, SigErrors> { let proc = Process::this_process(); let modd = proc.get_base_module().unwrap(); - let sig = SIGS - .get(sig_type as usize) - .ok_or_else(|| SigErrors::NotFound)?; + let sig = SIGS.get(sig_type).ok_or(SigErrors::NotFound)?; let addr = modd .scan(sig) .map_err(|_| SigErrors::NotFound)? - .ok_or_else(|| SigErrors::NotFound)? as isize; + .ok_or(SigErrors::NotFound)? as isize; println!("sig found: {:x} ", addr); let ptr_to_fn = (addr as usize + size_of::()) as *const u8; let mut addr_offset = [0; 4]; diff --git a/src/lib.rs b/src/lib.rs index 93a0659..8ad90ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,13 +142,14 @@ pub unsafe fn spawn_and_inject(proc: &str) -> anyhow::Result<[u8; 32]> { }; let game_ver = check_gd_ver(pth)?; println!("gamever = {game_ver}"); - let sig_id = match game_ver - .chars() - .next() - .ok_or(anyhow::anyhow!("unable to check gd version"))? + let sig_id = match &game_ver + .chars().collect::>()[..] + // .next() + // .ok_or(anyhow::anyhow!("unable to check gd version"))? { - '4' => 0u32, - '3' => 1u32, + ['4',..] => 0u32, + ['3','.','6',..] => 2u32, + ['3',..] => 1u32, _ => return Err(anyhow::anyhow!("invalid godot version")), };