Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-28
2
Medium Priority
?
1,216 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 750 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 750 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

ATEN's HDBaseT Presentation at InfoComm 2017

Hear ATEN Product Manager YT Liang review HDBaseT technology, highlighting ATEN’s latest solutions as they relate to real-world applications during her presentation at the HDBaseT booth at InfoComm 2017.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

715 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