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 


[C++] PostmessageA
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Jun 14, 2008 1:18 pm    Post subject: Reply with quote

oib111 wrote:
Here's an example of bypassing PostMessageA (from 1gaz's source of hBot.cpp).

Code:

void LoadUser32()
{
   hpInst = LoadLibrary("User32.Dll");
   pmDLLFunc = NULL;
   if (hpInst != NULL)
      pmDLLFunc = (DWORD)GetProcAddress(hpInst,"PostMessageA");
   if (pmDLLFunc != NULL)
      pmDLLFunc += 5;
}

__declspec(naked) BOOL WINAPI PostMessageX(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   __asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[pmDLLFunc]
   }
}

//more coding

LPARAM lParam = (MapVirtualKey(0x5A, NULL) << 16);
PostMessageX(hMS, WM_KEYDOWN, 0x5A, lParam);

I tried this, but for some reason it doesnt work for me. heres what i tried:
Code:

HMODULE hpInst;
 UINT pmDLLFunc;

// some code

void LoadUser32()
{
 
  hpInst = LoadLibrary("User32.Dll");
   pmDLLFunc = NULL;
   if (hpInst != NULL)
      pmDLLFunc = (DWORD)GetProcAddress(hpInst,"PostMessageA");
   if (pmDLLFunc != NULL)
      pmDLLFunc += 5;
}

__declspec(naked) BOOL WINAPI PostMessageX(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   __asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[pmDLLFunc]
   }
}
void AutoLoot (HWND thisHwnd)
{
   LPARAM lParam = (MapVirtualKey(0x5A, NULL) << 16);
   PostMessageX(thisHwnd, WM_KEYDOWN, 0x5A, lParam);
       if (autoLootStop)
        {
   ExitThread(0);
        }
}
 
//Some more code

CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)AutoLoot, hWnd, 0, 0 );// this is called on a hotkey press

Which is almost exactly the same. Where did i go wrong? =/.
Back to top
View user's profile Send private message MSN Messenger
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 14, 2008 1:28 pm    Post subject: Reply with quote

You declared pmDLLFunc as a UINT type varaible, when then you assign it a DWORD value. Change it to:

Code:

DWORD pmDLLFunc;

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Jun 14, 2008 1:31 pm    Post subject: Reply with quote

I see, i was a little unsure what value type that function returned.
Thanks alot ^_^.
Edit: Seems it still doesnt work =/
Back to top
View user's profile Send private message MSN Messenger
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Sat Jun 14, 2008 1:46 pm    Post subject: Reply with quote

KittonKicker made a driver to bypass SendInput and PostMessage, search it. It is very simple to use. But if you are using the SendInput to change the cursor position, then you have a problem.
_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Sat Jun 14, 2008 2:57 pm    Post subject: Reply with quote

Ok im going to spoonfeed you

Code:
#define VK_Z 90

DWORD dwPostMessage = (DWORD)GetProcAddress( GetModuleHandle( "user32.dll" ), "PostMessageA" ) + 5;
HWND sHandle = FindWindow("MapleStoryClass", NULL);

BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   __asm {
      push ebp
      mov  ebp, esp
      jmp dwPostMessage
   }
   return TRUE;
}

void SendKey(UINT vk_key) {

   skey = MapVirtualKey(vk_key, 0);

   lparam = (skey << 16) + 1;

   PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);
}

void AutoLoot()
{
   SendKey(VK_Z);
}


For MS already.

_________________
Gone
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Jun 14, 2008 3:16 pm    Post subject: Reply with quote

Trying out KiInput now. Instead of adding the KiInput.h file to my project, i just transferred the code within it. But now, when i call Initialize() it tells me that the DLL is missing. Ive placed both the DLL and the driver file everywhere within the project folders, so i dont quite understand why it cant find it. Should i place them somewhere else?
Edit: oh thanks GMZorita, very much appreciated.
Back to top
View user's profile Send private message MSN Messenger
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Sat Jun 14, 2008 3:33 pm    Post subject: Reply with quote

