How to make code Data Execution Prevention (DEP) compatible?

Discussion in 'C Programming' started by P, Nov 13, 2006.

  1. P

    P Guest

    I was wondering what sort of changes I need to make in order to make an
    application to be DEP compatible with on Windows XP x64 version 2003.
    I have compiled an open source C application
    (japach:http://www.jikos.cz/jikos/japach/) but when I ran it on Windows
    with DEP turned on, I get a core file and inside that, it says
    "STATUS_ACCESS_VIOLATION". After searching through Google, most of the
    results came back were on making an exception to the application that
    isn't compatible through system settings. Is there a way to make it
    compatible by making changes in the code?

    Patrick
    P, Nov 13, 2006
    #1
    1. Advertising

  2. P

    santosh Guest

    P wrote:
    > I was wondering what sort of changes I need to make in order to make an
    > application to be DEP compatible with on Windows XP x64 version 2003.
    > I have compiled an open source C application
    > (japach:http://www.jikos.cz/jikos/japach/) but when I ran it on Windows
    > with DEP turned on, I get a core file and inside that, it says
    > "STATUS_ACCESS_VIOLATION". After searching through Google, most of the
    > results came back were on making an exception to the application that
    > isn't compatible through system settings. Is there a way to make it
    > compatible by making changes in the code?
    >
    > Patrick


    All this is intricately linked with OS level details. As this group
    tries to confine itself to standard C, please post to a group under
    comp.os.ms-windows.* hierarchy, or to MSDN forums.
    santosh, Nov 13, 2006
    #2
    1. Advertising

  3. P

    Skarmander Guest

    P wrote:
    > I was wondering what sort of changes I need to make in order to make an
    > application to be DEP compatible with on Windows XP x64 version 2003.


    That's conceptually easy; fix the errors your program contains. If your
    program is strictly conforming C (or rather, just well-behaved C) it should
    never trigger the DEP mechanism.

    > I have compiled an open source C application
    > (japach:http://www.jikos.cz/jikos/japach/) but when I ran it on Windows
    > with DEP turned on, I get a core file and inside that, it says
    > "STATUS_ACCESS_VIOLATION".


    I took a brief look at that program; it appears to be targeting UNIX-like
    platforms and there's no mention of Windows support. If you can compile it
    at all, it's still quite likely that the assumptions the program makes are
    wrong (pay particular attention to any warnings your compiler emits; these
    are not to be ignored). The core dump is just an indication that the program
    isn't running the way it expected to.

    > After searching through Google, most of the results came back were on
    > making an exception to the application that isn't compatible through
    > system settings. Is there a way to make it compatible by making changes
    > in the code?
    >

    Not unless you want to invest some time in finding and fixing whatever is
    causing the program to misbehave on Windows, which could be anything from an
    incomplete library implementation to a data type mismatch. Turning off DEP
    is a waste of time; it's very unlikely the program will run any better, and
    triggering DEP is always an indication of either an error or an unportable
    trick/hack that in standard C would be undefined behavior.

    Try googling for "Cygwin" and "MinGW" for general information on how to
    compile UNIX applications on Windows, and find appropriate newsgroups (like
    comp.unix.programmer and comp.os.ms-windows.programmer) for questions about
    OS-specific constructs (which are off-topic here).

    S.
    Skarmander, Nov 13, 2006
    #3
  4. P

    P Guest

    > Not unless you want to invest some time in finding and fixing whatever is
    > causing the program to misbehave on Windows, which could be anything from an
    > incomplete library implementation to a data type mismatch. Turning off DEP
    > is a waste of time; it's very unlikely the program will run any better, and
    > triggering DEP is always an indication of either an error or an unportable
    > trick/hack that in standard C would be undefined behavior.
    >
    > Try googling for "Cygwin" and "MinGW" for general information on how to
    > compile UNIX applications on Windows, and find appropriate newsgroups (like
    > comp.unix.programmer and comp.os.ms-windows.programmer) for questions about
    > OS-specific constructs (which are off-topic here).
    >
    > S.


    I forgot to mention I'm compiling in cygwin and it's working in windows
    that don't come with DEP and windows with DEP but it's turned off. I
    will post in those groups. Thanks.

    Patrick
    P, Nov 13, 2006
    #4
  5. P

    goose Guest

    P wrote:
    > I was wondering what sort of changes I need to make in order to make an
    > application to be DEP compatible with on Windows XP x64 version 2003.
    > I have compiled an open source C application
    > (japach:http://www.jikos.cz/jikos/japach/) but when I ran it on Windows
    > with DEP turned on, I get a core file and inside that, it says
    > "STATUS_ACCESS_VIOLATION". After searching through Google, most of the
    > results came back were on making an exception to the application that
    > isn't compatible through system settings. Is there a way to make it
    > compatible by making changes in the code?
    >


    I've downloaded and attempted to compile it (linux 2.4). It won't
    compile due to exit being called with no arguments.

    After fixing all the calls to exit, it compiles and (seems to) run
    fine.

    After adding "-W -Wall" to the CFLAGS variable in the makefile,
    it generates a *ton* of warnings including:

    1. return without a value in functions declared as
    returning non-void.
    2. trampling over the std c libs namespaces; essentially
    redefining "log"
    3. falling of the end of functions declared as returning
    a value.
    4. implicit declaration of "free" - implies a missing include
    directive.
    5. ambiguity in assignment/comparison.
    6. unused variables.
    7. no declarations for some functions.
    8. redefinition of #defines.
    9. signed/unsigned comparison.

    I suspect that the problem is not with DEP, but with the fact
    that the program does so many illegal things that it's bound
    to crash under some configurations.

    Maybe you could try to fix all the warnings and give it another
    try?


    goose,
    goose, Nov 14, 2006
    #5
  6. P

    P Guest

    > I've downloaded and attempted to compile it (linux 2.4). It won't
    > compile due to exit being called with no arguments.
    >
    > After fixing all the calls to exit, it compiles and (seems to) run
    > fine.
    >
    > After adding "-W -Wall" to the CFLAGS variable in the makefile,
    > it generates a *ton* of warnings including:
    >
    > 1. return without a value in functions declared as
    > returning non-void.
    > 2. trampling over the std c libs namespaces; essentially
    > redefining "log"
    > 3. falling of the end of functions declared as returning
    > a value.
    > 4. implicit declaration of "free" - implies a missing include
    > directive.
    > 5. ambiguity in assignment/comparison.
    > 6. unused variables.
    > 7. no declarations for some functions.
    > 8. redefinition of #defines.
    > 9. signed/unsigned comparison.
    >
    > I suspect that the problem is not with DEP, but with the fact
    > that the program does so many illegal things that it's bound
    > to crash under some configurations.
    >
    > Maybe you could try to fix all the warnings and give it another
    > try?
    >
    >
    > goose,


    Hi goose,

    Thanks! I've turned on the CFLAGS and fixed all the warnings. I'm
    able to run it without having to turn off DEP. I'm not sure if this
    was happening before but now I'm noticing the memory usage
    progressively increments after a number of files being served.

    Thanks for your help!

    Patrick
    P, Nov 15, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Curry
    Replies:
    1
    Views:
    482
    Anon-E-Moose
    Jul 23, 2004
  2. Carl Gilbert

    Image padding prevention / issue

    Carl Gilbert, Dec 6, 2004, in forum: HTML
    Replies:
    7
    Views:
    506
    Toby Inkster
    Dec 8, 2004
  3. mahesh
    Replies:
    6
    Views:
    1,116
    benben
    Sep 27, 2006
  4. pantagruel
    Replies:
    0
    Views:
    220
    pantagruel
    Feb 17, 2006
  5. optimistx

    cluttered code prevention?

    optimistx, Oct 20, 2009, in forum: Javascript
    Replies:
    5
    Views:
    198
Loading...

Share This Page