Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - System hooks & DLL shared segmentsGreetings, I need the help of someone with a grasp on windows system hooks and DLL's. I have created a DLL containing a keyboard hook procedure. In another driver application I am loading the library, getting the procedure address and successfully calling SetWindowsHookEx to set up a global keyboard hook. My procedure then is intercepting all keystrokes throughout the system as expected. So far, so good. Since I want also to be able to call any other chained hook procedures, I also added an init function to the dll that gets the registered hook handle and stores it so that it can be passed to CallNextHookEx. The stored hook handle needs to be shared among all instances of the DLL, so I made the DLL's data segment shared. After making the data segment shared, however, my hook stopped working properly. It would intercept keystrokes in some applications only, while others would go unintercepted. Which applications are intercepted seems to vary. I have also noticed that sometimes applications would crash after having installed that hook. What problems could cause that shared data segment and could they be avoided without resorting to other methods of sharing data between DLL instances? Any comments and suggestions appreciated. Best regards, Dimitri Oct 24 2004
Dimitri Kaparis wrote:Greetings, I need the help of someone with a grasp on windows system hooks and DLL's. I have created a DLL containing a keyboard hook procedure. In another driver application I am loading the library, getting the procedure address and successfully calling SetWindowsHookEx to set up a global keyboard hook. My procedure then is intercepting all keystrokes throughout the system as expected. So far, so good. Since I want also to be able to call any other chained hook procedures, I also added an init function to the dll that gets the registered hook handle and stores it so that it can be passed to CallNextHookEx. The stored hook handle needs to be shared among all instances of the DLL, so I made the DLL's data segment shared. After making the data segment shared, however, my hook stopped working properly. It would intercept keystrokes in some applications only, while others would go unintercepted. Which applications are intercepted seems to vary. I have also noticed that sometimes applications would crash after having installed that hook. Oct 24 2004
|