mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-24 01:06:40 +00:00
chore: fix annoying IW4 cross-type pointer reusage with dirty hack
The game reuses pointer across different types as long as bytes and size matches This leads to non-pointer and pointer types being reused To fix this loading code now handles block memory offsets by nulling and block offsets to non-block data with pointing to raw block data The behaviour only seems to realistically happen on nulled memory
This commit is contained in:
@@ -349,7 +349,7 @@ namespace
|
||||
m_pointer_redirect_lookup.emplace(zonePtr, alias);
|
||||
}
|
||||
|
||||
void* ConvertOffsetToPointerLookup(const void* offset) override
|
||||
MaybePointerFromLookup<void> ConvertOffsetToPointerLookup(const void* offset) override
|
||||
{
|
||||
// For details see ConvertOffsetToPointer
|
||||
const auto offsetInt = reinterpret_cast<uintptr_t>(offset) - 1u;
|
||||
@@ -367,10 +367,9 @@ namespace
|
||||
|
||||
const auto foundPointerLookup = m_pointer_redirect_lookup.find(offsetInt);
|
||||
if (foundPointerLookup != m_pointer_redirect_lookup.end())
|
||||
return foundPointerLookup->second;
|
||||
return MaybePointerFromLookup<void>(foundPointerLookup->second);
|
||||
|
||||
assert(false);
|
||||
return &block->m_buffer[blockOffset];
|
||||
return MaybePointerFromLookup<void>(&block->m_buffer[blockOffset], blockNum, blockOffset);
|
||||
}
|
||||
|
||||
void* ConvertOffsetToAliasLookup(const void* offset) override
|
||||
|
Reference in New Issue
Block a user