#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <iostream>
#include <string>
#include <d3dx9.h>
#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
using namespace std;
#define QWORD UINT64
struct ResourceManager{
int ResourceArray[0xFFFF];
int GetResource(int iIndex){
return ResourceArray[iIndex] >> 1;
}
int SetResource(int iIndex, int iAmount){
return ResourceArray[iIndex] = iAmount << 1;
}
int MultiplyResource(int iIndex, int iMultiplier){
return ResourceArray[iIndex] *= iMultiplier;
}
int AddResource(int iIndex, int iAmount){
return ResourceArray[iIndex] += iAmount << 1;
}
};
enum TargetType{
None = 0,
Enemy = 1,
Ally = 2
};
struct CWeapon{
WORD Ammo;
WORD Unknown;
BYTE Suppressor; // 0xF - 0x0
void SetSuppressor(float SuppressorVal){
Suppressor = max((BYTE)((float)0xF * SuppressorVal),0);
}
float GetSuppressor(){
return (float)Suppressor / (float)0xF;
}
void SetAmmo(WORD w){
Ammo = max(w,0);
}
WORD GetAmmo(){
return Ammo;
}
};
class CEquipmentList{
public:
CWeapon * GetFultonDevice(){
return (CWeapon*)((QWORD)this + 0x48A);
}
CWeapon * GetWeapon(int WepId){
return (CWeapon*)((QWORD)this + 0x3D8 + 0xC * WepId);
}
};
class CGeneralInformation{
public:
D3DXVECTOR3 * GetFootPosition(){
return (D3DXVECTOR3*)((char*)this + 0xE0);
}
D3DXVECTOR3 * GetCameraPosition1(){ // ?
return (D3DXVECTOR3*)((char*)this + 0x170);
}
D3DXVECTOR3 * GetCameraPosition2(){ // ?
return (D3DXVECTOR3*)((char*)this + 0x1B0);
}
D3DXVECTOR2 * GetAngle1(){ // ?
return (D3DXVECTOR2*)((char*)this + 0x168);
}
D3DXVECTOR2 * GetAngle2(){ // ?
return (D3DXVECTOR2*)((char*)this + 0x160);
}
float * GetCurrentHealth(){
return (float*)((char*)this + 0x3C0);
}
float * GetMaxHealth(){
return (float*)((char*)this + 0x3C4);
}
};
class CCurrentWeaponInformation{
public:
// breath, recoil, spread, probably aim assist
};
class CEntity{
public:
WORD GetTargetInCrosshair(){ // Works under all conditions
return *(WORD*)(*(char**)((char*)this + 0xE0) + 0x5AC);
}
bool HasTargetInCrosshair(){
return GetTargetInCrosshair() != 0xFFFF;
}
CEquipmentList * GetEquipmentList(){
return *(CEquipmentList**)((char*)this + 0xE8);
}
CGeneralInformation * GetGeneralInformation(){
return *(CGeneralInformation**)((char*)this + 0x2A0);
}
CCurrentWeaponInformation * GetCurrentWeaponInformation(){
return *(CCurrentWeaponInformation**)((char*)this + 0x110);
}
bool IsValid(){
return this != nullptr &&
*(char**)((char*)this + 0xE0) != nullptr &&
*(char**)((char*)this + 0xE8) != nullptr &&
*(char**)((char*)this + 0x2A0) != nullptr&&
*(char**)((char*)this + 0x110) != nullptr;
}
};
class CLocalPlayer{
public:
CEntity * GetEntity(){
return *(CEntity**)((char*)this + 0x48);
}
bool IsValid(){
return this != nullptr && GetEntity()->IsValid();
}
};
class CGameModule{
private:
QWORD ModuleHandle;
public:
void * m_pSuppressor = nullptr;
void * m_pAmmo = nullptr;
void * m_pBreathRecoil = nullptr;
void * m_pSpread = nullptr;
DWORD * m_pGMP = nullptr;
ResourceManager * m_pResourceMgr;
char * m_pFultonTemp1;
char * m_pFultonTemp2;
TargetType (__fastcall*CompareTeams) (void * LocalPlayer, DWORD EntityID);
ResourceManager * GetResouceManager(){
return m_pResourceMgr;
}
void SetFultonExtractionCount(char chFultonCount){
GetLocalPlayer()->GetEntity()->GetEquipmentList()->GetFultonDevice()->SetAmmo(chFultonCount);
*m_pFultonTemp1 = chFultonCount;
*m_pFultonTemp2 = chFultonCount;
}
char GetFultonExtractionCount(){
return GetLocalPlayer()->GetEntity()->GetEquipmentList()->GetFultonDevice()->GetAmmo();
}
DWORD GetGmp(){
return *m_pGMP;
}
void SetGmp(DWORD iGMP){
*m_pGMP = iGMP;
}
void AddGmp(DWORD iGMP){
*m_pGMP += iGMP;
}
void MultiplyGmp(float iMultiplier){
*m_pGMP *= iMultiplier;
}
DWORD * GetGmpPointer(){
return m_pGMP;
}
CLocalPlayer * GetLocalPlayer(){
// dynamic
// [ule+2963210]+308]+10
QWORD pLocalPlayer = *(QWORD*)(ModuleHandle + 0x2963210);
if (pLocalPlayer == 0) return nullptr;
pLocalPlayer = *(QWORD*)(pLocalPlayer + 0x308);
if (pLocalPlayer == 0) return nullptr;
pLocalPlayer = *(QWORD*)(pLocalPlayer + 0x10);
return (CLocalPlayer*)pLocalPlayer;
}
void PatchAntiDebugger(){
DWORD Junk;
void * pNtdllProtect = (char*)ModuleHandle + 0x4F47554;
void * pDbgUiRemoteBreakin = GetProcAddress(GetModuleHandle("ntdll.dll"), "DbgUiRemoteBreakin");
void * pDbgUiIssueRemoteBreakin = GetProcAddress(GetModuleHandle("ntdll.dll"), "DbgUiIssueRemoteBreakin");
static char * arNtdllProtect = "\x90\x90";
static char * arDbgUiRemoteBreakin = "\x48\x83\xEC\x28\x65\x48\x8B\x04\x25\x30\x00\x00\x00\x48\x8B\x48\x60\x80\x79\x02\x00\x75\x0A\xF6\x04\x25\xD4\x02\xFE\x7F\x02\x74\x19\x65\x48\x8B\x04\x25\x30\x00\x00\x00\xF6\x80\xEE\x17\x00\x00\x20\x75\x07\xE8\x88\x86\xF5\xFF\xEB\x00\x33\xC9\xE8\x2F\xEA\xF4\xFF\xCC";
static char * arDbgUiIssueRemoteBreakin = "\x4C\x8B\xDC\x53\x48\x83\xEC\x70\x49\x8D\x43\xE8\x45\x33\xC9\x33\xD2\x49\x89\x43\xD8\x49\x8D\x43\x10\x45\x8D\x41\x02\x49\x89\x43\xD0\x49\x83\x63\xC8\x00\x48\x8D\x05\xC3\x11\x03\x00\x49\x89\x43\xC0\x49\x83\x63\xB8\x00\x49\xC7\x43\xB0\x00\x40\x00\x00\x49\x83\x63\xA8\x00\xE8\xD8\x75\xF5\xFF\x8B\xD8\x85\xC0\x78\x0D\x48\x8B\x8C\x24\x88\x00\x00\x00\xE8\x65\xA6\xF8\xFF\x8B\xC3\x48\x83\xC4\x70\x5B\xC3";
static int szNtdllProtect = 2;
static int szDbgUiIssueRemoteBreakin = 99;
static int szDbgUiRemoteBreakin = 66;
VirtualProtect(pNtdllProtect, szNtdllProtect, PAGE_EXECUTE_READWRITE, &Junk);
VirtualProtect(pDbgUiRemoteBreakin, szDbgUiRemoteBreakin, PAGE_EXECUTE_READWRITE, &Junk);
VirtualProtect(pDbgUiIssueRemoteBreakin, szDbgUiIssueRemoteBreakin, PAGE_EXECUTE_READWRITE, &Junk);
memcpy(pNtdllProtect, arNtdllProtect, szNtdllProtect);
memcpy(pDbgUiRemoteBreakin, arDbgUiRemoteBreakin, szDbgUiRemoteBreakin);
memcpy(pDbgUiIssueRemoteBreakin, arDbgUiIssueRemoteBreakin, szDbgUiIssueRemoteBreakin);
}
CGameModule(QWORD ModuleHandle){
this->ModuleHandle = ModuleHandle;
CompareTeams = (TargetType(__fastcall*)(void *, DWORD))(ModuleHandle + 0x3D47F10);
m_pResourceMgr = (ResourceManager*)(ModuleHandle + 0x2ad713c);
m_pSuppressor = (QWORD*)(ModuleHandle + 0x3C54B53);
m_pAmmo = (QWORD*)(ModuleHandle + 0x3C546FF);
m_pBreathRecoil = (QWORD*)(ModuleHandle + 0x3D4D861);
m_pSpread = (QWORD*)(ModuleHandle + 0x3D4B945);
m_pGMP = (DWORD*)(ModuleHandle + 0x2AC9C98);
m_pFultonTemp1 = (char*)(ModuleHandle + 0x2940CAA);
m_pFultonTemp2 = (char*)(ModuleHandle + 0x2AC752A);
}
}