Files
AnyPS5/core/libs/tests/GuestUnwindModuleInfoFixture.cpp
T
MerijnandClaude Opus 5.5 b86370285b fix(kernel): throw on unsupported unwind tables in sceKernelGetModuleInfoForUnwind
Once an image has .ehmeta, an eh_frame_hdr version other than 1, an
eh_frame_ptr encoding other than absptr or pcrel, a 64-bit record length,
an eh_frame_ptr outside the image or a missing terminator now throw
instead of returning the empty answer. The test queries a fixture DLL
whose .ehmeta it can break, since the unwinder reads the same section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 00:54:43 +02:00

20 lines
807 B
C++

#include "tests/GuestUnwindModuleInfoFixture.hpp"
#include <cstdint>
#include <windows.h>
__attribute__((section(".ehmeta"), used)) static volatile std::uint32_t ehMeta = 0;
extern "C" IMAGE_DOS_HEADER __ImageBase;
static UnwindFixture fixture;
extern "C" __declspec(dllexport) UnwindFixture* GetUnwindFixture() {
const auto base = reinterpret_cast<std::uint64_t>(&__ImageBase);
fixture.header.frames = static_cast<std::int32_t>(reinterpret_cast<std::intptr_t>(&fixture.frames) - reinterpret_cast<std::intptr_t>(&fixture.header.frames));
DWORD old = 0;
if (!VirtualProtect(const_cast<std::uint32_t*>(&ehMeta), sizeof(ehMeta), PAGE_READWRITE, &old)) return nullptr;
ehMeta = static_cast<std::uint32_t>(reinterpret_cast<std::uint64_t>(&fixture.header) - base);
return &fixture;
}