Odecey wrote:
Trying out KiInput now. Instead of adding the KiInput.h file to my project, i just transferred the code within it. But now, when i call Initialize() it tells me that the DLL is missing. Ive placed both the DLL and the driver file everywhere within the project folders, so i dont quite understand why it cant find it. Should i place them somewhere else?
Edit: oh thanks GMZorita, very much appreciated.

I sugest you to do something like
Code:

while (sHandle = NULL)
{
     sHandle = FindWindow("MapleStoryClass", NULL);
}

_________________
Gone
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Jun 14, 2008 4:11 pm    Post subject: Reply with quote

OK, im getting a little tired off not getting any results.
Btw GMZorita, isnt
"BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)" supposed to be "__declspec(naked) BOOL WINAPI PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)" and shouldnt"PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);" have been ""PostMessageX(sHandle, WM_KEYDOWN, vk_key, lparam);"?
Edit: Finally got it to work after realizing i was lacking a "=". Thanks again GMZorita and oib111.
Back to top
View user's profile Send private message MSN Messenger
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Sat Jun 14, 2008 4:25 pm    Post subject: Reply with quote

Odecey wrote:
Trying out KiInput now. Instead of adding the KiInput.h file to my project, i just transferred the code within it. But now, when i call Initialize() it tells me that the DLL is missing. Ive placed both the DLL and the driver file everywhere within the project folders, so i dont quite understand why it cant find it. Should i place them somewhere else?
Edit: oh thanks GMZorita, very much appreciated.


I"m not sure, but I think you have to use the KiInput.h. Also in your main.cpp you should have this code:

Code:
#include "KiInput.h"


Oh wait, I didn't read the second sentence...

If you are using MSVC++ then have the KiDriver and KiInput.dll in your folder with another folder called "Debug".

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sat Jun 14, 2008 5:19 pm    Post subject: Reply with quote

GMZorita wrote:
Ok im going to spoonfeed you

Code:
#define VK_Z 90

DWORD dwPostMessage = (DWORD)GetProcAddress( GetModuleHandle( "user32.dll" ), "PostMessageA" ) + 5;
HWND sHandle = FindWindow("MapleStoryClass", NULL);

BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   __asm {
      push ebp
      mov  ebp, esp
      jmp dwPostMessage
   }
   return TRUE;
}

void SendKey(UINT vk_key) {

   skey = MapVirtualKey(vk_key, 0);

   lparam = (skey << 16) + 1;

   PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);
}

void AutoLoot()
{
   SendKey(VK_Z);
}


For MS already.


How would I call Autoloot?

void Autoloot(); would call it, right?

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Cx
Master Cheater
Reputation: 0

Joined: 27 Jul 2007
Posts: 367

PostPosted: Sat Jun 14, 2008 6:01 pm    Post subject: Reply with quote

ElectroFusion wrote:
GMZorita wrote:
Ok im going to spoonfeed you

Code:
#define VK_Z 90

DWORD dwPostMessage = (DWORD)GetProcAddress( GetModuleHandle( "user32.dll" ), "PostMessageA" ) + 5;
HWND sHandle = FindWindow("MapleStoryClass", NULL);

BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   __asm {
      push ebp
      mov  ebp, esp
      jmp dwPostMessage
   }
   return TRUE;
}

void SendKey(UINT vk_key) {

   skey = MapVirtualKey(vk_key, 0);

   lparam = (skey << 16) + 1;

   PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);
}

void AutoLoot()
{
   SendKey(VK_Z);
}


For MS already.


How would I call Autoloot?

void Autoloot(); would call it, right?


Definitely learn the basics of C(++) before you try to do this...


Also...
Is MAPVK_VK_TO_VSC defined as 0?

_________________

armed with this small butterfly net
i will face the world alone
& never be lonely.
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Sat Jun 14, 2008 6:50 pm    Post subject: Reply with quote

Cx wrote:
ElectroFusion wrote:
GMZorita wrote:
Ok im going to spoonfeed you

