Merge branch 'GP-2973_ryanmkurtz_pe-symbols'

This commit is contained in:
Ryan Kurtz 2022-12-27 10:31:26 -05:00
commit cbba392386
2 changed files with 18 additions and 4 deletions

View File

@ -318,7 +318,7 @@ public class FileHeader implements StructConverter {
return ptrToSections;
}
void processSections(OptionalHeader optHeader) throws IOException {
void processSections(OptionalHeader optHeader, boolean symbolsProcessed) throws IOException {
long oldIndex = reader.getPointerIndex();
int tmpIndex = getPointerToSections();
@ -329,7 +329,7 @@ public class FileHeader implements StructConverter {
Msg.error(this, "File alignment == 0: section processing skipped");
}
else {
long stringTableOffset = getStringTableOffset();
long stringTableOffset = symbolsProcessed ? getStringTableOffset() : -1;
sectionHeaders = new SectionHeader[numberOfSections];
for (int i = 0; i < numberOfSections; ++i) {
SectionHeader section =

View File

@ -255,6 +255,7 @@ public class NTHeader implements StructConverter, OffsetValidator {
}
tmpIndex += FileHeader.IMAGE_SIZEOF_FILE_HEADER;
// Process Optional Header. Abort load on failure.
try {
optionalHeader = new OptionalHeaderImpl(this, reader, tmpIndex);
}
@ -263,9 +264,22 @@ public class NTHeader implements StructConverter, OffsetValidator {
return;
}
fileHeader.processSections(optionalHeader);
fileHeader.processSymbols();
// Process symbols. Allow parsing to continue on failure.
boolean symbolsProcessed = false;
try {
fileHeader.processSymbols();
symbolsProcessed = true;
}
catch (Exception e) {
Msg.error(this, "Failed to process symbols: " + e.getMessage());
}
// Process sections. Resolving some sections names (i.e., "/21") requires symbols to have
// been successfully processed. Resolving is optional though.
fileHeader.processSections(optionalHeader, symbolsProcessed);
// Perform advanced processing. If advanced processing is disabled, these things may be
// independently parsed later in the load if they are needed.
if (advancedProcess) {
optionalHeader.processDataDirectories(TaskMonitor.DUMMY);
}