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#] PMX.dll / PostMessageX with MOUSE (maplestory)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Tue Oct 21, 2008 10:25 am    Post subject: [C#] PMX.dll / PostMessageX with MOUSE (maplestory) Reply with quote

http://pastebin.com/m3b5df731
Am trying to simulate mouse events towards maplestory, although it is "running" it doesn't do jackshit ingame. I tried simulating enter, or any key - worked fine.

Ideas?

Code:
   internal static int MakeLParam(int lo, int hi)
        {
            return (int)(((short)hi << 16) | (lo & 0xffff));
        } 

PostMessageX(WindowHandle, WM_LBUTTONDOWN, 0, MakeLParam(Convert.ToInt32(MouseX.Text), Convert.ToInt32(MouseY.Text)));

(content of the pastebin)

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Tue Oct 21, 2008 11:27 am    Post subject: Reply with quote

Code:

void SendClick(bool dbl = false);

void SendClick(bool dbl)
{
   POINT pPos;
   GetCursorPos(&pPos);
   SetCursorPos(pPos.x,pPos.y);
   if (dbl)
   {
      PostMessageX(sHandle, WM_LBUTTONDBLCLK, NULL, (LPARAM)(pPos.x,pPos.y));
   }
    else
          PostMessageX(sHandle, WM_LBUTTONDOWN, NULL, (LPARAM)(pPos.x,pPos.y));
   PostMessageX(sHandle, WM_LBUTTONUP, NULL, (LPARAM)(pPos.x,pPos.y));
}


Ohh my bad its C++, but you can make it to C# i guess.

_________________
Gone
Back to top
View user's profile Send private message
SFP+
Comp. talk moderator
Reputation: 26

Joined: 02 May 2007
Posts: 1228
Location: Sweden

PostPosted: Tue Oct 21, 2008 11:46 am    Post subject: Reply with quote

Code:

VOID SendClickEx(__in HWND hWnd, __in WPARAM wParam, __in BOOL bDoubleClick)
{
  POINT Point;

  if (GetCursorPos(&Point))
  {
    _PostMessage(hWnd, bDoubleClick ? WM_LBUTTONDBLCLK : WM_LBUTTONDOWN, wParam, MAKELPARAM(Point.x, Point.y));
    _PostMessage(hWnd, WM_LBUTTONUP, wParam, MAKELPARAM(Point.x, Point.y));
  }
}
#define SendClick(x, y) SendClickEx(x, 0, y)
Back to top
View user's profile Send private message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Tue Oct 21, 2008 11:55 am    Post subject: Reply with quote

Gah, I'll fucking start coding in C++ soon. C# is starting to piss me off.
_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Tue Oct 21, 2008 1:46 pm    Post subject: Reply with quote

GMZorita wrote:
Code:

void SendClick(bool dbl = false);

void SendClick(bool dbl)
{
   POINT pPos;
   GetCursorPos(&pPos);
   SetCursorPos(pPos.x,pPos.y);
   if (dbl)
   {
      PostMessageX(sHandle, WM_LBUTTONDBLCLK, NULL, (LPARAM)(pPos.x,pPos.y));
   }
    else
          PostMessageX(sHandle, WM_LBUTTONDOWN, NULL, (LPARAM)(pPos.x,pPos.y));
   PostMessageX(sHandle, WM_LBUTTONUP, NULL, (LPARAM)(pPos.x,pPos.y));
}


Ohh my bad its C++, but you can make it to C# i guess.


ahhh remember that SetCursorPos is not hooked.

_________________
Back to top
View user's profile Send private message Send e-mail
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Tue Oct 21, 2008 2:13 pm    Post subject: Reply with quote

kitterz wrote:
GMZorita wrote:
Code:

void SendClick(bool dbl = false);

void SendClick(bool dbl)
{
   POINT pPos;
   GetCursorPos(&pPos);
   SetCursorPos(pPos.x,pPos.y);
   if (dbl)
   {
      PostMessageX(sHandle, WM_LBUTTONDBLCLK, NULL, (LPARAM)(pPos.x,pPos.y));
   }
    else
          PostMessageX(sHandle, WM_LBUTTONDOWN, NULL, (LPARAM)(pPos.x,pPos.y));
   PostMessageX(sHandle, WM_LBUTTONUP, NULL, (LPARAM)(pPos.x,pPos.y));
}


Ohh my bad its C++, but you can make it to C# i guess.


ahhh remember that SetCursorPos is not hooked.

You mean is hooked?
Well just use the trampoline bypass.

_________________
Gone
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: Tue Oct 21, 2008 2:34 pm    Post subject: Reply with quote

GMZorita wrote:
kitterz wrote:
GMZorita wrote:
Code:

void SendClick(bool dbl = false);

void SendClick(bool dbl)
{
   POINT pPos;
   GetCursorPos(&pPos);
   SetCursorPos(pPos.x,pPos.y);
   if (dbl)
   {
      PostMessageX(sHandle, WM_LBUTTONDBLCLK, NULL, (LPARAM)(pPos.x,pPos.y));
   }
    else
          PostMessageX(sHandle, WM_LBUTTONDOWN, NULL, (LPARAM)(pPos.x,pPos.y));
   PostMessageX(sHandle, WM_LBUTTONUP, NULL, (LPARAM)(pPos.x,pPos.y));
}