Code:
#define VK_Z 90

DWORD dwPostMessage = (DWORD)GetProcAddress( GetModuleHandle( "user32.dll" ), "PostMessageA" ) + 5;
HWND sHandle = FindWindow("MapleStoryClass", NULL);

BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   __asm {
      push ebp
      mov  ebp, esp
      jmp dwPostMessage
   }
   return TRUE;
}

void SendKey(UINT vk_key) {

   skey = MapVirtualKey(vk_key, 0);

   lparam = (skey << 16) + 1;

   PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);
}

void AutoLoot()
{
   SendKey(VK_Z);
}


For MS already.


How would I call Autoloot?

void Autoloot(); would call it, right?


Definitely learn the basics of C(++) before you try to do this...

Ur telling this to him right?

Also you should use
Code:
AutoLoot();


Cx wrote:

Also...
Is MAPVK_VK_TO_VSC defined as 0?

No idea lol

_________________
Gone
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sat Jun 14, 2008 7:01 pm    Post subject: Reply with quote

GMZorita wrote:
Cx wrote:
ElectroFusion wrote:
GMZorita wrote:
Ok im going to spoonfeed you

Code:
#define VK_Z 90

DWORD dwPostMessage = (DWORD)GetProcAddress( GetModuleHandle( "user32.dll" ), "PostMessageA" ) + 5;
HWND sHandle = FindWindow("MapleStoryClass", NULL);

BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   __asm {
      push ebp
      mov  ebp, esp
      jmp dwPostMessage
   }
   return TRUE;
}

void SendKey(UINT vk_key) {

   skey = MapVirtualKey(vk_key, 0);

   lparam = (skey << 16) + 1;

   PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);
}

void AutoLoot()
{
   SendKey(VK_Z);
}


For MS already.


How would I call Autoloot?

void Autoloot(); would call it, right?


Definitely learn the basics of C(++) before you try to do this...

Ur telling this to him right?

Also you should use
Code:
AutoLoot();


Cx wrote:

Also...
Is MAPVK_VK_TO_VSC defined as 0?

No idea lol


GMZortia is helping a nub Very Happy

How bout hotkeys? like

if(VK_F5){
AutoLoot();
}

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 14, 2008 7:09 pm    Post subject: Reply with quote

RegiterHotKey

or

GetASyncKeyState

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Sat Jun 14, 2008 7:20 pm    Post subject: Reply with quote

ElectroFusion wrote:
GMZorita wrote:
Cx wrote:
ElectroFusion wrote:
GMZorita wrote:
Ok im going to spoonfeed you

Code:
#define VK_Z 90

DWORD dwPostMessage = (DWORD)GetProcAddress( GetModuleHandle( "user32.dll" ), "PostMessageA" ) + 5;
HWND sHandle = FindWindow("MapleStoryClass", NULL);

BOOL WINAPI __declspec(naked) PostMessageX(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
   __asm {
      push ebp
      mov  ebp, esp
      jmp dwPostMessage
   }
   return TRUE;
}

void SendKey(UINT vk_key) {

   skey = MapVirtualKey(vk_key, 0);

   lparam = (skey << 16) + 1;

   PostMessageX(sHandle, WM_KEYUP, vk_key, lparam);
}

void AutoLoot()
{
   SendKey(VK_Z);
}


For MS already.


How would I call Autoloot?

void Autoloot(); would call it, right?


Definitely learn the basics of C(++) before you try to do this...

Ur telling this to him right?

Also you should use
Code:
AutoLoot();


Cx wrote:

Also...
Is MAPVK_VK_TO_VSC defined as 0?

No idea lol


GMZortia is helping a nub :D

How bout hotkeys? like

if(VK_F5){
AutoLoot();
}


Mostly:
Code:
if( GetAsyncKeyState( VK_F12 )&1 )
AutoLoot();
}

_________________
Gone
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 Previous  1, 2, 3  Next
Page 2 of 3

 
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