CLEO Help Disable/block keyboard and mouse

CLEO related
Status
Not open for further replies.

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
26
Hello, how to disable/block keyboard and mouse via CLEO?

@monday
@supahdupahnubah
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
I have honestly no idea on how can you do it in cleo remaining your code cool and easy to read but...
To block keyboard input you can attach your hook with WinAPI, to block mouse input you have to hook directinput
This is all so complicated to do in cleo so it is better to either kill yourself or do that in C++

Maybe I'm trippin and there's an easy way but I just have not seen it yet
Also you can just show the cursor via SF opcodes if you dont mind have your cursor ballin around the screen
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
157
Code:
{$CLEO}
0000:

repeat
wait 50
until 0AFA:  is_samp_available


while true
wait 0

    if key_down 48 // key 0 (not numpad)
    then
        while key_down 48  // necessary because key needs to be unpressed before setting the hook (because callback will ignore "key_up" message and assume it's pressed all the time, resulting in another hook after unhook)
        wait 1
        end

        0AC6: 30@ = label @KeyboardHookCallback offset
        call @GetThreadID 0 _threadID 28@

        call @SetWindowsHookEx 4 type 2{WH_KEYBOARD - local} /*13{WH_KEYBOARD_LL - global}*/ callback 30@ hinstance 0 thread_id 28@ _returnedHookHandle 31@    // if your game crashes while hooked (using global hook) use ctrl+alt+del
                                                                                                                             
        printf "Keyboard input should be ~R~disabled ~W~now" 5000                        
        wait 5000
 
        call @UnhookWindowsHookEx 1 hook_handle 31@
        printf "Keyboard input should be ~G~enabled ~W~ again now" 2000
        
        
        // it just doesn't work for mouse for some reason (it works in .exe version in the same configuration I used for keyboard) 
        // maybe it's because of the way gta handles mouse input, just a guess (or I messed something up)       
        //0AC6: 30@ = label @MouseHookCallback offset
        //call @SetWindowsHookEx 4 type 14 {WH_MOUSE_LL} callback 30@ _returnedHookHandle 29@  
        //call @UnhookWindowsHookEx 1 hook_handle 29@        
    end
end

 /*
//call @LockKeyboardAndMouseInput 1 lock_state 1
//call @LockKeyboardAndMouseInput 1 lock_state 0
:LockKeyboardAndMouseInput  // works only when ran as administrator in .exe version, maybe that's the reason why it doesn't work in game
0AA2: 31@ = load_library "User32.dll"
if 0AA4: 31@ = get_proc_address "BlockInput" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 31@ push 1 pop 0 bool_fBlockIt 0@ _returned 30@
   if 30@ > 0
   then 
   chatmsg "Success" -1
   //success
   else
   chatmsg "Failure" -1
   //failure
   {"If the function succeeds, the return value is nonzero.
   If input is already blocked, the return value is zero. To get extended error information, call GetLastError."} 
   end
end
0AA3: free_library 31@
ret 0
*/


:SetWindowsHookEx
{
    0@ _In_ int       idHook (hook type - WH_KEYBOARD_LL which is 13)
    1@ _In_ HOOKPROC  lpfn   (pointer to callback function)
    2@ _In_ HINSTANCE hMod   (idk, can be 0)
    3@ _In_ DWORD     dwThreadId  (idk, can be 0)
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "SetWindowsHookExA" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 4 pop 0 dwThreadId 3@ hMod 2@ lpfn 1@ idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Hooked successfully" -1
   else
   chatmsg "Failed to hook" -1
   end
else
chatmsg "Failed to find SetWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 1 29@


:UnhookWindowsHookEx
{
    0@ - hook handle
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "UnhookWindowsHookEx" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 1 pop 0 idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Unhooked successfully" -1
   else
   chatmsg "Failed to unhook" -1
   end
else
chatmsg "Failed to find UnhookWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 0
    
:KeyboardHookCallback // just returns 1              
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end

/*
:MouseHookCallback
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end
*/

:GetThreadID  // used to make local hook (global hook would not allow you to use keyboard after game crashes or if you forget to unhook it in the code)
0AA2: 31@ = load_library "kernel32.dll"
if 0AA4: 30@ = get_proc_address "GetCurrentThreadId" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 0 pop 0 _returnedThreadID 28@
else
chatmsg "Failed to find GetCurrentThreadId function" -1
end
0AA3: free_library 31@
ret 1 28@

I managed to do it for keyboard but not for mouse, idk why it doesn't work for mouse, you could try searching "camera lock" / "set actor lock" opcodes + if cursor is visible then get its position and repetatively set it back to it unless you want to "unfreeze" the mouse
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
monday said:
Code:
{$CLEO}
0000:

repeat
wait 50
until 0AFA:  is_samp_available


while true
wait 0

    if key_down 48 // key 0 (not numpad)
    then
        while key_down 48  // necessary because key needs to be unpressed before setting the hook (because callback will ignore "key_up" message and assume it's pressed all the time, resulting in another hook after unhook)
        wait 1
        end

        0AC6: 30@ = label @KeyboardHookCallback offset
        call @GetThreadID 0 _threadID 28@

        call @SetWindowsHookEx 4 type 2{WH_KEYBOARD - local} /*13{WH_KEYBOARD_LL - global}*/ callback 30@ hinstance 0 thread_id 28@ _returnedHookHandle 31@    // if your game crashes while hooked (using global hook) use ctrl+alt+del
                                                                                                                             
        printf "Keyboard input should be ~R~disabled ~W~now" 5000                        
        wait 5000
 
        call @UnhookWindowsHookEx 1 hook_handle 31@
        printf "Keyboard input should be ~G~enabled ~W~ again now" 2000
        
        
        // it just doesn't work for mouse for some reason (it works in .exe version in the same configuration I used for keyboard) 
        // maybe it's because of the way gta handles mouse input, just a guess (or I messed something up)       
        //0AC6: 30@ = label @MouseHookCallback offset
        //call @SetWindowsHookEx 4 type 14 {WH_MOUSE_LL} callback 30@ _returnedHookHandle 29@  
        //call @UnhookWindowsHookEx 1 hook_handle 29@        
    end
end

 /*
//call @LockKeyboardAndMouseInput 1 lock_state 1
//call @LockKeyboardAndMouseInput 1 lock_state 0
:LockKeyboardAndMouseInput  // works only when ran as administrator in .exe version, maybe that's the reason why it doesn't work in game
0AA2: 31@ = load_library "User32.dll"
if 0AA4: 31@ = get_proc_address "BlockInput" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 31@ push 1 pop 0 bool_fBlockIt 0@ _returned 30@
   if 30@ > 0
   then 
   chatmsg "Success" -1
   //success
   else
   chatmsg "Failure" -1
   //failure
   {"If the function succeeds, the return value is nonzero.
   If input is already blocked, the return value is zero. To get extended error information, call GetLastError."} 
   end
end
0AA3: free_library 31@
ret 0
*/


:SetWindowsHookEx
{
    0@ _In_ int       idHook (hook type - WH_KEYBOARD_LL which is 13)
    1@ _In_ HOOKPROC  lpfn   (pointer to callback function)
    2@ _In_ HINSTANCE hMod   (idk, can be 0)
    3@ _In_ DWORD     dwThreadId  (idk, can be 0)
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "SetWindowsHookExA" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 4 pop 0 dwThreadId 3@ hMod 2@ lpfn 1@ idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Hooked successfully" -1
   else
   chatmsg "Failed to hook" -1
   end
else
chatmsg "Failed to find SetWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 1 29@


:UnhookWindowsHookEx
{
    0@ - hook handle
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "UnhookWindowsHookEx" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 1 pop 0 idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Unhooked successfully" -1
   else
   chatmsg "Failed to unhook" -1
   end
else
chatmsg "Failed to find UnhookWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 0
    
:KeyboardHookCallback // just returns 1              
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end

/*
:MouseHookCallback
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end
*/

:GetThreadID  // used to make local hook (global hook would not allow you to use keyboard after game crashes or if you forget to unhook it in the code)
0AA2: 31@ = load_library "kernel32.dll"
if 0AA4: 30@ = get_proc_address "GetCurrentThreadId" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 0 pop 0 _returnedThreadID 28@
else
chatmsg "Failed to find GetCurrentThreadId function" -1
end
0AA3: free_library 31@
ret 1 28@

I managed to do it for keyboard but not for mouse, idk why it doesn't work for mouse, you could try searching "camera lock" / "set actor lock" opcodes + if cursor is visible then get its position and repetatively set it back to it unless you want to "unfreeze" the mouse

damn monster
stahp
 

CSprite

Active member
Joined
Nov 12, 2016
Messages
94
Reaction score
7
monday said:
Code:
{$CLEO}
0000:

repeat
wait 50
until 0AFA:  is_samp_available


while true
wait 0

    if key_down 48 // key 0 (not numpad)
    then
        while key_down 48  // necessary because key needs to be unpressed before setting the hook (because callback will ignore "key_up" message and assume it's pressed all the time, resulting in another hook after unhook)
        wait 1
        end

        0AC6: 30@ = label @KeyboardHookCallback offset
        call @GetThreadID 0 _threadID 28@

        call @SetWindowsHookEx 4 type 2{WH_KEYBOARD - local} /*13{WH_KEYBOARD_LL - global}*/ callback 30@ hinstance 0 thread_id 28@ _returnedHookHandle 31@    // if your game crashes while hooked (using global hook) use ctrl+alt+del
                                                                                                                             
        printf "Keyboard input should be ~R~disabled ~W~now" 5000                        
        wait 5000
 
        call @UnhookWindowsHookEx 1 hook_handle 31@
        printf "Keyboard input should be ~G~enabled ~W~ again now" 2000
        
        
        // it just doesn't work for mouse for some reason (it works in .exe version in the same configuration I used for keyboard) 
        // maybe it's because of the way gta handles mouse input, just a guess (or I messed something up)       
        //0AC6: 30@ = label @MouseHookCallback offset
        //call @SetWindowsHookEx 4 type 14 {WH_MOUSE_LL} callback 30@ _returnedHookHandle 29@  
        //call @UnhookWindowsHookEx 1 hook_handle 29@        
    end
end

 /*
//call @LockKeyboardAndMouseInput 1 lock_state 1
//call @LockKeyboardAndMouseInput 1 lock_state 0
:LockKeyboardAndMouseInput  // works only when ran as administrator in .exe version, maybe that's the reason why it doesn't work in game
0AA2: 31@ = load_library "User32.dll"
if 0AA4: 31@ = get_proc_address "BlockInput" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 31@ push 1 pop 0 bool_fBlockIt 0@ _returned 30@
   if 30@ > 0
   then 
   chatmsg "Success" -1
   //success
   else
   chatmsg "Failure" -1
   //failure
   {"If the function succeeds, the return value is nonzero.
   If input is already blocked, the return value is zero. To get extended error information, call GetLastError."} 
   end
end
0AA3: free_library 31@
ret 0
*/


:SetWindowsHookEx
{
    0@ _In_ int       idHook (hook type - WH_KEYBOARD_LL which is 13)
    1@ _In_ HOOKPROC  lpfn   (pointer to callback function)
    2@ _In_ HINSTANCE hMod   (idk, can be 0)
    3@ _In_ DWORD     dwThreadId  (idk, can be 0)
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "SetWindowsHookExA" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 4 pop 0 dwThreadId 3@ hMod 2@ lpfn 1@ idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Hooked successfully" -1
   else
   chatmsg "Failed to hook" -1
   end
else
chatmsg "Failed to find SetWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 1 29@


:UnhookWindowsHookEx
{
    0@ - hook handle
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "UnhookWindowsHookEx" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 1 pop 0 idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Unhooked successfully" -1
   else
   chatmsg "Failed to unhook" -1
   end
else
chatmsg "Failed to find UnhookWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 0
    
:KeyboardHookCallback // just returns 1              
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end

/*
:MouseHookCallback
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end
*/

:GetThreadID  // used to make local hook (global hook would not allow you to use keyboard after game crashes or if you forget to unhook it in the code)
0AA2: 31@ = load_library "kernel32.dll"
if 0AA4: 30@ = get_proc_address "GetCurrentThreadId" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 0 pop 0 _returnedThreadID 28@
else
chatmsg "Failed to find GetCurrentThreadId function" -1
end
0AA3: free_library 31@
ret 1 28@

I managed to do it for keyboard but not for mouse, idk why it doesn't work for mouse, you could try searching "camera lock" / "set actor lock" opcodes + if cursor is visible then get its position and repetatively set it back to it unless you want to "unfreeze" the mouse

What language is that ?  :sadpepe: :sadpepe: :sadpepe:
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
157
@springfield
I thought the same but I have no idea how to do it...

@CSprite
It's adapted to cleo from this:
https://www.unknowncheats.me/forum/c-and-c-/83707-setwindowshookex-example.html
that's the method I used: http://ugbase.eu/Thread-Tutorial-Using-functions-from-Windows-libraries

Only the HookCallback function content is replaced with "return 1;"
 

Ezel

Active member
Joined
Dec 6, 2017
Messages
134
Reaction score
18
Location
Syria
monday said:
Code:
{$CLEO}
0000:

repeat
wait 50
until 0AFA:  is_samp_available


while true
wait 0

    if key_down 48 // key 0 (not numpad)
    then
        while key_down 48  // necessary because key needs to be unpressed before setting the hook (because callback will ignore "key_up" message and assume it's pressed all the time, resulting in another hook after unhook)
        wait 1
        end

        0AC6: 30@ = label @KeyboardHookCallback offset
        call @GetThreadID 0 _threadID 28@

        call @SetWindowsHookEx 4 type 2{WH_KEYBOARD - local} /*13{WH_KEYBOARD_LL - global}*/ callback 30@ hinstance 0 thread_id 28@ _returnedHookHandle 31@    // if your game crashes while hooked (using global hook) use ctrl+alt+del
                                                                                                                             
        printf "Keyboard input should be ~R~disabled ~W~now" 5000                        
        wait 5000
 
        call @UnhookWindowsHookEx 1 hook_handle 31@
        printf "Keyboard input should be ~G~enabled ~W~ again now" 2000
        
        
        // it just doesn't work for mouse for some reason (it works in .exe version in the same configuration I used for keyboard) 
        // maybe it's because of the way gta handles mouse input, just a guess (or I messed something up)       
        //0AC6: 30@ = label @MouseHookCallback offset
        //call @SetWindowsHookEx 4 type 14 {WH_MOUSE_LL} callback 30@ _returnedHookHandle 29@  
        //call @UnhookWindowsHookEx 1 hook_handle 29@        
    end
end

 /*
//call @LockKeyboardAndMouseInput 1 lock_state 1
//call @LockKeyboardAndMouseInput 1 lock_state 0
:LockKeyboardAndMouseInput  // works only when ran as administrator in .exe version, maybe that's the reason why it doesn't work in game
0AA2: 31@ = load_library "User32.dll"
if 0AA4: 31@ = get_proc_address "BlockInput" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 31@ push 1 pop 0 bool_fBlockIt 0@ _returned 30@
   if 30@ > 0
   then 
   chatmsg "Success" -1
   //success
   else
   chatmsg "Failure" -1
   //failure
   {"If the function succeeds, the return value is nonzero.
   If input is already blocked, the return value is zero. To get extended error information, call GetLastError."} 
   end
end
0AA3: free_library 31@
ret 0
*/


:SetWindowsHookEx
{
    0@ _In_ int       idHook (hook type - WH_KEYBOARD_LL which is 13)
    1@ _In_ HOOKPROC  lpfn   (pointer to callback function)
    2@ _In_ HINSTANCE hMod   (idk, can be 0)
    3@ _In_ DWORD     dwThreadId  (idk, can be 0)
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "SetWindowsHookExA" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 4 pop 0 dwThreadId 3@ hMod 2@ lpfn 1@ idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Hooked successfully" -1
   else
   chatmsg "Failed to hook" -1
   end
else
chatmsg "Failed to find SetWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 1 29@


:UnhookWindowsHookEx
{
    0@ - hook handle
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "UnhookWindowsHookEx" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 1 pop 0 idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Unhooked successfully" -1
   else
   chatmsg "Failed to unhook" -1
   end
else
chatmsg "Failed to find UnhookWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 0
    
:KeyboardHookCallback // just returns 1              
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end

/*
:MouseHookCallback
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end
*/

:GetThreadID  // used to make local hook (global hook would not allow you to use keyboard after game crashes or if you forget to unhook it in the code)
0AA2: 31@ = load_library "kernel32.dll"
if 0AA4: 30@ = get_proc_address "GetCurrentThreadId" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 0 pop 0 _returnedThreadID 28@
else
chatmsg "Failed to find GetCurrentThreadId function" -1
end
0AA3: free_library 31@
ret 1 28@

I managed to do it for keyboard but not for mouse, idk why it doesn't work for mouse, you could try searching "camera lock" / "set actor lock" opcodes + if cursor is visible then get its position and repetatively set it back to it unless you want to "unfreeze" the mouse
oh boi

you suprise me everytiem  :sadpepe:
 

CSprite

Active member
Joined
Nov 12, 2016
Messages
94
Reaction score
7
monday said:
@springfield
I thought the same but I have no idea how to do it...

@CSprite
It's adapted to cleo from this:
https://www.unknowncheats.me/forum/c-and-c-/83707-setwindowshookex-example.html
that's the method I used: http://ugbase.eu/Thread-Tutorial-Using-functions-from-Windows-libraries
Only the HookCallback function content is replaced with "return 1;"

:sadpepe:  :sadpepe: :sadpepe: :sadpepe: :sadpepe: 
I`ll stay in my playzone aka game guardian lua scripts for shitty android games .
:sadpepe:  :sadpepe: :sadpepe: :sadpepe: :sadpepe:
 

user88

Well-known member
Joined
Jun 29, 2017
Messages
426
Reaction score
165
Location
LINK CLEO DICE HACK HERE!
monday said:
Code:
{$CLEO}
0000:

repeat
wait 50
until 0AFA:  is_samp_available


while true
wait 0

    if key_down 48 // key 0 (not numpad)
    then
        while key_down 48  // necessary because key needs to be unpressed before setting the hook (because callback will ignore "key_up" message and assume it's pressed all the time, resulting in another hook after unhook)
        wait 1
        end

        0AC6: 30@ = label @KeyboardHookCallback offset
        call @GetThreadID 0 _threadID 28@

        call @SetWindowsHookEx 4 type 2{WH_KEYBOARD - local} /*13{WH_KEYBOARD_LL - global}*/ callback 30@ hinstance 0 thread_id 28@ _returnedHookHandle 31@    // if your game crashes while hooked (using global hook) use ctrl+alt+del
                                                                                                                             
        printf "Keyboard input should be ~R~disabled ~W~now" 5000                        
        wait 5000
 
        call @UnhookWindowsHookEx 1 hook_handle 31@
        printf "Keyboard input should be ~G~enabled ~W~ again now" 2000
        
        
        // it just doesn't work for mouse for some reason (it works in .exe version in the same configuration I used for keyboard) 
        // maybe it's because of the way gta handles mouse input, just a guess (or I messed something up)       
        //0AC6: 30@ = label @MouseHookCallback offset
        //call @SetWindowsHookEx 4 type 14 {WH_MOUSE_LL} callback 30@ _returnedHookHandle 29@  
        //call @UnhookWindowsHookEx 1 hook_handle 29@        
    end
end

 /*
//call @LockKeyboardAndMouseInput 1 lock_state 1
//call @LockKeyboardAndMouseInput 1 lock_state 0
:LockKeyboardAndMouseInput  // works only when ran as administrator in .exe version, maybe that's the reason why it doesn't work in game
0AA2: 31@ = load_library "User32.dll"
if 0AA4: 31@ = get_proc_address "BlockInput" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 31@ push 1 pop 0 bool_fBlockIt 0@ _returned 30@
   if 30@ > 0
   then 
   chatmsg "Success" -1
   //success
   else
   chatmsg "Failure" -1
   //failure
   {"If the function succeeds, the return value is nonzero.
   If input is already blocked, the return value is zero. To get extended error information, call GetLastError."} 
   end
end
0AA3: free_library 31@
ret 0
*/


:SetWindowsHookEx
{
    0@ _In_ int       idHook (hook type - WH_KEYBOARD_LL which is 13)
    1@ _In_ HOOKPROC  lpfn   (pointer to callback function)
    2@ _In_ HINSTANCE hMod   (idk, can be 0)
    3@ _In_ DWORD     dwThreadId  (idk, can be 0)
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "SetWindowsHookExA" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 4 pop 0 dwThreadId 3@ hMod 2@ lpfn 1@ idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Hooked successfully" -1
   else
   chatmsg "Failed to hook" -1
   end
else
chatmsg "Failed to find SetWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 1 29@


:UnhookWindowsHookEx
{
    0@ - hook handle
}
0AA2: 31@ = load_library "user32.dll"
if 0AA4: 30@ = get_proc_address "UnhookWindowsHookEx" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 1 pop 0 idHook 0@ _returned 29@
   if 29@ > 0
   then 
   //chatmsg "Unhooked successfully" -1
   else
   chatmsg "Failed to unhook" -1
   end
else
chatmsg "Failed to find UnhookWindowsHookEx function" -1
end
0AA3: free_library 31@
ret 0
    
:KeyboardHookCallback // just returns 1              
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end

/*
:MouseHookCallback
hex          
B8 01 00 00 00 // mov eax 1
C2 0C 00// ret (?)
end
*/

:GetThreadID  // used to make local hook (global hook would not allow you to use keyboard after game crashes or if you forget to unhook it in the code)
0AA2: 31@ = load_library "kernel32.dll"
if 0AA4: 30@ = get_proc_address "GetCurrentThreadId" library 31@ //https://msdn.microsoft.com/en-us/library/ms646290%28VS.85%29.aspx
then
   0AA7: 30@ push 0 pop 0 _returnedThreadID 28@
else
chatmsg "Failed to find GetCurrentThreadId function" -1
end
0AA3: free_library 31@
ret 1 28@

I managed to do it for keyboard but not for mouse, idk why it doesn't work for mouse, you could try searching "camera lock" / "set actor lock" opcodes + if cursor is visible then get its position and repetatively set it back to it unless you want to "unfreeze" the mouse

thx now i can make b1g hooke samp 2k18 keyhokz
cleo
 
Status
Not open for further replies.
Top