IDAPython 9.0
Loading...
Searching...
No Matches
ida_loader Namespace Reference

Detailed Description

Definitions of IDP, LDR, PLUGIN module interfaces.

This file also contains:
* functions to load files into the database
* functions to generate output files
* high level functions to work with the database (open, save, close)


The LDR interface consists of one structure: loader_t 
The IDP interface consists of one structure: processor_t 
The PLUGIN interface consists of one structure: plugin_t
Modules can't use standard FILE* functions. They must use functions from <fpro.h>
Modules can't use standard memory allocation functions. They must use functions from <pro.h>
The exported entry #1 in the module should point to the the appropriate structure. (loader_t for LDR module, for example) 

Classes

class  idp_desc_t
 
class  idp_name_t
 
class  loader_t
 
class  plugin_info_t
 
class  qvector_snapshotvec_t
 
class  snapshot_t
 

Functions

bool load_binary_file (str filename, 'linput_t *' li, 'ushort' _neflags, 'qoff64_t' fileoff, ida_idaapi.ea_t basepara, ida_idaapi.ea_t binoff, 'uint64' nbytes)
 
str process_archive (str temp_file, 'linput_t *' li, str module_name, 'ushort *' neflags, str defmember, 'load_info_t const *' loader)
 
int gen_file ('ofile_type_t' otype, 'FILE *' fp, ida_idaapi.ea_t ea1, ida_idaapi.ea_t ea2, int flags)
 
int file2base ('linput_t *' li, 'qoff64_t' pos, ida_idaapi.ea_t ea1, ida_idaapi.ea_t ea2, int patchable)
 
int base2file ('FILE *' fp, 'qoff64_t' pos, ida_idaapi.ea_t ea1, ida_idaapi.ea_t ea2)
 
'filetype_t' get_basic_file_type ('linput_t *' li)
 
str get_file_type_name ()
 
None set_import_ordinal (int modnode, ida_idaapi.ea_t ea, int ord)
 
None set_import_name (int modnode, ida_idaapi.ea_t ea, str name)
 
int load_ids_module ('char *' fname)
 
str get_plugin_options (str plugin)
 
'plugin_t *' find_plugin (str name, bool load_if_needed=False)
 
'qoff64_t' get_fileregion_offset (ida_idaapi.ea_t ea)
 
ida_idaapi.ea_t get_fileregion_ea ('qoff64_t' offset)
 
int gen_exe_file ('FILE *' fp)
 
bool reload_file (str file, bool is_remote)
 
bool build_snapshot_tree ('snapshot_t' root)
 
int flush_buffers ()
 
bool is_trusted_idb ()
 
bool save_database (str outfile=None, int flags=-1, 'snapshot_t' root=None, 'snapshot_t' attr=None)
 
bool is_database_flag (int dbfl)
 
None set_database_flag (int dbfl, bool cnd=True)
 
None clr_database_flag (int dbfl)
 
str get_path ('path_type_t' pt)
 
None set_path ('path_type_t' pt, str path)
 
str get_elf_debug_file_directory ()
 
 mem2base (mem, ea, fpos)
 
 load_plugin (name)
 
 run_plugin (plg, arg)
 
bool load_and_run_plugin (str name, 'size_t' arg)
 
'PyObject *' extract_module_from_archive (str fname, bool is_remote=False)
 

