I am using C++, and would like to get the permission to execute on an area of memory. Is there a way I can do this? Right now when I just try to execute it, I get an access violation error.
Asked
Active
Viewed 310 times
0
-
1platform? operating system? how are you trying to execute data? – msw Jul 15 '10 at 01:17
-
Windows 7 home premium 64 bit. I thought of a neat way to execute dynamic assembly: typedef void(*funcptr)(); /* Moves 1 into ebx and returns */ char funcbody[8] = {'\xbb', '\x01', '\x00', '\x00', '\x00', '\xc3'}; void* tmp = funcbody; funcptr f = (funcptr)tmp; f(); but I get a memory access violation. – Langley Jul 15 '10 at 01:24
1 Answers
1
On Windows the function is VirtualProtect, you'll want to pass in PAGE_EXECUTE_READWRITE to get execute permission.
By default Windows does not allow memory. It's called Data Execute Prevention (DEP).

shf301
- 31,086
- 2
- 52
- 86