Example #1
0
 def setUpClass(cls):
     cls.memory_handler = dump_loader.load('test/src/test-ctypes5.32.dump')
     cls.my_target = cls.memory_handler.get_target_platform()
     cls.my_ctypes = cls.my_target.get_target_ctypes()
     cls.my_utils = cls.my_target.get_target_ctypes_utils()
     cls.my_model = cls.memory_handler.get_model()
     cls.ctypes5_gen32 = cls.my_model.import_module("test.src.ctypes5_gen32")
     cls.validator = listmodel.ListModel(cls.memory_handler, None)
Example #2
0
def validate_record(memory_handler, instance, record_constraints=None, max_depth=10):
    """
    Validate a loaded record against constraints.

    :param memory_handler: IMemoryHandler
    :param instance: a ctypes record
    :param record_constraints: IModuleConstraints to be considered during validation
    :return:
    """
    validator = listmodel.ListModel(memory_handler, record_constraints)
    return validator.load_members(instance, max_depth)
Example #3
0
 def _load_at(self, mem_map, address, struct_type, depth=99):
     """
         loads a haystack ctypes structure from a specific offset.
             return (instance,validated) with instance being the
             haystack ctypes structure instance and validated a boolean True/False.
     """
     log.debug("Loading %s from 0x%lx " % (struct_type, address))
     instance = mem_map.read_struct(address, struct_type)
     log.debug("Validating %s from 0x%lx " % (struct_type, address))
     validator = listmodel.ListModel(self._memory_handler, self._my_constraints)
     # check if data matches
     if validator.load_members(instance, depth):
         # FIXME: should be if validator.is_valid(instance):
         log.debug("found instance %s @ 0x%lx", struct_type, address)
         # do stuff with it.
         validated = True
     else:
         log.debug("Address not validated")
         validated = False
     return instance, validated