2

I need to determine if Windows DEP is disabled, set to essential windows programs and services or all programs except those I select.

I've searched for a way of doing this but haven't had any success. Is there a way of doing this? Developing in C#.

Zong
  • 6,160
  • 5
  • 32
  • 46
Dan Hall
  • 1,474
  • 2
  • 18
  • 43

1 Answers1

6
public enum DepSystemPolicyType
{
    AlwaysOff = 0,
    AlwaysOn,
    OptIn,
    OptOut
}

[DllImport("kernel32.dll")]
static extern int GetSystemDEPPolicy();

public static void ValidateDepPolicy()
{
    int policy = GetSystemDEPPolicy();
    //here you can evaluate the return value
    //against the enum DepSystemPolicyType
}

MSDN documentation: GetSystemDEPPolicy function

BryanJ
  • 8,485
  • 1
  • 42
  • 61
  • Thanks Bryan, out of interest...do you have a code library with code snips like this in it, or do you recall this and tap it out by hand? – Dan Hall Dec 05 '13 at 18:05
  • @DanHall I had to implement something similar in an installer which I happened to be working on when I saw your question. I just grabbed the code snippet. – BryanJ Dec 05 '13 at 18:17