Exemplo n.º 1
0
def warn_errors(errors):
    """
    Warn the user of any encountered errors with a messagebox.
    """
    if not errors:
        return

    for error_type, error_list in iteritems(errors):

        #
        # loop through the individual instances/files that caused this error
        # and dump the results to the disassembler console...
        #

        lmsg("-"*50)
        lmsg("Files reporting %s:" % error_type.name)
        for error in error_list:
            lmsg(" - %s" % error.filepath)

        #
        # popup a more verbose error messagebox for the user to read regarding
        # this class of error they encountered
        #

        disassembler.warning(error.verbose)

    # done ...
    lmsg("-"*50)
Exemplo n.º 2
0
def warn_drcov_malformed():
    """
    Display a warning for malformed/unreadable coverage files.
    """
    disassembler.warning(
        "Failed to parse one or more of the selected coverage files!\n\n"
        " Possible reasons:\n"
        " - You selected a file that was *not* a coverage file.\n"
        " - The selected coverage file is malformed or unreadable.\n\n"
        "Please see the disassembler console for more info...")
Exemplo n.º 3
0
def warn_module_missing():
    """
    Display a warning for missing coverage data.
    """
    disassembler.warning(
        "No coverage data was extracted from one of the selected files.\n\n"
        " Possible reasons:\n"
        " - You selected a coverage file for the wrong binary.\n"
        " - The name of the executable file used to generate this database\n"
        "    is different than the one you collected coverage against.\n\n"
        "Please see the disassembler console for more info...")
Exemplo n.º 4
0
def warn_bad_mapping():
    """
    Display a warning for badly mapped coverage data.
    """
    disassembler.warning(
        "One or more of the loaded coverage files appears to be badly mapped.\n\n"
        " Possible reasons:\n"
        " - You selected a coverage file that was collected against a\n"
        "    slightly different version of the binary.\n"
        " - You recorded an application with very abnormal control flow.\n"
        " - The coverage file might be malformed.\n\n"
        "This means that any coverage displayed by Lighthouse is probably\n"
        "wrong, and should be used at your own discretion.")
Exemplo n.º 5
0
    def warmup(self):
        """
        Warms up the theming system prior to initial use.
        """
        if self._initialized:
            return

        logger.debug("Warming up theme subsystem...")

        #
        # attempt to load the user's preferred (or hinted) theme. if we are
        # successful, then there's nothing else to do!
        #

        self._refresh_theme_hints()
        if self._load_preferred_theme():
            self._initialized = True
            logger.debug(" - warmup complete, using preferred theme!")
            return

        #
        # failed to load the preferred theme... so delete the 'active'
        # file (if there is one) and warn the user before falling back
        #

        try:
            os.remove(os.path.join(self.get_user_theme_dir(), ".active_theme"))
        except:
            pass

        disassembler.warning(
            "Failed to load Lighthouse user theme!\n\n"
            "Please check the console for more information..."
        )

        #
        # if no theme is loaded, we will attempt to detect & load the in-box
        # themes based on the user's disassembler theme
        #

        loaded = self._load_preferred_theme(fallback=True)
        if not loaded:
            lmsg("Could not load Lighthouse fallback theme!") # this is a bad place to be...
            return

        logger.debug(" - warmup complete, using hint-recommended theme!")
        self._initialized = True
Exemplo n.º 6
0
    def interactive_change_theme(self):
        """
        Open a file dialog and let the user select a new Lighthoue theme.
        """

        # create & configure a Qt File Dialog for immediate use
        file_dialog = QtWidgets.QFileDialog(
            None,
            "Open Lighthouse theme file",
            self._last_directory,
            "JSON Files (*.json)"
        )
        file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)

        # prompt the user with the file dialog, and await filename(s)
        filename, _ = file_dialog.getOpenFileName()
        if not filename:
            return

        #
        # ensure the user is only trying to load themes from the user theme
        # directory as it helps ensure some of our intenal loading logic
        #

        file_dir = os.path.abspath(os.path.dirname(filename))
        user_dir = os.path.abspath(self.get_user_theme_dir())
        if file_dir != user_dir:
            text = "Please install your Lighthouse theme into the user theme directory:\n\n" + user_dir
            disassembler.warning(text)
            return

        #
        # remember the last directory we were in (parsed from a selected file)
        # for the next time the user comes to load coverage files
        #

        if filename:
            self._last_directory = os.path.dirname(filename) + os.sep

        # log the captured (selected) filenames from the dialog
        logger.debug("Captured filename from theme file dialog: '%s'" % filename)

        #
        # before applying the selected lighthouse theme, we should ensure that
        # we know if the user is using a light or dark disassembler theme as
        # it may change which colors get used by the lighthouse theme
        #

        self._refresh_theme_hints()

        # if the selected theme fails to load, throw a visible warning
        if not self._load_theme(filename):
            disassembler.warning(
                "Failed to load Lighthouse user theme!\n\n"
                "Please check the console for more information..."
            )
            return

        # since everthing looks like it loaded okay, save this as the preferred theme
        with open(os.path.join(self.get_user_theme_dir(), ".active_theme"), "w") as f:
            f.write(filename)
Exemplo n.º 7
0
 def _open_coverage_overview(self, context):
     dctx = disassembler.binja_get_bv_from_dock()
     if not dctx:
         disassembler.warning("Lighthouse requires an open BNDB to open the overview.")
         return
     super(LighthouseBinja, self).open_coverage_overview(dctx)
Exemplo n.º 8
0
 def _interactive_load_batch(self, context):
     dctx = disassembler.binja_get_bv_from_dock()
     if not dctx:
         disassembler.warning("Lighthouse requires an open BNDB to load coverage.")
         return
     super(LighthouseBinja, self).interactive_load_batch(dctx)