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 


MASM - IAT Hook

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

Joined: 18 Aug 2009
Posts: 21

PostPosted: Wed Aug 19, 2009 8:39 am    Post subject: MASM - IAT Hook Reply with quote

Thought this should be shared. Tis asm sexh.
Written by Ksbunker

Code:
.data
 
        o_MessageBoxA     DWORD 0
        dwOrigProtect      DWORD 0
               
.code
 
        MyMsgHook PROC uses ebx esi edx hWin:DWORD, lpText:DWORD, lpCaption:DWORD, dwStyle:DWORD
       
                push DWORD PTR [dwStyle]
                push DWORD PTR [lpCaption]
                push DWORD PTR [lpText]
                push DWORD PTR [hWin]
                call o_MessageBoxA
                ret
       
        MyMsgHook ENDP
 
start:
 
        ;       get user32!MessageBoxA and save into o_MessageBoxA
 
        INVOKE  LoadLibrary, CTEXT("user32.dll")
        INVOKE  GetProcAddress, eax, CTEXT("MessageBoxA")
        mov     o_MessageBoxA, eax
 
        ;       call user32!MessageBox test
 
        invoke MessageBox, 0, CTEXT("caption..."), 0, 0
 
        ;       install hook and change protections
 
        mov     eax, MessageBoxA
        add     eax, 2
        mov     eax, [eax]
        push    eax
        invoke  VirtualProtect, eax, 4, PAGE_WRITECOPY, addr dwOrigProtect
        pop     eax
        mov     [eax], OFFSET MyMsgHook
        invoke  VirtualProtect, eax, 4, addr dwOrigProtect, NULL
 
        ;       this time we execute our hookproc instead of user32!MessageBoxA
       
        invoke  MessageBox, 0, CTEXT("hooked..."), 0, 0
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Aug 19, 2009 10:37 am    Post subject: Reply with quote

Title says IAT Hook?
Back to top
View user's profile Send private message MSN Messenger
NoManchesPuto
I post too much
Reputation: 0

Joined: 24 Jan 2009
Posts: 2820

PostPosted: Wed Aug 19, 2009 10:58 am    Post subject: Reply with quote

Sorry but I don't understand what this does Confused Mind to shed some light?
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Aug 19, 2009 11:34 am    Post subject: Reply with quote

that isn't an IAT hook. let me show you my sexiness MASM32 IAT hook :
x59.zwit.org
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Wed Aug 19, 2009 1:48 pm    Post subject: Reply with quote

That's not an IAT hook...
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Aug 19, 2009 3:02 pm    Post subject: Reply with quote

looked more carefully and actually that is an IAT hook but it's not as nice as my one : D

Code:
mov     eax, MessageBoxA
        add     eax, 2
        mov     eax, [eax]


first line moves jmp thunk table entry address for messageboxa to eax. add 2 is to get pointer to IAT entry. third line sets eax as IAT entry address for MessageBoxA

but that only performs an IAT hook on your own module which is not particularly useful even when injecting your dll since you'll just hook your own dll and not the other modules. my IAT hook does it properly though
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