示例#1
0
    def __call__(self):
        local_type = []
        for t in self.local_type:
            if t is not None:
                local_type.append((
                    t[0],
                    Event.encode_bytes(t[1]),
                    Event.encode_bytes(t[2]),
                    Event.encode_bytes(t[3]),
                ))
            else:
                local_type.append(None)

        def alloc_oridinal(target_ordinal):
            # Get_ordinal_qty() will return (current max ordinal + 1)
            missing_ord = (target_ordinal - ida_typeinf.get_ordinal_qty(None) +
                           1)
            if missing_ord > 0:
                ida_typeinf.alloc_type_ordinals(None, missing_ord)

        for t in local_type:
            if t is not None:
                alloc_oridinal(t[0])

                # Can't change some local types if we don't delete them first
                ida_typeinf.del_numbered_type(None, t[0])

                cur_tinfo = ida_typeinf.tinfo_t()
                cur_tinfo.deserialize(None, t[1], t[2])
                cur_tinfo.set_numbered_type(None, t[0], 0, t[3])
                ida_typeinf.import_type(None, -1, t[-1])

        ida_kernwin.request_refresh(ida_kernwin.IWID_LOCTYPS)
示例#2
0
    def __call__(self):
        local_type = []
        for t in self.local_type:
            if t is not None:
                local_type.append((
                    t[0],
                    Event.encode_bytes(t[1]),
                    Event.encode_bytes(t[2]),
                    Event.encode_bytes(t[3]),
                ))
            else:
                local_type.append(None)

        def alloc_oridinal(target_ordinal):
            # get_ordinal_qty() will return (current max ordinal + 1)
            missing_ord = target_ordinal - ida_typeinf.get_ordinal_qty(
                None) + 1
            if missing_ord > 0:
                ida_typeinf.alloc_type_ordinals(None, missing_ord)

        for t in local_type:
            if t is not None:
                logger.debug("Processing: %s", str(t))
                alloc_oridinal(t[0])

                # Can't change some local types if not delete them first
                # Example: struct aaa{int a;}'
                ida_typeinf.del_numbered_type(None, t[0])

                cur_tinfo = ida_typeinf.tinfo_t()
                cur_tinfo.deserialize(None, t[1], t[2])
                logger.debug("set_numbered_type ret: %d",
                             cur_tinfo.set_numbered_type(None, t[0], 0, t[3]))

        ida_kernwin.request_refresh(ida_kernwin.IWID_LOCTYPS)
示例#3
0
    def __call__(self):
        from .core import Core

        dll = Core.get_ida_dll()

        get_idati = dll.get_idati
        get_idati.argtypes = []
        get_idati.restype = ctypes.c_void_p

        set_numbered_type = dll.set_numbered_type
        set_numbered_type.argtypes = [
            ctypes.c_void_p,
            ctypes.c_uint32,
            ctypes.c_int,
            ctypes.c_char_p,
            ctypes.c_char_p,
            ctypes.c_char_p,
            ctypes.c_char_p,
            ctypes.c_char_p,
            ctypes.c_int,
        ]
        set_numbered_type.restype = ctypes.c_int

        py_ti = ida_typeinf.get_idati()
        ordinal_qty = ida_typeinf.get_ordinal_qty(py_ti) - 1
        last_ordinal = self.local_types[-1][0]
        if ordinal_qty < last_ordinal:
            ida_typeinf.alloc_type_ordinals(py_ti, last_ordinal - ordinal_qty)
        else:
            for py_ordinal in range(last_ordinal + 1, ordinal_qty + 1):
                ida_typeinf.del_numbered_type(py_ti, py_ordinal)

        local_types = self.local_types
        for py_ord, name, type, fields, cmt, fieldcmts, sclass in local_types:
            if type:
                ti = get_idati()
                ordinal = ctypes.c_uint32(py_ord)
                ntf_flags = ctypes.c_int(ida_typeinf.NTF_REPLACE)
                name = ctypes.c_char_p(name)
                type = ctypes.c_char_p(type)
                fields = ctypes.c_char_p(fields)
                cmt = ctypes.c_char_p(cmt)
                fieldcmts = ctypes.c_char_p(fieldcmts)
                sclass = ctypes.c_int(sclass)
                set_numbered_type(
                    ti,
                    ordinal,
                    ntf_flags,
                    name,
                    type,
                    fields,
                    cmt,
                    fieldcmts,
                    sclass,
                )
            else:
                ida_typeinf.del_numbered_type(py_ti, py_ord)

        ida_kernwin.request_refresh(ida_kernwin.IWID_LOCTYPS)
示例#4
0
    def __call__(self):
        ti = ida_typeinf.get_idati()

        ordinal_qty = ida_typeinf.get_ordinal_qty(ti)
        last_ordinal = self.local_types[-1][0]
        if ordinal_qty < last_ordinal:
            ida_typeinf.alloc_type_ordinals(ti, last_ordinal - ordinal_qty)
        else:
            for ordinal in range(last_ordinal + 1, ordinal_qty + 1):
                ida_typeinf.del_numbered_type(ti, ordinal)

        for ordinal, name, ret in self.local_types:
            name = Event.encode_bytes(name)
            type, fields, fieldcmts = ret
            type = Event.encode_bytes(type)
            fields = Event.encode_bytes(fields)
            fieldcmts = Event.encode_bytes(fieldcmts)

            type_info = ida_typeinf.tinfo_t()
            type_info.deserialize(ti, type, fields, fieldcmts)
            type_info.set_numbered_type(ti, ordinal, 0, name)

        ida_kernwin.request_refresh(ida_kernwin.IWID_LOCTYPS)
示例#5
0
文件: events.py 项目: kindow/IDArling
    def __call__(self):
        local_type = []
        for t in self.local_type:
            if t is not None:
                local_type.append((
                    Event.encode_bytes(t[0]),
                    Event.encode_bytes(t[1]),
                    Event.encode_bytes(t[2]),
                ))
            else:
                local_type.append(None)

        missing_ord = len(local_type) - ida_typeinf.get_ordinal_qty(None) + 1
        if missing_ord > 0:
            ida_typeinf.alloc_type_ordinals(None, missing_ord)

        for i, t in enumerate(local_type):
            if t is not None:
                cur_tinfo = ida_typeinf.tinfo_t()
                cur_tinfo.deserialize(None, t[0], t[1])
                cur_tinfo.set_numbered_type(None, i + 1, 0, t[2])
            else:
                ida_typeinf.del_numbered_type(None, i + 1)
        ida_kernwin.request_refresh(ida_kernwin.IWID_LOCTYPS)