I'm not a pro in code writing and C# programming. I wrote a simple app to read from process memory using the ZeraPain script ReadProcessMemory(). Is working good with the 4 bytes and 8 bytes value. The other function of this App is that can read strings, but i really need to read Double values and i cant find anything on the web. Can somebody HELP me with this? here's a printscreen of the app
http://i.stack.imgur.com/q0QTh.jpg[
^]
p.s. Excuse my English
Here's the class (by ZERAPAIN) - with some editing
class Memory
{
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Boolean bInheritHandle, UInt32 dwProcessId);
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
byte[] lpBuffer, UIntPtr nSize, uint lpNumberOfBytesWritten);
IntPtr Handle;
public Memory(string sprocess)
{
try
{
Process[] Processes = Process.GetProcessesByName(sprocess);
Process nProcess = Processes[0];
Handle = OpenProcess(0x10, false, (uint)nProcess.Id);
}
catch
{
}
}
public string ReadString(uint pointer, Int32 bts)
{
byte[] bytes = new byte[bts];
ReadProcessMemory(Handle, (IntPtr)pointer, bytes, (UIntPtr)24, 0);
return Encoding.UTF8.GetString(bytes);
}
public int ReadPointer(uint pointer, Int32 bts)
{
byte[] bytes = new byte[bts];
ReadProcessMemory(Handle, (IntPtr)pointer, bytes, (UIntPtr)sizeof(int), 0);
return BitConverter.ToInt32(bytes, 0);
}
}
And here's the script
private void timer1_Tick(object sender, EventArgs e)
{
try
{
Memory mem = new Memory(processnameTB.Text);
uint address = Convert.ToUInt32(AddressTB.Text, 16);
if (checkBox1.Checked == true)
{
try
{
int byt = Convert.ToInt32(bytesnumberTB.Text);
string str = mem.ReadString(address, byt);
stringvalue.Text = str;
}
catch
{
timer1.Enabled = false;
}
}
if (checkBox2.Checked == true)
{
try
{
int byt = Convert.ToInt32(bytesnumberTB.Text);
double pointer = mem.ReadPointer(address,byt);
pointervalue.Text = pointer.ToString();
}
catch
{
timer1.Enabled = false;
}
}
}
catch (Exception ex)
{
timer1.Enabled = false;
MessageBox.Show(ex.Message, "Error");
}
}