Ohh my bad its C++, but you can make it to C# i guess.


ahhh remember that SetCursorPos is not hooked.

You mean is hooked?
Well just use the trampoline bypass.


He either made a typo, or doesn't think its hooked because he injects a .dll for his bots, and GG protected processes are allowed to use SetCursorPos.
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Tue Oct 21, 2008 4:00 pm    Post subject: Reply with quote

I wrote something similar to this awhile ago,
Code:
[DllImport("gghh.dll")]
private static extern bool hhPostMessageA(IntPtr hWnd, uint Msg, uint wParam, uint lParam); // hook hop

[DllImport("gghh.dll")]
private static extern bool hhSetCursorPos(int x, int y); // hook hop

[DllImport("user32.dll")]
private static extern bool ClientToScreen(IntPtr hWnd, ref Point p);

const uint WM_LBUTTONDOWN = 0x0201;
const uint WM_LBUTTONUP = 0x0202;
const uint MK_LBUTTON = 0x0001;

public void Click(IntPtr hWnd, int x, int y) // click relative to the window
{
    Point p = new Point(x, y);
    ClientToScreen(hWnd, ref p);
    hhSetCursorPos(p.X, p.Y);

    Thread.Sleep(10); // increase delay if cursor moves but does not click.

    hhPostMessageA(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, MakeLParam(x, y));
    hhPostMessageA(hWnd, WM_LBUTTONUP, 0, MakeLParam(x, y));
}

private uint MakeLParam(int LoWord, int HiWord)
{
    return (uint)((HiWord << 16) | (LoWord & 0xFFFF));
}

Note: From past experience, using Spy++ shows that SetCursorPos is often recieved after the WM_LBUTTONDOWN message. I recommend you have a minor delay before the click, and possibly increase it for reliability if you need to.


Last edited by sloppy on Tue Oct 21, 2008 10:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Tue Oct 21, 2008 7:55 pm    Post subject: Reply with quote

smartz993 wrote:
GMZorita wrote:
kitterz wrote:
GMZorita wrote:
Code:

void SendClick(bool dbl = false);

void SendClick(bool dbl)
{
   POINT pPos;
   GetCursorPos(&pPos);
   SetCursorPos(pPos.x,pPos.y);
   if (dbl)
   {
      PostMessageX(sHandle, WM_LBUTTONDBLCLK, NULL, (LPARAM)(pPos.x,pPos.y));
   }
    else
          PostMessageX(sHandle, WM_LBUTTONDOWN, NULL, (LPARAM)(pPos.x,pPos.y));
   PostMessageX(sHandle, WM_LBUTTONUP, NULL, (LPARAM)(pPos.x,pPos.y));
}


Ohh my bad its C++, but you can make it to C# i guess.


ahhh remember that SetCursorPos is not hooked.

You mean is hooked?
Well just use the trampoline bypass.


He either made a typo, or doesn't think its hooked because he injects a .dll for his bots, and GG protected processes are allowed to use SetCursorPos.


lol ya typo i mean "now hooked" not "not hooked" lol

_________________
Back to top
View user's profile Send private message Send e-mail
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Wed Oct 22, 2008 8:29 am    Post subject: Reply with quote

sloppy wrote:
I wrote something similar to this awhile ago,
Code:
[DllImport("gghh.dll")]
private static extern bool hhPostMessageA(IntPtr hWnd, uint Msg, uint wParam, uint lParam); // hook hop

[DllImport("gghh.dll")]
private static extern bool hhSetCursorPos(int x, int y); // hook hop

[DllImport("user32.dll")]
private static extern bool ClientToScreen(IntPtr hWnd, ref Point p);

const uint WM_LBUTTONDOWN = 0x0201;
const uint WM_LBUTTONUP = 0x0202;
const uint MK_LBUTTON = 0x0001;

public void Click(IntPtr hWnd, int x, int y) // click relative to the window
{
    Point p = new Point(x, y);
    ClientToScreen(hWnd, ref p);
    hhSetCursorPos(p.X, p.Y);

    Thread.Sleep(10); // increase delay if cursor moves but does not click.

    hhPostMessageA(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, MakeLParam(x, y));
    hhPostMessageA(hWnd, WM_LBUTTONUP, 0, MakeLParam(x, y));
}

private uint MakeLParam(int LoWord, int HiWord)
{
    return (uint)((HiWord << 16) | (LoWord & 0xFFFF));
}

Note: From past experience, using Spy++ shows that SetCursorPos is often recieved after the WM_LBUTTONDOWN message. I recommend you have a minor delay before the click, and possibly increase it for reliability if you need to.

I'll do that, thanks for the tips.

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Sun Oct 26, 2008 12:56 am    Post subject: Reply with quote

so did it work?

im pretty sure im doing something wrong

i can't even reference pmx.dll

_________________
Back to top
View user's profile Send private message AIM Address
imeantobebad
Master Cheater
Reputation: 0

Joined: 11 Jan 2007
Posts: 469
Location: Moree

PostPosted: Mon Oct 27, 2008 4:26 am    Post subject: Reply with quote

Spawnfestis wrote:
Gah, I'll fucking start coding in C++ soon. C# is starting to piss me off.


Lol i thought u already coded in C++? SpawnPE?
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