🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: hook / global hook question

#2900
From: Remy Lebeau (TeamB)
Date: Sat, 28 Oct 2006 06:24
32 lines
2349 bytes
"Jeff Kish" <kishjjrjj@charter.net> wrote in message
news:fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com...

> I see Matt Pietraks articel from 1997 about how to hook mouse
> messages globally. I hear there is alot of overhead because the
> dll gets loaded with every application.

I don't know if I would call it "alot" of overhead, but a global hook DLL
does get injected into every running process, and can cause each application
to slow down if the hook is not performing efficient operations.

> Is there any way to code it up so it only gets loaded with
> selected apps

You would need to code the DLL's DllEntryPoint() function to dynamically
determine the application that is currently loading it, and then return
FALSE to cancel the loading if needed.  You can use GetModuleFileName(),
specifying NULL as the module handle, to get the filename of the process
that is currently loading the DLL.

A less intrusion approach would be for your main application to monitor all
running processes, and then install thread-specific hooks for each desired
application when they start up.  Enumerating the running processes will give
you the thread IDs of each process, and SetWindowsHookEx() can be used to
set up a single hook in a specific thread of an external application.  Since
your main application, not the DLL, would be filtering the processe and
threads, the DLL would not be injected into unwanted applications, thus
reducing system resource usage.


Gambit
Technical Details
Message-ID: <4542f7f0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2c3bbe422461484a
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com>
Subject: Re: hook / global hook question
Date: Fri, 27 Oct 2006 23:24:04 -0700
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 69.169.4.232
Message-ID: <4542f7f0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1162016752 69.169.4.232 (27 Oct 2006 23:25:52 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail