계속 인터넷을 계속 검색하면이를 파악할 수 없으므로 ReadProcessMemory
이 올바르게 실행됩니다. 그러나 출력은 항상 비어 있습니다. 배열의 길이는 0
입니다. 당신이 그것을 완전히 비어 (new byte[] {}
) 초기화하기 때문에 당신이 그것을 채우기 위해주는 버퍼가 0
의 길이를 가지고 있기 때문에RPM이 작동하고 이유를 파악할 수 없습니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace MemEd
{
class Program
{
static void Main(string[] args)
{
Process proc = Process.GetProcessesByName("client")[0];
byte[] buff = new byte[]{};
IntPtr bread;
IntPtr pHandle = OpenProcess(0x0010, false, proc.Id);
bool check = ReadProcessMemory(pHandle, (IntPtr)0x5EFF75B8, buff, 10, out bread);
if (!check)
Console.WriteLine("RPM Fail");
Console.WriteLine(buff.Length); //ALWAYS returns 0, Even the value is a string "xyle"
Console.WriteLine(Encoding.Unicode.GetString(buff));//Always empty, tryed most of Encoding types to check still a blank result.
Console.ReadKey();
}
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[Out] byte[] lpBuffer,
int dwSize,
out IntPtr lpNumberOfBytesRead);
}
}
현재 dwSize (이 경우 1024)에 대한 버퍼 크기를 전달하십시오. 현재 가지고있는 10은 아닙니다. –