Data directories past NumberOfRvaAndSizes were read anyway (only the
exception directory checked the count), so stale bytes there were parsed
as import, delay-import, export or relocation tables. And resolve_forwarder
range-checked the ordinal before adding each digit, so '#65537' passed and
was cast to ordinal 1. The hand-built test images now declare their 16
directories.
- make_common_stub checks RtlAddFunctionTable and reports a failure once;
the stub keeps working, only stack walks through it stop.
- rt_unimplemented keys per-import state by the thunk's `what` pointer, so a
repeat call does one map lookup and builds no strings.
- A test hook (set_unimplemented_test_hook) lets unimplemented_policy_test
check, from inside the call, that rsp is aligned and that
RtlLookupFunctionEntry/RtlVirtualUnwind walk through rt_unimplemented and
the stub back to the caller.
- abi_probe.asm (MASM) calls a thunk with rbx/rbp/rdi/rsi/r12-r15 and
xmm6-xmm15 set to patterns and compares them afterwards, with a control
callee that clobbers rbx and xmm6.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An unimplemented import used to return 0 silently, which is S_OK for an
HRESULT function with its out parameters never written. The thunk now passes
the caller's return address and rcx/rdx/r8/r9 to a shared stub, and
LEONIDA_UNIMPLEMENTED picks the behaviour:
- log (default): exactly as before.
- fail: E_NOTIMPL for imports known to return HRESULT (D3D12Create*/Serialize*,
CreateDXGIFactory*, XGameRuntimeInitialize, and the GDK XAsync/XTaskQueue/
XUser/XStore/XGameSave/XPackage/XGameUi families minus their documented
void/bool/int functions), 0 otherwise.
- stop: print the import, the caller as module+RVA and the four argument
registers, then break under a debugger or exit with code 3.
--dry-run now counts unimplemented imports by return class. The stub zeroes
xmm0 and has unwind info, so float callers and debuggers are unaffected.
unimplemented_policy_test builds a synthetic image and checks all three modes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>