├── src ├── sdk │ ├── classes │ │ ├── CCSPlayerPawn.cpp │ │ ├── CCSPlayerPawn.h │ │ ├── CBaseEntity.cpp │ │ ├── CBasePlayerWeapon.cpp │ │ ├── CCSGameRulesProxy.h │ │ ├── CBasePlayerWeapon.h │ │ ├── CBasePlayer.cpp │ │ ├── CPlayerWeaponServices.h │ │ ├── CSkeletonInstance.h │ │ ├── CGameSceneNode.h │ │ ├── CStrongHandle.h │ │ ├── CHandle.h │ │ ├── CEntityIdentity.h │ │ ├── CBaseEntity.h │ │ ├── CEntityInstance.h │ │ ├── CBasePlayer.h │ │ └── CBoneSystem.h │ ├── math │ │ ├── Vector.cpp │ │ ├── Viewmatrix.h │ │ └── Vector.h │ ├── helpers │ │ ├── dynamic_module.cpp │ │ ├── console.h │ │ ├── modules.cpp │ │ ├── CUtlString.h │ │ ├── modules.h │ │ ├── vfunc.h │ │ ├── CUtlMap.cpp │ │ ├── BitFlag.h │ │ ├── CUtlMap.h │ │ ├── console.cpp │ │ ├── netvars.h │ │ ├── entity_data.h │ │ ├── CUtlSymbolLarge.hpp │ │ ├── CUtlVector.h │ │ ├── netvars.cpp │ │ ├── fnv.h │ │ ├── CUtlTSHash.h │ │ ├── CUtlMemory.h │ │ ├── CUtlVector.cpp │ │ ├── entity_data.cpp │ │ └── dynamic_module.h │ ├── interfaces │ │ ├── CGameResourceService.h │ │ ├── IMemAlloc.h │ │ ├── IVEngineClient.h │ │ ├── GameEntitySystem.h │ │ └── CSGOInput.h │ ├── sdk.h │ ├── hooking │ │ └── minhook │ │ │ ├── hde │ │ │ ├── pstdint.h │ │ │ ├── hde32.h │ │ │ ├── hde64.h │ │ │ ├── table32.h │ │ │ ├── table64.h │ │ │ ├── hde64.c │ │ │ └── hde32.c │ │ │ ├── buffer.h │ │ │ ├── trampoline.h │ │ │ ├── MinHook.h │ │ │ ├── buffer.c │ │ │ └── trampoline.c │ └── sdk.cpp ├── render │ └── menu │ │ ├── main_window.h │ │ └── main_window.cpp ├── settings │ ├── settings.cpp │ └── settings.h ├── Cloud-Internal.vcxproj.user ├── features │ └── visuals │ │ ├── visuals.h │ │ └── visuals.cpp ├── hooks │ ├── functions │ │ ├── CreateMove.cpp │ │ ├── WinProc.cpp │ │ ├── OnRemoveEntity.cpp │ │ ├── OnAddEntity.cpp │ │ ├── FrameStageNotify.cpp │ │ └── Present.cpp │ ├── hooks.h │ └── hooks.cpp ├── thirdparty │ └── imgui │ │ ├── backends │ │ ├── imgui_impl_dx11.h │ │ └── imgui_impl_win32.h │ │ └── imconfig.h ├── main.cpp ├── Cloud-Internal.vcxproj └── Cloud-Internal.filters ├── .gitignore ├── README.md ├── LICENSE └── Cloud-Internal.sln /src/sdk/classes/CCSPlayerPawn.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/sdk/classes/CCSPlayerPawn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /src/sdk/math/Vector.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector.h" 2 | -------------------------------------------------------------------------------- /src/sdk/classes/CBaseEntity.cpp: -------------------------------------------------------------------------------- 1 | #include "CBaseEntity.h" 2 | -------------------------------------------------------------------------------- /src/sdk/helpers/dynamic_module.cpp: -------------------------------------------------------------------------------- 1 | #include "dynamic_module.h" 2 | -------------------------------------------------------------------------------- /src/sdk/classes/CBasePlayerWeapon.cpp: -------------------------------------------------------------------------------- 1 | #include "CBasePlayerWeapon.h" 2 | -------------------------------------------------------------------------------- /src/sdk/math/Viewmatrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct VMatrix 4 | { 5 | auto operator[](int i) { return m[i]; }; 6 | 7 | float m[4][4]; 8 | }; 9 | -------------------------------------------------------------------------------- /src/render/menu/main_window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../thirdparty/ImGui/imgui.h" 3 | #include "../../settings/settings.h" 4 | 5 | namespace main_window 6 | { 7 | extern bool is_open; 8 | 9 | void Draw(); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/settings/settings.cpp: -------------------------------------------------------------------------------- 1 | #include "../settings/settings.h" 2 | 3 | namespace settings 4 | { 5 | namespace visuals 6 | { 7 | bool m_bFovChanger = false; 8 | int m_iFov = 90; 9 | 10 | bool m_bBoneEsp = false; 11 | } 12 | } -------------------------------------------------------------------------------- /src/settings/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace settings 4 | { 5 | namespace visuals 6 | { 7 | extern bool m_bFovChanger; 8 | extern int m_iFov; 9 | 10 | extern bool m_bBoneEsp; 11 | } 12 | } 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/sdk/helpers/console.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace console 9 | { 10 | void attach(); 11 | void detach(); 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/sdk/classes/CCSGameRulesProxy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sdk/helpers/netvars.h" 4 | #include "sdk/helpers/vfunc.h" 5 | 6 | class CCSGameRulesProxy 7 | { 8 | NETVAR(bool, m_bBombDropped, "C_CSGameRules", "m_bBombDropped"); 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /src/Cloud-Internal.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/sdk/helpers/modules.cpp: -------------------------------------------------------------------------------- 1 | #include "modules.h" 2 | 3 | namespace modules 4 | { 5 | DynamicModule client; 6 | DynamicModule engine; 7 | DynamicModule schema; 8 | DynamicModule tier0; 9 | DynamicModule render_dx11; 10 | DynamicModule nav_system; 11 | } 12 | -------------------------------------------------------------------------------- /src/sdk/classes/CBasePlayerWeapon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../sdk/helpers/netvars.h" 4 | #include "../../sdk/helpers/vfunc.h" 5 | 6 | class CBasePlayerWeapon 7 | { 8 | public: 9 | NETVAR(int, m_iClip1, "C_BasePlayerWeapon", "m_iClip1"); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /src/features/visuals/visuals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../hooks/hooks.h" 4 | #include "../../sdk/sdk.h" 5 | 6 | namespace visuals 7 | { 8 | 9 | namespace players 10 | { 11 | // soon. for now check present 12 | void run(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/sdk/interfaces/CGameResourceService.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GameEntitySystem.h" 4 | 5 | class CGameResourceService 6 | { 7 | public: 8 | CGameEntitySystem* GetGameEntitySystem() 9 | { 10 | return *reinterpret_cast(reinterpret_cast(this) + 0x58); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /src/sdk/classes/CBasePlayer.cpp: -------------------------------------------------------------------------------- 1 | #include "CBasePlayer.h" 2 | 3 | #include "../../sdk/helpers/fnv.h" 4 | 5 | bool CBasePlayer::InAir() 6 | { 7 | return m_hGroundEntity() == nullptr; 8 | } 9 | 10 | bool CBasePlayer::IsAlive() 11 | { 12 | return m_iHealth() > 0 || m_lifeState() == LIFE_ALIVE; 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.vsidx 3 | .vs/Cloud-Internal/v17/.suo 4 | *.db 5 | *.db-shm 6 | *.db-wal 7 | *.opendb 8 | *.bin 9 | *.ipch 10 | .vs/Sensum/v17/.suo 11 | *.dll 12 | *.pdb 13 | *.obj 14 | *.recipe 15 | *.ilk 16 | *.log 17 | *.tlog 18 | *.ifc 19 | *.json 20 | *.idb 21 | build/Debug/std.ixx.ifc.dt.module.json.command 22 | *.command 23 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "CUtlMemory.h" 4 | 5 | class CUtlString 6 | { 7 | public: 8 | const char* Get() 9 | { 10 | return reinterpret_cast(m_Memory.m_pMemory); 11 | } 12 | 13 | CUtlMemory m_Memory; 14 | int m_nActualLength; 15 | }; 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/sdk/helpers/modules.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/helpers/dynamic_module.h" 3 | 4 | namespace modules 5 | { 6 | extern DynamicModule client; 7 | extern DynamicModule engine; 8 | extern DynamicModule schema; 9 | extern DynamicModule tier0; 10 | extern DynamicModule render_dx11; 11 | 12 | extern DynamicModule nav_system; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/sdk/classes/CPlayerWeaponServices.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/helpers/netvars.h" 3 | #include "../../sdk/helpers/vfunc.h" 4 | #include "../../sdk/classes/CHandle.h" 5 | #include "../../sdk/classes/CBasePlayerWeapon.h" 6 | 7 | class CPlayerWeaponServices 8 | { 9 | public: 10 | NETVAR(CHandle, m_hActiveWeapon, "CPlayer_WeaponServices", "m_hActiveWeapon"); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /src/features/visuals/visuals.cpp: -------------------------------------------------------------------------------- 1 | #include "visuals.h" 2 | 3 | #include "../../sdk/classes/CBasePlayer.h" 4 | #include "../../sdk/math/Viewmatrix.h" 5 | #include "../../sdk/helpers/entity_data.h" 6 | 7 | namespace visuals 8 | { 9 | 10 | namespace players 11 | { 12 | // soon. for now check present 13 | void run() 14 | { 15 | 16 | } 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /src/sdk/helpers/vfunc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //Example usage: 4 | //GetVirtual(this, func_index)(this, optional_arguments_value); 5 | //GetVirtual(this, 1)(this, size); 6 | 7 | template 8 | __forceinline static FuncType GetVirtual(void* ppClass, int index) 9 | { 10 | return (*static_cast(ppClass))[index]; 11 | } -------------------------------------------------------------------------------- /src/sdk/classes/CSkeletonInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/helpers/vfunc.h" 3 | #include "../../sdk/helpers/netvars.h" 4 | #include "../../sdk/classes/CGameSceneNode.h" 5 | #include "../../sdk/classes/CBoneSystem.h" 6 | 7 | class CSkeletonInstance //: public CGameSceneNode //Compiler error because of line #4: include loop 8 | { 9 | public: 10 | NETVAR(CModelState, m_modelState, "CSkeletonInstance", "m_modelState"); 11 | NETVAR(uint8_t, m_nHitboxSet, "CSkeletonInstance", "m_nHitboxSet"); 12 | }; 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # https://discord.gg/9xmxvpcnts 2 | 3 | I don't push small updates all the time, i do bigger ones before pushing so thats why the repo might seem inactive. 4 | 5 | # Features 6 | - Proper entity data caching 7 | - Fully optimized ESP (0 drops w bone esp, etc) 8 | - Simple ESP (box & name & health) 9 | - Simple ImGui rendering 10 | - Simple FOV changer with slider in menu to show a hooking example 11 | 12 | # TODO 13 | - Compute bbox 14 | - Get local pawn by signature 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/render/menu/main_window.cpp: -------------------------------------------------------------------------------- 1 | #include "main_window.h" 2 | 3 | namespace main_window 4 | { 5 | bool is_open = false; 6 | 7 | void Draw() 8 | { 9 | ImGui::Begin("Sensum", 0, ImGuiWindowFlags_NoCollapse); 10 | 11 | ImGui::Checkbox("Fov changer", &settings::visuals::m_bFovChanger); 12 | ImGui::Checkbox("Bone ESP", &settings::visuals::m_bBoneEsp); 13 | 14 | if (settings::visuals::m_bFovChanger) 15 | ImGui::SliderInt("Fov slider", &settings::visuals::m_iFov, 0, 200); 16 | 17 | ImGui::End(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/sdk/classes/CGameSceneNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/helpers/netvars.h" 3 | #include "../../sdk/helpers/vfunc.h" 4 | #include "../../sdk/math/Vector.h" 5 | #include "../../sdk/classes/CSkeletonInstance.h" 6 | 7 | class CGameSceneNode 8 | { 9 | public: 10 | NETVAR(Vector, m_vecOrigin, "CGameSceneNode", "m_vecOrigin"); 11 | NETVAR(Vector, m_vecAbsOrigin, "CGameSceneNode", "m_vecAbsOrigin"); 12 | 13 | CSkeletonInstance* GetSkeletonInstance() 14 | { 15 | return GetVirtual(this, 8)(this); 16 | } 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlMap.cpp: -------------------------------------------------------------------------------- 1 | #include "CUtlMap.h" 2 | 3 | template 4 | inline S& CUtlMap::Count() const 5 | { 6 | return size_; 7 | } 8 | 9 | template 10 | inline S& CUtlMap::Count() 11 | { 12 | return size_; 13 | } 14 | 15 | template 16 | inline T& CUtlMap::Element(int i) 17 | { 18 | assert(i < size_); 19 | return base_[i]; 20 | } 21 | 22 | template 23 | const T& CUtlMap::Element(int i) const 24 | { 25 | assert(i < size_); 26 | return base_[i]; 27 | } -------------------------------------------------------------------------------- /src/hooks/functions/CreateMove.cpp: -------------------------------------------------------------------------------- 1 | #include "../hooks.h" 2 | #include "../../sdk/sdk.h" 3 | #include "../../sdk/helpers/entity_data.h" 4 | 5 | #include "../../sdk/classes/CBasePlayer.h" 6 | 7 | 8 | 9 | void __fastcall hooks::create_move::hooked(c_csgo_input* input, int slot, bool unk, bool sub_tick) 10 | { 11 | sdk::sub_tick = sub_tick; 12 | sdk::user_cmd = input->get_usercmd(); 13 | sdk::base_user_cmd = sdk::user_cmd->m_base_cmd; 14 | 15 | if (!g::engine_client->IsConnected() || !g::engine_client->IsInGame() || !entity_data::local_player_pawn || !sdk::user_cmd || !sdk::base_user_cmd) 16 | original_fn(input, slot, unk, sub_tick); 17 | 18 | original_fn(input, slot, unk, sub_tick); 19 | } 20 | -------------------------------------------------------------------------------- /src/sdk/classes/CStrongHandle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | struct ResourceBinding_t 3 | { 4 | void* data; 5 | }; 6 | 7 | template 8 | class CStrongHandle 9 | { 10 | public: 11 | explicit operator T* () const 12 | { 13 | if (!IsValid()) 14 | return nullptr; 15 | 16 | return reinterpret_cast(resource_binding->data); 17 | } 18 | 19 | T* operator->() const 20 | { 21 | if (!IsValid()) 22 | return nullptr; 23 | 24 | return reinterpret_cast(resource_binding->data); 25 | } 26 | 27 | [[nodiscard]] bool IsValid() const 28 | { 29 | return resource_binding->data != nullptr; 30 | } 31 | 32 | private: 33 | const ResourceBinding_t* resource_binding; 34 | }; -------------------------------------------------------------------------------- /src/sdk/helpers/BitFlag.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class BitFlag 6 | { 7 | public: 8 | BitFlag() = default; 9 | 10 | explicit BitFlag(const std::uintptr_t flag) : flag(flag) {} 11 | 12 | __forceinline void AddFlag(const std::uintptr_t flag) 13 | { 14 | this->flag |= flag; 15 | } 16 | 17 | [[nodiscard]] __forceinline bool HasFlag(const std::uintptr_t flag) const 18 | { 19 | return this->flag & flag; 20 | } 21 | 22 | __forceinline void RemoveFlag(const std::uintptr_t flag) 23 | { 24 | this->flag &= ~flag; 25 | } 26 | 27 | [[nodiscard]] __forceinline std::uintptr_t get_flag() const 28 | { 29 | return this->flag; 30 | } 31 | 32 | private: 33 | std::uintptr_t flag; 34 | }; -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlMap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class CUtlMap 5 | { 6 | public: 7 | inline CUtlMap begin() noexcept 8 | { 9 | return base_; 10 | } 11 | 12 | inline CUtlMap end() noexcept 13 | { 14 | return base_ + size_; 15 | } 16 | 17 | [[nodiscard]] CUtlMap begin() const 18 | { 19 | return base_; 20 | } 21 | 22 | [[nodiscard]] CUtlMap end() const 23 | { 24 | return base_ + size_; 25 | } 26 | 27 | T& operator[](int i) 28 | { 29 | return base_[i]; 30 | } 31 | 32 | S& Count() const; 33 | S& Count(); 34 | 35 | T& Element(int i); 36 | const T& Element(int i) const; 37 | 38 | private: 39 | T* base_ = nullptr; 40 | S size_ = 0; 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /src/sdk/helpers/console.cpp: -------------------------------------------------------------------------------- 1 | #include "Console.h" 2 | 3 | #include "../helpers/importer.h" 4 | 5 | namespace console 6 | { 7 | HANDLE out, old_out; 8 | 9 | void attach() 10 | { 11 | AllocConsole(); 12 | AttachConsole(ATTACH_PARENT_PROCESS); 13 | 14 | //#ifdef NDEBUG 15 | // ShowWindow(GetConsoleWindow(), SW_SHOWMINIMIZED); 16 | //#endif //NDEBUG 17 | 18 | ShowWindow(GetConsoleWindow(), SW_MINIMIZE); 19 | 20 | FILE* file; 21 | freopen_s(&file, "CONIN$", "r", stdin); 22 | freopen_s(&file, "CONOUT$", "w", stdout); 23 | freopen_s(&file, "CONOUT$", "w", stderr); 24 | } 25 | 26 | void detach() 27 | { 28 | HWND hwnd = GetConsoleWindow(); 29 | 30 | FreeConsole(); 31 | 32 | PostMessageA(hwnd, WM_QUIT, 0, 0); //Was WM_CLOSE 33 | } 34 | } -------------------------------------------------------------------------------- /src/hooks/functions/WinProc.cpp: -------------------------------------------------------------------------------- 1 | #include "../hooks.h" 2 | #include "../../render/menu/main_window.h" 3 | #include "../../thirdparty/ImGui/backends/imgui_impl_win32.h" 4 | 5 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 6 | 7 | namespace hooks 8 | { 9 | LRESULT __stdcall hooks::wndproc::hooked(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 10 | { 11 | if (msg == WM_KEYDOWN && wparam == VK_INSERT) 12 | main_window::is_open = !main_window::is_open; 13 | 14 | if (msg == WM_KEYDOWN && wparam == VK_END) 15 | sdk::can_unhook = true; 16 | 17 | if (main_window::is_open) 18 | ImGui_ImplWin32_WndProcHandler(hwnd, msg, wparam, lparam); 19 | 20 | return ::CallWindowProcA(original, hwnd, msg, wparam, lparam); 21 | } 22 | } -------------------------------------------------------------------------------- /src/sdk/classes/CHandle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../sdk.h" 3 | #include "../../sdk/classes/CBaseEntity.h" 4 | 5 | #define INVALID_EHANDLE_INDEX 0xFFFFFFFF 6 | #define ENT_ENTRY_MASK 0x7FFF 7 | 8 | class CHandle 9 | { 10 | public: 11 | bool operator==(const CHandle& rhs) const 12 | { 13 | return entity_index == rhs.entity_index; 14 | } 15 | 16 | bool IsValid() const 17 | { 18 | return entity_index != INVALID_EHANDLE_INDEX; 19 | } 20 | 21 | int GetEntryIndex() const 22 | { 23 | return entity_index & ENT_ENTRY_MASK; 24 | } 25 | 26 | template 27 | T* Get() const 28 | { 29 | auto base_entity = g::entity_system->GetBaseEntity(GetEntryIndex()); 30 | 31 | return reinterpret_cast(base_entity); 32 | } 33 | 34 | uint32_t entity_index; 35 | }; -------------------------------------------------------------------------------- /src/sdk/interfaces/IMemAlloc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma warning(disable:4191) 3 | #include 4 | #include 5 | 6 | #include "../helpers/vfunc.h" 7 | 8 | class IMemAlloc 9 | { 10 | public: 11 | void* Alloc(std::size_t size) 12 | { 13 | return GetVirtual(this, 1)(this, size); 14 | } 15 | 16 | void* ReAlloc(const void* p, std::size_t size) 17 | { 18 | return GetVirtual(this, 2)(this, p, size); 19 | } 20 | 21 | void Free(const void* p) 22 | { 23 | return GetVirtual(this, 3)(this, p); 24 | } 25 | 26 | std::size_t GetSize(const void* p) 27 | { 28 | return GetVirtual(this, 21)(this, p); 29 | } 30 | }; 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/sdk/helpers/netvars.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../../sdk/helpers/fnv.h" 5 | 6 | #define NETVAR(type, function, class_name, var_name) \ 7 | __forceinline type& function() \ 8 | { \ 9 | constexpr auto hash = fnv::hash_constexpr(class_name "->" var_name); \ 10 | auto offset = netvars::get_offset_by_hash_cached(hash); \ 11 | return *reinterpret_cast(reinterpret_cast(this) + offset); \ 12 | } \ 13 | 14 | #define PNETVAR(type, function, class_name, var_name) \ 15 | auto function() \ 16 | { \ 17 | constexpr auto hash = fnv::hash_constexpr(class_name "->" var_name); \ 18 | auto offset = netvars::get_offset_by_hash_cached(hash); \ 19 | return reinterpret_cast>((uintptr_t)(this) + offset); \ 20 | } \ 21 | 22 | namespace netvars 23 | { 24 | static std::map netvars_data; 25 | 26 | void init(); 27 | uintptr_t get_offset_by_hash_cached(const fnv::hash hash); 28 | }; 29 | 30 | -------------------------------------------------------------------------------- /src/hooks/functions/OnRemoveEntity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../hooks.h" 3 | #include "../../sdk/sdk.h" 4 | #include "../../sdk/helpers/entity_data.h" 5 | 6 | void remove_players(CEntityInstance* instance, CHandle handle) 7 | { 8 | if (!instance || !instance->IsController()) 9 | return; 10 | 11 | auto it = std::remove_if(entity_data::player_instances.begin(), entity_data::player_instances.end(), [&](const entity_data::instance_t& e) { return e.entity->m_pEntity() == instance->m_pEntity(); }); 12 | 13 | entity_data::player_instances.erase(it, entity_data::player_instances.end()); 14 | } 15 | 16 | void on_remove_entity_fn(CEntityInstance* instance, CHandle handle) 17 | { 18 | if (!instance) 19 | return; 20 | 21 | remove_players(instance, handle); 22 | } 23 | 24 | CEntityInstance* __fastcall hooks::on_remove_entity::hooked(void* rcx, CEntityInstance* instance, CHandle handle) 25 | { 26 | on_remove_entity_fn(instance, handle); 27 | 28 | return original_fn(rcx, instance, handle); 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/sdk/classes/CEntityIdentity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../sdk/helpers/netvars.h" 4 | #include "../../sdk/helpers/vfunc.h" 5 | #include "../../sdk/helpers/CUtlSymbolLarge.hpp" 6 | 7 | class CEntityIdentity 8 | { 9 | public: 10 | NETVAR(CUtlSymbolLarge, m_name, "CEntityIdentity", "m_name"); 11 | NETVAR(CUtlSymbolLarge, m_designerName, "CEntityIdentity", "m_designerName"); 12 | 13 | //int m_nameStringableIndex; // 0x14 int32_t 14 | //CUtlSymbolLarge m_name; // 0x18 CUtlSymbolLarge 15 | //CUtlSymbolLarge m_designerName; // 0x20 CUtlSymbolLarge 16 | //uint32_t m_flags; // 0x30 uint32_t 17 | //void* m_worldGroupId; // 0x38 WorldGroupId_t 18 | //uint32_t m_fDataObjectTypes; // 0x3C uint32_t 19 | //void* m_PathIndex; // 0x40 ChangeAccessorFieldPathIndex_t 20 | //CEntityIdentity* m_pPrev; // 0x58 CEntityIdentity* 21 | //CEntityIdentity* m_pNext; // 0x60 CEntityIdentity* 22 | //CEntityIdentity* m_pPrevByClass; // 0x68 CEntityIdentity* 23 | //CEntityIdentity* m_pNextByClass; // 0x70 CEntityIdentity* 24 | }; 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 clouddss 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/hooks/functions/OnAddEntity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../hooks.h" 4 | #include "../../sdk/sdk.h" 5 | #include "../../sdk/helpers/entity_data.h" 6 | 7 | void add_players(CEntityInstance* instance, CHandle handle) 8 | { 9 | if (!instance || !instance->IsController()) 10 | return; 11 | 12 | CBasePlayer* player = reinterpret_cast(instance); 13 | 14 | bool exists = std::any_of(entity_data::player_instances.begin(), entity_data::player_instances.end(), [&](const entity_data::instance_t& e) { return e.entity->m_pEntity() == instance->m_pEntity(); }); 15 | 16 | if (!exists) 17 | entity_data::player_instances.emplace_back(player, handle); 18 | } 19 | 20 | void on_add_entity_fn(CEntityInstance* instance, CHandle handle) 21 | { 22 | if (!instance) 23 | return; 24 | 25 | add_players(instance, handle); 26 | } 27 | 28 | 29 | CEntityInstance* __fastcall hooks::on_add_entity::hooked(void* rcx, CEntityInstance* instance, CHandle handle) 30 | { 31 | on_add_entity_fn(instance, handle); 32 | 33 | return original_fn(rcx, instance, handle); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Cloud-Internal.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34322.80 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cloud-sdk", "src\Cloud-Internal.vcxproj", "{080FCF7F-1A84-40FD-9DF2-941AAD42E03E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {080FCF7F-1A84-40FD-9DF2-941AAD42E03E}.Debug|x64.ActiveCfg = Debug|x64 15 | {080FCF7F-1A84-40FD-9DF2-941AAD42E03E}.Debug|x64.Build.0 = Debug|x64 16 | {080FCF7F-1A84-40FD-9DF2-941AAD42E03E}.Release|x64.ActiveCfg = Release|x64 17 | {080FCF7F-1A84-40FD-9DF2-941AAD42E03E}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {FE9C9877-AC06-4EF8-8FCC-821AEA0EFEB7} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/sdk/helpers/entity_data.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../classes/CBasePlayer.h" 5 | #include "../classes/CSkeletonInstance.h" 6 | #include "../classes/CGameSceneNode.h" 7 | #include "../classes/CStrongHandle.h" 8 | 9 | #include 10 | 11 | namespace entity_data 12 | { 13 | struct player_data_t 14 | { 15 | int m_iHealth; 16 | Vector m_vecOrigin; 17 | int m_iShotsFired; 18 | int clip; 19 | uint32_t index; 20 | Vector m_vOldOrigin; 21 | CModelState* model_state; 22 | CStrongHandle model; 23 | RECT bbox; 24 | 25 | Vector mins; 26 | Vector maxs; 27 | }; 28 | 29 | struct entry_data_t 30 | { 31 | std::list player_data; 32 | }; 33 | 34 | struct instance_t 35 | { 36 | CBasePlayer* entity; 37 | CHandle handle; 38 | }; 39 | 40 | extern std::list player_instances; 41 | extern CBasePlayer* local_player_pawn; 42 | extern CCSPlayerController* local_player_controller; 43 | extern std::list entity_instances; 44 | extern std::list player_entry_data; 45 | 46 | extern std::mutex locker; 47 | 48 | void fetch_player_data(); 49 | void destroy(); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/thirdparty/imgui/backends/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for DirectX11 2 | // This needs to be used along with a Platform Binding (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 9 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 10 | // https://github.com/ocornut/imgui 11 | 12 | #pragma once 13 | 14 | struct ID3D11Device; 15 | struct ID3D11DeviceContext; 16 | 17 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 18 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 19 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 20 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 21 | 22 | // Use if you want to reset your rendering device without losing ImGui state. 23 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 24 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); 25 | -------------------------------------------------------------------------------- /src/sdk/classes/CBaseEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/helpers/netvars.h" 3 | #include "../../sdk/helpers/vfunc.h" 4 | #include "../../sdk/classes/CGameSceneNode.h" 5 | #include "../../sdk/classes/CEntityInstance.h" 6 | 7 | enum LifeState_t : uint8_t 8 | { 9 | LIFE_ALIVE, 10 | LIFE_DYING, 11 | LIFE_DEAD, 12 | LIFE_RESPAWNABLE, 13 | LIFE_RESPAWNING 14 | }; 15 | 16 | class CCollisionProperty //TODO: Add more members later 17 | { 18 | public: 19 | NETVAR(Vector, m_vecMins, "CCollisionProperty", "m_vecMins"); 20 | NETVAR(Vector, m_vecMaxs, "CCollisionProperty", "m_vecMaxs"); 21 | }; 22 | 23 | class CBaseEntity : public CEntityInstance 24 | { 25 | public: 26 | NETVAR(int, m_iHealth, "C_BaseEntity", "m_iHealth"); 27 | NETVAR(LifeState_t, m_lifeState, "C_BaseEntity", "m_lifeState"); 28 | NETVAR(uint8_t, m_iTeamNum, "C_BaseEntity", "m_iTeamNum"); 29 | NETVAR(CGameSceneNode*, m_pGameSceneNode, "C_BaseEntity", "m_pGameSceneNode"); 30 | NETVAR(CCollisionProperty*, m_pCollision, "C_BaseEntity", "m_pCollision"); //This returns nullptr for CBasePlayer, wtf? 31 | 32 | /*CCollisionProperty* m_pCollision() 33 | { 34 | return reinterpret_cast(reinterpret_cast(this) + 0x320); 35 | }*/ 36 | }; 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/sdk/classes/CEntityInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/classes/CEntityIdentity.h" 3 | #include "../../sdk/interfaces/SchemaSystem.h" 4 | //#include "../../sdk/classes/CHandle.h" 5 | 6 | class CEntityInstance 7 | { 8 | public: 9 | CEntityIdentity* m_pEntity() 10 | { 11 | return reinterpret_cast(reinterpret_cast(this) + 0x10); 12 | } 13 | 14 | SchemaClassInfoData_t* GetSchemaClassInfo() 15 | { 16 | SchemaClassInfoData_t* pClassInfo = nullptr; 17 | GetVirtual(this, 34)(this, &pClassInfo); 18 | 19 | return pClassInfo; 20 | } 21 | 22 | bool IsController() 23 | { 24 | const auto& class_info = GetSchemaClassInfo(); 25 | 26 | if (!class_info) 27 | return false; 28 | 29 | auto hash = fnv::hash_runtime(class_info->m_name); 30 | 31 | return hash == FNV("CCSPlayerController"); 32 | } 33 | 34 | bool IsPawn() 35 | { 36 | const auto& class_info = GetSchemaClassInfo(); 37 | 38 | if (!class_info) 39 | return false; 40 | 41 | auto hash = fnv::hash_runtime(class_info->m_name); 42 | 43 | return hash == FNV("C_CSPlayerPawn"); 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /src/hooks/functions/FrameStageNotify.cpp: -------------------------------------------------------------------------------- 1 | #include "../hooks.h" 2 | #include "../../sdk/sdk.h" 3 | 4 | #include "../../sdk/classes/CBasePlayer.h" 5 | 6 | #include "../../sdk/helpers/entity_data.h" 7 | 8 | void __fastcall hooks::frame_stage_notify::hooked(void* a1, int stage) 9 | { 10 | switch (stage) 11 | { 12 | case FRAME_START: 13 | break; 14 | 15 | case FRAME_NET_UPDATE_START: 16 | entity_data::fetch_player_data(); 17 | break; 18 | 19 | case FRAME_NET_UPDATE_POSTDATAUPDATE_START: 20 | break; 21 | case FRAME_NET_UPDATE_POSTDATAUPDATE_END: 22 | for (auto i = 1; i < 32; i++) { 23 | auto controller = g::entity_system->GetEntityController(i); 24 | 25 | if (!controller) 26 | return; 27 | 28 | static auto pawn = g::entity_system->GetPlayerPawn(controller); 29 | 30 | if (!pawn) 31 | return; 32 | 33 | if (controller->m_bIsLocalPlayerController()) { 34 | entity_data::local_player_pawn = pawn; 35 | entity_data::local_player_controller = controller; 36 | break; 37 | } 38 | } 39 | break; 40 | 41 | case FRAME_NET_UPDATE_END: 42 | break; 43 | 44 | case FRAME_RENDER_START: 45 | break; 46 | 47 | case FRAME_RENDER_END: 48 | break; 49 | 50 | case FRAME_NET_FULL_FRAME_UPDATE_ON_REMOVE: 51 | break; 52 | } 53 | 54 | original_fn(a1, stage); 55 | } 56 | -------------------------------------------------------------------------------- /src/thirdparty/imgui/backends/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | #pragma once 11 | 12 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 13 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 14 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 15 | 16 | // Handler for Win32 messages, update mouse/keyboard data. 17 | // You may or not need this for your implementation, but it can serve as reference for handling inputs. 18 | // Intentionally commented out to avoid dragging dependencies on types. You can COPY this line into your .cpp code instead. 19 | /* 20 | IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 21 | */ 22 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlSymbolLarge.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using CUtlSymLargeId = int*; 4 | 5 | class CUtlSymbolLarge 6 | { 7 | inline static const CUtlSymLargeId UTL_INVALID_SYMBOL_LARGE = reinterpret_cast(-1); 8 | 9 | public: 10 | CUtlSymbolLarge() { id_ = UTL_INVALID_SYMBOL_LARGE; } 11 | 12 | explicit CUtlSymbolLarge(CUtlSymLargeId id) { id_ = id; } 13 | 14 | CUtlSymbolLarge(CUtlSymbolLarge const& sym) { id_ = sym.id_; } 15 | 16 | CUtlSymbolLarge& operator=(CUtlSymbolLarge const& src) 17 | { 18 | id_ = src.id_; 19 | 20 | return *this; 21 | } 22 | 23 | bool operator==(CUtlSymbolLarge const& src) const { return id_ == src.id_; } 24 | 25 | bool operator==(CUtlSymLargeId const& src) const { return id_ == src; } 26 | 27 | bool operator!=(CUtlSymbolLarge const& src) const { return id_ != src.id_; } 28 | 29 | bool operator!=(CUtlSymLargeId const& src) const { return id_ != src; } 30 | 31 | explicit operator CUtlSymLargeId() const { return id_; } 32 | 33 | [[nodiscard]] const char* String() const 34 | { 35 | if (id_ == UTL_INVALID_SYMBOL_LARGE) 36 | return ""; 37 | 38 | return string_; 39 | } 40 | 41 | [[nodiscard]] bool IsValid() const 42 | { 43 | return id_ != UTL_INVALID_SYMBOL_LARGE; 44 | } 45 | 46 | private: 47 | union 48 | { 49 | CUtlSymLargeId id_; 50 | const char* string_ = ""; 51 | }; 52 | }; -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "sdk/sdk.h" 3 | #include "sdk/classes/CBasePlayer.h" 4 | #include "sdk/helpers/netvars.h" 5 | #include "sdk/helpers/console.h" 6 | #include "hooks/hooks.h" 7 | #include "sdk/helpers/entity_data.h" 8 | #include "sdk/classes/CBasePlayerWeapon.h" 9 | #include "sdk/math/Vector.h" 10 | 11 | //Notice: This project is WORK IN PROGRESS! 12 | DWORD __stdcall on_attach(void* base) 13 | { 14 | if (!modules::nav_system.base) 15 | std::this_thread::sleep_for(std::chrono::milliseconds(5000)); //Sleep 5 seconds to avoid switch to desktop because of console 16 | 17 | console::attach(); //TODO: Minimize console if in release mode? //#ifdef NDEBUG #endif // NDEBUG 18 | 19 | sdk::init_modules(); 20 | sdk::init_interfaces(); 21 | 22 | netvars::init(); 23 | hooks::init(); 24 | 25 | while (!sdk::can_unhook) 26 | std::this_thread::sleep_for(std::chrono::milliseconds(200)); 27 | 28 | //TODO: if (sdk::can_unhook) {}; 29 | hooks::detach(); 30 | console::detach(); 31 | 32 | FreeLibraryAndExitThread(reinterpret_cast(base), EXIT_SUCCESS); 33 | 34 | return TRUE; 35 | } 36 | 37 | BOOL APIENTRY DllMain(HMODULE module, DWORD reason, void* reserved) 38 | { 39 | if (reason != DLL_PROCESS_ATTACH) 40 | return false; 41 | 42 | DisableThreadLibraryCalls(module); 43 | 44 | auto thread = LI_FN(CreateThread)(nullptr, 0, on_attach, module, 0, nullptr); 45 | 46 | if (thread) 47 | LI_FN(CloseHandle)(thread); 48 | 49 | return TRUE; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/sdk/sdk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "../sdk/interfaces/IVEngineClient.h" 6 | #include "../sdk/interfaces/SchemaSystem.h" 7 | #include "../sdk/interfaces/IMemAlloc.h" 8 | #include "../sdk/interfaces/CGameResourceService.h" 9 | #include "../sdk/interfaces/CSGOInput.h" 10 | 11 | #include "../thirdparty/ImGui/imgui_internal.h" 12 | #include "../thirdparty/ImGui/backends/imgui_impl_win32.h" 13 | #include "../thirdparty/ImGui/backends/imgui_impl_dx11.h" 14 | 15 | #include 16 | #include 17 | 18 | #include "../sdk/math/Viewmatrix.h" 19 | 20 | class c_usercmd; 21 | class c_base_usercmd; 22 | 23 | namespace sdk 24 | { 25 | extern bool can_unhook; 26 | extern bool sub_tick; 27 | extern c_usercmd* user_cmd; 28 | extern c_base_usercmd* base_user_cmd; 29 | 30 | void init_modules(); 31 | 32 | void init_interfaces(); 33 | bool world_to_screen(const Vector& pos, Vector& out); //This is here for now, will move later 34 | 35 | extern VMatrix* viewmatrix; //Temp placement, move to eg: globals.cpp or something like that 36 | } 37 | 38 | class CRenderSystem 39 | { 40 | public: 41 | std::byte pad001[0x170]; 42 | IDXGISwapChain* swap_chain; 43 | }; 44 | 45 | namespace interfaces 46 | { 47 | extern IVEngineClient* engine_client; 48 | extern CSchemaSystem* schema_system; 49 | extern IMemAlloc* mem_alloc; 50 | extern CGameResourceService* game_resource_service; 51 | extern CGameEntitySystem* entity_system; 52 | extern c_csgo_input* csgo_input; 53 | extern CRenderSystem* render_system; 54 | extern IDXGISwapChain* swap_chain; 55 | } 56 | 57 | namespace g = interfaces; 58 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class CUtlVector 5 | { 6 | public: 7 | CUtlVector() 8 | { 9 | m_Size = 0; 10 | m_pElements = nullptr; 11 | } 12 | 13 | T& Element(int i); 14 | const T& Element(int i) const; 15 | 16 | T& operator[](int i) 17 | { 18 | return m_pElements[i]; 19 | } 20 | 21 | [[nodiscard]] int Count() const 22 | { 23 | return m_Size; 24 | } 25 | 26 | int m_Size; 27 | T* m_pElements; 28 | 29 | // Adds an element, uses default constructor 30 | int AddToHead(); 31 | int AddToTail(); 32 | int InsertBefore(int elem); 33 | int InsertAfter(int elem); 34 | // Adds an element, uses copy constructor 35 | int AddToHead(const T& src); 36 | int AddToTail(const T& src); 37 | int InsertBefore(int elem, const T& src); 38 | int InsertAfter(int elem, const T& src); 39 | 40 | // Grows the vector 41 | void GrowVector(int num = 1); 42 | 43 | // Shifts elements.... 44 | void ShiftElementsRight(int elem, int num = 1); 45 | void ShiftElementsLeft(int elem, int num = 1); 46 | 47 | // Element removal 48 | void FastRemove(int elem); // doesn't preserve order 49 | void Remove(int elem); // preserves order, shifts elements 50 | bool FindAndRemove(const T& src); // removes first occurrence of src, preserves order, shifts elements 51 | bool FindAndFastRemove(const T& src); // removes first occurrence of src, doesn't preserve order 52 | 53 | // Finds an element (element needs operator== defined) 54 | int GetOffset(const T& src) const; 55 | }; 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/pstdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | // Integer types for HDE. 32 | typedef INT8 int8_t; 33 | typedef INT16 int16_t; 34 | typedef INT32 int32_t; 35 | typedef INT64 int64_t; 36 | typedef UINT8 uint8_t; 37 | typedef UINT16 uint16_t; 38 | typedef UINT32 uint32_t; 39 | typedef UINT64 uint64_t; 40 | -------------------------------------------------------------------------------- /src/sdk/interfaces/IVEngineClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../helpers/vfunc.h" 4 | 5 | enum EClientFrameStage : int 6 | { 7 | FRAME_UNDEFINED = -1, 8 | FRAME_START, 9 | FRAME_NET_UPDATE_START, 10 | FRAME_NET_UPDATE_POSTDATAUPDATE_START, 11 | FRAME_NET_UPDATE_POSTDATAUPDATE_END, 12 | FRAME_NET_UPDATE_END, 13 | FRAME_RENDER_START, 14 | FRAME_RENDER_END, 15 | FRAME_NET_FULL_FRAME_UPDATE_ON_REMOVE 16 | }; 17 | 18 | class IVEngineClient 19 | { 20 | public: 21 | 22 | void ExecuteClientCmd(const char* command) //not working 23 | { 24 | GetVirtual(this, 36)(this, command); // index != 38 37 36 25 | } 26 | 27 | bool IsPaused() //not returning correct values 28 | { 29 | return GetVirtual(this, 11)(this); //not 10 11 12 13 15 16 17 18 30 | } 31 | 32 | int GetMaxClients() 33 | { 34 | return GetVirtual(this, 31)(this); 35 | } 36 | 37 | bool IsInGame() 38 | { 39 | return GetVirtual(this, 32)(this); 40 | } 41 | 42 | bool IsConnected() 43 | { 44 | return GetVirtual(this, 33)(this); 45 | } 46 | 47 | void GetScreenSize(int& width, int& height) 48 | { 49 | GetVirtual(this, 50)(this, width, height); 50 | } 51 | 52 | const char* GetLevelName() 53 | { 54 | return GetVirtual(this, 53)(this); 55 | } 56 | 57 | const char* GetLevelNameShort() 58 | { 59 | return GetVirtual(this, 54)(this); 60 | } 61 | 62 | int GetLocalPlayer() 63 | { 64 | return GetVirtual(this, 84)(this); 65 | } 66 | }; -------------------------------------------------------------------------------- /src/sdk/helpers/netvars.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Netvars.h" 4 | #include "../sdk.h" 5 | 6 | namespace netvars 7 | { 8 | void init() 9 | { 10 | std::vector netvar_modules = { "client.dll", "engine2.dll", "schemasystem.dll" }; 11 | 12 | for (const auto& module : netvar_modules) 13 | { 14 | const auto& netvar_class = g::schema_system->FindTypeScopeForModule(module); 15 | if (!netvar_class) 16 | continue; 17 | 18 | auto classes = netvar_class->GetClasses(); 19 | 20 | for (const auto& class_binding : classes.GetElements()) 21 | { 22 | const auto& class_info = netvar_class->FindDeclaredClass(class_binding->m_name); 23 | 24 | for (auto j = 0; j < class_info->m_fields_size; j++) 25 | { 26 | const auto& field = &class_info->m_fields[j]; 27 | 28 | if (!field) 29 | continue; 30 | 31 | char name_hashed[256]; 32 | 33 | strcpy_s(name_hashed, class_binding->m_name); 34 | strcat_s(name_hashed, "->"); 35 | strcat_s(name_hashed, field->m_name); 36 | 37 | const auto hash = fnv::hash_runtime(name_hashed); 38 | 39 | netvars_data[hash] = field->m_single_inheritance_offset; 40 | 41 | //if (!strstr(class_binding->m_name, "CEntityInstance")); 42 | //printf("DEBUG: %s->%s: 0x%p\n", class_binding->m_name, field->m_name, (uintptr_t)field->m_single_inheritance_offset); 43 | } 44 | } 45 | } 46 | } 47 | 48 | uintptr_t get_offset_by_hash_cached(const fnv::hash hash) 49 | { 50 | uintptr_t offset(0); 51 | 52 | if (!offset) 53 | offset = netvars_data[hash]; 54 | 55 | return offset; 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | // Size of each memory slot. 32 | #if defined(_M_X64) || defined(__x86_64__) 33 | #define MEMORY_SLOT_SIZE 64 34 | #else 35 | #define MEMORY_SLOT_SIZE 32 36 | #endif 37 | 38 | VOID InitializeBuffer(VOID); 39 | VOID UninitializeBuffer(VOID); 40 | LPVOID AllocateBuffer(LPVOID pOrigin); 41 | VOID FreeBuffer(LPVOID pBuffer); 42 | BOOL IsExecutableAddress(LPVOID pAddress); 43 | -------------------------------------------------------------------------------- /src/sdk/helpers/fnv.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define NOMINMAX 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "importer.h" 9 | 10 | namespace detail 11 | { 12 | class protect_guard 13 | { 14 | public: 15 | protect_guard(void* base, size_t len, std::uint32_t flags) 16 | { 17 | _base = base; 18 | _length = len; 19 | 20 | if (!LI_FN(VirtualProtect).cached()(base, len, flags, PDWORD(&_old))) 21 | throw std::runtime_error("Failed to protect region."); 22 | } 23 | ~protect_guard() 24 | { 25 | LI_FN(VirtualProtect).cached()(_base, _length, _old, PDWORD(&_old)); 26 | } 27 | 28 | private: 29 | void* _base; 30 | size_t _length; 31 | std::uint32_t _old; 32 | }; 33 | 34 | template 35 | struct size_dependant_data 36 | { 37 | using type = Type; 38 | constexpr static auto k_offset_basis = OffsetBasis; 39 | constexpr static auto k_prime = Prime; 40 | }; 41 | 42 | template 43 | struct size_selector; 44 | 45 | template <> 46 | struct size_selector<32> 47 | { 48 | using type = size_dependant_data; 49 | }; 50 | 51 | template <> 52 | struct size_selector<64> 53 | { 54 | using type = size_dependant_data; 55 | }; 56 | 57 | // Implements FNV-1a hash algorithm 58 | template 59 | class fnv_hash 60 | { 61 | private: 62 | using data_t = typename size_selector::type; 63 | 64 | public: 65 | using hash = typename data_t::type; 66 | 67 | private: 68 | constexpr static auto k_offset_basis = data_t::k_offset_basis; 69 | constexpr static auto k_prime = data_t::k_prime; 70 | 71 | public: 72 | template 73 | static __forceinline constexpr auto hash_constexpr(const char(&str)[N], const std::size_t size = N) -> hash 74 | { 75 | return static_cast(1ull * (size == 1 76 | ? (k_offset_basis ^ str[0]) 77 | : (hash_constexpr(str, size - 1) ^ str[size - 1])) * k_prime); 78 | } 79 | 80 | static auto __forceinline hash_runtime(const char* str) -> hash 81 | { 82 | auto result = k_offset_basis; 83 | do 84 | { 85 | result ^= *str++; 86 | result *= k_prime; 87 | } while (*(str - 1) != '\0'); 88 | 89 | return result; 90 | } 91 | }; 92 | } 93 | 94 | using fnv = ::detail::fnv_hash; 95 | 96 | #define FNV(str) (std::integral_constant::value) 97 | -------------------------------------------------------------------------------- /src/sdk/classes/CBasePlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../sdk/helpers/netvars.h" 3 | #include "../../sdk/helpers/vfunc.h" 4 | #include "../../sdk/math/Vector.h" 5 | #include "../../sdk/classes/CBaseEntity.h" 6 | #include "../../sdk/classes/CPlayerWeaponServices.h" 7 | 8 | //TODO: Rebuild the entity classes, since nonlocalplayer entities/players are CCSPlayerControllers 9 | 10 | class CCSPlayerController_InGameMoneyServices 11 | { 12 | public: 13 | NETVAR(int, m_iAccount, "CCSPlayerController_InGameMoneyServices", "m_iAccount"); 14 | }; 15 | 16 | class CBasePlayerPawn 17 | { 18 | public: 19 | NETVAR(CPlayerWeaponServices*, m_pWeaponServices, "C_BasePlayerPawn", "m_pWeaponServices"); 20 | NETVAR(Vector, m_vOldOrigin, "C_BasePlayerPawn", "m_vOldOrigin"); 21 | }; 22 | 23 | class CCSPlayerController { 24 | public: 25 | NETVAR(int, m_nFinalPredictedTick, "CBasePlayerController", "m_nFinalPredictedTick"); 26 | NETVAR(char*, m_iszPlayerName, "CBasePlayerCOntroller", "m_iszPlayerName"); 27 | NETVAR(uint64_t, m_steamID, "CBasePlayerController", "m_steamID"); 28 | NETVAR(bool, m_bIsLocalPlayerController, "CBasePlayerController", "m_bIsLocalPlayerController"); 29 | NETVAR(int, m_iDesiredFOV, "CBasePlayerController", "m_iDesiredFOV"); 30 | NETVAR(bool, m_bPawnIsAlive, "CCSPlayerController", "m_bPawnIsAlive"); 31 | NETVAR(const char*, m_sSanitizedPlayerName, "CCSPlayerController", "m_sSanitizedPlayerName"); 32 | }; 33 | 34 | class CBasePlayer : public CBaseEntity //Rebuild CBasePlayer class to CCSPlayerController? 35 | { 36 | public: 37 | NETVAR(const char*, m_iszPlayerName, "CBasePlayerController", "m_iszPlayerName"); 38 | NETVAR(uint32_t, m_fFlags, "C_BaseEntity", "m_fFlags"); 39 | NETVAR(void*, m_hGroundEntity, "C_BaseEntity", "m_hGroundEntity"); 40 | NETVAR(int, m_iShotsFired, "C_CSPlayerPawnBase", "m_iShotsFired"); 41 | NETVAR(Vector, m_aimPunchAngle, "C_CSPlayerPawn", "m_aimPunchAngle"); 42 | NETVAR(int, m_iEFlags, "C_BaseEntity", "m_iEFlags"); 43 | NETVAR(float, m_flFlashDuration, "C_CSPlayerPawnBase", "m_flFlashDuration"); 44 | NETVAR(int, m_iIDEntIndex, "C_CSPlayerPawnBase", "m_iIDEntIndex"); 45 | NETVAR(Vector, m_vOldOrigin, "C_BasePlayerPawn", "m_vOldOrigin"); 46 | 47 | NETVAR(CHandle, m_hPawn, "CBasePlayerController", "m_hPawn"); 48 | 49 | NETVAR(CPlayerWeaponServices*, m_pWeaponServices, "C_BasePlayerPawn", "m_pWeaponServices"); 50 | NETVAR(CCSPlayerController_InGameMoneyServices*, m_pInGameMoneyServices, "CCSPlayerController", "m_pInGameMoneyServices"); 51 | 52 | bool InAir(); 53 | bool IsAlive(); 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/hde32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 32 3 | * Copyright (c) 2006-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | * hde32.h: C/C++ header file 7 | * 8 | */ 9 | 10 | #ifndef _HDE32_H_ 11 | #define _HDE32_H_ 12 | 13 | /* stdint.h - C99 standard header 14 | * http://en.wikipedia.org/wiki/stdint.h 15 | * 16 | * if your compiler doesn't contain "stdint.h" header (for 17 | * example, Microsoft Visual C++), you can download file: 18 | * http://www.azillionmonkeys.com/qed/pstdint.h 19 | * and change next line to: 20 | * #include "pstdint.h" 21 | */ 22 | #include "pstdint.h" 23 | 24 | #define F_MODRM 0x00000001 25 | #define F_SIB 0x00000002 26 | #define F_IMM8 0x00000004 27 | #define F_IMM16 0x00000008 28 | #define F_IMM32 0x00000010 29 | #define F_DISP8 0x00000020 30 | #define F_DISP16 0x00000040 31 | #define F_DISP32 0x00000080 32 | #define F_RELATIVE 0x00000100 33 | #define F_2IMM16 0x00000800 34 | #define F_ERROR 0x00001000 35 | #define F_ERROR_OPCODE 0x00002000 36 | #define F_ERROR_LENGTH 0x00004000 37 | #define F_ERROR_LOCK 0x00008000 38 | #define F_ERROR_OPERAND 0x00010000 39 | #define F_PREFIX_REPNZ 0x01000000 40 | #define F_PREFIX_REPX 0x02000000 41 | #define F_PREFIX_REP 0x03000000 42 | #define F_PREFIX_66 0x04000000 43 | #define F_PREFIX_67 0x08000000 44 | #define F_PREFIX_LOCK 0x10000000 45 | #define F_PREFIX_SEG 0x20000000 46 | #define F_PREFIX_ANY 0x3f000000 47 | 48 | #define PREFIX_SEGMENT_CS 0x2e 49 | #define PREFIX_SEGMENT_SS 0x36 50 | #define PREFIX_SEGMENT_DS 0x3e 51 | #define PREFIX_SEGMENT_ES 0x26 52 | #define PREFIX_SEGMENT_FS 0x64 53 | #define PREFIX_SEGMENT_GS 0x65 54 | #define PREFIX_LOCK 0xf0 55 | #define PREFIX_REPNZ 0xf2 56 | #define PREFIX_REPX 0xf3 57 | #define PREFIX_OPERAND_SIZE 0x66 58 | #define PREFIX_ADDRESS_SIZE 0x67 59 | 60 | #pragma pack(push,1) 61 | 62 | typedef struct { 63 | uint8_t len; 64 | uint8_t p_rep; 65 | uint8_t p_lock; 66 | uint8_t p_seg; 67 | uint8_t p_66; 68 | uint8_t p_67; 69 | uint8_t opcode; 70 | uint8_t opcode2; 71 | uint8_t modrm; 72 | uint8_t modrm_mod; 73 | uint8_t modrm_reg; 74 | uint8_t modrm_rm; 75 | uint8_t sib; 76 | uint8_t sib_scale; 77 | uint8_t sib_index; 78 | uint8_t sib_base; 79 | union { 80 | uint8_t imm8; 81 | uint16_t imm16; 82 | uint32_t imm32; 83 | } imm; 84 | union { 85 | uint8_t disp8; 86 | uint16_t disp16; 87 | uint32_t disp32; 88 | } disp; 89 | uint32_t flags; 90 | } hde32s; 91 | 92 | #pragma pack(pop) 93 | 94 | #ifdef __cplusplus 95 | extern "C" { 96 | #endif 97 | 98 | /* __cdecl */ 99 | unsigned int hde32_disasm(const void *code, hde32s *hs); 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* _HDE32_H_ */ 106 | -------------------------------------------------------------------------------- /src/sdk/classes/CBoneSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../../sdk/classes/CStrongHandle.h" 6 | #include "../../sdk/helpers/CUtlSymbolLarge.hpp" 7 | #include "../../sdk/helpers/BitFlag.h" 8 | #include "../../sdk/helpers/modules.h" 9 | 10 | enum EBoneFlags : uint32_t 11 | { 12 | FLAG_NO_BONE_FLAGS = 0x0, 13 | FLAG_BONEFLEXDRIVER = 0x4, 14 | FLAG_CLOTH = 0x8, 15 | FLAG_PHYSICS = 0x10, 16 | FLAG_ATTACHMENT = 0x20, 17 | FLAG_ANIMATION = 0x40, 18 | FLAG_MESH = 0x80, 19 | FLAG_HITBOX = 0x100, 20 | FLAG_BONE_USED_BY_VERTEX_LOD0 = 0x400, 21 | FLAG_BONE_USED_BY_VERTEX_LOD1 = 0x800, 22 | FLAG_BONE_USED_BY_VERTEX_LOD2 = 0x1000, 23 | FLAG_BONE_USED_BY_VERTEX_LOD3 = 0x2000, 24 | FLAG_BONE_USED_BY_VERTEX_LOD4 = 0x4000, 25 | FLAG_BONE_USED_BY_VERTEX_LOD5 = 0x8000, 26 | FLAG_BONE_USED_BY_VERTEX_LOD6 = 0x10000, 27 | FLAG_BONE_USED_BY_VERTEX_LOD7 = 0x20000, 28 | FLAG_BONE_MERGE_READ = 0x40000, 29 | FLAG_BONE_MERGE_WRITE = 0x80000, 30 | FLAG_ALL_BONE_FLAGS = 0xfffff, 31 | BLEND_PREALIGNED = 0x100000, 32 | FLAG_RIGIDLENGTH = 0x200000, 33 | FLAG_PROCEDURAL = 0x400000, 34 | }; 35 | 36 | struct alignas(16) CBoneData 37 | { 38 | Vector position; 39 | float scale; 40 | Vector rotation; 41 | }; 42 | 43 | class CModel 44 | { 45 | public: 46 | BitFlag GetBoneFlags(const int index) 47 | { 48 | using fn = int(__thiscall*)(void*, int); //int -> BitFlag? 49 | 50 | static auto addr = modules::client.pattern_scanner.scan("85 D2 78 16 3B 91").as(); 51 | 52 | const auto& get_bone_flags = reinterpret_cast(addr); 53 | 54 | if (get_bone_flags) 55 | return BitFlag(get_bone_flags(this, index)); 56 | 57 | return {}; 58 | } 59 | 60 | int GetBoneParent(const int index) 61 | { 62 | using fn = int(__thiscall*)(void*, int); 63 | 64 | static auto addr = modules::client.pattern_scanner.scan("85 D2 78 17 3B 91 70").as(); 65 | 66 | const auto& get_bone_parent = reinterpret_cast(addr); 67 | 68 | if (get_bone_parent) 69 | return get_bone_parent(this, index); 70 | 71 | return {}; //MJ: Probably better to return -1 ? 72 | } 73 | 74 | const char* GetBoneName(const std::int32_t index) 75 | { 76 | using fn = const char* (__thiscall*)(void*, int); 77 | 78 | static auto addr = modules::client.pattern_scanner.scan("85 D2 78 25 3B 91").as(); 79 | 80 | const auto& get_bone_name = reinterpret_cast(addr); 81 | 82 | if (get_bone_name) 83 | return get_bone_name(this, index); 84 | 85 | return nullptr; 86 | } 87 | 88 | public: 89 | std::uint8_t padding_0[0x170]; 90 | std::int32_t BoneCount; 91 | }; 92 | 93 | class CModelState 94 | { 95 | public: 96 | std::uint8_t padding_0[0x80]; 97 | CBoneData* bones; 98 | std::uint8_t padding_1[0x18]; 99 | CStrongHandle modelHandle; 100 | CUtlSymbolLarge modelName; 101 | }; 102 | 103 | -------------------------------------------------------------------------------- /src/sdk/math/Vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Vector 7 | { 8 | public: 9 | 10 | Vector() : x(0.f), y(0.f), z(0.f) { }; 11 | Vector(float _x, float _y) : x(_x), y(_y), z(0.f) { }; 12 | Vector(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { }; 13 | 14 | 15 | float length() const 16 | { 17 | return std::sqrtf(x * x + y * y + z * z); 18 | } 19 | 20 | void normalize() 21 | { 22 | float length = this->length(); 23 | 24 | if (length != 0) 25 | *this /= length; 26 | } 27 | 28 | std::string ToString() 29 | { 30 | auto str = std::format("x: {:.2f}, y: {:.2f}, z: {:.2f}", x, y, z); 31 | 32 | return str; 33 | } 34 | 35 | float operator[](const size_t& index) 36 | { 37 | switch (index) 38 | { 39 | case 0: 40 | return x; 41 | break; 42 | case 1: 43 | return y; 44 | break; 45 | case 2: 46 | return z; 47 | break; 48 | } 49 | } 50 | 51 | Vector operator+(const Vector& other) 52 | { 53 | Vector& temp = *this; 54 | 55 | temp = Vector(temp.x + other.x, temp.y + other.y, temp.z + other.z); 56 | 57 | return temp; 58 | } 59 | 60 | Vector& operator+=(const Vector& other) 61 | { 62 | x += other.x; 63 | y += other.y; 64 | z += other.z; 65 | 66 | return *this; 67 | } 68 | 69 | Vector& operator+=(const float& value) 70 | { 71 | x += value; 72 | y += value; 73 | z += value; 74 | 75 | return *this; 76 | } 77 | 78 | Vector operator-(const Vector& other) 79 | { 80 | Vector& temp = *this; 81 | 82 | temp = Vector(temp.x - other.x, temp.y - other.y, temp.z - other.z); 83 | 84 | return temp; 85 | } 86 | 87 | Vector& operator-=(const Vector& other) 88 | { 89 | x -= other.x; 90 | y -= other.y; 91 | z -= other.z; 92 | 93 | return *this; 94 | } 95 | 96 | Vector& operator-=(const float& value) 97 | { 98 | x -= value; 99 | y -= value; 100 | z -= value; 101 | 102 | return *this; 103 | } 104 | 105 | Vector operator*(const Vector& other) 106 | { 107 | Vector& temp = *this; 108 | 109 | temp = Vector(temp.x * other.x, temp.y * other.y, temp.z * other.z); 110 | 111 | return temp; 112 | } 113 | 114 | Vector& operator*=(const Vector& other) 115 | { 116 | x *= other.x; 117 | y *= other.y; 118 | z *= other.z; 119 | 120 | return *this; 121 | } 122 | 123 | Vector operator*=(const float& value) 124 | { 125 | x *= value; 126 | y *= value; 127 | z *= value; 128 | 129 | return *this; 130 | } 131 | 132 | Vector operator/(const Vector& other) 133 | { 134 | Vector& temp = *this; 135 | 136 | temp = Vector(temp.x / other.x, temp.y / other.y, temp.z / other.z); 137 | 138 | return temp; 139 | } 140 | 141 | Vector& operator/=(const Vector& other) 142 | { 143 | x /= other.x; 144 | y /= other.y; 145 | z /= other.z; 146 | 147 | return *this; 148 | } 149 | 150 | Vector& operator/=(const float& value) 151 | { 152 | x /= value; 153 | y /= value; 154 | z /= value; 155 | 156 | return *this; 157 | } 158 | 159 | float x; 160 | float y; 161 | float z; 162 | }; 163 | 164 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/hde64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 64 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | * hde64.h: C/C++ header file 7 | * 8 | */ 9 | 10 | #ifndef _HDE64_H_ 11 | #define _HDE64_H_ 12 | 13 | /* stdint.h - C99 standard header 14 | * http://en.wikipedia.org/wiki/stdint.h 15 | * 16 | * if your compiler doesn't contain "stdint.h" header (for 17 | * example, Microsoft Visual C++), you can download file: 18 | * http://www.azillionmonkeys.com/qed/pstdint.h 19 | * and change next line to: 20 | * #include "pstdint.h" 21 | */ 22 | #include "pstdint.h" 23 | 24 | #define F_MODRM 0x00000001 25 | #define F_SIB 0x00000002 26 | #define F_IMM8 0x00000004 27 | #define F_IMM16 0x00000008 28 | #define F_IMM32 0x00000010 29 | #define F_IMM64 0x00000020 30 | #define F_DISP8 0x00000040 31 | #define F_DISP16 0x00000080 32 | #define F_DISP32 0x00000100 33 | #define F_RELATIVE 0x00000200 34 | #define F_ERROR 0x00001000 35 | #define F_ERROR_OPCODE 0x00002000 36 | #define F_ERROR_LENGTH 0x00004000 37 | #define F_ERROR_LOCK 0x00008000 38 | #define F_ERROR_OPERAND 0x00010000 39 | #define F_PREFIX_REPNZ 0x01000000 40 | #define F_PREFIX_REPX 0x02000000 41 | #define F_PREFIX_REP 0x03000000 42 | #define F_PREFIX_66 0x04000000 43 | #define F_PREFIX_67 0x08000000 44 | #define F_PREFIX_LOCK 0x10000000 45 | #define F_PREFIX_SEG 0x20000000 46 | #define F_PREFIX_REX 0x40000000 47 | #define F_PREFIX_ANY 0x7f000000 48 | 49 | #define PREFIX_SEGMENT_CS 0x2e 50 | #define PREFIX_SEGMENT_SS 0x36 51 | #define PREFIX_SEGMENT_DS 0x3e 52 | #define PREFIX_SEGMENT_ES 0x26 53 | #define PREFIX_SEGMENT_FS 0x64 54 | #define PREFIX_SEGMENT_GS 0x65 55 | #define PREFIX_LOCK 0xf0 56 | #define PREFIX_REPNZ 0xf2 57 | #define PREFIX_REPX 0xf3 58 | #define PREFIX_OPERAND_SIZE 0x66 59 | #define PREFIX_ADDRESS_SIZE 0x67 60 | 61 | #pragma pack(push,1) 62 | 63 | typedef struct { 64 | uint8_t len; 65 | uint8_t p_rep; 66 | uint8_t p_lock; 67 | uint8_t p_seg; 68 | uint8_t p_66; 69 | uint8_t p_67; 70 | uint8_t rex; 71 | uint8_t rex_w; 72 | uint8_t rex_r; 73 | uint8_t rex_x; 74 | uint8_t rex_b; 75 | uint8_t opcode; 76 | uint8_t opcode2; 77 | uint8_t modrm; 78 | uint8_t modrm_mod; 79 | uint8_t modrm_reg; 80 | uint8_t modrm_rm; 81 | uint8_t sib; 82 | uint8_t sib_scale; 83 | uint8_t sib_index; 84 | uint8_t sib_base; 85 | union { 86 | uint8_t imm8; 87 | uint16_t imm16; 88 | uint32_t imm32; 89 | uint64_t imm64; 90 | } imm; 91 | union { 92 | uint8_t disp8; 93 | uint16_t disp16; 94 | uint32_t disp32; 95 | } disp; 96 | uint32_t flags; 97 | } hde64s; 98 | 99 | #pragma pack(pop) 100 | 101 | #ifdef __cplusplus 102 | extern "C" { 103 | #endif 104 | 105 | /* __cdecl */ 106 | unsigned int hde64_disasm(const void *code, hde64s *hs); 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* _HDE64_H_ */ 113 | -------------------------------------------------------------------------------- /src/sdk/interfaces/GameEntitySystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../classes/CEntityInstance.h" 3 | #include "../helpers/modules.h" 4 | #include "../classes/CBaseEntity.h" 5 | 6 | #include 7 | //#include "../classes/CHandle.h" 8 | 9 | class CCSPlayerController; 10 | class CBasePlayer; 11 | 12 | class CGameEntitySystem 13 | { 14 | public: 15 | CBaseEntity* GetBaseEntity(uint32_t index) 16 | { 17 | uint64_t entity; 18 | 19 | uint64_t temp_entity_ptr = *(uint64_t*)(this + 0x8 * (index >> 9) + 0x10); 20 | 21 | if (!temp_entity_ptr) 22 | return nullptr; 23 | 24 | int64_t temp_entity = 0x78 * (index & 0x1FF) + temp_entity_ptr; 25 | 26 | if (!temp_entity) 27 | return nullptr; 28 | 29 | uint32_t entity_index = (*(uint32_t*)(temp_entity + 0x10) & 0x7FFF); 30 | 31 | if (index <= 0x7FFE && (index >> 9) <= 0x3F && temp_entity_ptr && temp_entity && entity_index == index) 32 | entity = *(uint64_t*)temp_entity; 33 | else entity = 0; 34 | 35 | /*if (entity && reinterpret_cast(entity)->IsBasePlayerController()) 36 | printf("entity_index: %d\n", entity_index);*/ 37 | 38 | return reinterpret_cast(entity); 39 | } 40 | 41 | CCSPlayerController* GetEntityController(int index) 42 | { 43 | static auto func = reinterpret_cast(modules::client.pattern_scanner.scan("81 FA FE 7F 00 00 77 36").as()); 44 | 45 | return func(this, index); 46 | } 47 | 48 | CBasePlayer* GetPlayerPawn(CCSPlayerController* controlller) 49 | { 50 | static auto func = reinterpret_cast(modules::client.pattern_scanner.scan("81 FA ? ? ? ? 77 3B 8B C2").as()); 51 | 52 | return func(controlller); 53 | } 54 | 55 | /*CBaseEntity* GetBaseEntity(int index) 56 | { 57 | using fn = CBaseEntity*(__thiscall*)(void*, int); 58 | 59 | static const auto& addr = modules::client.pattern_scan("8B D3 E8 ? ? ? ? 48 8B F8 48 85 C0 74 76"); 60 | 61 | if (!addr) 62 | return nullptr; 63 | 64 | //DynamicModule::resolve_rip_copy(addr, 3, 0); 65 | 66 | auto rip_offset = DynamicModule::resolve_rip(addr, 0x3, std::nullopt); 67 | 68 | if (!rip_offset) 69 | return nullptr; 70 | 71 | auto get_base_entity_fn = reinterpret_cast(rip_offset); 72 | 73 | if (!get_base_entity_fn) 74 | return nullptr; 75 | 76 | const auto& base_entity = get_base_entity_fn(this, index); 77 | 78 | return base_entity; 79 | }*/ 80 | 81 | CEntityInstance* FindEntityByName(const char* name) 82 | { 83 | return GetVirtual(this, 12)(this, name); 84 | } 85 | 86 | CEntityInstance* OnAddEntity(CEntityInstance* entity_instance, void* handle) 87 | { 88 | return GetVirtual(this, 14)(this, entity_instance, handle); 89 | } 90 | 91 | CEntityInstance* OnRemoveEntity(CEntityInstance* entity_instance, void* handle) 92 | { 93 | return GetVirtual(this, 15)(this, entity_instance, handle); 94 | } 95 | 96 | int GetHighestEntityIndex() 97 | { 98 | return *reinterpret_cast(this + 0x1510); 99 | } 100 | }; 101 | -------------------------------------------------------------------------------- /src/sdk/sdk.cpp: -------------------------------------------------------------------------------- 1 | #include "sdk.h" 2 | #include "../sdk/helpers/modules.h" 3 | #include "../hooks/hooks.h" 4 | 5 | #include 6 | 7 | void print_status(const char* name, void* ptr) 8 | { 9 | printf("%s: 0x%p\n", name, ptr); 10 | } 11 | 12 | namespace sdk 13 | { 14 | inline ID3D11Device* device; 15 | bool sub_tick; 16 | c_usercmd* user_cmd; 17 | c_base_usercmd* base_user_cmd; 18 | inline ID3D11DeviceContext* context; 19 | inline ID3D11RenderTargetView* render_target_view; 20 | 21 | VMatrix* viewmatrix; 22 | 23 | bool can_unhook = false; 24 | 25 | bool world_to_screen(const Vector& pos, Vector& out) 26 | { 27 | if (!viewmatrix) 28 | return false; 29 | 30 | out.x = viewmatrix->m[0][0] * pos.x + viewmatrix->m[0][1] * pos.y + viewmatrix->m[0][2] * pos.z + viewmatrix->m[0][3]; 31 | out.y = viewmatrix->m[1][0] * pos.x + viewmatrix->m[1][1] * pos.y + viewmatrix->m[1][2] * pos.z + viewmatrix->m[1][3]; 32 | 33 | float w = viewmatrix->m[3][0] * pos.x + viewmatrix->m[3][1] * pos.y + viewmatrix->m[3][2] * pos.z + viewmatrix->m[3][3]; 34 | 35 | if (w < 0.01f) 36 | return false; 37 | 38 | float inv_w = 1.f / w; 39 | out.x *= inv_w; 40 | out.y *= inv_w; 41 | 42 | int width, height; 43 | g::engine_client->GetScreenSize(width, height); 44 | 45 | float x = width * .5f; 46 | float y = height * .5f; 47 | 48 | x += 0.5f * out.x * width + 0.5f; 49 | y -= 0.5f * out.y * height + 0.5f; 50 | 51 | out.x = x; 52 | out.y = y; 53 | 54 | return true; 55 | } 56 | 57 | void init_modules() 58 | { 59 | modules::client = DynamicModule("client.dll"); 60 | modules::nav_system = DynamicModule("navsystem.dll"); 61 | modules::engine = DynamicModule("engine2.dll"); 62 | modules::schema = DynamicModule("schemasystem.dll"); 63 | modules::tier0 = DynamicModule("tier0.dll"); 64 | modules::render_dx11 = DynamicModule("rendersystemdx11.dll"); 65 | 66 | } 67 | 68 | void init_interfaces() 69 | { 70 | g::engine_client = modules::engine.GetInterfaceFromList("Source2EngineToClient001"); 71 | g::schema_system = modules::schema.GetInterfaceFromList("SchemaSystem_001"); 72 | g::game_resource_service = modules::engine.GetInterfaceFromList("GameResourceServiceClientV001"); 73 | 74 | g::csgo_input = g::csgo_input->get(); 75 | g::entity_system = g::game_resource_service->GetGameEntitySystem(); 76 | g::render_system = **reinterpret_cast(modules::render_dx11.pattern_scanner.scan("66 0F 7F 05 ? ? ? ? 66 0F 7F 0D ? ? ? ? 48 89 35 ? ? ? ?").add(4).abs().as()); 77 | 78 | if (g::render_system) 79 | g::swap_chain = g::render_system->swap_chain; 80 | 81 | g::mem_alloc = *reinterpret_cast(modules::tier0.GetExport("g_pMemAlloc")); 82 | 83 | printf("Interfaces info:\n"); 84 | print_status("engine_client", g::engine_client); 85 | print_status("schema_system", g::schema_system); 86 | print_status("mem_alloc", g::mem_alloc); 87 | print_status("game_resource_service", g::game_resource_service); 88 | print_status("entity_system", g::entity_system); 89 | print_status("csgo_input", g::entity_system); 90 | print_status("render_system", g::render_system); 91 | print_status("swap_chain", g::swap_chain); 92 | printf("\n"); 93 | } 94 | } 95 | 96 | namespace interfaces 97 | { 98 | IVEngineClient* engine_client{}; 99 | CSchemaSystem* schema_system{}; 100 | IMemAlloc* mem_alloc{}; 101 | CGameResourceService* game_resource_service{}; 102 | CGameEntitySystem* entity_system{}; 103 | c_csgo_input* csgo_input{}; 104 | CRenderSystem* render_system{}; 105 | IDXGISwapChain* swap_chain{}; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/table32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 32 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #define C_NONE 0x00 9 | #define C_MODRM 0x01 10 | #define C_IMM8 0x02 11 | #define C_IMM16 0x04 12 | #define C_IMM_P66 0x10 13 | #define C_REL8 0x20 14 | #define C_REL32 0x40 15 | #define C_GROUP 0x80 16 | #define C_ERROR 0xff 17 | 18 | #define PRE_ANY 0x00 19 | #define PRE_NONE 0x01 20 | #define PRE_F2 0x02 21 | #define PRE_F3 0x04 22 | #define PRE_66 0x08 23 | #define PRE_67 0x10 24 | #define PRE_LOCK 0x20 25 | #define PRE_SEG 0x40 26 | #define PRE_ALL 0xff 27 | 28 | #define DELTA_OPCODES 0x4a 29 | #define DELTA_FPU_REG 0xf1 30 | #define DELTA_FPU_MODRM 0xf8 31 | #define DELTA_PREFIXES 0x130 32 | #define DELTA_OP_LOCK_OK 0x1a1 33 | #define DELTA_OP2_LOCK_OK 0x1b9 34 | #define DELTA_OP_ONLY_MEM 0x1cb 35 | #define DELTA_OP2_ONLY_MEM 0x1da 36 | 37 | unsigned char hde32_table[] = { 38 | 0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3, 39 | 0xa8,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xac,0xaa,0xb2,0xaa,0x9f,0x9f, 40 | 0x9f,0x9f,0xb5,0xa3,0xa3,0xa4,0xaa,0xaa,0xba,0xaa,0x96,0xaa,0xa8,0xaa,0xc3, 41 | 0xc3,0x96,0x96,0xb7,0xae,0xd6,0xbd,0xa3,0xc5,0xa3,0xa3,0x9f,0xc3,0x9c,0xaa, 42 | 0xaa,0xac,0xaa,0xbf,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0x90, 43 | 0x82,0x7d,0x97,0x59,0x59,0x59,0x59,0x59,0x7f,0x59,0x59,0x60,0x7d,0x7f,0x7f, 44 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x9a,0x88,0x7d, 45 | 0x59,0x50,0x50,0x50,0x50,0x59,0x59,0x59,0x59,0x61,0x94,0x61,0x9e,0x59,0x59, 46 | 0x85,0x59,0x92,0xa3,0x60,0x60,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59, 47 | 0x59,0x59,0x9f,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xcc,0x01,0xbc,0x03,0xf0, 48 | 0x10,0x10,0x10,0x10,0x50,0x50,0x50,0x50,0x14,0x20,0x20,0x20,0x20,0x01,0x01, 49 | 0x01,0x01,0xc4,0x02,0x10,0x00,0x00,0x00,0x00,0x01,0x01,0xc0,0xc2,0x10,0x11, 50 | 0x02,0x03,0x11,0x03,0x03,0x04,0x00,0x00,0x14,0x00,0x02,0x00,0x00,0xc6,0xc8, 51 | 0x02,0x02,0x02,0x02,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xca, 52 | 0x01,0x01,0x01,0x00,0x06,0x00,0x04,0x00,0xc0,0xc2,0x01,0x01,0x03,0x01,0xff, 53 | 0xff,0x01,0x00,0x03,0xc4,0xc4,0xc6,0x03,0x01,0x01,0x01,0xff,0x03,0x03,0x03, 54 | 0xc8,0x40,0x00,0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00, 55 | 0x00,0x00,0x00,0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00, 56 | 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 57 | 0x00,0xff,0xff,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 58 | 0x7f,0x00,0x00,0xff,0x4a,0x4a,0x4a,0x4a,0x4b,0x52,0x4a,0x4a,0x4a,0x4a,0x4f, 59 | 0x4c,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x55,0x45,0x40,0x4a,0x4a,0x4a, 60 | 0x45,0x59,0x4d,0x46,0x4a,0x5d,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a, 61 | 0x4a,0x4a,0x4a,0x4a,0x4a,0x61,0x63,0x67,0x4e,0x4a,0x4a,0x6b,0x6d,0x4a,0x4a, 62 | 0x45,0x6d,0x4a,0x4a,0x44,0x45,0x4a,0x4a,0x00,0x00,0x00,0x02,0x0d,0x06,0x06, 63 | 0x06,0x06,0x0e,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x00,0x06,0x06,0x02,0x06, 64 | 0x00,0x0a,0x0a,0x07,0x07,0x06,0x02,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04, 65 | 0x04,0x04,0x00,0x00,0x00,0x0e,0x05,0x06,0x06,0x06,0x01,0x06,0x00,0x00,0x08, 66 | 0x00,0x10,0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01, 67 | 0x86,0x00,0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba, 68 | 0xf8,0xbb,0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00, 69 | 0xc4,0xff,0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00, 70 | 0x13,0x09,0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07, 71 | 0xb2,0xff,0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf, 72 | 0xe7,0x08,0x00,0xf0,0x02,0x00 73 | }; 74 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/table64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 64 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #define C_NONE 0x00 9 | #define C_MODRM 0x01 10 | #define C_IMM8 0x02 11 | #define C_IMM16 0x04 12 | #define C_IMM_P66 0x10 13 | #define C_REL8 0x20 14 | #define C_REL32 0x40 15 | #define C_GROUP 0x80 16 | #define C_ERROR 0xff 17 | 18 | #define PRE_ANY 0x00 19 | #define PRE_NONE 0x01 20 | #define PRE_F2 0x02 21 | #define PRE_F3 0x04 22 | #define PRE_66 0x08 23 | #define PRE_67 0x10 24 | #define PRE_LOCK 0x20 25 | #define PRE_SEG 0x40 26 | #define PRE_ALL 0xff 27 | 28 | #define DELTA_OPCODES 0x4a 29 | #define DELTA_FPU_REG 0xfd 30 | #define DELTA_FPU_MODRM 0x104 31 | #define DELTA_PREFIXES 0x13c 32 | #define DELTA_OP_LOCK_OK 0x1ae 33 | #define DELTA_OP2_LOCK_OK 0x1c6 34 | #define DELTA_OP_ONLY_MEM 0x1d8 35 | #define DELTA_OP2_ONLY_MEM 0x1e7 36 | 37 | unsigned char hde64_table[] = { 38 | 0xa5,0xaa,0xa5,0xb8,0xa5,0xaa,0xa5,0xaa,0xa5,0xb8,0xa5,0xb8,0xa5,0xb8,0xa5, 39 | 0xb8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xac,0xc0,0xcc,0xc0,0xa1,0xa1, 40 | 0xa1,0xa1,0xb1,0xa5,0xa5,0xa6,0xc0,0xc0,0xd7,0xda,0xe0,0xc0,0xe4,0xc0,0xea, 41 | 0xea,0xe0,0xe0,0x98,0xc8,0xee,0xf1,0xa5,0xd3,0xa5,0xa5,0xa1,0xea,0x9e,0xc0, 42 | 0xc0,0xc2,0xc0,0xe6,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0xab, 43 | 0x8b,0x90,0x64,0x5b,0x5b,0x5b,0x5b,0x5b,0x92,0x5b,0x5b,0x76,0x90,0x92,0x92, 44 | 0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x6a,0x73,0x90, 45 | 0x5b,0x52,0x52,0x52,0x52,0x5b,0x5b,0x5b,0x5b,0x77,0x7c,0x77,0x85,0x5b,0x5b, 46 | 0x70,0x5b,0x7a,0xaf,0x76,0x76,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b, 47 | 0x5b,0x5b,0x86,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xd5,0x03,0xcc,0x01,0xbc, 48 | 0x03,0xf0,0x03,0x03,0x04,0x00,0x50,0x50,0x50,0x50,0xff,0x20,0x20,0x20,0x20, 49 | 0x01,0x01,0x01,0x01,0xc4,0x02,0x10,0xff,0xff,0xff,0x01,0x00,0x03,0x11,0xff, 50 | 0x03,0xc4,0xc6,0xc8,0x02,0x10,0x00,0xff,0xcc,0x01,0x01,0x01,0x00,0x00,0x00, 51 | 0x00,0x01,0x01,0x03,0x01,0xff,0xff,0xc0,0xc2,0x10,0x11,0x02,0x03,0x01,0x01, 52 | 0x01,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x10, 53 | 0x10,0x10,0x10,0x02,0x10,0x00,0x00,0xc6,0xc8,0x02,0x02,0x02,0x02,0x06,0x00, 54 | 0x04,0x00,0x02,0xff,0x00,0xc0,0xc2,0x01,0x01,0x03,0x03,0x03,0xca,0x40,0x00, 55 | 0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00,0x00,0x00,0x00, 56 | 0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xff,0x00, 57 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff, 58 | 0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00, 59 | 0xff,0x40,0x40,0x40,0x40,0x41,0x49,0x40,0x40,0x40,0x40,0x4c,0x42,0x40,0x40, 60 | 0x40,0x40,0x40,0x40,0x40,0x40,0x4f,0x44,0x53,0x40,0x40,0x40,0x44,0x57,0x43, 61 | 0x5c,0x40,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, 62 | 0x40,0x40,0x64,0x66,0x6e,0x6b,0x40,0x40,0x6a,0x46,0x40,0x40,0x44,0x46,0x40, 63 | 0x40,0x5b,0x44,0x40,0x40,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x01,0x06, 64 | 0x06,0x02,0x06,0x06,0x00,0x06,0x00,0x0a,0x0a,0x00,0x00,0x00,0x02,0x07,0x07, 65 | 0x06,0x02,0x0d,0x06,0x06,0x06,0x0e,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04, 66 | 0x04,0x04,0x05,0x06,0x06,0x06,0x00,0x00,0x00,0x0e,0x00,0x00,0x08,0x00,0x10, 67 | 0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01,0x86,0x00, 68 | 0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba,0xf8,0xbb, 69 | 0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00,0xc4,0xff, 70 | 0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00,0x13,0x09, 71 | 0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07,0xb2,0xff, 72 | 0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,0xe7,0x08, 73 | 0x00,0xf0,0x02,0x00 74 | }; 75 | -------------------------------------------------------------------------------- /src/hooks/hooks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../sdk/hooking/minhook/MinHook.h" 3 | #include "../sdk/classes/CEntityInstance.h" 4 | #include "../sdk/classes/CHandle.h" 5 | #include "../sdk/math/Viewmatrix.h" 6 | #include "../sdk/sdk.h" 7 | #include 8 | 9 | class CDetourHook { 10 | void* function; 11 | void* detour; 12 | void* trampoline; 13 | public: 14 | void hook(void* target, void* dtr) { 15 | function = target; 16 | detour = dtr; 17 | 18 | MH_CreateHook(function, detour, &trampoline); 19 | } 20 | 21 | void hook(uintptr_t target, void* dtr) { 22 | hook((void*)target, dtr); 23 | } 24 | 25 | template 26 | tOriginal get_original() { 27 | return reinterpret_cast(trampoline); 28 | } 29 | 30 | void unhook() { 31 | if (!function || !detour) 32 | return; 33 | 34 | MH_DisableHook(function); 35 | MH_RemoveHook(function); 36 | } 37 | }; 38 | 39 | template 40 | inline tFunc get_vfunction(void* class_ptr, int index) { 41 | void** __vfptr = *reinterpret_cast(class_ptr); 42 | return reinterpret_cast(__vfptr[index]); 43 | } 44 | 45 | namespace hooks 46 | { 47 | bool init(); 48 | bool detach(); 49 | 50 | namespace wndproc 51 | { 52 | inline WNDPROC original; 53 | LRESULT __stdcall hooked(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); 54 | } 55 | 56 | struct should_draw_player 57 | { 58 | using fn = bool(__fastcall*)(void*); 59 | static bool __fastcall hooked(void* player_pawn); 60 | 61 | inline static fn original_fn; 62 | }; 63 | 64 | struct create_move 65 | { 66 | static const int index = 5; 67 | using fn = void(__fastcall*)(c_csgo_input*, int, bool, bool); 68 | static void __fastcall hooked( c_csgo_input* input, int slot, bool unk, bool sub_tick); 69 | 70 | inline static fn original_fn; 71 | }; 72 | 73 | struct on_add_entity 74 | { 75 | static const int index = 14; 76 | using fn = CEntityInstance*(__thiscall*)(void*, CEntityInstance*, CHandle); 77 | static CEntityInstance* __fastcall hooked(void* rcx, CEntityInstance* instance, CHandle handle); 78 | 79 | inline static fn original_fn; 80 | }; 81 | 82 | struct on_remove_entity 83 | { 84 | static const int index = 15; 85 | using fn = CEntityInstance * (__thiscall*)(void*, CEntityInstance*, CHandle); 86 | static CEntityInstance* __fastcall hooked(void* rcx, CEntityInstance* instance, CHandle handle); 87 | 88 | inline static fn original_fn; 89 | }; 90 | 91 | struct present 92 | { 93 | static const int index = 8; 94 | using fn = long(__stdcall*)(void*, uint32_t, uint32_t); 95 | static long __stdcall hooked(IDXGISwapChain* swap_chain, uint32_t sync_interval, uint32_t flags); 96 | 97 | inline static fn original_fn; 98 | }; 99 | 100 | struct resize_buffers 101 | { 102 | static const int index = 13; 103 | using fn = long(__stdcall*)(void*, uint32_t, uint32_t, uint32_t, DXGI_FORMAT, uint32_t); 104 | static long __stdcall hooked(IDXGISwapChain* swap_chain, uint32_t buffer_count, uint32_t width, uint32_t height, DXGI_FORMAT new_format, uint32_t swap_chain_flags); 105 | 106 | inline static fn original_fn; 107 | }; 108 | 109 | struct frame_stage_notify 110 | { 111 | using fn = void(__fastcall*)(void*, int); 112 | static void __fastcall hooked(void* a1, int stage); 113 | 114 | inline static fn original_fn; 115 | }; 116 | 117 | struct fov_changer_test 118 | { 119 | using fn = float(__fastcall*)(void*); 120 | static float __fastcall hooked(void* camera); 121 | 122 | inline static fn original_fn; 123 | }; 124 | 125 | struct get_matrices_for_view 126 | { 127 | using fn = void(__fastcall*)(void*, void* rdx, VMatrix* world_to_view, VMatrix* view_to_projection, VMatrix* world_to_projection, VMatrix* world_to_pixels); 128 | static void __fastcall hooked(void* rcx, void* rdx, VMatrix* world_to_view, VMatrix* view_to_projection, VMatrix* world_to_projection, VMatrix* world_to_pixels); 129 | 130 | inline static fn original_fn; 131 | }; 132 | 133 | extern ID3D11Device* device; 134 | extern ID3D11DeviceContext* context; 135 | extern ID3D11RenderTargetView* render_target_view; 136 | extern ID3D11Texture2D* back_buffer; 137 | extern HWND window; 138 | } 139 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/trampoline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #pragma pack(push, 1) 32 | 33 | // Structs for writing x86/x64 instructions. 34 | 35 | // 8-bit relative jump. 36 | typedef struct _JMP_REL_SHORT 37 | { 38 | UINT8 opcode; // EB xx: JMP +2+xx 39 | UINT8 operand; 40 | } JMP_REL_SHORT, *PJMP_REL_SHORT; 41 | 42 | // 32-bit direct relative jump/call. 43 | typedef struct _JMP_REL 44 | { 45 | UINT8 opcode; // E9/E8 xxxxxxxx: JMP/CALL +5+xxxxxxxx 46 | UINT32 operand; // Relative destination address 47 | } JMP_REL, *PJMP_REL, CALL_REL; 48 | 49 | // 64-bit indirect absolute jump. 50 | typedef struct _JMP_ABS 51 | { 52 | UINT8 opcode0; // FF25 00000000: JMP [+6] 53 | UINT8 opcode1; 54 | UINT32 dummy; 55 | UINT64 address; // Absolute destination address 56 | } JMP_ABS, *PJMP_ABS; 57 | 58 | // 64-bit indirect absolute call. 59 | typedef struct _CALL_ABS 60 | { 61 | UINT8 opcode0; // FF15 00000002: CALL [+6] 62 | UINT8 opcode1; 63 | UINT32 dummy0; 64 | UINT8 dummy1; // EB 08: JMP +10 65 | UINT8 dummy2; 66 | UINT64 address; // Absolute destination address 67 | } CALL_ABS; 68 | 69 | // 32-bit direct relative conditional jumps. 70 | typedef struct _JCC_REL 71 | { 72 | UINT8 opcode0; // 0F8* xxxxxxxx: J** +6+xxxxxxxx 73 | UINT8 opcode1; 74 | UINT32 operand; // Relative destination address 75 | } JCC_REL; 76 | 77 | // 64bit indirect absolute conditional jumps that x64 lacks. 78 | typedef struct _JCC_ABS 79 | { 80 | UINT8 opcode; // 7* 0E: J** +16 81 | UINT8 dummy0; 82 | UINT8 dummy1; // FF25 00000000: JMP [+6] 83 | UINT8 dummy2; 84 | UINT32 dummy3; 85 | UINT64 address; // Absolute destination address 86 | } JCC_ABS; 87 | 88 | #pragma pack(pop) 89 | 90 | typedef struct _TRAMPOLINE 91 | { 92 | LPVOID pTarget; // [In] Address of the target function. 93 | LPVOID pDetour; // [In] Address of the detour function. 94 | LPVOID pTrampoline; // [In] Buffer address for the trampoline and relay function. 95 | 96 | #if defined(_M_X64) || defined(__x86_64__) 97 | LPVOID pRelay; // [Out] Address of the relay function. 98 | #endif 99 | BOOL patchAbove; // [Out] Should use the hot patch area? 100 | UINT nIP; // [Out] Number of the instruction boundaries. 101 | UINT8 oldIPs[8]; // [Out] Instruction boundaries of the target function. 102 | UINT8 newIPs[8]; // [Out] Instruction boundaries of the trampoline function. 103 | } TRAMPOLINE, *PTRAMPOLINE; 104 | 105 | BOOL CreateTrampolineFunction(PTRAMPOLINE ct); 106 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlTSHash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using UtlTsHashHandleT = std::uint64_t; 4 | 5 | class CUtlMemoryPool 6 | { 7 | public: 8 | // returns number of allocated blocks 9 | int BlockSize() const 10 | { 11 | return m_blocks_per_blob_; 12 | } 13 | int Count() const 14 | { 15 | return m_block_allocated_size_; 16 | } 17 | int PeakCount() const 18 | { 19 | return m_peak_alloc_; 20 | } 21 | private: 22 | std::int32_t m_block_size_ = 0; // 0x0558 23 | std::int32_t m_blocks_per_blob_ = 0; // 0x055C 24 | std::int32_t m_grow_mode_ = 0; // 0x0560 25 | std::int32_t m_blocks_allocated_ = 0; // 0x0564 26 | std::int32_t m_block_allocated_size_ = 0; // 0x0568 27 | std::int32_t m_peak_alloc_ = 0; // 0x056C 28 | }; 29 | 30 | template 31 | class CUtlTSHash 32 | { 33 | public: 34 | // Invalid handle. 35 | static UtlTsHashHandleT InvalidHandle(void) 36 | { 37 | return static_cast(0); 38 | } 39 | 40 | // Returns the number of elements in the hash table 41 | [[nodiscard]] int BlockSize() const 42 | { 43 | return m_entry_memory_.BlockSize(); 44 | } 45 | [[nodiscard]] int Count() const 46 | { 47 | return m_entry_memory_.Count(); 48 | } 49 | 50 | // Returns elements in the table 51 | std::vector GetElements(void); 52 | public: 53 | // Templatized for memory tracking purposes 54 | template 55 | struct HashFixedDataInternalT 56 | { 57 | Keytype m_ui_key; 58 | HashFixedDataInternalT* m_next; 59 | DataT m_data; 60 | }; 61 | 62 | using HashFixedDataT = HashFixedDataInternalT; 63 | 64 | // Templatized for memory tracking purposes 65 | template 66 | struct HashFixedStructDataInternalT 67 | { 68 | DataT m_data; 69 | Keytype m_ui_key; 70 | char pad_0x0020[0x8]; 71 | }; 72 | 73 | using HashFixedStructDataT = HashFixedStructDataInternalT; 74 | 75 | struct HashStructDataT 76 | { 77 | char pad_0x0000[0x10]; // 0x0000 78 | std::array m_list; 79 | }; 80 | 81 | struct HashAllocatedDataT 82 | { 83 | public: 84 | auto GetList() 85 | { 86 | return m_list_; 87 | } 88 | private: 89 | char pad_0x0000[0x18]; // 0x0000 90 | std::array m_list_; 91 | }; 92 | 93 | // Templatized for memory tracking purposes 94 | template 95 | struct HashBucketDataInternalT 96 | { 97 | DataT m_data; 98 | HashFixedDataInternalT* m_next; 99 | Keytype m_ui_key; 100 | }; 101 | 102 | using HashBucketDataT = HashBucketDataInternalT; 103 | 104 | struct HashUnallocatedDataT 105 | { 106 | HashUnallocatedDataT* m_next_ = nullptr; // 0x0000 107 | Keytype m_6114; // 0x0008 108 | Keytype m_ui_key; // 0x0010 109 | Keytype m_i_unk_1; // 0x0018 110 | std::array m_current_block_list; // 0x0020 111 | }; 112 | 113 | struct HashBucketT 114 | { 115 | HashStructDataT* m_struct_data = nullptr; 116 | void* m_mutex_list = nullptr; 117 | HashAllocatedDataT* m_allocated_data = nullptr; 118 | HashUnallocatedDataT* m_unallocated_data = nullptr; 119 | }; 120 | 121 | CUtlMemoryPool m_entry_memory_; 122 | char pad_001[0x40]; 123 | HashBucketT m_buckets_; 124 | bool m_needs_commit_ = false; 125 | }; 126 | 127 | template 128 | std::vector CUtlTSHash::GetElements(void) 129 | { 130 | std::vector list; 131 | 132 | const int n_count = Count(); 133 | auto n_index = 0; 134 | auto& unallocated_data = m_buckets_.m_unallocated_data; 135 | for (auto element = unallocated_data; element == nullptr; element = element->m_next_) 136 | { 137 | for (auto i = 0; i < BlockSize() && i != n_count; i++) 138 | { 139 | list.emplace_back(element->m_current_block_list.at(i).m_data); 140 | n_index++; 141 | 142 | if (n_index >= n_count) 143 | break; 144 | } 145 | } 146 | return list; 147 | } 148 | 149 | -------------------------------------------------------------------------------- /src/hooks/hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "../settings/settings.h" 3 | #include "../sdk/helpers/entity_data.h" 4 | #include 5 | 6 | bool hooks::init() 7 | { 8 | if (MH_Initialize() != MH_STATUS::MH_OK) 9 | return false; 10 | 11 | if (MH_CreateHookVirtual(g::entity_system, on_add_entity::index, &on_add_entity::hooked, reinterpret_cast(&on_add_entity::original_fn)) != MH_STATUS::MH_OK) 12 | return false; 13 | 14 | if (MH_CreateHookVirtual(g::entity_system, on_remove_entity::index, &on_remove_entity::hooked, reinterpret_cast(&on_remove_entity::original_fn)) != MH_STATUS::MH_OK) 15 | return false; 16 | 17 | if (MH_CreateHookVirtual(g::csgo_input, create_move::index, &create_move::hooked, reinterpret_cast(&create_move::original_fn)) != MH_STATUS::MH_OK) 18 | return false; 19 | 20 | if (MH_CreateHook(modules::client.pattern_scanner.scan("48 89 5C 24 ? 56 48 83 EC ? 8B 05 ? ? ? ? 8D 5A").as(), &frame_stage_notify::hooked, reinterpret_cast(&frame_stage_notify::original_fn)) != MH_STATUS::MH_OK) 21 | return false; 22 | 23 | if (MH_CreateHook(modules::client.pattern_scanner.scan("E8 ? ? ? ? F3 0F 11 45 ? 48 8B 5C 24 ?").add(0x1).abs().as(), &fov_changer_test::hooked, reinterpret_cast(&fov_changer_test::original_fn)) != MH_STATUS::MH_OK) 24 | return false; 25 | 26 | if (MH_CreateHookVirtual(g::swap_chain, present::index, &present::hooked, reinterpret_cast(&present::original_fn)) != MH_STATUS::MH_OK) 27 | return false; 28 | 29 | if (MH_CreateHookVirtual(g::swap_chain, resize_buffers::index, &resize_buffers::hooked, reinterpret_cast(&resize_buffers::original_fn)) != MH_STATUS::MH_OK) 30 | return false; 31 | 32 | if (MH_CreateHook(modules::client.pattern_scanner.scan("40 53 48 81 EC ? ? ? ? 49 8B C1").as(), get_matrices_for_view::hooked, reinterpret_cast(&get_matrices_for_view::original_fn)) != MH_STATUS::MH_OK) 33 | return false; 34 | 35 | if (MH_CreateHook(modules::client.pattern_scanner.scan("40 53 48 83 EC ? 48 8B D9 E8 ? ? ? ? 48 85 C0 0F 85").as(), should_draw_player::hooked, reinterpret_cast(&should_draw_player::original_fn)) != MH_STATUS::MH_OK) 36 | return false; 37 | 38 | MH_EnableHook(MH_ALL_HOOKS); 39 | 40 | return true; 41 | } 42 | 43 | bool __fastcall hooks::should_draw_player::hooked(void* player_pawn) 44 | { 45 | if (!g::engine_client->IsInGame() || g::csgo_input->m_in_thirdperson || player_pawn != entity_data::local_player_pawn) 46 | return original_fn(player_pawn); 47 | 48 | return false; 49 | } 50 | 51 | bool hooks::detach() 52 | { 53 | SetWindowLongPtrA(hooks::window, GWLP_WNDPROC, LONG_PTR(hooks::wndproc::original)); 54 | 55 | if (MH_Uninitialize() != MH_STATUS::MH_OK) 56 | return false; 57 | 58 | return true; 59 | } 60 | 61 | float __fastcall hooks::fov_changer_test::hooked(void* camera) 62 | { 63 | if (g::engine_client->IsInGame() && settings::visuals::m_bFovChanger) 64 | return static_cast(settings::visuals::m_iFov); 65 | 66 | return original_fn(camera); 67 | } 68 | 69 | //Temp placement, move later 70 | void __fastcall hooks::get_matrices_for_view::hooked(void* rcx, void* rdx, VMatrix* world_to_view, VMatrix* view_to_projection, VMatrix* world_to_projection, VMatrix* world_to_pixels) 71 | { 72 | if (!sdk::viewmatrix) 73 | sdk::viewmatrix = world_to_projection; 74 | 75 | original_fn(rcx, rdx, world_to_view, view_to_projection, world_to_projection, world_to_pixels); 76 | } 77 | 78 | long __stdcall hooks::resize_buffers::hooked(IDXGISwapChain* swap_chain, uint32_t buffer_count, uint32_t width, uint32_t height, DXGI_FORMAT new_format, uint32_t swap_chain_flags) 79 | { 80 | const auto hr = original_fn(swap_chain, buffer_count, width, height, new_format, swap_chain_flags); 81 | 82 | if (hr >= 0) 83 | { 84 | ImGui_ImplDX11_CreateDeviceObjects(); 85 | ImGui_ImplDX11_InvalidateDeviceObjects(); 86 | ImGui::CreateContext(); 87 | 88 | swap_chain->GetDevice(__uuidof(ID3D11Device), reinterpret_cast(&device)); 89 | device->GetImmediateContext(&context); 90 | 91 | ImGui_ImplWin32_Init(window); 92 | ImGui_ImplDX11_Init(device, context); 93 | 94 | swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast(&back_buffer)); 95 | 96 | // Create render target view 97 | device->CreateRenderTargetView(back_buffer, nullptr, &render_target_view); 98 | } 99 | 100 | return hr; 101 | } 102 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlMemory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../helpers/vfunc.h" 3 | 4 | template 5 | inline T* Construct(T* pMemory) 6 | { 7 | return ::new (pMemory) T; 8 | } 9 | 10 | template 11 | inline T* Construct(T* pMemory, ARG1 a1) 12 | { 13 | return ::new (pMemory) T(a1); 14 | } 15 | 16 | template 17 | inline T* Construct(T* pMemory, ARG1 a1, ARG2 a2) 18 | { 19 | return ::new (pMemory) T(a1, a2); 20 | } 21 | 22 | template 23 | inline T* Construct(T* pMemory, ARG1 a1, ARG2 a2, ARG3 a3) 24 | { 25 | return ::new (pMemory) T(a1, a2, a3); 26 | } 27 | 28 | template 29 | inline T* Construct(T* pMemory, ARG1 a1, ARG2 a2, ARG3 a3, ARG4 a4) 30 | { 31 | return ::new (pMemory) T(a1, a2, a3, a4); 32 | } 33 | 34 | template 35 | inline T* Construct(T* pMemory, ARG1 a1, ARG2 a2, ARG3 a3, ARG4 a4, ARG5 a5) 36 | { 37 | return ::new (pMemory) T(a1, a2, a3, a4, a5); 38 | } 39 | 40 | template 41 | inline T* CopyConstruct(T* pMemory, const T& src) 42 | { 43 | return ::new (pMemory) T(src); 44 | } 45 | 46 | template 47 | inline void Destruct(T* pMemory) 48 | { 49 | pMemory->~T(); 50 | 51 | #ifdef _DEBUG 52 | memset(pMemory, 0xDD, sizeof(T)); 53 | #endif 54 | } 55 | 56 | template 57 | class CUtlMemory 58 | { 59 | public: 60 | // constructor, destructor 61 | CUtlMemory(int nGrowSize = 0, int nInitSize = 0); 62 | CUtlMemory(T* pMemory, int numElements); 63 | CUtlMemory(const T* pMemory, int numElements); 64 | ~CUtlMemory(); 65 | 66 | // Set the size by which the memory grows 67 | void Init(int nGrowSize = 0, int nInitSize = 0); 68 | 69 | class Iterator_t 70 | { 71 | public: 72 | Iterator_t(I i): index(i) { } 73 | 74 | I index; 75 | 76 | bool operator==(const Iterator_t& it) const 77 | { 78 | return index == it.index; 79 | } 80 | bool operator!=(const Iterator_t& it) const 81 | { 82 | return index != it.index; 83 | } 84 | }; 85 | 86 | Iterator_t First() const 87 | { 88 | return Iterator_t(IsIdxValid(0) ? 0 : InvalidIndex()); 89 | } 90 | 91 | Iterator_t Next(const Iterator_t& it) const 92 | { 93 | return Iterator_t(IsIdxValid(it.index + 1) ? it.index + 1 : InvalidIndex()); 94 | } 95 | 96 | I GetIndex(const Iterator_t& it) const 97 | { 98 | return it.index; 99 | } 100 | bool IsIdxAfter(I i, const Iterator_t& it) const 101 | { 102 | return i > it.index; 103 | } 104 | bool IsValidIterator(const Iterator_t& it) const 105 | { 106 | return IsIdxValid(it.index); 107 | } 108 | Iterator_t InvalidIterator() const 109 | { 110 | return Iterator_t(InvalidIndex()); 111 | } 112 | 113 | // element access 114 | T& operator[](I i); 115 | const T& operator[](I i) const; 116 | T& Element(I i); 117 | const T& Element(I i) const; 118 | 119 | bool IsIdxValid(I i) const; 120 | 121 | static const I INVALID_INDEX = (I)-1; // For use with COMPILE_TIME_ASSERT 122 | static I InvalidIndex() 123 | { 124 | return INVALID_INDEX; 125 | } 126 | 127 | T* Base(); 128 | const T* Base() const; 129 | 130 | void SetExternalBuffer(T* pMemory, int numElements); 131 | void SetExternalBuffer(const T* pMemory, int numElements); 132 | void AssumeMemory(T* pMemory, int nSize); 133 | T* Detach(); 134 | void* DetachMemory(); 135 | 136 | void Swap(CUtlMemory& mem); 137 | void ConvertToGrowableMemory(int nGrowSize); 138 | int NumAllocated() const; 139 | int Count() const; 140 | void Grow(int num = 1); 141 | void EnsureCapacity(int num); 142 | void Purge(); 143 | void Purge(int numElements); 144 | bool IsExternallyAllocated() const; 145 | bool IsReadOnly() const; 146 | void SetGrowSize(int size); 147 | protected: 148 | void ValidateGrowSize() const { } 149 | 150 | enum { 151 | EXTERNAL_BUFFER_MARKER = -1, 152 | EXTERNAL_CONST_BUFFER_MARKER = -2, 153 | }; 154 | public: 155 | T* m_pMemory; 156 | int m_nAllocationCount; 157 | int m_nGrowSize; 158 | }; 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /src/sdk/helpers/CUtlVector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "CUtlVector.h" 4 | #include "../sdk.h" 5 | 6 | template 7 | inline T& CUtlVector::Element(int i) 8 | { 9 | assert(i < m_Size); 10 | return m_pElements[i]; 11 | } 12 | 13 | template 14 | inline const T& CUtlVector::Element(int i) const 15 | { 16 | assert(i < m_Size); 17 | return m_pElements[i]; 18 | } 19 | 20 | template 21 | void CUtlVector::GrowVector(int num) 22 | { 23 | m_Size += num; 24 | if (m_pElements) 25 | m_pElements = (T*)g::mem_alloc->ReAlloc(m_pElements, m_Size * sizeof(T)); 26 | else 27 | m_pElements = (T*)g::mem_alloc->Alloc(m_Size * sizeof(T)); 28 | } 29 | 30 | //----------------------------------------------------------------------------- 31 | // Adds an element, uses default constructor 32 | //----------------------------------------------------------------------------- 33 | template 34 | inline int CUtlVector::AddToHead() 35 | { 36 | return InsertBefore(0); 37 | } 38 | 39 | template 40 | inline int CUtlVector::AddToTail() 41 | { 42 | return InsertBefore(m_Size); 43 | } 44 | 45 | template 46 | inline int CUtlVector::InsertAfter(int elem) 47 | { 48 | return InsertBefore(elem + 1); 49 | } 50 | 51 | template 52 | int CUtlVector::InsertBefore(int elem) 53 | { 54 | // Can insert at the end 55 | GrowVector(); 56 | ShiftElementsRight(elem); 57 | Construct(&Element(elem)); 58 | return elem; 59 | } 60 | 61 | //----------------------------------------------------------------------------- 62 | // Adds an element, uses copy constructor 63 | //----------------------------------------------------------------------------- 64 | template 65 | inline int CUtlVector::AddToHead(const T& src) 66 | { 67 | return InsertBefore(0, src); 68 | } 69 | 70 | template 71 | inline int CUtlVector::AddToTail(const T& src) 72 | { 73 | return InsertBefore(m_Size, src); 74 | } 75 | 76 | template 77 | inline int CUtlVector::InsertAfter(int elem, const T& src) 78 | { 79 | return InsertBefore(elem + 1, src); 80 | } 81 | 82 | template 83 | int CUtlVector::InsertBefore(int elem, const T& src) 84 | { 85 | GrowVector(); 86 | ShiftElementsRight(elem); 87 | CopyConstruct(&Element(elem), src); 88 | return elem; 89 | } 90 | 91 | //----------------------------------------------------------------------------- 92 | // Shifts elements 93 | //----------------------------------------------------------------------------- 94 | template 95 | void CUtlVector::ShiftElementsRight(int elem, int num) 96 | { 97 | int numToMove = m_Size - elem - num; 98 | if ((numToMove > 0) && (num > 0)) 99 | memmove(&Element(elem + num), &Element(elem), numToMove * sizeof(T)); 100 | } 101 | 102 | template 103 | void CUtlVector::ShiftElementsLeft(int elem, int num) 104 | { 105 | int numToMove = m_Size - elem - num; 106 | 107 | if ((numToMove > 0) && (num > 0)) 108 | { 109 | memmove(&Element(elem), &Element(elem + num), numToMove * sizeof(T)); 110 | 111 | #ifdef _DEBUG 112 | memset(&Element(m_Size - num), 0xDD, num * sizeof(T)); 113 | #endif 114 | } 115 | } 116 | 117 | //----------------------------------------------------------------------------- 118 | // Element removal 119 | //----------------------------------------------------------------------------- 120 | template 121 | void CUtlVector::FastRemove(int elem) 122 | { 123 | Destruct(&Element(elem)); 124 | 125 | if (m_Size > 0) 126 | { 127 | if (elem != m_Size - 1) 128 | memcpy(&Element(elem), &Element(m_Size - 1), sizeof(T)); 129 | 130 | --m_Size; 131 | } 132 | } 133 | 134 | template 135 | void CUtlVector::Remove(int elem) 136 | { 137 | Destruct(&Element(elem)); 138 | ShiftElementsLeft(elem); 139 | --m_Size; 140 | } 141 | 142 | template 143 | bool CUtlVector::FindAndRemove(const T& src) 144 | { 145 | int elem = GetOffset(src); 146 | 147 | if (elem != -1) 148 | { 149 | Remove(elem); 150 | 151 | return true; 152 | } 153 | return false; 154 | } 155 | 156 | template 157 | bool CUtlVector::FindAndFastRemove(const T& src) 158 | { 159 | int elem = GetOffset(src); 160 | 161 | if (elem != -1) 162 | { 163 | FastRemove(elem); 164 | 165 | return true; 166 | } 167 | return false; 168 | } 169 | 170 | //----------------------------------------------------------------------------- 171 | // Finds an element (element needs operator== defined) 172 | //----------------------------------------------------------------------------- 173 | template 174 | int CUtlVector::GetOffset(const T& src) const 175 | { 176 | for (auto i = 0; i < Count(); ++i) 177 | { 178 | if (Element(i) == src) 179 | return i; 180 | } 181 | return -1; 182 | } -------------------------------------------------------------------------------- /src/hooks/functions/Present.cpp: -------------------------------------------------------------------------------- 1 | #include "../hooks.h" 2 | #include "../../sdk/helpers/entity_data.h" 3 | #include "../../render/menu/main_window.h" 4 | 5 | namespace hooks 6 | { 7 | ID3D11Device* device; 8 | ID3D11DeviceContext* context; 9 | ID3D11RenderTargetView* render_target_view; 10 | ID3D11Texture2D* back_buffer; 11 | HWND window; 12 | 13 | namespace esp //Just an example, dont put any next features here! Make an esp.cpp 14 | { 15 | std::list m_entries; //get list of player_data_t so we can get the player data 16 | 17 | void render(ImDrawList* draw_list) 18 | { 19 | if (!g::engine_client->IsInGame()) 20 | return; 21 | 22 | if (entity_data::player_instances.empty()) 23 | return; 24 | 25 | if (entity_data::locker.try_lock()) //mutex stuff 26 | { 27 | m_entries.clear(); 28 | std::copy(entity_data::player_entry_data.front().player_data.begin(), entity_data::player_entry_data.front().player_data.end(), std::back_inserter(m_entries)); 29 | entity_data::locker.unlock(); 30 | } 31 | 32 | Vector screen_head_pos; 33 | Vector screen_player_pos; 34 | Vector head_pos; 35 | Vector out; 36 | Vector bone_pos_out; 37 | Vector bone_parent_pos_out; 38 | 39 | for (auto& data : m_entries) //TODO:Compute bbox in the future 40 | { 41 | if (data.index == 0) 42 | continue; 43 | 44 | head_pos = data.m_vOldOrigin; 45 | head_pos.z += 75.f; 46 | 47 | if (!sdk::world_to_screen(data.m_vOldOrigin, screen_player_pos)) 48 | continue; 49 | 50 | if (!sdk::world_to_screen(head_pos, screen_head_pos)) 51 | continue; 52 | 53 | if (!sdk::world_to_screen(data.m_vecOrigin, out)) 54 | continue; 55 | 56 | float height = screen_player_pos.y - screen_head_pos.y; 57 | float width = height * 2.5f; 58 | width /= 10.f; 59 | 60 | // Example text 61 | draw_list->AddText(ImVec2(out.x, out.y), IM_COL32_WHITE, std::to_string(data.m_iHealth).c_str()); 62 | 63 | // Example box 64 | draw_list->AddRect({ screen_head_pos.x - width, screen_head_pos.y }, { screen_head_pos.x + width, screen_player_pos.y }, IM_COL32_WHITE, 0.f, 0.f, 1); 65 | 66 | const auto& bbox = data.bbox; 67 | 68 | const bool& on_screen = (bbox.left > 0 || bbox.right > 0) && (bbox.top > 0 || bbox.bottom > 0); 69 | 70 | printf("on_screen: %d, left: %d, right: %d, top: %d, bottom: %d\n", on_screen, bbox.left, bbox.right, bbox.top, bbox.bottom); 71 | 72 | if (settings::visuals::m_bBoneEsp) 73 | { 74 | if (!data.model_state) 75 | continue; 76 | 77 | if (data.model.IsValid()) 78 | { 79 | for (int i = 0; i <= data.model->BoneCount; ++i) 80 | { 81 | const auto flag = data.model->GetBoneFlags(i); 82 | 83 | if (!flag.HasFlag(static_cast(FLAG_HITBOX))) 84 | continue; 85 | 86 | auto bone_parent_index = data.model->GetBoneParent(i); 87 | 88 | if (bone_parent_index == -1) 89 | continue; 90 | 91 | if (sdk::world_to_screen(data.model_state->bones[i].position, bone_pos_out) && 92 | sdk::world_to_screen(data.model_state->bones[bone_parent_index].position, bone_parent_pos_out)) 93 | { 94 | draw_list->AddLine(ImVec2{ bone_pos_out.x, bone_pos_out.y }, ImVec2{ bone_parent_pos_out.x, bone_parent_pos_out.y }, IM_COL32_WHITE); 95 | } 96 | } 97 | } 98 | } 99 | } 100 | } 101 | } 102 | 103 | std::once_flag init_flag; 104 | long __stdcall present::hooked(IDXGISwapChain* swap_chain, uint32_t sync_interval, uint32_t flags) 105 | { 106 | //Todo: cleanup imgui and the various dx11 pointers on exit/unhook, etc... 107 | 108 | DXGI_SWAP_CHAIN_DESC desc; 109 | swap_chain->GetDesc(&desc); 110 | 111 | window = desc.OutputWindow; 112 | 113 | std::call_once(init_flag, [&]() 114 | { 115 | swap_chain->GetDevice(__uuidof(ID3D11Device), reinterpret_cast(&device)); 116 | device->GetImmediateContext(&context); 117 | swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast(&back_buffer)); 118 | 119 | device->CreateRenderTargetView(back_buffer, nullptr, &render_target_view); 120 | 121 | if (back_buffer) 122 | back_buffer->Release(); 123 | 124 | hooks::wndproc::original = reinterpret_cast(SetWindowLongPtr(window, GWLP_WNDPROC, reinterpret_cast(wndproc::hooked))); 125 | 126 | ImGui::CreateContext(); 127 | ImGui_ImplWin32_Init(window); 128 | ImGui_ImplDX11_Init(device, context); 129 | 130 | ImGuiIO& io = ImGui::GetIO(); 131 | io.ConfigFlags = ImGuiConfigFlags_NoMouseCursorChange; 132 | ImGui::GetStyle().WindowMinSize = ImVec2(500, 350); 133 | }); 134 | 135 | ImGui_ImplDX11_NewFrame(); 136 | ImGui_ImplWin32_NewFrame(); 137 | 138 | ImGui::NewFrame(); 139 | { 140 | if (main_window::is_open) 141 | main_window::Draw(); 142 | 143 | ImDrawList* draw_list = ImGui::GetBackgroundDrawList(); 144 | 145 | esp::render(draw_list); 146 | } 147 | ImGui::EndFrame(); 148 | 149 | ImGui::Render(); 150 | context->OMSetRenderTargets(0, nullptr, nullptr); 151 | context->OMSetRenderTargets(1, &render_target_view, nullptr); 152 | 153 | ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); 154 | 155 | return original_fn(swap_chain, sync_interval, flags); 156 | } 157 | } -------------------------------------------------------------------------------- /src/sdk/helpers/entity_data.cpp: -------------------------------------------------------------------------------- 1 | #include "entity_data.h" 2 | 3 | #include "../../sdk/classes/CStrongHandle.h" 4 | 5 | #include 6 | 7 | namespace entity_data 8 | { 9 | std::list player_instances; 10 | std::list entity_instances; 11 | CBasePlayer* local_player_pawn = nullptr; 12 | CCSPlayerController* local_player_controller = nullptr; 13 | std::list player_entry_data; 14 | 15 | std::mutex locker; 16 | 17 | void destroy() //TODO: Call this if localplayer is nullptr 18 | { 19 | locker.lock(); 20 | { 21 | player_instances.clear(); 22 | } 23 | locker.unlock(); 24 | } 25 | 26 | RECT get_box(CBaseEntity* entity) 27 | { 28 | auto collision = entity->m_pCollision(); 29 | 30 | if (!collision) 31 | return {}; 32 | 33 | auto& mins = collision->m_vecMins(); 34 | auto& maxs = collision->m_vecMaxs(); 35 | 36 | static Vector screen_points[8]; 37 | 38 | //Vector transformed_points[8] = 39 | //{ 40 | // {mins.x, mins.y, mins.z}, //minimum extent of the bounding box (bottom-left-back corner) 41 | // {mins.x, mins.y, maxs.z}, //minimum x and y extents, but maximum z extent (bottom-left-front corner) 42 | // {mins.x, maxs.y, mins.z}, //minimum x extent, maximum y extent, and minimum z extent (bottom-right-back corner) 43 | // {mins.x, maxs.y, maxs.z}, //minimum x extent, maximum y extent, and maximum z extent (bottom-right-front corner) 44 | // {maxs.x, mins.y, mins.z}, //maximum x extent, minimum y extent, and minimum z extent (top-left-back corner) 45 | // {maxs.x, mins.y, maxs.z}, //maximum x extent, minimum y extent, and maximum z extent (top-left-front corner) 46 | // {maxs.x, maxs.y, mins.z}, //maximum x and y extents, but minimum z extent (top-right-back corner) 47 | // {maxs.x, maxs.y, maxs.z} //maximum extent of the bounding box (top-right-front corner) 48 | //}; 49 | 50 | for (int i = 0; i < 8; i++) 51 | { 52 | Vector transformed_points[8] = 53 | { 54 | { 55 | i & 1 ? maxs.x : mins.x, 56 | i & 2 ? maxs.y : mins.y, 57 | i & 4 ? maxs.z : mins.z 58 | }, // minimum extent of the bounding box (bottom-left-back corner) 59 | { 60 | i & 1 ? maxs.x : mins.x, 61 | i & 2 ? maxs.y : mins.y, 62 | i & 4 ? maxs.z : maxs.z 63 | }, // minimum x and y extents, but maximum z extent (bottom-left-front corner) 64 | { 65 | i & 1 ? maxs.x : mins.x, 66 | i & 2 ? maxs.y : maxs.y, 67 | i & 4 ? maxs.z : mins.z 68 | }, // minimum x extent, maximum y extent, and minimum z extent (bottom-right-back corner) 69 | { 70 | i & 1 ? maxs.x : mins.x, 71 | i & 2 ? maxs.y : maxs.y, 72 | i & 4 ? maxs.z : maxs.z 73 | }, // minimum x extent, maximum y extent, and maximum z extent (bottom-right-front corner) 74 | { 75 | i & 1 ? maxs.x : maxs.x, 76 | i & 2 ? maxs.y : mins.y, 77 | i & 4 ? maxs.z : mins.z 78 | }, // maximum x extent, minimum y extent, and minimum z extent (top-left-back corner) 79 | { 80 | i & 1 ? maxs.x : maxs.x, 81 | i & 2 ? maxs.y : mins.y, 82 | i & 4 ? maxs.z : maxs.z 83 | }, // maximum x extent, minimum y extent, and maximum z extent (top-left-front corner) 84 | { 85 | i & 1 ? maxs.x : maxs.x, 86 | i & 2 ? maxs.y : maxs.y, 87 | i & 4 ? maxs.z : mins.z 88 | }, // maximum x and y extents, but minimum z extent (top-right-back corner) 89 | { 90 | i & 1 ? maxs.x : maxs.x, 91 | i & 2 ? maxs.y : maxs.y, 92 | i & 4 ? maxs.z : maxs.z 93 | } // maximum extent of the bounding box (top-right-front corner) 94 | }; 95 | 96 | if (!sdk::world_to_screen(transformed_points[i], screen_points[i])) 97 | return {}; 98 | } 99 | 100 | auto top = screen_points[0].y; 101 | auto left = screen_points[0].x; 102 | auto right = screen_points[0].x; 103 | auto bottom = screen_points[0].y; 104 | 105 | for (int i = 1; i < 8; i++) 106 | { 107 | if (left > screen_points[i].x) 108 | left = screen_points[i].x; 109 | if (top > screen_points[i].y) 110 | top = screen_points[i].y; 111 | if (right < screen_points[i].x) 112 | right = screen_points[i].x; 113 | if (bottom < screen_points[i].y) 114 | bottom = screen_points[i].y; 115 | } 116 | 117 | return RECT{ (long)left, (long)top, (long)(right - left), (long)(bottom - top) }; 118 | } 119 | 120 | void fetch_player_data() 121 | { 122 | if (!g::engine_client->IsInGame()) 123 | return; 124 | 125 | std::lock_guard lock(locker); 126 | 127 | entry_data_t entry_data; 128 | 129 | for (const auto& instance : player_instances) 130 | { 131 | auto player = instance.entity; 132 | 133 | if (!player || !instance.handle.IsValid()) 134 | continue; 135 | 136 | uint32_t index = instance.handle.GetEntryIndex(); 137 | 138 | auto pawn = player->m_hPawn().Get(); 139 | 140 | if (!pawn) 141 | continue; 142 | 143 | auto scene_node = pawn->m_pGameSceneNode(); 144 | 145 | if (!scene_node) 146 | continue; 147 | 148 | auto weapon_services = pawn->m_pWeaponServices(); 149 | 150 | if (!weapon_services) 151 | continue; 152 | 153 | auto active_wpn = weapon_services->m_hActiveWeapon().Get(); 154 | 155 | if (!active_wpn) 156 | continue; 157 | 158 | auto skeleton_instance = scene_node->GetSkeletonInstance(); 159 | 160 | if (!skeleton_instance) 161 | continue; 162 | 163 | auto& model_state = skeleton_instance->m_modelState(); 164 | 165 | auto model = model_state.modelHandle; 166 | 167 | auto collision = pawn->m_pCollision(); 168 | 169 | if (!collision) 170 | continue; 171 | 172 | auto& mins = collision->m_vecMins(); 173 | auto& maxs = collision->m_vecMaxs(); 174 | 175 | if (pawn->m_iHealth() <= 0 || !(pawn->m_lifeState() == LIFE_ALIVE)) 176 | continue; 177 | 178 | player_data_t player_data; 179 | 180 | player_data.m_iHealth = pawn->m_iHealth(); 181 | player_data.m_iShotsFired = pawn->m_iShotsFired(); 182 | player_data.m_vecOrigin = scene_node->m_vecOrigin(); 183 | player_data.m_vOldOrigin = pawn->m_vOldOrigin(); 184 | player_data.clip = active_wpn->m_iClip1(); 185 | player_data.model_state = &model_state; 186 | player_data.model = model; 187 | player_data.bbox = get_box(pawn); 188 | player_data.index = index; 189 | 190 | entry_data.player_data.push_back(std::move(player_data)); 191 | } 192 | 193 | player_entry_data.push_front(std::move(entry_data)); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /src/sdk/interfaces/CSGOInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "../math/Vector.h" 6 | #include "../helpers/modules.h" 7 | 8 | #define MULTIPLAYER_BACKUP 150 9 | 10 | enum ECommandButtons { 11 | IN_NONE = 0x0, 12 | IN_ALL = 0xffffffffffffffff, 13 | IN_ATTACK = 0x1, 14 | IN_JUMP = 0x2, 15 | IN_DUCK = 0x4, 16 | IN_FORWARD = 0x8, 17 | IN_BACK = 0x10, 18 | IN_USE = 0x20, 19 | IN_TURNLEFT = 0x80, 20 | IN_TURNRIGHT = 0x100, 21 | IN_MOVELEFT = 0x200, 22 | IN_MOVERIGHT = 0x400, 23 | IN_ATTACK2 = 0x800, 24 | IN_RELOAD = 0x2000, 25 | IN_SPEED = 0x10000, 26 | IN_JOYAUTOSPRINT = 0x20000, 27 | IN_FIRST_MOD_SPECIFIC_BIT = 0x100000000, 28 | IN_USEORRELOAD = 0x100000000, 29 | IN_SCORE = 0x200000000, 30 | IN_ZOOM = 0x400000000, 31 | IN_JUMP_THROW_RELEASE = 0x800000000, 32 | }; 33 | 34 | template 35 | struct repeated_ptr_field_t 36 | { 37 | struct repeat_t 38 | { 39 | int m_alloc_size; 40 | T* m_elements[(INT_MAX - 2 * sizeof(int)) / sizeof(void*)]; 41 | }; 42 | 43 | void* m_arena; 44 | int m_current_size; 45 | int m_total_size; 46 | repeat_t* m_repeat; 47 | }; 48 | 49 | class c_msg_qangle 50 | { 51 | public: 52 | std::uint8_t pad_1[ 24 ]; //0x0000 53 | Vector m_view_angles; // 0x18 54 | }; 55 | static_assert( sizeof( c_msg_qangle ) == 0x24 ); 56 | 57 | class c_csgo_interpolation_info 58 | { 59 | public: 60 | char pad_0000[ 24 ]; //0x0000 61 | float m_fraction; // 0x18 62 | int m_src_tick; // 0x1C 63 | int m_dst_tick; // 0x20 64 | char pad_0024[ 12 ]; //0x0024 65 | c_msg_qangle entiy_view_angles; //0x0030 66 | }; 67 | static_assert( sizeof( c_csgo_interpolation_info ) == 0x54 ); 68 | 69 | class c_csgo_input_history_entry_pb 70 | { 71 | public: 72 | std::uint8_t padding_1[0x18]{ }; 73 | c_msg_qangle* m_view_cmd; // 0x18 74 | char pad_0020[ 32 ]; //0x0020 75 | c_csgo_interpolation_info* cl_interp; // 0x40 76 | c_csgo_interpolation_info* sv_interp0; // 0x48 77 | c_csgo_interpolation_info* sv_interp1; // 0x50 78 | c_csgo_interpolation_info* m_player_interp; // 0x58 79 | int m_render_tick_count; // 0x60 80 | float m_render_tick_fraction; // 0x64 81 | int m_player_tick_count; // 0x68 82 | float m_player_tick_fraction; // 0x6C 83 | int m_frame_number; // 0x70 84 | int m_target_ent_index; // 0x74 85 | int32_t idk; //0x0078 86 | int32_t idk1; //0x007C 87 | }; 88 | static_assert( sizeof( c_csgo_input_history_entry_pb ) == 0x80 ); 89 | 90 | struct c_subtick_move_step 91 | { 92 | std::uint8_t padding_1[0x18]{ }; 93 | uint64_t m_button; 94 | bool m_pressed; 95 | float m_when; 96 | }; 97 | 98 | struct c_in_button_state_pb 99 | { 100 | char pad_0000[ 24 ]; //0x0000 101 | std::uint64_t m_hold; 102 | std::uint64_t m_pressed; 103 | std::uint64_t m_scrolled; 104 | }; 105 | static_assert( sizeof( c_in_button_state_pb ) == 0x30 ); 106 | 107 | class c_valve_proto 108 | { 109 | public: 110 | void* __vfptr; 111 | uint64_t m_has_bits; 112 | uint64_t m_cached_bits; 113 | }; 114 | 115 | class c_base_usercmd : c_valve_proto 116 | { 117 | public: 118 | repeated_ptr_field_t m_subtick_moves_field; 119 | const char* m_move_crc; 120 | c_in_button_state_pb* m_in_button_state; 121 | c_msg_qangle* m_view; 122 | int32_t m_command_number; 123 | int32_t m_tick_count; 124 | float m_forward_move; 125 | float m_side_move; 126 | float m_up_move; 127 | int32_t m_impulse; 128 | int32_t m_weapon_select; 129 | int32_t m_random_seed; 130 | int32_t m_moused_x; 131 | int32_t m_moused_y; 132 | uint32_t m_consumed_server_angle_changes; 133 | int32_t m_cmd_flags; 134 | uint32_t m_pawn_entity_handle; 135 | }; 136 | 137 | struct c_in_button_state 138 | { 139 | char pad_0000[ 8 ]; //0x0000 140 | std::uint64_t m_hold; 141 | std::uint64_t m_pressed; 142 | std::uint64_t m_scrolled; 143 | }; 144 | 145 | class c_sub_tick_container 146 | { 147 | public: 148 | std::int32_t tick_count; 149 | char pad_0004[ 4 ]; //0x0004 150 | std::uintptr_t tick_pointer; 151 | 152 | c_csgo_input_history_entry_pb* get_tick(std::int32_t i) 153 | { 154 | if (i < this->tick_count) 155 | { 156 | c_csgo_input_history_entry_pb** tick_list = reinterpret_cast(this->tick_pointer + 0x8); 157 | return tick_list[i]; 158 | } 159 | 160 | return nullptr; 161 | } 162 | }; 163 | 164 | class c_usercmd 165 | { 166 | public: 167 | uint32_t m_has_bits; 168 | uint64_t m_cached_size; 169 | repeated_ptr_field_t m_input_history_field; 170 | c_base_usercmd* m_base_cmd; 171 | int32_t m_weapon_decision; 172 | int32_t m_weapon_decision_weapon; 173 | int32_t m_attack3_start_history_index; 174 | int32_t m_attack1_start_history_index; 175 | int32_t m_attack2_start_history_index; 176 | c_in_button_state m_button_state; 177 | char pad_0068[ 8 ]; //0x0068 178 | double some_time; //0x0070 179 | char pad_0078[ 16 ]; //0x0078 180 | 181 | c_sub_tick_container get_sub_tick_container() 182 | { 183 | return *reinterpret_cast(reinterpret_cast(this) + 0x20); 184 | } 185 | 186 | void set_sub_tick_angles(Vector& angles) 187 | { 188 | c_sub_tick_container container = this->get_sub_tick_container(); 189 | for (std::int32_t i = 0; i < container.tick_count; i++) 190 | { 191 | c_csgo_input_history_entry_pb* tick = container.get_tick(i); 192 | 193 | if (tick && tick->m_view_cmd) 194 | { 195 | tick->m_view_cmd->m_view_angles = angles; 196 | } 197 | } 198 | } 199 | }; 200 | 201 | class c_csgo_input { 202 | public: 203 | char pad_0000[ 592 ]; //0x0000 204 | c_usercmd m_commands[150]; //0x3040 205 | char pad_5200[ 1 ]; //0x5200 206 | bool m_in_thirdperson; //0x8E01 207 | char pad_5202[ 34 ]; //0x5202 208 | int32_t m_seq_number; //0x8E24 209 | int32_t m_prev_seq_number; //0x8E28 210 | char pad_522C[ 56 ]; //0x522C 211 | int32_t m_mousedx; //0x5264 212 | int32_t m_mousedy; //0x5268 213 | char pad_526C[ 292 ]; //0x526C 214 | Vector m_viewangles; //0x5390 215 | 216 | c_usercmd* get_usercmd() 217 | { 218 | return &m_commands[m_seq_number % 150]; 219 | } 220 | 221 | c_usercmd* get_prev_cmd() 222 | { 223 | return &m_commands[m_prev_seq_number % 150]; 224 | } 225 | 226 | static c_csgo_input* get() 227 | { 228 | static auto addr = modules::client.pattern_scanner.scan( "E8 ? ? ? ? 48 8B 56 60" ).add( 0x1 ).abs( ).as( ); 229 | 230 | const auto& get_input = reinterpret_cast(addr); 231 | 232 | if (get_input) 233 | return get_input(); 234 | 235 | return nullptr; 236 | } 237 | }; 238 | -------------------------------------------------------------------------------- /src/sdk/helpers/dynamic_module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../helpers/importer.h" 10 | 11 | using fn = void* (__cdecl*)(); 12 | 13 | struct InterfaceReg 14 | { 15 | fn func; 16 | const char* name; 17 | InterfaceReg* next; 18 | }; 19 | 20 | //Usage: 21 | //modules::client.pattern_scan("").abs().add(0x1).as(); 22 | 23 | class PatternScanner 24 | { 25 | public: 26 | PatternScanner(HMODULE base) 27 | { 28 | this->base = base; 29 | } 30 | 31 | PatternScanner() 32 | { 33 | 34 | } 35 | 36 | PatternScanner& scan(const char* signature) 37 | { 38 | this->addr = pattern_scan(signature); 39 | 40 | return *this; 41 | } 42 | 43 | PatternScanner& abs() 44 | { 45 | const int relative = *reinterpret_cast(this->addr); 46 | 47 | this->addr += relative + sizeof(int); 48 | 49 | return *this; 50 | } 51 | 52 | PatternScanner& add(const uintptr_t& offset) 53 | { 54 | this->addr += offset; 55 | 56 | return *this; 57 | } 58 | 59 | template 60 | T* as() 61 | { 62 | if (!addr) 63 | return {}; 64 | 65 | return reinterpret_cast(addr); 66 | } 67 | private: 68 | std::uint8_t* pattern_scan(const char* signature) const 69 | { 70 | static auto pattern_to_byte = [](const char* pattern) 71 | { 72 | auto bytes = std::vector{}; 73 | auto start = const_cast(pattern); 74 | auto end = const_cast(pattern) + strlen(pattern); 75 | 76 | for (auto current = start; current < end; ++current) 77 | { 78 | if (*current == '?') 79 | { 80 | ++current; 81 | 82 | if (*current == '?') 83 | ++current; 84 | 85 | bytes.emplace_back(-1); 86 | } 87 | else bytes.emplace_back(strtoul(current, ¤t, 16)); 88 | } 89 | return bytes; 90 | }; 91 | 92 | auto offset_ptr = [](auto* base, std::size_t offset) -> PIMAGE_NT_HEADERS 93 | { 94 | return reinterpret_cast(reinterpret_cast(base) + offset); 95 | }; 96 | 97 | auto dos_header = reinterpret_cast(this->base); 98 | auto nt_headers = offset_ptr(dos_header, dos_header->e_lfanew); 99 | 100 | auto size_of_image = nt_headers->OptionalHeader.SizeOfImage; 101 | auto pattern_bytes = pattern_to_byte(signature); 102 | auto scan_bytes = reinterpret_cast(this->base); 103 | 104 | for (std::size_t i = 0; i < size_of_image - pattern_bytes.size(); ++i) 105 | { 106 | bool found = true; 107 | for (std::size_t j = 0; j < pattern_bytes.size(); ++j) 108 | { 109 | if (scan_bytes[i + j] != pattern_bytes[j] && pattern_bytes[j] != -1) 110 | { 111 | found = false; 112 | break; 113 | } 114 | } 115 | 116 | if (found) 117 | return &scan_bytes[i]; 118 | } 119 | 120 | return nullptr; 121 | } 122 | 123 | const char* pattern; 124 | HMODULE base; 125 | uint8_t* addr; 126 | }; 127 | 128 | class DynamicModule 129 | { 130 | public: 131 | std::map modules = {}; 132 | 133 | HMODULE get_module(const std::string& name) 134 | { 135 | if (modules.count(name) == 0 || !modules[name]) 136 | modules[name] = LI_FN(GetModuleHandleA).cached()(name.c_str()); 137 | 138 | return modules[name]; 139 | } 140 | 141 | DynamicModule(const std::string_view& dll_name) 142 | { 143 | this->base = get_module(dll_name.data()); 144 | this->base_addr = reinterpret_cast(this->base); 145 | this->dll_name = dll_name.data(); 146 | 147 | pattern_scanner = PatternScanner(this->base); 148 | } 149 | 150 | DynamicModule() 151 | { 152 | 153 | } 154 | 155 | ~DynamicModule() 156 | { 157 | //FreeLibrary(dll); 158 | } 159 | 160 | void* GetExport(const std::string_view& func_name) 161 | { 162 | if (!base) 163 | return nullptr; 164 | 165 | return LI_FN(GetProcAddress).cached()(base, func_name.data()); 166 | } 167 | 168 | void* GetCreateInterface() 169 | { 170 | void* CreateInterface = this->GetExport("CreateInterface"); 171 | 172 | if (!CreateInterface) 173 | return nullptr; 174 | 175 | return CreateInterface; 176 | } 177 | 178 | template 179 | T GetInterface(const std::string_view& interface_name) 180 | { 181 | using fn = void* (*)(const char* pName, int* pReturnCode); 182 | 183 | fn CreateInterface = reinterpret_cast(GetCreateInterface()); 184 | 185 | if (CreateInterface) 186 | { 187 | T interface_val = reinterpret_cast(CreateInterface(interface_name.data(), 0)); 188 | 189 | return interface_val; 190 | } 191 | 192 | return nullptr; 193 | } 194 | 195 | template 196 | T GetInterfaceFromList(const std::string_view& interface_name) 197 | { 198 | uint8_t* CreateInterface = reinterpret_cast(GetCreateInterface()); 199 | 200 | if (!CreateInterface) 201 | return nullptr; 202 | 203 | const auto& rip_offset = resolve_rip(CreateInterface, std::nullopt, std::nullopt); 204 | 205 | InterfaceReg* reg = *reinterpret_cast(rip_offset); 206 | 207 | if (!reg) 208 | return nullptr; 209 | 210 | for (InterfaceReg* it = reg; it; it = it->next) 211 | { 212 | size_t pos = interface_name.find(it->name); 213 | if (pos != std::string_view::npos) 214 | { 215 | T interface_val = reinterpret_cast(it->func()); 216 | 217 | return interface_val; 218 | } 219 | } 220 | 221 | return nullptr; 222 | } 223 | 224 | void PrintAllInterfaces() 225 | { 226 | uint8_t* CreateInterface = reinterpret_cast(GetCreateInterface()); 227 | 228 | if (!CreateInterface) 229 | return; 230 | 231 | InterfaceReg* reg = *reinterpret_cast(resolve_rip(CreateInterface, std::nullopt, std::nullopt)); 232 | 233 | if (reg) 234 | { 235 | printf("reg: 0x%p", reg); 236 | 237 | for (InterfaceReg* it = reg; it; it = it->next) 238 | { 239 | printf("name: %s\n", it->name); 240 | } 241 | } 242 | } 243 | 244 | static uint8_t* resolve_rip_copy(std::uint8_t* addr, std::uint32_t rva, std::uint32_t size) 245 | { 246 | auto relative = addr + *reinterpret_cast(addr + rva); 247 | 248 | return reinterpret_cast(relative + size); 249 | } 250 | 251 | static uint8_t* resolve_rip(uint8_t* address, std::optional offset = std::nullopt, std::optional length = std::nullopt) 252 | { 253 | uint32_t displacement = *reinterpret_cast(address + (offset.value_or(0x3))); 254 | 255 | return address + (length.value_or(0x7)) + static_cast(displacement); 256 | } 257 | 258 | HMODULE base; 259 | uintptr_t base_addr; 260 | const char* dll_name; 261 | PatternScanner pattern_scanner{}; 262 | }; 263 | 264 | 265 | 266 | 267 | 268 | -------------------------------------------------------------------------------- /src/thirdparty/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec( dllexport ) 27 | //#define IMGUI_API __declspec( dllimport ) 28 | 29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 31 | //#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions. 32 | 33 | //---- Disable all of Dear ImGui or don't implement standard windows/tools. 34 | // It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp. 35 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 36 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. 37 | //#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowStackToolWindow() will be empty (this was called IMGUI_DISABLE_METRICS_WINDOW before 1.88). 38 | 39 | //---- Don't implement some functions to reduce linkage requirements. 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 41 | //#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW) 42 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a) 43 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). 44 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 45 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 46 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 47 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) 48 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 49 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 50 | //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available 51 | 52 | //---- Include imgui_user.h at the end of imgui.h as a convenience 53 | //#define IMGUI_INCLUDE_IMGUI_USER_H 54 | 55 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 56 | //#define IMGUI_USE_BGRA_PACKED_COLOR 57 | 58 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 59 | //#define IMGUI_USE_WCHAR32 60 | 61 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 62 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 63 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 64 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 65 | //#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if enabled 66 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 67 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 68 | 69 | //---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 70 | // Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h. 71 | //#define IMGUI_USE_STB_SPRINTF 72 | 73 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 74 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 75 | // On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'. 76 | //#define IMGUI_ENABLE_FREETYPE 77 | 78 | //---- Use stb_truetype to build and rasterize the font atlas (default) 79 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 80 | //#define IMGUI_ENABLE_STB_TRUETYPE 81 | 82 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 83 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 84 | /* 85 | #define IM_VEC2_CLASS_EXTRA \ 86 | constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \ 87 | operator MyVec2() const { return MyVec2(x,y); } 88 | 89 | #define IM_VEC4_CLASS_EXTRA \ 90 | constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \ 91 | operator MyVec4() const { return MyVec4(x,y,z,w); } 92 | */ 93 | //---- ...Or use Dear ImGui's own very basic math operators. 94 | //#define IMGUI_DEFINE_MATH_OPERATORS 95 | 96 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 97 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 98 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 99 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 100 | //#define ImDrawIdx unsigned int 101 | 102 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 103 | //struct ImDrawList; 104 | //struct ImDrawCmd; 105 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 106 | //#define ImDrawCallback MyImDrawCallback 107 | 108 | //---- Debug Tools: Macro to break in Debugger 109 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 110 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 111 | //#define IM_DEBUG_BREAK __debugbreak() 112 | 113 | //---- Debug Tools: Enable slower asserts 114 | //#define IMGUI_DEBUG_PARANOID 115 | 116 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 117 | /* 118 | namespace ImGui 119 | { 120 | void MyFunction(const char* name, const MyMatrix44& v); 121 | } 122 | */ 123 | 124 | //#define IMGUI_ENABLE_FREETYPE -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/MinHook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__) 32 | #error MinHook supports only x86 and x64 systems. 33 | #endif 34 | 35 | #include 36 | 37 | // MinHook Error Codes. 38 | typedef enum MH_STATUS 39 | { 40 | // Unknown error. Should not be returned. 41 | MH_UNKNOWN = -1, 42 | 43 | // Successful. 44 | MH_OK = 0, 45 | 46 | // MinHook is already initialized. 47 | MH_ERROR_ALREADY_INITIALIZED, 48 | 49 | // MinHook is not initialized yet, or already uninitialized. 50 | MH_ERROR_NOT_INITIALIZED, 51 | 52 | // The hook for the specified target function is already created. 53 | MH_ERROR_ALREADY_CREATED, 54 | 55 | // The hook for the specified target function is not created yet. 56 | MH_ERROR_NOT_CREATED, 57 | 58 | // The hook for the specified target function is already enabled. 59 | MH_ERROR_ENABLED, 60 | 61 | // The hook for the specified target function is not enabled yet, or already 62 | // disabled. 63 | MH_ERROR_DISABLED, 64 | 65 | // The specified pointer is invalid. It points the address of non-allocated 66 | // and/or non-executable region. 67 | MH_ERROR_NOT_EXECUTABLE, 68 | 69 | // The specified target function cannot be hooked. 70 | MH_ERROR_UNSUPPORTED_FUNCTION, 71 | 72 | // Failed to allocate memory. 73 | MH_ERROR_MEMORY_ALLOC, 74 | 75 | // Failed to change the memory protection. 76 | MH_ERROR_MEMORY_PROTECT, 77 | 78 | // The specified module is not loaded. 79 | MH_ERROR_MODULE_NOT_FOUND, 80 | 81 | // The specified function is not found. 82 | MH_ERROR_FUNCTION_NOT_FOUND 83 | } 84 | MH_STATUS; 85 | 86 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, 87 | // MH_QueueEnableHook or MH_QueueDisableHook. 88 | #define MH_ALL_HOOKS NULL 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | // Initialize the MinHook library. You must call this function EXACTLY ONCE 95 | // at the beginning of your program. 96 | MH_STATUS WINAPI MH_Initialize(VOID); 97 | 98 | // Uninitialize the MinHook library. You must call this function EXACTLY 99 | // ONCE at the end of your program. 100 | MH_STATUS WINAPI MH_Uninitialize(VOID); 101 | 102 | // Creates a Hook for the specified target function, in disabled state. 103 | // Parameters: 104 | // pTarget [in] A pointer to the target function, which will be 105 | // overridden by the detour function. 106 | // pDetour [in] A pointer to the detour function, which will override 107 | // the target function. 108 | // ppOriginal [out] A pointer to the trampoline function, which will be 109 | // used to call the original target function. 110 | // This parameter can be NULL. 111 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); 112 | 113 | // Creates a Hook for the specified API function, in disabled state. 114 | // Parameters: 115 | // pszModule [in] A pointer to the loaded module name which contains the 116 | // target function. 117 | // pszTarget [in] A pointer to the target function name, which will be 118 | // overridden by the detour function. 119 | // pDetour [in] A pointer to the detour function, which will override 120 | // the target function. 121 | // ppOriginal [out] A pointer to the trampoline function, which will be 122 | // used to call the original target function. 123 | // This parameter can be NULL. 124 | MH_STATUS WINAPI MH_CreateHookApi( 125 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); 126 | 127 | // Creates a Hook for the specified API function, in disabled state. 128 | // Parameters: 129 | // pszModule [in] A pointer to the loaded module name which contains the 130 | // target function. 131 | // pszTarget [in] A pointer to the target function name, which will be 132 | // overridden by the detour function. 133 | // pDetour [in] A pointer to the detour function, which will override 134 | // the target function. 135 | // ppOriginal [out] A pointer to the trampoline function, which will be 136 | // used to call the original target function. 137 | // This parameter can be NULL. 138 | // ppTarget [out] A pointer to the target function, which will be used 139 | // with other functions. 140 | // This parameter can be NULL. 141 | MH_STATUS WINAPI MH_CreateHookApiEx( 142 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); 143 | 144 | // Creates a Hook for the specified virtual method, in disabled state. 145 | // Parameters: 146 | // pInstance [in] A pointer to the instance of the class which contains the 147 | // virtual method table. 148 | // methodPos [in] The zero-based position of the target method in the table, 149 | // which will be overridden by the detour function. 150 | // pDetour [in] A pointer to the detour function, which will override 151 | // the target method. 152 | // ppOriginal [out] A pointer to the trampoline function, which will be 153 | // used to call the original target function. 154 | // This parameter can be NULL. 155 | MH_STATUS WINAPI MH_CreateHookVirtual( 156 | LPVOID pInstance, UINT methodPos, LPVOID pDetour, LPVOID* ppOriginal); 157 | 158 | // Creates a Hook for the specified virtual method, in disabled state. 159 | // Parameters: 160 | // pInstance [in] A pointer to the instance of the class which contains the 161 | // virtual method table. 162 | // methodPos [in] The zero-based position of the target method in the table, 163 | // which will be overridden by the detour function. 164 | // pDetour [in] A pointer to the detour function, which will override 165 | // the target method. 166 | // ppOriginal [out] A pointer to the trampoline function, which will be 167 | // used to call the original target function. 168 | // This parameter can be NULL. 169 | // ppTarget [out] A pointer to the target function, which will be used 170 | // with other functions. 171 | // This parameter can be NULL. 172 | MH_STATUS WINAPI MH_CreateHookVirtualEx( 173 | LPVOID pInstance, UINT methodPos, LPVOID pDetour, LPVOID* ppOriginal, LPVOID* ppTarget); 174 | 175 | // Removes an already created hook. 176 | // Parameters: 177 | // pTarget [in] A pointer to the target function. 178 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 179 | 180 | // Enables an already created hook. 181 | // Parameters: 182 | // pTarget [in] A pointer to the target function. 183 | // If this parameter is MH_ALL_HOOKS, all created hooks are 184 | // enabled in one go. 185 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 186 | 187 | // Disables an already created hook. 188 | // Parameters: 189 | // pTarget [in] A pointer to the target function. 190 | // If this parameter is MH_ALL_HOOKS, all created hooks are 191 | // disabled in one go. 192 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 193 | 194 | // Queues to enable an already created hook. 195 | // Parameters: 196 | // pTarget [in] A pointer to the target function. 197 | // If this parameter is MH_ALL_HOOKS, all created hooks are 198 | // queued to be enabled. 199 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 200 | 201 | // Queues to disable an already created hook. 202 | // Parameters: 203 | // pTarget [in] A pointer to the target function. 204 | // If this parameter is MH_ALL_HOOKS, all created hooks are 205 | // queued to be disabled. 206 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 207 | 208 | // Applies all queued changes in one go. 209 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 210 | 211 | // Translates the MH_STATUS to its name as a string. 212 | const char * WINAPI MH_StatusToString(MH_STATUS status); 213 | 214 | #ifdef __cplusplus 215 | } 216 | #endif 217 | 218 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/hde64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 64 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #if defined(_M_X64) || defined(__x86_64__) 9 | 10 | #include 11 | #include "hde64.h" 12 | #include "table64.h" 13 | 14 | unsigned int hde64_disasm(const void* code, hde64s* hs) 15 | { 16 | uint8_t x, c, * p = (uint8_t*)code, cflags, opcode, pref = 0; 17 | uint8_t* ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0; 18 | uint8_t op64 = 0; 19 | 20 | memset(hs, 0, sizeof(hde64s)); 21 | 22 | for (x = 16; x; x--) 23 | switch (c = *p++) { 24 | case 0xf3: 25 | hs->p_rep = c; 26 | pref |= PRE_F3; 27 | break; 28 | case 0xf2: 29 | hs->p_rep = c; 30 | pref |= PRE_F2; 31 | break; 32 | case 0xf0: 33 | hs->p_lock = c; 34 | pref |= PRE_LOCK; 35 | break; 36 | case 0x26: case 0x2e: case 0x36: 37 | case 0x3e: case 0x64: case 0x65: 38 | hs->p_seg = c; 39 | pref |= PRE_SEG; 40 | break; 41 | case 0x66: 42 | hs->p_66 = c; 43 | pref |= PRE_66; 44 | break; 45 | case 0x67: 46 | hs->p_67 = c; 47 | pref |= PRE_67; 48 | break; 49 | default: 50 | goto pref_done; 51 | } 52 | pref_done: 53 | 54 | hs->flags = (uint32_t)pref << 23; 55 | 56 | if (!pref) 57 | pref |= PRE_NONE; 58 | 59 | if ((c & 0xf0) == 0x40) { 60 | hs->flags |= F_PREFIX_REX; 61 | if ((hs->rex_w = (c & 0xf) >> 3) && (*p & 0xf8) == 0xb8) 62 | op64++; 63 | hs->rex_r = (c & 7) >> 2; 64 | hs->rex_x = (c & 3) >> 1; 65 | hs->rex_b = c & 1; 66 | if (((c = *p++) & 0xf0) == 0x40) { 67 | opcode = c; 68 | goto error_opcode; 69 | } 70 | } 71 | 72 | if ((hs->opcode = c) == 0x0f) { 73 | hs->opcode2 = c = *p++; 74 | ht += DELTA_OPCODES; 75 | } 76 | else if (c >= 0xa0 && c <= 0xa3) { 77 | op64++; 78 | if (pref & PRE_67) 79 | pref |= PRE_66; 80 | else 81 | pref &= ~PRE_66; 82 | } 83 | 84 | opcode = c; 85 | cflags = ht[ht[opcode / 4] + (opcode % 4)]; 86 | 87 | if (cflags == C_ERROR) { 88 | error_opcode: 89 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 90 | cflags = 0; 91 | if ((opcode & -3) == 0x24) 92 | cflags++; 93 | } 94 | 95 | x = 0; 96 | if (cflags & C_GROUP) { 97 | uint16_t t; 98 | t = *(uint16_t*)(ht + (cflags & 0x7f)); 99 | cflags = (uint8_t)t; 100 | x = (uint8_t)(t >> 8); 101 | } 102 | 103 | if (hs->opcode2) { 104 | ht = hde64_table + DELTA_PREFIXES; 105 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref) 106 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 107 | } 108 | 109 | if (cflags & C_MODRM) { 110 | hs->flags |= F_MODRM; 111 | hs->modrm = c = *p++; 112 | hs->modrm_mod = m_mod = c >> 6; 113 | hs->modrm_rm = m_rm = c & 7; 114 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3; 115 | 116 | if (x && ((x << m_reg) & 0x80)) 117 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 118 | 119 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) { 120 | uint8_t t = opcode - 0xd9; 121 | if (m_mod == 3) { 122 | ht = hde64_table + DELTA_FPU_MODRM + t * 8; 123 | t = ht[m_reg] << m_rm; 124 | } 125 | else { 126 | ht = hde64_table + DELTA_FPU_REG; 127 | t = ht[t] << m_reg; 128 | } 129 | if (t & 0x80) 130 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 131 | } 132 | 133 | if (pref & PRE_LOCK) { 134 | if (m_mod == 3) { 135 | hs->flags |= F_ERROR | F_ERROR_LOCK; 136 | } 137 | else { 138 | uint8_t* table_end, op = opcode; 139 | if (hs->opcode2) { 140 | ht = hde64_table + DELTA_OP2_LOCK_OK; 141 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK; 142 | } 143 | else { 144 | ht = hde64_table + DELTA_OP_LOCK_OK; 145 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK; 146 | op &= -2; 147 | } 148 | for (; ht != table_end; ht++) 149 | if (*ht++ == op) { 150 | if (!((*ht << m_reg) & 0x80)) 151 | goto no_lock_error; 152 | else 153 | break; 154 | } 155 | hs->flags |= F_ERROR | F_ERROR_LOCK; 156 | no_lock_error: 157 | ; 158 | } 159 | } 160 | 161 | if (hs->opcode2) { 162 | switch (opcode) { 163 | case 0x20: case 0x22: 164 | m_mod = 3; 165 | if (m_reg > 4 || m_reg == 1) 166 | goto error_operand; 167 | else 168 | goto no_error_operand; 169 | case 0x21: case 0x23: 170 | m_mod = 3; 171 | if (m_reg == 4 || m_reg == 5) 172 | goto error_operand; 173 | else 174 | goto no_error_operand; 175 | } 176 | } 177 | else { 178 | switch (opcode) { 179 | case 0x8c: 180 | if (m_reg > 5) 181 | goto error_operand; 182 | else 183 | goto no_error_operand; 184 | case 0x8e: 185 | if (m_reg == 1 || m_reg > 5) 186 | goto error_operand; 187 | else 188 | goto no_error_operand; 189 | } 190 | } 191 | 192 | if (m_mod == 3) { 193 | uint8_t* table_end; 194 | if (hs->opcode2) { 195 | ht = hde64_table + DELTA_OP2_ONLY_MEM; 196 | table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM; 197 | } 198 | else { 199 | ht = hde64_table + DELTA_OP_ONLY_MEM; 200 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM; 201 | } 202 | for (; ht != table_end; ht += 2) 203 | if (*ht++ == opcode) { 204 | if (*ht++ & pref && !((*ht << m_reg) & 0x80)) 205 | goto error_operand; 206 | else 207 | break; 208 | } 209 | goto no_error_operand; 210 | } 211 | else if (hs->opcode2) { 212 | switch (opcode) { 213 | case 0x50: case 0xd7: case 0xf7: 214 | if (pref & (PRE_NONE | PRE_66)) 215 | goto error_operand; 216 | break; 217 | case 0xd6: 218 | if (pref & (PRE_F2 | PRE_F3)) 219 | goto error_operand; 220 | break; 221 | case 0xc5: 222 | goto error_operand; 223 | } 224 | goto no_error_operand; 225 | } 226 | else 227 | goto no_error_operand; 228 | 229 | error_operand: 230 | hs->flags |= F_ERROR | F_ERROR_OPERAND; 231 | no_error_operand: 232 | 233 | c = *p++; 234 | if (m_reg <= 1) { 235 | if (opcode == 0xf6) 236 | cflags |= C_IMM8; 237 | else if (opcode == 0xf7) 238 | cflags |= C_IMM_P66; 239 | } 240 | 241 | switch (m_mod) { 242 | case 0: 243 | if (m_rm == 5) 244 | disp_size = 4; 245 | break; 246 | case 1: 247 | disp_size = 1; 248 | break; 249 | case 2: 250 | disp_size = 4; 251 | } 252 | 253 | if (m_mod != 3 && m_rm == 4) { 254 | hs->flags |= F_SIB; 255 | p++; 256 | hs->sib = c; 257 | hs->sib_scale = c >> 6; 258 | hs->sib_index = (c & 0x3f) >> 3; 259 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1)) 260 | disp_size = 4; 261 | } 262 | 263 | p--; 264 | switch (disp_size) { 265 | case 1: 266 | hs->flags |= F_DISP8; 267 | hs->disp.disp8 = *p; 268 | break; 269 | case 2: 270 | hs->flags |= F_DISP16; 271 | hs->disp.disp16 = *(uint16_t*)p; 272 | break; 273 | case 4: 274 | hs->flags |= F_DISP32; 275 | hs->disp.disp32 = *(uint32_t*)p; 276 | } 277 | p += disp_size; 278 | } 279 | else if (pref & PRE_LOCK) 280 | hs->flags |= F_ERROR | F_ERROR_LOCK; 281 | 282 | if (cflags & C_IMM_P66) { 283 | if (cflags & C_REL32) { 284 | if (pref & PRE_66) { 285 | hs->flags |= F_IMM16 | F_RELATIVE; 286 | hs->imm.imm16 = *(uint16_t*)p; 287 | p += 2; 288 | goto disasm_done; 289 | } 290 | goto rel32_ok; 291 | } 292 | if (op64) { 293 | hs->flags |= F_IMM64; 294 | hs->imm.imm64 = *(uint64_t*)p; 295 | p += 8; 296 | } 297 | else if (!(pref & PRE_66)) { 298 | hs->flags |= F_IMM32; 299 | hs->imm.imm32 = *(uint32_t*)p; 300 | p += 4; 301 | } 302 | else 303 | goto imm16_ok; 304 | } 305 | 306 | 307 | if (cflags & C_IMM16) { 308 | imm16_ok: 309 | hs->flags |= F_IMM16; 310 | hs->imm.imm16 = *(uint16_t*)p; 311 | p += 2; 312 | } 313 | if (cflags & C_IMM8) { 314 | hs->flags |= F_IMM8; 315 | hs->imm.imm8 = *p++; 316 | } 317 | 318 | if (cflags & C_REL32) { 319 | rel32_ok: 320 | hs->flags |= F_IMM32 | F_RELATIVE; 321 | hs->imm.imm32 = *(uint32_t*)p; 322 | p += 4; 323 | } 324 | else if (cflags & C_REL8) { 325 | hs->flags |= F_IMM8 | F_RELATIVE; 326 | hs->imm.imm8 = *p++; 327 | } 328 | 329 | disasm_done: 330 | 331 | if ((hs->len = (uint8_t)(p - (uint8_t*)code)) > 15) { 332 | hs->flags |= F_ERROR | F_ERROR_LENGTH; 333 | hs->len = 15; 334 | } 335 | 336 | return (unsigned int)hs->len; 337 | } 338 | 339 | #endif // defined(_M_X64) || defined(__x86_64__) -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/hde/hde32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 32 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #if defined(_M_IX86) || defined(__i386__) 9 | 10 | #include "hde32.h" 11 | #include "table32.h" 12 | 13 | unsigned int hde32_disasm(const void *code, hde32s *hs) 14 | { 15 | uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0; 16 | uint8_t *ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0; 17 | 18 | // Avoid using memset to reduce the footprint. 19 | #ifndef _MSC_VER 20 | memset((LPBYTE)hs, 0, sizeof(hde32s)); 21 | #else 22 | __stosb((LPBYTE)hs, 0, sizeof(hde32s)); 23 | #endif 24 | 25 | for (x = 16; x; x--) 26 | switch (c = *p++) { 27 | case 0xf3: 28 | hs->p_rep = c; 29 | pref |= PRE_F3; 30 | break; 31 | case 0xf2: 32 | hs->p_rep = c; 33 | pref |= PRE_F2; 34 | break; 35 | case 0xf0: 36 | hs->p_lock = c; 37 | pref |= PRE_LOCK; 38 | break; 39 | case 0x26: case 0x2e: case 0x36: 40 | case 0x3e: case 0x64: case 0x65: 41 | hs->p_seg = c; 42 | pref |= PRE_SEG; 43 | break; 44 | case 0x66: 45 | hs->p_66 = c; 46 | pref |= PRE_66; 47 | break; 48 | case 0x67: 49 | hs->p_67 = c; 50 | pref |= PRE_67; 51 | break; 52 | default: 53 | goto pref_done; 54 | } 55 | pref_done: 56 | 57 | hs->flags = (uint32_t)pref << 23; 58 | 59 | if (!pref) 60 | pref |= PRE_NONE; 61 | 62 | if ((hs->opcode = c) == 0x0f) { 63 | hs->opcode2 = c = *p++; 64 | ht += DELTA_OPCODES; 65 | } else if (c >= 0xa0 && c <= 0xa3) { 66 | if (pref & PRE_67) 67 | pref |= PRE_66; 68 | else 69 | pref &= ~PRE_66; 70 | } 71 | 72 | opcode = c; 73 | cflags = ht[ht[opcode / 4] + (opcode % 4)]; 74 | 75 | if (cflags == C_ERROR) { 76 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 77 | cflags = 0; 78 | if ((opcode & -3) == 0x24) 79 | cflags++; 80 | } 81 | 82 | x = 0; 83 | if (cflags & C_GROUP) { 84 | uint16_t t; 85 | t = *(uint16_t *)(ht + (cflags & 0x7f)); 86 | cflags = (uint8_t)t; 87 | x = (uint8_t)(t >> 8); 88 | } 89 | 90 | if (hs->opcode2) { 91 | ht = hde32_table + DELTA_PREFIXES; 92 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref) 93 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 94 | } 95 | 96 | if (cflags & C_MODRM) { 97 | hs->flags |= F_MODRM; 98 | hs->modrm = c = *p++; 99 | hs->modrm_mod = m_mod = c >> 6; 100 | hs->modrm_rm = m_rm = c & 7; 101 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3; 102 | 103 | if (x && ((x << m_reg) & 0x80)) 104 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 105 | 106 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) { 107 | uint8_t t = opcode - 0xd9; 108 | if (m_mod == 3) { 109 | ht = hde32_table + DELTA_FPU_MODRM + t*8; 110 | t = ht[m_reg] << m_rm; 111 | } else { 112 | ht = hde32_table + DELTA_FPU_REG; 113 | t = ht[t] << m_reg; 114 | } 115 | if (t & 0x80) 116 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 117 | } 118 | 119 | if (pref & PRE_LOCK) { 120 | if (m_mod == 3) { 121 | hs->flags |= F_ERROR | F_ERROR_LOCK; 122 | } else { 123 | uint8_t *table_end, op = opcode; 124 | if (hs->opcode2) { 125 | ht = hde32_table + DELTA_OP2_LOCK_OK; 126 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK; 127 | } else { 128 | ht = hde32_table + DELTA_OP_LOCK_OK; 129 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK; 130 | op &= -2; 131 | } 132 | for (; ht != table_end; ht++) 133 | if (*ht++ == op) { 134 | if (!((*ht << m_reg) & 0x80)) 135 | goto no_lock_error; 136 | else 137 | break; 138 | } 139 | hs->flags |= F_ERROR | F_ERROR_LOCK; 140 | no_lock_error: 141 | ; 142 | } 143 | } 144 | 145 | if (hs->opcode2) { 146 | switch (opcode) { 147 | case 0x20: case 0x22: 148 | m_mod = 3; 149 | if (m_reg > 4 || m_reg == 1) 150 | goto error_operand; 151 | else 152 | goto no_error_operand; 153 | case 0x21: case 0x23: 154 | m_mod = 3; 155 | if (m_reg == 4 || m_reg == 5) 156 | goto error_operand; 157 | else 158 | goto no_error_operand; 159 | } 160 | } else { 161 | switch (opcode) { 162 | case 0x8c: 163 | if (m_reg > 5) 164 | goto error_operand; 165 | else 166 | goto no_error_operand; 167 | case 0x8e: 168 | if (m_reg == 1 || m_reg > 5) 169 | goto error_operand; 170 | else 171 | goto no_error_operand; 172 | } 173 | } 174 | 175 | if (m_mod == 3) { 176 | uint8_t *table_end; 177 | if (hs->opcode2) { 178 | ht = hde32_table + DELTA_OP2_ONLY_MEM; 179 | table_end = ht + sizeof(hde32_table) - DELTA_OP2_ONLY_MEM; 180 | } else { 181 | ht = hde32_table + DELTA_OP_ONLY_MEM; 182 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM; 183 | } 184 | for (; ht != table_end; ht += 2) 185 | if (*ht++ == opcode) { 186 | if (*ht++ & pref && !((*ht << m_reg) & 0x80)) 187 | goto error_operand; 188 | else 189 | break; 190 | } 191 | goto no_error_operand; 192 | } else if (hs->opcode2) { 193 | switch (opcode) { 194 | case 0x50: case 0xd7: case 0xf7: 195 | if (pref & (PRE_NONE | PRE_66)) 196 | goto error_operand; 197 | break; 198 | case 0xd6: 199 | if (pref & (PRE_F2 | PRE_F3)) 200 | goto error_operand; 201 | break; 202 | case 0xc5: 203 | goto error_operand; 204 | } 205 | goto no_error_operand; 206 | } else 207 | goto no_error_operand; 208 | 209 | error_operand: 210 | hs->flags |= F_ERROR | F_ERROR_OPERAND; 211 | no_error_operand: 212 | 213 | c = *p++; 214 | if (m_reg <= 1) { 215 | if (opcode == 0xf6) 216 | cflags |= C_IMM8; 217 | else if (opcode == 0xf7) 218 | cflags |= C_IMM_P66; 219 | } 220 | 221 | switch (m_mod) { 222 | case 0: 223 | if (pref & PRE_67) { 224 | if (m_rm == 6) 225 | disp_size = 2; 226 | } else 227 | if (m_rm == 5) 228 | disp_size = 4; 229 | break; 230 | case 1: 231 | disp_size = 1; 232 | break; 233 | case 2: 234 | disp_size = 2; 235 | if (!(pref & PRE_67)) 236 | disp_size <<= 1; 237 | } 238 | 239 | if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) { 240 | hs->flags |= F_SIB; 241 | p++; 242 | hs->sib = c; 243 | hs->sib_scale = c >> 6; 244 | hs->sib_index = (c & 0x3f) >> 3; 245 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1)) 246 | disp_size = 4; 247 | } 248 | 249 | p--; 250 | switch (disp_size) { 251 | case 1: 252 | hs->flags |= F_DISP8; 253 | hs->disp.disp8 = *p; 254 | break; 255 | case 2: 256 | hs->flags |= F_DISP16; 257 | hs->disp.disp16 = *(uint16_t *)p; 258 | break; 259 | case 4: 260 | hs->flags |= F_DISP32; 261 | hs->disp.disp32 = *(uint32_t *)p; 262 | } 263 | p += disp_size; 264 | } else if (pref & PRE_LOCK) 265 | hs->flags |= F_ERROR | F_ERROR_LOCK; 266 | 267 | if (cflags & C_IMM_P66) { 268 | if (cflags & C_REL32) { 269 | if (pref & PRE_66) { 270 | hs->flags |= F_IMM16 | F_RELATIVE; 271 | hs->imm.imm16 = *(uint16_t *)p; 272 | p += 2; 273 | goto disasm_done; 274 | } 275 | goto rel32_ok; 276 | } 277 | if (pref & PRE_66) { 278 | hs->flags |= F_IMM16; 279 | hs->imm.imm16 = *(uint16_t *)p; 280 | p += 2; 281 | } else { 282 | hs->flags |= F_IMM32; 283 | hs->imm.imm32 = *(uint32_t *)p; 284 | p += 4; 285 | } 286 | } 287 | 288 | if (cflags & C_IMM16) { 289 | if (hs->flags & F_IMM32) { 290 | hs->flags |= F_IMM16; 291 | hs->disp.disp16 = *(uint16_t *)p; 292 | } else if (hs->flags & F_IMM16) { 293 | hs->flags |= F_2IMM16; 294 | hs->disp.disp16 = *(uint16_t *)p; 295 | } else { 296 | hs->flags |= F_IMM16; 297 | hs->imm.imm16 = *(uint16_t *)p; 298 | } 299 | p += 2; 300 | } 301 | if (cflags & C_IMM8) { 302 | hs->flags |= F_IMM8; 303 | hs->imm.imm8 = *p++; 304 | } 305 | 306 | if (cflags & C_REL32) { 307 | rel32_ok: 308 | hs->flags |= F_IMM32 | F_RELATIVE; 309 | hs->imm.imm32 = *(uint32_t *)p; 310 | p += 4; 311 | } else if (cflags & C_REL8) { 312 | hs->flags |= F_IMM8 | F_RELATIVE; 313 | hs->imm.imm8 = *p++; 314 | } 315 | 316 | disasm_done: 317 | 318 | if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) { 319 | hs->flags |= F_ERROR | F_ERROR_LENGTH; 320 | hs->len = 15; 321 | } 322 | 323 | return (unsigned int)hs->len; 324 | } 325 | 326 | #endif // defined(_M_IX86) || defined(__i386__) 327 | -------------------------------------------------------------------------------- /src/Cloud-Internal.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 17.0 15 | Win32Proj 16 | {080fcf7f-1a84-40fd-9df2-941aad42e03e} 17 | clouds 18 | 10.0 19 | cloud-sdk 20 | 21 | 22 | 23 | DynamicLibrary 24 | true 25 | v143 26 | Unicode 27 | 28 | 29 | DynamicLibrary 30 | false 31 | v143 32 | true 33 | Unicode 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | cloud-cs2 49 | $(SolutionDir)\bin\$(Configuration)\ 50 | $(SolutionDir)\build\$(Configuration)\ 51 | 52 | 53 | $(SolutionDir)\bin\$(Configuration)\ 54 | cloud-cs2 55 | $(SolutionDir)\build\$(Configuration)\ 56 | C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;$(IncludePath) 57 | C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64;$(LibraryPath) 58 | 59 | 60 | 61 | TurnOffAllWarnings 62 | true 63 | _DEBUG;SENSUM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 64 | true 65 | NotUsing 66 | 67 | 68 | stdcpplatest 69 | $(SolutionDir)vendor\Zydis;%(AdditionalIncludeDirectories) 70 | 71 | 72 | Windows 73 | true 74 | false 75 | 76 | 77 | 78 | 79 | TurnOffAllWarnings 80 | true 81 | true 82 | true 83 | NDEBUG;SENSUM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 84 | true 85 | NotUsing 86 | 87 | 88 | stdcpp20 89 | 90 | 91 | Windows 92 | true 93 | true 94 | true 95 | false 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 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 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/buffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | #include "buffer.h" 31 | 32 | // Size of each memory block. (= page size of VirtualAlloc) 33 | #define MEMORY_BLOCK_SIZE 0x1000 34 | 35 | // Max range for seeking a memory block. (= 1024MB) 36 | #define MAX_MEMORY_RANGE 0x40000000 37 | 38 | // Memory protection flags to check the executable address. 39 | #define PAGE_EXECUTE_FLAGS \ 40 | (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY) 41 | 42 | // Memory slot. 43 | typedef struct _MEMORY_SLOT 44 | { 45 | union 46 | { 47 | struct _MEMORY_SLOT *pNext; 48 | UINT8 buffer[MEMORY_SLOT_SIZE]; 49 | }; 50 | } MEMORY_SLOT, *PMEMORY_SLOT; 51 | 52 | // Memory block info. Placed at the head of each block. 53 | typedef struct _MEMORY_BLOCK 54 | { 55 | struct _MEMORY_BLOCK *pNext; 56 | PMEMORY_SLOT pFree; // First element of the free slot list. 57 | UINT usedCount; 58 | } MEMORY_BLOCK, *PMEMORY_BLOCK; 59 | 60 | //------------------------------------------------------------------------- 61 | // Global Variables: 62 | //------------------------------------------------------------------------- 63 | 64 | // First element of the memory block list. 65 | PMEMORY_BLOCK g_pMemoryBlocks; 66 | 67 | //------------------------------------------------------------------------- 68 | VOID InitializeBuffer(VOID) 69 | { 70 | // Nothing to do for now. 71 | } 72 | 73 | //------------------------------------------------------------------------- 74 | VOID UninitializeBuffer(VOID) 75 | { 76 | PMEMORY_BLOCK pBlock = g_pMemoryBlocks; 77 | g_pMemoryBlocks = NULL; 78 | 79 | while (pBlock) 80 | { 81 | PMEMORY_BLOCK pNext = pBlock->pNext; 82 | VirtualFree(pBlock, 0, MEM_RELEASE); 83 | pBlock = pNext; 84 | } 85 | } 86 | 87 | //------------------------------------------------------------------------- 88 | #if defined(_M_X64) || defined(__x86_64__) 89 | static LPVOID FindPrevFreeRegion(LPVOID pAddress, LPVOID pMinAddr, DWORD dwAllocationGranularity) 90 | { 91 | ULONG_PTR tryAddr = (ULONG_PTR)pAddress; 92 | 93 | // Round down to the allocation granularity. 94 | tryAddr -= tryAddr % dwAllocationGranularity; 95 | 96 | // Start from the previous allocation granularity multiply. 97 | tryAddr -= dwAllocationGranularity; 98 | 99 | while (tryAddr >= (ULONG_PTR)pMinAddr) 100 | { 101 | MEMORY_BASIC_INFORMATION mbi; 102 | if (VirtualQuery((LPVOID)tryAddr, &mbi, sizeof(mbi)) == 0) 103 | break; 104 | 105 | if (mbi.State == MEM_FREE) 106 | return (LPVOID)tryAddr; 107 | 108 | if ((ULONG_PTR)mbi.AllocationBase < dwAllocationGranularity) 109 | break; 110 | 111 | tryAddr = (ULONG_PTR)mbi.AllocationBase - dwAllocationGranularity; 112 | } 113 | 114 | return NULL; 115 | } 116 | #endif 117 | 118 | //------------------------------------------------------------------------- 119 | #if defined(_M_X64) || defined(__x86_64__) 120 | static LPVOID FindNextFreeRegion(LPVOID pAddress, LPVOID pMaxAddr, DWORD dwAllocationGranularity) 121 | { 122 | ULONG_PTR tryAddr = (ULONG_PTR)pAddress; 123 | 124 | // Round down to the allocation granularity. 125 | tryAddr -= tryAddr % dwAllocationGranularity; 126 | 127 | // Start from the next allocation granularity multiply. 128 | tryAddr += dwAllocationGranularity; 129 | 130 | while (tryAddr <= (ULONG_PTR)pMaxAddr) 131 | { 132 | MEMORY_BASIC_INFORMATION mbi; 133 | if (VirtualQuery((LPVOID)tryAddr, &mbi, sizeof(mbi)) == 0) 134 | break; 135 | 136 | if (mbi.State == MEM_FREE) 137 | return (LPVOID)tryAddr; 138 | 139 | tryAddr = (ULONG_PTR)mbi.BaseAddress + mbi.RegionSize; 140 | 141 | // Round up to the next allocation granularity. 142 | tryAddr += dwAllocationGranularity - 1; 143 | tryAddr -= tryAddr % dwAllocationGranularity; 144 | } 145 | 146 | return NULL; 147 | } 148 | #endif 149 | 150 | //------------------------------------------------------------------------- 151 | static PMEMORY_BLOCK GetMemoryBlock(LPVOID pOrigin) 152 | { 153 | PMEMORY_BLOCK pBlock; 154 | #if defined(_M_X64) || defined(__x86_64__) 155 | ULONG_PTR minAddr; 156 | ULONG_PTR maxAddr; 157 | 158 | SYSTEM_INFO si; 159 | GetSystemInfo(&si); 160 | minAddr = (ULONG_PTR)si.lpMinimumApplicationAddress; 161 | maxAddr = (ULONG_PTR)si.lpMaximumApplicationAddress; 162 | 163 | // pOrigin ± 512MB 164 | if ((ULONG_PTR)pOrigin > MAX_MEMORY_RANGE && minAddr < (ULONG_PTR)pOrigin - MAX_MEMORY_RANGE) 165 | minAddr = (ULONG_PTR)pOrigin - MAX_MEMORY_RANGE; 166 | 167 | if (maxAddr > (ULONG_PTR)pOrigin + MAX_MEMORY_RANGE) 168 | maxAddr = (ULONG_PTR)pOrigin + MAX_MEMORY_RANGE; 169 | 170 | // Make room for MEMORY_BLOCK_SIZE bytes. 171 | maxAddr -= MEMORY_BLOCK_SIZE - 1; 172 | #endif 173 | 174 | // Look the registered blocks for a reachable one. 175 | for (pBlock = g_pMemoryBlocks; pBlock != NULL; pBlock = pBlock->pNext) 176 | { 177 | #if defined(_M_X64) || defined(__x86_64__) 178 | // Ignore the blocks too far. 179 | if ((ULONG_PTR)pBlock < minAddr || (ULONG_PTR)pBlock >= maxAddr) 180 | continue; 181 | #endif 182 | // The block has at least one unused slot. 183 | if (pBlock->pFree != NULL) 184 | return pBlock; 185 | } 186 | 187 | #if defined(_M_X64) || defined(__x86_64__) 188 | // Alloc a new block above if not found. 189 | { 190 | LPVOID pAlloc = pOrigin; 191 | while ((ULONG_PTR)pAlloc >= minAddr) 192 | { 193 | pAlloc = FindPrevFreeRegion(pAlloc, (LPVOID)minAddr, si.dwAllocationGranularity); 194 | if (pAlloc == NULL) 195 | break; 196 | 197 | pBlock = (PMEMORY_BLOCK)VirtualAlloc( 198 | pAlloc, MEMORY_BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); 199 | if (pBlock != NULL) 200 | break; 201 | } 202 | } 203 | 204 | // Alloc a new block below if not found. 205 | if (pBlock == NULL) 206 | { 207 | LPVOID pAlloc = pOrigin; 208 | while ((ULONG_PTR)pAlloc <= maxAddr) 209 | { 210 | pAlloc = FindNextFreeRegion(pAlloc, (LPVOID)maxAddr, si.dwAllocationGranularity); 211 | if (pAlloc == NULL) 212 | break; 213 | 214 | pBlock = (PMEMORY_BLOCK)VirtualAlloc( 215 | pAlloc, MEMORY_BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); 216 | if (pBlock != NULL) 217 | break; 218 | } 219 | } 220 | #else 221 | // In x86 mode, a memory block can be placed anywhere. 222 | pBlock = (PMEMORY_BLOCK)VirtualAlloc( 223 | NULL, MEMORY_BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); 224 | #endif 225 | 226 | if (pBlock != NULL) 227 | { 228 | // Build a linked list of all the slots. 229 | PMEMORY_SLOT pSlot = (PMEMORY_SLOT)pBlock + 1; 230 | pBlock->pFree = NULL; 231 | pBlock->usedCount = 0; 232 | do 233 | { 234 | pSlot->pNext = pBlock->pFree; 235 | pBlock->pFree = pSlot; 236 | pSlot++; 237 | } while ((ULONG_PTR)pSlot - (ULONG_PTR)pBlock <= MEMORY_BLOCK_SIZE - MEMORY_SLOT_SIZE); 238 | 239 | pBlock->pNext = g_pMemoryBlocks; 240 | g_pMemoryBlocks = pBlock; 241 | } 242 | 243 | return pBlock; 244 | } 245 | 246 | //------------------------------------------------------------------------- 247 | LPVOID AllocateBuffer(LPVOID pOrigin) 248 | { 249 | PMEMORY_SLOT pSlot; 250 | PMEMORY_BLOCK pBlock = GetMemoryBlock(pOrigin); 251 | if (pBlock == NULL) 252 | return NULL; 253 | 254 | // Remove an unused slot from the list. 255 | pSlot = pBlock->pFree; 256 | pBlock->pFree = pSlot->pNext; 257 | pBlock->usedCount++; 258 | #ifdef _DEBUG 259 | // Fill the slot with INT3 for debugging. 260 | memset(pSlot, 0xCC, sizeof(MEMORY_SLOT)); 261 | #endif 262 | return pSlot; 263 | } 264 | 265 | //------------------------------------------------------------------------- 266 | VOID FreeBuffer(LPVOID pBuffer) 267 | { 268 | PMEMORY_BLOCK pBlock = g_pMemoryBlocks; 269 | PMEMORY_BLOCK pPrev = NULL; 270 | ULONG_PTR pTargetBlock = ((ULONG_PTR)pBuffer / MEMORY_BLOCK_SIZE) * MEMORY_BLOCK_SIZE; 271 | 272 | while (pBlock != NULL) 273 | { 274 | if ((ULONG_PTR)pBlock == pTargetBlock) 275 | { 276 | PMEMORY_SLOT pSlot = (PMEMORY_SLOT)pBuffer; 277 | #ifdef _DEBUG 278 | // Clear the released slot for debugging. 279 | memset(pSlot, 0x00, sizeof(*pSlot)); 280 | #endif 281 | // Restore the released slot to the list. 282 | pSlot->pNext = pBlock->pFree; 283 | pBlock->pFree = pSlot; 284 | pBlock->usedCount--; 285 | 286 | // Free if unused. 287 | if (pBlock->usedCount == 0) 288 | { 289 | if (pPrev) 290 | pPrev->pNext = pBlock->pNext; 291 | else 292 | g_pMemoryBlocks = pBlock->pNext; 293 | 294 | VirtualFree(pBlock, 0, MEM_RELEASE); 295 | } 296 | 297 | break; 298 | } 299 | 300 | pPrev = pBlock; 301 | pBlock = pBlock->pNext; 302 | } 303 | } 304 | 305 | //------------------------------------------------------------------------- 306 | BOOL IsExecutableAddress(LPVOID pAddress) 307 | { 308 | MEMORY_BASIC_INFORMATION mi; 309 | VirtualQuery(pAddress, &mi, sizeof(mi)); 310 | 311 | return (mi.State == MEM_COMMIT && (mi.Protect & PAGE_EXECUTE_FLAGS)); 312 | } 313 | -------------------------------------------------------------------------------- /src/sdk/hooking/minhook/trampoline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | 31 | #ifndef ARRAYSIZE 32 | #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) 33 | #endif 34 | 35 | #if defined(_M_X64) || defined(__x86_64__) 36 | #include "./hde/hde64.h" 37 | typedef hde64s HDE; 38 | #define HDE_DISASM(code, hs) hde64_disasm(code, hs) 39 | #else 40 | #include "./hde/hde32.h" 41 | typedef hde32s HDE; 42 | #define HDE_DISASM(code, hs) hde32_disasm(code, hs) 43 | #endif 44 | 45 | #include "trampoline.h" 46 | #include "buffer.h" 47 | 48 | // Maximum size of a trampoline function. 49 | #if defined(_M_X64) || defined(__x86_64__) 50 | #define TRAMPOLINE_MAX_SIZE (MEMORY_SLOT_SIZE - sizeof(JMP_ABS)) 51 | #else 52 | #define TRAMPOLINE_MAX_SIZE MEMORY_SLOT_SIZE 53 | #endif 54 | 55 | //------------------------------------------------------------------------- 56 | static BOOL IsCodePadding(LPBYTE pInst, UINT size) 57 | { 58 | UINT i; 59 | 60 | if (pInst[0] != 0x00 && pInst[0] != 0x90 && pInst[0] != 0xCC) 61 | return FALSE; 62 | 63 | for (i = 1; i < size; ++i) 64 | { 65 | if (pInst[i] != pInst[0]) 66 | return FALSE; 67 | } 68 | return TRUE; 69 | } 70 | 71 | //------------------------------------------------------------------------- 72 | BOOL CreateTrampolineFunction(PTRAMPOLINE ct) 73 | { 74 | #if defined(_M_X64) || defined(__x86_64__) 75 | CALL_ABS call = { 76 | 0xFF, 0x15, 0x00000002, // FF15 00000002: CALL [RIP+8] 77 | 0xEB, 0x08, // EB 08: JMP +10 78 | 0x0000000000000000ULL // Absolute destination address 79 | }; 80 | JMP_ABS jmp = { 81 | 0xFF, 0x25, 0x00000000, // FF25 00000000: JMP [RIP+6] 82 | 0x0000000000000000ULL // Absolute destination address 83 | }; 84 | JCC_ABS jcc = { 85 | 0x70, 0x0E, // 7* 0E: J** +16 86 | 0xFF, 0x25, 0x00000000, // FF25 00000000: JMP [RIP+6] 87 | 0x0000000000000000ULL // Absolute destination address 88 | }; 89 | #else 90 | CALL_REL call = { 91 | 0xE8, // E8 xxxxxxxx: CALL +5+xxxxxxxx 92 | 0x00000000 // Relative destination address 93 | }; 94 | JMP_REL jmp = { 95 | 0xE9, // E9 xxxxxxxx: JMP +5+xxxxxxxx 96 | 0x00000000 // Relative destination address 97 | }; 98 | JCC_REL jcc = { 99 | 0x0F, 0x80, // 0F8* xxxxxxxx: J** +6+xxxxxxxx 100 | 0x00000000 // Relative destination address 101 | }; 102 | #endif 103 | 104 | UINT8 oldPos = 0; 105 | UINT8 newPos = 0; 106 | ULONG_PTR jmpDest = 0; // Destination address of an internal jump. 107 | BOOL finished = FALSE; // Is the function completed? 108 | #if defined(_M_X64) || defined(__x86_64__) 109 | UINT8 instBuf[16]; 110 | #endif 111 | 112 | ct->patchAbove = FALSE; 113 | ct->nIP = 0; 114 | 115 | do 116 | { 117 | HDE hs; 118 | UINT copySize; 119 | LPVOID pCopySrc; 120 | ULONG_PTR pOldInst = (ULONG_PTR)ct->pTarget + oldPos; 121 | ULONG_PTR pNewInst = (ULONG_PTR)ct->pTrampoline + newPos; 122 | 123 | copySize = HDE_DISASM((LPVOID)pOldInst, &hs); 124 | if (hs.flags & F_ERROR) 125 | return FALSE; 126 | 127 | pCopySrc = (LPVOID)pOldInst; 128 | if (oldPos >= sizeof(JMP_REL)) 129 | { 130 | // The trampoline function is long enough. 131 | // Complete the function with the jump to the target function. 132 | #if defined(_M_X64) || defined(__x86_64__) 133 | jmp.address = pOldInst; 134 | #else 135 | jmp.operand = (UINT32)(pOldInst - (pNewInst + sizeof(jmp))); 136 | #endif 137 | pCopySrc = &jmp; 138 | copySize = sizeof(jmp); 139 | 140 | finished = TRUE; 141 | } 142 | #if defined(_M_X64) || defined(__x86_64__) 143 | else if ((hs.modrm & 0xC7) == 0x05) 144 | { 145 | // Instructions using RIP relative addressing. (ModR/M = 00???101B) 146 | 147 | // Modify the RIP relative address. 148 | PUINT32 pRelAddr; 149 | 150 | // Avoid using memcpy to reduce the footprint. 151 | #ifndef _MSC_VER 152 | memcpy(instBuf, (LPBYTE)pOldInst, copySize); 153 | #else 154 | __movsb(instBuf, (LPBYTE)pOldInst, copySize); 155 | #endif 156 | pCopySrc = instBuf; 157 | 158 | // Relative address is stored at (instruction length - immediate value length - 4). 159 | pRelAddr = (PUINT32)(instBuf + hs.len - ((hs.flags & 0x3C) >> 2) - 4); 160 | *pRelAddr 161 | = (UINT32)((pOldInst + hs.len + (INT32)hs.disp.disp32) - (pNewInst + hs.len)); 162 | 163 | // Complete the function if JMP (FF /4). 164 | if (hs.opcode == 0xFF && hs.modrm_reg == 4) 165 | finished = TRUE; 166 | } 167 | #endif 168 | else if (hs.opcode == 0xE8) 169 | { 170 | // Direct relative CALL 171 | ULONG_PTR dest = pOldInst + hs.len + (INT32)hs.imm.imm32; 172 | #if defined(_M_X64) || defined(__x86_64__) 173 | call.address = dest; 174 | #else 175 | call.operand = (UINT32)(dest - (pNewInst + sizeof(call))); 176 | #endif 177 | pCopySrc = &call; 178 | copySize = sizeof(call); 179 | } 180 | else if ((hs.opcode & 0xFD) == 0xE9) 181 | { 182 | // Direct relative JMP (EB or E9) 183 | ULONG_PTR dest = pOldInst + hs.len; 184 | 185 | if (hs.opcode == 0xEB) // isShort jmp 186 | dest += (INT8)hs.imm.imm8; 187 | else 188 | dest += (INT32)hs.imm.imm32; 189 | 190 | // Simply copy an internal jump. 191 | if ((ULONG_PTR)ct->pTarget <= dest 192 | && dest < ((ULONG_PTR)ct->pTarget + sizeof(JMP_REL))) 193 | { 194 | if (jmpDest < dest) 195 | jmpDest = dest; 196 | } 197 | else 198 | { 199 | #if defined(_M_X64) || defined(__x86_64__) 200 | jmp.address = dest; 201 | #else 202 | jmp.operand = (UINT32)(dest - (pNewInst + sizeof(jmp))); 203 | #endif 204 | pCopySrc = &jmp; 205 | copySize = sizeof(jmp); 206 | 207 | // Exit the function If it is not in the branch 208 | finished = (pOldInst >= jmpDest); 209 | } 210 | } 211 | else if ((hs.opcode & 0xF0) == 0x70 212 | || (hs.opcode & 0xFC) == 0xE0 213 | || (hs.opcode2 & 0xF0) == 0x80) 214 | { 215 | // Direct relative Jcc 216 | ULONG_PTR dest = pOldInst + hs.len; 217 | 218 | if ((hs.opcode & 0xF0) == 0x70 // Jcc 219 | || (hs.opcode & 0xFC) == 0xE0) // LOOPNZ/LOOPZ/LOOP/JECXZ 220 | dest += (INT8)hs.imm.imm8; 221 | else 222 | dest += (INT32)hs.imm.imm32; 223 | 224 | // Simply copy an internal jump. 225 | if ((ULONG_PTR)ct->pTarget <= dest 226 | && dest < ((ULONG_PTR)ct->pTarget + sizeof(JMP_REL))) 227 | { 228 | if (jmpDest < dest) 229 | jmpDest = dest; 230 | } 231 | else if ((hs.opcode & 0xFC) == 0xE0) 232 | { 233 | // LOOPNZ/LOOPZ/LOOP/JCXZ/JECXZ to the outside are not supported. 234 | return FALSE; 235 | } 236 | else 237 | { 238 | UINT8 cond = ((hs.opcode != 0x0F ? hs.opcode : hs.opcode2) & 0x0F); 239 | #if defined(_M_X64) || defined(__x86_64__) 240 | // Invert the condition in x64 mode to simplify the conditional jump logic. 241 | jcc.opcode = 0x71 ^ cond; 242 | jcc.address = dest; 243 | #else 244 | jcc.opcode1 = 0x80 | cond; 245 | jcc.operand = (UINT32)(dest - (pNewInst + sizeof(jcc))); 246 | #endif 247 | pCopySrc = &jcc; 248 | copySize = sizeof(jcc); 249 | } 250 | } 251 | else if ((hs.opcode & 0xFE) == 0xC2) 252 | { 253 | // RET (C2 or C3) 254 | 255 | // Complete the function if not in a branch. 256 | finished = (pOldInst >= jmpDest); 257 | } 258 | 259 | // Can't alter the instruction length in a branch. 260 | if (pOldInst < jmpDest && copySize != hs.len) 261 | return FALSE; 262 | 263 | // Trampoline function is too large. 264 | if ((newPos + copySize) > TRAMPOLINE_MAX_SIZE) 265 | return FALSE; 266 | 267 | // Trampoline function has too many instructions. 268 | if (ct->nIP >= ARRAYSIZE(ct->oldIPs)) 269 | return FALSE; 270 | 271 | ct->oldIPs[ct->nIP] = oldPos; 272 | ct->newIPs[ct->nIP] = newPos; 273 | ct->nIP++; 274 | 275 | // Avoid using memcpy to reduce the footprint. 276 | #ifndef _MSC_VER 277 | memcpy((LPBYTE)ct->pTrampoline + newPos, pCopySrc, copySize); 278 | #else 279 | __movsb((LPBYTE)ct->pTrampoline + newPos, pCopySrc, copySize); 280 | #endif 281 | newPos += copySize; 282 | oldPos += hs.len; 283 | } 284 | while (!finished); 285 | 286 | // Is there enough place for a long jump? 287 | if (oldPos < sizeof(JMP_REL) 288 | && !IsCodePadding((LPBYTE)ct->pTarget + oldPos, sizeof(JMP_REL) - oldPos)) 289 | { 290 | // Is there enough place for a short jump? 291 | if (oldPos < sizeof(JMP_REL_SHORT) 292 | && !IsCodePadding((LPBYTE)ct->pTarget + oldPos, sizeof(JMP_REL_SHORT) - oldPos)) 293 | { 294 | return FALSE; 295 | } 296 | 297 | // Can we place the long jump above the function? 298 | if (!IsExecutableAddress((LPBYTE)ct->pTarget - sizeof(JMP_REL))) 299 | return FALSE; 300 | 301 | if (!IsCodePadding((LPBYTE)ct->pTarget - sizeof(JMP_REL), sizeof(JMP_REL))) 302 | return FALSE; 303 | 304 | ct->patchAbove = TRUE; 305 | } 306 | 307 | #if defined(_M_X64) || defined(__x86_64__) 308 | // Create a relay function. 309 | jmp.address = (ULONG_PTR)ct->pDetour; 310 | 311 | ct->pRelay = (LPBYTE)ct->pTrampoline + newPos; 312 | memcpy(ct->pRelay, &jmp, sizeof(jmp)); 313 | #endif 314 | 315 | return TRUE; 316 | } 317 | -------------------------------------------------------------------------------- /src/Cloud-Internal.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {c9b3a16f-d44c-4de2-b2a3-b0b2bbbf48f3} 6 | 7 | 8 | {ab6ee54a-51b4-4907-af79-c614888de0de} 9 | 10 | 11 | {6701b1ae-6870-4e13-9684-63164f8aa6e6} 12 | 13 | 14 | {a42b14bb-c064-4bc4-ab30-157879b35527} 15 | 16 | 17 | {8d35a5ef-b844-4ff8-8b99-3815d6963d7d} 18 | 19 | 20 | {f6cf6b5b-aaec-4cea-b32e-5971754be6d6} 21 | 22 | 23 | {867b9848-d467-4fc1-8268-f004853a419f} 24 | 25 | 26 | {73f3fb94-f2b9-4e53-8320-b9851a791cf6} 27 | 28 | 29 | {e018ee6c-82f7-4e7a-a0f9-372b266f6aa5} 30 | 31 | 32 | {dd4269f1-5a17-49f6-9072-032ced46c8d6} 33 | 34 | 35 | {d7c987c8-d617-4171-8743-daca1b52155b} 36 | 37 | 38 | {7b9e56cf-4065-4cb3-9b93-8c170f6ccab3} 39 | 40 | 41 | {1835228c-b970-45fa-9e0b-5a632923ed12} 42 | 43 | 44 | {198305ad-65c6-4b18-86a7-7d20d90c2f36} 45 | 46 | 47 | 48 | 49 | sdk\interfaces 50 | 51 | 52 | sdk\interfaces 53 | 54 | 55 | sdk\interfaces 56 | 57 | 58 | sdk\interfaces 59 | 60 | 61 | sdk\interfaces 62 | 63 | 64 | sdk\classes 65 | 66 | 67 | sdk\classes 68 | 69 | 70 | sdk 71 | 72 | 73 | sdk\helpers 74 | 75 | 76 | sdk\helpers 77 | 78 | 79 | sdk\helpers 80 | 81 | 82 | sdk\helpers 83 | 84 | 85 | sdk\helpers 86 | 87 | 88 | sdk\helpers 89 | 90 | 91 | sdk\helpers 92 | 93 | 94 | sdk\helpers 95 | 96 | 97 | sdk\helpers 98 | 99 | 100 | sdk\helpers 101 | 102 | 103 | sdk\helpers 104 | 105 | 106 | sdk\helpers 107 | 108 | 109 | sdk\classes 110 | 111 | 112 | sdk\classes 113 | 114 | 115 | sdk\classes 116 | 117 | 118 | sdk\classes 119 | 120 | 121 | sdk\classes 122 | 123 | 124 | sdk\classes 125 | 126 | 127 | sdk\hooking\minhook\hde 128 | 129 | 130 | sdk\hooking\minhook\hde 131 | 132 | 133 | sdk\hooking\minhook\hde 134 | 135 | 136 | sdk\hooking\minhook\hde 137 | 138 | 139 | sdk\hooking\minhook\hde 140 | 141 | 142 | sdk\hooking\minhook 143 | 144 | 145 | sdk\hooking\minhook 146 | 147 | 148 | sdk\hooking\minhook 149 | 150 | 151 | hooks 152 | 153 | 154 | sdk\math 155 | 156 | 157 | sdk\classes 158 | 159 | 160 | sdk\helpers 161 | 162 | 163 | sdk\classes 164 | 165 | 166 | sdk\interfaces 167 | 168 | 169 | sdk\math 170 | 171 | 172 | thirdparty\imgui 173 | 174 | 175 | thirdparty\imgui 176 | 177 | 178 | thirdparty\imgui 179 | 180 | 181 | thirdparty\imgui 182 | 183 | 184 | thirdparty\imgui 185 | 186 | 187 | thirdparty\imgui 188 | 189 | 190 | thirdparty\imgui 191 | 192 | 193 | thirdparty\imgui 194 | 195 | 196 | menu 197 | 198 | 199 | settings 200 | 201 | 202 | sdk\helpers 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | sdk\classes 213 | 214 | 215 | sdk\classes 216 | 217 | 218 | sdk 219 | 220 | 221 | sdk\helpers 222 | 223 | 224 | sdk\helpers 225 | 226 | 227 | sdk\helpers 228 | 229 | 230 | sdk\helpers 231 | 232 | 233 | sdk\classes 234 | 235 | 236 | sdk\hooking\minhook\hde 237 | 238 | 239 | sdk\hooking\minhook\hde 240 | 241 | 242 | sdk\hooking\minhook 243 | 244 | 245 | sdk\hooking\minhook 246 | 247 | 248 | sdk\hooking\minhook 249 | 250 | 251 | hooks\functions 252 | 253 | 254 | hooks 255 | 256 | 257 | sdk\helpers 258 | 259 | 260 | sdk\helpers 261 | 262 | 263 | sdk\math 264 | 265 | 266 | sdk\helpers 267 | 268 | 269 | sdk\classes 270 | 271 | 272 | hooks\functions 273 | 274 | 275 | hooks\functions 276 | 277 | 278 | hooks\functions 279 | 280 | 281 | thirdparty\imgui 282 | 283 | 284 | thirdparty\imgui 285 | 286 | 287 | thirdparty\imgui 288 | 289 | 290 | thirdparty\imgui 291 | 292 | 293 | thirdparty\imgui 294 | 295 | 296 | thirdparty\imgui 297 | 298 | 299 | thirdparty\imgui 300 | 301 | 302 | menu 303 | 304 | 305 | settings 306 | 307 | 308 | hooks\functions 309 | 310 | 311 | hooks\functions 312 | 313 | 314 | sdk\helpers 315 | 316 | 317 | 318 | 319 | 320 | --------------------------------------------------------------------------------