diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml index 9e2b49b..3507551 100644 --- a/.github/workflows/build-check.yml +++ b/.github/workflows/build-check.yml @@ -18,11 +18,11 @@ jobs: - name: Building project run: | - msbuild CS2-External-Base.sln -t:Rebuild -p:Configuration=Release -p:Platform=x64 + msbuild TempleWare-External.sln -t:Rebuild -p:Configuration=Release -p:Platform=x64 - name: Archive artifacts uses: actions/upload-artifact@v4 with: name: Compiled-Binaries path: | - D:\a\CS2-External-Base\x64\Release\CS2-External-Base.exe \ No newline at end of file + D:\a\TempleWare-External\x64\Release\TempleWare-External.exe \ No newline at end of file diff --git a/TempleWare-External/source/features/bhop.cpp b/TempleWare-External/source/features/bhop.cpp index 4510804..598ed3b 100644 --- a/TempleWare-External/source/features/bhop.cpp +++ b/TempleWare-External/source/features/bhop.cpp @@ -14,9 +14,8 @@ namespace features return; HWND hwnd_cs2 = FindWindowA(NULL, "Counter-Strike 2"); - if (hwnd_cs2 == NULL) { + if (hwnd_cs2 == NULL) hwnd_cs2 = FindWindowA(NULL, "Counter-Strike 2"); - } bool spacePressed = GetAsyncKeyState(VK_SPACE); int flags = memory.Read(localPlayer + offsets::m_fFlags); @@ -27,14 +26,9 @@ namespace features SendMessage(hwnd_cs2, WM_KEYUP, VK_SPACE, 0); SendMessage(hwnd_cs2, WM_KEYDOWN, VK_SPACE, 0); } - else if (spacePressed && !isInAir) - { SendMessage(hwnd_cs2, WM_KEYUP, VK_SPACE, 0); - } else if (!spacePressed) - { SendMessage(hwnd_cs2, WM_KEYUP, VK_SPACE, 0); - } } } \ No newline at end of file diff --git a/TempleWare-External/source/features/bhop.h b/TempleWare-External/source/features/bhop.h index 82abab2..987428a 100644 --- a/TempleWare-External/source/features/bhop.h +++ b/TempleWare-External/source/features/bhop.h @@ -10,5 +10,6 @@ namespace features { public: static void Run(const Memory& memory) noexcept; + }; } \ No newline at end of file diff --git a/TempleWare-External/source/features/fov.h b/TempleWare-External/source/features/fov.h index a3ce4a1..b66c6df 100644 --- a/TempleWare-External/source/features/fov.h +++ b/TempleWare-External/source/features/fov.h @@ -2,9 +2,12 @@ #include "../memory/Memory.h" -namespace features { - class FOVManager { +namespace features +{ + class FOVManager + { public: static void AdjustFOV(const Memory& memory) noexcept; + }; } diff --git a/TempleWare-External/source/features/glow.h b/TempleWare-External/source/features/glow.h index 6ae109c..f1cfd4f 100644 --- a/TempleWare-External/source/features/glow.h +++ b/TempleWare-External/source/features/glow.h @@ -2,9 +2,12 @@ #include "../memory/memory.h" -namespace features { - class Glow { +namespace features +{ + class Glow + { public: static void Run(const Memory& memory) noexcept; + }; } diff --git a/TempleWare-External/source/features/noflash.cpp b/TempleWare-External/source/features/noflash.cpp index 822b7ca..e56f845 100644 --- a/TempleWare-External/source/features/noflash.cpp +++ b/TempleWare-External/source/features/noflash.cpp @@ -2,16 +2,22 @@ #include "../globals/globals.h" #include "../offsets/offsets.h" -namespace features { - void NoFlash::Run(const Memory& memory) noexcept { - if (globals::NoFlashEnabled) { +namespace features +{ + + void NoFlash::Run(const Memory& memory) noexcept + { + if (globals::NoFlashEnabled) + { std::uintptr_t localPlayer = memory.Read(globals::client + offsets::dwLocalPlayerPawn); - if (localPlayer) { + + if (localPlayer) + { float flashDuration = memory.Read(localPlayer + offsets::flFlashDuration); - if (flashDuration > 0.0f) { + if (flashDuration > 0.0f) memory.Write(localPlayer + offsets::flFlashDuration, 0.0f); - } } } } + } diff --git a/TempleWare-External/source/features/noflash.h b/TempleWare-External/source/features/noflash.h index 8c1c99b..5205cb4 100644 --- a/TempleWare-External/source/features/noflash.h +++ b/TempleWare-External/source/features/noflash.h @@ -2,9 +2,12 @@ #include "../memory/Memory.h" -namespace features { - class NoFlash { +namespace features +{ + class NoFlash + { public: static void Run(const Memory& memory) noexcept; + }; } diff --git a/TempleWare-External/source/features/triggerbot.cpp b/TempleWare-External/source/features/triggerbot.cpp index e2b9573..ac67e5d 100644 --- a/TempleWare-External/source/features/triggerbot.cpp +++ b/TempleWare-External/source/features/triggerbot.cpp @@ -4,29 +4,36 @@ #include #include -namespace features { +namespace features +{ void TriggerBot::Run(const Memory& memory) noexcept { - while (globals::isRunning) { - if (!globals::TriggerBot) { + while (globals::isRunning) + { + if (!globals::TriggerBot) + { std::this_thread::sleep_for(std::chrono::milliseconds(20)); continue; } - bool keyState = GetAsyncKeyState(globals::TriggerBotKey) & 0x8000; - - if (globals::TriggerBotMode == 0) { - if (!keyState) { + bool keyDown = (GetAsyncKeyState(globals::TriggerBotKey) & 0x8000) != 0; + if (globals::TriggerBotMode == 0) + { + if (!keyDown) + { std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; } } - else if (globals::TriggerBotMode == 1) { - if (keyState) { + else if (globals::TriggerBotMode == 1) + { + if (keyDown) + { globals::TriggerBotToggled = !globals::TriggerBotToggled; std::this_thread::sleep_for(std::chrono::milliseconds(200)); } - if (!globals::TriggerBotToggled) { + if (!globals::TriggerBotToggled) + { std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; } @@ -35,7 +42,8 @@ namespace features { std::uintptr_t localPlayer = memory.Read(globals::client + offsets::dwLocalPlayerPawn); BYTE team = memory.Read(localPlayer + offsets::m_iTeamNum); - if (!globals::TriggerBotIgnoreFlash) { + if (!globals::TriggerBotIgnoreFlash) + { float flashDuration = memory.Read(localPlayer + offsets::flFlashDuration); if (flashDuration > 0.0f) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); @@ -44,32 +52,25 @@ namespace features { } int crosshairEntityIndex = memory.Read(localPlayer + offsets::m_iIDEntIndex); - if (crosshairEntityIndex == 0) { + if (crosshairEntityIndex == 0) continue; - } std::uintptr_t entityList = memory.Read(globals::client + offsets::dwEntityList); - std::uintptr_t listEntry = memory.Read(entityList + 0x8 * (crosshairEntityIndex >> 9) + 0x10); - std::uintptr_t entity = memory.Read(listEntry + 120 * (crosshairEntityIndex & 0x1ff)); - - if (!entity) { + std::uintptr_t entity = memory.Read(memory.Read(entityList + 0x8 * (crosshairEntityIndex >> 9) + 0x10) + 120 * (crosshairEntityIndex & 0x1ff)); + if (!entity) continue; - } - if (globals::TriggerBotTeamCheck && team == memory.Read(entity + offsets::m_iTeamNum)) { + // Skip teammate or dead target (optional) + if (globals::TriggerBotTeamCheck && team == memory.Read(entity + offsets::m_iTeamNum)) continue; - } - if (memory.Read(entity + offsets::m_iHealth) <= 0) { + if (memory.Read(entity + offsets::m_iHealth) <= 0) continue; - } - - memory.Write(globals::client + offsets::attack, 65537); + // Simulate shooting + memory.Write(globals::client + offsets::attack, 65537); // Set attack command std::this_thread::sleep_for(std::chrono::milliseconds(globals::TriggerBotDelay)); - - memory.Write(globals::client + offsets::attack, 256); - + memory.Write(globals::client + offsets::attack, 256); // Clear attack command std::this_thread::sleep_for(std::chrono::milliseconds(globals::TriggerBotDelay)); } } diff --git a/TempleWare-External/source/features/triggerbot.h b/TempleWare-External/source/features/triggerbot.h index a5728f4..306fbfe 100644 --- a/TempleWare-External/source/features/triggerbot.h +++ b/TempleWare-External/source/features/triggerbot.h @@ -2,9 +2,12 @@ #include "../memory/Memory.h" -namespace features { - class TriggerBot { +namespace features +{ + class TriggerBot + { public: static void Run(const Memory& memory) noexcept; + }; } diff --git a/TempleWare-External/source/globals/globals.h b/TempleWare-External/source/globals/globals.h index 73a48e1..beaa1f4 100644 --- a/TempleWare-External/source/globals/globals.h +++ b/TempleWare-External/source/globals/globals.h @@ -6,7 +6,8 @@ #include "../../external/imgui/imgui.h" -namespace globals { +namespace globals +{ // TriggerBot inline bool TriggerBot = false; diff --git a/TempleWare-External/source/memory/memory.h b/TempleWare-External/source/memory/memory.h index 90eb690..48f5e41 100644 --- a/TempleWare-External/source/memory/memory.h +++ b/TempleWare-External/source/memory/memory.h @@ -1,81 +1,72 @@ -#pragma once -#define WIN32_LEAN_AND_MEAN +#pragma once + #include #include - #include -#include +#include -class Memory -{ +class Memory { private: - std::uintptr_t processId = 0; - void* processHandle = nullptr; + std::uintptr_t processId_; + HANDLE processHandle_; public: - - Memory(const std::string_view processName) noexcept + Memory(const std::string& processName) noexcept { - ::PROCESSENTRY32 entry = { }; - entry.dwSize = sizeof(::PROCESSENTRY32); - - const auto snapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + PROCESSENTRY32 entry = { sizeof(PROCESSENTRY32) }; + auto snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - while (::Process32Next(snapShot, &entry)) + while (Process32Next(snapshot, &entry)) { - if (!processName.compare(entry.szExeFile)) + if (entry.szExeFile == processName) { - processId = entry.th32ProcessID; - processHandle = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId); + processId_ = entry.th32ProcessID; + processHandle_ = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId_); break; } } - if (snapShot) - ::CloseHandle(snapShot); + CloseHandle(snapshot); } - ~Memory() + ~Memory() noexcept { - if (processHandle) - ::CloseHandle(processHandle); + if (processHandle_) + CloseHandle(processHandle_); } - const std::uintptr_t GetModuleAddress(const std::string_view moduleName) const noexcept + std::uintptr_t GetModuleAddress(const std::string& moduleName) const noexcept { - ::MODULEENTRY32 entry = { }; - entry.dwSize = sizeof(::MODULEENTRY32); - - const auto snapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processId); - + MODULEENTRY32 entry = { sizeof(MODULEENTRY32) }; + auto snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processId_); std::uintptr_t result = 0; - while (::Module32Next(snapShot, &entry)) + while (Module32Next(snapshot, &entry)) { - if (!moduleName.compare(entry.szModule)) + if (entry.szModule == moduleName) { result = reinterpret_cast(entry.modBaseAddr); break; } } - if (snapShot) - ::CloseHandle(snapShot); - + CloseHandle(snapshot); return result; } template - constexpr const T Read(const std::uintptr_t& address) const noexcept + T Read(const std::uintptr_t& address) const noexcept { - T value = { }; - ::ReadProcessMemory(processHandle, reinterpret_cast(address), &value, sizeof(T), NULL); + T value; + SIZE_T bytesRead; + ReadProcessMemory(processHandle_, reinterpret_cast(address), &value, sizeof(T), &bytesRead); return value; } template - constexpr void Write(const std::uintptr_t& address, const T& value) const noexcept + void Write(const std::uintptr_t& address, const T& value) const noexcept { - ::WriteProcessMemory(processHandle, reinterpret_cast(address), &value, sizeof(T), NULL); + SIZE_T bytesWritten; + WriteProcessMemory(processHandle_, reinterpret_cast(address), &value, sizeof(T), &bytesWritten); } }; \ No newline at end of file diff --git a/TempleWare-External/source/menu/menu.h b/TempleWare-External/source/menu/menu.h index 5aa466b..2b9564d 100644 --- a/TempleWare-External/source/menu/menu.h +++ b/TempleWare-External/source/menu/menu.h @@ -1,5 +1,4 @@ #pragma once - #include namespace gui @@ -7,28 +6,23 @@ namespace gui constexpr int WIDTH = 500; constexpr int HEIGHT = 300; - inline bool isRunning = true; inline HWND window = nullptr; - inline WNDCLASSEX windowClass = { }; - + inline WNDCLASSEX windowClass = {}; inline POINTS position = { }; - inline PDIRECT3D9 d3d = nullptr; inline LPDIRECT3DDEVICE9 device = nullptr; - inline D3DPRESENT_PARAMETERS presentParameters = { }; + inline D3DPRESENT_PARAMETERS presentParameters = {}; void CreateHWindow(const char* windowName) noexcept; void DestroyHWindow() noexcept; - bool CreateDevice() noexcept; void ResetDevice() noexcept; void DestroyDevice() noexcept; void CreateImGui() noexcept; void DestroyImGui() noexcept; - void SetupImGuiStyle() noexcept; void SetupImGuiFonts() noexcept; diff --git a/TempleWare-External/source/offsets/offsets.cpp b/TempleWare-External/source/offsets/offsets.cpp index 194684c..32159c1 100644 --- a/TempleWare-External/source/offsets/offsets.cpp +++ b/TempleWare-External/source/offsets/offsets.cpp @@ -6,73 +6,67 @@ bool Get(std::string url, std::string& response) { - response = ""; std::string cmd = "curl -s -X GET " + url; std::array buffer; std::unique_ptr pipe(_popen(cmd.c_str(), "r"), _pclose); if (!pipe) - { return false; - } + while (fgets(buffer.data(), static_cast(buffer.size()), pipe.get()) != nullptr) - { response += buffer.data(); - } std::regex pattern("\\d{3}:"); if (std::regex_search(response, pattern)) - { return false; - } return true; } bool offsets::UpdateOffset() { - const std::string offsetsUrl = "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json"; - const std::string buttonsUrl = "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/buttons.json"; + const std::string offsetsUrl = "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json"; + const std::string buttonsUrl = "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/buttons.json"; const std::string client_dllUrl = "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/client_dll.json"; std::string offsetsData, buttonsData, client_dllData; if (!Get(offsetsUrl, offsetsData) || !Get(buttonsUrl, buttonsData) || !Get(client_dllUrl, client_dllData)) return 0; - json offsetsJson = json::parse(offsetsData); + json offsetsJson = json::parse(offsetsData); json client_dllJson = json::parse(client_dllData)["client.dll"]["classes"]; - json buttonsJson = json::parse(buttonsData); + json buttonsJson = json::parse(buttonsData); // Game offsets - dwLocalPlayerPawn= offsetsJson["client.dll"]["dwLocalPlayerPawn"]; - dwLocalPlayerController= offsetsJson["client.dll"]["dwLocalPlayerController"]; - dwEntityList= offsetsJson["client.dll"]["dwEntityList"]; - dwViewMatrix= offsetsJson["client.dll"]["dwViewMatrix"]; - dwViewAngles= offsetsJson["client.dll"]["dwViewAngles"]; + dwLocalPlayerPawn= offsetsJson["client.dll"]["dwLocalPlayerPawn"]; + dwLocalPlayerController= offsetsJson["client.dll"]["dwLocalPlayerController"]; + dwEntityList= offsetsJson["client.dll"]["dwEntityList"]; + dwViewMatrix= offsetsJson["client.dll"]["dwViewMatrix"]; + dwViewAngles= offsetsJson["client.dll"]["dwViewAngles"]; // Player details - m_pCameraServices= client_dllJson["C_BasePlayerPawn"]["fields"]["m_pCameraServices"]; - m_glowColorOverride= client_dllJson["CGlowProperty"]["fields"]["m_glowColorOverride"]; - m_iFOV= client_dllJson["CCSPlayerBase_CameraServices"]["fields"]["m_iFOV"]; - m_bGlowing= client_dllJson["CGlowProperty"]["fields"]["m_bGlowing"]; - m_bIsScoped= client_dllJson["C_CSPlayerPawn"]["fields"]["m_bIsScoped"]; - attack= buttonsJson["client.dll"]["attack"]; - m_iIDEntIndex= client_dllJson["C_CSPlayerPawnBase"]["fields"]["m_iIDEntIndex"];; - flFlashDuration= client_dllJson["C_CSPlayerPawnBase"]["fields"]["m_flFlashDuration"]; - m_iShotsFired = client_dllJson["C_CSPlayerPawn"]["fields"]["m_iShotsFired"]; - m_aimPunchAngle = client_dllJson["C_CSPlayerPawn"]["fields"]["m_aimPunchAngle"]; + m_pCameraServices= client_dllJson["C_BasePlayerPawn"]["fields"]["m_pCameraServices"]; + m_glowColorOverride= client_dllJson["CGlowProperty"]["fields"]["m_glowColorOverride"]; + m_iFOV= client_dllJson["CCSPlayerBase_CameraServices"]["fields"]["m_iFOV"]; + m_bGlowing= client_dllJson["CGlowProperty"]["fields"]["m_bGlowing"]; + m_bIsScoped= client_dllJson["C_CSPlayerPawn"]["fields"]["m_bIsScoped"]; + attack= buttonsJson["client.dll"]["attack"]; + m_iIDEntIndex= client_dllJson["C_CSPlayerPawnBase"]["fields"]["m_iIDEntIndex"];; + flFlashDuration= client_dllJson["C_CSPlayerPawnBase"]["fields"]["m_flFlashDuration"]; + m_iShotsFired = client_dllJson["C_CSPlayerPawn"]["fields"]["m_iShotsFired"]; + m_aimPunchAngle = client_dllJson["C_CSPlayerPawn"]["fields"]["m_aimPunchAngle"]; // Entity details - m_hPawn= client_dllJson["CBasePlayerController"]["fields"]["m_hPawn"]; - m_hPlayerPawn= client_dllJson["CCSPlayerController"]["fields"]["m_hPlayerPawn"]; - m_Glow= client_dllJson["C_BaseModelEntity"]["fields"]["m_Glow"]; - m_iHealth= client_dllJson["C_BaseEntity"]["fields"]["m_iHealth"]; - m_iTeamNum= client_dllJson["C_BaseEntity"]["fields"]["m_iTeamNum"];; - m_vOldOrigin= client_dllJson["C_BasePlayerPawn"]["fields"]["m_vOldOrigin"]; - m_entitySpottedState= client_dllJson["C_CSPlayerPawn"]["fields"]["m_entitySpottedState"]; - m_vecViewOffset= client_dllJson["C_BaseModelEntity"]["fields"]["m_vecViewOffset"]; - m_fFlags= client_dllJson["C_BaseEntity"]["fields"]["m_fFlags"]; + m_hPawn= client_dllJson["CBasePlayerController"]["fields"]["m_hPawn"]; + m_hPlayerPawn= client_dllJson["CCSPlayerController"]["fields"]["m_hPlayerPawn"]; + m_Glow= client_dllJson["C_BaseModelEntity"]["fields"]["m_Glow"]; + m_iHealth= client_dllJson["C_BaseEntity"]["fields"]["m_iHealth"]; + m_iTeamNum= client_dllJson["C_BaseEntity"]["fields"]["m_iTeamNum"];; + m_vOldOrigin= client_dllJson["C_BasePlayerPawn"]["fields"]["m_vOldOrigin"]; + m_entitySpottedState= client_dllJson["C_CSPlayerPawn"]["fields"]["m_entitySpottedState"]; + m_vecViewOffset= client_dllJson["C_BaseModelEntity"]["fields"]["m_vecViewOffset"]; + m_fFlags= client_dllJson["C_BaseEntity"]["fields"]["m_fFlags"]; return 1; diff --git a/TempleWare-External/source/offsets/offsets.h b/TempleWare-External/source/offsets/offsets.h index 55cde89..4c0a18c 100644 --- a/TempleWare-External/source/offsets/offsets.h +++ b/TempleWare-External/source/offsets/offsets.h @@ -5,7 +5,8 @@ using json = nlohmann::json; -namespace offsets { +namespace offsets +{ // Game offsets inline std::ptrdiff_t dwLocalPlayerPawn; inline std::ptrdiff_t dwLocalPlayerController; diff --git a/TempleWare-External/source/threads/threads.cpp b/TempleWare-External/source/threads/threads.cpp index 24becb8..d01d134 100644 --- a/TempleWare-External/source/threads/threads.cpp +++ b/TempleWare-External/source/threads/threads.cpp @@ -12,16 +12,20 @@ #include namespace threads { - void RunMiscThread(const Memory& memory) noexcept { - while (gui::isRunning) { + void RunMiscThread(const Memory& memory) noexcept + { + while (gui::isRunning) + { features::FOVManager::AdjustFOV(memory); features::Bhop::Run(memory); std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } - void RunVisualThread(const Memory& memory) noexcept { - while (gui::isRunning) { + void RunVisualThread(const Memory& memory) noexcept + { + while (gui::isRunning) + { features::NoFlash::Run(memory); features::Glow::Run(memory); std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -33,9 +37,7 @@ namespace threads { while (gui::isRunning) { if (globals::TriggerBot) - { features::TriggerBot::Run(memory); - } std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } diff --git a/TempleWare-External/source/threads/threads.h b/TempleWare-External/source/threads/threads.h index 424e5cf..8930957 100644 --- a/TempleWare-External/source/threads/threads.h +++ b/TempleWare-External/source/threads/threads.h @@ -2,7 +2,8 @@ #include "../memory/Memory.h" -namespace threads { +namespace threads +{ void RunMiscThread(const Memory& memory) noexcept; void RunVisualThread(const Memory& memory) noexcept; void RunAimThread(const Memory& memory) noexcept;