102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
core.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <windows.h>
#include <dttr_core.h>
#include <dttr_pcdogs.h>
#include <dttr_runtime.h>
#include <dttr_test_support.h>

Go to the source code of this file.

Macros

#define DTTR_SDK_ENABLE_UNSTABLE

Functions

static uintptr_t sigscan_bytes (const uint8_t *bytes, size_t size, const char *sig, const char *mask)
static uintptr_t sigscan (HMODULE mod, const char *sig, const char *mask)
static DTTR_Core_Context runtime_context ()
static void test_signature_helpers_resolve_aob_patterns (void **state)
static void test_patch_group_target_failure_rolls_back_only_new_entries (void **state)
static DTTR_PCDOGS_T_File_Handlepcdogs_file_open_detour (const char *filename, const char *mode)
static BOOL pcdogs_cleanup_title_resources_detour ()
static HRESULT pcdogs_ddraw_create_ex_detour (DTTR_PCDOGS_T_Win32_GUID *guid, void **ddraw_out, DTTR_PCDOGS_T_Win32_GUID *iid, DTTR_PCDOGS_T_COM_IUnknown *outer)
static void test_pcdogs_unstable_patch_specs_match_stable_shape (void **state)
static void test_pcdogs_generated_function_patch_specs_name_current_hooks (void **state)
static void test_pcdogs_generated_title_resource_patch_specs_use_current_names (void **state)

Variables

static uint8_t sig_target [] = {0x55, 0x8B, 0xEC, 0x90, 0x90, 0xC3, 0x33, 0xC0}
static uint8_t patch_target [4]
static uint8_t group_patch_target [2]
static const DTTR_Core_API RUNTIME
static const DTTR_TestCase TEST_CASES []

Macro Definition Documentation

◆ DTTR_SDK_ENABLE_UNSTABLE

#define DTTR_SDK_ENABLE_UNSTABLE

Definition at line 1 of file core.c.

Function Documentation

◆ pcdogs_cleanup_title_resources_detour()

BOOL pcdogs_cleanup_title_resources_detour ( )
static

Definition at line 147 of file core.c.

References BOOL.

Referenced by test_pcdogs_generated_function_patch_specs_name_current_hooks().

◆ pcdogs_ddraw_create_ex_detour()

HRESULT pcdogs_ddraw_create_ex_detour ( DTTR_PCDOGS_T_Win32_GUID * guid,
void ** ddraw_out,
DTTR_PCDOGS_T_Win32_GUID * iid,
DTTR_PCDOGS_T_COM_IUnknown * outer )
static

Definition at line 151 of file core.c.

References S_OK.

Referenced by test_pcdogs_unstable_patch_specs_match_stable_shape().

◆ pcdogs_file_open_detour()

DTTR_PCDOGS_T_File_Handle * pcdogs_file_open_detour ( const char * filename,
const char * mode )
static

Definition at line 140 of file core.c.

References NULL.

Referenced by test_pcdogs_generated_function_patch_specs_name_current_hooks().

◆ runtime_context()

DTTR_Core_Context runtime_context ( )
static

◆ sigscan()

uintptr_t sigscan ( HMODULE mod,
const char * sig,
const char * mask )
static

Definition at line 45 of file core.c.

References sig_target, and sigscan_bytes().

Referenced by aob_scan_with().

◆ sigscan_bytes()

uintptr_t sigscan_bytes ( const uint8_t * bytes,
size_t size,
const char * sig,
const char * mask )
static

Definition at line 17 of file core.c.

References size.

Referenced by sigscan().

◆ test_patch_group_target_failure_rolls_back_only_new_entries()

◆ test_pcdogs_generated_function_patch_specs_name_current_hooks()

◆ test_pcdogs_generated_title_resource_patch_specs_use_current_names()

◆ test_pcdogs_unstable_patch_specs_match_stable_shape()

◆ test_signature_helpers_resolve_aob_patterns()

void test_signature_helpers_resolve_aob_patterns ( void ** state)
static

Variable Documentation

◆ group_patch_target

uint8_t group_patch_target[2]
static

Definition at line 15 of file core.c.

Referenced by test_patch_group_target_failure_rolls_back_only_new_entries().

◆ patch_target

uint8_t patch_target[4]
static

◆ RUNTIME

const DTTR_Core_API RUNTIME
static
Initial value:
= {
.sigscan = sigscan,
.hook_function = DTTR_Core_HookAttachFunction,
.hook_pointer = DTTR_Core_HookAttachPointer,
.patch_bytes = DTTR_Core_HookPatchBytes,
.hook_is_active = DTTR_Core_HookIsActive,
.unhook_checked = DTTR_Core_HookDetachChecked,
}
DTTR_Core_Hook * DTTR_Core_HookAttachPointer(uintptr_t addr, void *new_value, void **out_original)
bool DTTR_Core_HookIsActive(DTTR_Core_Hook *hook)
DTTR_Core_Hook * DTTR_Core_HookAttachFunction(uintptr_t addr, int prologue_size, void *handler, void **out_original)
DTTR_Core_Hook * DTTR_Core_HookPatchBytes(uintptr_t addr, const uint8_t *bytes, size_t size)
void DTTR_Core_HookDetach(DTTR_Core_Hook *hook)
bool DTTR_Core_HookDetachChecked(DTTR_Core_Hook *hook)
static uintptr_t sigscan(HMODULE mod, const char *sig, const char *mask)
Definition core.c:45

Definition at line 49 of file core.c.

Referenced by runtime_context().

◆ sig_target

uint8_t sig_target[] = {0x55, 0x8B, 0xEC, 0x90, 0x90, 0xC3, 0x33, 0xC0}
static

Definition at line 13 of file core.c.

Referenced by sigscan(), and test_signature_helpers_resolve_aob_patterns().

◆ TEST_CASES

const DTTR_TestCase TEST_CASES[]
static
Initial value:
= {
{"core-sdk-patch-group-rollback",
{"pcdogs-generated-function-patch-specs",
{"pcdogs-generated-title-resource-patch-specs",
{"pcdogs-unstable-patch-specs", test_pcdogs_unstable_patch_specs_match_stable_shape},
}
static void test_patch_group_target_failure_rolls_back_only_new_entries(void **state)
Definition core.c:83
static void test_pcdogs_unstable_patch_specs_match_stable_shape(void **state)
Definition core.c:160
static void test_pcdogs_generated_function_patch_specs_name_current_hooks(void **state)
Definition core.c:197
static void test_signature_helpers_resolve_aob_patterns(void **state)
Definition core.c:66
static void test_pcdogs_generated_title_resource_patch_specs_use_current_names(void **state)
Definition core.c:228

Definition at line 259 of file core.c.