Solved

SetWindowHookEx() from 32-bit app to get events from 64-bit apps.

Posted on 2008-10-28
2
1,147 Views
Last Modified: 2013-12-04
I have a management app which calls SetWindowsHookEx(WH_CALLWNDPROC, ..., ..., 0); This is in a 32-bit DLL which is loaded from my 32-bit app. On Vista-32, it works as expected. On Vista-64, the call succeeds and I do see the events from all 32-bit apps running on the same desktop.

However, I want to be able to see ALL events on the same desktop; not just those from 32-bit apps. MSDN sheds liight:

SetWindowsHookEx can be used to inject a DLL into another process. A 32-bit DLL cannot be injected into a 64-bit process, and a 64-bit DLL cannot be injected into a 32-bit process. If an application requires the use of hooks in other processes, it is required that a 32-bit application call SetWindowsHookEx to inject a 32-bit DLL into 32-bit processes, and a 64-bit application call SetWindowsHookEx to inject a 64-bit DLL into 64-bit processes. The 32-bit and 64-bit DLLs must have different names.

I suppose I could write a 64-bit helper app which my 32-bit app would run. That app could then load the 64-bit dll which could then hook the 64-bit apps. IPC would have to be tight, as I do not think my 32-bit app can call into a 64-bit DLL (or am I mistaken???). I was thinking of using WM_COPYDATA as the quick and simple IPC. I will be calling this often, but the return data is not very large.

Before I start down that road, is that the best way to do this? Is there some other way a 32-bit app can load a 64-bit DLL and call into it? Any ideas???? Since this app is a C++ Win32 app, any code snippets in C++ would be appreciated.

0
Comment
Question by:dddogget
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
Comment Utility
Well, since only 64bit processes can load 64bit DLLs, that's definitely the way to go. The code itself will be identical to your 32bit DLL loading code - just that it is compiled as a 64bit executable. Actually, quite simple...
0
 
LVL 41

Assisted Solution

by:graye
graye earned 250 total points
Comment Utility
Yes, two separate apps...   However, I don't think the WM_COPYDATA is gonna work across the 32-64 boundary.   I suspect  you'll need a more "formal" transport mechanism to marshal data between the two programs, ie Named Pipes, Sockets, etc
0

Featured Post

Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

Join & Write a Comment

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now