I am trying to override another process memory in order to create a simple detour in the future. This use case is more specific than what I managed to find in other questions already as I’m trying to modify memory region of the binary code and not just some variable.
I am enabling SeDebugPrivilege (and running as an administrator) and getting the handle using OpenProcess
with PROCESS_ALL_ACCESS
. Then I’m calling VirtualProtectEx
with obtained handle in attempt to set PAGE_EXECUTE_READWRITE
permissions, but I keep getting error 87 (ERROR_INVALID_PARAMETER
). I know all parameters are correct, so that’s probably a permission issue. I also tried calling WriteProcessMemory
without prior modification of the permissions, but then It fails.
Memory regions containing code from executable are probably guarded, but tools like frida manage to modify them, so there must be a way.
I expected VirtualProtectEx
to change page’s permission and then allow me to write to this memory, this however did not happen and I keep getting errors. I also tried creating a DLL that would be injected into another process, but It seems like It cannot modify that process either.
Oliwier Michalik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.