Skip to content

Commit

Permalink
GP-3584: Failing to parse PE ExceptionDataDirectory no longer prevents
Browse files Browse the repository at this point in the history
the import from finishing (Closes NationalSecurityAgency#5483, Closes NationalSecurityAgency#5496)
  • Loading branch information
ryanmkurtz committed Jun 27, 2023
1 parent 233aba0 commit bdd2143
Showing 1 changed file with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,33 @@ public boolean parse() throws IOException {
long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(ptr);

functionEntries = switch (ntHeader.getFileHeader().getMachine() & IMAGE_FILE_MACHINE_MASK) {
case IMAGE_FILE_MACHINE_I386:
case IMAGE_FILE_MACHINE_IA64:
case IMAGE_FILE_MACHINE_AMD64:
yield new ImageRuntimeFunctionEntries_X86(reader, size, ntHeader);
case IMAGE_FILE_MACHINE_ARM:
case IMAGE_FILE_MACHINE_ARM64:
case IMAGE_FILE_MACHINE_ARMNT:
yield new ImageRuntimeFunctionEntries_ARM(reader, size, ntHeader);
default:
Msg.error(this, String.format("Exception Data unsupported architecture: 0x%02x",
ntHeader.getFileHeader().getMachine()));
yield null;
};
try {
functionEntries =
switch (ntHeader.getFileHeader().getMachine() & IMAGE_FILE_MACHINE_MASK) {
case IMAGE_FILE_MACHINE_I386:
case IMAGE_FILE_MACHINE_IA64:
case IMAGE_FILE_MACHINE_AMD64:
yield new ImageRuntimeFunctionEntries_X86(reader, size, ntHeader);
case IMAGE_FILE_MACHINE_ARM:
case IMAGE_FILE_MACHINE_ARM64:
case IMAGE_FILE_MACHINE_ARMNT:
yield new ImageRuntimeFunctionEntries_ARM(reader, size, ntHeader);
default:
Msg.error(this,
String.format("Exception Data unsupported architecture: 0x%02x",
ntHeader.getFileHeader().getMachine()));
yield null;
};
return true;
}
catch (IOException e) {
Msg.error(this, "Failed to parse " + ExceptionDataDirectory.class.getSimpleName(), e);
}
finally {
reader.setPointerIndex(oldIndex);
}

reader.setPointerIndex(oldIndex);
return true;
return false;
}

@Override
Expand Down

0 comments on commit bdd2143

Please sign in to comment.