titbits from the world less travelled

Implementing GetSystemDEPPolicy Function

For those of you, who dont know about GetSystemDEPPolicy Function, Please refer to this link:

http://msdn.microsoft.com/en-us/library/bb736298%28VS.85%29.aspx

For others lets see on implementing this:
GetSystemDEPPolicy Function

Gets the data execution prevention (DEP) policy setting for the system.

Syntax in C++:

DEP_SYSTEM_POLICY_TYPE  WINAPI  GetSystemDEPPolicy(void);

Describe a typedef in the beginning.

typedef      DEP_SYSTEM_POLICY_TYPE (WINAPI *ptr_getsystemdeppolicy) (void);

Next you will need to load the kernel32.dll. You can do that using GetModuleHandleW. After this,

ptr_getsystemdeppolicy ptrfunc = (ptr_getsystemdeppolicy)GetProcAddress(hMod,”GetSystemDEPPolicy”);
DEP_SYSTEM_POLICY_TYPE var = ptrfunc();

From the above you can get the state of the DEP. But his works I think on XP SP3 and above. For others you will need to manually read c:\boot.ini.

posted by admin in Uncategorized, c++, windows and have No Comments