Ich habe versucht, dies mit Process.EnterDebugMode()
ausgeführt, aber es funktioniert auch nicht.64bit ReadProcessMemory Zugriff verweigert
Ich möchte die Notepad-memory
vorlesen, aber ich weiß nicht, wie man darauf zugreifen, oder wenn das 64-Bit-System Probleme macht. Diese
ist das, was ich getan habe:
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();
}
}
Führen Sie Ihre Anwendung als Administrator – dotctor
Ich denke, Sie sollten es als x86 ausführen. Ich habe es vorher getan, und ich brauchte Administrator Privileg –
Sie können Pinvoke Erklärungen von Methoden in www.pinvoke.net erhalten –