コード例 #1
0
 def createStruct(self, name):
     sid = ida_struct.get_struc_id(name)
     if sid != -1:
         idc.del_struc(sid)
     sid = idc.add_struc(-1, name, 0)
     self.types_id["name"] = sid
     return sid
コード例 #2
0
ファイル: database_entries.py プロジェクト: paperCut11/Classy
    def unlink_struct(self, delete_orphaned=False):
        if self.struct_id == idc.BADADDR:
            return

        del database.get().classes_by_struct_id[self.struct_id]

        if delete_orphaned:
            idc.del_struc(self.struct_id)
        else:
            struct_name = idc.get_struc_name(self.struct_id)
            idc.set_struc_cmt(self.struct_id, 'Orphaned from %s' % self.name, False)
            idc.set_struc_name(self.struct_id, '%s_orphaned' % struct_name)

        self.struct_id = idc.BADADDR
コード例 #3
0
def type_to_struct(name):
    idc.del_struc(idc.get_struc_id(name))  # delete existing struct
    idc.import_type(-1, name)  # -1 = append to end
コード例 #4
0
ファイル: events.py プロジェクト: snyiu100/IDAConnect
 def __call__(self):
     idc.del_struc(self.struc)
コード例 #5
0
# This script demonstrates how to create structures and populate them
# with members of different types.
#
# Author: Gergely Erdelyi <*****@*****.**>
#---------------------------------------------------------------------

import ida_struct
import ida_idaapi
import ida_bytes
import ida_nalt

import idc

sid = ida_struct.get_struc_id("mystr1")
if sid != -1:
    idc.del_struc(sid)
sid = ida_struct.add_struc(ida_idaapi.BADADDR, "mystr1", 0)
print("%x" % sid)

# Test simple data types
simple_types_data = [
    (ida_bytes.FF_BYTE, 1),
    (ida_bytes.FF_WORD, 2),
    (ida_bytes.FF_DWORD, 4),
    (ida_bytes.FF_QWORD, 8),
    (ida_bytes.FF_TBYTE, 10),
    (ida_bytes.FF_OWORD, 16),
    (ida_bytes.FF_FLOAT, 4),
    (ida_bytes.FF_DOUBLE, 8),
    (ida_bytes.FF_PACKREAL, 10),
]
コード例 #6
0
def register_structs():

    str_afu_header = """

	struct afu_header {
		unsigned short magic;
		unsigned short unk_0x100;
		unsigned short fw_type;
		unsigned short fw_version;
		unsigned int fw_len;
		unsigned int fw_crc;
		unsigned short product_id;
		unsigned short hw_revision_id;
	};

	"""

    str_afu_sig_header = """

	struct afu_sig_header {
		unsigned int magic;
		unsigned short unk_0x100;
		unsigned short unk_0x120;
		unsigned short digest_type; // guess 1 sha256?
		unsigned short digest_len;
		unsigned int digest_offs;
		unsigned short sig_type;
		unsigned short sig_len;
		unsigned int sig_offs;
	};

	"""

    str_afu_pers_header = """

	struct afu_pers_header {
		unsigned int magic;
		unsigned short unk_0x100;
		unsigned char uniqueid[12];
		unsigned char reserved[0x1c-0x12];
		unsigned int flags;
	};

	"""

    str_afu_full_header = """

	struct afu_full_header {
		struct afu_header header;
		unsigned char reserved1[0x20-0x14];
		struct afu_sig_header sig_header;
		unsigned char reserved2[0x40-0x38];
		struct afu_pers_header pers_header;
		unsigned char reserved3[0x7c-0x60];
		unsigned int header_crc;
	};

	"""

    sid = idc.get_struc_id("afu_header")
    if sid != -1:
        idc.del_struc(sid)

    r = idc.SetLocalType(-1, str_afu_header, 0)

    r = idc.import_type(-1, "afu_header")

    sid = idc.get_struc_id("afu_sig_header")
    if sid != -1:
        idc.del_struc(sid)

    r = idc.SetLocalType(-1, str_afu_sig_header, 0)

    r = idc.import_type(-1, "afu_sig_header")

    sid = idc.get_struc_id("afu_pers_header")
    if sid != -1:
        idc.del_struc(sid)

    r = idc.SetLocalType(-1, str_afu_pers_header, 0)

    r = idc.import_type(-1, "afu_pers_header")

    sid = idc.get_struc_id("afu_full_header")
    if sid != -1:
        idc.del_struc(sid)

    r = idc.SetLocalType(-1, str_afu_full_header, 0)

    r = idc.import_type(-1, "afu_full_header")
コード例 #7
0
ファイル: events.py プロジェクト: fcccode/IDAConnect
 def __call__(self):
     idc.del_struc(idc.get_struc_id(self.sname.encode('utf-8')))