Szerző Téma: [Forráskód c#] Memória hack  (Megtekintve 2238 alkalommal)

Nem elérhető tja

  • 107
    • Profil megtekintése
[Forráskód c#] Memória hack
« Dátum: 2011. Március 11. - 14:59:04 »
0 Show voters
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.
« Utoljára szerkesztve: 2011. November 13. - 13:20:21 írta Jethro »

Yeaseiro

  • Vendég
[Forráskód c#] Memória hack
« Válasz #1 Dátum: 2011. Március 11. - 15:24:38 »
0 Show voters
Nem rossz...
De ezzel egy probléma van. Tudtommal sampban nem mûködik a C# de Singlebe nem tudom :shy:
Amúgy meg nem akarok hozzányúlni C:/Windows/System32 fájlokhoz
gondolok a(z) User32.dll, kernel32.dll-re :neutral:

Nem elérhető tja

  • 107
    • Profil megtekintése
[Forráskód c#] Memória hack
« Válasz #2 Dátum: 2011. Március 11. - 15:42:57 »
0 Show voters
Valójában a system32 fájlokból szedi ki az infót, és azt módosítja..
Singleplayerbe mûködik(teszteltem), samp-ba nem tudom. Már vagy 3 hónapja nem sampoztam :S

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal