Daniel Plohmann avatar Daniel Plohmann committed 6cd6c28

Preparation of a filter option for FunctionInspection

Comments (0)

Files changed (3)

idascope/core/SemanticIdentifier.py

                 number_of_functions += 1
         return number_of_functions
 
-    def getFunctionAddresses(self, dummy=False, tag=False):
+    def getFunctionAddresses(self, context_filter):
         """
         Get all function address that have been covered by the last scanning.
         @param dummy_only: only return functions with dummy names
         @type tag_only: bool
         @return: (list of int) The addresses of covered functions.
         """
-        if tag and dummy:
+        if context_filter.display_tag_only and context_filter.display_dummy_only:
             return [addr for addr in self.last_scan_result.keys() if self.last_scan_result[addr].has_dummy_name and \
                 self.last_scan_result[addr].has_tags]
-        elif tag:
+        elif context_filter.display_tag_only:
             return [addr for addr in self.last_scan_result.keys() if self.last_scan_result[addr].has_tags]
-        elif dummy:
+        elif context_filter.display_dummy_only:
             return [addr for addr in self.last_scan_result.keys() if self.last_scan_result[addr].has_dummy_name]
         else:
             return self.last_scan_result.keys()

idascope/core/structures/FunctionContextFilter.py

+#!/usr/bin/python
+########################################################################
+# Copyright (c) 2012
+# Daniel Plohmann <daniel.plohmann<at>gmail<dot>com>
+# Alexander Hanel <alexander.hanel<at>gmail<dot>com>
+# All rights reserved.
+########################################################################
+#
+#  This file is part of IDAscope
+#
+#  IDAscope is free software: you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see
+#  <http://www.gnu.org/licenses/>.
+#
+########################################################################
+
+
+class FunctionContextFilter():
+    """
+    This class is defines the filter properties applicable to a scan result in order to select gathered information
+    more precisely.
+    """
+
+    def __init__(self):
+        self.display_tags = True
+        self.display_groups = False
+        self.display_tag_only = True
+        self.display_dummy_only = False
+        self.enabled_tags = []
+        self.enabled_groups = []
+        self.enabled_additions = []
+
+    def setGroupDisplay(self):
+        self.display_tags = False
+        self.display_groups = True
+
+    def setTagDisplay(self):
+        self.display_tags = True
+        self.display_groups = False

idascope/widgets/FunctionInspectionWidget.py

 from PySide.QtGui import QIcon
 
 from NumberQTableWidgetItem import NumberQTableWidgetItem
+from idascope.core.structures.FunctionContextFilter import FunctionContextFilter
 
 
 class FunctionInspectionWidget(QtGui.QMainWindow):
         self.parameter_table = QtGui.QTableWidget()
         self.parameter_table.doubleClicked.connect(self._onParameterDoubleClicked)
 
+################################################################################
+# Rendering and state keeping
+################################################################################
+
     def populateFunctionTable(self):
         """
         Populate the function table with information from the last scan of I{SemanticIdentifier}.
         self.funcs_table.setColumnCount(len(self.funcs_header_labels))
         self.funcs_table.setHorizontalHeaderLabels(self.funcs_header_labels)
         # Identify number of table entries and prepare addresses to display
-        function_addresses = self.si.getFunctionAddresses(self.function_dummy_only_cb.isChecked(), \
-            self.function_tag_only_cb.isChecked())
+        context_filter = self._getContextFilter()
+        function_addresses = self.si.getFunctionAddresses(context_filter)
         if self.ida_proxy.BAD_ADDR in function_addresses:
             self.funcs_table.setRowCount(len(function_addresses) - 1)
         else:
         self.parameter_table.setHorizontalHeaderLabels(self.parameter_header_labels)
 
     def updateFunctionsLabel(self):
-        num_displayed_functions = len(self.si.getFunctionAddresses(self.function_dummy_only_cb.isChecked(), \
-            self.function_tag_only_cb.isChecked()))
+        context_filter = self._getContextFilter()
+        num_displayed_functions = len(self.si.getFunctionAddresses(context_filter))
         self.funcs_label.setText("Functions of Interest (%d/%d)" %
             (num_displayed_functions, self.si.calculateNumberOfFunctions()))
 
+    def _getContextFilter(self):
+        context_filter = FunctionContextFilter()
+        context_filter.display_tag_only = self.function_dummy_only_cb.isChecked()
+        context_filter.display_tag_only = self.function_tag_only_cb.isChecked()
+        return context_filter
+
+################################################################################
+# Button actions
+################################################################################
+
     def _onRenameButtonClicked(self):
         """
         Action for renaming functions when the rename action from the toolbar is activated.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.