Skip to content

Commit

Permalink
fix: remove unnecessary VirtualProtect
Browse files Browse the repository at this point in the history
  • Loading branch information
progre committed Jan 10, 2023
1 parent 81f7602 commit 522fe49
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/dinput8_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use windows::{
Foundation::{FARPROC, HINSTANCE, HWND, MAX_PATH},
System::{
LibraryLoader::{GetModuleFileNameW, GetProcAddress, LoadLibraryW},
Memory::{VirtualProtect, PAGE_PROTECTION_FLAGS, PAGE_READWRITE},
SystemInformation::GetSystemDirectoryW,
},
},
Expand Down Expand Up @@ -111,23 +110,10 @@ fn setup_method_hook(
original_method_addr: &mut usize,
) {
let vtable = unsafe { *obj };
let mut old_protect: PAGE_PROTECTION_FLAGS = Default::default();
let method_addr = unsafe { vtable.offset(method_offset) };
unsafe {
VirtualProtect(
method_addr as _,
size_of::<usize>(),
PAGE_READWRITE,
&mut old_protect,
);
*original_method_addr = *method_addr;
*method_addr = hooked_method_addr;
VirtualProtect(
method_addr as _,
size_of::<usize>(),
old_protect,
&mut old_protect,
);
}
}

Expand Down

0 comments on commit 522fe49

Please sign in to comment.