Variables

 LDRF_RELOAD = _ida_loader.LDRF_RELOAD
 
 LDRF_REQ_PROC = _ida_loader.LDRF_REQ_PROC
 
 ACCEPT_ARCHIVE = _ida_loader.ACCEPT_ARCHIVE
 
 ACCEPT_CONTINUE = _ida_loader.ACCEPT_CONTINUE
 
 ACCEPT_FIRST = _ida_loader.ACCEPT_FIRST
 
 NEF_SEGS = _ida_loader.NEF_SEGS
 
 NEF_RSCS = _ida_loader.NEF_RSCS
 
 NEF_NAME = _ida_loader.NEF_NAME
 
 NEF_MAN = _ida_loader.NEF_MAN
 
 NEF_FILL = _ida_loader.NEF_FILL
 
 NEF_IMPS = _ida_loader.NEF_IMPS
 
 NEF_FIRST = _ida_loader.NEF_FIRST
 
 NEF_CODE = _ida_loader.NEF_CODE
 
 NEF_RELOAD = _ida_loader.NEF_RELOAD
 
 NEF_FLAT = _ida_loader.NEF_FLAT
 
 NEF_MINI = _ida_loader.NEF_MINI
 
 NEF_LOPT = _ida_loader.NEF_LOPT
 
 NEF_LALL = _ida_loader.NEF_LALL
 
 DLLEXT = _ida_loader.DLLEXT
 
 LOADER_DLL = _ida_loader.LOADER_DLL
 
 OFILE_MAP = _ida_loader.OFILE_MAP
 
 OFILE_EXE = _ida_loader.OFILE_EXE
 
 OFILE_IDC = _ida_loader.OFILE_IDC
 
 OFILE_LST = _ida_loader.OFILE_LST
 
 OFILE_ASM = _ida_loader.OFILE_ASM
 
 OFILE_DIF = _ida_loader.OFILE_DIF
 
 GENFLG_MAPSEG = _ida_loader.GENFLG_MAPSEG
 
 GENFLG_MAPNAME = _ida_loader.GENFLG_MAPNAME
 
 GENFLG_MAPDMNG = _ida_loader.GENFLG_MAPDMNG
 
 GENFLG_MAPLOC = _ida_loader.GENFLG_MAPLOC
 
 GENFLG_IDCTYPE = _ida_loader.GENFLG_IDCTYPE
 
 GENFLG_ASMTYPE = _ida_loader.GENFLG_ASMTYPE
 
 GENFLG_GENHTML = _ida_loader.GENFLG_GENHTML
 
 GENFLG_ASMINC = _ida_loader.GENFLG_ASMINC
 
 FILEREG_PATCHABLE = _ida_loader.FILEREG_PATCHABLE
 
 FILEREG_NOTPATCHABLE = _ida_loader.FILEREG_NOTPATCHABLE
 
 PLUGIN_DLL = _ida_loader.PLUGIN_DLL
 
 MODULE_ENTRY_LOADER = _ida_loader.MODULE_ENTRY_LOADER
 
 MODULE_ENTRY_PLUGIN = _ida_loader.MODULE_ENTRY_PLUGIN
 
 MODULE_ENTRY_IDP = _ida_loader.MODULE_ENTRY_IDP
 
 IDP_DLL = _ida_loader.IDP_DLL
 
 MAX_DATABASE_DESCRIPTION = _ida_loader.MAX_DATABASE_DESCRIPTION
 
 SSF_AUTOMATIC = _ida_loader.SSF_AUTOMATIC
 
 SSUF_DESC = _ida_loader.SSUF_DESC
 
 SSUF_PATH = _ida_loader.SSUF_PATH
 
 SSUF_FLAGS = _ida_loader.SSUF_FLAGS
 
 DBFL_KILL = _ida_loader.DBFL_KILL
 
 DBFL_COMP = _ida_loader.DBFL_COMP
 
 DBFL_BAK = _ida_loader.DBFL_BAK
 
 DBFL_TEMP = _ida_loader.DBFL_TEMP
 
 PATH_TYPE_CMD = _ida_loader.PATH_TYPE_CMD
 
 PATH_TYPE_IDB = _ida_loader.PATH_TYPE_IDB
 
 PATH_TYPE_ID0 = _ida_loader.PATH_TYPE_ID0
 

Function Documentation

◆ base2file()

int base2file ( 'FILE *' fp,
'qoff64_t' pos,
ida_idaapi.ea_t ea1,
ida_idaapi.ea_t ea2 )
Unload database to a binary file. This function works for wide byte processors too. 
    
@param fp: pointer to file
@param pos: position in the file
@param ea1: range of source linear addresses
@param ea2: range of source linear addresses
@returns 1-ok(always), write error leads to immediate exit

◆ build_snapshot_tree()

bool build_snapshot_tree ( 'snapshot_t' root)
Build the snapshot tree. 
    
@param root: snapshot root that will contain the snapshot tree elements.
@returns success

◆ clr_database_flag()

None clr_database_flag ( int dbfl)

◆ extract_module_from_archive()

'PyObject *' extract_module_from_archive ( str fname,
bool is_remote = False )
Extract a module for an archive file. Parse an archive file, show the list of modules to the user, allow him to select a module, extract the selected module to a file (if the extract module is an archive, repeat the process). This function can handle ZIP, AR, AIXAR, OMFLIB files. The temporary file will be automatically deleted by IDA at the end. 
    
@param is_remote: is the input file remote?
@retval true: ok
@retval false: something bad happened (error message has been displayed to the user)

◆ file2base()

