Migrating a project from VS2005 to VS2008 disables ASLR
I just spent about an hour trying to figure out why some of KoroIRC’s binaries did not have the IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE and IMAGE_DLLCHARACTERISTICS_NX_COMPAT flags enabled in their PE header, and some other had them.
Oddly, only the older projects in the solution had this problem, the newer were OK. I spent a while wondering if it might have been a linker bug, then I decided to look at the build log. Surprisingly, the affected projects had the /DYNAMICBASE:NO linker switch specified, even though I specified the opposite in the solution-global .vsprops files.
So I decided to take a look directly in the .vsproj files, and lo and behold, in the linker options, the following lines where there:
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Since I never add stuff directly to the .vsproj files, because I prefer .vsprops files which allow sharing common settings between projects, then in the migration from VS2005 to VS2008, it must have “helpfully” inserted these for me.
To quote Stan from South Park, “I learned something today…”