Gondoltam hogy ha kurta leírta a c++ost, leírom én is a c#-ost.
#region hack
// C# Signature for the FindWindow() API
[DllImport(\"USER32.DLL\")]
public static extern IntPtr FindWindow(
string lpClassName,
string lpWindowName
);
// 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
);
#endregion
public static bool EditMemory(int Address, uint Value) {
UInt32 ProcID;
IntPtr bytesout;
IntPtr WindowHandle = FindWindow(null, \"GTA: San Andreas\");
if (WindowHandle == null) { return false; }
GetWindowThreadProcessId(WindowHandle, out ProcID);
IntPtr ProcessHandle = OpenProcess(0x1F0FFF, 1, ProcID);
WriteProcessMemory(ProcessHandle, (IntPtr)Address, BitConverter.GetBytes(Value), (UIntPtr)sizeof(uint), out bytesout);
return true;
}
Szükség lehet még erre is:
using System.Runtime.InteropServices;
Példa a használatra:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace codhack {
public class ButtonclsForm : System.Windows.Forms.Form {
private System.Windows.Forms.Button button1;
public ButtonclsForm() {
Text = \"Gta San Andreas pénz hack. by straY\'\";
ShowInTaskbar = true;
//Button
this.button1 = new Button();
this.button1.Text = \"Add a pénzem!\";
this.button1.Name = \"button1\";
this.button1.Size = new System.Drawing.Size(72, 30);
this.button1.Location = new System.Drawing.Point((ClientRectangle.Width - button1.Size.Width) / 2, ClientRectangle.Height - 60);
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1 });
this.button1.Click += new System.EventHandler(btnMoney_Click);
}
static public void Main() {
Application.Run(new ButtonclsForm() );
}
#region hack files
// C# Signature for the FindWindow() API
[DllImport(\"USER32.DLL\")]
public static extern IntPtr FindWindow(
string lpClassName,
string lpWindowName
);
// 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
);
#endregion
public static bool EditMemory(int Address, uint Value) {
UInt32 ProcID;
IntPtr bytesout;
IntPtr WindowHandle = FindWindow(null, \"GTA: San Andreas\");
if (WindowHandle == null) { return false; }
GetWindowThreadProcessId(WindowHandle, out ProcID);
IntPtr ProcessHandle = OpenProcess(0x1F0FFF, 1, ProcID);
WriteProcessMemory(ProcessHandle, (IntPtr)Address, BitConverter.GetBytes(Value), (UIntPtr)sizeof(uint), out bytesout);
return true;
}
private void btnMoney_Click(object sender, EventArgs e) {
uint money = 99999999;
EditMemory(0xB7CE50, money);
}
private void InitializeComponent() {
this.SuspendLayout();
//
// ButtonclsForm
//
this.ClientSize = new System.Drawing.Size(418, 262);
this.Name = \"ButtonclsForm\";
this.ResumeLayout(false);
}
}
}
Persze ez csak egy alap, lehetne még belerakni 1-2 dolgot.