From bdd2143f98c0bab610de34e8dac18a48f6f01e46 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Tue, 27 Jun 2023 06:50:59 -0400 Subject: [PATCH] GP-3584: Failing to parse PE ExceptionDataDirectory no longer prevents the import from finishing (Closes #5483, Closes #5496) --- .../bin/format/pe/ExceptionDataDirectory.java | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ExceptionDataDirectory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ExceptionDataDirectory.java index cec7800dd89..c528e6dd86d 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ExceptionDataDirectory.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/ExceptionDataDirectory.java @@ -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