Why doesn't Windows randomize the base address of my executable?

I made a simple C program that simply prints the address main()on execution:

printf("%08X\n", &main);

I will compile it with Visual C ++ 2015 with a parameter /DYNAMICBASEfor x86 (the same thing happens when compiling for x64).

The first two times I run it, the return address is different, as expected. However, after two times, the address returned by the program remains unchanged:

00C31050
00221050
00221050
00221050 

Re-compiling or renaming the executable file will randomize the address again.

What's going on here? Does Windows somehow cache the executable?

+6
source share
1 answer

, , % p, . :

printf ("%p\n", main);

ASLR, , , , , . , , , . () 32- Windows-7 10 :

00BE1260
00BE1260
00221260
00F71260
01391260
01391260
01391260
01391260
01391260
003A1260

, , . , , exe-. 400000h, :

00401260
00401260
00401260
00401260
00401260
...

, , - , - . , , .

, Windows , . , , . , RAM , , . , . , .

. . , (). , . , Windows "" . , , . , , .

EDIT:

, , /DYNAMICBASE VS2015, ASLR, /DYNAMICBASE: NO. , - , , ( ) . , VS2015 ASLR, IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE exe-. , MS.

+2

All Articles