🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Hooking another application

#17282
From: Remy Lebeau (TeamB)
Date: Thu, 27 Mar 2003 20:36
33 lines
2144 bytes
"nicolasr" <nicolasrATSIGNgmx.net> wrote in message
news:3e834e27$1@newsgroups.borland.com...

> I tried WH_GETMESSAGE together with PostMessage()
> as you suggested and this works well now.

Just be careful with PostMessage().  Keep in mind that it returns
immediately, it does not wait for the message to actually be processed.  So
if you're passing pointers, especially local ones as your earlier samples
with COPYDATASTRUCT were doing, and your code exits and frees the data
before the receiver gets a chance to process the message, the receiver is
going to blow up from accessing invalid memory.

> The hook callback is called for other messages (redraw
> etc.)

Those are posted to the message queue, thus the WH_GETMESSAGE hook would
pick them up.

> but never for my SendMessage().

Did you call SetWindowsHookEx() a second time to register the WH_CALLWNDPROC
hook as well?

> Which window proc is actually hooked, the main form,
> the application window?

All of the procedures for all of the windows associated with the thread ID
you specified to SetWindowsHookEx().


Gambit
Technical Details
Message-ID: <3e835e66$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!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
References: <3e824b00@newsgroups.borland.com> <3e824e7e$1@newsgroups.borland.com> <3e834e27$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c5183b6fe95bcc6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-27 12:33:53 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e824b00@newsgroups.borland.com> <3e824e7e$1@newsgroups.borland.com> <3e834e27$1@newsgroups.borland.com>
Subject: Re: Hooking another application
Date: Thu, 27 Mar 2003 12:36:07 -0800
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3e835e66$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048796774 207.175.226.26 (27 Mar 2003 12:26:14 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!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