| View previous topic :: View next topic |
| Author |
Message |
Wintermoot Expert Cheater
Reputation: 0
Joined: 08 Nov 2007 Posts: 198
|
Posted: Wed Aug 20, 2008 6:21 am Post subject: C++ PostMessageX crashing |
|
|
| Code: |
DWORD PMA = (DWORD)GetProcAddress(LoadLibrary("USER32.DLL"), "PostMessageA")+5;
_declspec(naked) BOOL PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
_asm {
mov edi, edi
push ebp
mov ebp, esp
jmp[PMA]
}
}
//Shitloads of useless code
HWND h = FindWindow( "MapleStoryClass", NULL );
while ( bAtkON )
{
UINT pewram;
LPARAM lparam;
pewram = MapVirtualKey( 0xA2, 0 );
lparam = ( pewram << 16 ) + 1;
PostMessageX( h, WM_KEYDOWN, 0xA2, lparam );
Sleep( 1000 );
PostMessageX( h, WM_KEYUP, 0xA2, lparam );
Sleep( 1000 );
}
|
It attacks about 17 times before crashing...
I have tested on:
Notepad (Different keys)
a Maple private server (Same keys and different keys... no difference)
Yes, I am using an injected DLL with AllocConsole()...
Yes, the loop is in a new thread...
Last edited by Wintermoot on Wed Aug 20, 2008 6:47 am; edited 1 time in total |
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Wed Aug 20, 2008 6:27 am Post subject: |
|
|
| Use pewram as your wParam
|
|
| Back to top |
|
 |
Wintermoot Expert Cheater
Reputation: 0
Joined: 08 Nov 2007 Posts: 198
|
Posted: Wed Aug 20, 2008 6:50 am Post subject: |
|
|
| Code: |
HWND h = FindWindow( "MapleStoryClass", NULL );
UINT pewram;
LPARAM lparam;
pewram = MapVirtualKey( 0xA2, 0 );
lparam = ( pewram << 16 ) + 1;
PostMessageX( h, WM_KEYDOWN, pewram, lparam );
Sleep( 1000 );
PostMessageX( h, WM_KEYUP, pewram, lparam );
Sleep( 1000 );
|
Attacks 17 times and crashes while finishing the 18th...
*bets that it is my compiler because MSVC++ 2008 Express = evil*
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Wed Aug 20, 2008 6:56 am Post subject: |
|
|
It attacks 17 times?
Hmm
| Code: |
HWND h = FindWindow( "MapleStoryClass", NULL );
UINT pewram = MapVirtualKey( 0xA2, 0 );
PostMessageX( h, WM_KEYDOWN, pewram, pewram << 16 );
PostMessageX( h, WM_KEYUP, pewram, pewram << 16 );
|
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Aug 20, 2008 7:41 am Post subject: |
|
|
Stack Overflow.
| Quote: | while ( bAtkON )
{
UINT pewram;
LPARAM lparam;
pewram = MapVirtualKey( 0xA2, 0 );
lparam = ( pewram << 16 ) + 1;
PostMessageX( h, WM_KEYDOWN, 0xA2, lparam );
Sleep( 1000 );
PostMessageX( h, WM_KEYUP, 0xA2, lparam );
Sleep( 1000 );
} |
By the way, there's no point of sending WM_KEYUP message, you can remove it.
|
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Wed Aug 20, 2008 8:26 pm Post subject: |
|
|
| Symbol wrote: | Stack Overflow.
| Quote: | while ( bAtkON )
{
UINT pewram;
LPARAM lparam;
pewram = MapVirtualKey( 0xA2, 0 );
lparam = ( pewram << 16 ) + 1;
PostMessageX( h, WM_KEYDOWN, 0xA2, lparam );
Sleep( 1000 );
PostMessageX( h, WM_KEYUP, 0xA2, lparam );
Sleep( 1000 );
} |
By the way, there's no point of sending WM_KEYUP message, you can remove it. |
You're partially correct. Look at his function prototype:
| Code: |
_declspec(naked) BOOL PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
He forgot WINAPI or __stdcall. The function doesn't clean up the stack and stack overflows. It's not the loop variables that are causing it. It's the PostMessageX function.
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Thu Aug 21, 2008 12:19 am Post subject: |
|
|
i think it's
jmp[PMA]
with that you are getting the address of PMA variable
just
jmp PMA
should work.. since PMA holds the address where to jump!
_________________
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Thu Aug 21, 2008 12:25 am Post subject: |
|
|
Its what Symbol and rapion said. The stack is over flowing because he did not label it __stdcall. Its just a silly mistake thats all. But also putting those variable declarations inside the while loop; it doesn't make it any easier on your computer.
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Aug 21, 2008 12:27 am Post subject: |
|
|
| pkedpker wrote: | i think it's
jmp[PMA]
with that you are getting the address of PMA variable
just
jmp PMA
should work.. since PMA holds the address where to jump! |
The compiler ignores the brackets if you didn't specify the size, and you can also simple do:
| Code: | mov eax,dword ptr ds:[PostMessageA]
add eax,5
jmp eax |
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Thu Aug 21, 2008 12:40 am Post subject: |
|
|
Right
| Code: |
__declspec(naked) BOOL WINAPI PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
__asm
{
mov edi, edi
push ebp
mov ebp, esp
jmp dword ptr ds:[PMA]
}
}
|
_________________
|
|
| Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Thu Aug 21, 2008 12:43 am Post subject: |
|
|
i don't like using hookhop. it tends to mess up ur real keyboard input sometimes and BSOD.
use callwindowproc instead. no need to modify USER32 or other dll
| Code: | | CallWindowProc(WndProc, hWnd, uMsg, wParam, lParam); | [/code]
_________________
w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils |
|
| Back to top |
|
 |
Wintermoot Expert Cheater
Reputation: 0
Joined: 08 Nov 2007 Posts: 198
|
Posted: Fri Aug 22, 2008 8:28 am Post subject: |
|
|
Thank you x0r. That is a much nicer method.
Everyone else, I solved it after seeing rapion's post but, I forgot to post... Thank you all for helping though.
|
|
| Back to top |
|
 |
|