mirror of
https://github.com/QuasarApp/pe-parse.git
synced 2025-05-01 22:59:33 +00:00
parse: Fix DIR_SECURITY data directory retrieval (#122)
* parse: Fix DIR_SECURITY data directory retrieval Fixes #121. * parse: Fix variables * parse: Add MSDN link for DIR_SECURITY special case
This commit is contained in:
parent
c0208d643f
commit
2bf8ad917e
@ -2655,20 +2655,37 @@ bool GetDataDirectoryEntry(parsed_pe *pe,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
section sec;
|
/* NOTE(ww): DIR_SECURITY is an annoying special case: its contents
|
||||||
if (!getSecForVA(pe->internal->secs, addr, sec)) {
|
* are never mapped into memory, so its "RVA" is actually a direct
|
||||||
PE_ERR(PEERR_SECTVA);
|
* file offset.
|
||||||
return false;
|
* See:
|
||||||
}
|
* https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-attribute-certificate-table-image-only
|
||||||
|
*/
|
||||||
|
if (dirnum == DIR_SECURITY) {
|
||||||
|
auto *buf = splitBuffer(
|
||||||
|
pe->fileBuffer, dir.VirtualAddress, dir.VirtualAddress + dir.Size);
|
||||||
|
if (buf == nullptr) {
|
||||||
|
PE_ERR(PEERR_SIZE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto off = static_cast<std::uint32_t>(addr - sec.sectionBase);
|
raw_entry.assign(buf->buf, buf->buf + buf->bufLen);
|
||||||
if (off + dir.Size >= sec.sectionData->bufLen) {
|
} else {
|
||||||
PE_ERR(PEERR_SIZE);
|
section sec;
|
||||||
return false;
|
if (!getSecForVA(pe->internal->secs, addr, sec)) {
|
||||||
}
|
PE_ERR(PEERR_SECTVA);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
raw_entry.assign(sec.sectionData->buf + off,
|
auto off = static_cast<std::uint32_t>(addr - sec.sectionBase);
|
||||||
sec.sectionData->buf + off + dir.Size);
|
if (off + dir.Size >= sec.sectionData->bufLen) {
|
||||||
|
PE_ERR(PEERR_SIZE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_entry.assign(sec.sectionData->buf + off,
|
||||||
|
sec.sectionData->buf + off + dir.Size);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user