How to use the continuum.index.LocalTypesIter function in continuum

To help you get started, we’ve selected a few continuum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zyantific / continuum / continuum / index.py View on Github external
def index_types_for_this_idb(self, purge_locally_deleted=False):
        """Indexes local types from this IDB into the DB."""
        cursor = self.db.cursor()

        # Create or update types.
        local_types = set()
        for cur_named_type in LocalTypesIter():
            local_types.add(cur_named_type)
            code, type_str, fields_str, cmt, field_cmts, sclass, value = idaapi.get_named_type64(
                idaapi.cvar.idati,
                cur_named_type,
                idaapi.NTF_TYPE | idaapi.NTF_SYMM,
            )

            ti = idaapi.tinfo_t()
            ti.deserialize(idaapi.cvar.idati, type_str, fields_str)
            c_type = ti._print(
                cur_named_type,
                idaapi.PRTYPE_1LINE | idaapi.PRTYPE_TYPE | idaapi.PRTYPE_SEMI,
                0, 0, None, cmt,
            )

            # TODO: prefer more concrete type rather than stupidly replacing.
github zyantific / continuum / continuum / index.py View on Github external
def sync_types_into_idb(self, purge_non_indexed=False):
        """Loads types from the index into this IDB and deletes all orphaned types."""
        cursor = self.db.cursor()
        self.project.ignore_changes = True

        try:
            cursor.execute("SELECT name, c_type FROM types")
            indexed_types = set()
            for cur_row in cursor.fetchall():
                idaapi.parse_decls(idaapi.cvar.idati, str(cur_row['c_type']), None, 0)
                indexed_types.add(cur_row['name'])

            if purge_non_indexed:
                orphaned_types = [x for x in LocalTypesIter() if x not in indexed_types]
                for cur_orphan in orphaned_types:
                    idaapi.del_named_type(
                        idaapi.cvar.idati, cur_orphan, idaapi.NTF_TYPE | idaapi.NTF_SYMM
                    )
        finally:
            self.project.ignore_changes = False