Beispiel #1
0
 def getFunctionReturnAddress(self, pygdb, ptid, pid=None):
     if pid is None:
         _pid = pygdb.getPidFromTid(ptid)
     else:
         _pid = pid
     sp = pygdb.getRegisterIndex(self.INDEX_SP, ptid)
     tmp = pygdb.readMemory(sp, self.WORD_SIZE, pid=_pid)
     return tools.byteStrToInt(tmp, tools.ENDIANESS.LITTLE)
Beispiel #2
0
 def getPointerAt(self, pygdb, addr, pid):
     """
     Gets the pointer at the given address.
     @param pygdb: The PyGdb instance to use
     @param addr: THe address of interest
     @param pid: The pid of interest
     """
     mem = pygdb.readMemory(addr, self.NATIVE_REGISTER_WIDTH >> 3, False, pid=pid)
     if mem is None:
         return None
     return tools.byteStrToInt(mem, self.endianess)
Beispiel #3
0
    def parseInstruction(ins):
        """
        Interprets a given byte-string (4 bytes) as an instruction.
        @param ins: The byte-string.
        @return: A tupel of the for values describing the instruction.
        """
        i = tools.byteStrToInt(ins, tools.ENDIANESS.BIG)
        a = i >> (MIPS32.NATIVE_REGISTER_WIDTH - 6)
        b = i >> (MIPS32.NATIVE_REGISTER_WIDTH - 6 - 5) & 0x1F
        c = i >> (MIPS32.NATIVE_REGISTER_WIDTH - 6 - 5 - 5) & 0x1F
        d = i & 0xFFFF
        e = i & ((1 << (MIPS32.NATIVE_REGISTER_WIDTH - 6)) - 1) # lower 26 bits

        return (a, b, c, d, e)
Beispiel #4
0
 def getAuxiliaryVector(self, gdbSession):
     
     rawAuxv = gdbSession.getRawAuxiliaryVector()
     entrySize = gdbSession.cpu.getNativeRegisterWidth()/8
     if gdbSession.cpu.islittleEndian():
         endianess = tools.ENDIANESS.LITTLE
     else:
         endianess = tools.ENDIANESS.BIG
     auxv = {}
     isIndex = True
     for i in range(len(rawAuxv))[::entrySize]:
         chunk = rawAuxv[i:i+entrySize]
         tmp = tools.byteStrToInt(chunk, endianess)
         if isIndex:
             index = tmp
         else:
             auxv[index] = tmp
         isIndex = not isIndex
     return auxv
Beispiel #5
0
 def _GET_JMP_OFFSET(opnd):
     opndSize = len(opnd)
     v = tools.byteStrToInt(opnd, tools.ENDIANESS.LITTLE)
     mask = 1 << ((opndSize*8)-1) 
     offset = (v^mask) - mask
     return offset