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

P

P

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
 
S

santosh

P said:
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.
 
S

Skarmander

P said:
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.
 
P

P

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
 
G

goose

P said:
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,
 
P

P

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top