Witam. Mam problem z kodem, gdyż czyta on tylko wartości 4 bajtowe. Chciałbym go zmienić na to, by czytał wartości double (8 bajtowe). Posiada ktoś wiedzę jak to zrobić? Co jest źle?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
class Program
{
[DllImport("kernel32.dll")]
public static extern Int64 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
public static byte[] ReadBytes(IntPtr Handle, Int64 Address, uint BytesToRead)
{
IntPtr bytesRead;
byte[] buffer = new byte[BytesToRead];
ReadProcessMemory(Handle, new IntPtr(Address), buffer, BytesToRead, out bytesRead);
return buffer;
}
public static int ReadInt32(Int64 Address, IntPtr Handle)
{
return BitConverter.ToInt32(ReadBytes(Handle, Address, 8), 0);
}
public static string ReadString(long Address, IntPtr Handle, uint length = 64)
{
return ASCIIEncoding.Default.GetString(ReadBytes(Handle, Address, length)).Split('\0')[0];
}
static void Main(string[] args)
{
Process File = Process.GetProcessesByName("TestFile")[0];
IntPtr Handle = File.Handle;
UInt32 HPAdr = 0xA036C68;
Console.WriteLine("Sprawdzenie : " + Convert.ToString(ReadInt32(HPAdr, Handle)));
Console.ReadLine();
}
}
}
Ja się nad tym męczę i mi nie idzie to.