diff options
| author | OreoFR <29048345+OreoFR@users.noreply.github.com> | 2026-11-29 17:43:47 +0100 |
|---|---|---|
| committer | OreoFR <29048345+OreoFR@users.noreply.github.com> | 2026-11-29 17:43:47 +0100 |
| commit | 90c54a3278a53b266af2ac5db32440321b307012 (patch) | |
| tree | 294b40a37398d7399e71907eeefd98366259423a /runtime/test/code_hooks_test.cpp | |
| parent | 7342eadaa549907554f18a46ca7c30578375d5df (diff) | |
| parent | 1d3da5ebc7c59cf0c614774c7cdf0ca3ba796eac (diff) | |
Merge origin/main into carry/pr-220
runtime/shims/d3d12_vulkan_device.cpp: main made image_descriptor serve
unordered-access views too (storage), added the title texture registry
beside it and moved the buffer SRV encoding into write_buffer_srv. Main's
code is kept and the PR's checks are applied to shader-resource views only
(!storage): the component mapping and ResourceMinLODClamp at the start, the
typeless view format checks before the format path, the mip and layer
range checks after main's layer bounds; and the buffer SRV mapping check
before CreateShaderResourceView calls write_buffer_srv.
Co-authored-by: justr4mzi <243612488+justr4mzi@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/code_hooks_test.cpp')
| -rw-r--r-- | runtime/test/code_hooks_test.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/test/code_hooks_test.cpp b/runtime/test/code_hooks_test.cpp index 39efb9be1..2b76f8fa2 100644 --- a/runtime/test/code_hooks_test.cpp +++ b/runtime/test/code_hooks_test.cpp | |||
| @@ -367,6 +367,33 @@ int main() { | |||
| 367 | free_thunk(unwind_remap); | 367 | free_thunk(unwind_remap); |
| 368 | } | 368 | } |
| 369 | free_thunk(nullptr); | 369 | free_thunk(nullptr); |
| 370 | check(finish_thunk(nullptr, 16, {0x01, 0, 0, 0}) == nullptr, "finish_thunk refuses null thunk buffer"); | ||
| 371 | |||
| 372 | // Zero direct callers: redirect_image_calls succeeds and frees the unused thunk and its function table. | ||
| 373 | uint8_t* img_zero = alloc_near(reinterpret_cast<const void*>(&remap_lucia), 0x2000); | ||
| 374 | check(img_zero != nullptr, "synthetic PE64 image for zero-caller check allocated"); | ||
| 375 | if (img_zero) { | ||
| 376 | std::memset(img_zero, 0, 0x2000); | ||
| 377 | IMAGE_SECTION_HEADER sec_z{}; | ||
| 378 | std::memcpy(sec_z.Name, ".text", 5); | ||
| 379 | sec_z.Misc.VirtualSize = 0x100; | ||
| 380 | sec_z.VirtualAddress = 0x1000; | ||
| 381 | sec_z.SizeOfRawData = 0x100; | ||
| 382 | sec_z.Characteristics = IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_CNT_CODE; | ||
| 383 | init_pe64(img_zero, 0x2000, {sec_z}); | ||
| 384 | put(img_zero + 0x1000, {0x89, 0xC8, 0xC3}); // target with no direct E8/E9 callers | ||
| 385 | uint8_t* unused_thunk = nullptr; | ||
| 386 | const HookResult rz = redirect_image_calls(img_zero, 0x1000, [&](uint8_t* target) { | ||
| 387 | unused_thunk = make_remap_thunk(target, 0, &remap_lucia, target); | ||
| 388 | return unused_thunk; | ||
| 389 | }); | ||
| 390 | DWORD64 base = 0; | ||
| 391 | check(rz.ok && rz.redirected == 0 && unused_thunk != nullptr, | ||
| 392 | "redirect_image_calls succeeds with zero redirected branches"); | ||
| 393 | check(unused_thunk && RtlLookupFunctionEntry(reinterpret_cast<DWORD64>(unused_thunk) + 1, &base, nullptr) == nullptr, | ||
| 394 | "unused thunk and its function table are freed when zero branches were redirected"); | ||
| 395 | VirtualFree(img_zero, 0, MEM_RELEASE); | ||
| 396 | } | ||
| 370 | 397 | ||
| 371 | std::printf("code_hooks_test: %d checks, %d failures\n", g_checks, g_failures); | 398 | std::printf("code_hooks_test: %d checks, %d failures\n", g_checks, g_failures); |
| 372 | return g_failures == 0 ? 0 : 1; | 399 | return g_failures == 0 ? 0 : 1; |