IDA C++ SDK 9.2
Loading...
Searching...
No Matches
xref.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 _XREF_HPP
9#define _XREF_HPP
10
34
35class func_t; // #include <funcs.hpp>
36
37//---------------------------------------------------------------------------
38// C R O S S - R E F E R E N C E T Y P E S
39//---------------------------------------------------------------------------
40
46
64
86
87
93#define XREF_USER 0x20
98#define XREF_TAIL 0x40
99#define XREF_BASE 0x80
100#define XREF_MASK 0x1F
101
102#define XREF_PASTEND 0x100
107
110idaman char ida_export xrefchar(char xrtype);
111
113
114//---------------------------------------------------------------------------
115// A D D / D E L E T E C R O S S - R E F E R E N C E S
116//---------------------------------------------------------------------------
117
123
124idaman bool ida_export add_cref(ea_t from, ea_t to, cref_t type);
125
126
136
137idaman bool ida_export del_cref(ea_t from, ea_t to, bool expand);
138
139
145
146idaman bool ida_export add_dref(ea_t from, ea_t to, dref_t type);
147
148
152
153idaman void ida_export del_dref(ea_t from, ea_t to);
154
155
156//-------------------------------------------------------------------------
157// E N U M E R A T E ( G E T ) C R O S S - R E F E R E N C E S
158//-------------------------------------------------------------------------
159
160struct xrefblk_t;
164idaman bool ida_export xrefblk_t_first_from(xrefblk_t *, ea_t from, int flags);
165idaman bool ida_export xrefblk_t_next_from(xrefblk_t *);
166idaman bool ida_export xrefblk_t_first_to(xrefblk_t *, ea_t to, int flags);
167idaman bool ida_export xrefblk_t_next_to(xrefblk_t *);
169
196{
199 bool iscode;
202 bool user;
204
208#define XREF_FLOW 0x00
209#define XREF_NOFLOW 0x01
211#define XREF_DATA 0x02
212#define XREF_CODE 0x04
213#define XREF_EA 0x08
214#define XREF_TID 0x10
218
227
229 bool first_from(ea_t _from, int flags=XREF_FLOW)
230 { return xrefblk_t_first_from(this, _from, flags); }
231
234 { return xrefblk_t_next_from(this); }
235
237 bool first_to(ea_t _to, int flags=XREF_FLOW)
238 { return xrefblk_t_first_to(this, _to, flags); }
239
241 bool next_to()
242 { return xrefblk_t_next_to(this); }
243
245 bool next_from(ea_t _from, ea_t _to, int flags)
246 {
247 if ( first_from(_from, flags) )
248 {
249 to = _to;
250 return next_from();
251 }
252 return false;
253 }
254
256 bool next_to(ea_t _from, ea_t _to, int flags)
257 {
258 if ( first_to(_to, flags) )
259 {
260 from = _from;
261 return next_to();
262 }
263 return false;
264 }
265
267};
268
269//-------------------------------------------------------------------------
275
276idaman ea_t ida_export get_first_dref_from(ea_t from);
277
278
285
286idaman ea_t ida_export get_next_dref_from(ea_t from, ea_t current);
287
288
292
293idaman ea_t ida_export get_first_dref_to(ea_t to);
294
295
302
303idaman ea_t ida_export get_next_dref_to(ea_t to, ea_t current);
304
305
314
315idaman ea_t ida_export get_first_cref_from(ea_t from);
316
317
324
325idaman ea_t ida_export get_next_cref_from(ea_t from, ea_t current);
326
327
335
336idaman ea_t ida_export get_first_cref_to(ea_t to);
337
338
345
346idaman ea_t ida_export get_next_cref_to(ea_t to, ea_t current);
347
348
355idaman ea_t ida_export get_first_fcref_from(ea_t from);
356idaman ea_t ida_export get_next_fcref_from(ea_t from, ea_t current);
357idaman ea_t ida_export get_first_fcref_to(ea_t to);
358idaman ea_t ida_export get_next_fcref_to(ea_t to, ea_t current);
360
361
363
364idaman bool ida_export has_external_refs(func_t *pfn, ea_t ea);
365
366
368
369idaman bool ida_export has_jump_or_flow_xref(ea_t ea);
370
371
372//-------------------------------------------------------------------------
373// S W I T C H T A B L E F U N C T I O N S
374//-------------------------------------------------------------------------
375#ifdef NALT_HPP
376
383
384idaman bool ida_export create_switch_table(
385 ea_t insn_ea,
386 const switch_info_t &si);
387
388
395
396idaman void ida_export create_switch_xrefs(
397 ea_t insn_ea,
398 const switch_info_t &si);
399
400
403
404
411
412idaman bool ida_export calc_switch_cases(
413 casevec_t *casevec,
414 eavec_t *targets,
415 ea_t insn_ea,
416 const switch_info_t &si);
417
422idaman void ida_export delete_switch_table(
423 ea_t jump_ea,
424 const switch_info_t &si);
425
426#endif
427
428//-------------------------------------------------------------------------
429// F U N C T I O N S F O R T H E K E R N E L
430//-------------------------------------------------------------------------
431
433idaman bool ida_export create_xrefs_from(ea_t ea); // returns false: no item at ea
434idaman void ida_export delete_all_xrefs_from(ea_t ea, bool expand);
436
437
438#if !defined(NO_OBSOLETE_FUNCS)
439#define XREF_ALL XREF_FLOW
440#define XREF_FAR XREF_NOFLOW
441#endif
442
443#endif // _XREF_HPP
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:85
Reimplementation of vector class from STL.
Definition pro.h:2250
idaman char ida_export xrefchar(char xrtype)
Get character describing the xref type.
cref_t
CODE xref types.
Definition xref.hpp:49
dref_t
DATA xref types.
Definition xref.hpp:67
@ fl_JN
Jump Near.
Definition xref.hpp:59
@ fl_U
unknown – for compatibility with old versions.
Definition xref.hpp:50
@ fl_F
Ordinary flow: used to specify execution flow to the next instruction.
Definition xref.hpp:61
@ fl_JF
Jump Far.
Definition xref.hpp:58
@ fl_CN
Call Near This xref creates a function at the referenced location.
Definition xref.hpp:55
@ fl_CF
Call Far This xref creates a function at the referenced location.
Definition xref.hpp:52
@ fl_USobsolete
User specified (obsolete)
Definition xref.hpp:60
@ dr_O
Offset The reference uses 'offset' of data rather than its value OR The reference appeared because th...
Definition xref.hpp:70
@ dr_W
Write access.
Definition xref.hpp:77
@ dr_I
Informational (a derived java class references its base class informationally)
Definition xref.hpp:81
@ dr_U
Unknown – for compatibility with old versions.
Definition xref.hpp:68
@ dr_R
Read access.
Definition xref.hpp:78
@ dr_S
Reference to enum member (symbolic constant)
Definition xref.hpp:84
@ dr_T
Text (for forced operands only) Name of data is used in manual operand.
Definition xref.hpp:79
const tinfo_t & type
Definition hexrays.hpp:7301
uint64 ea_t
Definition pro.h:421
unsigned char uchar
unsigned 8 bit value
Definition pro.h:337
qvector< ea_t > eavec_t
vector of addresses
Definition pro.h:2764
Information about a switch statement.
Definition nalt.hpp:710
Structure to enumerate all xrefs.
Definition xref.hpp:196
ea_t to
the referenced address - filled by first_from(), next_from()
Definition xref.hpp:198
bool first_to(ea_t _to, int flags=XREF_FLOW)
Get xref to given address (store in from)
Definition xref.hpp:237
bool next_to(ea_t _from, ea_t _to, int flags)
Get xref to '_to' that comes after '_from'.
Definition xref.hpp:256
ea_t from
the referencing address - filled by first_to(),next_to()
Definition xref.hpp:197
bool iscode
is code reference (cref_t)?
Definition xref.hpp:199
bool next_from()
Get next xref from address provided to first_from()
Definition xref.hpp:233
uchar type
type of the last returned reference (cref_t & dref_t)
Definition xref.hpp:201
bool first_from(ea_t _from, int flags=XREF_FLOW)
Get first xref from the given address (store in to)
Definition xref.hpp:229
uchar _flags
Definition xref.hpp:203
bool next_from(ea_t _from, ea_t _to, int flags)
Get xref from '_from' that comes after '_to'.
Definition xref.hpp:245
bool next_to()
Get next xref to address provided to first_to()
Definition xref.hpp:241
bool user
is user defined xref? otherwise defined by ida
Definition xref.hpp:202
idaman bool ida_export xrefblk_t_next_to(xrefblk_t *)
idaman bool ida_export add_dref(ea_t from, ea_t to, dref_t type)
Create a data cross-reference.
idaman bool ida_export has_external_refs(func_t *pfn, ea_t ea)
Does 'ea' have references from outside of 'pfn'?
idaman bool ida_export xrefblk_t_next_from(xrefblk_t *)
idaman ea_t ida_export get_next_cref_from(ea_t from, ea_t current)
Get next instruction referenced from the specified instruction.
idaman ea_t ida_export get_first_cref_from(ea_t from)
Get first instruction referenced from the specified instruction.
idaman ea_t ida_export get_first_cref_to(ea_t to)
Get first instruction referencing to the specified instruction.
idaman bool ida_export add_cref(ea_t from, ea_t to, cref_t type)
Create a code cross-reference.
idaman bool ida_export del_cref(ea_t from, ea_t to, bool expand)
Delete a code cross-reference.
idaman void ida_export delete_switch_table(ea_t jump_ea, const switch_info_t &si)
Delete information created by the call of create_switch_table().
idaman void ida_export create_switch_xrefs(ea_t insn_ea, const switch_info_t &si)
Create code xrefs for the switch table.
idaman ea_t ida_export get_next_dref_to(ea_t to, ea_t current)
Get address of instruction/data referencing to the specified data.
idaman ea_t ida_export get_first_fcref_to(ea_t to)
idaman ea_t ida_export get_first_dref_from(ea_t from)
Get first data referenced from the specified address.
idaman ea_t ida_export get_next_fcref_to(ea_t to, ea_t current)
idaman bool ida_export xrefblk_t_first_to(xrefblk_t *, ea_t to, int flags)
idaman ea_t ida_export get_first_dref_to(ea_t to)
Get address of instruction/data referencing to the specified data.
idaman bool ida_export calc_switch_cases(casevec_t *casevec, eavec_t *targets, ea_t insn_ea, const switch_info_t &si)
Get detailed information about the switch table cases.
idaman void ida_export del_dref(ea_t from, ea_t to)
Delete a data cross-reference.
idaman ea_t ida_export get_next_dref_from(ea_t from, ea_t current)
Get next data referenced from the specified address.
idaman ea_t ida_export get_first_fcref_from(ea_t from)
qvector< svalvec_t > casevec_t
Vector of case values - see calc_switch_cases()
Definition xref.hpp:402
idaman bool ida_export has_jump_or_flow_xref(ea_t ea)
Are there jump or flow references to EA?
idaman ea_t ida_export get_next_fcref_from(ea_t from, ea_t current)
idaman bool ida_export create_switch_table(ea_t insn_ea, const switch_info_t &si)
Create switch table from the switch information.
idaman bool ida_export xrefblk_t_first_from(xrefblk_t *, ea_t from, int flags)
idaman ea_t ida_export get_next_cref_to(ea_t to, ea_t current)
Get next instruction referencing to the specified instruction.