Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL relocation? 1

Status
Not open for further replies.

IonelBurtan

Programmer
May 25, 2001
601
RO
Let's say I compile 3 dlls with VC++ from 3 different projects.
Now these DLLs are used by an exe (another project).
I get two messages of these type in the debug window when I start the EXE in debug mode:

LDR: Automatic DLL Relocation in MyExe.exe
LDR: Dll Second.dll base 10000000 relocated due to collision with D:\work3\Apps\First.dll

LDR: Automatic DLL Relocation in MyExe.exe
LDR: Dll Third.dll base 10000000 relocated due to collision with D:\work3\Apps\First.dll

I have read about DLLs and relocation. I know I have to change the default base adress of the dlls with:

#pragma comment(linker,"/BASE:'new base in hexa'"):

My problem is:
If I want to know the necesary virtual space between the DLLs what do I have to consider: (the image size + stack size+ heap size). Is there someting else?

Because I want to give contigouous base adresses to avoid memory waste.

Thank you,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
It's only the size of the image that's relevant. Also there's no problem with wasted space due to the way Windows allocates storage. :) Hope that this helped! :)
 
--DavesTips
I just read some more, and I think you are right, stack does not count because it belongs to the calling process and the heap belongs to the operating system.

However, how do I read the ImageSize or the BaseAddress of a Dll or exe?

Thanks,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
You can get all the info by right clicking on a dll and using quick view, or running
"link -dump -headers ...\name.dll"
(with maybe a >dump.txt)

Windows loads executables on 64k boundaries, as far as I can recall. :) Hope that this helped! ;-)
 
Thank you Daves this I know until now (Dependency walker or Quickview or Dumpbin.exe) but I mean it in a programatical way so that I can unse it inside another program.

Thanks, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Then look in MSDN under "IMAGEHLP", there's a set of API functions to get such information. :) Hope that this helped! ;-)
 
Never mind I found it:

is ImageLoad/ImageUnload and is working very fine for Win32 Executables or Dlls with PE header.

Thanks,


s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top