├── .gitattributes ├── dependencies ├── minhook │ ├── buffer.c │ ├── hde │ │ ├── pstdint.h │ │ ├── hde32.h │ │ ├── hde64.h │ │ ├── table32.h │ │ ├── table64.h │ │ ├── hde32.c │ │ └── hde64.c │ ├── buffer.h │ ├── trampoline.h │ ├── minhook.h │ └── trampoline.c ├── utilities │ ├── csgo.cpp │ ├── console │ │ ├── console.hpp │ │ └── console.cpp │ ├── singleton.hpp │ ├── utilities.hpp │ ├── fnv.hpp │ ├── renderer │ │ ├── renderer.hpp │ │ └── renderer.cpp │ ├── csgo.hpp │ ├── utilities.cpp │ └── netvars │ │ ├── netvars.hpp │ │ └── netvars.cpp ├── interfaces │ ├── i_localize.hpp │ ├── i_weapon_system.hpp │ ├── i_render_view.hpp │ ├── i_input.hpp │ ├── c_global_vars_base.hpp │ ├── iv_debug_overlay.hpp │ ├── i_client_entity_list.hpp │ ├── iv_model_render.hpp │ ├── i_app_system.hpp │ ├── i_panel.hpp │ ├── glow_manager.hpp │ ├── iv_model_info.hpp │ ├── imageformats.h │ ├── i_console.hpp │ ├── i_base_client_dll.hpp │ ├── i_game_event_manager.hpp │ ├── interfaces.hpp │ ├── iv_engine_client.hpp │ ├── i_input_system.hpp │ ├── interfaces.cpp │ ├── i_client_state.hpp │ ├── i_player_movement.hpp │ ├── i_surface.hpp │ └── i_material_system.hpp └── math │ ├── math.hpp │ └── math.cpp ├── source-sdk ├── classes │ ├── view_setup.h │ ├── net_channel.hpp │ ├── collideable.hpp │ ├── c_usercmd.hpp │ ├── recv_props.hpp │ ├── convar.hpp │ ├── client_class.hpp │ └── studio.hpp ├── structs │ ├── vertex_t.hpp │ ├── dlight.hpp │ ├── models.hpp │ ├── weaponinfo.hpp │ ├── animstate.hpp │ └── materials.hpp ├── sdk.hpp ├── misc │ └── color.hpp └── math │ ├── vector2d.hpp │ ├── vector3d.cpp │ ├── utl_vector.hpp │ ├── vector3d.hpp │ └── view_matrix.hpp ├── core ├── menu │ ├── menu.hpp │ ├── variables.hpp │ ├── framework.hpp │ ├── framework.cpp │ └── menu.cpp ├── features │ ├── misc │ │ ├── engine_prediction.hpp │ │ ├── misc.cpp │ │ ├── engine_prediction.cpp │ │ └── backtracking.cpp │ ├── features.hpp │ └── legitbot │ │ └── legitbot.cpp ├── hooks │ ├── hooks.hpp │ └── hooks.cpp └── main.cpp ├── csgo-cheat.vcxproj.user └── csgo-cheat.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /dependencies/minhook/buffer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clem45/LegitInternalSource/HEAD/dependencies/minhook/buffer.c -------------------------------------------------------------------------------- /source-sdk/classes/view_setup.h: -------------------------------------------------------------------------------- 1 | 2 | struct view_setup_t { 3 | std::byte pad[176]; 4 | float fov; 5 | std::byte pad1[32]; 6 | float far_z; 7 | }; -------------------------------------------------------------------------------- /dependencies/utilities/csgo.cpp: -------------------------------------------------------------------------------- 1 | #include "csgo.hpp" 2 | 3 | namespace csgo { 4 | player_t* local_player = nullptr; 5 | 6 | namespace fonts { 7 | unsigned long watermark_font; 8 | unsigned long name_font; 9 | } 10 | } -------------------------------------------------------------------------------- /core/menu/menu.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../dependencies/utilities/csgo.hpp" 3 | #include "framework.hpp" 4 | #include "variables.hpp" 5 | 6 | namespace menu { 7 | inline static int current_tab = 0; 8 | 9 | void render(); 10 | void toggle(); 11 | }; 12 | -------------------------------------------------------------------------------- /dependencies/interfaces/i_localize.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class i_localize { 4 | public: 5 | wchar_t* find(const char* token_name) { 6 | using original_fn = wchar_t* (__thiscall*)(i_localize*, const char*); 7 | return (*(original_fn * *)this)[11](this, token_name); 8 | } 9 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_weapon_system.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/structs/weaponinfo.hpp" 3 | 4 | class i_weapon_system { 5 | virtual void unused0() = 0; 6 | virtual void unused1() = 0; 7 | public: 8 | virtual weapon_info_t* get_weapon_data(unsigned int idx) const = 0; 9 | }; -------------------------------------------------------------------------------- /source-sdk/classes/net_channel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class i_net_channel { 4 | public: 5 | uint8_t pad_0x0000[0x17]; 6 | bool should_delete; 7 | int out_sequence_nr; 8 | int in_sequence_nr; 9 | int out_sequence_nr_ack; 10 | int out_reliable_state; 11 | int in_reliable_state; 12 | int choked_packets; 13 | }; -------------------------------------------------------------------------------- /core/features/misc/engine_prediction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../../dependencies/utilities/csgo.hpp" 3 | 4 | namespace prediction { 5 | void start(c_usercmd* cmd); 6 | void end(); 7 | 8 | inline player_move_data data; 9 | inline float old_cur_time; 10 | inline float old_frame_time; 11 | inline int* prediction_random_seed; 12 | }; 13 | -------------------------------------------------------------------------------- /source-sdk/classes/collideable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class collideable_t { 4 | public: 5 | vec3_t& mins() { 6 | using original_fn = vec3_t & (__thiscall*)(void*); 7 | return (*(original_fn * *)this)[1](this); 8 | } 9 | vec3_t& maxs() { 10 | using original_fn = vec3_t & (__thiscall*)(void*); 11 | return (*(original_fn * *)this)[2](this); 12 | } 13 | }; -------------------------------------------------------------------------------- /dependencies/utilities/console/console.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../utilities/csgo.hpp" 3 | 4 | namespace console { 5 | void initialize(const char* title); 6 | void release(); 7 | 8 | template 9 | void log(char const* const format, Args const& ... args) { 10 | #ifdef _DEBUG 11 | printf(format, args ...); 12 | #endif 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /source-sdk/structs/vertex_t.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../math/vector2d.hpp" 3 | struct vertex_t { 4 | vertex_t() {} 5 | vertex_t(const vec2_t& pos, const vec2_t& coord = vec2_t(0, 0)) { 6 | position = pos; 7 | tex_coord = coord; 8 | } 9 | void initialize(const vec2_t& pos, const vec2_t& coord = vec2_t(0, 0)) { 10 | position = pos; 11 | tex_coord = coord; 12 | } 13 | 14 | vec2_t position; 15 | vec2_t tex_coord; 16 | }; -------------------------------------------------------------------------------- /dependencies/utilities/singleton.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class singleton { 5 | protected: 6 | singleton() { } 7 | ~singleton() { } 8 | 9 | singleton(const singleton&) = delete; 10 | singleton& operator=(const singleton&) = delete; 11 | 12 | singleton(singleton&&) = delete; 13 | singleton& operator=(singleton&&) = delete; 14 | public: 15 | static T& get() { 16 | static T inst{}; 17 | return inst; 18 | } 19 | }; -------------------------------------------------------------------------------- /source-sdk/sdk.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "math/vector3d.hpp" 4 | #include "misc/color.hpp" 5 | #include "classes/c_usercmd.hpp" 6 | #include "classes/recv_props.hpp" 7 | #include "classes/client_class.hpp" 8 | #include "classes/convar.hpp" 9 | #include "classes/studio.hpp" 10 | #include "structs/dlight.hpp" 11 | #include "structs/weaponinfo.hpp" 12 | #include "classes/view_setup.h" 13 | #include "classes/entities.hpp" 14 | #include "structs/animstate.hpp" -------------------------------------------------------------------------------- /dependencies/utilities/utilities.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../../source-sdk/math/vector3d.hpp" 4 | 5 | namespace utilities { 6 | template 7 | __forceinline static FuncType call_virtual(void* ppClass, int index) { 8 | int* pVTable = *(int**)ppClass; 9 | int dwAddress = pVTable[index]; 10 | return (FuncType)(dwAddress); 11 | } 12 | 13 | std::uint8_t* pattern_scan(const char* module_name, const char* signature) noexcept; 14 | } -------------------------------------------------------------------------------- /dependencies/interfaces/i_render_view.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/misc/color.hpp" 3 | 4 | class i_render_view { 5 | private: 6 | virtual void __pad0(); 7 | virtual void __pad1(); 8 | virtual void __pad2(); 9 | virtual void __pad3(); 10 | 11 | public: 12 | virtual void set_blend(float blend) = 0; 13 | virtual float get_blend(void) = 0; 14 | 15 | virtual void modulate_color(float const* blend) = 0; 16 | virtual void get_color_modulation(float* blend) = 0; 17 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_input.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/classes/c_usercmd.hpp" 3 | 4 | class i_input { 5 | public: 6 | char pad_0000[172]; //0x0000 7 | bool N0000004E; //0x00AC 8 | bool m_fCameraInThirdPerson; //0x00AD 9 | char pad_00AE[2]; //0x00AE 10 | vec3_t m_vecCameraOffset; //0x00B0 11 | 12 | c_usercmd* get_user_cmd(int slot, int sequence_num) { 13 | using original_fn = c_usercmd * (__thiscall*)(void*, int, int); 14 | return (*(original_fn * *)this)[8](this, slot, sequence_num); 15 | } 16 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/c_global_vars_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class c_global_vars_base { 4 | public: 5 | float realtime; 6 | int frame_count; 7 | float absolute_frametime; 8 | float absolute_frame_start_time; 9 | float cur_time; 10 | float frame_time; 11 | int max_clients; 12 | int tick_count; 13 | float interval_per_tick; 14 | float interpolation_amount; 15 | int sim_ticks_this_frame; 16 | int network_protocol; 17 | void* p_save_data; 18 | bool is_client; 19 | bool is_remote_client; 20 | int timestamp_networking_base; 21 | int timestamp_randomize_window; 22 | }; -------------------------------------------------------------------------------- /source-sdk/structs/dlight.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum dlight_flags { 4 | dlight_no_world_illumination = 0x1, 5 | dlight_no_model_illumination = 0x2, 6 | dlight_add_displacement_alpha = 0x4, 7 | dlight_subtract_displacement_alpha = 0x8, 8 | dlight_displacement_mask = (dlight_add_displacement_alpha | dlight_subtract_displacement_alpha), 9 | }; 10 | 11 | struct dlight_t { 12 | int flags; 13 | vec3_t origin; 14 | float radius; 15 | color color; 16 | float die_time; 17 | float decay; 18 | float min_light; 19 | int key; 20 | int style; 21 | vec3_t direction; 22 | float inner_angle; 23 | float outer_angle; 24 | }; -------------------------------------------------------------------------------- /dependencies/utilities/console/console.cpp: -------------------------------------------------------------------------------- 1 | #include "console.hpp" 2 | 3 | void console::initialize(const char* title) { 4 | AllocConsole(); 5 | 6 | freopen_s((_iobuf * *)__acrt_iob_func(0), "conin$", "r", (_iobuf*)__acrt_iob_func(0)); 7 | freopen_s((_iobuf * *)__acrt_iob_func(1), "conout$", "w", (_iobuf*)__acrt_iob_func(1)); 8 | freopen_s((_iobuf * *)__acrt_iob_func(2), "conout$", "w", (_iobuf*)__acrt_iob_func(2)); 9 | 10 | SetConsoleTitleA(title); 11 | } 12 | 13 | void console::release() { 14 | fclose((_iobuf*)__acrt_iob_func(0)); 15 | fclose((_iobuf*)__acrt_iob_func(1)); 16 | fclose((_iobuf*)__acrt_iob_func(2)); 17 | 18 | FreeConsole(); 19 | } -------------------------------------------------------------------------------- /core/features/misc/misc.cpp: -------------------------------------------------------------------------------- 1 | #include "../features.hpp" 2 | 3 | void misc::movement::bunny_hop(c_usercmd* cmd) { 4 | if (!variables::bhop) 5 | return; 6 | 7 | static bool last_jumped = false, should_fake = false; 8 | 9 | if (!last_jumped && should_fake) { 10 | should_fake = false; 11 | cmd->buttons |= in_jump; 12 | } 13 | else if (cmd->buttons & in_jump) { 14 | if (csgo::local_player->flags() & fl_onground) { 15 | last_jumped = true; 16 | should_fake = true; 17 | } 18 | else { 19 | cmd->buttons &= ~in_jump; 20 | last_jumped = false; 21 | } 22 | } 23 | else { 24 | last_jumped = false; 25 | should_fake = false; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /dependencies/interfaces/iv_debug_overlay.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/math/vector3d.hpp" 3 | 4 | class iv_debug_overlay { 5 | public: 6 | bool world_to_screen(const vec3_t& in, vec3_t& out) { 7 | using original_fn = int(__thiscall*)(iv_debug_overlay*, const vec3_t&, vec3_t&); 8 | int return_value = (*(original_fn * *)this)[13](this, in, out); 9 | return static_cast(return_value != 1); 10 | } 11 | 12 | bool screen_position(const vec3_t& in, vec3_t& out) { 13 | using original_fn = bool(__thiscall*)(iv_debug_overlay*, const vec3_t&, vec3_t&); 14 | return (*(original_fn * *)this)[11](this, std::ref(in), std::ref(out)); 15 | } 16 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_client_entity_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class i_client_entity_list { 5 | public: 6 | void* get_client_entity(int index) { 7 | using original_fn = void* (__thiscall*)(i_client_entity_list*, int); 8 | return (*(original_fn * *)this)[3](this, index); 9 | } 10 | void* get_client_entity_handle(uintptr_t handle) { 11 | using original_fn = void* (__thiscall*)(i_client_entity_list*, uintptr_t); 12 | return (*(original_fn * *)this)[4](this, handle); 13 | } 14 | int get_highest_index() { 15 | using original_fn = int(__thiscall*)(i_client_entity_list*); 16 | return (*(original_fn * *)this)[6](this); 17 | } 18 | }; -------------------------------------------------------------------------------- /core/hooks/hooks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace hooks { 4 | bool initialize(); 5 | void release(); 6 | 7 | inline unsigned int get_virtual(void* _class, unsigned int index) { return static_cast((*reinterpret_cast(_class))[index]); } 8 | 9 | namespace create_move { 10 | using fn = bool(__stdcall*)(float, c_usercmd*); 11 | static bool __fastcall hook(void* ecx, void* edx, int input_sample_frametime, c_usercmd* cmd); 12 | }; 13 | 14 | namespace paint_traverse { 15 | using fn = void(__thiscall*)(i_panel*, unsigned int, bool, bool); 16 | static void __stdcall hook(unsigned int panel, bool force_repaint, bool allow_force); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /dependencies/interfaces/iv_model_render.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/structs/materials.hpp" 3 | struct draw_model_state_t { 4 | studio_hdr_t* m_pStudioHdr; 5 | studiohwdata_t* m_pStudioHWData; 6 | i_client_renderable* m_pRenderable; 7 | const matrix3x4_t* m_pModelToWorld; 8 | studio_decal_handle_t m_decals; 9 | int m_drawFlags; 10 | int m_lod; 11 | }; 12 | 13 | class iv_model_render { 14 | public: 15 | void override_material(i_material* material) { 16 | using original_fn = void(__thiscall*)(iv_model_render*, i_material*, int, int); 17 | return (*(original_fn * *)this)[1](this, material, 0, 0); 18 | } 19 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_app_system.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* declarations */ 4 | class i_app_system; 5 | 6 | /* defs */ 7 | typedef void* (*create_interface_fn)(const char* pName, int* pReturnCode); 8 | 9 | /* functions */ 10 | class i_app_system { 11 | public: 12 | virtual bool connect(create_interface_fn factory) = 0; 13 | virtual void disconnect() = 0; 14 | virtual void* query_interface(const char* pInterfaceName) = 0; 15 | virtual int init() = 0; 16 | virtual void shutdown() = 0; 17 | virtual const void* get_dependencies() = 0; 18 | virtual int get_tier() = 0; 19 | virtual void reconnect(create_interface_fn factory, const char* pInterfaceName) = 0; 20 | virtual void unknown() = 0; 21 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_panel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class i_panel { 4 | public: 5 | void set_keyboard_input_enabled(unsigned int panel_id, bool state) { 6 | using original_fn = void(__thiscall*)(i_panel*, unsigned int, bool); 7 | return (*(original_fn**)this)[31](this, panel_id, state); 8 | } 9 | 10 | void set_mouse_input_enabled(unsigned int panel_id, bool state) { 11 | using original_fn = void(__thiscall*)(i_panel*, unsigned int, bool); 12 | return (*(original_fn**)this)[32](this, panel_id, state); 13 | } 14 | 15 | const char* get_panel_name(unsigned int panel_id) { 16 | using original_fn = const char* (__thiscall*)(i_panel*, unsigned int); 17 | return (*(original_fn * *)this)[36](this, panel_id); 18 | } 19 | }; -------------------------------------------------------------------------------- /core/features/features.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../dependencies/utilities/csgo.hpp" 3 | #include "../menu/variables.hpp" 4 | 5 | namespace misc { 6 | namespace movement { 7 | void bunny_hop(c_usercmd* cmd); 8 | }; 9 | } 10 | 11 | namespace visuals { 12 | void boxesp(); 13 | void nameesp(); 14 | void healthesp(); 15 | void armoresp(); 16 | void glowesp(); 17 | void boneesp(); 18 | void snaplineesp(); 19 | void drawc4(); 20 | void drawfov(); 21 | } 22 | 23 | namespace CBacktracking 24 | { 25 | void RegisterTick(c_usercmd* cmd); 26 | void Begin(c_usercmd* cmd); 27 | void End(); 28 | void Draw(); 29 | } 30 | 31 | namespace legitbot 32 | { 33 | player_t* GetBestTarget(c_usercmd* cmd); 34 | void AimBot(c_usercmd* cmd); 35 | } -------------------------------------------------------------------------------- /dependencies/math/math.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace math { 4 | void correct_movement(vec3_t old_angles, c_usercmd* cmd, float old_forwardmove, float old_sidemove); 5 | vec3_t calculate_angle(vec3_t& a, vec3_t& b); 6 | void sin_cos(float r, float* s, float* c); 7 | vec3_t angle_vector(vec3_t angle); 8 | void transform_vector(vec3_t&, matrix_t&, vec3_t&); 9 | void vector_angles(vec3_t&, vec3_t&); 10 | void angle_vectors(vec3_t&, vec3_t*, vec3_t*, vec3_t*); 11 | vec3_t vector_add(vec3_t&, vec3_t&); 12 | vec3_t vector_subtract(vec3_t&, vec3_t&); 13 | vec3_t vector_multiply(vec3_t&, vec3_t&); 14 | vec3_t vector_divide(vec3_t&, vec3_t&); 15 | bool screen_transform(const vec3_t& point, vec3_t& screen); 16 | bool world_to_screen(const vec3_t& origin, vec3_t& screen); 17 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/glow_manager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/math/vector3d.hpp" 3 | 4 | class glow_object_definition_t { 5 | public: 6 | void set(float r, float g, float b, float a) { 7 | color = vec3_t(r, g, b); 8 | alpha = a; 9 | render_when_occluded = true; 10 | render_when_unoccluded = false; 11 | bloom_amount = 1.0f; 12 | } 13 | bool unused() { 14 | return next_free_slot != -2; 15 | } 16 | 17 | void* entity; 18 | vec3_t color; 19 | float alpha; 20 | char unknown0[8]; 21 | float bloom_amount; 22 | char unknown1[4]; 23 | bool render_when_occluded; 24 | bool render_when_unoccluded; 25 | bool full_bloom_render; 26 | char unknown2[13]; 27 | int next_free_slot; 28 | }; 29 | 30 | class glow_manager_t { 31 | public: 32 | glow_object_definition_t* objects; 33 | char pad[8]; 34 | int size; 35 | }; -------------------------------------------------------------------------------- /source-sdk/structs/models.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../math/vector3d.hpp" 3 | 4 | struct model_t { 5 | void* handle; 6 | char name[260]; 7 | int loadFlags; 8 | int serverCount; 9 | int type; 10 | int flags; 11 | vec3_t vecMins; 12 | vec3_t vecMaxs; 13 | float radius; 14 | }; 15 | 16 | struct model_render_info_t { 17 | vec3_t origin; 18 | vec3_t angles; 19 | char pad[0x4]; // added this 20 | void* renderable; // this 21 | //const void *model; // and this 22 | const model_t* model; 23 | const matrix_t* model_to_world; 24 | const matrix_t* lighting_offset; 25 | const vec3_t* lighting_origin; 26 | int flags; 27 | int entity_index; 28 | int skin; 29 | int body; 30 | int hitboxset; 31 | unsigned short instance; 32 | 33 | model_render_info_t() { 34 | model_to_world = NULL; 35 | lighting_offset = NULL; 36 | lighting_origin = NULL; 37 | } 38 | }; -------------------------------------------------------------------------------- /core/menu/variables.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace variables { 4 | // misc 5 | inline bool watermark = true; 6 | inline bool bhop = false; 7 | inline bool backtrack = false; 8 | //visuals 9 | inline bool showteamesp = false; 10 | inline bool boxesp = false; 11 | inline bool nameesp = false; 12 | inline bool healthesp = false; 13 | inline bool armoresp = false; 14 | inline bool glowesp = false; 15 | inline bool boneesp = false; 16 | inline bool snaplineesp = false; 17 | inline bool drawc4 = false; 18 | inline bool drawbacktrack = false; 19 | inline bool drawfov = false; 20 | //aim 21 | inline bool aimbot = false; 22 | inline float aimbot_fov = 0.f; 23 | inline float aimbot_smoothing = 2.f; 24 | inline bool aimbot_isvisiblecheck = true; 25 | 26 | namespace menu { 27 | inline bool opened = false; 28 | inline int x = 140, y = 140; 29 | inline int w = 600, h = 450; 30 | } 31 | } -------------------------------------------------------------------------------- /core/menu/framework.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../dependencies/utilities/csgo.hpp" 3 | 4 | namespace menu_framework { 5 | void group_box(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, unsigned long font, const std::string string, bool show_label); 6 | void tab(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, unsigned long font, const std::string, std::int32_t& tab, std::int32_t count, bool show_outline); 7 | void check_box(std::int32_t x, std::int32_t y, std::int32_t position, unsigned long font, const std::string string, bool& value); 8 | void slider(std::int32_t x, std::int32_t y, std::int32_t position, unsigned long font, const std::string string, float& value, float min_value, float max_value); 9 | void menu_movement(std::int32_t& x, std::int32_t& y, std::int32_t w, std::int32_t h); 10 | 11 | inline bool should_drag = false; 12 | inline bool should_move = false; 13 | }; -------------------------------------------------------------------------------- /csgo-cheat.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | Script 8 | WindowsLocalDebugger 9 | 10 | 11 | C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo.exe 12 | WindowsLocalDebugger 13 | Auto 14 | true 15 | 16 | -------------------------------------------------------------------------------- /dependencies/interfaces/iv_model_info.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/structs/models.hpp" 3 | #include "../../source-sdk/classes/studio.hpp" 4 | 5 | class iv_model_info { 6 | public: 7 | model_t* get_model(int index) { 8 | using original_fn = model_t * (__thiscall*)(iv_model_info*, int); 9 | return (*(original_fn * *)this)[1](this, index); 10 | } 11 | int get_model_index(const char* filename) { 12 | using original_fn = int(__thiscall*)(iv_model_info*, const char*); 13 | return (*(original_fn * *)this)[2](this, filename); 14 | } 15 | const char* get_model_name(const model_t* model) { 16 | using original_fn = const char* (__thiscall*)(iv_model_info*, const model_t*); 17 | return (*(original_fn * *)this)[3](this, model); 18 | } 19 | studio_hdr_t* get_studio_model(const model_t* model) { 20 | using original_fn = studio_hdr_t * (__thiscall*)(iv_model_info*, const model_t*); 21 | return (*(original_fn * *)this)[32](this, model); 22 | } 23 | }; -------------------------------------------------------------------------------- /source-sdk/misc/color.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct color { 6 | int a, r, g, b; 7 | color() = default; 8 | color(int r, int g, int b, int a = 255) { 9 | this->r = r; 10 | this->g = g; 11 | this->b = b; 12 | this->a = a; 13 | } 14 | color(uint32_t color) { 15 | this->a = (color >> 24) & 0xff; 16 | this->r = (color >> 16) & 0xff; 17 | this->g = (color >> 8) & 0xff; 18 | this->b = (color & 0xff); 19 | } 20 | color from_uint(uint32_t uint) { 21 | return color(uint); 22 | } 23 | D3DCOLOR from_color(color col) { 24 | return D3DCOLOR_ARGB(col.a, col.r, col.g, col.b); 25 | } 26 | 27 | static color black(int a = 255) { return { 0, 0, 0, a }; } 28 | static color white(int a = 255) { return { 255, 255, 255, a }; } 29 | static color red(int a = 255) { return { 255, 0, 0, a }; } 30 | static color green(int a = 255) { return { 0, 255, 0, a }; } 31 | static color blue(int a = 255) { return { 0, 0, 255, a }; } 32 | }; -------------------------------------------------------------------------------- /dependencies/utilities/fnv.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fnv_1a { 5 | template< typename S > 6 | struct fnv_internal; 7 | template< typename S > 8 | struct fnv1a; 9 | 10 | template< > 11 | struct fnv_internal< uint32_t > { 12 | constexpr static uint32_t default_offset_basis = 0x811C9DC5; 13 | constexpr static uint32_t prime = 0x01000193; 14 | }; 15 | 16 | template< > 17 | struct fnv1a< uint32_t > : public fnv_internal< uint32_t > { 18 | constexpr static uint32_t hash(char const* string, const uint32_t val = default_offset_basis) { 19 | return (string[0] == '\0') 20 | ? val 21 | : hash(&string[1], (val ^ uint32_t(string[0])) * prime); 22 | } 23 | 24 | constexpr static uint32_t hash(wchar_t const* string, const uint32_t val = default_offset_basis) { 25 | return (string[0] == L'\0') 26 | ? val 27 | : hash(&string[1], (val ^ uint32_t(string[0])) * prime); 28 | } 29 | }; 30 | } 31 | 32 | using fnv = fnv_1a::fnv1a< uint32_t >; -------------------------------------------------------------------------------- /source-sdk/math/vector2d.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vector3d.hpp" 4 | class vec2_t { 5 | public: 6 | float x, y; 7 | 8 | vec2_t() { 9 | x = 0; y = 0; 10 | }; 11 | vec2_t(float X, float Y) { 12 | x = X; y = Y; 13 | }; 14 | vec2_t(vec3_t vec) { 15 | x = vec.x; y = vec.y; 16 | } 17 | 18 | inline vec2_t operator*(const float n) const { 19 | return vec2_t(x * n, y * n); 20 | } 21 | inline vec2_t operator+(const vec2_t& v) const { 22 | return vec2_t(x + v.x, y + v.y); 23 | } 24 | inline vec2_t operator-(const vec2_t & v) const { 25 | return vec2_t(x - v.x, y - v.y); 26 | } 27 | inline void operator+=(const vec2_t & v) { 28 | x += v.x; 29 | y += v.y; 30 | } 31 | inline void operator-=(const vec2_t & v) { 32 | x -= v.x; 33 | y -= v.y; 34 | } 35 | 36 | bool operator==(const vec2_t & v) const { 37 | return (v.x == x && v.y == y); 38 | } 39 | bool operator!=(const vec2_t & v) const { 40 | return (v.x != x || v.y != y); 41 | } 42 | 43 | inline float length() { 44 | return sqrt((x * x) + (y * y)); 45 | } 46 | }; -------------------------------------------------------------------------------- /csgo-cheat.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2000 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aristois beta", "csgo-cheat.vcxproj", "{AF041675-F00D-4A72-B40F-78D0C4BB72D9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {AF041675-F00D-4A72-B40F-78D0C4BB72D9}.Debug|x86.ActiveCfg = Debug|Win32 15 | {AF041675-F00D-4A72-B40F-78D0C4BB72D9}.Debug|x86.Build.0 = Debug|Win32 16 | {AF041675-F00D-4A72-B40F-78D0C4BB72D9}.Release|x86.ActiveCfg = Release|Win32 17 | {AF041675-F00D-4A72-B40F-78D0C4BB72D9}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {BB5EEA13-1F46-49E7-8ED1-B56C1ACFEF5D} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /source-sdk/classes/c_usercmd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum cmd_buttons { 4 | in_attack = (1 << 0), 5 | in_jump = (1 << 1), 6 | in_duck = (1 << 2), 7 | in_forward = (1 << 3), 8 | in_back = (1 << 4), 9 | in_use = (1 << 5), 10 | in_cancel = (1 << 6), 11 | in_left = (1 << 7), 12 | in_right = (1 << 8), 13 | in_moveleft = (1 << 9), 14 | in_moveright = (1 << 10), 15 | in_attack2 = (1 << 11), 16 | in_run = (1 << 12), 17 | in_reload = (1 << 13), 18 | in_alt1 = (1 << 14), 19 | in_alt2 = (1 << 15), 20 | in_score = (1 << 16), 21 | in_speed = (1 << 17), 22 | in_walk = (1 << 18), 23 | in_zoom = (1 << 19), 24 | in_weapon1 = (1 << 20), 25 | in_weapon2 = (1 << 21), 26 | in_bullrush = (1 << 22), 27 | in_grenade1 = (1 << 23), 28 | in_grenade2 = (1 << 24), 29 | in_attack3 = (1 << 25) 30 | }; 31 | 32 | struct c_usercmd { 33 | int pad; 34 | int command_number; 35 | int tick_count; 36 | vec3_t viewangles; 37 | vec3_t aimdirection; 38 | float forwardmove; 39 | float sidemove; 40 | float upmove; 41 | int buttons; 42 | char impulse; 43 | int weaponselect; 44 | int weaponsubtype; 45 | int randomseed; 46 | short mousedx; 47 | short mousedy; 48 | bool hasbeenpredicted; 49 | }; -------------------------------------------------------------------------------- /dependencies/utilities/renderer/renderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../utilities/csgo.hpp" 3 | 4 | enum font_flags { 5 | fontflag_none, 6 | fontflag_italic = 0x001, 7 | fontflag_underline = 0x002, 8 | fontflag_strikeout = 0x004, 9 | fontflag_symbol = 0x008, 10 | fontflag_antialias = 0x010, 11 | fontflag_gaussianblur = 0x020, 12 | fontflag_rotary = 0x040, 13 | fontflag_dropshadow = 0x080, 14 | fontflag_additive = 0x100, 15 | fontflag_outline = 0x200, 16 | fontflag_custom = 0x400, 17 | fontflag_bitmap = 0x800, 18 | }; 19 | 20 | namespace render { 21 | void initialize(); 22 | 23 | void draw_line(int x1, int y1, int x2, int y2, color colour); 24 | void draw_text_wchar(int x, int y, unsigned long font, const wchar_t* string, color colour); 25 | void draw_text_string(int x, int y, unsigned long font, std::string string, bool text_centered, color colour); 26 | void draw_rect(int x, int y, int w, int h, color color); 27 | void draw_filled_rect(int x, int y, int w, int h, color colour); 28 | void draw_outline(int x, int y, int w, int h, color colour); 29 | void draw_textured_polygon(int n, vertex_t* vertice, color col); 30 | void draw_circle(int x, int y, float r, float s, color col); 31 | vec2_t get_text_size(unsigned long font, std::string text); 32 | 33 | namespace fonts { 34 | extern unsigned long watermark_font; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /dependencies/interfaces/imageformats.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* includes */ 4 | #include 5 | 6 | // don't bitch that inline functions aren't used! 7 | #pragma warning(disable : 4514) 8 | 9 | /* enums */ 10 | enum image_format { 11 | IMAGE_FORMAT_UNKNOWN = -1, 12 | IMAGE_FORMAT_RGBA8888 = 0, 13 | IMAGE_FORMAT_ABGR8888, 14 | IMAGE_FORMAT_RGB888, 15 | IMAGE_FORMAT_BGR888, 16 | IMAGE_FORMAT_RGB565, 17 | IMAGE_FORMAT_I8, 18 | IMAGE_FORMAT_IA88, 19 | IMAGE_FORMAT_P8, 20 | IMAGE_FORMAT_A8, 21 | IMAGE_FORMAT_RGB888_BLUESCREEN, 22 | IMAGE_FORMAT_BGR888_BLUESCREEN, 23 | IMAGE_FORMAT_ARGB8888, 24 | IMAGE_FORMAT_BGRA8888, 25 | IMAGE_FORMAT_DXT1, 26 | IMAGE_FORMAT_DXT3, 27 | IMAGE_FORMAT_DXT5, 28 | IMAGE_FORMAT_BGRX8888, 29 | IMAGE_FORMAT_BGR565, 30 | IMAGE_FORMAT_BGRX5551, 31 | IMAGE_FORMAT_BGRA4444, 32 | IMAGE_FORMAT_DXT1_ONEBITALPHA, 33 | IMAGE_FORMAT_BGRA5551, 34 | IMAGE_FORMAT_UV88, 35 | IMAGE_FORMAT_UVWQ8888, 36 | IMAGE_FORMAT_RGBA16161616F, 37 | IMAGE_FORMAT_RGBA16161616, 38 | IMAGE_FORMAT_UVLX8888, 39 | IMAGE_FORMAT_R32F, 40 | IMAGE_FORMAT_RGB323232F, 41 | IMAGE_FORMAT_RGBA32323232F, 42 | IMAGE_FORMAT_NV_DST16, 43 | IMAGE_FORMAT_NV_DST24, 44 | IMAGE_FORMAT_NV_INTZ, 45 | IMAGE_FORMAT_NV_RAWZ, 46 | IMAGE_FORMAT_ATI_DST16, 47 | IMAGE_FORMAT_ATI_DST24, 48 | IMAGE_FORMAT_NV_NULL, 49 | IMAGE_FORMAT_ATI2N, 50 | IMAGE_FORMAT_ATI1N, 51 | IMAGE_FORMAT_DXT1_RUNTIME, 52 | IMAGE_FORMAT_DXT5_RUNTIME, 53 | NUM_IMAGE_FORMATS 54 | }; -------------------------------------------------------------------------------- /core/main.cpp: -------------------------------------------------------------------------------- 1 | #include "../dependencies/utilities/csgo.hpp" 2 | #include "features/features.hpp" 3 | 4 | unsigned long WINAPI initialize(void* instance) { 5 | while (!GetModuleHandleA("serverbrowser.dll")) 6 | Sleep(200); 7 | 8 | #ifdef _DEBUG 9 | console::initialize("csgo-cheat console"); 10 | #endif 11 | 12 | try { 13 | interfaces::initialize(); 14 | render::initialize(); 15 | hooks::initialize(); 16 | } 17 | 18 | catch (const std::runtime_error & error) { 19 | MessageBoxA(NULL, error.what(), "csgo-cheat error!", MB_OK | MB_ICONERROR); 20 | FreeLibraryAndExitThread(static_cast(instance), 0); 21 | } 22 | 23 | while (!GetAsyncKeyState(VK_END)) 24 | std::this_thread::sleep_for(std::chrono::milliseconds(50)); 25 | 26 | FreeLibraryAndExitThread(static_cast(instance), 0); 27 | } 28 | 29 | unsigned long WINAPI release() { 30 | hooks::release(); 31 | 32 | #ifdef _DEBUG 33 | console::release(); 34 | #endif 35 | 36 | return TRUE; 37 | } 38 | 39 | std::int32_t WINAPI DllMain(const HMODULE instance [[maybe_unused]], const unsigned long reason, const void* reserved [[maybe_unused]] ) { 40 | DisableThreadLibraryCalls(instance); 41 | 42 | switch (reason) { 43 | case DLL_PROCESS_ATTACH: { 44 | if (auto handle = CreateThread(nullptr, NULL, initialize, instance, NULL, nullptr)) 45 | CloseHandle(handle); 46 | 47 | break; 48 | } 49 | 50 | case DLL_PROCESS_DETACH: { 51 | release(); 52 | break; 53 | } 54 | } 55 | 56 | return true; 57 | } 58 | -------------------------------------------------------------------------------- /dependencies/utilities/csgo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../utilities/singleton.hpp" 17 | #include "../utilities/fnv.hpp" 18 | #include "../utilities/utilities.hpp" 19 | #include "../../dependencies/minhook/minhook.h" 20 | #include "../interfaces/interfaces.hpp" 21 | #include "../../source-sdk/sdk.hpp" 22 | #include "../../core/hooks/hooks.hpp" 23 | #include "../../dependencies/math/math.hpp" 24 | #include "../../dependencies/utilities/renderer/renderer.hpp" 25 | #include "../../dependencies/utilities/console/console.hpp" 26 | #include "../utilities/csgo.hpp" 27 | 28 | //interfaces 29 | #define sig_client_state "A1 ? ? ? ? 8B 80 ? ? ? ? C3" 30 | #define sig_directx "A1 ? ? ? ? 50 8B 08 FF 51 0C" 31 | #define sig_input "B9 ? ? ? ? F3 0F 11 04 24 FF 50 10" 32 | #define sig_glow_manager "0F 11 05 ? ? ? ? 83 C8 01 C7 05 ? ? ? ? 00 00 00 00" 33 | #define sig_player_move_helper "8B 0D ? ? ? ? 8B 46 08 68" 34 | #define sig_weapon_data "8B 35 ? ? ? ? FF 10 0F B7 C0" 35 | 36 | //misc 37 | #define sig_set_angles "55 8B EC 83 E4 F8 83 EC 64 53 56 57 8B F1" 38 | #define sig_prediction_random_seed "8B 0D ? ? ? ? BA ? ? ? ? E8 ? ? ? ? 83 C4 04" 39 | 40 | namespace csgo { 41 | extern player_t* local_player; 42 | } -------------------------------------------------------------------------------- /core/features/misc/engine_prediction.cpp: -------------------------------------------------------------------------------- 1 | #include "engine_prediction.hpp" 2 | 3 | void prediction::start(c_usercmd* cmd) { 4 | if (!csgo::local_player) 5 | return; 6 | 7 | if (!prediction_random_seed) 8 | prediction_random_seed = *reinterpret_cast(utilities::pattern_scan("client.dll", sig_prediction_random_seed) + 2); 9 | 10 | *prediction_random_seed = cmd->randomseed & 0x7FFFFFFF; 11 | 12 | old_cur_time = interfaces::globals->cur_time; 13 | old_frame_time = interfaces::globals->frame_time; 14 | 15 | interfaces::globals->cur_time = csgo::local_player->get_tick_base() * interfaces::globals->interval_per_tick; 16 | interfaces::globals->frame_time = interfaces::globals->interval_per_tick; 17 | 18 | interfaces::game_movement->start_track_prediction_errors(csgo::local_player); 19 | 20 | memset(&data, 0, sizeof(data)); 21 | interfaces::move_helper->set_host(csgo::local_player); 22 | interfaces::prediction->setup_move(csgo::local_player, cmd, interfaces::move_helper, &data); 23 | interfaces::game_movement->process_movement(csgo::local_player, &data); 24 | interfaces::prediction->finish_move(csgo::local_player, cmd, &data); 25 | } 26 | 27 | void prediction::end() { 28 | if (!csgo::local_player) 29 | return; 30 | 31 | interfaces::game_movement->finish_track_prediction_errors(csgo::local_player); 32 | interfaces::move_helper->set_host(nullptr); 33 | 34 | *prediction_random_seed = -1; 35 | 36 | interfaces::globals->cur_time = old_cur_time; 37 | interfaces::globals->frame_time = old_cur_time; 38 | } 39 | -------------------------------------------------------------------------------- /source-sdk/classes/recv_props.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class d_variant; 4 | class recv_table; 5 | class recv_prop; 6 | class c_recv_proxy_data; 7 | 8 | using recv_var_proxy_fn = void(*)(const c_recv_proxy_data* data, void* struct_ptr, void* out_ptr); 9 | using array_length_recv_proxy_fn = void(*)(void* struct_ptr, int object_id, int current_array_length); 10 | using data_table_recv_var_proxy_fn = void(*)(const recv_prop* prop, void** out_ptr, void* data_ptr, int object_id); 11 | 12 | enum send_prop_type { 13 | _int = 0, 14 | _float, 15 | _vec, 16 | _vec_xy, 17 | _string, 18 | _array, 19 | _data_table, 20 | _int_64, 21 | }; 22 | class d_variant { 23 | public: 24 | union { 25 | float m_float; 26 | long m_int; 27 | char* m_string; 28 | void* m_data; 29 | float m_vector[3]; 30 | __int64 m_int64; 31 | }; 32 | send_prop_type type; 33 | }; 34 | class c_recv_proxy_data { 35 | public: 36 | const recv_prop* recv_prop; 37 | d_variant value; 38 | int element_index; 39 | int object_id; 40 | }; 41 | class recv_prop { 42 | public: 43 | char* prop_name; 44 | send_prop_type prop_type; 45 | int prop_flags; 46 | int buffer_size; 47 | int is_inside_of_array; 48 | const void* extra_data_ptr; 49 | recv_prop* array_prop; 50 | array_length_recv_proxy_fn array_length_proxy; 51 | recv_var_proxy_fn proxy_fn; 52 | data_table_recv_var_proxy_fn data_table_proxy_fn; 53 | recv_table* data_table; 54 | int offset; 55 | int element_stride; 56 | int elements_count; 57 | const char* parent_array_prop_name; 58 | }; 59 | class recv_table { 60 | public: 61 | recv_prop* props; 62 | int props_count; 63 | void* decoder_ptr; 64 | char* table_name; 65 | bool is_initialized; 66 | bool is_in_main_list; 67 | }; -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /dependencies/utilities/utilities.cpp: -------------------------------------------------------------------------------- 1 | #include "utilities.hpp" 2 | #include "../utilities/csgo.hpp" 3 | #include 4 | 5 | std::uint8_t* utilities::pattern_scan(const char* module_name, const char* signature) noexcept { 6 | const auto module_handle = GetModuleHandleA(module_name); 7 | 8 | if (!module_handle) 9 | return nullptr; 10 | 11 | static auto pattern_to_byte = [](const char* pattern) { 12 | auto bytes = std::vector{}; 13 | auto start = const_cast(pattern); 14 | auto end = const_cast(pattern) + std::strlen(pattern); 15 | 16 | for (auto current = start; current < end; ++current) { 17 | if (*current == '?') { 18 | ++current; 19 | 20 | if (*current == '?') 21 | ++current; 22 | 23 | bytes.push_back(-1); 24 | } 25 | else { 26 | bytes.push_back(std::strtoul(current, ¤t, 16)); 27 | } 28 | } 29 | return bytes; 30 | }; 31 | 32 | auto dos_header = reinterpret_cast(module_handle); 33 | auto nt_headers = 34 | reinterpret_cast(reinterpret_cast(module_handle) + dos_header->e_lfanew); 35 | 36 | auto size_of_image = nt_headers->OptionalHeader.SizeOfImage; 37 | auto pattern_bytes = pattern_to_byte(signature); 38 | auto scan_bytes = reinterpret_cast(module_handle); 39 | 40 | auto s = pattern_bytes.size(); 41 | auto d = pattern_bytes.data(); 42 | 43 | for (auto i = 0ul; i < size_of_image - s; ++i) { 44 | bool found = true; 45 | 46 | for (auto j = 0ul; j < s; ++j) { 47 | if (scan_bytes[i + j] != d[j] && d[j] != -1) { 48 | found = false; 49 | break; 50 | } 51 | } 52 | if (found) 53 | return &scan_bytes[i]; 54 | } 55 | 56 | return nullptr; 57 | } -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /source-sdk/math/vector3d.cpp: -------------------------------------------------------------------------------- 1 | #include "vector3d.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | vec3_t::vec3_t(void) { 9 | x = y = z = 0.0f; 10 | } 11 | 12 | vec3_t::vec3_t(float fx, float fy, float fz) { 13 | x = fx; 14 | y = fy; 15 | z = fz; 16 | } 17 | 18 | vec3_t::~vec3_t(void) { 19 | }; 20 | 21 | void vec3_t::init(float ix, float iy, float iz) { 22 | x = ix; y = iy; z = iz; 23 | } 24 | 25 | void vec3_t::clamp(void) { 26 | x = std::clamp(x, -89.0f, 89.0f); 27 | y = std::clamp(std::remainder(y, 360.0f), -180.0f, 180.0f); 28 | z = std::clamp(z, -50.0f, 50.0f); 29 | } 30 | 31 | vec3_t vec3_t::clamped() { 32 | vec3_t clamped = *this; 33 | clamped.clamp(); 34 | return clamped; 35 | } 36 | 37 | float vec3_t::distance_to(const vec3_t& other) { 38 | vec3_t delta; 39 | delta.x = x - other.x; 40 | delta.y = y - other.y; 41 | delta.z = z - other.z; 42 | 43 | return delta.length(); 44 | } 45 | 46 | void vec3_t::normalize() { 47 | x = std::isfinite(x) ? std::remainderf(x, 360.0f) : 0.0f; 48 | y = std::isfinite(y) ? std::remainderf(y, 360.0f) : 0.0f; 49 | z = 0.0f; 50 | } 51 | 52 | vec3_t vec3_t::normalized(void) { 53 | vec3_t vec(*this); 54 | vec.normalize(); 55 | 56 | return vec; 57 | } 58 | 59 | float vec3_t::length(void) { 60 | float root = 0.0f, sqsr = this->length_sqr(); 61 | 62 | __asm sqrtss xmm0, sqsr 63 | __asm movss root, xmm0 64 | 65 | return root; 66 | } 67 | 68 | float vec3_t::length_sqr(void) { 69 | auto sqr = [](float n) { 70 | return static_cast(n * n); 71 | }; 72 | 73 | return (sqr(x) + sqr(y) + sqr(z)); 74 | } 75 | 76 | float vec3_t::length_2d_sqr(void) const { 77 | return (x * x + y * y); 78 | } 79 | 80 | float vec3_t::dot(const vec3_t other) { 81 | return (x * other.x + y * other.y + z * other.z); 82 | } 83 | 84 | float vec3_t::dot(const float* other) { 85 | const vec3_t& a = *this; 86 | 87 | return(a.x * other[0] + a.y * other[1] + a.z * other[2]); 88 | } -------------------------------------------------------------------------------- /dependencies/utilities/netvars/netvars.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include "../../../source-sdk/classes/recv_props.hpp" 45 | #include "../../../source-sdk/classes/client_class.hpp" 46 | #include "../../utilities/fnv.hpp" 47 | 48 | #define NETVAR(table, prop, func_name, type) \ 49 | type& func_name( ) { \ 50 | static uintptr_t offset = 0; \ 51 | if(!offset) \ 52 | { offset = netvar_manager::get_net_var(fnv::hash( table ), fnv::hash( prop ) ); } \ 53 | \ 54 | return *reinterpret_cast< type* >( uintptr_t( this ) + offset ); \ 55 | } 56 | 57 | #define NETVAR_PTR(table, prop, func_name, type) \ 58 | type* func_name( ) { \ 59 | static uintptr_t offset = 0; \ 60 | if(!offset) \ 61 | { offset = netvar_manager::get_net_var(fnv::hash( table ), fnv::hash( prop ) ); } \ 62 | \ 63 | return reinterpret_cast< type* >( uintptr_t( this ) + offset ); \ 64 | } 65 | 66 | #define OFFSET(type, var, offset) \ 67 | type& var() { \ 68 | return *(type*)(uintptr_t(this) + offset); \ 69 | } \ 70 | 71 | namespace netvar_manager { 72 | uintptr_t get_net_var(uint32_t table, uint32_t prop); 73 | } -------------------------------------------------------------------------------- /source-sdk/structs/weaponinfo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class weapon_info_t { 4 | public: 5 | char pad_0x0000[0x4]; //0x0000 6 | char* m_szWeaponName; //0x0004 7 | char pad_0x0008[0xC]; //0x0008 8 | __int32 m_iMaxClip; //0x0014 9 | char pad_0x0018[0xC]; //0x0018 10 | __int32 m_iMaxReservedAmmo; //0x0024 11 | char pad_0x0028[0x4]; //0x0028 12 | char* m_szWeaponMdlPath; //0x002C 13 | char* m_szWeaponMdlPath2; //0x0030 14 | char* m_szDroppedWeaponMdlPath; //0x0034 15 | char* m_szDefaultClip; //0x0038 16 | char pad_0x003C[0x44]; //0x003C 17 | char* m_szBulletType; //0x0080 18 | char pad_0x0084[0x4]; //0x0084 19 | char* m_szHudName; //0x0088 20 | char* m_szWeaponName2; //0x008C 21 | char pad_0x0090[0x38]; //0x0090 22 | __int32 m_iWeaponType; //0x00C8 23 | __int32 m_iWeaponType2; //0x00CC 24 | __int32 m_iWeaponPrice; //0x00D0 25 | __int32 m_iWeaponReward; //0x00D4 26 | char* m_szWeaponType; //0x00D8 27 | float m_flUnknownFloat0; //0x00DC 28 | char pad_0x00E0[0xC]; //0x00E0 29 | unsigned char m_ucFullAuto; //0x00EC 30 | char pad_0x00ED[0x3]; //0x00ED 31 | __int32 m_iWeaponDamage; //0x00F0 32 | float m_flArmorRatio; //0x00F4 33 | __int32 m_iBullets; //0x00F8 34 | float m_flPenetration; //0x00FC 35 | char pad_0x0100[0x8]; //0x0100 36 | float m_flWeaponRange; //0x0108 37 | float m_flRangeModifier; //0x010C 38 | float m_flThrowVelocity; //0x0110 39 | char pad_0x0114[0xC]; //0x0114 40 | unsigned char m_ucHasSilencer; //0x0120 41 | char pad_0x0121[0xF]; //0x0121 42 | float m_flMaxSpeed; //0x0130 43 | float m_flMaxSpeed2; //0x0134 44 | float m_flAttackMoveSpeedFactor; //0x0138 45 | float m_flSpread; //0x013C 46 | float m_flSpreadAlt; //0x0140 47 | float m_flInaccuracyCrouch; //0x0144 48 | float m_flInaccuracyCrouchAlt; //0x0148 49 | float m_flInaccuracyStand; //0x014C 50 | float m_flInaccuracyStandAlt; //0x0150 51 | float m_flInaccuracyJump; //0x0154 52 | float m_flInaccuracyJumpAlt; //0x0158 53 | char pad_0x015C[0x28]; //0x015C 54 | __int32 m_iRecoilSeed; //0x0184 55 | char pad_0x0188[0x68]; //0x0188 56 | char* m_szWeaponTracesType; //0x01F0 57 | char pad_0x01F4[0x648]; //0x01F4 58 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_console.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/classes/convar.hpp" 3 | #include "../../source-sdk/misc/color.hpp" 4 | #include "i_app_system.hpp" 5 | 6 | class i_console; 7 | class convar; 8 | class con_command; 9 | class con_command_base; 10 | 11 | typedef int cvar_dll_indentifier_t; 12 | 13 | class i_console_display_func { 14 | public: 15 | virtual void ColorPrint(const uint8_t* clr, const char* pMessage) = 0; 16 | virtual void Print(const char* pMessage) = 0; 17 | virtual void DPrint(const char* pMessage) = 0; 18 | }; 19 | 20 | class i_console : public i_app_system { 21 | public: 22 | virtual cvar_dll_indentifier_t allocate_dll_indentifier() = 0; 23 | virtual void register_con_command(con_command_base* pCommandBase) = 0; 24 | virtual void unregister_con_command(con_command_base* pCommandBase) = 0; 25 | virtual void unregister_con_commands(cvar_dll_indentifier_t id) = 0; 26 | virtual const char* get_command_line_value(const char* pVariableName) = 0; 27 | virtual con_command_base* find_command_base(const char* name) = 0; 28 | virtual const con_command_base* find_command_base(const char* name) const = 0; 29 | virtual convar* get_convar(const char* var_name) = 0; 30 | virtual const convar* get_convar(const char* var_name) const = 0; 31 | virtual con_command* find_command(const char* name) = 0; 32 | virtual const con_command* find_command(const char* name) const = 0; 33 | virtual void install_global_change_callback(fn_change_callback_t callback) = 0; 34 | virtual void remove_global_change_callback(fn_change_callback_t callback) = 0; 35 | virtual void call_global_change_callbacks(convar* var, const char* pOldString, float flOldValue) = 0; 36 | virtual void install_console_display_func(i_console_display_func* pDisplayFunc) = 0; 37 | virtual void remove_console_display_func(i_console_display_func* pDisplayFunc) = 0; 38 | virtual void console_color_printf(const color& clr, const char* pFormat, ...) const = 0; 39 | virtual void console_printf(const char* pFormat, ...) const = 0; 40 | virtual void donsole_dprintf(const char* pFormat, ...) const = 0; 41 | virtual void rever_flagged_convars(int nFlag) = 0; 42 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_base_client_dll.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/classes/client_class.hpp" 3 | 4 | enum cstrike15_user_message_t { 5 | cs_um_vguimenu = 1, 6 | cs_um_geiger = 2, 7 | cs_um_train = 3, 8 | cs_um_hudtext = 4, 9 | cs_um_saytext = 5, 10 | cs_um_saytext2 = 6, 11 | cs_um_textmsg = 7, 12 | cs_um_hudmsg = 8, 13 | cs_um_resethud = 9, 14 | cs_um_gametitle = 10, 15 | cs_um_shake = 12, 16 | cs_um_fade = 13, 17 | cs_um_rumble = 14, 18 | cs_um_closecaption = 15, 19 | cs_um_closecaptiondirect = 16, 20 | cs_um_sendaudio = 17, 21 | cs_um_rawaudio = 18, 22 | cs_um_voicemask = 19, 23 | cs_um_requeststate = 20, 24 | cs_um_damage = 21, 25 | cs_um_radiotext = 22, 26 | cs_um_hinttext = 23, 27 | cs_um_keyhinttext = 24, 28 | cs_um_processspottedentityupdate = 25, 29 | cs_um_reloadeffect = 26, 30 | cs_um_adjustmoney = 27, 31 | cs_um_updateteammoney = 28, 32 | cs_um_stopspectatormode = 29, 33 | cs_um_killcam = 30, 34 | cs_um_desiredtimescale = 31, 35 | cs_um_currenttimescale = 32, 36 | cs_um_achievementevent = 33, 37 | cs_um_matchendconditions = 34, 38 | cs_um_disconnecttolobby = 35, 39 | cs_um_playerstatsupdate = 36, 40 | cs_um_displayinventory = 37, 41 | cs_um_warmuphasended = 38, 42 | cs_um_clientinfo = 39, 43 | cs_um_xrankget = 40, 44 | cs_um_xrankupd = 41, 45 | cs_um_callvotefailed = 45, 46 | cs_um_votestart = 46, 47 | cs_um_votepass = 47, 48 | cs_um_votefailed = 48, 49 | cs_um_votesetup = 49, 50 | cs_um_serverrankrevealall = 50, 51 | cs_um_sendlastkillerdamagetoclient = 51, 52 | cs_um_serverrankupdate = 52, 53 | cs_um_itempickup = 53, 54 | cs_um_showmenu = 54, 55 | cs_um_bartime = 55, 56 | cs_um_ammodenied = 56, 57 | cs_um_markachievement = 57, 58 | cs_um_matchstatsupdate = 58, 59 | cs_um_itemdrop = 59, 60 | cs_um_glowpropturnoff = 60, 61 | cs_um_sendplayeritemdrops = 61 62 | }; 63 | 64 | class i_base_client_dll { 65 | public: 66 | c_client_class* get_client_classes() { 67 | using original_fn = c_client_class * (__thiscall*)(i_base_client_dll*); 68 | return (*(original_fn * *)this)[8](this); 69 | } 70 | 71 | bool dispatch_user_message(int msg_type, unsigned int arg1, unsigned int length, const void* data = nullptr) { 72 | using original_fn = bool(__thiscall*)(void*, int, unsigned int, unsigned int, const void*); 73 | return (*(original_fn * *)this)[38](this, msg_type, arg1, length, data); 74 | } 75 | }; -------------------------------------------------------------------------------- /core/features/legitbot/legitbot.cpp: -------------------------------------------------------------------------------- 1 | #include "../features.hpp" 2 | 3 | player_t* legitbot::GetBestTarget(c_usercmd* cmd) 4 | { 5 | float ofov = variables::aimbot_fov; 6 | float nfov = 0; 7 | player_t* player = nullptr; 8 | 9 | for (int iPlayer = 0; iPlayer < interfaces::globals->max_clients; iPlayer++) 10 | { 11 | auto pCSPlayer = reinterpret_cast(interfaces::entity_list->get_client_entity(iPlayer)); 12 | if (!pCSPlayer) 13 | continue; 14 | if (pCSPlayer == csgo::local_player || pCSPlayer->team() == csgo::local_player->team()) 15 | continue; 16 | if (pCSPlayer->dormant()) 17 | continue; 18 | if (!(pCSPlayer->is_alive() && pCSPlayer->health() > 0)) 19 | continue; 20 | if (pCSPlayer->has_gun_game_immunity()) 21 | continue; 22 | vec3_t eyepos = csgo::local_player->get_eye_pos(); 23 | vec3_t enemyheadpos = pCSPlayer->get_bone_position(8); 24 | vec3_t angleTo = math::calculate_angle(eyepos, enemyheadpos); 25 | angleTo.clamp(); 26 | nfov = cmd->viewangles.distance_to(angleTo); 27 | 28 | if (nfov < ofov) 29 | { 30 | ofov = nfov; 31 | player = pCSPlayer; 32 | } 33 | } 34 | return player; 35 | } 36 | 37 | void legitbot::AimBot(c_usercmd* cmd) 38 | { 39 | if (!variables::aimbot) 40 | return; 41 | if (!interfaces::engine->is_connected() || !interfaces::engine->is_in_game()) 42 | return; 43 | if (!csgo::local_player) 44 | return; 45 | if (!csgo::local_player->is_alive()) 46 | return; 47 | player_t* target = GetBestTarget(cmd); 48 | if (target) 49 | { 50 | vec3_t eyepos = csgo::local_player->get_eye_pos(); 51 | vec3_t targethead = target->get_bone_position(8); 52 | vec3_t viewangles = math::calculate_angle(eyepos, targethead); 53 | viewangles.clamp(); 54 | vec3_t delta = cmd->viewangles - viewangles; 55 | delta.clamp(); 56 | vec3_t finalAng = cmd->viewangles - delta / (variables::aimbot_smoothing * 20); 57 | finalAng.clamp(); 58 | if (variables::aimbot_isvisiblecheck && csgo::local_player->can_see_player_pos(target, target->get_eye_pos())) 59 | { 60 | cmd->viewangles = finalAng; 61 | interfaces::engine->set_view_angles(cmd->viewangles); 62 | } 63 | else if(!variables::aimbot_isvisiblecheck) 64 | { 65 | cmd->viewangles = finalAng; 66 | interfaces::engine->set_view_angles(cmd->viewangles); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /dependencies/utilities/netvars/netvars.cpp: -------------------------------------------------------------------------------- 1 | #include "netvars.hpp" 2 | #include "../../interfaces/interfaces.hpp" 3 | 4 | //antario if i remember correctly 5 | namespace netvar_manager { 6 | using netvar_key_value_map = std::unordered_map< uint32_t, uintptr_t >; 7 | using netvar_table_map = std::unordered_map< uint32_t, netvar_key_value_map >; 8 | void initialize_props(netvar_table_map& table_map); 9 | 10 | uintptr_t get_net_var(const uint32_t table, 11 | const uint32_t prop) { 12 | static netvar_table_map map = {}; 13 | if (map.empty()) 14 | initialize_props(map); 15 | 16 | if (map.find(table) == map.end()) 17 | return 0; 18 | 19 | netvar_key_value_map & table_map = map.at(table); 20 | if (table_map.find(prop) == table_map.end()) 21 | return 0; 22 | 23 | return table_map.at(prop); 24 | } 25 | 26 | void add_props_for_table(netvar_table_map & table_map, const uint32_t table_name_hash, const std::string & table_name, recv_table * table, const bool dump_vars, std::map< std::string, std::map< uintptr_t, std::string > > & var_dump, const size_t child_offset = 0) { 27 | for (auto i = 0; i < table->props_count; ++i) { 28 | auto& prop = table->props[i]; 29 | 30 | if (prop.data_table && prop.elements_count > 0) { 31 | if (std::string(prop.prop_name).substr(0, 1) == std::string("0")) 32 | continue; 33 | 34 | add_props_for_table(table_map, table_name_hash, table_name, prop.data_table, dump_vars, var_dump, prop.offset + child_offset); 35 | } 36 | 37 | auto name = std::string(prop.prop_name); 38 | 39 | if (name.substr(0, 1) != "m" /*&& name.substr( 0, 1 ) != "b"*/) 40 | continue; 41 | 42 | const auto name_hash = fnv::hash(prop.prop_name); 43 | const auto offset = uintptr_t(prop.offset) + child_offset; 44 | 45 | table_map[table_name_hash][name_hash] = offset; 46 | 47 | if (dump_vars) 48 | var_dump[table_name][offset] = prop.prop_name; 49 | } 50 | } 51 | 52 | void initialize_props(netvar_table_map & table_map) { 53 | const auto dump_vars = true; //true if netvar dump 54 | 55 | std::map< std::string, std::map< uintptr_t, std::string > > var_dump; 56 | for (auto client_class = interfaces::client->get_client_classes(); 57 | client_class; 58 | client_class = client_class->next_ptr) { 59 | const auto table = reinterpret_cast(client_class->recvtable_ptr); 60 | const auto table_name = table->table_name; 61 | const auto table_name_hash = fnv::hash(table_name); 62 | 63 | if (table == nullptr) 64 | continue; 65 | 66 | add_props_for_table(table_map, table_name_hash, table_name, table, dump_vars, var_dump); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /source-sdk/classes/convar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class convar; 5 | using fn_change_callback_t = void(*)(convar* var, const char* old_value, float f_old_value); 6 | 7 | template 8 | class utl_vector { 9 | public: 10 | constexpr T& operator[](int i) { return memory[i]; }; 11 | 12 | T* memory; 13 | int allocation_count; 14 | int grow_size; 15 | int size; 16 | T* elements; 17 | }; 18 | 19 | enum cvar_flags { 20 | fcvar_none = 0, 21 | fcvar_unregistered = (1 << 0), 22 | fcvar_developmentonly = (1 << 1), 23 | fcvar_gamedll = (1 << 2), 24 | fcvar_clientdll = (1 << 3), 25 | fcvar_hidden = (1 << 4), 26 | fcvar_protected = (1 << 5), 27 | fcvar_sponly = (1 << 6), 28 | fcvar_archive = (1 << 7), 29 | fcvar_notify = (1 << 8), 30 | fcvar_userinfo = (1 << 9), 31 | fcvar_printableonly = (1 << 10), 32 | fcvar_unlogged = (1 << 11), 33 | fcvar_never_as_string = (1 << 12), 34 | fcvar_replicated = (1 << 13), 35 | fcvar_cheat = (1 << 14), 36 | fcvar_ss = (1 << 15), 37 | fcvar_demo = (1 << 16), 38 | fcvar_dontrecord = (1 << 17), 39 | fcvar_ss_added = (1 << 18), 40 | fcvar_release = (1 << 19), 41 | fcvar_reload_materials = (1 << 20), 42 | fcvar_reload_textures = (1 << 21), 43 | fcvar_not_connected = (1 << 22), 44 | fcvar_material_system_thread = (1 << 23), 45 | fcvar_archive_xbox = (1 << 24), 46 | fcvar_accessible_from_threads = (1 << 25), 47 | fcvar_server_can_execute = (1 << 28), 48 | fcvar_server_cannot_query = (1 << 29), 49 | fcvar_clientcmd_can_execute = (1 << 30), 50 | fcvar_meme_dll = (1 << 31), 51 | fcvar_material_thread_mask = (fcvar_reload_materials | fcvar_reload_textures | fcvar_material_system_thread) 52 | }; 53 | 54 | class convar { 55 | public: 56 | void set_value(const char* value) { 57 | using original_fn = void(__thiscall*)(convar*, const char*); 58 | return (*(original_fn * *)this)[14](this, value); 59 | } 60 | void set_value(float value) { 61 | using original_fn = void(__thiscall*)(convar*, float); 62 | return (*(original_fn * *)this)[15](this, value); 63 | } 64 | void set_value(int value) { 65 | using original_fn = void(__thiscall*)(convar*, int); 66 | return (*(original_fn * *)this)[16](this, value); 67 | } 68 | void set_value(bool value) { 69 | using original_fn = void(__thiscall*)(convar*, int); 70 | return (*(original_fn * *)this)[16](this, static_cast(value)); 71 | } 72 | 73 | private: 74 | char pad_0x0000[0x4]; 75 | 76 | public: 77 | convar* next; 78 | __int32 is_registered; 79 | char* name; 80 | char* help_string; 81 | __int32 flags; 82 | 83 | private: 84 | char pad_0x0018[0x4]; 85 | 86 | public: 87 | convar* parent; 88 | char* default_value; 89 | char* string; 90 | __int32 string_length; 91 | float float_value; 92 | __int32 numerical_value; 93 | __int32 has_min; 94 | float min; 95 | __int32 has_max; 96 | float max; 97 | utl_vector callbacks; 98 | }; -------------------------------------------------------------------------------- /core/features/misc/backtracking.cpp: -------------------------------------------------------------------------------- 1 | #include "../features.hpp" 2 | #define FLOW_OUTGOING 0 3 | #define FLOW_INCOMING 1 4 | #define MAX_FLOWS 2 // in & out 5 | float GetFOV(const vec3_t& viewAngle, const vec3_t& aimAngle) 6 | { 7 | vec3_t delta = aimAngle - viewAngle; 8 | delta.clamp(); 9 | 10 | return sqrtf(powf(delta.x, 2.0f) + powf(delta.y, 2.0f)); 11 | } 12 | 13 | struct BacktrackRecord 14 | { 15 | player_t* entity; 16 | vec3_t head; 17 | vec3_t origin; 18 | }; 19 | 20 | struct BacktrackTick 21 | { 22 | int tickcount; 23 | std::vector records; 24 | }; 25 | 26 | std::vector ticks; 27 | player_t* entity; 28 | vec3_t prevOrig; 29 | 30 | void CBacktracking::RegisterTick(c_usercmd* cmd) 31 | { 32 | ticks.insert(ticks.begin(), BacktrackTick{ cmd->tick_count }); 33 | auto& cur = ticks[0]; 34 | 35 | while (ticks.size() > (1.0f/interfaces::globals->interval_per_tick) * 0.2f) 36 | ticks.pop_back(); 37 | 38 | for (int i = 1; i < interfaces::globals->max_clients; i++) 39 | { 40 | auto entity = reinterpret_cast(interfaces::entity_list->get_client_entity(i)); 41 | 42 | if (!entity || 43 | entity->dormant() || 44 | entity->health() <= 0 || 45 | entity->team() == csgo::local_player->team() || 46 | !entity->is_alive() || 47 | entity->has_gun_game_immunity()) 48 | continue; 49 | 50 | cur.records.emplace_back(BacktrackRecord{ entity, entity->get_bone_position(8), entity->origin() }); 51 | } 52 | } 53 | 54 | void CBacktracking::Begin(c_usercmd* cmd) 55 | { 56 | entity = nullptr; 57 | 58 | float serverTime = csgo::local_player->get_tick_base() * interfaces::globals->interval_per_tick; 59 | auto weapon = csgo::local_player->active_weapon(); 60 | 61 | if (cmd->buttons & in_attack && weapon->next_primary_attack() < serverTime + 0.001) 62 | { 63 | float fov = 5.f; 64 | int tickcount = 0; 65 | bool hasTarget = false; 66 | vec3_t orig; 67 | 68 | for (auto& tick : ticks) 69 | { 70 | for (auto& record : tick.records) 71 | { 72 | vec3_t localeyepos = csgo::local_player->get_eye_pos(); 73 | vec3_t angle = math::calculate_angle(localeyepos, record.head); 74 | float tmpFOV = GetFOV(cmd->viewangles, angle); 75 | 76 | if (tmpFOV < fov) 77 | { 78 | fov = tmpFOV; 79 | tickcount = tick.tickcount; 80 | hasTarget = true; 81 | entity = record.entity; 82 | orig = record.origin; 83 | } 84 | } 85 | } 86 | 87 | if (entity && hasTarget) 88 | { 89 | cmd->tick_count = tickcount; 90 | prevOrig = entity->origin(); 91 | entity->origin() = orig; 92 | } 93 | } 94 | } 95 | 96 | void CBacktracking::End() 97 | { 98 | if (entity) 99 | entity->origin() = prevOrig; 100 | 101 | entity = nullptr; 102 | } 103 | 104 | c -------------------------------------------------------------------------------- /dependencies/interfaces/i_game_event_manager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define EVENT_DEBUG_ID_INIT 42 6 | #define EVENT_DEBUG_ID_SHUTDOWN 13 7 | 8 | class bf_write; 9 | class bf_read; 10 | class i_game_event { 11 | public: 12 | virtual ~i_game_event() = 0; 13 | virtual const char* get_name() const = 0; 14 | 15 | virtual bool is_reliable() const = 0; 16 | virtual bool is_local() const = 0; 17 | virtual bool is_empty(const char* keyName = nullptr) = 0; 18 | 19 | virtual bool get_bool(const char* keyName = nullptr, bool defaultValue = false) = 0; 20 | virtual int get_int(const char* keyName = nullptr, int defaultValue = 0) = 0; 21 | virtual uint64_t get_uint_64(const char* keyName = nullptr, unsigned long defaultValue = 0) = 0; 22 | virtual float get_float(const char* keyName = nullptr, float defaultValue = 0.0f) = 0; 23 | virtual const char* get_string(const char* keyName = nullptr, const char* defaultValue = "") = 0; 24 | virtual const wchar_t* get_wstring(const char* keyName, const wchar_t* defaultValue = L"") = 0; 25 | 26 | virtual void set_bool(const char* keyName, bool value) = 0; 27 | virtual void set_int(const char* keyName, int value) = 0; 28 | virtual void set_uint_64(const char* keyName, unsigned long value) = 0; 29 | virtual void set_float(const char* keyName, float value) = 0; 30 | virtual void set_string(const char* keyName, const char* value) = 0; 31 | virtual void set_wstring(const char* keyName, const wchar_t* value) = 0; 32 | }; 33 | 34 | class i_game_event_listener2 { 35 | public: 36 | virtual ~i_game_event_listener2(void) {} 37 | 38 | virtual void fire_game_event(i_game_event* event) = 0; 39 | int m_i_debug_id; 40 | virtual int get_event_debug_id(void) { return m_i_debug_id; }; 41 | }; 42 | 43 | class i_game_event_manager2 { 44 | public: 45 | virtual ~i_game_event_manager2() = 0; 46 | virtual int load_events_from_file(const char* filename) = 0; 47 | virtual void reset() = 0; 48 | virtual bool add_listener(i_game_event_listener2* listener, const char* name, bool bServerSide) = 0; 49 | virtual bool find_listener(i_game_event_listener2* listener, const char* name) = 0; 50 | virtual int remove_listener(i_game_event_listener2* listener) = 0; 51 | virtual i_game_event* CreateEvent(const char* name, bool bForce, unsigned int dwUnknown) = 0; 52 | virtual bool fire_event(i_game_event* event, bool bDontBroadcast = false) = 0; 53 | virtual bool fire_event_client_side(i_game_event* event) = 0; 54 | virtual i_game_event* duplicate_event(i_game_event* event) = 0; 55 | virtual void free_event(i_game_event* event) = 0; 56 | virtual bool serialize_event(i_game_event* event, bf_write* buf) = 0; 57 | virtual i_game_event* unserialize_event(bf_read* buf) = 0; 58 | }; -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /dependencies/interfaces/interfaces.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "i_base_client_dll.hpp" 8 | #include "i_client_entity_list.hpp" 9 | #include "iv_engine_client.hpp" 10 | #include "i_client_state.hpp" 11 | #include "i_panel.hpp" 12 | #include "i_surface.hpp" 13 | #include "c_global_vars_base.hpp" 14 | #include "i_material_system.hpp" 15 | #include "iv_model_info.hpp" 16 | #include "iv_model_render.hpp" 17 | #include "iv_debug_overlay.hpp" 18 | #include "i_console.hpp" 19 | #include "i_localize.hpp" 20 | #include "i_game_event_manager.hpp" 21 | #include "i_input.hpp" 22 | #include "i_input_system.hpp" 23 | #include "i_trace.hpp" 24 | #include "i_render_view.hpp" 25 | #include "glow_manager.hpp" 26 | #include "i_player_movement.hpp" 27 | #include "i_weapon_system.hpp" 28 | 29 | namespace interfaces { 30 | enum class interface_type { index, bruteforce }; 31 | 32 | template 33 | ret* get_interface(std::string module_name, std::string interface_name) { 34 | using create_interface_fn = void* (*)(const char*, int*); 35 | create_interface_fn fn = reinterpret_cast(GetProcAddress(GetModuleHandle(module_name.c_str()), "CreateInterface")); 36 | 37 | if (fn) { 38 | void* result = nullptr; 39 | 40 | switch (type) { 41 | case interface_type::index: 42 | result = fn(interface_name.c_str(), nullptr); 43 | 44 | break; 45 | case interface_type::bruteforce: 46 | char buf[128]; 47 | 48 | for (uint32_t i = 0; i <= 100; i++) { 49 | memset((void*)buf, 0, sizeof buf); 50 | 51 | result = fn(interface_name.c_str(), nullptr); 52 | 53 | if (result) 54 | break; 55 | } 56 | 57 | break; 58 | } 59 | 60 | if (!result) 61 | throw std::runtime_error(interface_name.c_str()); 62 | 63 | return reinterpret_cast(result); 64 | } 65 | 66 | return reinterpret_cast(nullptr); 67 | } 68 | 69 | extern i_base_client_dll* client; 70 | extern i_input* input; 71 | extern i_client_entity_list* entity_list; 72 | extern iv_engine_client* engine; 73 | extern i_client_mode* clientmode; 74 | extern i_client_state* clientstate; 75 | extern i_panel* panel; 76 | extern i_surface* surface; 77 | extern c_global_vars_base* globals; 78 | extern i_material_system* material_system; 79 | extern iv_model_info* model_info; 80 | extern iv_model_render* model_render; 81 | extern i_render_view* render_view; 82 | extern iv_debug_overlay* debug_overlay; 83 | extern i_console* console; 84 | extern i_localize* localize; 85 | extern i_game_event_manager2* event_manager; 86 | extern i_inputsytem* inputsystem; 87 | extern IDirect3DDevice9* directx; 88 | extern trace* trace_ray; 89 | extern glow_manager_t* glow_manager; 90 | extern player_game_movement* game_movement; 91 | extern player_prediction* prediction; 92 | extern player_move_helper* move_helper; 93 | extern i_weapon_system* weapon_system; 94 | 95 | bool initialize(); 96 | } -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /dependencies/interfaces/iv_engine_client.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../../source-sdk/math/vector3d.hpp" 4 | #include "../../source-sdk/math/vector2d.hpp" 5 | #include "../../source-sdk/math/view_matrix.hpp" 6 | #include "../../source-sdk/classes/net_channel.hpp" 7 | #include "../../dependencies/utilities/utilities.hpp" 8 | 9 | struct player_info_t { 10 | int64_t __pad0; 11 | union { 12 | int64_t xuid; 13 | struct { 14 | int xuidlow; 15 | int xuidhigh; 16 | }; 17 | }; 18 | char name[128]; 19 | int userid; 20 | char guid[33]; 21 | unsigned int friendsid; 22 | char friendsname[128]; 23 | bool fakeplayer; 24 | bool ishltv; 25 | unsigned int customfiles[4]; 26 | unsigned char filesdownloaded; 27 | }; 28 | 29 | class iv_engine_client { 30 | public: 31 | i_net_channel* get_net_channel_info() { 32 | using original_fn = i_net_channel * (__thiscall*)(iv_engine_client*); 33 | return (*(original_fn * *)this)[78](this); 34 | } 35 | int get_local_player() { 36 | using original_fn = int(__thiscall*)(iv_engine_client*); 37 | return (*(original_fn * *)this)[12](this); 38 | } 39 | int get_player_for_user_id(int user_id) { 40 | using original_fn = int(__thiscall*)(iv_engine_client*, int); 41 | return (*(original_fn * *)this)[9](this, user_id); 42 | } 43 | void get_player_info(int index, player_info_t* info) { 44 | using original_fn = void(__thiscall*)(iv_engine_client*, int, player_info_t*); 45 | return (*(original_fn * *)this)[8](this, index, info); 46 | } 47 | void get_screen_size(int& width, int& height) { 48 | using original_fn = void(__thiscall*)(iv_engine_client*, int&, int&); 49 | return (*(original_fn * *)this)[5](this, width, height); 50 | } 51 | bool is_in_game() { 52 | using original_fn = bool(__thiscall*)(iv_engine_client*); 53 | return (*(original_fn * *)this)[26](this); 54 | } 55 | bool is_connected() { 56 | using original_fn = bool(__thiscall*)(iv_engine_client*); 57 | return (*(original_fn * *)this)[27](this); 58 | } 59 | void execute_cmd(const char* cmd) { 60 | using original_fn = void(__thiscall*)(iv_engine_client*, const char*); 61 | return (*(original_fn * *)this)[108](this, cmd); // this always seems to crash whilst debugging, just feel free to continue. 62 | } 63 | void set_view_angles(vec3_t& angles) { 64 | using original_fn = void(__thiscall*)(iv_engine_client*, vec3_t&); 65 | return (*(original_fn * *)this)[19](this, angles); 66 | } 67 | 68 | void get_view_angles(vec3_t& angles) { 69 | return utilities::call_virtual(this, 18)(this, angles); 70 | } 71 | 72 | view_matrix_t& world_to_screen_matrix() { 73 | view_matrix_t temp; 74 | using original_fn = view_matrix_t & (__thiscall*)(iv_engine_client*); 75 | return (*(original_fn * *)this)[37](this); 76 | } 77 | 78 | bool is_taking_screenshot() { 79 | using original_fn = bool(__thiscall*)(iv_engine_client*); 80 | return (*(original_fn * *)this)[92](this); 81 | } 82 | 83 | const char* get_level_name() { 84 | using original_fn = const char* (__thiscall*)(iv_engine_client*); 85 | return (*(original_fn * *)this)[53](this); 86 | } 87 | }; -------------------------------------------------------------------------------- /core/menu/framework.cpp: -------------------------------------------------------------------------------- 1 | #include "framework.hpp" 2 | 3 | //credits to harcuz for menu framework (https://www.unknowncheats.me/forum/members/2669363.html), 4 | POINT cursor; 5 | POINT cursor_corrected; 6 | 7 | void menu_framework::group_box(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, unsigned long font, const std::string string, bool show_label) { 8 | //groupbox background 9 | render::draw_filled_rect(x, y, w, h, color(255, 153, 51, 255)); 10 | 11 | //groupbox outline 12 | render::draw_rect(x, y, w, h, color(45, 45, 45, 255)); 13 | 14 | //groupbox label 15 | if (show_label) 16 | render::draw_text_string(x + 2, y - 12, font, string, false, color::white()); 17 | } 18 | 19 | void menu_framework::tab(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, unsigned long font, const std::string string, std::int32_t& tab, std::int32_t count, bool show_outline) { 20 | GetCursorPos(&cursor); 21 | 22 | if ((cursor.x > x) && (cursor.x < x + w) && (cursor.y > y) && (cursor.y < y + h) && (GetAsyncKeyState(VK_LBUTTON) & 1)) 23 | tab = count; 24 | 25 | //tab background 26 | if (show_outline) 27 | render::draw_rect(x, y, w, h, tab == count ? color(52, 134, 235, 255) : color(25, 25, 25, 255)); 28 | 29 | //tab label 30 | render::draw_text_string(x - render::get_text_size(font, string).x / 2 + 50, y + h / 2 - 8, font, string, false, show_outline ? color::white() : tab == count ? color(52, 134, 235, 255) : color::white()); 31 | } 32 | 33 | void menu_framework::check_box(std::int32_t x, std::int32_t y, std::int32_t position, unsigned long font, const std::string string, bool& value) { 34 | GetCursorPos(&cursor); 35 | 36 | int w = 10, h = 10; 37 | 38 | if ((cursor.x > position) && (cursor.x < position + w) && (cursor.y > y) && (cursor.y < y + h) && GetAsyncKeyState(VK_LBUTTON) & 1) 39 | value = !value; 40 | 41 | //checkbox background 42 | render::draw_filled_rect(position, y, w, h, value ? color(52, 134, 235, 255) : color(36, 36, 36, 255)); 43 | 44 | //checkbox label 45 | render::draw_text_string(x + 2, y - 1, font, string, false, color::white()); 46 | } 47 | 48 | void menu_framework::slider(std::int32_t x, std::int32_t y, std::int32_t position, unsigned long font, const std::string string, float& value, float min_value, float max_value) { 49 | GetCursorPos(&cursor); 50 | 51 | int ix = x + 140; 52 | int yi = y + 4; 53 | 54 | if ((cursor.x > ix) && (cursor.x < ix + position) && (cursor.y > yi) && (cursor.y < yi + 6) && (GetAsyncKeyState(VK_LBUTTON))) 55 | value = (cursor.x - ix) / (float(position) / float(max_value)); 56 | 57 | //slider background 58 | render::draw_filled_rect(ix, yi, position, 6, color(36, 36, 36, 255)); 59 | render::draw_filled_rect(ix, yi, value * (float(position) / float(max_value)), 6, color(52, 134, 235, 255)); 60 | 61 | //slider label 62 | render::draw_text_string(x + 2, y - 1, font, (std::stringstream{ } << string << ": " << std::setprecision(3) << value).str(), false, color::white()); 63 | } 64 | 65 | void menu_framework::menu_movement(std::int32_t& x, std::int32_t& y, std::int32_t w, std::int32_t h) { 66 | GetCursorPos(&cursor); 67 | 68 | if (GetAsyncKeyState(VK_LBUTTON) < 0 && (cursor.x > x && cursor.x < x + w && cursor.y > y && cursor.y < y + h)) { 69 | should_drag = true; 70 | 71 | if (!should_move) { 72 | cursor_corrected.x = cursor.x - x; 73 | cursor_corrected.y = cursor.y - y; 74 | should_move = true; 75 | } 76 | } 77 | 78 | if (should_drag) { 79 | x = cursor.x - cursor_corrected.x; 80 | y = cursor.y - cursor_corrected.y; 81 | } 82 | 83 | if (GetAsyncKeyState(VK_LBUTTON) == 0) { 84 | should_drag = false; 85 | should_move = false; 86 | } 87 | } 88 | 89 | -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /dependencies/interfaces/i_input_system.hpp: -------------------------------------------------------------------------------- 1 | enum analog_code_t { 2 | ANALOG_CODE_INVALID = -1, 3 | MOUSE_X = 0, 4 | MOUSE_Y, 5 | MOUSE_XY, // invoked when either x or y changes 6 | MOUSE_WHEEL, 7 | ANALOG_CODE_LAST = 10, 8 | }; 9 | 10 | enum button_code_t{ 11 | BUTTON_CODE_INVALID = -1, 12 | BUTTON_CODE_NONE = 0, 13 | 14 | KEY_FIRST = 0, 15 | 16 | KEY_NONE = KEY_FIRST, 17 | KEY_0, 18 | KEY_1, 19 | KEY_2, 20 | KEY_3, 21 | KEY_4, 22 | KEY_5, 23 | KEY_6, 24 | KEY_7, 25 | KEY_8, 26 | KEY_9, 27 | KEY_A, 28 | KEY_B, 29 | KEY_C, 30 | KEY_D, 31 | KEY_E, 32 | KEY_F, 33 | KEY_G, 34 | KEY_H, 35 | KEY_I, 36 | KEY_J, 37 | KEY_K, 38 | KEY_L, 39 | KEY_M, 40 | KEY_N, 41 | KEY_O, 42 | KEY_P, 43 | KEY_Q, 44 | KEY_R, 45 | KEY_S, 46 | KEY_T, 47 | KEY_U, 48 | KEY_V, 49 | KEY_W, 50 | KEY_X, 51 | KEY_Y, 52 | KEY_Z, 53 | KEY_PAD_0, 54 | KEY_PAD_1, 55 | KEY_PAD_2, 56 | KEY_PAD_3, 57 | KEY_PAD_4, 58 | KEY_PAD_5, 59 | KEY_PAD_6, 60 | KEY_PAD_7, 61 | KEY_PAD_8, 62 | KEY_PAD_9, 63 | KEY_PAD_DIVIDE, 64 | KEY_PAD_MULTIPLY, 65 | KEY_PAD_MINUS, 66 | KEY_PAD_PLUS, 67 | KEY_PAD_ENTER, 68 | KEY_PAD_DECIMAL, 69 | KEY_LBRACKET, 70 | KEY_RBRACKET, 71 | KEY_SEMICOLON, 72 | KEY_APOSTROPHE, 73 | KEY_BACKQUOTE, 74 | KEY_COMMA, 75 | KEY_PERIOD, 76 | KEY_SLASH, 77 | KEY_BACKSLASH, 78 | KEY_MINUS, 79 | KEY_EQUAL, 80 | KEY_ENTER, 81 | KEY_SPACE, 82 | KEY_BACKSPACE, 83 | KEY_TAB, 84 | KEY_CAPSLOCK, 85 | KEY_NUMLOCK, 86 | KEY_ESCAPE, 87 | KEY_SCROLLLOCK, 88 | KEY_INSERT, 89 | KEY_DELETE, 90 | KEY_HOME, 91 | KEY_END, 92 | KEY_PAGEUP, 93 | KEY_PAGEDOWN, 94 | KEY_BREAK, 95 | KEY_LSHIFT, 96 | KEY_RSHIFT, 97 | KEY_LALT, 98 | KEY_RALT, 99 | KEY_LCONTROL, 100 | KEY_RCONTROL, 101 | KEY_LWIN, 102 | KEY_RWIN, 103 | KEY_APP, 104 | KEY_UP, 105 | KEY_LEFT, 106 | KEY_DOWN, 107 | KEY_RIGHT, 108 | KEY_F1, 109 | KEY_F2, 110 | KEY_F3, 111 | KEY_F4, 112 | KEY_F5, 113 | KEY_F6, 114 | KEY_F7, 115 | KEY_F8, 116 | KEY_F9, 117 | KEY_F10, 118 | KEY_F11, 119 | KEY_F12, 120 | KEY_CAPSLOCKTOGGLE, 121 | KEY_NUMLOCKTOGGLE, 122 | KEY_SCROLLLOCKTOGGLE, 123 | 124 | KEY_LAST = KEY_SCROLLLOCKTOGGLE, 125 | KEY_COUNT = KEY_LAST - KEY_FIRST + 1, 126 | 127 | // Mouse 128 | MOUSE_FIRST = KEY_LAST + 1, 129 | 130 | MOUSE_LEFT = MOUSE_FIRST, 131 | MOUSE_RIGHT, 132 | MOUSE_MIDDLE, 133 | MOUSE_4, 134 | MOUSE_5, 135 | MOUSE_WHEEL_UP, // A fake button which is 'pressed' and 'released' when the wheel is moved up 136 | MOUSE_WHEEL_DOWN, // A fake button which is 'pressed' and 'released' when the wheel is moved down 137 | 138 | MOUSE_LAST = MOUSE_WHEEL_DOWN, 139 | MOUSE_COUNT = MOUSE_LAST - MOUSE_FIRST + 1, 140 | 141 | }; 142 | 143 | 144 | class i_inputsytem { 145 | public: 146 | void enable_input(bool bEnable) { 147 | using original_fn = void(__thiscall*)(void*, bool); 148 | return (*(original_fn * *)this)[11](this, bEnable); 149 | } 150 | 151 | void reset_input_state() { 152 | using original_fn = void(__thiscall*)(void*); 153 | return (*(original_fn * *)this)[39](this); 154 | } 155 | 156 | bool is_button_down(button_code_t code) { 157 | using original_fn = bool(__thiscall*)(void*, button_code_t); 158 | return (*(original_fn * *)this)[15](this, code); 159 | } 160 | 161 | int get_analog_value(analog_code_t code) { 162 | using original_fn = int(__thiscall*)(void*, analog_code_t); 163 | return (*(original_fn * *)this)[18](this, code); 164 | 165 | } 166 | 167 | int get_analog_delta(analog_code_t code) { 168 | using original_fn = int(__thiscall*)(void*, analog_code_t); 169 | return (*(original_fn * *)this)[19](this, code); 170 | } 171 | 172 | const char* button_code_to_string(int code) { 173 | using original_fn = const char* (__thiscall*)(void*, int); 174 | return (*(original_fn * *)this)[40](this, code); 175 | } 176 | 177 | }; -------------------------------------------------------------------------------- /dependencies/utilities/renderer/renderer.cpp: -------------------------------------------------------------------------------- 1 | #include "renderer.hpp" 2 | 3 | unsigned long render::fonts::watermark_font; 4 | 5 | void render::initialize() { 6 | render::fonts::watermark_font = interfaces::surface->font_create(); 7 | 8 | interfaces::surface->set_font_glyph(render::fonts::watermark_font, "Tahoma", 12, 500, 0, 0, font_flags::fontflag_dropshadow); 9 | 10 | console::log("[setup] render initialized!\n"); 11 | } 12 | 13 | void render::draw_line(std::int32_t x1, std::int32_t y1, std::int32_t x2, std::int32_t y2, color colour) { 14 | interfaces::surface->set_drawing_color(colour.r, colour.g, colour.b, colour.a); 15 | interfaces::surface->draw_line(x1, y1, x2, y2); 16 | } 17 | 18 | void render::draw_text_wchar(std::int32_t x, std::int32_t y, unsigned long font, const wchar_t* string, color colour) { 19 | interfaces::surface->set_text_color(colour.r, colour.g, colour.b, colour.a); 20 | interfaces::surface->draw_text_font(font); 21 | interfaces::surface->draw_text_pos(x, y); 22 | interfaces::surface->draw_render_text(string, wcslen(string)); 23 | } 24 | 25 | void render::draw_text_string(std::int32_t x, std::int32_t y, unsigned long font, std::string string, bool text_centered, color colour) { 26 | const auto converted_text = std::wstring(string.begin(), string.end()); 27 | 28 | int width, height; 29 | interfaces::surface->get_text_size(font, converted_text.c_str(), width, height); 30 | 31 | interfaces::surface->set_text_color(colour.r, colour.g, colour.b, colour.a); 32 | interfaces::surface->draw_text_font(font); 33 | if (text_centered) 34 | interfaces::surface->draw_text_pos(x - (width / 2), y); 35 | else 36 | interfaces::surface->draw_text_pos(x, y); 37 | interfaces::surface->draw_render_text(converted_text.c_str(), wcslen(converted_text.c_str())); 38 | } 39 | 40 | void render::draw_rect(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, color color) { 41 | interfaces::surface->set_drawing_color(color.r, color.g, color.b, color.a); 42 | interfaces::surface->draw_outlined_rect(x, y, w, h); 43 | } 44 | 45 | void render::draw_filled_rect(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, color colour) { 46 | interfaces::surface->set_drawing_color(colour.r, colour.g, colour.b, colour.a); 47 | interfaces::surface->draw_filled_rectangle(x, y, w, h); 48 | } 49 | 50 | void render::draw_outline(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, color colour) { 51 | interfaces::surface->set_drawing_color(colour.r, colour.g, colour.b, colour.a); 52 | interfaces::surface->draw_outlined_rect(x, y, w, h); 53 | } 54 | 55 | void render::draw_textured_polygon(std::int32_t n, vertex_t* vertice, color col) { 56 | static unsigned char buf[4] = { 255, 255, 255, 255 }; 57 | unsigned int texture_id{}; 58 | if (!texture_id) { 59 | texture_id = interfaces::surface->create_new_texture_id(true); 60 | interfaces::surface->set_texture_rgba(texture_id, buf, 1, 1); 61 | } 62 | interfaces::surface->set_drawing_color(col.r, col.g, col.b, col.a); 63 | interfaces::surface->set_texture(texture_id); 64 | interfaces::surface->draw_polygon(n, vertice); 65 | } 66 | 67 | void render::draw_circle(std::int32_t x, std::int32_t y, float r, float s, color col) { 68 | float Step = M_PI * 2.0 / s; 69 | for (float a = 0; a < (M_PI * 2.0); a += Step) { 70 | float x1 = r * cos(a) + x; 71 | float y1 = r * sin(a) + y; 72 | float x2 = r * cos(a + Step) + x; 73 | float y2 = r * sin(a + Step) + y; 74 | interfaces::surface->set_drawing_color(col.r, col.g, col.b, col.a); 75 | interfaces::surface->draw_line(x1, y1, x2, y2); 76 | } 77 | } 78 | 79 | vec2_t render::get_text_size(unsigned long font, std::string text) { 80 | std::wstring a(text.begin(), text.end()); 81 | const wchar_t* wstr = a.c_str(); 82 | static int w, h; 83 | 84 | interfaces::surface->get_text_size(font, wstr, w, h); 85 | return { static_cast(w), static_cast(h) }; 86 | } -------------------------------------------------------------------------------- /dependencies/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 | -------------------------------------------------------------------------------- /dependencies/interfaces/interfaces.cpp: -------------------------------------------------------------------------------- 1 | #include "interfaces.hpp" 2 | #include "../utilities/csgo.hpp" 3 | 4 | i_base_client_dll* interfaces::client = nullptr; 5 | i_input* interfaces::input = nullptr; 6 | i_client_entity_list* interfaces::entity_list = nullptr; 7 | iv_engine_client* interfaces::engine = nullptr; 8 | i_client_mode* interfaces::clientmode = nullptr; 9 | i_client_state* interfaces::clientstate = nullptr; 10 | i_panel* interfaces::panel = nullptr; 11 | i_surface* interfaces::surface = nullptr; 12 | c_global_vars_base* interfaces::globals = nullptr; 13 | i_material_system* interfaces::material_system = nullptr; 14 | iv_model_info* interfaces::model_info = nullptr; 15 | iv_model_render* interfaces::model_render = nullptr; 16 | i_render_view* interfaces::render_view = nullptr; 17 | i_console* interfaces::console = nullptr; 18 | i_localize* interfaces::localize = nullptr; 19 | i_game_event_manager2* interfaces::event_manager = nullptr; 20 | i_inputsytem* interfaces::inputsystem = nullptr; 21 | iv_debug_overlay* interfaces::debug_overlay = nullptr; 22 | IDirect3DDevice9* interfaces::directx = nullptr; 23 | trace* interfaces::trace_ray = nullptr; 24 | glow_manager_t* interfaces::glow_manager = nullptr; 25 | player_game_movement* interfaces::game_movement = nullptr; 26 | player_prediction* interfaces::prediction = nullptr; 27 | player_move_helper* interfaces::move_helper = nullptr; 28 | i_weapon_system* interfaces::weapon_system = nullptr; 29 | 30 | bool interfaces::initialize() { 31 | client = get_interface("client.dll", "VClient018"); 32 | entity_list = get_interface("client.dll", "VClientEntityList003"); 33 | engine = get_interface("engine.dll", "VEngineClient014"); 34 | panel = get_interface("vgui2.dll", "VGUI_Panel009"); 35 | surface = get_interface("vguimatsurface.dll", "VGUI_Surface031"); 36 | material_system = get_interface("materialsystem.dll", "VMaterialSystem080"); 37 | model_info = get_interface("engine.dll", "VModelInfoClient004"); 38 | model_render = get_interface("engine.dll", "VEngineModel016"); 39 | render_view = get_interface("engine.dll", "VEngineRenderView014"); 40 | console = get_interface("vstdlib.dll", "VEngineCvar007"); 41 | localize = get_interface("localize.dll", "Localize_001"); 42 | event_manager = get_interface("engine.dll", "GAMEEVENTSMANAGER002"); 43 | debug_overlay = get_interface("engine.dll", "VDebugOverlay004"); 44 | inputsystem = get_interface("inputsystem.dll", "InputSystemVersion001"); 45 | trace_ray = get_interface("engine.dll", "EngineTraceClient004"); 46 | game_movement = get_interface("client.dll", "GameMovement001"); 47 | prediction = get_interface("client.dll", "VClientPrediction001"); 48 | 49 | /*custom interfaces*/ 50 | clientmode = **reinterpret_cast((*reinterpret_cast(client))[10] + 5); 51 | globals = **reinterpret_cast((*reinterpret_cast(client)[0] + 27)); 52 | 53 | clientstate = **(i_client_state ***)(utilities::pattern_scan("engine.dll", sig_client_state) + 1); 54 | directx = **(IDirect3DDevice9***)(utilities::pattern_scan("shaderapidx9.dll", sig_directx) + 1); 55 | input = *(i_input**)(utilities::pattern_scan("client.dll", sig_input) + 1); 56 | glow_manager = (glow_manager_t*)(*(uintptr_t*)(utilities::pattern_scan("client.dll", sig_glow_manager) + 3)); 57 | move_helper = **(player_move_helper***)(utilities::pattern_scan("client.dll", sig_player_move_helper) + 2); 58 | weapon_system = *(i_weapon_system**)(utilities::pattern_scan("client.dll", sig_weapon_data) + 2); 59 | 60 | console::log("[setup] interfaces initialized!\n"); 61 | 62 | return true; 63 | } -------------------------------------------------------------------------------- /source-sdk/structs/animstate.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class anim_state { 4 | public: 5 | char pad_0x0000[0x18]; //0x0000 6 | float anim_update_timer; //0x0018 7 | char pad_0x001C[0xC]; //0x001C 8 | float started_moving_time; //0x0028 9 | float last_move_time; //0x002C 10 | char pad_0x0030[0x10]; //0x0030 11 | float last_lby_time; //0x0040 12 | char pad_0x0044[0x8]; //0x0044 13 | float run_amount; //0x004C 14 | char pad_0x0050[0x10]; //0x0050 15 | void* entity; //0x0060 16 | __int32 active_weapon; //0x0064 17 | __int32 last_active_weapon; //0x0068 18 | float last_client_side_animation_update_time; //0x006C 19 | __int32 last_client_side_animation_update_framecount; //0x0070 20 | float eye_timer; //0x0074 21 | float eye_angles_y; //0x0078 22 | float eye_angles_x; //0x007C 23 | float goal_feet_yaw; //0x0080 24 | float current_feet_yaw; //0x0084 25 | float torso_yaw; //0x0088 26 | float last_move_yaw; //0x008C 27 | float lean_amount; //0x0090 28 | char pad_0x0094[0x4]; //0x0094 29 | float feet_cycle; //0x0098 30 | float feet_yaw_rate; //0x009C 31 | char pad_0x00A0[0x4]; //0x00A0 32 | float duck_amount; //0x00A4 33 | float landing_duck_amount; //0x00A8 34 | char pad_0x00AC[0x4]; //0x00AC 35 | vec3_t current_origin; 36 | vec3_t last_origin; 37 | float velocity_x; //0x00C8 38 | float velocity_y; //0x00CC 39 | char pad_0x00D0[0x10]; //0x00D0 40 | float move_direction_1; //0x00E0 41 | float move_direction_2; //0x00E4 42 | char pad_0x00E8[0x4]; //0x00E8 43 | float m_velocity; //0x00EC 44 | float jump_fall_velocity; //0x00F0 45 | float clamped_velocity; //0x00F4 46 | float feet_speed_forwards_or_sideways; //0x00F8 47 | float feet_speed_unknown_forwards_or_sideways; //0x00FC 48 | float last_time_started_moving; //0x0100 49 | float last_time_stopped_moving; //0x0104 50 | bool on_ground; //0x0108 51 | bool hit_in_ground_animation; //0x010C 52 | char pad_0x0110[0x4]; //0x0110 53 | float last_origin_z; //0x0114 54 | float head_from_ground_distance_standing; //0x0118 55 | float stop_to_full_running_fraction; //0x011C 56 | char pad_0x0120[0x14]; //0x0120 57 | __int32 is_not_moving; //0x0134 58 | char pad_0x0138[0x20]; //0x0138 59 | float last_anim_update_time; //0x0158 60 | float moving_direction_x; //0x015C 61 | float moving_direction_y; //0x0160 62 | float moving_direction_z; //0x0164 63 | char pad_0x0168[0x44]; //0x0168 64 | __int32 started_moving; //0x01AC 65 | char pad_0x01B0[0x8]; //0x01B0 66 | float lean_yaw; //0x01B8 67 | char pad_0x01BC[0x8]; //0x01BC 68 | float poses_speed; //0x01C4 69 | char pad_0x01C8[0x8]; //0x01C8 70 | float ladder_speed; //0x01D0 71 | char pad_0x01D4[0x8]; //0x01D4 72 | float ladder_yaw; //0x01DC 73 | char pad_0x01E0[0x8]; //0x01E0 74 | float some_pose; //0x01E8 75 | char pad_0x01EC[0x14]; //0x01EC 76 | float body_yaw; //0x0200 77 | char pad_0x0204[0x8]; //0x0204 78 | float body_pitch; //0x020C 79 | char pad_0x0210[0x8]; //0x0210 80 | float death_yaw; //0x0218 81 | char pad_0x021C[0x8]; //0x021C 82 | float stand; //0x0224 83 | char pad_0x0228[0x8]; //0x0228 84 | float jump_fall; //0x0230 85 | char pad_0x0234[0x8]; //0x0234 86 | float aim_blend_stand_idle; //0x023C 87 | char pad_0x0240[0x8]; //0x0240 88 | float aim_blend_crouch_idle; //0x0248 89 | char pad_0x024C[0x8]; //0x024C 90 | float strafe_yaw; //0x0254 91 | char pad_0x0258[0x8]; //0x0258 92 | float aim_blend_stand_walk; //0x0260 93 | char pad_0x0264[0x8]; //0x0264 94 | float aim_blend_stand_run; //0x026C 95 | char pad_0x0270[0x8]; //0x0270 96 | float aim_blend_crouch_walk; //0x0278 97 | char pad_0x027C[0x8]; //0x027C 98 | float move_blend_walk; //0x0284 99 | char pad_0x0288[0x8]; //0x0288 100 | float move_blend_run; //0x0290 101 | char pad_0x0294[0x8]; //0x0294 102 | float move_blend_crouch; //0x029C 103 | char pad_0x02A0[0x4]; //0x02A0 104 | float speed; //0x02A4 105 | __int32 moving_in_any_direction; //0x02A8 106 | float acceleration; //0x02AC 107 | char pad_0x02B0[0x74]; //0x02B0 108 | float crouch_height; //0x0324 109 | __int32 is_full_crouched; //0x0328 110 | char pad_0x032C[0x4]; //0x032C 111 | float velocity_subtract_x; //0x0330 112 | float velocity_subtract_y; //0x0334 113 | float velocity_subtract_z; //0x0338 114 | float standing_head_height; //0x033C 115 | char pad_0x0340[0x4]; //0x0340 116 | }; -------------------------------------------------------------------------------- /dependencies/interfaces/i_client_state.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma pack(push, 1) 4 | 5 | class i_net_channel_info { 6 | public: 7 | 8 | enum { 9 | GENERIC = 0, // must be first and is default group 10 | LOCALPLAYER, // bytes for local player entity update 11 | OTHERPLAYERS, // bytes for other players update 12 | ENTITIES, // all other entity bytes 13 | SOUNDS, // game sounds 14 | EVENTS, // event messages 15 | USERMESSAGES, // user messages 16 | ENTMESSAGES, // entity messages 17 | VOICE, // voice data 18 | STRINGTABLE, // a stringtable update 19 | MOVE, // client move cmds 20 | STRINGCMD, // string command 21 | SIGNON, // various signondata 22 | TOTAL, // must be last and is not a real group 23 | }; 24 | 25 | virtual const char* get_name(void) const = 0; // get channel name 26 | virtual const char* get_address(void) const = 0; // get channel IP address as string 27 | virtual float get_time(void) const = 0; // current net time 28 | virtual float get_time_connected(void) const = 0; // get connection time in seconds 29 | virtual int get_buffer_size(void) const = 0; // netchannel packet history size 30 | virtual int get_data_rate(void) const = 0; // send data rate in byte/sec 31 | 32 | virtual bool is_loop_back(void) const = 0; // true if loopback channel 33 | virtual bool is_timing_out(void) const = 0; // true if timing out 34 | virtual bool is_play_back(void) const = 0; // true if demo playback 35 | 36 | virtual float get_latency(int flow) const = 0; // current latency (RTT), more accurate but jittering 37 | virtual float get_average_latency(int flow) const = 0; // average packet latency in seconds 38 | virtual float get_average_loss(int flow) const = 0; // avg packet loss[0..1] 39 | virtual float get_average_choke(int flow) const = 0; // avg packet choke[0..1] 40 | virtual float get_average_data(int flow) const = 0; // data flow in bytes/sec 41 | virtual float get_average_packets(int flow) const = 0; // avg packets/sec 42 | virtual int get_total_data(int flow) const = 0; // total flow in/out in bytes 43 | virtual int get_sequence_number(int flow) const = 0; // last send seq number 44 | virtual bool is_valid_packet(int flow, int frame_number) const = 0; // true if packet was not lost/dropped/chocked/flushed 45 | virtual float get_packet_time(int flow, int frame_number) const = 0; // time when packet was send 46 | virtual int get_packet_bytes(int flow, int frame_number, int group) const = 0; // group size of this packet 47 | virtual bool get_stream_progress(int flow, int* received, int* total) const = 0; // TCP progress if transmitting 48 | virtual float get_since_last_time_recieved(void) const = 0; // get time since last recieved packet in seconds 49 | virtual float get_command_interpolation_ammount(int flow, int frame_number) const = 0; 50 | virtual void get_packet_response_latency(int flow, int frame_number, int* pnLatencyMsecs, int* pnChoke) const = 0; 51 | virtual void get_remote_framerate(float* pflFrameTime, float* pflFrameTimeStdDeviation) const = 0; 52 | 53 | virtual float get_timeout_seconds() const = 0; 54 | }; 55 | 56 | 57 | class i_client_state { 58 | public: 59 | char pad_0000[156]; 60 | i_net_channel_info* net_channel; 61 | uint32_t challenge_count; 62 | double reconnect_time; 63 | int32_t retry_count; 64 | char pad_00A8[88]; 65 | int32_t signon_state_count; 66 | char pad_0104[8]; 67 | float next_cmd_time; 68 | int32_t server_count; 69 | uint32_t current_sequence; 70 | char pad_0118[8]; 71 | char pad_0120[0x4C]; 72 | int32_t delta_tick; 73 | bool is_paused; 74 | char pad_0171[3]; 75 | int32_t view_entity; 76 | int32_t player_slot; 77 | char pad_017C[4]; 78 | char level_name[260]; 79 | char level_name_short[40]; 80 | char pad_02AC[92]; 81 | int32_t max_clients; 82 | char pad_030C[4083]; 83 | uint32_t string_table_container; 84 | char pad_1303[14737]; 85 | float last_server_tick_time; 86 | bool is_in_simulation; 87 | char pad_4C99[3]; 88 | uint32_t old_tick_count; 89 | float tick_remainder; 90 | float frame_time; 91 | int32_t last_outgoing_command; 92 | int32_t choked_commands; 93 | int32_t last_command_ack; 94 | int32_t command_ack; 95 | int32_t sound_sequence; 96 | char pad_4CBC[80]; 97 | vec3_t view_angles; 98 | 99 | void full_update() { 100 | delta_tick = -1; 101 | } 102 | }; 103 | 104 | #pragma pack(pop) -------------------------------------------------------------------------------- /source-sdk/math/utl_vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | template class utl_memory 4 | { 5 | public: 6 | inline bool IsIdxValid(I i) const 7 | { 8 | long x = i; 9 | return (x >= 0) && (x < m_nAllocationCount); 10 | } 11 | T& operator[](I i); 12 | const T& operator[](I i) const; 13 | T* Base() 14 | { 15 | return m_pMemory; 16 | } 17 | inline int NumAllocated() const 18 | { 19 | return m_nAllocationCount; 20 | } 21 | void Grow(int num) 22 | { 23 | assert(num > 0); 24 | 25 | auto oldAllocationCount = m_nAllocationCount; 26 | // Make sure we have at least numallocated + num allocations. 27 | // Use the grow rules specified for this memory (in m_nGrowSize) 28 | int nAllocationRequested = m_nAllocationCount + num; 29 | 30 | int nNewAllocationCount = UtlMemory_CalcNewAllocationCount(m_nAllocationCount, m_nGrowSize, nAllocationRequested, sizeof(T)); 31 | 32 | // if m_nAllocationRequested wraps index type I, recalculate 33 | if ((int)(I)nNewAllocationCount < nAllocationRequested) 34 | { 35 | if ((int)(I)nNewAllocationCount == 0 && (int)(I)(nNewAllocationCount - 1) >= nAllocationRequested) 36 | { 37 | --nNewAllocationCount; // deal w/ the common case of m_nAllocationCount == MAX_USHORT + 1 38 | } 39 | else 40 | { 41 | if ((int)(I)nAllocationRequested != nAllocationRequested) 42 | { 43 | // we've been asked to grow memory to a size s.t. the index type can't address the requested amount of memory 44 | assert(0); 45 | return; 46 | } 47 | while ((int)(I)nNewAllocationCount < nAllocationRequested) 48 | { 49 | nNewAllocationCount = (nNewAllocationCount + nAllocationRequested) / 2; 50 | } 51 | } 52 | } 53 | 54 | m_nAllocationCount = nNewAllocationCount; 55 | 56 | if (m_pMemory) 57 | { 58 | auto ptr = new unsigned char[m_nAllocationCount * sizeof(T)]; 59 | 60 | memcpy(ptr, m_pMemory, oldAllocationCount * sizeof(T)); 61 | m_pMemory = (T*)ptr; 62 | } 63 | else 64 | { 65 | m_pMemory = (T*)new unsigned char[m_nAllocationCount * sizeof(T)]; 66 | } 67 | } 68 | protected: 69 | T* m_pMemory; 70 | int m_nAllocationCount; 71 | int m_nGrowSize; 72 | }; 73 | 74 | template< class T, class I > 75 | inline T& utl_memory::operator[](I i) 76 | { 77 | assert(IsIdxValid(i)); 78 | return m_pMemory[i]; 79 | } 80 | 81 | template< class T, class I > 82 | inline const T& utl_memory::operator[](I i) const 83 | { 84 | assert(IsIdxValid(i)); 85 | return m_pMemory[i]; 86 | } 87 | 88 | template< class T, class A = utl_memory > 89 | class utl_vector 90 | { 91 | typedef A CAllocator; 92 | 93 | typedef T* iterator; 94 | typedef const T* const_iterator; 95 | public: 96 | T& operator[](int i); 97 | const T& operator[](int i) const; 98 | 99 | T& Element(int i) 100 | { 101 | return m_Memory[i]; 102 | } 103 | 104 | T* Base() 105 | { 106 | return m_Memory.Base(); 107 | } 108 | 109 | int count() const 110 | { 111 | return m_Size; 112 | } 113 | 114 | void remove_all() 115 | { 116 | for (int i = m_Size; --i >= 0; ) 117 | Destruct(&Element(i)); 118 | 119 | m_Size = 0; 120 | } 121 | 122 | inline bool IsValidIndex(int i) const 123 | { 124 | return (i >= 0) && (i < m_Size); 125 | } 126 | 127 | void GrowVector(int num = 1) 128 | { 129 | if (m_Size + num > m_Memory.NumAllocated()) 130 | { 131 | m_Memory.Grow(m_Size + num - m_Memory.NumAllocated()); 132 | } 133 | 134 | m_Size += num; 135 | } 136 | 137 | int InsertBefore(int elem) 138 | { 139 | // Can insert at the end 140 | assert((elem == count()) || IsValidIndex(elem)); 141 | 142 | GrowVector(); 143 | Construct(&Element(elem)); 144 | return elem; 145 | } 146 | 147 | inline int AddToHead() 148 | { 149 | return InsertBefore(0); 150 | } 151 | 152 | inline int AddToTail() 153 | { 154 | return InsertBefore(m_Size); 155 | } 156 | 157 | iterator begin() { return Base(); } 158 | const_iterator begin() const { return Base(); } 159 | iterator end() { return Base() + count(); } 160 | const_iterator end() const { return Base() + count(); } 161 | 162 | protected: 163 | CAllocator m_Memory; 164 | int m_Size; 165 | T* m_pElements; 166 | }; 167 | 168 | template< typename T, class A > 169 | inline T& utl_vector::operator[](int i) 170 | { 171 | assert(i < m_Size); 172 | return m_Memory[i]; 173 | } 174 | 175 | template< typename T, class A > 176 | inline const T& utl_vector::operator[](int i) const 177 | { 178 | assert(i < m_Size); 179 | return m_Memory[i]; 180 | } -------------------------------------------------------------------------------- /core/hooks/hooks.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../dependencies/utilities/csgo.hpp" 3 | #include "../features/features.hpp" 4 | #include "../features/misc/engine_prediction.hpp" 5 | #include "../menu/menu.hpp" 6 | 7 | hooks::create_move::fn create_move_original = nullptr; 8 | hooks::paint_traverse::fn paint_traverse_original = nullptr; 9 | 10 | bool hooks::initialize() { 11 | auto create_move_target = reinterpret_cast(get_virtual(interfaces::clientmode, 24)); 12 | auto paint_traverse_target = reinterpret_cast(get_virtual(interfaces::panel, 41)); 13 | 14 | if (MH_Initialize() != MH_OK) { 15 | throw std::runtime_error("failed to initialize MH_Initialize."); 16 | return false; 17 | } 18 | 19 | if (MH_CreateHook(create_move_target, &create_move::hook, reinterpret_cast(&create_move_original)) != MH_OK) { 20 | throw std::runtime_error("failed to initialize create_move. (outdated index?)"); 21 | return false; 22 | } 23 | 24 | if (MH_CreateHook(paint_traverse_target, &paint_traverse::hook, reinterpret_cast(&paint_traverse_original)) != MH_OK) { 25 | throw std::runtime_error("failed to initialize paint_traverse. (outdated index?)"); 26 | return false; 27 | } 28 | 29 | if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) { 30 | throw std::runtime_error("failed to enable hooks."); 31 | return false; 32 | } 33 | 34 | console::log("[setup] hooks initialized!\n"); 35 | return true; 36 | } 37 | 38 | void hooks::release() { 39 | MH_Uninitialize(); 40 | 41 | MH_DisableHook(MH_ALL_HOOKS); 42 | } 43 | 44 | bool __fastcall hooks::create_move::hook(void* ecx, void* edx, int input_sample_frametime, c_usercmd* cmd) { 45 | create_move_original(input_sample_frametime, cmd); 46 | 47 | if (!cmd || !cmd->command_number) 48 | return create_move_original(input_sample_frametime, cmd); 49 | 50 | csgo::local_player = reinterpret_cast(interfaces::entity_list->get_client_entity(interfaces::engine->get_local_player())); 51 | 52 | uintptr_t* frame_pointer; 53 | __asm mov frame_pointer, ebp; 54 | bool& send_packet = *reinterpret_cast(*frame_pointer - 0x1C); 55 | 56 | auto old_viewangles = cmd->viewangles; 57 | auto old_forwardmove = cmd->forwardmove; 58 | auto old_sidemove = cmd->sidemove; 59 | if(csgo::local_player) 60 | if (variables::backtrack && interfaces::engine->is_in_game() && interfaces::engine->is_connected() && csgo::local_player->is_alive()) 61 | { 62 | if (cmd->command_number) 63 | { 64 | CBacktracking::RegisterTick(cmd); 65 | } 66 | CBacktracking::Begin(cmd); 67 | CBacktracking::End(); 68 | } 69 | misc::movement::bunny_hop(cmd); 70 | legitbot::AimBot(cmd); 71 | prediction::start(cmd); { 72 | 73 | 74 | 75 | } prediction::end(); 76 | 77 | math::correct_movement(old_viewangles, cmd, old_forwardmove, old_sidemove); 78 | 79 | cmd->forwardmove = std::clamp(cmd->forwardmove, -450.0f, 450.0f); 80 | cmd->sidemove = std::clamp(cmd->sidemove, -450.0f, 450.0f); 81 | cmd->upmove = std::clamp(cmd->sidemove, -320.0f, 320.0f); 82 | 83 | cmd->viewangles.normalize(); 84 | cmd->viewangles.x = std::clamp(cmd->viewangles.x, -89.0f, 89.0f); 85 | cmd->viewangles.y = std::clamp(cmd->viewangles.y, -180.0f, 180.0f); 86 | cmd->viewangles.z = 0.0f; 87 | return false; 88 | } 89 | 90 | void __stdcall hooks::paint_traverse::hook(unsigned int panel, bool force_repaint, bool allow_force) { 91 | auto panel_to_draw = fnv::hash(interfaces::panel->get_panel_name(panel)); 92 | 93 | switch (panel_to_draw) { 94 | case fnv::hash("MatSystemTopPanel"): 95 | 96 | if(variables::watermark) 97 | render::draw_text_string(10, 10, render::fonts::watermark_font, "ClemInternal", false, color::white(255)); 98 | 99 | visuals::boxesp(); 100 | visuals::nameesp(); 101 | visuals::healthesp(); 102 | visuals::armoresp(); 103 | visuals::glowesp(); 104 | visuals::boneesp(); 105 | visuals::snaplineesp(); 106 | visuals::drawc4(); 107 | visuals::drawfov(); 108 | if(csgo::local_player) 109 | if(variables::backtrack && variables::drawbacktrack && interfaces::engine->is_in_game() && interfaces::engine->is_connected() && csgo::local_player->is_alive()) 110 | CBacktracking::Draw(); 111 | menu::toggle(); 112 | menu::render(); 113 | 114 | break; 115 | 116 | case fnv::hash("FocusOverlayPanel"): 117 | interfaces::panel->set_keyboard_input_enabled(panel, variables::menu::opened); 118 | interfaces::panel->set_mouse_input_enabled(panel, variables::menu::opened); 119 | break; 120 | } 121 | 122 | paint_traverse_original(interfaces::panel, panel, force_repaint, allow_force); 123 | } -------------------------------------------------------------------------------- /dependencies/interfaces/i_player_movement.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/math/vector3d.hpp" 3 | #include "../../source-sdk/classes/c_usercmd.hpp" 4 | 5 | class player_move_helper { 6 | public: 7 | 8 | bool bFirstRunOfFunctions : 1; 9 | bool bGameCodeMovedPlayer : 1; 10 | int nPlayerHandle; // edict index on server, client entity handle on client= 11 | int nImpulseCommand; // Impulse command issued. 12 | vec3_t vecViewAngles; // Command view angles (local space) 13 | vec3_t vecAbsViewAngles; // Command view angles (world space) 14 | int nButtons; // Attack buttons. 15 | int nOldButtons; // From host_client->oldbuttons; 16 | float flForwardMove; 17 | float flSideMove; 18 | float flUpMove; 19 | float flMaxSpeed; 20 | float flClientMaxSpeed; 21 | vec3_t vecVelocity; // edict::velocity // Current movement direction. 22 | vec3_t vecAngles; // edict::angles 23 | vec3_t vecOldAngles; 24 | float outStepHeight; // how much you climbed this move 25 | vec3_t outWishVel; // This is where you tried 26 | vec3_t outJumpVel; // This is your jump velocity 27 | vec3_t vecConstraintCenter; 28 | float flConstraintRadius; 29 | float flConstraintWidth; 30 | float flConstraintSpeedFactor; 31 | float flUnknown[5]; 32 | vec3_t vecAbsOrigin; 33 | 34 | virtual void _vpad() = 0; 35 | virtual void set_host(player_t* host) = 0; 36 | }; 37 | 38 | class player_move_data { 39 | public: 40 | bool bFirstRunOfFunctions : 1; 41 | bool bGameCodeMovedPlayer : 1; 42 | int nPlayerHandle; // edict index on server, client entity handle on client= 43 | int nImpulseCommand; // Impulse command issued. 44 | vec3_t vecViewAngles; // Command view angles (local space) 45 | vec3_t vecAbsViewAngles; // Command view angles (world space) 46 | int nButtons; // Attack buttons. 47 | int nOldButtons; // From host_client->oldbuttons; 48 | float flForwardMove; 49 | float flSideMove; 50 | float flUpMove; 51 | float flMaxSpeed; 52 | float flClientMaxSpeed; 53 | vec3_t vecVelocity; // edict::velocity // Current movement direction. 54 | vec3_t vecAngles; // edict::angles 55 | vec3_t vecOldAngles; 56 | float outStepHeight; // how much you climbed this move 57 | vec3_t outWishVel; // This is where you tried 58 | vec3_t outJumpVel; // This is your jump velocity 59 | vec3_t vecConstraintCenter; 60 | float flConstraintRadius; 61 | float flConstraintWidth; 62 | float flConstraintSpeedFactor; 63 | float flUnknown[5]; 64 | vec3_t vecAbsOrigin; 65 | }; 66 | 67 | class virtual_game_movement { 68 | public: 69 | virtual ~virtual_game_movement(void) { } 70 | 71 | virtual void process_movement(player_t* pPlayer, player_move_data* pMove) = 0; 72 | virtual void Reset(void) = 0; 73 | virtual void start_track_prediction_errors(player_t* pPlayer) = 0; 74 | virtual void finish_track_prediction_errors(player_t* pPlayer) = 0; 75 | virtual void DiffPrint(char const* fmt, ...) = 0; 76 | virtual vec3_t const& GetPlayerMins(bool ducked) const = 0; 77 | virtual vec3_t const& GetPlayerMaxs(bool ducked) const = 0; 78 | virtual vec3_t const& GetPlayerViewOffset(bool ducked) const = 0; 79 | virtual bool IsMovingPlayerStuck(void) const = 0; 80 | virtual player_t* GetMovingPlayer(void) const = 0; 81 | virtual void UnblockPusher(player_t* pPlayer, player_t* pPusher) = 0; 82 | virtual void SetupMovementBounds(player_move_data* pMove) = 0; 83 | }; 84 | 85 | class player_game_movement 86 | : public virtual_game_movement { 87 | public: 88 | virtual ~player_game_movement(void) { } 89 | }; 90 | 91 | class player_prediction { 92 | public: 93 | bool in_prediction() { 94 | typedef bool(__thiscall * oInPrediction)(void*); 95 | return utilities::call_virtual(this, 14)(this); 96 | } 97 | 98 | void run_command(player_t* player, c_usercmd* ucmd, player_move_helper* moveHelper) { 99 | typedef void(__thiscall * oRunCommand)(void*, player_t*, c_usercmd*, player_move_helper*); 100 | return utilities::call_virtual(this, 19)(this, player, ucmd, moveHelper); 101 | } 102 | 103 | void setup_move(player_t* player, c_usercmd* ucmd, player_move_helper* moveHelper, void* pMoveData) { 104 | typedef void(__thiscall * oSetupMove)(void*, player_t*, c_usercmd*, player_move_helper*, void*); 105 | return utilities::call_virtual(this, 20)(this, player, ucmd, moveHelper, pMoveData); 106 | } 107 | 108 | void finish_move(player_t* player, c_usercmd* ucmd, void* pMoveData) { 109 | typedef void(__thiscall * oFinishMove)(void*, player_t*, c_usercmd*, void*); 110 | return utilities::call_virtual(this, 21)(this, player, ucmd, pMoveData); 111 | } 112 | }; -------------------------------------------------------------------------------- /core/menu/menu.cpp: -------------------------------------------------------------------------------- 1 | #include "menu.hpp" 2 | 3 | //todo auto elements positioning 4 | 5 | auto do_frame = [&](std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, color bg, color header_text, color header_line, const std::string& name) { 6 | render::draw_filled_rect(x, y, w, h, bg); 7 | render::draw_filled_rect(x, y, w, 30, header_text); 8 | render::draw_filled_rect(x, y + 30, w, 2, header_line); 9 | render::draw_text_string(x + 10, y + 8, render::fonts::watermark_font, name, false, color::white()); 10 | }; 11 | 12 | void menu::render() { 13 | if (!variables::menu::opened) 14 | return; 15 | 16 | do_frame(variables::menu::x, variables::menu::y, variables::menu::w, variables::menu::h, color(255, 128, 0, 255), color(255, 153, 51, 255), color(255, 128, 0, 255), "ClemInternal"); 17 | 18 | menu_framework::group_box(variables::menu::x + 5, variables::menu::y + 35, variables::menu::w - 10, 80, render::fonts::watermark_font, "tabs", false); { 19 | menu_framework::tab(variables::menu::x + variables::menu::w / 3 - 35, variables::menu::y + 55, 100, 30, render::fonts::watermark_font, "legitbot", menu::current_tab, 0, false); 20 | menu_framework::tab(variables::menu::x + variables::menu::w / 2 - 35, variables::menu::y + 55, 100, 30, render::fonts::watermark_font, "visuals", menu::current_tab, 1, false); 21 | menu_framework::tab(variables::menu::x + variables::menu::w - variables::menu::w / 3 - 35, variables::menu::y + 55, 100, 30, render::fonts::watermark_font, "misc", menu::current_tab, 2, false); 22 | } 23 | 24 | switch (current_tab) { 25 | case 0: 26 | menu_framework::group_box(variables::menu::x + 5, variables::menu::y + 125, variables::menu::w - 10, 320, render::fonts::watermark_font, "legitbot", false); { 27 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 135, variables::menu::x + 575, render::fonts::watermark_font, "AimBot", variables::aimbot); 28 | menu_framework::slider(variables::menu::x + 10, variables::menu::y + 150, 125, render::fonts::watermark_font, "AimBot Fov", variables::aimbot_fov, 0.f, 10.f); 29 | menu_framework::slider(variables::menu::x + 10, variables::menu::y + 165, 125, render::fonts::watermark_font, "AimBot Smoothing", variables::aimbot_smoothing, 1.f, 5.f); 30 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 180, variables::menu::x + 575, render::fonts::watermark_font, "Only enemy is visible", variables::aimbot_isvisiblecheck); 31 | } 32 | break; 33 | case 1: 34 | menu_framework::group_box(variables::menu::x + 5, variables::menu::y + 125, variables::menu::w - 10, 320, render::fonts::watermark_font, "visuals", false); { 35 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 135, variables::menu::x + 575, render::fonts::watermark_font, "Team ESP", variables::showteamesp); 36 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 150, variables::menu::x + 575, render::fonts::watermark_font, "Box ESP", variables::boxesp); 37 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 165, variables::menu::x + 575, render::fonts::watermark_font, "Name ESP", variables::nameesp); 38 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 180, variables::menu::x + 575, render::fonts::watermark_font, "Health ESP", variables::healthesp); 39 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 195, variables::menu::x + 575, render::fonts::watermark_font, "Armor ESP", variables::armoresp); 40 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 210, variables::menu::x + 575, render::fonts::watermark_font, "Glow ESP", variables::glowesp); 41 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 225, variables::menu::x + 575, render::fonts::watermark_font, "Bone ESP", variables::boneesp); 42 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 240, variables::menu::x + 575, render::fonts::watermark_font, "Snapline ESP", variables::snaplineesp); 43 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 255, variables::menu::x + 575, render::fonts::watermark_font, "C4 Timer and ESP", variables::drawc4); 44 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 270, variables::menu::x + 575, render::fonts::watermark_font, "Draw Backtrack", variables::drawbacktrack); 45 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 285, variables::menu::x + 575, render::fonts::watermark_font, "Draw Aimbot FOV", variables::drawfov); 46 | } 47 | break; 48 | case 2: 49 | menu_framework::group_box(variables::menu::x + 5, variables::menu::y + 125, variables::menu::w - 10, 320, render::fonts::watermark_font, "misc", false); { 50 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 135, variables::menu::x + 575, render::fonts::watermark_font, "WaterMark", variables::watermark); 51 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 150, variables::menu::x + 575, render::fonts::watermark_font, "BunnyHop", variables::bhop); 52 | menu_framework::check_box(variables::menu::x + 10, variables::menu::y + 165, variables::menu::x + 575, render::fonts::watermark_font, "Backtracking", variables::backtrack); 53 | } 54 | break; 55 | } 56 | 57 | menu_framework::menu_movement(variables::menu::x, variables::menu::y, variables::menu::w, 30); 58 | } 59 | 60 | void menu::toggle() { 61 | if (GetAsyncKeyState(VK_INSERT) & 1) 62 | variables::menu::opened = !variables::menu::opened; 63 | } -------------------------------------------------------------------------------- /source-sdk/math/vector3d.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | inline float bits_to_float(std::uint32_t i) { 6 | union convertor_t { float f; unsigned long ul; 7 | } tmp; 8 | 9 | tmp.ul = i; 10 | return tmp.f; 11 | } 12 | 13 | constexpr double M_PI = 3.14159265358979323846; 14 | constexpr float M_RADPI = 57.295779513082f; 15 | constexpr float M_PI_F = static_cast(M_PI); 16 | 17 | constexpr float RAD2DEG(const float x) { 18 | return (float)(x) * (float)(180.f / M_PI_F); 19 | } 20 | constexpr float DEG2RAD(const float x) { 21 | return (float)(x) * (float)(M_PI_F / 180.f); 22 | } 23 | 24 | constexpr std::uint32_t FLOAT32_NAN_BITS = 0x7FC00000; 25 | const float FLOAT32_NAN = bits_to_float(FLOAT32_NAN_BITS); 26 | #define VEC_T_NAN FLOAT32_NAN 27 | #define ASSERT( _exp ) ( (void ) 0 ) 28 | 29 | 30 | class vec3_t { 31 | public: 32 | vec3_t(); 33 | vec3_t(float, float, float); 34 | ~vec3_t(); 35 | 36 | float x, y, z; 37 | 38 | vec3_t& operator+=(const vec3_t& v) { 39 | x += v.x; y += v.y; z += v.z; return *this; 40 | } 41 | vec3_t& operator-=(const vec3_t& v) { 42 | x -= v.x; y -= v.y; z -= v.z; return *this; 43 | } 44 | vec3_t& operator*=(float v) { 45 | x *= v; y *= v; z *= v; return *this; 46 | } 47 | vec3_t operator+(const vec3_t& v) { 48 | return vec3_t{ x + v.x, y + v.y, z + v.z }; 49 | } 50 | vec3_t operator-(const vec3_t& v) { 51 | return vec3_t{ x - v.x, y - v.y, z - v.z }; 52 | } 53 | vec3_t operator*(float fl) const { 54 | return vec3_t(x * fl, y * fl, z * fl); 55 | } 56 | vec3_t operator*(const vec3_t& v) const { 57 | return vec3_t(x * v.x, y * v.y, z * v.z); 58 | } 59 | vec3_t& operator/=(float fl) { 60 | x /= fl; 61 | y /= fl; 62 | z /= fl; 63 | return *this; 64 | } 65 | auto operator-(const vec3_t& other) const -> vec3_t { 66 | auto buf = *this; 67 | 68 | buf.x -= other.x; 69 | buf.y -= other.y; 70 | buf.z -= other.z; 71 | 72 | return buf; 73 | } 74 | 75 | auto operator/(float other) const { 76 | vec3_t vec; 77 | vec.x = x / other; 78 | vec.y = y / other; 79 | vec.z = z / other; 80 | return vec; 81 | } 82 | 83 | float& operator[](int i) { 84 | return ((float*)this)[i]; 85 | } 86 | float operator[](int i) const { 87 | return ((float*)this)[i]; 88 | } 89 | 90 | inline float Length2D() const { 91 | return sqrt((x * x) + (y * y)); 92 | } 93 | void crossproduct(vec3_t v1, vec3_t v2, vec3_t cross_p) const { 94 | cross_p.x = (v1.y * v2.z) - (v1.z * v2.y); //i 95 | cross_p.y = -((v1.x * v2.z) - (v1.z * v2.x)); //j 96 | cross_p.z = (v1.x * v2.y) - (v1.y * v2.x); //k 97 | } 98 | 99 | vec3_t cross(const vec3_t & vOther) const { 100 | vec3_t res; 101 | crossproduct(*this, vOther, res); 102 | return res; 103 | } 104 | 105 | void init(float ix, float iy, float iz); 106 | void clamp(); 107 | vec3_t clamped(); 108 | vec3_t normalized(); 109 | float distance_to(const vec3_t & other); 110 | void normalize(); 111 | float length(); 112 | float length_sqr(); 113 | float length_2d_sqr(void) const; 114 | float dot(const vec3_t other); 115 | float dot(const float* other); 116 | }; 117 | 118 | inline vec3_t operator*(float lhs, const vec3_t & rhs) { 119 | return vec3_t(rhs.x * lhs, rhs.x * lhs, rhs.x * lhs); 120 | } 121 | 122 | struct matrix_t { 123 | matrix_t() { } 124 | matrix_t( 125 | float m00, float m01, float m02, float m03, 126 | float m10, float m11, float m12, float m13, 127 | float m20, float m21, float m22, float m23) 128 | { 129 | mat_val[0][0] = m00; mat_val[0][1] = m01; mat_val[0][2] = m02; mat_val[0][3] = m03; 130 | mat_val[1][0] = m10; mat_val[1][1] = m11; mat_val[1][2] = m12; mat_val[1][3] = m13; 131 | mat_val[2][0] = m20; mat_val[2][1] = m21; mat_val[2][2] = m22; mat_val[2][3] = m23; 132 | } 133 | 134 | //----------------------------------------------------------------------------- 135 | // Creates a matrix where the X axis = forward 136 | // the Y axis = left, and the Z axis = up 137 | //----------------------------------------------------------------------------- 138 | void init(const vec3_t& xAxis, const vec3_t& yAxis, const vec3_t& zAxis, const vec3_t& vecOrigin) { 139 | mat_val[0][0] = xAxis.x; mat_val[0][1] = yAxis.x; mat_val[0][2] = zAxis.x; mat_val[0][3] = vecOrigin.x; 140 | mat_val[1][0] = xAxis.y; mat_val[1][1] = yAxis.y; mat_val[1][2] = zAxis.y; mat_val[1][3] = vecOrigin.y; 141 | mat_val[2][0] = xAxis.z; mat_val[2][1] = yAxis.z; mat_val[2][2] = zAxis.z; mat_val[2][3] = vecOrigin.z; 142 | } 143 | 144 | //----------------------------------------------------------------------------- 145 | // Creates a matrix where the X axis = forward 146 | // the Y axis = left, and the Z axis = up 147 | //----------------------------------------------------------------------------- 148 | matrix_t(const vec3_t& xAxis, const vec3_t& yAxis, const vec3_t& zAxis, const vec3_t& vecOrigin) { 149 | init(xAxis, yAxis, zAxis, vecOrigin); 150 | } 151 | 152 | inline void set_origin(vec3_t const& p) { 153 | mat_val[0][3] = p.x; 154 | mat_val[1][3] = p.y; 155 | mat_val[2][3] = p.z; 156 | } 157 | 158 | inline void invalidate(void) { 159 | for (int i = 0; i < 3; i++) { 160 | for (int j = 0; j < 4; j++) { 161 | mat_val[i][j] = VEC_T_NAN; 162 | } 163 | } 164 | } 165 | 166 | float* operator[](int i) { ASSERT((i >= 0) && (i < 3)); return mat_val[i]; } 167 | const float* operator[](int i) const { ASSERT((i >= 0) && (i < 3)); return mat_val[i]; } 168 | float* base() { return &mat_val[0][0]; } 169 | const float* base() const { return &mat_val[0][0]; } 170 | 171 | float mat_val[3][4]; 172 | }; -------------------------------------------------------------------------------- /source-sdk/math/view_matrix.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "vector3d.hpp" 3 | 4 | typedef float vec_t; 5 | 6 | class view_matrix_t { 7 | public: 8 | 9 | view_matrix_t(); 10 | view_matrix_t( 11 | vec_t m00, vec_t m01, vec_t m02, vec_t m03, 12 | vec_t m10, vec_t m11, vec_t m12, vec_t m13, 13 | vec_t m20, vec_t m21, vec_t m22, vec_t m23, 14 | vec_t m30, vec_t m31, vec_t m32, vec_t m33 15 | ); 16 | 17 | // Creates a matrix where the X axis = forward 18 | // the Y axis = left, and the Z axis = up 19 | view_matrix_t(const vec3_t& forward, const vec3_t& left, const vec3_t& up); 20 | 21 | // Construct from a 3x4 matrix 22 | view_matrix_t(const matrix_t& matrix3x4); 23 | 24 | // Set the values in the matrix. 25 | void init( 26 | vec_t m00, vec_t m01, vec_t m02, vec_t m03, 27 | vec_t m10, vec_t m11, vec_t m12, vec_t m13, 28 | vec_t m20, vec_t m21, vec_t m22, vec_t m23, 29 | vec_t m30, vec_t m31, vec_t m32, vec_t m33 30 | ); 31 | 32 | // Initialize from a 3x4 33 | void init(const matrix_t& matrix3x4); 34 | 35 | // array access 36 | inline float* operator[](int i) { 37 | return m[i]; 38 | } 39 | 40 | inline const float* operator[](int i) const { 41 | return m[i]; 42 | } 43 | 44 | // Get a pointer to m[0][0] 45 | inline float* base() { 46 | return &m[0][0]; 47 | } 48 | 49 | inline const float* base() const { 50 | return &m[0][0]; 51 | } 52 | 53 | void set_left(const vec3_t& vLeft); 54 | void set_up(const vec3_t& vUp); 55 | void set_forward(const vec3_t& vForward); 56 | 57 | void get_basis_vector_3d(vec3_t& vForward, vec3_t& vLeft, vec3_t& vUp) const; 58 | void set_basis_vector_3d(const vec3_t& vForward, const vec3_t& vLeft, const vec3_t& vUp); 59 | 60 | // Get/set the translation. 61 | vec3_t& get_translation(vec3_t& vTrans) const; 62 | void set_translation(const vec3_t& vTrans); 63 | 64 | void pre_translate(const vec3_t& vTrans); 65 | void post_translate(const vec3_t& vTrans); 66 | 67 | matrix_t& as_matrix(); 68 | const matrix_t& as_matrix() const; 69 | void copy_from_matrix(const matrix_t& m3x4); 70 | void set_matrix(matrix_t& matrix3x4) const; 71 | 72 | bool operator==(const view_matrix_t& src) const; 73 | bool operator!=(const view_matrix_t& src) const { return !(*this == src); } 74 | 75 | // Access the basis vec3_ts. 76 | vec3_t get_left() const; 77 | vec3_t get_up() const; 78 | vec3_t get_forward() const; 79 | vec3_t get_translation() const; 80 | 81 | // Matrix->vec3_t operations. 82 | public: 83 | // Multiply by a 3D vec3_t (same as operator*). 84 | void vector_3d_multiply(const vec3_t & vIn, vec3_t & vOut) const; 85 | 86 | // Multiply by a 4D vec3_t. 87 | //void V4Mul( const vec3_t4D &vIn, vec3_t4D &vOut ) const; 88 | 89 | // Applies the rotation (ignores translation in the matrix). (This just calls VMul3x3). 90 | vec3_t apply_rotation(const vec3_t & vVec) const; 91 | 92 | // Multiply by a vec3_t (divides by w, assumes input w is 1). 93 | vec3_t operator*(const vec3_t & vVec) const; 94 | 95 | // Multiply by the upper 3x3 part of the matrix (ie: only apply rotation). 96 | vec3_t vector_3d_multiply(const vec3_t & vVec) const; 97 | 98 | // Apply the inverse (transposed) rotation (only works on pure rotation matrix) 99 | vec3_t vector_3d_transpose_rotation(const vec3_t & vVec) const; 100 | 101 | // Multiply by the upper 3 rows. 102 | vec3_t vector_3d_multiply_upper(const vec3_t & vVec) const; 103 | 104 | // Apply the inverse (transposed) transformation (only works on pure rotation/translation) 105 | vec3_t vector_3d_transpose(const vec3_t & vVec) const; 106 | 107 | // Matrix->plane operations. 108 | //public: 109 | // Transform the plane. The matrix can only contain translation and rotation. 110 | //void TransformPlane( const VPlane &inPlane, VPlane &outPlane ) const; 111 | 112 | // Just calls TransformPlane and returns the result. 113 | //VPlane operator*(const VPlane &thePlane) const; 114 | 115 | // Matrix->matrix operations. 116 | public: 117 | 118 | view_matrix_t& operator=(const view_matrix_t & mOther); 119 | 120 | // Multiply two matrices (out = this * vm). 121 | void MatrixMul(const view_matrix_t & vm, view_matrix_t & out) const; 122 | 123 | // Add two matrices. 124 | const view_matrix_t& operator+=(const view_matrix_t & other); 125 | 126 | // Just calls MatrixMul and returns the result. 127 | view_matrix_t operator*(const view_matrix_t & mOther) const; 128 | 129 | // Add/Subtract two matrices. 130 | view_matrix_t operator+(const view_matrix_t & other) const; 131 | view_matrix_t operator-(const view_matrix_t & other) const; 132 | 133 | // Negation. 134 | view_matrix_t operator-() const; 135 | 136 | // Matrix operations. 137 | public: 138 | // Set to identity. 139 | void identity(); 140 | 141 | bool is_identity() const; 142 | 143 | // Setup a matrix for origin and angles. 144 | void setup_maitrx_orginal_angles(const vec3_t & origin, const vec3_t & vAngles); 145 | 146 | // Does a fast inverse, assuming the matrix only contains translation and rotation. 147 | void inverse_tr(view_matrix_t & mRet) const; 148 | 149 | // Usually used for debug checks. Returns true if the upper 3x3 contains 150 | // unit vec3_ts and they are all orthogonal. 151 | bool is_rotation_matrix() const; 152 | 153 | // This calls the other InverseTR and returns the result. 154 | view_matrix_t inverse_tr() const; 155 | 156 | // Get the scale of the matrix's basis vec3_ts. 157 | vec3_t get_scale() const; 158 | 159 | // (Fast) multiply by a scaling matrix setup from vScale. 160 | view_matrix_t scale(const vec3_t & vScale); 161 | 162 | // Normalize the basis vec3_ts. 163 | view_matrix_t normalize_basis_vector_3d() const; 164 | 165 | // Transpose. 166 | view_matrix_t transpose() const; 167 | 168 | // Transpose upper-left 3x3. 169 | view_matrix_t transpose_3x3() const; 170 | 171 | public: 172 | // The matrix. 173 | vec_t m[4][4]; 174 | }; -------------------------------------------------------------------------------- /source-sdk/structs/materials.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imageformats.h" 3 | 4 | enum material_var_flags_t { 5 | material_var_debug = (1 << 0), 6 | material_var_no_debug_override = (1 << 1), 7 | material_var_no_draw = (1 << 2), 8 | material_var_use_in_fillrate_mode = (1 << 3), 9 | material_var_vertexcolor = (1 << 4), 10 | material_var_vertexalpha = (1 << 5), 11 | material_var_selfillum = (1 << 6), 12 | material_var_additive = (1 << 7), 13 | material_var_alphatest = (1 << 8), 14 | //material_var_unused = (1 << 9), 15 | material_var_znearer = (1 << 10), 16 | material_var_model = (1 << 11), 17 | material_var_flat = (1 << 12), 18 | material_var_nocull = (1 << 13), 19 | material_var_nofog = (1 << 14), 20 | material_var_ignorez = (1 << 15), 21 | material_var_decal = (1 << 16), 22 | material_var_envmapsphere = (1 << 17), // obsolete 23 | material_var_unused = (1 << 18), // unused 24 | material_var_envmapcameraspace = (1 << 19), // obsolete 25 | material_var_basealphaenvmapmask = (1 << 20), 26 | material_var_translucent = (1 << 21), 27 | material_var_normalmapalphaenvmapmask = (1 << 22), 28 | material_var_needs_software_skinning = (1 << 23), // obsolete 29 | material_var_opaquetexture = (1 << 24), 30 | material_var_envmapmode = (1 << 25), // obsolete 31 | material_var_suppress_decals = (1 << 26), 32 | material_var_halflambert = (1 << 27), 33 | material_var_wireframe = (1 << 28), 34 | material_var_allowalphatocoverage = (1 << 29), 35 | material_var_alpha_modified_by_proxy = (1 << 30), 36 | material_var_vertexfog = (1 << 31), 37 | }; 38 | 39 | enum preview_image_retval_t { 40 | material_preview_image_bad = 0, 41 | material_preview_image_ok, 42 | material_no_preview_image, 43 | }; 44 | 45 | typedef int ImageFormat; 46 | class IMaterialVar; 47 | typedef int VertexFormat_t; 48 | typedef int MaterialPropertyTypes_t; 49 | class i_material_var; 50 | struct model_t; 51 | class i_material; 52 | class c_studio_hdr; 53 | class c_key_values; 54 | class i_material_var; 55 | struct studiohwdata_t; 56 | struct color_mesh_info_t; 57 | struct draw_model_info_t; 58 | class i_client_renderable; 59 | class data_cache_handle_t; 60 | class i_mat_render_context; 61 | struct material_lighting_state_t; 62 | typedef int vertex_format_t; 63 | typedef void* light_cache_handle_t; 64 | typedef void* studio_decal_handle_t; 65 | typedef int material_property_types_t; 66 | typedef unsigned short model_instance_handle_t; 67 | using material_handle_t = unsigned short; 68 | 69 | 70 | class i_material { 71 | public: 72 | virtual const char* get_name() const = 0; 73 | virtual const char* GetTextureGroupName() const = 0; 74 | virtual preview_image_retval_t get_preview_image_properties(int* width, int* height, image_format* imageFormat, bool* isTranslucent) const = 0; 75 | virtual preview_image_retval_t get_preview_image(unsigned char* data, int width, int height, image_format imageFormat) const = 0; 76 | virtual int get_mapping_width() = 0; 77 | virtual int get_mapping_height() = 0; 78 | virtual int get_num_animation_frames() = 0; 79 | virtual bool in_material_page(void) = 0; 80 | virtual void get_material_offset(float* pOffset) = 0; 81 | virtual void get_material_scale(float* pScale) = 0; 82 | virtual i_material* get_material_page(void) = 0; 83 | virtual i_material_var* find_var(const char* varName, bool* found, bool complain = true) = 0; 84 | virtual void increment_reference_count(void) = 0; 85 | virtual void decrement_reference_count(void) = 0; 86 | inline void add_ref() { increment_reference_count(); } 87 | inline void release() { decrement_reference_count(); } 88 | virtual int get_enumeration_id(void) const = 0; 89 | virtual void get_low_res_color_sample(float s, float t, float* color) const = 0; 90 | virtual void recompute_state_snapshots() = 0; 91 | virtual bool is_translucent() = 0; 92 | virtual bool is_alpha_tested() = 0; 93 | virtual bool is_vertex_lit() = 0; 94 | virtual vertex_format_t get_vertex_format() const = 0; 95 | virtual bool has_proxy(void) const = 0; 96 | virtual bool uses_env_cubemap(void) = 0; 97 | virtual bool needs_tangent_space(void) = 0; 98 | virtual bool needs_power_of_two_frame_buffer_texture(bool bCheckSpecificToThisFrame = true) = 0; 99 | virtual bool needs_full_frame_buffer_texture(bool bCheckSpecificToThisFrame = true) = 0; 100 | virtual bool needs_software_skinning(void) = 0; 101 | virtual void alpha_modulate(float alpha) = 0; 102 | virtual void color_modulate(float r, float g, float b) = 0; 103 | virtual void set_material_var_flag(material_var_flags_t flag, bool on) = 0; 104 | virtual bool get_material_var_flag(material_var_flags_t flag) const = 0; 105 | virtual void get_reflectivity(vec3_t& reflect) = 0; 106 | virtual bool get_property_flag(material_property_types_t type) = 0; 107 | virtual bool is_two_sided() = 0; 108 | virtual void set_shader(const char* pShaderName) = 0; 109 | virtual int get_num_passes(void) = 0; 110 | virtual int get_texture_memory_bytes(void) = 0; 111 | virtual void refresh() = 0; 112 | virtual bool needs_lightmap_blend_alpha(void) = 0; 113 | virtual bool needs_software_lighting(void) = 0; 114 | virtual int shader_param_count() const = 0; 115 | virtual i_material_var** get_shader_params(void) = 0; 116 | virtual bool is_error_material() const = 0; 117 | virtual void unused() = 0; 118 | virtual float get_alpha_modulation() = 0; 119 | virtual void get_color_modulation(float* r, float* g, float* b) = 0; 120 | virtual bool is_translucent_under_modulation(float fAlphaModulation = 1.0f) const = 0; 121 | virtual i_material_var* find_var_fast(char const* pVarName, unsigned int* pToken) = 0; 122 | virtual void set_shader_and_params(c_key_values* pKeyValues) = 0; 123 | virtual const char* get_shader_name() const = 0; 124 | virtual void delete_if_unreferenced() = 0; 125 | virtual bool is_sprite_card() = 0; 126 | virtual void call_bind_proxy(void* proxyData) = 0; 127 | virtual void refresh_preserving_material_vars() = 0; 128 | virtual bool was_reloaded_from_whitelist() = 0; 129 | virtual bool set_temp_excluded(bool bSet, int nExcludedDimensionLimit) = 0; 130 | virtual int get_reference_count() const = 0; 131 | }; -------------------------------------------------------------------------------- /dependencies/math/math.cpp: -------------------------------------------------------------------------------- 1 | #include "../utilities/csgo.hpp" 2 | 3 | //aimtux 4 | void math::correct_movement(vec3_t old_angles, c_usercmd* cmd, float old_forwardmove, float old_sidemove) { 5 | float delta_view; 6 | float f1; 7 | float f2; 8 | 9 | if (old_angles.y < 0.f) 10 | f1 = 360.0f + old_angles.y; 11 | else 12 | f1 = old_angles.y; 13 | 14 | if (cmd->viewangles.y < 0.0f) 15 | f2 = 360.0f + cmd->viewangles.y; 16 | else 17 | f2 = cmd->viewangles.y; 18 | 19 | if (f2 < f1) 20 | delta_view = abs(f2 - f1); 21 | else 22 | delta_view = 360.0f - abs(f1 - f2); 23 | 24 | delta_view = 360.0f - delta_view; 25 | 26 | cmd->forwardmove = cos(DEG2RAD(delta_view)) * old_forwardmove + cos(DEG2RAD(delta_view + 90.f)) * old_sidemove; 27 | cmd->sidemove = sin(DEG2RAD(delta_view)) * old_forwardmove + sin(DEG2RAD(delta_view + 90.f)) * old_sidemove; 28 | } 29 | 30 | vec3_t math::calculate_angle(vec3_t& a, vec3_t& b) { 31 | vec3_t angles; 32 | vec3_t delta; 33 | delta.x = (a.x - b.x); 34 | delta.y = (a.y - b.y); 35 | delta.z = (a.z - b.z); 36 | 37 | double hyp = sqrt(delta.x * delta.x + delta.y * delta.y); 38 | angles.x = (float)(atanf(delta.z / hyp) * 57.295779513082f); 39 | angles.y = (float)(atanf(delta.y / delta.x) * 57.295779513082f); 40 | 41 | angles.z = 0.0f; 42 | if (delta.x >= 0.0) { angles.y += 180.0f; } 43 | return angles; 44 | } 45 | 46 | void math::sin_cos(float r, float* s, float* c) { 47 | *s = sin(r); 48 | *c = cos(r); 49 | } 50 | 51 | vec3_t math::angle_vector(vec3_t angle) { 52 | auto sy = sin(angle.y / 180.f * static_cast(M_PI)); 53 | auto cy = cos(angle.y / 180.f * static_cast(M_PI)); 54 | 55 | auto sp = sin(angle.x / 180.f * static_cast(M_PI)); 56 | auto cp = cos(angle.x / 180.f * static_cast(M_PI)); 57 | 58 | return vec3_t(cp * cy, cp * sy, -sp); 59 | } 60 | 61 | void math::transform_vector(vec3_t & a, matrix_t & b, vec3_t & out) { 62 | out.x = a.dot(b.mat_val[0]) + b.mat_val[0][3]; 63 | out.y = a.dot(b.mat_val[1]) + b.mat_val[1][3]; 64 | out.z = a.dot(b.mat_val[2]) + b.mat_val[2][3]; 65 | } 66 | 67 | void math::vector_angles(vec3_t & forward, vec3_t & angles) { 68 | if (forward.y == 0.0f && forward.x == 0.0f) { 69 | angles.x = (forward.z > 0.0f) ? 270.0f : 90.0f; 70 | angles.y = 0.0f; 71 | } 72 | else { 73 | angles.x = atan2(-forward.z, vec2_t(forward).length()) * -180 / static_cast(M_PI); 74 | angles.y = atan2(forward.y, forward.x) * 180 / static_cast(M_PI); 75 | 76 | if (angles.y > 90) 77 | angles.y -= 180; 78 | else if (angles.y < 90) 79 | angles.y += 180; 80 | else if (angles.y == 90) 81 | angles.y = 0; 82 | } 83 | 84 | angles.z = 0.0f; 85 | } 86 | 87 | void math::angle_vectors(vec3_t & angles, vec3_t * forward, vec3_t * right, vec3_t * up) { 88 | float sp, sy, sr, cp, cy, cr; 89 | 90 | sin_cos(DEG2RAD(angles.x), &sp, &cp); 91 | sin_cos(DEG2RAD(angles.y), &sy, &cy); 92 | sin_cos(DEG2RAD(angles.z), &sr, &cr); 93 | 94 | if (forward) { 95 | forward->x = cp * cy; 96 | forward->y = cp * sy; 97 | forward->z = -sp; 98 | } 99 | 100 | if (right) { 101 | right->x = -1 * sr * sp * cy + -1 * cr * -sy; 102 | right->y = -1 * sr * sp * sy + -1 * cr * cy; 103 | right->z = -1 * sr * cp; 104 | } 105 | 106 | if (up) { 107 | up->x = cr * sp * cy + -sr * -sy; 108 | up->y = cr * sp * sy + -sr * cy; 109 | up->z = cr * cp; 110 | } 111 | } 112 | 113 | vec3_t math::vector_add(vec3_t & a, vec3_t & b) { 114 | return vec3_t(a.x + b.x, 115 | a.y + b.y, 116 | a.z + b.z); 117 | } 118 | 119 | vec3_t math::vector_subtract(vec3_t & a, vec3_t & b) { 120 | return vec3_t(a.x - b.x, 121 | a.y - b.y, 122 | a.z - b.z); 123 | } 124 | 125 | vec3_t math::vector_multiply(vec3_t & a, vec3_t & b) { 126 | return vec3_t(a.x * b.x, 127 | a.y * b.y, 128 | a.z * b.z); 129 | } 130 | 131 | vec3_t math::vector_divide(vec3_t & a, vec3_t & b) { 132 | return vec3_t(a.x / b.x, 133 | a.y / b.y, 134 | a.z / b.z); 135 | } 136 | 137 | bool math::screen_transform(const vec3_t & point, vec3_t & screen) { 138 | auto matrix = interfaces::engine->world_to_screen_matrix(); 139 | 140 | float w = matrix[3][0] * point.x + matrix[3][1] * point.y + matrix[3][2] * point.z + matrix[3][3]; 141 | screen.x = matrix[0][0] * point.x + matrix[0][1] * point.y + matrix[0][2] * point.z + matrix[0][3]; 142 | screen.y = matrix[1][0] * point.x + matrix[1][1] * point.y + matrix[1][2] * point.z + matrix[1][3]; 143 | screen.z = 0.0f; 144 | 145 | int inverse_width = static_cast((w < 0.001f) ? -1.0f / w : 146 | 1.0f / w); 147 | 148 | screen.x *= inverse_width; 149 | screen.y *= inverse_width; 150 | return (w < 0.001f); 151 | } 152 | 153 | bool math::world_to_screen(const vec3_t & origin, vec3_t & screen) { 154 | auto matrix = interfaces::engine->world_to_screen_matrix(); 155 | 156 | auto find_point = [](vec3_t & point, int screen_w, int screen_h, int degrees) -> void { 157 | float x2 = screen_w * 0.5f; 158 | float y2 = screen_h * 0.5f; 159 | 160 | float d = sqrt(pow((point.x - x2), 2) + (pow((point.y - y2), 2))); //Distance 161 | float r = degrees / d; //Segment ratio 162 | 163 | point.x = r * point.x + (1 - r) * x2; //find point that divides the segment 164 | point.y = r * point.y + (1 - r) * y2; //into the ratio (1-r):r 165 | }; 166 | 167 | float w = matrix[3][0] * origin.x + matrix[3][1] * origin.y + matrix[3][2] * origin.z + matrix[3][3]; 168 | 169 | int screen_width, screen_height; 170 | interfaces::engine->get_screen_size(screen_width, screen_height); 171 | 172 | float inverse_width = -1.0f / w; 173 | bool behind = true; 174 | 175 | if (w > 0.01) { 176 | inverse_width = 1.0f / w; 177 | behind = false; 178 | } 179 | 180 | screen.x = (float)((screen_width / 2) + (0.5 * ((matrix[0][0] * origin.x 181 | + matrix[0][1] * origin.y 182 | + matrix[0][2] * origin.z 183 | + matrix[0][3]) * inverse_width) * screen_width + 0.5)); 184 | 185 | screen.y = (float)((screen_height / 2) - (0.5 * ((matrix[1][0] * origin.x 186 | + matrix[1][1] * origin.y 187 | + matrix[1][2] * origin.z 188 | + matrix[1][3]) * inverse_width) * screen_height + 0.5)); 189 | 190 | if (screen.x > screen_width || screen.x < 0 || screen.y > screen_height || screen.y < 0 || behind) { 191 | find_point(screen, screen_width, screen_height, screen_height / 2); 192 | return false; 193 | } 194 | 195 | return !(behind); 196 | } 197 | -------------------------------------------------------------------------------- /dependencies/interfaces/i_surface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/structs/vertex_t.hpp" 3 | 4 | class i_surface { 5 | public: 6 | void set_drawing_color(int r, int g, int b, int a = 255) { 7 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 8 | return (*(original_fn * *)this)[15](this, r, g, b, a); 9 | } 10 | 11 | void play_sound(const char* sound_path) { 12 | using original_fn = void(__thiscall*)(i_surface*, const char*); 13 | return (*(original_fn * *)this)[82](this, sound_path); 14 | } 15 | 16 | void set_text_color(int r, int g, int b, int a = 255) { 17 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 18 | return (*(original_fn * *)this)[25](this, r, g, b, a); 19 | } 20 | 21 | void draw_polygon(int n, vertex_t* vertice, bool clip_vertices = true) { 22 | using original_fn = void(__thiscall*)(i_surface*, int, vertex_t*, bool); 23 | return (*(original_fn * *)this)[106](this, n, vertice, clip_vertices); 24 | } 25 | void draw_filled_rectangle(int x, int y, int w, int h) { 26 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 27 | return (*(original_fn * *)this)[16](this, x, y, x + w, y + h); 28 | } 29 | void set_texture(int id) { 30 | using original_fn = void(__thiscall*)(i_surface*, int); 31 | return (*(original_fn * *)this)[38](this, id); 32 | } 33 | inline void draw_textured_rectangle(int x, int y, int w, int h) { 34 | typedef void(__thiscall * original_fn)(void*, int, int, int, int); 35 | return (*(original_fn * *)this)[41](this, x, y, w, h); 36 | } 37 | void set_texture_rgba(int id, const unsigned char* rgba, int wide, int tall) { 38 | using original_fn = void(__thiscall*)(i_surface*, int, const unsigned char*, int, int, int, bool); 39 | return (*(original_fn * *)this)[37](this, id, rgba, wide, tall, 0, false); 40 | } 41 | int create_new_texture_id(bool procedural = false) { 42 | using original_fn = int(__thiscall*)(i_surface*, bool); 43 | return (*(original_fn * *)this)[43](this, procedural); 44 | } 45 | void draw_outlined_rect(int x, int y, int w, int h) { 46 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 47 | return (*(original_fn * *)this)[18](this, x, y, x + w, y + h); 48 | } 49 | void draw_line(int x1, int y1, int x2, int y2) { 50 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 51 | return (*(original_fn * *)this)[19](this, x1, y1, x2, y2); 52 | } 53 | void draw_text_font(unsigned long font) { 54 | using original_fn = void(__thiscall*)(i_surface*, unsigned long); 55 | return (*(original_fn * *)this)[23](this, font); 56 | } 57 | void draw_text_pos(int x, int y) { 58 | using original_fn = void(__thiscall*)(i_surface*, int, int); 59 | return (*(original_fn * *)this)[26](this, x, y); 60 | } 61 | void draw_render_text(const wchar_t* text, int textLen) { 62 | using original_fn = void(__thiscall*)(i_surface*, const wchar_t*, int, int); 63 | return (*(original_fn * *)this)[28](this, text, textLen, 0); 64 | } 65 | unsigned long font_create() { 66 | using original_fn = unsigned int(__thiscall*)(i_surface*); 67 | return (*(original_fn * *)this)[71](this); 68 | } 69 | void set_font_glyph(unsigned long font, const char* windowsFontName, int tall, int weight, int blur, int scanlines, int flags) { 70 | using original_fn = void(__thiscall*)(i_surface*, unsigned long, const char*, int, int, int, int, int, int, int); 71 | return (*(original_fn * *)this)[72](this, font, windowsFontName, tall, weight, blur, scanlines, flags, 0, 0); 72 | } 73 | void get_text_size(unsigned long font, const wchar_t* text, int& wide, int& tall) { 74 | using original_fn = void(__thiscall*)(i_surface*, unsigned long, const wchar_t*, int&, int&); 75 | return (*(original_fn * *)this)[79](this, font, text, wide, tall); 76 | } 77 | void unlock_cursor() { 78 | using original_fn = void(__thiscall*)(i_surface*); 79 | return (*(original_fn * *)this)[66](this); 80 | } 81 | 82 | void set_clip_rect(int x, int y, int w, int h) { 83 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 84 | return (*(original_fn * *)this)[147](this, x, y, w, h); 85 | } 86 | 87 | void draw_filled_rect_fade(int x, int y, int w, int h, unsigned int alpha1, unsigned int alpha2, bool is_horizontal) { 88 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int, unsigned int, unsigned int, bool); 89 | return (*(original_fn * *)this)[123](this, x, y, w, h, alpha1, alpha2, is_horizontal); 90 | } 91 | 92 | void draw_colored_text(unsigned long font, int x, int y, int red, int green, int blue, int alpha, const char* text) { 93 | using original_fn = void(__thiscall*)(i_surface*, unsigned long, int, int, int, int, int, int, const char*); 94 | return (*(original_fn * *)this)[163](this, font, x, y, red, green, blue, alpha, text); 95 | } 96 | 97 | void get_screen_size(int& width, int& height) { 98 | using original_fn = void(__thiscall*)(i_surface*, int&, int&); 99 | return (*(original_fn * *)this)[44](this, std::ref(width), std::ref(height)); //width, height 100 | } 101 | 102 | void draw_textured_polygon(int vertex_count, vertex_t* vertex, bool clip_vertices = true) { 103 | using original_fn = void(__thiscall*)(i_surface*, int, vertex_t*, bool); 104 | return (*(original_fn * *)this)[106](this, vertex_count, vertex, clip_vertices); 105 | } 106 | 107 | void draw_outlined_circle(int x, int y, int radius, int segments) { 108 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 109 | return (*(original_fn * *)this)[103](this, x, y, radius, segments); 110 | } 111 | 112 | void draw_set_texture_file(int texture_id, const char* texture_name, int hardware_filter, bool force_reload = 0) { 113 | using original_fn = void(__thiscall*)(i_surface*, int, const char*, int, bool); 114 | return (*(original_fn * *)this)[36](this, texture_id, texture_name, hardware_filter, force_reload); 115 | } 116 | 117 | bool is_texture_id_valid(int texture_id) { 118 | using original_fn = bool(__thiscall*)(i_surface*, int); 119 | return (*(original_fn * *)this)[42](this, texture_id); 120 | } 121 | 122 | void surface_get_cursor_pos(int& x, int& y) { 123 | using original_fn = void(__thiscall*)(i_surface*, int&, int&); 124 | return (*(original_fn * *)this)[100](this, std::ref(x), std::ref(y)); //x, y 125 | } 126 | 127 | void draw_textured_rect(int x, int y, int width, int height) { 128 | using original_fn = void(__thiscall*)(i_surface*, int, int, int, int); 129 | return (*(original_fn * *)this)[41](this, x, y, width, height); 130 | } 131 | }; -------------------------------------------------------------------------------- /source-sdk/classes/client_class.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "recv_props.hpp" 3 | 4 | class client_class; 5 | class i_client_networkable; 6 | class i_client_mode; 7 | 8 | typedef i_client_networkable* (*create_client_class_fn)(int ent_number, int serial_number); 9 | typedef i_client_networkable* (*create_event_fn)(); 10 | 11 | enum class_ids { 12 | cai_basenpc = 0, 13 | cak47, 14 | cbaseanimating, 15 | cbaseanimatingoverlay, 16 | cbaseattributableitem, 17 | cbasebutton, 18 | cbasecombatcharacter, 19 | cbasecombatweapon, 20 | cbasecsgrenade, 21 | cbasecsgrenadeprojectile, 22 | cbasedoor, 23 | cbaseentity, 24 | cbaseflex, 25 | cbasegrenade, 26 | cbaseparticleentity, 27 | cbaseplayer, 28 | cbasepropdoor, 29 | cbaseteamobjectiveresource, 30 | cbasetempentity, 31 | cbasetoggle, 32 | cbasetrigger, 33 | cbaseviewmodel, 34 | cbasevphysicstrigger, 35 | cbaseweaponworldmodel, 36 | cbeam, 37 | cbeamspotlight, 38 | cbonefollower, 39 | cbrc4target, 40 | cbreachcharge, 41 | cbreachchargeprojectile, 42 | cbreakableprop, 43 | cbreakablesurface, 44 | cbumpmine, 45 | cbumpmineprojectile, 46 | cc4, 47 | ccascadelight, 48 | cchicken, 49 | ccolorcorrection, 50 | ccolorcorrectionvolume, 51 | ccsgamerulesproxy, 52 | ccsplayer, 53 | ccsplayerresource, 54 | ccsragdoll, 55 | ccsteam, 56 | cdangerzone, 57 | cdangerzonecontroller, 58 | cdeagle, 59 | cdecoygrenade, 60 | cdecoyprojectile, 61 | cdrone, 62 | cdronegun, 63 | cdynamiclight, 64 | cdynamicprop, 65 | ceconentity, 66 | ceconwearable, 67 | cembers, 68 | centitydissolve, 69 | centityflame, 70 | centityfreezing, 71 | centityparticletrail, 72 | cenvambientlight, 73 | cenvdetailcontroller, 74 | cenvdofcontroller, 75 | cenvgascanister, 76 | cenvparticlescript, 77 | cenvprojectedtexture, 78 | cenvquadraticbeam, 79 | cenvscreeneffect, 80 | cenvscreenoverlay, 81 | cenvtonemapcontroller, 82 | cenvwind, 83 | cfeplayerdecal, 84 | cfirecrackerblast, 85 | cfiresmoke, 86 | cfiretrail, 87 | cfish, 88 | cfists, 89 | cflashbang, 90 | cfogcontroller, 91 | cfootstepcontrol, 92 | cfunc_dust, 93 | cfunc_lod, 94 | cfuncareaportalwindow, 95 | cfuncbrush, 96 | cfuncconveyor, 97 | cfuncladder, 98 | cfuncmonitor, 99 | cfuncmovelinear, 100 | cfuncoccluder, 101 | cfuncreflectiveglass, 102 | cfuncrotating, 103 | cfuncsmokevolume, 104 | cfunctracktrain, 105 | cgamerulesproxy, 106 | cgrassburn, 107 | chandletest, 108 | chegrenade, 109 | chostage, 110 | chostagecarriableprop, 111 | cincendiarygrenade, 112 | cinferno, 113 | cinfoladderdismount, 114 | cinfomapregion, 115 | cinfooverlayaccessor, 116 | citem_healthshot, 117 | citemcash, 118 | citemdogtags, 119 | cknife, 120 | cknifegg, 121 | clightglow, 122 | cmaterialmodifycontrol, 123 | cmelee, 124 | cmolotovgrenade, 125 | cmolotovprojectile, 126 | cmoviedisplay, 127 | cparadropchopper, 128 | cparticlefire, 129 | cparticleperformancemonitor, 130 | cparticlesystem, 131 | cphysbox, 132 | cphysboxmultiplayer, 133 | cphysicsprop, 134 | cphysicspropmultiplayer, 135 | cphysmagnet, 136 | cphyspropammobox, 137 | cphysproplootcrate, 138 | cphyspropradarjammer, 139 | cphyspropweaponupgrade, 140 | cplantedc4, 141 | cplasma, 142 | cplayerping, 143 | cplayerresource, 144 | cpointcamera, 145 | cpointcommentarynode, 146 | cpointworldtext, 147 | cposecontroller, 148 | cpostprocesscontroller, 149 | cprecipitation, 150 | cprecipitationblocker, 151 | cpredictedviewmodel, 152 | cprop_hallucination, 153 | cpropcounter, 154 | cpropdoorrotating, 155 | cpropjeep, 156 | cpropvehicledriveable, 157 | cragdollmanager, 158 | cragdollprop, 159 | cragdollpropattached, 160 | cropekeyframe, 161 | cscar17, 162 | csceneentity, 163 | csensorgrenade, 164 | csensorgrenadeprojectile, 165 | cshadowcontrol, 166 | cslideshowdisplay, 167 | csmokegrenade, 168 | csmokegrenadeprojectile, 169 | csmokestack, 170 | csnowball, 171 | csnowballpile, 172 | csnowballprojectile, 173 | cspatialentity, 174 | cspotlightend, 175 | csprite, 176 | cspriteoriented, 177 | cspritetrail, 178 | cstatueprop, 179 | csteamjet, 180 | csun, 181 | csunlightshadowcontrol, 182 | csurvivalspawnchopper, 183 | ctablet, 184 | cteam, 185 | cteamplayroundbasedrulesproxy, 186 | ctearmorricochet, 187 | ctebasebeam, 188 | ctebeamentpoint, 189 | ctebeaments, 190 | ctebeamfollow, 191 | ctebeamlaser, 192 | ctebeampoints, 193 | ctebeamring, 194 | ctebeamringpoint, 195 | ctebeamspline, 196 | ctebloodsprite, 197 | ctebloodstream, 198 | ctebreakmodel, 199 | ctebspdecal, 200 | ctebubbles, 201 | ctebubbletrail, 202 | cteclientprojectile, 203 | ctedecal, 204 | ctedust, 205 | ctedynamiclight, 206 | cteeffectdispatch, 207 | cteenergysplash, 208 | cteexplosion, 209 | ctefirebullets, 210 | ctefizz, 211 | ctefootprintdecal, 212 | ctefoundryhelpers, 213 | ctegaussexplosion, 214 | cteglowsprite, 215 | cteimpact, 216 | ctekillplayerattachments, 217 | ctelargefunnel, 218 | ctemetalsparks, 219 | ctemuzzleflash, 220 | cteparticlesystem, 221 | ctephysicsprop, 222 | cteplantbomb, 223 | cteplayeranimevent, 224 | cteplayerdecal, 225 | cteprojecteddecal, 226 | cteradioicon, 227 | cteshattersurface, 228 | cteshowline, 229 | ctesla, 230 | ctesmoke, 231 | ctesparks, 232 | ctesprite, 233 | ctespritespray, 234 | ctest_proxytoggle_networkable, 235 | ctesttraceline, 236 | cteworlddecal, 237 | ctriggerplayermovement, 238 | ctriggersoundoperator, 239 | cvguiscreen, 240 | cvotecontroller, 241 | cwaterbullet, 242 | cwaterlodcontrol, 243 | cweaponaug, 244 | cweaponawp, 245 | cweaponbaseitem, 246 | cweaponbizon, 247 | cweaponcsbase, 248 | cweaponcsbasegun, 249 | cweaponcycler, 250 | cweaponelite, 251 | cweaponfamas, 252 | cweaponfiveseven, 253 | cweapong3sg1, 254 | cweapongalil, 255 | cweapongalilar, 256 | cweaponglock, 257 | cweaponhkp2000, 258 | cweaponm249, 259 | cweaponm3, 260 | cweaponm4a1, 261 | cweaponmac10, 262 | cweaponmag7, 263 | cweaponmp5navy, 264 | cweaponmp7, 265 | cweaponmp9, 266 | cweaponnegev, 267 | cweaponnova, 268 | cweaponp228, 269 | cweaponp250, 270 | cweaponp90, 271 | cweaponsawedoff, 272 | cweaponscar20, 273 | cweaponscout, 274 | cweaponsg550, 275 | cweaponsg552, 276 | cweaponsg556, 277 | cweaponshield, 278 | cweaponssg08, 279 | cweapontaser, 280 | cweapontec9, 281 | cweapontmp, 282 | cweaponump45, 283 | cweaponusp, 284 | cweaponxm1014, 285 | cworld, 286 | cworldvguitext, 287 | dusttrail, 288 | movieexplosion, 289 | particlesmokegrenade, 290 | rockettrail, 291 | smoketrail, 292 | sporeexplosion, 293 | sporetrail, 294 | }; 295 | 296 | class c_client_class { 297 | public: 298 | create_client_class_fn create_fn; 299 | create_event_fn create_event_fn; 300 | char* network_name; 301 | recv_table* recvtable_ptr; 302 | c_client_class* next_ptr; 303 | class_ids class_id; 304 | }; -------------------------------------------------------------------------------- /source-sdk/classes/studio.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | using quaternion = float[4]; 5 | using rad_euler = float[3]; 6 | 7 | #define MAX_QPATH 260 8 | 9 | #define BONE_CALCULATE_MASK 0x1F 10 | #define BONE_PHYSICALLY_SIMULATED 0x01 // bone is physically simulated when physics are active 11 | #define BONE_PHYSICS_PROCEDURAL 0x02 // procedural when physics is active 12 | #define BONE_ALWAYS_PROCEDURAL 0x04 // bone is always procedurally animated 13 | #define BONE_SCREEN_ALIGN_SPHERE 0x08 // bone aligns to the screen, not constrained in motion. 14 | #define BONE_SCREEN_ALIGN_CYLINDER 0x10 // bone aligns to the screen, constrained by it's own axis. 15 | 16 | #define BONE_USED_MASK 0x0007FF00 17 | #define BONE_USED_BY_ANYTHING 0x0007FF00 18 | #define BONE_USED_BY_HITBOX 0x00000100 // bone (or child) is used by a hit box 19 | #define BONE_USED_BY_ATTACHMENT 0x00000200 // bone (or child) is used by an attachment point 20 | #define BONE_USED_BY_VERTEX_MASK 0x0003FC00 21 | #define BONE_USED_BY_VERTEX_LOD0 0x00000400 // bone (or child) is used by the toplevel model via skinned vertex 22 | #define BONE_USED_BY_VERTEX_LOD1 0x00000800 23 | #define BONE_USED_BY_VERTEX_LOD2 0x00001000 24 | #define BONE_USED_BY_VERTEX_LOD3 0x00002000 25 | #define BONE_USED_BY_VERTEX_LOD4 0x00004000 26 | #define BONE_USED_BY_VERTEX_LOD5 0x00008000 27 | #define BONE_USED_BY_VERTEX_LOD6 0x00010000 28 | #define BONE_USED_BY_VERTEX_LOD7 0x00020000 29 | #define BONE_USED_BY_BONE_MERGE 0x00040000 // bone is available for bone merge to occur against it 30 | 31 | #define BONE_USED_BY_VERTEX_AT_LOD(lod) ( BONE_USED_BY_VERTEX_LOD0 << (lod) ) 32 | #define BONE_USED_BY_ANYTHING_AT_LOD(lod) ( ( BONE_USED_BY_ANYTHING & ~BONE_USED_BY_VERTEX_MASK ) | BONE_USED_BY_VERTEX_AT_LOD(lod) ) 33 | 34 | #define MAX_NUM_LODS 8 35 | #define MAXSTUDIOBONES 128 // total bones actually used 36 | 37 | #define BONE_TYPE_MASK 0x00F00000 38 | #define BONE_FIXED_ALIGNMENT 0x00100000 // bone can't spin 360 degrees, all interpolation is normalized around a fixed orientation 39 | 40 | #define BONE_HAS_SAVEFRAME_POS 0x00200000 // Vector48 41 | #define BONE_HAS_SAVEFRAME_ROT64 0x00400000 // Quaternion64 42 | #define BONE_HAS_SAVEFRAME_ROT32 0x00800000 // Quaternion32 43 | 44 | enum bone_flags { 45 | bone_calculate_mask = 0x1f, 46 | bone_physically_simulated = 0x01, 47 | bone_physics_procedural = 0x02, 48 | bone_always_procedural = 0x04, 49 | bone_screen_align_sphere = 0x08, 50 | bone_screen_align_cylinder = 0x10, 51 | bone_used_mask = 0x0007ff00, 52 | bone_used_by_anything = 0x0007ff00, 53 | bone_used_by_hitbox = 0x00000100, 54 | bone_used_by_attachment = 0x00000200, 55 | bone_used_by_vertex_mask = 0x0003fc00, 56 | bone_used_by_vertex_lod0 = 0x00000400, 57 | bone_used_by_vertex_lod1 = 0x00000800, 58 | bone_used_by_vertex_lod2 = 0x00001000, 59 | bone_used_by_vertex_lod3 = 0x00002000, 60 | bone_used_by_vertex_lod4 = 0x00004000, 61 | bone_used_by_vertex_lod5 = 0x00008000, 62 | bone_used_by_vertex_lod6 = 0x00010000, 63 | bone_used_by_vertex_lod7 = 0x00020000, 64 | bone_used_by_bone_merge = 0x00040000, 65 | bone_type_mask = 0x00f00000, 66 | bone_fixed_alignment = 0x00100000, 67 | bone_has_saveframe_pos = 0x00200000, 68 | bone_has_saveframe_rot = 0x00400000 69 | }; 70 | 71 | enum hitgroups { 72 | hitgroup_generic = 0, 73 | hitgroup_head = 1, 74 | hitgroup_chest = 2, 75 | hitgroup_stomach = 3, 76 | hitgroup_leftarm = 4, 77 | hitgroup_rightarm = 5, 78 | hitgroup_leftleg = 6, 79 | hitgroup_rightleg = 7, 80 | hitgroup_gear = 10 81 | }; 82 | 83 | enum modtypes { 84 | mod_bad = 0, 85 | mod_brush, 86 | mod_sprite, 87 | mod_studio 88 | }; 89 | 90 | enum hitboxes { 91 | hitbox_head, 92 | hitbox_neck, 93 | hitbox_lower_neck, 94 | hitbox_pelvis, 95 | hitbox_stomach, 96 | hitbox_lower_chest, 97 | hitbox_chest, 98 | hitbox_upper_chest, 99 | hitbox_right_thigh, 100 | hitbox_left_thigh, 101 | hitbox_right_calf, 102 | hitbox_left_calf, 103 | hitbox_right_foot, 104 | hitbox_left_foot, 105 | hitbox_right_hand, 106 | hitbox_left_hand, 107 | hitbox_right_upper_arm, 108 | hitbox_right_forearm, 109 | hitbox_left_upper_arm, 110 | hitbox_left_forearm, 111 | hitbox_max 112 | }; 113 | 114 | struct studio_bone_t { 115 | int name_index; 116 | inline char* const name(void) const { 117 | return ((char*)this) + name_index; 118 | } 119 | int parent; 120 | int bone_controller[6]; 121 | 122 | vec3_t pos; 123 | quaternion quat; 124 | rad_euler rotation; 125 | 126 | vec3_t pos_scale; 127 | vec3_t rot_scale; 128 | 129 | matrix_t pose_to_bone; 130 | quaternion quat_alignement; 131 | int flags; 132 | int proc_type; 133 | int proc_index; 134 | mutable int physics_bone; 135 | 136 | inline void* procedure() const { 137 | if (proc_index == 0) return NULL; 138 | else return(void*)(((unsigned char*)this) + proc_index); 139 | }; 140 | 141 | int surface_prop_idx; 142 | inline char* const surface_prop(void) const { 143 | return ((char*)this) + surface_prop_idx; 144 | } 145 | inline int get_surface_prop(void) const { 146 | return surf_prop_lookup; 147 | } 148 | 149 | int contents; 150 | int surf_prop_lookup; 151 | int unused[7]; 152 | }; 153 | 154 | struct studio_box_t { 155 | int bone; 156 | int group; 157 | vec3_t mins; 158 | vec3_t maxs; 159 | int name_index; 160 | int pad01[3]; 161 | float radius; 162 | int pad02[4]; 163 | }; 164 | 165 | struct studio_hitbox_set_t { 166 | int name_index; 167 | int hitbox_count; 168 | int hitbox_index; 169 | 170 | inline char* const name(void) const { 171 | return ((char*)this) + name_index; 172 | } 173 | inline studio_box_t* hitbox(int i) const { 174 | return (studio_box_t*)(((unsigned char*)this) + hitbox_index) + i; 175 | } 176 | }; 177 | 178 | class studio_hdr_t { 179 | public: 180 | int id; 181 | int version; 182 | long checksum; 183 | char name_char_array[64]; 184 | int length; 185 | vec3_t eye_pos; 186 | vec3_t illium_pos; 187 | vec3_t hull_mins; 188 | vec3_t hull_maxs; 189 | vec3_t mins; 190 | vec3_t maxs; 191 | int flags; 192 | int bones_count; 193 | int bone_index; 194 | int bone_controllers_count; 195 | int bone_controller_index; 196 | int hitbox_sets_count; 197 | int hitbox_set_index; 198 | int local_anim_count; 199 | int local_anim_index; 200 | int local_seq_count; 201 | int local_seq_index; 202 | int activity_list_version; 203 | int events_indexed; 204 | int textures_count; 205 | int texture_index; 206 | 207 | studio_hitbox_set_t* hitbox_set(int i) { 208 | if (i > hitbox_sets_count) return nullptr; 209 | return (studio_hitbox_set_t*)((uint8_t*)this + hitbox_set_index) + i; 210 | } 211 | studio_bone_t* bone(int i) { 212 | if (i > bones_count) return nullptr; 213 | return (studio_bone_t*)((uint8_t*)this + bone_index) + i; 214 | } 215 | }; -------------------------------------------------------------------------------- /dependencies/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 | // Removes an already created hook. 145 | // Parameters: 146 | // pTarget [in] A pointer to the target function. 147 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 148 | 149 | // Enables an already created hook. 150 | // Parameters: 151 | // pTarget [in] A pointer to the target function. 152 | // If this parameter is MH_ALL_HOOKS, all created hooks are 153 | // enabled in one go. 154 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 155 | 156 | // Disables an already created hook. 157 | // Parameters: 158 | // pTarget [in] A pointer to the target function. 159 | // If this parameter is MH_ALL_HOOKS, all created hooks are 160 | // disabled in one go. 161 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 162 | 163 | // Queues to enable an already created hook. 164 | // Parameters: 165 | // pTarget [in] A pointer to the target function. 166 | // If this parameter is MH_ALL_HOOKS, all created hooks are 167 | // queued to be enabled. 168 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 169 | 170 | // Queues to disable an already created hook. 171 | // Parameters: 172 | // pTarget [in] A pointer to the target function. 173 | // If this parameter is MH_ALL_HOOKS, all created hooks are 174 | // queued to be disabled. 175 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 176 | 177 | // Applies all queued changes in one go. 178 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 179 | 180 | // Translates the MH_STATUS to its name as a string. 181 | const char* WINAPI MH_StatusToString(MH_STATUS status); 182 | 183 | #ifdef __cplusplus 184 | } 185 | #endif 186 | -------------------------------------------------------------------------------- /dependencies/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 | } 66 | else if (c >= 0xa0 && c <= 0xa3) { 67 | if (pref & PRE_67) 68 | pref |= PRE_66; 69 | else 70 | pref &= ~PRE_66; 71 | } 72 | 73 | opcode = c; 74 | cflags = ht[ht[opcode / 4] + (opcode % 4)]; 75 | 76 | if (cflags == C_ERROR) { 77 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 78 | cflags = 0; 79 | if ((opcode & -3) == 0x24) 80 | cflags++; 81 | } 82 | 83 | x = 0; 84 | if (cflags & C_GROUP) { 85 | uint16_t t; 86 | t = *(uint16_t*)(ht + (cflags & 0x7f)); 87 | cflags = (uint8_t)t; 88 | x = (uint8_t)(t >> 8); 89 | } 90 | 91 | if (hs->opcode2) { 92 | ht = hde32_table + DELTA_PREFIXES; 93 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref) 94 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 95 | } 96 | 97 | if (cflags & C_MODRM) { 98 | hs->flags |= F_MODRM; 99 | hs->modrm = c = *p++; 100 | hs->modrm_mod = m_mod = c >> 6; 101 | hs->modrm_rm = m_rm = c & 7; 102 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3; 103 | 104 | if (x && ((x << m_reg) & 0x80)) 105 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 106 | 107 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) { 108 | uint8_t t = opcode - 0xd9; 109 | if (m_mod == 3) { 110 | ht = hde32_table + DELTA_FPU_MODRM + t * 8; 111 | t = ht[m_reg] << m_rm; 112 | } 113 | else { 114 | ht = hde32_table + DELTA_FPU_REG; 115 | t = ht[t] << m_reg; 116 | } 117 | if (t & 0x80) 118 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 119 | } 120 | 121 | if (pref & PRE_LOCK) { 122 | if (m_mod == 3) { 123 | hs->flags |= F_ERROR | F_ERROR_LOCK; 124 | } 125 | else { 126 | uint8_t* table_end, op = opcode; 127 | if (hs->opcode2) { 128 | ht = hde32_table + DELTA_OP2_LOCK_OK; 129 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK; 130 | } 131 | else { 132 | ht = hde32_table + DELTA_OP_LOCK_OK; 133 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK; 134 | op &= -2; 135 | } 136 | for (; ht != table_end; ht++) 137 | if (*ht++ == op) { 138 | if (!((*ht << m_reg) & 0x80)) 139 | goto no_lock_error; 140 | else 141 | break; 142 | } 143 | hs->flags |= F_ERROR | F_ERROR_LOCK; 144 | no_lock_error: 145 | ; 146 | } 147 | } 148 | 149 | if (hs->opcode2) { 150 | switch (opcode) { 151 | case 0x20: case 0x22: 152 | m_mod = 3; 153 | if (m_reg > 4 || m_reg == 1) 154 | goto error_operand; 155 | else 156 | goto no_error_operand; 157 | case 0x21: case 0x23: 158 | m_mod = 3; 159 | if (m_reg == 4 || m_reg == 5) 160 | goto error_operand; 161 | else 162 | goto no_error_operand; 163 | } 164 | } 165 | else { 166 | switch (opcode) { 167 | case 0x8c: 168 | if (m_reg > 5) 169 | goto error_operand; 170 | else 171 | goto no_error_operand; 172 | case 0x8e: 173 | if (m_reg == 1 || m_reg > 5) 174 | goto error_operand; 175 | else 176 | goto no_error_operand; 177 | } 178 | } 179 | 180 | if (m_mod == 3) { 181 | uint8_t* table_end; 182 | if (hs->opcode2) { 183 | ht = hde32_table + DELTA_OP2_ONLY_MEM; 184 | table_end = ht + sizeof(hde32_table) - DELTA_OP2_ONLY_MEM; 185 | } 186 | else { 187 | ht = hde32_table + DELTA_OP_ONLY_MEM; 188 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM; 189 | } 190 | for (; ht != table_end; ht += 2) 191 | if (*ht++ == opcode) { 192 | if (*ht++ & pref && !((*ht << m_reg) & 0x80)) 193 | goto error_operand; 194 | else 195 | break; 196 | } 197 | goto no_error_operand; 198 | } 199 | else if (hs->opcode2) { 200 | switch (opcode) { 201 | case 0x50: case 0xd7: case 0xf7: 202 | if (pref & (PRE_NONE | PRE_66)) 203 | goto error_operand; 204 | break; 205 | case 0xd6: 206 | if (pref & (PRE_F2 | PRE_F3)) 207 | goto error_operand; 208 | break; 209 | case 0xc5: 210 | goto error_operand; 211 | } 212 | goto no_error_operand; 213 | } 214 | else 215 | goto no_error_operand; 216 | 217 | error_operand: 218 | hs->flags |= F_ERROR | F_ERROR_OPERAND; 219 | no_error_operand: 220 | 221 | c = *p++; 222 | if (m_reg <= 1) { 223 | if (opcode == 0xf6) 224 | cflags |= C_IMM8; 225 | else if (opcode == 0xf7) 226 | cflags |= C_IMM_P66; 227 | } 228 | 229 | switch (m_mod) { 230 | case 0: 231 | if (pref & PRE_67) { 232 | if (m_rm == 6) 233 | disp_size = 2; 234 | } 235 | else 236 | if (m_rm == 5) 237 | disp_size = 4; 238 | break; 239 | case 1: 240 | disp_size = 1; 241 | break; 242 | case 2: 243 | disp_size = 2; 244 | if (!(pref & PRE_67)) 245 | disp_size <<= 1; 246 | } 247 | 248 | if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) { 249 | hs->flags |= F_SIB; 250 | p++; 251 | hs->sib = c; 252 | hs->sib_scale = c >> 6; 253 | hs->sib_index = (c & 0x3f) >> 3; 254 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1)) 255 | disp_size = 4; 256 | } 257 | 258 | p--; 259 | switch (disp_size) { 260 | case 1: 261 | hs->flags |= F_DISP8; 262 | hs->disp.disp8 = *p; 263 | break; 264 | case 2: 265 | hs->flags |= F_DISP16; 266 | hs->disp.disp16 = *(uint16_t*)p; 267 | break; 268 | case 4: 269 | hs->flags |= F_DISP32; 270 | hs->disp.disp32 = *(uint32_t*)p; 271 | } 272 | p += disp_size; 273 | } 274 | else if (pref & PRE_LOCK) 275 | hs->flags |= F_ERROR | F_ERROR_LOCK; 276 | 277 | if (cflags & C_IMM_P66) { 278 | if (cflags & C_REL32) { 279 | if (pref & PRE_66) { 280 | hs->flags |= F_IMM16 | F_RELATIVE; 281 | hs->imm.imm16 = *(uint16_t*)p; 282 | p += 2; 283 | goto disasm_done; 284 | } 285 | goto rel32_ok; 286 | } 287 | if (pref & PRE_66) { 288 | hs->flags |= F_IMM16; 289 | hs->imm.imm16 = *(uint16_t*)p; 290 | p += 2; 291 | } 292 | else { 293 | hs->flags |= F_IMM32; 294 | hs->imm.imm32 = *(uint32_t*)p; 295 | p += 4; 296 | } 297 | } 298 | 299 | if (cflags & C_IMM16) { 300 | if (hs->flags & F_IMM32) { 301 | hs->flags |= F_IMM16; 302 | hs->disp.disp16 = *(uint16_t*)p; 303 | } 304 | else if (hs->flags & F_IMM16) { 305 | hs->flags |= F_2IMM16; 306 | hs->disp.disp16 = *(uint16_t*)p; 307 | } 308 | else { 309 | hs->flags |= F_IMM16; 310 | hs->imm.imm16 = *(uint16_t*)p; 311 | } 312 | p += 2; 313 | } 314 | if (cflags & C_IMM8) { 315 | hs->flags |= F_IMM8; 316 | hs->imm.imm8 = *p++; 317 | } 318 | 319 | if (cflags & C_REL32) { 320 | rel32_ok: 321 | hs->flags |= F_IMM32 | F_RELATIVE; 322 | hs->imm.imm32 = *(uint32_t*)p; 323 | p += 4; 324 | } 325 | else if (cflags & C_REL8) { 326 | hs->flags |= F_IMM8 | F_RELATIVE; 327 | hs->imm.imm8 = *p++; 328 | } 329 | 330 | disasm_done: 331 | 332 | if ((hs->len = (uint8_t)(p - (uint8_t*)code)) > 15) { 333 | hs->flags |= F_ERROR | F_ERROR_LENGTH; 334 | hs->len = 15; 335 | } 336 | 337 | return (unsigned int)hs->len; 338 | } 339 | 340 | #endif // defined(_M_IX86) || defined(__i386__) -------------------------------------------------------------------------------- /dependencies/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 "hde64.h" 11 | #include "table64.h" 12 | 13 | unsigned int hde64_disasm(const void* code, hde64s* hs) 14 | { 15 | uint8_t x, c, * p = (uint8_t*)code, cflags, opcode, pref = 0; 16 | uint8_t* ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0; 17 | uint8_t op64 = 0; 18 | 19 | // Avoid using memset to reduce the footprint. 20 | #ifndef _MSC_VER 21 | memset((LPBYTE)hs, 0, sizeof(hde64s)); 22 | #else 23 | __stosb((LPBYTE)hs, 0, sizeof(hde64s)); 24 | #endif 25 | 26 | for (x = 16; x; x--) 27 | switch (c = *p++) { 28 | case 0xf3: 29 | hs->p_rep = c; 30 | pref |= PRE_F3; 31 | break; 32 | case 0xf2: 33 | hs->p_rep = c; 34 | pref |= PRE_F2; 35 | break; 36 | case 0xf0: 37 | hs->p_lock = c; 38 | pref |= PRE_LOCK; 39 | break; 40 | case 0x26: case 0x2e: case 0x36: 41 | case 0x3e: case 0x64: case 0x65: 42 | hs->p_seg = c; 43 | pref |= PRE_SEG; 44 | break; 45 | case 0x66: 46 | hs->p_66 = c; 47 | pref |= PRE_66; 48 | break; 49 | case 0x67: 50 | hs->p_67 = c; 51 | pref |= PRE_67; 52 | break; 53 | default: 54 | goto pref_done; 55 | } 56 | pref_done: 57 | 58 | hs->flags = (uint32_t)pref << 23; 59 | 60 | if (!pref) 61 | pref |= PRE_NONE; 62 | 63 | if ((c & 0xf0) == 0x40) { 64 | hs->flags |= F_PREFIX_REX; 65 | if ((hs->rex_w = (c & 0xf) >> 3) && (*p & 0xf8) == 0xb8) 66 | op64++; 67 | hs->rex_r = (c & 7) >> 2; 68 | hs->rex_x = (c & 3) >> 1; 69 | hs->rex_b = c & 1; 70 | if (((c = *p++) & 0xf0) == 0x40) { 71 | opcode = c; 72 | goto error_opcode; 73 | } 74 | } 75 | 76 | if ((hs->opcode = c) == 0x0f) { 77 | hs->opcode2 = c = *p++; 78 | ht += DELTA_OPCODES; 79 | } 80 | else if (c >= 0xa0 && c <= 0xa3) { 81 | op64++; 82 | if (pref & PRE_67) 83 | pref |= PRE_66; 84 | else 85 | pref &= ~PRE_66; 86 | } 87 | 88 | opcode = c; 89 | cflags = ht[ht[opcode / 4] + (opcode % 4)]; 90 | 91 | if (cflags == C_ERROR) { 92 | error_opcode: 93 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 94 | cflags = 0; 95 | if ((opcode & -3) == 0x24) 96 | cflags++; 97 | } 98 | 99 | x = 0; 100 | if (cflags & C_GROUP) { 101 | uint16_t t; 102 | t = *(uint16_t*)(ht + (cflags & 0x7f)); 103 | cflags = (uint8_t)t; 104 | x = (uint8_t)(t >> 8); 105 | } 106 | 107 | if (hs->opcode2) { 108 | ht = hde64_table + DELTA_PREFIXES; 109 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref) 110 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 111 | } 112 | 113 | if (cflags & C_MODRM) { 114 | hs->flags |= F_MODRM; 115 | hs->modrm = c = *p++; 116 | hs->modrm_mod = m_mod = c >> 6; 117 | hs->modrm_rm = m_rm = c & 7; 118 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3; 119 | 120 | if (x && ((x << m_reg) & 0x80)) 121 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 122 | 123 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) { 124 | uint8_t t = opcode - 0xd9; 125 | if (m_mod == 3) { 126 | ht = hde64_table + DELTA_FPU_MODRM + t * 8; 127 | t = ht[m_reg] << m_rm; 128 | } 129 | else { 130 | ht = hde64_table + DELTA_FPU_REG; 131 | t = ht[t] << m_reg; 132 | } 133 | if (t & 0x80) 134 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 135 | } 136 | 137 | if (pref & PRE_LOCK) { 138 | if (m_mod == 3) { 139 | hs->flags |= F_ERROR | F_ERROR_LOCK; 140 | } 141 | else { 142 | uint8_t* table_end, op = opcode; 143 | if (hs->opcode2) { 144 | ht = hde64_table + DELTA_OP2_LOCK_OK; 145 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK; 146 | } 147 | else { 148 | ht = hde64_table + DELTA_OP_LOCK_OK; 149 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK; 150 | op &= -2; 151 | } 152 | for (; ht != table_end; ht++) 153 | if (*ht++ == op) { 154 | if (!((*ht << m_reg) & 0x80)) 155 | goto no_lock_error; 156 | else 157 | break; 158 | } 159 | hs->flags |= F_ERROR | F_ERROR_LOCK; 160 | no_lock_error: 161 | ; 162 | } 163 | } 164 | 165 | if (hs->opcode2) { 166 | switch (opcode) { 167 | case 0x20: case 0x22: 168 | m_mod = 3; 169 | if (m_reg > 4 || m_reg == 1) 170 | goto error_operand; 171 | else 172 | goto no_error_operand; 173 | case 0x21: case 0x23: 174 | m_mod = 3; 175 | if (m_reg == 4 || m_reg == 5) 176 | goto error_operand; 177 | else 178 | goto no_error_operand; 179 | } 180 | } 181 | else { 182 | switch (opcode) { 183 | case 0x8c: 184 | if (m_reg > 5) 185 | goto error_operand; 186 | else 187 | goto no_error_operand; 188 | case 0x8e: 189 | if (m_reg == 1 || m_reg > 5) 190 | goto error_operand; 191 | else 192 | goto no_error_operand; 193 | } 194 | } 195 | 196 | if (m_mod == 3) { 197 | uint8_t* table_end; 198 | if (hs->opcode2) { 199 | ht = hde64_table + DELTA_OP2_ONLY_MEM; 200 | table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM; 201 | } 202 | else { 203 | ht = hde64_table + DELTA_OP_ONLY_MEM; 204 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM; 205 | } 206 | for (; ht != table_end; ht += 2) 207 | if (*ht++ == opcode) { 208 | if (*ht++ & pref && !((*ht << m_reg) & 0x80)) 209 | goto error_operand; 210 | else 211 | break; 212 | } 213 | goto no_error_operand; 214 | } 215 | else if (hs->opcode2) { 216 | switch (opcode) { 217 | case 0x50: case 0xd7: case 0xf7: 218 | if (pref & (PRE_NONE | PRE_66)) 219 | goto error_operand; 220 | break; 221 | case 0xd6: 222 | if (pref & (PRE_F2 | PRE_F3)) 223 | goto error_operand; 224 | break; 225 | case 0xc5: 226 | goto error_operand; 227 | } 228 | goto no_error_operand; 229 | } 230 | else 231 | goto no_error_operand; 232 | 233 | error_operand: 234 | hs->flags |= F_ERROR | F_ERROR_OPERAND; 235 | no_error_operand: 236 | 237 | c = *p++; 238 | if (m_reg <= 1) { 239 | if (opcode == 0xf6) 240 | cflags |= C_IMM8; 241 | else if (opcode == 0xf7) 242 | cflags |= C_IMM_P66; 243 | } 244 | 245 | switch (m_mod) { 246 | case 0: 247 | if (pref & PRE_67) { 248 | if (m_rm == 6) 249 | disp_size = 2; 250 | } 251 | else 252 | if (m_rm == 5) 253 | disp_size = 4; 254 | break; 255 | case 1: 256 | disp_size = 1; 257 | break; 258 | case 2: 259 | disp_size = 2; 260 | if (!(pref & PRE_67)) 261 | disp_size <<= 1; 262 | } 263 | 264 | if (m_mod != 3 && m_rm == 4) { 265 | hs->flags |= F_SIB; 266 | p++; 267 | hs->sib = c; 268 | hs->sib_scale = c >> 6; 269 | hs->sib_index = (c & 0x3f) >> 3; 270 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1)) 271 | disp_size = 4; 272 | } 273 | 274 | p--; 275 | switch (disp_size) { 276 | case 1: 277 | hs->flags |= F_DISP8; 278 | hs->disp.disp8 = *p; 279 | break; 280 | case 2: 281 | hs->flags |= F_DISP16; 282 | hs->disp.disp16 = *(uint16_t*)p; 283 | break; 284 | case 4: 285 | hs->flags |= F_DISP32; 286 | hs->disp.disp32 = *(uint32_t*)p; 287 | } 288 | p += disp_size; 289 | } 290 | else if (pref & PRE_LOCK) 291 | hs->flags |= F_ERROR | F_ERROR_LOCK; 292 | 293 | if (cflags & C_IMM_P66) { 294 | if (cflags & C_REL32) { 295 | if (pref & PRE_66) { 296 | hs->flags |= F_IMM16 | F_RELATIVE; 297 | hs->imm.imm16 = *(uint16_t*)p; 298 | p += 2; 299 | goto disasm_done; 300 | } 301 | goto rel32_ok; 302 | } 303 | if (op64) { 304 | hs->flags |= F_IMM64; 305 | hs->imm.imm64 = *(uint64_t*)p; 306 | p += 8; 307 | } 308 | else if (!(pref & PRE_66)) { 309 | hs->flags |= F_IMM32; 310 | hs->imm.imm32 = *(uint32_t*)p; 311 | p += 4; 312 | } 313 | else 314 | goto imm16_ok; 315 | } 316 | 317 | if (cflags & C_IMM16) { 318 | imm16_ok: 319 | hs->flags |= F_IMM16; 320 | hs->imm.imm16 = *(uint16_t*)p; 321 | p += 2; 322 | } 323 | if (cflags & C_IMM8) { 324 | hs->flags |= F_IMM8; 325 | hs->imm.imm8 = *p++; 326 | } 327 | 328 | if (cflags & C_REL32) { 329 | rel32_ok: 330 | hs->flags |= F_IMM32 | F_RELATIVE; 331 | hs->imm.imm32 = *(uint32_t*)p; 332 | p += 4; 333 | } 334 | else if (cflags & C_REL8) { 335 | hs->flags |= F_IMM8 | F_RELATIVE; 336 | hs->imm.imm8 = *p++; 337 | } 338 | 339 | disasm_done: 340 | 341 | if ((hs->len = (uint8_t)(p - (uint8_t*)code)) > 15) { 342 | hs->flags |= F_ERROR | F_ERROR_LENGTH; 343 | hs->len = 15; 344 | } 345 | 346 | return (unsigned int)hs->len; 347 | } 348 | 349 | #endif // defined(_M_X64) || defined(__x86_64__) -------------------------------------------------------------------------------- /dependencies/interfaces/i_material_system.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../source-sdk/structs/materials.hpp" 3 | #define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name 4 | #define MAXSTUDIOSKINS 32 5 | 6 | // These are given to FindMaterial to reference the texture groups that Show up on the 7 | #define TEXTURE_GROUP_LIGHTMAP "Lightmaps" 8 | #define TEXTURE_GROUP_WORLD "World textures" 9 | #define TEXTURE_GROUP_MODEL "Model textures" 10 | #define TEXTURE_GROUP_VGUI "VGUI textures" 11 | #define TEXTURE_GROUP_PARTICLE "Particle textures" 12 | #define TEXTURE_GROUP_DECAL "Decal textures" 13 | #define TEXTURE_GROUP_SKYBOX "SkyBox textures" 14 | #define TEXTURE_GROUP_CLIENT_EFFECTS "ClientEffect textures" 15 | #define TEXTURE_GROUP_OTHER "Other textures" 16 | #define TEXTURE_GROUP_PRECACHED "Precached" 17 | #define TEXTURE_GROUP_CUBE_MAP "CubeMap textures" 18 | #define TEXTURE_GROUP_RENDER_TARGET "RenderTargets" 19 | #define TEXTURE_GROUP_UNACCOUNTED "Unaccounted textures" 20 | //#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER "Static Vertex" 21 | #define TEXTURE_GROUP_STATIC_INDEX_BUFFER "Static Indices" 22 | #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_DISP "Displacement Verts" 23 | #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_COLOR "Lighting Verts" 24 | #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_WORLD "World Verts" 25 | #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_MODELS "Model Verts" 26 | #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_OTHER "Other Verts" 27 | #define TEXTURE_GROUP_DYNAMIC_INDEX_BUFFER "Dynamic Indices" 28 | #define TEXTURE_GROUP_DYNAMIC_VERTEX_BUFFER "Dynamic Verts" 29 | #define TEXTURE_GROUP_DEPTH_BUFFER "DepthBuffer" 30 | #define TEXTURE_GROUP_VIEW_MODEL "ViewModel" 31 | #define TEXTURE_GROUP_PIXEL_SHADERS "Pixel Shaders" 32 | #define TEXTURE_GROUP_VERTEX_SHADERS "Vertex Shaders" 33 | #define TEXTURE_GROUP_RENDER_TARGET_SURFACE "RenderTarget Surfaces" 34 | #define TEXTURE_GROUP_MORPH_TARGETS "Morph Targets" 35 | 36 | //----------------------------------------------------------------------------- 37 | // forward declarations 38 | //----------------------------------------------------------------------------- 39 | class IMaterial; 40 | class IMesh; 41 | class IVertexBuffer; 42 | class IIndexBuffer; 43 | struct MaterialSystem_Config_t; 44 | class VMatrix; 45 | class matrix3x4_t; 46 | class ITexture; 47 | struct MaterialSystemHWID_t; 48 | class KeyValues; 49 | class IShader; 50 | class IVertexTexture; 51 | class IMorph; 52 | class IMatRenderContext; 53 | class ICallQueue; 54 | struct MorphWeight_t; 55 | class IFileList; 56 | struct VertexStreamSpec_t; 57 | struct ShaderStencilState_t; 58 | struct MeshInstanceData_t; 59 | class IClientMaterialSystem; 60 | class CPaintMaterial; 61 | class IPaintMapDataManager; 62 | class IPaintMapTextureManager; 63 | class GPUMemoryStats; 64 | struct AspectRatioInfo_t; 65 | struct CascadedShadowMappingState_t; 66 | 67 | class IMaterialProxyFactory; 68 | class ITexture; 69 | class IMaterialSystemHardwareConfig; 70 | class CShadowMgr; 71 | 72 | enum CompiledVtfFlags 73 | { 74 | TEXTUREFLAGS_POINTSAMPLE = 0x00000001, 75 | TEXTUREFLAGS_TRILINEAR = 0x00000002, 76 | TEXTUREFLAGS_CLAMPS = 0x00000004, 77 | TEXTUREFLAGS_CLAMPT = 0x00000008, 78 | TEXTUREFLAGS_ANISOTROPIC = 0x00000010, 79 | TEXTUREFLAGS_HINT_DXT5 = 0x00000020, 80 | TEXTUREFLAGS_PWL_CORRECTED = 0x00000040, 81 | TEXTUREFLAGS_NORMAL = 0x00000080, 82 | TEXTUREFLAGS_NOMIP = 0x00000100, 83 | TEXTUREFLAGS_NOLOD = 0x00000200, 84 | TEXTUREFLAGS_ALL_MIPS = 0x00000400, 85 | TEXTUREFLAGS_PROCEDURAL = 0x00000800, 86 | TEXTUREFLAGS_ONEBITALPHA = 0x00001000, 87 | TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000, 88 | TEXTUREFLAGS_ENVMAP = 0x00004000, 89 | TEXTUREFLAGS_RENDERTARGET = 0x00008000, 90 | TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000, 91 | TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000, 92 | TEXTUREFLAGS_SINGLECOPY = 0x00040000, 93 | TEXTUREFLAGS_PRE_SRGB = 0x00080000, 94 | TEXTUREFLAGS_UNUSED_00100000 = 0x00100000, 95 | TEXTUREFLAGS_UNUSED_00200000 = 0x00200000, 96 | TEXTUREFLAGS_UNUSED_00400000 = 0x00400000, 97 | TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000, 98 | TEXTUREFLAGS_UNUSED_01000000 = 0x01000000, 99 | TEXTUREFLAGS_CLAMPU = 0x02000000, 100 | TEXTUREFLAGS_VERTEXTEXTURE = 0x04000000, 101 | TEXTUREFLAGS_SSBUMP = 0x08000000, 102 | TEXTUREFLAGS_UNUSED_10000000 = 0x10000000, 103 | TEXTUREFLAGS_BORDER = 0x20000000, 104 | TEXTUREFLAGS_UNUSED_40000000 = 0x40000000, 105 | TEXTUREFLAGS_UNUSED_80000000 = 0x80000000 106 | }; 107 | 108 | enum StandardLightmap_t 109 | { 110 | MATERIAL_SYSTEM_LIGHTMAP_PAGE_WHITE = -1, 111 | MATERIAL_SYSTEM_LIGHTMAP_PAGE_WHITE_BUMP = -2, 112 | MATERIAL_SYSTEM_LIGHTMAP_PAGE_USER_DEFINED = -3 113 | }; 114 | 115 | struct MaterialSystem_SortInfo_t 116 | { 117 | IMaterial* material; 118 | int lightmapPageID; 119 | }; 120 | 121 | enum MaterialThreadMode_t 122 | { 123 | MATERIAL_SINGLE_THREADED, 124 | MATERIAL_QUEUED_SINGLE_THREADED, 125 | MATERIAL_QUEUED_THREADED 126 | }; 127 | 128 | enum MaterialContextType_t 129 | { 130 | MATERIAL_HARDWARE_CONTEXT, 131 | MATERIAL_QUEUED_CONTEXT, 132 | MATERIAL_NULL_CONTEXT 133 | }; 134 | 135 | enum 136 | { 137 | MATERIAL_ADAPTER_NAME_LENGTH = 512 138 | }; 139 | 140 | struct MaterialTextureInfo_t 141 | { 142 | int iExcludeInformation; 143 | }; 144 | 145 | struct ApplicationPerformanceCountersInfo_t 146 | { 147 | float msMain; 148 | float msMST; 149 | float msGPU; 150 | float msFlip; 151 | float msTotal; 152 | }; 153 | 154 | struct ApplicationInstantCountersInfo_t 155 | { 156 | uint32_t m_nCpuActivityMask; 157 | uint32_t m_nDeferredWordsAllocated; 158 | }; 159 | struct MaterialAdapterInfo_t 160 | { 161 | char m_pDriverName[MATERIAL_ADAPTER_NAME_LENGTH]; 162 | unsigned int m_VendorID; 163 | unsigned int m_DeviceID; 164 | unsigned int m_SubSysID; 165 | unsigned int m_Revision; 166 | int m_nDXSupportLevel; // This is the *preferred* dx support level 167 | int m_nMinDXSupportLevel; 168 | int m_nMaxDXSupportLevel; 169 | unsigned int m_nDriverVersionHigh; 170 | unsigned int m_nDriverVersionLow; 171 | }; 172 | 173 | struct MaterialVideoMode_t 174 | { 175 | int m_Width; // if width and height are 0 and you select 176 | int m_Height; // windowed mode, it'll use the window size 177 | ImageFormat m_Format; // use ImageFormats (ignored for windowed mode) 178 | int m_RefreshRate; // 0 == default (ignored for windowed mode) 179 | }; 180 | enum HDRType_t 181 | { 182 | HDR_TYPE_NONE, 183 | HDR_TYPE_INTEGER, 184 | HDR_TYPE_FLOAT, 185 | }; 186 | 187 | enum RestoreChangeFlags_t 188 | { 189 | MATERIAL_RESTORE_VERTEX_FORMAT_CHANGED = 0x1, 190 | MATERIAL_RESTORE_RELEASE_MANAGED_RESOURCES = 0x2, 191 | }; 192 | 193 | enum RenderTargetSizeMode_t 194 | { 195 | RT_SIZE_NO_CHANGE = 0, 196 | RT_SIZE_DEFAULT = 1, 197 | RT_SIZE_PICMIP = 2, 198 | RT_SIZE_HDR = 3, 199 | RT_SIZE_FULL_FRAME_BUFFER = 4, 200 | RT_SIZE_OFFSCREEN = 5, 201 | RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP = 6 202 | }; 203 | 204 | enum MaterialRenderTargetDepth_t 205 | { 206 | MATERIAL_RT_DEPTH_SHARED = 0x0, 207 | MATERIAL_RT_DEPTH_SEPARATE = 0x1, 208 | MATERIAL_RT_DEPTH_NONE = 0x2, 209 | MATERIAL_RT_DEPTH_ONLY = 0x3, 210 | }; 211 | 212 | typedef void(*MaterialBufferReleaseFunc_t)(int nChangeFlags); // see RestoreChangeFlags_t 213 | typedef void(*MaterialBufferRestoreFunc_t)(int nChangeFlags); // see RestoreChangeFlags_t 214 | typedef void(*ModeChangeCallbackFunc_t)(void); 215 | typedef void(*EndFrameCleanupFunc_t)(void); 216 | typedef bool(*EndFramePriorToNextContextFunc_t)(void); 217 | typedef void(*OnLevelShutdownFunc_t)(void* pUserData); 218 | 219 | typedef unsigned short MaterialHandle_t; 220 | DECLARE_POINTER_HANDLE(MaterialLock_t); 221 | 222 | class i_material_system { 223 | public: 224 | i_material* find_material(char const* material_name, const char* group_name, bool complain = true, const char* complain_prefix = 0) { 225 | using original_fn = i_material * (__thiscall*)(i_material_system*, char const*, const char*, bool, const char*); 226 | return (*(original_fn * *)this)[84](this, material_name, group_name, complain, complain_prefix); 227 | } 228 | material_handle_t first_material() { 229 | using original_fn = material_handle_t(__thiscall*)(i_material_system*); 230 | return (*(original_fn * *)this)[86](this); 231 | } 232 | material_handle_t next_material(material_handle_t handle) { 233 | using original_fn = material_handle_t(__thiscall*)(i_material_system*, material_handle_t); 234 | return (*(original_fn * *)this)[87](this, handle); 235 | } 236 | material_handle_t invalid_material_handle() { 237 | using original_fn = material_handle_t(__thiscall*)(i_material_system*); 238 | return (*(original_fn * *)this)[88](this); 239 | } 240 | i_material* get_material(material_handle_t handle) { 241 | using original_fn = i_material * (__thiscall*)(i_material_system*, material_handle_t); 242 | return (*(original_fn * *)this)[89](this, handle); 243 | } 244 | int get_materials_count() { 245 | using original_fn = int(__thiscall*)(i_material_system*); 246 | return (*(original_fn * *)this)[90](this); 247 | } 248 | }; -------------------------------------------------------------------------------- /dependencies/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 | } while (!finished); 284 | 285 | // Is there enough place for a long jump? 286 | if (oldPos < sizeof(JMP_REL) 287 | && !IsCodePadding((LPBYTE)ct->pTarget + oldPos, sizeof(JMP_REL) - oldPos)) 288 | { 289 | // Is there enough place for a short jump? 290 | if (oldPos < sizeof(JMP_REL_SHORT) 291 | && !IsCodePadding((LPBYTE)ct->pTarget + oldPos, sizeof(JMP_REL_SHORT) - oldPos)) 292 | { 293 | return FALSE; 294 | } 295 | 296 | // Can we place the long jump above the function? 297 | if (!IsExecutableAddress((LPBYTE)ct->pTarget - sizeof(JMP_REL))) 298 | return FALSE; 299 | 300 | if (!IsCodePadding((LPBYTE)ct->pTarget - sizeof(JMP_REL), sizeof(JMP_REL))) 301 | return FALSE; 302 | 303 | ct->patchAbove = TRUE; 304 | } 305 | 306 | #if defined(_M_X64) || defined(__x86_64__) 307 | // Create a relay function. 308 | jmp.address = (ULONG_PTR)ct->pDetour; 309 | 310 | ct->pRelay = (LPBYTE)ct->pTrampoline + newPos; 311 | memcpy(ct->pRelay, &jmp, sizeof(jmp)); 312 | #endif 313 | 314 | return TRUE; 315 | } --------------------------------------------------------------------------------