| View previous topic :: View next topic |
| Author |
Message |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Sat Jun 19, 2010 8:12 pm Post subject: [C++, help] PostMessage |
|
|
I'm trying to send VK_TAB to a game, without it being active.
| Code: |
unsigned int scanCode = MapVirtualKey(VK_TAB, 0);
PostMessage(hWnd, WM_KEYDOWN, VK_TAB, scanCode << 16);
PostMessage(hWnd, WM_KEYUP, VK_TAB, scanCode << 16);
|
From searching around the above code is how it's done.
The game receives the following events, from the above code: (Spy++)
And then when you actually press tab:
So I'm assuming that if cRepeat was set to 1 for WM_KEYDOWN, cRepeat/fRepeat/fUp set to 1 for WM_KEYUP, that it might work?
Also WM_CHAR seems to be sent twice, not sure if this has anything to do with it not working.
|
|
| Back to top |
|
 |
Deltron Z Expert Cheater
Reputation: 1
Joined: 14 Jun 2009 Posts: 164
|
Posted: Sun Jun 20, 2010 2:44 am Post subject: |
|
|
First of all, the first pictures shows WM_KEYDOWN->WM_KEYUP->WM_CHAR and in the second it's WM_KEYDOWN->WM_CHAR->WM_KEYUP.
Also, you might want to take a look at MSDN, haven't you wondered why you have to shift 16 bits left to the scan code? because the scan code is bits 16~23:
| MSDN wrote: | lParam
The repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown following.
Bits Meaning
0-15 The repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16-23 The scan code. The value depends on the OEM.
24 Indicates whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25-28 Reserved; do not use.
29 The context code. The value is always 0 for a WM_KEYDOWN message.
30 The previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up.
31 The transition state. The value is always 0 for a WM_KEYDOWN message. |
You can simply do:
| Code: | | (ScanCode << 16) | (RepeatTimes << 30) |
Where repeat time is boolean (0 or 1) to set cRepeat.
|
|
| Back to top |
|
 |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Sun Jun 20, 2010 2:07 pm Post subject: |
|
|
Thanks, this is what I have now: (It matches when tab is actually sent, but the game still isn't doing anything with it)
| Code: |
// scanCode = 0x0F
unsigned int scanCode = MapVirtualKey(VK_TAB, 0);
// cRepeat = 1
unsigned int keyDown = (1 << 0) | (scanCode << 16);
// cRepeat = 1, fRepeat = 1, fUp = 1
unsigned int keyUp = (1 << 0) | (scanCode << 16) | (1 << 30) | (1 << 31);
PostMessage(window, WM_KEYDOWN, VK_TAB, keyDown);
PostMessage(window, WM_KEYUP, VK_TAB, keyUp);
|
|
|
| Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Sun Jun 20, 2010 4:06 pm Post subject: |
|
|
| it could be hooked, use a tramplotine bypass
|
|
| Back to top |
|
 |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Tue Jun 22, 2010 6:21 am Post subject: |
|
|
| NoMercy wrote: | | it could be hooked, use a tramplotine bypass |
How can I tell if PostMessage is hooked? Would the PostMessageA function be changed in user32.dll? If so it doesn't seem to be any different when logged into the game.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Jun 22, 2010 7:44 pm Post subject: |
|
|
Depends on the type of hook.
If it's an IAT hook, you will need to check the IAT table of the application/module that you rerouted.
If it's a 'hook-hop' style hook, read the first chunk of the API and compare to what it should be.
There are plenty of other hooking methods, but those are the two most common to begin with.
_________________
- Retired. |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Jun 22, 2010 7:52 pm Post subject: |
|
|
| surely it's not hooked else the game wouldn't be receiving all those messages he's been trying to send anyway..
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Jun 22, 2010 8:00 pm Post subject: |
|
|
| Slugsnack wrote: | | surely it's not hooked else the game wouldn't be receiving all those messages he's been trying to send anyway.. |
Just because the game is still receiving the messages doesn't mean it's not hooked. His messages could be passing through a hook.
_________________
- Retired. |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Jun 22, 2010 8:06 pm Post subject: |
|
|
| if that is the case, why would he care about whether there is a hook there or not lol ? that would be a poor, poor hook either way T_T
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Tue Jun 22, 2010 8:36 pm Post subject: |
|
|
| The much more likely event is that the game uses DirectInput instead of windows messages.
|
|
| Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Wed Jun 23, 2010 1:33 am Post subject: |
|
|
| Which game could be handy?
|
|
| Back to top |
|
 |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Wed Jun 23, 2010 5:04 am Post subject: |
|
|
| NoMercy wrote: | | Which game could be handy? |
Grand Fantasia
Last edited by 661089799107 on Mon Jun 28, 2010 7:41 pm; edited 2 times in total |
|
| Back to top |
|
 |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Mon Jun 28, 2010 7:39 pm Post subject: |
|
|
| Flyte wrote: | | The much more likely event is that the game uses DirectInput instead of windows messages. |
I don't think it uses DirectInput(?) I couldn't find any calls for it. (DirectInput8Create, DirectInputCreateEx, etc)
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Mon Jun 28, 2010 8:19 pm Post subject: |
|
|
| Bill87 wrote: | | Flyte wrote: | | The much more likely event is that the game uses DirectInput instead of windows messages. |
I don't think it uses DirectInput(?) I couldn't find any calls for it. (DirectInput8Create, DirectInputCreateEx, etc) |
Check GetProcAddress.
|
|
| Back to top |
|
 |
|