Process.EnterDebugMode()
과 함께 실행 해 보았지만 작동하지 않습니다.64bit ReadProcessMemory access denied
나는 Notepad-memory
을 읽고 싶지만, 어떻게 접근 할 것인지, 아니면 64 비트 시스템이 문제를 일으키는 지 알지 못합니다.
이 내가 무슨 짓을했는지입니다 :
이using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
public class MemoryRead
{
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(int hProcess, Int64 lpBaseAddress, byte[] buffer, int size, ref int lpNumberOfBytesRead);
[DllImport("kernel32.dll")]
static extern bool CloseHandle(IntPtr hObject);
static void Main(string[] args)
{
var pid = 10956; //notepad.exe
var processHandle = OpenProcess(0x10, false, pid);
byte[] buffer = new byte[24];
int bytesRead = 0;
ReadProcessMemory((int)processHandle, 0x21106B35770, buffer, buffer.Length, ref bytesRead); //0x21106B35770 is the address where "hello world" is written in notepad
Console.WriteLine(Encoding.Unicode.GetString(buffer) +
" (" + bytesRead.ToString() + "bytes)");
Console.ReadLine();
CloseHandle(processHandle);
Console.ReadLine();
}
}
응용 프로그램을 관리자로 실행하십시오. – dotctor
나는 x86으로 실행해야한다고 생각합니다. 나는 전에 그것을했고 관리자 권한이 필요하지 않았다. –
www.pinvoke.net에서 메소드의 Pinvoke 선언을 얻을 수있다. –