I am having problems using WH_JOURNALRECORD.
I have a program with a DLL. The DLL installs the hook with the hook procedure being within the DLL. It sets it up, returns a handle, yet the hook procedure never gets called and the system stops responding to input except CTRL-ESC and CTRL_ALT_DEL, which were meant to get ppl out of these situations and are luckily doing their job. Also, when I press the windows key, the start menu appears and the system does not repaint any windows covered by the start menu once I make it go away. I have read and re-read every word on SetWindowsHookEx, WH_JOURNALRECORD, and EVENTMSG and I don't see any problems.

Do you guys see what I'm doing wrong?

Here's the code:



...
invoke SetWindowsHookEx, WH_JOURNALRECORD, ADDR HookProc, hInstn, 0
mov hHook, eax
...

HookProc PROC USES edi Code:DWORD, wParam:DWORD, lParam:DWORD
LOCAL RecordFlag:DWORD
invoke CallNextHookEx, hHook, Code, wParam, lParam
.IF Code < 0
ret
.ENDIF
.IF Code == HC_ACTION && RecordFlag == 1
mov edi, lParam
ASSUME edi:ptr EVENTMSG
.IF [edi].message == WM_KEYDOWN
mov eax, [edi].paramH
.IF eax == VK_SHIFT
invoke MyFunction, 1F4h
.ENDIF
.ENDIF
ASSUME edi:nothing
.ELSEIF Code == HC_SYSMODALOFF
mov RecordFlag, 1
.ELSEIF Code == HC_SYSMODALON
mov RecordFlag, 0
.ENDIF
ret
HookProc ENDP
Posted on 2002-01-14 22:47:16 by Hel
I haven't checked out the doco on this type of hook (i am tired and can't be bothered), but are you supposed to return any value from your HookProc to say that the message has been processed? And what happens if you put the CallNextHookEx call at the end of your HookProc, so that it gets called after you have done your processing?
Posted on 2002-01-15 02:45:32 by sluggy
journal hooks resist not in a dll... they're inside your application...
i wrote a very simple to understand program to demonstrate the
use of those hook-types... that prog is very old and has a few
bugs... just enter "test" in the record input-box and hit "record",
after you stopped recording you can load your file and replay
everything you did while recording (mouse/keyboard actions).
Posted on 2002-01-15 07:10:26 by mob
Sluggy, i tried that and it didn't work. The API reference says you can put it wherever you want, so I put it at the beginning to optimize somewhat.

Mob, I read the documentation and it did say that it has to be in the application. However, I thought that because the DLL is loaded by my application, the code IS within the application process. I'm going to move it to the program itself and see what happens.

Your code works. It's pretty neat seeing the cursor move by itself!
Posted on 2002-01-15 08:59:53 by Hel
:) oh well... i had ALOT problems when playing with hooks...
and this terrible api-ref only compounds things... journal-hooks
are SO bad described there... unbelievable... hm, good luck.
Posted on 2002-01-15 09:36:04 by mob
it works. thanks mob!
Posted on 2002-01-15 09:50:09 by Hel