IDA C++ SDK 9.2
|
Functions that deal with fixup information. More...
Go to the source code of this file.
Classes | |
struct | fixup_data_t |
struct | fixup_handler_t |
Implements the core behavior of a custom fixup. More... | |
struct | fixup_info_t |
Collect fixup records for the specified range. More... |
Typedefs | |
typedef uint16 | fixup_type_t |
Fixup information structure. | |
typedef qvector< fixup_info_t > | fixups_t |
Functions | |
THREAD_SAFE bool | is_fixup_custom (fixup_type_t type) |
Is fixup processed by processor module? | |
idaman bool ida_export | get_fixup (fixup_data_t *fd, ea_t source) |
Get fixup information. | |
bool | exists_fixup (ea_t source) |
Check that a fixup exists at the given address. | |
idaman void ida_export | set_fixup (ea_t source, const fixup_data_t &fd) |
Set fixup information. | |
idaman void ida_export | del_fixup (ea_t source) |
Delete fixup information. | |
idaman const fixup_handler_t *ida_export | get_fixup_handler (fixup_type_t type) |
Get handler of standard or custom fixup. | |
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. | |
idaman uval_t ida_export | get_fixup_value (ea_t ea, fixup_type_t type) |
Get the operand value. | |
idaman bool ida_export | patch_fixup_value (ea_t ea, const fixup_data_t &fd) |
Patch the fixup bytes. | |
idaman const char *ida_export | get_fixup_desc (qstring *buf, ea_t source, const fixup_data_t &fd) |
Get FIXUP description comment. | |
idaman int ida_export | calc_fixup_size (fixup_type_t type) |
Calculate size of fixup in bytes (the number of bytes the fixup patches) | |
DECLARE_TYPE_AS_MOVABLE (fixup_info_t) | |
idaman bool ida_export | get_fixups (fixups_t *out, ea_t ea, asize_t size) |
bool | 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). | |
idaman bool ida_export | handle_fixups_in_macro (refinfo_t *ri, ea_t ea, fixup_type_t other, uint32 macro_reft_and_flags) |
Handle two fixups in a macro. | |
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) |
Find next address with fixup information. | |
idaman ea_t ida_export | get_prev_fixup_ea (ea_t ea) |
Find previous address with fixup information. | |
std_get_value() | |
This internal function takes Tuning options to determine how to get the operand value. It is opposite in meaning to the std_patch_value(). 1) it gets the fixup_handler_t::size bytes at the given address, 2) it shifts the result left by fixup_handler_t::shift bits, 3) it returns the rightmost fixup_handler_t::width bits as a signed value. In details: b) size = 4, width = 28, shift = 2
| |
idaman fixup_type_t ida_export | register_custom_fixup (const fixup_handler_t *cfh) |
Register a new custom fixup. | |
idaman bool ida_export | unregister_custom_fixup (fixup_type_t type) |
Unregister a new custom fixup format. | |
idaman fixup_type_t ida_export | find_custom_fixup (const char *name) |
Get id of a custom fixup handler. |
Functions that deal with fixup information.
A loader should setup fixup information using set_fixup().
typedef uint16 fixup_type_t |
Fixup information structure.
see Types of fixups
typedef qvector<fixup_info_t> fixups_t |
|
inline |
Is fixup processed by processor module?
idaman bool ida_export get_fixup | ( | fixup_data_t * | fd, |
ea_t | source ) |
Get fixup information.
idaman void ida_export set_fixup | ( | ea_t | source, |
const fixup_data_t & | fd ) |
Set fixup information.
You should fill fixup_data_t and call this function and the kernel will remember information in the database.
source | the fixup source address, i.e. the address modified by the fixup |
fd | fixup data |
Get the first address with fixup information
Find next address with fixup information.
ea | current address |
Find previous address with fixup information.
ea | current address |
idaman const fixup_handler_t *ida_export get_fixup_handler | ( | fixup_type_t | type | ) |
Get handler of standard or custom fixup.
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.
item_ea | start address of item to modify |
fixup_ea | address of fixup record |
n | 0..#UA_MAXOP-1 operand number, OPND_ALL one of the operands |
is_macro | is the instruction at 'item_ea' a macro? if yes, then partial fixups (HIGH, LOW) won't be applied |
false | no fixup at fixup_ea or it has #FIXUPF_UNUSED flag |
true | ok, the fixup information was applied |
idaman uval_t ida_export get_fixup_value | ( | ea_t | ea, |
fixup_type_t | type ) |
Get the operand value.
This function get fixup bytes from data or an instruction at ea and convert them to the operand value (maybe partially). It is opposite in meaning to the patch_fixup_value(). For example, FIXUP_HI8 read a byte at ea and shifts it left by 8 bits, or AArch64's custom fixup BRANCH26 get low 26 bits of the insn at ea and shifts it left by 2 bits. This function is mainly used to get a relocation addend.
ea | address to get fixup bytes from, the size of the fixup bytes depends on the fixup type. |
type | fixup type |
operand | value |
idaman bool ida_export patch_fixup_value | ( | ea_t | ea, |
const fixup_data_t & | fd ) |
Patch the fixup bytes.
This function updates data or an instruction at ea to the fixup bytes. For example, FIXUP_HI8 updates a byte at ea to the high byte of fd->off, or AArch64's custom fixup BRANCH26 updates low 26 bits of the insn at ea to the value of fd->off shifted right by 2.
ea | address where data are changed, the size of the changed data depends on the fixup type. |
fd | fixup data |
false | the fixup bytes do not fit (e.g. fd->off is greater than 0xFFFFFFC for BRANCH26). The database is changed even in this case. |
idaman const char *ida_export get_fixup_desc | ( | qstring * | buf, |
ea_t | source, | ||
const fixup_data_t & | fd ) |
Get FIXUP description comment.
idaman int ida_export calc_fixup_size | ( | fixup_type_t | type | ) |
Calculate size of fixup in bytes (the number of bytes the fixup patches)
-1 | means error |
idaman fixup_type_t ida_export register_custom_fixup | ( | const 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 find_custom_fixup() function to find the handler created by the processor module.
idaman bool ida_export unregister_custom_fixup | ( | fixup_type_t | type | ) |
Unregister a new custom fixup format.
Should be called by the processor module before the database gets closed.
idaman fixup_type_t ida_export find_custom_fixup | ( | const char * | name | ) |
Get id of a custom fixup handler.
name | name of the custom fixup handler |
DECLARE_TYPE_AS_MOVABLE | ( | fixup_info_t | ) |
Does the specified address range contain any fixup information?
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. If loader_t::move_segm is not defined then this function will be called automatically when moving segments or rebasing the entire program. Special parameter values (from = BADADDR, size = 0, to = delta) are used when the function is called from rebase_program(delta).
idaman bool ida_export handle_fixups_in_macro | ( | refinfo_t * | ri, |
ea_t | ea, | ||
fixup_type_t | other, | ||
uint32 | macro_reft_and_flags ) |
Handle two fixups in a macro.
We often combine two instruction that load parts of a value into one macro instruction. For example:
When applying the fixups that fall inside such a macro, we should convert them to one refinfo. This function does exactly that. It should be called from the apply() callback of a custom fixup.