 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
charch84 How do I cheat?
Reputation: 0
Joined: 25 Mar 2008 Posts: 7
|
Posted: Fri Apr 04, 2008 2:02 pm Post subject: [Help]C++ |
|
|
I am making a game trainer for Minesweeper. Here is my code:
| Code: | #include <windows.h>
#include <iostream>
#include <conio.h>
#include <tlhelp32.h>
#include <tchar.h>
#pragma warning( disable: 4996 )
PROCESSENTRY32 pe32;
BOOL GetProcessInfo(PROCESSENTRY32* pe)
{
PROCESSENTRY32 proc32;
HANDLE hSnapshot = NULL;
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
proc32.dwSize = sizeof( PROCESSENTRY32 );
if( Process32First( hSnapshot, &proc32 ) )
{
do{
if( _tcscmp( _tcslwr( proc32.szExeFile ), TEXT("winmine.exe") ) == 0 )
{
CloseHandle( hSnapshot );
memcpy( pe, &proc32, sizeof(PROCESSENTRY32) );
return TRUE;
}
}while( Process32Next( hSnapshot, &proc32 ) );
}
return FALSE;
}
void FreezeTime( DWORD dwProcId, DWORD dwValue )
{
HANDLE hHandle = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwProcId );
if( hHandle == 0 || hHandle == INVALID_HANDLE_VALUE )
return;
WriteProcessMemory( hHandle, (BYTE*)0x100579C, &dwValue, 4, NULL );
CloseHandle( hHandle );
}
void GodMode( DWORD dwProcId, DWORD dwValue )
{
HANDLE hHandle = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwProcId );
if( hHandle == 0 || hHandle == INVALID_HANDLE_VALUE )
return;
WriteProcessMemory( hHandle, (BYTE*)0x1005000, &dwValue, 4, NULL );
CloseHandle( hHandle );
}
int main()
{
char cOption = 0;
bool bLoop = true;
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo;
COORD cCoord = {0};
while( bLoop )
{
GetConsoleScreenBufferInfo( GetStdHandle(STD_OUTPUT_HANDLE), &strConsoleInfo );
FillConsoleOutputCharacter( GetStdHandle(STD_OUTPUT_HANDLE), 32, strConsoleInfo.dwSize.X * strConsoleInfo.dwSize.Y, cCoord, NULL );
SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), cCoord );
std::cout << "Minesweeper Console Trainer - By Charch84" << std::endl;
std::cout << "1. God Mode" << std::endl;
std::cout << "2. Set Time to 0" << std::endl;
std::cout << "3. Exit Trainer" << std::endl;
std::cout << "Select an option: ";
std::cin >> cOption;
switch( cOption )
{
case '1':
GetProcessInfo( &pe32 );
GodMode( pe32.th32ProcessID, 1 );
break;
case '2':
GetProcessInfo( &pe32 );
FreezeTime( pe32.th32ProcessID, 0 );
break;
case '3':
bLoop = false;
break;
default:
std::cout << "Invalid option" << std::endl;
break;
}
}
return ERROR_SUCCESS;
} |
How could I freeze my values instead of just setting them?
|
|
| Back to top |
|
 |
isair Grandmaster Cheater
Reputation: 0
Joined: 28 Dec 2007 Posts: 804
|
Posted: Fri Apr 04, 2008 2:08 pm Post subject: |
|
|
you can freeze an address without pausing your main checks by creating another thread.
like this:
| Code: |
DWORD TimeFreezerId;
//Forward declaration
DWORD WINAPI TimeFreezer(LPVOID);
|
| Code: |
//Create the thread
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&TimeFreezer,0,0,&TimeFreezerId);
|
| Code: |
DWORD WINAPI TimeFreezer(LPVOID)
{
while(true)
{
if(isTimeFrozen)
{
WriteProcessMemory(hHandle,(BYTE*)0x100579C,&dwValue,4,NULL );
}
}
ExitThread(0);
}
|
|
|
| Back to top |
|
 |
charch84 How do I cheat?
Reputation: 0
Joined: 25 Mar 2008 Posts: 7
|
Posted: Fri Apr 04, 2008 2:43 pm Post subject: |
|
|
Thank you I can't rep+ right now but once I can I will. sorry .
|
|
| Back to top |
|
 |
isair Grandmaster Cheater
Reputation: 0
Joined: 28 Dec 2007 Posts: 804
|
Posted: Fri Apr 04, 2008 2:49 pm Post subject: |
|
|
| I am just happy to help.
|
|
| Back to top |
|
 |
Deletion I post too much
Reputation: 0
Joined: 22 Jun 2006 Posts: 2148 Location: Underground
|
Posted: Fri Apr 04, 2008 2:54 pm Post subject: |
|
|
| isair wrote: | | I am just happy to help. |
^^ Rep whore. lol jk.
Multi Threading is very important for programs that do more than one thing.
_________________
Bitch, please.
| redslothx wrote: | | oh im a man so respect the penis powers |
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Apr 04, 2008 4:07 pm Post subject: |
|
|
You're going to rape the shit out of CPU if you don't Sleep the thread, it's just going to chomp all available resources.
An easier (and often better) way is to find what writes to the address, then NOP the instruction. If there's nothing to do, it's basically 'frozen'.
0x90 = NOP
There's 2 instructions that take care of increasing the time in minesweeper. After the first second, the second one takes over.
01003830 | FF 05 9C 57 00 01 | inc [0100579c]
0100255F | FF 05 9C 57 00 01 | inc [0100579c]
Those bytes make up the instruction that ticks the time up by one second (hence INC). You can do a bunch of things to it, make it tick down by changing it to.
FF 0D 9C 57 00 01 | dec [0100579c]
or you could just flat out NOP it, which means no operation, so you can guess what would happen when it's hit... nothing.
90 90 90 90 90 90
| Code: | BYTE normal[] = { 0xFF, 0x05, 0x9C, 0x57, 0x00, 0x01 }; //inc [0100579c]
BYTE nop[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; //nops
BOOL noped = FALSE;
void doShit(){
if(!noped){
WriteProcessMemory(gameProcess, (void*)0x01003830, &nop, sizeof(nop), NULL);
WriteProcessMemory(gameProcess, (void*)0x0100255F, &nop, sizeof(nop), NULL);
CloseHandle(gameProcess); noped = TRUE;
}
else{
WriteProcessMemory(gameProcess, (void*)0x01003830, &normal, sizeof(normal), NULL);
WriteProcessMemory(gameProcess, (void*)0x0100255F, &normal, sizeof(normal), NULL);
CloseHandle(gameProcess); noped = FALSE;
}
} |
|
|
| 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
|
|