IDA SDK

- Main Page
- Header Files
- Classes
- Modules

- File List
- File Members

Classes | Functions | Macros | Variables
fixup.hpp File Reference

## Detailed Description

Functions that deal with fixup information.

A loader should setup fixup information using set_fixup().

## Classes
struct | fixup_data_t
| Fixup information structure. More...
struct | custom_fixup_handler_t
| Implements the core behavior of a custom fixup. More...

## Functions
idaman void ida_export | set_fixup (ea_t source, const fixup_data_t *fp)
| Set fixup information. More...
idaman void ida_export | set_fixup_ex (ea_t source, const fixup_data_t *fd, ea_t offset_base)
| Set fixup information. More...
idaman void ida_export | del_fixup (ea_t source)
| Delete fixup information.
idaman bool ida_export | get_fixup (ea_t source, fixup_data_t *fd)
| Get fixup information.
idaman bool ida_export | apply_fixup (ea_t item_ea, ea_t fixup_ea, int n, bool is_macro)
| Use fixup information for an address. More...
idaman ea_t ida_export | get_fixup_base (ea_t source, const fixup_data_t *fd)
| Get base of fixup for set_offset() function.
ea_t | get_fixup_extdef_ea (ea_t source, const fixup_data_t *fd)
| See get_fixup_extdef_ea(ea_t ea)
sel_t | get_fixup_segdef_sel (const fixup_data_t *fd)
| See get_fixup_segdef_sel(ea_t ea)
ea_t | get_fixup_extdef_ea (ea_t ea)
| Get fixup target location. More...
sel_t | get_fixup_segdef_sel (ea_t ea)
| Get fixup target selector. More...
idaman char *ida_export | get_fixup_desc (ea_t source, const fixup_data_t *fdp, char *buf, size_t bufsize)
| Get FIXUP description comment. More...
idaman bool ida_export | contains_fixups (ea_t ea, asize_t size)
| Does the specified address range contain any fixup information?
idaman void ida_export | gen_fix_fixups (ea_t from, ea_t to, asize_t size)
| Relocate the bytes with fixup information once more (generic function). More...
Enumerate addresses with fixup information:
idaman ea_t ida_export | get_first_fixup_ea (void)
idaman ea_t ida_export | get_next_fixup_ea (ea_t ea)
idaman ea_t ida_export | get_prev_fixup_ea (ea_t ea)

## Custom fixups
File loaders should ask the processor module to register a custom fixup handler. After registering a handler file loaders may call set_custom_fixup() to create custom fixups. The loaders can not register a custom fixup handler themselves because they will eventually be unloaded but the handler must stay in the memory until the database is closed. The processor module should unregister the custom fixup handler before the database gets closed.
typedef qvector< const custom_fixup_handler_t * > | custom_fixup_handlers_t
| Vector of custom fixup handlers.
idaman int ida_export | register_custom_fixup (const custom_fixup_handler_t *cfh)
| Register a new custom fixup. More...
idaman bool ida_export | unregister_custom_fixup (int cfid)
| Unregister a new custom fixup format. More...
idaman void ida_export | set_custom_fixup (ea_t ea, int cfid, const fixup_data_t *fd)
| Setup custom fixup information. More...
idaman void ida_export | set_custom_fixup_ex (ea_t ea, int cfid, const fixup_data_t *fd, ea_t offbase)
| Setup custom fixup information. More...

