🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17391

Hooking another application

#17391
From: nicolasr
Date: Thu, 27 Mar 2003 00:51
38 lines
2168 bytes
Hi,

I'm trying to hook a third party app to send it messages that can't be sent
accross process boundaries (f.e. messages that have pointers as
wParam/lParam, since the pointers are invalid in the other address space).

I wrote a DLL, a client app and a test server (simulating the third party
app)

The DLL exports:
SetHook(DWORD threadID)
Unhook()
and implements the hook callback function with the WH_GETMESSAGE hook type.


The client uses CreateProcess() to launch the server, then loads the DLL and
calls SetHook() with the threadID returned by CreateProcess(). I used
MessageBeep() to confirm that the DLL is loaded in the address space of the
server and that the hook callback is called for standard messages.

The problem is:
I want to send a custom message from the client to the server that should
arrive in the DLLs callback. So I defined a custom message in both the
client and the DLL:

#define HOOK_WM_TEST (WM_USER + 100)

Now I used FindWindow() in the client to get the window handle of the
servers main window. Then I did:

SendMessage(hwndServer, HOOK_WM_TEST, 0, 0);

But this messages does not arrive in the DLL callback function.

What am I doing wrong? Is WH_GETMESSAGE the correct hook type?

thanks for any idea,
Nick
Technical Details
Message-ID: <3e824b00@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c5183b6fe95bcc6,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-26 20:15:04 PST
From: "nicolasr" <nicolasrATSIGNgmx.net>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Hooking another application
Date: Thu, 27 Mar 2003 01:51:16 +0100
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 80.133.173.200
Message-ID: <3e824b00@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048726272 80.133.173.200 (26 Mar 2003 16:51:12 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail