I am writing an assembly program which will attempt, once the program is loaded into memory, to re-write over a portion of previous instructions, move the instruction pointer to them, and begin execution. However, a general protection exception occurs because of virtual memory protection settings.
The assembly function will be called from a C++ application, e.g. like so:
#include <iostream> #include <Windows.h> // External assembly function 'asm_func' found // in asm_func.asm; using C calling convention extern "C" void asm_func(); int main(void) { asm_func(); return 0; }
I would like to set read/write/execute permissions on the entire application, including on the memory where main() and asm_func() are loaded into. I was thinking of usingVirtualProtect(), but how do I acquire the parameters to do so?