Wim ten Brink
Wim ten Brink

Reputation: 26682

DEP and ASLR and how to use it?

ASLR and DEP are two techniques that are used to protect applications from hackers. With many modern applications becoming more security-aware, these techniques are becoming more important. For now, I just focus on Windows 7 and these techniques. I wonder when and how I can best use these techniques, especially when developing desktop applications by using developer tools other than .NET compilers. (For .NET security, this question will provide an answer.) I'm especially interested in compilers like Delphi and C++Builder but also other WIN32 compilers. Basically, how do I get those applications to support both DEP and ASLR? And is there some way that I can control these options from within my own (WIN32) code?

Upvotes: 0

Views: 1530

Answers (2)

horace badman
horace badman

Reputation: 1

{$SetPEOptFlags $100}//to set the ASLR flag

{$SetPEOptFlags $40}//to set the DEP flag

Upvotes: 0

Hans Passant
Hans Passant

Reputation: 941465

This is simply a matter of using the right linker option so it flips a bit in the executable header. The Microsoft linker options are /NXCOMPAT (DEP) and /DYNAMICBASE (ASLR). I don't know your tools well enough to know if they have similar options. Editbin.exe supports these options too, you can always run it in a post-build event.

Upvotes: 3

Related Questions