Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


ReadProcessMemory

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
brodeur235
How do I cheat?
Reputation: 0

Joined: 10 May 2009
Posts: 4
Location: Texas, US

PostPosted: Sun May 10, 2009 7:19 pm    Post subject: ReadProcessMemory Reply with quote

I actually have a couple of questions that I suspect are related. I'll start with the simplest question I have:

I recently downloaded cheat engine (awesome BTW, DB) and opened up call of duty 4 to begin testing. In doing so I found several addresses that hold values such as my score, the number of kills I have, and the number of times I've died in the game. I changed these values suspecting that if I ever wanted to change them again, they'd be stored in at new locations in memory. Interestingly enough, when I closed cod4 and cheat engine, started some extra processes, and closed other processes, and finally restarted cod4 and cheat engine, the same addresses were used to save the same values. Why is that? Logically, if 50,000 bytes of memory were being used at the time call of duty started up, cod4 itself would get addresses 50001-50001+x, x being however much it needs... Troubling...

The other question I have is more specific and possibly related to my last question. Here is a source I have:
Code:

#include <windows.h>
#include <Strings.h>
#include <fstream>
#include <iostream>
using namespace std;

void writeMemToFile(const char* title, const char* fileName);

int main()
{
    const char *a = "Minesweeper";
    const char *b = "file";
    writeMemToFile(a, b);
    cout << "Done." << endl;
    system("PAUSE");
    return 0;
}

void writeMemToFile(const char* title, const char* fileName)
{
     ofstream file;
     file.open(fileName);
     
     DWORD pID;
     HWND window = FindWindow(NULL,title);
     
     if(!window)
         return;
     
     GetWindowThreadProcessId(window,&pID);
     HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS,false,pID);
     
     if(!processHandle)
         return;
     
     int current;
     for(int address = 0x00000000; address < 0xFFFFFFFF; address+=0x4)
     {
         if( ReadProcessMemory(processHandle, (LPCVOID)address, &current, 4, NULL) )
             file << current << endl;
     }
}

This code works, but running it takes forever as I have to loop from 0x00000000 to 0xFFFFFFFF. My question is, given the process handle, how do I know where it's memory segment begins and ends?

All help is appreciated,

Brodeur235
[/code]

_________________
No trees were hurt in the transmissionof this message, however a few thousand electrons were terribly inconvenienced.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun May 10, 2009 7:32 pm    Post subject: Reply with quote

If you MapViewOfFile instead, you can use the function ImageNtHeader to get all the addresses and such.
_________________
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Mon May 11, 2009 7:14 am    Post subject: Reply with quote

I think you need VirtualQueryEx
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites