IDA C++ SDK 9.2
Loading...
Searching...
No Matches
bytes.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 BYTES_HPP
9#define BYTES_HPP
10
11#include <nalt.hpp>
12#include <lines.hpp>
13#include <range.hpp>
14
15class insn_t;
16
31
32//--------------------------------------------------------------------------
40
41idaman error_t ida_export enable_flags(ea_t start_ea, ea_t end_ea, storage_type_t stt);
42
43
49
50idaman error_t ida_export disable_flags(ea_t start_ea, ea_t end_ea);
51
52
58
59idaman error_t ida_export change_storage_type(ea_t start_ea, ea_t end_ea, storage_type_t stt);
60
61
64
65idaman ea_t ida_export next_addr(ea_t ea);
66
67
70
71idaman ea_t ida_export prev_addr(ea_t ea);
72
73
76
77idaman ea_t ida_export next_chunk(ea_t ea);
78
79
82
83idaman ea_t ida_export prev_chunk(ea_t ea);
84
85
88
89idaman ea_t ida_export chunk_start(ea_t ea);
90
91
94
95idaman asize_t ida_export chunk_size(ea_t ea);
96
97
104
105idaman ea_t ida_export find_free_chunk(ea_t start, asize_t size, asize_t alignment);
106
107
109typedef bool idaapi testf_t(flags64_t flags, void *ud);
110
111
120
121idaman ea_t ida_export next_that(
122 ea_t ea,
123 ea_t maxea,
124 testf_t *testf,
125 void *ud=nullptr);
126
127
129
130inline ea_t idaapi next_unknown(ea_t ea, ea_t maxea)
131{
132 return next_that(ea, maxea, nullptr);
133}
134
135
144
145idaman ea_t ida_export prev_that(
146 ea_t ea,
147 ea_t minea,
148 testf_t *testf,
149 void *ud=nullptr);
150
151
153
154inline ea_t idaapi prev_unknown(ea_t ea, ea_t minea)
155{
156 return prev_that(ea, minea, nullptr);
157}
158
159
164
165idaman ea_t ida_export prev_head(ea_t ea, ea_t minea);
166
167
172
173idaman ea_t ida_export next_head(ea_t ea, ea_t maxea);
174
175
178
179idaman ea_t ida_export prev_not_tail(ea_t ea);
180
181
184
185idaman ea_t ida_export next_not_tail(ea_t ea);
186
187
191
193
194
197
198idaman ea_t ida_export prev_visea(ea_t ea);
199
200
203
204idaman ea_t ida_export next_visea(ea_t ea);
205
206
208
210
211
213
215
216
218
219bool is_visible_finally(ea_t ea); // do we need to show anything
220 // at this address?
221
222
223
227
228inline ea_t idaapi get_item_head(ea_t ea);
229
230
234
235idaman ea_t ida_export get_item_end(ea_t ea);
236
237
245
246idaman ea_t ida_export calc_max_item_end(ea_t ea, int how=15);
250#define ITEM_END_FIXUP 0x0001
251#define ITEM_END_INITED 0x0002
255#define ITEM_END_NAME 0x0004
256#define ITEM_END_XREF 0x0008
257#define ITEM_END_CANCEL 0x0010
260
261
265
266inline asize_t get_item_size(ea_t ea) { return get_item_end(ea) - ea; }
267
268
269
270
272
273idaman bool ida_export is_mapped(ea_t ea);
274
275
277
278idaman flags64_t ida_export get_flags_ex(ea_t ea, int how);
279
280#define GFE_VALUE 0x0001
284#define GFE_IDB_VALUE 0x0002
286#define GFE_32BIT 0x0004
287
296inline flags64_t idaapi get_flags32(ea_t ea) { return get_flags_ex(ea, GFE_32BIT); }
297
304inline flags64_t idaapi get_flags(ea_t ea) { return get_flags_ex(ea, 0); }
305
311inline flags64_t idaapi get_full_flags(ea_t ea) { return get_flags_ex(ea, GFE_VALUE); }
312
313
324
325idaman flags64_t ida_export get_item_flag(ea_t from, int n, ea_t ea, bool appzero);
326
327
328//--------------------------------------------------------------------------
338idaman bool ida_export get_item_refinfo(refinfo_t *ri, ea_t ea, int n);
339
340//--------------------------------------------------------------------------
346#define MS_VAL 0x000000FF
347#define FF_IVL 0x00000100
349
351
352inline THREAD_SAFE constexpr bool idaapi has_value(flags64_t F) { return (F & FF_IVL) != 0; }
353
354
357
358idaman void ida_export del_value(ea_t ea);
359
360
362
363idaman bool ida_export is_loaded(ea_t ea);
364
365
370
371idaman int ida_export nbits(ea_t ea);
372
373
375
376inline int bytesize(ea_t ea)
377 { return (nbits(ea)+7)/8; }
378
379
382
383idaman uchar ida_export get_byte(ea_t ea);
384
385
390
391idaman uchar ida_export get_db_byte(ea_t ea);
392
393
397
398idaman ushort ida_export get_word(ea_t ea);
399
400
404
405idaman uint32 ida_export get_dword(ea_t ea);
406
407
411
412idaman uint64 ida_export get_qword(ea_t ea);
413
414
418
419idaman uint64 ida_export get_wide_byte(ea_t ea);
420
421
426
427idaman uint64 ida_export get_wide_word(ea_t ea);
428
429
435
436idaman uint64 ida_export get_wide_dword(ea_t ea);
437
438
452
454{
457 int avail_bits = 0;
459 octet_generator_t(ea_t _ea) : ea(_ea) {}
461#ifndef SWIG
463 {
464 COMPARE_FIELDS(ea);
465 if ( avail_bits < r.avail_bits )
466 return 1; // less bits available means that we have advanced more
467 if ( avail_bits > r.avail_bits )
468 return -1; // more bits available means that we have advanced less
469 return 0;
470 }
471#endif
472};
473
474idaman bool ida_export get_octet(uchar *out, octet_generator_t *ogen);
475
476
477
481
482idaman uint32 ida_export get_16bit(ea_t ea);
483
484
490
491idaman uint32 ida_export get_32bit(ea_t ea);
492
493
499
500idaman uint64 ida_export get_64bit(ea_t ea);
501
502
511
512idaman bool ida_export get_data_value(uval_t *v, ea_t ea, asize_t size);
513
514
524
525idaman int ida_export visit_patched_bytes(
526 ea_t ea1,
527 ea_t ea2,
528 int (idaapi *cb)(ea_t ea, qoff64_t fpos, uint64 o, uint64 v, void *ud),
529 void *ud = nullptr);
530
531
534
535idaman uint64 ida_export get_original_byte(ea_t ea);
536
537
541
542idaman uint64 ida_export get_original_word(ea_t ea);
543
544
548
549idaman uint64 ida_export get_original_dword(ea_t ea);
550
551
555
556idaman uint64 ida_export get_original_qword(ea_t ea);
557
558
570
571idaman bool ida_export put_byte(ea_t ea, uint64 x);
572
573
581
582idaman void ida_export put_word(ea_t ea, uint64 x);
583
584
592
593idaman void ida_export put_dword(ea_t ea, uint64 x);
594
595
601
602idaman void ida_export put_qword(ea_t ea, uint64 x);
603
604
613
614idaman bool ida_export patch_byte(ea_t ea, uint64 x);
615
616
626
627idaman bool ida_export patch_word(ea_t ea, uint64 x);
628
629
639
640idaman bool ida_export patch_dword(ea_t ea, uint64 x);
641
642
652
653idaman bool ida_export patch_qword(ea_t ea, uint64 x);
654
655
658
659idaman bool ida_export revert_byte(ea_t ea);
660
661
666
667idaman void ida_export add_byte(ea_t ea, uint32 value);
668
669
675
676idaman void ida_export add_word(ea_t ea, uint64 value);
677
678
685
686idaman void ida_export add_dword(ea_t ea, uint64 value);
687
688
694
695idaman void ida_export add_qword(ea_t ea, uint64 value);
696
697
705
706idaman bool ida_export get_zero_ranges(rangeset_t *zranges, const range_t *range);
707
708
719
720idaman ssize_t ida_export get_bytes(
721 void *buf,
723 ea_t ea,
724 int gmb_flags=0,
725 void *mask=nullptr);
726
729#define GMB_READALL 0x01
731#define GMB_WAITBOX 0x02
733
734
741
742idaman void ida_export put_bytes(ea_t ea, const void *buf, size_t size);
743
744
752
753idaman void ida_export patch_bytes(ea_t ea, const void *buf, size_t size);
754
755//-------------------------------------------------------------------------
770
773#define MS_CLS 0x00000600
774#define FF_CODE 0x00000600
775#define FF_DATA 0x00000400
776#define FF_TAIL 0x00000200
777#define FF_UNK 0x00000000
779
782
784
785inline THREAD_SAFE constexpr bool idaapi is_code(flags64_t F) { return (F & MS_CLS) == FF_CODE; }
786inline THREAD_SAFE constexpr bool idaapi f_is_code(flags64_t F, void *) { return is_code(F); }
787
788
790
791inline THREAD_SAFE constexpr bool idaapi is_data(flags64_t F) { return (F & MS_CLS) == FF_DATA; }
792inline THREAD_SAFE constexpr bool idaapi f_is_data(flags64_t F, void *) { return is_data(F); }
793
794
796
797inline THREAD_SAFE constexpr bool idaapi is_tail(flags64_t F) { return (F & MS_CLS) == FF_TAIL; }
798inline THREAD_SAFE constexpr bool idaapi f_is_tail(flags64_t F, void *) { return is_tail(F); }
799inline THREAD_SAFE constexpr bool idaapi is_not_tail(flags64_t F) { return !is_tail(F); }
800inline THREAD_SAFE constexpr bool idaapi f_is_not_tail(flags64_t F, void *) { return is_not_tail(F); }
801
802
804
805inline THREAD_SAFE constexpr bool idaapi is_unknown(flags64_t F) { return (F & MS_CLS) == FF_UNK; }
806
807
809
810inline THREAD_SAFE constexpr bool idaapi is_head(flags64_t F) { return (F & FF_DATA) != 0; }
811inline THREAD_SAFE constexpr bool idaapi f_is_head(flags64_t F, void *) { return is_head(F); }
812
815
817typedef bool idaapi may_destroy_cb_t(ea_t);
818
829
830idaman bool ida_export del_items(
831 ea_t ea,
832 int flags=0,
833 asize_t nbytes=1,
834 may_destroy_cb_t *may_destroy=nullptr);
835
839#define DELIT_SIMPLE 0x0000
840#define DELIT_EXPAND 0x0001
845#define DELIT_DELNAMES 0x0002
848#define DELIT_NOTRUNC 0x0004
850#define DELIT_NOUNAME 0x0008
853#define DELIT_NOCMT 0x0010
856#define DELIT_KEEPFUNC 0x0020
859
860
861//-------------------------------------------------------------------------
862// Manual instructions (they are used to completely override an automatically
863// generated instruction by a user specified string).
864
867
868idaman bool ida_export is_manual_insn(ea_t ea); // Is the instruction overridden?
869
870
875
876idaman ssize_t ida_export get_manual_insn(qstring *buf, ea_t ea);
877
878
883
884idaman void ida_export set_manual_insn(ea_t ea, const char *manual_insn); // Set user-specified string
885
886
887//-------------------------------------------------------------------------
895#define MS_COMM 0x000FF800
896#define FF_COMM 0x00000800
897#define FF_REF 0x00001000
898#define FF_LINE 0x00002000
899#define FF_NAME 0x00004000
900#define FF_LABL 0x00008000
901#define FF_FLOW 0x00010000
902#define FF_SIGN 0x00020000
903#define FF_BNOT 0x00040000
904#define FF_UNUSED 0x00080000
906
910
912
913inline THREAD_SAFE constexpr bool idaapi is_flow(flags64_t F) { return (F & FF_FLOW) != 0; }
914
915
917
918inline THREAD_SAFE constexpr bool idaapi has_extra_cmts(flags64_t F) { return (F & FF_LINE) != 0; }
919inline THREAD_SAFE constexpr bool idaapi f_has_extra_cmts(flags64_t f, void *) { return has_extra_cmts(f); }
920
922
923inline THREAD_SAFE constexpr bool idaapi has_cmt(flags64_t F) { return (F & FF_COMM) != 0; }
924inline THREAD_SAFE constexpr bool idaapi f_has_cmt(flags64_t f, void *) { return has_cmt(f); }
925
927
928inline THREAD_SAFE constexpr bool idaapi has_xref(flags64_t F) { return (F & FF_REF) != 0; }
929inline THREAD_SAFE constexpr bool idaapi f_has_xref(flags64_t f, void *) { return has_xref(f); }
930
931
933
934inline THREAD_SAFE constexpr bool idaapi has_name(flags64_t F) { return (F & FF_NAME) != 0; }
935inline THREAD_SAFE constexpr bool idaapi f_has_name(flags64_t f, void *) { return has_name(f); }
936
937
938
939#define FF_ANYNAME (FF_LABL|FF_NAME)
940
942
943inline THREAD_SAFE constexpr bool idaapi has_dummy_name(flags64_t F) { return (F & FF_ANYNAME) == FF_LABL; }
944inline THREAD_SAFE constexpr bool idaapi f_has_dummy_name(flags64_t f, void *) { return has_dummy_name(f); }
945
946
948
949inline THREAD_SAFE constexpr bool idaapi has_auto_name(flags64_t F) { return (F & FF_ANYNAME) == FF_ANYNAME; }
950
951
953
954inline THREAD_SAFE constexpr bool idaapi has_any_name(flags64_t F) { return (F & FF_ANYNAME) != 0; }
955
956
958
959inline THREAD_SAFE constexpr bool idaapi has_user_name(flags64_t F) { return (F & FF_ANYNAME) == FF_NAME; }
960inline THREAD_SAFE constexpr bool idaapi f_has_user_name(flags64_t F, void *) { return has_user_name(F); }
961
962// signness deals with the form of operands of the current instruction/data.
963// inverted sign means the following:
964// if the bit is clear |then when the bit is set
965// and the output is |the output should be:
966// ------------ |----------
967// unsigned |signed
968// signed |unsigned
969//
970
973
974idaman bool ida_export is_invsign(ea_t ea, flags64_t F, int n);
975
976
979
980idaman bool ida_export toggle_sign(ea_t ea, int n);
981
982
986
987idaman bool ida_export is_bnot(ea_t ea, flags64_t F, int n);
988idaman bool ida_export toggle_bnot(ea_t ea, int n);
989
990
999
1000idaman bool ida_export is_lzero(ea_t ea, int n);
1001
1009
1010idaman bool ida_export set_lzero(ea_t ea, int n);
1011
1019
1020idaman bool ida_export clr_lzero(ea_t ea, int n);
1021
1026
1027inline bool idaapi toggle_lzero(ea_t ea, int n)
1028{
1029 return (is_lzero(ea, n) ? clr_lzero : set_lzero)(ea, n);
1030}
1031
1032
1034
1035
1037
1038idaman bool ida_export leading_zero_important(ea_t ea, int n);
1039
1040//-------------------------------------------------------------------------
1050
1051#define MS_N_TYPE 0xFLLU
1052#define FF_N_VOID 0x0
1053#define FF_N_NUMH 0x1
1054#define FF_N_NUMD 0x2
1055#define FF_N_CHAR 0x3
1056#define FF_N_SEG 0x4
1057#define FF_N_OFF 0x5
1058#define FF_N_NUMB 0x6
1059#define FF_N_NUMO 0x7
1060#define FF_N_ENUM 0x8
1061#define FF_N_FOP 0x9
1062#define FF_N_STRO 0xA
1063#define FF_N_STK 0xB
1064#define FF_N_FLT 0xC
1065#define FF_N_CUST 0xD
1066
1074
1075inline constexpr int get_operand_type_shift(uint32 n)
1076{
1077 return 20 + (4 * (n + (n > 1)));
1078}
1079
1086
1087inline constexpr flags64_t get_operand_flag(uint8 typebits, int n)
1088{
1089 return n >= 0 && n < UA_MAXOP ? flags64_t(typebits) << get_operand_type_shift(n) : 0;
1090}
1091
1099
1100inline constexpr bool is_flag_for_operand(flags64_t F, uint8 typebits, int n)
1101{
1102 return n < UA_MAXOP && (F & get_operand_flag(MS_N_TYPE, n)) == get_operand_flag(typebits, n);
1103}
1104
1107
1109
1110inline THREAD_SAFE constexpr bool idaapi is_defarg0(flags64_t F) { return !is_flag_for_operand(F, FF_N_VOID, 0); }
1111
1112
1114
1115inline THREAD_SAFE constexpr bool idaapi is_defarg1(flags64_t F) { return !is_flag_for_operand(F, FF_N_VOID, 1); }
1116
1117
1119
1120inline THREAD_SAFE constexpr bool idaapi is_off0(flags64_t F) { return is_flag_for_operand(F, FF_N_OFF, 0); }
1121
1122
1124
1125inline THREAD_SAFE constexpr bool idaapi is_off1(flags64_t F) { return is_flag_for_operand(F, FF_N_OFF, 1); }
1126
1127
1129
1130inline THREAD_SAFE constexpr bool idaapi is_char0(flags64_t F) { return is_flag_for_operand(F, FF_N_CHAR, 0); }
1131
1132
1134
1135inline THREAD_SAFE constexpr bool idaapi is_char1(flags64_t F) { return is_flag_for_operand(F, FF_N_CHAR, 1); }
1136
1137
1139
1140inline THREAD_SAFE constexpr bool idaapi is_seg0(flags64_t F) { return is_flag_for_operand(F, FF_N_SEG, 0); }
1141
1142
1144
1145inline THREAD_SAFE constexpr bool idaapi is_seg1(flags64_t F) { return is_flag_for_operand(F, FF_N_SEG, 1); }
1146
1147
1149
1150inline THREAD_SAFE constexpr bool idaapi is_enum0(flags64_t F) { return is_flag_for_operand(F, FF_N_ENUM, 0); }
1151
1152
1154
1155inline THREAD_SAFE constexpr bool idaapi is_enum1(flags64_t F) { return is_flag_for_operand(F, FF_N_ENUM, 1); }
1156
1157
1159
1160inline THREAD_SAFE constexpr bool idaapi is_stroff0(flags64_t F) { return is_flag_for_operand(F, FF_N_STRO, 0); }
1161
1162
1164
1165inline THREAD_SAFE constexpr bool idaapi is_stroff1(flags64_t F) { return is_flag_for_operand(F, FF_N_STRO, 1); }
1166
1167
1169
1170inline THREAD_SAFE constexpr bool idaapi is_stkvar0(flags64_t F) { return is_flag_for_operand(F, FF_N_STK, 0); }
1171
1172
1174
1175inline THREAD_SAFE constexpr bool idaapi is_stkvar1(flags64_t F) { return is_flag_for_operand(F, FF_N_STK, 1); }
1176
1177
1179
1180inline THREAD_SAFE constexpr bool idaapi is_float0(flags64_t F) { return is_flag_for_operand(F, FF_N_FLT, 0); }
1181
1182
1184
1185inline THREAD_SAFE constexpr bool idaapi is_float1(flags64_t F) { return is_flag_for_operand(F, FF_N_FLT, 1); }
1186
1187
1189
1190inline THREAD_SAFE constexpr bool idaapi is_custfmt0(flags64_t F) { return is_flag_for_operand(F, FF_N_CUST, 0); }
1191
1192
1194
1195inline THREAD_SAFE constexpr bool idaapi is_custfmt1(flags64_t F) { return is_flag_for_operand(F, FF_N_CUST, 1); }
1196
1197
1199
1200idaman bool ida_export is_numop0(flags64_t F);
1201
1202
1204
1205idaman bool ida_export is_numop1(flags64_t F);
1206
1207
1209
1210inline THREAD_SAFE constexpr flags64_t get_optype_flags0(flags64_t F) { return F & (MS_N_TYPE << get_operand_type_shift(0)); }
1211
1212
1214
1215inline THREAD_SAFE constexpr flags64_t get_optype_flags1(flags64_t F) { return F & (MS_N_TYPE << get_operand_type_shift(1)); }
1216
1218
1219//-------------------------------------------------------------------------
1220//
1221// The following 2 masks are used with operand numbers
1222//
1223#define OPND_OUTER 0x80
1225#define OPND_MASK 0x0F
1226#define OPND_ALL OPND_MASK
1227
1235idaman bool ida_export is_defarg(flags64_t F, int n);
1236idaman bool ida_export is_off(flags64_t F, int n);
1237idaman bool ida_export is_char(flags64_t F, int n);
1238idaman bool ida_export is_seg(flags64_t F, int n);
1239idaman bool ida_export is_enum(flags64_t F, int n);
1240idaman bool ida_export is_manual(flags64_t F, int n);
1241idaman bool ida_export is_stroff(flags64_t F, int n);
1242idaman bool ida_export is_stkvar(flags64_t F, int n);
1243idaman bool ida_export is_fltnum(flags64_t F, int n);
1244idaman bool ida_export is_custfmt(flags64_t F, int n);
1245idaman bool ida_export is_numop(flags64_t F, int n);
1246idaman bool ida_export is_suspop(ea_t ea, flags64_t F, int n);
1248
1249
1252
1253idaman bool ida_export op_adds_xrefs(flags64_t F, int n);
1254
1255
1263
1264idaman bool ida_export set_op_type(ea_t ea, flags64_t type, int n);
1265
1266
1272
1273idaman bool ida_export op_seg(ea_t ea, int n);
1274
1275
1285
1286idaman bool ida_export op_enum(ea_t ea, int n, tid_t id, uchar serial=0);
1287
1288
1295
1296idaman tid_t ida_export get_enum_id(uchar *serial, ea_t ea, int n);
1297
1298
1307
1308idaman bool ida_export op_stroff(
1309 const insn_t &insn,
1310 int n,
1311 const tid_t *path,
1312 int path_len,
1313 adiff_t delta);
1314
1315
1329
1330idaman bool ida_export op_based_stroff(
1331 const insn_t &insn,
1332 int n,
1333 adiff_t opval,
1334 ea_t base);
1335
1336
1343
1344idaman int ida_export get_stroff_path(tid_t *path, adiff_t *delta, ea_t ea, int n);
1345
1353
1354idaman bool ida_export op_stkvar(ea_t ea, int n);
1355
1356
1364
1365idaman bool ida_export set_forced_operand(ea_t ea, int n, const char *op);
1366
1367
1373
1374idaman ssize_t ida_export get_forced_operand(qstring *buf, ea_t ea, int n);
1375
1376
1380
1381idaman bool ida_export is_forced_operand(ea_t ea, int n);
1382
1383
1384//-------------------------------------------------------------------------
1385inline constexpr flags64_t idaapi combine_flags(flags64_t F)
1386{
1387 return (F << get_operand_type_shift(0))
1388 | (F << get_operand_type_shift(1))
1389 | (F << get_operand_type_shift(2))
1390 | (F << get_operand_type_shift(3))
1391 | (F << get_operand_type_shift(4))
1392 | (F << get_operand_type_shift(5))
1393 | (F << get_operand_type_shift(6))
1394 | (F << get_operand_type_shift(7));
1395}
1396
1397//-------------------------------------------------------------------------
1402inline constexpr flags64_t idaapi char_flag(void) { return combine_flags(FF_N_CHAR); }
1403inline constexpr flags64_t idaapi off_flag(void) { return combine_flags(FF_N_OFF); }
1404inline constexpr flags64_t idaapi enum_flag(void) { return combine_flags(FF_N_ENUM); }
1405inline constexpr flags64_t idaapi stroff_flag(void) { return combine_flags(FF_N_STRO); }
1406inline constexpr flags64_t idaapi stkvar_flag(void) { return combine_flags(FF_N_STK); }
1407inline constexpr flags64_t idaapi flt_flag(void) { return combine_flags(FF_N_FLT); }
1408inline constexpr flags64_t idaapi custfmt_flag(void) { return combine_flags(FF_N_CUST); }
1409inline constexpr flags64_t idaapi seg_flag(void) { return combine_flags(FF_N_SEG); }
1410
1411idaman flags64_t ida_export num_flag(void);
1413inline constexpr flags64_t idaapi hex_flag(void) { return combine_flags(FF_N_NUMH); }
1414inline constexpr flags64_t idaapi dec_flag(void) { return combine_flags(FF_N_NUMD); }
1415inline constexpr flags64_t idaapi oct_flag(void) { return combine_flags(FF_N_NUMO); }
1416inline constexpr flags64_t idaapi bin_flag(void) { return combine_flags(FF_N_NUMB); }
1418
1430inline bool idaapi op_chr(ea_t ea, int n) { return set_op_type(ea, char_flag(), n); }
1431inline bool idaapi op_num(ea_t ea, int n) { return set_op_type(ea, num_flag(), n); }
1432inline bool idaapi op_hex(ea_t ea, int n) { return set_op_type(ea, hex_flag(), n); }
1433inline bool idaapi op_dec(ea_t ea, int n) { return set_op_type(ea, dec_flag(), n); }
1434inline bool idaapi op_oct(ea_t ea, int n) { return set_op_type(ea, oct_flag(), n); }
1435inline bool idaapi op_bin(ea_t ea, int n) { return set_op_type(ea, bin_flag(), n); }
1436inline bool idaapi op_flt(ea_t ea, int n) { return set_op_type(ea, flt_flag(), n); }
1438
1440
1441idaman bool ida_export op_custfmt(ea_t ea, int n, int fid);
1442
1443
1449
1450idaman bool ida_export clr_op_type(ea_t ea, int n);
1451
1452
1455
1456idaman int ida_export get_default_radix(void);
1457
1458
1464
1465idaman int ida_export get_radix(flags64_t F, int n);
1466
1467
1468//-------------------------------------------------------------------------
1471#define DT_TYPE 0xF0000000
1472
1473#define FF_BYTE 0x00000000
1474#define FF_WORD 0x10000000
1475#define FF_DWORD 0x20000000
1476#define FF_QWORD 0x30000000
1477#define FF_TBYTE 0x40000000
1478#define FF_STRLIT 0x50000000
1479#define FF_STRUCT 0x60000000
1480#define FF_OWORD 0x70000000
1481#define FF_FLOAT 0x80000000
1482#define FF_DOUBLE 0x90000000
1483#define FF_PACKREAL 0xA0000000
1484#define FF_ALIGN 0xB0000000
1485// 0xC0000000 ///< reserved
1486#define FF_CUSTOM 0xD0000000
1487#define FF_YWORD 0xE0000000
1488#define FF_ZWORD 0xF0000000
1490
1493inline constexpr flags64_t idaapi code_flag(void) { return FF_CODE; }
1494inline constexpr flags64_t idaapi byte_flag(void) { return FF_DATA|FF_BYTE; }
1495inline constexpr flags64_t idaapi word_flag(void) { return FF_DATA|FF_WORD; }
1496inline constexpr flags64_t idaapi dword_flag(void) { return FF_DATA|FF_DWORD; }
1497inline constexpr flags64_t idaapi qword_flag(void) { return FF_DATA|FF_QWORD; }
1498inline constexpr flags64_t idaapi oword_flag(void) { return FF_DATA|FF_OWORD; }
1499inline constexpr flags64_t idaapi yword_flag(void) { return FF_DATA|FF_YWORD; }
1500inline constexpr flags64_t idaapi zword_flag(void) { return FF_DATA|FF_ZWORD; }
1501inline constexpr flags64_t idaapi tbyte_flag(void) { return FF_DATA|FF_TBYTE; }
1502inline constexpr flags64_t idaapi strlit_flag(void) { return FF_DATA|FF_STRLIT; }
1503inline constexpr flags64_t idaapi stru_flag(void) { return FF_DATA|FF_STRUCT; }
1504inline constexpr flags64_t idaapi cust_flag(void) { return FF_DATA|FF_CUSTOM; }
1505inline constexpr flags64_t idaapi align_flag(void) { return FF_DATA|FF_ALIGN; }
1506inline constexpr flags64_t idaapi float_flag(void) { return FF_DATA|FF_FLOAT; }
1507inline constexpr flags64_t idaapi double_flag(void) { return FF_DATA|FF_DOUBLE; }
1508inline constexpr flags64_t idaapi packreal_flag(void) { return FF_DATA|FF_PACKREAL; }
1509
1510inline THREAD_SAFE constexpr bool idaapi is_byte(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_BYTE; }
1511inline THREAD_SAFE constexpr bool idaapi is_word(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_WORD; }
1512inline THREAD_SAFE constexpr bool idaapi is_dword(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_DWORD; }
1513inline THREAD_SAFE constexpr bool idaapi is_qword(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_QWORD; }
1514inline THREAD_SAFE constexpr bool idaapi is_oword(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_OWORD; }
1515inline THREAD_SAFE constexpr bool idaapi is_yword(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_YWORD; }
1516inline THREAD_SAFE constexpr bool idaapi is_zword(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_ZWORD; }
1517inline THREAD_SAFE constexpr bool idaapi is_tbyte(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_TBYTE; }
1518inline THREAD_SAFE constexpr bool idaapi is_float(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_FLOAT; }
1519inline THREAD_SAFE constexpr bool idaapi is_double(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_DOUBLE; }
1520inline THREAD_SAFE constexpr bool idaapi is_pack_real(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_PACKREAL; }
1521inline THREAD_SAFE constexpr bool idaapi is_strlit(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_STRLIT; }
1522inline THREAD_SAFE constexpr bool idaapi is_struct(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_STRUCT; }
1523inline THREAD_SAFE constexpr bool idaapi is_align(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_ALIGN; }
1524inline THREAD_SAFE constexpr bool idaapi is_custom(flags64_t F) { return is_data(F) && (F & DT_TYPE) == FF_CUSTOM; }
1525
1526inline THREAD_SAFE constexpr bool idaapi f_is_byte(flags64_t F, void *) { return is_byte(F); }
1527inline THREAD_SAFE constexpr bool idaapi f_is_word(flags64_t F, void *) { return is_word(F); }
1528inline THREAD_SAFE constexpr bool idaapi f_is_dword(flags64_t F, void *) { return is_dword(F); }
1529inline THREAD_SAFE constexpr bool idaapi f_is_qword(flags64_t F, void *) { return is_qword(F); }
1530inline THREAD_SAFE constexpr bool idaapi f_is_oword(flags64_t F, void *) { return is_oword(F); }
1531inline THREAD_SAFE constexpr bool idaapi f_is_yword(flags64_t F, void *) { return is_yword(F); }
1532inline THREAD_SAFE constexpr bool idaapi f_is_tbyte(flags64_t F, void *) { return is_tbyte(F); }
1533inline THREAD_SAFE constexpr bool idaapi f_is_float(flags64_t F, void *) { return is_float(F); }
1534inline THREAD_SAFE constexpr bool idaapi f_is_double(flags64_t F, void *) { return is_double(F); }
1535inline THREAD_SAFE constexpr bool idaapi f_is_pack_real(flags64_t F, void *) { return is_pack_real(F); }
1536inline THREAD_SAFE constexpr bool idaapi f_is_strlit(flags64_t F, void *) { return is_strlit(F); }
1537inline THREAD_SAFE constexpr bool idaapi f_is_struct(flags64_t F, void *) { return is_struct(F); }
1538inline THREAD_SAFE constexpr bool idaapi f_is_align(flags64_t F, void *) { return is_align(F); }
1539inline THREAD_SAFE constexpr bool idaapi f_is_custom(flags64_t F, void *) { return is_custom(F); }
1540
1541
1543
1544inline THREAD_SAFE constexpr bool idaapi is_same_data_type(flags64_t F1, flags64_t F2) { return ((F1 ^ F2) & DT_TYPE) == 0; }
1545
1546
1550
1551idaman flags64_t ida_export get_flags_by_size(size_t size);
1553
1554
1561
1572
1573idaman bool ida_export create_data(
1574 ea_t ea,
1575 flags64_t dataflag,
1576 asize_t size,
1577 tid_t tid);
1578
1579
1580inline THREAD_SAFE flags64_t idaapi calc_dflags(flags64_t f, bool force) { return f | (force ? FF_COMM : 0); }
1582inline bool idaapi create_byte(ea_t ea, asize_t length, bool force=false)
1583{
1584 return create_data(ea, calc_dflags(FF_BYTE, force), length, BADNODE);
1585}
1586
1587inline bool idaapi create_word(ea_t ea, asize_t length, bool force=false)
1588{
1589 return create_data(ea, calc_dflags(FF_WORD, force), length, BADNODE);
1590}
1591
1592inline bool idaapi create_dword(ea_t ea, asize_t length, bool force=false)
1593{
1594 return create_data(ea, calc_dflags(FF_DWORD, force), length, BADNODE);
1595}
1596
1597inline bool idaapi create_qword(ea_t ea, asize_t length, bool force=false)
1598{
1599 return create_data(ea, calc_dflags(FF_QWORD, force), length, BADNODE);
1600}
1601
1602inline bool idaapi create_oword(ea_t ea, asize_t length, bool force=false)
1603{
1604 return create_data(ea, calc_dflags(FF_OWORD, force), length, BADNODE);
1605}
1606
1607inline bool idaapi create_yword(ea_t ea, asize_t length, bool force=false)
1608{
1609 return create_data(ea, calc_dflags(FF_YWORD, force), length, BADNODE);
1610}
1611
1612inline bool idaapi create_zword(ea_t ea, asize_t length, bool force=false)
1613{
1614 return create_data(ea, calc_dflags(FF_ZWORD, force), length, BADNODE);
1615}
1616
1617inline bool idaapi create_tbyte(ea_t ea, asize_t length, bool force=false)
1618{
1619 return create_data(ea, calc_dflags(FF_TBYTE, force), length, BADNODE);
1620}
1621
1622inline bool idaapi create_float(ea_t ea, asize_t length, bool force=false)
1623{
1624 return create_data(ea, calc_dflags(FF_FLOAT, force), length, BADNODE);
1625}
1626
1627inline bool idaapi create_double(ea_t ea, asize_t length, bool force=false)
1628{
1629 return create_data(ea, calc_dflags(FF_DOUBLE, force), length, BADNODE);
1630}
1631
1632inline bool idaapi create_packed_real(ea_t ea, asize_t length, bool force=false)
1633{
1634 return create_data(ea, calc_dflags(FF_PACKREAL, force), length, BADNODE);
1635}
1636
1637inline bool idaapi create_struct(ea_t ea, asize_t length, tid_t tid, bool force=false)
1638{
1639 return create_data(ea, calc_dflags(FF_STRUCT, force), length, tid);
1640}
1641
1642inline bool idaapi create_custdata(ea_t ea, asize_t length, int dtid, int fid, bool force=false)
1643{
1644 return create_data(ea, calc_dflags(FF_CUSTOM, force), length, dtid|(fid<<16));
1645}
1646
1647
1655
1656idaman bool ida_export create_align(ea_t ea, asize_t length, int alignment);
1657
1661
1662idaman int ida_export calc_min_align(asize_t length);
1663
1664
1668
1669idaman int ida_export calc_max_align(ea_t endea);
1670
1675
1676idaman int ida_export calc_def_align(ea_t ea, int mina, int maxa);
1677
1678
1680
1681idaman bool ida_export create_16bit_data(ea_t ea, asize_t length);
1682
1683
1685
1686idaman bool ida_export create_32bit_data(ea_t ea, asize_t length);
1687
1688
1690
1692
1696#define ALOPT_IGNHEADS 0x01
1701#define ALOPT_IGNPRINT 0x02
1704#define ALOPT_IGNCLT 0x04
1709#define ALOPT_MAX4K 0x08
1711#define ALOPT_ONLYTERM 0x10
1714#define ALOPT_APPEND 0x20
1716
1718
1729
1730idaman size_t ida_export get_max_strlit_length(
1731 ea_t ea,
1732 int32 strtype,
1733 int options = 0);
1734
1738#define STRCONV_ESCAPE 0x00000001
1739#define STRCONV_REPLCHAR 0x00000002
1740#define STRCONV_INCLLEN 0x00000004
1742
1772
1774 qstring *utf8,
1775 ea_t ea,
1776 size_t len,
1777 int32 type,
1778 size_t *maxcps = nullptr,
1779 int flags = 0);
1780
1781
1790
1791idaman bool ida_export create_strlit(ea_t start, size_t len, int32 strtype);
1792
1793
1794
1795//-------------------------------------------------------------------------
1798#define PSTF_TNORM 0x00
1799#define PSTF_TBRIEF 0x01
1800#define PSTF_TINLIN 0x02
1801#define PSTF_TMASK 0x03
1802#define PSTF_HOTKEY 0x04
1803#define PSTF_ENC 0x08
1804#define PSTF_ONLY_ENC 0x0B
1805#define PSTF_ATTRIB 0x10
1807
1808
1817
1818idaman bool ida_export print_strlit_type(
1819 qstring *out,
1820 int32 strtype,
1821 qstring *out_tooltip = nullptr,
1822 int flags = 0);
1823
1824
1831
1832idaman opinfo_t *ida_export get_opinfo(
1833 opinfo_t *buf,
1834 ea_t ea,
1835 int n,
1836 flags64_t flags);
1837
1838
1851
1852idaman bool ida_export set_opinfo(
1853 ea_t ea,
1854 int n,
1855 flags64_t flag,
1856 const opinfo_t *ti,
1857 bool suppress_events=false);
1858
1859
1873
1874idaman asize_t ida_export get_data_elsize(ea_t ea, flags64_t F, const opinfo_t *ti=nullptr);
1875
1876
1880inline asize_t get_full_data_elsize(ea_t ea, flags64_t F, const opinfo_t *ti=nullptr)
1881{
1882 asize_t nbytes = get_data_elsize(ea, F, ti);
1883 return nbytes * bytesize(ea);
1884}
1885
1886
1899
1900idaman int ida_export is_varsize_item(
1901 ea_t ea,
1902 flags64_t F,
1903 const opinfo_t *ti=nullptr,
1904 asize_t *itemsize=nullptr);
1905
1906
1913
1915 ea_t ea,
1916 const tinfo_t &tif);
1917
1918
1941
1942idaman bool ida_export can_define_item(ea_t ea, asize_t length, flags64_t flags);
1943
1948
1949//-------------------------------------------------------------------------
1952#define MS_CODE 0xF0000000
1953#define FF_FUNC 0x10000000
1954// 0x20000000 // not used
1955#define FF_IMMD 0x40000000
1956#define FF_JUMP 0x80000000
1958
1961
1963
1964inline THREAD_SAFE bool idaapi has_immd(flags64_t F) { return is_code(F) && (F & FF_IMMD) != 0; }
1965
1966
1968
1969inline THREAD_SAFE bool idaapi is_func(flags64_t F) { return is_code(F) && (F & FF_FUNC) != 0; }
1970
1971
1974
1975idaman bool ida_export set_immd(ea_t ea);
1976
1977
1980
1981//-----------------------------------------------------------------------
1982// Custom data type and format definitions
1983//-----------------------------------------------------------------------
1984
1987{
1989 void *ud;
1990 int props;
1991#define DTP_NODUP 0x0001
1992 const char *name;
1993 const char *menu_name;
1995 const char *hotkey;
1997 const char *asm_keyword;
2001
2004 bool is_present_in_menus() const { return menu_name != nullptr && asm_keyword != nullptr; }
2005
2010 bool (idaapi *may_create_at)(
2011 void *ud,
2013 size_t nbytes);
2014
2021 asize_t (idaapi *calc_item_size)(
2022 void *ud,
2023 ea_t ea,
2025
2026#ifndef SWIG
2028#endif
2029};
2030
2033{
2035 void *ud;
2036 int props;
2037 const char *name;
2038 const char *menu_name;
2040 const char *hotkey;
2049
2052 bool is_present_in_menus() const { return menu_name != nullptr; }
2053
2063 bool (idaapi *print)(
2064 void *ud,
2066 const void *value,
2070 int dtid);
2071
2080 bool (idaapi *scan)(
2081 void *ud,
2083 const char *input,
2087
2094 void (idaapi *analyze)(
2095 void *ud,
2098
2099#ifndef SWIG
2101#endif
2102};
2103
2104
2111
2112idaman int ida_export register_custom_data_type(const data_type_t *dtinfo);
2113
2114
2125
2126idaman bool ida_export unregister_custom_data_type(int dtid);
2127
2128
2135
2136idaman int ida_export register_custom_data_format(const data_format_t *dtform);
2137
2138
2144
2145idaman bool ida_export unregister_custom_data_format(int dfid);
2146
2147
2151
2152idaman const data_type_t *ida_export get_custom_data_type(int dtid);
2153
2154
2158
2159idaman const data_format_t *ida_export get_custom_data_format(int dfid);
2160
2161
2172
2173idaman bool ida_export attach_custom_data_format(int dtid, int dfid);
2174
2175
2186
2187idaman bool ida_export detach_custom_data_format(int dtid, int dfid);
2188
2189
2194
2195idaman bool ida_export is_attached_custom_data_format(int dtid, int dfid);
2196
2202
2203idaman int ida_export get_custom_data_types(
2204 intvec_t *out,
2205 asize_t min_size=0,
2206 asize_t max_size=BADADDR);
2207
2208
2213
2214idaman int ida_export get_custom_data_formats(intvec_t *out, int dtid);
2215
2216
2220
2221idaman int ida_export find_custom_data_type(const char *name);
2222
2223
2227
2228idaman int ida_export find_custom_data_format(const char *name);
2229
2230
2231//--------------------------------------------------------------------------
2232// I N D E N T E D C O M M E N T S
2233//--------------------------------------------------------------------------
2234
2242
2243idaman bool ida_export set_cmt(ea_t ea, const char *comm, bool rptble);
2244
2245
2252
2253idaman ssize_t ida_export get_cmt(qstring *buf, ea_t ea, bool rptble);
2254
2255
2263
2264idaman bool ida_export append_cmt(ea_t ea, const char *str, bool rptble);
2265
2266
2267//--------------------------------------------------------------------
2268// P R E D E F I N E D C O M M E N T S
2269//--------------------------------------------------------------------
2270
2275
2277 qstring *buf,
2278 const insn_t &ins);
2279
2280
2281//--------------------------------------------------------------------------
2282// S E A R C H F U N C T I O N S
2283//--------------------------------------------------------------------------
2291
2292idaman ea_t ida_export find_byte(ea_t sEA, asize_t size, uchar value, int bin_search_flags);
2293
2294
2302
2303idaman ea_t ida_export find_byter(ea_t sEA, asize_t size, uchar value, int bin_search_flags);
2304
2305
2306//-------------------------------------------------------------------------
2307struct compiled_binpat_t // compiled binary pattern compiled_binpat_t
2308{
2311 rangevec_t strlits; // range of string literals, in _bytes_ ranges (not CPs)
2313
2315 bool all_bytes_defined() const { return mask.empty(); }
2316 void qclear() { bytes.qclear(); mask.qclear(); strlits.qclear(); encidx = -1; }
2317
2318 bool operator==(const compiled_binpat_t &r) const
2319 {
2320 return bytes == r.bytes
2321 && mask == r.mask
2322 && strlits == r.strlits
2323 && encidx == r.encidx;
2324 }
2325 bool operator!=(const compiled_binpat_t &r) const { return !(*this == r); }
2326};
2329
2330#define PBSENC_DEF1BPU 0
2331#define PBSENC_ALL -1
2332
2369// true otherwise
2370idaman bool ida_export parse_binpat_str(
2372 ea_t ea,
2373 const char *in,
2374 int radix,
2375 int strlits_encoding=PBSENC_DEF1BPU,
2376 qstring *errbuf=nullptr);
2377
2378
2386
2387idaman ea_t ida_export bin_search(
2388 ea_t start_ea,
2389 ea_t end_ea,
2390 const compiled_binpat_vec_t &data,
2391 int flags,
2392 size_t *out_matched_idx=nullptr);
2393
2395 ea_t start_ea,
2396 ea_t end_ea,
2397 const uchar *image,
2398 const uchar *mask,
2399 size_t len,
2400 int flags)
2401{
2403 compiled_binpat_t &bv = bbv.push_back();
2404 bv.bytes.append(image, len);
2405 if ( mask != nullptr )
2406 bv.mask.append(mask, len);
2407 return bin_search(start_ea, end_ea, bbv, flags);
2408}
2409
2414#define BIN_SEARCH_CASE 0x01
2415#define BIN_SEARCH_NOCASE 0x00
2416#define BIN_SEARCH_NOBREAK 0x02
2417#define BIN_SEARCH_INITED 0x04
2418#define BIN_SEARCH_NOSHOW 0x08
2419#define BIN_SEARCH_FORWARD 0x00
2420#define BIN_SEARCH_BACKWARD 0x10
2421#define BIN_SEARCH_BITMASK 0x20
2423
2424
2426
2427inline ea_t idaapi next_inited(ea_t ea, ea_t maxea)
2428{
2429 if ( ea >= maxea )
2430 return BADADDR;
2431 ++ea;
2432 return find_byte(ea, maxea-ea, 0, BIN_SEARCH_INITED);
2433}
2434
2436
2437inline ea_t idaapi prev_inited(ea_t ea, ea_t minea)
2438{
2439 if ( ea <= minea )
2440 return BADADDR;
2441 --ea;
2442 return find_byter(minea, ea-minea, 0, BIN_SEARCH_INITED);
2443}
2444
2459
2460idaman bool ida_export equal_bytes(
2461 ea_t ea,
2462 const uchar *image,
2463 const uchar *mask,
2464 size_t len,
2465 int bin_search_flags);
2466
2468#define SKIP_FF_MASK ((const uchar *)0xFF)
2469
2470// Compare two bytes. This helper function is used for binary search.
2472 uchar c1,
2473 uchar c2,
2474 const uchar *mask,
2475 int i,
2476 int bin_search_flags)
2477{
2478 if ( (bin_search_flags & BIN_SEARCH_CASE) == 0 )
2479 {
2480 c1 = qtoupper(c1);
2481 c2 = qtoupper(c2);
2482 }
2483 if ( mask != nullptr )
2484 {
2485 if ( (bin_search_flags & BIN_SEARCH_BITMASK) != 0 )
2486 return ((c1 ^ c2) & mask[i]) == 0; // are bytes equal with mask applied?
2487 if ( mask == SKIP_FF_MASK )
2488 {
2489 if ( c2 == 0xFF )
2490 return true;
2491 }
2492 else if ( mask[i] == 0 )
2493 {
2494 return true;
2495 }
2496 }
2497 return c1 == c2;
2498}
2499
2500idaman ea_t ida_export find_binary(
2501 ea_t startea,
2502 ea_t endea,
2503 const char *ubinstr,
2504 int radix,
2505 int sflag,
2506 int strlits_encoding=0);
2507
2508//------------------------------------------------------------------------
2509// H I D D E N A R E A S
2510//------------------------------------------------------------------------
2511
2515
2517{
2519 char *header;
2520 char *footer;
2521 bool visible;
2523};
2524
2529
2530idaman bool ida_export update_hidden_range(const hidden_range_t *ha);
2531
2532
2540
2541idaman bool ida_export add_hidden_range(
2542 ea_t ea1,
2543 ea_t ea2,
2544 const char *description,
2545 const char *header,
2546 const char *footer,
2547 bgcolor_t color=DEFCOLOR);
2548
2549
2552
2553idaman hidden_range_t *ida_export get_hidden_range(ea_t ea);
2554
2555
2558
2559idaman hidden_range_t *ida_export getn_hidden_range(int n);
2560
2561
2563
2564idaman int ida_export get_hidden_range_qty(void);
2565
2566
2570
2571idaman int ida_export get_hidden_range_num(ea_t ea);
2572
2573
2577
2579
2580
2584
2586
2587
2590
2592
2593
2596
2597idaman hidden_range_t *ida_export get_last_hidden_range(void);
2598
2599
2603
2604idaman bool ida_export del_hidden_range(ea_t ea);
2605
2606
2607//--------------------------------------------------------------------------
2608#define GET_ITEM_HEAD_BODY \
2609 if ( is_tail(get_flags32(ea)) ) \
2610 ea = prev_not_tail(ea); \
2611 return ea;
2612inline ea_t idaapi get_item_head(ea_t ea) { GET_ITEM_HEAD_BODY }
2613
2614//------------------------------------------------------------------------
2615// M E M O R Y M A P P I N G
2616//------------------------------------------------------------------------
2617
2621
2622
2628
2629idaman bool ida_export add_mapping(ea_t from, ea_t to, asize_t size);
2630
2631
2634
2635idaman void ida_export del_mapping(ea_t ea);
2636
2637
2641
2642idaman ea_t ida_export use_mapping(ea_t ea);
2643
2645
2646idaman size_t ida_export get_mappings_qty(void);
2647
2655idaman bool ida_export get_mapping(
2656 ea_t *from,
2657 ea_t *to,
2658 asize_t *size,
2659 size_t n);
2660
2661
2662#ifndef BYTES_SOURCE // undefined bit masks so no one can use them directly
2663#undef MS_VAL
2664#undef FF_IVL
2665#undef MS_CLS
2666#undef FF_CODE
2667#undef FF_DATA
2668#undef FF_TAIL
2669#undef FF_UNK
2670#undef MS_COMM
2671#undef FF_COMM
2672#undef FF_REF
2673#undef FF_LINE
2674#undef FF_NAME
2675#undef FF_LABL
2676#undef FF_ANYNAME
2677#undef FF_FLOW
2678#undef FF_SIGN
2679#undef FF_BNOT
2680#undef DT_TYPE
2681#undef FF_BYTE
2682#undef FF_WORD
2683#undef FF_DWORD
2684#undef FF_QWORD
2685#undef FF_OWORD
2686#undef FF_YWORD
2687#undef FF_ZWORD
2688#undef FF_FLOAT
2689#undef FF_DOUBLE
2690#undef FF_TBYTE
2691#undef FF_PACKREAL
2692#undef FF_STRLIT
2693#undef FF_STRUCT
2694#undef FF_ALIGN
2695#undef FF_CUSTOM
2696#undef MS_CODE
2697#undef FF_FUNC
2698#undef FF_IMMD
2699//#undef FF_JUMP
2700#undef MS_TAIL
2701#undef TL_TSFT
2702#undef TL_TOFF
2703#undef MAX_TOFF
2704#endif // BYTES_SOURCE
2705
2706// byte array to hex string
2707inline THREAD_SAFE ssize_t get_hex_string(char *buf, size_t bufsize, const uchar *bytes, size_t len)
2708{
2709 const char *const start = buf;
2710 const char *const end = buf + bufsize;
2711 for ( size_t i = 0; i < len; i++ )
2712 buf += ::qsnprintf(buf, end - buf, "%02X", *bytes++);
2713 return buf - start;
2714}
2715
2716
2717#endif // BYTES_HPP
idaman bool ida_export is_attached_custom_data_format(int dtid, int dfid)
Is the custom data format attached to the custom data type?
idaman ea_t ida_export prev_head(ea_t ea, ea_t minea)
Get start of previous defined item.
ea_t idaapi get_item_head(ea_t ea)
Get the start address of the item at 'ea'.
Definition bytes.hpp:2612
THREAD_SAFE constexpr bool idaapi has_value(flags64_t F)
Do flags contain byte value?
Definition bytes.hpp:352
idaman uint32 ida_export get_16bit(ea_t ea)
Get 16bits of the program at 'ea'.
idaman asize_t ida_export get_data_elsize(ea_t ea, flags64_t F, const opinfo_t *ti=nullptr)
Get size of data type specified in flags 'F'.
idaman uchar ida_export get_byte(ea_t ea)
Get one byte (8-bit) of the program at 'ea'.
qvector< compiled_binpat_t > compiled_binpat_vec_t
Definition bytes.hpp:2328
idaman uint32 ida_export get_32bit(ea_t ea)
Get not more than 32bits of the program at 'ea'.
idaman bool ida_export is_mapped(ea_t ea)
Is the specified address 'ea' present in the program?
int bytesize(ea_t ea)
Get number of bytes required to store a byte at the given address.
Definition bytes.hpp:376
idaman bool ida_export parse_binpat_str(compiled_binpat_vec_t *out, ea_t ea, const char *in, int radix, int strlits_encoding=PBSENC_DEF1BPU, qstring *errbuf=nullptr)
Convert user-specified binary string to internal representation.
idaman bool ida_export del_hidden_range(ea_t ea)
Delete hidden range.
idaman size_t ida_export get_max_strlit_length(ea_t ea, int32 strtype, int options=0)
Determine maximum length of string literal.
idaman hidden_range_t *ida_export get_last_hidden_range(void)
Get pointer to the last hidden range.
idaman uint64 ida_export get_64bit(ea_t ea)
Get not more than 64bits of the program at 'ea'.
idaman void ida_export add_dword(ea_t ea, uint64 value)
Add a value to one dword of the program.
idaman bool ida_export get_octet(uchar *out, octet_generator_t *ogen)
idaman bool ida_export patch_qword(ea_t ea, uint64 x)
Patch a qword of the program.
bool bytes_match_for_bin_search(uchar c1, uchar c2, const uchar *mask, int i, int bin_search_flags)
Definition bytes.hpp:2471
idaman hidden_range_t *ida_export get_first_hidden_range(void)
Get pointer to the first hidden range.
idaman ea_t ida_export next_addr(ea_t ea)
Get next address in the program (i.e.
idaman void ida_export put_qword(ea_t ea, uint64 x)
Set value of one qword (8 bytes) of the program.
flags64_t idaapi get_flags32(ea_t ea)
Get only 32 low bits of flags.
Definition bytes.hpp:296
idaman hidden_range_t *ida_export get_next_hidden_range(ea_t ea)
Get pointer to next hidden range.
idaman ushort ida_export get_word(ea_t ea)
Get one word (16-bit) of the program at 'ea'.
bool is_visible_finally(ea_t ea)
Is the address visible on the screen (not hidden)?
idaman ea_t ida_export use_mapping(ea_t ea)
Translate address according to current mappings.
ea_t idaapi prev_unknown(ea_t ea, ea_t minea)
Similar to prev_that(), but will find the previous address that is unexplored.
Definition bytes.hpp:154
idaman ssize_t ida_export get_bytes(void *buf, ssize_t size, ea_t ea, int gmb_flags=0, void *mask=nullptr)
Get the specified number of bytes of the program into the buffer.
idaman bool ida_export detach_custom_data_format(int dtid, int dfid)
Attach the data format to the data type.
idaman ssize_t ida_export get_manual_insn(qstring *buf, ea_t ea)
Retrieve the user-specified string for the manual instruction.
idaman int ida_export find_custom_data_type(const char *name)
Get id of a custom data type.
idaman void ida_export put_word(ea_t ea, uint64 x)
Set value of one word of the program.
idaman uchar ida_export get_db_byte(ea_t ea)
Get one byte (8-bit) of the program at 'ea' from the database.
idaman size_t ida_export get_mappings_qty(void)
Get number of mappings.
idaman bool ida_export get_mapping(ea_t *from, ea_t *to, asize_t *size, size_t n)
Get memory mapping range by its number.
ea_t adjust_visea(ea_t ea)
Adjust the address and get the nearest visible address.
asize_t get_item_size(ea_t ea)
Get size of item (instruction/data) in bytes.
Definition bytes.hpp:266
idaman void ida_export patch_bytes(ea_t ea, const void *buf, size_t size)
Patch the specified number of bytes of the program.
idaman bool ida_export unregister_custom_data_type(int dtid)
Unregister a data type.
idaman opinfo_t *ida_export get_opinfo(opinfo_t *buf, ea_t ea, int n, flags64_t flags)
Get additional information about an operand representation.
idaman bool ida_export get_item_refinfo(refinfo_t *ri, ea_t ea, int n)
Get refinfo of the item at 'ea'.
idaman asize_t ida_export get_possible_item_varsize(ea_t ea, const tinfo_t &tif)
Return the possible size of the item at EA of type TIF if TIF is the variable structure.
idaman bool ida_export patch_dword(ea_t ea, uint64 x)
Patch a dword of the program.
flags64_t idaapi get_full_flags(ea_t ea)
Get full flags value for address 'ea'.
Definition bytes.hpp:311
idaman ea_t ida_export prev_that(ea_t ea, ea_t minea, testf_t *testf, void *ud=nullptr)
Find previous address with a flag satisfying the function 'testf'.
idaman bool ida_export patch_byte(ea_t ea, uint64 x)
Patch a byte of the program.
idaman flags64_t ida_export get_item_flag(ea_t from, int n, ea_t ea, bool appzero)
Get flag of the item at 'ea' even if it is a tail byte of some array or structure.
idaman int ida_export get_custom_data_formats(intvec_t *out, int dtid)
Get list of attached custom data formats for the specified data type.
ea_t idaapi next_unknown(ea_t ea, ea_t maxea)
Similar to next_that(), but will find the next address that is unexplored.
Definition bytes.hpp:130
idaman ea_t ida_export prev_visea(ea_t ea)
Get previous visible address.
idaman hidden_range_t *ida_export get_hidden_range(ea_t ea)
Get pointer to hidden range structure, in: linear address.
idaman ssize_t ida_export get_strlit_contents(qstring *utf8, ea_t ea, size_t len, int32 type, size_t *maxcps=nullptr, int flags=0)
Get contents of string literal, as UTF-8-encoded codepoints.
idaman bool ida_export can_define_item(ea_t ea, asize_t length, flags64_t flags)
Can define item (instruction/data) of the specified 'length', starting at 'ea'?
idaman ea_t ida_export find_byte(ea_t sEA, asize_t size, uchar value, int bin_search_flags)
Find forward a byte with the specified value (only 8-bit value from the database).
idaman ea_t ida_export prev_addr(ea_t ea)
Get previous address in the program.
idaman ea_t ida_export prev_not_tail(ea_t ea)
Get address of previous non-tail byte.
THREAD_SAFE ssize_t get_hex_string(char *buf, size_t bufsize, const uchar *bytes, size_t len)
Definition bytes.hpp:2707
idaman error_t ida_export enable_flags(ea_t start_ea, ea_t end_ea, storage_type_t stt)
Allocate flags for address range.
ea_t idaapi prev_inited(ea_t ea, ea_t minea)
Find the previous initialized address.
Definition bytes.hpp:2437
idaman bool ida_export patch_word(ea_t ea, uint64 x)
Patch a word of the program.
idaman uint64 ida_export get_original_qword(ea_t ea)
Get original qword value (that was before patching) This function DOESN'T work for wide byte processo...
idaman hidden_range_t *ida_export get_prev_hidden_range(ea_t ea)
Get pointer to previous hidden range.
idaman asize_t ida_export chunk_size(ea_t ea)
Get size of the contiguous address block containing 'ea'.
idaman bool ida_export add_mapping(ea_t from, ea_t to, asize_t size)
IDA supports memory mapping.
idaman int ida_export is_varsize_item(ea_t ea, flags64_t F, const opinfo_t *ti=nullptr, asize_t *itemsize=nullptr)
Is the item at 'ea' variable size?
idaman int ida_export get_hidden_range_qty(void)
Get number of hidden ranges.
DECLARE_TYPE_AS_MOVABLE(compiled_binpat_t)
idaman bool ida_export equal_bytes(ea_t ea, const uchar *image, const uchar *mask, size_t len, int bin_search_flags)
Compare 'len' bytes of the program starting from 'ea' with 'image'.
idaman int ida_export get_hidden_range_num(ea_t ea)
Get number of a hidden range.
idaman bool ida_export del_items(ea_t ea, int flags=0, asize_t nbytes=1, may_destroy_cb_t *may_destroy=nullptr)
Convert item (instruction/data) to unexplored bytes.
idaman uint64 ida_export get_original_byte(ea_t ea)
Get original byte value (that was before patching).
idaman ea_t ida_export bin_search(ea_t start_ea, ea_t end_ea, const compiled_binpat_vec_t &data, int flags, size_t *out_matched_idx=nullptr)
Search for a pattern in the program.
idaman const data_format_t *ida_export get_custom_data_format(int dfid)
Get definition of a registered custom data format.
idaman error_t ida_export disable_flags(ea_t start_ea, ea_t end_ea)
Deallocate flags for address range.
idaman uint64 ida_export get_wide_dword(ea_t ea)
Get two wide words (4 'bytes') of the program at 'ea'.
idaman int ida_export register_custom_data_format(const data_format_t *dtform)
Register a new data format.
idaman bool ida_export get_data_value(uval_t *v, ea_t ea, asize_t size)
Get the value at of the item at 'ea'.
idaman bool ida_export print_strlit_type(qstring *out, int32 strtype, qstring *out_tooltip=nullptr, int flags=0)
Get string type information: the string type name (possibly decorated with hotkey markers),...
idaman bool ida_export is_manual_insn(ea_t ea)
Is the instruction overridden?
idaman uint64 ida_export get_qword(ea_t ea)
Get one qword (64-bit) of the program at 'ea'.
idaman void ida_export add_qword(ea_t ea, uint64 value)
Add a value to one qword of the program.
idaman void ida_export add_word(ea_t ea, uint64 value)
Add a value to one word of the program.
idaman ssize_t ida_export get_cmt(qstring *buf, ea_t ea, bool rptble)
Get an indented comment.
idaman void ida_export put_bytes(ea_t ea, const void *buf, size_t size)
Modify the specified number of bytes of the program.
idaman void ida_export put_dword(ea_t ea, uint64 x)
Set value of one dword of the program.
idaman bool ida_export put_byte(ea_t ea, uint64 x)
Set value of one byte of the program.
idaman ea_t ida_export next_visea(ea_t ea)
Get next visible address.
idaman ea_t ida_export find_binary(ea_t startea, ea_t endea, const char *ubinstr, int radix, int sflag, int strlits_encoding=0)
idaman bool ida_export update_hidden_range(const hidden_range_t *ha)
Update hidden range information in the database.
idaman const data_type_t *ida_export get_custom_data_type(int dtid)
Get definition of a registered custom data type.
idaman int ida_export register_custom_data_type(const data_type_t *dtinfo)
Register a new data type.
idaman ea_t ida_export calc_max_item_end(ea_t ea, int how=15)
Calculate maximal reasonable end address of a new item.
idaman bool ida_export leading_zero_important(ea_t ea, int n)
Check if leading zeroes are important.
idaman bool ida_export set_cmt(ea_t ea, const char *comm, bool rptble)
Set an indented comment.
idaman ea_t ida_export chunk_start(ea_t ea)
Get start of the contiguous address block containing 'ea'.
idaman bool ida_export add_hidden_range(ea_t ea1, ea_t ea2, const char *description, const char *header, const char *footer, bgcolor_t color=DEFCOLOR)
Mark a range of addresses as hidden.
flags64_t idaapi get_flags(ea_t ea)
Get flags value for address 'ea'.
Definition bytes.hpp:304
idaman bool ida_export create_strlit(ea_t start, size_t len, int32 strtype)
Convert to string literal and give a meaningful name.
idaman bool ida_export append_cmt(ea_t ea, const char *str, bool rptble)
Append to an indented comment.
idaman ea_t ida_export get_item_end(ea_t ea)
Get the end address of the item at 'ea'.
idaman bool ida_export get_zero_ranges(rangeset_t *zranges, const range_t *range)
Return set of ranges with zero initialized bytes.
bool is_first_visea(ea_t ea)
Is an address the first visible address?
idaman void ida_export add_byte(ea_t ea, uint32 value)
Add a value to one byte of the program.
idaman int ida_export get_custom_data_types(intvec_t *out, asize_t min_size=0, asize_t max_size=BADADDR)
Get list of registered custom data type ids.
ea_t idaapi next_inited(ea_t ea, ea_t maxea)
Find the next initialized address.
Definition bytes.hpp:2427
idaman ea_t ida_export next_chunk(ea_t ea)
Get the first address of next contiguous chunk in the program.
idaman ea_t ida_export next_that(ea_t ea, ea_t maxea, testf_t *testf, void *ud=nullptr)
Find next address with a flag satisfying the function 'testf'.
idaman int ida_export nbits(ea_t ea)
Get number of bits in a byte at the given address.
idaman hidden_range_t *ida_export getn_hidden_range(int n)
Get pointer to hidden range structure, in: number of hidden range.
idaman uint32 ida_export get_dword(ea_t ea)
Get one dword (32-bit) of the program at 'ea'.
idaman bool ida_export unregister_custom_data_format(int dfid)
Unregister a data format.
idaman bool ida_export set_opinfo(ea_t ea, int n, flags64_t flag, const opinfo_t *ti, bool suppress_events=false)
Set additional information about an operand representation.
bool idaapi may_destroy_cb_t(ea_t)
del_items' callback function
Definition bytes.hpp:817
idaman uint64 ida_export get_wide_byte(ea_t ea)
Get one wide byte of the program at 'ea'.
idaman ea_t ida_export next_head(ea_t ea, ea_t maxea)
Get start of next defined item.
bool idaapi testf_t(flags64_t flags, void *ud)
Flag tester - see next_that(), prev_that()
Definition bytes.hpp:109
idaman ea_t ida_export find_free_chunk(ea_t start, asize_t size, asize_t alignment)
Search for a hole in the addressing space of the program.
idaman void ida_export set_manual_insn(ea_t ea, const char *manual_insn)
Set manual instruction string.
idaman void ida_export del_value(ea_t ea)
Delete byte value from flags.
idaman bool ida_export is_loaded(ea_t ea)
Does the specified address have a byte value (is initialized?)
idaman uint64 ida_export get_original_dword(ea_t ea)
Get original dword (that was before patching) This function works for wide byte processors too.
idaman int ida_export find_custom_data_format(const char *name)
Get id of a custom data format.
idaman ea_t ida_export find_byter(ea_t sEA, asize_t size, uchar value, int bin_search_flags)
Find reverse a byte with the specified value (only 8-bit value from the database).
idaman flags64_t ida_export get_flags_ex(ea_t ea, int how)
Get flags for the specified address, extended form.
idaman ea_t ida_export next_not_tail(ea_t ea)
Get address of next non-tail byte.
idaman int ida_export visit_patched_bytes(ea_t ea1, ea_t ea2, int(idaapi *cb)(ea_t ea, qoff64_t fpos, uint64 o, uint64 v, void *ud), void *ud=nullptr)
Visit all the patched bytes one byte at a time.
idaman ssize_t ida_export get_predef_insn_cmt(qstring *buf, const insn_t &ins)
Get predefined comment.
idaman bool ida_export revert_byte(ea_t ea)
Revert patched byte.
asize_t get_full_data_elsize(ea_t ea, flags64_t F, const opinfo_t *ti=nullptr)
Get full size of data type specified in flags 'F'.
Definition bytes.hpp:1880
idaman error_t ida_export change_storage_type(ea_t start_ea, ea_t end_ea, storage_type_t stt)
Change flag storage type for address range.
idaman void ida_export del_mapping(ea_t ea)
Delete memory mapping range.
bool is_last_visea(ea_t ea)
Is an address the last visible address?
idaman ea_t ida_export prev_chunk(ea_t ea)
Get the last address of previous contiguous chunk in the program.
idaman uint64 ida_export get_wide_word(ea_t ea)
Get one wide word (2 'byte') of the program at 'ea'.
idaman uint64 ida_export get_original_word(ea_t ea)
Get original word value (that was before patching).
Vector of bytes (use for dynamic memory)
Definition pro.h:3773
bytevec_t & append(const void *buf, size_t sz)
Append bytes to the bytevec.
Definition pro.h:3782
Reimplementation of vector class from STL.
Definition pro.h:2250
void push_back(T &&x)
Append a new element to the end the qvector with a move semantics.
Definition pro.h:2361
Primary mechanism for managing type information.
Definition typeinf.hpp:3046
THREAD_SAFE bool idaapi is_func(flags64_t F)
Is function start?
Definition bytes.hpp:1969
THREAD_SAFE bool idaapi has_immd(flags64_t F)
Has immediate value?
Definition bytes.hpp:1964
idaman bool ida_export set_immd(ea_t ea)
Set 'has immediate operand' flag.
idaman flags64_t ida_export get_flags_by_size(size_t size)
Get flags from size (in bytes).
constexpr flags64_t idaapi align_flag(void)
Get a flags64_t representing an alignment directive.
Definition bytes.hpp:1505
THREAD_SAFE constexpr bool idaapi is_struct(flags64_t F)
FF_STRUCT
Definition bytes.hpp:1522
THREAD_SAFE constexpr bool idaapi is_float(flags64_t F)
FF_FLOAT
Definition bytes.hpp:1518
constexpr flags64_t idaapi word_flag(void)
Get a flags64_t representing a word.
Definition bytes.hpp:1495
THREAD_SAFE constexpr bool idaapi is_custom(flags64_t F)
FF_CUSTOM
Definition bytes.hpp:1524
THREAD_SAFE constexpr bool idaapi f_is_strlit(flags64_t F, void *)
See is_strlit()
Definition bytes.hpp:1536
constexpr flags64_t idaapi cust_flag(void)
Get a flags64_t representing custom type data.
Definition bytes.hpp:1504
THREAD_SAFE constexpr bool idaapi is_oword(flags64_t F)
FF_OWORD
Definition bytes.hpp:1514
THREAD_SAFE constexpr bool idaapi is_pack_real(flags64_t F)
FF_PACKREAL
Definition bytes.hpp:1520
THREAD_SAFE constexpr bool idaapi is_yword(flags64_t F)
FF_YWORD
Definition bytes.hpp:1515
THREAD_SAFE constexpr bool idaapi is_double(flags64_t F)
FF_DOUBLE
Definition bytes.hpp:1519
THREAD_SAFE constexpr bool idaapi f_is_qword(flags64_t F, void *)
See is_qword()
Definition bytes.hpp:1529
THREAD_SAFE constexpr bool idaapi is_word(flags64_t F)
FF_WORD
Definition bytes.hpp:1511
constexpr flags64_t idaapi dword_flag(void)
Get a flags64_t representing a double word.
Definition bytes.hpp:1496
THREAD_SAFE constexpr bool idaapi f_is_tbyte(flags64_t F, void *)
See is_tbyte()
Definition bytes.hpp:1532
constexpr flags64_t idaapi tbyte_flag(void)
Get a flags64_t representing a tbyte.
Definition bytes.hpp:1501
THREAD_SAFE constexpr bool idaapi is_tbyte(flags64_t F)
FF_TBYTE
Definition bytes.hpp:1517
THREAD_SAFE constexpr bool idaapi f_is_oword(flags64_t F, void *)
See is_oword()
Definition bytes.hpp:1530
constexpr flags64_t idaapi byte_flag(void)
Get a flags64_t representing a byte.
Definition bytes.hpp:1494
THREAD_SAFE constexpr bool idaapi is_zword(flags64_t F)
FF_ZWORD
Definition bytes.hpp:1516
THREAD_SAFE constexpr bool idaapi f_is_double(flags64_t F, void *)
See is_double()
Definition bytes.hpp:1534
THREAD_SAFE constexpr bool idaapi f_is_word(flags64_t F, void *)
See is_word()
Definition bytes.hpp:1527
constexpr flags64_t idaapi qword_flag(void)
Get a flags64_t representing a quad word.
Definition bytes.hpp:1497
THREAD_SAFE constexpr bool idaapi is_qword(flags64_t F)
FF_QWORD
Definition bytes.hpp:1513
constexpr flags64_t idaapi packreal_flag(void)
Get a flags64_t representing a packed decimal real.
Definition bytes.hpp:1508
constexpr flags64_t idaapi stru_flag(void)
Get a flags64_t representing a struct.
Definition bytes.hpp:1503
constexpr flags64_t idaapi float_flag(void)
Get a flags64_t representing a float.
Definition bytes.hpp:1506
THREAD_SAFE constexpr bool idaapi f_is_dword(flags64_t F, void *)
See is_dword()
Definition bytes.hpp:1528
THREAD_SAFE constexpr bool idaapi f_is_float(flags64_t F, void *)
See is_float()
Definition bytes.hpp:1533
constexpr flags64_t idaapi yword_flag(void)
Get a flags64_t representing a ymm word.
Definition bytes.hpp:1499
constexpr flags64_t idaapi zword_flag(void)
Get a flags64_t representing a zmm word.
Definition bytes.hpp:1500
THREAD_SAFE constexpr bool idaapi is_strlit(flags64_t F)
FF_STRLIT
Definition bytes.hpp:1521
THREAD_SAFE constexpr bool idaapi f_is_struct(flags64_t F, void *)
See is_struct()
Definition bytes.hpp:1537
THREAD_SAFE constexpr bool idaapi f_is_custom(flags64_t F, void *)
See is_custom()
Definition bytes.hpp:1539
constexpr flags64_t idaapi oword_flag(void)
Get a flags64_t representing a octaword.
Definition bytes.hpp:1498
constexpr flags64_t idaapi code_flag(void)
FF_CODE
Definition bytes.hpp:1493
THREAD_SAFE constexpr bool idaapi is_dword(flags64_t F)
FF_DWORD
Definition bytes.hpp:1512
THREAD_SAFE constexpr bool idaapi is_same_data_type(flags64_t F1, flags64_t F2)
Do the given flags specify the same data type?
Definition bytes.hpp:1544
constexpr flags64_t idaapi double_flag(void)
Get a flags64_t representing a double.
Definition bytes.hpp:1507
THREAD_SAFE constexpr bool idaapi is_align(flags64_t F)
FF_ALIGN
Definition bytes.hpp:1523
THREAD_SAFE constexpr bool idaapi f_is_align(flags64_t F, void *)
See is_align()
Definition bytes.hpp:1538
THREAD_SAFE constexpr bool idaapi f_is_byte(flags64_t F, void *)
See is_byte()
Definition bytes.hpp:1526
THREAD_SAFE constexpr bool idaapi f_is_pack_real(flags64_t F, void *)
See is_pack_real()
Definition bytes.hpp:1535
THREAD_SAFE constexpr bool idaapi f_is_yword(flags64_t F, void *)
See is_yword()
Definition bytes.hpp:1531
THREAD_SAFE constexpr bool idaapi is_byte(flags64_t F)
FF_BYTE
Definition bytes.hpp:1510
constexpr flags64_t idaapi strlit_flag(void)
Get a flags64_t representing a string literal.
Definition bytes.hpp:1502
bool idaapi create_word(ea_t ea, asize_t length, bool force=false)
Convert to word.
Definition bytes.hpp:1587
idaman bool ida_export create_data(ea_t ea, flags64_t dataflag, asize_t size, tid_t tid)
Convert to data (byte, word, dword, etc).
bool idaapi create_struct(ea_t ea, asize_t length, tid_t tid, bool force=false)
Convert to struct.
Definition bytes.hpp:1637
bool idaapi create_yword(ea_t ea, asize_t length, bool force=false)
Convert to ymm word.
Definition bytes.hpp:1607
idaman int ida_export calc_def_align(ea_t ea, int mina, int maxa)
Calculate the default alignment exponent.
idaman int ida_export calc_min_align(asize_t length)
Calculate the minimal possible alignment exponent.
idaman bool ida_export create_align(ea_t ea, asize_t length, int alignment)
Create an alignment item.
bool idaapi create_qword(ea_t ea, asize_t length, bool force=false)
Convert to quadword.
Definition bytes.hpp:1597
bool idaapi create_double(ea_t ea, asize_t length, bool force=false)
Convert to double.
Definition bytes.hpp:1627
THREAD_SAFE flags64_t idaapi calc_dflags(flags64_t f, bool force)
Definition bytes.hpp:1580
bool idaapi create_byte(ea_t ea, asize_t length, bool force=false)
Convert to byte.
Definition bytes.hpp:1582
bool idaapi create_dword(ea_t ea, asize_t length, bool force=false)
Convert to dword.
Definition bytes.hpp:1592
bool idaapi create_oword(ea_t ea, asize_t length, bool force=false)
Convert to octaword/xmm word.
Definition bytes.hpp:1602
bool idaapi create_float(ea_t ea, asize_t length, bool force=false)
Convert to float.
Definition bytes.hpp:1622
idaman int ida_export calc_max_align(ea_t endea)
Calculate the maximal possible alignment exponent.
bool idaapi create_packed_real(ea_t ea, asize_t length, bool force=false)
Convert to packed decimal real.
Definition bytes.hpp:1632
bool idaapi create_custdata(ea_t ea, asize_t length, int dtid, int fid, bool force=false)
Convert to custom data type.
Definition bytes.hpp:1642
bool idaapi create_zword(ea_t ea, asize_t length, bool force=false)
Convert to zmm word.
Definition bytes.hpp:1612
idaman bool ida_export create_32bit_data(ea_t ea, asize_t length)
Convert to 32-bit quantity (take the byte size into account)
idaman bool ida_export create_16bit_data(ea_t ea, asize_t length)
Convert to 16-bit quantity (take the byte size into account)
bool idaapi create_tbyte(ea_t ea, asize_t length, bool force=false)
Convert to tbyte.
Definition bytes.hpp:1617
idaman bool ida_export op_stroff(const insn_t &insn, int n, const tid_t *path, int path_len, adiff_t delta)
Set operand representation to be 'struct offset'.
idaman int ida_export get_stroff_path(tid_t *path, adiff_t *delta, ea_t ea, int n)
Get struct path of operand.
idaman int ida_export get_radix(flags64_t F, int n)
Get radix of the operand, in: flags.
idaman ssize_t ida_export get_forced_operand(qstring *buf, ea_t ea, int n)
Get forced operand.
idaman bool ida_export op_based_stroff(const insn_t &insn, int n, adiff_t opval, ea_t base)
Set operand representation to be 'struct offset' if the operand likely points to a structure member.
constexpr flags64_t idaapi combine_flags(flags64_t F)
Definition bytes.hpp:1385
idaman bool ida_export set_forced_operand(ea_t ea, int n, const char *op)
Set forced operand.
idaman bool ida_export is_forced_operand(ea_t ea, int n)
Is operand manually defined?
constexpr flags64_t get_operand_flag(uint8 typebits, int n)
Place operand n's type flag in the right nibble of a 64-bit flags set.
Definition bytes.hpp:1087
idaman bool ida_export set_op_type(ea_t ea, flags64_t type, int n)
(internal function) change representation of operand(s).
idaman bool ida_export op_adds_xrefs(flags64_t F, int n)
Should processor module create xrefs from the operand?
constexpr bool is_flag_for_operand(flags64_t F, uint8 typebits, int n)
Check that the 64-bit flags set has the expected type for operand n.
Definition bytes.hpp:1100
idaman bool ida_export op_stkvar(ea_t ea, int n)
Set operand representation to be 'stack variable'.
idaman bool ida_export clr_op_type(ea_t ea, int n)
Remove operand representation information.
idaman int ida_export get_default_radix(void)
Get default base of number for the current processor.
idaman bool ida_export op_enum(ea_t ea, int n, tid_t id, uchar serial=0)
Set operand representation to be enum type If applied to unexplored bytes, converts them to 16/32bit ...
idaman bool ida_export op_seg(ea_t ea, int n)
Set operand representation to be 'segment'.
idaman bool ida_export op_custfmt(ea_t ea, int n, int fid)
Set custom data format for operand (fid-custom data format id)
idaman tid_t ida_export get_enum_id(uchar *serial, ea_t ea, int n)
Get enum id of 'enum' operand.
constexpr int get_operand_type_shift(uint32 n)
Get the shift in flags64_t for the nibble representing operand n's type.
Definition bytes.hpp:1075
THREAD_SAFE constexpr bool idaapi is_custfmt0(flags64_t F)
Does the first operand use a custom data representation?
Definition bytes.hpp:1190
THREAD_SAFE constexpr bool idaapi is_stkvar1(flags64_t F)
Is the second operand a stack variable?
Definition bytes.hpp:1175
THREAD_SAFE constexpr bool idaapi is_custfmt1(flags64_t F)
Does the second operand use a custom data representation?
Definition bytes.hpp:1195
THREAD_SAFE constexpr bool idaapi is_enum1(flags64_t F)
Is the second operand a symbolic constant (enum member)?
Definition bytes.hpp:1155
THREAD_SAFE constexpr bool idaapi is_defarg1(flags64_t F)
Is the second operand defined? Initially operand has no defined representation.
Definition bytes.hpp:1115
idaman bool ida_export is_numop0(flags64_t F)
Is the first operand a number (i.e. binary, octal, decimal or hex?)
THREAD_SAFE constexpr bool idaapi is_off0(flags64_t F)
Is the first operand offset? (example: push offset xxx)
Definition bytes.hpp:1120
THREAD_SAFE constexpr bool idaapi is_stroff1(flags64_t F)
Is the second operand an offset within a struct?
Definition bytes.hpp:1165
THREAD_SAFE constexpr bool idaapi is_float0(flags64_t F)
Is the first operand a floating point number?
Definition bytes.hpp:1180
THREAD_SAFE constexpr bool idaapi is_stroff0(flags64_t F)
Is the first operand an offset within a struct?
Definition bytes.hpp:1160
THREAD_SAFE constexpr flags64_t get_optype_flags1(flags64_t F)
Get flags for second operand.
Definition bytes.hpp:1215
THREAD_SAFE constexpr bool idaapi is_stkvar0(flags64_t F)
Is the first operand a stack variable?
Definition bytes.hpp:1170
idaman bool ida_export is_numop1(flags64_t F)
Is the second operand a number (i.e. binary, octal, decimal or hex?)
THREAD_SAFE constexpr bool idaapi is_defarg0(flags64_t F)
Is the first operand defined? Initially operand has no defined representation.
Definition bytes.hpp:1110
THREAD_SAFE constexpr flags64_t get_optype_flags0(flags64_t F)
Get flags for first operand.
Definition bytes.hpp:1210
THREAD_SAFE constexpr bool idaapi is_float1(flags64_t F)
Is the second operand a floating point number?
Definition bytes.hpp:1185
THREAD_SAFE constexpr bool idaapi is_char1(flags64_t F)
Is the second operand character constant? (example: mov al, 'a')
Definition bytes.hpp:1135
THREAD_SAFE constexpr bool idaapi is_seg1(flags64_t F)
Is the second operand segment selector? (example: mov dx, seg dseg)
Definition bytes.hpp:1145
THREAD_SAFE constexpr bool idaapi is_off1(flags64_t F)
Is the second operand offset? (example: mov ax, offset xxx)
Definition bytes.hpp:1125
THREAD_SAFE constexpr bool idaapi is_seg0(flags64_t F)
Is the first operand segment selector? (example: push seg seg001)
Definition bytes.hpp:1140
THREAD_SAFE constexpr bool idaapi is_enum0(flags64_t F)
Is the first operand a symbolic constant (enum member)?
Definition bytes.hpp:1150
THREAD_SAFE constexpr bool idaapi is_char0(flags64_t F)
Is the first operand character constant? (example: push 'a')
Definition bytes.hpp:1130
idaman bool ida_export is_enum(flags64_t F, int n)
is enum?
idaman bool ida_export is_defarg(flags64_t F, int n)
is defined?
idaman bool ida_export is_stroff(flags64_t F, int n)
is struct offset?
idaman bool ida_export is_seg(flags64_t F, int n)
is segment?
idaman bool ida_export is_manual(flags64_t F, int n)
is forced operand? (use is_forced_operand())
idaman bool ida_export is_off(flags64_t F, int n)
is offset?
idaman bool ida_export is_stkvar(flags64_t F, int n)
is stack variable?
idaman bool ida_export is_numop(flags64_t F, int n)
is number (bin, oct, dec, hex)?
idaman bool ida_export is_suspop(ea_t ea, flags64_t F, int n)
is suspicious operand?
idaman bool ida_export is_char(flags64_t F, int n)
is character constant?
idaman bool ida_export is_fltnum(flags64_t F, int n)
is floating point number?
idaman bool ida_export is_custfmt(flags64_t F, int n)
is custom data format?
constexpr flags64_t idaapi flt_flag(void)
see FF_opbits
Definition bytes.hpp:1407
constexpr flags64_t idaapi enum_flag(void)
see FF_opbits
Definition bytes.hpp:1404
constexpr flags64_t idaapi custfmt_flag(void)
see FF_opbits
Definition bytes.hpp:1408
constexpr flags64_t idaapi seg_flag(void)
see FF_opbits
Definition bytes.hpp:1409
constexpr flags64_t idaapi stroff_flag(void)
see FF_opbits
Definition bytes.hpp:1405
constexpr flags64_t idaapi off_flag(void)
see FF_opbits
Definition bytes.hpp:1403
constexpr flags64_t idaapi hex_flag(void)
Get number flag of the base, regardless of current processor - better to use num_flag()
Definition bytes.hpp:1413
constexpr flags64_t idaapi bin_flag(void)
Get number flag of the base, regardless of current processor - better to use num_flag()
Definition bytes.hpp:1416
idaman flags64_t ida_export num_flag(void)
Get number of default base (bin, oct, dec, hex)
constexpr flags64_t idaapi oct_flag(void)
Get number flag of the base, regardless of current processor - better to use num_flag()
Definition bytes.hpp:1415
constexpr flags64_t idaapi dec_flag(void)
Get number flag of the base, regardless of current processor - better to use num_flag()
Definition bytes.hpp:1414
constexpr flags64_t idaapi char_flag(void)
see FF_opbits
Definition bytes.hpp:1402
constexpr flags64_t idaapi stkvar_flag(void)
see FF_opbits
Definition bytes.hpp:1406
bool idaapi op_oct(ea_t ea, int n)
set op type to oct_flag()
Definition bytes.hpp:1434
bool idaapi op_hex(ea_t ea, int n)
set op type to hex_flag()
Definition bytes.hpp:1432
bool idaapi op_num(ea_t ea, int n)
set op type to num_flag()
Definition bytes.hpp:1431
bool idaapi op_dec(ea_t ea, int n)
set op type to dec_flag()
Definition bytes.hpp:1433
bool idaapi op_flt(ea_t ea, int n)
set op type to flt_flag()
Definition bytes.hpp:1436
bool idaapi op_chr(ea_t ea, int n)
set op type to char_flag()
Definition bytes.hpp:1430
bool idaapi op_bin(ea_t ea, int n)
set op type to bin_flag()
Definition bytes.hpp:1435
THREAD_SAFE constexpr bool idaapi is_tail(flags64_t F)
Does flag denote tail byte?
Definition bytes.hpp:797
THREAD_SAFE constexpr bool idaapi f_is_head(flags64_t F, void *)
Does flag denote start of instruction OR data?
Definition bytes.hpp:811
THREAD_SAFE constexpr bool idaapi f_is_tail(flags64_t F, void *)
Does flag denote tail byte?
Definition bytes.hpp:798
THREAD_SAFE constexpr bool idaapi is_head(flags64_t F)
Does flag denote start of instruction OR data?
Definition bytes.hpp:810
THREAD_SAFE constexpr bool idaapi is_not_tail(flags64_t F)
Does flag denote tail byte?
Definition bytes.hpp:799
THREAD_SAFE constexpr bool idaapi is_data(flags64_t F)
Does flag denote start of data?
Definition bytes.hpp:791
THREAD_SAFE constexpr bool idaapi f_is_data(flags64_t F, void *)
Does flag denote start of data?
Definition bytes.hpp:792
THREAD_SAFE constexpr bool idaapi f_is_code(flags64_t F, void *)
Does flag denote start of an instruction?
Definition bytes.hpp:786
THREAD_SAFE constexpr bool idaapi is_unknown(flags64_t F)
Does flag denote unexplored byte?
Definition bytes.hpp:805
THREAD_SAFE constexpr bool idaapi is_code(flags64_t F)
Does flag denote start of an instruction?
Definition bytes.hpp:785
THREAD_SAFE constexpr bool idaapi f_is_not_tail(flags64_t F, void *)
Does flag denote tail byte?
Definition bytes.hpp:800
THREAD_SAFE constexpr bool idaapi has_auto_name(flags64_t F)
Does the current byte have auto-generated (no special prefix) name?
Definition bytes.hpp:949
idaman bool ida_export is_bnot(ea_t ea, flags64_t F, int n)
Should we negate the operand?
idaman bool ida_export is_lzero(ea_t ea, int n)
Display leading zeroes?
THREAD_SAFE constexpr bool idaapi has_dummy_name(flags64_t F)
Does the current byte have dummy (auto-generated, with special prefix) name?
Definition bytes.hpp:943
THREAD_SAFE constexpr bool idaapi has_cmt(flags64_t F)
Does the current byte have an indented comment?
Definition bytes.hpp:923
THREAD_SAFE constexpr bool idaapi f_has_xref(flags64_t f, void *)
Does the current byte have cross-references to it?
Definition bytes.hpp:929
idaman bool ida_export toggle_bnot(ea_t ea, int n)
Toggle binary negation of operand. also see is_bnot()
THREAD_SAFE constexpr bool idaapi f_has_cmt(flags64_t f, void *)
Definition bytes.hpp:924
bool idaapi toggle_lzero(ea_t ea, int n)
Toggle lzero bit.
Definition bytes.hpp:1027
THREAD_SAFE constexpr bool idaapi f_has_name(flags64_t f, void *)
Does the current byte have non-trivial (non-dummy) name?
Definition bytes.hpp:935
THREAD_SAFE constexpr bool idaapi is_flow(flags64_t F)
Does the previous instruction exist and pass execution flow to the current byte?
Definition bytes.hpp:913
THREAD_SAFE constexpr bool idaapi f_has_extra_cmts(flags64_t f, void *)
Definition bytes.hpp:919
THREAD_SAFE constexpr bool idaapi has_user_name(flags64_t F)
Does the current byte have user-specified name?
Definition bytes.hpp:959
THREAD_SAFE constexpr bool idaapi has_name(flags64_t F)
Does the current byte have non-trivial (non-dummy) name?
Definition bytes.hpp:934
THREAD_SAFE constexpr bool idaapi f_has_dummy_name(flags64_t f, void *)
Does the current byte have dummy (auto-generated, with special prefix) name?
Definition bytes.hpp:944
idaman bool ida_export set_lzero(ea_t ea, int n)
Set toggle lzero bit.
THREAD_SAFE constexpr bool idaapi has_any_name(flags64_t F)
Does the current byte have any name?
Definition bytes.hpp:954
idaman bool ida_export is_invsign(ea_t ea, flags64_t F, int n)
Should sign of n-th operand inverted during output?
THREAD_SAFE constexpr bool idaapi f_has_user_name(flags64_t F, void *)
Does the current byte have user-specified name?
Definition bytes.hpp:960
THREAD_SAFE constexpr bool idaapi has_xref(flags64_t F)
Does the current byte have cross-references to it?
Definition bytes.hpp:928
THREAD_SAFE constexpr bool idaapi has_extra_cmts(flags64_t F)
Does the current byte have additional anterior or posterior lines?
Definition bytes.hpp:918
idaman bool ida_export toggle_sign(ea_t ea, int n)
Toggle sign of n-th operand.
idaman bool ida_export clr_lzero(ea_t ea, int n)
Clear toggle lzero bit.
idaman const char * end
Definition pro.h:1001
idaman size_t n
Definition pro.h:997
const tinfo_t & type
Definition hexrays.hpp:7301
storage_type_t
Storage types for flag bits.
Definition ida.hpp:99
bool inf_is_wide_high_byte_first(void)
Definition ida.hpp:641
int nbytes
Definition kernwin.hpp:2861
uval_t uval_t
Definition kernwin.hpp:1878
idaman size_t len
Definition kernwin.hpp:1356
asize_t size
Definition kernwin.hpp:6339
size_t max_size
Definition kernwin.hpp:7958
High level functions that deal with the generation of the disassembled text lines.
unsigned __int64 uint64
Definition llong.hpp:13
Definitions of various information kept in netnodes.
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
qvector< int > intvec_t
vector of integers
Definition pro.h:2765
uint64 asize_t
Definition pro.h:423
uint32 bgcolor_t
background color in RGB
Definition pro.h:5012
int64 adiff_t
Definition pro.h:424
uint64 ea_t
Definition pro.h:421
int int32
signed 32 bit value
Definition pro.h:347
unsigned char uchar
unsigned 8 bit value
Definition pro.h:337
idaman size_t bufsize
Definition pro.h:600
int error_t
Error code (errno)
Definition pro.h:458
INLINE THREAD_SAFE int ida_local qtoupper(char c)
Get uppercase equivalent of given char.
Definition pro.h:952
uint64 flags64_t
64-bit flags for each address
Definition pro.h:5009
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
unsigned short ushort
unsigned 16 bit value
Definition pro.h:338
ea_t tid_t
type id (for enums, structs, etc)
Definition pro.h:5010
unsigned char uint8
unsigned 8 bit value
Definition pro.h:344
_qstring< char > qstring
regular string
Definition pro.h:3694
Contains the definition of range_t.
Definition bytes.hpp:2308
rangevec_t strlits
Definition bytes.hpp:2311
bytevec_t mask
Definition bytes.hpp:2310
bytevec_t bytes
Definition bytes.hpp:2309
bool operator==(const compiled_binpat_t &r) const
Definition bytes.hpp:2318
void qclear()
Definition bytes.hpp:2316
bool all_bytes_defined() const
Definition bytes.hpp:2315
compiled_binpat_t()
Definition bytes.hpp:2314
int encidx
Definition bytes.hpp:2312
bool operator!=(const compiled_binpat_t &r) const
Definition bytes.hpp:2325
Information about a data format.
Definition bytes.hpp:2033
int32 text_width
Usual width of the text representation This value is used to calculate the width of the control to di...
Definition bytes.hpp:2046
bool(idaapi *print)(void *ud
Convert to colored string.
DECLARE_COMPARISONS(data_format_t)
bytevec_t const char * input
Definition bytes.hpp:2083
int props
properties (currently 0)
Definition bytes.hpp:2036
asize_t value_size
size of the value in bytes 0 means any size is ok data formats that are registered for standard types...
Definition bytes.hpp:2042
qstring const void asize_t ea_t current_ea
Definition bytes.hpp:2068
int32 cbsize
size of this structure
Definition bytes.hpp:2034
bool is_present_in_menus() const
Should this format be shown in UI menus.
Definition bytes.hpp:2052
qstring const void * value
Definition bytes.hpp:2066
const char * name
Format name, must be unique.
Definition bytes.hpp:2037
qstring const void asize_t ea_t int int dtid
Definition bytes.hpp:2070
bytevec_t const char ea_t int qstring * errstr
Definition bytes.hpp:2086
qstring * out
Definition bytes.hpp:2065
const char * menu_name
Visible format name to use in menus if nullptr, no menu item will be created.
Definition bytes.hpp:2038
bool(idaapi *scan)(void *ud
Convert from uncolored string.
void * ud
user-defined data to be passed to callbacks
Definition bytes.hpp:2035
qstring const void asize_t size
Definition bytes.hpp:2067
void(idaapi *analyze)(void *ud
Analyze custom data format occurrence This callback can be used to create xrefs from the current item...
const char * hotkey
Hotkey for the corresponding menu item if nullptr, no hotkey will be associated with the menu item.
Definition bytes.hpp:2040
qstring const void asize_t ea_t int operand_num
Definition bytes.hpp:2069
Information about a data type.
Definition bytes.hpp:1987
asize_t(idaapi *calc_item_size)(void *ud
This function is used to determine size of the (possible) item at 'ea'.
const char * asm_keyword
keyword to use for this type in the assembly if nullptr, the data type cannot be used in the listing ...
Definition bytes.hpp:1997
ea_t asize_t maxsize
Definition bytes.hpp:2024
int cbsize
size of this structure
Definition bytes.hpp:1988
const char * menu_name
Visible data type name to use in menus if nullptr, no menu item will be created.
Definition bytes.hpp:1993
ea_t ea
Definition bytes.hpp:2012
bool is_present_in_menus() const
Should this type be shown in UI menus.
Definition bytes.hpp:2004
DECLARE_COMPARISONS(data_type_t)
bool(idaapi *may_create_at)(void *ud
May create data?
void * ud
user-defined data to be passed to callbacks
Definition bytes.hpp:1989
int props
properties
Definition bytes.hpp:1990
const char * hotkey
Hotkey for the corresponding menu item if nullptr, no hotkey will be associated with the menu item.
Definition bytes.hpp:1995
ea_t size_t nbytes
Definition bytes.hpp:2013
asize_t value_size
size of the value in bytes
Definition bytes.hpp:2000
const char * name
name of the data type. must be unique
Definition bytes.hpp:1992
Hidden ranges - address ranges which can be replaced by their descriptions.
Definition bytes.hpp:2517
char * footer
footer lines to display if the range is expanded
Definition bytes.hpp:2520
bool visible
the range state
Definition bytes.hpp:2521
bgcolor_t color
range color
Definition bytes.hpp:2522
char * header
header lines to display if the range is expanded
Definition bytes.hpp:2519
char * description
description to display if the range is collapsed
Definition bytes.hpp:2518
Get 8 bits of the program at 'ea'.
Definition bytes.hpp:454
bool high_byte_first
Definition bytes.hpp:458
octet_generator_t(ea_t _ea)
Definition bytes.hpp:459
void invert_byte_order()
Definition bytes.hpp:460
DECLARE_COMPARISONS(octet_generator_t)
Definition bytes.hpp:462
ea_t ea
Definition bytes.hpp:456
uint64 value
Definition bytes.hpp:455
int avail_bits
Definition bytes.hpp:457
Base class for an range.
Definition range.hpp:35
range_t(ea_t ea1=0, ea_t ea2=0)
Definition range.hpp:39
Vector of range_t instances.
Definition range.hpp:93
Information about a reference.
Definition nalt.hpp:1010
Additional information about an operand type.
Definition nalt.hpp:1244