## Macros
#define | FIXUP_MASK 0xF
| type mask
#define | FIXUP_OFF8 0
| 8-bit offset
#define | FIXUP_OFF16 1
| 16-bit offset
#define | FIXUP_SEG16 2
| 16-bit base–logical segment base (selector)
#define | FIXUP_PTR16 3
| 32-bit long pointer (16-bit base:16-bit More...
#define | FIXUP_OFF32 4
| 32-bit offset
#define | FIXUP_PTR32 5
| 48-bit pointer (16-bit base:32-bit offset)
#define | FIXUP_HI8 6
| high 8 bits of 16bit offset
#define | FIXUP_HI16 7
| high 16 bits of 32bit offset
#define | FIXUP_LOW8 8
| low 8 bits of 16bit offset
#define | FIXUP_LOW16 9
| low 16 bits of 32bit offset
#define | FIXUP_VHIGH 0xA
| high processor_t::high_fixup_bits of 32bit offset
#define | FIXUP_VLOW 0xB
| low processor_t::high_fixup_bits of 32bit offset
#define | FIXUP_OFF64 0xC
| 64-bit offset
#define | FIXUP_CUSTOM 0xF
| fixup is processed by processor module
#define | FIXUP_REL 0x10
| fixup is relative to the linear address specified in the 3d parameter to set_fixup()
#define | FIXUP_SELFREL 0x0
| self-relative? More...
#define | FIXUP_EXTDEF 0x20
| target is a location (otherwise - segment). More...
#define | FIXUP_UNUSED 0x40
| fixup is ignored by IDA More...
#define | FIXUP_CREATED 0x80
| fixup was not present in the input file

## Variables
idaman netnode ida_export_data | fixup_node
| Main netnode to access fixup info.

## Function Documentation

idaman void ida_export set_fixup | ( | ea_t | source,
|  | const fixup_data_t * | fp
| ) |  |

Set fixup information.

You should fill fixup_data_t and call this function and the kernel will remember information in the database. Use this function if FIXUP_REL bit is clear. For custom fixups use set_custom_fixup().

Parameters

  source | the fixup source address, i.e. the address modified by the fixup

idaman void ida_export set_fixup_ex | ( | ea_t | source,
|  | const fixup_data_t * | fd,
|  | ea_t | offset_base
| ) |  |

Set fixup information.

You should fill fixup_data_t and call this function and the kernel will remember information in the database. Use this function if FIXUP_REL bit is set. For custom fixups use set_custom_fixup_ex().

idaman bool ida_export apply_fixup | ( | ea_t | item_ea,
|  | ea_t | fixup_ea,
|  | int | n,
|  | bool | is_macro
| ) |  |

Use fixup information for an address.

This function converts item_ea flags to offsets/segments. For undefined bytes, you may set item_ea == fixup_ea. In this case this function will create an item (byte, word, dword) there.

Parameters

  item_ea | start address of item to modify
  fixup_ea | address of fixup record
  n | number of operand. may be 0, 1, 2
  is_macro | is the instruction at 'item_ea' a macro? if yes, then partial fixups (HIGH, LOW) won't be applied

Return values

  false | no fixup at fixup_ea or it has FIXUP_UNUSED flag
  true | ok, the fixup information was applied

idaman int ida_export register_custom_fixup | ( | const custom_fixup_handler_t * | cfh | ) |

Register a new custom fixup.

This function must be called by a processor module or plugin, but not by a file loader. File loaders should use create_custom_fixup() convenience function to ask the processor module to create of a new handler.

idaman bool ida_export unregister_custom_fixup | ( | int | cfid | ) |

Unregister a new custom fixup format.

Should be called by the processor module before the database gets closed.

idaman void ida_export set_custom_fixup | ( | ea_t | ea,
|  | int | cfid,
|  | const fixup_data_t * | fd
| ) |  |

Setup custom fixup information.

This function is called by file loader. Use this function if FIXUP_REL bit is clear.

idaman void ida_export set_custom_fixup_ex | ( | ea_t | ea,
|  | int | cfid,
|  | const fixup_data_t * | fd,
|  | ea_t | offbase
| ) |  |

Setup custom fixup information.

This function is called by file loader. Use this function if FIXUP_REL bit is set.

ea_t get_fixup_extdef_ea | ( | ea_t | ea | ) |
| inline

Get fixup target location.

Returns
  BADADDR if target is a segment (FIXUP_EXTDEF), or if no fixup info available.

sel_t get_fixup_segdef_sel | ( | ea_t | ea | ) |
| inline

Get fixup target selector.

Returns
  BADSEL if target is a location (FIXUP_EXTDEF), or if no fixup info available.

idaman char* ida_export get_fixup_desc | ( | ea_t | source,
|  | const fixup_data_t * | fdp,
|  | char * | buf,
|  | size_t | bufsize
| ) |  |

Get FIXUP description comment.

fdp can't be NULL.

idaman void ida_export gen_fix_fixups | ( | ea_t | from,
|  | ea_t | to,
|  | asize_t | size
| ) |  |

Relocate the bytes with fixup information once more (generic function).

This function may be called from loader_t::move_segm() if it suits the goal.