| View previous topic :: View next topic |
| Author |
Message |
Spawnfestis GO Moderator
Reputation: 0
Joined: 02 Nov 2007 Posts: 1746 Location: Pakistan
|
Posted: Wed Oct 22, 2008 3:02 pm Post subject: [C#] Trainer template (for the beginners!) |
|
|
I had some time to kill so I wrote an extremely simple application that modifies the target process memory using FindWindow() as an entry point to open up the process for memory editing.
I know that this isn't the ideal way, but this also shows how to use a window handle which is useful if you/they want to implement a botting feature to their trainer.
Anyways, I just wanted to post it here since I know people are struggling to understand the hard terms of programming, and I'm trying to show you that it's not hard at all.
* This will require basic skill with the C# GUI editor and variable understanding, nothing more - nothing less.
- Create one button called Write, then another one called Get handles or something.
- Continue to code (?)
| Code: | using System;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TrainerTemplate
{
public partial class Form1 : Form
{
//C# Signature for the FindWindow() API
[DllImport("USER32.DLL")] // Let the computer know where the below function will be imported from (user32.dll)
public static extern IntPtr FindWindow( // Create a function "template"
string lpClassName, // The function has two arguments, lpClassName (=Window class name) and lpWindowName (=Window name)
string lpWindowName // Example of FindWindow() call using the arguments -> FindWindow("WindowClass" <- this is the lpClassName type string, "WindowName" <- this is the lpWindowName type string);
);
//C# Signature for the WriteProcessMemory() API
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
byte[] lpBuffer,
UIntPtr nSize,
out IntPtr lpNumberOfBytesWritten
);
//C# Signature for the OpenProcess() API
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
UInt32 dwDesiredAccess,
Int32 bInheritHandle,
UInt32 dwProcessId
);
//C# Signature for the GetWindowThreadProcessId() API
[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(
IntPtr hWnd,
out uint lpdwProcessId
);
//C# Signature for the ReadProcessMemory() API
[DllImport("kernel32.dll", SetLastError = true)]
static unsafe extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
void* lpBuffer,
int dwSize,
out IntPtr lpNumberOfBytesRead
);
// Global variables (containers)
UInt32 ProcID;
IntPtr WindowHandle;
IntPtr ProcessHandle;
IntPtr bytesout; // If using ReadProcessMemory(), dump the successfully read bytes here.
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
byte[] InfiniteMoney = { 0x90, 0x90 }; // Byte array
WriteProcessMemory(ProcessHandle, (IntPtr)0x00C47F74 /*Target address*/, InfiniteMoney /*Byte array call*/, (UIntPtr)2 /*Byte array size*/, out bytesout);
}
private void button2_Click(object sender, EventArgs e)
{
WindowHandle = FindWindow("WindowClass", "WindowTitle"); // Establish a Window Handle (hWnd)
GetWindowThreadProcessId(WindowHandle, out ProcID); // Get the Process ID (PID) from the targeted window/window class
ProcessHandle = OpenProcess(0x1F0FFF, 1, ProcID); // Gain access to the process memory with OpenProcess() using Process ID as an entry
}
}
}
|
Now let the coding begin!
_________________
CLICK TO HAX MAPLESTORAY ^ !!!! |
|
| Back to top |
|
 |
Fuzz Grandmaster Cheater
Reputation: 0
Joined: 12 Nov 2006 Posts: 531
|
Posted: Wed Oct 22, 2008 3:44 pm Post subject: |
|
|
| Good post spawn. Commented and everthing. Good thinking.
|
|
| Back to top |
|
 |
Hieroglyphics I post too much
Reputation: 0
Joined: 06 Dec 2007 Posts: 2007 Location: Your bedroom
|
Posted: Wed Oct 22, 2008 4:31 pm Post subject: |
|
|
Good Job. Though I don't like C# I shall make one for C++, still not sure yet though.
_________________
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Oct 22, 2008 4:37 pm Post subject: |
|
|
| Good work but I would personally not encourage handing out templates like this since they generate more and more template coders, eg. ^
|
|
| Back to top |
|
 |
13 I post too much
Reputation: 0
Joined: 24 Apr 2007 Posts: 4603
|
Posted: Wed Oct 22, 2008 6:21 pm Post subject: |
|
|
| Thanks spawn :D I've just begun learning C# and this is extremely useful.
|
|
| Back to top |
|
 |
Zan.exe Grandmaster Cheater
Reputation: 0
Joined: 22 Feb 2007 Posts: 752 Location: The U.S. of A.
|
Posted: Wed Oct 22, 2008 6:22 pm Post subject: |
|
|
why do I get an error when posting it in a clean new project in project.cs?
Error 1 The name 'InitializeComponent' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Program.cs 61 13 WindowsFormsApplication1
_________________
PM Me if you play FFXI - Bismark Server
Lv75 BST
Almost all the mods on CEF are morons.
<3 SunBeam |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Oct 22, 2008 11:20 pm Post subject: |
|
|
You don't need to go through all that to get the process handle in .NET
You can just use the Process class.
Process[] p = Process.GetProcessesByName("winmine");
WriteProcessMemory(p[0].Handle, ...);
Last edited by hcavolsdsadgadsg on Thu Oct 23, 2008 9:29 am; edited 1 time in total |
|
| Back to top |
|
 |
