问题
We have an app where some parts of the heap are executed as assembly instructions / for testing purposes - we download programs to PLCs but allow users to simulate running their applications by executing their code before downloading to the PLC. Before we always executed these programs from the heap where the instructions are stored and this worked fine but we have now converted to VS2012 and now it seems that turning off DEP is not so easy. I was wondering if it is somehow possible to turn off the DEP regardless of what GetProcessDEPPolicy
returns or if there is some other technique to execute assembly instructions from heap without involving DEP?
回答1:
You don't want to disable DEP; you want to modify your app to work within it.
Per http://msdn.microsoft.com/en-us/library/windows/desktop/aa366553%28v=vs.85%29.aspx
If your application must run code from a memory page, it must allocate and set the proper
virtual memory protection attributes. The allocated memory must be marked PAGE_EXECUTE,
PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, or PAGE_EXECUTE_WRITECOPY when allocating memory.
Follow these simple directions and your code can coexist with DEP.
来源:https://stackoverflow.com/questions/15581581/how-to-disable-dep