|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include "dttr_test_support.h"#include <dttr_path.h>#include <dttr_sigscan.h>#include <Zydis/Utils.h>#include <physfs.h>#include <xxhash.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | DTTR_TEST_BINARY_SUPPORT |
Functions | |
| static void | dttr_test_pe_free_image (DTTR_TestPEImage *image) |
| static bool | dttr_test_pe_fixture_hash_matches (const DTTR_TestBinaryFixture *fixture, const DTTR_TestPEImage *image) |
| static const uint8_t * | pe_rva_bytes (const DTTR_TestPEImage *image, uintptr_t rva, size_t size) |
| static sds | dttr_test_join_path (const char *dir, const char *file) |
| static bool | mount_fixture_dir (const char *fixture_dir, bool *out_initialized) |
| static void | unmount_fixture_dir (const char *fixture_dir, bool initialized) |
| static bool | read_fixture_file (const char *filename, uint8_t **out, size_t *out_size) |
| bool | dttr_test_range_valid (size_t offset, size_t size, size_t total) |
| static uintptr_t | signed_offset_magnitude (int32_t offset) |
| bool | dttr_test_signed_range_valid (uintptr_t base, int32_t offset, size_t size, size_t total) |
| uintptr_t | dttr_test_offset_site (uintptr_t base, int32_t offset) |
| static bool | dttr_test_bytes_match_mask (const uint8_t *actual, const uint8_t *expected, const char *mask, size_t size) |
| bool | dttr_test_case_equal (const char *a, const char *b) |
| bool | dttr_test_fixture_required (DTTR_TestFixtureMask required, size_t fixture_index) |
| bool | dttr_test_fixtures_available (const DTTR_TestBinaryFixture *fixtures, size_t fixture_count, const char *fixture_dir) |
| static bool | pe_section_table (const DTTR_TestPEImage *image, size_t pe_offset, const IMAGE_NT_HEADERS32 *nt, const IMAGE_SECTION_HEADER **out_sections) |
| static bool | pe_copy_section (DTTR_TestPEImage *image, const IMAGE_SECTION_HEADER *section) |
| static bool | load_pe_image (uint8_t *file, size_t file_size, DTTR_TestPEImage *image) |
| static bool | dttr_test_pe_load_fixture (const DTTR_TestBinaryFixture *fixtures, size_t fixture_count, size_t fixture_index, const char *fixture_dir, sds *out_path, DTTR_TestPEImage *out_image) |
| bool | dttr_test_pe_for_each_fixture (const DTTR_TestBinaryFixture *fixtures, size_t fixture_count, const char *fixture_dir, DTTR_TestPEFixtureVisitor visitor, void *userdata) |
| static size_t | masked_sigscan_count (const uint8_t *bytes, size_t size, const uint8_t *sig, const char *mask) |
| size_t | DTTR_TestPE_SigscanCount (const DTTR_TestPEImage *image, const uint8_t *sig, const char *mask) |
| uintptr_t | DTTR_TestPE_Sigscan (const DTTR_TestPEImage *image, const uint8_t *sig, const char *mask) |
| static uint64_t | dttr_test_pe_file_hash (const DTTR_TestPEImage *image) |
| static const char * | dttr_test_pe_cstr (const DTTR_TestPEImage *image, uintptr_t rva) |
| size_t | DTTR_TestPE_CollectImports (const DTTR_TestPEImage *image, DTTR_TestImportEntry *imports, size_t imports_cap) |
| static ZydisDecoder * | zydis_decoder32 () |
| static bool | dttr_test_zydis_decode32 (const uint8_t *bytes, size_t size, DTTR_TestDecodedInstruction *out) |
| bool | dttr_test_zydis_decode32_at (const DTTR_TestPEImage *image, uintptr_t rva, DTTR_TestDecodedInstruction *out) |
| static bool | dttr_test_zydis_decode32_prefix (const DTTR_TestPEImage *image, uintptr_t rva, size_t required_size, size_t *out_size) |
| static bool | dttr_test_zydis_absolute_operand (const DTTR_TestDecodedInstruction *decoded, size_t operand_index, uintptr_t runtime_address, uintptr_t *out_address) |
| static void | assert_pointer_ff25_e8_target (const DTTR_TestBinaryFixture *fixture, const DTTR_TestTargetExpectation *target, const DTTR_TestPEImage *image, uintptr_t match) |
| static void | assert_pointer_u32_at_match_plus_2 (const DTTR_TestPEImage *image, uintptr_t match) |
| static void | assert_byte_patch_site (const DTTR_TestBinaryFixture *fixture, const DTTR_TestTargetExpectation *target, const DTTR_TestPEImage *image, uintptr_t match) |
| void | dttr_test_assert_target_resolved (const DTTR_TestBinaryFixture *fixture, const DTTR_TestTargetExpectation *target, const DTTR_TestPEImage *image) |
|
static |
Definition at line 800 of file binary.c.
References dttr_test_bytes_match_mask(), dttr_test_offset_site(), dttr_test_signed_range_valid(), dttr_test_zydis_decode32_at(), and target.
Referenced by dttr_test_assert_target_resolved().
|
static |
Definition at line 751 of file binary.c.
References dttr_test_range_valid(), dttr_test_zydis_absolute_operand(), dttr_test_zydis_decode32_at(), target, and target_address().
Referenced by dttr_test_assert_target_resolved().
|
static |
Definition at line 786 of file binary.c.
References dttr_test_zydis_absolute_operand(), dttr_test_zydis_decode32_at(), and target_address().
Referenced by dttr_test_assert_target_resolved().
| void dttr_test_assert_target_resolved | ( | const DTTR_TestBinaryFixture * | fixture, |
| const DTTR_TestTargetExpectation * | target, | ||
| const DTTR_TestPEImage * | image ) |
Definition at line 842 of file binary.c.
References assert_byte_patch_site(), assert_pointer_ff25_e8_target(), assert_pointer_u32_at_match_plus_2(), dttr_test_zydis_decode32_at(), dttr_test_zydis_decode32_prefix(), DTTR_TestPE_Sigscan(), DTTR_TestPE_SigscanCount(), and target.
Referenced by assert_targets_for_fixture().
|
static |
| bool dttr_test_case_equal | ( | const char * | a, |
| const char * | b ) |
Definition at line 183 of file binary.c.
Referenced by assert_imports_for_fixture().
| bool dttr_test_fixture_required | ( | DTTR_TestFixtureMask | required, |
| size_t | fixture_index ) |
Definition at line 187 of file binary.c.
Referenced by assert_blueprint_functions_for_fixture(), assert_signatures_for_fixture(), and assert_targets_for_fixture().
| bool dttr_test_fixtures_available | ( | const DTTR_TestBinaryFixture * | fixtures, |
| size_t | fixture_count, | ||
| const char * | fixture_dir ) |
Definition at line 191 of file binary.c.
References mount_fixture_dir(), and unmount_fixture_dir().
Referenced by pcdogs_fixtures_available().
|
static |
Definition at line 34 of file binary.c.
References DTTR_Path_AppendSegment(), and NULL.
Referenced by dttr_test_pe_load_fixture().
| uintptr_t dttr_test_offset_site | ( | uintptr_t | base, |
| int32_t | offset ) |
Definition at line 159 of file binary.c.
References signed_offset_magnitude().
Referenced by assert_byte_patch_site(), and blueprint_function_site().
|
static |
Definition at line 557 of file binary.c.
References NULL, and pe_rva_bytes().
Referenced by DTTR_TestPE_CollectImports().
|
static |
Definition at line 537 of file binary.c.
Referenced by dttr_test_pe_fixture_hash_matches().
|
static |
Definition at line 545 of file binary.c.
References dttr_test_pe_file_hash().
Referenced by dttr_test_pe_load_fixture().
| bool dttr_test_pe_for_each_fixture | ( | const DTTR_TestBinaryFixture * | fixtures, |
| size_t | fixture_count, | ||
| const char * | fixture_dir, | ||
| DTTR_TestPEFixtureVisitor | visitor, | ||
| void * | userdata ) |
Definition at line 405 of file binary.c.
References dttr_test_pe_free_image(), dttr_test_pe_load_fixture(), and NULL.
Referenced by pcdogs_for_each_fixture().
|
static |
Definition at line 444 of file binary.c.
References free.
Referenced by dttr_test_pe_for_each_fixture(), dttr_test_pe_load_fixture(), and load_pe_image().
|
static |
Definition at line 360 of file binary.c.
References dttr_test_join_path(), dttr_test_pe_fixture_hash_matches(), dttr_test_pe_free_image(), load_pe_image(), mount_fixture_dir(), NULL, read_fixture_file(), and unmount_fixture_dir().
Referenced by dttr_test_pe_for_each_fixture().
| bool dttr_test_range_valid | ( | size_t | offset, |
| size_t | size, | ||
| size_t | total ) |
Definition at line 125 of file binary.c.
References size.
Referenced by assert_patch_window_decodes(), assert_pointer_ff25_e8_target(), dttr_test_signed_range_valid(), load_pe_image(), pe_copy_section(), pe_rva_bytes(), and pe_section_table().
| bool dttr_test_signed_range_valid | ( | uintptr_t | base, |
| int32_t | offset, | ||
| size_t | size, | ||
| size_t | total ) |
Definition at line 134 of file binary.c.
References dttr_test_range_valid(), signed_offset_magnitude(), and size.
Referenced by assert_byte_patch_site(), and blueprint_function_site().
|
static |
Definition at line 721 of file binary.c.
Referenced by assert_pointer_ff25_e8_target(), and assert_pointer_u32_at_match_plus_2().
|
static |
Definition at line 658 of file binary.c.
References decoder, size, and zydis_decoder32().
Referenced by dttr_test_zydis_decode32_at().
| bool dttr_test_zydis_decode32_at | ( | const DTTR_TestPEImage * | image, |
| uintptr_t | rva, | ||
| DTTR_TestDecodedInstruction * | out ) |
Definition at line 675 of file binary.c.
References dttr_test_zydis_decode32().
Referenced by assert_abi_return_matches(), assert_byte_patch_site(), assert_decodes_at(), assert_patch_window_decodes(), assert_pointer_ff25_e8_target(), assert_pointer_u32_at_match_plus_2(), dttr_test_assert_target_resolved(), and dttr_test_zydis_decode32_prefix().
|
static |
Definition at line 691 of file binary.c.
References dttr_test_zydis_decode32_at().
Referenced by dttr_test_assert_target_resolved().
| size_t DTTR_TestPE_CollectImports | ( | const DTTR_TestPEImage * | image, |
| DTTR_TestImportEntry * | imports, | ||
| size_t | imports_cap ) |
Definition at line 567 of file binary.c.
References count, desc, dttr_test_pe_cstr(), and pe_rva_bytes().
Referenced by pcdogs_collect_imports().
| uintptr_t DTTR_TestPE_Sigscan | ( | const DTTR_TestPEImage * | image, |
| const uint8_t * | sig, | ||
| const char * | mask ) |
Definition at line 524 of file binary.c.
References DTTR_Sigscan_Bytes().
Referenced by dttr_test_assert_target_resolved(), and pcdogs_sigscan().
| size_t DTTR_TestPE_SigscanCount | ( | const DTTR_TestPEImage * | image, |
| const uint8_t * | sig, | ||
| const char * | mask ) |
Definition at line 512 of file binary.c.
References masked_sigscan_count().
Referenced by dttr_test_assert_target_resolved(), and pcdogs_sigscan_count().
|
static |
Definition at line 286 of file binary.c.
References dttr_test_pe_free_image(), dttr_test_range_valid(), NULL, pe_copy_section(), and pe_section_table().
Referenced by dttr_test_pe_load_fixture().
|
static |
|
static |
Definition at line 50 of file binary.c.
References NULL.
Referenced by dttr_test_fixtures_available(), and dttr_test_pe_load_fixture().
|
static |
Definition at line 259 of file binary.c.
References dttr_test_range_valid().
Referenced by load_pe_image().
|
static |
Definition at line 22 of file binary.c.
References dttr_test_range_valid(), NULL, and size.
Referenced by dttr_test_pe_cstr(), and DTTR_TestPE_CollectImports().
|
static |
Definition at line 223 of file binary.c.
References dttr_test_range_valid().
Referenced by load_pe_image().
|
static |
|
static |
Definition at line 130 of file binary.c.
Referenced by dttr_test_offset_site(), and dttr_test_signed_range_valid().
|
static |
Definition at line 75 of file binary.c.
Referenced by dttr_test_fixtures_available(), and dttr_test_pe_load_fixture().
|
static |
Definition at line 639 of file binary.c.
Referenced by dttr_test_zydis_decode32().