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 


C++ Cheat Trainer with source code

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Niels8500
Grandmaster Cheater
Reputation: 0

Joined: 19 Sep 2007
Posts: 859
Location: The Netherlands

PostPosted: Mon Nov 17, 2008 10:20 am    Post subject: C++ Cheat Trainer with source code Reply with quote

Hello can anyone help me to make a cheat trainer, for a singleplayer game like 007 quantum of solace, like ammo hack. how i can make a trainer in C++ ty Smile

Code:
#include <windows.h>
#include <tlhelp32.h>
#include <conio.h>
#include <stdlib.h>

bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size);

void main()
{
     printf("=== Pinball Trainer Example. Made by <your name here> ===\n\n");
     if(ChangeMemVal("PINBALL.EXE", (void*) 0xA90C62, 100000000, 4))
          printf("The score has been edited successfully.\n");
     else
          printf("An error occured while attempting edit the score.\n");
     system("PAUSE");
     return 0;
}


/* This function modifys a memory address according to its arguments.
   Arguments :
             ProcessName - the process we want to modify
             MemAddress - the memory address we want to modify
             NewVal - the value we want to change the memory address to
             size - the size of the memory address
   Returns :
           the success of the edit.
   */


bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size)
{
     HANDLE hProcessSnap;
     HANDLE hProcess = NULL;
     PROCESSENTRY32 pe32;   
     hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
     pe32.dwSize = sizeof( PROCESSENTRY32 );
     Process32First(hProcessSnap, &pe32);
     do
     {         
          if(!strcmp(pe32.szExeFile, ProcessName))
          {
               hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
               break;
          }
     }
     while(Process32Next(hProcessSnap, &pe32));
     CloseHandle( hProcessSnap );
     if(hProcess != NULL)
     {
          WriteProcessMemory(hProcess, MemAddress, &NewVal, size, NULL);     // write the value         
          CloseHandle(hProcess);   
          return true;
     }   
     return false;
}
Back to top
View user's profile Send private message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Mon Nov 17, 2008 11:20 am    Post subject: Reply with quote

God, at least get the least grip of how it works before you try to make a trainer on your own. Read some basic ASM tutorials first or something. Confused
_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Nov 17, 2008 11:58 am    Post subject: Reply with quote

Pinball uses pointers FYI.

So you'd have to do something like (yes, this is the right address, assuming you're on XP sp2):
Code:

void SetBalls(DWORD number){
   DWORD buffer;
   ReadProcessMemory(handle, (LPCVOID)0x01025658, &buffer, sizeof(DWORD), 0);
   buffer += 0x0146;
   WriteProcessMemory(handle, (LPVOID)buffer, &number, sizeof(number), 0);
}
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Mon Nov 17, 2008 12:56 pm    Post subject: Reply with quote

Doing all that every time you want to write to the process seems a bit silly =|
Back to top
View user's profile Send private message MSN Messenger
Niels8500
Grandmaster Cheater
Reputation: 0

Joined: 19 Sep 2007
Posts: 859
Location: The Netherlands

PostPosted: Mon Nov 17, 2008 1:44 pm    Post subject: Reply with quote

Lol iam on Vista 32BIT
Back to top
View user's profile Send private message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Mon Nov 17, 2008 8:14 pm    Post subject: Reply with quote

Niels8500 wrote:
Lol iam on Vista 32BIT


So?
Back to top
View user's profile Send private message
Niels8500
Grandmaster Cheater
Reputation: 0

Joined: 19 Sep 2007
Posts: 859
Location: The Netherlands

PostPosted: Tue Nov 18, 2008 7:36 am    Post subject: Reply with quote

But now with the problem can anyone help me
with a trainer
for like the game Command & Conquer Red alert 3
Back to top
View user's profile Send private message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Tue Nov 18, 2008 8:32 am    Post subject: Reply with quote

Niels8500 wrote:
But now with the problem can anyone help me
with a trainer
for like the game Command & Conquer Red alert 3

No. Confused

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Niels8500
Grandmaster Cheater
Reputation: 0

Joined: 19 Sep 2007
Posts: 859
Location: The Netherlands

PostPosted: Tue Nov 18, 2008 8:49 am    Post subject: Reply with quote

Spawnfestis wrote:
Niels8500 wrote:
But now with the problem can anyone help me
with a trainer
for like the game Command & Conquer Red alert 3

No. Confused


Why not, i wanne make my own cheat Razz
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Tue Nov 18, 2008 11:02 am    Post subject: Reply with quote

Code:

