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 


Finding Method of Keyboard Input?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Mapleblitzer
Master Cheater
Reputation: 0

Joined: 08 Apr 2007
Posts: 254

PostPosted: Tue Aug 18, 2009 9:31 pm    Post subject: Finding Method of Keyboard Input? Reply with quote

Hi,

I'm playing a game called rakion, which is protected by GG, and I'm trying to simulate keystrokes to create a bot, but I am unsure of the method of keyboard input. I've checked the dlls loaded, and I'm sure that it does not use Direct Input, and I've tried PostMessage (normal and bypassed) but neither produce a keystroke. What other methods could there be? If it helps, I think the game draws using GDI32.

Thanks.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Aug 19, 2009 12:32 am    Post subject: Reply with quote

probably either: WM_CHAR or WM_INPUT
Back to top
View user's profile Send private message
LolSalad
Grandmaster Cheater
Reputation: 1

Joined: 26 Aug 2007
Posts: 988
Location: Australia

PostPosted: Wed Aug 19, 2009 1:22 am    Post subject: Reply with quote

Google Images suggests this game is 3D... I seriously doubt that it draws with GDI.
_________________
Back to top
View user's profile Send private message MSN Messenger
Mapleblitzer
Master Cheater
Reputation: 0

Joined: 08 Apr 2007
Posts: 254

PostPosted: Wed Aug 19, 2009 8:16 am    Post subject: Reply with quote

Ah sorry, I don't know what I was thinking when I typed that out -_-. So if it uses directx, can I safely assume it uses directinput? And would it be easier to hook directinput rather than trying to bypass sendinput? I've heard sendinput is hooked in kernelmode, and I have not done driver programming before.
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Wed Aug 19, 2009 9:17 am    Post subject: Reply with quote

Why don't you unpack the .exe and look for imports from dinput
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Aug 19, 2009 7:42 pm    Post subject: Reply with quote

Mapleblitzer wrote:
So if it uses directx, can I safely assume it uses directinput?


no, not really.
Back to top
View user's profile Send private message
Mapleblitzer
Master Cheater
Reputation: 0

Joined: 08 Apr 2007
Posts: 254

PostPosted: Thu Aug 20, 2009 10:50 pm    Post subject: Reply with quote

Ok, I unpacked it and got the following dlls imported: keyhook.dll (looked into it, hooks ctrl and the alt key to stop it from working),msvcp71.dll and msvcr71.dll. Did I unpack it wrong? Should there be a d3d9 dll somewhere too?

I think I'm going to try to just do postmessage with WM_INPUT and see what happens. How do I get a handle to a struct? I'm supposed to fill the lParam with it.

Thanks for the advice.
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Aug 21, 2009 10:23 am    Post subject: Reply with quote

You could also try WM_KEYDOWN.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Aug 21, 2009 10:57 pm    Post subject: Reply with quote

smartz993 wrote:
You could also try WM_KEYDOWN.


I'd be somewhat doubtful of this, unless the developer is retarded.

Processing WM_CHAR has the benefit of allowing you to support different keyboard layouts.
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Aug 21, 2009 11:52 pm    Post subject: Reply with quote

slovach wrote:
smartz993 wrote:
You could also try WM_KEYDOWN.


I'd be somewhat doubtful of this, unless the developer is retarded.

Processing WM_CHAR has the benefit of allowing you to support different keyboard layouts.


I guess certain nex developers are retarded. Go figure.
Back to top
View user's profile Send private message
Mapleblitzer
Master Cheater
Reputation: 0

Joined: 08 Apr 2007
Posts: 254

PostPosted: Sat Aug 22, 2009 11:05 pm    Post subject: Reply with quote

hmm, i've tried WM_CHAR and WM_KEYDOWN, but they don't seem to work. Here's the code I have, some is clearly not mine (getting the hwid by stepping the process list).

Code:
_declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
   _asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[PMA]
   }
}

DWORD WINAPI BotThread(LPVOID lpParam)
{
   PMA = (DWORD)GetProcAddress(GetModuleHandle("user32.dll"),"PostMessageA")+5;
   PROCESSENTRY32 entry;
   entry.dwFlags = sizeof(PROCESSENTRY32);
   HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);
   if (Process32First(snap,&entry) == TRUE)
   {
      while(Process32Next(snap,&entry) == TRUE)
      {
         if(_stricmp(entry.szExeFile,"Rakion.bin")==0)
         {
            hRakion = (HWND)OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE,FALSE,entry.th32ProcessID);
            char buffer[MAX_PATH];
            sprintf_s(buffer,MAX_PATH,"%X",hRakion);
            MessageBox(0,buffer,0,0);
         }
      }
   }

   while(true)
   {
      if(GetAsyncKeyState(0x30)&1) //0 key
      {
         _PostMessageA(hRakion,WM_KEYDOWN,0x57,0); //"W" key
      }
      if(GetAsyncKeyState(0x31)&1)// 1 key
      {
         _PostMessageA(hRakion,WM_CHAR,0x57,0);
      }
      Sleep(100);
   }
}
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sun Aug 23, 2009 6:22 am    Post subject: Reply with quote

You don't "post" messages to a Handle to the process..

The whole way PostMessage works is by sending the messages to the WndProc's message queue of the main window.

You need a handle to the game window aka hWnd.

Use FindWindow.
Back to top
View user's profile Send private message
Mapleblitzer
Master Cheater
Reputation: 0

Joined: 08 Apr 2007
Posts: 254

PostPosted: Sun Aug 23, 2009 9:21 am    Post subject: Reply with quote

Blah, still no luck.

Code:
_declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
   _asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[PMA]
   }
}

DWORD WINAPI BotThread(LPVOID lpParam)
{
   PMA = (DWORD)GetProcAddress(GetModuleHandle("user32.dll"),"PostMessageA")+5;

   while(true)
   {
      if(GetAsyncKeyState(0x30)&1) //0 key
      {
         hRakion = FindWindow(NULL,"Rakion");
         if(hRakion == NULL)
         {
            MessageBox(0,"Error",0,0);
         }
         _PostMessageA(hRakion,WM_KEYDOWN,0x57,0); //"W" key
      }
      if(GetAsyncKeyState(0x31)&1)// 1 key
      {
         hRakion = FindWindow(NULL,"Rakion");
         if(hRakion == NULL)
         {
            MessageBox(0,"Error",0,0);
         }
         _PostMessageA(hRakion,WM_CHAR,0x57,0);
      }
      Sleep(100);
   }
}
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Aug 23, 2009 10:13 am    Post subject: Reply with quote

well why did you just ignore lParam in both of the PostMessageA trampoline calls ?

out of interest why are you doing GetAsyncKeyState and then &ing the result.. ?
Back to top
View user's profile Send private message
Mapleblitzer
Master Cheater
Reputation: 0

Joined: 08 Apr 2007
Posts: 254

PostPosted: Sun Aug 23, 2009 3:46 pm    Post subject: Reply with quote

I left it as 0 because I saw other examples do so, and because it should mean the key must be pressed down (the transition state?). Should I fill it with the scancode?

I remember seeing someone do &1 to the return, I think its to isolate the return value's bit that decides whether the key was down or not.
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
Goto page 1, 2  Next
Page 1 of 2

 
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