itanium.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:devirtualize 作者: ALSchwalm 项目源码 文件源码
def __init__(self, ea):
        #: The address of the start of this vtable
        self.ea = ea

        ea, offset_to_top = get_address(ea)

        #: The offset to the top of the object for a subobject with this vtable
        self.offset_to_top = as_signed(offset_to_top, TARGET_ADDRESS_SIZE)

        # Arbitrary bounds for offset size
        if self.offset_to_top < -0xFFFFFF or self.offset_to_top > 0xFFFFFF:
            raise ValueError("Invalid table address `0x{:02x}`".format(self.ea))

        ea, typeinfo = get_address(ea)

        #: Handle to the RTTI object associated with this vtable (if any)
        self.typeinfo = None

        if typeinfo != 0:
            if not in_same_segment(typeinfo, self.ea):
                raise ValueError("Invalid table address `0x{:02x}`".format(self.ea))
            else:
                self.typeinfo = ItaniumTypeInfo(typeinfo)

        #: A list of function addresses in this vtable (some may be NULL)
        self.functions = []

        #: The address of the start of the function array
        self.address_point = ea

        try:
            next(idautils.XrefsTo(self.address_point))
        except StopIteration:
            raise ValueError("Invalid table address `0x{:02x}`".format(self.ea))

        while True:
            ea, func = get_address(ea)

            # The first few function pointers can be 0
            if not is_in_executable_segment(func):
                if func == 0 and all([f == 0 for f in self.functions]):
                    pass
                else:
                    break

            self.functions.append(func)

        # Because the first two functions can be zero, and the RTTI
        # pointer and base offset can also be zero, require at least
        # one function to not be zero (so blocks of zero don't match).
        if all([f == 0 for f in self.functions]):
            raise ValueError("Invalid table address `0x{:02x}`".format(self.ea))

        #: The size in bytes of this vtable
        self.size = TARGET_ADDRESS_SIZE*(len(self.functions) + 2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号