├── deadlock ├── source │ ├── pch │ │ ├── pch.cpp │ │ └── pch.hpp │ ├── valve │ │ ├── structs │ │ │ ├── entities │ │ │ │ ├── base_player.inl │ │ │ │ ├── base_entity.cpp │ │ │ │ ├── base_entity.inl │ │ │ │ ├── handle_entity.inl │ │ │ │ ├── handle_entity.hpp │ │ │ │ ├── base_player.cpp │ │ │ │ ├── base_entity.hpp │ │ │ │ └── base_player.hpp │ │ │ └── data_types │ │ │ │ ├── utl │ │ │ │ ├── utl_memory_pool.hpp │ │ │ │ ├── utl_hash.hpp │ │ │ │ ├── utl_memory.inl │ │ │ │ └── utl_hash.inl │ │ │ │ └── handle │ │ │ │ ├── handle.inl │ │ │ │ └── handle.hpp │ │ ├── interfaces │ │ │ ├── citadel_input │ │ │ │ ├── citadel_input.inl │ │ │ │ └── citadel_input.hpp │ │ │ ├── mem_alloc │ │ │ │ └── mem_alloc.hpp │ │ │ ├── schema_system │ │ │ │ ├── schema_system.inl │ │ │ │ └── schema_system.hpp │ │ │ └── entity_system │ │ │ │ ├── entity_system.inl │ │ │ │ └── entity_system.hpp │ │ ├── entity_utils │ │ │ ├── entity_utils.inl │ │ │ ├── entity_utils.cpp │ │ │ └── entity_utils.hpp │ │ └── net_vars │ │ │ ├── net_vars.inl │ │ │ └── net_vars.hpp │ ├── core │ │ ├── ui │ │ │ ├── ui.inl │ │ │ ├── ui.hpp │ │ │ └── ui.cpp │ │ └── hooks │ │ │ ├── detours │ │ │ ├── client.cpp │ │ │ └── game_overlay_renderer.cpp │ │ │ └── hooks.hpp │ ├── systems │ │ ├── input │ │ │ ├── input.inl │ │ │ ├── input.hpp │ │ │ └── input.cpp │ │ ├── module_parser │ │ │ ├── module_parser.cpp │ │ │ ├── module_parser.hpp │ │ │ ├── module_parser.inl │ │ │ └── ldr_module │ │ │ │ ├── ldr_module.hpp │ │ │ │ └── ldr_module.inl │ │ ├── render │ │ │ ├── render.hpp │ │ │ ├── render.inl │ │ │ └── render.cpp │ │ ├── hooker │ │ │ ├── hooker.inl │ │ │ └── hooker.hpp │ │ └── logger │ │ │ ├── logger.inl │ │ │ └── logger.hpp │ ├── utils │ │ ├── memory │ │ │ ├── memory.hpp │ │ │ └── base_address │ │ │ │ ├── base_address.inl │ │ │ │ └── base_address.hpp │ │ ├── hash │ │ │ └── hash.hpp │ │ └── math │ │ │ └── data_types │ │ │ └── vector.hpp │ ├── bootstrap.cpp │ └── vendor.hpp ├── cpp.hint ├── third_party │ ├── imgui │ │ ├── imgui_impl_dx11.h │ │ ├── imgui_impl_win32.h │ │ └── imconfig.h │ └── minhk │ │ ├── hde │ │ ├── pstdint.hpp │ │ ├── hde32.hpp │ │ ├── hde64.hpp │ │ ├── table32.hpp │ │ └── table64.hpp │ │ ├── buffer.hpp │ │ ├── trampoline.hpp │ │ └── minhook.hpp └── deadlock.vcxproj.filters ├── deadlock.sln.DotSettings ├── deadlock.sln ├── LICENSE.txt ├── README.md ├── .gitattributes ├── .clang-format └── .gitignore /deadlock/source/pch/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/base_player.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base_player.hpp" 3 | 4 | namespace hack::valve::inline entities { 5 | 6 | 7 | } // namespace hack::cs2::inline entities -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/citadel_input/citadel_input.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "citadel_input.hpp" 3 | 4 | namespace hack::valve::inline interfaces { 5 | _INLINE void citadel_input_t::set_view_angles( utils::vec3_t &angles ) noexcept { 6 | return g_set_view_angles( this, 0, &angles ); 7 | } 8 | } // namespace hack::valve::inline interfaces -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/base_entity.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "base_entity.hpp" 4 | #include "base_player.hpp" 5 | #include "valve/entity_utils/entity_utils.hpp" 6 | 7 | namespace hack::valve::inline entities { 8 | bool entity_t::is_enemy( ) noexcept { 9 | return true; 10 | } 11 | } // namespace hack::valve::inline entities -------------------------------------------------------------------------------- /deadlock/cpp.hint: -------------------------------------------------------------------------------- 1 | #define _OFFSET(add_offset, var, treturn, __VA_ARGS__) [[nodiscard]] _INLINE std::add_lvalue_reference_t< treturn __VA_OPT__(, ) __VA_ARGS__ > var( ) const noexcept { return *utils::base_address_t { this }.offset( add_offset ).as< std::add_pointer_t< treturn __VA_OPT__(, ) __VA_ARGS__ > >( ); } 2 | #define _HOOK(hooker, func) using fn_##func = decltype( &func ); fn_##func m_orig_##func = hack::systems::hook_impl< fn_##func >( _HASH( #hooker ), hooker, reinterpret_cast< void * >( func ) ); 3 | -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/base_entity.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base_entity.hpp" 3 | 4 | namespace hack::valve::inline entities { 5 | _INLINE bool entity_t::is_player_pawn( ) const noexcept { 6 | return is_class( _HASH( "C_CitadelPlayerPawn" ) ); 7 | } 8 | 9 | _INLINE bool entity_t::is_player_controller( ) const noexcept { 10 | return is_class( _HASH( "CCitadelPlayerController" ) ); 11 | } 12 | 13 | _INLINE bool entity_t::is_modifier_invis( ) const noexcept { 14 | return is_class( _HASH( "CCitadel_Modifier_Invis" ) ); 15 | } 16 | } // namespace hack::cs2::inline entities 17 | -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/mem_alloc/mem_alloc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace hack::valve::inline interfaces { 4 | inline const auto g_alloc_func = systems::get_export< fastcall_t< void *, std::size_t > >( "tier0.dll", "MemAlloc_AllocFunc" ); 5 | inline const auto g_realloc_func 6 | = systems::get_export< fastcall_t< void *, void *, std::size_t > >( "tier0.dll", "MemAlloc_ReallocFunc" ); 7 | inline const auto g_free_func = systems::get_export< fastcall_t< void, void *> >( "tier0.dll", "MemAlloc_FreeFunc" ); 8 | inline const auto g_str_dup_func = systems::get_export< fastcall_t< char *, const char * > >( "tier0.dll", "MemAlloc_StrDupFunc" ); 9 | } // namespace hack::valve::inline interfaces -------------------------------------------------------------------------------- /deadlock/source/core/ui/ui.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ui.hpp" 3 | 4 | namespace hack::core { 5 | _INLINE ui_t::ui_t( ) noexcept { 6 | auto &style { ImGui::GetStyle( ) }; 7 | 8 | style.AntiAliasedFill = false; 9 | style.AntiAliasedLines = false; 10 | style.WindowRounding = 0.0f; 11 | style.ChildRounding = 6.f; 12 | style.PopupRounding = 2.f; 13 | style.FrameRounding = 2.f; 14 | style.ScrollbarRounding = 2.f; 15 | style.GrabRounding = 2.f; 16 | style.TabRounding = 2.f; 17 | 18 | ImGui::StyleColorsDark( ); ///< Set a dark theme by default 19 | } 20 | 21 | _INLINE bool &ui_t::opened( ) noexcept { 22 | return m_opened; 23 | } 24 | } // namespace hack::core 25 | -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/handle_entity.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "handle_entity.hpp" 3 | 4 | namespace hack::valve::inline entities { 5 | _INLINE auto i_handle_entity_t::game_get_ent_class_info( void *, class_info_t **ret ) const noexcept { 6 | return hack::utils::get_virtual< void >( 36, this, &ret ); 7 | } 8 | 9 | _INLINE interfaces::class_info_t *i_handle_entity_t::get_class_info( ) const noexcept { 10 | interfaces::class_info_t *ret { }; 11 | hack::utils::get_virtual< void >( 38, this, &ret ); 12 | return ret; 13 | } 14 | 15 | bool i_handle_entity_t::is_class( const std::size_t name_hash ) const noexcept { 16 | const auto class_info { get_class_info( ) }; 17 | return class_info ? _HASH( class_info->m_name ) == name_hash : false; 18 | } 19 | } // namespace hack::valve::inline entities -------------------------------------------------------------------------------- /deadlock/source/core/ui/ui.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imgui/imgui.h" 3 | #include "vendor.hpp" 4 | 5 | namespace hack::core { 6 | /** 7 | * @brief Structure representing the core UI. 8 | */ 9 | struct ui_t { 10 | /** 11 | * @brief Initializes the UI components and sets up the layout. 12 | */ 13 | _INLINE ui_t( ) noexcept; 14 | 15 | _INLINE bool &opened( ) noexcept; 16 | 17 | /** 18 | * @brief Renders the main menu interface. 19 | */ 20 | void render( ) const noexcept; 21 | 22 | /** 23 | * @brief Cleans up UI resources if needed. 24 | */ 25 | static void cleanup( ) noexcept; 26 | 27 | private: 28 | bool m_opened { }; 29 | }; 30 | 31 | inline auto g_ui { std::unique_ptr< ui_t > {} }; 32 | } // namespace hack::core 33 | 34 | #include "ui.inl" -------------------------------------------------------------------------------- /deadlock/source/valve/structs/data_types/utl/utl_memory_pool.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace hack::valve::inline data_types { 4 | class utl_memory_pool_t { 5 | public: 6 | struct free_list_t { 7 | free_list_t *m_next{ }, *m_prev{ }; 8 | void* m_data{ }; 9 | }; 10 | 11 | struct blob_t { 12 | blob_t* m_next_blob{ }; 13 | std::int32_t m_num_bytes{ }; 14 | free_list_t m_free_list[ 1 ] = { }; 15 | }; 16 | 17 | int m_block_size{ }, m_blocks_per_blob{ }, m_grow_mode{ }, m_blocks_allocated{ }, m_peak_alloc{ }; 18 | std::uint16_t m_alignment{ }, m_num_blobs{ }; 19 | free_list_t *m_head_of_free_list{ }, *m_free_list{ }; 20 | blob_t *m_last_blob{ }, *m_first_blob{ }; 21 | int m_mem_alloc_attribute{ }; 22 | std::uint8_t m_unknown{ }; 23 | }; 24 | } // namespace hack::cs2::inline data_types -------------------------------------------------------------------------------- /deadlock.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True 4 | True 5 | True 6 | True 7 | True 8 | True -------------------------------------------------------------------------------- /deadlock/source/valve/structs/data_types/handle/handle.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "handle.hpp" 3 | 4 | namespace hack::valve::inline data_types { 5 | _INLINE constexpr void c_handle::set_index( const std::uint32_t index ) { 6 | m_index = index; 7 | } 8 | 9 | _INLINE constexpr bool c_handle::is_valid( ) const noexcept { 10 | return m_index != k_invalid_ehandle_index; 11 | } 12 | 13 | _INLINE constexpr int c_handle::get_index( ) const noexcept { 14 | return is_valid( ) ? static_cast< int >( m_index & k_ent_entry_mask ) : 0; 15 | } 16 | 17 | _INLINE constexpr std::uint32_t c_handle::get_int( ) const noexcept { 18 | return m_index; 19 | } 20 | 21 | _INLINE constexpr bool c_handle::operator== ( const c_handle rhs ) const noexcept { 22 | return m_index == rhs.m_index; 23 | } 24 | 25 | _INLINE constexpr bool c_handle::operator!= ( const c_handle rhs ) const noexcept { 26 | return m_index != rhs.m_index; 27 | } 28 | } // namespace hack::valve::inline data_types -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/handle_entity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../data_types/handle/handle.hpp" 3 | #include "valve/net_vars/net_vars.hpp" 4 | 5 | namespace hack::valve::inline entities { 6 | static inline constexpr std::uint32_t k_num_serial_shift_bits { 0xfu }; 7 | struct entity_identity_t; 8 | 9 | struct i_handle_entity_t { 10 | i_handle_entity_t( ) = delete; 11 | i_handle_entity_t( i_handle_entity_t && ) = delete; 12 | i_handle_entity_t( const i_handle_entity_t & ) = delete; 13 | 14 | NET_VAR( "CEntityInstance", m_pEntity, entity_identity_t * ) 15 | 16 | [[nodiscard]] _INLINE auto game_get_ent_class_info( void *, class_info_t **ret ) const noexcept; 17 | 18 | [[nodiscard]] _INLINE interfaces::class_info_t *get_class_info( ) const noexcept; 19 | 20 | [[nodiscard]] _INLINE bool is_class( const std::size_t name_hash ) const noexcept; 21 | }; 22 | } // namespace hack::valve::inline entities 23 | 24 | #include "handle_entity.inl" -------------------------------------------------------------------------------- /deadlock.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34330.188 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deadlock", "deadlock\deadlock.vcxproj", "{2459ED8D-1EC2-4E70-8F8C-87B18AF0D702}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | debug|x64 = debug|x64 11 | release|x64 = release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2459ED8D-1EC2-4E70-8F8C-87B18AF0D702}.debug|x64.ActiveCfg = dbg|x64 15 | {2459ED8D-1EC2-4E70-8F8C-87B18AF0D702}.debug|x64.Build.0 = dbg|x64 16 | {2459ED8D-1EC2-4E70-8F8C-87B18AF0D702}.release|x64.ActiveCfg = rel|x64 17 | {2459ED8D-1EC2-4E70-8F8C-87B18AF0D702}.release|x64.Build.0 = rel|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {784FDB5C-D4DC-4149-8F45-290BAAA9E739} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /deadlock/source/systems/input/input.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "input.hpp" 3 | 4 | namespace hack::systems { 5 | _INLINE c_input::c_input( const HWND game_window ) noexcept { 6 | m_game_window = game_window; 7 | m_wnd_proc 8 | = reinterpret_cast< WNDPROC >( SetWindowLongPtr( m_game_window, GWLP_WNDPROC, reinterpret_cast< std::intptr_t >( wnd_proc ) ) ); 9 | } 10 | 11 | _INLINE c_input::~c_input( ) noexcept { 12 | SetWindowLongPtr( m_game_window, GWLP_WNDPROC, reinterpret_cast< std::intptr_t >( m_wnd_proc ) ); 13 | 14 | { 15 | const std::unique_lock lock_wnd_proc( m_wnd_proc_mutex ); 16 | 17 | m_wnd_proc = nullptr; 18 | } 19 | 20 | m_game_window = nullptr; 21 | } 22 | 23 | _INLINE void c_input::register_callback( const key_id_t key_id, std::function< void( ) > &&callback ) noexcept { 24 | m_callbacks[ key_id - 1 ] = std::move( callback ); 25 | } 26 | 27 | _INLINE auto c_input::get_hwnd( ) noexcept { 28 | return m_game_window; 29 | } 30 | 31 | _INLINE void c_input::remove_callback( const key_id_t key_id ) noexcept { 32 | m_callbacks[ key_id - 1 ] = nullptr; 33 | } 34 | } // namespace hack::systems -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/schema_system/schema_system.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "schema_system.hpp" 3 | 4 | namespace hack::valve::inline interfaces { 5 | struct class_info_t; 6 | 7 | struct system_type_scope_t { 8 | system_type_scope_t( ) = delete; 9 | system_type_scope_t( system_type_scope_t && ) = delete; 10 | system_type_scope_t( const system_type_scope_t & ) = delete; 11 | 12 | _VFUNC( class_info_t *, find_decl_class( const char *class_name ), 2, this, class_name ) 13 | 14 | _OFFSET( 0x8, get_name, char[ 256 ] ) 15 | _OFFSET( 0x500, get_bindings_table, utl_ts_hash_t< class_info_data_t *, 256 > ) 16 | }; 17 | 18 | struct schema_system_t { 19 | schema_system_t( ) = delete; 20 | schema_system_t( schema_system_t && ) = delete; 21 | schema_system_t( const schema_system_t & ) = delete; 22 | 23 | _VFUNC( system_type_scope_t *, find_type_scope( const char *name, std::uint64_t *unk = nullptr ), 13, this, name, nullptr ) 24 | }; 25 | 26 | inline auto g_schema_system = systems::get_interface< schema_system_t * >( "schemasystem.dll", "SchemaSystem_001" ); 27 | } // namespace hack::valve::inline interfaces 28 | -------------------------------------------------------------------------------- /deadlock/source/systems/module_parser/module_parser.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "module_parser.hpp" 4 | #include "utils/hash/hash.hpp" 5 | 6 | namespace hack::systems::inline memory { 7 | bool module_parser_t::parse_modules( ) noexcept { 8 | const auto *const peb { get_current_teb( )->m_process_environment_block }; 9 | 10 | _ASSERT( peb != nullptr ); 11 | 12 | const auto *const modules_order { &peb->m_ldr->m_in_load_order_module_list }; 13 | 14 | _ASSERT( modules_order != nullptr ); 15 | 16 | for ( const auto *module { modules_order->m_flink }; module != nullptr && module != modules_order; module = module->m_flink ) { 17 | const auto ldr_table { utils::base_address_t { module }.self_offset( 18 | -_OFFSETOF( utils::ldr_data_table_entry, m_in_load_order_links ) ) }; 19 | 20 | if ( !ldr_table ) 21 | continue; 22 | 23 | auto module_record { std::make_unique< ldr_module_t >( ldr_table ) }; 24 | 25 | if ( !module_record ) 26 | continue; 27 | 28 | m_modules_list.try_emplace( _HASH( module_record->get_name( ) ), std::move( module_record ) ); 29 | } 30 | 31 | return !m_modules_list.empty( ); 32 | } 33 | } // namespace hack::systems::inline memory -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/entity_system/entity_system.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "entity_system.hpp" 3 | 4 | namespace hack::valve::inline interfaces { 5 | _INLINE valve::entity_identity_t *game_entity_system_t::get_identity( const int idx ) const noexcept { 6 | if ( idx <= -1 || idx >= ( k_max_total_entities - 1 ) ) 7 | return nullptr; 8 | 9 | const auto chunk_to_use { get_identity_chunks( )[ ( idx / k_max_entities_in_list ) ] }; // equal to ( index >> 9 ) 10 | 11 | if ( !chunk_to_use ) 12 | return nullptr; 13 | 14 | const auto identity { &chunk_to_use->m_identities[ idx % k_max_entities_in_list ] }; // equal to ( index & 1FF ) 15 | if ( !identity ) 16 | return nullptr; 17 | 18 | return identity; 19 | } 20 | 21 | _INLINE entity_identity_t *game_entity_system_t::get_entity( const c_handle ent ) const noexcept { 22 | return get_identity( ent.get_index( ) ); 23 | } 24 | 25 | template < typename type_t > 26 | std::add_pointer_t< type_t > game_entity_system_t::get_entity( const int idx ) noexcept { 27 | if ( const auto identity { get_identity( idx ) }; identity && identity->m_handle.get_index( ) == idx ) { 28 | return std::to_address( identity->m_entity ); 29 | } 30 | return nullptr; 31 | } 32 | } // namespace hack::valve::inline interfaces -------------------------------------------------------------------------------- /deadlock/source/core/hooks/detours/client.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "../hooks.hpp" 4 | #include "valve/entity_utils/entity_utils.hpp" 5 | #include "valve/interfaces/citadel_input/citadel_input.hpp" 6 | 7 | namespace hack::core { 8 | void get_matrices( void *render_game_system, void *view_params, void *world_to_view, void *view_to_projection, 9 | void *world_to_projection, void *world_to_screen ) noexcept { 10 | g_orig_get_matrices( render_game_system, view_params, world_to_view, view_to_projection, world_to_projection, world_to_screen ); 11 | } 12 | 13 | void create_move( valve::citadel_input_t *citadel_input, const int slot, const bool is_active ) { 14 | g_orig_create_move( citadel_input, slot, is_active ); 15 | 16 | const auto local_controller { valve::g_entity_list->get_local_controller( ) }; 17 | if ( !local_controller ) 18 | return g_orig_create_move( citadel_input, slot, is_active ); 19 | 20 | const auto cmd { local_controller->get_cmd( ) }; 21 | if ( !cmd || !cmd->m_base_user_cmd || !cmd->m_camera_angle ) 22 | return g_orig_create_move( citadel_input, slot, is_active ); 23 | 24 | const auto base_cmd { cmd->m_base_user_cmd }; 25 | if ( !base_cmd->m_angle ) 26 | return g_orig_create_move( citadel_input, slot, is_active ); 27 | 28 | // todo: legitbot :) 29 | } 30 | } // namespace hack::core -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/schema_system/schema_system.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "systems/module_parser/module_parser.hpp" 3 | #include "utils/memory/memory.hpp" 4 | #include "valve/structs/data_types/utl/utl_hash.hpp" 5 | 6 | namespace hack::valve::inline interfaces { 7 | struct class_field_t; 8 | struct class_info_t; 9 | 10 | struct [[nodiscard]] base_class_info_data_t { 11 | std::int32_t m_offset { }; 12 | class_info_t *m_class { }; 13 | }; 14 | 15 | struct base_class_info_t : base_class_info_data_t { }; 16 | 17 | struct class_info_data_t { 18 | _PAD( 0x8 ) 19 | const char *m_name { }, *m_description { }; 20 | std::int32_t m_size_of { }; 21 | std::uint8_t m_fields_count { }; 22 | _PAD( 0x5 ) 23 | std::uint8_t m_align_of { }, m_base_classes_count { }; 24 | _PAD( 0x4 ) 25 | class_field_t *m_fields { }; 26 | _PAD( 0x8 ) 27 | base_class_info_t *m_base_classes { }; 28 | _PAD( 0x28 ) 29 | }; 30 | 31 | struct class_info_t : class_info_data_t { }; 32 | 33 | struct [[nodiscard]] class_field_data_t { 34 | const char *m_name { }; 35 | _PAD( 0x8 ) 36 | std::int32_t m_offset { }; 37 | _PAD( 0xC ) 38 | }; 39 | 40 | struct class_field_t : class_field_data_t { 41 | public: 42 | }; 43 | } // namespace hack::valve::inline interfaces 44 | 45 | #include "schema_system.inl" -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/base_player.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "base_player.hpp" 4 | #include "valve/entity_utils/entity_utils.hpp" 5 | #include "valve/interfaces/citadel_input/citadel_input.hpp" 6 | #include "valve/interfaces/entity_system/entity_system.hpp" 7 | 8 | namespace hack::valve::inline entities { 9 | inline const auto g_get_index 10 | = systems::get_pattern< fastcall_t< void, void *, void * > >( "client.dll", "40 53 48 83 EC 20 4C 8B 41 10 48 8B DA" ); 11 | 12 | user_cmd_pb_t *player_controller_t::get_cmd( ) const noexcept { 13 | const auto local_controller { g_entity_list->get_local_controller( ) }; 14 | if ( !local_controller || local_controller != this ) 15 | return { }; 16 | 17 | int index { }; 18 | g_get_index( local_controller, &index ); 19 | 20 | std::intptr_t corrected_index; 21 | if ( index != -1 ) { 22 | if ( static_cast< std::uint32_t >( index - 1 ) > k_max_entity_lists - 1 ) 23 | return { }; 24 | 25 | corrected_index = static_cast< std::uint32_t >( index - 1 ); 26 | } else { 27 | corrected_index = 0xFFFFFFFF; 28 | } 29 | 30 | const auto base_cmd_ptr { *utils::base_address_t { g_cmd_base }.offset( corrected_index * 0x8 ).as< base_user_cmd_t ** >( ) }; 31 | return g_get_user_cmd( local_controller, *utils::base_address_t { base_cmd_ptr }.offset( 21136 ).as< std::uint32_t * >( ) ); 32 | } 33 | } // namespace hack::valve::inline entities -------------------------------------------------------------------------------- /deadlock/source/utils/memory/memory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base_address/base_address.hpp" 3 | 4 | #define _OFFSET( add_offset, var, treturn, ... ) \ 5 | [[nodiscard]] _INLINE std::add_lvalue_reference_t< treturn __VA_OPT__(, ) __VA_ARGS__ > var( ) const noexcept { \ 6 | return *utils::base_address_t { this }.offset( add_offset ).as< std::add_pointer_t< treturn __VA_OPT__(, ) __VA_ARGS__ > >( ); \ 7 | } 8 | 9 | #define _VFUNC( ret_type, name, index, ... ) \ 10 | [[nodiscard]] _INLINE constexpr auto name const noexcept { \ 11 | return hack::utils::get_virtual< ret_type >( index, __VA_ARGS__ ); \ 12 | } 13 | 14 | namespace hack::utils::inline memory { 15 | /** 16 | * Retrieves the function pointer at the specified index in the virtual function table 17 | * @tparam T Integral type 18 | * @param base Base address of the vtable 19 | * @param args Argument list 20 | * @param index Index of the function pointer in the vtable 21 | * @return Function call 22 | */ 23 | template < typename T, typename... args_t > 24 | _INLINE T get_virtual( const std::uint32_t index, const void *base, args_t... args ) noexcept { 25 | const auto vtable { *reinterpret_cast< fastcall_t< T, void *, args_t... > ** >( const_cast< void * >( base ) ) }; 26 | return vtable[ index ]( const_cast< void * >( base ), args... ); 27 | } 28 | } // namespace hack::utils::inline memory -------------------------------------------------------------------------------- /deadlock/source/core/ui/ui.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "ui.hpp" 4 | 5 | namespace hack::core { 6 | void ui_t::render( ) const noexcept { 7 | if ( !m_opened ) 8 | return; 9 | 10 | ImGui::SetNextWindowSize( { 630, 460 } ); 11 | 12 | // Begin rendering a simple main menu 13 | ImGui::Begin( "Hack Menu" ); 14 | 15 | // Display tabs or main options 16 | if ( ImGui::CollapsingHeader( "Settings" ) ) { 17 | ImGui::Text( "Configuration Settings" ); 18 | 19 | static auto feature_enabled { false }; 20 | ImGui::Checkbox( "Enable Feature", &feature_enabled ); 21 | 22 | static auto slider_value { 0.5f }; 23 | ImGui::SliderFloat( "Intensity", &slider_value, 0.0f, 1.0f, "%.2f" ); 24 | 25 | static auto choice { 0 }; 26 | const char *items[] = { "Option 1", "Option 2", "Option 3" }; 27 | ImGui::Combo( "Choose Option", &choice, items, IM_ARRAYSIZE( items ) ); 28 | } 29 | 30 | if ( ImGui::CollapsingHeader( "Debug Tools" ) ) { 31 | ImGui::Text( "Debugging Options" ); 32 | static auto show_metrics { false }; 33 | ImGui::Checkbox( "Show Metrics Window", &show_metrics ); 34 | 35 | if ( show_metrics ) { 36 | ImGui::ShowMetricsWindow( &show_metrics ); 37 | } 38 | } 39 | 40 | ImGui::End( ); 41 | } 42 | 43 | void ui_t::cleanup( ) noexcept { 44 | // todo: cleanup resources if necessary 45 | } 46 | } // namespace hack::core 47 | -------------------------------------------------------------------------------- /deadlock/source/valve/entity_utils/entity_utils.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "entity_utils.hpp" 3 | 4 | namespace hack::valve { 5 | _INLINE c_entity_list::c_entity_list( ) { 6 | m_entities.reserve( k_ent_entry_mask ); 7 | m_player_pawns.reserve( k_max_entity_lists ); 8 | m_player_controllers.reserve( k_max_entity_lists ); 9 | 10 | m_entity_system->get_listeners( ).add_to_head( &m_entity_listener ); 11 | 12 | for ( int idx { }; idx <= m_entity_system->get_highest_entity_index( ); ++idx ) { 13 | const auto entity_instance { m_entity_system->get_entity( idx ) }; 14 | if ( !entity_instance ) 15 | continue; 16 | 17 | add_entity( entity_instance ); 18 | } 19 | 20 | sort( ); 21 | }; 22 | 23 | _INLINE c_entity_list::~c_entity_list( ) noexcept { 24 | m_entity_system->get_listeners( ).find_and_remove( &m_entity_listener ); 25 | } 26 | 27 | _INLINE std::span< entity_t *const > c_entity_list::get_entities( ) const noexcept { 28 | return m_entities; 29 | } 30 | 31 | _INLINE std::span< player_pawn_t *const > c_entity_list::get_player_pawns( ) const noexcept { 32 | return m_player_pawns; 33 | } 34 | 35 | _INLINE std::span< player_controller_t *const > c_entity_list::get_player_controllers( ) const noexcept { 36 | return m_player_controllers; 37 | } 38 | 39 | _INLINE player_controller_t *c_entity_list::get_local_controller( ) noexcept { 40 | return g_get_player_controller_by_id( -1 ); 41 | } 42 | } // namespace hack::valve -------------------------------------------------------------------------------- /deadlock/source/utils/hash/hash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vendor.hpp" 4 | 5 | #define _HASH \ 6 | ::hack::utils::c_string_hash< std::string_view > { } 7 | 8 | namespace hack::utils { 9 | template < typename string_type > 10 | requires is_any_of< string_type, char, wchar_t, std::string, std::wstring, std::string_view, std::wstring_view > 11 | class c_string_hash { 12 | public: 13 | using basic_string 14 | = std::conditional_t< is_any_of< string_type, char, wchar_t >, std::basic_string_view< const string_type >, const string_type >; 15 | 16 | _INLINE constexpr std::size_t operator( ) ( const basic_string &string, std::size_t basis = m_basis ) const noexcept { 17 | for ( const auto &character : string ) 18 | basis = ( basis ^ static_cast< std::uint8_t >( character ) ) * m_prime; 19 | 20 | return basis; 21 | } 22 | 23 | private: 24 | static constexpr auto m_prime { 0x100000001B3 }; 25 | static constexpr auto m_basis { 0xCBF29CE484222325 }; 26 | }; 27 | 28 | namespace literals { 29 | _INLINE constexpr std::size_t operator""_hash ( const char *const string, [[maybe_unused]] const std::size_t length ) noexcept { 30 | return c_string_hash< char > { }( string ); 31 | } 32 | 33 | _INLINE constexpr std::size_t operator""_hash ( const wchar_t *const string, [[maybe_unused]] const std::size_t length ) noexcept { 34 | return c_string_hash< wchar_t > { }( string ); 35 | } 36 | } // namespace literals 37 | } // namespace hack::utils -------------------------------------------------------------------------------- /deadlock/third_party/imgui/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX11 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // Learn about Dear ImGui: 11 | // - FAQ https://dearimgui.com/faq 12 | // - Getting Started https://dearimgui.com/getting-started 13 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 14 | // - Introduction, links and more at the top of imgui.cpp 15 | 16 | #pragma once 17 | #include "imgui.h" // IMGUI_IMPL_API 18 | #ifndef IMGUI_DISABLE 19 | 20 | struct ID3D11Device; 21 | struct ID3D11DeviceContext; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 24 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 25 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 26 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 27 | 28 | // Use if you want to reset your rendering device without losing Dear ImGui state. 29 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 30 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); 31 | 32 | #endif // #ifndef IMGUI_DISABLE 33 | -------------------------------------------------------------------------------- /deadlock/source/core/hooks/detours/game_overlay_renderer.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "../hooks.hpp" 4 | #include "core/ui/ui.hpp" 5 | #include "systems/render/render.hpp" 6 | 7 | namespace hack::core { 8 | std::int32_t present( IDXGISwapChain *const swap_chain, const std::uint32_t sync_interval, 9 | const std::uint32_t flags ) noexcept { 10 | if ( !systems::g_render ) 11 | return g_orig_present( swap_chain, sync_interval, flags ); 12 | 13 | // Prepare some imgui data 14 | { 15 | systems::g_render->prepare( swap_chain ); 16 | systems::g_render->new_frame( ); 17 | } 18 | 19 | // Render draw data 20 | { 21 | core::g_ui->render( ); 22 | 23 | ImGui::Render( ); 24 | ImGui_ImplDX11_RenderDrawData( ImGui::GetDrawData( ) ); 25 | } 26 | 27 | // End of present 28 | const auto result { g_orig_present( swap_chain, sync_interval, flags ) }; 29 | if ( systems::g_render ) 30 | systems::g_render->reset( ); 31 | 32 | return result; 33 | } 34 | 35 | std::int32_t resize_buffers( IDXGISwapChain *const swap_chain, const std::uint32_t buffer_count, 36 | const std::uint32_t width, const std::uint32_t height, const std::int32_t new_format, 37 | const std::uint32_t swap_chain_flags ) noexcept { 38 | systems::g_render->resize_buffers( ); 39 | return g_orig_resize_buffers( swap_chain, buffer_count, width, height, new_format, swap_chain_flags ); 40 | } 41 | } // namespace hack::core -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/base_entity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "handle_entity.hpp" 3 | #include "utils/math/data_types/vector.hpp" 4 | #include "valve/net_vars/net_vars.hpp" 5 | 6 | namespace hack::valve::inline data_types { 7 | struct collision_property_t; 8 | struct game_scene_node_t; 9 | } // namespace hack::valve::inline data_types 10 | 11 | namespace hack::valve::inline entities { 12 | struct entity_identity_t; 13 | 14 | struct entity_t : i_handle_entity_t { 15 | entity_t( ) = delete; 16 | entity_t( entity_t && ) = delete; 17 | entity_t( const entity_t & ) = delete; 18 | 19 | NET_VAR( "C_BaseEntity", m_iHealth, int ); 20 | NET_VAR( "C_BaseEntity", m_iMaxHealth, int ); 21 | NET_VAR( "C_BaseEntity", m_pCollision, collision_property_t * ); 22 | NET_VAR( "C_BaseEntity", m_iTeamNum, std::uint8_t ) 23 | 24 | [[nodiscard]] _INLINE bool is_player_pawn( ) const noexcept, is_player_controller( ) const noexcept, 25 | is_modifier_invis( ) const noexcept; 26 | [[nodiscard]] bool is_enemy( ) noexcept; 27 | }; 28 | 29 | struct base_model_entity_t : entity_t { 30 | base_model_entity_t( ) = delete; 31 | base_model_entity_t( base_model_entity_t && ) = delete; 32 | base_model_entity_t( const base_model_entity_t & ) = delete; 33 | }; 34 | 35 | struct entity_instance_t { 36 | entity_instance_t( ) = delete; 37 | entity_instance_t( entity_instance_t && ) = delete; 38 | entity_instance_t( const entity_instance_t & ) = delete; 39 | 40 | NET_VAR( "CEntityInstance", m_entity, entity_identity_t * ); 41 | }; 42 | 43 | } // namespace hack::valve::inline entities 44 | 45 | #include "base_entity.inl" -------------------------------------------------------------------------------- /deadlock/third_party/minhk/hde/pstdint.hpp: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /deadlock/source/valve/net_vars/net_vars.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "net_vars.hpp" 3 | 4 | namespace hack::valve { 5 | _INLINE net_vars_t::net_vars_t( ) noexcept { 6 | const auto type_scope { g_schema_system->find_type_scope( "client.dll" ) }; 7 | if ( !type_scope ) 8 | return; 9 | 10 | auto &binding_table { type_scope->get_bindings_table( ) }; 11 | const auto elements { std::make_unique_for_overwrite< utl_ts_hash_handle_t[] >( binding_table.count( ) ) }; 12 | const auto elements_count { binding_table.get_elements( 0, binding_table.count( ), elements.get( ) ) }; 13 | 14 | for ( int i { }; i < elements_count; i++ ) { 15 | const auto element { elements[ i ] }; 16 | if ( !element ) 17 | continue; 18 | 19 | const auto class_binding { binding_table.element( element ) }; 20 | if ( !class_binding ) 21 | continue; 22 | 23 | const auto class_hashed { _HASH( class_binding->m_name ) }; 24 | const auto delimiter_hashed { _HASH( "->", class_hashed ) }; 25 | for ( int j { }; j < class_binding->m_fields_count; j++ ) { 26 | auto &schema_field { class_binding->m_fields[ j ] }; 27 | const auto field_hashed { _HASH( schema_field.m_name, delimiter_hashed ) }; 28 | 29 | m_cache.try_emplace( field_hashed, schema_field.m_offset ); 30 | } 31 | } 32 | } 33 | 34 | net_vars_t::~net_vars_t( ) noexcept { 35 | m_cache.clear( ); 36 | } 37 | 38 | _INLINE std::uint32_t net_vars_t::get_offset( const std::size_t property_key ) noexcept { 39 | const auto &offset { m_cache.find( property_key ) }; 40 | return offset == m_cache.end( ) ? 0 : offset->second; 41 | } 42 | } // namespace hack::valve -------------------------------------------------------------------------------- /deadlock/source/bootstrap.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "core/hooks/hooks.hpp" 4 | #include "core/ui/ui.hpp" 5 | #include "systems/input/input.hpp" 6 | #include "systems/logger/logger.hpp" 7 | #include "systems/render/render.hpp" 8 | #include "valve/entity_utils/entity_utils.hpp" 9 | #include "valve/net_vars/net_vars.hpp" 10 | 11 | namespace hack::bootstrap { 12 | void on_dll_detach( void *handle ) noexcept; 13 | 14 | void on_dll_attach( [[maybe_unused]] void *handle ) noexcept { 15 | systems::g_logger = std::make_unique< systems::logger_t >( "C:\\deadlock\\cheat.log" ); 16 | systems::g_render = std::make_unique< systems::render_t >( ); 17 | valve::g_net_vars = std::make_unique< valve::net_vars_t >( ); 18 | valve::g_entity_list = std::make_unique< valve::c_entity_list >( ); 19 | 20 | systems::g_input->register_callback( VK_END, [ handle ] { 21 | systems::g_input->remove_callback( VK_END ); 22 | std::jthread( on_dll_detach, handle ).detach( ); 23 | } ); 24 | } 25 | 26 | void on_dll_detach( void *handle ) noexcept { 27 | _INFO_LOG( "Unloading..." ); 28 | 29 | systems::g_hook_manager.reset( ); 30 | core::g_ui.reset( ); 31 | systems::g_render.reset( ); 32 | systems::g_input.reset( ); 33 | valve::g_net_vars.reset( ); 34 | valve::g_entity_list.reset( ); 35 | 36 | systems::g_logger.reset( ); 37 | 38 | FreeLibrary( static_cast< HMODULE >( handle ) ); 39 | } 40 | } // namespace hack::bootstrap 41 | 42 | bool _STDCALL DllMain( void *handle, const std::uint8_t reason, [[maybe_unused]] void *const reserved ) { 43 | if ( reason == DLL_PROCESS_ATTACH ) { 44 | std::jthread( hack::bootstrap::on_dll_attach, handle ).detach( ); 45 | return true; 46 | } 47 | return false; 48 | } -------------------------------------------------------------------------------- /deadlock/source/systems/render/render.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imgui/imgui_impl_dx11.h" 3 | #include "imgui/imgui_impl_win32.h" 4 | 5 | #include "utils/math/data_types/vector.hpp" 6 | #include "vendor.hpp" 7 | 8 | namespace hack::systems { 9 | /// @brief A struct for rendering ImGui in a DirectX 11 environment. 10 | struct render_t { 11 | /// @brief Initialize render. 12 | _INLINE render_t( ) noexcept; 13 | 14 | /// @brief Destructor. 15 | _INLINE ~render_t( ) noexcept; 16 | 17 | /** 18 | * @brief Prepares ImGui rendering. 19 | * 20 | * @param swap_chain Pointer to the IDXGISwapChain interface. This interface is used to manipulate an image 21 | * buffer (a swap chain). 22 | */ 23 | void prepare( IDXGISwapChain *swap_chain ) noexcept; 24 | 25 | /// @brief Resets the rendering environment. 26 | void reset( ) noexcept; 27 | 28 | /// @brief Resizes rendering buffers. 29 | void resize_buffers( ) noexcept; 30 | 31 | /// @brief Starts a new frame for rendering. 32 | void new_frame( ) const noexcept; 33 | 34 | private: 35 | struct { 36 | ImFont *m_esp { }; 37 | } m_fonts { }; 38 | 39 | ImGuiIO *m_imgui_io { }; /**< Pointer to the ImGuiIO structure. */ 40 | ID3D11Device *m_d3d11device { }; /**< Pointer to the Direct3D 11 device. */ 41 | ID3D11DeviceContext *m_d3d11device_context { }; /**< Pointer to the Direct3D 11 device context. */ 42 | ID3D11RenderTargetView *m_render_target_view { }, *m_backup_render_target_view { }; /**< Render target views. */ 43 | bool m_initialized { }; 44 | }; 45 | 46 | inline auto g_render { std::unique_ptr< render_t > {} }; 47 | } // namespace hack::systems 48 | 49 | #include "render.inl" -------------------------------------------------------------------------------- /deadlock/third_party/minhk/buffer.hpp: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /deadlock/source/pch/pch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // 17.4.1.2 Headers 3 | 4 | // clang-format off 5 | #include 6 | #include 7 | // clang-format on 8 | #include "propvarutil.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #pragma comment( lib, "d3d11.lib" ) 28 | #pragma comment( lib, "d3dx11.lib" ) 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | // C 35 | #ifndef _GLIBCXX_NO_ASSERT 36 | #include 37 | #endif 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #if __cplusplus >= 201103L 48 | #include 49 | #endif 50 | 51 | // C++ 52 | // #include 53 | // #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | #if __cplusplus >= 201103L 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #endif 75 | 76 | #if __cplusplus >= 201402L 77 | #endif 78 | 79 | #if __cplusplus >= 201703L 80 | #include 81 | // #include 82 | #include 83 | #include 84 | #include 85 | #endif 86 | 87 | #if __cplusplus >= 202002L 88 | #include 89 | #include 90 | #include 91 | #include 92 | #include 93 | #include 94 | #include 95 | #include 96 | #endif 97 | 98 | #if __cplusplus > 202002L 99 | #include 100 | #include 101 | #if __cpp_impl_coroutine 102 | #include 103 | #endif 104 | #endif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deadlock Cheat Base 2 | 3 | Welcome to Deadlock Cheat Base, an advanced, modular cheat development framework for games on the Source 2 engine. Deadlock Cheat Base offers a highly optimized, extensible, and well-organized structure, designed for developers looking to create secure and efficient cheats with minimal runtime overhead. 4 | 5 | # Key Features 6 | - Doxygen Documentation: In-depth, clean, and organized documentation across all modules using Doxygen comments. This facilitates an easy understanding of the codebase for contributors. 7 | - Hook Management System: A powerful hook manager that leverages compile-time validation and tokenized hook identifiers. Hooks can be easily created, managed, and removed with minimal code, providing an organized way to inject functionality into the game. 8 | - Interactive ImGui Menu: Features a customizable and modern UI built with ImGui, allowing real-time configuration and control over cheat options. 9 | 10 | # Project Structure 11 | - ``core``: Contains essential components for initializing and configuring the project: 12 | - ``bootstrap``: Sets up and manages the foundational settings and system initialization. 13 | - ``ui``: Manages the ImGui-based user interface, providing customizable and responsive UI elements for in-game controls. 14 | - ``systems``: Core systems that provide the cheat's primary functionalities: 15 | - ``render``: Handles graphics rendering for UI elements and overlays. 16 | - ``input``: Processes user inputs, allowing for customizable control bindings and cheat toggling. 17 | - ``hooker``: Manages the creation, registration, and removal of hooks, using the powerful hook management system. 18 | - ``module & pattern parser``: Implements memory scanning and pattern matching, enabling fast, compile-time optimized access to function addresses in the game's memory. 19 | - ``utils``: Contains helper functions and utility classes. 20 | - ``third_party``: Contains external libraries that the project depends on: 21 | - ``imgui``: A popular, lightweight library for creating graphical user interfaces, used here to build intuitive in-game menus. 22 | - ``minhook``: A versatile, minimalistic hooking library. 23 | - ``valve``: Implements the Source 2 SDK to support Valve’s games and engine structures. 24 | 25 | # Requirements 26 | - C++20/23-compliant compiler 27 | - Windows platform (DirectX 11 and Windows API integration) 28 | - ImGui library 29 | -------------------------------------------------------------------------------- /deadlock/source/systems/hooker/hooker.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "hooker.hpp" 3 | 4 | namespace hack::systems { 5 | _INLINE hook_t::hook_t( void *table, void *hook_func ) noexcept : m_table( table ), m_hook_func( hook_func ) { 6 | if ( m_table && m_hook_func ) 7 | ( void ) MH_CreateHook( m_table, m_hook_func, reinterpret_cast< void ** >( &m_original_func ) ); 8 | } 9 | 10 | _INLINE void hook_t::hook( void *replace ) const noexcept { 11 | if ( MH_EnableHook( m_table ) != MH_OK ) 12 | return; 13 | } 14 | 15 | _INLINE void hook_t::unhook( ) const noexcept { 16 | if ( MH_DisableHook( m_table ) != MH_OK ) 17 | return; 18 | } 19 | 20 | _INLINE hook_manager_t::hook_manager_t( ) noexcept { 21 | MH_Initialize( ); 22 | } 23 | 24 | _INLINE hook_manager_t::~hook_manager_t( ) noexcept { 25 | MH_Uninitialize( ); 26 | } 27 | 28 | _INLINE void hook_manager_t::add_hook( const std::size_t token, void *table, void *hook_func ) noexcept { 29 | if ( m_hook_map.contains( token ) ) 30 | return; 31 | 32 | m_hook_map[ token ] = hook_t( table, hook_func ); 33 | m_hook_map[ token ].hook( hook_func ); 34 | } 35 | 36 | _INLINE void hook_manager_t::remove_hook( const std::size_t token ) noexcept { 37 | if ( const auto it { m_hook_map.find( token ) }; it != m_hook_map.end( ) ) { 38 | it->second.unhook( ); 39 | m_hook_map.erase( it ); 40 | } 41 | } 42 | 43 | _INLINE hook_t *hook_manager_t::get_hook( const std::size_t token ) noexcept { 44 | const auto it { m_hook_map.find( token ) }; 45 | return it != m_hook_map.end( ) ? &it->second : nullptr; 46 | } 47 | 48 | template < typename fn_t > 49 | _INLINE fn_t hook_t::get_original( ) const noexcept { 50 | return reinterpret_cast< fn_t >( m_original_func ); 51 | } 52 | 53 | template < typename fn_t > 54 | fn_t hook_impl( const std::size_t token, void *table, void *func ) { 55 | // If the hook does not exist, add it 56 | if ( g_hook_manager->get_hook( token ) == nullptr ) { 57 | g_hook_manager->add_hook( token, table, func ); 58 | } 59 | 60 | // Retrieve the hook and apply it 61 | const auto &hook { *g_hook_manager->get_hook( token ) }; 62 | return hook.get_original< fn_t >( ); 63 | } 64 | } // namespace hack::systems -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/citadel_input/citadel_input.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utils/math/data_types/vector.hpp" 3 | #include "utils/memory/memory.hpp" 4 | 5 | namespace hack::valve::inline interfaces { 6 | // note: you can find the pattern in the CCitadelInput::CreateMove 7 | inline const auto g_cmd_base 8 | = systems::get_pattern< void ** >( "client.dll", "48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B CF 4C 8B E8", 3, true ); 9 | 10 | // ref: "cl_demoviewoverride" 11 | inline const auto g_set_view_angles = systems::get_pattern< fastcall_t< void, void *, int, utils::vec3_t * > >( 12 | "client.dll", "E8 ? ? ? ? 48 8B 0D ? ? ? ? 41 B1 01 48 8B 05" ); 13 | 14 | // note: you can find the pattern in the CCitadelInput::CreateMove 15 | inline const auto g_get_user_cmd 16 | = systems::get_pattern< fastcall_t< user_cmd_pb_t *, void *, int > >( "client.dll", "40 53 48 83 EC 20 8B DA 85 D2 78" ); 17 | 18 | struct msg_qangle_t { 19 | _PAD( 0x18 ); 20 | utils::vec3_t m_view_angles { }; 21 | }; 22 | 23 | struct msg_vector_t { 24 | _PAD( 0x18 ); 25 | utils::vec3_t m_vector { }; 26 | }; 27 | 28 | struct in_button_state_pb_t { 29 | _PAD( 0x18 ); 30 | std::uint32_t m_buttons { }; 31 | }; 32 | 33 | struct base_user_cmd_t { 34 | _PAD( 0x38 ); 35 | in_button_state_pb_t *m_in_button_state_pb { }; 36 | msg_qangle_t *m_angle { }; 37 | _PAD( 0x10 ); 38 | float m_forward_move { }; 39 | float m_side_move { }; 40 | }; 41 | 42 | struct user_cmd_pb_t { 43 | _PAD( 0x28 ); 44 | base_user_cmd_t *m_base_user_cmd { }; 45 | msg_vector_t *m_camera_pos { }; 46 | msg_qangle_t *m_camera_angle { }; 47 | _PAD( 0x18 ); 48 | std::uint32_t m_buttons { }; 49 | }; 50 | 51 | struct citadel_input_t { 52 | _PAD( 0x251 ); 53 | bool m_is_td { }; 54 | _PAD( 0x19E ); 55 | std::uint32_t m_td_distance { }; 56 | _OFFSET( 0x2F5C, view_angle, utils::vec3_t ) 57 | 58 | _INLINE void set_view_angles( utils::vec3_t &angles ) noexcept; 59 | }; 60 | 61 | // ref: "c_thirdpersonshoulder" 62 | inline const auto g_citadel_input 63 | = systems::get_pattern< citadel_input_t ** >( "client.dll", "48 8B 05 ?? ?? ?? ?? 33 C9 C6 80 51 02 00 00 00", 3, true ); 64 | 65 | } // namespace hack::valve::inline interfaces 66 | 67 | #include "citadel_input.inl" -------------------------------------------------------------------------------- /deadlock/source/core/hooks/hooks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "systems/hooker/hooker.hpp" 3 | #include "systems/module_parser/module_parser.hpp" 4 | #include "utils/memory/base_address/base_address.hpp" 5 | 6 | #define _HOOK( hooker, func ) \ 7 | using fn_##func = decltype( &func ); \ 8 | inline fn_##func g_orig_##func = hack::systems::hook_impl< fn_##func >( _HASH( #hooker ), hooker, reinterpret_cast< void * >( func ) ); 9 | 10 | namespace hack { 11 | namespace valve::inline interfaces { 12 | struct citadel_input_t; 13 | } 14 | 15 | namespace core { 16 | inline const auto g_get_matrices = hack::systems::get_pattern< void * >( "client.dll", "40 53 48 81 EC 10 01 00 00 49" ); 17 | 18 | // xref: "cl: %d: %s\n", "cl: %d ===========================\n" 19 | inline const auto g_create_move = hack::systems::get_pattern< void * >( "client.dll", "85 D2 0F 85 21" ); 20 | 21 | inline const auto g_present = hack::systems::get_pattern< void * >( 22 | "gameoverlayrenderer64.dll", "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ? 57 41 56 41 57 48 83 EC 20 41 8B E8" ); 23 | inline const auto g_resize_buffers = hack::systems::get_pattern< void * >( 24 | "gameoverlayrenderer64.dll", "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 83 EC 30 44" ); 25 | 26 | void _FASTCALL get_matrices( void *render_game_system, void *view_params, void *world_to_view, void *view_to_projection, 27 | void *world_to_projection, void *world_to_screen ) noexcept; 28 | void _FASTCALL create_move( valve::citadel_input_t *citadel_input, int slot, bool is_active ); 29 | std::int32_t _FASTCALL present( IDXGISwapChain *const swap_chain, const std::uint32_t sync_interval, 30 | const std::uint32_t flags ) noexcept; 31 | std::int32_t _FASTCALL resize_buffers( IDXGISwapChain *const swap_chain, const std::uint32_t buffer_count, 32 | const std::uint32_t width, const std::uint32_t height, const std::int32_t new_format, 33 | const std::uint32_t swap_chain_flags ) noexcept; 34 | 35 | _HOOK( g_get_matrices, get_matrices ) 36 | _HOOK( g_create_move, create_move ) 37 | _HOOK( g_present, present ) 38 | _HOOK( g_resize_buffers, resize_buffers ) 39 | } // namespace core 40 | } // namespace hack 41 | 42 | #undef _HOOK -------------------------------------------------------------------------------- /deadlock/source/valve/entity_utils/entity_utils.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "entity_utils.hpp" 4 | 5 | namespace hack::valve { 6 | void c_entity_list::add_entity( entity_t *entity ) noexcept { 7 | if ( !entity || std::ranges::find( m_entities, entity ) != m_entities.end( ) ) 8 | return; 9 | 10 | m_entities.emplace_back( entity ); 11 | 12 | if ( const auto base_entity { entity }; base_entity->is_player_pawn( ) ) 13 | m_player_pawns.emplace_back( static_cast< player_pawn_t * >( base_entity ) ); 14 | else if ( base_entity->is_player_controller( ) ) 15 | m_player_controllers.emplace_back( static_cast< player_controller_t * >( base_entity ) ); 16 | } 17 | 18 | void c_entity_list::remove_entity( entity_t *entity ) noexcept { 19 | if ( !entity ) 20 | return; 21 | 22 | const auto founded_entity { std::ranges::find( m_entities, entity ) }; 23 | if ( founded_entity == m_entities.end( ) ) 24 | return; 25 | 26 | m_entities.erase( founded_entity ); 27 | 28 | if ( const auto base_entity { entity }; base_entity->is_player_pawn( ) ) { 29 | if ( const auto player_pawn { std::ranges::find( m_player_pawns, entity ) }; player_pawn != m_player_pawns.end( ) ) 30 | m_player_pawns.erase( player_pawn ); 31 | } else if ( base_entity->is_player_controller( ) ) { 32 | if ( const auto player_controller { std::ranges::find( m_player_controllers, entity ) }; 33 | player_controller != m_player_controllers.end( ) ) 34 | m_player_controllers.erase( player_controller ); 35 | } 36 | } 37 | 38 | void c_entity_list::sort( ) noexcept { 39 | auto entity_sort = []( const entity_t *first, const entity_t *second ) { 40 | return first->m_pEntity( )->m_handle.get_index( ) < second->m_pEntity( )->m_handle.get_index( ); 41 | }; 42 | 43 | std::ranges::sort( m_entities, entity_sort ); 44 | std::ranges::sort( m_player_pawns, entity_sort ); 45 | std::ranges::sort( m_player_controllers, entity_sort ); 46 | } 47 | 48 | void c_entity_list::c_entity_listener::on_entity_created( entity_t *ent ) noexcept { 49 | g_entity_list->add_entity( ent ); 50 | g_entity_list->sort( ); 51 | } 52 | 53 | void c_entity_list::c_entity_listener::on_entity_deleted( entity_t *ent ) noexcept { 54 | g_entity_list->remove_entity( ent ); 55 | g_entity_list->sort( ); 56 | } 57 | } // namespace hack::valve -------------------------------------------------------------------------------- /deadlock/source/systems/module_parser/module_parser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ldr_module/ldr_module.hpp" 3 | #include "utils/hash/hash.hpp" 4 | 5 | namespace hack::systems::inline memory { 6 | struct module_parser_t { 7 | /** 8 | * @brief Constructor that initializes the module parser and parses modules. 9 | * 10 | * This constructor calls the `parse_modules` function to populate the module list. 11 | * It also prints the number of parsed modules in debug mode. 12 | */ 13 | explicit _INLINE _CONSTRUCTOR module_parser_t( ) noexcept; 14 | 15 | /** 16 | * @brief Parses the modules and populates the module list. 17 | * 18 | * This function retrieves the list of loaded modules from the process environment block (PEB) 19 | * and populates the `m_modules_list` with module information. 20 | * 21 | * @return True if modules were successfully parsed, false otherwise. 22 | */ 23 | bool parse_modules( ) noexcept; 24 | 25 | /** 26 | * @brief Retrieves a module by its hash. 27 | * 28 | * This function searches the module list for a module with the specified hash and returns it. 29 | * 30 | * @param hash The hash of the module to retrieve. 31 | * @return A shared pointer to the module if found, nullptr otherwise. 32 | */ 33 | [[nodiscard]] _INLINE std::shared_ptr< ldr_module_t > get_module( const std::size_t hash ) const noexcept; 34 | 35 | private: 36 | /** 37 | * @brief Retrieves the current thread environment block (TEB). 38 | * 39 | * This function uses inline assembly to get the current TEB. 40 | * 41 | * @return A pointer to the current TEB. 42 | */ 43 | [[nodiscard]] static _INLINE const utils::teb *_HIDDEN get_current_teb( ) noexcept; 44 | 45 | /** 46 | * @brief Type definition for the map of modules. 47 | * 48 | * This map stores modules indexed by their hash values. 49 | */ 50 | using modules_map_t = std::unordered_map< std::size_t, const std::shared_ptr< ldr_module_t > >; 51 | 52 | /** 53 | * @brief The list of parsed modules. 54 | * 55 | * This member variable holds the parsed modules in an unordered map indexed by their hash values. 56 | */ 57 | modules_map_t m_modules_list { }; 58 | }; 59 | 60 | inline auto g_module_parser { std::make_unique< module_parser_t >( ) }; 61 | } // namespace hack::systems::inline memory 62 | 63 | #include "module_parser.inl" -------------------------------------------------------------------------------- /deadlock/source/systems/logger/logger.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "logger.hpp" 3 | 4 | namespace hack::systems { 5 | static inline constexpr std::array k_log_level_strings = { " [INFO] ", " [WARNING] ", " [ERROR] " }; 6 | 7 | _INLINE logger_t::logger_t( const std::string &file_name ) noexcept { 8 | if ( AllocConsole( ) ) { 9 | std::freopen( "CONOUT$", "w", stdout ); 10 | std::freopen( "CONOUT$", "w", stderr ); 11 | } 12 | 13 | if ( !std::filesystem::exists( "C:\\deadlock\\" ) ) 14 | std::filesystem::create_directory( "C:\\deadlock\\" ); 15 | 16 | m_log_file.open( file_name, std::ios::app ); 17 | if ( !m_log_file.is_open( ) ) { 18 | std::printf( "Failed to open log file: %s\n", file_name.c_str( ) ); 19 | } 20 | } 21 | 22 | _INLINE logger_t::~logger_t( ) noexcept { 23 | if ( m_log_file.is_open( ) ) { 24 | m_log_file.close( ); 25 | } 26 | 27 | std::fclose( stdout ); 28 | std::fclose( stderr ); 29 | FreeConsole( ); 30 | } 31 | 32 | _INLINE std::string logger_t::log_level_to_string( e_log_level level ) noexcept { 33 | if ( static_cast< std::size_t >( level ) < k_log_level_strings.size( ) ) { 34 | return k_log_level_strings[ static_cast< std::size_t >( level ) ]; 35 | } 36 | return "[UNKNOWN] "; 37 | } 38 | 39 | _INLINE std::string logger_t::current_timestamp( ) noexcept { 40 | const auto now { std::chrono::system_clock::now( ) }; 41 | const auto now_c { std::chrono::system_clock::to_time_t( now ) }; 42 | auto oss { std::ostringstream {} }; 43 | oss << std::put_time( std::localtime( &now_c ), "%Y-%m-%d %H:%M:%S" ); 44 | return oss.str( ); 45 | } 46 | 47 | _INLINE void logger_t::log( const e_log_level level, const std::string &message ) const noexcept { 48 | std::lock_guard lock( m_mutex ); 49 | { 50 | auto log_entry { current_timestamp( ) + log_level_to_string( level ) + message }; 51 | 52 | // Log to console 53 | std::printf( ( log_entry + "\n" ).c_str( ) ); 54 | 55 | // Log to file 56 | if ( m_log_file.is_open( ) ) { 57 | m_log_file << log_entry << std::endl; 58 | } 59 | } 60 | } 61 | 62 | template < typename... Args > 63 | void logger_t::log( const e_log_level level, const std::string &format_str, Args &&...args ) const noexcept { 64 | const auto message { std::format( format_str, std::forward< Args >( args )... ) }; 65 | log( level, message ); 66 | } 67 | } // namespace hack::systems -------------------------------------------------------------------------------- /deadlock/source/systems/input/input.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "vendor.hpp" 3 | 4 | namespace hack::systems { 5 | /// @brief Type alias for key identifier. 6 | using key_id_t = std::uint8_t; 7 | 8 | /// @brief Class for handling input events. 9 | class c_input { 10 | public: 11 | /** 12 | * @brief Constructor. 13 | * @param game_window Handle to the game window. 14 | */ 15 | _INLINE c_input( HWND game_window ) noexcept; 16 | 17 | /// @brief Destructor. 18 | _INLINE ~c_input( ) noexcept; 19 | 20 | /** 21 | * @brief Registers a callback function for a specific key. 22 | * @param key_id Identifier of the key. 23 | * @param callback Callback function to be executed. 24 | */ 25 | _INLINE void register_callback( key_id_t key_id, std::function< void( ) > &&callback ) noexcept; 26 | 27 | _INLINE auto get_hwnd( ) noexcept; 28 | 29 | /** 30 | * @brief Removes the callback function associated with a key. 31 | * @param key_id Identifier of the key. 32 | */ 33 | _INLINE void remove_callback( key_id_t key_id ) noexcept; 34 | 35 | private: 36 | WNDPROC m_wnd_proc { }; /**< Pointer to the original window procedure. */ 37 | HWND m_game_window { }; /**< Handle to the game window. */ 38 | 39 | std::function< void( ) > m_callbacks[ std::numeric_limits< key_id_t >::max( ) ] 40 | = { }; /**< Array of callback functions for each key. 41 | */ 42 | 43 | std::mutex m_wnd_proc_mutex { }; /**< Mutex for thread safety. */ 44 | 45 | /** 46 | * @brief Handle window procedure. 47 | * 48 | * A callback function, which you define in your application, that processes messages sent to a window. The 49 | * WNDPROC type defines a pointer to this callback function. The WndProc name is a placeholder for the name of 50 | * the function that you define in your application. 51 | * 52 | * @param window Handle to the window. 53 | * @param msg Message identifier. 54 | * @param u_param Additional message information. 55 | * @param i_param Additional message information. 56 | * @param window 57 | * @param msg 58 | * @param u_param 59 | * @return Result of the window procedure. 60 | */ 61 | static std::intptr_t wnd_proc( HWND window, std::uint32_t msg, std::uintptr_t u_param, std::intptr_t i_param ) noexcept; 62 | }; 63 | 64 | inline std::unique_ptr< c_input > g_input { }; 65 | } // namespace hack::utils 66 | 67 | #include "input.inl" -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /deadlock/source/systems/logger/logger.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "vendor.hpp" 3 | 4 | #if defined( _DEBUG ) 5 | #define _ERROR_LOG( ... ) \ 6 | if ( hack::systems::g_logger ) \ 7 | hack::systems::g_logger->log( hack::systems::e_log_level::error, __VA_ARGS__ ) 8 | #define _INFO_LOG( ... ) \ 9 | if ( hack::systems::g_logger ) \ 10 | hack::systems::g_logger->log( hack::systems::e_log_level::info, __VA_ARGS__ ) 11 | #define _WARN_LOG( ... ) \ 12 | if ( hack::systems::g_logger ) \ 13 | hack::systems::g_logger->log( hack::systems::e_log_level::warning, __VA_ARGS__ ) 14 | #else 15 | #define _ERROR_LOG( ... ) void( 0 ) 16 | #define _INFO_LOG( ... ) void( 0 ) 17 | #define _WARN_LOG( ... ) void( 0 ) 18 | #endif 19 | 20 | namespace hack::systems { 21 | enum class e_log_level : std::uint8_t { 22 | info, 23 | warning, 24 | error 25 | }; 26 | 27 | /** 28 | * @brief Logger class for logging messages to console and file. 29 | */ 30 | struct logger_t { 31 | /** 32 | * @brief Constructs a Logger object. 33 | * @param file_name Name of the log file. 34 | */ 35 | _INLINE explicit logger_t( const std::string &file_name ) noexcept; 36 | 37 | /** 38 | * @brief Logs a message with a specific log level. 39 | * @param level The log level. 40 | * @param message The message to log. 41 | */ 42 | _INLINE void log( e_log_level level, const std::string &message ) const noexcept; 43 | 44 | /** 45 | * @brief Logs a formatted message with a specific log level. 46 | * @param level The log level. 47 | * @param format_str The format string. 48 | * @param args Arguments for the format string. 49 | */ 50 | template < typename... args_t > 51 | void log( e_log_level level, const std::string &format_str, args_t &&...args ) const noexcept; 52 | 53 | /** 54 | * @brief Destructor that closes the log file. 55 | */ 56 | _INLINE ~logger_t( ) noexcept; 57 | 58 | private: 59 | mutable std::ofstream m_log_file { }; ///< Log file stream. 60 | mutable std::mutex m_mutex { }; ///< Mutex for thread-safe logging. 61 | 62 | /** 63 | * @brief Returns a string representation of the log level. 64 | * @param level The log level. 65 | * @return String representation of the log level. 66 | */ 67 | [[nodiscard]] static _INLINE std::string _HIDDEN log_level_to_string( e_log_level level ) noexcept; 68 | 69 | /** 70 | * @brief Returns the current timestamp as a string. 71 | * @return Current timestamp. 72 | */ 73 | [[nodiscard]] static _INLINE std::string _HIDDEN current_timestamp( ) noexcept; 74 | }; 75 | 76 | inline auto g_logger { std::unique_ptr< logger_t > {} }; 77 | } // namespace hack::systems 78 | 79 | #include "logger.inl" -------------------------------------------------------------------------------- /deadlock/third_party/minhk/hde/hde32.hpp: -------------------------------------------------------------------------------- 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.hpp" 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 | -------------------------------------------------------------------------------- /deadlock/source/valve/structs/entities/base_player.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base_entity.hpp" 3 | 4 | namespace hack::valve { 5 | inline namespace interfaces { 6 | struct user_cmd_pb_t; 7 | } 8 | 9 | inline namespace entities { 10 | class c_econ_item_view : public i_handle_entity_t { 11 | public: 12 | NET_VAR( "C_EconItemView", m_iItemDefinitionIndex, std::uint16_t ) 13 | NET_VAR( "C_EconItemView", m_iItemID, std::uint64_t ); 14 | NET_VAR( "C_EconItemView", m_iItemIDLow, std::int32_t ); 15 | NET_VAR( "C_EconItemView", m_iItemIDHigh, std::int32_t ); 16 | NET_VAR( "C_EconItemView", m_iAccountID, std::int32_t ); 17 | NET_VAR( "C_EconItemView", m_iEntityQuality, std::int32_t ); 18 | NET_VAR( "C_EconItemView", m_bInitialized, bool ); 19 | }; 20 | 21 | struct attribute_container_t { 22 | NET_VAR( "C_AttributeContainer", m_Item, c_econ_item_view ) 23 | }; 24 | 25 | struct econ_entity_t : entity_t { 26 | NET_VAR( "C_EconEntity", m_AttributeManager, attribute_container_t ); 27 | NET_VAR( "C_EconEntity", m_OriginalOwnerXuidLow, std::uint32_t ); 28 | NET_VAR( "C_EconEntity", m_OriginalOwnerXuidHigh, std::uint32_t ); 29 | NET_VAR( "C_EconEntity", m_nFallbackPaintKit, std::int32_t ); 30 | NET_VAR( "C_EconEntity", m_nFallbackSeed, std::int32_t ); 31 | NET_VAR( "C_EconEntity", m_flFallbackWear, float ); 32 | NET_VAR( "C_BasePlayerWeapon", m_iClip1, std::int32_t ) 33 | }; 34 | 35 | struct weapon_services_t { 36 | NET_VAR( "CPlayer_WeaponServices", m_hMyWeapons, econ_entity_t * ) 37 | NET_VAR( "CPlayer_WeaponServices", m_hActiveWeapon, c_handle ) 38 | }; 39 | 40 | struct player_pawn_t : entity_t { 41 | player_pawn_t( ) = delete; 42 | player_pawn_t( player_pawn_t && ) = delete; 43 | player_pawn_t( const player_pawn_t & ) = delete; 44 | 45 | NET_VAR( "C_BasePlayerPawn", m_hController, c_handle ) 46 | NET_VAR( "C_BasePlayerPawn", m_pWeaponServices, weapon_services_t * ) 47 | }; 48 | 49 | struct player_controller_t : entity_t { 50 | player_controller_t( ) = delete; 51 | player_controller_t( player_controller_t && ) = delete; 52 | player_controller_t( const player_controller_t & ) = delete; 53 | 54 | [[nodiscard]] user_cmd_pb_t *get_cmd( ) const noexcept; 55 | 56 | NET_VAR( "CBasePlayerController", m_hPawn, c_handle ) 57 | NET_VAR( "CCSPlayerController", m_hPlayerPawn, c_handle ); 58 | NET_VAR( "CCSPlayerController", m_iszPlayerName, char * ); 59 | }; 60 | 61 | inline const auto g_get_player_controller_by_id 62 | = systems::get_pattern< fastcall_t< player_controller_t *, int > >( "client.dll", "33 C0 83 F9 FF" ); 63 | } // namespace entities 64 | } // namespace hack::valve 65 | 66 | #include "base_player.inl" -------------------------------------------------------------------------------- /deadlock/source/systems/hooker/hooker.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "minhk/minhook.hpp" 3 | #include "systems/logger/logger.hpp" 4 | #include "utils/memory/base_address/base_address.hpp" 5 | 6 | namespace hack::systems { 7 | /** 8 | * @brief Manages the function hooks, including installation and removal. 9 | */ 10 | struct hook_t { 11 | /** 12 | * @brief Constructs a hook with a function table and installs the hook. 13 | * @param table Pointer to the function table where the hook is applied. 14 | */ 15 | explicit _INLINE hook_t( void *table = nullptr, void *hook_func = nullptr ) noexcept; 16 | 17 | void *m_table { }; ///< The function table to be hooked. 18 | void *m_original_func { }; ///< The original function pointer before hooking. 19 | void *m_hook_func { }; ///< The function pointer to be used as the hook. 20 | 21 | /** 22 | * @brief Applies the hook by enabling it. 23 | * @param replace Pointer to the replacement function. 24 | */ 25 | _INLINE void hook( void *replace ) const noexcept; 26 | 27 | /** 28 | * @brief Disables the hook. 29 | */ 30 | _INLINE void unhook( ) const noexcept; 31 | 32 | /** 33 | * @brief Retrieves the original function pointer. 34 | * @tparam fn_t The function signature type. 35 | * @return The original function pointer cast to the specified signature. 36 | */ 37 | template < typename fn_t > 38 | [[nodiscard]] _INLINE fn_t get_original( ) const noexcept; 39 | }; 40 | 41 | /** 42 | * @brief Manages a collection of hooks, indexed by unique tokens. 43 | */ 44 | struct hook_manager_t { 45 | _INLINE hook_manager_t( ) noexcept; 46 | _INLINE ~hook_manager_t( ) noexcept; 47 | 48 | /// Map of hooks, indexed by a unique token (e.g., function address or identifier). 49 | std::unordered_map< std::size_t, hook_t > m_hook_map { }; 50 | 51 | /** 52 | * @brief Adds a new hook to the map. 53 | * @param token Unique identifier for the hook. 54 | * @param table Pointer to the function table where the hook is applied. 55 | * @param hook_func Pointer to the function that replaces the original. 56 | */ 57 | _INLINE void add_hook( const std::size_t token, void *table, void *hook_func ) noexcept; 58 | 59 | /** 60 | * @brief Removes a hook from the map by its unique token. 61 | * @param token Unique identifier for the hook. 62 | */ 63 | _INLINE void remove_hook( const std::size_t token ) noexcept; 64 | 65 | /** 66 | * @brief Retrieves a hook by its unique token. 67 | * @param token Unique identifier for the hook. 68 | * @return Pointer to the hook if found, or nullptr if not. 69 | */ 70 | _INLINE hook_t *get_hook( const std::size_t token ) noexcept; 71 | }; 72 | 73 | inline auto g_hook_manager { std::make_unique< hook_manager_t >( ) }; 74 | } // namespace hack::systems 75 | 76 | #include "hooker.inl" -------------------------------------------------------------------------------- /deadlock/third_party/minhk/hde/hde64.hpp: -------------------------------------------------------------------------------- 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.hpp" 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 | -------------------------------------------------------------------------------- /deadlock/source/valve/structs/data_types/utl/utl_hash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utl_memory_pool.hpp" 3 | #include "vendor.hpp" 4 | 5 | namespace hack::valve::inline data_types { 6 | using utl_ts_hash_handle_t = std::uintptr_t; 7 | 8 | template < int bucket_count_t, class key_t = std::uintptr_t > 9 | struct utl_ts_hash_generic_hash_t { 10 | static _INLINE constexpr int hash( const key_t &key, const int bucket_mask ) noexcept; 11 | 12 | static _INLINE bool compare( const key_t &lhs, const key_t &rhs ) noexcept { 13 | return lhs == rhs; 14 | } 15 | }; 16 | 17 | template < class element_t, int bucket_count_t, class key_t = std::uintptr_t, 18 | class hash_funcs_t = utl_ts_hash_generic_hash_t< bucket_count_t, key_t >, int alignment_t = 0 > 19 | struct utl_ts_hash_t { 20 | static inline constexpr int m_bucket_mask { bucket_count_t - 1 }; 21 | static _INLINE consteval utl_ts_hash_handle_t _HIDDEN invalid_handle( ) noexcept; 22 | 23 | [[nodiscard]] _INLINE utl_ts_hash_handle_t find( key_t key ) noexcept; 24 | 25 | [[nodiscard]] _INLINE int count( ) const noexcept { 26 | return m_entry_memory.m_peak_alloc; 27 | } 28 | 29 | [[nodiscard]] _INLINE int get_elements( int first_element, const int count, utl_ts_hash_handle_t *elements ) const noexcept; 30 | 31 | [[nodiscard]] _INLINE element_t &element( utl_ts_hash_handle_t hash ) noexcept; 32 | [[nodiscard]] _INLINE const element_t &element( utl_ts_hash_handle_t hash ) const noexcept; 33 | 34 | [[nodiscard]] _INLINE element_t &operator[] ( utl_ts_hash_handle_t hash ) noexcept; 35 | [[nodiscard]] _INLINE const element_t &operator[] ( utl_ts_hash_handle_t hash ) const noexcept; 36 | 37 | [[nodiscard]] static _INLINE key_t get_id( utl_ts_hash_handle_t hash ) noexcept; 38 | 39 | private: 40 | template < typename data_t > 41 | struct hash_fixed_data_internal_t { 42 | key_t m_key { }; 43 | hash_fixed_data_internal_t< data_t > *m_next { }; 44 | data_t m_data { }; 45 | 46 | [[nodiscard]] std::add_lvalue_reference_t< hash_fixed_data_internal_t< data_t > * > get_next( ) noexcept; 47 | [[nodiscard]] _INLINE std::add_lvalue_reference_t< data_t > get_data( ) noexcept; 48 | }; 49 | 50 | using hash_fixed_data_t = hash_fixed_data_internal_t< element_t >; 51 | 52 | struct hash_bucket_t { 53 | _PAD( 0x18 ) 54 | hash_fixed_data_t *m_first { }, *m_first_uncommited { }; 55 | }; 56 | 57 | [[nodiscard]] _INLINE utl_ts_hash_handle_t find( key_t key, hash_fixed_data_t *first_element, 58 | hash_fixed_data_t *last_element ) noexcept; 59 | 60 | utl_memory_pool_t m_entry_memory { }; 61 | _PAD( 0x40 ) 62 | hash_bucket_t m_buckets[ bucket_count_t ] { }; 63 | bool m_needs_commit { }; 64 | }; 65 | 66 | } // namespace hack::cs2::inline data_types 67 | 68 | #include "utl_hash.inl" -------------------------------------------------------------------------------- /deadlock/source/valve/structs/data_types/handle/handle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "vendor.hpp" 3 | 4 | namespace hack::valve { 5 | inline namespace entities { 6 | struct entity_t; 7 | } // namespace entities 8 | 9 | inline namespace data_types { 10 | static inline constexpr std::uint32_t k_ent_entry_mask { 0x7fffu }, k_invalid_ehandle_index { 0xffffffffu }; 11 | static inline constexpr auto k_max_edicts { 16384 }; 12 | 13 | class c_handle { 14 | std::uint32_t m_index { }; 15 | 16 | public: 17 | constexpr c_handle( ) noexcept : m_index( k_invalid_ehandle_index ) { } 18 | 19 | explicit constexpr c_handle( const std::uint32_t index ) noexcept : m_index( index ) { } 20 | 21 | /** 22 | * @brief Retrieves the index of the c_handle. 23 | * 24 | * This method retrieves the index of the c_handle. 25 | * 26 | * @return The index of the c_handle. 27 | */ 28 | _INLINE constexpr void set_index( const std::uint32_t index ); 29 | 30 | /** 31 | * @brief Checks if the c_handle is valid. 32 | * 33 | * This method checks if the c_handle is valid. 34 | * 35 | * @return true if the c_handle is valid, false otherwise. 36 | */ 37 | [[nodiscard]] _INLINE constexpr bool is_valid( ) const noexcept; 38 | 39 | /** 40 | * @brief Retrieves the index of the c_handle. 41 | * 42 | * This method retrieves the index of the c_handle. 43 | * 44 | * @return The index of the c_handle. 45 | */ 46 | [[nodiscard]] _INLINE constexpr int get_index( ) const noexcept; 47 | 48 | /** 49 | * @brief Equality operator for c_handle. 50 | * 51 | * This method checks for equality between two c_handle objects. 52 | * 53 | * @param rhs The right-hand side c_handle object to compare. 54 | * @return true if the c_handle objects are equal, false otherwise. 55 | */ 56 | [[nodiscard]] _INLINE constexpr bool operator== ( const c_handle rhs ) const noexcept; 57 | 58 | /** 59 | * @brief Inequality operator for c_handle. 60 | * 61 | * This method checks for inequality between two c_handle objects. 62 | * 63 | * @param rhs The right-hand side c_handle object to compare. 64 | * @return true if the c_handle objects are not equal, false otherwise. 65 | */ 66 | [[nodiscard]] _INLINE constexpr bool operator!= ( const c_handle rhs ) const noexcept; 67 | 68 | /** 69 | * @brief Retrieves the integer value of the c_handle. 70 | * 71 | * This method retrieves the integer value of the c_handle. 72 | * 73 | * @return The integer value of the c_handle. 74 | */ 75 | [[nodiscard]] _INLINE constexpr std::uint32_t get_int( ) const noexcept; 76 | }; 77 | } // namespace data_types 78 | } // namespace hack::valve 79 | 80 | #include "handle.inl" -------------------------------------------------------------------------------- /deadlock/source/systems/render/render.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "render.hpp" 3 | 4 | namespace hack::systems { 5 | _INLINE render_t::render_t( ) noexcept { 6 | // Retrieves the path to the system's font directory 7 | std::filesystem::path fonts_path { }; 8 | { 9 | wchar_t *path { }; 10 | // Retrieves the font directory path 11 | if ( FAILED( SHGetKnownFolderPath( FOLDERID_Fonts, 0, nullptr, &path ) ) ) 12 | return; 13 | 14 | fonts_path = path; 15 | 16 | /* Frees the allocated memory for the font directory path 17 | * @note: @william: 18 | * ATL provides some classes like ATL::CComPtr which are wrapper objects that handle the reference counting 19 | * of COM objects for you. They are not foolproof to use correctly, and, in fact, have a few more gotchas 20 | * than most of the modern STL classes, so read the documentation carefully. When used correctly, it's 21 | * relatively easy to make sure the AddRef and Release calls all match up. 22 | */ 23 | CoTaskMemFree( path ); 24 | } 25 | 26 | // Creates a new ImGui context if one does not already exist 27 | if ( !ImGui::GetCurrentContext( ) ) { 28 | ImGui::CreateContext( ); 29 | } 30 | 31 | m_imgui_io = &ImGui::GetIO( ); 32 | 33 | // Disables mouse cursor change and keyboard capture for navigation 34 | m_imgui_io->LogFilename = m_imgui_io->IniFilename = nullptr; 35 | 36 | m_imgui_io->ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NavNoCaptureKeyboard; 37 | 38 | // Defines ranges of Unicode characters for font rendering 39 | ImVector< ImWchar > ranges { }; 40 | ImFontGlyphRangesBuilder ranges_builder { }; 41 | 42 | static constexpr auto base_ranges { std::to_array< ImWchar >( { 43 | 0x0020, 44 | 0x00FF, // Basic Latin + Latin Supplement 45 | 0x0400, 46 | 0x044F, // Cyrillic 47 | 0xF000, 48 | 0xF3FF, // icons 49 | 0, 50 | } ) }; 51 | 52 | // Adds base character ranges 53 | ranges_builder.AddRanges( base_ranges.data( ) ); 54 | 55 | // Adds Cyrillic character ranges 56 | ranges_builder.AddRanges( m_imgui_io->Fonts->GetGlyphRangesCyrillic( ) ); 57 | 58 | // Builds the final character ranges for font rendering 59 | ranges_builder.BuildRanges( &ranges ); 60 | 61 | // Configures and loads the Verdana font for rendering 62 | const ImFontConfig verdana_config { }; 63 | 64 | m_imgui_io->Fonts->Clear( ); 65 | m_fonts.m_esp = m_imgui_io->Fonts->AddFontFromFileTTF( ( fonts_path / "Verdana.ttf" ).string( ).c_str( ), 12.0f, &verdana_config, 66 | ranges.Data ); 67 | 68 | // Builds the font atlas 69 | m_imgui_io->Fonts->Build( ); 70 | } 71 | 72 | _INLINE render_t::~render_t( ) noexcept { 73 | // Destroys the ImGui context 74 | if ( ImGui::GetCurrentContext( ) ) { 75 | if ( m_imgui_io->Fonts ) 76 | m_imgui_io->Fonts->ClearFonts( ); 77 | 78 | ImGui_ImplDX11_Shutdown( ); 79 | ImGui_ImplWin32_Shutdown( ); 80 | 81 | ImGui::DestroyContext( ); 82 | } 83 | } 84 | } // namespace hack::systems -------------------------------------------------------------------------------- /deadlock/third_party/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32-bits AND 64-bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen. 7 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 10 | 11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 13 | // Learn about Dear ImGui: 14 | // - FAQ https://dearimgui.com/faq 15 | // - Getting Started https://dearimgui.com/getting-started 16 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 17 | // - Introduction, links and more at the top of imgui.cpp 18 | 19 | #pragma once 20 | #include "imgui.h" // IMGUI_IMPL_API 21 | #ifndef IMGUI_DISABLE 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 24 | IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd); 25 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 27 | 28 | // Win32 message handler your application need to call. 29 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 30 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 31 | // - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE. 32 | 33 | #if 0 34 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 35 | #endif 36 | 37 | // DPI-related helpers (optional) 38 | // - Use to enable DPI awareness without having to create an application manifest. 39 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 40 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 41 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 42 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 43 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 44 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 45 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 46 | 47 | // Transparency related helpers (optional) [experimental] 48 | // - Use to enable alpha compositing transparency with the desktop. 49 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 50 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 51 | 52 | #endif // #ifndef IMGUI_DISABLE 53 | -------------------------------------------------------------------------------- /deadlock/source/systems/module_parser/module_parser.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "module_parser.hpp" 3 | 4 | namespace hack::systems::inline memory { 5 | _INLINE _CONSTRUCTOR module_parser_t::module_parser_t( ) noexcept { 6 | _ASSERT( this->parse_modules( ) ); 7 | } 8 | 9 | _INLINE std::shared_ptr< ldr_module_t > module_parser_t::get_module( const std::size_t hash ) const noexcept { 10 | const auto iterator { this->m_modules_list.find( hash ) }; 11 | 12 | if ( iterator == this->m_modules_list.cend( ) ) 13 | return nullptr; 14 | 15 | return iterator->second; 16 | } 17 | 18 | _INLINE const utils::teb *module_parser_t::get_current_teb( ) noexcept { 19 | utils::teb *current_teb { }; 20 | 21 | asm volatile( "mov %%gs:0x30, %0" 22 | : "=r"( current_teb ) ); 23 | 24 | return current_teb; 25 | } 26 | 27 | /** 28 | * @brief Retrieves the pattern address from the specified module. 29 | * 30 | * This function uses the provided module name and pattern to search for the pattern. 31 | * Optionally, you can provide an offset to modify the found address. 32 | * 33 | * @param module_name The name of the module to search within. 34 | * @param pattern The pattern to search for in the module. 35 | * @param offset The optional offset to add to the found pattern (default is 0). 36 | * @param dereference Whether to dereference the pattern address (default is false). 37 | * @return The address of the found pattern, potentially adjusted by the offset. 38 | */ 39 | template < typename T = utils::base_address_t > 40 | constexpr std::add_const_t< T > get_pattern( const std::string_view module_name, const std::string_view pattern, 41 | const std::uint8_t offset = 0, const bool dereference = false ) noexcept { 42 | const auto module { g_module_parser->get_module( _HASH( module_name ) ) }; 43 | auto pattern_addr { module->find_pattern( pattern ) }; 44 | 45 | if ( offset != 0 ) 46 | pattern_addr = pattern_addr.relative( offset ); 47 | 48 | if ( dereference ) 49 | return pattern_addr.dereference( ).as< std::add_const_t< T > >( ); 50 | 51 | return pattern_addr.as< std::add_const_t< T > >( ); 52 | } 53 | 54 | /** 55 | * @brief Retrieves the export address from the specified module. 56 | * 57 | * @param module_name The name of the module. 58 | * @param export_name The name of the export. 59 | * @return The address of the export. 60 | */ 61 | template < typename T > 62 | constexpr std::add_const_t< T > get_export( const std::string_view module_name, const std::string_view export_name ) noexcept { 63 | return g_module_parser->get_module( _HASH( module_name ) ) 64 | ->get_export_address( export_name ) 65 | .template as< std::add_const_t< T > >( ); 66 | } 67 | 68 | /** 69 | * @brief Retrieves the interface address from the specified module. 70 | * 71 | * @param module_name The name of the module. 72 | * @param interface_name The name of the interface. 73 | * @return The address of the interface. 74 | */ 75 | template < typename T > 76 | constexpr std::add_const_t< T > get_interface( const std::string_view module_name, const std::string_view interface_name ) noexcept { 77 | return g_module_parser->get_module( _HASH( module_name ) ) 78 | ->find_interface( interface_name ) 79 | .template as< std::add_const_t< T > >( ); 80 | } 81 | 82 | } // namespace hack::systems::inline memory -------------------------------------------------------------------------------- /deadlock/source/valve/entity_utils/entity_utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "systems/module_parser/module_parser.hpp" 3 | #include "valve/interfaces/entity_system/entity_system.hpp" 4 | #include "valve/structs/entities/base_player.hpp" 5 | 6 | namespace hack::valve { 7 | inline namespace interfaces { 8 | struct game_entity_system_t; 9 | } 10 | 11 | inline game_entity_system_t *g_game_entity_system { }; 12 | 13 | class c_entity_list { 14 | static inline auto m_entity_system { systems::get_pattern< game_entity_system_t * >( 15 | "client.dll", 16 | "48 8B 0D ?? ?? ?? ?? 89 45 CB E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 0F 28 00 0F 29 45 D7 0F " 17 | "28 48 10 0F 29 4D E7 0F 28 40 " 18 | "20 48 8B 05 ?? ?? ?? ?? 48 89 45 B7 0F 29 45 F7 4C 89 7D A7", 19 | 3, true ) }; 20 | public: 21 | class c_entity_listener : public entity_listener_t { 22 | public: 23 | void on_entity_created( entity_t *ent ) noexcept final; 24 | void on_entity_spawned( [[maybe_unused]] entity_t *ent ) noexcept final { }; 25 | void on_entity_deleted( entity_t *ent ) noexcept final; 26 | void on_entity_parent_changed( [[maybe_unused]] entity_t *ent, [[maybe_unused]] entity_t *parent ) noexcept final { }; 27 | }; 28 | 29 | _INLINE c_entity_list( ); 30 | _INLINE ~c_entity_list( ) noexcept; 31 | 32 | /** 33 | * @brief Retrieves all entities in the list. 34 | * 35 | * @return A span of pointers to entities. 36 | */ 37 | [[nodiscard]] _INLINE std::span< entity_t *const > get_entities( ) const noexcept; 38 | 39 | /** 40 | * @brief Retrieves all player pawns. 41 | * 42 | * @return A span of pointers to player pawns. 43 | */ 44 | [[nodiscard]] _INLINE std::span< player_pawn_t *const > get_player_pawns( ) const noexcept; 45 | 46 | /** 47 | * @brief Retrieves all player controllers. 48 | * 49 | * @return A span of pointers to player controllers. 50 | */ 51 | [[nodiscard]] _INLINE std::span< player_controller_t *const > get_player_controllers( ) const noexcept; 52 | 53 | /** 54 | * @brief Retrieves the local player's controller. 55 | * 56 | * This method retrieves the local player's controller. 57 | * 58 | * @return A pointer to the local player's controller. 59 | */ 60 | [[nodiscard]] static _INLINE player_controller_t *get_local_controller( ) noexcept; 61 | 62 | private: 63 | /** 64 | * @brief Adds an entity to the list. 65 | * 66 | * @param entity Pointer to the entity to add. 67 | */ 68 | void _HIDDEN add_entity( entity_t *entity ) noexcept; 69 | 70 | /** 71 | * @brief Removes an entity from the list. 72 | * 73 | * @param entity Pointer to the entity to remove. 74 | */ 75 | void _HIDDEN remove_entity( entity_t *entity ) noexcept; 76 | 77 | /** 78 | * @brief Sorts entities, player pawns, and player controllers by their index. 79 | */ 80 | void _HIDDEN sort( ) noexcept; 81 | 82 | c_entity_listener m_entity_listener = { }; 83 | 84 | std::vector< entity_t * > m_entities = { }; 85 | std::vector< player_pawn_t * > m_player_pawns = { }; 86 | std::vector< player_controller_t * > m_player_controllers = { }; 87 | }; 88 | 89 | inline std::unique_ptr< c_entity_list > g_entity_list { }; 90 | } // namespace hack::valve 91 | 92 | #include "entity_utils.inl" -------------------------------------------------------------------------------- /deadlock/third_party/minhk/hde/table32.hpp: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /deadlock/source/valve/net_vars/net_vars.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utils/hash/hash.hpp" 3 | #include "valve/interfaces/schema_system/schema_system.hpp" 4 | #include "vendor.hpp" 5 | 6 | #define NET_VAR_OFFSET( datatable, prop_name, add_offset, type ) \ 7 | [[nodiscard]] _INLINE std::add_lvalue_reference_t< std::add_const_t< type > > prop_name( ) const noexcept { \ 8 | static const auto class_hashed { _HASH( ( datatable ) ) }; \ 9 | static const auto delimiter_hashed { _HASH( ( "->" ), class_hashed ) }; \ 10 | static const auto field_hashed { _HASH( ( #prop_name ), delimiter_hashed ) }; \ 11 | static const auto offset { ::hack::valve::g_net_vars->get_offset( field_hashed ) }; \ 12 | return *::hack::utils::base_address_t { this } \ 13 | .offset( static_cast< std::ptrdiff_t >( offset + ( add_offset ) ) ) \ 14 | .as< std::add_pointer_t< std::add_const_t< type > > >( ); \ 15 | } 16 | 17 | #define NET_VAR_OFFSET_NON_CONST( datatable, prop_name, add_offset, type ) \ 18 | [[nodiscard]] _INLINE std::add_lvalue_reference_t< type > prop_name( ) const noexcept { \ 19 | static const auto class_hashed { _HASH( ( datatable ) ) }; \ 20 | static const auto delimiter_hashed { _HASH( ( "->" ), class_hashed ) }; \ 21 | static const auto field_hashed { _HASH( ( #prop_name ), delimiter_hashed ) }; \ 22 | static const auto offset { ::hack::valve::g_net_vars->get_offset( field_hashed ) }; \ 23 | return *::hack::utils::base_address_t { this } \ 24 | .offset( static_cast< std::ptrdiff_t >( offset + ( add_offset ) ) ) \ 25 | .as< std::add_pointer_t< type > >( ); \ 26 | } 27 | 28 | #define NET_VAR( datatable, prop_name, type ) NET_VAR_OFFSET( datatable, prop_name, 0, type ) 29 | #define NET_VAR_EX( datatable, prop_name, type ) NET_VAR_OFFSET_NON_CONST( datatable, prop_name, 0, type ) 30 | 31 | namespace hack::valve { 32 | /** 33 | * @brief Manages network variable offsets and caching for efficient retrieval. 34 | */ 35 | struct net_vars_t { 36 | /** 37 | * @brief Constructs a net_vars_t object, initializing and caching network variable offsets. 38 | * 39 | * @details Scans through available classes and fields within the "client.dll" type scope to 40 | * populate a cache of hashed property keys and their offsets. 41 | */ 42 | _INLINE net_vars_t( ) noexcept; 43 | 44 | /** 45 | * @brief Destroys the net_vars_t object, clearing the cached offset data. 46 | */ 47 | _INLINE ~net_vars_t( ) noexcept; 48 | 49 | /** 50 | * @brief Retrieves the offset for a specified property key. 51 | * 52 | * @param property_key A hashed key representing the network variable property. 53 | * @return The offset of the network variable if found; otherwise, returns 0. 54 | */ 55 | [[nodiscard]] static _INLINE std::uint32_t get_offset( const std::size_t property_key ) noexcept; 56 | 57 | private: 58 | /// A cache of property keys mapped to their corresponding offsets for quick lookup. 59 | inline static std::unordered_map< std::size_t, std::uint32_t > m_cache { }; 60 | }; 61 | 62 | inline std::unique_ptr< net_vars_t > g_net_vars { }; 63 | } // namespace hack::valve 64 | 65 | #include "net_vars.inl" -------------------------------------------------------------------------------- /deadlock/third_party/minhk/hde/table64.hpp: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /deadlock/source/valve/structs/data_types/utl/utl_memory.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utl_memory.hpp" 3 | 4 | namespace hack::valve::inline data_types { 5 | template < typename t_element, typename t_index > typename utl_memory_t< t_element, t_index >::iterator_t 6 | utl_memory_t< t_element, t_index >::first( ) const noexcept { 7 | return iterator_t( is_index_valid( 0 ) ? 0 : invalid_index( ) ); 8 | } 9 | 10 | template < typename t_element, typename t_index > typename utl_memory_t< t_element, t_index >::iterator_t 11 | utl_memory_t< t_element, t_index >::next( const iterator_t& it ) const noexcept { 12 | return iterator_t( is_index_valid( it.i_index + 1 ) ? it.i_index + 1 : invalid_index( ) ); 13 | } 14 | 15 | template < typename t_element, typename t_index > 16 | t_index utl_memory_t< t_element, t_index >::get_index( const iterator_t& it ) noexcept { 17 | return it.i_index; 18 | } 19 | 20 | template < typename t_element, typename t_index > 21 | constexpr bool utl_memory_t< t_element, t_index >::is_index_after( t_index index, const iterator_t& it ) noexcept { 22 | return index > it.i_index; 23 | } 24 | 25 | template < typename t_element, typename t_index > constexpr typename utl_memory_t< t_element, t_index >::iterator_t 26 | utl_memory_t< t_element, t_index >::invalid_iterator( ) noexcept { 27 | return iterator_t( invalid_index( ) ); 28 | } 29 | 30 | template < typename t_element, typename t_index > 31 | consteval t_index utl_memory_t< t_element, t_index >::invalid_index( ) noexcept { 32 | return m_invalid_index; 33 | } 34 | 35 | template < typename t_element, typename t_index > 36 | utl_memory_t< t_element, t_index >::utl_memory_t( int grow_size, int init_size ) noexcept : 37 | m_memory( nullptr ), 38 | m_allocation_count( init_size ), 39 | m_grow_size( grow_size ) { 40 | if ( m_allocation_count ) 41 | m_memory = static_cast< t_element* >( mem_alloc.MemAlloc_AllocFunc( m_allocation_count * sizeof( t_element ) ) ); 42 | } 43 | 44 | template < typename t_element, typename t_index > 45 | utl_memory_t< t_element, t_index >::utl_memory_t( t_element* p_memory, int num_elements ) noexcept : 46 | m_memory( p_memory ), 47 | m_allocation_count( num_elements ) { 48 | m_grow_size = external_buffer_marker; 49 | } 50 | 51 | template < typename t_element, typename t_index > 52 | utl_memory_t< t_element, t_index >::utl_memory_t( const t_element* p_memory, int num_elements ) noexcept : 53 | m_memory( p_memory ), 54 | m_allocation_count( num_elements ) { 55 | m_grow_size = external_const_buffer_marker; 56 | } 57 | 58 | template < typename t_element, typename t_index > utl_memory_t< t_element, t_index >::~utl_memory_t( ) noexcept { 59 | purge( ); 60 | } 61 | 62 | template < typename t_element, typename t_index > 63 | utl_memory_t< t_element, t_index >::utl_memory_t( utl_memory_t&& utl_memory ) noexcept : 64 | m_memory( utl_memory.m_memory ), 65 | m_allocation_count( utl_memory.m_allocation_count ), 66 | m_grow_size( utl_memory.m_grow_size ) { 67 | utl_memory.m_memory = nullptr; 68 | utl_memory.m_allocation_count = 0; 69 | utl_memory.m_grow_size = 0; 70 | } 71 | 72 | template < typename t_element, typename t_index > utl_memory_t< t_element, t_index >& 73 | utl_memory_t< t_element, t_index >::operator=( utl_memory_t&& utl_memory ) noexcept { 74 | t_element* p_memory = utl_memory.m_memory; 75 | const int allocation_count = utl_memory.m_allocation_count; 76 | const int grow_size = utl_memory.m_grow_size; 77 | 78 | utl_memory.m_memory = nullptr; 79 | utl_memory.m_allocation_count = 0; 80 | utl_memory.m_grow_size = 0; 81 | 82 | purge( ); 83 | 84 | m_memory = p_memory; 85 | m_allocation_count = allocation_count; 86 | m_grow_size = grow_size; 87 | 88 | return *this; 89 | } 90 | } // namespace hack::cs2::inline data_types 91 | -------------------------------------------------------------------------------- /deadlock/third_party/minhk/trampoline.hpp: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | AccessModifierOffset: -2 4 | AlignAfterOpenBracket: Align 5 | AlignArrayOfStructures: Right 6 | AlignConsecutiveAssignments: 7 | Enabled: true 8 | AcrossEmptyLines: false 9 | AcrossComments: false 10 | AlignCompound: true 11 | PadOperators: true 12 | AlignConsecutiveBitFields: 13 | Enabled: true 14 | AcrossEmptyLines: false 15 | AcrossComments: false 16 | AlignConsecutiveDeclarations: 17 | Enabled: true 18 | AcrossEmptyLines: false 19 | AcrossComments: false 20 | AlignConsecutiveMacros: 21 | Enabled: true 22 | AcrossEmptyLines: true 23 | AcrossComments: false 24 | AlignEscapedNewlines: Left 25 | AlignOperands: AlignAfterOperator 26 | AllowAllArgumentsOnNextLine: false 27 | AllowAllParametersOfDeclarationOnNextLine: false 28 | AllowShortBlocksOnASingleLine: Empty 29 | AllowShortCaseLabelsOnASingleLine: false 30 | AllowShortEnumsOnASingleLine: false 31 | AllowShortFunctionsOnASingleLine: Empty 32 | AllowShortIfStatementsOnASingleLine: Never 33 | AllowShortLambdasOnASingleLine: Empty 34 | AllowShortLoopsOnASingleLine: false 35 | AlwaysBreakAfterReturnType: None 36 | AlwaysBreakBeforeMultilineStrings: false 37 | AlwaysBreakTemplateDeclarations: Yes 38 | BinPackArguments: true 39 | BinPackParameters: true 40 | BitFieldColonSpacing: Both 41 | BreakBeforeBraces: Custom 42 | BraceWrapping: 43 | AfterCaseLabel: false 44 | AfterClass: false 45 | AfterControlStatement: Never 46 | AfterEnum: false 47 | AfterFunction: false 48 | AfterNamespace: false 49 | AfterStruct: false 50 | AfterUnion: false 51 | AfterExternBlock: false 52 | BeforeCatch: false 53 | BeforeElse: false 54 | BeforeLambdaBody: false 55 | BeforeWhile: false 56 | IndentBraces: false 57 | SplitEmptyFunction: false 58 | SplitEmptyRecord: false 59 | SplitEmptyNamespace: false 60 | BreakAfterAttributes: Never 61 | BreakBeforeBinaryOperators: All 62 | BreakBeforeConceptDeclarations: Always 63 | BreakBeforeInlineASMColon: Always 64 | BreakBeforeTernaryOperators: true 65 | BreakConstructorInitializers: AfterColon 66 | BreakInheritanceList: AfterComma 67 | BreakStringLiterals: true 68 | ColumnLimit: 140 69 | CompactNamespaces: true 70 | ConstructorInitializerIndentWidth: 4 71 | ContinuationIndentWidth: 4 72 | Cpp11BracedListStyle: false 73 | DisableFormat: false 74 | EmptyLineAfterAccessModifier: Never 75 | EmptyLineBeforeAccessModifier: LogicalBlock 76 | FixNamespaceComments: true 77 | IndentAccessModifiers: false 78 | IndentCaseBlocks: false 79 | IndentCaseLabels: true 80 | IndentExternBlock: Indent 81 | IndentGotoLabels: true 82 | IndentPPDirectives: None 83 | IndentRequiresClause: true 84 | IndentWidth: 4 85 | IndentWrappedFunctionNames: true 86 | InsertNewlineAtEOF: false 87 | KeepEmptyLinesAtTheStartOfBlocks: false 88 | LambdaBodyIndentation: Signature 89 | LineEnding: LF 90 | MaxEmptyLinesToKeep: 1 91 | NamespaceIndentation: All 92 | PackConstructorInitializers: CurrentLine 93 | PointerAlignment: Right 94 | ReferenceAlignment: Right 95 | ReflowComments: true 96 | RequiresClausePosition: OwnLine 97 | SeparateDefinitionBlocks: Always 98 | ShortNamespaceLines: 1 99 | SortIncludes: 'true' 100 | SortUsingDeclarations: true 101 | SpaceAfterCStyleCast: true 102 | SpaceAfterLogicalNot: false 103 | SpaceAfterTemplateKeyword: true 104 | SpaceAroundPointerQualifiers: After 105 | SpaceBeforeAssignmentOperators: true 106 | SpaceBeforeCaseColon: true 107 | SpaceBeforeCpp11BracedList: true 108 | SpaceBeforeCtorInitializerColon: true 109 | SpaceBeforeInheritanceColon: true 110 | SpaceBeforeParens: Custom 111 | SpaceBeforeParensOptions: 112 | AfterControlStatements: true 113 | AfterForeachMacros: true 114 | AfterFunctionDeclarationName: false 115 | AfterFunctionDefinitionName: false 116 | AfterIfMacros: true 117 | AfterOverloadedOperator: true 118 | AfterRequiresInClause: true 119 | AfterRequiresInExpression: true 120 | BeforeNonEmptyParentheses: false 121 | SpaceBeforeRangeBasedForLoopColon: true 122 | SpaceBeforeSquareBrackets: false 123 | SpaceInEmptyBlock: true 124 | SpaceInEmptyParentheses: true 125 | SpacesBeforeTrailingComments: 1 126 | SpacesInAngles: Always 127 | SpacesInCStyleCastParentheses: true 128 | SpacesInConditionalStatement: true 129 | SpacesInContainerLiterals: true 130 | SpacesInLineCommentPrefix: 131 | Minimum: 1 132 | Maximum: 1 133 | SpacesInParentheses: true 134 | SpacesInSquareBrackets: true -------------------------------------------------------------------------------- /deadlock/source/systems/render/render.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "core/ui/ui.hpp" 4 | #include "render.hpp" 5 | #include "systems/input/input.hpp" 6 | #include "systems/logger/logger.hpp" 7 | 8 | namespace hack::systems { 9 | void render_t::prepare( IDXGISwapChain *const swap_chain ) noexcept { 10 | // Obtains the Direct3D device associated with the swap chain 11 | if ( FAILED( swap_chain->GetDevice( IID_PPV_ARGS( &m_d3d11device ) ) ) ) 12 | return; 13 | 14 | // Obtains the immediate context of the Direct3D device 15 | m_d3d11device->GetImmediateContext( &m_d3d11device_context ); 16 | 17 | #pragma clang diagnostic ignored "-Wlanguage-extension-token" 18 | // Declares a pointer to a Direct3D texture that will hold the back buffer 19 | ID3D11Texture2D *back_buffer { }; 20 | if ( FAILED( swap_chain->GetBuffer( 0, IID_PPV_ARGS( &back_buffer ) ) ) ) 21 | return; 22 | #pragma clang diagnostic warning "-Wlanguage-extension-token" 23 | 24 | DXGI_SWAP_CHAIN_DESC back_buffer_desc { }; 25 | if ( FAILED( swap_chain->GetDesc( &back_buffer_desc ) ) ) 26 | return; 27 | 28 | // Retrieves the handle to the game window 29 | const auto game_window { back_buffer_desc.OutputWindow }; 30 | 31 | // Sets up the description for creating a render target view 32 | D3D11_RENDER_TARGET_VIEW_DESC d3d11_render_target_view_desc { }; 33 | d3d11_render_target_view_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; 34 | d3d11_render_target_view_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS; 35 | 36 | // Creates a render target view for the back buffer 37 | if ( FAILED( m_d3d11device->CreateRenderTargetView( back_buffer, &d3d11_render_target_view_desc, &m_render_target_view ) ) ) 38 | return; 39 | 40 | // Backs up the current render target view 41 | m_d3d11device_context->OMGetRenderTargets( 1, &m_backup_render_target_view, nullptr ); 42 | // Sets the newly created render target view as the active render target 43 | m_d3d11device_context->OMSetRenderTargets( 1, &m_render_target_view, nullptr ); 44 | 45 | if ( !m_initialized ) { 46 | // Initializes ImGui only once 47 | if ( !ImGui::GetCurrentContext( ) ) 48 | ImGui::CreateContext( ); 49 | 50 | ImGui_ImplWin32_Init( game_window ); 51 | ImGui_ImplDX11_Init( m_d3d11device, m_d3d11device_context ); 52 | 53 | core::g_ui = std::make_unique< core::ui_t >( ); 54 | g_input = std::make_unique< c_input >( game_window ); 55 | 56 | g_input->register_callback( VK_INSERT, [] { 57 | core::g_ui->opened( ) = !core::g_ui->opened( ); 58 | } ); 59 | 60 | _INFO_LOG( "Initialized ImGui" ); 61 | m_initialized = true; 62 | } 63 | } 64 | 65 | void render_t::new_frame( ) const noexcept { 66 | if ( !m_initialized ) 67 | return; 68 | 69 | ImGui_ImplDX11_NewFrame( ); 70 | ImGui_ImplWin32_NewFrame( ); 71 | ImGui::NewFrame( ); 72 | } 73 | 74 | void render_t::reset( ) noexcept { 75 | if ( !m_render_target_view ) 76 | return; 77 | 78 | // Resets the render target view to the backed up render target view 79 | m_d3d11device_context->OMSetRenderTargets( 1, &m_backup_render_target_view, nullptr ); 80 | 81 | // Clear the backed up render target view 82 | if ( m_backup_render_target_view ) { 83 | m_backup_render_target_view->Release( ); 84 | m_backup_render_target_view = nullptr; 85 | } 86 | 87 | // Cleat the current render target view 88 | if ( m_render_target_view ) { 89 | m_render_target_view->Release( ); 90 | m_render_target_view = nullptr; 91 | } 92 | } 93 | 94 | void render_t::resize_buffers( ) noexcept { 95 | if ( m_backup_render_target_view ) { 96 | m_backup_render_target_view->Release( ); 97 | m_backup_render_target_view = nullptr; 98 | } 99 | 100 | if ( m_render_target_view ) { 101 | m_render_target_view->Release( ); 102 | m_render_target_view = nullptr; 103 | } 104 | 105 | if ( m_d3d11device_context ) { 106 | m_d3d11device_context->Release( ); 107 | m_d3d11device_context = nullptr; 108 | } 109 | 110 | if ( m_d3d11device ) { 111 | m_d3d11device->Release( ); 112 | m_d3d11device = nullptr; 113 | } 114 | 115 | ImGui_ImplDX11_Shutdown( ); 116 | ImGui::DestroyContext( ); 117 | } 118 | } // namespace hack::systems -------------------------------------------------------------------------------- /deadlock/source/systems/module_parser/ldr_module/ldr_module.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utils/memory/base_address/base_address.hpp" 3 | #include "utils/memory/win_types/win_types.hpp" 4 | 5 | namespace hack::systems::inline memory { 6 | struct ldr_module_t { 7 | private: 8 | /** 9 | * @brief Address of the module (ldr_data_table_entry structure). 10 | */ 11 | utils::base_address_t m_base_address { }; 12 | 13 | public: 14 | /** 15 | * @brief Constructor that initializes the module with a given base address. 16 | * 17 | * @param address The base address of the module. 18 | */ 19 | explicit _INLINE ldr_module_t( const utils::base_address_t &address ) noexcept; 20 | 21 | /** 22 | * @brief Retrieves the base address of the module. 23 | * 24 | * @return The base address of the module. 25 | */ 26 | [[nodiscard]] _INLINE utils::base_address_t get_base_address( ) const noexcept; 27 | 28 | /** 29 | * @brief Enumeration for specifying the case of the module name. 30 | */ 31 | enum class e_name_case : std::uint8_t { 32 | e_unknown = 0, ///< Unknown case (should not be used). 33 | e_unmodified, ///< Unmodified case. 34 | e_lowercase, ///< Lowercase. 35 | e_uppercase ///< Uppercase. 36 | }; 37 | 38 | /** 39 | * @brief Retrieves the wide string name of the module. 40 | * 41 | * @param name_case The case to convert the name to (default is lowercase). 42 | * @return The wide string name of the module. 43 | */ 44 | [[nodiscard]] _INLINE std::wstring get_wname( const e_name_case name_case = e_name_case::e_lowercase ) const noexcept; 45 | 46 | /** 47 | * @brief Retrieves the string name of the module. 48 | * 49 | * @param name_case The case to convert the name to (default is lowercase). 50 | * @return The string name of the module. 51 | */ 52 | [[nodiscard]] _INLINE std::string get_name( const e_name_case name_case = e_name_case::e_lowercase ) const noexcept; 53 | 54 | /** 55 | * @brief Retrieves the NT headers of the module. 56 | * 57 | * @return A pointer to the NT headers of the module. 58 | */ 59 | _INLINE utils::image_nt_headers_64 *get_nt_headers( ) const; 60 | 61 | /** 62 | * @brief Retrieves the optional header of the module. 63 | * 64 | * @param base_address The base address of the module. 65 | * @return The optional header of the module. 66 | */ 67 | static _INLINE constexpr utils::base_address_t _HIDDEN get_optional_header( const utils::base_address_t &base_address ) noexcept; 68 | 69 | /** 70 | * @brief Converts a pattern string to a vector of bytes. 71 | * 72 | * @param pattern The pattern string to convert. 73 | * @return A vector of bytes representing the pattern. 74 | */ 75 | [[nodiscard]] _INLINE static std::vector< std::optional< std::byte > > pattern_to_bytes( const std::string_view pattern ) noexcept; 76 | [[nodiscard]] _INLINE utils::base_address_t find_interface( std::string_view interface_name ) const noexcept; 77 | 78 | /** 79 | * @brief Finds a pattern in the module's memory. 80 | * 81 | * @param pattern The pattern to search for. 82 | * @return The base address of the found pattern, or an empty base_address_t if not found. 83 | */ 84 | [[nodiscard]] _INLINE utils::base_address_t find_pattern( const std::string_view pattern ) const noexcept; 85 | 86 | enum class e_data_directory : std::uint16_t { 87 | e_export = 0, 88 | e_import, 89 | e_resource, 90 | e_exception, 91 | e_security, 92 | e_base_reloc, 93 | e_debug, 94 | e_architecture, 95 | e_global_ptr, 96 | e_tls, 97 | e_load_config, 98 | e_bound_import, 99 | e_iat, 100 | e_delay_import, 101 | e_com_descriptor 102 | }; 103 | 104 | [[nodiscard]] static constexpr utils::base_address_t get_data_directory( const utils::base_address_t &base_address, 105 | e_data_directory data_directory ) noexcept; 106 | 107 | [[nodiscard]] constexpr utils::base_address_t get_export_address( std::string_view procedure_name ) const noexcept; 108 | }; 109 | } // namespace hack::systems::inline memory 110 | 111 | #include "ldr_module.inl" -------------------------------------------------------------------------------- /deadlock/source/systems/input/input.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.hpp" 2 | 3 | #include "core/ui/ui.hpp" 4 | #include "input.hpp" 5 | 6 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler( HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lParam ); 7 | 8 | namespace hack::systems { 9 | std::intptr_t c_input::wnd_proc( const HWND window, const std::uint32_t msg, const std::uintptr_t u_param, 10 | const std::intptr_t i_param ) noexcept { 11 | const auto wnd_proc { g_input->m_wnd_proc }; 12 | const auto lock_wnd_proc { std::unique_lock( g_input->m_wnd_proc_mutex, std::try_to_lock_t( ) ) }; 13 | 14 | auto key_id { key_id_t {} }; 15 | auto key_pressed { false }; 16 | 17 | switch ( msg ) { 18 | case WM_KEYDOWN : 19 | case WM_SYSKEYDOWN : { 20 | key_id = static_cast< key_id_t >( u_param ); 21 | key_pressed = true; 22 | 23 | break; 24 | } 25 | case WM_KEYUP : 26 | case WM_SYSKEYUP : { 27 | key_id = static_cast< key_id_t >( u_param ); 28 | key_pressed = false; 29 | 30 | break; 31 | } 32 | case WM_LBUTTONDOWN : 33 | case WM_LBUTTONDBLCLK : { 34 | key_id = VK_LBUTTON; 35 | key_pressed = true; 36 | 37 | break; 38 | } 39 | case WM_LBUTTONUP : { 40 | key_id = VK_LBUTTON; 41 | key_pressed = false; 42 | 43 | break; 44 | } 45 | case WM_RBUTTONDOWN : 46 | case WM_RBUTTONDBLCLK : { 47 | key_id = VK_RBUTTON; 48 | key_pressed = true; 49 | 50 | break; 51 | } 52 | case WM_RBUTTONUP : { 53 | key_id = VK_RBUTTON; 54 | key_pressed = false; 55 | 56 | break; 57 | } 58 | case WM_MBUTTONDOWN : 59 | case WM_MBUTTONDBLCLK : { 60 | key_id = VK_MBUTTON; 61 | key_pressed = true; 62 | 63 | break; 64 | } 65 | case WM_MBUTTONUP : { 66 | key_id = VK_MBUTTON; 67 | key_pressed = false; 68 | 69 | break; 70 | } 71 | case WM_XBUTTONDOWN : 72 | case WM_XBUTTONDBLCLK : { 73 | key_id = static_cast< key_id_t >( GET_XBUTTON_WPARAM( u_param ) == XBUTTON1 ? VK_XBUTTON1 : VK_XBUTTON2 ); 74 | key_pressed = true; 75 | 76 | break; 77 | } 78 | case WM_XBUTTONUP : { 79 | key_id = static_cast< key_id_t >( GET_XBUTTON_WPARAM( u_param ) == XBUTTON1 ? VK_XBUTTON1 : VK_XBUTTON2 ); 80 | key_pressed = false; 81 | 82 | break; 83 | } 84 | default : 85 | break; 86 | } 87 | 88 | if ( key_id ) { 89 | // note: callback array is [0, 254], and keycodes are [1-255], so we need to compensate it. 90 | if ( auto &fn_callback { g_input->m_callbacks[ key_id - 1 ] }; key_pressed && fn_callback ) 91 | std::invoke( fn_callback ); 92 | } 93 | 94 | if ( core::g_ui ) { 95 | if ( ImGui::GetCurrentContext( ) ) 96 | ImGui_ImplWin32_WndProcHandler( window, msg, u_param, i_param ); 97 | 98 | if ( core::g_ui->opened( ) ) { 99 | switch ( msg ) { 100 | case WM_MOUSEMOVE : 101 | case WM_NCMOUSEMOVE : 102 | case WM_MOUSELEAVE : 103 | case WM_NCMOUSELEAVE : 104 | case WM_LBUTTONDOWN : 105 | case WM_LBUTTONDBLCLK : 106 | case WM_RBUTTONDOWN : 107 | case WM_RBUTTONDBLCLK : 108 | case WM_MBUTTONDOWN : 109 | case WM_MBUTTONDBLCLK : 110 | case WM_XBUTTONDOWN : 111 | case WM_XBUTTONDBLCLK : 112 | case WM_LBUTTONUP : 113 | case WM_RBUTTONUP : 114 | case WM_MBUTTONUP : 115 | case WM_XBUTTONUP : 116 | case WM_MOUSEWHEEL : 117 | case WM_MOUSEHWHEEL : 118 | case WM_KEYDOWN : 119 | case WM_KEYUP : 120 | case WM_SYSKEYDOWN : 121 | case WM_SYSKEYUP : 122 | case WM_SETFOCUS : 123 | case WM_KILLFOCUS : 124 | case WM_CHAR : 125 | case WM_SETCURSOR : 126 | case WM_DEVICECHANGE : 127 | return true; 128 | default : 129 | break; 130 | } 131 | 132 | if ( ImGui::GetIO( ).WantTextInput || ImGui::GetIO( ).MouseWheel > 0.0f ) 133 | return true; 134 | } 135 | } 136 | 137 | return CallWindowProc( wnd_proc, window, msg, u_param, i_param ); 138 | } 139 | } // namespace hack::utils -------------------------------------------------------------------------------- /deadlock/source/vendor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined( __x86_64__ ) || defined( _M_AMD64 ) || defined( _M_X64 ) 4 | #define _ARCH_X64 5 | #elif defined( __i386 ) || defined( _M_IX86 ) 6 | #define _ARCH_X86 7 | #endif 8 | 9 | #define _COMBINE_IMPL( x, y ) x##y 10 | #define _COMBINE( x, y ) _COMBINE_IMPL( x, y ) 11 | 12 | #define _PAD( bytes ) \ 13 | private: \ 14 | [[maybe_unused]] std::array< std::byte, bytes > _COMBINE( __pad_, __COUNTER__ ) { }; \ 15 | \ 16 | public: 17 | 18 | #define _CHECK_SIZE( type, size ) \ 19 | static_assert( sizeof( type ) >= ( size ), #type " too small: sizeof(" #type ") < " #size ); \ 20 | static_assert( sizeof( type ) <= ( size ), #type " too large: sizeof(" #type ") > " #size ) 21 | 22 | /// Function calling conventions 23 | #if defined( __GNUC__ ) || defined( __clang__ ) 24 | #define _CDECL __attribute__( ( cdecl ) ) 25 | #define _STDCALL __attribute__( ( stdcall ) ) 26 | #define _THISCALL __attribute__( ( thiscall ) ) 27 | #define _FASTCALL __attribute__( ( fastcall ) ) 28 | #define _VECTORCALL __attribute__( ( vectorcall ) ) 29 | #define _HIDDEN __attribute__( ( visibility( "hidden" ) ) ) 30 | #define _NAKED __attribute__( ( naked ) ) 31 | #define _CONSTRUCTOR __attribute__( ( constructor ) ) 32 | #define _LIKE( x ) __builtin_expect( static_cast< bool >( x ), 1 ) 33 | #define _UNLIKE( x ) __builtin_expect( static_cast< bool >( x ), 0 ) 34 | #elif defined( _MSC_VER ) 35 | #define _CDECL __cdecl 36 | #define _STDCALL __stdcall 37 | #define _THISCALL __thiscall 38 | #define _FASTCALL __fastcall 39 | #define _VECTORCALL __vectorcall 40 | #define _HIDDEN 41 | #define _NAKED __declspec( naked ) 42 | #define _LIKE( x ) static_cast< bool >( x ) 43 | #define _UNLIKE( x ) static_cast< bool >( x ) 44 | #else 45 | #define _CDECL 46 | #define _STDCALL 47 | #define _THISCALL 48 | #define _FASTCALL 49 | #define _VECTORCALL 50 | #define _HIDDEN 51 | #define _NAKED 52 | #endif 53 | 54 | /// Inline and noinline attributes 55 | #if defined( __GNUC__ ) || defined( __clang__ ) 56 | #define _INLINE __attribute__( ( always_inline ) ) inline 57 | #elif defined( _MSC_VER ) 58 | #define _INLINE __pragma( warning( suppress : 4714 ) ) inline __forceinline 59 | #else 60 | #define _INLINE inline 61 | 62 | #endif 63 | #if defined( __GNUC__ ) || defined( __clang__ ) 64 | #define _NOINLINE __attribute__( ( noinline ) ) 65 | #elif defined( _MSC_VER ) 66 | #define _NOINLINE __declspec( noinline ) 67 | #else 68 | #define _NOINLINE 69 | #endif 70 | 71 | #if defined( __cplusplus ) && defined( __has_cpp_attribute ) 72 | #define _HAS_ATTRIBUTE( attrib, value ) ( __has_cpp_attribute( attrib ) >= value ) 73 | #else 74 | #define _HAS_ATTRIBUTE( attrib, value ) ( 0 ) 75 | #endif 76 | 77 | #if _HAS_ATTRIBUTE( likely, 201803L ) 78 | #define _ATTR_LIKELY likely 79 | #else 80 | #define _ATTR_LIKELY 81 | #endif 82 | 83 | #if _HAS_ATTRIBUTE( unlikely, 201803L ) 84 | #define _ATTR_UNLIKELY unlikely 85 | #else 86 | #define _ATTR_UNLIKELY 87 | #endif 88 | 89 | #if defined( __has_builtin ) 90 | #define _HAS_BUILTIN( feature ) __has_builtin( feature ) 91 | #else 92 | #define CS2_HAS_BUILTIN( feature ) 0 93 | #endif 94 | 95 | #if _HAS_BUILTIN( __builtin_debugtrap ) 96 | #define _DEBUG_BREAK( ) __builtin_debugtrap( ) 97 | #endif 98 | 99 | #if defined( _DEBUG_BREAK ) 100 | #if defined( _DEBUG ) 101 | #define _ASSERT( expression ) static_cast< void >( static_cast< bool >( expression ) || ( ( _DEBUG_BREAK( ), 0 ) != 0 ) ) 102 | #elif _HAS_BUILTIN( __builtin_unreachable ) 103 | #define _ASSERT( expression ) static_cast< void >( static_cast< bool >( expression ) || ( __builtin_unreachable( ), 0 ) ) 104 | #else 105 | #define _ASSERT( expression ) static_cast< void >( expression ) 106 | #endif 107 | #endif 108 | 109 | #if _HAS_BUILTIN( __builtin_offsetof ) 110 | #define _OFFSETOF( type, member ) __builtin_offsetof( type, member ) 111 | #else 112 | #define _OFFSETOF( type, member ) \ 113 | ( reinterpret_cast< std::size_t >( &( reinterpret_cast< type * >( sizeof( type ) )->member ) ) - sizeof( type ) ) 114 | #endif 115 | 116 | namespace hack { 117 | template < typename type, typename... compare_types > 118 | concept is_any_of = ( std::same_as< type, compare_types > || ... ); 119 | 120 | inline namespace conventions { 121 | template < typename result_t, typename... args_t > 122 | using func_t = result_t ( * )( args_t... ); 123 | 124 | template < typename result_t, typename class_t, typename... args_t > 125 | using member_func_t = result_t ( class_t::* )( args_t... ); 126 | 127 | template < typename result_t, typename... args_t > 128 | using cdecl_t = result_t( _CDECL * )( args_t... ); 129 | 130 | template < typename result_t, typename... args_t > 131 | using stdcall_t = result_t( _STDCALL * )( args_t... ); 132 | 133 | template < typename result_t, typename... args_t > 134 | using fastcall_t = result_t( _FASTCALL * )( args_t... ); 135 | 136 | template < typename result_t, typename... args_t > 137 | using thiscall_t = result_t( _THISCALL * )( args_t... ); 138 | } // namespace conventions 139 | } // namespace hack -------------------------------------------------------------------------------- /deadlock/source/utils/memory/base_address/base_address.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base_address.hpp" 3 | 4 | namespace hack::utils::inline memory { 5 | template < typename address_type > 6 | requires std::unsigned_integral< address_type > 7 | constexpr c_base_address< address_type >::c_base_address( const_reference_type address ) noexcept : m_address { address } { } 8 | 9 | template < typename address_type > 10 | requires std::unsigned_integral< address_type > 11 | template < typename pointer_type > 12 | requires std::is_pointer_v< pointer_type > 13 | constexpr c_base_address< address_type >::c_base_address( pointer_type pointer ) noexcept : 14 | m_address { reinterpret_cast< const_value_type >( pointer ) } { } 15 | 16 | template < typename address_type > 17 | requires std::unsigned_integral< address_type > 18 | constexpr c_base_address< address_type > &c_base_address< address_type >::operator= ( const_reference_type address ) noexcept { 19 | this->m_address = address; 20 | 21 | return *this; 22 | } 23 | 24 | template < typename address_type > 25 | requires std::unsigned_integral< address_type > 26 | constexpr c_base_address< address_type > &c_base_address< address_type >::operator= ( const void *const address ) noexcept { 27 | this->m_address = reinterpret_cast< const_value_type >( address ); 28 | 29 | return *this; 30 | } 31 | 32 | template < typename address_type > 33 | requires std::unsigned_integral< address_type > 34 | constexpr c_base_address< address_type > &c_base_address< address_type >::self_offset( const difference_type value ) noexcept { 35 | if ( value == 0 ) 36 | return *this; 37 | 38 | _ASSERT( this->m_address && ( value > 0 ? this->m_address + value >= this->m_address : this->m_address + value <= this->m_address ) 39 | && this->m_address >= 0 ); 40 | 41 | this->m_address += value; 42 | 43 | return *this; 44 | } 45 | 46 | template < typename address_type > 47 | requires std::unsigned_integral< address_type > 48 | constexpr c_base_address< address_type > &c_base_address< address_type >::self_dereference( const size_type count ) noexcept { 49 | if ( count == 0 ) 50 | return *this; 51 | 52 | _ASSERT( this->m_address && this->m_address >= 0 ); 53 | 54 | for ( auto i { count }; i > 0 && this->m_address != 0; --i ) 55 | this->m_address = *this->template as< std::add_pointer_t< const_value_type > >( ); 56 | 57 | return *this; 58 | } 59 | 60 | template < typename address_type > 61 | requires std::unsigned_integral< address_type > 62 | constexpr c_base_address< address_type > c_base_address< address_type >::offset( const difference_type value ) const noexcept { 63 | return c_base_address { *this }.self_offset( value ); 64 | } 65 | 66 | template < typename address_type > 67 | requires std::unsigned_integral< address_type > 68 | constexpr c_base_address< address_type > c_base_address< address_type >::dereference( const size_type count ) const noexcept { 69 | return c_base_address { *this }.self_dereference( count ); 70 | } 71 | 72 | template < typename address_type > 73 | requires std::unsigned_integral< address_type > 74 | constexpr c_base_address< address_type > c_base_address< address_type >::relative( const difference_type offset ) noexcept { 75 | if ( offset == 0 ) 76 | return *this; 77 | 78 | _ASSERT( this->m_address && this->m_address >= 0 ); 79 | 80 | const std::int32_t relative_address = *this->offset( offset ).template as< std::add_pointer_t< const_value_type > >( ); 81 | 82 | return c_base_address { this->offset( relative_address + sizeof( int ) + offset ) }; 83 | } 84 | 85 | template < typename address_type > 86 | requires std::unsigned_integral< address_type > 87 | template < typename pointer_type > 88 | requires std::is_pointer_v< pointer_type > 89 | constexpr pointer_type c_base_address< address_type >::as( ) const noexcept { 90 | return reinterpret_cast< pointer_type >( this->m_address ); 91 | } 92 | 93 | template < typename address_type > 94 | requires std::unsigned_integral< address_type > 95 | constexpr bool c_base_address< address_type >::operator!( ) const noexcept { 96 | return this->m_address == 0; 97 | } 98 | 99 | template < typename address_type > 100 | requires std::unsigned_integral< address_type > 101 | constexpr bool c_base_address< address_type >::operator== ( std::nullptr_t ) const noexcept { 102 | return this->m_address == 0; 103 | } 104 | 105 | template < typename address_type > 106 | requires std::unsigned_integral< address_type > 107 | template < typename compare_type > 108 | constexpr bool c_base_address< address_type >::operator== ( const compare_type &other ) const noexcept { 109 | if constexpr ( std::is_pointer_v< compare_type > ) { 110 | return this->m_address == reinterpret_cast< const_value_type >( other ); 111 | } else 112 | return this->m_address == static_cast< const_value_type >( other ); 113 | } 114 | 115 | template < typename address_type > 116 | requires std::unsigned_integral< address_type > 117 | constexpr c_base_address< address_type >::operator std::conditional_t< 118 | std::is_const_v< address_type >, std::remove_const_t< address_type >, address_type > ( ) const noexcept { 119 | return this->m_address; 120 | } 121 | 122 | } // namespace hack::utils::inline memory -------------------------------------------------------------------------------- /deadlock/deadlock.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /deadlock/source/valve/interfaces/entity_system/entity_system.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utils/memory/memory.hpp" 3 | #include "valve/structs/data_types/handle/handle.hpp" 4 | #include "valve/structs/data_types/utl/utl_vector.hpp" 5 | #include "vendor.hpp" 6 | 7 | namespace hack::valve { 8 | static inline constexpr auto k_max_entities_in_list { 512 }; 9 | static inline constexpr auto k_max_entity_lists { 64 }; // 0x3F 10 | static inline constexpr auto k_max_total_entities { k_max_entities_in_list * k_max_entity_lists }; // 0x8000 11 | 12 | inline namespace entities { 13 | struct entity_t; 14 | 15 | struct entity_identity_t { 16 | entity_t *m_entity { }; 17 | void *m_entity_class { }; 18 | c_handle m_handle { }; // LOWORD(handle) & 0x7FFF = entID 19 | int m_name_stringable_index { }; // always seems to be -1 20 | const char *m_internal_name { }; // these two strings are optional! 21 | const char *m_entity_name { }; // ex: item_tpscroll 22 | _PAD( 0x8 ); 23 | std::uint32_t m_flags { }; 24 | _PAD( 0x4 ); 25 | int m_world_group_id { }; 26 | std::uint32_t m_data_object_types { }; 27 | std::uint16_t m_path_index { }; 28 | _PAD( 0x16 ); 29 | entity_identity_t *m_prev { }; 30 | entity_identity_t *m_next { }; 31 | entity_identity_t *m_prev_by_class { }; 32 | entity_identity_t *m_next_by_class { }; 33 | }; 34 | } // namespace entities 35 | 36 | inline namespace interfaces { 37 | struct entity_identities_t { 38 | entity_identity_t m_identities[ k_max_entities_in_list ]; 39 | }; 40 | 41 | // The entity system utilizes listeners for the events mentioned below 42 | // I almost feel like a Valve employee doing these things the intended way 43 | struct entity_listener_t { 44 | virtual void on_entity_created( entity_t *ent ) = 0; 45 | virtual void on_entity_spawned( entity_t *ent ) = 0; 46 | virtual void on_entity_deleted( entity_t *ent ) = 0; 47 | virtual void on_entity_parent_changed( entity_t *ent, entity_t *parent ) = 0; 48 | }; 49 | 50 | struct entity_system_t { 51 | entity_system_t( ) = delete; 52 | entity_system_t( entity_system_t && ) = delete; 53 | entity_system_t( const entity_system_t & ) = delete; 54 | 55 | virtual void build_resource_manifest( void ) = 0; // 01 56 | virtual void n_2( ) = 0; 57 | virtual void n_3( ) = 0; 58 | virtual void n_4( ) = 0; 59 | virtual void n_5( ) = 0; 60 | virtual void n_6( ) = 0; 61 | virtual void n_7( ) = 0; 62 | virtual void add_ref_key_values( void const *) = 0; // 7 63 | virtual void release_key_values( void const *) = 0; // 8 64 | virtual void n_9( ) = 0; 65 | virtual void n_10( ) = 0; 66 | virtual void clear_entity_database( void ) = 0; // 11 67 | virtual entity_t *find_entity_procedural( const char *... ) = 0; 68 | virtual entity_t *on_entity_parent_changed( entity_t *, entity_t * ) = 0; // 13 69 | virtual entity_t *on_add_entity( entity_t *, c_handle ) = 0; // 14 70 | virtual entity_t *on_remove_entity( entity_t *, c_handle ) = 0; // 15 71 | virtual void n_16( ) = 0; 72 | virtual void sort_entities( int, void *, int *, int *) = 0; // 17 73 | virtual void n_18( ) = 0; 74 | virtual void n_19( ) = 0; 75 | virtual void n_20( ) = 0; 76 | virtual void n_21( ) = 0; 77 | }; 78 | 79 | struct game_entity_system_t : entity_system_t { 80 | /** 81 | * @brief Retrieves the identity of a game entity by index. 82 | * 83 | * @param idx The index of the entity. 84 | * @return A pointer to the entity's identity or nullptr if out of range. 85 | */ 86 | [[nodiscard]] _INLINE entity_identity_t *get_identity( int idx ) const noexcept; 87 | 88 | /** 89 | * @brief Retrieves a pointer to a game entity. 90 | * 91 | * @param ent The handle of the entity. 92 | */ 93 | [[nodiscard]] _INLINE entity_identity_t *get_entity( c_handle ent ) const noexcept; 94 | 95 | /** 96 | * @brief Retrieves a pointer to a game entity. 97 | * 98 | * @tparam type_t The type of the entity. 99 | * @param idx The index of the entity. 100 | * @return A pointer to the entity or nullptr if not found. 101 | */ 102 | template < class type_t = entity_t > 103 | [[nodiscard]] std::add_pointer_t< type_t > get_entity( int idx ) noexcept; 104 | 105 | // Iterated in OnAddEntity/OnRemoveEntity 106 | _OFFSET( 0x10, get_identity_chunks, std::array< entity_identities_t *, k_max_entity_lists > ); 107 | 108 | // Iterated in OnAddEntity/OnRemoveEntity 109 | // Func: 8B 81 10 15 00 110 | // #STR: "(missing),", "(missing)", "Ent %3d: %s class %s name %s\n" 111 | _OFFSET( 0x1530, get_highest_entity_index, int ); 112 | 113 | // Iterated in OnAddEntity/OnRemoveEntity 114 | /* 115 | * mov eax, [rdi+1548h] 116 | * sub eax, 1 117 | * movsxd rbx, eax 118 | * js short loc_180C2D1FA 119 | */ 120 | _OFFSET( 0x1568, get_listeners, utl_vector_t< entity_listener_t * > ); 121 | }; 122 | 123 | } // namespace interfaces 124 | } // namespace hack::valve 125 | 126 | #include "entity_system.inl" -------------------------------------------------------------------------------- /deadlock/source/valve/structs/data_types/utl/utl_hash.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utl_hash.hpp" 3 | #include "vendor.hpp" 4 | 5 | namespace hack::valve::inline data_types { 6 | _INLINE constexpr std::uint32_t _HIDDEN hash_int_conventional( const int value ) noexcept { 7 | std::uint32_t hash { ( 0xAAAAAAAA ) + ( value & 0xFF ) }; 8 | hash = ( hash << 5 ) + hash + ( ( value >> 8 ) & 0xFF ); 9 | hash = ( hash << 5 ) + hash + ( ( value >> 16 ) & 0xFF ); 10 | hash = ( hash << 5 ) + hash + ( ( value >> 24 ) & 0xFF ); 11 | 12 | return hash; 13 | } 14 | 15 | template < int bucket_count_t, class key_t > 16 | constexpr int utl_ts_hash_generic_hash_t< bucket_count_t, key_t >::hash( const key_t &key, const int bucket_mask ) noexcept { 17 | int hash_value { hash_int_conventional( reinterpret_cast< std::uintptr_t >( key ) ) }; 18 | if ( bucket_count_t <= std::numeric_limits< std::uint16_t >::max( ) ) { 19 | hash_value ^= ( hash_value >> 16 ); 20 | } 21 | 22 | if ( bucket_count_t <= std::numeric_limits< std::uint8_t >::max( ) ) { 23 | hash_value ^= ( hash_value >> 8 ); 24 | } 25 | 26 | return ( hash_value & bucket_mask ); 27 | } 28 | 29 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 30 | consteval utl_ts_hash_handle_t 31 | utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::invalid_handle( ) noexcept { 32 | return 0; 33 | } 34 | 35 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 36 | utl_ts_hash_handle_t utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::find( key_t key ) noexcept { 37 | auto bucket { hash_funcs_t::hash( key, bucket_count_t ) }; 38 | const auto &hash_bucket { m_buckets[ bucket ] }; 39 | const auto hash_handle { find( key, hash_bucket.m_first, nullptr ) }; 40 | return hash_handle ? hash_handle : find( key, hash_bucket.m_first_uncommited, hash_bucket.m_first ); 41 | } 42 | 43 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 44 | int utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::get_elements( 45 | int first_element, const int count, utl_ts_hash_handle_t *elements ) const noexcept { 46 | int index { }; 47 | for ( int i { }; i < bucket_count_t; i++ ) { 48 | const auto &hash_bucket { m_buckets[ i ] }; 49 | 50 | for ( auto element { hash_bucket.m_first_uncommited }; element; element = element->m_next ) { 51 | if ( --first_element >= 0 ) 52 | continue; 53 | 54 | elements[ index++ ] = reinterpret_cast< utl_ts_hash_handle_t >( element ); 55 | if ( index >= count ) 56 | return index; 57 | } 58 | } 59 | 60 | return index; 61 | } 62 | 63 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 64 | element_t &utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::element( utl_ts_hash_handle_t hash ) noexcept { 65 | return reinterpret_cast< hash_fixed_data_t * >( hash )->get_data( ); 66 | } 67 | 68 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 69 | const element_t & 70 | utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::element( utl_ts_hash_handle_t hash ) const noexcept { 71 | return reinterpret_cast< hash_fixed_data_t * >( hash )->m_data; 72 | } 73 | 74 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 75 | element_t & 76 | utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::operator[] ( utl_ts_hash_handle_t hash ) noexcept { 77 | return reinterpret_cast< hash_fixed_data_t * >( hash )->m_data; 78 | } 79 | 80 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 81 | const element_t &utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::operator[] ( 82 | utl_ts_hash_handle_t hash ) const noexcept { 83 | return reinterpret_cast< hash_fixed_data_t * >( hash )->m_data; 84 | } 85 | 86 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 87 | key_t utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::get_id( utl_ts_hash_handle_t hash ) noexcept { 88 | return reinterpret_cast< hash_fixed_data_t * >( hash )->m_key; 89 | } 90 | 91 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 92 | template < typename data_t > 93 | std::add_lvalue_reference_t< typename utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, 94 | alignment_t >::template hash_fixed_data_internal_t< data_t > * > 95 | utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, 96 | 97 | alignment_t >::hash_fixed_data_internal_t< data_t >::get_next( ) noexcept { 98 | return *reinterpret_cast< std::add_pointer_t< hash_fixed_data_internal_t< data_t > * > >( reinterpret_cast< std::uintptr_t >( this ) 99 | + 0x8 ); 100 | } 101 | 102 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 103 | template < typename data_t > 104 | std::add_lvalue_reference_t< data_t > utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, 105 | alignment_t >::hash_fixed_data_internal_t< data_t >::get_data( ) noexcept { 106 | return *reinterpret_cast< std::add_pointer_t< data_t > >( reinterpret_cast< std::uintptr_t >( this ) + 0x10 ); 107 | } 108 | 109 | template < class element_t, int bucket_count_t, class key_t, class hash_funcs_t, int alignment_t > 110 | utl_ts_hash_handle_t 111 | utl_ts_hash_t< element_t, bucket_count_t, key_t, hash_funcs_t, alignment_t >::find( key_t key, hash_fixed_data_t *first_element, 112 | hash_fixed_data_t *last_element ) noexcept { 113 | for ( auto element { first_element }; element != last_element; element = element->m_next ) { 114 | if ( hash_funcs_t::compare( element->m_key, key ) ) 115 | return reinterpret_cast< utl_ts_hash_handle_t >( element ); 116 | } 117 | 118 | return invalid_handle( ); 119 | } 120 | } // namespace hack::cs2::inline data_types -------------------------------------------------------------------------------- /deadlock/source/utils/memory/base_address/base_address.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vendor.hpp" 4 | 5 | namespace hack::utils::inline memory { 6 | /** 7 | * @class c_base_address 8 | * @brief A generic address manipulation class that operates on unsigned integral types. 9 | * 10 | * This class provides utilities for performing various pointer operations such as offsetting, 11 | * dereferencing, and type-casting for low-level memory manipulation. 12 | * 13 | * @tparam address_type The underlying address type, constrained to unsigned integral types. 14 | */ 15 | template < typename address_type = std::uintptr_t > 16 | requires std::unsigned_integral< address_type > 17 | class c_base_address { 18 | public: 19 | /// Type representing a non-constant address. 20 | using value_type = std::conditional_t< std::is_const_v< address_type >, std::remove_const_t< address_type >, address_type >; 21 | 22 | /// Type representing a constant address. 23 | using const_value_type = std::conditional_t< std::is_const_v< address_type >, address_type, std::add_const_t< address_type > >; 24 | 25 | /// Reference type for non-constant address. 26 | using reference_type = std::add_lvalue_reference_t< value_type >; 27 | 28 | /// Reference type for constant address. 29 | using const_reference_type = std::add_lvalue_reference_t< const_value_type >; 30 | 31 | /// Type for size-related values. 32 | using size_type = std::size_t; 33 | 34 | /// Type for difference or offset values. 35 | using difference_type = std::ptrdiff_t; 36 | 37 | /** 38 | * @brief Default constructor initializing an empty address. 39 | */ 40 | _INLINE constexpr c_base_address( ) noexcept = default; 41 | 42 | /** 43 | * @brief Constructs a base address with a specific address value. 44 | * 45 | * @param address The address to initialize. 46 | */ 47 | _INLINE constexpr explicit c_base_address( const_reference_type address ) noexcept; 48 | 49 | /** 50 | * @brief Constructs a base address from a pointer. 51 | * 52 | * @tparam pointer_type The pointer type being cast to the address type. 53 | * @param pointer A pointer representing the address. 54 | */ 55 | template < typename pointer_type = std::add_pointer< std::uint8_t > > 56 | requires std::is_pointer_v< pointer_type > 57 | _INLINE constexpr explicit c_base_address( pointer_type pointer ) noexcept; 58 | 59 | /** 60 | * @brief Assigns a new address to the current object. 61 | * 62 | * @param address The address to assign. 63 | * @return Reference to the current object. 64 | */ 65 | _INLINE constexpr c_base_address &operator= ( const_reference_type address ) noexcept; 66 | 67 | /** 68 | * @brief Assigns an address from a void pointer. 69 | * 70 | * @param address A void pointer representing the new address. 71 | * @return Reference to the current object. 72 | */ 73 | _INLINE constexpr c_base_address &operator= ( const void *const address ) noexcept; 74 | 75 | /** 76 | * @brief Offsets the current address by a specified value. 77 | * 78 | * @param value The offset to apply. 79 | * @return Reference to the current object. 80 | */ 81 | _INLINE constexpr c_base_address &self_offset( const difference_type value ) noexcept; 82 | 83 | /** 84 | * @brief Dereferences the current address a specified number of times. 85 | * 86 | * @param count The number of times to dereference. 87 | * @return Reference to the current object. 88 | */ 89 | _INLINE constexpr c_base_address &self_dereference( const size_type count = 1 ) noexcept; 90 | 91 | /** 92 | * @brief Returns a new address offset by a specified value. 93 | * 94 | * @param value The offset to apply. 95 | * @return A new c_base_address with the offset applied. 96 | */ 97 | [[nodiscard]] _INLINE constexpr c_base_address offset( const difference_type value ) const noexcept; 98 | 99 | /** 100 | * @brief Returns a new address after dereferencing a specified number of times. 101 | * 102 | * @param count The number of times to dereference. 103 | * @return A new c_base_address with the dereferenced value. 104 | */ 105 | [[nodiscard]] _INLINE constexpr c_base_address dereference( const size_type count = 1 ) const noexcept; 106 | 107 | /** 108 | * @brief Returns a relative address based on an offset. 109 | * 110 | * @param offset The offset for relative addressing. 111 | * @return A new c_base_address representing the relative address. 112 | */ 113 | [[nodiscard]] _INLINE constexpr c_base_address relative( const difference_type offset ) noexcept; 114 | 115 | /** 116 | * @brief Casts the current address to a specified pointer type. 117 | * 118 | * @tparam pointer_type The type of pointer to cast to. 119 | * @return The address as the specified pointer type. 120 | */ 121 | template < typename pointer_type = std::add_pointer_t< std::uint8_t > > 122 | requires std::is_pointer_v< pointer_type > 123 | [[nodiscard]] _INLINE constexpr pointer_type as( ) const noexcept; 124 | 125 | /** 126 | * @brief Compares two c_base_address objects. 127 | * 128 | * @param other The address to compare with. 129 | * @return Comparison result. 130 | */ 131 | [[nodiscard]] _INLINE constexpr auto operator<=> ( const c_base_address &other ) const noexcept = default; 132 | 133 | /** 134 | * @brief Checks if the address is null. 135 | * 136 | * @return True if address is null, otherwise false. 137 | */ 138 | [[nodiscard]] _INLINE constexpr bool operator!( ) const noexcept; 139 | 140 | /** 141 | * @brief Checks if the address is equal to nullptr. 142 | * 143 | * @return True if the address is nullptr, otherwise false. 144 | */ 145 | [[nodiscard]] _INLINE constexpr bool operator== ( std::nullptr_t ) const noexcept; 146 | 147 | /** 148 | * @brief Checks if the address is equal to a specified value. 149 | * 150 | * @tparam compare_type The type of value to compare with. 151 | * @param other The value to compare. 152 | * @return True if addresses are equal, otherwise false. 153 | */ 154 | template < typename compare_type = const_value_type > 155 | [[nodiscard]] _INLINE constexpr bool operator== ( const compare_type &other ) const noexcept; 156 | 157 | /** 158 | * @brief Converts the address to its underlying value type. 159 | * 160 | * @return The address as value_type. 161 | */ 162 | [[nodiscard]] _INLINE constexpr explicit operator value_type ( ) const noexcept; 163 | 164 | protected: 165 | /// The underlying address value. 166 | address_type m_address { }; 167 | }; 168 | 169 | /// Alias for `c_base_address` using `std::uintptr_t` as the address type. 170 | using base_address_t = c_base_address< std::uintptr_t >; 171 | } // namespace hack::utils::inline memory 172 | 173 | #include "base_address.inl" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | /dll/dbg 365 | /dll/rel 366 | -------------------------------------------------------------------------------- /deadlock/third_party/minhk/minhook.hpp: -------------------------------------------------------------------------------- 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 | // pszProcName [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 | // pszProcName [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 | -------------------------------------------------------------------------------- /deadlock/source/systems/module_parser/ldr_module/ldr_module.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ldr_module.hpp" 3 | 4 | namespace hack::systems::inline memory { 5 | _INLINE systems::ldr_module_t::ldr_module_t( const utils::base_address_t &address ) noexcept : m_base_address { address } { } 6 | 7 | _INLINE utils::base_address_t ldr_module_t::get_base_address( ) const noexcept { 8 | return utils::base_address_t { this->m_base_address.as< const utils::ldr_data_table_entry * >( )->m_dll_base }; 9 | } 10 | 11 | _INLINE std::wstring ldr_module_t::get_wname( const e_name_case name_case ) const noexcept { 12 | _ASSERT( name_case != e_name_case::e_unknown ); 13 | 14 | const auto *const base_name { &this->m_base_address.as< const utils::ldr_data_table_entry * >( )->m_base_dll_name }; 15 | 16 | _ASSERT( base_name->m_buffer != nullptr && base_name->m_length != 0 ); 17 | 18 | auto stl_name { 19 | std::wstring {base_name->m_buffer, base_name->m_length / sizeof( wchar_t )} 20 | }; 21 | 22 | _ASSERT( !stl_name.empty( ) ); 23 | 24 | switch ( name_case ) { 25 | case e_name_case::e_unmodified : 26 | break; 27 | case e_name_case::e_lowercase : 28 | std::ranges::transform( stl_name, stl_name.begin( ), towlower ); 29 | break; 30 | case e_name_case::e_uppercase : 31 | std::ranges::transform( stl_name, stl_name.begin( ), towupper ); 32 | break; 33 | default : 34 | _ASSERT( false ); 35 | } 36 | 37 | return stl_name; 38 | } 39 | 40 | _INLINE std::string ldr_module_t::get_name( const e_name_case name_case ) const noexcept { 41 | _ASSERT( name_case != e_name_case::e_unknown ); 42 | 43 | const auto wname { this->get_wname( name_case ) }; 44 | 45 | _ASSERT( !wname.empty( ) ); 46 | 47 | return { wname.cbegin( ), wname.cend( ) }; 48 | } 49 | 50 | _INLINE utils::image_nt_headers_64 *ldr_module_t::get_nt_headers( ) const { 51 | const auto base_address { m_base_address }; 52 | 53 | _ASSERT( base_address != nullptr ); 54 | 55 | static constexpr auto dos_header_signature { 0x5A4D }; 56 | static constexpr auto nt_headers_signature { 0x4550 }; 57 | 58 | const auto dos_header { base_address.as< const utils::image_dos_header * >( ) }; 59 | 60 | _ASSERT( dos_header != nullptr && dos_header->m_magic == dos_header_signature ); 61 | 62 | const auto nt_headers { base_address.offset( dos_header->m_lfanew ).as< utils::image_nt_headers_64 * >( ) }; 63 | 64 | _ASSERT( nt_headers != nullptr && nt_headers->m_signature == nt_headers_signature ); 65 | return nt_headers; 66 | } 67 | 68 | _INLINE std::vector< std::optional< std::byte > > ldr_module_t::pattern_to_bytes( const std::string_view pattern ) noexcept { 69 | std::vector< std::optional< std::byte > > bytes = { }; 70 | 71 | const auto start { pattern.data( ) }; 72 | const auto end { start + pattern.size( ) }; 73 | 74 | for ( auto current { start }; current < end; ++current ) { 75 | if ( *current == '?' ) { 76 | ++current; 77 | if ( *current == '?' ) 78 | ++current; 79 | 80 | bytes.emplace_back( std::nullopt ); 81 | } else 82 | bytes.emplace_back( static_cast< std::byte >( std::strtoul( current, const_cast< char ** >( ¤t ), 16 ) ) ); 83 | } 84 | 85 | return bytes; 86 | } 87 | 88 | _INLINE utils::base_address_t ldr_module_t::find_interface( const std::string_view interface_name ) const noexcept { 89 | const auto base_address { this->get_base_address( ) }; 90 | 91 | _ASSERT( base_address != nullptr ); 92 | 93 | const auto interface_func_addr { this->get_export_address( "CreateInterface" ) }; 94 | 95 | _ASSERT( interface_func_addr != nullptr ); 96 | 97 | const auto create_interface { interface_func_addr.as< fastcall_t< void *, const char *, int * > >( ) }; 98 | 99 | return utils::base_address_t( create_interface( interface_name.data( ), nullptr ) ); 100 | } 101 | 102 | _INLINE utils::base_address_t ldr_module_t::find_pattern( const std::string_view pattern ) const noexcept { 103 | const auto bytes { pattern_to_bytes( pattern ) }; 104 | 105 | _ASSERT( !bytes.empty( ) ); 106 | 107 | const auto base_address { this->get_base_address( ) }; 108 | 109 | _ASSERT( base_address != nullptr ); 110 | 111 | const auto *const optional_header { get_optional_header( base_address ).as< const utils::image_optional_header_64 * >( ) }; 112 | 113 | _ASSERT( optional_header != nullptr ); 114 | 115 | const auto size_of_image { optional_header->m_size_of_image }; 116 | 117 | _ASSERT( size_of_image != 0 ); 118 | 119 | const auto scan_bytes { 120 | std::span {base_address.as< const std::byte * >( ), size_of_image} 121 | }; 122 | 123 | for ( auto i { std::size_t {} }; i < scan_bytes.size( ); ++i ) { 124 | auto found { true }; 125 | 126 | for ( auto j { std::size_t {} }; j < bytes.size( ); ++j ) { 127 | if ( bytes.at( j ) == std::nullopt ) 128 | continue; 129 | 130 | if ( scan_bytes[ i + j ] != bytes.at( j ) ) { 131 | found = false; 132 | break; 133 | } 134 | } 135 | 136 | if ( found ) { 137 | return base_address.offset( static_cast< std::ptrdiff_t >( i ) ); 138 | } 139 | } 140 | 141 | return { }; 142 | } 143 | 144 | _INLINE constexpr utils::base_address_t ldr_module_t::get_data_directory( const utils::base_address_t &base_address, 145 | const e_data_directory data_directory ) noexcept { 146 | _ASSERT( base_address != nullptr 147 | && ( data_directory >= e_data_directory::e_export && data_directory <= e_data_directory::e_com_descriptor ) ); 148 | 149 | const auto *const optional_header { get_optional_header( base_address ).as< const utils::image_optional_header_64 * >( ) }; 150 | 151 | _ASSERT( optional_header != nullptr 152 | && static_cast< const std::uint16_t >( data_directory ) < optional_header->m_data_directory.size( ) ); 153 | 154 | const auto data_directory_entry { optional_header->m_data_directory.at( static_cast< const std::uint16_t >( data_directory ) ) }; 155 | 156 | _ASSERT( data_directory_entry.m_virtual_address != 0 && data_directory_entry.m_size != 0 ); 157 | 158 | return base_address.offset( data_directory_entry.m_virtual_address ); 159 | } 160 | 161 | _INLINE constexpr utils::base_address_t ldr_module_t::get_export_address( const std::string_view procedure_name ) const noexcept { 162 | _ASSERT( !procedure_name.empty( ) ); 163 | return utils::base_address_t { GetProcAddress( this->get_base_address( ).as< HMODULE >( ), procedure_name.data( ) ) }; 164 | } 165 | 166 | _INLINE constexpr utils::base_address_t ldr_module_t::get_optional_header( const utils::base_address_t &base_address ) noexcept { 167 | _ASSERT( base_address != nullptr ); 168 | 169 | static constexpr auto dos_header_signature { 0x5A4D }; 170 | static constexpr auto nt_headers_signature { 0x4550 }; 171 | static constexpr auto optional_header_magic { 0x20B }; 172 | 173 | const auto *const dos_header { base_address.as< const utils::image_dos_header * >( ) }; 174 | 175 | _ASSERT( dos_header != nullptr && dos_header->m_magic == dos_header_signature ); 176 | 177 | const auto *const nt_headers { base_address.offset( dos_header->m_lfanew ).as< const utils::image_nt_headers_64 * >( ) }; 178 | 179 | _ASSERT( nt_headers != nullptr && nt_headers->m_signature == nt_headers_signature ); 180 | 181 | const auto *const optional_header { &nt_headers->m_optional_header }; 182 | 183 | _ASSERT( optional_header != nullptr && optional_header->m_magic == optional_header_magic ); 184 | 185 | return utils::base_address_t { optional_header }; 186 | } 187 | } // namespace hack::systems::inline memory -------------------------------------------------------------------------------- /deadlock/source/utils/math/data_types/vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imgui/imgui.h" 3 | 4 | namespace hack::utils::inline math { 5 | enum class e_axis { 6 | x = 0, ///< X-axis (index 0) 7 | y = 1, ///< Y-axis (index 1) 8 | z = 2 ///< Z-axis (index 2) 9 | }; 10 | 11 | template < std::size_t N > 12 | struct vec_t { 13 | static_assert( N == 2 || N == 3, "Only 2D and 3D vectors are supported." ); 14 | 15 | /** 16 | * @brief Default constructor, initializes all components to zero. 17 | */ 18 | constexpr vec_t( ) noexcept = default; 19 | 20 | /** 21 | * @brief Constructor that initializes the vector with specific values. 22 | * @param args Initial values for the vector components. 23 | */ 24 | template < typename... Args > 25 | requires ( sizeof...( Args ) == N ) 26 | explicit constexpr vec_t( Args... args ) noexcept : m_data { static_cast< float >( args )... } { } 27 | 28 | /** 29 | * @brief Accesses the component at the given index. 30 | * @param i Index of the component to access (0-based). 31 | * @return Reference to the vector component. 32 | */ 33 | constexpr float &operator[] ( std::size_t i ) noexcept { 34 | return m_data[ i ]; 35 | } 36 | 37 | /** 38 | * @brief Accesses the component at the given index (const version). 39 | * @param i Index of the component to access (0-based). 40 | * @return Constant reference to the vector component. 41 | */ 42 | constexpr const float &operator[] ( std::size_t i ) const noexcept { 43 | return m_data[ i ]; 44 | } 45 | 46 | float &operator[] ( e_axis axis ) { 47 | if constexpr ( N == 2 ) { 48 | if ( axis == e_axis::z ) { 49 | throw std::out_of_range( "Z axis is not valid for 2D vectors." ); 50 | } 51 | } 52 | return m_data[ static_cast< std::size_t >( axis ) ]; 53 | } 54 | 55 | /** 56 | * @brief Adds another vector to this vector. 57 | * @param other Vector to add. 58 | * @return Reference to the resulting vector. 59 | */ 60 | constexpr vec_t &operator+= ( const vec_t &other ) noexcept { 61 | for ( std::size_t i { }; i < N; ++i ) 62 | m_data[ i ] += other[ i ]; 63 | return *this; 64 | } 65 | 66 | /** 67 | * @brief Subtracts another vector from this vector. 68 | * @param other Vector to subtract. 69 | * @return Reference to the resulting vector. 70 | */ 71 | constexpr vec_t &operator-= ( const vec_t &other ) noexcept { 72 | for ( std::size_t i { }; i < N; ++i ) 73 | m_data[ i ] -= other[ i ]; 74 | return *this; 75 | } 76 | 77 | /** 78 | * @brief Multiplies the vector by a scalar value. 79 | * @param scalar Scalar value to multiply by. 80 | * @return Reference to the resulting vector. 81 | */ 82 | constexpr vec_t &operator*= ( float scalar ) noexcept { 83 | for ( std::size_t i { }; i < N; ++i ) 84 | m_data[ i ] *= scalar; 85 | return *this; 86 | } 87 | 88 | /** 89 | * @brief Divides the vector by a scalar value. 90 | * @param scalar Scalar value to divide by. 91 | * @return Reference to the resulting vector. 92 | */ 93 | constexpr vec_t &operator/= ( float scalar ) noexcept { 94 | for ( std::size_t i { }; i < N; ++i ) 95 | m_data[ i ] /= scalar; 96 | return *this; 97 | } 98 | 99 | /** 100 | * @brief Computes the length (magnitude) of the vector. 101 | * @return Length of the vector. 102 | */ 103 | [[nodiscard]] constexpr float length( ) const noexcept { 104 | auto sum { 0.0f }; 105 | for ( const auto &val : m_data ) 106 | sum += val * val; 107 | return std::sqrt( sum ); 108 | } 109 | 110 | /** 111 | * @brief Normalizes the vector to a unit vector. 112 | * @return Normalized vector. 113 | */ 114 | [[nodiscard]] constexpr vec_t normalized( ) const noexcept { 115 | const auto len { length( ) }; 116 | return ( *this ) / ( len > 0.0f ? len : 1.0f ); // Avoid division by zero 117 | } 118 | 119 | /** 120 | * @brief Computes the dot product with another vector. 121 | * @param other Vector to compute the dot product with. 122 | * @return Dot product result. 123 | */ 124 | [[nodiscard]] constexpr float dot( const vec_t &other ) const noexcept { 125 | auto result { 0.0f }; 126 | for ( std::size_t i = 0; i < N; ++i ) 127 | result += m_data[ i ] * other[ i ]; 128 | return result; 129 | } 130 | 131 | /** 132 | * @brief Computes the cross product with another vector. 133 | * @note Only defined for 3D vectors (vec3_t). 134 | * @param other 3D vector to compute the cross product with. 135 | * @return Resulting 3D vector from the cross product. 136 | */ 137 | [[nodiscard]] constexpr vec_t< 3 > cross( const vec_t< 3 > &other ) const 138 | requires ( N == 3 ) 139 | { 140 | return vec_t< 3 > { m_data[ 1 ] * other[ 2 ] - m_data[ 2 ] * other[ 1 ], m_data[ 2 ] * other[ 0 ] - m_data[ 0 ] * other[ 2 ], 141 | m_data[ 0 ] * other[ 1 ] - m_data[ 1 ] * other[ 0 ] }; 142 | } 143 | 144 | /** 145 | * @brief Compares two vectors for equality. 146 | * @param other Vector to compare with. 147 | * @return True if vectors are equal, false otherwise. 148 | */ 149 | constexpr bool operator== ( const vec_t &other ) const noexcept = default; 150 | 151 | private: 152 | std::array< float, N > m_data { }; ///< Array holding vector components. 153 | }; 154 | 155 | /** 156 | * @brief Adds two vectors. 157 | * @tparam N Dimension of the vectors. 158 | * @param lhs Left-hand side vector. 159 | * @param rhs Right-hand side vector. 160 | * @return Resulting vector after addition. 161 | */ 162 | template < std::size_t N > 163 | constexpr vec_t< N > operator+ ( const vec_t< N > &lhs, const vec_t< N > &rhs ) noexcept { 164 | vec_t< N > result = lhs; 165 | result += rhs; 166 | return result; 167 | } 168 | 169 | /** 170 | * @brief Subtracts two vectors. 171 | * @tparam N Dimension of the vectors. 172 | * @param lhs Left-hand side vector. 173 | * @param rhs Right-hand side vector. 174 | * @return Resulting vector after subtraction. 175 | */ 176 | template < std::size_t N > 177 | constexpr vec_t< N > operator- ( const vec_t< N > &lhs, const vec_t< N > &rhs ) noexcept { 178 | vec_t< N > result = lhs; 179 | result -= rhs; 180 | return result; 181 | } 182 | 183 | /** 184 | * @brief Multiplies a vector by a scalar. 185 | * @tparam N Dimension of the vector. 186 | * @param vec Vector to multiply. 187 | * @param scalar Scalar value to multiply by. 188 | * @return Resulting vector after scalar multiplication. 189 | */ 190 | template < std::size_t N > 191 | constexpr vec_t< N > operator* ( const vec_t< N > &vec, float scalar ) noexcept { 192 | vec_t< N > result = vec; 193 | result *= scalar; 194 | return result; 195 | } 196 | 197 | /** 198 | * @brief Divides a vector by a scalar. 199 | * @tparam N Dimension of the vector. 200 | * @param vec Vector to divide. 201 | * @param scalar Scalar value to divide by. 202 | * @return Resulting vector after scalar division. 203 | */ 204 | template < std::size_t N > 205 | constexpr vec_t< N > operator/ ( const vec_t< N > &vec, float scalar ) noexcept { 206 | vec_t< N > result = vec; 207 | result /= scalar; 208 | return result; 209 | } 210 | 211 | using vec2_t = vec_t< 2 >; ///< Alias for 2D vector 212 | using vec3_t = vec_t< 3 >; ///< Alias for 3D vector 213 | } // namespace hack::utils::inline math -------------------------------------------------------------------------------- /deadlock/third_party/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // DEAR IMGUI COMPILE-TIME OPTIONS 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec( dllexport ) 27 | //#define IMGUI_API __declspec( dllimport ) 28 | 29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names. 30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 31 | //#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions. 32 | 33 | //---- Disable all of Dear ImGui or don't implement standard windows/tools. 34 | // It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp. 35 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 36 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. 37 | //#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty. 38 | 39 | //---- Don't implement some functions to reduce linkage requirements. 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 41 | //#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW) 42 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a) 43 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME). 44 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 45 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 46 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 47 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) 48 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 49 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 50 | //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available 51 | 52 | //---- Include imgui_user.h at the end of imgui.h as a convenience 53 | //#define IMGUI_INCLUDE_IMGUI_USER_H 54 | 55 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 56 | //#define IMGUI_USE_BGRA_PACKED_COLOR 57 | 58 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 59 | //#define IMGUI_USE_WCHAR32 60 | 61 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 62 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 63 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 64 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 65 | //#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined. 66 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 67 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 68 | //#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined. 69 | 70 | //---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 71 | // Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h. 72 | //#define IMGUI_USE_STB_SPRINTF 73 | 74 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 75 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 76 | // On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'. 77 | //#define IMGUI_ENABLE_FREETYPE 78 | 79 | //---- Use FreeType+lunasvg library to render OpenType SVG fonts (SVGinOT) 80 | // Requires lunasvg headers to be available in the include path + program to be linked with the lunasvg library (not provided). 81 | // Only works in combination with IMGUI_ENABLE_FREETYPE. 82 | // (implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement) 83 | //#define IMGUI_ENABLE_FREETYPE_LUNASVG 84 | 85 | //---- Use stb_truetype to build and rasterize the font atlas (default) 86 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 87 | //#define IMGUI_ENABLE_STB_TRUETYPE 88 | 89 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 90 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 91 | /* 92 | #define IM_VEC2_CLASS_EXTRA \ 93 | constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \ 94 | operator MyVec2() const { return MyVec2(x,y); } 95 | 96 | #define IM_VEC4_CLASS_EXTRA \ 97 | constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \ 98 | operator MyVec4() const { return MyVec4(x,y,z,w); } 99 | */ 100 | //---- ...Or use Dear ImGui's own very basic math operators. 101 | #define IMGUI_DEFINE_MATH_OPERATORS 102 | 103 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 104 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 105 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 106 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 107 | //#define ImDrawIdx unsigned int 108 | 109 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 110 | //struct ImDrawList; 111 | //struct ImDrawCmd; 112 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 113 | //#define ImDrawCallback MyImDrawCallback 114 | 115 | //---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase) 116 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 117 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 118 | //#define IM_DEBUG_BREAK __debugbreak() 119 | 120 | //---- Debug Tools: Enable slower asserts 121 | //#define IMGUI_DEBUG_PARANOID 122 | 123 | //---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files) 124 | /* 125 | namespace ImGui 126 | { 127 | void MyFunction(const char* name, MyMatrix44* mtx); 128 | } 129 | */ 130 | --------------------------------------------------------------------------------