| View previous topic :: View next topic |
| Author |
Message |
b6oy Newbie cheater
Reputation: 0
Joined: 21 Sep 2009 Posts: 10
|
Posted: Thu Jul 26, 2012 6:30 pm Post subject: Change image base |
|
|
I have a dll that is always loaded at a constant position. I want it to be loaded at any other position except this one via hooking something like LoadLibrary to change the image base.
I did make a dummy dll to be loaded first at that location, so that the original dll is loaded somewhere else, but that is not what I want.
If you have any information of how to do that, please share.
Thanks.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jul 26, 2012 6:53 pm Post subject: |
|
|
it is unnecessary to detour anything at all. you can specify the /FIXED linker option when building your dll:
http://msdn.microsoft.com/en-us/library/w368ysh2(v=vs.100).aspx
| Quote: | The /FIXED option tells the operating system to load the program only at its preferred base address. If the preferred base address is unavailable, the operating system will not load the file. For more information, see /BASE (Base Address).
By default, /FIXED:NO is the default when building a DLL, and /FIXED is the default for any other project type.
When /FIXED is specified, LINK does not generate a relocation section in the program. At run time, if the operating system is unable to load the program at that address, it issues an error message and does not load the program. |
or more likely you want to use /BASE:
http://msdn.microsoft.com/en-us/library/f7f5138s.aspx
| Quote: | | The /BASE option sets a base address for the program, overriding the default location for an .exe file (at 0x400000) or a DLL (at 0x10000000). The operating system first attempts to load a program at its specified or default base address. If sufficient space is not available there, the system relocates the program. To prevent relocation, use the /FIXED option. |
i've highlighted the key difference of the two linker options
if you are working only with a dll binary without source, you can use tools such as this one to fix the preferred relocation address:
http://www.codeproject.com/Articles/35829/Modify-the-Base-Addresses-for-a-DLL-Files-Series
|
|
| Back to top |
|
 |
b6oy Newbie cheater
Reputation: 0
Joined: 21 Sep 2009 Posts: 10
|
Posted: Sat Jul 28, 2012 6:42 pm Post subject: |
|
|
I know this, it wasn't what I needed.
I must detour or hook the thing that loads the image base because I can't modify the DLL file.
or I need a custom function like LoadLibraryAtLocation to load it at a different base.
thanks anyways.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Jul 28, 2012 6:44 pm Post subject: |
|
|
| look at that last link i posted
|
|
| Back to top |
|
 |
b6oy Newbie cheater
Reputation: 0
Joined: 21 Sep 2009 Posts: 10
|
Posted: Sat Jul 28, 2012 7:17 pm Post subject: |
|
|
| Slugsnack wrote: | | look at that last link i posted |
Works on a normal DLL but doesn't work on that DLL because it is heavily protected with **** (thats why I don't want to touch the file).
I think I found what I was looking for, i'll just have to detour LoadLibrary, GetProcAddress and FreeLibrary.
|
|
| Back to top |
|
 |
|