• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Problems with WinSetHook

Started by Radek, 2009.01.19, 12:51:22

Previous topic - Next topic

Radek

I have written a keyboard remapper. The remapper is simple, it monitors WM_CHAR messages (using a system-wide input hook) and manipulates them according to the custom keyboard layout. The remapper used to work perfectly - with RC2. The remapper crashes the operating system with RC4 and RC5.
Something has happened between RC2 and RC4. The question is what happened?
Here are some details about the remapper:
(1) It consists of a control EXE and a DLL containing the hook. The EXE and the DLL communicate using posted messages and a named shared memory.
(2) The EXE allocates the shared memory, fills in keyboard data, creates an object window, and sets the hook.
(3) The DLL monitors the WM_CHAR messages and it also posts its requests to the object window. Every time a WM_CHAR is passing, the DLL gets (DosGetNamedSharedMem) the shared memory and processes the message. Then it frees (DosFreeMem) the shared memory and returns.
(4) When the user decides to quit the remapper, the object window is closed, the hook and the shared memory are released and the application exits.
(5) The application is written in OpenWatcom.
All this worked flawlessly in RC2. In RC4, I get a system crash: some windows on the screen get whitened and I can see some hard disk activity, which I should not see. Luckily, Ctrl-Alt-Del works. The problem has been traced to WinSetHook(), that's this call which causes the crash. As a next step, I installed the hook locally (I added an entryfield for testing and installed the hook with HMQ_CURRENT). Now, the hook works again but the whole app is useless.
Therefore, the hook works as a local hook but it does not work as a system-wide hook. What can be wrong?

warpcafe

Radek,

sorry this is just pure guessing:
Talking about "global hooks" and keyboard... there's eWP / xWP coming to mind. Perhaps a new release of any such used DLL within newer eCS RCs? Could be a DLL that is (now) incompatible with your type of "subclassing"...? Have you any contact to Mensys like developers forum or similar? Perhaps Roderick can tell? (One more thing on his list... sorry).

Cheers,
Thomas
"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy

Radek

No, I don't have such contact. My only connection to the web is here from my work - and I cannot reach even netlabs.org because it uses XML and my micro$oft IE cannot process it.
At any rate, the problem will be with processing the hook entry during WinSetHook(). Perhaps something that was possible yesterday but what isn't possible today. One possible reason could be not shared DGROUP - OpenWatcom does not support shared DGROUP in DLLs. Even if the hook does not have any global data and it does everything on the stack (few bytes) and on the shared memory, the not shared DGROUP coud cause problems.
Okay, I can redo the hook in assembler but that's exactly what I wanted to avoid :)

EugeneGorbunoff

DevCon (http://ecomstation.ru/projects/developer/?action=tools)
-> XRay -> source code -> example how to use WinSetHook

Radek

Yes, it's the app which have been described in an EDM/2 article. The hook is used that way.