Exemple #1
0
 def _resolvePointerToStructField(self, field): #, structs_addrs, structCache):
   raise NotImplementedError('Obselete')
   ## TODO DEBUG, i got gaps in my memory mappings structures
   #  struct_add16e8 -> struct_add173c
   #if len(structs_addrs) == 0:
   if len(self._context._malloc_addresses) == 0:
     raise TypeError
     #return None
   # TODO use context's helpers
   nearest_addr, ind = utils.closestFloorValue(field.value, self._context._malloc_addresses)
   log.debug('nearest_addr:%x ind:%d'%(nearest_addr, ind))
   tgt_st = self._context.getStructureForAddr(nearest_addr)
   if field.value%Config.WORDSIZE != 0:
     # non aligned, nothing could match
     return tgt_st, None
   log.debug('tgt_st %s'%tgt_st)
   if field.value in tgt_st:
     offset = field.value - nearest_addr
     for f in tgt_st._fields:
       if f.offset == offset:
         tgt_field = f
         log.debug('Found %s'%f)
         return tgt_st, tgt_field
   log.debug('no field found')
   return tgt_st, None
Exemple #2
0
 def _resolvePointerToStructField(self,
                                  field):  #, structs_addrs, structCache):
     raise NotImplementedError('Obselete')
     ## TODO DEBUG, i got gaps in my memory mappings structures
     #  struct_add16e8 -> struct_add173c
     #if len(structs_addrs) == 0:
     if len(self._context._malloc_addresses) == 0:
         raise TypeError
         #return None
     # TODO use context's helpers
     nearest_addr, ind = utils.closestFloorValue(
         field.value, self._context._malloc_addresses)
     log.debug('nearest_addr:%x ind:%d' % (nearest_addr, ind))
     tgt_st = self._context.getStructureForAddr(nearest_addr)
     if field.value % Config.WORDSIZE != 0:
         # non aligned, nothing could match
         return tgt_st, None
     log.debug('tgt_st %s' % tgt_st)
     if field.value in tgt_st:
         offset = field.value - nearest_addr
         for f in tgt_st._fields:
             if f.offset == offset:
                 tgt_field = f
                 log.debug('Found %s' % f)
                 return tgt_st, tgt_field
     log.debug('no field found')
     return tgt_st, None
Exemple #3
0
 def _resolvePointerToStructField(self, field, structs_addrs, structCache):
     ## TODO DEBUG, i got gaps in my memory mappings structures
     #  struct_add16e8 -> struct_add173c
     if len(structs_addrs) == 0:
         raise TypeError
         #return None
     nearest_addr, ind = utils.closestFloorValue(field.value, structs_addrs)
     log.debug('nearest_addr:%x ind:%d' % (nearest_addr, ind))
     tgt_st = structCache[nearest_addr]
     if field.value % Config.WORDSIZE != 0:
         # non aligned, nothing could match
         return tgt_st, None
     log.debug('tgt_st %s' % tgt_st)
     if field.value in tgt_st:
         offset = field.value - nearest_addr
         for f in tgt_st._fields:
             if f.offset == offset:
                 tgt_field = f
                 log.debug('Found %s' % f)
                 return tgt_st, tgt_field
     log.debug('no field found')
     return tgt_st, None
 def _resolvePointerToStructField(self, field, structs_addrs, structCache):
   ## TODO DEBUG, i got gaps in my memory mappings structures
   #  struct_add16e8 -> struct_add173c
   if len(structs_addrs) == 0:
     raise TypeError
     #return None
   nearest_addr, ind = utils.closestFloorValue(field.value, structs_addrs)
   log.debug('nearest_addr:%x ind:%d'%(nearest_addr, ind))
   tgt_st = structCache[nearest_addr]
   if field.value%Config.WORDSIZE != 0:
     # non aligned, nothing could match
     return tgt_st, None
   log.debug('tgt_st %s'%tgt_st)
   if field.value in tgt_st:
     offset = field.value - nearest_addr
     for f in tgt_st._fields:
       if f.offset == offset:
         tgt_field = f
         log.debug('Found %s'%f)
         return tgt_st, tgt_field
   log.debug('no field found')
   return tgt_st, None
Exemple #5
0
 def getStructureAddrForOffset(self, offset):
   '''Returns the closest containing structure address for this offset in this heap.'''
   if offset not in self.heap:
     raise ValueError('address not in heap')
   return utils.closestFloorValue(offset, self._structures_addresses)[0] # [1] is the index of [0]