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 


IAT Hook

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Jun 07, 2009 6:09 am    Post subject: IAT Hook Reply with quote

so i wanna place IAT hooks on every single module of a given executable. so.. let's say i wanna hook MessageBoxA, this was my idea.

1) GetProcAddress() on MessageBoxA
2) Traverse module list with CreateToolhelp32Snapshot(), Module32First()/Module32Next()
3) Use modBaseAddr to PE header >> read offset to PE signature >> fetch IAT address + IAT size
4) Walk IAT checking each entry for whether it matches the return from GetProcAddress(), if yes, redirect to hook function then move to next module

my questions..
1) is there a way to distinguish from system modules and user code ? that would save walking the IATs (if existent) of unnecessary modules
2) is there a better way to find the entry of the function to be hooked ? i am thinking something like.. import table
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Sun Jun 07, 2009 7:44 am    Post subject: Re: IAT Hook Reply with quote

Slugsnack wrote:
my questions..
1) is there a way to distinguish from system modules and user code ? that would save walking the IATs (if existent) of unnecessary modules
2) is there a better way to find the entry of the function to be hooked ? i am thinking something like.. import table

1) Maybe you could check it's version information and check whether the company name is Microsoft or something like that, or check for a digital signature. But remember that a user module might call a system module which then calls the MessageBox, so in that case you will have to hook every module.
2) I think GetProcAddress will be the best since it will do the same as you will do when you write the function yourself (walk the export table of user32)
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Jun 07, 2009 9:09 am    Post subject: Reply with quote

q1.. now you bring up that point maybe it is smarter to walk all modules, there isn't a massive overhead anyway
q2.. i think you might have misunderstood my question. i mean is there a better way to find the entry within the IAT rather than walking and testing each entry. although now i think about it i don't think there is a better way

gonna do some coding tonight and test it out
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