示例#1
0
    def test_closestFloorValue(self):
        lst = numpy.asarray(range(0, 100, 10))
        self.assertEquals(utils.closestFloorValue(41, lst), (40, 4))
        self.assertEquals(utils.closestFloorValue(40, lst), (40, 4))
        with self.assertRaises(ValueError):
            utils.closestFloorValue(-1, lst)

        ctx = context.get_context('test/src/test-ctypes3.dump')
        lst = ctx._structures_addresses
示例#2
0
 def test_closestFloorValue(self):
   lst = numpy.asarray(range(0,100,10))
   self.assertEquals(utils.closestFloorValue(41, lst), (40,4))
   self.assertEquals(utils.closestFloorValue(40, lst), (40,4))
   with self.assertRaises(ValueError):
     utils.closestFloorValue(-1, lst)
   
   ctx = context.get_context('test/src/test-ctypes3.dump')
   lst = ctx._structures_addresses
示例#3
0
    def test_closestFloorValue(self):
        lst = numpy.asarray(range(0, 100, 10))
        self.assertEquals(utils.closestFloorValue(41, lst), (40, 4))
        self.assertEquals(utils.closestFloorValue(40, lst), (40, 4))
        with self.assertRaises(ValueError):
            utils.closestFloorValue(-1, lst)

        memory_handler = dump_loader.load('test/src/test-ctypes3.32.dump')
        finder = memory_handler.get_heap_finder()
        heap = finder.get_heap_mappings()[0]
        heap_addr = heap.get_marked_heap_address()
        ctx = context.get_context_for_address(memory_handler, heap_addr)
        lst = ctx._structures_addresses
示例#4
0
    def test_closestFloorValue(self):
        lst = numpy.asarray(range(0, 100, 10))
        self.assertEquals(utils.closestFloorValue(41, lst), (40, 4))
        self.assertEquals(utils.closestFloorValue(40, lst), (40, 4))
        with self.assertRaises(ValueError):
            utils.closestFloorValue(-1, lst)

        memory_handler = dump_loader.load('test/src/test-ctypes3.32.dump')
        finder = memory_handler.get_heap_finder()
        heap = finder.get_heap_mappings()[0]
        heap_addr = heap.get_marked_heap_address()
        ctx = context.get_context_for_address(memory_handler, heap_addr)
        lst = ctx._structures_addresses
示例#5
0
 def get_record_address_at_address(self, _address):
     """
     Returns the closest containing record address for this address.
     :param _address:
     :return:
     """
     # if offset not in self.heap:
     #  raise ValueError('address 0x%0.8x not in heap 0x%0.8x'%(offset, self.heap.start))
     return utils.closestFloorValue(_address, self._structures_addresses)[0]  # [1] is the index of [0]
示例#6
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 0x%0.8x not in heap 0x%0.8x'%(offset, self.heap.start))
   return utils.closestFloorValue(offset, self._structures_addresses)[0] # [1] is the index of [0]