The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RHL on February 07, 2012, 09:30:59 PM

Title: How to make a hook global, (HSHELL_WINDOWCREATED , ...)
Post by: RHL on February 07, 2012, 09:30:59 PM
Hello all, for a week I have problems, I am trying to program
a global hook to capture messages on windows like these:

HCBT_ACTIVATE
HCBT_CREATEWND

or

HSHELL_REDRAW
HSHELL_WINDOWACTIVATED
HSHELL_WINDOWCREATED

I detect when an application is active (the window), when destroyed, and among other on windows.

I tried to make a hook with SetWindowLong api, but that does not api
global hook (not for all windows, only one)

then try the api SetWindowHookEx with the constants:
WH_CBT
WH_SHELL

but Neither I achieve , can you help me please, I have time with the problem and I'm annoyed  :(
Title: Re: How to make a hook global, (HSHELL_WINDOWCREATED , ...)
Post by: qWord on February 07, 2012, 10:20:37 PM
you must place the hook procedure in a DLL - see the documentation. Using your favourite search engine, you will find more than enough examples (c,c++,...)
Title: Re: How to make a hook global, (HSHELL_WINDOWCREATED , ...)
Post by: RHL on February 07, 2012, 11:27:27 PM
yes thanks, look at an example using a dll. but do not want to use a dll, it seems simple I want to do, but it not is  :(
Title: Re: How to make a hook global, (HSHELL_WINDOWCREATED , ...)
Post by: ToutEnMasm on February 08, 2012, 07:17:33 AM
there is RegisterShellHookWindow
http://www.asmfr.com/codes/HOOK-SANS-DLL-DETECTER-DEMARRAGE-APPLICATION-REGISTERSHELLHOOKWINDOW_52639.aspx
Title: Re: How to make a hook global, (HSHELL_WINDOWCREATED , ...)
Post by: RHL on February 09, 2012, 02:09:14 AM
thanks! I found!  :clap: