|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include "../graphics/graphics_private.h"#include "mods_private.h"#include "sidecar_private.h"#include <dttr_runtime.h>#include <dttr_config.h>#include <dttr_errors.h>#include <dttr_log.h>#include <dttr_path.h>#include <kvec.h>#include <sds.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | MOD_MAX_SHADOW_ATTEMPTS 32 |
| #define | MOD_RELOAD_STABLE_MS 500u |
| #define | MOD_RELOAD_POLL_MS 1000u |
| #define | MOD_WITH_OWNER(mod, call) |
| #define | MOD_DISPATCH(field, ...) |
| #define | MOD_OPTIONAL_EXPORTS(X) |
| #define | LOAD_OPTIONAL_EXPORT(field, fn_type, symbol) |
| #define LOAD_OPTIONAL_EXPORT | ( | field, | |
| fn_type, | |||
| symbol ) |
Referenced by load_optional_exports().
| #define MOD_DISPATCH | ( | field, | |
| ... ) |
Definition at line 120 of file mods.c.
Referenced by dttr_mods_after_event(), dttr_mods_after_game_frame(), dttr_mods_after_present(), dttr_mods_before_game_frame(), dttr_mods_before_present(), dttr_mods_frame_begin(), dttr_mods_frame_end(), dttr_mods_game_frame_advanced(), dttr_mods_game_frame_blocked(), dttr_mods_graphics_device_created(), dttr_mods_graphics_device_destroying(), dttr_mods_graphics_device_lost(), dttr_mods_graphics_device_restored(), dttr_mods_imgui_begin(), dttr_mods_imgui_end(), dttr_mods_input_mode_changed(), dttr_mods_late_init(), dttr_mods_overlay_visible_changed(), dttr_mods_render(), dttr_mods_render_game(), dttr_mods_window_created(), dttr_mods_window_destroying(), and dttr_mods_window_resized().
| #define MOD_MAX_SHADOW_ATTEMPTS 32 |
Definition at line 17 of file mods.c.
Referenced by make_shadow_path().
| #define MOD_OPTIONAL_EXPORTS | ( | X | ) |
Definition at line 130 of file mods.c.
Referenced by load_optional_exports().
| #define MOD_RELOAD_POLL_MS 1000u |
Definition at line 19 of file mods.c.
Referenced by attempt_hot_reload_mods().
| #define MOD_RELOAD_STABLE_MS 500u |
Definition at line 18 of file mods.c.
Referenced by should_reload_now().
| #define MOD_WITH_OWNER | ( | mod, | |
| call ) |
Definition at line 113 of file mods.c.
Referenced by dispatch_event_until_consumed(), dttr_mods_should_advance_game_frame(), dttr_mods_tick(), and unload_mod().
|
static |
Definition at line 578 of file mods.c.
References dttr_config, DWORD, MOD_RELOAD_POLL_MS, and scan_mods().
Referenced by dttr_mods_tick().
|
static |
Definition at line 173 of file mods.c.
References loaded_mod::shadow_path.
Referenced by prepare_mod(), and unload_mod().
|
static |
Definition at line 94 of file mods.c.
References loaded_mod::context, free, and NULL.
Referenced by unload_mod().
|
static |
Definition at line 686 of file mods.c.
References loaded_mod::before_event, event, loaded_mod::event, and MOD_WITH_OWNER.
Referenced by dttr_mods_before_event(), and dttr_mods_handle_event().
Definition at line 708 of file mods.c.
References event, and MOD_DISPATCH.
| void dttr_mods_after_game_frame | ( | const DTTR_Mods_FrameContext * | ctx | ) |
Definition at line 630 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_after_present | ( | const DTTR_Mods_PresentContext * | ctx | ) |
Definition at line 638 of file mods.c.
References ctx, and MOD_DISPATCH.
| bool dttr_mods_before_event | ( | const SDL_Event * | event | ) |
Definition at line 704 of file mods.c.
References dispatch_event_until_consumed(), and event.
Referenced by dttr_sidecar_handle_sdl_event().
| void dttr_mods_before_game_frame | ( | const DTTR_Mods_FrameContext * | ctx | ) |
Definition at line 626 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_before_present | ( | const DTTR_Mods_PresentContext * | ctx | ) |
Definition at line 634 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_cleanup | ( | ) |
Definition at line 788 of file mods.c.
References remove_all_mods().
Referenced by cleanup_runtime().
| void dttr_mods_frame_begin | ( | const DTTR_Mods_FrameContext * | ctx | ) |
Definition at line 622 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_frame_end | ( | const DTTR_Mods_FrameContext * | ctx | ) |
Definition at line 642 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_game_frame_advanced | ( | ) |
| void dttr_mods_game_frame_blocked | ( | ) |
| void dttr_mods_graphics_device_created | ( | const DTTR_Mods_GraphicsContext * | ctx | ) |
Definition at line 670 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_graphics_device_destroying | ( | const DTTR_Mods_GraphicsContext * | ctx | ) |
Definition at line 682 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_graphics_device_lost | ( | const DTTR_Mods_GraphicsContext * | ctx | ) |
Definition at line 674 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_graphics_device_restored | ( | const DTTR_Mods_GraphicsContext * | ctx | ) |
Definition at line 678 of file mods.c.
References ctx, and MOD_DISPATCH.
| bool dttr_mods_handle_event | ( | const SDL_Event * | event | ) |
Definition at line 759 of file mods.c.
References dispatch_event_until_consumed(), and event.
Referenced by dttr_sidecar_handle_sdl_event().
| bool dttr_mods_hot_reload_enabled | ( | ) |
Definition at line 784 of file mods.c.
References dttr_config.
| void dttr_mods_imgui_begin | ( | const DTTR_Mods_RenderContext * | ctx | ) |
Definition at line 646 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_imgui_end | ( | const DTTR_Mods_RenderContext * | ctx | ) |
Definition at line 650 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_init | ( | ) |
Definition at line 592 of file mods.c.
References DTTR_LOG_INFO, resolve_mods_dir(), and scan_mods().
Referenced by DTTR_Hook_WinMainCallback().
| void dttr_mods_input_mode_changed | ( | const DTTR_Mods_InputContext * | ctx | ) |
Definition at line 712 of file mods.c.
References ctx, and MOD_DISPATCH.
Referenced by DTTR_Hook_WinMainCallback().
| void dttr_mods_late_init | ( | ) |
Definition at line 618 of file mods.c.
References MOD_DISPATCH.
Referenced by DTTR_Hook_WinMainCallback().
| DWORD dttr_mods_loaded_elapsed_ms | ( | size_t | index | ) |
| const char * dttr_mods_loaded_name | ( | size_t | index | ) |
Definition at line 767 of file mods.c.
References loaded_mod::display_name, loaded_mod::filename, and NULL.
| void dttr_mods_overlay_visible_changed | ( | bool | visible | ) |
Definition at line 654 of file mods.c.
References MOD_DISPATCH.
Referenced by DTTR_Hook_WinMainCallback().
| void dttr_mods_render | ( | const DTTR_Mods_RenderContext * | ctx | ) |
Definition at line 755 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_render_game | ( | const DTTR_Mods_RenderGameContext * | ctx | ) |
Definition at line 751 of file mods.c.
References ctx, and MOD_DISPATCH.
| bool dttr_mods_should_advance_game_frame | ( | ) |
Definition at line 716 of file mods.c.
References MOD_WITH_OWNER, and loaded_mod::should_advance_game_frame.
Referenced by tick_main_loop().
| void dttr_mods_tick | ( | ) |
Definition at line 605 of file mods.c.
References attempt_hot_reload_mods(), MOD_WITH_OWNER, and loaded_mod::tick.
Referenced by tick_main_loop().
| void dttr_mods_window_created | ( | const DTTR_Mods_WindowContext * | ctx | ) |
Definition at line 658 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_window_destroying | ( | const DTTR_Mods_WindowContext * | ctx | ) |
Definition at line 666 of file mods.c.
References ctx, and MOD_DISPATCH.
| void dttr_mods_window_resized | ( | const DTTR_Mods_WindowContext * | ctx | ) |
Definition at line 662 of file mods.c.
References ctx, and MOD_DISPATCH.
|
static |
Definition at line 43 of file mods.c.
References mod_file_id::size_high, mod_file_id::size_low, and mod_file_id::write_time.
Referenced by should_reload_now().
|
static |
Definition at line 182 of file mods.c.
Referenced by scan_mod_file().
|
static |
|
static |
Definition at line 349 of file mods.c.
References loaded_mod::context, DTTR_Core_HookSetOwner(), DTTR_LOG_WARN, dttr_sidecar_context(), loaded_mod::filename, get_mod_info(), loaded_mod::hook_owner, loaded_mod::info, loaded_mod::init, loaded_mod::initialized, loaded_mod::loaded_at_ms, log_mod_info(), refresh_mod_context(), loaded_mod::reload_pending, set_mod_display_name(), and unload_mod().
Referenced by load_mod(), and reload_mod().
|
static |
Definition at line 66 of file mods.c.
References DTTR_MODS_SHADOW_PREFIX.
Referenced by scan_mod_file().
| typedef kvec_t | ( | loaded_mod | ) |
Definition at line 21 of file mods.c.
References DTTR_Mods_Context::abi_version, DTTR_Mods_Context::api, DTTR_Mods_Context::config, dttr_exe_hash, dttr_graphics_get_window(), dttr_loader_dir, DWORD, DTTR_Mods_Context::runtime, DTTR_Mods_Context::sidecar_module, and DTTR_Mods_API::struct_size.
|
static |
Definition at line 396 of file mods.c.
References DTTR_LOG_INFO, DTTR_LOG_WARN, init_mod(), MODS_MAX, and prepare_mod().
Referenced by scan_mod_file().
|
static |
Definition at line 289 of file mods.c.
References LOAD_OPTIONAL_EXPORT, and MOD_OPTIONAL_EXPORTS.
Referenced by prepare_mod().
|
static |
Definition at line 61 of file mods.c.
References DTTR_LOG_INFO, and loaded_mod::filename.
Referenced by remove_all_mods(), and remove_missing_mods().
|
static |
Definition at line 80 of file mods.c.
References DTTR_Mods_Info::author, DTTR_LOG_INFO, DTTR_Mods_Info::name, and DTTR_Mods_Info::version.
Referenced by init_mod().
|
static |
Definition at line 48 of file mods.c.
Referenced by scan_mod_file().
|
static |
Definition at line 56 of file mods.c.
References DTTR_Path_AppendSegment().
Referenced by make_shadow_path(), scan_mod_file(), and scan_mods().
|
static |
Definition at line 244 of file mods.c.
References DTTR_MODS_SHADOW_PREFIX, DTTR_Path_CopySds(), DWORD, loaded_mod::filename, make_mod_path(), MOD_MAX_SHADOW_ATTEMPTS, NULL, loaded_mod::shadow_path, and loaded_mod::source_path.
Referenced by prepare_mod().
|
static |
Definition at line 298 of file mods.c.
References loaded_mod::cleanup, delete_shadow_copy(), dttr_config, DTTR_LOG_WARN, DTTR_Path_CopyString(), loaded_mod::filename, loaded_mod::handle, loaded_mod::hook_owner, loaded_mod::init, load_optional_exports(), make_shadow_path(), loaded_mod::shadow_path, loaded_mod::source_file, loaded_mod::source_path, and unload_mod().
Referenced by load_mod(), and reload_mod().
|
static |
Definition at line 100 of file mods.c.
References loaded_mod::context, DTTR_LOG_WARN, and loaded_mod::filename.
Referenced by init_mod().
|
static |
Definition at line 419 of file mods.c.
References DTTR_LOG_INFO, loaded_mod::filename, init_mod(), prepare_mod(), remove_mod_at(), and unload_mod().
Referenced by scan_mod_file().
|
static |
Definition at line 454 of file mods.c.
References log_mod_deleted(), and remove_mod_at().
Referenced by dttr_mods_cleanup(), and scan_mods().
|
static |
Definition at line 439 of file mods.c.
References log_mod_deleted(), and remove_mod_at().
Referenced by scan_mods().
|
static |
Definition at line 225 of file mods.c.
References unload_mod().
Referenced by reload_mod(), remove_all_mods(), and remove_missing_mods().
|
static |
Definition at line 558 of file mods.c.
References dttr_loader_dir, DTTR_LOG_INFO, DTTR_Path_AppendSegment(), DTTR_Path_CopySds(), and DWORD.
Referenced by dttr_mods_init().
|
static |
Definition at line 465 of file mods.c.
References dttr_config, DTTR_Config_IsModDisabled(), DTTR_LOG_INFO, DWORD, find_mod(), is_shadow_mod(), load_mod(), make_mod_file_id(), make_mod_path(), NULL, reload_mod(), and should_reload_now().
Referenced by scan_mods().
|
static |
Definition at line 514 of file mods.c.
References DTTR_LOG_INFO, DWORD, make_mod_path(), MODS_MAX, NULL, remove_all_mods(), remove_missing_mods(), and scan_mod_file().
Referenced by attempt_hot_reload_mods(), and dttr_mods_init().
|
static |
Definition at line 75 of file mods.c.
References loaded_mod::display_name, DTTR_Path_CopyString(), loaded_mod::filename, and DTTR_Mods_Info::name.
Referenced by init_mod().
|
static |
Definition at line 376 of file mods.c.
References DWORD, file_id_equal(), MOD_RELOAD_STABLE_MS, loaded_mod::pending_file, loaded_mod::pending_since_ms, loaded_mod::reload_pending, and loaded_mod::source_file.
Referenced by scan_mod_file().
|
static |
Definition at line 193 of file mods.c.
References loaded_mod::before_unload, loaded_mod::cleanup, delete_shadow_copy(), destroy_mod_context(), DTTR_Core_HookDetachOwnerChecked(), DTTR_FATAL, DTTR_LOG_INFO, loaded_mod::filename, loaded_mod::handle, loaded_mod::hook_owner, loaded_mod::initialized, MOD_WITH_OWNER, and NULL.
Referenced by init_mod(), prepare_mod(), reload_mod(), and remove_mod_at().