102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
pcdogs.c File Reference
#include <dttr_test.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  target_filter

Macros

#define SIDECAR_JMP_HOOK_TARGET(NAME, SIG, MASK, REQUIRED)
#define SIDECAR_BYTE_PATCH_TARGET(NAME, SIG, MASK, OFFSET, PATCH, ORIGINAL, ORIGINAL_MASK)

Functions

static bool assert_targets_for_fixture (size_t fixture_index, const DTTR_TestBinaryFixture *fixture, const char *path, const DTTR_TestPEImage *image, void *userdata)
static void test_targets_matching (E_TargetKind kind)
static void test_expected_pcdogs_jmp_hook_targets_resolve (void **state)
static void test_expected_pcdogs_byte_patch_targets_resolve (void **state)
static bool import_hook_expected (const char *name)
static bool assert_imports_for_fixture (size_t fixture_index, const DTTR_TestBinaryFixture *fixture, const char *path, const DTTR_TestPEImage *image, void *userdata)
static void test_expected_mss32_imports_are_hooked (void **state)

Variables

static const uint8_t PATCH_FAST_PATH [] = {0xE9, 0xBA, 0x00, 0x00, 0x00, 0x90}
static const uint8_t PATCH_NOP2 [] = {0x90, 0x90}
static const uint8_t PATCH_FTOL_X [] = {0xD9, 0x1F, 0x90, 0x90, 0x90}
static const uint8_t PATCH_NOP4 [] = {0x90, 0x90, 0x90, 0x90}
static const uint8_t PATCH_FTOL_Y [] = {0xD9, 0x5D, 0x00, 0x90, 0x90}
static const uint8_t PATCH_NOP3 [] = {0x90, 0x90, 0x90}
static const uint8_t PATCH_RET [] = {0xC3}
static const uint8_t ORIGINAL_FAST_PATH [] = {0x0F, 0x85, 0xB9, 0x00, 0x00, 0x00}
static const uint8_t ORIGINAL_BATCH_LIMIT_A [] = {0x7D, 0x39}
static const uint8_t ORIGINAL_BATCH_LIMIT_B [] = {0x7D, 0x59}
static const uint8_t ORIGINAL_FTOL_CALL [] = {0xE8, 0, 0, 0, 0}
static const uint8_t ORIGINAL_MOV_XY [] = {0x89, 0x44, 0x24, 0x30}
static const uint8_t ORIGINAL_FSTP_X [] = {0xD9, 0x1F}
static const uint8_t ORIGINAL_FILD_X [] = {0xDB, 0x44, 0x24, 0x30}
static const uint8_t ORIGINAL_FSTP_Y [] = {0xD9, 0x5D, 0x00}
static const uint8_t ORIGINAL_FILD_Y [] = {0xDB, 0x44, 0x24, 0x34}
static const uint8_t ORIGINAL_PUSH_EBX [] = {0x53}
const pcdogs_target_expectation DTTR_TEST_PCDOGS_SIDECAR_TARGETS []
const size_t DTTR_TEST_PCDOGS_SIDECAR_TARGET_COUNT
const char *const DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOKS []
const size_t DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOK_COUNT
static const DTTR_TestCase TEST_CASES []

Macro Definition Documentation

◆ SIDECAR_BYTE_PATCH_TARGET

#define SIDECAR_BYTE_PATCH_TARGET ( NAME,
SIG,
MASK,
OFFSET,
PATCH,
ORIGINAL,
ORIGINAL_MASK )
Value:
{ \
NAME, \
(const uint8_t *)(SIG), \
MASK, \
OFFSET, \
PATCH, \
sizeof(PATCH), \
ORIGINAL, \
ORIGINAL_MASK, \
}
#define DTTR_TEST_PCDOGS_REQUIRED_ALL
Definition dttr_test.h:8
#define TARGET_BYTE_PATCH
Definition dttr_test.h:28

