Search code examples
c++windowswinapidata-execution-prevention

Check if DEP is enabled


Is it possible to check if Data Execution Prevention is enabled?

Is there any function that works the same as this CMD command

wmic OS Get DataExecutionPrevention_SupportPolicy

And returns something like this?

0 – DEP is disabled for all processes.
1 – DEP is enabled for all processes.
2 – DEP is enabled for only Windows system components and services. (Default)
3 – DEP is enabled for all processes.

Solution

  • GetSystemDEPPolicy function:

    This function returns a value of type DEP_SYSTEM_POLICY_TYPE, which can be one of the following values: AlwaysOff, AlwaysOn, OptIn, OptOut.