| View previous topic :: View next topic |
| Author |
Message |
Mapleblitzer Master Cheater
Reputation: 0
Joined: 08 Apr 2007 Posts: 254
|
Posted: Tue Aug 18, 2009 9:31 pm Post subject: Finding Method of Keyboard Input? |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Aug 19, 2009 12:32 am Post subject: |
|
|
| probably either: WM_CHAR or WM_INPUT |
|
| Back to top |
|
 |
LolSalad Grandmaster Cheater
Reputation: 1
Joined: 26 Aug 2007 Posts: 988 Location: Australia
|
Posted: Wed Aug 19, 2009 1:22 am Post subject: |
|
|
Google Images suggests this game is 3D... I seriously doubt that it draws with GDI. _________________
|
|
| Back to top |
|
 |
Mapleblitzer Master Cheater
Reputation: 0
Joined: 08 Apr 2007 Posts: 254
|
Posted: Wed Aug 19, 2009 8:16 am Post subject: |
|
|
| 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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Wed Aug 19, 2009 9:17 am Post subject: |
|
|
| Why don't you unpack the .exe and look for imports from dinput |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Aug 19, 2009 7:42 pm Post subject: |
|
|
| Mapleblitzer wrote: | | So if it uses directx, can I safely assume it uses directinput? |
no, not really. |
|
| Back to top |
|
 |
Mapleblitzer Master Cheater
Reputation: 0
Joined: 08 Apr 2007 Posts: 254
|
Posted: Thu Aug 20, 2009 10:50 pm Post subject: |
|
|
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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Fri Aug 21, 2009 10:23 am Post subject: |
|
|
| You could also try WM_KEYDOWN. |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Aug 21, 2009 10:57 pm Post subject: |
|
|
| 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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Fri Aug 21, 2009 11:52 pm Post subject: |
|
|
| 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 |
|
 |
Mapleblitzer Master Cheater
Reputation: 0
Joined: 08 Apr 2007 Posts: 254
|
Posted: Sat Aug 22, 2009 11:05 pm Post subject: |
|
|
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 |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Sun Aug 23, 2009 6:22 am Post subject: |
|
|
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 |
|
 |
Mapleblitzer Master Cheater
Reputation: 0
Joined: 08 Apr 2007 Posts: 254
|
Posted: Sun Aug 23, 2009 9:21 am Post subject: |
|
|
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 |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Aug 23, 2009 10:13 am Post subject: |
|
|
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 |
|
 |
Mapleblitzer Master Cheater
Reputation: 0
Joined: 08 Apr 2007 Posts: 254
|
Posted: Sun Aug 23, 2009 3:46 pm Post subject: |
|
|
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 |
|
 |
|