IDA C++ SDK 9.2
Loading...
Searching...
No Matches
offset.hpp
Go to the documentation of this file.
1/*
2 * Interactive disassembler (IDA).
3 * Copyright (c) 1990-2025 Hex-Rays
4 * ALL RIGHTS RESERVED.
5 *
6 */
7
8#ifndef _OFFSET_HPP
9#define _OFFSET_HPP
10
11#include <nalt.hpp>
12#include <segment.hpp>
13
31
32
35
36idaman reftype_t ida_export get_default_reftype(ea_t ea);
37
38
54
55idaman bool ida_export op_offset_ex(ea_t ea, int n, const refinfo_t *ri);
56
57
59
60idaman bool ida_export op_offset(
61 ea_t ea,
62 int n,
63 uint32 type_and_flags,
64 ea_t target=BADADDR,
65 ea_t base=0,
66 adiff_t tdelta=0);
67
68
70
71inline bool op_plain_offset(ea_t ea, int n, ea_t base)
72{
73 reftype_t reftype = get_default_reftype(ea);
74 return op_offset(ea, n, reftype, BADADDR, base) != 0;
75}
76
77
82
83inline ea_t get_offbase(ea_t ea, int n)
84{
85 refinfo_t ri;
86 if ( !get_refinfo(&ri, ea, n) )
87 return BADADDR;
88 return ri.base;
89}
90
91
138
139
140idaman int ida_export get_offset_expression(
141 qstring *buf,
142 ea_t ea,
143 int n,
144 ea_t from,
145 adiff_t offset,
146 int getn_flags=0);
147
148
150
151idaman int ida_export get_offset_expr(
152 qstring *buf,
153 ea_t ea,
154 int n,
155 const refinfo_t &ri,
156 ea_t from,
157 adiff_t offset,
158 int getn_flags=0);
159
160
165
166idaman ea_t ida_export can_be_off32(ea_t ea);
167
168
179
180idaman ea_t ida_export calc_offset_base(ea_t ea, int n);
181
182
186
187idaman ea_t ida_export calc_probable_base_by_value(ea_t ea, uval_t off);
188
189
205idaman bool ida_export calc_reference_data(
206 ea_t *target,
207 ea_t *base,
208 ea_t from,
209 const refinfo_t &ri,
210 adiff_t opval);
211
212
224idaman ea_t ida_export add_refinfo_dref(
225 const insn_t &insn,
226 ea_t from,
227 const refinfo_t &ri,
228 adiff_t opval,
229 dref_t type,
230 int opoff);
231
232
234inline ea_t calc_target(ea_t from, adiff_t opval, const refinfo_t &ri)
235{
236 ea_t target;
237 if ( !calc_reference_data(&target, nullptr, from, ri, opval) )
238 return BADADDR;
239 return target;
240}
241
243inline ea_t calc_target(ea_t from, ea_t ea, int n, adiff_t opval)
244{
245 refinfo_t ri;
246 return get_refinfo(&ri, ea, n) ? calc_target(from, opval, ri) : BADADDR;
247}
248
250inline ea_t calc_basevalue(ea_t target, ea_t base)
251{
252 return base - get_segm_base(getseg(target));
253}
254
255
256#endif // _OFFSET_HPP
idaman size_t n
Definition pro.h:997
idaman ea_t ida_export get_segm_base(const segment_t *s)
Get segment base linear address.
idaman segment_t *ida_export getseg(ea_t ea)
Get pointer to segment by linear address.
dref_t
DATA xref types.
Definition xref.hpp:67
const tinfo_t & type
Definition hexrays.hpp:7301
uval_t uval_t
Definition kernwin.hpp:1878
Definitions of various information kept in netnodes.
uchar reftype_t
see Types of references
Definition nalt.hpp:971
idaman bool ida_export get_refinfo(refinfo_t *ri, ea_t ea, int n)
idaman bool ida_export op_offset(ea_t ea, int n, uint32 type_and_flags, ea_t target=BADADDR, ea_t base=0, adiff_t tdelta=0)
See op_offset_ex()
idaman ea_t ida_export calc_probable_base_by_value(ea_t ea, uval_t off)
Try to calculate the offset base.
idaman ea_t ida_export can_be_off32(ea_t ea)
Does the specified address contain a valid OFF32 value?
ea_t calc_basevalue(ea_t target, ea_t base)
Calculate the value of the reference base.
Definition offset.hpp:250
bool op_plain_offset(ea_t ea, int n, ea_t base)
Convert operand to a reference with the default reference type.
Definition offset.hpp:71
ea_t get_offbase(ea_t ea, int n)
Get offset base value.
Definition offset.hpp:83
idaman ea_t ida_export calc_offset_base(ea_t ea, int n)
Try to calculate the offset base This function takes into account the fixup information,...
idaman bool ida_export calc_reference_data(ea_t *target, ea_t *base, ea_t from, const refinfo_t &ri, adiff_t opval)
Calculate the target and base addresses of an offset expression.
idaman ea_t ida_export add_refinfo_dref(const insn_t &insn, ea_t from, const refinfo_t &ri, adiff_t opval, dref_t type, int opoff)
Add xrefs for a reference from the given instruction (\insn_t{ea}).
idaman int ida_export get_offset_expression(qstring *buf, ea_t ea, int n, ea_t from, adiff_t offset, int getn_flags=0)
Get offset expression (in the form "offset name+displ").
idaman int ida_export get_offset_expr(qstring *buf, ea_t ea, int n, const refinfo_t &ri, ea_t from, adiff_t offset, int getn_flags=0)
See get_offset_expression()
idaman reftype_t ida_export get_default_reftype(ea_t ea)
Get default reference type depending on the segment.
ea_t calc_target(ea_t from, adiff_t opval, const refinfo_t &ri)
Calculate the target using the provided refinfo_t.
Definition offset.hpp:234
idaman bool ida_export op_offset_ex(ea_t ea, int n, const refinfo_t *ri)
Convert operand to a reference.
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
int64 adiff_t
Definition pro.h:424
uint64 ea_t
Definition pro.h:421
_qstring< char > qstring
regular string
Definition pro.h:3694
Functions that deal with segments.
Information about a reference.
Definition nalt.hpp:1010
ea_t base
base of reference (may be BADADDR)
Definition nalt.hpp:1012