 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Tue Mar 17, 2009 3:44 am Post subject: PostMessage help |
|
|
Hey,
Im trying to make a bot for a game. I got a hooked myPostMessage from somewhere, but i can't seem to send messages to a game...
I tried it with Notepad but it just didnt work. Help me out please
Code: | #include <windows.h>
#include "main.h"
HINSTANCE hInst;
DWORD DLLFunc;
HWND hFlyff;
HWND hWnd;
bool bBotting = false;
__declspec(naked) BOOL WINAPI __stdcall myPostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
__asm
{
mov edi, edi
push ebp
mov ebp, esp
jmp [DLLFunc]
}
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReason*/)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
if (DLLFunc == NULL)
{
hInst = LoadLibrary("user32.dll");
DLLFunc = (DWORD)GetProcAddress(hInst, "PostMessageA") + 5;
}
if (hWnd == NULL)
{
hWnd = FindWindow(NULL, "Untitled - Notepad");
}
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)listenHotkeys, NULL, 0, NULL );
}
break;
case DLL_THREAD_ATTACH:
{
if (DLLFunc == NULL) {
hInst = LoadLibrary("user32.dll");
DLLFunc = (DWORD)GetProcAddress(hInst, "PostMessageA") + 5;
}
if (hWnd == NULL) {
hWnd = FindWindow(NULL, "Untitled - Notepad");
}
}
break;
case DLL_THREAD_DETACH:
{
if (hInst != NULL) {
// Un-Load DLL
FreeLibrary(hInst);
hInst = NULL;
}
}
break;
case DLL_PROCESS_DETACH:
{
if (hInst != NULL) {
// Un-Load DLL
FreeLibrary(hInst);
hInst = NULL;
}
}
break;
}
return TRUE;
}
void listenHotkeys()
{
while(1)
{
if(GetAsyncKeyState(VK_F9)&1)
{
bBotting = !bBotting;
}
if(bBotting)
{
hWnd = FindWindow(NULL, "Untitled - Notepad"); //Test WIndow
Sleep(4000);
MessageBox(hWnd, "lulz!", "lulz!" , MB_OK);
myPostMessageA(hWnd, WM_KEYDOWN,0x46, 0);
PostMessageA(hWnd, WM_KEYDOWN, 0x47,0);
}
}
} |
|
|
Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Tue Mar 17, 2009 5:07 am Post subject: |
|
|
You need a handle to the edit box in notepad,
Code: | HWND hWnd = FindWindowEx(FindWindow("Notepad", 0), 0, "Edit", 0);
PostMessage(hWnd, WM_KEYDOWN, 'F', 0); |
Use Spy++ or something similar to monitor window messages, try replicate them as best you can.
|
|
Back to top |
|
 |
Zerith Master Cheater
Reputation: 1
Joined: 07 Oct 2007 Posts: 468
|
Posted: Tue Mar 17, 2009 6:47 am Post subject: |
|
|
I suggest you learn before copy-pasting code.
|
|
Back to top |
|
 |
mStorm Expert Cheater
Reputation: 0
Joined: 21 Feb 2009 Posts: 107
|
Posted: Tue Mar 17, 2009 9:09 am Post subject: |
|
|
If the game uses DirectInput (DirectX), then you are out of luck. You will need to either use SendInput using DIK_ constants (like sendkeys, just at a lower level), or hook the directx dll and inject keys into the game that way.
if it doesn't use DirectX, and PostMessage works... you will need to use APISpy to find the correct window to post the message to. It's not always the one you'd expect.
|
|
Back to top |
|
 |
Bizarro I post too much
Reputation: 0
Joined: 01 May 2007 Posts: 2648
|
Posted: Tue Mar 17, 2009 9:29 am Post subject: |
|
|
i heard in the latest gg, postmessage is hooked on the ring0 as well.
i don't think a simple trampoline would work on that anymore. assuming u are working on a gg protected game
otherwise, fix ur code. i do see a lot of errors.
_________________
w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils |
|
Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Mar 17, 2009 10:37 am Post subject: |
|
|
Bizarro wrote: | i heard in the latest gg, postmessage is hooked on the ring0 as well.
i don't think a simple trampoline would work on that anymore. assuming u are working on a gg protected game
otherwise, fix ur code. i do see a lot of errors. |
GameGuard has been hooking NtUserPostMessage for quite some time, but it hasn't stopped the simple trampoline from working, so I don't know what the hell GameGuard is doing there...
_________________
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Mar 17, 2009 3:33 pm Post subject: |
|
|
mStorm wrote: | If the game uses DirectInput (DirectX), then you are out of luck. You will need to either use SendInput using DIK_ constants (like sendkeys, just at a lower level), or hook the directx dll and inject keys into the game that way.
if it doesn't use DirectX, and PostMessage works... you will need to use APISpy to find the correct window to post the message to. It's not always the one you'd expect. |
DirectX is not DirectInput
|
|
Back to top |
|
 |
manc Grandmaster Cheater
Reputation: 1
Joined: 16 Jun 2006 Posts: 551
|
Posted: Tue Mar 17, 2009 7:30 pm Post subject: |
|
|
slovach wrote: | mStorm wrote: | If the game uses DirectInput (DirectX), then you are out of luck. |
DirectX is not DirectInput |
He's just saying that its a subset of DirectX, not literally the same thing.
_________________
|
|
Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Fri Mar 20, 2009 12:12 pm Post subject: |
|
|
Hey Guys, thanks all!
I've got it working now. I used a very nice loader from someone who injected the dll else as soon as the process was found. (anyone has an opensource link to a VB one?)
But now i have another problem. I want to read the address of the HP, and press some key, but i don't know the pointer. I dont have any memory finding tools. They are all detected.
Anyone has some undetected cheat engine or another tool with which i can look for the values?
A better solution would be to totally disable GG ofcourse, but that's kinda hard.
|
|
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
|
|