Ejemplo n.º 1
0
    def __init__(
        self,
        theType,
        offset,
        vm,
        parent=None,
        count=1,
        targetType=None,
        target=None,
        name=None,
        **kwargs,
    ):
        ## Instantiate the first object on the offset:
        BaseObject.__init__(
            self, theType, offset, vm, parent=parent, name=name, **kwargs
        )

        if callable(count):
            count = count(parent)

        self.count = int(count)

        self.original_offset = offset
        if targetType:
            self.target = Curry(Object, targetType)
        else:
            self.target = target

        self.current = self.target(
            offset=offset, vm=vm, parent=self, name=name
        )
        if self.current.size() == 0:
            ## It is an error to have a zero sized element
            debug.debug("Array with 0 sized members???", level=10)
            debug.b()
Ejemplo n.º 2
0
    def __init__(self, theType, offset, vm, parent=None, count=1, targetType=None, target=None, name=None, **kwargs):
        ## Instantiate the first object on the offset:
        BaseObject.__init__(self, theType, offset, vm, parent=parent, name=name, **kwargs)

        if isinstance(count, collections.Callable):
            count = count(parent)

        self.count = int(count)

        self.original_offset = offset
        if targetType:
            self.target = Curry(Object, targetType)
        else:
            self.target = target

        self.current = self.target(offset=offset, vm=vm, parent=self, name=name)
        if self.current.size() == 0:
            ## It is an error to have a zero sized element
            debug.debug("Array with 0 sized members???", level=10)
            debug.b()
Ejemplo n.º 3
0
    def check_addr(self, found):
        """ This calls all our constraints on the offset found and
        returns the number of contraints that matched.

        We shortcut the loop as soon as its obvious that there will
        not be sufficient matches to fit the criteria. This allows for
        an early exit and a speed boost.
        """
        cnt = 0
        for check in self.constraints:
            ## constraints can raise for an error
            try:
                val = check.check(found)
            except Exception:
                debug.b()
                val = False

            if not val:
                cnt = cnt + 1

            if cnt > self.error_count:
                return False

        return True
Ejemplo n.º 4
0
    def check_addr(self, found):
        """ This calls all our constraints on the offset found and
        returns the number of contraints that matched.

        We shortcut the loop as soon as its obvious that there will
        not be sufficient matches to fit the criteria. This allows for
        an early exit and a speed boost.
        """
        cnt = 0
        for check in self.constraints:
            ## constraints can raise for an error
            try:
                val = check.check(found)
            except Exception:
                debug.b()
                val = False

            if not val:
                cnt = cnt + 1

            if cnt > self.error_count:
                return False

        return True