Solved

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

Posted on 2008-10-28
2
1,205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 22826546
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
ID: 22830769
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
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…

635 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