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 


How I do a loop for when he finds GAMEOF in memory

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

Joined: 10 May 2016
Posts: 2

PostPosted: Fri May 13, 2016 6:25 pm    Post subject: How I do a loop for when he finds GAMEOF in memory Reply with quote

How I do a loop for when he finds GAMEOF in memory of the process
it takes 200 characters before and puts on a string.



#include <iostream>
#include <iomanip>
#include <windows.h>
#include <tlhelp32.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <fstream>

#define ReadLimit 100*4096 //6 zeroes - for ReadProcessMemory
#define StaticCacheSize 2*40000


using namespace std;

int main()
{


char* value = new char[79];
HANDLE hProcess, hProcesses;
MEMORY_BASIC_INFORMATION MBI;
BYTE *Buf, pGlobalBuf;
DWORD ReadAddr, QueryAddr, BytesRead, BufSize;
ofstream meuArquivo;

// OpenProcess
HANDLE phandle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
0,
28104);
// verifica se o soft está em execução
if (!phandle)
{
cout << "Programa não está em execução!";
}

QueryAddr = 0;
while (1)
{ //Enumerate process memory regions

VirtualQueryEx(phandle, (LPVOID) QueryAddr, &MBI, sizeof(MBI)); //if its bigger than 1 0 000 000 bytes, read only that amount

if (MBI.BaseAddress == 0 && QueryAddr != 0)
{
break;
} //memory regions finished

QueryAddr += (DWORD) MBI.RegionSize;

if (MBI.Protect & PAGE_NOACCESS || MBI.Protect & PAGE_GUARD /*|| MBI.Protect&PAGE_EXECUTE || MBI.Protect&PAGE_EXECUTE_READ || MBI.State&MEM_FREE*/)
{
continue;
}

ReadAddr = 0;

while (MBI.RegionSize > 0)
{

if (ReadAddr != 0)
{
ReadAddr += ReadLimit;
}
else
{
ReadAddr = (DWORD) MBI.BaseAddress;
}

if (MBI.RegionSize > ReadLimit)
{

BufSize = ReadLimit;
MBI.RegionSize -= ReadLimit;
}
else
{
BufSize = MBI.RegionSize;
MBI.RegionSize = 0;
}

BytesRead = 0;
ReadProcessMemory(phandle,
(LPVOID) ReadAddr,
&value[0],
BufSize,
&BytesRead);

}

}

return 0;
}
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri May 13, 2016 6:47 pm    Post subject: Reply with quote

You need to actually learn what you are doing instead of copy pasting things from around the internet. You are not using the API correctly in a manner that is proper or efficient. If you actually read the API documentation for Windows (MSDN) you will have a better understanding of the things you are trying to do and use.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri May 13, 2016 6:53 pm    Post subject: Reply with quote

Code:
for (int i = 0; i < BytesRead; ++i) {
  bool found = true;
  for (int j = 0; j < CompareSize; ++j) {
    int k = i + j;
    if (k >= BytesRead || value[k] != compare[j]) {
      found = false;
      break;
    }
  }
  if (found) {
    // yay
  }
}
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