|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>#include "dttr_crashdump.h"#include "graphics/graphics_com_private.h"#include "inputs/inputs_private.h"#include <dttr_config.h>#include <dttr_log.h>#include <dttr_path.h>#include <sds.h>#include <SDL3/SDL.h>#include "audio/hooks_private.h"#include "dttr_errors.h"#include "dttr_hooks.h"#include "game/hooks_private.h"#include "graphics/graphics_private.h"#include "graphics/hooks_private.h"#include "inputs/hooks_private.h"#include "movies/hooks_private.h"#include "movies/movies_private.h"#include "sidecar_private.h"#include <dttr_pcdogs.h>#include <dttr_runtime.h>#include <xxhash.h>Go to the source code of this file.
Macros | |
| #define | after_sdl_event(event, consumed) |
| #define | REQUIRE_PCDOGS_CALL(expr_) |
Enumerations | |
| enum | dttr_startup_movies_result { DTTR_STARTUP_MOVIES_CONTINUE , DTTR_STARTUP_MOVIES_QUIT , DTTR_STARTUP_MOVIES_FAILED } |
Variables | |
| HINSTANCE | dttr_sidecar_module |
| char | dttr_loader_dir [MAX_PATH] |
| char | dttr_exe_hash [DTTR_EXE_HASH_LENGTH+1] |
| static HMODULE | pc_dogs_module |
| static DTTR_Mods_Context | sidecar_ctx |
| static const DTTR_Mods_API | MOD_API |
| static const DTTR_Core_API | RUNTIME_API |
| #define after_sdl_event | ( | event, | |
| consumed ) |
Definition at line 295 of file entrypoint.c.
Referenced by dttr_sidecar_handle_sdl_event().
| #define REQUIRE_PCDOGS_CALL | ( | expr_ | ) |
Definition at line 313 of file entrypoint.c.
Referenced by attempt_play_startup_movies(), DTTR_Hook_WinMainCallback(), dttr_sidecar_handle_sdl_event(), initialize_pcdogs_runtime(), start_pcdogs_runtime(), and tick_main_loop().
| Enumerator | |
|---|---|
| DTTR_STARTUP_MOVIES_CONTINUE | |
| DTTR_STARTUP_MOVIES_QUIT | |
| DTTR_STARTUP_MOVIES_FAILED | |
Definition at line 439 of file entrypoint.c.
|
static |
Definition at line 497 of file entrypoint.c.
References dttr_config, DTTR_LOG_WARN, DTTR_MOVIE_ENDED, DTTR_MOVIE_QUIT, dttr_movies_is_playing(), dttr_movies_start(), dttr_movies_stop(), DTTR_Path_AppendSegment(), DTTR_PCDOGS_D_Input_ProcessWindowMessages_ShouldQuit, DTTR_PCDOGS_D_Video_PlayMovieIntro_FileNames, DTTR_PCDOGS_D_Video_PlayMovieIntro_PathPrefix, dttr_sidecar_poll_sdl_events(), DTTR_STARTUP_MOVIES_CONTINUE, DTTR_STARTUP_MOVIES_FAILED, DTTR_STARTUP_MOVIES_QUIT, REQUIRE_PCDOGS_CALL, and tick_main_loop().
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 392 of file entrypoint.c.
References ctx, dttr_audio_cleanup(), DTTR_Core_HookCleanupAll(), dttr_game_data_cleanup(), dttr_game_hooks_cleanup(), dttr_graphics_cleanup(), dttr_graphics_hooks_cleanup(), dttr_imgui_cleanup(), dttr_inputs_cleanup(), dttr_inputs_hooks_cleanup(), dttr_mods_cleanup(), dttr_movies_cleanup(), dttr_movies_hooks_cleanup(), and dttr_pcdogs_crash_symbols_clear().
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 203 of file entrypoint.c.
References dttr_exe_hash, DTTR_LOG_ERROR, DWORD, free, NULL, pc_dogs_module, and set_default_exe_hash().
Referenced by DTTR_Hook_WinMainCallback().
Definition at line 766 of file entrypoint.c.
References BOOL, dttr_sidecar_module, DTTR_UNWRAP_WINAPI_EXISTS, DWORD, install_win_main_hook(), and pc_dogs_module.
| int32_t _stdcall DTTR_Hook_WinMainCallback | ( | HINSTANCE | hInstance, |
| HINSTANCE | hPrevInstance, | ||
| LPSTR | lpCmdLine, | ||
| int32_t | nCmdShow ) |
Callback target for the patched game Window_RunWinMain routine.
Definition at line 574 of file entrypoint.c.
References attempt_play_startup_movies(), cleanup(), cleanup_runtime(), compute_exe_hash(), ctx, dttr_backend, dttr_config, DTTR_CONFIG_FILENAME, DTTR_Config_Load(), DTTR_CrashDump_Init(), DTTR_FATAL, dttr_game_data_init(), dttr_graphics_get_device(), dttr_graphics_get_window(), dttr_graphics_init(), dttr_graphics_mod_device_created(), dttr_graphics_mod_device_restored(), dttr_graphics_mod_window_created(), dttr_imgui_init(), dttr_inputs_late_init(), dttr_loader_dir, DTTR_Log_AddFP(), DTTR_LOG_ERROR, DTTR_LOG_INFO, DTTR_Log_SetLevel(), DTTR_LOG_WARN, dttr_mods_init(), dttr_mods_input_mode_changed(), dttr_mods_late_init(), dttr_mods_overlay_visible_changed(), DTTR_Path_CopySds(), DTTR_Path_ResolveRelativeTo(), dttr_pcdogs_crash_symbols_register(), DTTR_PCDOGS_D_Audio_InitializeSystem_DigitalDriver, DTTR_PCDOGS_D_Input_ProcessWindowMessages_ShouldQuit, DTTR_PCDOGS_D_Window_MainHandle, DTTR_PCDOGS_D_Window_ProcessGameProc_Initialized, DTTR_PCDOGS_D_Window_RunWinMain_RenderingEnabled, DTTR_PCDOGS_D_Window_RunWinMain_SecondaryWindowHandle, DTTR_PCDOGS_ResolveAll(), dttr_sidecar_context(), dttr_sidecar_module, dttr_sidecar_poll_sdl_events(), DTTR_STARTUP_MOVIES_FAILED, DTTR_STARTUP_MOVIES_QUIT, get_config_path(), get_loader_dir(), init_sidecar_context(), initialize_pcdogs_runtime(), install_required_sidecar_hooks(), NULL, pc_dogs_module, REQUIRE_PCDOGS_CALL, start_pcdogs_runtime(), and tick_main_loop().
Referenced by install_win_main_hook().
| const DTTR_Mods_Context * dttr_sidecar_context | ( | ) |
Definition at line 152 of file entrypoint.c.
References sidecar_ctx.
Referenced by DTTR_Hook_WinMainCallback(), DTTR_STORAGE_SLOT(), and init_mod().
Definition at line 316 of file entrypoint.c.
References after_sdl_event, dttr_audio_handle_device_event(), dttr_graphics_handle_window_resize(), dttr_imgui_process_event(), dttr_inputs_handle_device_event(), dttr_mods_before_event(), dttr_mods_handle_event(), dttr_movies_handle_event(), DTTR_PCDOGS_D_Input_ProcessWindowMessages_ShouldQuit, event, REQUIRE_PCDOGS_CALL, and toggle_fullscreen().
Referenced by dttr_sidecar_poll_sdl_events(), and DTTR_STORAGE_SLOT().
| void dttr_sidecar_poll_sdl_events | ( | ) |
Definition at line 383 of file entrypoint.c.
References dttr_sidecar_handle_sdl_event(), and event.
Referenced by attempt_play_startup_movies(), DTTR_Hook_WinMainCallback(), dttr_movies_hook_movie_play_file_callback(), and DTTR_STORAGE_SLOT().
| const DTTR_Core_Context * dttr_sidecar_runtime_context | ( | ) |
Definition at line 156 of file entrypoint.c.
References sidecar_ctx.
Referenced by dttr_hook_resolve_pcdogs_path_callback(), dttr_inputs_hook_dinput_poll_callback(), DTTR_STORAGE_SLOT(), file_open_with_mode(), handle_audio_device_removed(), and tick_main_loop().
|
static |
Definition at line 42 of file entrypoint.c.
Referenced by dttr_sidecar_write_exception_report().
|
static |
Definition at line 60 of file entrypoint.c.
References DTTR_Mods_ExceptionReportRequest::context, DTTR_CrashDump_FormatStackTrace(), DTTR_CrashDump_Write(), dttr_sidecar_store_sds(), DTTR_Mods_ExceptionReport::dump_path, DTTR_Mods_ExceptionReport::dump_written, DWORD, DTTR_Mods_ExceptionReportRequest::exception_record, FALSE, NULL, DTTR_Mods_ExceptionReport::stack_trace, DTTR_Mods_ExceptionReport::stack_trace_written, DTTR_Mods_ExceptionReport::struct_size, DTTR_Mods_ExceptionReportRequest::struct_size, DTTR_Mods_ExceptionReportRequest::thread_id, and DTTR_Mods_ExceptionReport::win32_error.
|
static |
Definition at line 275 of file entrypoint.c.
References DTTR_CONFIG_FILENAME.
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 260 of file entrypoint.c.
References DTTR_Path_ModuleDir(), dttr_sidecar_module, and NULL.
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 161 of file entrypoint.c.
References dttr_config, dttr_exe_hash, dttr_loader_dir, DTTR_SDK_ABI_VERSION, MOD_API, NULL, RUNTIME_API, and sidecar_ctx.
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 415 of file entrypoint.c.
References ctx, DTTR_PCDOGS_F_D3D_InitializeGraphicsSubsystem, DTTR_PCDOGS_F_PKG_FindAndOpenFile, DTTR_PCDOGS_F_PKG_InitializeResourceGameEngine, DTTR_PCDOGS_F_PKG_InitializeSystem, NULL, and REQUIRE_PCDOGS_CALL.
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 182 of file entrypoint.c.
References ctx, dttr_audio_init(), dttr_game_hooks_init(), dttr_graphics_hooks_init(), dttr_inputs_hooks_init(), dttr_inputs_init(), dttr_movies_hooks_init(), and dttr_movies_init().
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 552 of file entrypoint.c.
References DTTR_Core_HookPatchBytes(), DTTR_Core_HookSigscan(), DTTR_Hook_WinMainCallback(), and pc_dogs_module.
Referenced by DllMain().
|
static |
Definition at line 300 of file entrypoint.c.
References DTTR_LOG_ERROR, DTTR_ResultOK(), and dttr_sidecar_result_detail().
|
static |
Definition at line 198 of file entrypoint.c.
References dttr_exe_hash.
Referenced by compute_exe_hash().
|
static |
Definition at line 429 of file entrypoint.c.
References ctx, DTTR_PCDOGS_F_Config_LoadAlternateFromINI, DTTR_PCDOGS_F_Display_SetMode, DTTR_PCDOGS_F_Input_ResetState, and REQUIRE_PCDOGS_CALL.
Referenced by DTTR_Hook_WinMainCallback().
|
static |
Definition at line 446 of file entrypoint.c.
References dttr_graphics_begin_frame(), dttr_graphics_end_frame(), dttr_mods_game_frame_advanced(), dttr_mods_game_frame_blocked(), dttr_mods_should_advance_game_frame(), dttr_mods_tick(), dttr_movies_is_playing(), dttr_movies_tick(), DTTR_PCDOGS_D_Window_RunWinMain_RenderingEnabled, DTTR_PCDOGS_F_Graphics_RenderFrame, dttr_sidecar_runtime_context(), and REQUIRE_PCDOGS_CALL.
Referenced by attempt_play_startup_movies(), and DTTR_Hook_WinMainCallback().
|
static |
Definition at line 281 of file entrypoint.c.
References dttr_backend, and DTTR_LOG_WARN.
Referenced by dttr_sidecar_handle_sdl_event().
| char dttr_exe_hash[DTTR_EXE_HASH_LENGTH+1] |
Definition at line 37 of file entrypoint.c.
Referenced by build_save_slot_dir(), compute_exe_hash(), init_sidecar_context(), kvec_t(), and set_default_exe_hash().
| char dttr_loader_dir[MAX_PATH] |
Definition at line 36 of file entrypoint.c.
Referenced by build_saves_dir(), DTTR_Hook_WinMainCallback(), init_sidecar_context(), kvec_t(), and resolve_mods_dir().
| HINSTANCE dttr_sidecar_module |
Definition at line 35 of file entrypoint.c.
Referenced by DllMain(), DTTR_Hook_WinMainCallback(), and get_loader_dir().
|
static |
Definition at line 130 of file entrypoint.c.
Referenced by init_sidecar_context().
|
static |
Definition at line 39 of file entrypoint.c.
Referenced by compute_exe_hash(), DllMain(), DTTR_Hook_WinMainCallback(), and install_win_main_hook().
|
static |
Definition at line 139 of file entrypoint.c.
Referenced by init_sidecar_context().
|
static |
Definition at line 40 of file entrypoint.c.
Referenced by dttr_sidecar_context(), dttr_sidecar_runtime_context(), and init_sidecar_context().