diff --git a/__init__.py b/__init__.py index 5b134cf..006d547 100644 --- a/__init__.py +++ b/__init__.py @@ -6,7 +6,6 @@ from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, QWidget, QListWidget, QListWidgetItem, QTextEdit, QCheckBox, QPushButton from PySide6.QtGui import QMouseEvent - class SEHListItem(QListWidgetItem): def __init__(self, base: int, entry: ExceptionsDirEntryData): self.entry = entry @@ -86,6 +85,11 @@ def __init__(self, bv: BinaryView, file: PE): header_layout = QHBoxLayout() + self.show_handler_name = QCheckBox() + handler_name_layout = QHBoxLayout() + handler_name_layout.addWidget(QLabel("Show handler name: ")) + handler_name_layout.addWidget(self.show_handler_name) + self.follow_cb = QCheckBox() follow_layout = QHBoxLayout() follow_layout.addWidget(QLabel("Follow Cursor: ")) @@ -97,6 +101,7 @@ def __init__(self, bv: BinaryView, file: PE): header_layout.addWidget(goto_button) header_layout.addStretch() + header_layout.addLayout(handler_name_layout) header_layout.addLayout(follow_layout) self.begin_addr = AddrLabel(None, bv) @@ -124,6 +129,7 @@ def __init__(self, bv: BinaryView, file: PE): self.unwind_codes = QTextEdit() self.unwind_codes.setReadOnly(True) self.unwind_exception_handler = AddrLabel(None, bv) + self.unwind_handler_name = AddrLabel(None, bv) title = QLabel("Unwind Info") title.setAlignment(QtCore.Qt.AlignCenter) @@ -141,9 +147,12 @@ def __init__(self, bv: BinaryView, file: PE): unwind_exception_handler_layout = QHBoxLayout() unwind_exception_handler_layout.addWidget( - QLabel("Exception Handler: ")) + QLabel("Exception Handler: ")) + unwind_exception_handler_layout.addWidget( + self.unwind_handler_name) unwind_exception_handler_layout.addWidget( self.unwind_exception_handler) + unwind_layout.addLayout(unwind_exception_handler_layout) unwind_prolog_size_layout = QHBoxLayout() @@ -204,6 +213,7 @@ def listItemClicked(self, clickedItem): self.begin_addr.setAddr(None) self.end_addr.setAddr(None) self.unwind_addr.setAddr(None) + self.unwind_handler_name.setAddr(None) self.unwind_version.clear() self.unwind_flags.clear() self.unwind_prolog_size.clear() @@ -222,7 +232,6 @@ def listItemClicked(self, clickedItem): self.unwind_version.setText(str(clickedItem.entry.unwindinfo.Version)) - unwind_flags = [] if clickedItem.entry.unwindinfo.Flags == 0: unwind_flags.append("UNW_FLAG_NHANDLER") @@ -254,10 +263,25 @@ def listItemClicked(self, clickedItem): codes += str(x) + '\n' self.unwind_codes.setText(codes) + self.unwind_handler_name.setHidden(not self.show_handler_name.isChecked()) + self.unwind_exception_handler.setHidden(self.unwind_handler_name.isVisible()) + + self.adjustSize() + if hasattr(clickedItem.entry.unwindinfo, 'ExceptionHandler'): - self.unwind_exception_handler.setAddr( - self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.unwindinfo.ExceptionHandler) + handler_addr = self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.unwindinfo.ExceptionHandler + symbol = self.bv.get_symbol_at(handler_addr) + + if self.unwind_handler_name.isHidden() or symbol.name.startswith("sub_"): + self.unwind_exception_handler.setAddr( + handler_addr) + else: + if all([symbol, symbol.name]): + self.unwind_handler_name.setOptText( + f"{symbol.name} @ ") + self.unwind_handler_name.setAddr(handler_addr) else: + self.unwind_handler_name.clear() self.unwind_exception_handler.clear() @staticmethod