X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
To: =?UTF-8?B?QXVyaW1hcyDEjGVybml1cw==?= <aurisc4@gmail.com>,
   cygwin@cygwin.com
Date: Fri, 03 Oct 2008 13:12:09 +0100
Subject: Re: non-persistent DllMain
Envelope-To: aurisc4@gmail.com,cygwin@cygwin.com
References: <48E5FB68.1090104@liddicott.com> <48E5FE38.7040400@gmail.com>
Message-ID: <48E60C19.8070409@liddicott.com>
From: "Sam Liddicott" <sam@liddicott.com>
User-Agent: Thunderbird 2.0.0.17 (X11/20080925)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m93CE0xR020066

[Forgot to copy this to the list, + new question]

* Aurimas Černius wrote, On 03/10/08 12:12:
> If I'm not wrong, GetModuleHandle(NULL) returns the handle of the
> current module (should be DLL handle, when called from DLL). So saving
> handle to a global variable is not needed.
>
thanks!
>
>
> I think that DllMain is called when DLL is not yet completely loaded,
> so it is impossible to set values of global variables. Isn't it?
>
Makes sense, but most examples state to store hModule at this point...
however your suggestion was good, and I can now hook wndprocs.

Sadly it then crashes explorer.exe, but thats another problem for me to
look into.

Thanks very much.

I can now hook the wndproc OK, but I don't think it is being called.
I test this by coding a tight loop (up to ten trillion or something) and
watching the load graph in process monitor.

I can make the load shoot up before I hook, and after I hook, and before
I call the hook, but if the loop is in the hookproc, the load never goes
high before it crashes.

It crashes when I do the first sendmessage after hooking.

Sam


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


