XEX2 Loading Fixes (#51)

* Fixes loading .xex import table names when a name is not aligned to 4
  bytes.
* Fixes loading .xex optional headers, adds missing case when the
  header_key & 0xFF == 1
* Fixes loading .xex base address and entry point to be the XEX2
  base/entry to successfully resolve all import thunks.
This commit is contained in:
nithax
2025-04-04 10:01:18 -04:00
committed by GitHub
parent c017eb630a
commit 0bfeaed44a
2 changed files with 23 additions and 7 deletions

View File

@@ -245,13 +245,17 @@ inline const void* getOptHeaderPtr(const uint8_t* moduleBytes, uint32_t headerKe
const Xex2OptHeader& optHeader = ((const Xex2OptHeader*)(xex2Header + 1))[i];
if (optHeader.key == headerKey)
{
if ((headerKey & 0xFF) == 0)
if((headerKey & 0xFF) == 0)
{
return &optHeader.value;
return reinterpret_cast<const uint32_t *>(&optHeader.value);
}
else if ((headerKey & 0xFF) == 1)
{
return reinterpret_cast<const void *>(&optHeader.value);
}
else
{
return &moduleBytes[optHeader.offset];
return reinterpret_cast<const void *>(reinterpret_cast<uintptr_t>(moduleBytes) + optHeader.offset);
}
}
}