Setwindowshook msdn




















If you realy want to use a global hook and monitor all 32 and 64 Bit programms, then the first thing you should do is writing an injector DLL as an out of process COM server. That injector and also your hook DLL must be compiled for both 32 and 64 bit. In your hook DLL create a globally shared memory section and make it accessible systemwide.

Shared memory sections have a string by which they can be accessed. All you need to do is to pass the string of your shared memory back via surrogate when you inject the DLL EDIT : Actualy you need to to allocate globally shared memory for the string. The whole mechanism is hidden inside the injector though. Or you could just give out the string by using an export function in the DLL, but that would make the memory accessible to everybody.

To lock the shared memory section you should use a globally shared mutex which lays in the same memory section. The best thing is to wrap an interface around this which manages everything. If you want to pass interface pointers as parameters in or out of the DLL, then the best way of doing it is by using the injector via surrogate as that marshalls objects across process boundaries.

Of course the surrogate must be aware of the interface, you would have to define it in IDL. You must be very good and efficient in coding to counter the performance losses in applications that are handling window messages in combination with Direct3D rendering, because you can mess up a lot and there very millisecond counts. Yes i wasnt paying enough attention to the addresses.

It can be done either way but it should be done inside the DLL. The reason for this is a design issue. If you want to write an injector which you definitly need when you are dealing with hooks, then you need to call SetWindowsHookEx from inside the DLL.

Beleave me i spend years on studying that matter and after endless designs that was the best there was. You need to keep everything modular as much as possible. The content you requested has been removed.

Ask a question. Quick access. Search related threads. Remove From My Forums. Asked by:. Archived Forums. Visual C. Sign in to vote. More information about it at MSDN.

Read more about it at MSDN. Monday, May 28, PM. Sam Hobbs SimpleSamples. The call is made by sending a message to the thread that installed the hook. Therefore, the thread that installed the hook must have a message loop. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. In this article. The repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key. There are multiple answers.

With this restriction a process in the job object can set hooks only on processes that are also in the job. But setting this flag also means that you can't access any user handles HWND, etc created by processes not associated with the job. If your application has some UI, then you have a lot of work to do if you want to fix everything that is going to break! No icons, no cursors, can't access the desktop window. UserHandleGrantAccess can help you here On vista it's a little bit easier, you can run the application with a low integrity level token and User Interface Privilege Isolation UIPI will do the work for you.

Internet Explorer 7 is using it to be more secure. It will prevent your application from setting hooks on other applications running with a higher integrity level. What if you can't use any of them? Well, if your application is running with a restricted token, you may not have to worry about this at all.

A restricted token is a stripped down version of your token created with the CreateRestrictedToken api. The SidsToRestrict array passed to the function must be non-null.



0コメント

  • 1000 / 1000