def __init__(self, DISPLAY_LINE_NUMBERS=True, HIGHLIGHT_CURRENT_LINE=True, SyntaxHighlighter=Pylighter, lang="python", font_size=11, delimeter=" ", *args): super(QCodeEditor, self).__init__() font = getMonospaceFont(self) font.setPointSize(font_size) self.setFont(font) self.setLineWrapMode(QPlainTextEdit.NoWrap) self.completionState = 0 self.completing = False self.delimeter = delimeter self.completer = bncompleter.Completer() self.cursorPositionChanged.connect(self.resetCompletion) self.DISPLAY_LINE_NUMBERS = DISPLAY_LINE_NUMBERS if DISPLAY_LINE_NUMBERS: self.number_bar = self.NumberBar(self) if SyntaxHighlighter is not None: # add highlighter to textdocument self.highlighter = SyntaxHighlighter(self.document(), lang)
def __init__(self, instance): super(PythonScriptingInstance.InterpreterThread, self).__init__() self.instance = instance self.locals = {"__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__]} self.interpreter = code.InteractiveConsole(self.locals) self.event = threading.Event() self.daemon = True # Latest selections from UI self.current_view = None self.current_func = None self.current_block = None self.current_addr = 0 self.current_selection_begin = 0 self.current_selection_end = 0 # Selections that were current as of last issued command self.active_view = None self.active_func = None self.active_block = None self.active_addr = 0 self.active_selection_begin = 0 self.active_selection_end = 0 self.locals["get_selected_data"] = self.get_selected_data self.locals["write_at_cursor"] = self.write_at_cursor self.exit = False self.code = None self.input = "" self.completer = bncompleter.Completer(namespace = self.locals) self.interpreter.push("from binaryninja import *")
def __init__(self, instance): super(PythonScriptingInstance.InterpreterThread, self).__init__() self.instance = instance # Note: "current_address" and "here" are interactive auto-variables (i.e. can be set by user and programmatically) blacklisted_vars = { "current_view", "bv", "current_function", "current_basic_block", "current_selection", "current_llil", "current_mlil", "current_hlil" } self.locals = BlacklistedDict( blacklisted_vars, { "__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__] }) self.interpreter = code.InteractiveConsole(self.locals) self.event = threading.Event() self.daemon = True # Latest selections from UI self.current_view = None self.current_func = None self.current_block = None self.current_addr = 0 self.current_selection_begin = 0 self.current_selection_end = 0 # Selections that were current as of last issued command self.active_view = None self.active_func = None self.active_block = None self.active_addr = 0 self.active_selection_begin = 0 self.active_selection_end = 0 self.locals["get_selected_data"] = self.get_selected_data self.locals["write_at_cursor"] = self.write_at_cursor self.exit = False self.code = None self.input = "" self.completer = bncompleter.Completer(namespace=self.locals) self.interpreter.push("from binaryninja import *")