The underlying issue is that trailing null bytes are not stored in the exe and thus are not part of dwSizeofRaw, causing the null terminator of the xboxkrnl.exe-string to get cut off resulting in an oob-read and invalid string comparison, which ultimately produces an xbe with an incorrect import directory (the hello sample can be used to test this).
I've changed the exe loader and xbe constructor to instead keep the full section in memory so that valid reads from sections can no longer be out of bounds. This slightly increases memory consumption during the conversion, but that shouldn't be an issue.
Fixes regression introduced by https://github.com/XboxDev/nxdk/commit/d6f0f3a24b35f086889c8d8c2c591656e759fdbb.
The underlying issue is that trailing null bytes are not stored in the exe and thus are not part of
dwSizeofRaw
, causing the null terminator of thexboxkrnl.exe
-string to get cut off resulting in an oob-read and invalid string comparison, which ultimately produces an xbe with an incorrect import directory (thehello
sample can be used to test this).I've changed the exe loader and xbe constructor to instead keep the full section in memory so that valid reads from sections can no longer be out of bounds. This slightly increases memory consumption during the conversion, but that shouldn't be an issue.