Skip to content

Commit

Permalink
Fix lobby name hook not working on UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
trumank committed Aug 14, 2023
1 parent 2f91a34 commit 6015093
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions hook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,32 @@ unsafe fn patch() {
);

let pattern = [0x4C, 0x8B, 0xB4, 0x24, 0x48, 0x01, 0x00, 0x00, 0x0F, 0x84];
let Some(sig_rva) = scan(memory, &pattern).next() else {
return;
};

let patch = [0xB8, 0x01, 0x00, 0x00, 0x00];

let rva = sig_rva + 29;
let patch_mem = &mut memory[rva..rva + 5];

let mut old: PAGE_PROTECTION_FLAGS = Default::default();
VirtualProtect(
patch_mem.as_ptr() as *const c_void,
patch_mem.len(),
PAGE_EXECUTE_READWRITE,
&mut old as *mut _,
);

patch_mem.copy_from_slice(&patch);

VirtualProtect(
patch_mem.as_ptr() as *const c_void,
patch_mem.len(),
old,
&mut old as *mut _,
);
let mut scan_iter = scan(memory, &pattern);
if let Some(sig_rva) = scan_iter.next() {
drop(scan_iter);

let patch = [0xB8, 0x01, 0x00, 0x00, 0x00];

let rva = sig_rva + 29;
let patch_mem = &mut memory[rva..rva + 5];

let mut old: PAGE_PROTECTION_FLAGS = Default::default();
VirtualProtect(
patch_mem.as_ptr() as *const c_void,
patch_mem.len(),
PAGE_EXECUTE_READWRITE,
&mut old as *mut _,
);

patch_mem.copy_from_slice(&patch);

VirtualProtect(
patch_mem.as_ptr() as *const c_void,
patch_mem.len(),
old,
&mut old as *mut _,
);
}

let pattern = [
0x48, 0x89, 0x5C, 0x24, 0x10, 0x48, 0x89, 0x6C, 0x24, 0x18, 0x48, 0x89, 0x74, 0x24, 0x20,
Expand Down

0 comments on commit 6015093

Please sign in to comment.