Jump to content
Sign in to follow this  
4nt1h4cker

Proof of Concept "SetWindowsHookEx"

Recommended Posts

4nt1h4cker

I just tried to use SetWindowsHookEx in Autoit, first one good message i got i working so far. But i cant really handle the data.

$vCallBack = DllCallbackRegister ( "_hook", "int", "int;wparam;lparam;"); 

;~ ConsoleWrite ($vCallBack & @error)

$threadid = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
;~ ConsoleWrite ( "thread id: "& $threadid[0] & @CRLF)

$handle = DllCall ("user32.dll", "ptr", "SetWindowsHookEx", "int", 5, "ptr", DllCallbackGetPtr ($vCallBack), "int", 0, "dword", $threadid[0])


While 1
;~  Sleep ( 1 )
WEnd



func _hook ($nCode, $wParam, $lParam)
;~  ConsoleWrite ("here!")
;~  ConsoleWrite ($nCode & "|" & $wParam & "|" & $lParam & @CRLF )
    if $nCode < 0 Then
        DllCall ( "user32.dll", "int", "CallNextHookEx", "ptr", $handle[0], "int", $nCode, "wparam", $wParam, "lparam", $lParam)
        Return
    EndIf
    
    if $nCode == 3 Then
        ConsoleWrite ( "Window created: " & WinGetTitle ( $wParam ) & @CRLF )
    EndIf
    
    DllCall ( "user32.dll", "int", "CallNextHookEx", "ptr", $handle[0], "int", $nCode, "wparam", $wParam, "lparam", $lParam)
EndFunc

Share this post


Link to post
Share on other sites
monoceres

SetWindowsHookEx is already implemented in the standard UDF library (_WinAPI_SetWindowHookEx()) with a working example. Play around with it :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.