Improve performance and crash resistance when loading PE files containing 1000 or more sections. Tested on https://github.com/corkami/pocs/blob/master/PE/bin/65535sects.exe. Technically performance was already very good, but that was only due to crashing instantly
This commit is contained in:
parent
f515484790
commit
0bb2efcb2c
|
@ -153,7 +153,7 @@ void MemUpdateMap()
|
|||
{
|
||||
duint start = (duint)currentPage.mbi.BaseAddress;
|
||||
duint end = start + currentPage.mbi.RegionSize;
|
||||
for(int j = 0, k = 0; j < SectionNumber; j++)
|
||||
for(duint j = 0, k = 0; (j < (duint)SectionNumber) && (k + IMAGE_SIZEOF_SHORT_NAME < MAX_MODULE_SIZE); j++)
|
||||
{
|
||||
const auto & currentSection = sections.at(j);
|
||||
duint secStart = currentSection.addr;
|
||||
|
|
|
@ -575,8 +575,9 @@ void GetModuleInfo(MODINFO & Info, ULONG_PTR FileMapVA)
|
|||
}
|
||||
|
||||
// Enumerate all PE sections
|
||||
Info.sections.clear();
|
||||
WORD sectionCount = Info.headers->FileHeader.NumberOfSections;
|
||||
Info.sections.clear();
|
||||
Info.sections.reserve(sectionCount);
|
||||
PIMAGE_SECTION_HEADER ntSection = IMAGE_FIRST_SECTION(Info.headers);
|
||||
|
||||
for(WORD i = 0; i < sectionCount; i++)
|
||||
|
|
Loading…
Reference in New Issue