mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 00:22:57 -05:00
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>
20 lines
807 B
C++
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;
|
|
}
|