Skip to content

Commit

Permalink
feat: clear menu when leaving region covered by entry with follow cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseZeroTwo committed Feb 17, 2022
1 parent 75115cc commit 45d00f5
Showing 1 changed file with 45 additions and 31 deletions.
76 changes: 45 additions & 31 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setAddr(self, addr):
if self.addr != None:
self.setText(hex(self.addr))
else:
self.setText("")
self.clear()


class SEHNotifications(UIContextNotification):
Expand All @@ -61,7 +61,10 @@ def gotoAddr(self, addr):
row = self.dict[x]
self.list.setCurrentRow(row)
self.listItemClicked(self.list.item(row))
break
return

self.list.clearSelection()
self.listItemClicked(None)

def gotoButtonClicked(self):
self.gotoAddr(self.bv.offset)
Expand Down Expand Up @@ -185,36 +188,47 @@ def __init__(self, bv: BinaryView, file: PE):

self.notifications = SEHNotifications(self)

def listItemClicked(self, clickedItem: SEHListItem):
self.begin_addr.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.struct.BeginAddress)
self.end_addr.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.struct.EndAddress)
self.unwind_addr.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.struct.UnwindData)

self.unwind_version.setText(str(clickedItem.entry.unwindinfo.Version))
self.unwind_flags.setText(str(clickedItem.entry.unwindinfo.Flags))
self.unwind_prolog_size.setText(
str(clickedItem.entry.unwindinfo.SizeOfProlog))
self.unwind_code_count.setText(
str(clickedItem.entry.unwindinfo.CountOfCodes))
self.unwind_frame_register.setText(
str(clickedItem.entry.unwindinfo.FrameRegister))
self.unwind_frame_offset.setText(
str(clickedItem.entry.unwindinfo.FrameOffset))
codes = ""
for x in clickedItem.entry.unwindinfo.UnwindCodes:
codes += str(x) + '\n'
self.unwind_codes.setText(codes)

if hasattr(clickedItem.entry.unwindinfo, 'ExceptionHandler'):
self.unwind_exception_handler.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.unwindinfo.ExceptionHandler)
else:
def listItemClicked(self, clickedItem):
if clickedItem == None:
self.begin_addr.setAddr(None)
self.end_addr.setAddr(None)
self.unwind_addr.setAddr(None)
self.unwind_version.clear()
self.unwind_flags.clear()
self.unwind_prolog_size.clear()
self.unwind_code_count.clear()
self.unwind_frame_register.clear()
self.unwind_frame_offset.clear()
self.unwind_codes.clear()
self.unwind_exception_handler.clear()

return
else:
self.begin_addr.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.struct.BeginAddress)
self.end_addr.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.struct.EndAddress)
self.unwind_addr.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.struct.UnwindData)

self.unwind_version.setText(str(clickedItem.entry.unwindinfo.Version))
self.unwind_flags.setText(str(clickedItem.entry.unwindinfo.Flags))
self.unwind_prolog_size.setText(
str(clickedItem.entry.unwindinfo.SizeOfProlog))
self.unwind_code_count.setText(
str(clickedItem.entry.unwindinfo.CountOfCodes))
self.unwind_frame_register.setText(
str(clickedItem.entry.unwindinfo.FrameRegister))
self.unwind_frame_offset.setText(
str(clickedItem.entry.unwindinfo.FrameOffset))
codes = ""
for x in clickedItem.entry.unwindinfo.UnwindCodes:
codes += str(x) + '\n'
self.unwind_codes.setText(codes)

if hasattr(clickedItem.entry.unwindinfo, 'ExceptionHandler'):
self.unwind_exception_handler.setAddr(
self.file.OPTIONAL_HEADER.ImageBase + clickedItem.entry.unwindinfo.ExceptionHandler)
else:
self.unwind_exception_handler.clear()

@staticmethod
def createPane(context):
Expand Down

0 comments on commit 45d00f5

Please sign in to comment.