 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
maxmakki How do I cheat?
Reputation: 0
Joined: 29 Jun 2012 Posts: 7
|
Posted: Sat Jun 30, 2012 1:21 am Post subject: [SOLVED] [C++] Get DWORD from address like "game.exe&qu |
|
|
Hello everyone,
I have a static address I'd like to code into a trainer, but the address is not something like 12345678, it's more like "game.exe"+0002347C.
My code looks something like this:
| Code: |
// console trainer, read / write in C++
DWORD pointer = baseAddress;
DWORD pTemp;
DWORD pointerAddr;
for( int c = 0; c < pointerLevel; c++ )
{
if( c == 0 )
{
if( !ReadProcessMemory( hProcHandle, (LPCVOID)pointer, &pTemp, 4, NULL ) )
cout << "FAILED READ 1" << endl;
}
pointerAddr = pTemp + offsets[c];
if( !ReadProcessMemory( hProcHandle, (LPCVOID)pointerAddr, &pTemp, 4, NULL ) )
cout << "FAILED READ 2" << endl;
}
if ( !WriteProcessMemory(hProcHandle, (BYTE*)pointerAddr, &value, sizeof(value), NULL) )
cout << "FAILED WRITE" << endl;
else
cout << "WORKS" << endl;
|
How do I get "game.exe"+0002347C to go into the ReadProcessMemory and WriteProcessMemory functions?
Thank you.
Max
Last edited by maxmakki on Sat Jun 30, 2012 6:03 pm; edited 1 time in total |
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
|
| Back to top |
|
 |
maxmakki How do I cheat?
Reputation: 0
Joined: 29 Jun 2012 Posts: 7
|
Posted: Sat Jun 30, 2012 12:50 pm Post subject: |
|
|
Hi Innovation,
Thanks for the link.
I'm having some difficulty with initializing TCHAR using the memory module. When I do:
| Code: |
baseAddress = dwGetModuleBaseAddress( processId, "\"game.exe\"+00012345" );
|
dwGetModuleBaseAddress always returns 0. I set processId like this:
| Code: |
// Set processId
DWORD processId = NULL;
PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};
HANDLE hProcSnap;
HANDLE hProcHandle;
while(!processId)
{
system("CLS");
cout << "Searching for " << processName <<"..." <<endl;
hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(Process32First(hProcSnap, &pe32))
{
do
{
if(!strcmp(pe32.szExeFile, processName))
{
processId = pe32.th32ProcessID;
break;
}
}
while(Process32Next(hProcSnap, &pe32));
}
Sleep(1000);
}
|
Which appears to be a valid processId. I'm assuming it's the way I am entering the TCHAR value. What could be wrong?
Thank you.
Max
---------- EDIT -----------
I found a previous post by Innovation that utilizes this function. I tried setting the TCHAR like this:
| Code: |
DWORD speedMovBaseAddress = dwGetModuleBaseAddress( processId, _T("game.exe+00012345") );
|
It still returned 0. Then I tried:
| Code: |
DWORD speedMovBaseAddress = dwGetModuleBaseAddress( processId, _T("game.exe") );
|
And it returned "FAILED READ 2" from the bit of code I included in my first post to this thread. I believe it is because I was not able to account for the +00012345 part of the memory module. Any ideas?
Thanks
Max
---------- EDIT -----------
My updated code looks something like this:
| Code: |
// console trainer, read / write in C++
DWORD baseAddress = dwGetModuleBaseAddress( processId, _T("game.exe") );
DWORD staticOffset = { 0x12345 };
DWORD offsets = { 0x12, 0x34, 0x56 };
DWORD pointer = baseAddress;
DWORD pTemp;
DWORD pointerAddr;
for( int c = 0; c < 3; c++ )
{
if( c == 0 )
{
if( !ReadProcessMemory( hProcHandle, (LPCVOID)(pointer+staticOffset), &pTemp, sizeof(DWORD), NULL ) )
cout << "FAILED READ 1" << endl;
}
pointerAddr = pTemp + offsets[c];
if( !ReadProcessMemory( hProcHandle, (LPCVOID)pointerAddr, &pTemp, sizeof(DWORD), NULL ) )
cout << "FAILED READ 2" << endl;
}
if ( !WriteProcessMemory(hProcHandle, (BYTE*)pointerAddr, &value, sizeof(value), NULL) )
cout << "FAILED WRITE" << endl;
else
cout << "WORKS" << endl;
|
I keep getting "FAILED READ 2". It's difficult to debug this given that I don't know if I'm doing the "game.exe"+00012345 part right. Maybe someone else sees something I don't?
Thanks
Max
---------- EDIT (Still can't reply twice in a row) -----------
It was an offset issue, my offsets were listed backwards. All good now.
Max
|
|
| Back to top |
|
 |
|
|
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
|
|