 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Tue Dec 02, 2008 12:28 pm Post subject: [vc++] createwindow/ex hook. |
|
|
Hello,
To start off, this has no sense. It's just for fun/to learn.
| Code: | | hook = SetWindowsHookEx(WH_CBT, (HOOKPROC)MyHookProc, hInst, 0); |
| Code: | LRESULT CALLBACK MyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode == HCBT_CREATEWND){
CBT_CREATEWND *pccw = (CBT_CREATEWND *)lParam;
char szBuf[30];
GetAtomName (LOWORD (pccw->lpcs->lpszClass), szBuf, 30);
if(strcmp(szBuf, "notepad") == 0){
return 1;
}
}
LRESULT lResult = CallNextHookEx(hook, nCode, wParam, lParam);
return lResult;
} |
(return 1 on HCBT_CREATEWND means it wont create it.)
My problem is, it doesn't get the class name correctly.
I already tried returning 1 on all..worked. But let's say I only want to return 1 if the class-name of the Window will be "notepad", how do I do that?
I've been working on that for hours now..without result.
Any idea what I am doing wrong? |
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Tue Dec 02, 2008 1:14 pm Post subject: |
|
|
| Code: | LRESULT CALLBACK MyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode < 0)
return CallNextHookEx(hook, nCode, wParam, lParam);
if (nCode == HCBT_CREATEWND)
{
char szBuf[30];
GetClassName((HWND)wParam, szBuf, sizeof(szBuf));
if (strcmp(szBuf, "Notepad") == 0)
{
return 1;
}
}
return CallNextHookEx(hook, nCode, wParam, lParam);
} |
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Tue Dec 02, 2008 2:15 pm Post subject: |
|
|
Awesome thanks.
But is there any way I can access the parameters used in CreateWindow from the lParam? |
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Tue Dec 02, 2008 5:28 pm Post subject: |
|
|
Yep you can still use the lParam, although it doesn't seem very useful to me or I'm doing something wrong. I tried changing the x, y pos for notepad but there was no affect, and the title doesn't seem to be set yet either. /shrugs
| Code: | | CREATESTRUCT *CWndStruc = ((CBT_CREATEWND *)lParam)->lpcs; |
| MSDN Remarks wrote: | Note Because the lpszClass member can contain a pointer to a local (and thus inaccessable) atom, do not obtain the class name by using this member. Use the GetClassName function instead.
Windows NT/2000/XP: You should access the data represented by the lpCreateParams member using a pointer that has been declared using the UNALIGNED type, because the pointer may not be DWORD aligned. |
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Dec 03, 2008 6:38 am Post subject: |
|
|
I see, that's why it didn't work for me.
Anyway, I tried changing some of the parameters too.
It didn't work on notepad for me either, but on firefox when it creates the Browser window. Set cx, cy, x and y to 100 and it showed up google in a little browser then x).
Thanks alot for all your help x) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|