Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- use winapi::minwindef::{LPVOID, DWORD, PDWORD};
- fn main() {
- let address = 0xDEADBEEF; // in practice i know the address is right ok, just trust me.
- let old_protect: DWORD = 0;
- let t = unsafe { kernel32::VirtualProtect(address as LPVOID, 1, 0x40, old_protect as PDWORD) };
- println!("results: {}, {}", old_protect, t); // "t" returns 0, but I don't know why t.t
- }
- /*
- I'm suspecting something is wrong with how I did things regarding old_protect.
- I know that address is valid (checked it multiple times!) and that the other args (1, 0x40) are valid as I have equivalent C++ code that works fine.
- VirtualProtect returns 0 when it fails - GetLastError() tells me the error is 0x3E6, which is ERROR_NOACCESS "Invalid access to memory location."
- VirtualProtect takes (LPVOID, DWORD, DWORD, PDWORD),
- LPVOID = *mut std::os::raw::c_void
- DWORD = u32
- PDWORD = *mut u32
- I have no idea how to fix this :/
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement