IDA C++ SDK 9.2
Loading...
Searching...
No Matches
ua.hpp
Go to the documentation of this file.
1/*
2 * Interactive disassembler (IDA).
3 * Copyright (c) 1990-2026 Hex-Rays
4 * ALL RIGHTS RESERVED.
5 *
6 */
7
8#ifndef _UA_HPP
9#define _UA_HPP
10
11#include <kernwin.hpp> // for btoa()
12#include <lines.hpp> // for colors
13#include <xref.hpp> // add_cref()
14#include <bytes.hpp> // get_byte(), ...
15
55
56struct procmod_t;
57struct processor_t;
58struct asm_t;
59
62
63//--------------------------------------------------------------------------
64// T Y P E O F O P E R A N D
65//--------------------------------------------------------------------------
66typedef uchar optype_t;
81const optype_t
82 o_void = 0,
83 o_reg = 1,
84 o_mem = 2,
89 o_displ = 4,
92 o_imm = 5,
93 o_far = 6,
94 o_near = 7,
103
154
155//--------------------------------------------------------------------------
156// O P E R A N D O F I N S T R U C T I O N
157//--------------------------------------------------------------------------
161
169class op_t
170{
171public:
172
175 uchar n = 0;
176
179
189 char offb = 0;
190
195 char offo = 0;
196
202#define OF_NO_BASE_DISP 0x80
206#define OF_OUTER_DISP 0x40
209#define PACK_FORM_DEF 0x20
211#define OF_NUMBER 0x10
212#define OF_SHOW 0x08
214
216 void set_shown() { flags |= OF_SHOW; }
218 void clr_shown() { flags &= ~OF_SHOW; }
220 bool shown() const { return (flags & OF_SHOW) != 0; }
221
230// from here..
231#define dt_byte 0
232#define dt_word 1
233#define dt_dword 2
234#define dt_float 3
235#define dt_double 4
236#define dt_tbyte 5
237#define dt_packreal 6
238// ...to here the order should not be changed, see mc68000
239#define dt_qword 7
240#define dt_byte16 8
241#define dt_code 9
242#define dt_void 10
243#define dt_fword 11
244#define dt_bitfild 12
245#define dt_string 13
246#define dt_unicode 14
247#define dt_ldbl 15
248#define dt_byte32 16
249#define dt_byte64 17
250#define dt_half 18
252
253 // REG
254 union
255 {
260 };
261
263 bool is_reg(int r) const { return type == o_reg && reg == r; }
264
265 // Next fields (value, addr) bytes are used by mc68k for some float types
266
267 // VALUE
268 union
269 {
277
280 struct
281 {
285 };
286
288 bool is_imm(uval_t v) const { return type == o_imm && value == v; }
289
290 // VIRTUAL ADDRESS (offset within the segment)
291 union
292 {
295
298 struct
299 {
300 uint16 low;
301 uint16 high;
303 };
304
305 // IDP SPECIFIC INFORMATION
306 union
307 {
311 struct
312 {
313 uint16 low;
314 uint16 high;
316 };
317
323 char specflag1 = 0;
324 char specflag2 = 0;
325 char specflag3 = 0;
326 char specflag4 = 0;
328
330 {
331 reg = 0;
332 value = 0;
333 addr = 0;
334 specval = 0;
335 specflag1 = 0;
336 specflag2 = 0;
337 specflag3 = 0;
338 specflag4 = 0;
339 }
340};
341
342
343//--------------------------------------------------------------------------
344// I N S T R U C T I O N
345//--------------------------------------------------------------------------
348
354
355class insn_t;
356#define DECLARE_INSN_HELPERS(decl) \
357decl uint8 ida_export insn_get_next_byte(insn_t *insn); \
358decl uint16 ida_export insn_get_next_word(insn_t *insn); \
359decl uint32 ida_export insn_get_next_dword(insn_t *insn); \
360decl uint64 ida_export insn_get_next_qword(insn_t *insn); \
361decl bool ida_export insn_create_op_data(const insn_t &insn, ea_t ea, int opoff, op_dtype_t dtype); \
362decl void ida_export insn_add_cref(const insn_t &insn, ea_t to, int opoff, cref_t type); \
363decl void ida_export insn_add_dref(const insn_t &insn, ea_t to, int opoff, dref_t type); \
364decl ea_t ida_export insn_add_off_drefs(const insn_t &insn, const op_t &x, dref_t type, int outf); \
365decl bool ida_export insn_create_stkvar(const insn_t &insn, const op_t &x, adiff_t v, int flags);
366
367DECLARE_INSN_HELPERS(idaman)
368
369
370class insn_t
371{
372public:
373 insn_t() : auxpref(0) {}
374
376 ea_t cs = BADADDR;
377
380 ea_t ip = BADADDR;
381
384 ea_t ea = BADADDR;
385
390 uint16 itype = 0;
391
392 inline bool is_canon_insn(const processor_t &ph) const;
393 inline uint32 get_canon_feature(const processor_t &ph) const;
394 inline const char *get_canon_mnem(const processor_t &ph) const;
395
398 uint16 size = 0;
399
400 union
401 {
402 uint32 auxpref;
403 uint16 auxpref_u16[2];
404 uint8 auxpref_u8[4];
405 };
406 /*u*/ char segpref = 0;
407 /*u*/ char insnpref = 0;
408
409 /*u*/ int16 flags = 0;
410
411 op_t ops[UA_MAXOP];
412
417 #define Op1 ops[0]
418 #define Op2 ops[1]
419 #define Op3 ops[2]
420 #define Op4 ops[3]
421 #define Op5 ops[4]
422 #define Op6 ops[5]
423 #define Op7 ops[6]
424 #define Op8 ops[7]
426
431#define INSN_MACRO 0x01
432#define INSN_MODMAC 0x02
433#define INSN_64BIT 0x04
435
437 bool is_macro(void) const { return (flags & INSN_MACRO) != 0; }
438
440#ifdef __EA64__
441 bool is_64bit(void) const { return (flags & INSN_64BIT) != 0; }
442#else
443 bool is_64bit(void) const { return false; }
444#endif
445
452 uint8 get_next_byte()
453 {
454 return insn_get_next_byte(this);
455 }
456 uint16 get_next_word()
457 {
458 return insn_get_next_word(this);
459 }
460 uint32 get_next_dword()
461 {
462 return insn_get_next_dword(this);
463 }
464 uint64 get_next_qword()
465 {
466 return insn_get_next_qword(this);
467 }
469
472
483
484 bool create_op_data(ea_t ea_, int opoff, op_dtype_t dtype) const
485 {
486 return insn_create_op_data(*this, ea_, opoff, dtype);
487 }
488
490 bool create_op_data(ea_t ea_, const op_t &op) const
491 {
492 return insn_create_op_data(*this, ea_, op.offb, op.dtype);
493 }
494
495
505
506 bool create_stkvar(const op_t &x, adiff_t v, int stkvar_flags) const
507 {
508 return insn_create_stkvar(*this, x, v, stkvar_flags);
509 }
510
516
517 void add_cref(ea_t to, int opoff, cref_t type) const
518 {
519 insn_add_cref(*this, to, opoff, type);
520 }
521
522
529
530 void add_dref(ea_t to, int opoff, dref_t type) const
531 {
532 insn_add_dref(*this, to, opoff, type);
533 }
534
535
547
548 ea_t add_off_drefs(const op_t &x, dref_t type, int outf) const
549 {
550 return insn_add_off_drefs(*this, x, type, outf);
551 }
552
554
555 DECLARE_INSN_HELPERS(friend)
556};
557#ifdef __EA64__
558CASSERT(sizeof(insn_t) == 360);
559#else
560CASSERT(sizeof(insn_t) == 216);
561#endif
562
563//--------------------------------------------------------------------------
564// V A L U E O F O P E R A N D
565//--------------------------------------------------------------------------
566#ifndef SWIG
580
581#endif // SWIG
582
598
599idaman size_t ida_export get_immvals(
600 uval_t *out,
601 ea_t ea,
602 int n,
603 flags64_t F,
604 insn_t *cache=nullptr);
605
606
617
619 uval_t *out,
620 ea_t ea,
621 int n,
622 flags64_t F,
623 insn_t *cache=nullptr)
624{
625 F &= ~0x100; // no FF_IVL...
626 F |= 0xFF; // ...but a value of 0xFF
627 return get_immvals(out, ea, n, F, cache);
628}
629
630
637
638idaman int ida_export get_lookback(void);
639
640
641//--------------------------------------------------------------------------
642// I D P H E L P E R F U N C T I O N S - C O M M O N
643//--------------------------------------------------------------------------
644
658
662
663idaman ea_t ida_export calc_dataseg(const insn_t &insn, int n=-1, int rgnum=-1);
664
669
670inline ea_t map_data_ea(const insn_t &insn, ea_t addr, int opnum=-1)
671{
672 return to_ea(calc_dataseg(insn, opnum), addr);
673}
674
675inline ea_t map_data_ea(const insn_t &insn, const op_t &op)
676{
677 return map_data_ea(insn, op.addr, op.n);
678}
679
685
686idaman ea_t ida_export map_code_ea(const insn_t &insn, ea_t addr, int opnum);
687
688inline ea_t map_code_ea(const insn_t &insn, const op_t &op)
689{
690 return map_code_ea(insn, op.addr, op.n);
691}
692
693inline ea_t map_ea(const insn_t &insn, const op_t &op, bool iscode)
694{
695 return iscode ? map_code_ea(insn, op) : map_data_ea(insn, op);
696}
697
698inline ea_t map_ea(const insn_t &insn, ea_t addr, int opnum, bool iscode)
699{
700 return iscode ? map_code_ea(insn, addr, opnum) : map_data_ea(insn, addr, opnum);
701}
702
704
705//--------------------------------------------------------------------------
706// I D P H E L P E R F U N C T I O N S - O U T P U T
707//--------------------------------------------------------------------------
709{
711 // information for creating one line
716 int suspop;
718 uval_t *outvalues = nullptr;
720 void *user_data = nullptr;
721 void *kern_data = nullptr;
722
723 // information for generating many lines
724 qstrvec_t *lnar = nullptr;
725 int lnar_maxsize = 0;
726 int default_lnnum = -1;
727
730 int ctxflags = 0;
731#define CTXF_MAIN 0x00001
732#define CTXF_MULTI 0x00002
733#define CTXF_CODE 0x00004
734#define CTXF_STACK 0x00008
735#define CTXF_GEN_XREFS 0x00010
736#define CTXF_XREF_STATE 0x00060
737#define XREFSTATE_NONE 0x00
738#define XREFSTATE_GO 0x20
739#define XREFSTATE_DONE 0x40
740#define CTXF_GEN_CMT 0x00080
741#define CTXF_CMT_STATE 0x00300
742#define COMMSTATE_NONE 0x000
743#define COMMSTATE_GO 0x100
744#define COMMSTATE_DONE 0x200
745#define CTXF_VOIDS 0x00400
746#define CTXF_NORMAL_LABEL 0x00800
747#define CTXF_DEMANGLED_LABEL 0x01000
748#define CTXF_LABEL_OK 0x02000
749#define CTXF_DEMANGLED_OK 0x04000
750#define CTXF_OVSTORE_PRNT 0x08000
751#define CTXF_OUTCTX_T 0x10000
752#define CTXF_DBLIND_OPND 0x20000
753#define CTXF_BINOP_STATE 0xC0000
754#define BINOPSTATE_NONE 0x00000
755#define BINOPSTATE_GO 0x40000
756#define BINOPSTATE_DONE 0x80000
757#define CTXF_HIDDEN_ADDR 0x100000
758#define CTXF_BIT_PREFIX 0x200000
759#define CTXF_UNHIDE 0x400000
760
761 // internal data used by the kernel
762 int ind0 = 0;
763 ea_t cmt_ea = BADADDR;
765 const char *cmtptr = nullptr;
767
768 inline bool only_main_line() const { return (ctxflags & CTXF_MAIN) != 0; }
769 inline bool multiline() const { return (ctxflags & CTXF_MULTI) != 0; }
770 inline bool force_code() const { return (ctxflags & CTXF_CODE) != 0; }
771 inline bool stack_view() const { return (ctxflags & CTXF_STACK) != 0; }
772 inline bool display_voids() const { return (ctxflags & CTXF_VOIDS) != 0; }
773 inline bool display_hidden() const { return (ctxflags & CTXF_UNHIDE) != 0; }
774 inline void set_gen_xrefs(bool on=true) { setflag(ctxflags, CTXF_GEN_XREFS, on); }
775 inline int get_xrefgen_state() const { return ctxflags & CTXF_XREF_STATE; }
776 inline void set_gen_cmt(bool on=true) { setflag(ctxflags, CTXF_GEN_CMT, on); }
777 inline int get_cmtgen_state() const { return ctxflags & CTXF_CMT_STATE; }
778 inline int get_binop_state() const { return ctxflags & CTXF_BINOP_STATE; }
779 inline void clr_gen_label(void) { ctxflags &= ~(CTXF_NORMAL_LABEL|CTXF_DEMANGLED_LABEL); }
780 inline void set_gen_label(void) { ctxflags |= CTXF_NORMAL_LABEL; }
781 inline void set_gen_demangled_label(void) { ctxflags |= CTXF_DEMANGLED_LABEL; ctxflags &= ~CTXF_NORMAL_LABEL; }
782 inline void set_comment_addr(ea_t ea) { cmt_ea = ea; }
783 inline void set_dlbind_opnd(void) { ctxflags |= CTXF_DBLIND_OPND; }
784 inline bool print_label_now() const
785 {
786 return (ctxflags & (CTXF_LABEL_OK|CTXF_MAIN)) == 0 // label not ready
787 && (ctxflags & (CTXF_NORMAL_LABEL|CTXF_DEMANGLED_LABEL)) != 0; // requested it
788 }
790 { // temporarily forbid printing of xrefs, label, cmt
791 int bits = CTXF_GEN_XREFS|CTXF_NORMAL_LABEL|CTXF_DEMANGLED_LABEL|CTXF_GEN_CMT;
792 int saved_flags = ctxflags & bits;
793 ctxflags &= ~bits;
794 return saved_flags;
795 }
796 void restore_ctxflags(int saved_flags)
797 {
798 ctxflags |= saved_flags;
799 }
800
801 outctx_base_t(ea_t ea, flags64_t flags, int _suspop=0);
803 virtual ~outctx_base_t(void);
804
807
810 AS_PRINTF(2, 3) size_t out_printf(const char *format, ...)
811 {
812 va_list va;
814 size_t len = out_vprintf(format, va);
816 return len;
817 }
818
819 GCC_DIAG_OFF(format-nonliteral);
820 size_t nowarn_out_printf(const char *format, ...)
821 {
822 va_list va;
824 size_t len = out_vprintf(format, va);
825 va_end(va);
826 return len;
827 }
828 GCC_DIAG_ON(format-nonliteral);
829
830 virtual AS_PRINTF(2, 0) size_t idaapi out_vprintf(const char *format, va_list va);
831
841 virtual flags64_t idaapi out_value(const op_t &x, int outf=0);
842
847#define OOF_SIGNMASK 0x0003
848#define OOFS_IFSIGN 0x0000
849#define OOFS_NOSIGN 0x0001
850#define OOFS_NEEDSIGN 0x0002
851#define OOF_SIGNED 0x0004
852#define OOF_NUMBER 0x0008
853#define OOF_WIDTHMASK 0x0070
854#define OOFW_IMM 0x0000
855#define OOFW_8 0x0010
856#define OOFW_16 0x0020
857#define OOFW_24 0x0030
858#define OOFW_32 0x0040
859#define OOFW_64 0x0050
860#define OOF_ADDR 0x0080
862#define OOF_OUTER 0x0100
863#define OOF_ZSTROFF 0x0200
868#define OOF_NOBNOT 0x0400
869#define OOF_SPACES 0x0800
871#define OOF_ANYSERIAL 0x1000
872#define OOF_LZEROES 0x2000
873#define OOF_NO_LZEROES 0x4000
877
879 virtual void idaapi out_symbol(char c);
880
882 virtual void idaapi out_chars(char c, int n);
883
886 virtual void idaapi add_spaces(qstring *buf, ssize_t len);
887
889 virtual void idaapi out_line(const char *str, color_t color=0);
890
892 inline void out_keyword(const char *str)
893 {
895 }
896
898 inline void out_register(const char *str)
899 {
900 out_line(str, COLOR_REG);
901 }
902
904 inline void out_lvar(const char *name, int width=-1)
905 {
906 out_line(name, COLOR_LOCNAME);
907 if ( width != -1 && name != nullptr )
908 {
909 size_t len = ::qstrlen(name);
910 if ( len < width )
911 out_chars(' ', int(width - len));
912 }
913 }
914
916 virtual void idaapi out_tagon(color_t tag);
917
919 virtual void idaapi out_tagoff(color_t tag);
920
922 virtual void idaapi out_addr_tag(ea_t ea);
923
927 virtual void idaapi out_colored_register_line(const char *str);
928
932 virtual void idaapi out_char(char c) { outbuf.append(c); }
933
937 virtual void idaapi out_btoa(uval_t Word, char radix=0);
938
954 virtual void idaapi out_long(sval_t v, char radix);
955
964 virtual bool idaapi out_name_expr(
965 const op_t &x,
966 ea_t ea,
967 adiff_t off=BADADDR);
968
969 // Generate the closing comment if if it required by the assembler
970
971 inline void close_comment(void) { out_line(closing_comment()); }
972
975
979 virtual bool idaapi flush_outbuf(int indent=-1);
980
983 virtual bool idaapi flush_buf(const char *buf, int indent=-1);
984
987 virtual int idaapi term_outctx(const char *prefix=nullptr);
988
990 virtual AS_PRINTF(3, 0) bool idaapi gen_vprintf(
991 int indent,
992 const char *format,
993 va_list va);
994
1008
1009 AS_PRINTF(3, 4) inline bool gen_printf(int indent, const char *format, ...)
1010 {
1011 va_list va;
1013 bool code = gen_vprintf(indent, format, va);
1015 return code;
1016 }
1017#define DEFAULT_INDENT 0xFFFF
1018
1022
1023 virtual bool idaapi gen_empty_line(void);
1024
1025
1030
1031 virtual bool idaapi gen_border_line(bool solid=false);
1032
1034 virtual AS_PRINTF(3, 0) bool idaapi gen_colored_cmt_line_v(
1035 color_t color,
1036 const char *format,
1037 va_list va);
1038
1040
1041 AS_PRINTF(2, 0) inline bool gen_cmt_line_v(const char *format, va_list va)
1042 {
1043 return gen_colored_cmt_line_v(COLOR_AUTOCMT, format, va);
1044 }
1045
1050
1051 AS_PRINTF(2, 3) inline bool gen_cmt_line(const char *format, ...)
1052 {
1053 va_list va;
1055 bool code = gen_cmt_line_v(format, va);
1057 return code;
1058 }
1059
1064
1065 AS_PRINTF(2, 3) inline bool gen_collapsed_line(const char *format, ...)
1066 {
1067 va_list va;
1069 bool answer = gen_colored_cmt_line_v(COLOR_COLLAPSED, format, va);
1071 return answer;
1072 }
1073
1079
1080 virtual bool idaapi gen_block_cmt(const char *cmt, color_t color);
1081
1082 //-------------------------------------------------------------------------
1084 virtual void idaapi setup_outctx(const char *prefix, int makeline_flags);
1085#define MAKELINE_NONE 0x00
1086#define MAKELINE_BINPREF 0x01
1087#define MAKELINE_VOID 0x02
1088#define MAKELINE_STACK 0x04
1089
1090 virtual ssize_t idaapi retrieve_cmt(void) { return -1; }
1091 virtual ssize_t idaapi retrieve_name(qstring *, color_t *) { return -1; }
1092 virtual bool idaapi gen_xref_lines(void) { return false; }
1093
1094 virtual void idaapi init_lines_array(qstrvec_t *answers, int maxsize);
1095
1096 virtual ssize_t idaapi get_stkvar(const op_t &x, uval_t v, sval_t *vv, int *is_sp_based, tinfo_t *_frame);
1097
1099 {
1100 int saved_flags = forbid_annotations();
1102 restore_ctxflags(saved_flags);
1103 }
1104
1105 inline flags64_t getF() const;
1106
1107protected:
1108 virtual bool idaapi flush_and_reinit(void);
1109 virtual void idaapi append_user_prefix(const char *, int) {}
1110 virtual void idaapi add_aux_prefix(const char *, int) {}
1111 virtual void idaapi out_label_addr_tag(void) {}
1112 virtual void idaapi out_aux_cmts(void) {}
1114};
1115
1116//--------------------------------------------------------------------------
1117// This class is used to print instructions and data items
1119{
1120 // kernel only data:
1121 ea_t bin_ea; // Current binary format EA
1122 char bin_state; // =0 not generated,1-in process,2-finished
1123 int gl_bpsize = 0; // binary line prefix size
1124 int bin_width = 0;
1125
1126 // instruction to display:
1127 insn_t insn; // valid only when ph.out_insn() is called
1128
1129 // colorized and demangled label of the current address
1131
1132 // opinfo_t to use for out_value()
1134
1135 // processor module and its description
1139
1140 // out_value() saves the printed values here
1141 uval_t saved_immvals[UA_MAXOP] = { 0 };
1142
1143 ea_t prefix_ea = BADADDR;
1144 ea_t next_line_ea = BADADDR; // EA of next line (for prefix)
1146
1148 procmod_t *p,
1149 processor_t &ph,
1150 asm_t &ash,
1151 ea_t ea,
1152 flags64_t flags=0,
1153 int _suspop=0,
1154 const printop_t *_wif=nullptr);
1156 {
1157 }
1158 virtual void idaapi setup_outctx(const char *prefix, int flags) override;
1159 virtual int idaapi term_outctx(const char *prefix=nullptr) override;
1160 virtual ssize_t idaapi retrieve_cmt(void) override;
1161 virtual ssize_t idaapi retrieve_name(qstring *, color_t *) override;
1162 virtual bool idaapi gen_xref_lines(void) override;
1163 virtual void idaapi out_btoa(uval_t Word, char radix=0) override;
1164
1165 void set_bin_state(int value)
1166 {
1167 bin_state = value;
1168 ctxflags &= ~CTXF_BINOP_STATE;
1169 ctxflags |= value == 0 ? BINOPSTATE_NONE
1170 : value == 1 ? BINOPSTATE_GO
1171 : BINOPSTATE_DONE;
1172 }
1173
1183 virtual void idaapi out_mnem(int width=8, const char *postfix=nullptr) newapi;
1184
1193 virtual void idaapi out_custom_mnem(
1194 const char *mnem,
1195 int width=8,
1196 const char *postfix=nullptr) newapi;
1197
1202 virtual void idaapi out_mnemonic(void) newapi;
1203
1212 virtual bool idaapi out_one_operand(int n) newapi;
1213
1219 virtual size_t idaapi get_immvals(uval_t *out, int i) newapi;
1220
1225 virtual void idaapi out_immchar_cmts(void) newapi;
1226
1228 DEPRECATED virtual void idaapi gen_func_header(func_t *pfn) newapi;
1230 DEPRECATED virtual void idaapi gen_func_footer(const func_t *pfn) newapi;
1231
1232 // display data items and undefined bytes.
1233 virtual void idaapi out_data(bool analyze_only) newapi;
1234
1235 // generate declaration for item in a special segment
1236 // return: 0-ok, 1-overflow
1237 virtual bool idaapi out_specea(uchar segtype) newapi;
1238
1239 // convenience functions for processor modules
1240 // print lines from ash.header
1241 virtual void idaapi gen_header_extra() newapi;
1242
1243 // flags for gen_header()
1244#define GH_PRINT_PROC (1 << 0)
1245#define GH_PRINT_ASM (1 << 1)
1246#define GH_PRINT_BYTESEX (1 << 2)
1247#define GH_PRINT_HEADER (1 << 3)
1248#define GH_BYTESEX_HAS_HIGHBYTE (1 << 4)
1249#define GH_PRINT_PROC_AND_ASM (GH_PRINT_PROC | GH_PRINT_ASM)
1250#define GH_PRINT_PROC_ASM_AND_BYTESEX (GH_PRINT_PROC_AND_ASM | GH_PRINT_BYTESEX)
1251#define GH_PRINT_ALL (GH_PRINT_PROC_ASM_AND_BYTESEX | GH_PRINT_HEADER)
1252#define GH_PRINT_ALL_BUT_BYTESEX (GH_PRINT_PROC_AND_ASM | GH_PRINT_HEADER)
1253 virtual void idaapi gen_header(
1254 int flags = GH_PRINT_PROC_AND_ASM,
1255 const char *proc_name = nullptr,
1256 const char *proc_flavour = nullptr) newapi;
1257
1263 virtual void idaapi out_fcref_names() newapi;
1264
1268 virtual void idaapi gen_function_header(ea_t func_ea) newapi;
1269
1273 virtual void idaapi gen_function_footer(ea_t func_ea) newapi;
1274 friend struct outctx_internal_t;
1275
1277protected:
1278 virtual bool idaapi flush_and_reinit(void) override;
1279 virtual void idaapi add_aux_prefix(const char *contents, int indent) override;
1280 virtual void idaapi append_user_prefix(const char *contents, int indent) override;
1281
1282private:
1283 virtual void idaapi out_label_addr_tag() override;
1284 virtual void idaapi out_aux_cmts() override;
1285 virtual ssize_t idaapi get_stkvar(const op_t &x, uval_t v, sval_t *vv, int *is_sp_based, tinfo_t *_frame) override;
1286
1287
1288public:
1300 virtual void idaapi out_unmapped_addr(ea_t addr, char radix=16) newapi;
1301};
1302
1303//-------------------------------------------------------------------------
1305{
1306 return (ctxflags & CTXF_OUTCTX_T) != 0 ? ((outctx_t *) this)->F : F32;
1307}
1308
1309//--------------------------------------------------------------------------
1312
1313idaman outctx_base_t *ida_export create_outctx(ea_t ea, flags64_t F=0, int suspop=0);
1314
1315
1320
1321idaman bool ida_export print_insn_mnem(qstring *out, ea_t ea);
1322
1323
1327#define FCBF_CONT 0x00000001
1328#define FCBF_ERR_REPL 0x00000002
1330
1331#define FCBF_FF_LIT 0x00000004
1334
1335#define FCBF_DELIM 0x00000008
1339
1340
1369
1370idaman bool ida_export format_charlit(
1371 qstring *out,
1372 const uchar **ptr,
1373 size_t size,
1374 uint32 flags=0,
1375 int encidx=0);
1376
1377
1386
1387idaman bool ida_export print_fpval(char *buf, size_t bufsize, const void *v, int size);
1388
1389
1390//--------------------------------------------------------------------------
1391// I D P H E L P E R F U N C T I O N S - E M U L A T O R
1392//--------------------------------------------------------------------------
1394idaman flags64_t ida_export get_dtype_flag(op_dtype_t dtype);
1396idaman size_t ida_export get_dtype_size(op_dtype_t dtype);
1399
1402{
1403 return dtype == dt_float
1404 || dtype == dt_double
1405 || dtype == dt_tbyte
1406 || dtype == dt_ldbl
1407 || dtype == dt_half;
1408}
1409
1410
1411//--------------------------------------------------------------------------
1432template <class Derived>
1434{
1436
1437 bool empty() const { return regs == 0; }
1438 void clear() { regs = 0; }
1439 int count() const { return bitcount(regs); }
1440 void add(int regnum) { regs |= _encode(regnum); }
1441 template<typename... Args>
1442 void add(int regnum, Args... args) { add(regnum); add(args...); }
1443 void add(const reglist_base_t &r) { regs |= r.regs; }
1444 void add_range(int first, int count)
1445 {
1446 while ( count-- > 0 )
1447 add(first++);
1448 }
1449 void del(int regnum) { regs &= ~_encode(regnum); }
1450 void del(const reglist_base_t &r) { regs &= ~r.regs; }
1451 void intersect(const reglist_base_t &r) { regs &= r.regs; }
1452 bool has(int regnum) const { return (regs & _encode(regnum)) != 0; }
1453 bool has_any(const reglist_base_t &r) const { return (regs & r.regs) != 0; }
1454 bool contains(const reglist_base_t &r) const { return (r.regs & ~regs) == 0; }
1456 {
1457 return ::compare(regs, r.regs);
1458 }
1459 // FUNC can return a non-zero code to immediately exit the loop
1460 int for_each(std::function<int(int)> func) const
1461 {
1462 uint64 bitmask = regs;
1463 int bitnum = bitcountr_zero(bitmask);
1464 for ( bitmask >>= bitnum; bitmask != 0; bitmask >>= 1 )
1465 {
1466 if ( (bitmask & 1) != 0 )
1467 {
1468 int code = func(_decode(bitnum));
1469 if ( code != 0 )
1470 return code;
1471 }
1472 ++bitnum;
1473 }
1474 return 0;
1475 }
1476 int first_reg() const { return _decode(bitcountr_zero(regs)); }
1477 // print the register list taking into account consecutive registers
1478 void print(
1479 outctx_t *out,
1480 std::function<void(outctx_t *,int)> print_reg,
1481 const char *delim) const
1482 {
1483 int last_reg = -1;
1484 size_t count = 0;
1485 for_each([out, print_reg, delim, &last_reg, &count](int reg)
1486 {
1487 if ( last_reg >= 0 && reg == last_reg + 1 )
1488 { // count consecutive registers
1489 ++count;
1490 ++last_reg;
1491 }
1492 else
1493 {
1494 if ( count > 1 )
1495 { // output the register range
1496 out->out_line(count == 2 ? delim : "-", COLOR_SYMBOL);
1497 print_reg(out, last_reg);
1498 }
1499 if ( count != 0 )
1500 out->out_line(delim, COLOR_SYMBOL);
1501 print_reg(out, reg);
1502 // start new register range
1503 last_reg = reg;
1504 count = 1;
1505 }
1506 return 0;
1507 } );
1508 if ( count > 1 )
1509 {
1510 out->out_line(count == 2 ? delim : "-", COLOR_SYMBOL);
1511 print_reg(out, last_reg);
1512 }
1513 }
1514
1515protected:
1516 uint64 _encode(int regnum) const
1517 {
1518 return static_cast<const Derived *>(this)->encode(regnum);
1519 }
1520 int _decode(int bitnum) const
1521 {
1522 return static_cast<const Derived *>(this)->decode(bitnum);
1523 }
1524};
1525
1526
1527//--------------------------------------------------------------------------
1528// K E R N E L I N T E R F A C E T O I D P F U N C T I O N S
1529//--------------------------------------------------------------------------
1538idaman int ida_export create_insn(ea_t ea, insn_t *out=nullptr);
1539
1540
1548
1549idaman int ida_export decode_insn(insn_t *out, ea_t ea);
1550
1554
1555inline bool can_decode(ea_t ea) { insn_t insn; return decode_insn(&insn, ea) > 0; }
1556
1557
1568
1569idaman bool ida_export print_operand(
1570 qstring *out,
1571 ea_t ea,
1572 int n,
1573 int getn_flags=0,
1574 struct printop_t *newtype=nullptr);
1575
1576
1577//--------------------------------------------------------------------------
1578// Helper functions for the processor emulator/analyzer
1579//--------------------------------------------------------------------------
1580
1585
1586idaman ea_t ida_export decode_prev_insn(insn_t *out, ea_t ea);
1587
1588
1595
1596idaman ea_t ida_export decode_preceding_insn(insn_t *out, ea_t ea, bool *p_farref=nullptr);
1597
1598
1601{
1602 size_t reserved = 0;
1603
1605
1624 inline bool construct_macro(insn_t *insn, bool enable);
1625
1640 virtual bool idaapi build_macro(insn_t *insn, bool may_go_forward) = 0;
1641};
1642
1643// Do not directly call this function, use macro_constructor_t
1644idaman bool ida_export construct_macro(
1645 macro_constructor_t *_this,
1646 insn_t *insn,
1647 bool enable);
1648
1649inline bool macro_constructor_t::construct_macro(insn_t *insn, bool enable)
1650{
1651 return ::construct_macro(this, insn, enable);
1652}
1653
1654
1662
1663idaman int ida_export get_spoiled_reg(const insn_t &insn, const uint32 *regs, size_t n);
1664
1665#endif // _UA_HPP
Contains functions that deal with individual byte characteristics.
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:106
Operand of an instruction.
Definition ua.hpp:170
uint16 low
IBM PC: segment register number (o_mem,o_far,o_near)
Definition ua.hpp:282
uchar n
Number of operand (0,1,2).
Definition ua.hpp:175
bool is_reg(int r) const
Is register operand?
Definition ua.hpp:263
op_t()
Definition ua.hpp:329
struct op_t::@355145044314106136163341364327273110212111274006::@105003236016226244000346201374354173104334320270 addr_shorts
This structure is defined for your convenience only.
char offo
Same as offb (some operands have 2 numeric values used to form an operand).
Definition ua.hpp:195
uint16 reg
number of register (o_reg)
Definition ua.hpp:256
uint16 phrase
number of register phrase (o_phrase,o_displ).
Definition ua.hpp:257
bool is_imm(uval_t v) const
Is immediate operand?
Definition ua.hpp:288
uint16 high
IBM PC: segment selector value (o_mem,o_far,o_near)
Definition ua.hpp:283
uval_t value
operand value (o_imm) or outer displacement (o_displ+OF_OUTER_DISP).
Definition ua.hpp:270
optype_t type
Type of operand (see Operand types)
Definition ua.hpp:178
op_dtype_t dtype
Type of operand value (see Operand value types).
Definition ua.hpp:225
void set_shown()
Set operand to be shown.
Definition ua.hpp:216
char offb
Offset of operand value from the instruction start (0 means unknown).
Definition ua.hpp:189
struct op_t::@314264034300125366226121250377171170106022317216::@067003166240224161210217156357235221062015160112 specval_shorts
This structure is defined for your convenience only.
ea_t addr
virtual address pointed or used by the operand.
Definition ua.hpp:293
char specflag4
Definition ua.hpp:326
void clr_shown()
Set operand to hidden.
Definition ua.hpp:218
bool shown() const
Is operand set to be shown?
Definition ua.hpp:220
uchar flags
Operand flags
Definition ua.hpp:197
char specflag3
Definition ua.hpp:325
char specflag1
Definition ua.hpp:323
struct op_t::@140153357217061121023364357273245161007012105054::@172011301334131030205016047004346361350234062301 value_shorts
This structure is defined for your convenience only.
char specflag2
Definition ua.hpp:324
ea_t specval
This field may be used as you want.
Definition ua.hpp:308
Primary mechanism for managing type information.
Definition typeinf.hpp:3077
const color_t COLOR_AUTOCMT
Automatic comment.
Definition lines.hpp:102
const color_t COLOR_COLLAPSED
Collapsed line.
Definition lines.hpp:137
const color_t COLOR_REG
Register name.
Definition lines.hpp:131
const color_t COLOR_KEYWORD
Keywords.
Definition lines.hpp:130
const color_t COLOR_LOCNAME
Local variable name.
Definition lines.hpp:123
const color_t COLOR_SYMBOL
Punctuation.
Definition lines.hpp:107
uchar color_t
see <lines.hpp>
Definition kernwin.hpp:26
const optype_t o_mem
A direct memory reference to a data item.
Definition ua.hpp:84
const optype_t o_idpspec1
processor specific type.
Definition ua.hpp:96
const optype_t o_idpspec3
processor specific type.
Definition ua.hpp:98
const optype_t o_reg
General Register (al,ax,es,ds...).
Definition ua.hpp:83
const optype_t o_idpspec5
processor specific type.
Definition ua.hpp:100
const optype_t o_far
An immediate far code reference (inter-segment)
Definition ua.hpp:93
const optype_t o_idpspec2
processor specific type.
Definition ua.hpp:97
const optype_t o_phrase
An indirect memory reference that uses a register: [reg] There can be several registers but no displa...
Definition ua.hpp:87
const optype_t o_displ
An indirect memory reference that uses a register and has an immediate constant added to it: [reg+N] ...
Definition ua.hpp:89
const optype_t o_imm
An immediate Value (constant).
Definition ua.hpp:92
const optype_t o_idpspec4
processor specific type.
Definition ua.hpp:99
const optype_t o_idpspec0
processor specific type.
Definition ua.hpp:95
const optype_t o_near
An immediate near code reference (intra-segment)
Definition ua.hpp:94
const optype_t o_void
No Operand.
Definition ua.hpp:82
int code
Definition fpro.h:88
idaman size_t n
Definition pro.h:1000
idaman uchar ida_export segtype(ea_t ea)
Get segment type.
cref_t
CODE xref types.
Definition xref.hpp:49
dref_t
DATA xref types.
Definition xref.hpp:67
const tinfo_t & type
Definition hexrays.hpp:7698
carglist_t * args
Definition hexrays.hpp:7720
ea_t idaapi to_ea(sel_t reg_cs, uval_t reg_ip)
Convert (sel,off) value to a linear address.
Definition ida.hpp:1152
Defines the interface between the kernel and the UI.
uval_t uval_t
Definition kernwin.hpp:1926
asize_t size
Definition kernwin.hpp:6701
High level functions that deal with the generation of the disassembled text lines.
unsigned __int64 uint64
Definition llong.hpp:13
qvector< qstring > qstrvec_t
Definition lumina.hpp:831
THREAD_SAFE size_t idaapi qstrlen(const char *s)
Definition pro.h:3074
unsigned short uint16
unsigned 16 bit value
Definition pro.h:350
idaman int ida_export bitcountr_zero(uint64 x)
count the number of consecutive trailing zero bits (like C++20 std::countr_zero())
int bool
Definition pro.h:333
unsigned int uint32
unsigned 32 bit value
Definition pro.h:352
uint64 asize_t
Definition pro.h:427
uint8 op_dtype_t
Definition pro.h:464
adiff_t sval_t
signed value used by the processor.
Definition pro.h:450
short int16
signed 16 bit value
Definition pro.h:349
int64 adiff_t
Definition pro.h:428
uint64 ea_t
Definition pro.h:425
uint32 flags_t
32-bit flags for each address
Definition pro.h:5105
idaman int ida_export bitcount(uint64 x)
count the number of non-zero bits (the population count)
unsigned char uchar
unsigned 8 bit value
Definition pro.h:341
idaman size_t bufsize
Definition pro.h:604
uint64 flags64_t
64-bit flags for each address
Definition pro.h:5106
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:385
void idaapi setflag(T &where, U bit, bool cnd)
Set a 'bit' in 'where' if 'value' is not zero.
Definition pro.h:1530
unsigned char uint8
unsigned 8 bit value
Definition pro.h:348
_qstring< char > qstring
regular string
Definition pro.h:3771
Describes the target assembler.
Definition idp.hpp:178
helper class to support 32-bit addresses in ida64
Definition ida.hpp:1162
Helper class for processor modules to build macro instructions.
Definition ua.hpp:1601
size_t reserved
Definition ua.hpp:1602
bool construct_macro(insn_t *insn, bool enable)
Construct a macro instruction.
Definition ua.hpp:1649
virtual ~macro_constructor_t()
Definition ua.hpp:1604
virtual bool idaapi build_macro(insn_t *insn, bool may_go_forward)=0
Try to extend the instruction.
Definition ua.hpp:709
virtual flags64_t idaapi out_value(const op_t &x, int outf=0)
Output immediate value.
flags64_t getF() const
Definition ua.hpp:1304
GCC_DIAG_ON(format-nonliteral)
int get_cmtgen_state() const
Definition ua.hpp:777
bool multiline() const
Definition ua.hpp:769
virtual const char * format
Definition ua.hpp:992
virtual void idaapi out_char(char c)
Output one character.
Definition ua.hpp:932
virtual void idaapi setup_outctx(const char *prefix, int makeline_flags)
Initialization; normally used only by the kernel.
qstring line_prefix
usually segname:offset
Definition ua.hpp:728
qstring cmtbuf
indented comment
Definition ua.hpp:764
virtual ssize_t idaapi retrieve_cmt(void)
Definition ua.hpp:1090
void out_register(const char *str)
Output a character with COLOR_REG color.
Definition ua.hpp:898
ssize_t regname_idx
to rename registers
Definition ua.hpp:715
void set_comment_addr(ea_t ea)
Definition ua.hpp:782
virtual bool idaapi gen_empty_line(void)
Generate empty line.
void clr_gen_label(void)
Definition ua.hpp:779
virtual int idaapi term_outctx(const char *prefix=nullptr)
Finalize the output context.
virtual void idaapi out_tagoff(color_t tag)
Output "turn color off" escape sequence.
void out_lvar(const char *name, int width=-1)
Output local variable name with COLOR_LOCNAME color.
Definition ua.hpp:904
int outvalue_getn_flags
additional flags for print_operand()
Definition ua.hpp:719
void set_gen_demangled_label(void)
Definition ua.hpp:781
virtual void idaapi out_line(const char *str, color_t color=0)
Output a string with the specified color.
color_t cmtcolor
comment color
Definition ua.hpp:766
void close_comment(void)
Definition ua.hpp:971
ssize_t prefix_len
visible length of line_prefix
Definition ua.hpp:729
bool only_main_line() const
Definition ua.hpp:768
virtual void idaapi append_user_prefix(const char *, int)
Definition ua.hpp:1109
virtual void idaapi out_tagon(color_t tag)
Output "turn color on" escape sequence.
virtual void idaapi add_spaces(qstring *buf, ssize_t len)
virtual void idaapi out_symbol(char c)
Output a character with COLOR_SYMBOL color.
const char va_start(va, format)
virtual bool idaapi flush_outbuf(int indent=-1)
Move the contents of the output buffer to the line array (outbuf->lnar) The kernel augments the outbu...
bool display_hidden() const
Definition ua.hpp:773
ea_t cmt_ea
indirectly referenced address (used to generate cmt)
Definition ua.hpp:763
int get_binop_state() const
Definition ua.hpp:778
friend struct outctx_base_internal_t
Definition ua.hpp:1113
virtual bool idaapi flush_buf(const char *buf, int indent=-1)
Append contents of 'buf' to the line array.
virtual bool idaapi gen_block_cmt(const char *cmt, color_t color)
Generate big non-indented comment lines.
virtual va_list va
Definition ua.hpp:830
ea_helper_t & _eah
Definition ua.hpp:710
virtual ssize_t idaapi get_stkvar(const op_t &x, uval_t v, sval_t *vv, int *is_sp_based, tinfo_t *_frame)
size_t nowarn_out_printf(const char *format,...)
Definition ua.hpp:820
AS_PRINTF(2, 3) inline bool gen_cmt_line(const char *format
Generate one non-indented comment line, colored with COLOR_AUTOCMT.
void out_spaces(ssize_t len)
Appends spaces to outbuf until its tag_strlen becomes 'len'.
Definition ua.hpp:885
GCC_DIAG_OFF(format-nonliteral)
void * kern_data
internal info used by the kernel
Definition ua.hpp:721
bool display_voids() const
Definition ua.hpp:772
void set_gen_xrefs(bool on=true)
Definition ua.hpp:774
virtual bool idaapi gen_border_line(bool solid=false)
Generate thin border line.
void set_gen_cmt(bool on=true)
Definition ua.hpp:776
virtual void idaapi out_aux_cmts(void)
Definition ua.hpp:1112
bool answer
Definition ua.hpp:1069
virtual void idaapi out_colored_register_line(const char *str)
Output a colored line with register names in it.
virtual AS_PRINTF(3, 0) bool idaapi gen_vprintf(int indent
See gen_printf()
void * user_data
pointer to be used by the processor module for any purpose
Definition ua.hpp:720
qstring outbuf
buffer for the current output line once ready, it is moved to lnar
Definition ua.hpp:713
virtual bool idaapi flush_and_reinit(void)
virtual bool idaapi out_name_expr(const op_t &x, ea_t ea, adiff_t off=BADADDR)
Output a name expression.
int ctxflags
various bits
Definition ua.hpp:730
virtual AS_PRINTF(3, 0) bool idaapi gen_colored_cmt_line_v(color_t color
See gen_cmt_line()
int default_lnnum
index of the most important line in lnar
Definition ua.hpp:726
virtual AS_PRINTF(2, 0) size_t idaapi out_vprintf(const char *format
int lnar_maxsize
max permitted size of lnar
Definition ua.hpp:725
flags_t F32
please use outctx_t::F instead
Definition ua.hpp:717
void set_dlbind_opnd(void)
Definition ua.hpp:783
virtual void idaapi out_addr_tag(ea_t ea)
Output "address" escape sequence.
outctx_base_t & operator=(const outctx_base_t &)=delete
virtual ~outctx_base_t(void)
virtual void idaapi out_long(sval_t v, char radix)
Output a number with appropriate color.
void out_keyword(const char *str)
Output a string with COLOR_KEYWORD color.
Definition ua.hpp:892
virtual void idaapi out_label_addr_tag(void)
Definition ua.hpp:1111
bool code
Definition ua.hpp:1013
virtual void idaapi out_chars(char c, int n)
Append a character multiple times.
qstrvec_t * lnar
vector of output lines
Definition ua.hpp:724
virtual void idaapi init_lines_array(qstrvec_t *answers, int maxsize)
void gen_empty_line_without_annotations(void)
Definition ua.hpp:1098
void set_gen_label(void)
Definition ua.hpp:780
va_start(va, format)
size_t len
Definition ua.hpp:814
virtual ssize_t idaapi retrieve_name(qstring *, color_t *)
Definition ua.hpp:1091
virtual bool idaapi gen_xref_lines(void)
Definition ua.hpp:1092
int suspop
controls color for out_long()
Definition ua.hpp:716
uval_t * outvalues
at least 2*UA_MAXOP elements
Definition ua.hpp:718
const char * cmtptr
rest of indented comment
Definition ua.hpp:765
virtual void idaapi out_btoa(uval_t Word, char radix=0)
Output a number with the specified base (binary, octal, decimal, hex) The number is output without co...
void restore_ctxflags(int saved_flags)
Definition ua.hpp:796
AS_PRINTF(2, 3) size_t out_printf(const char *format
Append a formatted string to the output string.
ea_t insn_ea
Definition ua.hpp:712
AS_PRINTF(2, 3) inline bool gen_collapsed_line(const char *format
Generate one non-indented comment line, colored with COLOR_COLLAPSED.
bool print_label_now() const
Definition ua.hpp:784
outctx_base_t(ea_t ea, flags64_t flags, int _suspop=0)
bool force_code() const
Definition ua.hpp:770
bool stack_view() const
Definition ua.hpp:771
int ind0
Definition ua.hpp:762
int forbid_annotations()
Definition ua.hpp:789
int get_xrefgen_state() const
Definition ua.hpp:775
virtual void idaapi add_aux_prefix(const char *, int)
Definition ua.hpp:1110
Definition ua.hpp:1119
int bin_width
Definition ua.hpp:1124
int gl_bpsize
Definition ua.hpp:1123
ea_t bin_ea
Definition ua.hpp:1121
qstring curlabel
Definition ua.hpp:1130
virtual void idaapi add_aux_prefix(const char *contents, int indent) override
virtual void idaapi append_user_prefix(const char *contents, int indent) override
virtual void idaapi out_mnemonic(void) new api
Output instruction mnemonic using information in 'insn'.
virtual void idaapi gen_header(int flags=GH_PRINT_PROC_AND_ASM, const char *proc_name=nullptr, const char *proc_flavour=nullptr) new api
virtual void idaapi out_unmapped_addr(ea_t addr, char radix=16) new api
Output a reference to an address that is not (yet) mapped in the database.
procmod_t * procmod
Definition ua.hpp:1136
void set_bin_state(int value)
Definition ua.hpp:1165
uval_t saved_immvals[UA_MAXOP]
Definition ua.hpp:1141
virtual void idaapi out_fcref_names() new api
Print addresses referenced from the specified address as commented symbolic names.
virtual bool idaapi out_one_operand(int n) new api
Use this function to output an operand of an instruction.
virtual void idaapi out_immchar_cmts(void) new api
Print all operand values as commented character constants.
virtual void idaapi setup_outctx(const char *prefix, int flags) override
Initialization; normally used only by the kernel.
virtual ssize_t idaapi retrieve_cmt(void) override
flags64_t F
Definition ua.hpp:1145
virtual bool idaapi flush_and_reinit(void) override
Internal overrides; not part of the SDK API - do not call or override.
virtual void idaapi out_btoa(uval_t Word, char radix=0) override
Output a number with the specified base (binary, octal, decimal, hex) The number is output without co...
processor_t & ph
Definition ua.hpp:1137
~outctx_t(void)
Definition ua.hpp:1155
virtual DEPRECATED void idaapi gen_func_header(func_t *pfn) new api
outctx_t(procmod_t *p, processor_t &ph, asm_t &ash, ea_t ea, flags64_t flags=0, int _suspop=0, const printop_t *_wif=nullptr)
virtual int idaapi term_outctx(const char *prefix=nullptr) override
Finalize the output context.
char bin_state
Definition ua.hpp:1122
insn_t insn
Definition ua.hpp:1127
virtual void idaapi gen_function_footer(ea_t func_ea) new api
Generate function footer lines.
virtual ssize_t idaapi retrieve_name(qstring *, color_t *) override
virtual void idaapi out_data(bool analyze_only) new api
ea_t prefix_ea
Definition ua.hpp:1143
const printop_t * wif
Definition ua.hpp:1133
virtual DEPRECATED void idaapi gen_func_footer(const func_t *pfn) new api
virtual void idaapi gen_function_header(ea_t func_ea) new api
Generate function header lines.
virtual bool idaapi out_specea(uchar segtype) new api
virtual size_t idaapi get_immvals(uval_t *out, int i) new api
Get the immediate values used at the specified address.
ea_t next_line_ea
Definition ua.hpp:1144
virtual void idaapi gen_header_extra() new api
virtual bool idaapi gen_xref_lines(void) override
friend struct outctx_internal_t
Definition ua.hpp:1274
asm_t & ash
Definition ua.hpp:1138
virtual void idaapi out_custom_mnem(const char *mnem, int width=8, const char *postfix=nullptr) new api
Output custom mnemonic for 'insn'.
virtual void idaapi out_mnem(int width=8, const char *postfix=nullptr) new api
Output instruction mnemonic for 'insn' using information in 'ph.instruc' array.
Definition nalt.hpp:1254
Describes a processor module (IDP).
Definition idp.hpp:633
Definition idp.hpp:2265
A class for working with a list of registers.
Definition ua.hpp:1434
uint64 regs
Definition ua.hpp:1435
void print(outctx_t *out, std::function< void(outctx_t *, int)> print_reg, const char *delim) const
Definition ua.hpp:1478
void add(int regnum, Args... args)
Definition ua.hpp:1442
bool has_any(const reglist_base_t &r) const
Definition ua.hpp:1453
uint64 _encode(int regnum) const
Definition ua.hpp:1516
void add(int regnum)
Definition ua.hpp:1440
void clear()
Definition ua.hpp:1438
int first_reg() const
Definition ua.hpp:1476
void del(const reglist_base_t &r)
Definition ua.hpp:1450
void del(int regnum)
Definition ua.hpp:1449
void intersect(const reglist_base_t &r)
Definition ua.hpp:1451
int _decode(int bitnum) const
Definition ua.hpp:1520
DECLARE_COMPARISONS(reglist_base_t)
Definition ua.hpp:1455
int for_each(std::function< int(int)> func) const
Definition ua.hpp:1460
bool contains(const reglist_base_t &r) const
Definition ua.hpp:1454
int count() const
Definition ua.hpp:1439
void add_range(int first, int count)
Definition ua.hpp:1444
bool empty() const
Definition ua.hpp:1437
void add(const reglist_base_t &r)
Definition ua.hpp:1443
bool has(int regnum) const
Definition ua.hpp:1452
Definition ua.hpp:577
uint64 low
Definition ua.hpp:577
uint64 high
Definition ua.hpp:577
Definition ua.hpp:575
uint32 low
Definition ua.hpp:575
uint32 high
Definition ua.hpp:575
Definition ua.hpp:576
uint32 low
Definition ua.hpp:576
uint16 upper
Definition ua.hpp:576
uint32 high
Definition ua.hpp:576
idaman int ida_export get_spoiled_reg(const insn_t &insn, const uint32 *regs, size_t n)
Does the instruction spoil any register from 'regs'?
idaman int ida_export get_lookback(void)
Number of instructions to look back.
idaman bool ida_export print_fpval(char *buf, size_t bufsize, const void *v, int size)
Print a floating point value.
idaman outctx_base_t *ida_export create_outctx(ea_t ea, flags64_t F=0, int suspop=0)
Create a new output context.
idaman ea_t ida_export map_code_ea(const insn_t &insn, ea_t addr, int opnum)
Map a code address.
idaman ea_t ida_export decode_preceding_insn(insn_t *out, ea_t ea, bool *p_farref=nullptr)
Decode preceding instruction in the execution flow.
idaman bool ida_export print_insn_mnem(qstring *out, ea_t ea)
Print instruction mnemonics.
idaman size_t ida_export get_immvals(uval_t *out, ea_t ea, int n, flags64_t F, insn_t *cache=nullptr)
Get immediate values at the specified address.
idaman flags64_t ida_export get_dtype_flag(op_dtype_t dtype)
Get flags for op_t::dtype field.
size_t get_printable_immvals(uval_t *out, ea_t ea, int n, flags64_t F, insn_t *cache=nullptr)
Get immediate ready-to-print values at the specified address.
Definition ua.hpp:618
idaman int ida_export create_insn(ea_t ea, insn_t *out=nullptr)
Create an instruction at the specified address.
idaman ea_t ida_export calc_dataseg(const insn_t &insn, int n=-1, int rgnum=-1)
Get data segment for the instruction operand.
idaman bool ida_export format_charlit(qstring *out, const uchar **ptr, size_t size, uint32 flags=0, int encidx=0)
Format character literal.
idaman ea_t ida_export decode_prev_insn(insn_t *out, ea_t ea)
Decode previous instruction if it exists, fill 'out'.
uchar optype_t
see Operand types
Definition ua.hpp:66
bool is_floating_dtype(op_dtype_t dtype)
Is a floating type operand?
Definition ua.hpp:1401
ea_t map_ea(const insn_t &insn, const op_t &op, bool iscode)
Definition ua.hpp:693
idaman bool ida_export print_operand(qstring *out, ea_t ea, int n, int getn_flags=0, struct printop_t *newtype=nullptr)
Generate text representation for operand n.
idaman op_dtype_t ida_export get_dtype_by_size(asize_t size)
Get op_t::dtype from size.
CASSERT(sizeof(insn_t)==360)
idaman bool ida_export construct_macro(macro_constructor_t *_this, insn_t *insn, bool enable)
idaman size_t ida_export get_dtype_size(op_dtype_t dtype)
Get size of opt_::dtype field.
ea_t map_data_ea(const insn_t &insn, ea_t addr, int opnum=-1)
Map a data address.
Definition ua.hpp:670
bool can_decode(ea_t ea)
Can the bytes at address 'ea' be decoded as instruction?
Definition ua.hpp:1555
idaman int ida_export decode_insn(insn_t *out, ea_t ea)
Analyze the specified address and fill 'out'.
This union is used to pass byte values to various helper functions.
Definition ua.hpp:569
uval_t v_uval
Definition ua.hpp:574
uint32 v_long
Definition ua.hpp:572
struct value_union_t::d128_t d128
uint64 v_int64
Definition ua.hpp:573
struct value_union_t::dq_t _dq
uint16 v_short
Definition ua.hpp:571
struct value_union_t::dt_t dt
uint8 byte16[16]
Definition ua.hpp:578
uint8 v_char
Definition ua.hpp:570
Functions that deal with cross-references (xrefs).
idaman bool ida_export add_dref(ea_t from, ea_t to, dref_t type)
Create a data cross-reference.
idaman bool ida_export add_cref(ea_t from, ea_t to, cref_t type)
Create a code cross-reference.