The problem i have is that it don't seem to get anything from the adress that i supply to my program. The adress is taken from MHS and using the windows calculator I convert it from HEX to DEC since the memory_read Function wants an IntPtr.
I'm not a Hacking genius(obviously that's why I ask for help), And if someone of you grandmasters of hacking (with knowledge in c#) could take a quick peek at my code it is much appreciated.
note:I did download The memory editor class from "http://www.youtube.com/watch?v=sXu3jl2VxGc". If you want some more information just make a post below.
The memory editor class:
- Code: Select all
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Memedit
{
public class MemoryEditor
{
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UIntPtr nSize, out IntPtr lpNumberOfBytesWritten);
[DllImport("Kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesRead);
string pname = "";
IntPtr hand;
public MemoryEditor(string ProcName)
{
pname = ProcName.Replace(".exe", "");
Process[] proclist = Process.GetProcesses();
foreach (Process pr in proclist)
{
if (pr.ToString() == "System.Diagnostics.Process (" + pname + ")")
{
hand = pr.Handle;
}
}
}
public bool Write(int Address, byte[] data)
{
bool success = false;
Process[] proclist = Process.GetProcesses();
IntPtr bytesout;
success = WriteProcessMemory(hand, (IntPtr)Address, data, (UIntPtr)data.Length, out bytesout);
return success;
}
public byte[] Read(int Address, int length, bool GlobalAdress)
{
if (GlobalAdress)
{
hand = (IntPtr)0;
}
byte[] ret = new byte[length];
uint o = 0;
ReadProcessMemory(hand, (IntPtr)Address, ret, (UInt32)ret.Length, ref o);
return ret;
}
public int ReadInt32(int Address)
{
return BitConverter.ToInt32(Read(Address, 4,false), 0);
}
public float ReadSingle(int Address)
{
return BitConverter.ToSingle(Read(Address, 4, false), 0);
}
public string ReadString(int Address , int length, bool isUnicode)
{
if (isUnicode)
{
UnicodeEncoding enc = new UnicodeEncoding();
return enc.GetString(Read(Address, length, false));
}
else
{
ASCIIEncoding enc = new ASCIIEncoding();
return enc.GetString(Read(Address, length, false));
}
}
}
}
The windows form Code:
- Code: Select all
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 Memedit;
namespace MemoryhackTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MemoryEditor Editor = new MemoryEditor("TheProgram.exe");
label1.Text = Editor.ReadString(81963736, 10, false);
}
}
}
Thanks
//TopHat