hello guys, since the cheat with GUI is detected for hungames Ts2, i decided to show you how to make simple cheat ...:D
Prerequisites :
- IDE like visual studio
- C++ basic knowledge
- Cheat engine to find addresses/signatures
- Some knowledge in assembly/memory
- Object oriented programming basis (inheritance/composition...)
- copy/paste skills, at least know how to do a project in your favorite IDE :D
this cheat actually contains :
- gm-vision (numpad0)
- stack items (numpad1)
- vaccum (numpad2)
- instant go to clicked position (numpad3)
The first thing you have to do is to create a new empty project in visual studio...
- new -> project -> c++ -> empty project
Then you can add a header file called SDK.h, we will add our classes into this header file :
in this file you can have only the method declarations and put them into a cpp file, otherwise you can declare them and define them directly into the header file....
SDK.h
Code:
#ifndef SDK_H
#define SDK_H
#include <Windows.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>
/*
________________________________________________________________________
| |
| UTILS |
|________________________________________________________________________|
*/
namespace Utils
{
using namespace std;
//macro defines for patternScan -> credits LearnMore www.*****************
#define INRANGE(x,a,b) (x >= a && x <= b)
#define getBits( x ) (INRANGE(x,'0','9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xa))
#define getByte( x ) (getBits(x[0]) << 4 | getBits(x[1]))
//Logger class credits : megabyte..
class Logger
{
public:
//log to specified file (ungiven amount of params -> ...)
static void log(const char*format, ...)
{
char buf[1024] = { '\0' };
va_list va_alist;
va_start(va_alist, format);
vsprintf_s(buf, format, va_alist);
va_end(va_alist);
ofstream myfile;
myfile.open("TS2.log", ios::app);
myfile << buf << endl;
myfile.close();
}
//clear log file
static void logDelete()
{
remove("TS2.log");
}
};
//pattern class
class Pattern
{
public:
//find pattern method (credits Learn_More @*************)
static PBYTE findPattern(const PBYTE rangeStart, const PBYTE rangeEnd, const char* pattern)
{
const unsigned char* pat = reinterpret_cast<const unsigned char*>(pattern);
PBYTE firstMatch = 0;
for (PBYTE pCur = rangeStart; pCur < rangeEnd; ++pCur) {
if (*(PBYTE)pat == (BYTE)'\?' || *pCur == getByte(pat)) {
if (!firstMatch) {
firstMatch = pCur;
}
pat += (*(PWORD)pat == (WORD)'\?\?' || *(PBYTE)pat != (BYTE)'\?') ? 3 : 2;
if (!*pat) {
return firstMatch;
}
}
else if (firstMatch) {
pCur = firstMatch;
pat = reinterpret_cast<const unsigned char*>(pattern);
firstMatch = 0;
}
}
return NULL;
}
};
}
/*
________________________________________________________________________
| |
| CHEATCLASSES |
|________________________________________________________________________|
*/
//namespace for all cheats classes
namespace CheatClasses
{
using namespace Utils;
//master class -> parent class of all cheat classes to get some methods/members that can be inherited instead of being declared in each subclasses
class MasterClass
{
private:
//method to find address in one without constantly writing casts and such
void findAddress(DWORD start, DWORD size, const char* pattern, BYTE range){
address = reinterpret_cast<DWORD>(Pattern::findPattern(reinterpret_cast<PBYTE>(start), reinterpret_cast<PBYTE>(size), pattern)) + range;
memcpy(&address, (const void*)address, sizeof(address));
}
public:
//address of all subclasses cheats like(mob address, item address....)
DWORD address;
//findPattern function for all subclasses
bool findPattern(const char* pattern, int sizeTo, const char* name)
{
findAddress(0x00400000, 0x004fffff, pattern, sizeTo);
if (address != NULL){
Logger::log(name);
Logger::log("0x%x", address);
Logger::log("-----------------------");
return true;
}
Logger::log(name, " address: ", "not found");
return false;
}
};
//GameWindow class -> inherited MasterClass ( : Masterclass)
class GameWindow : public MasterClass
{
private:
//private constructor ->accessible via singleton function
GameWindow(){};
//incomplete struct of game window -> use reclass to complete it if you need it
struct GameWindowStruct
{
char pad0[0xda];
BYTE gmSight;
};
// return struct from address
GameWindowStruct* getAddy()
{
return (GameWindowStruct*)(address);
}
public:
//bool to toggle cheat on/off
bool isGmOn = false;
//singleton instance of class
static GameWindow& get()
{
static GameWindow instance;
return instance;
}
//toggle gm vision On/Off
void doGmHack()
{
if (isGmOn)
getAddy()[0].gmSight = 1;
else
getAddy()[0].gmSight = 0;
}
};
//map id class -> inherited MasterClass ( : Masterclass)
class MapId : public MasterClass{
private:
MapId(){};
struct Map{ int id; };
Map& getAddress() { return (Map&)(address); }
public:
static MapId& get()
{
static MapId instance;
return instance;
}
};
//screen class -> inherited MasterClass ( : Masterclass)
class Screen : public MasterClass
{
private:
Screen(){};
struct Screeny{
BYTE id;
};
Screeny& getAddress(){ return (Screeny&)(address); }
public:
static Screen& get()
{
static Screen instance;
return instance;
}
};
// -> inherited MasterClass(: Masterclass)
class Item : public MasterClass
{
private:
Item(){};
struct Inventory{
int itemID;
int row;
int col;
int count;
char Unknown[8];
};
bool isStack;
byte tempRow[128];
byte tempCol[128];
Inventory* getAddy()
{
return (Inventory*)(address);
}
public:
static Item& get()
{
static Item instance;
return instance;
}
void doStack()
{
isStack = !isStack;
if (isStack)
{
for (byte i = 0; i < 128; i++)
{
tempRow[i] = getAddy()[i].row;
getAddy()[i].row = 0;
tempCol[i] = getAddy()[i].col;
getAddy()[i].col = 0;
}
}
else
{
for (byte i = 0; i < 128; i++)
{
getAddy()[i].row = tempRow[i];
getAddy()[i].col = tempCol[i];
}
}
}
};
//Player class inherited from MasterClass
class Player : public MasterClass
{
private:
Player(){};
struct Players{
char pad0[0x20];
int contribution;
char pad1[0x24];
char name[0xD];
char pad2[0x9f];
int action;
int unknown;
float y;
float z;
float x;
float yTo;
float zTo;
float xTo;
};
public:
Players* getAddy()
{
return (Players*)(address);
}
bool isSpeed = false;
static Player& get()
{
static Player instance;
return instance;
}
void doSpeed()
{
if (getAddy()[0].xTo != 0 && getAddy()[0].yTo != 0
&& getAddy()[0].zTo != 0 && isSpeed)
{
getAddy()[0].x = getAddy()[0].xTo;
getAddy()[0].y = getAddy()[0].yTo;
getAddy()[0].z = getAddy()[0].zTo;
}
}
};
//Mob class inherited from masterClass
class Mob : public MasterClass{
private:
Mob(){};
struct Mobs{
char pad0[0x1c];
float y;
float z;
float x;
float yTo;
float zTo;
float xTo;
char pad1[0xdc];
};
Mobs* getAddy()
{
return (Mobs*)(address);
}
public:
bool isVac = false;
static Mob& get()
{
static Mob instance;
return instance;
}
void doVac()
{
if (isVac)
{
for (byte i = 0; i < 64; i++)
{
getAddy()[i].x = Player::get().getAddy()[0].x;
getAddy()[i].y = Player::get().getAddy()[0].y;
getAddy()[i].z = Player::get().getAddy()[0].z;
}
}
}
};
}
#endif
after you've done the SDK you can add main.cpp to your project, its only to toggle cheat and declare dll methods like that :
Main.cpp
Code:
#include "SDK.h"
using namespace CheatClasses;
using namespace Utils;
bool isLoaded = false;
bool findAddresses()
{
Logger::logDelete();
if (!GameWindow::get().findPattern("8b 15 ? ? ? ? 52 6a 00 6a", 2,"window"))return false;
if (!MapId::get().findPattern("83 3d ? ? ? ? 54", 2,"map"))return false;
if (!Screen::get().findPattern("83 3d ? ? ? ? 06 75 4a", 2,"screen"))return false;
if (!Player::get().findPattern("83 b8 ? ? ? ? 00 75 02 eb d8", 2,"player"))return false;
if (!Mob::get().findPattern("8b 82 ? ? ? ? 89 45 f8", 2,"mob"))return false;
if (!Item::get().findPattern("81 bc 02 ? ? ? ? e9 03", 3,"item"))return false;
return true;
}
void WINAPI cheatWork(HMODULE hModule) {
//findAddresses();
if (findAddresses()){
while (true){
if (GetAsyncKeyState(VK_NUMPAD0) & 0x8000){
Sleep(100);
GameWindow::get().isGmOn = !GameWindow::get().isGmOn;
}
if (GetAsyncKeyState(VK_NUMPAD1) & 0x8000){
Sleep(100);
Item::get().doStack();
}
if (GetAsyncKeyState(VK_NUMPAD2) & 0x8000){
Sleep(100);
Mob::get().isVac = !Mob::get().isVac;
}
if (GetAsyncKeyState(VK_NUMPAD3) & 0x8000){
Sleep(100);
Player::get().isSpeed = !Player::get().isSpeed;
}
Mob::get().doVac();
Player::get().doSpeed();
GameWindow::get().doGmHack();
Sleep(100);
}
}
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved){
if (dwReason == DLL_PROCESS_ATTACH) {
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&cheatWork, (HMODULE)hInstance, 0, NULL);
return TRUE;
}
return FALSE;
}
ok, i tell you that's very easy to copy/paste this and make it work into a c++ project, but i released it to educational purposes, so you can have a deeper look how too :
- Find a pattern in C++
- create classes
- create constructors
- using Singleton pattern in C++
- how to access memory from a dll, with pointers or such
- create a DLL
- inheritance, composition in C++
- Logging into a file (output input stream)
if youre interested in OOProgramming, google for the basics in your favorite programming language... If your interested on how to find pattern with cheat engine, there's a lot of tutorials on the internet.
Good luck and happy programing
Credits : LearnMore, Iktov, Megabyte, others ive forget to mention ;)
[Only registered and activated users can see links. Click Here To Register...]