Definition at line 35 of file pcdogs.c.

◆ SIDECAR_JMP_HOOK_TARGET

#define SIDECAR_JMP_HOOK_TARGET ( NAME,
SIG,
MASK,
REQUIRED )
Value:
{NAME, \
(const uint8_t *)(SIG), \
MASK, \
REQUIRED, \
0, \
NULL, \
0, \
NULL, \
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL
#define TARGET_JMP_HOOK
Definition dttr_test.h:24

Definition at line 24 of file pcdogs.c.

Function Documentation

◆ assert_imports_for_fixture()

bool assert_imports_for_fixture ( size_t fixture_index,
const DTTR_TestBinaryFixture * fixture,
const char * path,
const DTTR_TestPEImage * image,
void * userdata )
static

◆ assert_targets_for_fixture()

bool assert_targets_for_fixture ( size_t fixture_index,
const DTTR_TestBinaryFixture * fixture,
const char * path,
const DTTR_TestPEImage * image,
void * userdata )
static

◆ import_hook_expected()

bool import_hook_expected ( const char * name)
static

◆ test_expected_mss32_imports_are_hooked()

void test_expected_mss32_imports_are_hooked ( void ** state)
static

◆ test_expected_pcdogs_byte_patch_targets_resolve()

void test_expected_pcdogs_byte_patch_targets_resolve ( void ** state)
static

◆ test_expected_pcdogs_jmp_hook_targets_resolve()

void test_expected_pcdogs_jmp_hook_targets_resolve ( void ** state)
static

◆ test_targets_matching()

Variable Documentation

◆ DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOK_COUNT

const size_t DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOK_COUNT
Initial value:
const char *const DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOKS[]
Definition pcdogs.c:185

Definition at line 215 of file pcdogs.c.

Referenced by assert_imports_for_fixture(), and import_hook_expected().

◆ DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOKS

const char* const DTTR_TEST_PCDOGS_SIDECAR_MSS_IMPORT_HOOKS[]
Initial value:
= {
"_AIL_allocate_sample_handle@4",
"_AIL_close_stream@4",
"_AIL_end_sample@4",
"_AIL_get_preference@4",
"_AIL_init_sample@4",
"_AIL_open_stream@12",
"_AIL_pause_stream@8",
"_AIL_release_sample_handle@4",
"_AIL_sample_playback_rate@4",
"_AIL_sample_status@4",
"_AIL_set_digital_master_volume@8",
"_AIL_set_preference@8",
"_AIL_set_sample_file@12",
"_AIL_set_sample_loop_count@8",
"_AIL_set_sample_pan@8",
"_AIL_set_sample_playback_rate@8",
"_AIL_set_sample_volume@8",
"_AIL_set_stream_loop_count@8",
"_AIL_set_stream_volume@8",
"_AIL_shutdown@0",
"_AIL_start_sample@4",
"_AIL_start_stream@4",
"_AIL_startup@0",
"_AIL_stop_sample@4",
"_AIL_stream_status@4",
"_AIL_waveOutClose@4",
"_AIL_waveOutOpen@16",
}

Definition at line 185 of file pcdogs.c.

Referenced by import_hook_expected().

◆ DTTR_TEST_PCDOGS_SIDECAR_TARGET_COUNT

const size_t DTTR_TEST_PCDOGS_SIDECAR_TARGET_COUNT
Initial value:
= sizeof(
)
/ sizeof(
)
const pcdogs_target_expectation DTTR_TEST_PCDOGS_SIDECAR_TARGETS[]
Definition pcdogs.c:49

Definition at line 178 of file pcdogs.c.

Referenced by assert_targets_for_fixture().

◆ DTTR_TEST_PCDOGS_SIDECAR_TARGETS

const pcdogs_target_expectation DTTR_TEST_PCDOGS_SIDECAR_TARGETS[]

Definition at line 49 of file pcdogs.c.

Referenced by assert_targets_for_fixture().

◆ ORIGINAL_BATCH_LIMIT_A

const uint8_t ORIGINAL_BATCH_LIMIT_A[] = {0x7D, 0x39}
static

Definition at line 14 of file pcdogs.c.

◆ ORIGINAL_BATCH_LIMIT_B

const uint8_t ORIGINAL_BATCH_LIMIT_B[] = {0x7D, 0x59}
static

Definition at line 15 of file pcdogs.c.

◆ ORIGINAL_FAST_PATH

const uint8_t ORIGINAL_FAST_PATH[] = {0x0F, 0x85, 0xB9, 0x00, 0x00, 0x00}
static

Definition at line 13 of file pcdogs.c.

◆ ORIGINAL_FILD_X

const uint8_t ORIGINAL_FILD_X[] = {0xDB, 0x44, 0x24, 0x30}
static

Definition at line 19 of file pcdogs.c.

◆ ORIGINAL_FILD_Y

const uint8_t ORIGINAL_FILD_Y[] = {0xDB, 0x44, 0x24, 0x34}
static

Definition at line 21 of file pcdogs.c.

◆ ORIGINAL_FSTP_X

const uint8_t ORIGINAL_FSTP_X[] = {0xD9, 0x1F}
static

Definition at line 18 of file pcdogs.c.

◆ ORIGINAL_FSTP_Y

const uint8_t ORIGINAL_FSTP_Y[] = {0xD9, 0x5D, 0x00}
static

Definition at line 20 of file pcdogs.c.

◆ ORIGINAL_FTOL_CALL

const uint8_t ORIGINAL_FTOL_CALL[] = {0xE8, 0, 0, 0, 0}
static

Definition at line 16 of file pcdogs.c.

◆ ORIGINAL_MOV_XY

const uint8_t ORIGINAL_MOV_XY[] = {0x89, 0x44, 0x24, 0x30}
static

Definition at line 17 of file pcdogs.c.

◆ ORIGINAL_PUSH_EBX

const uint8_t ORIGINAL_PUSH_EBX[] = {0x53}
static

Definition at line 22 of file pcdogs.c.

◆ PATCH_FAST_PATH

const uint8_t PATCH_FAST_PATH[] = {0xE9, 0xBA, 0x00, 0x00, 0x00, 0x90}
static

Definition at line 5 of file pcdogs.c.

◆ PATCH_FTOL_X

const uint8_t PATCH_FTOL_X[] = {0xD9, 0x1F, 0x90, 0x90, 0x90}
static

Definition at line 7 of file pcdogs.c.

◆ PATCH_FTOL_Y

const uint8_t PATCH_FTOL_Y[] = {0xD9, 0x5D, 0x00, 0x90, 0x90}
static

Definition at line 9 of file pcdogs.c.

◆ PATCH_NOP2

const uint8_t PATCH_NOP2[] = {0x90, 0x90}
static

Definition at line 6 of file pcdogs.c.

◆ PATCH_NOP3

const uint8_t PATCH_NOP3[] = {0x90, 0x90, 0x90}
static

Definition at line 10 of file pcdogs.c.

◆ PATCH_NOP4

const uint8_t PATCH_NOP4[] = {0x90, 0x90, 0x90, 0x90}
static

Definition at line 8 of file pcdogs.c.

◆ PATCH_RET

const uint8_t PATCH_RET[] = {0xC3}
static

Definition at line 11 of file pcdogs.c.

◆ TEST_CASES

const DTTR_TestCase TEST_CASES[]
static
Initial value:
= {
}
static void test_expected_pcdogs_jmp_hook_targets_resolve(void **state)
Definition pcdogs.c:256
static void test_expected_pcdogs_byte_patch_targets_resolve(void **state)
Definition pcdogs.c:262
static void test_expected_mss32_imports_are_hooked(void **state)
Definition pcdogs.c:321

Definition at line 326 of file pcdogs.c.