Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the /baseaddress to a "good" value?

Tags:

c++

dll

native

We have a project with many dll files which get loaded when the application starts. The baseaddresses of the dll files do overlap so that the memory image gets relocated. Is there a possibility to assign the baseaddresses automatically or a way to calculate a "good" baseaddress for each dll file?

like image 425
frast Avatar asked Oct 08 '08 07:10

frast


2 Answers

You can use the REBASE utility which ships with the platform SDK and with Visual studio I think to set the base addresses of a whole bunch of DLLS loaded by the appliction

You supply REBASE with a list of the DLLS that make up your program, not including system Dlls, it then performs a dummy load of all the DLLs and assigns them new base addresses.

This can be performed as part of a final build step.

There is a Dr Dobbs article on rebasing here and a Microsoft article on rebasing in general here

like image 93
David Dibben Avatar answered Oct 02 '22 02:10

David Dibben


If you are distributing the DLLs, regardless how you set your base address, there is always a risk that other DLLs not written by you are loaded at that address already (for example global hooks DLLs).

Additionally if you are building for Vista you should actually use /DYNAMICBASE to enable ASLR to kick in.

Here is the msdn link: http://msdn.microsoft.com/en-us/library/bb384887.aspx.

like image 35
Dan Cristoloveanu Avatar answered Oct 02 '22 03:10

Dan Cristoloveanu