Any way to disable Heap placement randomization (ASLR) for a singleexecutable?

  • Thread starter Thread starter Paul Pluzhnikov
  • Start date Start date
P

Paul Pluzhnikov

Greetings,

This is more of a programming question, and doesn't appear to quite
fit into this newsgroup. Please feel free to direct me to a more
appropriate forum (if one exists).

I have an application (compiler) which dumps its whole parse
tree into a file, and then re-loads it later (for precompiled
header processing), via MapViewOfFileEx().

Because the parse tree contains pointers, it must be re-loaded at
the same address it was when it was saved [1].

This works fine everywhere, but breaks on Vista(R) due to address
space layout randomization (ASLR).

I can try to map the file at the same address it was when it was
saved, but there is a chance that some DLL has already created a
Heap in that space, and then the mapping will fail.

Questions:
1. Is there any address range that is "safe" from ASLR placing a
Heap there? (I could then hard-code that address).
2. Is there any way to tell Vista that "this executable's address
space should not be randomized" ?
3. Any other way for an executable to "reserve" certain fixed
address region?

Thanks,


[1]. Yes, I know I can save the parse tree in an alternative format
(using offsets instead of pointers), and then I would not care what
the mapping address is. But this is significantly slower.
 
I don't think this is ever going to be reliable. Depending on what other
dlls are loaded into your process, what memory is allocated where etc. means
that you can't guarantee that the same virtual address range is available
all the time.

Almost universally data files are stored with offsets, not raw pointers. In
my experience the effect on performance is insignificant.

Dave Wood
 
Hi Paul,
This is more of a programming question, and doesn't appear to quite
fit into this newsgroup.

You're quite correct. This would be more appropriate in a group designed for
the programming language you are using. These groups are for user shell
questions targeting general use, not in depth programming.
Please feel free to direct me to a more appropriate forum (if one exists).

You'll find a lot of language groups by pointing your newsreader to the
server farm at news://msnews.microsoft.com

--
Best of Luck,

Rick Rogers, aka "Nutcase" - Microsoft MVP

Windows help - www.rickrogers.org
My thoughts http://rick-mvp.blogspot.com

Paul Pluzhnikov said:
Greetings,

This is more of a programming question, and doesn't appear to quite
fit into this newsgroup. Please feel free to direct me to a more
appropriate forum (if one exists).

I have an application (compiler) which dumps its whole parse
tree into a file, and then re-loads it later (for precompiled
header processing), via MapViewOfFileEx().

Because the parse tree contains pointers, it must be re-loaded at
the same address it was when it was saved [1].

This works fine everywhere, but breaks on Vista(R) due to address
space layout randomization (ASLR).

I can try to map the file at the same address it was when it was
saved, but there is a chance that some DLL has already created a
Heap in that space, and then the mapping will fail.

Questions:
1. Is there any address range that is "safe" from ASLR placing a
Heap there? (I could then hard-code that address).
2. Is there any way to tell Vista that "this executable's address
space should not be randomized" ?
3. Any other way for an executable to "reserve" certain fixed
address region?

Thanks,


[1]. Yes, I know I can save the parse tree in an alternative format
(using offsets instead of pointers), and then I would not care what
the mapping address is. But this is significantly slower.
 
You might post this in one of the developer forums, however does disabling
DEP for that specific executable not work?

J
 
Joe said:
You might post this in one of the developer forums, however does
disabling DEP for that specific executable not work?

The current (default) settings are "Turn on DEP for essential
Windows programs and services only", so I assume my executable
already does not have DEP turned on.

Rick said:
This would be more appropriate in a group designed
for the programming language you are using.

The question has nothing to do with any language; it's a
Vista setup / Win32 API question.

I'll repeat my question in microsoft.public.win32.programmer.kernel,
which appears to be filled with similar questions (even though
this has little to do with kernel programming).

Thanks for all who responed.
 
Back
Top