| IDA SDK

Public Attributes | List of all members
loader_t Struct Reference

## Detailed Description

Loader description block - must be exported from the loader module.

## Public Attributes
uint32 | version
| api version, should be IDP_INTERFACE_VERSION
uint32 | flags
| Loader flags
int(idaapi * | accept_file )(qstring *fileformatname, qstring *processor, linput_t *li, const char *filename)
| Check input file format. More...
void(idaapi * | load_file )(linput_t *li, ushort neflags, const char *fileformatname)
| Load file into the database. More...
int(idaapi * | save_file )(FILE *fp, const char *fileformatname)
| Create output file from the database. More...
int(idaapi * | move_segm )(ea_t from, ea_t to, asize_t size, const char *fileformatname)
| Take care of a moved segment (fix up relocations, for example). More...
int(idaapi * | process_archive )(qstring *temp_file, linput_t *li, qstring *module_name, ushort *neflags, const char *fileformatname, const char *defmember, qstring *errbuf)
| Display list of archive members and let the user select one. More...

## Member Data Documentation

## ◆ accept_file

int(idaapi * loader_t::accept_file) (qstring *fileformatname, qstring *processor, linput_t *li, const char *filename)

Check input file format.

This function will be called one or more times depending on the result value.

Parameters

  [out] | fileformat | name of file format
  [out] | processor | desired processor (optional)
  | li | input file
  | filename | name of the input file, if it is an archive member name then the actual file doesn't exist

Returns
  1 if file format is recognized, and fills 'fileformatname', otherwise returns 0. This function may return a unique file format number instead of 1. To get this unique number, please contact the author. If the return value is ORed with ACCEPT_ARCHIVE, then it is an archive loader. Its process_archive() will be called instead of load_file(). If the return value is ORed with ACCEPT_CONTINUE, then this function will be called another time. If the return value is ORed with ACCEPT_FIRST, then this format should be placed first in the "load file" dialog box. In the sorting order of file formats the archive formats have priority.

## ◆ load_file

void(idaapi * loader_t::load_file) (linput_t *li, ushort neflags, const char *fileformatname)

Load file into the database.

Parameters

  li | input file
  neflags | Load file flags
  fileformatname | name of type of the file (it was returned by accept_file)

If this function fails, loader_failure() should be called

## ◆ save_file

int(idaapi * loader_t::save_file) (FILE *fp, const char *fileformatname)

Create output file from the database.

This function may be absent. If fp == nullptr, then this function returns:

- 0: can't create file of this type
- 1: ok, can create file of this type

If fp != nullptr, then this function should create the output file

## ◆ move_segm

int(idaapi * loader_t::move_segm) (ea_t from, ea_t to, asize_t size, const char *fileformatname)

Take care of a moved segment (fix up relocations, for example).

This function may be absent. A special calling method

move_segm(BADADDR, delta, 0, formatname);
BADADDR
#define BADADDR
this value is used for 'bad address'
Definition: pro.h:489
loader_t::move_segm
int(idaapi * move_segm)(ea_t from, ea_t to, asize_t size, const char *fileformatname)
Take care of a moved segment (fix up relocations, for example).
Definition: loader.hpp:152

means that the whole program has been moved in the memory (rebased) by delta bytes

Parameters

  from | previous linear address of the segment
  to | current linear address of the segment
  size | size of the moved segment
  fileformatname | the file format

Return values

  1 | ok
  0 | failure

## ◆ process_archive

int(idaapi * loader_t::process_archive) (qstring *temp_file, linput_t *li, qstring *module_name, ushort *neflags, const char *fileformatname, const char *defmember, qstring *errbuf)

Display list of archive members and let the user select one.

Extract the selected archive member into a temporary file.

Parameters

  [out] | temp_file | name of the file with the extracted archive member.
  | li | input file
  [in,out] | module_name | in: name of archive out: name of the extracted archive member
  [in,out] | neflags | Load file flags
  | fileformatname | name of type of the file (it was returned by accept_file)
  | defmember | extract the specified member, for example "subdir/member.exe", may be nullptr
  | errbuf | error message if 0 is returned, may be nullptr

Returns
  -1-cancelled by the user, 1-ok, 0-error, see errbuf for details

The documentation for this struct was generated from the following file:

- loader.hpp