int file2base ( 'linput_t *' li,
'qoff64_t' pos,
ida_idaapi.ea_t ea1,
ida_idaapi.ea_t ea2,
int patchable )
Load portion of file into the database. This function will include (ea1..ea2) into the addressing space of the program (make it enabled). 
    
@param li: pointer of input source
@param pos: position in the file
@param ea1: range of destination linear addresses
@param ea2: range of destination linear addresses
@param patchable: should the kernel remember correspondence of file offsets to linear addresses.
@retval 1: ok
@retval 0: read error, a warning is displayed

◆ find_plugin()

'plugin_t *' find_plugin ( str name,
bool load_if_needed = False )
Find a user-defined plugin and optionally load it. 
    
@param name: short plugin name without path and extension, or absolute path to the file name
@param load_if_needed: if the plugin is not present in the memory, try to load it
@returns pointer to plugin description block

◆ flush_buffers()

int flush_buffers ( )
Flush buffers to the disk.

◆ gen_exe_file()

int gen_exe_file ( 'FILE *' fp)
Generate an exe file (unload the database in binary form). 
    
@returns fp the output file handle. if fp == nullptr then return:
* 1: can generate an executable file
* 0: can't generate an executable file
@retval 1: ok
@retval 0: failed

◆ gen_file()

int gen_file ( 'ofile_type_t' otype,
'FILE *' fp,
ida_idaapi.ea_t ea1,
ida_idaapi.ea_t ea2,
int flags )
Generate an output file. OFILE_EXE: 
    
@param otype: type of output file.
@param fp: the output file handle
@param ea1: start address. For some file types this argument is ignored
@param ea2: end address. For some file types this argument is ignored as usual in ida, the end address of the range is not included
@param flags: Generate file flags
@returns number of the generated lines. -1 if an error occurred
@retval 0: can't generate exe file
@retval 1: ok

◆ get_basic_file_type()

'filetype_t' get_basic_file_type ( 'linput_t *' li)
Get the input file type. This function can recognize libraries and zip files. 

◆ get_elf_debug_file_directory()

str get_elf_debug_file_directory ( )
Get the value of the ELF_DEBUG_FILE_DIRECTORY configuration directive. 

◆ get_file_type_name()

str get_file_type_name ( )
Get name of the current file type. The current file type is kept in idainfo::filetype. 
    
@returns size of answer, this function always succeeds

◆ get_fileregion_ea()

ida_idaapi.ea_t get_fileregion_ea ( 'qoff64_t' offset)
Get linear address which corresponds to the specified input file offset. If can't be found, return BADADDR 

◆ get_fileregion_offset()

'qoff64_t' get_fileregion_offset ( ida_idaapi.ea_t ea)
Get offset in the input file which corresponds to the given ea. If the specified ea can't be mapped into the input file offset, return -1. 

◆ get_path()

str get_path ( 'path_type_t' pt)
Get the file path 
    
@param pt: file path type Types of the file pathes
@returns file path, never returns nullptr

◆ get_plugin_options()

str get_plugin_options ( str plugin)
Get plugin options from the command line. If the user has specified the options in the -Oplugin_name:options format, them this function will return the 'options' part of it The 'plugin' parameter should denote the plugin name Returns nullptr if there we no options specified 

◆ is_database_flag()

bool is_database_flag ( int dbfl)
Get the current database flag 
    
@param dbfl: flag Database flags
@returns the state of the flag (set or cleared)

◆ is_trusted_idb()

bool is_trusted_idb ( )
Is the database considered as trusted?

◆ load_and_run_plugin()

bool load_and_run_plugin ( str name,
'size_t' arg )
Load & run a plugin.

◆ load_binary_file()

bool load_binary_file ( str filename,
'linput_t *' li,
'ushort' _neflags,
'qoff64_t' fileoff,
ida_idaapi.ea_t basepara,
ida_idaapi.ea_t binoff,
'uint64' nbytes )
Load a binary file into the database. This function usually is called from ui. 
    
