fix: warden mmap on macOS, add external listfile support to asset extractor

Drop PROT_EXEC from warden module mmap when using Unicorn emulation
(not needed — module image is copied into emulator address space). Use
MAP_JIT on macOS for the native fallback path.

Add --listfile option to asset_extract and SFileAddListFileEntries
support for resolving unnamed MPQ hash table entries from external
listfiles.
This commit is contained in:
k 2026-04-04 00:22:07 -07:00
parent 84108c44f5
commit b3fa8cf5f3
4 changed files with 110 additions and 17 deletions

View file

@ -535,11 +535,25 @@ bool WardenModule::parseExecutableFormat(const std::vector<uint8_t>& exeData) {
return false;
}
#else
// When using Unicorn emulation the module image is copied into the
// emulator's address space, so we only need read/write access here.
// Native execution paths (non-Unicorn) need PROT_EXEC; on macOS this
// requires MAP_JIT due to hardened-runtime restrictions.
#ifdef HAVE_UNICORN
int mmapProt = PROT_READ | PROT_WRITE;
int mmapFlags = MAP_PRIVATE | MAP_ANONYMOUS;
#elif defined(__APPLE__)
int mmapProt = PROT_READ | PROT_WRITE | PROT_EXEC;
int mmapFlags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_JIT;
#else
int mmapProt = PROT_READ | PROT_WRITE | PROT_EXEC;
int mmapFlags = MAP_PRIVATE | MAP_ANONYMOUS;
#endif
moduleMemory_ = mmap(
nullptr,
finalCodeSize,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS,
mmapProt,
mmapFlags,
-1,
0
);