Example #1
0
    def _dumpCode(self, address, ip, manage_bp):
        if not HAS_DISASSEMBLER:
            code = self.readCode(address)
            text = " ".join("%02x" % ord(byte) for byte in code)
            error("CODE: %s" % text)
            return

        if manage_bp:
            for line in xrange(10):
                bp = False
                if address in self.breakpoints:
                    bytes = self.breakpoints[address].old_bytes
                    instr = disassembleOne(bytes, address)
                    bp = True
                else:
                    instr = self.disassembleOne(address)
                text = "ASM %s: %s (%s)" % (formatAddress(
                    instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                if bp:
                    text += "     * BREAKPOINT *"
                error(text)
                address = address + instr.size
        else:
            for instr in self.disassemble(address):
                text = "ASM %s: %s (%s)" % (formatAddress(
                    instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                error(text)
Example #2
0
 def disassembleOne(self, address=None):
     if not HAS_DISASSEMBLER:
         self.notImplementedError()
     if address is None:
         address = self.getInstrPointer()
     code = self.readBytes(address, MAX_INSTR_SIZE)
     return disassembleOne(code, address)
Example #3
0
 def disassembleOne(self, address=None):
     if not HAS_DISASSEMBLER:
         self.notImplementedError()
     if address is None:
         address = self.getInstrPointer()
     code = self.readBytes(address, MAX_INSTR_SIZE)
     return disassembleOne(code, address)
Example #4
0
    def _dumpCode(self, address, ip, manage_bp):
        if not HAS_DISASSEMBLER:
            code = self.readCode(address)
            text = " ".join( "%02x" % ord(byte) for byte in code )
            error("CODE: %s" % text)
            return

        if manage_bp:
            for line in xrange(10):
                bp = False
                if address in self.breakpoints:
                    bytes = self.breakpoints[address].old_bytes
                    instr = disassembleOne(bytes, address)
                    bp = True
                else:
                    instr = self.disassembleOne(address)
                text = "ASM %s: %s (%s)" % (formatAddress(instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                if bp:
                    text += "     * BREAKPOINT *"
                error(text)
                address = address+instr.size
        else:
            for instr in self.disassemble(address):
                text = "ASM %s: %s (%s)" % (formatAddress(instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                error(text)
Example #5
0
    def _dumpCode(self, start, stop, ip, manage_bp, log):
        if stop is not None:
            stop = max(start, stop)
            stop = min(stop, start + MAX_CODE_SIZE - 1)

        if not HAS_DISASSEMBLER:
            if stop is not None:
                size = stop - start + 1
            else:
                size = MIN_CODE_SIZE
            code = self.readBytes(start, size)
            if RUNNING_PYTHON3:
                text = " ".join("%02x" % byte for byte in code)
            else:
                text = " ".join("%02x" % ord(byte) for byte in code)
            log("CODE: %s" % text)
            return

        log("CODE:")
        if manage_bp:
            address = start
            for line in range(10):
                bp = False
                if address in self.breakpoints:
                    bytes = self.breakpoints[address].old_bytes
                    instr = disassembleOne(bytes, address)
                    bp = True
                else:
                    instr = self.disassembleOne(address)
                text = "%s| %s (%s)" % (formatAddress(
                    instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                if bp:
                    text += "     * BREAKPOINT *"
                log(text)
                address = address + instr.size
                if stop is not None and stop <= address:
                    break
        else:
            for instr in self.disassemble(start, stop):
                text = "%s| %s (%s)" % (formatAddress(
                    instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                log(text)
Example #6
0
    def _dumpCode(self, start, stop, ip, manage_bp, log):
        if stop is not None:
            stop = max(start, stop)
            stop = min(stop, start + MAX_CODE_SIZE - 1)

        if not HAS_DISASSEMBLER:
            if stop is not None:
                size = stop - start + 1
            else:
                size = MIN_CODE_SIZE
            code = self.readBytes(start, size)
            if RUNNING_PYTHON3:
                text = " ".join("%02x" % byte for byte in code)
            else:
                text = " ".join("%02x" % ord(byte) for byte in code)
            log("CODE: %s" % text)
            return

        if manage_bp:
            address = start
            for line in range(10):
                bp = False
                if address in self.breakpoints:
                    bytes = self.breakpoints[address].old_bytes
                    instr = disassembleOne(bytes, address)
                    bp = True
                else:
                    instr = self.disassembleOne(address)
                text = "%s| %s (%s)" % (formatAddress(
                    instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                if bp:
                    text += "     * BREAKPOINT *"
                log(text)
                address = address + instr.size
                if stop is not None and stop <= address:
                    break
        else:
            for instr in self.disassemble(start, stop):
                text = "%s| %s (%s)" % (formatAddress(
                    instr.address), instr.text, instr.hexa)
                if instr.address == ip:
                    text += " <=="
                log(text)
Example #7
0
 def disassembleOne(self, address=None):
     if address is None:
         address = self.getInstrPointer()
     code = self.readBytes(address, MAX_INSTR_SIZE)
     return disassembleOne(code, address)
Example #8
0
 def disassembleOne(self, address=None):
     if address is None:
         address = self.getInstrPointer()
     code = self.readBytes(address, MAX_INSTR_SIZE )
     return disassembleOne(code, address)