[Request]C# ReadProcessMemory

04/14/2010 21:19 shimo diaz#1
Hi epvp coders
I need an example for ReadProcessMemory in C#
I need a full console application example that explains the ReadProcessMemory (the whole code)

In deutsch
Hallo epvp Codierer
Ich brauche ein Beispiel für ReadProcessMemory in C #
Ich brauche ein voller Konsole-Anwendung beispielsweise, dass die ReadProcessMemory (der gesamte Code erklärt)
04/15/2010 19:36 Elite-1337#2
da wirste nix finden wo das gut erklärt ist, weil das schon immer nicht ganz einfach war und auch bleiben wird. Das ist eine API Funktion, welche du nicht mal ausführlich in Büchern erklärt bekommst (nur ansatzweise).

Zum einen würd ich auf der MSDN Seite schaun und auch mal auf pinvoke.net
Und auf 64Bit BS is es auch wieder anders als in 32Bit, also musste daran dann auch denken.
04/18/2010 05:28 Henri_#3
#define MYOFFSETADDRESS 0x00000 /* define here the address you want to read */

HWND WndW = FindWindow(lpClassName, lpWindowName); /* lpClassName = the class of the target window - lpWindowName = the name to the target window - change these values! */

DWORD processID = GetWindowThreadProcessId(WndW, &processID); /* processID = the process Id of the target window. necessary to get the handle of the process */

HANDLE trgtHandle = OpenProcess(PROCESS_ALL_ACCESS, false, processID); /* the handle of the process */

if (trgtHandle == 0){return;} /* could not get the handle... */

int theValue;

ReadProcessMemory(trgtHandle , (LPCVOID)MYOFFSETADDRESS , &theValue, sizeof(theValue), NULL); /* Read "MYOFFSETADDRESS" address value - "theValue" will store the value */

CloseHandle(trgtHandle); /* closes the handle when you're done with it */

~Henri