Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


PostMessage help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
blackmorpheus
Expert Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 159

PostPosted: Tue Mar 17, 2009 3:44 am    Post subject: PostMessage help Reply with quote

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 Very Happy

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
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Tue Mar 17, 2009 5:07 am    Post subject: Reply with quote

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
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Tue Mar 17, 2009 6:47 am    Post subject: Reply with quote

Code:
WINAPI __stdcall

I suggest you learn before copy-pasting code.
Back to top
View user's profile Send private message MSN Messenger
mStorm
Expert Cheater
Reputation: 0

Joined: 21 Feb 2009
Posts: 107

PostPosted: Tue Mar 17, 2009 9:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Tue Mar 17, 2009 9:29 am    Post subject: Reply with quote

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
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Mar 17, 2009 10:37 am    Post subject: Reply with quote

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
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Mar 17, 2009 3:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Tue Mar 17, 2009 7:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
blackmorpheus
Expert Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 159

PostPosted: Fri Mar 20, 2009 12:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites