|
| 1 | +use log::{debug, error}; |
| 2 | +use windows::Win32::{ |
| 3 | + Foundation::{GetLastError, WIN32_ERROR}, |
| 4 | + System::Memory::{VirtualProtect, PAGE_EXECUTE_READWRITE, PAGE_PROTECTION_FLAGS}, |
| 5 | +}; |
| 6 | +const PATCH_ADDRESS: u32 = 0x0067AB30; |
| 7 | + |
| 8 | +static HITBOXES: &[u8] = &[ |
| 9 | + 0x00, 0x00, 0xC9, 0xFF, 0x13, 0x00, 0xE1, 0xFF, 0x13, 0x00, 0x2F, 0x00, 0xED, 0xFF, 0x2F, 0x00, 0xED, 0xFF, 0xE1, 0xFF, 0x00, 0x00, 0xBE, 0xFF, 0x15, 0x00, |
| 10 | + 0xDC, 0xFF, 0x13, 0x00, 0x37, 0x00, 0xED, 0xFF, 0x37, 0x00, 0xEB, 0xFF, 0xDC, 0xFF, 0x00, 0x00, 0xCA, 0xFF, 0x19, 0x00, 0xF2, 0xFF, 0x13, 0x00, 0x43, 0x00, |
| 11 | + 0xED, 0xFF, 0x43, 0x00, 0xE7, 0xFF, 0xF2, 0xFF, 0x00, 0x00, 0xBD, 0xFF, 0x16, 0x00, 0xE7, 0xFF, 0x13, 0x00, 0x51, 0x00, 0xED, 0xFF, 0x51, 0x00, 0xEA, 0xFF, |
| 12 | + 0xE7, 0xFF, |
| 13 | +]; |
| 14 | + |
| 15 | +#[no_mangle] |
| 16 | +pub unsafe extern "C" fn start() -> u32 { |
| 17 | + let _ = log::set_logger(&win_dbg_logger::DEBUGGER_LOGGER); |
| 18 | + log::set_max_level(log::LevelFilter::Trace); |
| 19 | + let patch_ptr: *mut u8 = PATCH_ADDRESS as _; |
| 20 | + |
| 21 | + let mut old_flags: PAGE_PROTECTION_FLAGS = windows::Win32::System::Memory::PAGE_PROTECTION_FLAGS(0); |
| 22 | + if !VirtualProtect(patch_ptr as _, 5, PAGE_EXECUTE_READWRITE, &mut old_flags).as_bool() { |
| 23 | + let error: WIN32_ERROR = GetLastError(); |
| 24 | + error!("VirtualProtect PAGE_EXECUTE_READWRITE failed: {:?}", error); |
| 25 | + return 1; |
| 26 | + } |
| 27 | + |
| 28 | + debug!("Patching hitboxes at {:#x}", PATCH_ADDRESS); |
| 29 | + patch_ptr.copy_from(HITBOXES.as_ptr(), HITBOXES.len()); |
| 30 | + |
| 31 | + if !VirtualProtect(patch_ptr as _, 5, old_flags, &mut old_flags).as_bool() { |
| 32 | + let error: WIN32_ERROR = GetLastError(); |
| 33 | + error!("VirtualProtect restore failed: {:?}", error); |
| 34 | + return 2; |
| 35 | + } |
| 36 | + |
| 37 | + 0 |
| 38 | +} |
0 commit comments