 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun Nov 16, 2008 12:48 am Post subject: [C#]Making a MapleStory Bot |
|
|
K well, I figured I need to use pmx.dll, maybe another version of it, regardless
I've made a code, from what I could figure out, i'm sure with the eventhandlers and control names you'll be able to figure it out
i'm like 100% sure i've been doing it all wrong so, flame at me if you want to, i deserve it, i've been with c# for a few months now, and i've only been making small applications, i've wanted to take a crack at making a bot since the beginning, only now do I feel im the slightest bit ready to try
this is like my entire code, messy, and lots of unecesary code i haven't removed yet
it doesn't do the slightest bit of everything, can't figure out why, i took code from a source of a freemarket spot botter made by henley, and some codes i've found around CEF
i'll do whatever it takes to learn, links, anything at all
i've been puzzled for a few hours now
THANK YOU IF YOU EVEN READ THIS
| Code: | using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace SharpBot
{
public partial class frmMain : Form
{
[DllImport("kernel32")]
public extern static int LoadLibrary(string librayName);
[DllImport("kernel32", CharSet = CharSet.Ansi)]
public extern static int GetProcAddress(int hwnd, string procedureName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
[DllImport("user32.dll")]
static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("PMX.dll")]
private static extern bool PostMessageX(IntPtr hWnd, uint Msg, uint wParam, uint lParam);
private const int MOD_ALT = 0x1;
private const uint MOD_CONTROL = 0x2;
private const int MOD_SHIFT = 0x4;
private const int MOD_WIN = 0x8;
private const int WM_HOTKEY = 0x312;
public const int WM_KEYDOWN = 0x0100;
public const int WM_KEYUP = 0x0101;
public const int WM_LBUTTONDBLCLK = 0x0203;
public const int WM_MOUSEMOVE = 0x0200;
public const int WM_CHAR = 258;
MouseFunctions Mouse = new MouseFunctions();
[DllImport("USER32.DLL")]
public static extern IntPtr FindWindow(
string lpClassName,
string lpWindowName);
[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);
//Cursor.Position = new Point(MousePosition.X, MousePosition.Y);
//System.Threading.Thread.Sleep(10); // increase delay if cursor moves but does not click.
PostMessageX(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, MakeLParam(x, y));
PostMessageX(hWnd, WM_LBUTTONUP, 0, MakeLParam(x, y));
}
private uint MakeLParam(int LoWord, int HiWord)
{
return (uint)((HiWord << 16) | (LoWord & 0xFFFF));
}
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
string WndName = "MapleStory";
IntPtr hWnd = FindWindow(null, WndName);
PostMessageX(hWnd, WM_KEYDOWN, 0x08, 0);
int hwnd = LoadLibrary("user32.dll");
int addr = GetProcAddress(hwnd, "PostMessageX") + 5;
}
private void systemHotkey1_Pressed(object sender, EventArgs e)
{
if (cbAutoClick.Checked == false)
{
cbAutoClick.Checked = true;
tmrClick.Enabled = true;
}
else
{
cbAutoClick.Checked = false;
tmrClick.Enabled=false;
}
}
private void tmrClick_Tick(object sender, EventArgs e)
{
string WndName = "MapleStory";
IntPtr hWnd = FindWindow(null, WndName);
PostMessageX(hWnd, WM_LBUTTONDOWN, 0, MakeLParam(MousePosition.X, MousePosition.Y));
PostMessageX(hWnd, WM_LBUTTONUP, 0, MakeLParam(MousePosition.X, MousePosition.Y));
PostMessageX(hWnd, WM_LBUTTONDBLCLK, 0, MakeLParam(MousePosition.X, MousePosition.Y));
}
}
} |
_________________
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Sun Nov 16, 2008 1:56 am Post subject: |
|
|
Sending mouse clicks with PostMessageA will only work if your cursor is over the position you wish to click. SetCursorPos is hooked by GG also, so you will need a bypass for that too. I've attached a project with the source for a new dll you can use instead of pmx.dll. Compile it yourself or use the binary supplied then update your import references.. DllImport("gghop.dll"), hhPostMessageA, hhSetCursorPos, etc.
| Code: | //Point p = new Point(x, y);
//ClientToScreen(hWnd, ref p);
//Cursor.Position = new Point(MousePosition.X, MousePosition.Y);
//System.Threading.Thread.Sleep(10); |
Uncomment the above and replace your 3rd line with,
| Code: | | hhSetCursorPos(p.X, p.Y); |
Hopefully all goes well.
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Sun Nov 16, 2008 2:10 am Post subject: |
|
|
Bad idea. Use GetVersionEx to check for people who run XP SP1, as the hotpatching bytes were not implemented until SP2. You then can return an error and the callee can handle the error. Not sure if hookhopping works on x64. If it doesn't, a check should be implemented as well in the hookhop library.
_________________
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Sun Nov 16, 2008 2:40 am Post subject: |
|
|
| Making some good points as always. Although I'm not really concerned about those issues, but if other users are they can implement some error checking for themselves.
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Sun Nov 16, 2008 6:58 am Post subject: |
|
|
| sponge wrote: | | Bad idea. Use GetVersionEx to check for people who run XP SP1, as the hotpatching bytes were not implemented until SP2. You then can return an error and the callee can handle the error. Not sure if hookhopping works on x64. If it doesn't, a check should be implemented as well in the hookhop library. |
Or one could always use Microsoft's Detours library. It'll hook any function no matter what starting bytes it has. (It will check how many instructions it overwrites and then copy the necessary ones.) The only downside is that you have to include detours.dll with your project.
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Nov 16, 2008 9:08 am Post subject: |
|
|
| sponge wrote: | | Bad idea. Use GetVersionEx to check for people who run XP SP1, as the hotpatching bytes were not implemented until SP2. You then can return an error and the callee can handle the error. Not sure if hookhopping works on x64. If it doesn't, a check should be implemented as well in the hookhop library. |
There's a managed alternative to calling that API, and dealing with the native structures and what not.
Check out the System.Environment class.
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Nov 16, 2008 9:45 am Post subject: |
|
|
| Whats the point of including a pmx.dll? Just code it into your bot.
|
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun Nov 16, 2008 10:53 am Post subject: |
|
|
| dnsi0 wrote: | | Whats the point of including a pmx.dll? Just code it into your bot. |
like in your vb bot?
i've been wondering about that, mind sharing?
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Nov 16, 2008 3:40 pm Post subject: |
|
|
| My vb bot needs pmx.dll becuase vb is a dumb language and it doesn't surport inline asm. So my inprovised method of that is pack a file into the exe and at runtime,unpack it from the exe. Its a dumb method but it works.
|
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun Nov 16, 2008 4:33 pm Post subject: |
|
|
| dnsi0 wrote: | | My vb bot needs pmx.dll becuase vb is a dumb language and it doesn't surport inline asm. So my inprovised method of that is pack a file into the exe and at runtime,unpack it from the exe. Its a dumb method but it works. |
i understand what happens, but how are you doing it o.o, i can't find anything on packing a .dll into the .exe
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Nov 16, 2008 4:43 pm Post subject: |
|
|
| Oh HOW. K This is how it works. I convert the file into pure binary and store it into a string. at runtime, I rewrite the string into a file.
|
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun Nov 16, 2008 7:11 pm Post subject: |
|
|
| dnsi0 wrote: | | Oh HOW. K This is how it works. I convert the file into pure binary and store it into a string. at runtime, I rewrite the string into a file. |
thats genious o.o
anyways, thanks to the mass revamp by sloppy
it still doesn't seem to want to click in maplestory
confirmed to work for minesweeper, so it might be maple itself
http://paste2.org/p/102690
if any1's got ideas, please post
_________________
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Sun Nov 16, 2008 7:55 pm Post subject: |
|
|
| Code: | | FindWindow (0,"MapleStory"); |
does not work (ingame), im pretty sure. You need to use
| Code: | | FindWindow ("MapleStoryClass",0); |
Also, no need for MK_LBUTTON
| Code: | | PostMessageX(hWnd, WM_LBUTTONDOWN, 0, MakeLParam(x, y)); |
_________________
|
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun Nov 16, 2008 10:48 pm Post subject: |
|
|
the problem seems to be vista ._.
now usually 99% of the time i never blame vista, because 99% of the time, i can mess with compatibility settings, to fix it
when not in admin mode, upon start, it sets focus to maple, but thats it
when ran in admin mode, it freezes maple, it seems like lag, but even if i wait for half an hour or so, the screen doesn't budge, but it seems the game is still playing
much credit to sloppy, he re-everything my base source
thread close pelase ~ hah, expect another question from me, time to bot helicoptergame.net
_________________
|
|
| Back to top |
|
 |
Henley Grandmaster Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 671
|
Posted: Mon Nov 17, 2008 12:16 am Post subject: |
|
|
| kitterz wrote: | | Code: | | FindWindow (0,"MapleStory"); |
does not work (ingame), im pretty sure. You need to use
| Code: | | FindWindow ("MapleStoryClass",0); |
|
nah it does work
just that, using classname is better cause some folders are named "MapleStory"
|
|
| Back to top |
|
 |
|
|
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
|
|