我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用idaapi.get_import_module_name()。
def get_imports(): ''' enumerate the imports of the currently loaded module. Yields: Tuple[int, str, str, int]: - address of import table pointer - name of imported library - name of imported function - ordinal of import ''' for i in range(idaapi.get_import_module_qty()): dllname = idaapi.get_import_module_name(i) if not dllname: continue entries = [] def cb(ea, name, ordinal): entries.append((ea, name, ordinal)) return True # continue enumeration idaapi.enum_import_names(i, cb) for ea, name, ordinal in entries: yield ea, dllname, name, ordinal
def init_imported_ea(*args): def imp_cb(ea, name, ord): imported_ea.add(ea) # True -> Continue enumeration # False -> Stop enumeration return True print "[Info] Collecting information about imports" imported_ea.clear() nimps = idaapi.get_import_module_qty() for i in xrange(0, nimps): name = idaapi.get_import_module_name(i) if not name: print "[Warning] Failed to get import module name for #%d" % i continue # print "Walking-> %s" % name idaapi.enum_import_names(i, imp_cb) print "[Info] Done..."
def driver_type(): implist = idaapi.get_import_module_qty() for i in range(0, implist): name = idaapi.get_import_module_name(i) idaapi.enum_import_names(i, cb) for i in names: if name == "FltRegisterFilter": return "Mini-Filter" elif name == "WdfVersionBind": return "WDF" elif name == "StreamClassRegisterMinidriver": return "Stream Minidriver" elif name == "KsCreateFilterFactory": return "AVStream" elif name == "PcRegisterSubdevice": return "PortCls" return "WDM"
def get_imports(library_calls): """ Populate dictionaries with import information. Return imported modules. """ import_modules = [] import_names_callback = make_import_names_callback(library_calls) for i in xrange(0, idaapi.get_import_module_qty()): import_modules.append(idaapi.get_import_module_name(i)) idaapi.enum_import_names(i, import_names_callback) return import_modules
def __iterate__(): """Iterate through all of the imports in the database. Yields (ea,(module,name,ordinal)) for each iteration. """ for idx in xrange(idaapi.get_import_module_qty()): module = idaapi.get_import_module_name(idx) result = [] idaapi.enum_import_names(idx, utils.compose(utils.box,result.append,utils.fdiscard(lambda:True))) for ea,name,ordinal in result: yield (ea,(module,name,ordinal)) continue return
def modules(cls): '''Return all of the import modules defined in the database.''' return [idaapi.get_import_module_name(i) for i in xrange(idaapi.get_import_module_qty())]
def get_imports(): for i in xrange(0, idaapi.get_import_module_qty()): name = idaapi.get_import_module_name(i) if name: yield name
def compute_imports(): imports = {} current = "" def callback(ea, name, ordinal): imports[current].append((ea, name, ordinal)) return True nimps = idaapi.get_import_module_qty() for i in xrange(0, nimps): current = idaapi.get_import_module_name(i) imports[current] = [] idaapi.enum_import_names(i, callback) return imports
def handleBuildImport(self): nimps = get_import_module_qty() self.imports = [] for i in xrange(0, nimps): self.currentModuleName = get_import_module_name(i) if not self.currentModuleName: continue enum_import_names(i, self.imports_names_cb)