RAKO Master Cheater
Reputation: 0
Joined: 26 Jun 2006 Posts: 454
|
Posted: Thu Oct 23, 2008 2:39 am Post subject: |
|
|
do you know how to use asm in c#? other wise we can't hook hop so might as well program in c++ but i like c# gui.
_________________
| Dark Byte wrote: | | Who knows, perhaps i'm a maple gm!!!! |
|
|
| Back to top |
|
 |
Spawnfestis GO Moderator
Reputation: 0
Joined: 02 Nov 2007 Posts: 1746 Location: Pakistan
|
Posted: Thu Oct 23, 2008 9:59 am Post subject: |
|
|
| slovach wrote: | You don't need to go through all that to get the process handle in .NET
You can just use the Process class.
Process[] p = Process.GetProcessesByName("winmine");
WriteProcessMemory(p[0].Handle, ...); |
Usually you implement a bot within a trainer, and they should get to know how to get the window handle anyways so it doesn't really matter.
| Zan.exe wrote: | why do I get an error when posting it in a clean new project in project.cs?
Error 1 The name 'InitializeComponent' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Program.cs 61 13 WindowsFormsApplication1 |
You can't just copy and paste the code. You have to actually read it.
| RAKO wrote: | | do you know how to use asm in c#? other wise we can't hook hop so might as well program in c++ but i like c# gui. |
Easily import a DLL made in C++ into your C# project and use the function from there, it'll work just as nicely.
_________________
CLICK TO HAX MAPLESTORAY ^ !!!! |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Oct 23, 2008 10:11 am Post subject: |
|
|
| Spawnfestis wrote: | | slovach wrote: | You don't need to go through all that to get the process handle in .NET
You can just use the Process class.
Process[] p = Process.GetProcessesByName("winmine");
WriteProcessMemory(p[0].Handle, ...); |
Usually you implement a bot within a trainer, and they should get to know how to get the window handle anyways so it doesn't really matter. |
p[x].MainWindowHandle?
|
|
| Back to top |
|
 |
Zan.exe Grandmaster Cheater
Reputation: 0
Joined: 22 Feb 2007 Posts: 752 Location: The U.S. of A.
|
Posted: Thu Oct 23, 2008 1:42 pm Post subject: |
|
|
| Spawnfestis wrote: |
| Zan.exe wrote: | why do I get an error when posting it in a clean new project in project.cs?
Error 1 The name 'InitializeComponent' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Program.cs 61 13 WindowsFormsApplication1 |
You can't just copy and paste the code. You have to actually read it.
|
got it working, ty
_________________
PM Me if you play FFXI - Bismark Server
Lv75 BST
Almost all the mods on CEF are morons.
<3 SunBeam |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Oct 23, 2008 1:56 pm Post subject: |
|
|
| Spawnfestis wrote: | | slovach wrote: | You don't need to go through all that to get the process handle in .NET
You can just use the Process class.
Process[] p = Process.GetProcessesByName("winmine");
WriteProcessMemory(p[0].Handle, ...); |
Usually you implement a bot within a trainer, and they should get to know how to get the window handle anyways so it doesn't really matter |
Pointless to reinvent the wheel if it already has a implementation in .NET. The process class has everything you need and then some.
|
|
| Back to top |
|
 |
Hieroglyphics I post too much
Reputation: 0
Joined: 06 Dec 2007 Posts: 2007 Location: Your bedroom
|
Posted: Thu Oct 23, 2008 4:51 pm Post subject: |
|
|
| Zan.exe wrote: | why do I get an error when posting it in a clean new project in project.cs?
Error 1 The name 'InitializeComponent' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Program.cs 61 13 WindowsFormsApplication1 |
You just showed us that the bot in your siggy is fake
_________________
|
|
| Back to top |
|
 |
Spawnfestis GO Moderator
Reputation: 0
Joined: 02 Nov 2007 Posts: 1746 Location: Pakistan
|
Posted: Fri Oct 24, 2008 7:07 am Post subject: |
|
|
| Hieroglyphics wrote: | | Zan.exe wrote: | why do I get an error when posting it in a clean new project in project.cs?
Error 1 The name 'InitializeComponent' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Program.cs 61 13 WindowsFormsApplication1 |
You just showed us that the bot in your siggy is fake |
They always are.
_________________
CLICK TO HAX MAPLESTORAY ^ !!!! |
|
| Back to top |
|
 |
Zan.exe Grandmaster Cheater
Reputation: 0
Joined: 22 Feb 2007 Posts: 752 Location: The U.S. of A.
|
Posted: Fri Oct 24, 2008 9:58 am Post subject: |
|
|
did I say it was real?
It's the GUI for the bot I plan to make.
what's wrong with that? anyone?
If you don't like it, faggot it (hopefully your smart enough to be using firefox and faggot)
_________________
PM Me if you play FFXI - Bismark Server
Lv75 BST
Almost all the mods on CEF are morons.
<3 SunBeam |
|
| Back to top |
|
 |
|