├── external ├── pch.cpp ├── math.hpp ├── edgejump.hpp ├── on_entity.hpp ├── bhop.hpp ├── glow.hpp ├── triggerbot.hpp ├── skinchanger.hpp ├── imgui.ini ├── aimbot.hpp ├── engine.hpp ├── client.hpp ├── weapon.hpp ├── edgejump.cpp ├── pch.hpp ├── var.hpp ├── convar.hpp ├── sdk.hpp ├── weapon.cpp ├── menu.hpp ├── config.hpp ├── keybind.hpp ├── main.cpp ├── on_world.hpp ├── entity.hpp ├── archivex.hpp ├── safe_vector.hpp ├── config.cpp ├── client.cpp ├── memory.hpp ├── engine.cpp ├── bhop.cpp ├── triggerbot.cpp ├── convar.cpp ├── utils.hpp ├── sdk.cpp ├── aimbot.cpp ├── glow.cpp ├── process.hpp ├── qangle.hpp ├── skinchanger.cpp ├── memory.cpp ├── entity.cpp ├── vector.hpp ├── external.vcxproj.filters ├── offsets.hpp ├── external.vcxproj ├── xorstr.hpp ├── menu.cpp ├── lazy_importer.hpp └── structs.hpp ├── .gitattributes ├── .vscode ├── settings.json └── launch.json ├── external.sln ├── README.md ├── LICENSE ├── .github └── workflows │ └── msbuild.yml └── .gitignore /external/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | external/* -linguist-vendored 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "vector": "cpp", 4 | "memory": "cpp", 5 | "thread": "cpp", 6 | "chrono": "cpp" 7 | } 8 | } -------------------------------------------------------------------------------- /external/math.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define M_PI 3.14159265358979323846f 4 | #define DEG2RAD( x ) ( ( float )( x ) * ( float )( ( float )( M_PI ) / 180.0f ) ) 5 | 6 | namespace math { 7 | 8 | } -------------------------------------------------------------------------------- /external/edgejump.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" 4 | #include "client.hpp" 5 | 6 | class c_edgejump 7 | { 8 | public: 9 | c_edgejump() = default; 10 | ~c_edgejump() = default; 11 | 12 | void run(); 13 | }; 14 | 15 | inline auto g_edgejump = std::unique_ptr(); -------------------------------------------------------------------------------- /external/on_entity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.hpp" 3 | 4 | inline void on_entity_cache() 5 | { 6 | while (var::b_is_running) 7 | { 8 | timer::sleep(250); 9 | 10 | // Update entity 11 | //for (std::int32_t i = 1; i < g_engine->get_max_player_count(); i++) { 12 | // 13 | //} 14 | } 15 | } -------------------------------------------------------------------------------- /external/bhop.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" 4 | #include "client.hpp" 5 | 6 | class c_bhop 7 | { 8 | private: 9 | int last_tick = {}; 10 | int last_frame = {}; 11 | 12 | float function_elapsed = {}; 13 | 14 | public: 15 | c_bhop() = default; 16 | ~c_bhop() = default; 17 | 18 | void run(); 19 | }; 20 | 21 | inline auto g_bhop = std::make_unique(); -------------------------------------------------------------------------------- /external/glow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" 4 | #include "client.hpp" 5 | 6 | class c_glow 7 | { 8 | private: 9 | int last_tick = {}; 10 | int last_frame = {}; 11 | 12 | float function_elapsed = {}; 13 | 14 | public: 15 | c_glow() = default; 16 | ~c_glow() = default; 17 | 18 | void run(); 19 | }; 20 | 21 | inline auto g_glow = std::make_unique(); -------------------------------------------------------------------------------- /external/triggerbot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" 4 | #include "client.hpp" 5 | 6 | class c_triggerbot 7 | { 8 | private: 9 | int last_tick = {}; 10 | int last_frame = {}; 11 | 12 | float function_elapsed = {}; 13 | 14 | public: 15 | c_triggerbot() = default; 16 | ~c_triggerbot() = default; 17 | 18 | void run(); 19 | }; 20 | 21 | inline auto g_triggerbot = std::make_unique(); -------------------------------------------------------------------------------- /external/skinchanger.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" 4 | 5 | class c_skinchanger 6 | { 7 | public: 8 | c_skinchanger() = default; 9 | ~c_skinchanger() = default; 10 | 11 | void populate_models(); 12 | std::int32_t find_model_index_by_name(std::string_view model_name); 13 | 14 | void run(); 15 | }; 16 | 17 | inline std::map g_model_index_list = {}; 18 | inline auto g_skinchanger = std::make_unique(); -------------------------------------------------------------------------------- /external/imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][Debug##Default] 2 | Pos=60,60 3 | Size=400,400 4 | Collapsed=0 5 | 6 | [Window][Hello, world!] 7 | Pos=173,99 8 | Size=339,180 9 | Collapsed=0 10 | 11 | [Window][Dear ImGui Demo] 12 | Pos=121,50 13 | Size=1041,574 14 | Collapsed=0 15 | 16 | [Window][Another Window] 17 | Pos=60,60 18 | Size=198,71 19 | Collapsed=0 20 | 21 | [Window][clicker] 22 | Pos=0,0 23 | Size=600,350 24 | Collapsed=0 25 | 26 | [Window][external] 27 | Pos=0,0 28 | Size=600,350 29 | Collapsed=0 30 | 31 | -------------------------------------------------------------------------------- /external/aimbot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" 4 | #include "client.hpp" 5 | 6 | class c_aimbot 7 | { 8 | private: 9 | int last_tick = {}; 10 | int last_frame = {}; 11 | 12 | float best_fov = {}; 13 | float best_fov_local = { config.aimbot.f_aim_fov }; 14 | Vector best_angle = Vector{}; 15 | 16 | float function_elapsed = {}; 17 | 18 | public: 19 | c_aimbot() = default; 20 | ~c_aimbot() = default; 21 | 22 | void run(); 23 | }; 24 | 25 | inline auto g_aimbot = std::make_unique(); -------------------------------------------------------------------------------- /external/engine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class c_engine 4 | { 5 | public: // Read 6 | std::uintptr_t get_client_state() const; 7 | sdk::structs::globalvars_t get_globalvars() const; 8 | std::int32_t in_game() const; 9 | std::int32_t get_max_player_count() const; 10 | Vector get_view_angles() const; 11 | std::string get_map_name(); 12 | std::string get_game_directory(); 13 | 14 | public: // Write 15 | bool set_view_angles(Vector view_angles) const; 16 | std::int32_t force_full_update() const; 17 | std::uintptr_t get_user_info_table() const; 18 | }; 19 | 20 | inline auto g_engine = std::make_unique(); -------------------------------------------------------------------------------- /external/client.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "engine.hpp" // for g_engine 4 | 5 | class c_client 6 | { 7 | public: // Read 8 | std::tuple get_local_player() const; 9 | bool in_menu() const; 10 | std::int32_t get_game_type() const; 11 | std::uintptr_t get_glow_object_manager() const; 12 | std::int32_t get_force_jump() const; 13 | std::int32_t get_force_attack() const; 14 | 15 | public: // Write 16 | std::int32_t force_jump(const std::int32_t state) const; 17 | std::int32_t force_attack(const std::int32_t state) const; 18 | }; 19 | 20 | inline auto g_client = std::make_unique(); -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(Windows) Launch", 9 | "type": "cppvsdbg", 10 | "request": "launch", 11 | "program": "${workspaceRoot}/external/out/dbg/external.exe", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${fileDirname}", 15 | "environment": [], 16 | "console": "externalTerminal" 17 | }, 18 | ] 19 | } -------------------------------------------------------------------------------- /external/weapon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "offsets.hpp" 4 | 5 | class c_weapon 6 | { 7 | private: 8 | std::int32_t index = {}; 9 | std::uintptr_t address = {}; 10 | 11 | public: 12 | c_weapon(const std::uintptr_t e_address) 13 | { 14 | this->address = e_address; 15 | 16 | if (this->address) 17 | this->index = g_memory->read(e_address + sdk::netvars::m_iItemDefinitionIndex); 18 | } 19 | 20 | public: // Read 21 | constexpr auto& get_weapon_index() const { 22 | return this->index; 23 | } 24 | 25 | constexpr auto& get_weapon_address() const { 26 | return this->address; 27 | } 28 | 29 | sdk::structs::weapon_data_t get_weapon_data() const; 30 | std::int32_t get_table_index() const; 31 | std::string get_weapon_name_from_index() const; 32 | }; -------------------------------------------------------------------------------- /external/edgejump.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "edgejump.hpp" 3 | 4 | void c_edgejump::run() { 5 | while (var::b_is_running) 6 | { 7 | if (!config.misc.b_enable_ej) { 8 | timer::sleep(1); 9 | continue; 10 | } 11 | 12 | if (!var::binds::hold_edgejump_key.get()) { 13 | timer::sleep(1); 14 | continue; 15 | } 16 | 17 | // Check if in a game 18 | if (!g_engine->in_game()) 19 | continue; 20 | 21 | if (!(g_local.get_flags() & sdk::structs::e_flags::FL_ONGROUND)) 22 | continue; 23 | 24 | auto vec_origin = g_local.origin(); 25 | auto vec_origin_cpy = vec_origin; 26 | 27 | vec_origin_cpy.z -= 15; 28 | 29 | // Cast a ray trace onto the object 30 | static rn::valve::trace_t ray = {}; 31 | var::bsp::bp.trace_ray(rn::vector3(vec_origin.x, vec_origin.y, vec_origin.z), 32 | rn::vector3(vec_origin_cpy.x, vec_origin_cpy.y, vec_origin_cpy.z), &ray); 33 | 34 | if ( ray.fraction == 1.0f ) { 35 | g_client->force_jump(6); // +jump 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /external/pch.hpp: -------------------------------------------------------------------------------- 1 | #ifdef __clang__ 2 | // warning: precompiled header uses __DATE__ or __TIME__ 3 | #pragma clang diagnostic ignored "-Wpch-date-time" 4 | #endif 5 | 6 | // defs 7 | #define JM_XORSTR_DISABLE_AVX_INTRINSICS 8 | #define NOMINMAX 9 | 10 | // global incs 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | // external libs 28 | #include 29 | 30 | // incs 31 | #include "xorstr.hpp" 32 | #include "lazy_importer.hpp" 33 | #include "structs.hpp" 34 | #include "vector.hpp" 35 | #include "qangle.hpp" 36 | #include "memory.hpp" 37 | #include "keybind.hpp" 38 | #include "var.hpp" 39 | #include "utils.hpp" 40 | #include "sdk.hpp" 41 | #include "config.hpp" 42 | #include "math.hpp" -------------------------------------------------------------------------------- /external/var.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "safe_vector.hpp" // for safe_vector 4 | #include "entity.hpp" // for c_entity 5 | 6 | namespace var 7 | { 8 | namespace cs 9 | { 10 | inline std::wstring str_process = xorstr(L"csgo.exe"); 11 | inline HWND h_wnd = {}; 12 | } 13 | 14 | namespace binds 15 | { 16 | inline auto hold_triggerbot_key = keybind(false, keybind_state_t::hold, VK_XBUTTON2); 17 | inline auto hold_edgejump_key = keybind(false, keybind_state_t::hold, VK_XBUTTON1); 18 | inline auto hold_aimbot_key = keybind(false, keybind_state_t::hold, VK_LBUTTON); 19 | } 20 | 21 | namespace bsp 22 | { 23 | inline bool parsed_map = {}; 24 | inline rn::bsp_parser bp = {}; 25 | } 26 | 27 | namespace skins 28 | { 29 | inline std::string str_paint_kit = {}; 30 | inline std::vector models = {}; 31 | } 32 | 33 | namespace cache { 34 | inline safe_vector cached_entities = {}; 35 | } 36 | 37 | namespace ui { 38 | inline std::atomic needs_update = {}; 39 | } 40 | 41 | inline bool b_is_running = true; 42 | } -------------------------------------------------------------------------------- /external/convar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // From: https://www.unknowncheats.me/forum/counterstrike-global-offensive/181308-external-convarfinder.html 4 | class c_convar_manager 5 | { 6 | private: 7 | std::uintptr_t cvar_address = {}; 8 | 9 | public: 10 | c_convar_manager(const std::uintptr_t cvar = {}) { 11 | this->cvar_address = cvar; 12 | }; 13 | 14 | ~c_convar_manager() = default; 15 | 16 | public: // Read 17 | constexpr auto &get_pointer() const { 18 | return this->cvar_address; 19 | } 20 | 21 | int get_flags() const; 22 | std::string get_default_value() const; 23 | std::string get_string() const; 24 | float get_float() const; 25 | std::int32_t get_int() const; 26 | 27 | public: // Write 28 | void set(std::string value) const; 29 | void set(float value) const; 30 | void set(std::int32_t value) const; 31 | }; 32 | 33 | class c_convar : private c_convar_manager 34 | { 35 | public: // Read 36 | void populate_convars(); 37 | c_convar_manager find(std::string_view convar_name); 38 | }; 39 | 40 | inline std::map g_convar_list = {}; 41 | inline auto g_convar = std::make_unique(); -------------------------------------------------------------------------------- /external.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external", "external\external.vcxproj", "{F2BF0214-71E2-48C7-A58B-6D028037C13E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F2BF0214-71E2-48C7-A58B-6D028037C13E}.Debug|x86.ActiveCfg = Debug|Win32 15 | {F2BF0214-71E2-48C7-A58B-6D028037C13E}.Debug|x86.Build.0 = Debug|Win32 16 | {F2BF0214-71E2-48C7-A58B-6D028037C13E}.Release|x86.ActiveCfg = Release|Win32 17 | {F2BF0214-71E2-48C7-A58B-6D028037C13E}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {42C5B6C8-AF48-4435-A9D0-8EE4865ED7AE} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /external/sdk.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "process.hpp" 4 | #include "memory.hpp" 5 | #include "offsets.hpp" 6 | #include "structs.hpp" 7 | 8 | #include 9 | 10 | #include 11 | 12 | class c_basesdk 13 | { 14 | private: 15 | process proc = {}; 16 | 17 | std::pair engine = {}; 18 | std::pair client = {}; 19 | std::pair vstdlib = {}; 20 | 21 | struct image_t 22 | { 23 | std::uintptr_t base; 24 | std::uintptr_t size; 25 | } image = {}; 26 | 27 | public: 28 | c_basesdk() = default; 29 | ~c_basesdk(); 30 | 31 | bool run(); 32 | bool check_for_version_mismatch() const; 33 | 34 | constexpr auto &get_engine_image() 35 | { 36 | image = {engine.first, engine.second}; 37 | return image; 38 | }; 39 | 40 | constexpr auto &get_client_image() 41 | { 42 | image = {client.first, client.second}; 43 | return image; 44 | }; 45 | 46 | constexpr auto &get_vstdlib_image() 47 | { 48 | image = {vstdlib.first, vstdlib.second}; 49 | return image; 50 | }; 51 | }; 52 | 53 | namespace sdk 54 | { 55 | inline auto base = std::make_unique(); 56 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # external 2 | 3 | CS:GO external cheat with the most basic features that I like to use such as perfect bhop and non-flickering glow, really focused on performance. 4 | I made this for fun and personal use, don't expect it to be reliable for you. 5 | 6 | ## Credits 7 | 8 | - [qo0-base](https://github.com/rollraw/qo0-base) for their structs and organized code. 9 | - [hazedumper](https://github.com/frk1/hazedumper) for all the offsets. 10 | 11 | ## Compiling 12 | 13 | You need [LLVM-Obfuscator](https://github.com/heroims/obfuscator) for [Clang 13](https://github.com/heroims/obfuscator/tree/llvm-13.x) to successfully compile this project in Release. 14 | Once installed, follow [this guide](https://docs.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170#custom_llvm_location) and change the property `LLVMInstallDir` to the path of the compiled llvm-obfuscator with the libraries and binaries. 15 | 16 | ## Keybinds 17 | 18 | - `Mouse 1` - Aimbot 19 | - `Mouse 5` - Hold for triggerbot 20 | - `Home` - Toggle for glow 21 | - `Del` - Unload 22 | - `End` - Toggle skin changer (currently hard-coded vanilla M9 Bayonet, high cpu usage, unstable, may cause the cheat or the game to crash.) 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /.github/workflows/msbuild.yml: -------------------------------------------------------------------------------- 1 | name: MSBuild 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | env: 10 | # Path to the solution file relative to the root of the project. 11 | SOLUTION_FILE_PATH: . 12 | 13 | # Configuration type to build. 14 | # You can convert this to a build matrix if you need coverage of multiple configuration types. 15 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 16 | BUILD_CONFIGURATION: Debug 17 | 18 | permissions: 19 | contents: read 20 | 21 | jobs: 22 | build: 23 | runs-on: windows-latest 24 | 25 | steps: 26 | - uses: actions/checkout@v3 27 | 28 | - name: Add MSBuild to PATH 29 | uses: microsoft/setup-msbuild@v1.0.2 30 | 31 | - name: Restore NuGet packages 32 | working-directory: ${{env.GITHUB_WORKSPACE}} 33 | run: nuget restore ${{env.SOLUTION_FILE_PATH}} 34 | 35 | - name: Build 36 | working-directory: ${{env.GITHUB_WORKSPACE}} 37 | # Add additional options to the MSBuild command line here (like platform or verbosity level). 38 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference 39 | run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} 40 | -------------------------------------------------------------------------------- /external/weapon.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "weapon.hpp" 3 | 4 | // Thanks to: https://www.unknowncheats.me/forum/counterstrike-global-offensive/408596-ccsweapondata-itemdefinitionindex-internal-external.html 5 | sdk::structs::weapon_data_t c_weapon::get_weapon_data() const { 6 | auto weapon_table = g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwWeaponTable); 7 | 8 | for (std::int16_t i = 0; i <= weapon_table.last_index; i++) 9 | { 10 | auto current_weapon = g_memory->read((std::uintptr_t)weapon_table.weapon_table + sizeof(sdk::structs::weapon_info_table_object_t) * i); // weapon_data_t* pWeaponInfo; 0x000C WeaponInfo* 11 | if (current_weapon.item_definition_index == this->index) 12 | return g_memory->read((std::uintptr_t)current_weapon.weapon_info); 13 | } 14 | 15 | return {}; 16 | } 17 | 18 | std::int32_t c_weapon::get_table_index() const { 19 | return g_memory->read(this->address + sdk::offsets::dwWeaponTableIndex); 20 | } 21 | 22 | std::string c_weapon::get_weapon_name_from_index() const { 23 | for (const auto& [weapon_id, weapon_info] : sdk::structs::m_item_list) 24 | { 25 | if (weapon_id == this->index) 26 | return std::string(weapon_info.name); 27 | } 28 | 29 | return {}; 30 | } -------------------------------------------------------------------------------- /external/menu.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "weapon.hpp" 9 | 10 | #pragma comment(lib, "imgui.lib") 11 | #pragma comment(lib, "d3d9.lib") 12 | 13 | // Forward declare message handler from imgui_impl_win32.cpp 14 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 15 | 16 | namespace dx { 17 | // Data 18 | static LPDIRECT3D9 d3d = {}; 19 | static LPDIRECT3DDEVICE9 d3d_device = {}; 20 | static D3DPRESENT_PARAMETERS d3d_param = {}; 21 | } 22 | 23 | namespace ctx { 24 | inline HWND hWnd = {}; 25 | inline WNDCLASSEXW wc = {}; 26 | inline int menu_width = { 600 }, menu_height = { 350 }; 27 | } 28 | 29 | class c_menu 30 | { 31 | private: 32 | static LRESULT WINAPI wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 33 | void set_position(int x, int y, int cx, int cy, HWND hwnd); 34 | void get_mouse_offset(int& x, int& y, HWND hwnd); 35 | 36 | private: 37 | bool create_device_d3d(HWND hWnd); 38 | void cleanup_device_d3d(); 39 | void on_paint(); 40 | static void reset_device(); 41 | 42 | public: 43 | c_menu() = default; 44 | ~c_menu() = default; 45 | 46 | bool setup(); 47 | void render(); 48 | void destroy(); 49 | }; 50 | 51 | inline auto g_menu = std::unique_ptr(); -------------------------------------------------------------------------------- /external/config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "archivex.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class c_config 11 | { 12 | private: 13 | std::filesystem::path path; 14 | std::vector configs; 15 | 16 | public: 17 | void run(std::string name); 18 | void load(size_t id); 19 | void save(size_t id) const; 20 | void add(std::string name); 21 | void remove(size_t id); 22 | void rename(size_t item, std::string new_name); 23 | void reset(); 24 | 25 | constexpr auto& get_configs() { return configs; }; 26 | constexpr auto& get_path() { return path; }; 27 | 28 | struct 29 | { 30 | // Aimbot 31 | bool b_aim_enable = false; 32 | float f_aim_smooth = 15.f; 33 | float f_aim_fov = 10.f; 34 | 35 | // Triggerbot 36 | bool b_trigger_enable = false; 37 | } aimbot; 38 | 39 | struct 40 | { 41 | // Glow 42 | bool b_glow_enable = false; 43 | bool b_glow_health_based = false; 44 | bool b_glow_visible_only = false; 45 | 46 | ImVec4 f_glow_color = {0.f, 0.f, 255.f, 1.f}; 47 | 48 | // Skin changer 49 | bool b_sc_enable = false; 50 | bool b_sc_set_paint_kit = false; 51 | int i_sc_selected_model_index = 0; 52 | } visuals; 53 | 54 | struct 55 | { 56 | // Bhop 57 | bool b_enable_bhop = false; 58 | 59 | // EJ 60 | bool b_enable_ej = false; 61 | } misc; 62 | }; 63 | 64 | inline auto config = c_config(); -------------------------------------------------------------------------------- /external/keybind.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum keybind_state_t : int 4 | { 5 | always = 0, 6 | hold, 7 | toggle 8 | }; 9 | 10 | class keybind 11 | { 12 | public: 13 | bool b_state = false; 14 | bool b_is_down = false; 15 | 16 | int i_mode = 0; 17 | int i_key = 0; 18 | 19 | keybind() = default; 20 | explicit keybind(bool state, int mode = 0, int key = 0) 21 | { 22 | b_state = state; 23 | i_mode = mode; 24 | i_key = key; 25 | } 26 | 27 | inline bool get() 28 | { 29 | if (i_key == 0) 30 | return b_state; 31 | 32 | switch (i_mode) 33 | { 34 | case keybind_state_t::always: 35 | b_state = true; 36 | break; 37 | case keybind_state_t::hold: 38 | b_state = LI_FN(GetAsyncKeyState).cached()(i_key) & 0x8000; 39 | break; 40 | 41 | case keybind_state_t::toggle: 42 | auto h_state = LI_FN(GetAsyncKeyState).cached()(i_key); 43 | if (h_state & 0x8000) 44 | b_is_down = true; 45 | 46 | if (b_is_down && !(h_state & 0x8000)) 47 | { 48 | b_state = !b_state; 49 | b_is_down = false; 50 | } 51 | break; 52 | } 53 | 54 | return b_state; 55 | } 56 | 57 | inline std::wstring get_mode_as_string() const 58 | { 59 | switch (i_mode) 60 | { 61 | case keybind_state_t::always: 62 | return std::wstring(xorstr(L"on")); 63 | case keybind_state_t::hold: 64 | return std::wstring(xorstr(L"hold")); 65 | case keybind_state_t::toggle: 66 | return std::wstring(xorstr(L"toggle")); 67 | } 68 | 69 | return {}; 70 | } 71 | }; -------------------------------------------------------------------------------- /external/main.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | // menu 4 | #include "menu.hpp" 5 | 6 | // features 7 | #include "aimbot.hpp" 8 | #include "bhop.hpp" 9 | #include "glow.hpp" 10 | #include "edgejump.hpp" 11 | #include "skinchanger.hpp" 12 | #include "triggerbot.hpp" 13 | 14 | // cache 15 | #include "on_entity.hpp" 16 | #include "on_world.hpp" 17 | 18 | int main(int argc, const char *argv[]) { 19 | std::atexit([]{ var::b_is_running = false; }); 20 | 21 | // Run SDK 22 | if (!sdk::base->run()) 23 | return EXIT_FAILURE; 24 | 25 | // Run config system 26 | config.run("external"); 27 | 28 | // Run update threads 29 | // TODO: Finish proper caching 30 | std::thread(on_world_cache).detach(); 31 | std::thread(on_entity_cache).detach(); 32 | 33 | // Run cheat threads 34 | // Fix: aimbot, edgejump 35 | // Add: more features to: glow, skin changer 36 | // Change: triggerbot logic 37 | std::thread(&c_aimbot::run, g_aimbot.get()).detach(); 38 | std::thread(&c_bhop::run, g_bhop.get()).detach(); 39 | std::thread(&c_glow::run, g_glow.get()).detach(); 40 | std::thread(&c_edgejump::run, g_edgejump.get()).detach(); 41 | std::thread(&c_skinchanger::run, g_skinchanger.get()).detach(); 42 | std::thread(&c_triggerbot::run, g_triggerbot.get()).detach(); 43 | 44 | // TODO: See what's causing all loops to lag after implementing ImGui 45 | // Wait until stop signal 46 | if (!g_menu->setup()) 47 | { 48 | g_menu->destroy(); 49 | return EXIT_FAILURE; 50 | } 51 | 52 | // Render loop 53 | g_menu->render(); 54 | 55 | var::b_is_running = false; 56 | 57 | return EXIT_SUCCESS; 58 | } -------------------------------------------------------------------------------- /external/on_world.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.hpp" 4 | #include "convar.hpp" 5 | 6 | inline void on_world_cache() { 7 | while (var::b_is_running) 8 | { 9 | // Clear variables outside game 10 | if (!g_engine->in_game()) 11 | { 12 | g_local = c_entity(); 13 | g_convar_list.clear(); 14 | g_model_index_list.clear(); 15 | 16 | continue; 17 | } 18 | 19 | // Parse BSP when in game 20 | static std::string current_map; 21 | std::string map = g_engine->get_map_name(); 22 | if (map != current_map) { 23 | current_map = map; 24 | var::bsp::parsed_map = var::bsp::bp.load_map(g_engine->get_game_directory(), g_engine->get_map_name()); 25 | if (!var::bsp::parsed_map) 26 | std::cerr << "Failed to load map into BSP parser!\n"; 27 | } 28 | 29 | // Populate localplayer if none 30 | if (!g_local.get_entity()) 31 | { 32 | const auto [addr, index] = g_client->get_local_player(); 33 | g_local = c_entity(addr, index); 34 | } 35 | 36 | // Populate model vector if none 37 | if (var::skins::models.empty()) 38 | { 39 | for (const auto& [weapon_id, weapon_info] : sdk::structs::m_item_list) { 40 | if (weapon_id > sdk::structs::WEAPON_KNIFE_BAYONET && weapon_id < sdk::structs::WEAPON_KNIFE_SKELETON) 41 | var::skins::models.emplace_back(weapon_info.name); 42 | } 43 | } 44 | 45 | // Populate convar list if none 46 | if (g_convar_list.empty()) 47 | g_convar->populate_convars(); 48 | 49 | // Populate model index list if none 50 | if (g_model_index_list.empty()) 51 | g_skinchanger->populate_models(); 52 | 53 | timer::sleep(1000); 54 | } 55 | } -------------------------------------------------------------------------------- /external/entity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "convar.hpp" 4 | #include "weapon.hpp" 5 | #include "engine.hpp" 6 | 7 | class c_entity 8 | { 9 | private: 10 | std::int32_t index = {}; 11 | std::uintptr_t base_address = {}; 12 | 13 | public: 14 | c_entity() = default; 15 | c_entity(const std::uintptr_t base_addr, const std::int32_t e_index = {}) 16 | { 17 | this->base_address = base_addr; 18 | this->index = e_index; 19 | } 20 | 21 | public: // Read 22 | constexpr auto &get_entity() const{ 23 | return this->base_address; 24 | } 25 | 26 | constexpr auto &get_entity_index() const { 27 | return this->index; 28 | } 29 | 30 | std::int32_t get_health() const; 31 | std::int32_t get_team() const; 32 | std::int32_t get_flags() const; 33 | std::int32_t glow_index() const; 34 | std::int32_t crosshair_id() const; 35 | bool is_dormant() const; 36 | bool is_scoped() const; 37 | bool is_spotted() const; 38 | bool is_visible_ray() const; 39 | bool has_immunity() const; 40 | std::int32_t move_type() const; 41 | std::int32_t life_state() const; 42 | Vector get_velocity() const; 43 | std::int32_t get_class_id() const; 44 | Vector bone_matrix(int bone) const; 45 | Vector eye_pos() const; 46 | Vector view_offset() const; 47 | Vector origin() const; 48 | bool is_alive() const; 49 | std::uintptr_t get_view_model() const; 50 | Vector aim_punch() const; 51 | bool is_localplayer() const; 52 | // From: https://github.com/rollraw/qo0-base/blob/f6ded6392dbb9e433c279fdb6fc3843398b9e1c7/base/sdk/entity.cpp#L212 53 | bool is_enemy() const; 54 | c_weapon get_weapon() const; 55 | sdk::structs::playerinfo_t get_player_info() const; 56 | }; 57 | 58 | inline auto g_local = c_entity(); -------------------------------------------------------------------------------- /external/archivex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2019 Daniel Krupiñski 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | #pragma once 26 | 27 | template 28 | class archivex final 29 | { 30 | private: 31 | TS& stream; 32 | public: 33 | constexpr explicit archivex(TS& stream) : stream{ stream } {} 34 | 35 | template 36 | constexpr const auto& operator<<(const T& item) const 37 | { 38 | stream.write((const char*)(&item), sizeof(item)); 39 | return *this; 40 | } 41 | 42 | template 43 | constexpr const auto& operator>>(T& item) const 44 | { 45 | stream.read((char*)(&item), sizeof(item)); 46 | return *this; 47 | } 48 | }; -------------------------------------------------------------------------------- /external/safe_vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class safe_vector 5 | { 6 | private: 7 | std::vector vector_ = {}; 8 | 9 | // capacity 10 | public: 11 | void clear() 12 | { 13 | std::atomic_thread_fence(std::memory_order_acquire); 14 | vector_.clear(); 15 | std::atomic_thread_fence(std::memory_order_release); 16 | } 17 | 18 | bool empty() 19 | { 20 | std::atomic_thread_fence(std::memory_order_acquire); 21 | return vector_.empty(); 22 | std::atomic_thread_fence(std::memory_order_release); 23 | } 24 | 25 | size_t size() const 26 | { 27 | std::atomic_thread_fence(std::memory_order_acquire); 28 | return vector_.size(); 29 | std::atomic_thread_fence(std::memory_order_release); 30 | } 31 | 32 | // modifiers 33 | public: 34 | void push_back(const T& value) 35 | { 36 | std::atomic_thread_fence(std::memory_order_acquire); 37 | vector_.push_back(value); 38 | std::atomic_thread_fence(std::memory_order_release); 39 | } 40 | 41 | void pop_back() 42 | { 43 | std::atomic_thread_fence(std::memory_order_acquire); 44 | vector_.pop_back(); 45 | std::atomic_thread_fence(std::memory_order_release); 46 | } 47 | 48 | void swap(std::vector& x) 49 | { 50 | std::atomic_thread_fence(std::memory_order_acquire); 51 | vector_.swap(x); 52 | std::atomic_thread_fence(std::memory_order_release); 53 | } 54 | 55 | std::vector copy() 56 | { 57 | std::atomic_thread_fence(std::memory_order_acquire); 58 | return vector_; 59 | std::atomic_thread_fence(std::memory_order_release); 60 | } 61 | 62 | T& operator[](size_t index) 63 | { 64 | std::atomic_thread_fence(std::memory_order_acquire); 65 | return vector_[index]; 66 | std::atomic_thread_fence(std::memory_order_release); 67 | } 68 | 69 | const T& operator[](size_t index) const 70 | { 71 | std::atomic_thread_fence(std::memory_order_acquire); 72 | return vector_[index]; 73 | std::atomic_thread_fence(std::memory_order_release); 74 | } 75 | }; -------------------------------------------------------------------------------- /external/config.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "config.hpp" 3 | 4 | void c_config::run(std::string name) 5 | { 6 | if (PWSTR appdata_path; SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &appdata_path))) 7 | { 8 | path = appdata_path; 9 | path /= name; 10 | 11 | CoTaskMemFree(appdata_path); 12 | } 13 | 14 | if (std::filesystem::is_directory(path)) 15 | { 16 | std::transform 17 | ( 18 | std::filesystem::directory_iterator{ path }, 19 | std::filesystem::directory_iterator{ }, 20 | std::back_inserter(configs), 21 | [](const auto& entry) { return entry.path().filename().string(); } 22 | ); 23 | } 24 | } 25 | 26 | void c_config::load(size_t id) 27 | { 28 | if (!std::filesystem::is_directory(path)) 29 | { 30 | std::filesystem::remove(path); 31 | std::filesystem::create_directory(path); 32 | } 33 | 34 | std::ifstream in{ path / configs[id] }; 35 | 36 | if (!in.good()) 37 | return; 38 | 39 | archivex{ in } >> aimbot >> visuals >> misc; 40 | in.close(); 41 | } 42 | 43 | void c_config::save(size_t id) const 44 | { 45 | if (!std::filesystem::is_directory(path)) 46 | { 47 | std::filesystem::remove(path); 48 | std::filesystem::create_directory(path); 49 | } 50 | 51 | std::ofstream out{ path / configs[id] }; 52 | 53 | if (!out.good()) 54 | return; 55 | 56 | archivex{ out } << aimbot << visuals << misc; 57 | out.close(); 58 | } 59 | 60 | void c_config::add(std::string name) 61 | { 62 | if (!(name.empty()) && std::find(std::cbegin(configs), std::cend(configs), name) == std::cend(configs)) 63 | configs.emplace_back(name); 64 | } 65 | 66 | void c_config::remove(size_t id) 67 | { 68 | std::filesystem::remove(path / configs[id]); 69 | configs.erase(configs.cbegin() + id); 70 | } 71 | 72 | void c_config::rename(size_t item, std::string new_name) 73 | { 74 | std::filesystem::rename(path / configs[item], path / new_name); 75 | configs[item] = new_name; 76 | } 77 | 78 | void c_config::reset() 79 | { 80 | aimbot = { }; 81 | visuals = { }; 82 | misc = { }; 83 | } -------------------------------------------------------------------------------- /external/client.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "client.hpp" 3 | 4 | std::tuple c_client::get_local_player() const 5 | { 6 | const auto local_player_index = g_memory->read(g_engine->get_client_state() + sdk::offsets::dwClientState_GetLocalPlayer); 7 | const auto local_player_address = g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwEntityList + 0x10 * local_player_index); 8 | 9 | return {local_player_address, local_player_index}; 10 | } 11 | 12 | bool c_client::in_menu() const 13 | { 14 | CURSORINFO ci{sizeof(CURSORINFO)}; 15 | if (!GetCursorInfo(&ci)) 16 | return false; 17 | 18 | const auto handle = ci.hCursor; 19 | if ((handle > (HCURSOR)50000) && (handle < (HCURSOR)100000)) 20 | return true; 21 | 22 | return false; 23 | } 24 | 25 | std::int32_t c_client::get_game_type() const 26 | { 27 | const auto game_rules_proxy = g_memory->read(sdk::offsets::dwGameRulesProxy); 28 | const auto game_type = g_memory->read(game_rules_proxy + sdk::netvars::m_SurvivalGameRuleDecisionTypes); 29 | 30 | return game_type; 31 | } 32 | 33 | std::uintptr_t c_client::get_glow_object_manager() const 34 | { 35 | return g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwGlowObjectManager); 36 | } 37 | 38 | std::int32_t c_client::get_force_jump() const 39 | { 40 | return g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwForceJump); 41 | } 42 | 43 | std::int32_t c_client::get_force_attack() const 44 | { 45 | return g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwForceAttack); 46 | } 47 | 48 | std::int32_t c_client::force_jump(const std::int32_t state) const 49 | { 50 | return g_memory->write(sdk::base->get_client_image().base + sdk::offsets::dwForceJump, state); 51 | } 52 | 53 | std::int32_t c_client::force_attack(const std::int32_t state) const 54 | { 55 | return g_memory->write(sdk::base->get_client_image().base + sdk::offsets::dwForceAttack, state); 56 | } -------------------------------------------------------------------------------- /external/memory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class c_memory 6 | { 7 | private: 8 | std::once_flag grab_text_section_once = {}; 9 | 10 | bool attached{}; 11 | HANDLE process_handle{}; 12 | DWORD process_id{}; 13 | 14 | bool memory_compare(const std::uint8_t *bData, const std::uint8_t *bMask, const char *szMask); 15 | 16 | public: 17 | c_memory() = default; 18 | ~c_memory() = default; 19 | 20 | std::uintptr_t pattern_scan(std::uintptr_t dll_base, const char *sig, const char *mask); 21 | std::uintptr_t read_chain(std::uintptr_t dw_address, const std::vector &offsets); 22 | 23 | bool get_module(std::wstring_view mod, std::pair &data); 24 | 25 | bool attach(); 26 | 27 | bool read(std::uintptr_t dw_address, LPVOID lp_buffer, std::uintptr_t dw_size) const; 28 | 29 | template 30 | T read(std::uintptr_t dwAddress, const T &tDefault = T()) 31 | { 32 | T t_ret{}; 33 | if (!read(dwAddress, &t_ret, sizeof(T))) 34 | return tDefault; 35 | 36 | return t_ret; 37 | } 38 | 39 | template 40 | T resolve_offset(std::uintptr_t current_addr, std::uintptr_t module_base, const std::uint32_t relative_offset = sizeof(T)) 41 | { 42 | T read_data = read(current_addr); 43 | 44 | // failed read 45 | if (read_data == T()) 46 | return T(); 47 | 48 | T relative_address = current_addr + read_data + relative_offset; 49 | return relative_address - module_base; 50 | } 51 | 52 | bool write(std::uintptr_t dw_address, LPCVOID lp_buffer, std::uintptr_t dw_size) const; 53 | bool unload(); 54 | 55 | template 56 | bool write(std::uintptr_t dwAddress, const T &tValue) 57 | { 58 | return write(dwAddress, &tValue, sizeof(T)); 59 | } 60 | 61 | void set_pid(int pid) 62 | { 63 | process_id = pid; 64 | } 65 | 66 | int get_pid() const 67 | { 68 | return process_id; 69 | } 70 | 71 | bool is_loaded() const 72 | { 73 | return true; 74 | } 75 | 76 | constexpr auto &get_handle() const 77 | { 78 | return process_handle; 79 | } 80 | }; 81 | 82 | inline std::unique_ptr g_memory = std::make_unique(); -------------------------------------------------------------------------------- /external/engine.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "engine.hpp" 3 | 4 | std::uintptr_t c_engine::get_client_state() const 5 | { 6 | return g_memory->read(sdk::base->get_engine_image().base + sdk::offsets::dwClientState); 7 | } 8 | 9 | sdk::structs::globalvars_t c_engine::get_globalvars() const 10 | { 11 | return g_memory->read(sdk::base->get_engine_image().base + sdk::offsets::dwGlobalVars); 12 | } 13 | 14 | std::int32_t c_engine::in_game() const 15 | { 16 | return g_memory->read(this->get_client_state() + sdk::offsets::dwClientState_State) == SIGNONSTATE_FULL; 17 | } 18 | 19 | std::int32_t c_engine::get_max_player_count() const 20 | { 21 | return g_memory->read(this->get_client_state() + sdk::offsets::dwClientState_MaxPlayer); 22 | } 23 | 24 | Vector c_engine::get_view_angles() const 25 | { 26 | return g_memory->read(this->get_client_state() + sdk::offsets::dwClientState_ViewAngles); 27 | } 28 | 29 | std::string c_engine::get_map_name() 30 | { 31 | auto map_directory = std::make_unique(255); 32 | if (!g_memory->read(this->get_client_state() + sdk::offsets::dwClientState_MapDirectory, map_directory.get(), 255)) 33 | return {}; 34 | 35 | return std::string(map_directory.get()); 36 | } 37 | 38 | std::string c_engine::get_game_directory() 39 | { 40 | auto game_directory = std::make_unique(255); 41 | if (!g_memory->read(sdk::base->get_engine_image().base + sdk::offsets::dwGameDir, game_directory.get(), 255)) 42 | return {}; 43 | 44 | return std::string(game_directory.get()); 45 | } 46 | 47 | bool c_engine::set_view_angles(Vector view_angles) const 48 | { 49 | return g_memory->write(this->get_client_state() + sdk::offsets::dwClientState_ViewAngles, view_angles); 50 | } 51 | 52 | std::int32_t c_engine::force_full_update() const 53 | { 54 | return g_memory->write(this->get_client_state() + sdk::offsets::clientstate_delta_ticks, -1); 55 | } 56 | 57 | std::uintptr_t c_engine::get_user_info_table() const 58 | { 59 | return g_memory->read(this->get_client_state() + sdk::offsets::dwClientState_PlayerInfo); 60 | } 61 | -------------------------------------------------------------------------------- /external/bhop.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "bhop.hpp" 3 | 4 | void c_bhop::run() 5 | { 6 | while ( var::b_is_running ) 7 | { 8 | if (!config.misc.b_enable_bhop) { 9 | timer::sleep(1); 10 | continue; 11 | } 12 | 13 | // Only update each tick 14 | const auto global_vars = g_engine->get_globalvars(); 15 | const auto update = (global_vars.iTickCount != last_tick || global_vars.iFrameCount != last_frame); 16 | if ( !update ) 17 | { 18 | timer::sleep( global_vars.flIntervalPerTick ); 19 | continue; 20 | } 21 | 22 | const auto frametime = global_vars.flAbsFrameTime; 23 | const auto delay = (function_elapsed - (frametime < global_vars.flIntervalPerTick ? (frametime * 0.5f) : frametime)); 24 | const auto sleep = std::min( delay, (frametime * 1000) ); 25 | 26 | timer::sleep( sleep ); 27 | 28 | const auto start = std::chrono::high_resolution_clock::now(); 29 | 30 | // Check if active window is CS:GO 31 | if (!(var::cs::h_wnd == GetForegroundWindow())) 32 | continue; 33 | 34 | // Check if space is pressed down 35 | if (!(LI_FN(GetAsyncKeyState).cached()(VK_SPACE) & 0x8000)) 36 | continue; 37 | 38 | // Check if in menu 39 | if (g_client->in_menu()) 40 | continue; 41 | 42 | // Check if in a game 43 | if (!g_engine->in_game()) 44 | continue; 45 | 46 | // Check if in ladder, no clip or observer 47 | const auto move_type = g_local.move_type(); 48 | if ( move_type == sdk::structs::e_move_type::MOVETYPE_LADDER || 49 | move_type == sdk::structs::e_move_type::MOVETYPE_NOCLIP || 50 | move_type == sdk::structs::e_move_type::MOVETYPE_OBSERVER ) 51 | continue; 52 | 53 | // Check if on ground and jump, otherwise set -jump 54 | if ((g_local.get_flags() & sdk::structs::e_flags::FL_ONGROUND)) 55 | g_client->force_jump( 5 ); // +jump 56 | else 57 | if (g_client->get_force_jump() == 5) 58 | g_client->force_jump( 4 ); // -jump 59 | 60 | const auto end = std::chrono::high_resolution_clock::now(); 61 | 62 | // Update last frame and last tick 63 | last_tick = global_vars.iTickCount; 64 | last_frame = global_vars.iFrameCount; 65 | 66 | std::chrono::duration elapsed = end - start; 67 | function_elapsed = elapsed.count(); 68 | } 69 | } -------------------------------------------------------------------------------- /external/triggerbot.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "triggerbot.hpp" 3 | 4 | void c_triggerbot::run() 5 | { 6 | while ( var::b_is_running ) 7 | { 8 | if (!config.aimbot.b_trigger_enable) { 9 | timer::sleep(1); 10 | continue; 11 | } 12 | 13 | if ( !var::binds::hold_triggerbot_key.get() ) 14 | { 15 | timer::sleep( 1 ); 16 | continue; 17 | } 18 | 19 | // Only update each tick 20 | const auto global_vars = g_engine->get_globalvars(); 21 | const auto update = (global_vars.iTickCount != last_tick || global_vars.iFrameCount != last_frame); 22 | if ( !update ) 23 | { 24 | timer::sleep( global_vars.flIntervalPerTick ); 25 | continue; 26 | } 27 | 28 | const auto frametime = global_vars.flAbsFrameTime; 29 | const auto delay = (function_elapsed - (frametime < global_vars.flIntervalPerTick ? (frametime * 0.5f) : frametime)); 30 | const auto sleep = std::min( delay, (frametime * 1000) ); 31 | 32 | timer::sleep( sleep ); 33 | 34 | const auto start = std::chrono::high_resolution_clock::now(); 35 | 36 | // Check if active window is CS:GO 37 | if ( !(var::cs::h_wnd == GetForegroundWindow()) ) 38 | continue; 39 | 40 | // Check if in menu 41 | if ( g_client->in_menu() ) 42 | continue; 43 | 44 | // Check if in a game 45 | if ( !g_engine->in_game() ) 46 | continue; 47 | 48 | const auto crosshair_id = g_local.crosshair_id(); 49 | const c_entity entity( g_memory->read( sdk::base->get_client_image().base + sdk::offsets::dwEntityList + ((crosshair_id - 1) * 0x10) ) ); 50 | 51 | if ( !entity.get_entity() ) 52 | continue; 53 | 54 | if ( !entity.is_enemy() ) 55 | continue; 56 | 57 | if (!entity.is_visible_ray()) 58 | continue; 59 | 60 | if ( entity.has_immunity() ) 61 | continue; 62 | 63 | if ( crosshair_id > 0 && crosshair_id <= 64 ) 64 | { 65 | // auto delay = random::range( 15.f, 35.f ); 66 | // if ( g_local.is_scoped() ) // If scoped, wait more 67 | // delay = random::range( 45.f, 75.f ); 68 | // timer::sleep( delay ); 69 | g_client->force_attack( 6 ); // +attack 70 | } 71 | 72 | const auto end = std::chrono::high_resolution_clock::now(); 73 | 74 | std::chrono::duration elapsed = end - start; 75 | function_elapsed = elapsed.count(); 76 | 77 | // Update last frame and last tick 78 | last_tick = global_vars.iTickCount; 79 | last_frame = global_vars.iFrameCount; 80 | } 81 | } -------------------------------------------------------------------------------- /external/convar.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "convar.hpp" 3 | 4 | // From: https://www.unknowncheats.me/forum/counterstrike-global-offensive/181308-external-convarfinder.html 5 | int c_convar_manager::get_flags() const 6 | { 7 | return g_memory->read(this->cvar_address + 0x14); 8 | } 9 | 10 | std::string c_convar_manager::get_default_value() const 11 | { 12 | auto convar_default_value = std::make_unique(255); 13 | 14 | if (g_memory->read(g_memory->read(this->cvar_address + 0x20), convar_default_value.get(), 255)) 15 | return convar_default_value.get(); 16 | 17 | return {}; 18 | } 19 | 20 | std::string c_convar_manager::get_string() const 21 | { 22 | auto convar_string = std::make_unique(255); 23 | 24 | if (g_memory->read(g_memory->read(this->cvar_address + 0x24), convar_string.get(), 255)) 25 | return convar_string.get(); 26 | 27 | return {}; 28 | } 29 | 30 | float c_convar_manager::get_float() const 31 | { 32 | return g_memory->read(this->cvar_address + 0x2C); 33 | } 34 | 35 | std::int32_t c_convar_manager::get_int() const 36 | { 37 | return g_memory->read(this->cvar_address + 0x30); 38 | } 39 | 40 | void c_convar_manager::set(std::string value) const 41 | { 42 | g_memory->write(g_memory->read(this->cvar_address + 0x24), value.data(), 255); 43 | } 44 | 45 | void c_convar_manager::set(float value) const 46 | { 47 | g_memory->write(this->cvar_address + 0x2C, value); 48 | } 49 | 50 | void c_convar_manager::set(std::int32_t value) const 51 | { 52 | g_memory->write(this->cvar_address + 0x30, value); 53 | } 54 | 55 | void c_convar::populate_convars() 56 | { 57 | const auto convar_hash_table = g_memory->read(sdk::base->get_vstdlib_image().base + sdk::offsets::interface_engine_cvar); 58 | const auto convar_list = g_memory->read(convar_hash_table + 0x34); 59 | 60 | auto hash_map_entry = g_memory->read(convar_list); 61 | 62 | while (hash_map_entry) 63 | { 64 | auto read_convar_name = std::make_unique(255); 65 | 66 | const auto convar_address = g_memory->read(hash_map_entry + 0x4); 67 | const auto convar_address_name = g_memory->read(convar_address + 0xC); 68 | 69 | if (g_memory->read(convar_address_name, read_convar_name.get(), 255)) 70 | g_convar_list[read_convar_name.get()] = convar_address; 71 | 72 | hash_map_entry = g_memory->read(hash_map_entry + 0x4); 73 | } 74 | } 75 | 76 | c_convar_manager c_convar::find(std::string_view convar_name) 77 | { 78 | auto it = g_convar_list.find(convar_name.data()); 79 | if (it == g_convar_list.end()) 80 | return {}; 81 | 82 | return c_convar_manager(it->second); 83 | } -------------------------------------------------------------------------------- /external/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace timer 4 | { 5 | // For some reason llvm-obfuscator's bogus control flow doesn't like my timer sleep function on clang-12 6 | // inline void sleep(float ms) __attribute((__annotate__(("nobcf")))); 7 | 8 | inline void sleep(float ms) 9 | { 10 | static HMODULE ntdll = NULL; 11 | if (!ntdll) 12 | ntdll = GetModuleHandle(xorstr(L"ntdll.dll")); 13 | 14 | typedef NTSTATUS(WINAPI * fnNtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval); 15 | static fnNtDelayExecution oNtDelayExecution = NULL; 16 | 17 | if (!oNtDelayExecution) 18 | oNtDelayExecution = (fnNtDelayExecution)LI_FN(GetProcAddress).cached()(ntdll, xorstr("NtDelayExecution")); 19 | 20 | typedef NTSTATUS(WINAPI * fnZwSetTimerResolution)(IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution); 21 | static fnZwSetTimerResolution oZwSetTimerResolution = NULL; 22 | 23 | if (!oZwSetTimerResolution) 24 | oZwSetTimerResolution = (fnZwSetTimerResolution)LI_FN(GetProcAddress).cached()(ntdll, xorstr("ZwSetTimerResolution")); 25 | 26 | static std::once_flag flag; 27 | std::call_once(flag, []() 28 | { 29 | ULONG current; 30 | oZwSetTimerResolution( (ULONG)(0.5f * 10000.f), true, ¤t ); }); 31 | 32 | if (ms < 0.5f) 33 | ms = 0.5f; 34 | 35 | LARGE_INTEGER time = {}; 36 | time.QuadPart = -1 * (LONGLONG)(ms * 10000.f); 37 | 38 | oNtDelayExecution(false, &time); 39 | } 40 | } 41 | 42 | namespace string 43 | { 44 | inline std::string to_lower(std::string str) 45 | { 46 | std::transform(str.begin(), str.end(), str.begin(), static_cast(::tolower)); 47 | return str; 48 | } 49 | 50 | inline std::vector split(std::string s, std::string delimiter) 51 | { 52 | size_t pos_start = 0, pos_end, delim_len = delimiter.length(); 53 | std::string token; 54 | std::vector res; 55 | 56 | while ((pos_end = s.find(delimiter, pos_start)) != std::string::npos) 57 | { 58 | token = s.substr(pos_start, pos_end - pos_start); 59 | pos_start = pos_end + delim_len; 60 | res.push_back(token); 61 | } 62 | 63 | res.push_back(s.substr(pos_start)); 64 | return res; 65 | } 66 | } 67 | 68 | namespace random 69 | { 70 | template 71 | T range(T start, T end) 72 | { 73 | std::random_device rd = {}; 74 | std::mt19937_64 rng(rd()); 75 | std::uniform_real_distribution uni(start, end); 76 | 77 | return (T)uni(rng); 78 | } 79 | } -------------------------------------------------------------------------------- /external/sdk.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "sdk.hpp" 3 | 4 | bool c_basesdk::run() 5 | { 6 | // Wait for CS:GO to open 7 | std::cout << xorstr("Waiting for CS:GO to open...\n"); 8 | do { 9 | proc = process::get_by_name(var::cs::str_process); 10 | timer::sleep(250); 11 | } while (!proc.is_running()); 12 | 13 | // Attach memory to process 14 | std::cout << xorstr("Attaching to process\n"); 15 | g_memory->attach(); 16 | 17 | // Check for outdated offsets 18 | if (!sdk::base->check_for_version_mismatch()) { 19 | std::cout << xorstr("Cheat is outdated! exiting.\n"); 20 | timer::sleep(3000); 21 | 22 | return false; 23 | } 24 | 25 | // Close cheat when CS:GO closes thread 26 | std::thread([&] { 27 | while ( proc.is_running() ) 28 | timer::sleep( 1000 ); 29 | std::exit( EXIT_SUCCESS ); 30 | }).detach(); 31 | 32 | // Wait for vstdlib.dll to load 33 | std::cout << xorstr("Waiting for vstdlib.dll to load...\n"); 34 | do { 35 | g_memory->get_module(xorstr(L"vstdlib.dll"), vstdlib); 36 | timer::sleep(250); 37 | } while (get_vstdlib_image().base <= 0x0); 38 | 39 | std::cout << xorstr("vstdlib.dll -> ") << std::hex << get_vstdlib_image().base << std::endl; 40 | 41 | // Wait for engine.dll to load 42 | std::cout << xorstr("Waiting for engine.dll to load...\n"); 43 | do { 44 | g_memory->get_module(xorstr(L"engine.dll"), engine); 45 | timer::sleep(250); 46 | } while (get_engine_image().base <= 0x0); 47 | 48 | std::cout << xorstr("engine.dll -> ") << std::hex << get_engine_image().base << std::endl; 49 | 50 | // Wait for client.dll to load 51 | std::cout << xorstr("Waiting for client.dll to load...\n"); 52 | do { 53 | g_memory->get_module(xorstr(L"client.dll"), client); 54 | timer::sleep(250); 55 | } while (get_client_image().base <= 0x0); 56 | 57 | std::cout << xorstr("client.dll -> ") << std::hex << get_client_image().base << std::endl; 58 | 59 | // Get the window 60 | std::cout << xorstr("Waiting for window class handle...\n"); 61 | do { 62 | var::cs::h_wnd = FindWindow(xorstr(L"Valve001"), nullptr); 63 | timer::sleep(100); 64 | } while (!var::cs::h_wnd); 65 | 66 | return true; 67 | } 68 | 69 | bool c_basesdk::check_for_version_mismatch() const 70 | { 71 | wchar_t filename[MAX_PATH] = {}; 72 | if (!GetModuleFileNameEx(g_memory->get_handle(), NULL, filename, MAX_PATH)) 73 | return false; 74 | 75 | const std::wstring name = filename; 76 | const auto path = name.substr(0, name.find_last_of(xorstr(L"/\\"))) + xorstr(L"\\csgo\\steam.inf"); 77 | 78 | std::ifstream in(path); 79 | std::string line = {}; 80 | if (in.good()) 81 | std::getline(in, line); 82 | 83 | const auto csgo_version = string::split(line, "=")[1]; 84 | 85 | if (sdk::current_game_version != csgo_version) 86 | return false; 87 | 88 | return true; 89 | } 90 | 91 | c_basesdk::~c_basesdk() 92 | { 93 | g_memory->unload(); 94 | } -------------------------------------------------------------------------------- /external/aimbot.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "aimbot.hpp" 3 | 4 | void c_aimbot::run() 5 | { 6 | while (var::b_is_running) 7 | { 8 | if (!config.aimbot.b_aim_enable) { 9 | timer::sleep(1); 10 | continue; 11 | } 12 | 13 | if (!var::binds::hold_aimbot_key.get()) 14 | { 15 | timer::sleep(1); 16 | continue; 17 | } 18 | 19 | // Only update each tick 20 | const auto global_vars = g_engine->get_globalvars(); 21 | const auto update = (global_vars.iTickCount != last_tick || global_vars.iFrameCount != last_frame); 22 | if (!update) 23 | { 24 | timer::sleep(global_vars.flIntervalPerTick); 25 | continue; 26 | } 27 | 28 | const auto frametime = global_vars.flAbsFrameTime; 29 | const auto delay = (function_elapsed - (frametime < global_vars.flIntervalPerTick ? (frametime * 0.5f) : frametime)); 30 | const auto sleep = std::min(delay, (frametime * 1000)); 31 | 32 | timer::sleep(sleep); 33 | 34 | const auto start = std::chrono::high_resolution_clock::now(); 35 | 36 | // Check if active window is CS:GO 37 | if (!(var::cs::h_wnd == GetForegroundWindow())) 38 | continue; 39 | 40 | // Check if in menu 41 | if (g_client->in_menu()) 42 | continue; 43 | 44 | // Check if in a game 45 | if (!g_engine->in_game()) 46 | continue; 47 | 48 | const auto calculate_angle = [&](Vector local_pos, Vector enemy_pos, Vector view_angles) -> Vector { 49 | return ((enemy_pos - local_pos) - view_angles); 50 | }; 51 | 52 | this->best_fov_local = {}; 53 | this->best_angle = Vector{}; 54 | 55 | for (std::int32_t i = 1; i < g_engine->get_max_player_count(); i++) 56 | { 57 | const c_entity entity(g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwEntityList + (i * 0x10)), i); 58 | 59 | if (!entity.get_entity()) 60 | continue; 61 | 62 | if (entity.get_class_id() != (int)sdk::structs::e_class_index::CCSPlayer) 63 | continue; 64 | 65 | if (entity.is_localplayer()) 66 | continue; 67 | 68 | if (!entity.is_alive()) 69 | continue; 70 | 71 | if (entity.is_dormant()) 72 | continue; 73 | 74 | if (!entity.is_enemy()) 75 | continue; 76 | 77 | if (!entity.is_visible_ray()) 78 | continue; 79 | 80 | const auto bone_matrix = entity.bone_matrix(sdk::structs::BONE_HEAD); 81 | 82 | // Target angle of the enemy 83 | const auto angle = calculate_angle(g_local.eye_pos(), bone_matrix, g_engine->get_view_angles()); 84 | const auto fov = std::hypot(angle.x, angle.y); 85 | 86 | if (fov < best_fov_local) { 87 | best_fov_local = fov; 88 | best_angle = angle; 89 | } 90 | 91 | if (!best_angle.IsZero()) 92 | g_engine->set_view_angles(g_engine->get_view_angles() + best_angle / config.aimbot.f_aim_smooth); 93 | } 94 | 95 | const auto end = std::chrono::high_resolution_clock::now(); 96 | 97 | // Update last frame and last tick 98 | last_tick = global_vars.iTickCount; 99 | last_frame = global_vars.iFrameCount; 100 | 101 | std::chrono::duration elapsed = end - start; 102 | function_elapsed = elapsed.count(); 103 | } 104 | } -------------------------------------------------------------------------------- /external/glow.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "glow.hpp" 3 | 4 | void c_glow::run() 5 | { 6 | while ( var::b_is_running ) 7 | { 8 | if (!config.visuals.b_glow_enable) 9 | { 10 | timer::sleep(1); 11 | continue; 12 | } 13 | 14 | // Only update each tick 15 | const auto global_vars = g_engine->get_globalvars(); 16 | const auto update = (global_vars.iTickCount != last_tick || global_vars.iFrameCount != last_frame); 17 | if ( !update ) 18 | { 19 | timer::sleep( global_vars.flIntervalPerTick ); 20 | continue; 21 | } 22 | 23 | const auto frametime = global_vars.flAbsFrameTime; 24 | const auto delay = (function_elapsed - (frametime < global_vars.flIntervalPerTick ? (frametime * 0.5f) : frametime)); 25 | const auto sleep = std::min( delay, (frametime * 1000) ); 26 | 27 | timer::sleep( sleep ); 28 | 29 | const auto start = std::chrono::high_resolution_clock::now(); 30 | 31 | // Check if active window is CS:GO 32 | if ( !(var::cs::h_wnd == GetForegroundWindow()) ) 33 | continue; 34 | 35 | // Check if in menu 36 | if ( g_client->in_menu() ) 37 | continue; 38 | 39 | // Check if in a game 40 | if ( !g_engine->in_game() ) 41 | continue; 42 | 43 | for ( std::int32_t i = 1; i < g_engine->get_max_player_count(); i++ ) 44 | { 45 | const c_entity entity( g_memory->read( sdk::base->get_client_image().base + sdk::offsets::dwEntityList + (i * 0x10) ) ); 46 | 47 | if ( !entity.get_entity() ) 48 | continue; 49 | 50 | if ( entity.get_class_id() != (int)sdk::structs::e_class_index::CCSPlayer ) 51 | continue; 52 | 53 | if ( entity.is_localplayer() ) 54 | continue; 55 | 56 | if ( !entity.is_alive() ) 57 | continue; 58 | 59 | if ( entity.is_dormant() ) 60 | continue; 61 | 62 | if ( !entity.is_enemy() ) 63 | continue; 64 | 65 | if (config.visuals.b_glow_visible_only && !entity.is_visible_ray()) 66 | continue; 67 | 68 | const auto entity_glow_offset = g_client->get_glow_object_manager() + (entity.glow_index() * 0x38); 69 | auto glow = g_memory->read( entity_glow_offset ); 70 | 71 | if (config.visuals.b_glow_health_based) { 72 | // Health glow 73 | const auto entity_health = entity.get_health(); 74 | glow.set( 75 | 1.f - (entity_health / 100.f), // R 76 | entity_health / 100.f, // G 77 | 0.f / 255.f, // B 78 | config.visuals.f_glow_color.w // A 79 | ); 80 | } 81 | else { 82 | glow.set( 83 | config.visuals.f_glow_color.x, // R 84 | config.visuals.f_glow_color.y, // G 85 | config.visuals.f_glow_color.z, // B 86 | config.visuals.f_glow_color.w // A 87 | ); 88 | } 89 | 90 | g_memory->write( entity_glow_offset, glow ); // Set glow 91 | } 92 | 93 | const auto end = std::chrono::high_resolution_clock::now(); 94 | 95 | // Update last frame and last tick 96 | last_tick = global_vars.iTickCount; 97 | last_frame = global_vars.iFrameCount; 98 | 99 | std::chrono::duration elapsed = end - start; 100 | function_elapsed = elapsed.count(); 101 | } 102 | } -------------------------------------------------------------------------------- /external/process.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // TODO: Automatically CloseHandle on class destruct 8 | const auto CloseHandleCall = [](HANDLE h) { CloseHandle(h); }; 9 | typedef std::unique_ptr CloseHandlePtr; 10 | 11 | class process 12 | { 13 | private: 14 | std::uint32_t pid = {}; 15 | std::uint32_t parent_pid = {}; 16 | std::uint32_t flags = {}; 17 | 18 | std::wstring file = {}; 19 | 20 | public: 21 | process() = default; 22 | ~process() = default; 23 | 24 | process(PROCESSENTRY32 entry) 25 | { 26 | pid = entry.th32ProcessID; 27 | parent_pid = entry.th32ParentProcessID; 28 | flags = entry.dwFlags; 29 | file = std::wstring(entry.szExeFile); 30 | } 31 | 32 | public: 33 | static std::vector enumerate_process_list() 34 | { 35 | std::vector procs = {}; 36 | 37 | const auto hnd = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); 38 | PROCESSENTRY32 entry; entry.dwSize = sizeof(entry); 39 | 40 | if (!Process32First(hnd, &entry)) 41 | return {}; 42 | 43 | do 44 | { 45 | procs.emplace_back(entry); 46 | } while (Process32Next(hnd, &entry)); 47 | 48 | CloseHandle(hnd); 49 | return procs; 50 | } 51 | 52 | static process get_by_name(std::wstring_view name, const std::vector& cached_procs = {}) 53 | { 54 | if (name.empty()) 55 | return {}; 56 | 57 | auto procs = cached_procs; 58 | if (procs.empty()) 59 | procs = enumerate_process_list(); 60 | 61 | // TODO: should it be formatted to lowercase? 62 | for (const auto& ctx : procs) 63 | { 64 | auto current = ctx.get_name(); 65 | if (name.find(L".exe") == std::wstring_view::npos) 66 | { 67 | if (current.find(name) == std::wstring_view::npos) 68 | continue; 69 | } 70 | else 71 | { 72 | if (current != name) 73 | continue; 74 | } 75 | 76 | return ctx; 77 | } 78 | 79 | return {}; 80 | } 81 | 82 | static process get_by_pid(std::uint32_t pid, const std::vector& cached_procs = {}) 83 | { 84 | if (pid == 0) 85 | return {}; 86 | 87 | auto procs = cached_procs; 88 | if (procs.empty()) 89 | procs = enumerate_process_list(); 90 | 91 | for (const auto& ctx : procs) 92 | { 93 | if (pid == ctx.get_pid()) 94 | return ctx; 95 | } 96 | 97 | return {}; 98 | } 99 | 100 | static process get_by_window(std::wstring_view window, std::wstring_view clss = {}, const std::vector& cached_procs = {}) 101 | { 102 | if (window.empty()) 103 | return {}; 104 | 105 | auto procs = cached_procs; 106 | if (procs.empty()) 107 | procs = enumerate_process_list(); 108 | 109 | auto hwnd = FindWindow(clss.data(), window.data()); 110 | if (!hwnd) 111 | return {}; 112 | 113 | DWORD pid = 0; 114 | GetWindowThreadProcessId(hwnd, &pid); 115 | 116 | if (pid == 0) 117 | return {}; 118 | 119 | for (const auto& ctx : procs) 120 | { 121 | if (pid == ctx.get_pid()) 122 | return ctx; 123 | } 124 | 125 | return {}; 126 | } 127 | 128 | public: 129 | static process spawn_using_shell(std::wstring_view file, std::wstring_view params, std::wstring_view path) 130 | { 131 | SHELLEXECUTEINFO pi; 132 | { 133 | pi.cbSize = sizeof(SHELLEXECUTEINFO); 134 | pi.fMask = SEE_MASK_NOCLOSEPROCESS; 135 | pi.hwnd = nullptr; 136 | pi.lpVerb = L"runas"; 137 | pi.lpFile = file.data(); 138 | pi.lpParameters = params.data(); 139 | pi.lpDirectory = path.data(); 140 | pi.nShow = SW_HIDE; 141 | pi.hInstApp = nullptr; 142 | } 143 | ShellExecuteEx(&pi); 144 | 145 | auto tmp = GetProcessId(pi.hProcess); 146 | CloseHandle(pi.hProcess); 147 | 148 | return get_by_pid(tmp); 149 | } 150 | 151 | public: 152 | inline bool is_valid() const 153 | { 154 | return pid != 0; 155 | } 156 | 157 | inline bool is_running() const 158 | { 159 | return get_by_pid(pid).is_valid(); 160 | } 161 | 162 | public: 163 | inline bool terminate() const 164 | { 165 | const auto proc = LI_FN(OpenProcess).cached()(PROCESS_TERMINATE, false, pid); 166 | if (proc == INVALID_HANDLE_VALUE) 167 | return {}; 168 | 169 | CloseHandlePtr handle_guard(proc, CloseHandleCall); 170 | 171 | TerminateProcess(proc, 9); 172 | CloseHandle(proc); 173 | 174 | return true; 175 | } 176 | 177 | public: 178 | inline std::uint32_t get_pid() const 179 | { 180 | return pid; 181 | } 182 | 183 | inline std::uint32_t get_parent_pid() const 184 | { 185 | return parent_pid; 186 | } 187 | 188 | inline std::uint32_t get_flags() const 189 | { 190 | return flags; 191 | } 192 | 193 | inline std::wstring get_name() const 194 | { 195 | return file; 196 | } 197 | }; -------------------------------------------------------------------------------- /external/qangle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // used: clamp 3 | #include 4 | // used: isfinite, fmodf, remainderf 5 | #include 6 | 7 | class QAngle 8 | { 9 | public: 10 | constexpr QAngle(float x = 0.f, float y = 0.f, float z = 0.f) : 11 | x(x), y(y), z(z) { } 12 | 13 | constexpr QAngle(const float* arrAngles) : 14 | x(arrAngles[0]), y(arrAngles[1]), z(arrAngles[2]) { } 15 | 16 | bool operator==(const QAngle& angBase) const 17 | { 18 | return this->IsEqual(angBase); 19 | } 20 | 21 | bool operator!=(const QAngle& angBase) const 22 | { 23 | return !this->IsEqual(angBase); 24 | } 25 | 26 | constexpr QAngle& operator=(const QAngle& angBase) 27 | { 28 | this->x = angBase.x; this->y = angBase.y; this->z = angBase.z; 29 | return *this; 30 | } 31 | 32 | constexpr QAngle& operator+=(const QAngle& angBase) 33 | { 34 | this->x += angBase.x; this->y += angBase.y; this->z += angBase.z; 35 | return *this; 36 | } 37 | 38 | constexpr QAngle& operator-=(const QAngle& angBase) 39 | { 40 | this->x -= angBase.x; this->y -= angBase.y; this->z -= angBase.z; 41 | return *this; 42 | } 43 | 44 | constexpr QAngle& operator*=(const QAngle& angBase) 45 | { 46 | this->x *= angBase.x; this->y *= angBase.y; this->z *= angBase.z; 47 | return *this; 48 | } 49 | 50 | constexpr QAngle& operator/=(const QAngle& angBase) 51 | { 52 | this->x /= angBase.x; this->y /= angBase.y; this->z /= angBase.z; 53 | return *this; 54 | } 55 | 56 | constexpr QAngle& operator+=(const float flAdd) 57 | { 58 | this->x += flAdd; this->y += flAdd; this->z += flAdd; 59 | return *this; 60 | } 61 | 62 | constexpr QAngle& operator-=(const float flSubtract) 63 | { 64 | this->x -= flSubtract; this->y -= flSubtract; this->z -= flSubtract; 65 | return *this; 66 | } 67 | 68 | constexpr QAngle& operator*=(const float flMultiply) 69 | { 70 | this->x *= flMultiply; this->y *= flMultiply; this->z *= flMultiply; 71 | return *this; 72 | } 73 | 74 | constexpr QAngle& operator/=(const float flDivide) 75 | { 76 | this->x /= flDivide; this->y /= flDivide; this->z /= flDivide; 77 | return *this; 78 | } 79 | 80 | QAngle operator+(const QAngle& angAdd) const 81 | { 82 | return QAngle(this->x + angAdd.x, this->y + angAdd.y, this->z + angAdd.z); 83 | } 84 | 85 | QAngle operator-(const QAngle& angSubtract) const 86 | { 87 | return QAngle(this->x - angSubtract.x, this->y - angSubtract.y, this->z - angSubtract.z); 88 | } 89 | 90 | QAngle operator*(const QAngle& angMultiply) const 91 | { 92 | return QAngle(this->x * angMultiply.x, this->y * angMultiply.y, this->z * angMultiply.z); 93 | } 94 | 95 | QAngle operator/(const QAngle& angDivide) const 96 | { 97 | return QAngle(this->x / angDivide.x, this->y / angDivide.y, this->z / angDivide.z); 98 | } 99 | 100 | QAngle operator+(const float flAdd) const 101 | { 102 | return QAngle(this->x + flAdd, this->y + flAdd, this->z + flAdd); 103 | } 104 | 105 | QAngle operator-(const float flSubtract) const 106 | { 107 | return QAngle(this->x - flSubtract, this->y - flSubtract, this->z - flSubtract); 108 | } 109 | 110 | QAngle operator*(const float flMultiply) const 111 | { 112 | return QAngle(this->x * flMultiply, this->y * flMultiply, this->z * flMultiply); 113 | } 114 | 115 | QAngle operator/(const float flDivide) const 116 | { 117 | return QAngle(this->x / flDivide, this->y / flDivide, this->z / flDivide); 118 | } 119 | 120 | [[nodiscard]] bool IsEqual(const QAngle& angEqual, const float flErrorMargin = std::numeric_limits::epsilon()) const 121 | { 122 | return (std::fabsf(this->x - angEqual.x) < flErrorMargin && 123 | std::fabsf(this->y - angEqual.y) < flErrorMargin && 124 | std::fabsf(this->z - angEqual.z) < flErrorMargin); 125 | } 126 | 127 | [[nodiscard]] bool IsZero() const 128 | { 129 | return (std::fpclassify(this->x) == FP_ZERO && 130 | std::fpclassify(this->y) == FP_ZERO && 131 | std::fpclassify(this->z) == FP_ZERO); 132 | } 133 | 134 | QAngle Clamp() 135 | { 136 | this->x = std::clamp(this->x, -89.f, 89.f); 137 | this->y = std::clamp(this->y, -180.f, 180.f); 138 | this->z = std::clamp(this->z, -50.f, 50.f); 139 | return *this; 140 | } 141 | 142 | QAngle Normalize() 143 | { 144 | this->x = std::isfinite(this->x) ? std::remainderf(this->x, 360.f) : 0.f; 145 | this->y = std::isfinite(this->y) ? std::remainderf(this->y, 360.f) : 0.f; 146 | this->z = std::clamp(this->z, -50.f, 50.f); 147 | return *this; 148 | } 149 | 150 | QAngle Mod(const float flValue) 151 | { 152 | this->x = std::fmodf(this->x, flValue); 153 | this->y = std::fmodf(this->y, flValue); 154 | this->z = std::fmodf(this->z, flValue); 155 | return *this; 156 | } 157 | 158 | public: 159 | float x, y, z; 160 | }; -------------------------------------------------------------------------------- /external/skinchanger.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "skinchanger.hpp" 3 | 4 | void c_skinchanger::populate_models() 5 | { 6 | const auto client_state = g_engine->get_client_state(); 7 | const auto network_string_table = g_memory->read(client_state + 0x52A4); // m_dwModelPrecache 8 | const auto network_string_dictionary = g_memory->read(network_string_table + 0x40); 9 | const auto network_string_dictionary_item_first = g_memory->read(network_string_dictionary + 0xC); 10 | 11 | for (int i = 0; i < 1024; i++) 12 | { 13 | const auto mpc_name_ptr = g_memory->read(network_string_dictionary_item_first + 0xC + (i * 0x34)); 14 | if (!mpc_name_ptr) 15 | continue; 16 | 17 | auto mpc_read_name = std::make_unique(255); 18 | if (g_memory->read(mpc_name_ptr, mpc_read_name.get(), 255)) 19 | g_model_index_list[mpc_read_name.get()] = i; 20 | } 21 | } 22 | 23 | std::int32_t c_skinchanger::find_model_index_by_name(std::string_view model_name) 24 | { 25 | const auto it = g_model_index_list.find(model_name.data()); 26 | if (it == g_model_index_list.end()) 27 | return {}; 28 | 29 | return it->second; 30 | } 31 | 32 | // From: https://github.com/0xf1a/xSkins 33 | void c_skinchanger::run() 34 | { 35 | while ( var::b_is_running ) 36 | { 37 | if (!config.visuals.b_sc_enable) { 38 | timer::sleep(1); 39 | continue; 40 | } 41 | 42 | if (!g_engine->in_game()) 43 | continue; 44 | 45 | if (!g_local.get_entity()) 46 | continue; 47 | 48 | if (!g_local.is_alive()) 49 | continue; 50 | 51 | if (!g_local.get_view_model()) 52 | continue; 53 | 54 | if (var::skins::models.empty()) 55 | continue; 56 | 57 | auto target_knife = (int)sdk::structs::e_item_definitions::WEAPON_KNIFE_M9_BAYONET; 58 | auto model_index = find_model_index_by_name("models/weapons/v_knife_m9_bay.mdl"); 59 | 60 | for (const auto& [weapon_id, weapon_info] : sdk::structs::m_item_list) 61 | { 62 | if (weapon_info.name == var::skins::models[config.visuals.i_sc_selected_model_index]) 63 | { 64 | target_knife = weapon_id; 65 | model_index = find_model_index_by_name(weapon_info.model); 66 | } 67 | } 68 | 69 | for ( size_t i = 0; i < 8; i++ ) 70 | { 71 | const auto current_weapon = g_memory->read( (g_local.get_entity() + sdk::netvars::m_hMyWeapons) + i * 0x4 ); 72 | if (!current_weapon) 73 | continue; 74 | 75 | const auto current_weapon_entity = g_memory->read( sdk::base->get_client_image().base + sdk::offsets::dwEntityList + ((current_weapon & 0xFFF) - 1) * 0x10 ); 76 | if ( !current_weapon_entity ) 77 | continue; 78 | 79 | const auto weapon_index = g_memory->read( current_weapon_entity + sdk::netvars::m_iItemDefinitionIndex ); 80 | if ( weapon_index == sdk::structs::WEAPON_KNIFE || weapon_index == sdk::structs::WEAPON_KNIFE_T || weapon_index == target_knife) 81 | { 82 | g_memory->write( current_weapon_entity + sdk::netvars::m_iItemDefinitionIndex, target_knife); 83 | g_memory->write( current_weapon_entity + sdk::netvars::m_nModelIndex, model_index ); 84 | g_memory->write( current_weapon_entity + sdk::netvars::m_iViewModelIndex, model_index ); 85 | g_memory->write( current_weapon_entity + sdk::netvars::m_iEntityQuality, 3 ); 86 | 87 | // Skins 88 | if (config.visuals.b_sc_set_paint_kit && !var::skins::str_paint_kit.empty()) 89 | { 90 | g_memory->write(current_weapon_entity + sdk::netvars::m_iItemIDHigh, -1); 91 | g_memory->write(current_weapon_entity + sdk::netvars::m_nFallbackPaintKit, std::stoi(var::skins::str_paint_kit)); 92 | g_memory->write(current_weapon_entity + sdk::netvars::m_flFallbackWear, 0.0001f); 93 | } 94 | } 95 | } 96 | 97 | const auto active_weapon = g_memory->read( g_local.get_entity() + sdk::netvars::m_hActiveWeapon ); 98 | if (!active_weapon) 99 | continue; 100 | 101 | const auto active_weapon_entity = g_memory->read( sdk::base->get_client_image().base + sdk::offsets::dwEntityList + ((active_weapon & 0xFFF) - 1) * 0x10 ); 102 | if ( !active_weapon_entity ) 103 | continue; 104 | 105 | const auto weapon_index = g_memory->read( active_weapon_entity + sdk::netvars::m_iItemDefinitionIndex ); 106 | if ( weapon_index != target_knife ) 107 | continue; 108 | 109 | const auto view_model_entity = g_memory->read( sdk::base->get_client_image().base + sdk::offsets::dwEntityList + ((g_local.get_view_model() & 0xFFF) - 1) * 0x10); 110 | if ( !view_model_entity ) 111 | continue; 112 | 113 | g_memory->write( view_model_entity + sdk::netvars::m_nModelIndex, model_index ); 114 | } 115 | } -------------------------------------------------------------------------------- /external/memory.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "memory.hpp" 3 | 4 | bool c_memory::memory_compare(const std::uint8_t *bData, const std::uint8_t *bMask, const char *szMask) 5 | { 6 | for (; *szMask; ++szMask, ++bData, ++bMask) 7 | { 8 | if (*szMask == 'x' && *bData != *bMask) 9 | return false; 10 | } 11 | 12 | return (*szMask == NULL); 13 | } 14 | 15 | std::uintptr_t c_memory::pattern_scan(std::uintptr_t dll_base, const char *sig, const char *mask) 16 | { 17 | // for signatures that are hardcoded and not set 18 | if (!dll_base || sig == nullptr || mask == nullptr) 19 | return NULL; 20 | 21 | static std::uint32_t section_base_addr = {}; 22 | static std::uint32_t section_size = {}; 23 | 24 | std::call_once(grab_text_section_once, [this, dll_base]() 25 | { 26 | const std::uint16_t dos_sig = read(dll_base); 27 | if (dos_sig != IMAGE_DOS_SIGNATURE) 28 | return NULL; 29 | 30 | const std::int32_t e_lfanew_offset = read(dll_base + FIELD_OFFSET(IMAGE_DOS_HEADER, e_lfanew)); // e_lfanew 31 | if (!e_lfanew_offset) 32 | return NULL; 33 | 34 | const std::uintptr_t nt_header = dll_base + e_lfanew_offset; 35 | 36 | const std::uint32_t e_lfanew = read(nt_header); 37 | if (!e_lfanew || e_lfanew != IMAGE_NT_SIGNATURE) 38 | return NULL; 39 | 40 | const std::uint16_t num_sections = read(nt_header + (FIELD_OFFSET(IMAGE_NT_HEADERS, FileHeader.NumberOfSections))); 41 | if (num_sections < 1) 42 | return NULL; 43 | 44 | const std::uint16_t size_of_optional_header = read(nt_header + (FIELD_OFFSET(IMAGE_NT_HEADERS, FileHeader.SizeOfOptionalHeader))); 45 | if (!size_of_optional_header) 46 | return NULL; 47 | 48 | const std::uintptr_t first_section = nt_header + FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) + size_of_optional_header; 49 | 50 | for (auto i = 0; i < num_sections; ++i) 51 | { 52 | const auto section = first_section + (i * sizeof(IMAGE_SECTION_HEADER)); 53 | char section_name[IMAGE_SIZEOF_SHORT_NAME] = { 0 }; 54 | 55 | if (read(section + FIELD_OFFSET(IMAGE_SECTION_HEADER, Name), section_name, sizeof(section_name))) 56 | { 57 | if (!strcmp(section_name, xorstr(".text"))) 58 | { 59 | section_base_addr = read(section + FIELD_OFFSET(IMAGE_SECTION_HEADER, VirtualAddress)); 60 | section_size = read(section + FIELD_OFFSET(IMAGE_SECTION_HEADER, Misc.VirtualSize)); 61 | break; 62 | } 63 | } 64 | } 65 | 66 | return 1; }); 67 | 68 | if (!section_base_addr || !section_size) 69 | return NULL; 70 | 71 | auto data = std::make_unique(section_size); 72 | 73 | read(dll_base + section_base_addr, data.get(), section_size); 74 | for (std::uint32_t i = 0; i < section_size; ++i) 75 | { 76 | if (memory_compare((const std::uint8_t *)(data.get() + i), (const std::uint8_t *)sig, mask)) 77 | return dll_base + section_base_addr + i; 78 | } 79 | 80 | return NULL; 81 | } 82 | 83 | std::uintptr_t c_memory::read_chain(std::uintptr_t dw_address, const std::vector &offsets) 84 | { 85 | auto result = read(dw_address + offsets.at(0)); 86 | 87 | for (size_t i = 1; i < offsets.size(); i++) 88 | result = read(result + offsets.at(i)); 89 | 90 | return result; 91 | } 92 | 93 | bool c_memory::read(std::uintptr_t dw_address, LPVOID lp_buffer, std::uintptr_t dw_size) const 94 | { 95 | auto ret = LI_FN(ReadProcessMemory).cached()(process_handle, (LPCVOID)dw_address, lp_buffer, dw_size, nullptr); 96 | return ret != 0; 97 | } 98 | 99 | bool c_memory::write(std::uintptr_t dw_address, LPCVOID lp_buffer, std::uintptr_t dw_size) const 100 | { 101 | auto ret = LI_FN(WriteProcessMemory).cached()(process_handle, (LPVOID)dw_address, lp_buffer, dw_size, nullptr); 102 | return ret != 0; 103 | } 104 | 105 | bool c_memory::unload() 106 | { 107 | return CloseHandle(process_handle) != 0; 108 | } 109 | 110 | bool c_memory::get_module(std::wstring_view mod, std::pair &data) 111 | { 112 | HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, process_id); 113 | if (handle == INVALID_HANDLE_VALUE) 114 | return false; 115 | 116 | MODULEENTRY32 entry = {}; 117 | entry.dwSize = sizeof(entry); 118 | if (!Module32First(handle, &entry)) 119 | { 120 | CloseHandle(handle); 121 | return false; 122 | } 123 | 124 | do 125 | { 126 | if (mod == entry.szModule) 127 | { 128 | data = std::make_pair((std::uintptr_t)entry.modBaseAddr, (std::uintptr_t)entry.modBaseSize); 129 | CloseHandle(handle); 130 | 131 | return true; 132 | } 133 | } while (Module32Next(handle, &entry)); 134 | 135 | CloseHandle(handle); 136 | return false; 137 | } 138 | 139 | bool c_memory::attach() 140 | { 141 | HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); 142 | if (handle == INVALID_HANDLE_VALUE) 143 | return false; 144 | 145 | PROCESSENTRY32 entry = {}; 146 | entry.dwSize = sizeof(entry); 147 | if (!Process32First(handle, &entry)) 148 | { 149 | CloseHandle(handle); 150 | return false; 151 | } 152 | 153 | do 154 | { 155 | if (var::cs::str_process == entry.szExeFile) 156 | { 157 | process_id = entry.th32ProcessID; 158 | CloseHandle(handle); 159 | 160 | process_handle = LI_FN(OpenProcess).cached()(PROCESS_ALL_ACCESS, false, process_id); 161 | attached = true; 162 | 163 | return true; 164 | } 165 | } while (Process32Next(handle, &entry)); 166 | 167 | CloseHandle(handle); 168 | return false; 169 | } -------------------------------------------------------------------------------- /external/entity.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "entity.hpp" 3 | 4 | std::int32_t c_entity::get_health() const 5 | { 6 | return g_memory->read(base_address + sdk::netvars::m_iHealth); 7 | } 8 | 9 | std::int32_t c_entity::get_team() const 10 | { 11 | return g_memory->read(base_address + sdk::netvars::m_iTeamNum); 12 | } 13 | 14 | std::int32_t c_entity::get_flags() const 15 | { 16 | return g_memory->read(base_address + sdk::netvars::m_fFlags); 17 | } 18 | 19 | std::int32_t c_entity::glow_index() const 20 | { 21 | return g_memory->read(base_address + sdk::netvars::m_iGlowIndex); 22 | } 23 | 24 | std::int32_t c_entity::crosshair_id() const 25 | { 26 | return g_memory->read(base_address + sdk::netvars::m_iCrosshairId); 27 | } 28 | 29 | bool c_entity::is_dormant() const 30 | { 31 | return g_memory->read(base_address + sdk::offsets::m_bDormant); 32 | } 33 | 34 | bool c_entity::is_scoped() const 35 | { 36 | return g_memory->read(base_address + sdk::netvars::m_bIsScoped); 37 | } 38 | 39 | bool c_entity::is_spotted() const 40 | { 41 | return g_memory->read(base_address + sdk::netvars::m_bSpottedByMask); 42 | } 43 | 44 | bool c_entity::is_visible_ray() const 45 | { 46 | return var::bsp::parsed_map ? var::bsp::bp.is_visible(rn::vector3(g_local.eye_pos().x, 47 | g_local.eye_pos().y, g_local.eye_pos().z), rn::vector3(this->eye_pos().x, 48 | this->eye_pos().y, this->eye_pos().z)) : false; 49 | } 50 | 51 | bool c_entity::has_immunity() const 52 | { 53 | return g_memory->read(base_address + sdk::netvars::m_bGunGameImmunity); 54 | } 55 | 56 | std::int32_t c_entity::move_type() const 57 | { 58 | return g_memory->read(base_address + sdk::netvars::m_MoveType); 59 | } 60 | 61 | std::int32_t c_entity::life_state() const 62 | { 63 | return g_memory->read(base_address + sdk::netvars::m_lifeState); 64 | } 65 | 66 | Vector c_entity::get_velocity() const 67 | { 68 | return g_memory->read(base_address + sdk::netvars::m_vecVelocity); 69 | } 70 | 71 | std::int32_t c_entity::get_class_id() const 72 | { 73 | const auto IClientNetworkable = g_memory->read(base_address + 0x8); // IClientNetworkable vtable 74 | const auto GetClientClass = g_memory->read(IClientNetworkable + 2 * 0x4); // 3rd function in the vtable (GetClientClass) 75 | const auto GetClientClass_ptr = g_memory->read(GetClientClass + 0x1); // pointer to the ClientClass struct out of the mov eax 76 | 77 | return g_memory->read(GetClientClass_ptr + 0x14); // ClassID 78 | } 79 | 80 | Vector c_entity::bone_matrix(int bone) const 81 | { 82 | const auto matrix = g_memory->read(base_address + sdk::netvars::m_dwBoneMatrix); 83 | 84 | Vector vec_matrix = { 85 | g_memory->read(matrix + 0x30 * bone + 0xC), 86 | g_memory->read(matrix + 0x30 * bone + 0x1C), 87 | g_memory->read(matrix + 0x30 * bone + 0x2C)}; 88 | 89 | return vec_matrix; 90 | } 91 | 92 | Vector c_entity::eye_pos() const 93 | { 94 | return g_memory->read(base_address + sdk::netvars::m_vecOrigin) + g_memory->read(base_address + sdk::netvars::m_vecViewOffset); 95 | } 96 | 97 | Vector c_entity::view_offset() const { 98 | return g_memory->read(base_address + sdk::netvars::m_vecViewOffset); 99 | } 100 | 101 | Vector c_entity::origin() const { 102 | return g_memory->read(base_address + sdk::netvars::m_vecOrigin); 103 | } 104 | 105 | Vector c_entity::aim_punch() const 106 | { 107 | return g_memory->read(base_address + sdk::netvars::m_aimPunchAngle); 108 | } 109 | 110 | bool c_entity::is_alive() const 111 | { 112 | return (this->life_state() == sdk::structs::e_life_state::LIFE_ALIVE); 113 | } 114 | 115 | std::uintptr_t c_entity::get_view_model() const 116 | { 117 | return g_memory->read(g_local.get_entity() + sdk::netvars::m_hViewModel); 118 | } 119 | 120 | bool c_entity::is_localplayer() const 121 | { 122 | return (base_address == g_local.get_entity()); 123 | } 124 | 125 | // From: https://github.com/rollraw/qo0-base/blob/f6ded6392dbb9e433c279fdb6fc3843398b9e1c7/base/sdk/entity.cpp#L212 126 | bool c_entity::is_enemy() const 127 | { 128 | auto mp_teammates_are_enemies = g_convar->find(xorstr("mp_teammates_are_enemies")); 129 | if (!mp_teammates_are_enemies.get_pointer()) 130 | return false; 131 | 132 | auto teammates_are_enemies = mp_teammates_are_enemies.get_int(); 133 | teammates_are_enemies ^= mp_teammates_are_enemies.get_pointer(); 134 | 135 | return teammates_are_enemies ? true : this->get_team() != g_local.get_team(); 136 | } 137 | 138 | c_weapon c_entity::get_weapon() const 139 | { 140 | const auto current_weapon = g_memory->read(this->base_address + sdk::netvars::m_hActiveWeapon); 141 | if (!current_weapon) 142 | return c_weapon(NULL); 143 | 144 | const auto current_weapon_entity = g_memory->read(sdk::base->get_client_image().base + sdk::offsets::dwEntityList + ((current_weapon & 0xFFF) - 1) * 0x10); 145 | if (!current_weapon_entity) 146 | return c_weapon(NULL); 147 | 148 | return c_weapon(current_weapon_entity); 149 | } 150 | 151 | sdk::structs::playerinfo_t c_entity::get_player_info() const { 152 | const auto player_info_items = g_memory->read(g_memory->read(g_engine->get_user_info_table() + 0x40) + 0xC); 153 | return g_memory->read(g_memory->read(player_info_items + 0x28 + (this->index * 0x34))); 154 | } -------------------------------------------------------------------------------- /external/vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // @credits: https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/mathlib/vector.h 3 | 4 | // used: isfinite, fmodf, sqrtf 5 | #include 6 | // used: numeric_limits 7 | #include 8 | // used:: number 9 | #include 10 | 11 | class Vector2D 12 | { 13 | public: 14 | constexpr Vector2D(float x = 0.f, float y = 0.f) : 15 | x(x), y(y) { } 16 | 17 | [[nodiscard]] bool IsZero() const 18 | { 19 | return (std::fpclassify(this->x) == FP_ZERO && 20 | std::fpclassify(this->y) == FP_ZERO); 21 | } 22 | 23 | public: 24 | float x, y; 25 | }; 26 | 27 | class Vector 28 | { 29 | public: 30 | constexpr Vector(float x = 0.f, float y = 0.f, float z = 0.f) : 31 | x(x), y(y), z(z) { } 32 | 33 | constexpr Vector(const float* arrVector) : 34 | x(arrVector[0]), y(arrVector[1]), z(arrVector[2]) { } 35 | 36 | constexpr Vector(const Vector2D& vecBase2D) : 37 | x(vecBase2D.x), y(vecBase2D.y), z(0.0f) { } 38 | 39 | [[nodiscard]] bool IsValid() const 40 | { 41 | return std::isfinite(this->x) && std::isfinite(this->y) && std::isfinite(this->z); 42 | } 43 | 44 | constexpr void Invalidate() 45 | { 46 | this->x = this->y = this->z = std::numeric_limits::infinity(); 47 | } 48 | 49 | [[nodiscard]] float* data() 50 | { 51 | return reinterpret_cast(this); 52 | } 53 | 54 | [[nodiscard]] const float* data() const 55 | { 56 | return reinterpret_cast(const_cast(this)); 57 | } 58 | 59 | float& operator[](const std::size_t i) 60 | { 61 | return this->data()[i]; 62 | } 63 | 64 | const float& operator[](const std::size_t i) const 65 | { 66 | return this->data()[i]; 67 | } 68 | 69 | bool operator==(const Vector& vecBase) const 70 | { 71 | return this->IsEqual(vecBase); 72 | } 73 | 74 | bool operator!=(const Vector& vecBase) const 75 | { 76 | return !this->IsEqual(vecBase); 77 | } 78 | 79 | constexpr Vector& operator=(const Vector& vecBase) 80 | { 81 | this->x = vecBase.x; this->y = vecBase.y; this->z = vecBase.z; 82 | return *this; 83 | } 84 | 85 | constexpr Vector& operator=(const Vector2D& vecBase2D) 86 | { 87 | this->x = vecBase2D.x; this->y = vecBase2D.y; this->z = 0.0f; 88 | return *this; 89 | } 90 | 91 | constexpr Vector& operator+=(const Vector& vecBase) 92 | { 93 | this->x += vecBase.x; this->y += vecBase.y; this->z += vecBase.z; 94 | return *this; 95 | } 96 | 97 | constexpr Vector& operator-=(const Vector& vecBase) 98 | { 99 | this->x -= vecBase.x; this->y -= vecBase.y; this->z -= vecBase.z; 100 | return *this; 101 | } 102 | 103 | constexpr Vector& operator*=(const Vector& vecBase) 104 | { 105 | this->x *= vecBase.x; this->y *= vecBase.y; this->z *= vecBase.z; 106 | return *this; 107 | } 108 | 109 | constexpr Vector& operator/=(const Vector& vecBase) 110 | { 111 | this->x /= vecBase.x; this->y /= vecBase.y; this->z /= vecBase.z; 112 | return *this; 113 | } 114 | 115 | constexpr Vector& operator+=(const float flAdd) 116 | { 117 | this->x += flAdd; this->y += flAdd; this->z += flAdd; 118 | return *this; 119 | } 120 | 121 | constexpr Vector& operator-=(const float flSubtract) 122 | { 123 | this->x -= flSubtract; this->y -= flSubtract; this->z -= flSubtract; 124 | return *this; 125 | } 126 | 127 | constexpr Vector& operator*=(const float flMultiply) 128 | { 129 | this->x *= flMultiply; this->y *= flMultiply; this->z *= flMultiply; 130 | return *this; 131 | } 132 | 133 | constexpr Vector& operator/=(const float flDivide) 134 | { 135 | this->x /= flDivide; this->y /= flDivide; this->z /= flDivide; 136 | return *this; 137 | } 138 | 139 | Vector operator+(const Vector& vecAdd) const 140 | { 141 | return Vector(this->x + vecAdd.x, this->y + vecAdd.y, this->z + vecAdd.z); 142 | } 143 | 144 | Vector operator-(const Vector& vecSubtract) const 145 | { 146 | return Vector(this->x - vecSubtract.x, this->y - vecSubtract.y, this->z - vecSubtract.z); 147 | } 148 | 149 | Vector operator*(const Vector& vecMultiply) const 150 | { 151 | return Vector(this->x * vecMultiply.x, this->y * vecMultiply.y, this->z * vecMultiply.z); 152 | } 153 | 154 | Vector operator/(const Vector& vecDivide) const 155 | { 156 | return Vector(this->x / vecDivide.x, this->y / vecDivide.y, this->z / vecDivide.z); 157 | } 158 | 159 | Vector operator+(const float flAdd) const 160 | { 161 | return Vector(this->x + flAdd, this->y + flAdd, this->z + flAdd); 162 | } 163 | 164 | Vector operator-(const float flSubtract) const 165 | { 166 | return Vector(this->x - flSubtract, this->y - flSubtract, this->z - flSubtract); 167 | } 168 | 169 | Vector operator*(const float flMultiply) const 170 | { 171 | return Vector(this->x * flMultiply, this->y * flMultiply, this->z * flMultiply); 172 | } 173 | 174 | Vector operator/(const float flDivide) const 175 | { 176 | return Vector(this->x / flDivide, this->y / flDivide, this->z / flDivide); 177 | } 178 | 179 | [[nodiscard]] bool IsEqual(const Vector& vecEqual) const 180 | { 181 | return (std::fabsf(this->x - vecEqual.x) < std::numeric_limits::epsilon() && 182 | std::fabsf(this->y - vecEqual.y) < std::numeric_limits::epsilon() && 183 | std::fabsf(this->z - vecEqual.z) < std::numeric_limits::epsilon()); 184 | } 185 | 186 | [[nodiscard]] bool IsZero() const 187 | { 188 | return (std::fpclassify(this->x) == FP_ZERO && 189 | std::fpclassify(this->y) == FP_ZERO && 190 | std::fpclassify(this->z) == FP_ZERO); 191 | } 192 | 193 | [[nodiscard]] Vector2D ToVector2D() const 194 | { 195 | return Vector2D(this->x, this->y); 196 | } 197 | 198 | [[nodiscard]] float Length() const 199 | { 200 | return std::sqrtf(this->LengthSqr()); 201 | } 202 | 203 | [[nodiscard]] constexpr float LengthSqr() const 204 | { 205 | return DotProduct(*this); 206 | } 207 | 208 | [[nodiscard]] float Length2D() const 209 | { 210 | return std::sqrtf(this->Length2DSqr()); 211 | } 212 | 213 | [[nodiscard]] constexpr float Length2DSqr() const 214 | { 215 | return (this->x * this->x + this->y * this->y); 216 | } 217 | 218 | [[nodiscard]] float DistTo(const Vector& vecEnd) const 219 | { 220 | return (*this - vecEnd).Length(); 221 | } 222 | 223 | [[nodiscard]] constexpr float DistToSqr(const Vector& vecEnd) const 224 | { 225 | return (*this - vecEnd).LengthSqr(); 226 | } 227 | 228 | [[nodiscard]] Vector Normalized() const 229 | { 230 | Vector vecOut = *this; 231 | vecOut.NormalizeInPlace(); 232 | return vecOut; 233 | } 234 | 235 | float NormalizeInPlace() 236 | { 237 | const float flLength = this->Length(); 238 | const float flRadius = 1.0f / (flLength + std::numeric_limits::epsilon()); 239 | 240 | this->x *= flRadius; 241 | this->y *= flRadius; 242 | this->z *= flRadius; 243 | 244 | return flLength; 245 | } 246 | 247 | [[nodiscard]] constexpr float DotProduct(const Vector& vecDot) const 248 | { 249 | return (this->x * vecDot.x + this->y * vecDot.y + this->z * vecDot.z); 250 | } 251 | 252 | [[nodiscard]] constexpr Vector CrossProduct(const Vector& vecCross) const 253 | { 254 | return Vector(this->y * vecCross.z - this->z * vecCross.y, this->z * vecCross.x - this->x * vecCross.z, this->x * vecCross.y - this->y * vecCross.x); 255 | } 256 | 257 | public: 258 | float x, y, z; 259 | }; 260 | 261 | class Vector4D 262 | { 263 | public: 264 | constexpr Vector4D(float x = 0.f, float y = 0.f, float z = 0.f, float w = 0.f) : 265 | x(x), y(y), z(z), w(w) { } 266 | 267 | public: 268 | float x, y, z, w; 269 | }; 270 | 271 | class __declspec(align(16)) VectorAligned : public Vector 272 | { 273 | public: 274 | VectorAligned() = default; 275 | 276 | explicit VectorAligned(const Vector& vecBase) 277 | { 278 | this->x = vecBase.x; this->y = vecBase.y; this->z = vecBase.z; this->w = 0.f; 279 | } 280 | 281 | constexpr VectorAligned& operator=(const Vector& vecBase) 282 | { 283 | this->x = vecBase.x; this->y = vecBase.y; this->z = vecBase.z; this->w = 0.f; 284 | return *this; 285 | } 286 | 287 | public: 288 | float w; 289 | }; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | *.build.props 13 | 14 | # User-specific files (MonoDevelop/Xamarin Studio) 15 | *.userprefs 16 | 17 | # Mono auto generated files 18 | mono_crash.* 19 | 20 | # Build results 21 | [Dd]ebug/ 22 | [Dd]ebugPublic/ 23 | [Rr]elease/ 24 | [Rr]eleases/ 25 | dbg/ 26 | rel/ 27 | x64/ 28 | x86/ 29 | [Ww][Ii][Nn]32/ 30 | [Aa][Rr][Mm]/ 31 | [Aa][Rr][Mm]64/ 32 | bld/ 33 | [Bb]in/ 34 | [Oo]bj/ 35 | [Ll]og/ 36 | [Ll]ogs/ 37 | 38 | # Visual Studio 2015/2017 cache/options directory 39 | .vs/ 40 | # Uncomment if you have tasks that create the project's static files in wwwroot 41 | #wwwroot/ 42 | 43 | # Visual Studio 2017 auto generated files 44 | Generated\ Files/ 45 | 46 | # MSTest test Results 47 | [Tt]est[Rr]esult*/ 48 | [Bb]uild[Ll]og.* 49 | 50 | # NUnit 51 | *.VisualState.xml 52 | TestResult.xml 53 | nunit-*.xml 54 | 55 | # Build Results of an ATL Project 56 | [Dd]ebugPS/ 57 | [Rr]eleasePS/ 58 | dlldata.c 59 | 60 | # Benchmark Results 61 | BenchmarkDotNet.Artifacts/ 62 | 63 | # .NET Core 64 | project.lock.json 65 | project.fragment.lock.json 66 | artifacts/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.tlog 97 | *.vspscc 98 | *.vssscc 99 | .builds 100 | *.pidb 101 | *.svclog 102 | *.scc 103 | 104 | # Chutzpah Test files 105 | _Chutzpah* 106 | 107 | # Visual C++ cache files 108 | ipch/ 109 | *.aps 110 | *.ncb 111 | *.opendb 112 | *.opensdf 113 | *.sdf 114 | *.cachefile 115 | *.VC.db 116 | *.VC.VC.opendb 117 | 118 | # Visual Studio profiler 119 | *.psess 120 | *.vsp 121 | *.vspx 122 | *.sap 123 | 124 | # Visual Studio Trace Files 125 | *.e2e 126 | 127 | # TFS 2012 Local Workspace 128 | $tf/ 129 | 130 | # Guidance Automation Toolkit 131 | *.gpState 132 | 133 | # ReSharper is a .NET coding add-in 134 | _ReSharper*/ 135 | *.[Rr]e[Ss]harper 136 | *.DotSettings.user 137 | 138 | # TeamCity is a build add-in 139 | _TeamCity* 140 | 141 | # DotCover is a Code Coverage Tool 142 | *.dotCover 143 | 144 | # AxoCover is a Code Coverage Tool 145 | .axoCover/* 146 | !.axoCover/settings.json 147 | 148 | # Coverlet is a free, cross platform Code Coverage Tool 149 | coverage*.json 150 | coverage*.xml 151 | coverage*.info 152 | 153 | # Visual Studio code coverage results 154 | *.coverage 155 | *.coveragexml 156 | 157 | # NCrunch 158 | _NCrunch_* 159 | .*crunch*.local.xml 160 | nCrunchTemp_* 161 | 162 | # MightyMoose 163 | *.mm.* 164 | AutoTest.Net/ 165 | 166 | # Web workbench (sass) 167 | .sass-cache/ 168 | 169 | # Installshield output folder 170 | [Ee]xpress/ 171 | 172 | # DocProject is a documentation generator add-in 173 | DocProject/buildhelp/ 174 | DocProject/Help/*.HxT 175 | DocProject/Help/*.HxC 176 | DocProject/Help/*.hhc 177 | DocProject/Help/*.hhk 178 | DocProject/Help/*.hhp 179 | DocProject/Help/Html2 180 | DocProject/Help/html 181 | 182 | # Click-Once directory 183 | publish/ 184 | 185 | # Publish Web Output 186 | *.[Pp]ublish.xml 187 | *.azurePubxml 188 | # Note: Comment the next line if you want to checkin your web deploy settings, 189 | # but database connection strings (with potential passwords) will be unencrypted 190 | *.pubxml 191 | *.publishproj 192 | 193 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 194 | # checkin your Azure Web App publish settings, but sensitive information contained 195 | # in these scripts will be unencrypted 196 | PublishScripts/ 197 | 198 | # NuGet Packages 199 | *.nupkg 200 | # NuGet Symbol Packages 201 | *.snupkg 202 | # The packages folder can be ignored because of Package Restore 203 | **/[Pp]ackages/* 204 | # except build/, which is used as an MSBuild target. 205 | !**/[Pp]ackages/build/ 206 | # Uncomment if necessary however generally it will be regenerated when needed 207 | #!**/[Pp]ackages/repositories.config 208 | # NuGet v3's project.json files produces more ignorable files 209 | *.nuget.props 210 | *.nuget.targets 211 | 212 | # Microsoft Azure Build Output 213 | csx/ 214 | *.build.csdef 215 | 216 | # Microsoft Azure Emulator 217 | ecf/ 218 | rcf/ 219 | 220 | # Windows Store app package directories and files 221 | AppPackages/ 222 | BundleArtifacts/ 223 | Package.StoreAssociation.xml 224 | _pkginfo.txt 225 | *.appx 226 | *.appxbundle 227 | *.appxupload 228 | 229 | # Visual Studio cache files 230 | # files ending in .cache can be ignored 231 | *.[Cc]ache 232 | # but keep track of directories ending in .cache 233 | !?*.[Cc]ache/ 234 | 235 | # Others 236 | ClientBin/ 237 | ~$* 238 | *~ 239 | *.dbmdl 240 | *.dbproj.schemaview 241 | *.jfm 242 | *.pfx 243 | *.publishsettings 244 | orleans.codegen.cs 245 | 246 | # Including strong name files can present a security risk 247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 248 | #*.snk 249 | 250 | # Since there are multiple workflows, uncomment next line to ignore bower_components 251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 252 | #bower_components/ 253 | 254 | # RIA/Silverlight projects 255 | Generated_Code/ 256 | 257 | # Backup & report files from converting an old project file 258 | # to a newer Visual Studio version. Backup files are not needed, 259 | # because we have git ;-) 260 | _UpgradeReport_Files/ 261 | Backup*/ 262 | UpgradeLog*.XML 263 | UpgradeLog*.htm 264 | ServiceFabricBackup/ 265 | *.rptproj.bak 266 | 267 | # SQL Server files 268 | *.mdf 269 | *.ldf 270 | *.ndf 271 | 272 | # Business Intelligence projects 273 | *.rdl.data 274 | *.bim.layout 275 | *.bim_*.settings 276 | *.rptproj.rsuser 277 | *- [Bb]ackup.rdl 278 | *- [Bb]ackup ([0-9]).rdl 279 | *- [Bb]ackup ([0-9][0-9]).rdl 280 | 281 | # Microsoft Fakes 282 | FakesAssemblies/ 283 | 284 | # GhostDoc plugin setting file 285 | *.GhostDoc.xml 286 | 287 | # Node.js Tools for Visual Studio 288 | .ntvs_analysis.dat 289 | node_modules/ 290 | 291 | # Visual Studio 6 build log 292 | *.plg 293 | 294 | # Visual Studio 6 workspace options file 295 | *.opt 296 | 297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 298 | *.vbw 299 | 300 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 301 | *.vbp 302 | 303 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 304 | *.dsw 305 | *.dsp 306 | 307 | # Visual Studio 6 technical files 308 | *.ncb 309 | *.aps 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # CodeRush personal settings 327 | .cr/personal 328 | 329 | # Python Tools for Visual Studio (PTVS) 330 | __pycache__/ 331 | *.pyc 332 | 333 | # Cake - Uncomment if you are using it 334 | # tools/** 335 | # !tools/packages.config 336 | 337 | # Tabs Studio 338 | *.tss 339 | 340 | # Telerik's JustMock configuration file 341 | *.jmconfig 342 | 343 | # BizTalk build output 344 | *.btp.cs 345 | *.btm.cs 346 | *.odx.cs 347 | *.xsd.cs 348 | 349 | # OpenCover UI analysis results 350 | OpenCover/ 351 | 352 | # Azure Stream Analytics local run output 353 | ASALocalRun/ 354 | 355 | # MSBuild Binary and Structured Log 356 | *.binlog 357 | 358 | # NVidia Nsight GPU debugger configuration file 359 | *.nvuser 360 | 361 | # MFractors (Xamarin productivity tool) working folder 362 | .mfractor/ 363 | 364 | # Local History for Visual Studio 365 | .localhistory/ 366 | 367 | # Visual Studio History (VSHistory) files 368 | .vshistory/ 369 | 370 | # BeatPulse healthcheck temp database 371 | healthchecksdb 372 | 373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 374 | MigrationBackup/ 375 | 376 | # Ionide (cross platform F# VS Code tools) working folder 377 | .ionide/ 378 | 379 | # Fody - auto-generated XML schema 380 | FodyWeavers.xsd 381 | 382 | # VS Code files for those working on multiple tools 383 | .vscode/* 384 | !.vscode/settings.json 385 | !.vscode/tasks.json 386 | !.vscode/launch.json 387 | !.vscode/extensions.json 388 | *.code-workspace 389 | 390 | # Local History for Visual Studio Code 391 | .history/ 392 | 393 | # Windows Installer files from build outputs 394 | *.cab 395 | *.msi 396 | *.msix 397 | *.msm 398 | *.msp 399 | 400 | # JetBrains Rider 401 | *.sln.iml -------------------------------------------------------------------------------- /external/external.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {9193bbae-e4ed-4b6d-b844-9859db184dfc} 6 | 7 | 8 | {07cfaa2e-d81f-401a-aa6e-05388cbbae73} 9 | 10 | 11 | {c1a449d7-78cd-42da-89e3-0c60551fd7ea} 12 | 13 | 14 | {3a962fc3-607b-41f9-b120-ce657bcd3acd} 15 | 16 | 17 | {4475b62b-6b8d-4d29-92ef-1336f5b666d7} 18 | 19 | 20 | {4519f7bc-1371-449b-a7fd-dc6b118d92b3} 21 | 22 | 23 | {ea31dc5b-d35c-415c-b44b-db2d6d846530} 24 | 25 | 26 | {d286b7b5-6d21-4525-9543-683ca9e1bfc6} 27 | 28 | 29 | {600bc4ae-9567-4ae0-8a48-bc7f1ee88da9} 30 | 31 | 32 | {3543c591-7678-4583-8315-a38cf7c1206a} 33 | 34 | 35 | {4a36981a-fa04-4e12-9d67-68cc1c448749} 36 | 37 | 38 | {9522a8e2-d518-46b0-9e4f-c4b9544ac212} 39 | 40 | 41 | {73113ea4-9508-47e7-9f78-d5f749301b3b} 42 | 43 | 44 | {ac5f3c1b-9dc1-4f31-985f-2d9915123ab2} 45 | 46 | 47 | {a8478ac4-0a80-4b7e-8532-bb54415432f7} 48 | 49 | 50 | {8d496cb2-0f8c-4f26-8549-90f9133eece7} 51 | 52 | 53 | {d6d82f66-cc70-4863-8875-e89a2df01529} 54 | 55 | 56 | {dc99bdfa-8e54-4569-9337-abf1b401d8ca} 57 | 58 | 59 | {d2ffde6c-ba1d-4a93-afd2-f591807eee55} 60 | 61 | 62 | {97fb2fa9-adf5-4956-be49-ca44ede461d6} 63 | 64 | 65 | {ee67810e-58b4-457b-8925-fa511e95c64c} 66 | 67 | 68 | {6a25affa-6345-489b-aeb9-8a3f18de3620} 69 | 70 | 71 | {dc797bf0-75c7-426e-a915-ac3f765accd7} 72 | 73 | 74 | {ca0538ce-63c1-4e49-a9c6-8b1f91c879d4} 75 | 76 | 77 | {5e3b732d-4c56-4e59-a5b8-ebf922f36130} 78 | 79 | 80 | {2862286a-f8b2-4079-8b9f-21c9396cdd1c} 81 | 82 | 83 | 84 | 85 | utils\precompiled 86 | 87 | 88 | utils\memory 89 | 90 | 91 | utils\var 92 | 93 | 94 | utils\xorstr 95 | 96 | 97 | utils\lazyimporter 98 | 99 | 100 | sdk 101 | 102 | 103 | sdk 104 | 105 | 106 | cheats\bhop 107 | 108 | 109 | sdk 110 | 111 | 112 | utils 113 | 114 | 115 | cheats\glow 116 | 117 | 118 | utils\keybind 119 | 120 | 121 | utils\process 122 | 123 | 124 | cheats\triggerbot 125 | 126 | 127 | sdk\datatypes 128 | 129 | 130 | cheats\skinchanger 131 | 132 | 133 | cheats\aimbot 134 | 135 | 136 | utils\config 137 | 138 | 139 | utils\config 140 | 141 | 142 | utils\menu 143 | 144 | 145 | sdk\cache 146 | 147 | 148 | cheats\edgejump 149 | 150 | 151 | sdk\cache\world 152 | 153 | 154 | sdk\cache\entity 155 | 156 | 157 | utils\math 158 | 159 | 160 | sdk\datatypes 161 | 162 | 163 | sdk\classes\entity 164 | 165 | 166 | sdk\classes\entity 167 | 168 | 169 | sdk\classes\engine 170 | 171 | 172 | sdk\classes\engine 173 | 174 | 175 | sdk\classes\engine 176 | 177 | 178 | 179 | 180 | utils\precompiled 181 | 182 | 183 | utils\memory 184 | 185 | 186 | 187 | cheats\bhop 188 | 189 | 190 | sdk 191 | 192 | 193 | cheats\glow 194 | 195 | 196 | cheats\triggerbot 197 | 198 | 199 | cheats\skinchanger 200 | 201 | 202 | cheats\aimbot 203 | 204 | 205 | utils\config 206 | 207 | 208 | utils\menu 209 | 210 | 211 | cheats\edgejump 212 | 213 | 214 | sdk\classes\entity 215 | 216 | 217 | sdk\classes\entity 218 | 219 | 220 | sdk\classes\engine 221 | 222 | 223 | sdk\classes\engine 224 | 225 | 226 | sdk\classes\engine 227 | 228 | 229 | -------------------------------------------------------------------------------- /external/offsets.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // 2022-12-17 02:01:15.156766200 UTC 6 | 7 | namespace sdk 8 | { 9 | constexpr ::std::int64_t timestamp = 1671242475; 10 | inline std::string current_game_version = xorstr("1539"); 11 | 12 | namespace netvars 13 | { 14 | static constexpr std::uintptr_t cs_gamerules_data = 0x0; 15 | static constexpr std::uintptr_t m_ArmorValue = 0x117CC; 16 | static constexpr std::uintptr_t m_Collision = 0x320; 17 | static constexpr std::uintptr_t m_CollisionGroup = 0x474; 18 | static constexpr std::uintptr_t m_Local = 0x2FCC; 19 | static constexpr std::uintptr_t m_MoveType = 0x25C; 20 | static constexpr std::uintptr_t m_OriginalOwnerXuidHigh = 0x31D4; 21 | static constexpr std::uintptr_t m_OriginalOwnerXuidLow = 0x31D0; 22 | static constexpr std::uintptr_t m_SurvivalGameRuleDecisionTypes = 0x1328; 23 | static constexpr std::uintptr_t m_SurvivalRules = 0xD00; 24 | static constexpr std::uintptr_t m_aimPunchAngle = 0x303C; 25 | static constexpr std::uintptr_t m_aimPunchAngleVel = 0x3048; 26 | static constexpr std::uintptr_t m_angEyeAnglesX = 0x117D0; 27 | static constexpr std::uintptr_t m_angEyeAnglesY = 0x117D4; 28 | static constexpr std::uintptr_t m_bBombDefused = 0x29C0; 29 | static constexpr std::uintptr_t m_bBombPlanted = 0x9A5; 30 | static constexpr std::uintptr_t m_bBombTicking = 0x2990; 31 | static constexpr std::uintptr_t m_bFreezePeriod = 0x20; 32 | static constexpr std::uintptr_t m_bGunGameImmunity = 0x9990; 33 | static constexpr std::uintptr_t m_bHasDefuser = 0x117DC; 34 | static constexpr std::uintptr_t m_bHasHelmet = 0x117C0; 35 | static constexpr std::uintptr_t m_bInReload = 0x32B5; 36 | static constexpr std::uintptr_t m_bIsDefusing = 0x997C; 37 | static constexpr std::uintptr_t m_bIsQueuedMatchmaking = 0x74; 38 | static constexpr std::uintptr_t m_bIsScoped = 0x9974; 39 | static constexpr std::uintptr_t m_bIsValveDS = 0x7C; 40 | static constexpr std::uintptr_t m_bSpotted = 0x93D; 41 | static constexpr std::uintptr_t m_bSpottedByMask = 0x980; 42 | static constexpr std::uintptr_t m_bStartedArming = 0x3400; 43 | static constexpr std::uintptr_t m_bUseCustomAutoExposureMax = 0x9D9; 44 | static constexpr std::uintptr_t m_bUseCustomAutoExposureMin = 0x9D8; 45 | static constexpr std::uintptr_t m_bUseCustomBloomScale = 0x9DA; 46 | static constexpr std::uintptr_t m_clrRender = 0x70; 47 | static constexpr std::uintptr_t m_dwBoneMatrix = 0x26A8; 48 | static constexpr std::uintptr_t m_fAccuracyPenalty = 0x3340; 49 | static constexpr std::uintptr_t m_fFlags = 0x104; 50 | static constexpr std::uintptr_t m_flC4Blow = 0x29A0; 51 | static constexpr std::uintptr_t m_flCustomAutoExposureMax = 0x9E0; 52 | static constexpr std::uintptr_t m_flCustomAutoExposureMin = 0x9DC; 53 | static constexpr std::uintptr_t m_flCustomBloomScale = 0x9E4; 54 | static constexpr std::uintptr_t m_flDefuseCountDown = 0x29BC; 55 | static constexpr std::uintptr_t m_flDefuseLength = 0x29B8; 56 | static constexpr std::uintptr_t m_flFallbackWear = 0x31E0; 57 | static constexpr std::uintptr_t m_flFlashDuration = 0x10470; 58 | static constexpr std::uintptr_t m_flFlashMaxAlpha = 0x1046C; 59 | static constexpr std::uintptr_t m_flLastBoneSetupTime = 0x2928; 60 | static constexpr std::uintptr_t m_flLowerBodyYawTarget = 0x9ADC; 61 | static constexpr std::uintptr_t m_flNextAttack = 0x2D80; 62 | static constexpr std::uintptr_t m_flNextPrimaryAttack = 0x3248; 63 | static constexpr std::uintptr_t m_flSimulationTime = 0x268; 64 | static constexpr std::uintptr_t m_flTimerLength = 0x29A4; 65 | static constexpr std::uintptr_t m_hActiveWeapon = 0x2F08; 66 | static constexpr std::uintptr_t m_hBombDefuser = 0x29C4; 67 | static constexpr std::uintptr_t m_hMyWeapons = 0x2E08; 68 | static constexpr std::uintptr_t m_hObserverTarget = 0x339C; 69 | static constexpr std::uintptr_t m_hOwner = 0x29DC; 70 | static constexpr std::uintptr_t m_hOwnerEntity = 0x14C; 71 | static constexpr std::uintptr_t m_hViewModel = 0x3308; 72 | static constexpr std::uintptr_t m_iAccountID = 0x2FD8; 73 | static constexpr std::uintptr_t m_iClip1 = 0x3274; 74 | static constexpr std::uintptr_t m_iCompetitiveRanking = 0x1A84; 75 | static constexpr std::uintptr_t m_iCompetitiveWins = 0x1B88; 76 | static constexpr std::uintptr_t m_iCrosshairId = 0x11838; 77 | static constexpr std::uintptr_t m_iDefaultFOV = 0x333C; 78 | static constexpr std::uintptr_t m_iEntityQuality = 0x2FBC; 79 | static constexpr std::uintptr_t m_iFOV = 0x31F4; 80 | static constexpr std::uintptr_t m_iFOVStart = 0x31F8; 81 | static constexpr std::uintptr_t m_iGlowIndex = 0x10488; 82 | static constexpr std::uintptr_t m_iHealth = 0x100; 83 | static constexpr std::uintptr_t m_iItemDefinitionIndex = 0x2FBA; 84 | static constexpr std::uintptr_t m_iItemIDHigh = 0x2FD0; 85 | static constexpr std::uintptr_t m_iMostRecentModelBoneCounter = 0x2690; 86 | static constexpr std::uintptr_t m_iObserverMode = 0x3388; 87 | static constexpr std::uintptr_t m_iShotsFired = 0x103E0; 88 | static constexpr std::uintptr_t m_iState = 0x3268; 89 | static constexpr std::uintptr_t m_iTeamNum = 0xF4; 90 | static constexpr std::uintptr_t m_iViewModelIndex = 0x3250; 91 | static constexpr std::uintptr_t m_lifeState = 0x25F; 92 | static constexpr std::uintptr_t m_nBombSite = 0x2994; 93 | static constexpr std::uintptr_t m_nFallbackPaintKit = 0x31D8; 94 | static constexpr std::uintptr_t m_nFallbackSeed = 0x31DC; 95 | static constexpr std::uintptr_t m_nFallbackStatTrak = 0x31E4; 96 | static constexpr std::uintptr_t m_nForceBone = 0x268C; 97 | static constexpr std::uintptr_t m_nModelIndex = 0x258; 98 | static constexpr std::uintptr_t m_nTickBase = 0x3440; 99 | static constexpr std::uintptr_t m_nViewModelIndex = 0x29D0; 100 | static constexpr std::uintptr_t m_rgflCoordinateFrame = 0x444; 101 | static constexpr std::uintptr_t m_szCustomName = 0x304C; 102 | static constexpr std::uintptr_t m_szLastPlaceName = 0x35C4; 103 | static constexpr std::uintptr_t m_thirdPersonViewAngles = 0x31E8; 104 | static constexpr std::uintptr_t m_vecOrigin = 0x138; 105 | static constexpr std::uintptr_t m_vecVelocity = 0x114; 106 | static constexpr std::uintptr_t m_vecViewOffset = 0x108; 107 | static constexpr std::uintptr_t m_viewPunchAngle = 0x3030; 108 | static constexpr std::uintptr_t m_zoomLevel = 0x33E0; 109 | } // namespace netvars 110 | 111 | namespace offsets 112 | { 113 | static constexpr std::uintptr_t anim_overlays = 0x2990; 114 | static constexpr std::uintptr_t clientstate_choked_commands = 0x4D30; 115 | static constexpr std::uintptr_t clientstate_delta_ticks = 0x174; 116 | static constexpr std::uintptr_t clientstate_last_outgoing_command = 0x4D2C; 117 | static constexpr std::uintptr_t clientstate_net_channel = 0x9C; 118 | static constexpr std::uintptr_t convar_name_hash_table = 0x301A0; 119 | static constexpr std::uintptr_t dwClientState = 0x59F194; 120 | static constexpr std::uintptr_t dwClientState_GetLocalPlayer = 0x180; 121 | static constexpr std::uintptr_t dwClientState_IsHLTV = 0x4D48; 122 | static constexpr std::uintptr_t dwClientState_Map = 0x28C; 123 | static constexpr std::uintptr_t dwClientState_MapDirectory = 0x188; 124 | static constexpr std::uintptr_t dwClientState_MaxPlayer = 0x388; 125 | static constexpr std::uintptr_t dwClientState_PlayerInfo = 0x52C0; 126 | static constexpr std::uintptr_t dwClientState_State = 0x108; 127 | static constexpr std::uintptr_t dwClientState_ViewAngles = 0x4D90; 128 | static constexpr std::uintptr_t dwEntityList = 0x4DFFF14; 129 | static constexpr std::uintptr_t dwForceAttack = 0x322DD10; 130 | static constexpr std::uintptr_t dwForceAttack2 = 0x322DD1C; 131 | static constexpr std::uintptr_t dwForceBackward = 0x322DD40; 132 | static constexpr std::uintptr_t dwForceForward = 0x322DD34; 133 | static constexpr std::uintptr_t dwForceJump = 0x52BBC9C; 134 | static constexpr std::uintptr_t dwForceLeft = 0x322DD4C; 135 | static constexpr std::uintptr_t dwForceRight = 0x322DD58; 136 | static constexpr std::uintptr_t dwGameDir = 0x63AD80; 137 | static constexpr std::uintptr_t dwGameRulesProxy = 0x532F4CC; 138 | static constexpr std::uintptr_t dwGetAllClasses = 0xE0BFDC; 139 | static constexpr std::uintptr_t dwGlobalVars = 0x59EE58; 140 | static constexpr std::uintptr_t dwGlowObjectManager = 0x535A9D8; 141 | static constexpr std::uintptr_t dwInput = 0x525D4E8; 142 | static constexpr std::uintptr_t dwInterfaceLinkList = 0x99BC84; 143 | static constexpr std::uintptr_t dwLocalPlayer = 0xDEA964; 144 | static constexpr std::uintptr_t dwMouseEnable = 0x5239148; 145 | static constexpr std::uintptr_t dwMouseEnablePtr = 0x5239118; 146 | static constexpr std::uintptr_t dwPlayerResource = 0x322C0C0; 147 | static constexpr std::uintptr_t dwRadarBase = 0x52369EC; 148 | static constexpr std::uintptr_t dwSetClanTag = 0x8DA80; 149 | static constexpr std::uintptr_t dwViewMatrix = 0x4DF0D44; 150 | static constexpr std::uintptr_t dwWeaponTable = 0x525E5C4; 151 | static constexpr std::uintptr_t dwWeaponTableIndex = 0x326C; 152 | static constexpr std::uintptr_t dwbSendPackets = 0xDD072; 153 | static constexpr std::uintptr_t dwppDirect3DDevice9 = 0xA62C0; 154 | static constexpr std::uintptr_t find_hud_element = 0x3120FBD0; 155 | static constexpr std::uintptr_t force_update_spectator_glow = 0x3D91CA; 156 | static constexpr std::uintptr_t interface_engine_cvar = 0x3FA9C; 157 | static constexpr std::uintptr_t is_c4_owner = 0x3E69E0; 158 | static constexpr std::uintptr_t m_bDormant = 0xED; 159 | static constexpr std::uintptr_t m_bIsLocalPlayer = 0x3628; 160 | static constexpr std::uintptr_t m_flSpawnTime = 0x103C0; 161 | static constexpr std::uintptr_t m_pStudioHdr = 0x2950; 162 | static constexpr std::uintptr_t m_pitchClassPtr = 0x5239040; 163 | static constexpr std::uintptr_t model_ambient_min = 0x5A118C; 164 | static constexpr std::uintptr_t set_abs_angles = 0x1E72D0; 165 | static constexpr std::uintptr_t set_abs_origin = 0x1E7110; 166 | } // namespace offsets 167 | } // namespace sdk 168 | -------------------------------------------------------------------------------- /external/external.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {f2bf0214-71e2-48c7-a58b-6d028037c13e} 17 | external 18 | 10.0 19 | external 20 | 21 | 22 | 23 | Application 24 | true 25 | v143 26 | Unicode 27 | 28 | 29 | Application 30 | false 31 | ClangCL 32 | true 33 | Unicode 34 | 14.0.4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | true 50 | .\out\dbg\ 51 | .\out\dbg\obj\ 52 | C:\Users\biscoito\Desktop\projeto\dev\valve-bsp-parser\thirdparty\liblzma\include;C:\Users\biscoito\Desktop\projeto\dev\valve-bsp-parser\include;$(IncludePath) 53 | C:\Users\biscoito\Desktop\projeto\dev\vcpkg\installed\x86-windows-static\lib;C:\Users\biscoito\Desktop\projeto\dev\valve-bsp-parser\build\Debug-x86;$(LibraryPath) 54 | 55 | 56 | false 57 | .\out\rel\ 58 | .\out\rel\obj\ 59 | C:\Users\biscoito\Desktop\projeto\dev\valve-bsp-parser\thirdparty\liblzma\include;C:\Users\biscoito\Desktop\projeto\dev\valve-bsp-parser\include;$(IncludePath) 60 | C:\Users\biscoito\Desktop\projeto\dev\vcpkg\installed\x86-windows-static\lib;C:\Users\biscoito\Desktop\projeto\dev\valve-bsp-parser\build\Release-x86;$(LibraryPath) 61 | 62 | 63 | true 64 | false 65 | true 66 | 67 | 68 | true 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | 77 | 78 | 79 | Level3 80 | true 81 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 82 | true 83 | stdcpp20 84 | stdc17 85 | Use 86 | pch.hpp 87 | true 88 | MultiThreadedDebug 89 | 90 | 91 | 92 | 93 | Console 94 | true 95 | valve-bsp-parser.lib;%(AdditionalDependencies) 96 | RequireAdministrator 97 | 98 | 99 | 100 | 101 | Level3 102 | true 103 | true 104 | true 105 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp17 108 | stdc17 109 | AnySuitable 110 | Speed 111 | false 112 | Use 113 | pch.hpp 114 | MaxSpeed 115 | true 116 | -mllvm -sub -mllvm -sub_loop=2 -mllvm -bcf -mllvm -bcf_loop=1 -mllvm -bcf_prob=45 -mllvm -fla -mllvm -split -mllvm -split_num=2 %(AdditionalOptions) 117 | MultiThreaded 118 | None 119 | 120 | 121 | 122 | 123 | Console 124 | true 125 | true 126 | false 127 | valve-bsp-parser.lib;%(AdditionalDependencies) 128 | RequireAdministrator 129 | $(TargetName).pdb 130 | false 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | Create 181 | pch.hpp 182 | Create 183 | pch.hpp 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /external/xorstr.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 - 2021 Justas Masiulis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef JM_XORSTR_HPP 18 | #define JM_XORSTR_HPP 19 | 20 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__) 21 | #include 22 | #elif defined(_M_X64) || defined(__amd64__) || defined(_M_IX86) || defined(__i386__) 23 | #include 24 | #else 25 | #error Unsupported platform 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #define xorstr_(str) ::jm::xor_string([]() { return str; }, std::integral_constant{}, std::make_index_sequence<::jm::detail::_buffer_size()>{}) 34 | #define xorstr(str) xorstr_(str).crypt_get() 35 | 36 | #ifdef _MSC_VER 37 | #define XORSTR_FORCEINLINE __forceinline 38 | #else 39 | #define XORSTR_FORCEINLINE __attribute__((always_inline)) inline 40 | #endif 41 | 42 | namespace jm { 43 | 44 | namespace detail { 45 | 46 | template 47 | XORSTR_FORCEINLINE constexpr std::size_t _buffer_size() 48 | { 49 | return ((Size / 16) + (Size % 16 != 0)) * 2; 50 | } 51 | 52 | template 53 | XORSTR_FORCEINLINE constexpr std::uint32_t key4() noexcept 54 | { 55 | std::uint32_t value = Seed; 56 | for (char c : __TIME__) 57 | value = static_cast((value ^ c) * 16777619ull); 58 | return value; 59 | } 60 | 61 | template 62 | XORSTR_FORCEINLINE constexpr std::uint64_t key8() 63 | { 64 | constexpr auto first_part = key4<2166136261 + S>(); 65 | constexpr auto second_part = key4(); 66 | return (static_cast(first_part) << 32) | second_part; 67 | } 68 | 69 | // loads up to 8 characters of string into uint64 and xors it with the key 70 | template 71 | XORSTR_FORCEINLINE constexpr std::uint64_t 72 | load_xored_str8(std::uint64_t key, std::size_t idx, const CharT* str) noexcept 73 | { 74 | using cast_type = typename std::make_unsigned::type; 75 | constexpr auto value_size = sizeof(CharT); 76 | constexpr auto idx_offset = 8 / value_size; 77 | 78 | std::uint64_t value = key; 79 | for (std::size_t i = 0; i < idx_offset && i + idx * idx_offset < N; ++i) 80 | value ^= 81 | (std::uint64_t{ static_cast(str[i + idx * idx_offset]) } 82 | << ((i % idx_offset) * 8 * value_size)); 83 | 84 | return value; 85 | } 86 | 87 | // forces compiler to use registers instead of stuffing constants in rdata 88 | XORSTR_FORCEINLINE std::uint64_t load_from_reg(std::uint64_t value) noexcept 89 | { 90 | #if defined(__clang__) || defined(__GNUC__) 91 | asm("" : "=r"(value) : "0"(value) : ); 92 | return value; 93 | #else 94 | volatile std::uint64_t reg = value; 95 | return reg; 96 | #endif 97 | } 98 | 99 | } // namespace detail 100 | 101 | template 102 | class xor_string; 103 | 104 | template 105 | class xor_string, std::index_sequence> { 106 | #ifndef JM_XORSTR_DISABLE_AVX_INTRINSICS 107 | constexpr static inline std::uint64_t alignment = ((Size > 16) ? 32 : 16); 108 | #else 109 | constexpr static inline std::uint64_t alignment = 16; 110 | #endif 111 | 112 | alignas(alignment) std::uint64_t _storage[sizeof...(Keys)]; 113 | 114 | public: 115 | using value_type = CharT; 116 | using size_type = std::size_t; 117 | using pointer = CharT*; 118 | using const_pointer = const CharT*; 119 | 120 | template 121 | XORSTR_FORCEINLINE xor_string(L l, std::integral_constant, std::index_sequence) noexcept 122 | : _storage{ ::jm::detail::load_from_reg((std::integral_constant(Keys, Indices, l())>::value))... } 123 | {} 124 | 125 | XORSTR_FORCEINLINE constexpr size_type size() const noexcept 126 | { 127 | return Size - 1; 128 | } 129 | 130 | XORSTR_FORCEINLINE void crypt() noexcept 131 | { 132 | // everything is inlined by hand because a certain compiler with a certain linker is _very_ slow 133 | #if defined(__clang__) 134 | alignas(alignment) 135 | std::uint64_t arr[]{ ::jm::detail::load_from_reg(Keys)... }; 136 | std::uint64_t* keys = 137 | (std::uint64_t*)::jm::detail::load_from_reg((std::uint64_t)arr); 138 | #else 139 | alignas(alignment) std::uint64_t keys[]{ ::jm::detail::load_from_reg(Keys)... }; 140 | #endif 141 | 142 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__) 143 | #if defined(__clang__) 144 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : __builtin_neon_vst1q_v( 145 | reinterpret_cast(_storage) + Indices * 2, 146 | veorq_u64(__builtin_neon_vld1q_v(reinterpret_cast(_storage) + Indices * 2, 51), 147 | __builtin_neon_vld1q_v(reinterpret_cast(keys) + Indices * 2, 51)), 148 | 51)), ...); 149 | #else // GCC, MSVC 150 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : vst1q_u64( 151 | reinterpret_cast(_storage) + Indices * 2, 152 | veorq_u64(vld1q_u64(reinterpret_cast(_storage) + Indices * 2), 153 | vld1q_u64(reinterpret_cast(keys) + Indices * 2)))), ...); 154 | #endif 155 | #elif !defined(JM_XORSTR_DISABLE_AVX_INTRINSICS) 156 | ((Indices >= sizeof(_storage) / 32 ? static_cast(0) : _mm256_store_si256( 157 | reinterpret_cast<__m256i*>(_storage) + Indices, 158 | _mm256_xor_si256( 159 | _mm256_load_si256(reinterpret_cast(_storage) + Indices), 160 | _mm256_load_si256(reinterpret_cast(keys) + Indices)))), ...); 161 | 162 | if constexpr (sizeof(_storage) % 32 != 0) 163 | _mm_store_si128( 164 | reinterpret_cast<__m128i*>(_storage + sizeof...(Keys) - 2), 165 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage + sizeof...(Keys) - 2)), 166 | _mm_load_si128(reinterpret_cast(keys + sizeof...(Keys) - 2)))); 167 | #else 168 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : _mm_store_si128( 169 | reinterpret_cast<__m128i*>(_storage) + Indices, 170 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage) + Indices), 171 | _mm_load_si128(reinterpret_cast(keys) + Indices)))), ...); 172 | #endif 173 | } 174 | 175 | XORSTR_FORCEINLINE const_pointer get() const noexcept 176 | { 177 | return reinterpret_cast(_storage); 178 | } 179 | 180 | XORSTR_FORCEINLINE pointer get() noexcept 181 | { 182 | return reinterpret_cast(_storage); 183 | } 184 | 185 | XORSTR_FORCEINLINE pointer crypt_get() noexcept 186 | { 187 | // crypt() is inlined by hand because a certain compiler with a certain linker is _very_ slow 188 | #if defined(__clang__) 189 | alignas(alignment) 190 | std::uint64_t arr[]{ ::jm::detail::load_from_reg(Keys)... }; 191 | std::uint64_t* keys = 192 | (std::uint64_t*)::jm::detail::load_from_reg((std::uint64_t)arr); 193 | #else 194 | alignas(alignment) std::uint64_t keys[]{ ::jm::detail::load_from_reg(Keys)... }; 195 | #endif 196 | 197 | #if defined(_M_ARM64) || defined(__aarch64__) || defined(_M_ARM) || defined(__arm__) 198 | #if defined(__clang__) 199 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : __builtin_neon_vst1q_v( 200 | reinterpret_cast(_storage) + Indices * 2, 201 | veorq_u64(__builtin_neon_vld1q_v(reinterpret_cast(_storage) + Indices * 2, 51), 202 | __builtin_neon_vld1q_v(reinterpret_cast(keys) + Indices * 2, 51)), 203 | 51)), ...); 204 | #else // GCC, MSVC 205 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : vst1q_u64( 206 | reinterpret_cast(_storage) + Indices * 2, 207 | veorq_u64(vld1q_u64(reinterpret_cast(_storage) + Indices * 2), 208 | vld1q_u64(reinterpret_cast(keys) + Indices * 2)))), ...); 209 | #endif 210 | #elif !defined(JM_XORSTR_DISABLE_AVX_INTRINSICS) 211 | ((Indices >= sizeof(_storage) / 32 ? static_cast(0) : _mm256_store_si256( 212 | reinterpret_cast<__m256i*>(_storage) + Indices, 213 | _mm256_xor_si256( 214 | _mm256_load_si256(reinterpret_cast(_storage) + Indices), 215 | _mm256_load_si256(reinterpret_cast(keys) + Indices)))), ...); 216 | 217 | if constexpr (sizeof(_storage) % 32 != 0) 218 | _mm_store_si128( 219 | reinterpret_cast<__m128i*>(_storage + sizeof...(Keys) - 2), 220 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage + sizeof...(Keys) - 2)), 221 | _mm_load_si128(reinterpret_cast(keys + sizeof...(Keys) - 2)))); 222 | #else 223 | ((Indices >= sizeof(_storage) / 16 ? static_cast(0) : _mm_store_si128( 224 | reinterpret_cast<__m128i*>(_storage) + Indices, 225 | _mm_xor_si128(_mm_load_si128(reinterpret_cast(_storage) + Indices), 226 | _mm_load_si128(reinterpret_cast(keys) + Indices)))), ...); 227 | #endif 228 | 229 | return (pointer)(_storage); 230 | } 231 | }; 232 | 233 | template 234 | xor_string(L l, std::integral_constant, std::index_sequence)->xor_string< 235 | std::remove_const_t>, 236 | Size, 237 | std::integer_sequence()...>, 238 | std::index_sequence>; 239 | 240 | } // namespace jm 241 | 242 | #endif // include guard -------------------------------------------------------------------------------- /external/menu.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | #include "menu.hpp" 3 | 4 | void c_menu::on_paint() { 5 | static int x = 0, y = 0; 6 | 7 | ImGui::SetNextWindowSize({ (float)ctx::menu_width, (float)ctx::menu_height }, ImGuiCond_Once); 8 | ImGui::SetNextWindowPos({ 0, 0 }, ImGuiCond_Once); 9 | 10 | if (!var::b_is_running) 11 | std::exit(0); 12 | 13 | if (ImGui::Begin("external", &var::b_is_running, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove)) 14 | { 15 | if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) 16 | get_mouse_offset(x, y, ctx::hWnd); 17 | 18 | if (y >= 0 && y <= (ImGui::GetTextLineHeight() + ImGui::GetStyle().FramePadding.y * 4) && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) 19 | set_position(x, y, ctx::menu_width, ctx::menu_height, ctx::hWnd); 20 | 21 | if (ImGui::BeginTabBar("##var::external::tabs")) 22 | { 23 | if (ImGui::BeginTabItem("aimbot")) { 24 | // aimbot 25 | ImGui::Text("aimbot"); 26 | ImGui::Separator(); 27 | ImGui::Checkbox("enable##aimbot", &config.aimbot.b_aim_enable); 28 | ImGui::SliderFloat("smooth", &config.aimbot.f_aim_smooth, 1.f, 360.f); 29 | ImGui::SliderFloat("fov", &config.aimbot.f_aim_fov, 1.f, 180.f); 30 | 31 | // triggerbot 32 | ImGui::Text("triggerbot"); 33 | ImGui::Separator(); 34 | ImGui::Checkbox("enable##triggerbot", &config.aimbot.b_trigger_enable); 35 | 36 | ImGui::EndTabItem(); 37 | } 38 | 39 | if (ImGui::BeginTabItem("visuals")) { 40 | // glow 41 | ImGui::Text("visuals"); 42 | ImGui::Separator(); 43 | ImGui::Checkbox("enable##glow", &config.visuals.b_glow_enable); 44 | ImGui::Checkbox("health based", &config.visuals.b_glow_health_based); 45 | ImGui::Checkbox("visible only", &config.visuals.b_glow_visible_only); 46 | ImGui::ColorPicker4("color", (float*)&config.visuals.f_glow_color); 47 | 48 | ImGui::Text("skinchanger"); 49 | ImGui::Separator(); 50 | ImGui::Checkbox("enable##sc", &config.visuals.b_sc_enable); 51 | ImGui::Checkbox("set paint kit", &config.visuals.b_sc_set_paint_kit); 52 | 53 | static char paint_kit_buf[32]; 54 | ImGui::InputText("paint kit", paint_kit_buf, IM_ARRAYSIZE(paint_kit_buf)); 55 | 56 | var::skins::str_paint_kit = paint_kit_buf; 57 | 58 | ImGui::Combo("model", &config.visuals.i_sc_selected_model_index, var::skins::models.data(), (std::int32_t)var::skins::models.size()); 59 | 60 | ImGui::EndTabItem(); 61 | } 62 | 63 | if (ImGui::BeginTabItem("misc")) { 64 | // bhop 65 | ImGui::Text("bhop"); 66 | ImGui::Separator(); 67 | ImGui::Checkbox("enable##misc", &config.misc.b_enable_bhop); 68 | 69 | // edge jump 70 | ImGui::Text("edge jump"); 71 | ImGui::Separator(); 72 | ImGui::Checkbox("enable##edgejump", &config.misc.b_enable_ej); 73 | 74 | ImGui::EndTabItem(); 75 | } 76 | 77 | if (ImGui::BeginTabItem("config")) { 78 | ImGui::Text("Config settings"); 79 | ImGui::Separator(); 80 | 81 | if (ImGui::Button("Open config folder")) 82 | { 83 | if (PIDLIST_ABSOLUTE pidl; SUCCEEDED(SHParseDisplayName(config.get_path().wstring().data(), 0, &pidl, 0, 0))) 84 | { 85 | ITEMIDLIST id_null = { 0 }; 86 | LPCITEMIDLIST pidl_null[1] = { &id_null }; 87 | SHOpenFolderAndSelectItems(pidl, 1, pidl_null, 0); 88 | ILFree(pidl); 89 | } 90 | } 91 | 92 | constexpr auto& config_items = config.get_configs(); 93 | static auto current_config = -1; 94 | 95 | if ((size_t)(current_config) >= config_items.size()) 96 | current_config = -1; 97 | 98 | static char buffer[32]; 99 | 100 | ImGui::Text("Configs"); 101 | if (ImGui::ListBox("##var::external::config_list", ¤t_config, [](void* data, int idx, const char** out_text) 102 | { 103 | auto& vector = *(std::vector *)(data); 104 | *out_text = vector[idx].c_str(); 105 | return true; 106 | }, &config_items, (int)(config_items.size()), 5) && current_config != -1) strcpy_s(buffer, config_items[current_config].c_str()); 107 | 108 | if (ImGui::InputText("##var::external::config_name", buffer, IM_ARRAYSIZE(buffer), ImGuiInputTextFlags_EnterReturnsTrue)) 109 | { 110 | if (current_config != -1) 111 | config.rename(current_config, buffer); 112 | } 113 | 114 | if (ImGui::Button("Create", ImVec2(60, 25))) 115 | config.add(buffer); 116 | 117 | ImGui::SameLine(); 118 | 119 | if (ImGui::Button("Reset", ImVec2(60, 25))) 120 | config.reset(); 121 | 122 | ImGui::SameLine(); 123 | 124 | if (current_config > -1) 125 | { 126 | if (ImGui::Button("Save", ImVec2(60, 25))) 127 | config.save(current_config); 128 | 129 | ImGui::SameLine(); 130 | 131 | if (ImGui::Button("Load", ImVec2(60, 25))) 132 | config.load(current_config); 133 | 134 | ImGui::SameLine(); 135 | 136 | if (ImGui::Button("Delete", ImVec2(60, 25))) 137 | config.remove(current_config); 138 | } 139 | 140 | ImGui::EndTabItem(); 141 | } 142 | 143 | if (ImGui::BeginTabItem("debug")) { 144 | 145 | ImGui::Text("debug"); 146 | ImGui::Separator(); 147 | static bool show_advanced_debug{ false }; 148 | ImGui::Checkbox("Show advanced debug info", &show_advanced_debug); 149 | 150 | if (show_advanced_debug) 151 | { 152 | ImGui::Text("Information"); 153 | ImGui::Separator(); 154 | 155 | ImGui::Text("Application average: %.1f ms (%.1f fps)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); 156 | } 157 | 158 | ImGui::EndTabItem(); 159 | } 160 | ImGui::EndTabBar(); 161 | } 162 | ImGui::End(); 163 | } 164 | } 165 | 166 | void c_menu::set_position(int x, int y, int cx, int cy, HWND hwnd) 167 | { 168 | POINT point; GetCursorPos(&point); 169 | 170 | auto flags = SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE; 171 | if (x != 0 && y != 0) 172 | { 173 | x = point.x - x; 174 | y = point.y - y; 175 | flags &= ~SWP_NOMOVE; 176 | } 177 | 178 | if (cx != 0 && cy != 0) 179 | flags &= ~SWP_NOSIZE; 180 | 181 | SetWindowPos(hwnd, nullptr, x, y, cx, cy, flags); 182 | } 183 | 184 | void c_menu::get_mouse_offset(int& x, int& y, HWND hwnd) 185 | { 186 | POINT point; RECT rect; 187 | 188 | GetCursorPos(&point); 189 | GetWindowRect(hwnd, &rect); 190 | 191 | x = point.x - rect.left; 192 | y = point.y - rect.top; 193 | } 194 | 195 | bool c_menu::setup() { 196 | // Create application window 197 | ImGui_ImplWin32_EnableDpiAwareness(); 198 | ctx::wc = { 199 | sizeof(ctx::wc), 200 | CS_CLASSDC, 201 | wnd_proc, 202 | 0L, 0L, 203 | GetModuleHandle(NULL), 204 | NULL, NULL, 205 | NULL, NULL, 206 | L"Class", 207 | NULL 208 | }; 209 | 210 | RegisterClassEx(&ctx::wc); 211 | ctx::hWnd = CreateWindow( 212 | ctx::wc.lpszClassName, L"", 213 | WS_POPUP, 214 | 100, 100, 215 | ctx::menu_width, ctx::menu_height, 216 | NULL, NULL, 217 | ctx::wc.hInstance, 218 | NULL 219 | ); 220 | 221 | // Initialize Direct3D 222 | if (!create_device_d3d(ctx::hWnd)) 223 | { 224 | cleanup_device_d3d(); 225 | UnregisterClass(ctx::wc.lpszClassName, ctx::wc.hInstance); 226 | return false; 227 | } 228 | 229 | ShowWindow(ctx::hWnd, SW_SHOWDEFAULT); 230 | UpdateWindow(ctx::hWnd); 231 | 232 | // Setup Dear ImGui context 233 | IMGUI_CHECKVERSION(); 234 | ImGui::CreateContext(); 235 | ImGuiIO& io = ImGui::GetIO(); (void)io; 236 | 237 | // Setup Dear ImGui style 238 | ImGui::StyleColorsDark(); 239 | 240 | ImGui_ImplWin32_Init(ctx::hWnd); 241 | ImGui_ImplDX9_Init(dx::d3d_device); 242 | 243 | return true; 244 | } 245 | 246 | void c_menu::render() 247 | { 248 | // Our state 249 | ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); 250 | 251 | // Main loop 252 | bool done = false; 253 | while (!done) 254 | { 255 | MSG msg; 256 | while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) 257 | { 258 | TranslateMessage(&msg); 259 | DispatchMessage(&msg); 260 | if (msg.message == WM_QUIT) 261 | done = true; 262 | } 263 | 264 | if (done) 265 | break; 266 | 267 | // Start the Dear ImGui frame 268 | ImGui_ImplDX9_NewFrame(); 269 | ImGui_ImplWin32_NewFrame(); 270 | 271 | ImGui::NewFrame(); 272 | on_paint(); 273 | ImGui::EndFrame(); 274 | 275 | dx::d3d_device->SetRenderState(D3DRS_ZENABLE, FALSE); 276 | dx::d3d_device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); 277 | dx::d3d_device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); 278 | 279 | D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x * clear_color.w * 255.0f), (int)(clear_color.y * clear_color.w * 255.0f), (int)(clear_color.z * clear_color.w * 255.0f), (int)(clear_color.w * 255.0f)); 280 | dx::d3d_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); 281 | 282 | if (dx::d3d_device->BeginScene() >= 0) 283 | { 284 | ImGui::Render(); 285 | ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); 286 | dx::d3d_device->EndScene(); 287 | } 288 | 289 | HRESULT result = dx::d3d_device->Present(NULL, NULL, NULL, NULL); 290 | if (result == D3DERR_DEVICELOST && dx::d3d_device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) 291 | reset_device(); 292 | } 293 | 294 | this->destroy(); 295 | } 296 | 297 | void c_menu::destroy() { 298 | // Destroy 299 | ImGui_ImplDX9_Shutdown(); 300 | ImGui_ImplWin32_Shutdown(); 301 | ImGui::DestroyContext(); 302 | 303 | cleanup_device_d3d(); 304 | DestroyWindow(ctx::hWnd); 305 | UnregisterClass(ctx::wc.lpszClassName, ctx::wc.hInstance); 306 | } 307 | 308 | bool c_menu::create_device_d3d(HWND hWnd) 309 | { 310 | if ((dx::d3d = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) 311 | return false; 312 | 313 | // Create the D3DDevice 314 | ZeroMemory(&dx::d3d_param, sizeof(dx::d3d_param)); 315 | dx::d3d_param.Windowed = TRUE; 316 | dx::d3d_param.SwapEffect = D3DSWAPEFFECT_DISCARD; 317 | dx::d3d_param.BackBufferFormat = D3DFMT_UNKNOWN; // Need to use an explicit format with alpha if needing per-pixel alpha composition. 318 | dx::d3d_param.EnableAutoDepthStencil = TRUE; 319 | dx::d3d_param.AutoDepthStencilFormat = D3DFMT_D16; 320 | dx::d3d_param.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Present with vsync 321 | // g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate 322 | if (dx::d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &dx::d3d_param, &dx::d3d_device) < 0) 323 | return false; 324 | 325 | return true; 326 | } 327 | 328 | void c_menu::cleanup_device_d3d() 329 | { 330 | if (dx::d3d_device) { 331 | dx::d3d_device->Release(); 332 | dx::d3d_device = NULL; 333 | } 334 | 335 | if (dx::d3d) { 336 | dx::d3d->Release(); 337 | dx::d3d = NULL; 338 | } 339 | } 340 | 341 | void c_menu::reset_device() 342 | { 343 | ImGui_ImplDX9_InvalidateDeviceObjects(); 344 | 345 | HRESULT hr = dx::d3d_device->Reset(&dx::d3d_param); 346 | if (hr == D3DERR_INVALIDCALL) 347 | IM_ASSERT(0); 348 | 349 | ImGui_ImplDX9_CreateDeviceObjects(); 350 | } 351 | 352 | LRESULT WINAPI c_menu::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 353 | { 354 | if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) 355 | return true; 356 | 357 | switch (msg) 358 | { 359 | case WM_SIZE: 360 | if (dx::d3d_device != NULL && wParam != SIZE_MINIMIZED) 361 | { 362 | dx::d3d_param.BackBufferWidth = LOWORD(lParam); 363 | dx::d3d_param.BackBufferHeight = HIWORD(lParam); 364 | reset_device(); 365 | } 366 | return 0; 367 | 368 | case WM_SYSCOMMAND: 369 | if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu 370 | return 0; 371 | break; 372 | 373 | case WM_DESTROY: 374 | PostQuitMessage(0); 375 | return 0; 376 | } 377 | return DefWindowProc(hWnd, msg, wParam, lParam); 378 | } 379 | -------------------------------------------------------------------------------- /external/lazy_importer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 Justas Masiulis 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // === FAQ === documentation is available at https://github.com/JustasMasiulis/lazy_importer 18 | // * Code doesn't compile with errors about pointer conversion: 19 | // - Try using `nullptr` instead of `NULL` or call `get()` instead of using the overloaded operator() 20 | // * Lazy importer can't find the function I want: 21 | // - Double check that the module in which it's located in is actually loaded 22 | // - Try #define LAZY_IMPORTER_CASE_INSENSITIVE 23 | // This will start using case insensitive comparison globally 24 | // - Try #define LAZY_IMPORTER_RESOLVE_FORWARDED_EXPORTS 25 | // This will enable forwarded export resolution globally instead of needing explicit `forwarded()` calls 26 | 27 | #ifndef LAZY_IMPORTER_HPP 28 | #define LAZY_IMPORTER_HPP 29 | 30 | 31 | #define LI_FN(name) ::li::detail::lazy_function() 32 | 33 | #define LI_FN_DEF(name) ::li::detail::lazy_function() 34 | 35 | #define LI_MODULE(name) ::li::detail::lazy_module() 36 | 37 | #ifndef LAZY_IMPORTER_CPP_FORWARD 38 | #ifdef LAZY_IMPORTER_NO_CPP_FORWARD 39 | #define LAZY_IMPORTER_CPP_FORWARD(t, v) v 40 | #else 41 | #include 42 | #define LAZY_IMPORTER_CPP_FORWARD(t, v) std::forward( v ) 43 | #endif 44 | #endif 45 | 46 | #include 47 | 48 | #ifndef LAZY_IMPORTER_NO_FORCEINLINE 49 | #if defined(_MSC_VER) 50 | #define LAZY_IMPORTER_FORCEINLINE __forceinline 51 | #elif defined(__GNUC__) && __GNUC__ > 3 52 | #define LAZY_IMPORTER_FORCEINLINE inline __attribute__((__always_inline__)) 53 | #else 54 | #define LAZY_IMPORTER_FORCEINLINE inline 55 | #endif 56 | #else 57 | #define LAZY_IMPORTER_FORCEINLINE inline 58 | #endif 59 | 60 | 61 | #ifdef LAZY_IMPORTER_CASE_INSENSITIVE 62 | #define LAZY_IMPORTER_CASE_SENSITIVITY false 63 | #else 64 | #define LAZY_IMPORTER_CASE_SENSITIVITY true 65 | #endif 66 | 67 | #define LAZY_IMPORTER_STRINGIZE(x) #x 68 | #define LAZY_IMPORTER_STRINGIZE_EXPAND(x) LAZY_IMPORTER_STRINGIZE(x) 69 | 70 | #define LAZY_IMPORTER_KHASH(str) ::li::detail::khash(str, \ 71 | ::li::detail::khash_impl( __TIME__ __DATE__ LAZY_IMPORTER_STRINGIZE_EXPAND(__LINE__) LAZY_IMPORTER_STRINGIZE_EXPAND(__COUNTER__), 2166136261 )) 72 | 73 | namespace li { 74 | namespace detail { 75 | 76 | namespace win { 77 | 78 | struct LIST_ENTRY_T { 79 | const char* Flink; 80 | const char* Blink; 81 | }; 82 | 83 | struct UNICODE_STRING_T { 84 | unsigned short Length; 85 | unsigned short MaximumLength; 86 | wchar_t* Buffer; 87 | }; 88 | 89 | struct PEB_LDR_DATA_T { 90 | unsigned long Length; 91 | unsigned long Initialized; 92 | const char* SsHandle; 93 | LIST_ENTRY_T InLoadOrderModuleList; 94 | }; 95 | 96 | struct PEB_T { 97 | unsigned char Reserved1[2]; 98 | unsigned char BeingDebugged; 99 | unsigned char Reserved2[1]; 100 | const char* Reserved3[2]; 101 | PEB_LDR_DATA_T* Ldr; 102 | }; 103 | 104 | struct LDR_DATA_TABLE_ENTRY_T { 105 | LIST_ENTRY_T InLoadOrderLinks; 106 | LIST_ENTRY_T InMemoryOrderLinks; 107 | LIST_ENTRY_T InInitializationOrderLinks; 108 | const char* DllBase; 109 | const char* EntryPoint; 110 | union { 111 | unsigned long SizeOfImage; 112 | const char* _dummy; 113 | }; 114 | UNICODE_STRING_T FullDllName; 115 | UNICODE_STRING_T BaseDllName; 116 | 117 | LAZY_IMPORTER_FORCEINLINE const LDR_DATA_TABLE_ENTRY_T* 118 | load_order_next() const noexcept 119 | { 120 | return reinterpret_cast( 121 | InLoadOrderLinks.Flink); 122 | } 123 | }; 124 | 125 | struct IMAGE_DOS_HEADER { // DOS .EXE header 126 | unsigned short e_magic; // Magic number 127 | unsigned short e_cblp; // Bytes on last page of file 128 | unsigned short e_cp; // Pages in file 129 | unsigned short e_crlc; // Relocations 130 | unsigned short e_cparhdr; // Size of header in paragraphs 131 | unsigned short e_minalloc; // Minimum extra paragraphs needed 132 | unsigned short e_maxalloc; // Maximum extra paragraphs needed 133 | unsigned short e_ss; // Initial (relative) SS value 134 | unsigned short e_sp; // Initial SP value 135 | unsigned short e_csum; // Checksum 136 | unsigned short e_ip; // Initial IP value 137 | unsigned short e_cs; // Initial (relative) CS value 138 | unsigned short e_lfarlc; // File address of relocation table 139 | unsigned short e_ovno; // Overlay number 140 | unsigned short e_res[4]; // Reserved words 141 | unsigned short e_oemid; // OEM identifier (for e_oeminfo) 142 | unsigned short e_oeminfo; // OEM information; e_oemid specific 143 | unsigned short e_res2[10]; // Reserved words 144 | long e_lfanew; // File address of new exe header 145 | }; 146 | 147 | struct IMAGE_FILE_HEADER { 148 | unsigned short Machine; 149 | unsigned short NumberOfSections; 150 | unsigned long TimeDateStamp; 151 | unsigned long PointerToSymbolTable; 152 | unsigned long NumberOfSymbols; 153 | unsigned short SizeOfOptionalHeader; 154 | unsigned short Characteristics; 155 | }; 156 | 157 | struct IMAGE_EXPORT_DIRECTORY { 158 | unsigned long Characteristics; 159 | unsigned long TimeDateStamp; 160 | unsigned short MajorVersion; 161 | unsigned short MinorVersion; 162 | unsigned long Name; 163 | unsigned long Base; 164 | unsigned long NumberOfFunctions; 165 | unsigned long NumberOfNames; 166 | unsigned long AddressOfFunctions; // RVA from base of image 167 | unsigned long AddressOfNames; // RVA from base of image 168 | unsigned long AddressOfNameOrdinals; // RVA from base of image 169 | }; 170 | 171 | struct IMAGE_DATA_DIRECTORY { 172 | unsigned long VirtualAddress; 173 | unsigned long Size; 174 | }; 175 | 176 | struct IMAGE_OPTIONAL_HEADER64 { 177 | unsigned short Magic; 178 | unsigned char MajorLinkerVersion; 179 | unsigned char MinorLinkerVersion; 180 | unsigned long SizeOfCode; 181 | unsigned long SizeOfInitializedData; 182 | unsigned long SizeOfUninitializedData; 183 | unsigned long AddressOfEntryPoint; 184 | unsigned long BaseOfCode; 185 | unsigned long long ImageBase; 186 | unsigned long SectionAlignment; 187 | unsigned long FileAlignment; 188 | unsigned short MajorOperatingSystemVersion; 189 | unsigned short MinorOperatingSystemVersion; 190 | unsigned short MajorImageVersion; 191 | unsigned short MinorImageVersion; 192 | unsigned short MajorSubsystemVersion; 193 | unsigned short MinorSubsystemVersion; 194 | unsigned long Win32VersionValue; 195 | unsigned long SizeOfImage; 196 | unsigned long SizeOfHeaders; 197 | unsigned long CheckSum; 198 | unsigned short Subsystem; 199 | unsigned short DllCharacteristics; 200 | unsigned long long SizeOfStackReserve; 201 | unsigned long long SizeOfStackCommit; 202 | unsigned long long SizeOfHeapReserve; 203 | unsigned long long SizeOfHeapCommit; 204 | unsigned long LoaderFlags; 205 | unsigned long NumberOfRvaAndSizes; 206 | IMAGE_DATA_DIRECTORY DataDirectory[16]; 207 | }; 208 | 209 | struct IMAGE_OPTIONAL_HEADER32 { 210 | unsigned short Magic; 211 | unsigned char MajorLinkerVersion; 212 | unsigned char MinorLinkerVersion; 213 | unsigned long SizeOfCode; 214 | unsigned long SizeOfInitializedData; 215 | unsigned long SizeOfUninitializedData; 216 | unsigned long AddressOfEntryPoint; 217 | unsigned long BaseOfCode; 218 | unsigned long BaseOfData; 219 | unsigned long ImageBase; 220 | unsigned long SectionAlignment; 221 | unsigned long FileAlignment; 222 | unsigned short MajorOperatingSystemVersion; 223 | unsigned short MinorOperatingSystemVersion; 224 | unsigned short MajorImageVersion; 225 | unsigned short MinorImageVersion; 226 | unsigned short MajorSubsystemVersion; 227 | unsigned short MinorSubsystemVersion; 228 | unsigned long Win32VersionValue; 229 | unsigned long SizeOfImage; 230 | unsigned long SizeOfHeaders; 231 | unsigned long CheckSum; 232 | unsigned short Subsystem; 233 | unsigned short DllCharacteristics; 234 | unsigned long SizeOfStackReserve; 235 | unsigned long SizeOfStackCommit; 236 | unsigned long SizeOfHeapReserve; 237 | unsigned long SizeOfHeapCommit; 238 | unsigned long LoaderFlags; 239 | unsigned long NumberOfRvaAndSizes; 240 | IMAGE_DATA_DIRECTORY DataDirectory[16]; 241 | }; 242 | 243 | struct IMAGE_NT_HEADERS { 244 | unsigned long Signature; 245 | IMAGE_FILE_HEADER FileHeader; 246 | #ifdef _WIN64 247 | IMAGE_OPTIONAL_HEADER64 OptionalHeader; 248 | #else 249 | IMAGE_OPTIONAL_HEADER32 OptionalHeader; 250 | #endif 251 | }; 252 | 253 | } // namespace win 254 | 255 | struct forwarded_hashes { 256 | unsigned module_hash; 257 | unsigned function_hash; 258 | }; 259 | 260 | // 64 bit integer where 32 bits are used for the hash offset 261 | // and remaining 32 bits are used for the hash computed using it 262 | using offset_hash_pair = unsigned long long; 263 | 264 | LAZY_IMPORTER_FORCEINLINE constexpr unsigned get_hash(offset_hash_pair pair) noexcept { return (pair & 0xFFFFFFFF); } 265 | 266 | LAZY_IMPORTER_FORCEINLINE constexpr unsigned get_offset(offset_hash_pair pair) noexcept { return (pair >> 32); } 267 | 268 | template 269 | LAZY_IMPORTER_FORCEINLINE constexpr unsigned hash_single(unsigned value, char c) noexcept 270 | { 271 | return static_cast( 272 | (value ^ ((CaseSensitive && c >= 'A' && c <= 'Z') ? (c | (1 << 5)) : c)) * 273 | static_cast(16777619)); 274 | } 275 | 276 | LAZY_IMPORTER_FORCEINLINE constexpr unsigned 277 | khash_impl(const char* str, unsigned value) noexcept 278 | { 279 | return (*str ? khash_impl(str + 1, hash_single(value, *str)) : value); 280 | } 281 | 282 | LAZY_IMPORTER_FORCEINLINE constexpr offset_hash_pair khash( 283 | const char* str, unsigned offset) noexcept 284 | { 285 | return ((offset_hash_pair{ offset } << 32) | khash_impl(str, offset)); 286 | } 287 | 288 | template 289 | LAZY_IMPORTER_FORCEINLINE unsigned hash(const CharT* str, unsigned offset) noexcept 290 | { 291 | unsigned value = offset; 292 | 293 | for (;;) { 294 | char c = *str++; 295 | if (!c) 296 | return value; 297 | value = hash_single(value, c); 298 | } 299 | } 300 | 301 | LAZY_IMPORTER_FORCEINLINE unsigned hash( 302 | const win::UNICODE_STRING_T& str, unsigned offset) noexcept 303 | { 304 | auto first = str.Buffer; 305 | const auto last = first + (str.Length / sizeof(wchar_t)); 306 | auto value = offset; 307 | for (; first != last; ++first) 308 | value = hash_single(value, static_cast(*first)); 309 | 310 | return value; 311 | } 312 | 313 | LAZY_IMPORTER_FORCEINLINE forwarded_hashes hash_forwarded( 314 | const char* str, unsigned offset) noexcept 315 | { 316 | forwarded_hashes res{ offset, offset }; 317 | 318 | for (; *str != '.'; ++str) 319 | res.module_hash = hash_single(res.module_hash, *str); 320 | 321 | ++str; 322 | 323 | for (; *str; ++str) 324 | res.function_hash = hash_single(res.function_hash, *str); 325 | 326 | return res; 327 | } 328 | 329 | // some helper functions 330 | LAZY_IMPORTER_FORCEINLINE const win::PEB_T* peb() noexcept 331 | { 332 | #if defined(_M_X64) || defined(__amd64__) 333 | return reinterpret_cast(__readgsqword(0x60)); 334 | #elif defined(_M_IX86) || defined(__i386__) 335 | return reinterpret_cast(__readfsdword(0x30)); 336 | #elif defined(_M_ARM) || defined(__arm__) 337 | return *reinterpret_cast(_MoveFromCoprocessor(15, 0, 13, 0, 2) + 0x30); 338 | #elif defined(_M_ARM64) || defined(__aarch64__) 339 | return *reinterpret_cast(__getReg(18) + 0x60); 340 | #elif defined(_M_IA64) || defined(__ia64__) 341 | return *reinterpret_cast(static_cast(_rdteb()) + 0x60); 342 | #else 343 | #error Unsupported platform. Open an issue and I'll probably add support. 344 | #endif 345 | } 346 | 347 | LAZY_IMPORTER_FORCEINLINE const win::PEB_LDR_DATA_T* ldr() 348 | { 349 | return reinterpret_cast(peb()->Ldr); 350 | } 351 | 352 | LAZY_IMPORTER_FORCEINLINE const win::IMAGE_NT_HEADERS* nt_headers( 353 | const char* base) noexcept 354 | { 355 | return reinterpret_cast( 356 | base + reinterpret_cast(base)->e_lfanew); 357 | } 358 | 359 | LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* image_export_dir( 360 | const char* base) noexcept 361 | { 362 | return reinterpret_cast( 363 | base + nt_headers(base)->OptionalHeader.DataDirectory->VirtualAddress); 364 | } 365 | 366 | LAZY_IMPORTER_FORCEINLINE const win::LDR_DATA_TABLE_ENTRY_T* ldr_data_entry() noexcept 367 | { 368 | return reinterpret_cast( 369 | ldr()->InLoadOrderModuleList.Flink); 370 | } 371 | 372 | struct exports_directory { 373 | const char* _base; 374 | const win::IMAGE_EXPORT_DIRECTORY* _ied; 375 | unsigned long _ied_size; 376 | 377 | public: 378 | using size_type = unsigned long; 379 | 380 | LAZY_IMPORTER_FORCEINLINE 381 | exports_directory(const char* base) noexcept : _base(base) 382 | { 383 | const auto ied_data_dir = nt_headers(base)->OptionalHeader.DataDirectory[0]; 384 | _ied = reinterpret_cast( 385 | base + ied_data_dir.VirtualAddress); 386 | _ied_size = ied_data_dir.Size; 387 | } 388 | 389 | LAZY_IMPORTER_FORCEINLINE explicit operator bool() const noexcept 390 | { 391 | return reinterpret_cast(_ied) != _base; 392 | } 393 | 394 | LAZY_IMPORTER_FORCEINLINE size_type size() const noexcept 395 | { 396 | return _ied->NumberOfNames; 397 | } 398 | 399 | LAZY_IMPORTER_FORCEINLINE const char* base() const noexcept { return _base; } 400 | LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* ied() const noexcept 401 | { 402 | return _ied; 403 | } 404 | 405 | LAZY_IMPORTER_FORCEINLINE const char* name(size_type index) const noexcept 406 | { 407 | return reinterpret_cast( 408 | _base + reinterpret_cast( 409 | _base + _ied->AddressOfNames)[index]); 410 | } 411 | 412 | LAZY_IMPORTER_FORCEINLINE const char* address(size_type index) const noexcept 413 | { 414 | const auto* const rva_table = 415 | reinterpret_cast(_base + _ied->AddressOfFunctions); 416 | 417 | const auto* const ord_table = reinterpret_cast( 418 | _base + _ied->AddressOfNameOrdinals); 419 | 420 | return _base + rva_table[ord_table[index]]; 421 | } 422 | 423 | LAZY_IMPORTER_FORCEINLINE bool is_forwarded( 424 | const char* export_address) const noexcept 425 | { 426 | const auto ui_ied = reinterpret_cast(_ied); 427 | return (export_address > ui_ied && export_address < ui_ied + _ied_size); 428 | } 429 | }; 430 | 431 | struct safe_module_enumerator { 432 | using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T; 433 | value_type* value; 434 | value_type* head; 435 | 436 | LAZY_IMPORTER_FORCEINLINE safe_module_enumerator() noexcept 437 | : safe_module_enumerator(ldr_data_entry()) 438 | {} 439 | 440 | LAZY_IMPORTER_FORCEINLINE 441 | safe_module_enumerator(const detail::win::LDR_DATA_TABLE_ENTRY_T* ldr) noexcept 442 | : value(ldr->load_order_next()), head(value) 443 | {} 444 | 445 | LAZY_IMPORTER_FORCEINLINE void reset() noexcept 446 | { 447 | value = head->load_order_next(); 448 | } 449 | 450 | LAZY_IMPORTER_FORCEINLINE bool next() noexcept 451 | { 452 | value = value->load_order_next(); 453 | 454 | return value != head && value->DllBase; 455 | } 456 | }; 457 | 458 | struct unsafe_module_enumerator { 459 | using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T*; 460 | value_type value; 461 | 462 | LAZY_IMPORTER_FORCEINLINE unsafe_module_enumerator() noexcept 463 | : value(ldr_data_entry()) 464 | {} 465 | 466 | LAZY_IMPORTER_FORCEINLINE void reset() noexcept { value = ldr_data_entry(); } 467 | 468 | LAZY_IMPORTER_FORCEINLINE bool next() noexcept 469 | { 470 | value = value->load_order_next(); 471 | return true; 472 | } 473 | }; 474 | 475 | // provides the cached functions which use Derive classes methods 476 | template 477 | class lazy_base { 478 | protected: 479 | // This function is needed because every templated function 480 | // with different args has its own static buffer 481 | LAZY_IMPORTER_FORCEINLINE static void*& _cache() noexcept 482 | { 483 | static void* value = nullptr; 484 | return value; 485 | } 486 | 487 | public: 488 | template 489 | LAZY_IMPORTER_FORCEINLINE static T safe() noexcept 490 | { 491 | return Derived::template get(); 492 | } 493 | 494 | template 495 | LAZY_IMPORTER_FORCEINLINE static T cached() noexcept 496 | { 497 | auto& cached = _cache(); 498 | if (!cached) 499 | cached = Derived::template get(); 500 | 501 | return (T)(cached); 502 | } 503 | 504 | template 505 | LAZY_IMPORTER_FORCEINLINE static T safe_cached() noexcept 506 | { 507 | return cached(); 508 | } 509 | }; 510 | 511 | template 512 | struct lazy_module : lazy_base> { 513 | template 514 | LAZY_IMPORTER_FORCEINLINE static T get() noexcept 515 | { 516 | Enum e; 517 | do { 518 | if (hash(e.value->BaseDllName, get_offset(OHP)) == get_hash(OHP)) 519 | return (T)(e.value->DllBase); 520 | } while (e.next()); 521 | return {}; 522 | } 523 | 524 | template 525 | LAZY_IMPORTER_FORCEINLINE static T in(Ldr ldr) noexcept 526 | { 527 | safe_module_enumerator e((const detail::win::LDR_DATA_TABLE_ENTRY_T*)(ldr)); 528 | do { 529 | if (hash(e.value->BaseDllName, get_offset(OHP)) == get_hash(OHP)) 530 | return (T)(e.value->DllBase); 531 | } while (e.next()); 532 | return {}; 533 | } 534 | 535 | template 536 | LAZY_IMPORTER_FORCEINLINE static T in_cached(Ldr ldr) noexcept 537 | { 538 | auto& cached = lazy_base>::_cache(); 539 | if (!cached) 540 | cached = in(ldr); 541 | 542 | return (T)(cached); 543 | } 544 | }; 545 | 546 | template 547 | struct lazy_function : lazy_base, T> { 548 | using base_type = lazy_base, T>; 549 | 550 | template 551 | LAZY_IMPORTER_FORCEINLINE decltype(auto) operator()(Args&&... args) const 552 | { 553 | #ifndef LAZY_IMPORTER_CACHE_OPERATOR_PARENS 554 | return get()(LAZY_IMPORTER_CPP_FORWARD(Args, args)...); 555 | #else 556 | return this->cached()(LAZY_IMPORTER_CPP_FORWARD(Args, args)...); 557 | #endif 558 | } 559 | 560 | template 561 | LAZY_IMPORTER_FORCEINLINE static F get() noexcept 562 | { 563 | // for backwards compatability. 564 | // Before 2.0 it was only possible to resolve forwarded exports when 565 | // this macro was enabled 566 | #ifdef LAZY_IMPORTER_RESOLVE_FORWARDED_EXPORTS 567 | return forwarded(); 568 | #else 569 | 570 | Enum e; 571 | 572 | do { 573 | #ifdef LAZY_IMPORTER_HARDENED_MODULE_CHECKS 574 | if (!e.value->DllBase || !e.value->FullDllName.Length) 575 | continue; 576 | #endif 577 | 578 | const exports_directory exports(e.value->DllBase); 579 | 580 | if (exports) { 581 | auto export_index = exports.size(); 582 | while (export_index--) 583 | if (hash(exports.name(export_index), get_offset(OHP)) == get_hash(OHP)) 584 | return (F)(exports.address(export_index)); 585 | } 586 | } while (e.next()); 587 | return {}; 588 | #endif 589 | } 590 | 591 | template 592 | LAZY_IMPORTER_FORCEINLINE static F forwarded() noexcept 593 | { 594 | detail::win::UNICODE_STRING_T name; 595 | forwarded_hashes hashes{ 0, get_hash(OHP) }; 596 | 597 | Enum e; 598 | do { 599 | name = e.value->BaseDllName; 600 | name.Length -= 8; // get rid of .dll extension 601 | 602 | if (!hashes.module_hash || hash(name, get_offset(OHP)) == hashes.module_hash) { 603 | const exports_directory exports(e.value->DllBase); 604 | 605 | if (exports) { 606 | auto export_index = exports.size(); 607 | while (export_index--) 608 | if (hash(exports.name(export_index), get_offset(OHP)) == hashes.function_hash) { 609 | const auto addr = exports.address(export_index); 610 | 611 | if (exports.is_forwarded(addr)) { 612 | hashes = hash_forwarded( 613 | reinterpret_cast(addr), 614 | get_offset(OHP)); 615 | 616 | e.reset(); 617 | break; 618 | } 619 | return (F)(addr); 620 | } 621 | } 622 | } 623 | } while (e.next()); 624 | return {}; 625 | } 626 | 627 | template 628 | LAZY_IMPORTER_FORCEINLINE static F forwarded_safe() noexcept 629 | { 630 | return forwarded(); 631 | } 632 | 633 | template 634 | LAZY_IMPORTER_FORCEINLINE static F forwarded_cached() noexcept 635 | { 636 | auto& value = base_type::_cache(); 637 | if (!value) 638 | value = forwarded(); 639 | return (F)(value); 640 | } 641 | 642 | template 643 | LAZY_IMPORTER_FORCEINLINE static F forwarded_safe_cached() noexcept 644 | { 645 | return forwarded_cached(); 646 | } 647 | 648 | template 649 | LAZY_IMPORTER_FORCEINLINE static F in(Module m) noexcept 650 | { 651 | if (IsSafe && !m) 652 | return {}; 653 | 654 | const exports_directory exports((const char*)(m)); 655 | if (IsSafe && !exports) 656 | return {}; 657 | 658 | for (unsigned long i{};; ++i) { 659 | if (IsSafe && i == exports.size()) 660 | break; 661 | 662 | if (hash(exports.name(i), get_offset(OHP)) == get_hash(OHP)) 663 | return (F)(exports.address(i)); 664 | } 665 | return {}; 666 | } 667 | 668 | template 669 | LAZY_IMPORTER_FORCEINLINE static F in_safe(Module m) noexcept 670 | { 671 | return in(m); 672 | } 673 | 674 | template 675 | LAZY_IMPORTER_FORCEINLINE static F in_cached(Module m) noexcept 676 | { 677 | auto& value = base_type::_cache(); 678 | if (!value) 679 | value = in(m); 680 | return (F)(value); 681 | } 682 | 683 | template 684 | LAZY_IMPORTER_FORCEINLINE static F in_safe_cached(Module m) noexcept 685 | { 686 | return in_cached(m); 687 | } 688 | 689 | template 690 | LAZY_IMPORTER_FORCEINLINE static F nt() noexcept 691 | { 692 | return in(ldr_data_entry()->load_order_next()->DllBase); 693 | } 694 | 695 | template 696 | LAZY_IMPORTER_FORCEINLINE static F nt_safe() noexcept 697 | { 698 | return in_safe(ldr_data_entry()->load_order_next()->DllBase); 699 | } 700 | 701 | template 702 | LAZY_IMPORTER_FORCEINLINE static F nt_cached() noexcept 703 | { 704 | return in_cached(ldr_data_entry()->load_order_next()->DllBase); 705 | } 706 | 707 | template 708 | LAZY_IMPORTER_FORCEINLINE static F nt_safe_cached() noexcept 709 | { 710 | return in_safe_cached(ldr_data_entry()->load_order_next()->DllBase); 711 | } 712 | }; 713 | 714 | } 715 | } // namespace li::detail 716 | 717 | #endif // include guard -------------------------------------------------------------------------------- /external/structs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace sdk 4 | { 5 | namespace structs 6 | { 7 | struct globalvars_t 8 | { 9 | float flRealTime; // 0x00 10 | int iFrameCount; // 0x04 11 | float flAbsFrameTime; // 0x08 12 | float flAbsFrameStartTime; // 0x0C 13 | float flCurrentTime; // 0x10 14 | float flFrameTime; // 0x14 15 | int nMaxClients; // 0x18 16 | int iTickCount; // 0x1C 17 | float flIntervalPerTick; // 0x20 18 | float flInterpolationAmount; // 0x24 19 | int nFrameSimulationTicks; // 0x28 20 | int iNetworkProtocol; // 0x2C 21 | void *pSaveData; // 0x30 22 | bool bClient; // 0x34 23 | bool bRemoteClient; // 0x35 24 | int iTimestampNetworkingBase; // 0x36 25 | int iTimestampRandomizeWindow; // 0x3A 26 | }; // Size: 0x3E 27 | 28 | class convar_t 29 | { 30 | public: 31 | char pad_0x0000[0x4]; // 0x00 32 | std::uintptr_t m_pNext; // 0x04 33 | int m_bRegistered; // 0x08 change to bool 34 | std::uintptr_t m_pszName; // 0x0C 35 | std::uintptr_t m_pszDescription; // 0x10 36 | int m_nFlags; // 0x14 37 | char pad_0x0018[0x4]; // 0x18 38 | std::uintptr_t m_pParent; // 0x1C 39 | std::uintptr_t m_pszDefaultValue; // 0x20 40 | std::uintptr_t m_pszValue; // 0x24 41 | int m_nSize; // 0x28 42 | float m_flValue; // 0x2C 43 | int m_nValue; // 0x30 44 | int m_bHasMin; // 0x34 change to bool 45 | float m_fMinVal; // 0x38 46 | int m_bHasMax; // 0x3C change to bool 47 | float m_fMaxVal; // 0x40 48 | }; // Size: 0x44 49 | 50 | struct playerinfo_t 51 | { 52 | std::uint64_t ullVersion = 0ULL; 53 | union 54 | { 55 | std::uint64_t ullXuid; 56 | struct 57 | { 58 | std::uint32_t nXuidLow; 59 | std::uint32_t nXuidHigh; 60 | }; 61 | }; 62 | char szName[128]; 63 | int nUserID; 64 | char szSteamID[33]; 65 | std::uint32_t nFriendsID; 66 | char szFriendsName[128]; 67 | bool bFakePlayer; 68 | bool bIsHLTV; 69 | std::uint16_t uCustomFiles[4]; 70 | std::uint8_t dFilesDownloaded; 71 | }; 72 | 73 | enum e_glow_render_style : int 74 | { 75 | GLOWRENDERSTYLE_DEFAULT = 0, 76 | GLOWRENDERSTYLE_RIMGLOW3D, 77 | GLOWRENDERSTYLE_EDGE_HIGHLIGHT, 78 | GLOWRENDERSTYLE_EDGE_HIGHLIGHT_PULSE, 79 | GLOWRENDERSTYLE_COUNT 80 | }; 81 | 82 | struct glow_object_t 83 | { 84 | void set(const float red, const float green, const float blue, const float alpha, const int nRenderStyle = GLOWRENDERSTYLE_DEFAULT) // @note: styles not used cuz other styles doesnt have ignorez flag and needed to rebuild glow 85 | { 86 | this->R = red; 87 | this->G = green; 88 | this->B = blue; 89 | this->A = alpha; 90 | 91 | this->flBloomAmount = 1.0f; 92 | this->bRenderWhenOccluded = true; 93 | this->bRenderWhenUnoccluded = false; 94 | this->nRenderStyle = nRenderStyle; 95 | } 96 | 97 | std::int32_t m_nNextFreeSlot; // 0x00 98 | std::uint32_t pEntity; // 0x04 99 | float R; // 0x08 100 | float G; // 0x0C 101 | float B; // 0x10 102 | float A; // 0x14 103 | bool bAlphaCappedByRenderAlpha; // 0x18 104 | std::byte pad0[0x3]; // 0x19 - pack 1 bool as 4 bytes 105 | float flAlphaFunctionOfMaxVelocity; // 0x1C 106 | float flBloomAmount; // 0x20 107 | float flPulseOverdrive; // 0x24 108 | bool bRenderWhenOccluded; // 0x28 109 | bool bRenderWhenUnoccluded; // 0x29 110 | bool bFullBloomRender; // 0x2A 111 | std::byte pad1[0x1]; // 0x2B - pack 3 bool as 4 bytes 112 | int iFullBloomStencilTestValue; // 0x2C 113 | int nRenderStyle; // 0x30 114 | int nSplitScreenSlot; // 0x34 115 | }; // Size: 0x38 116 | 117 | /* baseentity flags */ 118 | enum e_flags : int 119 | { 120 | FL_ONGROUND = (1 << 0), 121 | FL_DUCKING = (1 << 1), 122 | FL_ANIMDUCKING = (1 << 2), 123 | FL_WATERJUMP = (1 << 3), 124 | FL_ONTRAIN = (1 << 4), 125 | FL_INRAIN = (1 << 5), 126 | FL_FROZEN = (1 << 6), 127 | FL_ATCONTROLS = (1 << 7), 128 | FL_CLIENT = (1 << 8), 129 | FL_FAKECLIENT = (1 << 9), 130 | FL_INWATER = (1 << 10), 131 | FL_FLY = (1 << 11), 132 | FL_SWIM = (1 << 12), 133 | FL_CONVEYOR = (1 << 13), 134 | FL_NPC = (1 << 14), 135 | FL_GODMODE = (1 << 15), 136 | FL_NOTARGET = (1 << 16), 137 | FL_AIMTARGET = (1 << 17), 138 | FL_PARTIALGROUND = (1 << 18), 139 | FL_STATICPROP = (1 << 19), 140 | FL_GRAPHED = (1 << 20), 141 | FL_GRENADE = (1 << 21), 142 | FL_STEPMOVEMENT = (1 << 22), 143 | FL_DONTTOUCH = (1 << 23), 144 | FL_BASEVELOCITY = (1 << 24), 145 | FL_WORLDBRUSH = (1 << 25), 146 | FL_OBJECT = (1 << 26), 147 | FL_KILLME = (1 << 27), 148 | FL_ONFIRE = (1 << 28), 149 | FL_DISSOLVING = (1 << 29), 150 | FL_TRANSRAGDOLL = (1 << 30), 151 | FL_UNBLOCKABLE_BY_PLAYER = (1 << 31) 152 | }; 153 | 154 | enum e_move_type : int 155 | { 156 | MOVETYPE_NONE = 0, 157 | MOVETYPE_ISOMETRIC, 158 | MOVETYPE_WALK, 159 | MOVETYPE_STEP, 160 | MOVETYPE_FLY, 161 | MOVETYPE_FLYGRAVITY, 162 | MOVETYPE_VPHYSICS, 163 | MOVETYPE_PUSH, 164 | MOVETYPE_NOCLIP, 165 | MOVETYPE_LADDER, 166 | MOVETYPE_OBSERVER, 167 | MOVETYPE_CUSTOM, 168 | MOVETYPE_LAST = MOVETYPE_CUSTOM, 169 | MOVETYPE_MAX_BITS = 4 170 | }; 171 | 172 | enum e_team_id : int 173 | { 174 | TEAM_UNASSIGNED = 0, 175 | TEAM_SPECTATOR, 176 | TEAM_TT, 177 | TEAM_CT 178 | }; 179 | 180 | /* baseentity lifestate */ 181 | enum e_life_state : int 182 | { 183 | LIFE_ALIVE = 0, 184 | LIFE_DYING, 185 | LIFE_DEAD, 186 | LIFE_RESPAWNABLE, 187 | LIFE_DISCARDBODY 188 | }; 189 | 190 | enum e_bone_index : int 191 | { 192 | BONE_INVALID = -1, 193 | BONE_PELVIS, 194 | BONE_LEAN_ROOT, 195 | BONE_CAM_DRIVER, 196 | BONE_SPINE_0, 197 | BONE_SPINE_1, 198 | BONE_SPINE_2, 199 | BONE_SPINE_3, 200 | BONE_NECK, 201 | BONE_HEAD, 202 | BONE_CLAVICLE_L, 203 | BONE_ARM_UPPER_L, 204 | BONE_ARM_LOWER_L, 205 | BONE_HAND_L, 206 | BONE_FINGER_MIDDLE_META_L, 207 | BONE_FINGER_MIDDLE_0_L, 208 | BONE_FINGER_MIDDLE_1_L, 209 | BONE_FINGER_MIDDLE_2_L, 210 | BONE_FINGER_PINKY_META_L, 211 | BONE_FINGER_PINKY_0_L, 212 | BONE_FINGER_PINKY_1_L, 213 | BONE_FINGER_PINKY_2_L, 214 | BONE_FINGER_INDEX_META_L, 215 | BONE_FINGER_INDEX_0_L, 216 | BONE_FINGER_INDEX_1_L, 217 | BONE_FINGER_INDEX_2_L, 218 | BONE_FINGER_THUMB_0_L, 219 | BONE_FINGER_THUMB_1_L, 220 | BONE_FINGER_THUMB_2_L, 221 | BONE_FINGER_RING_META_L, 222 | BONE_FINGER_RING_0_L, 223 | BONE_FINGER_RING_1_L, 224 | BONE_FINGER_RING_2_L, 225 | BONE_WEAPON_HAND_L, 226 | BONE_ARM_LOWER_L_TWIST, 227 | BONE_ARM_LOWER_L_TWIST1, 228 | BONE_ARM_UPPER_L_TWIST, 229 | BONE_ARM_UPPER_L_TWIST1, 230 | BONE_CLAVICLE_R, 231 | BONE_ARM_UPPER_R, 232 | BONE_ARM_LOWER_R, 233 | BONE_HAND_R, 234 | BONE_FINGER_MIDDLE_META_R, 235 | BONE_FINGER_MIDDLE_0_R, 236 | BONE_FINGER_MIDDLE_1_R, 237 | BONE_FINGER_MIDDLE_2_R, 238 | BONE_FINGER_PINKY_META_R, 239 | BONE_FINGER_PINKY_0_R, 240 | BONE_FINGER_PINKY_1_R, 241 | BONE_FINGER_PINKY_2_R, 242 | BONE_FINGER_INDEX_META_R, 243 | BONE_FINGER_INDEX_0_R, 244 | BONE_FINGER_INDEX_1_R, 245 | BONE_FINGER_INDEX_2_R, 246 | BONE_FINGER_THUMB_0_R, 247 | BONE_FINGER_THUMB_1_R, 248 | BONE_FINGER_THUMB_2_R, 249 | BONE_FINGER_RING_META_R, 250 | BONE_FINGER_RING_0_R, 251 | BONE_FINGER_RING_1_R, 252 | BONE_FINGER_RING_2_R, 253 | BONE_WEAPON_HAND_R, 254 | BONE_ARM_LOWER_R_TWIST, 255 | BONE_ARM_LOWER_R_TWIST1, 256 | BONE_ARM_UPPER_R_TWIST, 257 | BONE_ARM_UPPER_R_TWIST1, 258 | BONE_LEG_UPPER_L, 259 | BONE_LEG_LOWER_L, 260 | BONE_ANKLE_L, 261 | BONE_BALL_L, 262 | BONE_LFOOT_LOCK, 263 | BONE_LEG_UPPER_L_TWIST, 264 | BONE_LEG_UPPER_L_TWIST1, 265 | BONE_LEG_UPPER_R, 266 | BONE_LEG_LOWER_R, 267 | BONE_ANKLE_R, 268 | BONE_BALL_R, 269 | BONE_RFOOT_LOCK, 270 | BONE_LEG_UPPER_R_TWIST, 271 | BONE_LEG_UPPER_R_TWIST1, 272 | BONE_FINGER_PINKY_L_END, 273 | BONE_FINGER_PINKY_R_END, 274 | BONE_VALVEBIPED_WEAPON_BONE, 275 | BONE_LH_IK_DRIVER, 276 | BONE_PRIMARY_JIGGLE_JNT, 277 | }; 278 | 279 | enum e_game_type : int 280 | { 281 | GAMETYPE_UNKNOWN = -1, 282 | GAMETYPE_CLASSIC, 283 | GAMETYPE_GUNGAME, 284 | GAMETYPE_TRAINING, 285 | GAMETYPE_CUSTOM, 286 | GAMETYPE_COOPERATIVE, 287 | GAMETYPE_SKIRMISH, 288 | GAMETYPE_FREEFORALL 289 | }; 290 | 291 | enum class e_class_index : int 292 | { 293 | CAI_BaseNPC = 0, 294 | CAK47, 295 | CBaseAnimating, 296 | CBaseAnimatingOverlay, 297 | CBaseAttributableItem, 298 | CBaseButton, 299 | CBaseCombatCharacter, 300 | CBaseCombatWeapon, 301 | CBaseCSGrenade, 302 | CBaseCSGrenadeProjectile, 303 | CBaseDoor, 304 | CBaseEntity, 305 | CBaseFlex, 306 | CBaseGrenade, 307 | CBaseParticleEntity, 308 | CBasePlayer, 309 | CBasePropDoor, 310 | CBaseTeamObjectiveResource, 311 | CBaseTempEntity, 312 | CBaseToggle, 313 | CBaseTrigger, 314 | CBaseViewModel, 315 | CBaseVPhysicsTrigger, 316 | CBaseWeaponWorldModel, 317 | CBeam, 318 | CBeamSpotlight, 319 | CBoneFollower, 320 | CBRC4Target, 321 | CBreachCharge, 322 | CBreachChargeProjectile, 323 | CBreakableProp, 324 | CBreakableSurface, 325 | CBumpMine, 326 | CBumpMineProjectile, 327 | CC4, 328 | CCascadeLight, 329 | CChicken, 330 | CColorCorrection, 331 | CColorCorrectionVolume, 332 | CCSGameRulesProxy, 333 | CCSPlayer, 334 | CCSPlayerResource, 335 | CCSRagdoll, 336 | CCSTeam, 337 | CDangerZone, 338 | CDangerZoneController, 339 | CDEagle, 340 | CDecoyGrenade, 341 | CDecoyProjectile, 342 | CDrone, 343 | CDronegun, 344 | CDynamicLight, 345 | CDynamicProp, 346 | CEconEntity, 347 | CEconWearable, 348 | CEmbers, 349 | CEntityDissolve, 350 | CEntityFlame, 351 | CEntityFreezing, 352 | CEntityParticleTrail, 353 | CEnvAmbientLight, 354 | CEnvDetailController, 355 | CEnvDOFController, 356 | CEnvGasCanister, 357 | CEnvParticleScript, 358 | CEnvProjectedTexture, 359 | CEnvQuadraticBeam, 360 | CEnvScreenEffect, 361 | CEnvScreenOverlay, 362 | CEnvTonemapController, 363 | CEnvWind, 364 | CFEPlayerDecal, 365 | CFireCrackerBlast, 366 | CFireSmoke, 367 | CFireTrail, 368 | CFish, 369 | CFists, 370 | CFlashbang, 371 | CFogController, 372 | CFootstepControl, 373 | CFunc_Dust, 374 | CFunc_LOD, 375 | CFuncAreaPortalWindow, 376 | CFuncBrush, 377 | CFuncConveyor, 378 | CFuncLadder, 379 | CFuncMonitor, 380 | CFuncMoveLinear, 381 | CFuncOccluder, 382 | CFuncReflectiveGlass, 383 | CFuncRotating, 384 | CFuncSmokeVolume, 385 | CFuncTrackTrain, 386 | CGameRulesProxy, 387 | CGrassBurn, 388 | CHandleTest, 389 | CHEGrenade, 390 | CHostage, 391 | CHostageCarriableProp, 392 | CIncendiaryGrenade, 393 | CInferno, 394 | CInfoLadderDismount, 395 | CInfoMapRegion, 396 | CInfoOverlayAccessor, 397 | CItem_Healthshot, 398 | CItemCash, 399 | CItemDogtags, 400 | CKnife, 401 | CKnifeGG, 402 | CLightGlow, 403 | CMapVetoPickController, 404 | CMaterialModifyControl, 405 | CMelee, 406 | CMolotovGrenade, 407 | CMolotovProjectile, 408 | CMovieDisplay, 409 | CParadropChopper, 410 | CParticleFire, 411 | CParticlePerformanceMonitor, 412 | CParticleSystem, 413 | CPhysBox, 414 | CPhysBoxMultiplayer, 415 | CPhysicsProp, 416 | CPhysicsPropMultiplayer, 417 | CPhysMagnet, 418 | CPhysPropAmmoBox, 419 | CPhysPropLootCrate, 420 | CPhysPropRadarJammer, 421 | CPhysPropWeaponUpgrade, 422 | CPlantedC4, 423 | CPlasma, 424 | CPlayerPing, 425 | CPlayerResource, 426 | CPointCamera, 427 | CPointCommentaryNode, 428 | CPointWorldText, 429 | CPoseController, 430 | CPostProcessController, 431 | CPrecipitation, 432 | CPrecipitationBlocker, 433 | CPredictedViewModel, 434 | CProp_Hallucination, 435 | CPropCounter, 436 | CPropDoorRotating, 437 | CPropJeep, 438 | CPropVehicleDriveable, 439 | CRagdollManager, 440 | CRagdollProp, 441 | CRagdollPropAttached, 442 | CRopeKeyframe, 443 | CSCAR17, 444 | CSceneEntity, 445 | CSensorGrenade, 446 | CSensorGrenadeProjectile, 447 | CShadowControl, 448 | CSlideshowDisplay, 449 | CSmokeGrenade, 450 | CSmokeGrenadeProjectile, 451 | CSmokeStack, 452 | CSnowball, 453 | CSnowballPile, 454 | CSnowballProjectile, 455 | CSpatialEntity, 456 | CSpotlightEnd, 457 | CSprite, 458 | CSpriteOriented, 459 | CSpriteTrail, 460 | CStatueProp, 461 | CSteamJet, 462 | CSun, 463 | CSunlightShadowControl, 464 | CSurvivalSpawnChopper, 465 | CTablet, 466 | CTeam, 467 | CTeamplayRoundBasedRulesProxy, 468 | CTEArmorRicochet, 469 | CTEBaseBeam, 470 | CTEBeamEntPoint, 471 | CTEBeamEnts, 472 | CTEBeamFollow, 473 | CTEBeamLaser, 474 | CTEBeamPoints, 475 | CTEBeamRing, 476 | CTEBeamRingPoint, 477 | CTEBeamSpline, 478 | CTEBloodSprite, 479 | CTEBloodStream, 480 | CTEBreakModel, 481 | CTEBSPDecal, 482 | CTEBubbles, 483 | CTEBubbleTrail, 484 | CTEClientProjectile, 485 | CTEDecal, 486 | CTEDust, 487 | CTEDynamicLight, 488 | CTEEffectDispatch, 489 | CTEEnergySplash, 490 | CTEExplosion, 491 | CTEFireBullets, 492 | CTEFizz, 493 | CTEFootprintDecal, 494 | CTEFoundryHelpers, 495 | CTEGaussExplosion, 496 | CTEGlowSprite, 497 | CTEImpact, 498 | CTEKillPlayerAttachments, 499 | CTELargeFunnel, 500 | CTEMetalSparks, 501 | CTEMuzzleFlash, 502 | CTEParticleSystem, 503 | CTEPhysicsProp, 504 | CTEPlantBomb, 505 | CTEPlayerAnimEvent, 506 | CTEPlayerDecal, 507 | CTEProjectedDecal, 508 | CTERadioIcon, 509 | CTEShatterSurface, 510 | CTEShowLine, 511 | CTesla, 512 | CTESmoke, 513 | CTESparks, 514 | CTESprite, 515 | CTESpriteSpray, 516 | CTest_ProxyToggle_Networkable, 517 | CTestTraceline, 518 | CTEWorldDecal, 519 | CTriggerPlayerMovement, 520 | CTriggerSoundOperator, 521 | CVGuiScreen, 522 | CVoteController, 523 | CWaterBullet, 524 | CWaterLODControl, 525 | CWeaponAug, 526 | CWeaponAWP, 527 | CWeaponBaseItem, 528 | CWeaponBizon, 529 | CWeaponCSBase, 530 | CWeaponCSBaseGun, 531 | CWeaponCycler, 532 | CWeaponElite, 533 | CWeaponFamas, 534 | CWeaponFiveSeven, 535 | CWeaponG3SG1, 536 | CWeaponGalil, 537 | CWeaponGalilAR, 538 | CWeaponGlock, 539 | CWeaponHKP2000, 540 | CWeaponM249, 541 | CWeaponM3, 542 | CWeaponM4A1, 543 | CWeaponMAC10, 544 | CWeaponMag7, 545 | CWeaponMP5Navy, 546 | CWeaponMP7, 547 | CWeaponMP9, 548 | CWeaponNegev, 549 | CWeaponNOVA, 550 | CWeaponP228, 551 | CWeaponP250, 552 | CWeaponP90, 553 | CWeaponSawedoff, 554 | CWeaponSCAR20, 555 | CWeaponScout, 556 | CWeaponSG550, 557 | CWeaponSG552, 558 | CWeaponSG556, 559 | CWeaponShield, 560 | CWeaponSSG08, 561 | CWeaponTaser, 562 | CWeaponTec9, 563 | CWeaponTMP, 564 | CWeaponUMP45, 565 | CWeaponUSP, 566 | CWeaponXM1014, 567 | CWeaponZoneRepulsor, 568 | CWorld, 569 | CWorldVguiText, 570 | DustTrail, 571 | MovieExplosion, 572 | ParticleSmokeGrenade, 573 | RocketTrail, 574 | SmokeTrail, 575 | SporeExplosion, 576 | SporeTrail, 577 | }; 578 | 579 | enum e_item_definitions : short 580 | { 581 | WEAPON_NONE = 0, 582 | WEAPON_DEAGLE = 1, 583 | WEAPON_ELITE = 2, 584 | WEAPON_FIVESEVEN = 3, 585 | WEAPON_GLOCK = 4, 586 | WEAPON_AK47 = 7, 587 | WEAPON_AUG = 8, 588 | WEAPON_AWP = 9, 589 | WEAPON_FAMAS = 10, 590 | WEAPON_G3SG1 = 11, 591 | WEAPON_GALILAR = 13, 592 | WEAPON_M249 = 14, 593 | WEAPON_M4A1 = 16, 594 | WEAPON_MAC10 = 17, 595 | WEAPON_P90 = 19, 596 | WEAPON_ZONE_REPULSOR = 20, 597 | WEAPON_MP5SD = 23, 598 | WEAPON_UMP45 = 24, 599 | WEAPON_XM1014 = 25, 600 | WEAPON_BIZON = 26, 601 | WEAPON_MAG7 = 27, 602 | WEAPON_NEGEV = 28, 603 | WEAPON_SAWEDOFF = 29, 604 | WEAPON_TEC9 = 30, 605 | WEAPON_TASER = 31, 606 | WEAPON_HKP2000 = 32, 607 | WEAPON_MP7 = 33, 608 | WEAPON_MP9 = 34, 609 | WEAPON_NOVA = 35, 610 | WEAPON_P250 = 36, 611 | WEAPON_SHIELD = 37, 612 | WEAPON_SCAR20 = 38, 613 | WEAPON_SG556 = 39, 614 | WEAPON_SSG08 = 40, 615 | WEAPON_KNIFE_GG = 41, 616 | WEAPON_KNIFE = 42, 617 | WEAPON_FLASHBANG = 43, 618 | WEAPON_HEGRENADE = 44, 619 | WEAPON_SMOKEGRENADE = 45, 620 | WEAPON_MOLOTOV = 46, 621 | WEAPON_DECOY = 47, 622 | WEAPON_INCGRENADE = 48, 623 | WEAPON_C4 = 49, 624 | WEAPON_HEALTHSHOT = 57, 625 | WEAPON_KNIFE_T = 59, 626 | WEAPON_M4A1_SILENCER = 60, 627 | WEAPON_USP_SILENCER = 61, 628 | WEAPON_CZ75A = 63, 629 | WEAPON_REVOLVER = 64, 630 | WEAPON_TAGRENADE = 68, 631 | WEAPON_FISTS = 69, 632 | WEAPON_BREACHCHARGE = 70, 633 | WEAPON_TABLET = 72, 634 | WEAPON_MELEE = 74, 635 | WEAPON_AXE = 75, 636 | WEAPON_HAMMER = 76, 637 | WEAPON_SPANNER = 78, 638 | WEAPON_KNIFE_GHOST = 80, 639 | WEAPON_FIREBOMB = 81, 640 | WEAPON_DIVERSION = 82, 641 | WEAPON_FRAG_GRENADE = 83, 642 | WEAPON_SNOWBALL = 84, 643 | WEAPON_BUMPMINE = 85, 644 | WEAPON_KNIFE_BAYONET = 500, 645 | WEAPON_KNIFE_CSS = 503, 646 | WEAPON_KNIFE_FLIP = 505, 647 | WEAPON_KNIFE_GUT = 506, 648 | WEAPON_KNIFE_KARAMBIT = 507, 649 | WEAPON_KNIFE_M9_BAYONET = 508, 650 | WEAPON_KNIFE_TACTICAL = 509, 651 | WEAPON_KNIFE_FALCHION = 512, 652 | WEAPON_KNIFE_SURVIVAL_BOWIE = 514, 653 | WEAPON_KNIFE_BUTTERFLY = 515, 654 | WEAPON_KNIFE_PUSH = 516, 655 | WEAPON_KNIFE_CORD = 517, 656 | WEAPON_KNIFE_CANIS = 518, 657 | WEAPON_KNIFE_URSUS = 519, 658 | WEAPON_KNIFE_GYPSY_JACKKNIFE = 520, 659 | WEAPON_KNIFE_OUTDOOR = 521, 660 | WEAPON_KNIFE_STILETTO = 522, 661 | WEAPON_KNIFE_WIDOWMAKER = 523, 662 | WEAPON_KNIFE_SKELETON = 525, 663 | GLOVE_STUDDED_BROKENFANG = 4725, 664 | GLOVE_STUDDED_BLOODHOUND = 5027, 665 | GLOVE_T = 5028, 666 | GLOVE_CT = 5029, 667 | GLOVE_SPORTY = 5030, 668 | GLOVE_SLICK = 5031, 669 | GLOVE_LEATHER_HANDWRAPS = 5032, 670 | GLOVE_MOTORCYCLE = 5033, 671 | GLOVE_SPECIALIST = 5034, 672 | GLOVE_STUDDED_HYDRA = 5035, 673 | SPECIAL_AGENT_BLUEBERRIES_BUCKSHOT = 4619, 674 | SPECIAL_AGENT_TWO_TIMES_MCCOY_TACP = 4680, 675 | SPECIAL_AGENT_COMMANDOR_MAE_JAMISON = 4711, 676 | SPECIAL_AGENT_1ST_LIEUTENANT_FARLOW, 677 | SPECIAL_AGENT_JOHN_KASK, 678 | SPECIAL_AGENT_BIO_HAZ_SPECIALIST, 679 | SPECIAL_AGENT_SERGEANT_BOMBSON, 680 | SPECIAL_AGENT_CHEM_HAZ_SPECIALIST, 681 | SPECIAL_AGENT_REZAN_THE_REDSHIRT = 4718, 682 | SPECIAL_AGENT_SIR_BLOODY_MIAMI_DARRYL = 4726, 683 | SPECIAL_AGENT_SAFECRACKER_VOLTZMANN, 684 | SPECIAL_AGENT_LITTLE_KEV, 685 | SPECIAL_AGENT_GETAWAY_SALLY = 4730, 686 | SPECIAL_AGENT_NUMBER_K = 4732, 687 | SPECIAL_AGENT_SIR_BLOODY_SILENT_DARRYL = 4733, 688 | SPECIAL_AGENT_SIR_BLOODY_SKULLHEAD_DARRYL, 689 | SPECIAL_AGENT_SIR_BLOODY_DARRYL_ROYALE, 690 | SPECIAL_AGENT_SIR_BLOODY_LOUDMOUTH_DARRYL, 691 | SPECIAL_AGENT_T = 5036, 692 | SPECIAL_AGENT_CT = 5037, 693 | SPECIAL_AGENT_GROUND_REBEL = 5105, 694 | SPECIAL_AGENT_OSIRIS, 695 | SPECIAL_AGENT_SHAHMAT, 696 | SPECIAL_AGENT_MUHLIK, 697 | SPECIAL_AGENT_SOLDIER = 5205, 698 | SPECIAL_AGENT_ENFORCER, 699 | SPECIAL_AGENT_SLINGSHOT, 700 | SPECIAL_AGENT_STREET_SOLDIER, 701 | SPECIAL_AGENT_OPERATOR = 5305, 702 | SPECIAL_AGENT_MARKUS_DELROW, 703 | SPECIAL_AGENT_MICHAEL_SYFERS, 704 | SPECIAL_AGENT_AVA, 705 | SPECIAL_AGENT_3RD_COMMANDO_COMPANY = 5400, 706 | SPECIAL_AGENT_SEAL_TEAM_6_SOLDIER, 707 | SPECIAL_AGENT_BUCKSHOT, 708 | SPECIAL_AGENT_TWO_TIMES_MCCOY_USAF, 709 | SPECIAL_AGENT_RICKSAW, 710 | SPECIAL_AGENT_DRAGOMIR = 5500, 711 | SPECIAL_AGENT_MAXIMUS, 712 | SPECIAL_AGENT_REZAN_THE_READY, 713 | SPECIAL_AGENT_BLACKWOLF = 5503, 714 | SPECIAL_AGENT_THE_DOCTOR, 715 | SPECIAL_AGENT_DRAGOMIR_FOOTSOLDIERS, 716 | SPECIAL_AGENT_B_SQUADRON_OFFICER = 5601 717 | }; 718 | 719 | enum e_weapon_type : int 720 | { 721 | WEAPONTYPE_KNIFE = 0, 722 | WEAPONTYPE_PISTOL = 1, 723 | WEAPONTYPE_SUBMACHINEGUN = 2, 724 | WEAPONTYPE_RIFLE = 3, 725 | WEAPONTYPE_SHOTGUN = 4, 726 | WEAPONTYPE_SNIPER = 5, 727 | WEAPONTYPE_MACHINEGUN = 6, 728 | WEAPONTYPE_C4 = 7, 729 | WEAPONTYPE_PLACEHOLDER = 8, 730 | WEAPONTYPE_GRENADE = 9, 731 | WEAPONTYPE_HEALTHSHOT = 11, 732 | WEAPONTYPE_FISTS = 12, 733 | WEAPONTYPE_BREACHCHARGE = 13, 734 | WEAPONTYPE_BUMPMINE = 14, 735 | WEAPONTYPE_TABLET = 15, 736 | WEAPONTYPE_MELEE = 16 737 | }; 738 | 739 | struct skinobj_t 740 | { 741 | skinobj_t(const char* name, const char* model, const char* kill_icon = nullptr) 742 | : name(name), model(model), kill_icon(kill_icon) { } 743 | 744 | const char* name = nullptr; 745 | const char* model = nullptr; 746 | const char* kill_icon = nullptr; 747 | }; 748 | 749 | const std::unordered_map m_item_list = { 750 | { sdk::structs::WEAPON_DEAGLE, { "Desert Eagle", "models/weapons/v_pist_deagle.mdl", "deagle" } }, 751 | { sdk::structs::WEAPON_ELITE, { "Dual Berettas", "models/weapons/v_pist_elite.mdl", "elite" } }, 752 | { sdk::structs::WEAPON_FIVESEVEN, { "Five-SeveN", "models/weapons/v_pist_fiveseven.mdl", "fiveseven" } }, 753 | { sdk::structs::WEAPON_GLOCK, { "Glock-18", "models/weapons/v_pist_glock18.mdl", "glock" } }, 754 | { sdk::structs::WEAPON_AK47, { "AK-47", "models/weapons/v_rif_ak47.mdl", "ak47" } }, 755 | { sdk::structs::WEAPON_AUG, { "AUG", "models/weapons/v_rif_aug.mdl", "aug" } }, 756 | { sdk::structs::WEAPON_AWP, { "AWP", "models/weapons/v_snip_awp.mdl", "awp" } }, 757 | { sdk::structs::WEAPON_FAMAS, { "FAMAS", "models/weapons/v_rif_famas.mdl", "famas" } }, 758 | { sdk::structs::WEAPON_G3SG1, { "G3SG1", "models/weapons/v_snip_g3sg1.mdl", "g3sg1" } }, 759 | { sdk::structs::WEAPON_GALILAR, { "Galil AR", "models/weapons/v_rif_galilar.mdl", "galilar" } }, 760 | { sdk::structs::WEAPON_M249, { "M249", "models/weapons/v_mach_m249para.mdl", "m249" } }, 761 | { sdk::structs::WEAPON_M4A1, { "M4A4", "models/weapons/v_rif_m4a1.mdl", "m4a1" } }, 762 | { sdk::structs::WEAPON_MAC10, { "MAC-10", "models/weapons/v_smg_mac10.mdl", "mac10" } }, 763 | { sdk::structs::WEAPON_P90, { "P90", "models/weapons/v_smg_p90.mdl", "p90" } }, 764 | { sdk::structs::WEAPON_MP5SD, { "MP5-SD", "models/weapons/v_smg_mp5sd.mdl", "mp5sd" } }, 765 | { sdk::structs::WEAPON_UMP45, { "UMP-45", "models/weapons/v_smg_ump45.mdl", "ump45" } }, 766 | { sdk::structs::WEAPON_XM1014, { "XM1014", "models/weapons/v_shot_xm1014.mdl", "xm1014" } }, 767 | { sdk::structs::WEAPON_BIZON, { "PP-Bizon", "models/weapons/v_smg_bizon.mdl", "bizon" } }, 768 | { sdk::structs::WEAPON_MAG7, { "MAG-7", "models/weapons/v_shot_mag7.mdl", "mag7" } }, 769 | { sdk::structs::WEAPON_NEGEV, { "Negev", "models/weapons/v_mach_negev.mdl", "negev" } }, 770 | { sdk::structs::WEAPON_SAWEDOFF, { "Sawed-Off", "models/weapons/v_shot_sawedoff.mdl", "sawedoff" } }, 771 | { sdk::structs::WEAPON_TEC9, { "Tec-9", "models/weapons/v_pist_tec9.mdl", "tec9" } }, 772 | { sdk::structs::WEAPON_HKP2000, { "P2000", "models/weapons/v_pist_hkp2000.mdl", "hkp2000" } }, 773 | { sdk::structs::WEAPON_MP7, { "MP7", "models/weapons/v_smg_mp7.mdl", "mp7" } }, 774 | { sdk::structs::WEAPON_MP9, { "MP9", "models/weapons/v_smg_mp9.mdl", "mp9" } }, 775 | { sdk::structs::WEAPON_NOVA, { "Nova", "models/weapons/v_shot_nova.mdl", "nova" } }, 776 | { sdk::structs::WEAPON_P250, { "P250", "models/weapons/v_pist_p250.mdl", "p250" } }, 777 | { sdk::structs::WEAPON_SCAR20, { "SCAR-20", "models/weapons/v_snip_scar20.mdl", "scar20" } }, 778 | { sdk::structs::WEAPON_SG556, { "SG 553", "models/weapons/v_rif_sg556.mdl", "sg556" } }, 779 | { sdk::structs::WEAPON_SSG08, { "SSG 08", "models/weapons/v_snip_ssg08.mdl", "ssg08" } }, 780 | { sdk::structs::WEAPON_KNIFE, { "Knife (Counter-Terrorists)", "models/weapons/v_knife_default_ct.mdl", "knife_default_ct" } }, 781 | { sdk::structs::WEAPON_KNIFE_T, { "Knife (Terrorists)", "models/weapons/v_knife_default_t.mdl", "knife_t" } }, 782 | { sdk::structs::WEAPON_M4A1_SILENCER, { "M4A1-S", "models/weapons/v_rif_m4a1_s.mdl", "m4a1_silencer" } }, 783 | { sdk::structs::WEAPON_USP_SILENCER, { "USP-S", "models/weapons/v_pist_223.mdl", "usp_silencer" } }, 784 | { sdk::structs::WEAPON_CZ75A, { "CZ75 Auto", "models/weapons/v_pist_cz_75.mdl", "cz75a" } }, 785 | { sdk::structs::WEAPON_REVOLVER, { "R8 Revolver", "models/weapons/v_pist_revolver.mdl", "revolver" } }, 786 | { sdk::structs::WEAPON_KNIFE_BAYONET, { "Bayonet", "models/weapons/v_knife_bayonet.mdl", "bayonet" } }, 787 | { sdk::structs::WEAPON_KNIFE_FLIP, { "Flip Knife", "models/weapons/v_knife_flip.mdl", "knife_flip" } }, 788 | { sdk::structs::WEAPON_KNIFE_GUT, { "Gut Knife", "models/weapons/v_knife_gut.mdl", "knife_gut" } }, 789 | { sdk::structs::WEAPON_KNIFE_KARAMBIT, { "Karambit", "models/weapons/v_knife_karam.mdl", "knife_karambit" } }, 790 | { sdk::structs::WEAPON_KNIFE_M9_BAYONET, { "M9 Bayonet", "models/weapons/v_knife_m9_bay.mdl", "knife_m9_bayonet" } }, 791 | { sdk::structs::WEAPON_KNIFE_TACTICAL, { "Huntsman Knife", "models/weapons/v_knife_tactical.mdl", "knife_tactical" } }, 792 | { sdk::structs::WEAPON_KNIFE_FALCHION, { "Falchion Knife", "models/weapons/v_knife_falchion_advanced.mdl", "knife_falchion" } }, 793 | { sdk::structs::WEAPON_KNIFE_SURVIVAL_BOWIE, { "Bowie Knife", "models/weapons/v_knife_survival_bowie.mdl", "knife_survival_bowie" } }, 794 | { sdk::structs::WEAPON_KNIFE_BUTTERFLY, { "Butterfly Knife", "models/weapons/v_knife_butterfly.mdl", "knife_butterfly" } }, 795 | { sdk::structs::WEAPON_KNIFE_PUSH, { "Shadow Daggers", "models/weapons/v_knife_push.mdl", "knife_push" } }, 796 | { sdk::structs::WEAPON_KNIFE_CORD, { "Paracord Knife", "models/weapons/v_knife_cord.mdl", "knife_cord" } }, 797 | { sdk::structs::WEAPON_KNIFE_CANIS, { "Survival Knife", "models/weapons/v_knife_canis.mdl", "knife_canis" } }, 798 | { sdk::structs::WEAPON_KNIFE_URSUS, { "Ursus Knife", "models/weapons/v_knife_ursus.mdl", "knife_ursus" } }, 799 | { sdk::structs::WEAPON_KNIFE_GYPSY_JACKKNIFE, { "Navaja Knife", "models/weapons/v_knife_gypsy_jackknife.mdl", "knife_gypsy_jackknife" } }, 800 | { sdk::structs::WEAPON_KNIFE_OUTDOOR, { "Nomad Knife", "models/weapons/v_knife_outdoor.mdl", "knife_outdoor" } }, 801 | { sdk::structs::WEAPON_KNIFE_STILETTO, { "Stiletto Knife", "models/weapons/v_knife_stiletto.mdl", "knife_stiletto" } }, 802 | { sdk::structs::WEAPON_KNIFE_WIDOWMAKER, { "Talon Knife", "models/weapons/v_knife_widowmaker.mdl", "knife_widowmaker" } }, 803 | { sdk::structs::WEAPON_KNIFE_SKELETON, { "Skeleton Knife", "models/weapons/v_knife_skeleton.mdl", "knife_skeleton" } }, 804 | }; 805 | 806 | class weapon_data_t 807 | { 808 | public: 809 | std::byte pad0[0x14]; // 0x0000 810 | int iMaxClip1; // 0x0014 811 | int iMaxClip2; // 0x0018 812 | int iDefaultClip1; // 0x001C 813 | int iDefaultClip2; // 0x0020 814 | int iPrimaryMaxReserveAmmo; // 0x0024 815 | int iSecondaryMaxReserveAmmo; // 0x0028 816 | const char* szWorldModel; // 0x002C 817 | const char* szViewModel; // 0x0030 818 | const char* szDroppedModel; // 0x0034 819 | std::byte pad1[0x50]; // 0x0038 820 | const char* szHudName; // 0x0088 821 | const char* szWeaponName; // 0x008C 822 | std::byte pad2[0x2]; // 0x0090 823 | bool bIsMeleeWeapon; // 0x0092 824 | std::byte pad3[0x9]; // 0x0093 825 | float flWeaponWeight; // 0x009C 826 | std::byte pad4[0x4]; // 0x00A0 827 | int iSlot; // 0x00A4 828 | int iPosition; // 0x00A8 829 | std::byte pad5[0x1C]; // 0x00AC 830 | int nWeaponType; // 0x00C8 831 | std::byte pad6[0x4]; // 0x00CC 832 | int iWeaponPrice; // 0x00D0 833 | int iKillAward; // 0x00D4 834 | const char* szAnimationPrefix; // 0x00D8 835 | float flCycleTime; // 0x00DC 836 | float flCycleTimeAlt; // 0x00E0 837 | std::byte pad8[0x8]; // 0x00E4 838 | bool bFullAuto; // 0x00EC 839 | std::byte pad9[0x3]; // 0x00ED 840 | int iDamage; // 0x00F0 841 | float flHeadShotMultiplier; // 0x00F4 842 | float flArmorRatio; // 0x00F8 843 | int iBullets; // 0x00FC 844 | float flPenetration; // 0x0100 845 | std::byte pad10[0x8]; // 0x0104 846 | float flRange; // 0x010C 847 | float flRangeModifier; // 0x0110 848 | float flThrowVelocity; // 0x0114 849 | std::byte pad11[0xC]; // 0x0118 850 | bool bHasSilencer; // 0x0124 851 | std::byte pad12[0xF]; // 0x0125 852 | float flMaxSpeed[2]; // 0x0134 853 | std::byte pad13[0x4]; // 0x013C 854 | float flSpread[2]; // 0x0140 855 | float flInaccuracyCrouch[2]; // 0x0148 856 | float flInaccuracyStand[2]; // 0x0150 857 | std::byte pad14[0x8]; // 0x0158 858 | float flInaccuracyJump[2]; // 0x0160 859 | float flInaccuracyLand[2]; // 0x0168 860 | float flInaccuracyLadder[2]; // 0x0170 861 | float flInaccuracyFire[2]; // 0x0178 862 | float flInaccuracyMove[2]; // 0x0180 863 | float flInaccuracyReload; // 0x0188 864 | int iRecoilSeed; // 0x018C 865 | float flRecoilAngle[2]; // 0x0190 866 | float flRecoilAngleVariance[2]; // 0x0198 867 | float flRecoilMagnitude[2]; // 0x01A0 868 | float flRecoilMagnitudeVariance[2]; // 0x01A8 869 | int iSpreadSeed; // 0x01B0 870 | 871 | bool is_gun() const { 872 | switch (this->nWeaponType) { 873 | case WEAPONTYPE_PISTOL: 874 | case WEAPONTYPE_SUBMACHINEGUN: 875 | case WEAPONTYPE_RIFLE: 876 | case WEAPONTYPE_SHOTGUN: 877 | case WEAPONTYPE_SNIPER: 878 | case WEAPONTYPE_MACHINEGUN: 879 | return true; 880 | } 881 | 882 | return false; 883 | } 884 | }; 885 | 886 | struct weapon_info_table_object_t 887 | { 888 | std::byte pad_0x0000[0x8]; // 0x0000 889 | short item_definition_index; // 0x0008 890 | std::byte pad_0x000A[0x2]; // 0x000A 891 | weapon_data_t* weapon_info; // 0x000C WeaponInfo* 892 | }; 893 | 894 | struct weapon_info_table_t 895 | { 896 | std::byte pad_0x0000[0x8]; // 0x0000 897 | weapon_info_table_object_t* weapon_table; // 0x0008 898 | short max_index; // 0x000C 899 | std::byte pad_0x000E[0x6]; // 0x000E 900 | short N00000006; // 0x0014 901 | short N000011D5; // 0x0016 902 | std::byte pad_0x0018[0x2]; // 0x0018 903 | short last_index; // 0x001A 904 | int WeaponTable2; // 0x001C 905 | std::byte pad_0x0020[0x820]; // 0x0020 906 | }; 907 | } 908 | } 909 | 910 | #pragma region clientmode_definitions 911 | #define SIGNONSTATE_NONE 0 // no state yet, about to connect 912 | #define SIGNONSTATE_CHALLENGE 1 // client challenging server, all OOB packets 913 | #define SIGNONSTATE_CONNECTED 2 // client is connected to server, netchans ready 914 | #define SIGNONSTATE_NEW 3 // just got serverinfo and string tables 915 | #define SIGNONSTATE_PRESPAWN 4 // received signon buffers 916 | #define SIGNONSTATE_SPAWN 5 // ready to receive entity packets 917 | #define SIGNONSTATE_FULL 6 // we are fully connected, first non-delta packet received (in-game check) 918 | #define SIGNONSTATE_CHANGELEVEL 7 // server is changing level, please wait 919 | #pragma endregion --------------------------------------------------------------------------------