Hey what's up. I know I need to implement a hook in order to catch messages from another window outside my application's process. The only problem is, there are multiple windows to work with and I plan on using GetClassName to sift through the mass of messages. I don't know what kind of hook to use, and I know the code is so simple. Also, how do I make a routine call to a callback. Like when the calling process does 'invoke startHook,ADDR myProc', I want to be able to call the myProc routine from the dll's code. I've looked at the examples here on the site, and elsewhere, but they're either bloated with extras and it's too hard for me to weed out only what I need. I know the code is SO simple, I just can't seem to get it. I'm a bit stupid here... Is it possible to get the process id of a program that isn't started with my application, and set a hook to catch messages only from that process? I don't know.. I'm so lost, and I can do so much with this.

Masm32 - winxp sp1

Posted on 2003-08-28 16:16:02 by Xeek
I do a system wide cbt hook and then subclassing the windows.
to get the process id use GetWindowThreadProcessId
Posted on 2003-08-28 16:54:32 by Jnrz
I got an example (c++) that uses
LRESULT CALLBACK ShellDll_MainHook(int nCode, WPARAM wParam, LPARAM lParam)

.
.
HWND hwndToNewWindow = reinterpret_cast<HWND>(wParam);


what struct is passed to wParam? How do I make asm code 'walk' through the values in the struct? Or what is it, heh.

The example uses SetWindowLong, I know I should try b4 I ask, but I heard you couldn't use SetWindowLong on other processes. It uses a WH_CBT hook w/ HCBT_CREATEWND to watch for 'new' windows, then it uses SetWindowLong...

Posted on 2003-08-29 17:08:56 by Xeek
I example is for subclassing the msn right ?

wParam is not a struct, it is the handle of the window that is gonna be created
Posted on 2003-08-29 17:35:55 by Jnrz
yea, it's the one for msn, does it work... i mean if you were to build off the source...
no struct? this should make things easier ;)
Posted on 2003-08-29 17:37:18 by Xeek
that msn example does not work, it needs the variables to be shared
in c++ is #pragma something, I dont remember.
Posted on 2003-08-29 18:12:40 by Jnrz
GRRRRR.... :(
Posted on 2003-08-30 11:36:09 by Xeek
#pragma data_seg(".shared")

static HHOOK g_hHook = NULL; // handle to our hook
#pragma data_seg()
is it something like that, i don't have a clue :\
Posted on 2003-08-31 10:16:07 by Xeek
yap
thats for c++.
then you have to tell the linker that that segment is gonna be, rws
read, write, shared
Posted on 2003-08-31 16:07:54 by Jnrz
looks like i won't be translating it to asm :(

oh well, so the SetWindowLong api will work if that shit is shared?

I'm using vc++6, how do i set the linker options?
Posted on 2003-08-31 23:10:07 by Xeek
I dont know, I dont use VC++
but it is a #pragma thing too
Posted on 2003-09-01 01:59:23 by Jnrz