@param filename: the name of input file as is (if the input file is from library, then this is the name from the library)
@param li: loader input source
@param _neflags: Load file flags. For the first file, the flag NEF_FIRST must be set.
@param fileoff: Offset in the input file
@param basepara: Load address in paragraphs
@param binoff: Load offset (load_address=(basepara<<4)+binoff)
@param nbytes: Number of bytes to load from the file.
* 0: up to the end of the file
@retval true: ok
@retval false: failed (couldn't open the file)

◆ load_ids_module()

int load_ids_module ( 'char *' fname)
Load and apply IDS file. This function loads the specified IDS file and applies it to the database. If the program imports functions from a module with the same name as the name of the ids file being loaded, then only functions from this module will be affected. Otherwise (i.e. when the program does not import a module with this name) any function in the program may be affected. 
    
@param fname: name of file to apply
@retval 1: ok
@retval 0: some error (a message is displayed). if the ids file does not exist, no message is displayed

◆ load_plugin()

load_plugin ( name)
Loads a plugin

@param name: short plugin name without path and extension,
         or absolute path to the file name
@return:
- None if plugin could not be loaded
- An opaque object representing the loaded plugin

◆ mem2base()

mem2base ( mem,
ea,
fpos )
Load database from the memory.

@param mem: the buffer
@param ea: start linear addresses
@param fpos: position in the input file the data is taken from.
         if == -1, then no file position correspond to the data.
@return:
- Returns zero if the passed buffer was not a string
- Otherwise 1 is returned

◆ process_archive()

str process_archive ( str temp_file,
'linput_t *' li,
str module_name,
'ushort *' neflags,
str defmember,
'load_info_t const *' loader )
Calls loader_t::process_archive() For parameters and return value description look at loader_t::process_archive(). Additional parameter 'loader' is a pointer to load_info_t structure. 

◆ reload_file()

bool reload_file ( str file,
bool is_remote )
Reload the input file. This function reloads the byte values from the input file. It doesn't modify the segmentation, names, comments, etc. 
    
@param file: name of the input file. if file == nullptr then returns:
* 1: can reload the input file
* 0: can't reload the input file
@param is_remote: is the file located on a remote computer with the debugger server?
@returns success

◆ run_plugin()

run_plugin ( plg,
arg )
Runs a plugin

@param plg: A plugin object (returned by load_plugin())
@param arg: the code to pass to the plugin's "run()" function
@return: Boolean

◆ save_database()

bool save_database ( str outfile = None,
int flags = -1,
'snapshot_t' root = None,
'snapshot_t' attr = None )
Save current database using a new file name. 
    
@param outfile: output database file name; nullptr means the current path
@param flags: Database flags; -1 means the current flags
@param root: optional: snapshot tree root.
@param attr: optional: snapshot attributes
@returns success

◆ set_database_flag()

None set_database_flag ( int dbfl,
bool cnd = True )
Set or clear database flag 
    
@param dbfl: flag Database flags
@param cnd: set if true or clear flag otherwise

◆ set_import_name()

None set_import_name ( int modnode,
ida_idaapi.ea_t ea,
str name )
Set information about the named import entry. This function performs 'modnode.supset_ea(ea, name);' 
    
@param modnode: node with information about imported entries
@param ea: linear address of the entry
@param name: name of the entry

◆ set_import_ordinal()

None set_import_ordinal ( int modnode,
ida_idaapi.ea_t ea,
int ord )
Set information about the ordinal import entry. This function performs 'modnode.altset(ord, ea2node(ea));' 
    
@param modnode: node with information about imported entries
@param ea: linear address of the entry
@param ord: ordinal number of the entry

◆ set_path()

None set_path ( 'path_type_t' pt,
str path )
Set the file path 
    
@param pt: file path type Types of the file pathes
@param path: new file path, use nullptr or empty string to clear the file path

Variable Documentation

◆ ACCEPT_ARCHIVE

ACCEPT_ARCHIVE = _ida_loader.ACCEPT_ARCHIVE

◆ ACCEPT_CONTINUE

ACCEPT_CONTINUE = _ida_loader.ACCEPT_CONTINUE

◆ ACCEPT_FIRST

ACCEPT_FIRST = _ida_loader.ACCEPT_FIRST

◆ DBFL_BAK

DBFL_BAK = _ida_loader.DBFL_BAK

◆ DBFL_COMP

DBFL_COMP = _ida_loader.DBFL_COMP

◆ DBFL_KILL

DBFL_KILL = _ida_loader.DBFL_KILL

◆ DBFL_TEMP

DBFL_TEMP = _ida_loader.DBFL_TEMP

◆ DLLEXT

DLLEXT = _ida_loader.DLLEXT

◆ FILEREG_NOTPATCHABLE

FILEREG_NOTPATCHABLE = _ida_loader.FILEREG_NOTPATCHABLE

◆ FILEREG_PATCHABLE

FILEREG_PATCHABLE = _ida_loader.FILEREG_PATCHABLE

◆ GENFLG_ASMINC

GENFLG_ASMINC = _ida_loader.GENFLG_ASMINC

◆ GENFLG_ASMTYPE

GENFLG_ASMTYPE = _ida_loader.GENFLG_ASMTYPE

◆ GENFLG_GENHTML

GENFLG_GENHTML = _ida_loader.GENFLG_GENHTML

◆ GENFLG_IDCTYPE

GENFLG_IDCTYPE = _ida_loader.GENFLG_IDCTYPE

◆ GENFLG_MAPDMNG

GENFLG_MAPDMNG = _ida_loader.GENFLG_MAPDMNG

◆ GENFLG_MAPLOC

GENFLG_MAPLOC = _ida_loader.GENFLG_MAPLOC

◆ GENFLG_MAPNAME

GENFLG_MAPNAME = _ida_loader.GENFLG_MAPNAME

◆ GENFLG_MAPSEG

GENFLG_MAPSEG = _ida_loader.GENFLG_MAPSEG

◆ IDP_DLL

IDP_DLL = _ida_loader.IDP_DLL

◆ LDRF_RELOAD

LDRF_RELOAD = _ida_loader.LDRF_RELOAD

◆ LDRF_REQ_PROC

LDRF_REQ_PROC = _ida_loader.LDRF_REQ_PROC

◆ LOADER_DLL

LOADER_DLL = _ida_loader.LOADER_DLL

◆ MAX_DATABASE_DESCRIPTION

MAX_DATABASE_DESCRIPTION = _ida_loader.MAX_DATABASE_DESCRIPTION

◆ MODULE_ENTRY_IDP

MODULE_ENTRY_IDP = _ida_loader.MODULE_ENTRY_IDP

◆ MODULE_ENTRY_LOADER

MODULE_ENTRY_LOADER = _ida_loader.MODULE_ENTRY_LOADER

◆ MODULE_ENTRY_PLUGIN

MODULE_ENTRY_PLUGIN = _ida_loader.MODULE_ENTRY_PLUGIN

◆ NEF_CODE

NEF_CODE = _ida_loader.NEF_CODE

◆ NEF_FILL

NEF_FILL = _ida_loader.NEF_FILL

◆ NEF_FIRST

NEF_FIRST = _ida_loader.NEF_FIRST

◆ NEF_FLAT

NEF_FLAT = _ida_loader.NEF_FLAT

◆ NEF_IMPS

NEF_IMPS = _ida_loader.NEF_IMPS

◆ NEF_LALL

NEF_LALL = _ida_loader.NEF_LALL

◆ NEF_LOPT

NEF_LOPT = _ida_loader.NEF_LOPT

◆ NEF_MAN

NEF_MAN = _ida_loader.NEF_MAN

◆ NEF_MINI

NEF_MINI = _ida_loader.NEF_MINI

◆ NEF_NAME

NEF_NAME = _ida_loader.NEF_NAME

◆ NEF_RELOAD

NEF_RELOAD = _ida_loader.NEF_RELOAD

◆ NEF_RSCS

NEF_RSCS = _ida_loader.NEF_RSCS

◆ NEF_SEGS

NEF_SEGS = _ida_loader.NEF_SEGS

◆ OFILE_ASM

OFILE_ASM = _ida_loader.OFILE_ASM

◆ OFILE_DIF

OFILE_DIF = _ida_loader.OFILE_DIF

◆ OFILE_EXE

OFILE_EXE = _ida_loader.OFILE_EXE

◆ OFILE_IDC

OFILE_IDC = _ida_loader.OFILE_IDC

◆ OFILE_LST

OFILE_LST = _ida_loader.OFILE_LST

◆ OFILE_MAP

OFILE_MAP = _ida_loader.OFILE_MAP

◆ PATH_TYPE_CMD

PATH_TYPE_CMD = _ida_loader.PATH_TYPE_CMD

◆ PATH_TYPE_ID0

PATH_TYPE_ID0 = _ida_loader.PATH_TYPE_ID0

◆ PATH_TYPE_IDB

PATH_TYPE_IDB = _ida_loader.PATH_TYPE_IDB

◆ PLUGIN_DLL

PLUGIN_DLL = _ida_loader.PLUGIN_DLL

◆ SSF_AUTOMATIC

SSF_AUTOMATIC = _ida_loader.SSF_AUTOMATIC

◆ SSUF_DESC

SSUF_DESC = _ida_loader.SSUF_DESC

◆ SSUF_FLAGS

SSUF_FLAGS = _ida_loader.SSUF_FLAGS

◆ SSUF_PATH

SSUF_PATH = _ida_loader.SSUF_PATH