locked
DEP and shutdown of program RRS feed

  • Question

  • Hello,

    I have developed a program that works fine.
    Yesterday I have installed new upgrades for windows (automatically received via windows update).
    Today I launch my program again and after a while (leaving the app open), it gets shutdown with a message
    "DEP has shutdown this program".

    I have tried adding it to the exceptionlist, but I get a message saying that it's not allowed for this program.

    So basically for a quick fix I would like to know how I can add it to the exceptionlist (right now it would be to disable DEP completely)

    Also, since this error has been reported by one of my customers, I want to fix this problem at the source itself. How can I trackdown where this exception comes from (which part in my code is behaving badly). I don't have a clue to start.

    Best regards,
    Ike
    Wednesday, August 20, 2008 11:55 AM

Answers

  • My suggestion is to fix the problem rather than identify the app as "DEP exempt".

     

    Short article on DEP:

    http://technet.microsoft.com/en-us/library/bb457155.aspx

     

    DEP stands for something like 'Data Execution Prevention'.

     

    A process address space is composed of 'chunks' of virtual addresses; for example, one such chunk might be 0x01000000 - 0x0100f0000.  Each of these chunks is requested from the system's virtual memory manager with a particular set of permissions, like, PAGE_READ, or PAGE_WRITE, or PAGE_EXECUTE.  Flags can also be changed, after they're requested.

     

    When you start running code in one of the sections that isn't marked for PAGE_EXECUTE, that's when DEP kicks in and kills your process.

     

    The fastest way to figure out where your app is getting tripped up is to attach a debugger to it.  It will most likely break when the DEP exception occurs and there is a good chance you will be able to figure out from the call stack where the problem is.

     

    As far as how to avoid DEP triggering on your app in the future? If you want to run code you loaded without using the operating system's code loading APIs (loadlibrary, etc), place it in a buffer allocated with VirtualAlloc with the appropriate memory protection flags set.

    Wednesday, August 20, 2008 9:49 PM

All replies

  • My suggestion is to fix the problem rather than identify the app as "DEP exempt".

     

    Short article on DEP:

    http://technet.microsoft.com/en-us/library/bb457155.aspx

     

    DEP stands for something like 'Data Execution Prevention'.

     

    A process address space is composed of 'chunks' of virtual addresses; for example, one such chunk might be 0x01000000 - 0x0100f0000.  Each of these chunks is requested from the system's virtual memory manager with a particular set of permissions, like, PAGE_READ, or PAGE_WRITE, or PAGE_EXECUTE.  Flags can also be changed, after they're requested.

     

    When you start running code in one of the sections that isn't marked for PAGE_EXECUTE, that's when DEP kicks in and kills your process.

     

    The fastest way to figure out where your app is getting tripped up is to attach a debugger to it.  It will most likely break when the DEP exception occurs and there is a good chance you will be able to figure out from the call stack where the problem is.

     

    As far as how to avoid DEP triggering on your app in the future? If you want to run code you loaded without using the operating system's code loading APIs (loadlibrary, etc), place it in a buffer allocated with VirtualAlloc with the appropriate memory protection flags set.

    Wednesday, August 20, 2008 9:49 PM
  • Hello,

    Thanks for the reply.

    I agree that the problem should be solved at the root.
    I will try to add my debugger to the process and look if I can find the culprit.

    Best regards,
    Ike
    Sunday, August 24, 2008 3:57 PM