ReadProcessMemory

Find a Bug? Have a Problem? Like to Suggest a Feature? Do it Here

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

ReadProcessMemory

Postby Utev » Tue Jan 27, 2009 11:19 pm

I'm kinda new with c++ and googled this readymade source but I can't make it work

Code: Select all
#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
   DWORD bytes, wid;
   HWND w3wnd = FindWindow(NULL, "gamename");
   GetWindowThreadProcessId(w3wnd, &wid);
   HANDLE w3hnd = OpenProcess(PROCESS_ALL_ACCESS, false, wid);
   if (w3wnd==NULL)
   {
      printf("Not found...\n");
      system("PAUSE");
      return 0;
   }
   char* output[10];
   void* pointer=&output;
   ReadProcessMemory(w3hnd, (LPCVOID* )0x00442CD8 + 0x82C, pointer, 1, &bytes);
   printf("%s", output);
   system("PAUSE");
   return 0;
}


I need to read TEXT from [00442CD8] + 0x82C but I didn't found any sources which would have done so. So what's wrong here?
Utev
I Have A Few Questions
 
Posts: 6
Joined: Mon Aug 06, 2007 5:05 am

Postby L. Spiro » Wed Jan 28, 2009 7:41 am

#1: I already told you.

Code: Select all
UINT_PTR DeRef( HANDLE hProc, LPCVOID lpvAddr ) {
   UINT_PTR dwRet;
   ::ReadProcessMemory( hProc, lpvAddr, &dwRet, sizeof( dwRet ), NULL );
   return dwRet;
}


CHAR szBuffer[10] = { 0 }
::ReadProcessMemory( w3hnd, (LPCVOID)(DeRef( w3hnd , 0x00442CD8 ) + 0x82C), szBuffer, sizeof( szBuffer ), NULL );
szBuffer[sizeof( szBuffer )-1] = '\0';
printf( "%s", szBuffer );


#2: output is not initialized. Saving to that will just crash you. Use the code above.


#3: ReadProcessMemory() doesn’t take an (LPCVOID *), it takes an (LPCVOID).


#4: This is not a question about MHS.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan


Return to Bugs/Problems/Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests