Message board for the users of flat assembler.
> Windows > keyboard hook
example on a system wide keyboard hook, allowing you to disable keys and such. msdn docs say hook procs must be in a dll, works here in the exe itself with no problems on win2k. in this example the right and left windows logo keys are disabled
|03 Jun 2004, 08:14||
Was it supposed to run in Win98? It doesn't...
|03 Jun 2004, 11:11||
cant test on anything but win2k, msdn says
possibly the hookproc must be in a dll on 95/98 systems. id like to make a dll, but ive no idea how to make a dll export a callback function, anyone have an example?
|03 Jun 2004, 14:34||
oh i see it now..
try using WH_KEYBOARD on 95/98, tho it may not capture all the same keys
|03 Jun 2004, 14:36||
A hooked (witch MakeHook) function window receives WM_KEY message every time a key is depressed. wParam contains ASCII code. I wrote this a long time ago, so it may be buggy, but I think some parts may be useful.
[code]format PE GUI DLL
section '.code' code readable executable shareable
mov eax,1 ; successful initialization
proc MakeHook,hwnd ;returns 0 when error
KeyState rb 256
cBufor rb 4
push eax ;save return vaulue
test [lParam],80000000h ;is key being released
movzx eax,byte[lParam+2] ;scan code
push eax ;push character count
pop eax ;pop character count
pop eax ;restore ruturn value
section '.data' data readable writeable shareable
hModule dd ?
hHook dd ?
hHookedWnd dd ?
section '.idata' import data readable writeable
section '.edata' export data readable
export 'KEY.DLL',\ ;dll name
section '.reloc' fixups data readable discardable[/code]
|03 Jun 2004, 15:10||
msdn docs say hook procs must be in a dll
the reason for using a dll is due to it's ability to be accessed many times by many programs in a multitasking environment. Though, a dll is not required.
It is better to be on the right side of the devil than in his path.
|26 Jul 2004, 00:49||
The reason most global hooks must be in DLLs is simple - the hooks need to execute in the context of multiple processes, and thus the OS has to inject hook DLLs into those process address spaces.
It's pretty easy to determine if a global hook needs to be put in a DLL or not - try keeping it in your app, and install the hook. If the system comes crashing down, you need to put it in a DLL
|26 Jul 2004, 03:10||
works fine on 2k/xp in this example, no dll used
|26 Jul 2004, 03:26||
PlatformSDK has this to say:
...so it sounds like, officially too, no DLL is needed for this hook.
|26 Jul 2004, 03:46||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar.
Powered by rwasa.