__declspec(naked)void SetOffsetDword();
CONTEXT Context = {CONTEXT_FULL};
__declspec(naked)void SetOffsetDword()
{
      __asm
      {
          add ecx,edx
          mov [ecx],eax
       }
      SuspendThread(GetCurrentThread());
}
int Size = mlde(SetOffetDword);//mlde engine
CreateRemoteThread(blah,(LPTHREAD_START_ROUTINE)memcpy(VirtualAllocEx(,TargetProcess,blah,Size),SetOffsetDword,Size),blah);

Get/SetThreadContext to set params On the Thread
Base = ecx,
offset = edx,
Number = eax;

reuseable remote write process memory without WriteProcessMemory
Back to top
View user's profile Send private message MSN Messenger
Niels8500
Grandmaster Cheater
Reputation: 0

Joined: 19 Sep 2007
Posts: 859
Location: The Netherlands

PostPosted: Tue Nov 18, 2008 11:46 am    Post subject: Reply with quote

BanMe wrote:
Code:

__declspec(naked)void SetOffsetDword();
CONTEXT Context = {CONTEXT_FULL};
__declspec(naked)void SetOffsetDword()
{
      __asm
      {
          add ecx,edx
          mov [ecx],eax
       }
      SuspendThread(GetCurrentThread());
}
int Size = mlde(SetOffetDword);//mlde engine
CreateRemoteThread(blah,(LPTHREAD_START_ROUTINE)memcpy(VirtualAllocEx(,TargetProcess,blah,Size),SetOffsetDword,Size),blah);

Get/SetThreadContext to set params On the Thread
Base = ecx,
offset = edx,
Number = eax;

reuseable remote write process memory without WriteProcessMemory


to difficult...
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Nov 18, 2008 2:29 pm    Post subject: Reply with quote

Code:
#include <Windows.h>
#include <iostream>
#include "trainer.h"

int main()
{
   DWORD choice, num;
   if(CheckProcess("PINBALL.EXE")){
      std::cout << "Running." << std::endl;
      std::cout << "1. Read"  << std::endl;
      std::cout << "2. Write" << std::endl;
      std::cout << "3. Quit"  << std::endl;      
      do{
         std::cin  >> choice;
         switch(choice){
         case 1:
            std::cout << ReadBalls() << std::endl;
            break;
         case 2:   
            std::cin >> num;
            WriteBalls(num);
            break;
         case 3:
            return 0;
         default:            
            break;
         }
      }while(choice != 3);
   }
   else{
      std::cout << "Not running." << std::endl;
   }
   return 0;
}


Code:
#include <tlhelp32.h>

PROCESSENTRY32   pe;
HANDLE   snapshot,
      handle;

BOOL CheckProcess(char* target){
   pe.dwSize = sizeof(PROCESSENTRY32);
   snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
   Process32First(snapshot, &pe);
   while(lstrcmpi(pe.szExeFile, target) != 0){
      if(!Process32Next(snapshot, &pe)){
         return FALSE;
      }         
   }CloseHandle(snapshot);
   handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
   return TRUE;
}

DWORD ReadBalls(void){
   DWORD buffer = 0;
   ReadProcessMemory(handle, (LPCVOID)0x01025658, &buffer, sizeof(DWORD), 0);
   buffer += 0x0146;
   ReadProcessMemory(handle, (LPCVOID)buffer, &buffer, sizeof(DWORD), 0);
   return buffer;
}

void WriteBalls(DWORD number){
   DWORD buffer = 0;
   ReadProcessMemory(handle, (LPCVOID)0x01025658, &buffer, sizeof(DWORD), 0);
   buffer += 0x0146;
   WriteProcessMemory(handle, (LPVOID)buffer, &number, sizeof(number), 0);
}
Back to top
View user's profile Send private message
Niels8500
Grandmaster Cheater
Reputation: 0

Joined: 19 Sep 2007
Posts: 859
Location: The Netherlands

PostPosted: Wed Nov 19, 2008 9:48 am    Post subject: Reply with quote

Lol dont know what to do
with this do i have to add
buttons or something?
Back to top
View user's profile Send private message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Wed Nov 19, 2008 10:35 am    Post subject: Reply with quote

Niels8500 wrote:
Lol dont know what to do
with this do i have to add
buttons or something?

Can't someone lock this topic? The guy doesn't know jackshit, I already said in the top post that he should read the basics first.
Really, either lock it or answer him properly without feeding him source code just making it more troublesome for him and yourself. Confused

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Nov 19, 2008 11:24 am    Post subject: Reply with quote

Niels8500 wrote:
Lol dont know what to do
with this do i have to add
buttons or something?


You go to www.cplusplus.com

Come back after you've attempted to help yourself.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    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