コード例 #1
0
    def goto_addr(self, to_addr, from_addr=None):
        if to_addr is None:
            self.show_status("No address-like value to go to")
            return

        # If we can position cursor within current screen, do that,
        # to avoid jumpy UI
        no = self.model.addr2line_no(to_addr)
        if no is not None:
            if self.line_visible(no):
                self.goto_line(no)
                if from_addr is not None:
                    self.addr_stack.append(from_addr)
                return

        # Otherwise, re-render model around needed address, and redraw screen
        t = time.time()
        model = engine.render_partial_around(to_addr, 0, HEIGHT * 2)
        self.show_status("Rendering time: %fs" % (time.time() - t))
        if not model:
            self.show_status("Unknown address: 0x%x" % to_addr)
            return
        self.set_model(model)

        no = self.model.addr2line_no(to_addr)
        if no is not None:
            if from_addr is not None:
                self.addr_stack.append(from_addr)
            if not self.goto_line(no):
                # Need to redraw always, because we changed underlying model
                self.update_screen()
        else:
            self.show_status("Unknown address: %x" % to_addr)
コード例 #2
0
ファイル: scratchabit.py プロジェクト: pelrun/ScratchABit
 def update_model(self, stay_on_real=False):
     """Re-render model and update screen in such way that cursor stayed
     on the same line (as far as possible).
     stay_on_real == False - try to stay on same relative line no. for
     the current address.
     stay_on_real == True - try to stay on the line which contains real
     bytes for the current address (use this if you know that cursor
     stayed on such line before the update).
     """
     addr, subno = self.cur_addr_subno()
     t = time.time()
     model = engine.render_partial_around(addr, subno, HEIGHT * 2)
     self.show_status("Rendering time: %fs" % (time.time() - t))
     self.set_model(model)
     if stay_on_real:
         self.cur_line = model.target_addr_lineno_real
     else:
         self.cur_line = model.target_addr_lineno
     self.top_line = self.cur_line - self.row
     self.update_screen()
コード例 #3
0
 def update_model(self, stay_on_real=False):
     """Re-render model and update screen in such way that cursor stayed
     on the same line (as far as possible).
     stay_on_real == False - try to stay on same relative line no. for
     the current address.
     stay_on_real == True - try to stay on the line which contains real
     bytes for the current address (use this if you know that cursor
     stayed on such line before the update).
     """
     addr, subno = self.cur_addr_subno()
     t = time.time()
     model = engine.render_partial_around(addr, subno, HEIGHT * 2)
     self.show_status("Rendering time: %fs" % (time.time() - t))
     self.set_model(model)
     if stay_on_real:
         self.cur_line = model.target_addr_lineno_real
     else:
         self.cur_line = model.target_addr_lineno
     self.top_line = self.cur_line - self.row
     #log.debug("update_model: addr=%x, row=%d, cur_line=%d, top_line=%d" % (addr, self.row, self.cur_line, self.top_line))
     self.update_screen()
コード例 #4
0
ファイル: scratchabit.py プロジェクト: aeppert/ScratchABit
            engine.ADDRESS_SPACE.make_unique_label(addr, label)
        def _progress(cnt):
            sys.stdout.write("Performing initial analysis... %d\r" % cnt)
        engine.analyze(_progress)
        print()

    #engine.print_address_map()

    if ENTRYPOINTS:
        show_addr = ENTRYPOINTS[0][1]
    else:
        show_addr = engine.ADDRESS_SPACE.min_addr()

    t = time.time()
    #_model = engine.render()
    _model = engine.render_partial_around(show_addr, 0, HEIGHT * 2)
    print("Rendering time: %fs" % (time.time() - t))
    #print(_model.lines())
    #sys.exit()

    Editor.init_tty()
    try:
        screen_size = Editor.screen_size()
        e = Editor(1, 1, screen_size[0] - 2, screen_size[1] - 3)
        e.cls()
        e.enable_mouse()
        e.draw_box(0, 0, screen_size[0], screen_size[1] - 1)
        e.set_model(_model)
        e.goto_addr(show_addr)
        e.loop()
    except:
コード例 #5
0
    else:
        for label, addr in ENTRYPOINTS:
            engine.add_entrypoint(addr)
            engine.ADDRESS_SPACE.set_label(addr, label)
        engine.analyze()

    #engine.print_address_map()

    if ENTRYPOINTS:
        show_addr = ENTRYPOINTS[0][1]
    else:
        show_addr = engine.ADDRESS_SPACE.min_addr()

    t = time.time()
    #_model = engine.render()
    _model = engine.render_partial_around(show_addr, 0, HEIGHT * 2)
    print("Rendering time: %fs" % (time.time() - t))
    #print(_model.lines())
    #sys.exit()

    e = Editor(1, 1, 78, 21)
    e.init_tty()
    e.cls()
    e.enable_mouse()
    e.draw_box(0, 0, 80, 23)
    e.set_model(_model)
    e.goto_addr(show_addr)
    e.loop()
    e.deinit_tty()
    e.wr("\n\n")