Decompile fn_18142 (CMemMapPakFile::Read)
Batch #11715 by cremane: 0 byte-identical, 1 confirmed by peer review. - fn_18142 CMemMapPakFile::Read: logic confirmed by peer review Peer-reviewed-by: Yommy, KWDev Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
9c0e63c95d
commit
24401fdd20
1 changed files with 12 additions and 9 deletions
|
|
@ -76,27 +76,30 @@ std::uint8_t* CMemMapPakFile::Read(std::uint64_t offset, std::uint32_t length) {
|
|||
this->m_view = nullptr;
|
||||
}
|
||||
|
||||
while (this->m_windowSize >= length + (static_cast<std::uint32_t>(offset) & ~static_cast<std::uint32_t>(this->m_offsetMask))) {
|
||||
this->m_viewOffset = offset & this->m_offsetMask;
|
||||
this->m_viewSize = this->m_windowSize;
|
||||
SIZE_T bytes = this->m_windowSize;
|
||||
|
||||
if (this->m_viewOffset + this->m_windowSize > this->m_size) {
|
||||
bytes = 0;
|
||||
this->m_viewSize = static_cast<std::uint32_t>(this->m_size - this->m_viewOffset);
|
||||
while (this->m_windowSize) {
|
||||
if (this->m_windowSize < length + (static_cast<std::uint32_t>(offset) & ~static_cast<std::uint32_t>(this->m_offsetMask))) {
|
||||
break;
|
||||
}
|
||||
|
||||
this->m_viewOffset = offset & this->m_offsetMask;
|
||||
this->m_viewSize = this->m_windowSize;
|
||||
|
||||
if (this->m_viewOffset + this->m_windowSize > this->m_size) {
|
||||
this->m_view = static_cast<std::uint8_t*>(
|
||||
MapViewOfFile(this->m_mapping, FILE_MAP_READ, static_cast<DWORD>(this->m_viewOffset >> 32), static_cast<DWORD>(this->m_viewOffset), 0)
|
||||
);
|
||||
this->m_viewSize = static_cast<std::uint32_t>(this->m_size - this->m_viewOffset);
|
||||
} else {
|
||||
this->m_view = static_cast<std::uint8_t*>(MapViewOfFile(
|
||||
this->m_mapping, FILE_MAP_READ, static_cast<DWORD>(this->m_viewOffset >> 32), static_cast<DWORD>(this->m_viewOffset), this->m_windowSize
|
||||
));
|
||||
}
|
||||
|
||||
this->m_view = static_cast<std::uint8_t*>(
|
||||
MapViewOfFile(this->m_mapping, FILE_MAP_READ, static_cast<DWORD>(this->m_viewOffset >> 32), static_cast<DWORD>(this->m_viewOffset), bytes)
|
||||
);
|
||||
if (this->m_view) {
|
||||
return this->m_view + static_cast<std::uint32_t>(offset - this->m_viewOffset);
|
||||
}
|
||||
|
||||
this->m_windowSize >>= 1;
|
||||
if (!this->m_windowSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(this->m_mapping);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue