From dd0ba0d9345567513a1d147c553db4335ca622c9 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Wed, 28 Apr 2021 06:21:26 -0400 Subject: [PATCH 01/22] increment version --- SingleFile/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 95f12ba..d77a08e 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -848,7 +848,7 @@ VOID WINAPI Init (HMODULE mod) { AllocConsole(); SetConsoleTitleA("singlefile: console"); freopen_s((FILE**)stdout, "CONOUT$", "w", stdout); - printf("singlefile v1.3: loading... (compiled with %d lines of code)\n", GetLineCount()); + printf("singlefile v1.4 beta: loading... (compiled with %d lines of code)\n", GetLineCount()); csgo_window = FindWindowA("Valve001", NULL); orig_proc = (WNDPROC)SetWindowLongA(csgo_window, GWLP_WNDPROC, (LONG)Wndproc); client_dll = GetModuleHandleA("client.dll"); From cdf4941f56525174395403ed412a4fb5d55cf91a Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Wed, 28 Apr 2021 22:08:54 -0400 Subject: [PATCH 02/22] performance improvement --- SingleFile/main.cpp | 112 ++++++++++++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 31 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index d77a08e..8fb8447 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -1,5 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS #include +#include #include #include #include @@ -50,6 +51,7 @@ __forceinline I v(PVOID iface, Args... args) { return (*(I(__thiscall***)(void*, #define VIRTUAL_METHOD(returnType, name, idx, args, argsRaw) __forceinline returnType name args { return vargsRaw; } #define OFFSET(type, name, offset) __forceinline type name(VOID) { return *(type*)(this + offset); } #define ROFFSET(type, name, offset) __forceinline type& name(VOID) { return *(type*)(this + offset);} // not sure if there's a better way to do this but whatever +#define PAD(amt) private: char padding_##amt[amt]; public: using matrix_t = FLOAT[3][4]; using matrix4x4_t = FLOAT[4][4]; BOOLEAN menu_open = TRUE; @@ -71,6 +73,9 @@ struct sconfig { BOOLEAN m_bDisablePostProcess; BOOLEAN m_bRankRevealer; BOOLEAN m_bFlashReducer; + BOOLEAN m_bThirdperson; + INT m_nThirdpersonDistance = 10; + BOOLEAN m_bThirdpersonOnDead; }visuals; struct smisc { BOOLEAN m_bBhop; @@ -105,13 +110,7 @@ class vec3 { }; struct SPlayerInfo { ULONG64 m_ullVersion; - union { - ULONG64 m_ullXUID; - struct { - DWORD m_nXUIDLow; - DWORD m_nXUIDHigh; - }; - }; + ULONG64 m_ullXUID; CHAR m_szName[128]; INT m_nUserID; CHAR m_szGUID[33]; @@ -185,6 +184,7 @@ class CBaseEntity { ROFFSET(FLOAT, FlashMaxAlpha, 0xA41C) OFFSET(INT, Ammo, 0x3264); OFFSET(INT, CrosshairTarget, 0xB3E4); + ROFFSET(INT, ObserverMode, 0x3378); }; class CGlobalVarsBase { public: @@ -226,6 +226,7 @@ class IVEngineClient { VIRTUAL_METHOD(VOID, ClientCmdUnrestricted, 114, (LPCSTR szCommand), (this, szCommand, FALSE)); VIRTUAL_METHOD(LPCSTR, GetVersionString, 105, (VOID), (this)); VIRTUAL_METHOD(INT, GetPlayerIndex, 9, (INT nIndex), (this, nIndex)); + VIRTUAL_METHOD(VOID, GetViewAngles, 18, (vec3& angles), (this, std::ref(angles))); }; class IGameEvent { public: @@ -251,6 +252,32 @@ class ICVar { public: VIRTUAL_METHOD(CConvar*, FindVar, 15, (LPCSTR name), (this, name)); }; +class CRay { +public: + CRay(vec3 vecSource, vec3 vecDest) { this->vecStart = vecSource; this->vecDelta = (vecDelta - vecSource); } + vec3 vecStart; + vec3 vecDelta; +}; +struct CTraceFilter { + LPCVOID pSkip; + CTraceFilter(CBaseEntity* pEntity) { this->pSkip = pEntity; } +}; +class CTrace { +public: + vec3 vecStart; + vec3 vecEnd; + PAD(0x14); + FLOAT flFraction; + PAD(0xC); + LPCSTR pszSurfaceName; + PAD(0x0C); + CBaseEntity* pEntity; + INT nHitbox; +}; +class IEngineTrace { +public: + VIRTUAL_METHOD(VOID, TraceRay, 5, (const CRay& pRay, DWORD dwMask, const CTraceFilter& pSkip, CTrace& pTrace), (this, std::cref(pRay), dwMask, std::cref(pSkip), std::ref(pTrace))); +}; class CRecvProp; class CClientClass { public: @@ -266,20 +293,29 @@ class IClient { VIRTUAL_METHOD(CClientClass*, GetClientClasses, 8, (VOID), (this)) VIRTUAL_METHOD(BOOLEAN, DispatchUserMessage, 38, (INT m_nMessageType, INT m_nArgument1, INT m_nArgument2, PVOID m_pData), (this, m_nMessageType, m_nArgument1, m_nArgument2, m_pData)) }; +class CInput { +public: + PAD(173); + bool bCameraInThirdperson; + PAD(1); + vec3 vecCameraInThirdperson; +}; class IClientModeShared; class IGameEventManager2; class ISound; struct sinterfaces { - IVEngineClient* engine = nullptr; - CMatSystemSurface* surface = nullptr; - CBaseEntityList* entitylist = nullptr; - IPanel* panel = nullptr; - IClient* client = nullptr; - IClientModeShared* client_mode = nullptr; - IGameEventManager2* events = nullptr; - CGlobalVarsBase* globals = nullptr; - ICVar* cvar = nullptr; - ISound* sound = nullptr; + IVEngineClient* engine = NULL; + CMatSystemSurface* surface = NULL; + CBaseEntityList* entitylist = NULL; + IPanel* panel = NULL; + IClient* client = NULL; + IClientModeShared* client_mode = NULL; + IGameEventManager2* events = NULL; + CGlobalVarsBase* globals = NULL; + ICVar* cvar = NULL; + ISound* sound = NULL; + CInput* input = NULL; + IEngineTrace* trace = NULL; }interfaces; HWND csgo_window; WNDPROC orig_proc; @@ -473,6 +509,7 @@ VOID RenderMenu() { menu::checkbox(L"use spam", &config.misc.m_bUseSpam); menu::checkbox(L"flash reducer", &config.visuals.m_bFlashReducer); menu::checkbox(L"vote revealer", &config.misc.m_bVoteRevealer); + menu::checkbox(L"thirdperson", &config.visuals.m_bThirdperson); if (menu::button(L"load", {menu::start_pos.x + 10, menu::start_pos.y + 220}, {195, 30})) load("singlefile"); if (menu::button(L"save", {menu::start_pos.x + 215, menu::start_pos.y + 220}, {195, 30})) @@ -500,6 +537,7 @@ class CUserCmd { private: BYTE pad_0x1[0x18]; }; +VOID(WINAPI* OverrideViewOriginal)(PVOID); BOOLEAN(WINAPI* CreateMoveOriginal)(FLOAT, CUserCmd*); VOID(__thiscall* PaintTraverseOriginal)(IPanel*, DWORD, BOOLEAN, BOOLEAN); BOOLEAN(__thiscall* GameEventsOriginal)(IGameEventManager2*, IGameEvent*); @@ -521,7 +559,7 @@ LRESULT CALLBACK Wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } else { menu::inmove = FALSE; } - return CallWindowProc(orig_proc, hWnd, uMsg, wParam, lParam); + return CallWindowProcA(orig_proc, hWnd, uMsg, wParam, lParam); } enum { IN_ATTACK = 1 << 0, @@ -568,8 +606,11 @@ VOID autopistol(CUserCmd* cmd) { cmd->m_nButtons &= ~IN_ATTACK; } } +DWORD fnv(LPCSTR szString, DWORD nOffset = 0x811C9DC5) { + return (*szString == '\0') ? nOffset : fnv(&szString[1], (nOffset ^ DWORD(*szString)) * 0x01000193); +} VOID autoaccept(LPCSTR sound) { - if (strstr(sound, "UIPanorama.popup_accept_match_beep")) { + if (fnv(sound) == 0x1E7F4590) { // 0x1E7F4590 = Panorama UI Beep Hash static BOOLEAN(WINAPI * SetLPReady)(LPCSTR) = (decltype(SetLPReady))PatternScan(client_dll, "55 8B EC 83 E4 F8 8B 4D 08 BA ? ? ? ? E8 ? ? ? ? 85 C0 75 12"); if (config.misc.m_bAutoAccept) SetLPReady(""); @@ -613,23 +654,28 @@ BOOLEAN WorldToScreen(const vec3& world, vec3& screen) return TRUE; } #define FL_MAX 3.40282e+038; +#define PI 3.1415927f +#define Radians(x) ((FLOAT)(x)*(FLOAT)(PI / 180.f)) vec3 VectorTransform(vec3 in, matrix_t matrix) { return vec3(in.dot(matrix[0]) + matrix[0][3], in.dot(matrix[1]) + matrix[1][3], in.dot(matrix[2]) + matrix[2][3]); } +vec3 AngleVectors(vec3 vecAngles) { + vec3 vecReturn; + FLOAT p1, p2, p3, p4; + p1 = sinf(Radians(vecAngles.y)); + p2 = cosf(Radians(vecAngles.y)); + p3 = sinf(Radians(vecAngles.x)); + p4 = cosf(Radians(vecAngles.x)); + vecReturn = {p4 * p2, p4 * p1, -p3}; + return vecReturn; +} BOOLEAN getbbot(CBaseEntity* player, bbox& box) { matrix_t& rgflTransFrame = (matrix_t&)player->GetCoordinateFrame(); const vec3 min = player->CollisonMins(); const vec3 max = player->CollisonMaxs(); vec3 vecTransScreen[8]; vec3 points[] = { - vec3(min.x, min.y, min.z), - vec3(min.x, max.y, min.z), - vec3(max.x, max.y, min.z), - vec3(max.x, min.y, min.z), - vec3(max.x, max.y, max.z), - vec3(min.x, max.y, max.z), - vec3(min.x, min.y, max.z), - vec3(max.x, min.y, max.z) + vec3(min.x, min.y, min.z), vec3(min.x, max.y, min.z), vec3(max.x, max.y, min.z), vec3(max.x, min.y, min.z), vec3(max.x, max.y, max.z), vec3(min.x, max.y, max.z), vec3(min.x, min.y, max.z), vec3(max.x, min.y, max.z) }; for (INT i = 0; i <= 7; i++) { if (!WorldToScreen(VectorTransform(points[i], rgflTransFrame), vecTransScreen[i])) @@ -773,6 +819,9 @@ VOID usespam(CUserCmd* cmd) { cmd->m_nButtons &= ~IN_USE; } } +VOID __stdcall _OverrideView(PVOID pArgument) { + return OverrideViewOriginal(pArgument); +} BOOLEAN __fastcall _DispatchUserMessage(PVOID ecx, PVOID edx, INT nMessageType, INT nArgument, INT nArgument2, PVOID pData) { if (nMessageType == 47 && config.misc.m_bVoteRevealer) { ColoredMsg(colors::green, "[singlefile] Vote Passed!\n"); Beep(670, 50); } @@ -798,9 +847,6 @@ VOID WINAPI _EmitSound(void* filter, int entityIndex, int channel, const char* s autoaccept(soundEntry); return EmitSoundOriginal(filter, entityIndex, channel, soundEntry, soundEntryHash, sample, volume, seed, soundLevel, flags, pitch, std::cref(origin), std::cref(direction), utlVecOrigins, updatePositions, soundtime, speakerentity, soundParams); } -DWORD fnv(LPCSTR szString, DWORD nOffset = 0x811C9DC5) { - return (*szString == '\0') ? nOffset : fnv(&szString[1], (nOffset ^ DWORD(*szString)) * 0x01000193); -} BOOLEAN WINAPI _GameEvents(IGameEvent* event) { DWORD dwEventHash = fnv(event->GetName()); if (config.misc.m_bHitSound && dwEventHash == 0x1B30DDF0) { @@ -835,6 +881,7 @@ VOID LoadHooks() { MH_CreateHook((*(PVOID**)(interfaces.events))[9], &_GameEvents, (PVOID*)&GameEventsOriginal); MH_CreateHook((*(PVOID**)(interfaces.sound))[5], &_EmitSound, (PVOID*)&EmitSoundOriginal); MH_CreateHook((*(PVOID**)(interfaces.client))[38], &_DispatchUserMessage, (PVOID*)&DispatchUserMessageOriginal); + MH_CreateHook((*(PVOID**)(interfaces.client_mode))[18], &_OverrideView, (PVOID*)&OverrideViewOriginal); MH_EnableHook(NULL); } template @@ -857,7 +904,7 @@ VOID WINAPI Init (HMODULE mod) { PVOID vgui2_dll = GetModuleHandleA("vgui2.dll"); PVOID vstdlib_dll = GetModuleHandleA("vstdlib.dll"); interfaces.engine = CreateInterface(engine_dll, "VEngineClient014"); - if (!strstr(interfaces.engine->GetVersionString(), "1.37.8.7")) + if (!strstr(interfaces.engine->GetVersionString(), "1.37.8.8")) printf("note: you are using an unknown cs:go client version (%s). if you are experiencing crashes, you may need to update offsets. each offset in the source code has it's netvar name, or you can find it on hazedumper.\n", interfaces.engine->GetVersionString()); interfaces.entitylist = CreateInterface(client_dll, "VClientEntityList003"); interfaces.surface = CreateInterface(surface_dll, "VGUI_Surface031"); @@ -866,9 +913,12 @@ VOID WINAPI Init (HMODULE mod) { interfaces.cvar = CreateInterface(vstdlib_dll, "VEngineCvar007"); interfaces.events = CreateInterface(engine_dll, "GAMEEVENTSMANAGER002"); interfaces.sound = CreateInterface(engine_dll, "IEngineSoundClient003"); + interfaces.trace = CreateInterface(engine_dll, "EngineTraceClient004"); interfaces.client_mode = **(IClientModeShared***)((*(DWORD**)(interfaces.client))[0xA] + 0x5); interfaces.globals = **(CGlobalVarsBase***)((*(DWORD**)(interfaces.client))[0xB] + 0xA); + interfaces.input = *(CInput**)((*(DWORD**)(interfaces.client))[0x10] + 0x1); ColoredMsg = (decltype(ColoredMsg))GetProcAddress(GetModuleHandleA("tier0.dll"), "?ConColorMsg@@YAXABVColor@@PBDZZ"); + printf("0x%X\n", fnv("UIPanorama.popup_accept_match_beep")); SetupFonts(); LoadHooks(); printf("finished loading.\n"); From 7a26c1773d99021b368084ff31d61851494fa38d Mon Sep 17 00:00:00 2001 From: fiction Date: Thu, 29 Apr 2021 14:10:00 +0200 Subject: [PATCH 03/22] debugger autoattach --- SingleFile/SingleFile.vcxproj.user | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SingleFile/SingleFile.vcxproj.user b/SingleFile/SingleFile.vcxproj.user index 429333d..67d659e 100644 --- a/SingleFile/SingleFile.vcxproj.user +++ b/SingleFile/SingleFile.vcxproj.user @@ -3,4 +3,9 @@ true + + csgo.exe + true + WindowsLocalDebugger + \ No newline at end of file From 163374fdd73e74750a76ef1906a68bdcdae505dc Mon Sep 17 00:00:00 2001 From: fiction Date: Thu, 29 Apr 2021 14:22:52 +0200 Subject: [PATCH 04/22] feat(fnv): add compile-time fnv hashing --- SingleFile/main.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 8fb8447..5311220 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -606,11 +606,12 @@ VOID autopistol(CUserCmd* cmd) { cmd->m_nButtons &= ~IN_ATTACK; } } -DWORD fnv(LPCSTR szString, DWORD nOffset = 0x811C9DC5) { +__forceinline constexpr DWORD fnv(LPCSTR szString, DWORD nOffset = 0x811C9DC5) { return (*szString == '\0') ? nOffset : fnv(&szString[1], (nOffset ^ DWORD(*szString)) * 0x01000193); } +#define CT_FNV(str) (std::integral_constant::value) VOID autoaccept(LPCSTR sound) { - if (fnv(sound) == 0x1E7F4590) { // 0x1E7F4590 = Panorama UI Beep Hash + if (fnv(sound) == CT_FNV("UIPanorama.popup_accept_match_beep")) { static BOOLEAN(WINAPI * SetLPReady)(LPCSTR) = (decltype(SetLPReady))PatternScan(client_dll, "55 8B EC 83 E4 F8 8B 4D 08 BA ? ? ? ? E8 ? ? ? ? 85 C0 75 12"); if (config.misc.m_bAutoAccept) SetLPReady(""); @@ -634,8 +635,7 @@ VOID flashreducer() { struct bbox { INT x, y, w, h; }; -BOOLEAN WorldToScreen(const vec3& world, vec3& screen) -{ +BOOLEAN WorldToScreen(const vec3& world, vec3& screen) { matrix4x4_t& view = interfaces.engine->GetViewMatrix(); screen.x = world.x * view[0][0] + world.y * view[0][1] + world.z * view[0][2] + view[0][3]; screen.y = world.x * view[1][0] + world.y * view[1][1] + world.z * view[1][2] + view[1][3]; @@ -849,26 +849,26 @@ VOID WINAPI _EmitSound(void* filter, int entityIndex, int channel, const char* s } BOOLEAN WINAPI _GameEvents(IGameEvent* event) { DWORD dwEventHash = fnv(event->GetName()); - if (config.misc.m_bHitSound && dwEventHash == 0x1B30DDF0) { + if (config.misc.m_bHitSound && dwEventHash == CT_FNV("player_hurt")) { SPlayerInfo player; interfaces.engine->GetPlayerInfo(interfaces.engine->GetLocalPlayer(), &player); if (event->GetInt("attacker") == player.m_nUserID) interfaces.engine->ClientCmdUnrestricted("play buttons/arena_switch_press_02"); } - if (dwEventHash == 0xFDAD5FE5 && config.misc.m_bVoteRevealer) + if (dwEventHash == CT_FNV("vote_cast") && config.misc.m_bVoteRevealer) voterevealer(event); return GameEventsOriginal(interfaces.events, event); } VOID WINAPI _PaintTraverse(DWORD dwPanel, BOOLEAN bForceRepaint, BOOLEAN bAllowRepaint) { DWORD drawing = fnv(interfaces.panel->GetPanelName(dwPanel)); - if (drawing == 0xA4A548AF) { // fnv("MatSystemTopPanel") = 0xA4A548AF + if (drawing == CT_FNV("MatSystemTopPanel")) { players(); speclist(); flashreducer(); if (menu_open) RenderMenu(); } - if (drawing == 0x8BE56F81) { // fnv("FocusOverlayPanel") = 0x8BE56F81 + if (drawing == CT_FNV("FocusOverlayPanel")) { interfaces.panel->SetInputMouseState(dwPanel, menu_open); interfaces.panel->SetInputKeyboardState(dwPanel, menu_open && (config.misc.m_bGameKeyboard)); } @@ -918,7 +918,6 @@ VOID WINAPI Init (HMODULE mod) { interfaces.globals = **(CGlobalVarsBase***)((*(DWORD**)(interfaces.client))[0xB] + 0xA); interfaces.input = *(CInput**)((*(DWORD**)(interfaces.client))[0x10] + 0x1); ColoredMsg = (decltype(ColoredMsg))GetProcAddress(GetModuleHandleA("tier0.dll"), "?ConColorMsg@@YAXABVColor@@PBDZZ"); - printf("0x%X\n", fnv("UIPanorama.popup_accept_match_beep")); SetupFonts(); LoadHooks(); printf("finished loading.\n"); @@ -927,7 +926,7 @@ VOID WINAPI Init (HMODULE mod) { MH_DisableHook(NULL); // NULL = all hooks MH_RemoveHook(NULL); MH_Uninitialize(); - FreeConsole(); + FreeLibraryAndExitThread(mod, 0x1); } BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID pReserved) { if (dwReason == DLL_PROCESS_ATTACH) @@ -936,4 +935,4 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID pReserved) { } INT GetLineCount() { // must be at bottom obviously :P return (__LINE__ + 0x1); -} +} \ No newline at end of file From eca073e579f8848862b8d028fd8319c6ba70d013 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 17:29:10 -0400 Subject: [PATCH 05/22] add slider element --- SingleFile/main.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 5311220..e96029c 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -149,7 +149,7 @@ class CCSClientClass { public: PVOID CreateClassFn; PVOID CreateEventFn; - char* m_szNetworkedName; + LPSTR m_szNetworkedName; PVOID m_pRecvTable; CCSClientClass* m_pNextClass; INT m_nClassID; @@ -279,26 +279,17 @@ class IEngineTrace { VIRTUAL_METHOD(VOID, TraceRay, 5, (const CRay& pRay, DWORD dwMask, const CTraceFilter& pSkip, CTrace& pTrace), (this, std::cref(pRay), dwMask, std::cref(pSkip), std::ref(pTrace))); }; class CRecvProp; -class CClientClass { -public: - PVOID m_pCreateFunction; - PVOID m_pCreateEventFunction; - char* m_szNetworkName; - CRecvProp* m_pRecvPointer; - CClientClass* m_pNextPointer; - int m_nClassID; -}; class IClient { public: - VIRTUAL_METHOD(CClientClass*, GetClientClasses, 8, (VOID), (this)) + VIRTUAL_METHOD(CCSClientClass*, GetClientClasses, 8, (VOID), (this)) VIRTUAL_METHOD(BOOLEAN, DispatchUserMessage, 38, (INT m_nMessageType, INT m_nArgument1, INT m_nArgument2, PVOID m_pData), (this, m_nMessageType, m_nArgument1, m_nArgument2, m_pData)) }; class CInput { public: - PAD(173); + PAD(0xAD); bool bCameraInThirdperson; - PAD(1); - vec3 vecCameraInThirdperson; + PAD(0x1); + vec3 vecCameraOffset; }; class IClientModeShared; class IGameEventManager2; @@ -440,7 +431,7 @@ namespace menu { VOID keybinder(PINT pKey) { // Pints for the low hello Dex. INT x = x_pos + 180 - Keys[pKey].width; INT y = y_pos - 15; - LPCWSTR wszKeyName = pwszVirtualKeys[*pKey]; + LPCWSTR wszKeyName = pwszVirtualKeys[*pKey]; DWORD w, xh, h = 20; interfaces.surface->GetTextSize(menu::font, wszKeyName, w, xh); Keys[pKey].width = w + 16; @@ -472,6 +463,19 @@ namespace menu { } } } + VOID slider(LPCWSTR wsz, INT nMin, INT nMax, PINT pnOut) { + + interfaces.surface->SetTextPosition(x_pos + 5, y_pos); y_pos += 12; + interfaces.surface->DrawText(wsz, wcslen(wsz)); + interfaces.surface->SetColor(17, 17, 17, 255); + interfaces.surface->DrawRectOutline(x_pos, y_pos, 120, 15); + interfaces.surface->SetColor(37, 37, 37, 255); + interfaces.surface->DrawRectOutline(x_pos + 1, y_pos + 1, 118, 13); + interfaces.surface->SetColor(25, 100, 255, 255); + interfaces.surface->DrawFilledRect(x_pos + 2, y_pos + 2, (116 * ((FLOAT)(*pnOut) / (FLOAT)(nMax - nMin))), 11); + if (in_region(x_pos - 2, y_pos - 2, 122, 17) && GetAsyncKeyState(VK_LBUTTON)) // make the bbox slightly bigger if the mouse is moving quickly + *pnOut = (FLOAT)((last_mouse_x - x_pos) / 120.f) * nMax; + } } VOID SetupFonts() { menu::font = interfaces.surface->CreateFont(); @@ -509,7 +513,8 @@ VOID RenderMenu() { menu::checkbox(L"use spam", &config.misc.m_bUseSpam); menu::checkbox(L"flash reducer", &config.visuals.m_bFlashReducer); menu::checkbox(L"vote revealer", &config.misc.m_bVoteRevealer); - menu::checkbox(L"thirdperson", &config.visuals.m_bThirdperson); + static int nTest = 102; + menu::slider(L"test slider", 0, 200, &nTest); if (menu::button(L"load", {menu::start_pos.x + 10, menu::start_pos.y + 220}, {195, 30})) load("singlefile"); if (menu::button(L"save", {menu::start_pos.x + 215, menu::start_pos.y + 220}, {195, 30})) From 0f13c7790ff3788c68cfb957c64fb64b49933638 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 17:44:55 -0400 Subject: [PATCH 06/22] show slider value + tweaks --- SingleFile/main.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index e96029c..559563b 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -52,6 +52,7 @@ __forceinline I v(PVOID iface, Args... args) { return (*(I(__thiscall***)(void*, #define OFFSET(type, name, offset) __forceinline type name(VOID) { return *(type*)(this + offset); } #define ROFFSET(type, name, offset) __forceinline type& name(VOID) { return *(type*)(this + offset);} // not sure if there's a better way to do this but whatever #define PAD(amt) private: char padding_##amt[amt]; public: +#define CLAMP(val, _min, _max) (val > _max) ? _max : (val < _min) ? _min : val using matrix_t = FLOAT[3][4]; using matrix4x4_t = FLOAT[4][4]; BOOLEAN menu_open = TRUE; @@ -464,17 +465,21 @@ namespace menu { } } VOID slider(LPCWSTR wsz, INT nMin, INT nMax, PINT pnOut) { - - interfaces.surface->SetTextPosition(x_pos + 5, y_pos); y_pos += 12; + interfaces.surface->SetTextPosition(x_pos + 2, y_pos); y_pos += 12; interfaces.surface->DrawText(wsz, wcslen(wsz)); + WCHAR pwszValue[8]; _itow(*pnOut, pwszValue, 10); DWORD w, h; + interfaces.surface->GetTextSize(menu::font, pwszValue, w, h); + interfaces.surface->SetTextPosition((x_pos + 170) - (w + 2), y_pos - 12); // meh too lazy to change offset + interfaces.surface->DrawText(pwszValue, wcslen(pwszValue)); interfaces.surface->SetColor(17, 17, 17, 255); - interfaces.surface->DrawRectOutline(x_pos, y_pos, 120, 15); + interfaces.surface->DrawRectOutline(x_pos, y_pos, 170, 15); interfaces.surface->SetColor(37, 37, 37, 255); - interfaces.surface->DrawRectOutline(x_pos + 1, y_pos + 1, 118, 13); + interfaces.surface->DrawRectOutline(x_pos + 1, y_pos + 1, 168, 13); interfaces.surface->SetColor(25, 100, 255, 255); - interfaces.surface->DrawFilledRect(x_pos + 2, y_pos + 2, (116 * ((FLOAT)(*pnOut) / (FLOAT)(nMax - nMin))), 11); - if (in_region(x_pos - 2, y_pos - 2, 122, 17) && GetAsyncKeyState(VK_LBUTTON)) // make the bbox slightly bigger if the mouse is moving quickly - *pnOut = (FLOAT)((last_mouse_x - x_pos) / 120.f) * nMax; + interfaces.surface->DrawFilledRect(x_pos + 2, y_pos + 2, (166 * ((FLOAT)(*pnOut) / (FLOAT)(nMax - nMin))), 11); + if (in_region(x_pos - 2, y_pos - 2, 172, 17) && GetAsyncKeyState(VK_LBUTTON)) // make the bbox slightly bigger if the mouse is moving quickly + *pnOut = CLAMP((FLOAT)((last_mouse_x - x_pos) / 170.f) * nMax, nMin, nMax); + y_pos += 20; } } VOID SetupFonts() { From e3715f42f1379dccb33cc45a9937802846e7df57 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 18:38:16 -0400 Subject: [PATCH 07/22] broken colorpicker --- SingleFile/main.cpp | 125 ++++++++++++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 44 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 559563b..2831518 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -35,7 +35,8 @@ PBYTE PatternScan(PVOID m_pModule, LPCSTR m_szSignature) { if (!pat[0x2]) return first_match; pat += (*(PUSHORT)pat == (USHORT)'\?\?' || *(PBYTE)pat != (BYTE)'\?') ? 0x3 : 0x2; - } else { + } + else { if (first_match != 0x0) current = first_match; pat = m_szSignature; @@ -124,16 +125,17 @@ struct SPlayerInfo { }; class CMatSystemSurface { public: - VIRTUAL_METHOD(VOID, DrawFilledRect, 16, (DWORD x, DWORD y, DWORD w, DWORD h), (this, x, y, x + w, y + h)) - VIRTUAL_METHOD(VOID, SetColor, 15, (USHORT r, USHORT g, USHORT b, USHORT a), (this, r, g, b, a)) - VIRTUAL_METHOD(VOID, SetTextColor, 25, (USHORT r, USHORT g, USHORT b, USHORT a), (this, r, g, b, a)) - VIRTUAL_METHOD(VOID, SetTextPosition, 26, (DWORD x, DWORD y), (this, x, y)) - VIRTUAL_METHOD(VOID, DrawText, 28, (LPCWSTR text, DWORD len), (this, text, len, 0)) - VIRTUAL_METHOD(DWORD, CreateFont, 71, (VOID), (this)) - VIRTUAL_METHOD(BOOLEAN, SetFontGlyphs, 72, (DWORD _font, LPCSTR name, DWORD height, DWORD weight, DWORD font_flags), (this, _font, name, height, weight, 0, 0, font_flags, 0, 0)) - VIRTUAL_METHOD(VOID, SetTextFont, 23, (DWORD _font), (this, _font)) - VIRTUAL_METHOD(VOID, DrawRectOutline, 18, (DWORD x, DWORD y, DWORD w, DWORD h), (this, x, y, x + w, y + h)) - VIRTUAL_METHOD(VOID, GetTextSize, 79, (DWORD _font, LPCWSTR text, DWORD& w, DWORD& h), (this, _font, text, std::ref(w), std::ref(h))) + VIRTUAL_METHOD(VOID, DrawFilledRect, 16, (DWORD x, DWORD y, DWORD w, DWORD h), (this, x, y, x + w, y + h)); + VIRTUAL_METHOD(VOID, SetColor, 15, (USHORT r, USHORT g, USHORT b, USHORT a), (this, r, g, b, a)); + VIRTUAL_METHOD(VOID, SetTextColor, 25, (USHORT r, USHORT g, USHORT b, USHORT a), (this, r, g, b, a)); + VIRTUAL_METHOD(VOID, SetTextPosition, 26, (DWORD x, DWORD y), (this, x, y)); + VIRTUAL_METHOD(VOID, DrawText, 28, (LPCWSTR text, DWORD len), (this, text, len, 0)); + VIRTUAL_METHOD(DWORD, CreateFont, 71, (VOID), (this)); + VIRTUAL_METHOD(BOOLEAN, SetFontGlyphs, 72, (DWORD _font, LPCSTR name, DWORD height, DWORD weight, DWORD font_flags), (this, _font, name, height, weight, 0, 0, font_flags, 0, 0)); + VIRTUAL_METHOD(VOID, SetTextFont, 23, (DWORD _font), (this, _font)); + VIRTUAL_METHOD(VOID, DrawRectOutline, 18, (DWORD x, DWORD y, DWORD w, DWORD h), (this, x, y, x + w, y + h)); + VIRTUAL_METHOD(VOID, GetTextSize, 79, (DWORD _font, LPCWSTR text, DWORD& w, DWORD& h), (this, _font, text, std::ref(w), std::ref(h))); + VIRTUAL_METHOD(VOID, GradientRectangle, 123, (INT x, INT y, INT w, INT h, DWORD dwAlpha1, DWORD dwAlpha2, BOOLEAN bHoriz), (this, x, y, w, h, dwAlpha1, dwAlpha2, bHoriz)); }; enum EMoveType { NONE = 0, @@ -179,11 +181,11 @@ class CBaseEntity { ROFFSET(matrix_t, GetCoordinateFrame, 0x444); OFFSET(INT, GetTeamNumber, 0xF4); VIRTUAL_METHOD(CBaseEntity*, GetObserverTarget, 294, (VOID), (this)) - OFFSET(BOOLEAN, IsScoped, 0x3928); + OFFSET(BOOLEAN, IsScoped, 0x3928); ROFFSET(BOOLEAN, Spotted, 0x93D); OFFSET(FLOAT, FlashDuration, 0xA420); ROFFSET(FLOAT, FlashMaxAlpha, 0xA41C) - OFFSET(INT, Ammo, 0x3264); + OFFSET(INT, Ammo, 0x3264); OFFSET(INT, CrosshairTarget, 0xB3E4); ROFFSET(INT, ObserverMode, 0x3378); }; @@ -283,7 +285,7 @@ class CRecvProp; class IClient { public: VIRTUAL_METHOD(CCSClientClass*, GetClientClasses, 8, (VOID), (this)) - VIRTUAL_METHOD(BOOLEAN, DispatchUserMessage, 38, (INT m_nMessageType, INT m_nArgument1, INT m_nArgument2, PVOID m_pData), (this, m_nMessageType, m_nArgument1, m_nArgument2, m_pData)) + VIRTUAL_METHOD(BOOLEAN, DispatchUserMessage, 38, (INT m_nMessageType, INT m_nArgument1, INT m_nArgument2, PVOID m_pData), (this, m_nMessageType, m_nArgument1, m_nArgument2, m_pData)) }; class CInput { public: @@ -328,6 +330,15 @@ VOID save(LPCSTR szConfigName) { fwrite(&config, sizeof(config), 1, cfg); fclose(cfg); } +typedef struct TAGrgba { + INT r, g, b, a; + TAGrgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) { + this->r = r; + this->g = g; + this->b = b; + this->a = a; + } +}RGBA, * PRGBA; namespace menu { struct sctx { BOOLEAN open; INT width; }; std::unordered_map < LPCWSTR, BOOLEAN> item_clicks = {}; @@ -336,10 +347,10 @@ namespace menu { vec2 start_pos, size; BOOLEAN dragging = FALSE, clicked = FALSE, item_active = FALSE, inmove = FALSE; INT x_pos = 0, y_pos = 0, last_mouse_x = 0, last_mouse_y = 0; - BOOLEAN in_region( INT x, INT y, INT w, INT h ) { + BOOLEAN in_region(INT x, INT y, INT w, INT h) { return last_mouse_x >= x && last_mouse_y >= y && last_mouse_x <= x + w && last_mouse_y <= y + h; } - BOOLEAN clicked_at( LPCWSTR n, INT x, INT y, INT w, INT h ) { + BOOLEAN clicked_at(LPCWSTR n, INT x, INT y, INT w, INT h) { if (item_clicks.count(n) == 0) item_clicks[n] = FALSE; if (!in_region(x, y, w, h) && !item_clicks[n] || inmove) return FALSE; item_active = TRUE; @@ -371,7 +382,7 @@ namespace menu { interfaces.surface->SetTextColor(255, 255, 255, 255); static DWORD u, i; interfaces.surface->GetTextSize(menu::font, name, u, i); - interfaces.surface->SetTextPosition( start_pos.x + (size.x / 2) - (u / 2), start_pos.y + 6); + interfaces.surface->SetTextPosition(start_pos.x + (size.x / 2) - (u / 2), start_pos.y + 6); interfaces.surface->DrawText(name, wcslen(name)); x_pos = start_pos.x + 10; y_pos = start_pos.y + 25; @@ -415,7 +426,7 @@ namespace menu { return FALSE; } VOID move(INT x, INT y) { - auto store = [x, y] () -> VOID { menu::last_mouse_x = x; menu::last_mouse_y = y; }; + auto store = [x, y]() -> VOID { menu::last_mouse_x = x; menu::last_mouse_y = y; }; if (!clicked) { menu::dragging = FALSE; return store(); @@ -481,7 +492,35 @@ namespace menu { *pnOut = CLAMP((FLOAT)((last_mouse_x - x_pos) / 170.f) * nMax, nMin, nMax); y_pos += 20; } -} + VOID colorpicker(INT x, PRGBA pColor) { // we'll re-use the Keys object for the opened-ness. + interfaces.surface->SetColor(17, 17, 17, 255); + interfaces.surface->DrawRectOutline(x_pos + x, y_pos, 16, 16); + interfaces.surface->SetColor(37, 37, 37, 255); + interfaces.surface->DrawRectOutline(x_pos + x + 1, y_pos + 1, 14, 14); + interfaces.surface->SetColor(pColor->r, pColor->g, pColor->b, pColor->a); + interfaces.surface->DrawFilledRect(x_pos + x + 2, y_pos + 2, 12, 12); + interfaces.surface->SetColor(0, 0, 0, 255); + interfaces.surface->GradientRectangle(x_pos + x + 2, y_pos + 2, 12, 12, 75, 25, FALSE); // give 3d look + if (in_region(x_pos + x, y_pos, 16, 16) && GetAsyncKeyState(VK_LBUTTON)) + Keys[(PINT)(pColor)].open = TRUE; + if (!in_region(x_pos + x, y_pos, 16, 16) && GetAsyncKeyState(VK_LBUTTON) && !in_region(x_pos + x + 5, y_pos + 5, 230, 200)) + Keys[(PINT)(pColor)].open = FALSE; + if (Keys[(PINT)(pColor)].open) { + interfaces.surface->SetColor(42, 42, 42, 255); + //interfaces.surface->DrawFilledRect(x_pos + x + 5, y_pos + 5, 230, 200); + interfaces.surface->SetColor(37, 37, 37, 255); + interfaces.surface->DrawRectOutline(x_pos + x + 6, y_pos + 6, 228, 198); + interfaces.surface->SetColor(255, 255, 255, 255); + //interfaces.surface->DrawFilledRect(x_pos + x + 7, y_pos + 7, 196, 196); + interfaces.surface->SetColor(1, 1, 1, 255); + interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 255, 0, FALSE); + //interfaces.surface->SetColor(25, 100, 255, 255); + //interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 0, 255, TRUE); // Clipping with these rectangles is fucking retarded idk why, a gradient cannot draw over a regular thing + interfaces.surface->SetColor(25, 100, 220, 255); + interfaces.surface->GradientRectangle(80, 80, 80, 80, 255, 0, TRUE); + } + } +} VOID SetupFonts() { menu::font = interfaces.surface->CreateFont(); interfaces.surface->SetFontGlyphs(menu::font, "Verdana", 12, 600, 0); @@ -495,7 +534,7 @@ VOID RenderMenu() { once = TRUE; } menu::window(L"singlefile csgo internal"); - menu::checkbox(L"bhop", &config.misc.m_bBhop); + menu::checkbox(L"bhop", &config.misc.m_bBhop); menu::checkbox(L"auto pistol", &config.aimbot.m_bAutoPistol); menu::checkbox(L"hitsound", &config.misc.m_bHitSound); menu::checkbox(L"box esp", &config.visuals.m_bBoxESP); @@ -518,18 +557,20 @@ VOID RenderMenu() { menu::checkbox(L"use spam", &config.misc.m_bUseSpam); menu::checkbox(L"flash reducer", &config.visuals.m_bFlashReducer); menu::checkbox(L"vote revealer", &config.misc.m_bVoteRevealer); + RGBA pog(20, 100, 255); + menu::colorpicker(170, &pog); static int nTest = 102; menu::slider(L"test slider", 0, 200, &nTest); - if (menu::button(L"load", {menu::start_pos.x + 10, menu::start_pos.y + 220}, {195, 30})) + if (menu::button(L"load", { menu::start_pos.x + 10, menu::start_pos.y + 220 }, { 195, 30 })) load("singlefile"); - if (menu::button(L"save", {menu::start_pos.x + 215, menu::start_pos.y + 220}, {195, 30})) + if (menu::button(L"save", { menu::start_pos.x + 215, menu::start_pos.y + 220 }, { 195, 30 })) save("singlefile"); } class CUserCmd { private: BYTE pad_0x0[0x4]; public: - INT m_nCommandNumber; + INT m_nCommandNumber; INT m_nTickCount; vec3 m_vecAngles; vec3 m_vecDirection; @@ -566,7 +607,8 @@ LRESULT CALLBACK Wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (uMsg == WM_MOUSEMOVE) { menu::move((INT)((SHORT)(LOWORD(lParam))), (INT)((SHORT)(HIWORD(lParam)))); menu::inmove = TRUE; - } else { + } + else { menu::inmove = FALSE; } return CallWindowProcA(orig_proc, hWnd, uMsg, wParam, lParam); @@ -578,7 +620,7 @@ enum { IN_SCORE = 1 << 16, IN_COUNT = 1 << 26, }; -namespace colors { unsigned char green[4] = {0, 255, 0, 255}; unsigned char lightgreen[4] = {10, 200, 10, 255}; unsigned char red[4] = {255, 0, 0, 255}; unsigned char lightred[4] = {200, 10, 10, 255}; }; +namespace colors { unsigned char green[4] = { 0, 255, 0, 255 }; unsigned char lightgreen[4] = { 10, 200, 10, 255 }; unsigned char red[4] = { 255, 0, 0, 255 }; unsigned char lightred[4] = { 200, 10, 10, 255 }; }; void(*ColoredMsg)(PUCHAR, LPCSTR, ...); VOID voterevealer(IGameEvent* evt = NULL) { if (!config.misc.m_bVoteRevealer || !interfaces.engine->IsInGame()) @@ -638,7 +680,7 @@ VOID flashreducer() { interfaces.engine->GetScreenSize(w, h); interfaces.surface->GetTextSize(6, L"FLASHED!", tw, th); // first 50 built-in vgui fonts: https://cdn.discordapp.com/attachments/634094496300400641/821827439042101258/unknown.png interfaces.surface->SetTextPosition((DWORD)((w * 0.5f) - tw * 0.5f), (DWORD)(h * 0.75f)); - interfaces.surface->SetTextFont(6); + interfaces.surface->SetTextFont(6); interfaces.surface->DrawText(L"FLASHED!", 0x8); } } @@ -676,7 +718,7 @@ vec3 AngleVectors(vec3 vecAngles) { p2 = cosf(Radians(vecAngles.y)); p3 = sinf(Radians(vecAngles.x)); p4 = cosf(Radians(vecAngles.x)); - vecReturn = {p4 * p2, p4 * p1, -p3}; + vecReturn = { p4 * p2, p4 * p1, -p3 }; return vecReturn; } BOOLEAN getbbot(CBaseEntity* player, bbox& box) { @@ -692,7 +734,7 @@ BOOLEAN getbbot(CBaseEntity* player, bbox& box) { return FALSE; } vec3 vecBoxes[] = { - vecTransScreen[3], vecTransScreen[5], vecTransScreen[0], vecTransScreen[4], vecTransScreen[2], vecTransScreen[1], vecTransScreen[6], vecTransScreen[7] + vecTransScreen[3], vecTransScreen[5], vecTransScreen[0], vecTransScreen[4], vecTransScreen[2], vecTransScreen[1], vecTransScreen[6], vecTransScreen[7] }; FLOAT flLeft = vecTransScreen[3].x, flBottom = vecTransScreen[3].y, flRight = vecTransScreen[3].x, flTop = vecTransScreen[3].y; for (INT i = 0; i <= 7; i++) { @@ -711,15 +753,6 @@ BOOLEAN getbbot(CBaseEntity* player, bbox& box) { box.h = (INT)(flBottom)-(INT)(flTop); return TRUE; } -struct rgba { - INT r, g, b, a; - rgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) { - this->r = r; - this->g = g; - this->b = b; - this->a = a; - } -}; VOID players() { if (!interfaces.engine->IsInGame()) return; @@ -758,11 +791,11 @@ VOID players() { } } if (config.visuals.m_bHealthBar) { - rgba healthclr; + RGBA healthclr; if (entity->GetHealth() > 100) - healthclr = rgba(0, 255, 0, 255); + healthclr = RGBA(0, 255, 0, 255); else - healthclr = rgba((INT)(255 - entity->GetHealth() * 2.55f), (INT)(entity->GetHealth() * 2.55f), 0, 255); + healthclr = RGBA((INT)(255 - entity->GetHealth() * 2.55f), (INT)(entity->GetHealth() * 2.55f), 0, 255); interfaces.surface->SetColor(0, 0, 0, 255); interfaces.surface->DrawFilledRect(box.x - 10, box.y - 1, 5, box.h + 2); interfaces.surface->SetColor(healthclr.r, healthclr.g, healthclr.b, healthclr.a); @@ -774,7 +807,7 @@ VOID players() { } VOID cvars() { CBaseEntity* localplayer = interfaces.entitylist->GetEntity(interfaces.engine->GetLocalPlayer()); - interfaces.cvar->FindVar("mat_postprocess_enable")->SetValue(config.visuals.m_bDisablePostProcess ? 0 : 1); + interfaces.cvar->FindVar("mat_postprocess_enable")->SetValue(config.visuals.m_bDisablePostProcess ? 0 : 1); interfaces.cvar->FindVar("cl_crosshair_recoil")->SetValue(config.misc.m_bRecoilCrosshair ? 1 : 0); // i'm sure the ? 1 : 0 doesn't matter but this feels better. /shrug interfaces.cvar->FindVar("weapon_debug_spread_show")->SetValue(((config.misc.m_bNoScopeCrosshair) && !localplayer->IsScoped()) ? 2 : 0); } @@ -834,9 +867,11 @@ VOID __stdcall _OverrideView(PVOID pArgument) { } BOOLEAN __fastcall _DispatchUserMessage(PVOID ecx, PVOID edx, INT nMessageType, INT nArgument, INT nArgument2, PVOID pData) { if (nMessageType == 47 && config.misc.m_bVoteRevealer) { - ColoredMsg(colors::green, "[singlefile] Vote Passed!\n"); Beep(670, 50); } + ColoredMsg(colors::green, "[singlefile] Vote Passed!\n"); Beep(670, 50); + } if (nMessageType == 48 && config.misc.m_bVoteRevealer) { - ColoredMsg(colors::red, "[singlefile] Vote Failed!\n"); Beep(343, 50); } + ColoredMsg(colors::red, "[singlefile] Vote Failed!\n"); Beep(343, 50); + } return DispatchUserMessageOriginal(interfaces.client, nMessageType, nArgument, nArgument2, pData); } BOOLEAN WINAPI _CreateMove(FLOAT flInputSampleTime, CUserCmd* cmd) { @@ -877,6 +912,8 @@ VOID WINAPI _PaintTraverse(DWORD dwPanel, BOOLEAN bForceRepaint, BOOLEAN bAllowR flashreducer(); if (menu_open) RenderMenu(); + interfaces.surface->SetColor(25, 100, 220, 255); + interfaces.surface->GradientRectangle(2, 2, 80, 80, 255, 0, TRUE); } if (drawing == CT_FNV("FocusOverlayPanel")) { interfaces.panel->SetInputMouseState(dwPanel, menu_open); @@ -899,7 +936,7 @@ T CreateInterface(PVOID m_pModule, LPCSTR m_szInterface) { return ((T(*)(LPCSTR, DWORD))GetProcAddress((HMODULE)m_pModule, "CreateInterface"))(m_szInterface, 0x0); } INT GetLineCount(); -VOID WINAPI Init (HMODULE mod) { +VOID WINAPI Init(HMODULE mod) { while (!GetModuleHandleA("serverbrowser.dll")) Sleep(250); AllocConsole(); From 6e44a20157046fa2d7d642a2af53b709582b720b Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 18:39:10 -0400 Subject: [PATCH 08/22] actual broken colorpicker --- SingleFile/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 2831518..17d32d3 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -507,15 +507,15 @@ namespace menu { Keys[(PINT)(pColor)].open = FALSE; if (Keys[(PINT)(pColor)].open) { interfaces.surface->SetColor(42, 42, 42, 255); - //interfaces.surface->DrawFilledRect(x_pos + x + 5, y_pos + 5, 230, 200); + interfaces.surface->DrawFilledRect(x_pos + x + 5, y_pos + 5, 230, 200); interfaces.surface->SetColor(37, 37, 37, 255); interfaces.surface->DrawRectOutline(x_pos + x + 6, y_pos + 6, 228, 198); interfaces.surface->SetColor(255, 255, 255, 255); - //interfaces.surface->DrawFilledRect(x_pos + x + 7, y_pos + 7, 196, 196); + interfaces.surface->DrawFilledRect(x_pos + x + 7, y_pos + 7, 196, 196); interfaces.surface->SetColor(1, 1, 1, 255); interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 255, 0, FALSE); - //interfaces.surface->SetColor(25, 100, 255, 255); - //interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 0, 255, TRUE); // Clipping with these rectangles is fucking retarded idk why, a gradient cannot draw over a regular thing + interfaces.surface->SetColor(25, 100, 255, 255); + interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 0, 255, TRUE); interfaces.surface->SetColor(25, 100, 220, 255); interfaces.surface->GradientRectangle(80, 80, 80, 80, 255, 0, TRUE); } From af11f9b3686a22729b188df5e701c861b70b337a Mon Sep 17 00:00:00 2001 From: fiction Date: Fri, 30 Apr 2021 00:57:31 +0200 Subject: [PATCH 09/22] fix: fixed crash on unload --- SingleFile/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 17d32d3..7345fd9 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -972,6 +972,7 @@ VOID WINAPI Init(HMODULE mod) { Sleep(500); MH_DisableHook(NULL); // NULL = all hooks MH_RemoveHook(NULL); + SetWindowLongA(csgo_window, GWLP_WNDPROC, (LONG_PTR)orig_proc); MH_Uninitialize(); FreeLibraryAndExitThread(mod, 0x1); } From 75cf5a8af8abfd085d62c76c2935c638ba2b1dfb Mon Sep 17 00:00:00 2001 From: fiction Date: Fri, 30 Apr 2021 01:12:51 +0200 Subject: [PATCH 10/22] fix(colorpicker): GradientRectangle coordinates fix --- SingleFile/main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 7345fd9..1c7ffe3 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -135,7 +135,7 @@ class CMatSystemSurface { VIRTUAL_METHOD(VOID, SetTextFont, 23, (DWORD _font), (this, _font)); VIRTUAL_METHOD(VOID, DrawRectOutline, 18, (DWORD x, DWORD y, DWORD w, DWORD h), (this, x, y, x + w, y + h)); VIRTUAL_METHOD(VOID, GetTextSize, 79, (DWORD _font, LPCWSTR text, DWORD& w, DWORD& h), (this, _font, text, std::ref(w), std::ref(h))); - VIRTUAL_METHOD(VOID, GradientRectangle, 123, (INT x, INT y, INT w, INT h, DWORD dwAlpha1, DWORD dwAlpha2, BOOLEAN bHoriz), (this, x, y, w, h, dwAlpha1, dwAlpha2, bHoriz)); + VIRTUAL_METHOD(VOID, GradientRectangle, 123, (INT x, INT y, INT w, INT h, DWORD dwAlpha1, DWORD dwAlpha2, BOOLEAN bHoriz), (this, x, y, x + w, y + h, dwAlpha1, dwAlpha2, bHoriz)); }; enum EMoveType { NONE = 0, @@ -516,8 +516,6 @@ namespace menu { interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 255, 0, FALSE); interfaces.surface->SetColor(25, 100, 255, 255); interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 0, 255, TRUE); - interfaces.surface->SetColor(25, 100, 220, 255); - interfaces.surface->GradientRectangle(80, 80, 80, 80, 255, 0, TRUE); } } } @@ -557,14 +555,14 @@ VOID RenderMenu() { menu::checkbox(L"use spam", &config.misc.m_bUseSpam); menu::checkbox(L"flash reducer", &config.visuals.m_bFlashReducer); menu::checkbox(L"vote revealer", &config.misc.m_bVoteRevealer); - RGBA pog(20, 100, 255); - menu::colorpicker(170, &pog); - static int nTest = 102; - menu::slider(L"test slider", 0, 200, &nTest); if (menu::button(L"load", { menu::start_pos.x + 10, menu::start_pos.y + 220 }, { 195, 30 })) load("singlefile"); if (menu::button(L"save", { menu::start_pos.x + 215, menu::start_pos.y + 220 }, { 195, 30 })) save("singlefile"); + RGBA pog(20, 100, 255); + menu::colorpicker(170, &pog); + static int nTest = 102; + menu::slider(L"test slider", 0, 200, &nTest); } class CUserCmd { private: From 49176599c6b3c598a6c5acafddb201892e5012ff Mon Sep 17 00:00:00 2001 From: fiction Date: Fri, 30 Apr 2021 01:15:41 +0200 Subject: [PATCH 11/22] refactor(renderer): remove debug rectangles --- SingleFile/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 1c7ffe3..af5caf2 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -910,8 +910,6 @@ VOID WINAPI _PaintTraverse(DWORD dwPanel, BOOLEAN bForceRepaint, BOOLEAN bAllowR flashreducer(); if (menu_open) RenderMenu(); - interfaces.surface->SetColor(25, 100, 220, 255); - interfaces.surface->GradientRectangle(2, 2, 80, 80, 255, 0, TRUE); } if (drawing == CT_FNV("FocusOverlayPanel")) { interfaces.panel->SetInputMouseState(dwPanel, menu_open); From 3532c423ee068425def108393ef2a9d47e6f5022 Mon Sep 17 00:00:00 2001 From: fiction Date: Fri, 30 Apr 2021 01:44:39 +0200 Subject: [PATCH 12/22] refactor: reduce lines count from 982 to 969 --- SingleFile/SingleFile.vcxproj | 1 + SingleFile/main.cpp | 21 ++++----------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/SingleFile/SingleFile.vcxproj b/SingleFile/SingleFile.vcxproj index edf10c5..63a8ab6 100644 --- a/SingleFile/SingleFile.vcxproj +++ b/SingleFile/SingleFile.vcxproj @@ -45,6 +45,7 @@ Windows true + minhook.lib;%(AdditionalDependencies) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index af5caf2..17e8312 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -4,15 +4,13 @@ #include #include #include -#pragma comment(lib, "minhook") #define IN_RANGE(x, a, b) (x >= a && x <= b) #define GET_BITS(x) (IN_RANGE(x,'0','9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xA)) #define GET_BYTE(x) (GET_BITS(x[0x0]) << 0x4 | GET_BITS(x[0x1])) PVOID client_dll = NULL; PVOID engine_dll = NULL; HMODULE pModule = NULL; typedef enum MH_STATUS { MH_UNKNOWN = -1, MH_OK = 0, MH_ERROR_ALREADY_INITIALIZED, MH_ERROR_NOT_INITIALIZED, MH_ERROR_ALREADY_CREATED, MH_ERROR_NOT_CREATED, MH_ERROR_ENABLED, MH_ERROR_DISABLED, MH_ERROR_NOT_EXECUTABLE, MH_ERROR_UNSUPPORTED_FUNCTION, MH_ERROR_MEMORY_ALLOC, MH_ERROR_MEMORY_PROTECT, MH_ERROR_MODULE_NOT_FOUND, MH_ERROR_FUNCTION_NOT_FOUND -} -MH_STATUS; // get minhook here: https://github.com/TsudaKageyu/minhook | License for minhook (text of license has not been modified, just newlines removed) : /* MinHook - The Minimalistic API Hooking Library for x64 / x86 * Copyright(C) 2009 - 2017 Tsuda Kageyu. * All rights reserved. * *Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met : * *1. Redistributions of source code must retain the above copyright * notice, this list of conditionsand the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditionsand the following disclaimer in the * documentationand /or other materials provided with the distribution. * *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, *PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * / +} MH_STATUS; // get minhook here: https://github.com/TsudaKageyu/minhook | License for minhook (text of license has not been modified, just newlines removed) : /* MinHook - The Minimalistic API Hooking Library for x64 / x86 * Copyright(C) 2009 - 2017 Tsuda Kageyu. * All rights reserved. * *Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met : * *1. Redistributions of source code must retain the above copyright * notice, this list of conditionsand the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditionsand the following disclaimer in the * documentationand /or other materials provided with the distribution. * *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, *PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * / extern "C" { MH_STATUS WINAPI MH_Initialize(VOID); MH_STATUS WINAPI MH_Uninitialize(VOID); @@ -45,8 +43,6 @@ PBYTE PatternScan(PVOID m_pModule, LPCSTR m_szSignature) { } return NULL; } -#undef DrawText -#undef CreateFont template __forceinline I v(PVOID iface, Args... args) { return (*(I(__thiscall***)(void*, Args...))(iface))[Idx](iface, args...); } #define VIRTUAL_METHOD(returnType, name, idx, args, argsRaw) __forceinline returnType name args { return vargsRaw; } @@ -332,12 +328,7 @@ VOID save(LPCSTR szConfigName) { } typedef struct TAGrgba { INT r, g, b, a; - TAGrgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) { - this->r = r; - this->g = g; - this->b = b; - this->a = a; - } + TAGrgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) : r(r), g(g), b(b), a(a) { } }RGBA, * PRGBA; namespace menu { struct sctx { BOOLEAN open; INT width; }; @@ -601,14 +592,10 @@ LRESULT CALLBACK Wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; } } + menu::inmove = uMsg == WM_MOUSEMOVE; menu::clicked = (BOOLEAN)(wParam & MK_LBUTTON); - if (uMsg == WM_MOUSEMOVE) { + if (menu::inmove) menu::move((INT)((SHORT)(LOWORD(lParam))), (INT)((SHORT)(HIWORD(lParam)))); - menu::inmove = TRUE; - } - else { - menu::inmove = FALSE; - } return CallWindowProcA(orig_proc, hWnd, uMsg, wParam, lParam); } enum { From d000ca4d59e28f8f2f505671ed494a4c67308c7f Mon Sep 17 00:00:00 2001 From: fiction Date: Fri, 30 Apr 2021 01:49:29 +0200 Subject: [PATCH 13/22] refactor: reduce lines count from 969 to 964 --- SingleFile/SingleFile.vcxproj | 2 +- SingleFile/main.cpp | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/SingleFile/SingleFile.vcxproj b/SingleFile/SingleFile.vcxproj index 63a8ab6..45b33a1 100644 --- a/SingleFile/SingleFile.vcxproj +++ b/SingleFile/SingleFile.vcxproj @@ -38,7 +38,7 @@ Level3 true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpplatest diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 17e8312..3e894a0 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -1,13 +1,8 @@ -#define _CRT_SECURE_NO_WARNINGS #include -#include -#include #include -#include -#define IN_RANGE(x, a, b) (x >= a && x <= b) -#define GET_BITS(x) (IN_RANGE(x,'0','9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xA)) +#define GET_BITS(x) ((x >= '0' && x <= '9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xA)) #define GET_BYTE(x) (GET_BITS(x[0x0]) << 0x4 | GET_BITS(x[0x1])) -PVOID client_dll = NULL; PVOID engine_dll = NULL; HMODULE pModule = NULL; +PVOID client_dll = NULL; PVOID engine_dll = NULL; typedef enum MH_STATUS { MH_UNKNOWN = -1, MH_OK = 0, MH_ERROR_ALREADY_INITIALIZED, MH_ERROR_NOT_INITIALIZED, MH_ERROR_ALREADY_CREATED, MH_ERROR_NOT_CREATED, MH_ERROR_ENABLED, MH_ERROR_DISABLED, MH_ERROR_NOT_EXECUTABLE, MH_ERROR_UNSUPPORTED_FUNCTION, MH_ERROR_MEMORY_ALLOC, MH_ERROR_MEMORY_PROTECT, MH_ERROR_MODULE_NOT_FOUND, MH_ERROR_FUNCTION_NOT_FOUND } MH_STATUS; // get minhook here: https://github.com/TsudaKageyu/minhook | License for minhook (text of license has not been modified, just newlines removed) : /* MinHook - The Minimalistic API Hooking Library for x64 / x86 * Copyright(C) 2009 - 2017 Tsuda Kageyu. * All rights reserved. * *Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met : * *1. Redistributions of source code must retain the above copyright * notice, this list of conditionsand the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditionsand the following disclaimer in the * documentationand /or other materials provided with the distribution. * *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, *PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * / From f51b97b76c8fa77424b087485cb26c1b1f818288 Mon Sep 17 00:00:00 2001 From: fiction Date: Fri, 30 Apr 2021 01:56:49 +0200 Subject: [PATCH 14/22] refactor: reduce lines count from 964 to 950 --- SingleFile/main.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 3e894a0..20d8a6d 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -85,11 +85,7 @@ struct sconfig { class vec3 { public: FLOAT x, y, z; - vec3(FLOAT a = 0, FLOAT b = 0, FLOAT c = 0) { - this->x = a; - this->y = b; - this->z = c; - } + vec3(FLOAT a = 0, FLOAT b = 0, FLOAT c = 0) : x(a), y(b), z(c) { } vec3 operator-=(const vec3& in) { x -= in.x; y -= in.y; z -= in.z; return *this; } vec3 operator+=(const vec3& in) { x += in.x; y += in.y; z += in.z; return *this; } vec3 operator/=(const vec3& in) { x /= in.x; y /= in.y; z /= in.z; return *this; } @@ -172,11 +168,11 @@ class CBaseEntity { ROFFSET(matrix_t, GetCoordinateFrame, 0x444); OFFSET(INT, GetTeamNumber, 0xF4); VIRTUAL_METHOD(CBaseEntity*, GetObserverTarget, 294, (VOID), (this)) - OFFSET(BOOLEAN, IsScoped, 0x3928); + OFFSET(BOOLEAN, IsScoped, 0x3928); ROFFSET(BOOLEAN, Spotted, 0x93D); OFFSET(FLOAT, FlashDuration, 0xA420); ROFFSET(FLOAT, FlashMaxAlpha, 0xA41C) - OFFSET(INT, Ammo, 0x3264); + OFFSET(INT, Ammo, 0x3264); OFFSET(INT, CrosshairTarget, 0xB3E4); ROFFSET(INT, ObserverMode, 0x3378); }; @@ -276,7 +272,7 @@ class CRecvProp; class IClient { public: VIRTUAL_METHOD(CCSClientClass*, GetClientClasses, 8, (VOID), (this)) - VIRTUAL_METHOD(BOOLEAN, DispatchUserMessage, 38, (INT m_nMessageType, INT m_nArgument1, INT m_nArgument2, PVOID m_pData), (this, m_nMessageType, m_nArgument1, m_nArgument2, m_pData)) + VIRTUAL_METHOD(BOOLEAN, DispatchUserMessage, 38, (INT m_nMessageType, INT m_nArgument1, INT m_nArgument2, PVOID m_pData), (this, m_nMessageType, m_nArgument1, m_nArgument2, m_pData)) }; class CInput { public: @@ -306,10 +302,7 @@ HWND csgo_window; WNDPROC orig_proc; struct vec2 { INT x, y; - vec2(INT x = 0, INT y = 0) { - this->x = x; - this->y = y; - } + vec2(INT x = 0, INT y = 0) : x(x), y(y) {} }; VOID load(LPCSTR szConfigName) { FILE* cfg = fopen(szConfigName, "r"); @@ -451,10 +444,8 @@ namespace menu { interfaces.surface->DrawFilledRect(x + 1, y + 1, Keys[pKey].width - 2, h - 2); interfaces.surface->SetTextPosition(x + (Keys[pKey].width / 2) - 0x6, y + 3); // 0x6 = 12 / 2, 12 is the size of L"..." on the menu. interfaces.surface->DrawText(L"...", 0x3); - INT nState = *pKey; for (INT i = 0; i < 256; i++) { - USHORT nValue = GetAsyncKeyState(i) & 1; - if (nValue && i != nState) { + if (GetAsyncKeyState( i ) & 1 && i != *pKey) { *pKey = i; Keys[pKey].open = FALSE; } @@ -580,13 +571,8 @@ VOID(WINAPI* EmitSoundOriginal)(PVOID, INT, INT, LPCSTR, DWORD, LPCSTR, FLOAT, I BOOLEAN(__thiscall* DispatchUserMessageOriginal)(PVOID, INT, INT, INT, PVOID); LRESULT CALLBACK Wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if (uMsg == WM_KEYDOWN) { - switch (wParam) { - case VK_INSERT: - menu_open = !menu_open; - break; - } - } + if (uMsg == WM_KEYDOWN && wParam == VK_INSERT) + menu_open ^= true; menu::inmove = uMsg == WM_MOUSEMOVE; menu::clicked = (BOOLEAN)(wParam & MK_LBUTTON); if (menu::inmove) From 15b4f6aceab250059d31b4526d3971de11e5d0a4 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:01:42 -0400 Subject: [PATCH 15/22] rgb to hsv --- SingleFile/SingleFile.vcxproj.user | 5 ----- SingleFile/main.cpp | 36 +++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/SingleFile/SingleFile.vcxproj.user b/SingleFile/SingleFile.vcxproj.user index 67d659e..429333d 100644 --- a/SingleFile/SingleFile.vcxproj.user +++ b/SingleFile/SingleFile.vcxproj.user @@ -3,9 +3,4 @@ true - - csgo.exe - true - WindowsLocalDebugger - \ No newline at end of file diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 17e8312..171a18a 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -330,6 +330,30 @@ typedef struct TAGrgba { INT r, g, b, a; TAGrgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) : r(r), g(g), b(b), a(a) { } }RGBA, * PRGBA; +void RGBtoHSV(RGBA in, PINT h, PINT s, PINT v) { + float flMax = max(max(in.r / 255.f, in.g / 255.f), in.b / 255.f); + float flMin = min(min(in.r / 255.f, in.g / 255.f), in.b / 255.f); + float flDelta = flMax - flMin; + if (flDelta) { + if (flMax == in.r) + *h = 0x3C * (fmodf(in.g / 255.f - in.b / 255.f, 0x6)); + if (flMax == in.g) + *h = 0x3C * ((in.g / 255.f - in.r / 255.f) + 0x2); + if (flMax == in.b) + *h = 0x3C * ((in.r / 255.f - in.g / 255.f) + 0x4); + if (flMax) + *s = flDelta / flMax; + else + *s = 0x0; + *v = flMax; + } else { + *h = 0x0; + *s = 0x0; + *v = flMax; + } + if (*h < 0x0) + *h += 0x168; +} namespace menu { struct sctx { BOOLEAN open; INT width; }; std::unordered_map < LPCWSTR, BOOLEAN> item_clicks = {}; @@ -506,7 +530,17 @@ namespace menu { interfaces.surface->SetColor(1, 1, 1, 255); interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 255, 0, FALSE); interfaces.surface->SetColor(25, 100, 255, 255); - interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 0, 255, TRUE); + interfaces.surface->GradientRectangle(x_pos + x + 7, y_pos + 7, 196, 196, 0, 255, TRUE); + const RGBA Hues[7] = { + {255, 0, 0}, {255, 0, 255}, {0, 0, 255}, {0, 255, 255}, {0, 255, 0}, {255, 255, 0}, {255, 0, 0} + }; + for (INT i = 0; i < 6; i++) { + RGBA coly = Hues[i + 1], colx = Hues[i]; + interfaces.surface->SetColor(colx.r, colx.g, colx.b, 255); + interfaces.surface->DrawFilledRect(x_pos + x + 210, y_pos + 2 + (14 * i), 16, 14); + interfaces.surface->SetColor(coly.r, coly.g, coly.b, 255); + interfaces.surface->GradientRectangle(x_pos + x + 210, y_pos + 2 + (28 * i), 16, 28, 0, 255, FALSE); + } } } } From 6d7eada541a5a62147898ce61af8bb08630ce07e Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:04:14 -0400 Subject: [PATCH 16/22] ensure proper casting --- SingleFile/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 597b5f7..973deb4 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -319,16 +319,16 @@ typedef struct TAGrgba { TAGrgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) : r(r), g(g), b(b), a(a) { } }RGBA, * PRGBA; void RGBtoHSV(RGBA in, PINT h, PINT s, PINT v) { - float flMax = max(max(in.r / 255.f, in.g / 255.f), in.b / 255.f); - float flMin = min(min(in.r / 255.f, in.g / 255.f), in.b / 255.f); + float flMax = max(max((FLOAT)(in.r / 255.f), (FLOAT)(in.g / 255.f)), (FLOAT)(in.b / 255.f)); + float flMin = min(min((FLOAT)(in.r / 255.f), (FLOAT)(in.g / 255.f)), (FLOAT)(in.b / 255.f)); float flDelta = flMax - flMin; if (flDelta) { if (flMax == in.r) - *h = 0x3C * (fmodf(in.g / 255.f - in.b / 255.f, 0x6)); + *h = 0x3C * (fmodf((FLOAT)(in.g / 255.f) - (FLOAT)(in.b / 255.f), 0x6)); if (flMax == in.g) - *h = 0x3C * ((in.g / 255.f - in.r / 255.f) + 0x2); + *h = 0x3C * (((FLOAT)(in.g / 255.f) - (FLOAT)(in.r / 255.f)) + 0x2); if (flMax == in.b) - *h = 0x3C * ((in.r / 255.f - in.g / 255.f) + 0x4); + *h = 0x3C * (((FLOAT)(in.r / 255.f) - (FLOAT)(in.g / 255.f)) + 0x4); if (flMax) *s = flDelta / flMax; else @@ -342,6 +342,7 @@ void RGBtoHSV(RGBA in, PINT h, PINT s, PINT v) { if (*h < 0x0) *h += 0x168; } + namespace menu { struct sctx { BOOLEAN open; INT width; }; std::unordered_map < LPCWSTR, BOOLEAN> item_clicks = {}; From ff91955fe4073610d3c6d7c3f258b6e572fb3ba3 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:08:03 -0400 Subject: [PATCH 17/22] allow some values to be NULL if only one type is required --- SingleFile/main.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 973deb4..9ef031f 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -194,8 +194,7 @@ class CGlobalVarsBase { BOOLEAN m_bClient; BOOLEAN m_bRemoteClient; private: - DWORD unk1; - DWORD unk2; + PAD(0x8); }; template T RelativeToAbsolute(DWORD m_pAddress) { @@ -323,23 +322,25 @@ void RGBtoHSV(RGBA in, PINT h, PINT s, PINT v) { float flMin = min(min((FLOAT)(in.r / 255.f), (FLOAT)(in.g / 255.f)), (FLOAT)(in.b / 255.f)); float flDelta = flMax - flMin; if (flDelta) { - if (flMax == in.r) + if (flMax == in.r && h) *h = 0x3C * (fmodf((FLOAT)(in.g / 255.f) - (FLOAT)(in.b / 255.f), 0x6)); - if (flMax == in.g) + if (flMax == in.g && h) *h = 0x3C * (((FLOAT)(in.g / 255.f) - (FLOAT)(in.r / 255.f)) + 0x2); - if (flMax == in.b) + if (flMax == in.b && h) *h = 0x3C * (((FLOAT)(in.r / 255.f) - (FLOAT)(in.g / 255.f)) + 0x4); - if (flMax) + if (flMax && s) *s = flDelta / flMax; - else - *s = 0x0; + else { + if (s) { *s = 0x0; } } *v = flMax; } else { - *h = 0x0; - *s = 0x0; - *v = flMax; + if (h && s && v) { + *h = 0x0; + *s = 0x0; + *v = flMax; + } } - if (*h < 0x0) + if (h && *h < 0x0) *h += 0x168; } From 80a18f4853ab1ec1b3f40c278241ca79b67968c2 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:30:36 -0400 Subject: [PATCH 18/22] use directx hsv conversions --- SingleFile/main.cpp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 9ef031f..3afc71c 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #define GET_BITS(x) ((x >= '0' && x <= '9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xA)) #define GET_BYTE(x) (GET_BITS(x[0x0]) << 0x4 | GET_BITS(x[0x1])) PVOID client_dll = NULL; PVOID engine_dll = NULL; @@ -316,34 +317,8 @@ VOID save(LPCSTR szConfigName) { typedef struct TAGrgba { INT r, g, b, a; TAGrgba(INT r = 0, INT g = 0, INT b = 0, INT a = 255) : r(r), g(g), b(b), a(a) { } + FLOAT* AsFloat() { FLOAT p[4] = { this->r / 255.f, this->g / 255.f, this->b / 255.f, this->a / 255.f }; return p; } }RGBA, * PRGBA; -void RGBtoHSV(RGBA in, PINT h, PINT s, PINT v) { - float flMax = max(max((FLOAT)(in.r / 255.f), (FLOAT)(in.g / 255.f)), (FLOAT)(in.b / 255.f)); - float flMin = min(min((FLOAT)(in.r / 255.f), (FLOAT)(in.g / 255.f)), (FLOAT)(in.b / 255.f)); - float flDelta = flMax - flMin; - if (flDelta) { - if (flMax == in.r && h) - *h = 0x3C * (fmodf((FLOAT)(in.g / 255.f) - (FLOAT)(in.b / 255.f), 0x6)); - if (flMax == in.g && h) - *h = 0x3C * (((FLOAT)(in.g / 255.f) - (FLOAT)(in.r / 255.f)) + 0x2); - if (flMax == in.b && h) - *h = 0x3C * (((FLOAT)(in.r / 255.f) - (FLOAT)(in.g / 255.f)) + 0x4); - if (flMax && s) - *s = flDelta / flMax; - else { - if (s) { *s = 0x0; } } - *v = flMax; - } else { - if (h && s && v) { - *h = 0x0; - *s = 0x0; - *v = flMax; - } - } - if (h && *h < 0x0) - *h += 0x168; -} - namespace menu { struct sctx { BOOLEAN open; INT width; }; std::unordered_map < LPCWSTR, BOOLEAN> item_clicks = {}; @@ -968,6 +943,11 @@ VOID WINAPI Init(HMODULE mod) { SetupFonts(); LoadHooks(); printf("finished loading.\n"); + RGBA colr(123, 49, 98); + INT h, s, v; + RGBtoHSV(colr, &h, &s, &v); + HSVtoRGB(&colr, h, s, v); + printf("col test: (%d, %d, %d) => (%d, %d, %d) => (%d, %d, %d)\n", 123, 49, 98); while (!GetAsyncKeyState(VK_END)) Sleep(500); MH_DisableHook(NULL); // NULL = all hooks From 8e282c90f56b6c3920c7f8f6ace26a7d42019716 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:31:46 -0400 Subject: [PATCH 19/22] fix error --- SingleFile/main.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 3afc71c..a731a03 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -194,8 +194,6 @@ class CGlobalVarsBase { PVOID m_pGameSaveData; BOOLEAN m_bClient; BOOLEAN m_bRemoteClient; -private: - PAD(0x8); }; template T RelativeToAbsolute(DWORD m_pAddress) { @@ -943,11 +941,6 @@ VOID WINAPI Init(HMODULE mod) { SetupFonts(); LoadHooks(); printf("finished loading.\n"); - RGBA colr(123, 49, 98); - INT h, s, v; - RGBtoHSV(colr, &h, &s, &v); - HSVtoRGB(&colr, h, s, v); - printf("col test: (%d, %d, %d) => (%d, %d, %d) => (%d, %d, %d)\n", 123, 49, 98); while (!GetAsyncKeyState(VK_END)) Sleep(500); MH_DisableHook(NULL); // NULL = all hooks From dfd5267e24e642c0094a1ade233646ae9362c368 Mon Sep 17 00:00:00 2001 From: exploitmafia <78513100+exploitmafia@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:35:28 -0400 Subject: [PATCH 20/22] down to 945 lines --- SingleFile/main.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index a731a03..65ee088 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -178,22 +178,8 @@ class CBaseEntity { ROFFSET(INT, ObserverMode, 0x3378); }; class CGlobalVarsBase { -public: - FLOAT m_flRealTime; - INT m_nFrameCount; - FLOAT m_flAbsFrameTime; - FLOAT m_flAbsFrameStart; + PAD(0x10); // PAD resets access level to public FLOAT m_flCurrentTime; - FLOAT m_flFrameTime; - INT m_nMaxClients; - INT m_nTickCount; - FLOAT m_flTickInterval; - FLOAT m_flInteropolationAmount; - INT m_nTicksThisFrmae; - INT m_nNetworkProtocol; - PVOID m_pGameSaveData; - BOOLEAN m_bClient; - BOOLEAN m_bRemoteClient; }; template T RelativeToAbsolute(DWORD m_pAddress) { From af876cdade091c588d287b2dcf0ab2bea030f6bc Mon Sep 17 00:00:00 2001 From: exploitmafia Date: Mon, 24 May 2021 09:37:58 -0400 Subject: [PATCH 21/22] update offset --- SingleFile/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index 65ee088..aafca03 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -174,7 +174,7 @@ class CBaseEntity { OFFSET(FLOAT, FlashDuration, 0xA420); ROFFSET(FLOAT, FlashMaxAlpha, 0xA41C) OFFSET(INT, Ammo, 0x3264); - OFFSET(INT, CrosshairTarget, 0xB3E4); + OFFSET(INT, CrosshairTarget, 0xB3E8); ROFFSET(INT, ObserverMode, 0x3378); }; class CGlobalVarsBase { From af284eb338266c8c56028f14404e207e5abd0c5d Mon Sep 17 00:00:00 2001 From: exploitmafia Date: Mon, 24 May 2021 09:46:12 -0400 Subject: [PATCH 22/22] clantag changer --- SingleFile/main.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/SingleFile/main.cpp b/SingleFile/main.cpp index aafca03..63ee226 100644 --- a/SingleFile/main.cpp +++ b/SingleFile/main.cpp @@ -81,6 +81,7 @@ struct sconfig { BOOLEAN m_bSpectatorList; BOOLEAN m_bUseSpam; BOOLEAN m_bVoteRevealer; + BOOLEAN m_bClanTag; }misc; }config; class vec3 { @@ -530,11 +531,11 @@ VOID RenderMenu() { if (menu::button(L"load", { menu::start_pos.x + 10, menu::start_pos.y + 220 }, { 195, 30 })) load("singlefile"); if (menu::button(L"save", { menu::start_pos.x + 215, menu::start_pos.y + 220 }, { 195, 30 })) - save("singlefile"); - RGBA pog(20, 100, 255); - menu::colorpicker(170, &pog); - static int nTest = 102; - menu::slider(L"test slider", 0, 200, &nTest); +save("singlefile"); +RGBA pog(20, 100, 255); +menu::colorpicker(170, &pog); +static int nTest = 102; +menu::slider(L"test slider", 0, 200, &nTest); } class CUserCmd { private: @@ -582,7 +583,7 @@ enum { IN_COUNT = 1 << 26, }; namespace colors { unsigned char green[4] = { 0, 255, 0, 255 }; unsigned char lightgreen[4] = { 10, 200, 10, 255 }; unsigned char red[4] = { 255, 0, 0, 255 }; unsigned char lightred[4] = { 200, 10, 10, 255 }; }; -void(*ColoredMsg)(PUCHAR, LPCSTR, ...); +VOID(*ColoredMsg)(PUCHAR, LPCSTR, ...); VOID voterevealer(IGameEvent* evt = NULL) { if (!config.misc.m_bVoteRevealer || !interfaces.engine->IsInGame()) return; @@ -630,6 +631,14 @@ VOID autoaccept(LPCSTR sound) { SetLPReady(""); } } +LPCSTR szClantag = ""; +VOID clantag() { + static VOID(__fastcall * SetClantag)(LPCSTR, LPCSTR) = (decltype(SetClantag))PatternScan(engine_dll, "53 56 57 8B DA 8B F9 FF 15"); + if (config.misc.m_bClanTag && !strstr(szClantag, "SingleFile")) + SetClantag("SingleFile", "SingleFile"); + if (!config.misc.m_bClanTag && strstr(szClantag, "SingleFile")) + SetClantag("\x20", "\x20"); +} VOID flashreducer() { if (!config.visuals.m_bFlashReducer || !interfaces.engine->IsInGame()) return; @@ -778,7 +787,7 @@ VOID speclist() { CBaseEntity* localplayer = interfaces.entitylist->GetEntity(interfaces.engine->GetLocalPlayer()); if (!localplayer) return; - static INT b = 0; + INT b = 0; if (config.misc.m_bSpectatorList) { for (INT i = 1; i <= interfaces.engine->GetMaxClients(); i++) { CBaseEntity* entity = interfaces.entitylist->GetEntity(i); @@ -800,7 +809,6 @@ VOID speclist() { b += 12; } } - b = 0; } VOID triggerbot(CUserCmd* cmd) { if (!(config.aimbot.m_bTriggerbot)) @@ -837,9 +845,10 @@ BOOLEAN __fastcall _DispatchUserMessage(PVOID ecx, PVOID edx, INT nMessageType, } BOOLEAN WINAPI _CreateMove(FLOAT flInputSampleTime, CUserCmd* cmd) { BOOLEAN SetViewAngles = CreateMoveOriginal(flInputSampleTime, cmd); - if (cmd->m_nCommandNumber % 4 == 1) { + if (cmd->m_nCommandNumber % 10 == 1) { cmd->m_nButtons |= IN_COUNT; // anti-afk kick maybe make it it's own option at some point :P cvars(); // commands that do not to run each tick (i.e don't need usercmd, just dependent on localplayer & being in game) + clantag(); } if (cmd->m_nButtons & IN_SCORE && config.visuals.m_bRankRevealer) interfaces.client->DispatchUserMessage(50, 0, 0, NULL);