Chello, this is just a simple base.
It doesn't have anything like aim, bhop, trigger or anything like that... just a base.
Feel free to use it.
Credits are mentioned in the "Source.cpp".
Code:
// Do your chain hang low?
// =================================================
// | Credits: |
// |************************************************
// | ViKiNG, Steady, and the mpgh community ofc. |
// *************************************************
// You can put all of this into a single header later on.
#include <Windows.h>
#include <iostream>
#include <stddef.h>
#include <stdarg.h>
#include <cstdint>
#include <random>
#include <TlHelp32.h>
#include <string>
#include <xstring>
// vTable Reader.
// Credits to Casual_Hacker
inline void**& getvtable(void* inst, size_t offset = 0)
{
return *reinterpret_cast<void***>((size_t)inst + offset);
}
inline const void** getvtable(const void* inst, size_t offset = 0)
{
return *reinterpret_cast<const void***>((size_t)inst + offset);
}
template< typename o >
inline o getvfunc(const void* inst, size_t index, size_t offset = 0)
{
return reinterpret_cast<o>(getvtable(inst, offset)[index]);
}
// End.
/* Typedef's */
typedef void*(*Interface)(const char*, int*);
typedef void(__thiscall* tPaintTraverse)(void* ecx, unsigned int, bool, bool);
/* -- END -- */
#pragma region ColorClass
class zColor { // Credits: ViKiNG
public:
zColor(int r, int g, int b) {
SetClr(r, g, b, 0);
}
zColor(int r, int g, int b, int a) {
SetClr(r, g, b, a);
}
void SetClr(int r, int g, int b, int a = 0) {
colorz[0] = (unsigned char)r;
colorz[1] = (unsigned char)g;
colorz[2] = (unsigned char)b;
colorz[3] = (unsigned char)a;
}
inline int r() { return colorz[0]; };
inline int g() { return colorz[1]; };
inline int b() { return colorz[2]; };
inline int a() { return colorz[3]; };
static zColor Red() { return zColor(255, 0, 0, 255); };
static zColor Green() { return zColor(0, 255, 0, 255); };
static zColor Black() { return zColor(0, 0, 0, 255); };
static zColor Blue() { return zColor(0, 0, 255, 255); };
static zColor Orange() { return zColor(155, 155, 0, 255); };
private:
unsigned char colorz[4];
};
#define Color zColor
// EPIC SOLID MEME!!!
#pragma endregion ColorClass
#pragma region classes
enum SurfaceIndexes {
DRAWLINE = 19,
DRAWSETCOLOR = 14
};
enum EngineIndexes {
GETLOCALPLAYER = 12,
GETSCREENSIZE = 8
};
enum VguiIndex {
GETNAME = 36,
PAINTTRAVERSE = 41
};
class ISurface {
public:
void DrawSetColor(Color color) {
typedef void(__thiscall* surfaceOriginal)(PVOID, Color);
return getvfunc<surfaceOriginal>(this, DRAWSETCOLOR)(this, color);
}
void DrawLine(int x, int y, int xx, int yy) {
typedef void(__thiscall* surfaceOriginal)(PVOID, int, int, int, int);
return getvfunc<surfaceOriginal>(this, DRAWLINE)(this, x, y, xx, yy);
}
};
class EngineClient {
public:
void GetScreenSize(int& width, int& height) {
typedef void(__thiscall* EngineOriginal)(PVOID, int&, int&);
return getvfunc<EngineOriginal>(this, GETSCREENSIZE)(this, width, height);
}
};
class IPanel {
public:
const char* GetName(unsigned int vguiPanel) {
typedef const char*(__thiscall* vguiOriginal)(PVOID, unsigned int);
return getvfunc<vguiOriginal>(this, GETNAME)(this, vguiPanel);
}
};
class IBaseClientDLL {
public:
};
// Credits: ReactiioN @ Found on UC.
class CVMTHookManager {
public:
CVMTHookManager(void)
{
memset(this, 0, sizeof(CVMTHookManager));
}
CVMTHookManager(PDWORD* ppdwClassBase)
{
bInitialize(ppdwClassBase);
}
~CVMTHookManager(void)
{
UnHook();
}
bool bInitialize(PDWORD* ppdwClassBase)
{
m_ppdwClassBase = ppdwClassBase;
m_pdwOldVMT = *ppdwClassBase;
m_dwVMTSize = dwGetVMTCount(*ppdwClassBase);
m_pdwNewVMT = new DWORD[m_dwVMTSize];
memcpy(m_pdwNewVMT, m_pdwOldVMT, sizeof(DWORD)* m_dwVMTSize);
*ppdwClassBase = m_pdwNewVMT;
return true;
}
bool bInitialize(PDWORD** pppdwClassBase) // fix for pp
{
return bInitialize(*pppdwClassBase);
}
void UnHook(void)
{
if (m_ppdwClassBase)
{
*m_ppdwClassBase = m_pdwOldVMT;
}
}
void ReHook(void)
{
if (m_ppdwClassBase)
{
*m_ppdwClassBase = m_pdwNewVMT;
}
}
int iGetFuncCount(void)
{
return (int)m_dwVMTSize;
}
DWORD dwGetMethodAddress(int Index)
{
if (Index >= 0 && Index <= (int)m_dwVMTSize && m_pdwOldVMT != NULL)
{
return m_pdwOldVMT[Index];
}
return NULL;
}
PDWORD pdwGetOldVMT(void)
{
return m_pdwOldVMT;
}
DWORD dwHookMethod(DWORD dwNewFunc, unsigned int iIndex)
{
if (m_pdwNewVMT && m_pdwOldVMT && iIndex <= m_dwVMTSize && iIndex >= 0)
{
m_pdwNewVMT[iIndex] = dwNewFunc;
return m_pdwOldVMT[iIndex];
}
return NULL;
}
private:
DWORD dwGetVMTCount(PDWORD pdwVMT)
{
DWORD dwIndex = 0;
for (dwIndex = 0; pdwVMT[dwIndex]; dwIndex++)
{
if (IsBadCodePtr((FARPROC)pdwVMT[dwIndex]))
{
break;
}
}
return dwIndex;
}
PDWORD* m_ppdwClassBase;
PDWORD m_pdwNewVMT, m_pdwOldVMT;
DWORD m_dwVMTSize;
};
#pragma endregion classes
EngineClient* pEngine;
IBaseClientDLL* pClient;
ISurface* pSurface;
IPanel* pPanel;
tPaintTraverse oPaintTraverse;
CVMTHookManager* phook;
/* Test drawings... */
void DrawLine(int x, int y, int xx, int yy, Color col) {
pSurface->DrawSetColor(col);
pSurface->DrawLine(x, y, xx, yy);
}
/* END */
void __fastcall hkPaintTraverse(void* ecx, unsigned int vguiPanel, bool forceRepaint, bool allowForce) {
oPaintTraverse(ecx, vguiPanel, forceRepaint, allowForce);
static unsigned int FOP;
if (!FOP) {
const char* szName = pPanel->GetName(vguiPanel);
if (strstr(szName, "FocusOverlayPanel")) {
FOP = vguiPanel;
}
}
if (FOP == vguiPanel) {
DrawLine(10, 20, 30, 40, Color::Red());
}
}
Interface Engine = NULL;
Interface Client = NULL;
Interface Vgui = NULL;
Interface Surface = NULL;
Interface Vst = NULL;
DWORD WINAPI THREAD(LPVOID lpArguments) {
//Put all of your hook's in here.
//All the interface's aswell.
// Client, Engine, Vst, Surface and Vgui... They are all using "CreateInterface"
Engine = Interface(GetProcAddress(GetModuleHandleA("engine.dll"), "CreateInterface"));
Client = Interface(GetProcAddress(GetModuleHandleA("client.dll"), "CreateInterface"));
Surface = Interface(GetProcAddress(GetModuleHandleA("vguimatsurface.dll"), "CreateInterface"));
Vgui = Interface(GetProcAddress(GetModuleHandleA("vgui2.dll"), "CreateInterface"));
pClient = (IBaseClientDLL*)Client("VClient017", NULL);
pEngine = (EngineClient*)Engine("VEngineClient013", NULL);
pSurface = (ISurface*)Surface("VGUI_Surface031", NULL);
pPanel = (IPanel*)Vgui("VGUI_Panel009", NULL);
// Hook PaintTraverse.
phook = new CVMTHookManager((DWORD**)pPanel);
oPaintTraverse = (tPaintTraverse)phook->dwHookMethod((DWORD)hkPaintTraverse, 41);
return false;
}
BOOL APIENTRY DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID lpReserved) {
if (dwReason == DLL_PROCESS_ATTACH) {
// Remember ProcMem "Attach (aka) Process"?
// Here's a china copy of it but is not needed.
if (GetModuleHandleA("csgo.exe")) {
CreateThread(0, NULL, (LPTHREAD_START_ROUTINE)THREAD, 0, NULL, 0);
}
}
return true;
}