Re: Determining a DLL's preferred load address, how?
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Sat, 13 May 2006 14:33:32 -0700
"Stefan Kuhr" <kustt110@xxxxxx> wrote in message
news:446642DA.EB7C3D04@xxxxxxxxx
Hello everyone,
I am writing a tool for our build process that after the daily build
should examine each built DLL in order to determine its preferred load
address. If it is the default address (0x10000000) an error should be
raised and other stuff done (email sent to the buildmaster etc...), so
we know that someone forgot to set the base address correctly.
How do I get his preferred load address? I tried with imagehlp's
ImageLoad but the MappedAddress member of the LOADED_IMAGE structure it
returns always seems to have the same result. The best result always
gives a LoadLibraryEx with DONT_RESOLVE_DLL_REFERENCES, but it gives
incorrect results if the DLL has a preferred load address near the
default exe load address (0x00400000) bacause my test exe file is
located there, so I wonder if there is a canonical way to determine this
information from a PE file. Also, I have no idea how to get the image
size from this so I can find collisions in the virtual address space
between the DLLs we ship given the start address and the image size of
each DLL.
Any clues?
Just open the file (as a file - with CreateFile) and read the PE header to
see the preferred load address.
There's lots of information about the PE header format - you might start
with this article:
http://msdn.microsoft.com/msdnmag/issues/02/02/PE/default.aspx
-cd
.
- Follow-Ups:
- Re: Determining a DLL's preferred load address, how?
- From: Stefan Kuhr
- Re: Determining a DLL's preferred load address, how?
- From: Jochen Kalmbach [MVP]
- Re: Determining a DLL's preferred load address, how?
- From: Garfield Lewis
- Re: Determining a DLL's preferred load address, how?
- References:
- Determining a DLL's preferred load address, how?
- From: Stefan Kuhr
- Determining a DLL's preferred load address, how?
- Prev by Date: Re: GetCurrentProcessorNumber() for XP?
- Next by Date: Re: GetCurrentProcessorNumber() for XP?
- Previous by thread: Determining a DLL's preferred load address, how?
- Next by thread: Re: Determining a DLL's preferred load address, how?
- Index(es):
Relevant Pages
|
Loading