Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Change image base

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
b6oy
Newbie cheater
Reputation: 0

Joined: 21 Sep 2009
Posts: 10

PostPosted: Thu Jul 26, 2012 6:30 pm    Post subject: Change image base Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Thu Jul 26, 2012 6:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
b6oy
Newbie cheater
Reputation: 0

Joined: 21 Sep 2009
Posts: 10

PostPosted: Sat Jul 28, 2012 6:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Jul 28, 2012 6:44 pm    Post subject: Reply with quote

look at that last link i posted
Back to top
View user's profile Send private message
b6oy
Newbie cheater
Reputation: 0

Joined: 21 Sep 2009
Posts: 10

PostPosted: Sat Jul 28, 2012 7:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites