flat assembler
Message board for the users of flat assembler.

Index > Windows > Example: Global Keyboard Hook

Author
Thread Post new topic Reply to topic
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Jun 2010, 01:16
I just found some old hooking examples i wrote in Cpp years ago.
Recently i have been porting them to FASM for fun.
Here is the first example, global keyboard hooking.
It is a library only (no interface) so do as you wish with it.
Upon request i can supply sample interface (if ok with moderators)

Useage:
Create win32 GUI application.
Import the library: KBL.DLL and function: SetKeyboardHook
Create main window and supply a user defined message handler.
Call SetKeyboardHook with handle of window to be notified and message id.
Any keystrokes will then be passed to the windows message procedure.
The wParam contains the virtual key code.
The lParam contains the flags.
See MSDN KeyboardProc for more details.

Have fun Razz

PS: Please report any mistakes or errors (i did test it on xp2)


Description: Global Keyboard Hook
Download
Filename: kbl.asm
Filesize: 2.09 KB
Downloaded: 447 Time(s)


_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 30 Jun 2010, 01:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20486
Location: In your JS exploiting you and your system
revolution 30 Jun 2010, 01:24
Also note that one cannot incorporate this code into the main app because:
Win32 help: SetWindowsHookEx wrote:
All system hook functions must be in libraries.
Q: Does this code work for users without Admin rights?
Post 30 Jun 2010, 01:24
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Jun 2010, 01:44
Yep, thanks for adding that.
Note that it must be global with static (shared) data.
revolution wrote:

Q: Does this code work for users without Admin rights?

Good question, i will try, but i think no problem...

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 30 Jun 2010, 01:44
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Jun 2010, 02:22
Ok, i tried it in guest account and it works perfectly.
I modified MINIPAD example to use as interface.
If its ok with mods, i will share it to ease the pain...
Post 30 Jun 2010, 02:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.