| 1 | /* By Nguyen Anh Quynh <[email protected]>, 2013> */cxx . . $ `<file>/cstool/cstool_x86.c`/ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | |
| 6 | #include <capstone/capstone.h>cxx . . $ `<file>/include/capstone/capstone.h`/ |
| 7 | #include "cstool.h"cxx . . $ `<file>/cstool/cstool.h`/ |
| 8 | |
| 9 | void print_string_hexcxx . . $ print_string_hex(24a4beb24605093f).(const char *comment, unsigned char *str, size_tcxx . . $ size_t# len); |
| 10 | |
| 11 | static const char *get_eflag_namecxx . . $ get_eflag_name(30dde979ed96a187).(uint64_tcxx . . $ uint64_t# flag) |
| 12 | { |
| 13 | switch(flag) { |
| 14 | default: |
| 15 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 16 | case X86_EFLAGS_UNDEFINED_OFcxx . . $ `include/capstone/x86.h:116:9`!: |
| 17 | return "UNDEF_OF"; |
| 18 | case X86_EFLAGS_UNDEFINED_SFcxx . . $ `include/capstone/x86.h:117:9`!: |
| 19 | return "UNDEF_SF"; |
| 20 | case X86_EFLAGS_UNDEFINED_ZFcxx . . $ `include/capstone/x86.h:118:9`!: |
| 21 | return "UNDEF_ZF"; |
| 22 | case X86_EFLAGS_MODIFY_AFcxx . . $ `include/capstone/x86.h:76:9`!: |
| 23 | return "MOD_AF"; |
| 24 | case X86_EFLAGS_UNDEFINED_PFcxx . . $ `include/capstone/x86.h:119:9`!: |
| 25 | return "UNDEF_PF"; |
| 26 | case X86_EFLAGS_MODIFY_CFcxx . . $ `include/capstone/x86.h:77:9`!: |
| 27 | return "MOD_CF"; |
| 28 | case X86_EFLAGS_MODIFY_SFcxx . . $ `include/capstone/x86.h:78:9`!: |
| 29 | return "MOD_SF"; |
| 30 | case X86_EFLAGS_MODIFY_ZFcxx . . $ `include/capstone/x86.h:79:9`!: |
| 31 | return "MOD_ZF"; |
| 32 | case X86_EFLAGS_UNDEFINED_AFcxx . . $ `include/capstone/x86.h:120:9`!: |
| 33 | return "UNDEF_AF"; |
| 34 | case X86_EFLAGS_MODIFY_PFcxx . . $ `include/capstone/x86.h:80:9`!: |
| 35 | return "MOD_PF"; |
| 36 | case X86_EFLAGS_UNDEFINED_CFcxx . . $ `include/capstone/x86.h:121:9`!: |
| 37 | return "UNDEF_CF"; |
| 38 | case X86_EFLAGS_MODIFY_OFcxx . . $ `include/capstone/x86.h:81:9`!: |
| 39 | return "MOD_OF"; |
| 40 | case X86_EFLAGS_RESET_OFcxx . . $ `include/capstone/x86.h:97:9`!: |
| 41 | return "RESET_OF"; |
| 42 | case X86_EFLAGS_RESET_CFcxx . . $ `include/capstone/x86.h:98:9`!: |
| 43 | return "RESET_CF"; |
| 44 | case X86_EFLAGS_RESET_DFcxx . . $ `include/capstone/x86.h:99:9`!: |
| 45 | return "RESET_DF"; |
| 46 | case X86_EFLAGS_RESET_IFcxx . . $ `include/capstone/x86.h:100:9`!: |
| 47 | return "RESET_IF"; |
| 48 | case X86_EFLAGS_RESET_ZFcxx . . $ `include/capstone/x86.h:127:9`!: |
| 49 | return "RESET_ZF"; |
| 50 | case X86_EFLAGS_TEST_OFcxx . . $ `include/capstone/x86.h:109:9`!: |
| 51 | return "TEST_OF"; |
| 52 | case X86_EFLAGS_TEST_SFcxx . . $ `include/capstone/x86.h:110:9`!: |
| 53 | return "TEST_SF"; |
| 54 | case X86_EFLAGS_TEST_ZFcxx . . $ `include/capstone/x86.h:111:9`!: |
| 55 | return "TEST_ZF"; |
| 56 | case X86_EFLAGS_TEST_PFcxx . . $ `include/capstone/x86.h:112:9`!: |
| 57 | return "TEST_PF"; |
| 58 | case X86_EFLAGS_TEST_CFcxx . . $ `include/capstone/x86.h:113:9`!: |
| 59 | return "TEST_CF"; |
| 60 | case X86_EFLAGS_RESET_SFcxx . . $ `include/capstone/x86.h:101:9`!: |
| 61 | return "RESET_SF"; |
| 62 | case X86_EFLAGS_RESET_AFcxx . . $ `include/capstone/x86.h:102:9`!: |
| 63 | return "RESET_AF"; |
| 64 | case X86_EFLAGS_RESET_TFcxx . . $ `include/capstone/x86.h:103:9`!: |
| 65 | return "RESET_TF"; |
| 66 | case X86_EFLAGS_RESET_NTcxx . . $ `include/capstone/x86.h:104:9`!: |
| 67 | return "RESET_NT"; |
| 68 | case X86_EFLAGS_PRIOR_OFcxx . . $ `include/capstone/x86.h:87:9`!: |
| 69 | return "PRIOR_OF"; |
| 70 | case X86_EFLAGS_PRIOR_SFcxx . . $ `include/capstone/x86.h:88:9`!: |
| 71 | return "PRIOR_SF"; |
| 72 | case X86_EFLAGS_PRIOR_ZFcxx . . $ `include/capstone/x86.h:89:9`!: |
| 73 | return "PRIOR_ZF"; |
| 74 | case X86_EFLAGS_PRIOR_AFcxx . . $ `include/capstone/x86.h:90:9`!: |
| 75 | return "PRIOR_AF"; |
| 76 | case X86_EFLAGS_PRIOR_PFcxx . . $ `include/capstone/x86.h:91:9`!: |
| 77 | return "PRIOR_PF"; |
| 78 | case X86_EFLAGS_PRIOR_CFcxx . . $ `include/capstone/x86.h:92:9`!: |
| 79 | return "PRIOR_CF"; |
| 80 | case X86_EFLAGS_PRIOR_TFcxx . . $ `include/capstone/x86.h:93:9`!: |
| 81 | return "PRIOR_TF"; |
| 82 | case X86_EFLAGS_PRIOR_IFcxx . . $ `include/capstone/x86.h:94:9`!: |
| 83 | return "PRIOR_IF"; |
| 84 | case X86_EFLAGS_PRIOR_DFcxx . . $ `include/capstone/x86.h:95:9`!: |
| 85 | return "PRIOR_DF"; |
| 86 | case X86_EFLAGS_TEST_NTcxx . . $ `include/capstone/x86.h:114:9`!: |
| 87 | return "TEST_NT"; |
| 88 | case X86_EFLAGS_TEST_DFcxx . . $ `include/capstone/x86.h:115:9`!: |
| 89 | return "TEST_DF"; |
| 90 | case X86_EFLAGS_RESET_PFcxx . . $ `include/capstone/x86.h:105:9`!: |
| 91 | return "RESET_PF"; |
| 92 | case X86_EFLAGS_PRIOR_NTcxx . . $ `include/capstone/x86.h:96:9`!: |
| 93 | return "PRIOR_NT"; |
| 94 | case X86_EFLAGS_MODIFY_TFcxx . . $ `include/capstone/x86.h:82:9`!: |
| 95 | return "MOD_TF"; |
| 96 | case X86_EFLAGS_MODIFY_IFcxx . . $ `include/capstone/x86.h:83:9`!: |
| 97 | return "MOD_IF"; |
| 98 | case X86_EFLAGS_MODIFY_DFcxx . . $ `include/capstone/x86.h:84:9`!: |
| 99 | return "MOD_DF"; |
| 100 | case X86_EFLAGS_MODIFY_NTcxx . . $ `include/capstone/x86.h:85:9`!: |
| 101 | return "MOD_NT"; |
| 102 | case X86_EFLAGS_MODIFY_RFcxx . . $ `include/capstone/x86.h:86:9`!: |
| 103 | return "MOD_RF"; |
| 104 | case X86_EFLAGS_SET_CFcxx . . $ `include/capstone/x86.h:106:9`!: |
| 105 | return "SET_CF"; |
| 106 | case X86_EFLAGS_SET_DFcxx . . $ `include/capstone/x86.h:107:9`!: |
| 107 | return "SET_DF"; |
| 108 | case X86_EFLAGS_SET_IFcxx . . $ `include/capstone/x86.h:108:9`!: |
| 109 | return "SET_IF"; |
| 110 | case X86_EFLAGS_SET_OFcxx . . $ `include/capstone/x86.h:128:9`!: |
| 111 | return "SET_OF"; |
| 112 | case X86_EFLAGS_SET_SFcxx . . $ `include/capstone/x86.h:129:9`!: |
| 113 | return "SET_SF"; |
| 114 | case X86_EFLAGS_SET_ZFcxx . . $ `include/capstone/x86.h:130:9`!: |
| 115 | return "SET_ZF"; |
| 116 | case X86_EFLAGS_SET_AFcxx . . $ `include/capstone/x86.h:131:9`!: |
| 117 | return "SET_AF"; |
| 118 | case X86_EFLAGS_SET_PFcxx . . $ `include/capstone/x86.h:132:9`!: |
| 119 | return "SET_PF"; |
| 120 | case X86_EFLAGS_TEST_AFcxx . . $ `include/capstone/x86.h:126:9`!: |
| 121 | return "TEST_AF"; |
| 122 | case X86_EFLAGS_TEST_TFcxx . . $ `include/capstone/x86.h:125:9`!: |
| 123 | return "TEST_TF"; |
| 124 | case X86_EFLAGS_TEST_RFcxx . . $ `include/capstone/x86.h:123:9`!: |
| 125 | return "TEST_RF"; |
| 126 | case X86_EFLAGS_RESET_0Fcxx . . $ `include/capstone/x86.h:133:9`!: |
| 127 | return "RESET_0F"; |
| 128 | case X86_EFLAGS_RESET_ACcxx . . $ `include/capstone/x86.h:134:9`!: |
| 129 | return "RESET_AC"; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | static const char *get_fpu_flag_namecxx . . $ get_fpu_flag_name(30dde979ed96a187).(uint64_tcxx . . $ uint64_t# flag) |
| 134 | { |
| 135 | switch (flag) { |
| 136 | default: |
| 137 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 138 | case X86_FPU_FLAGS_MODIFY_C0cxx . . $ `include/capstone/x86.h:136:9`!: |
| 139 | return "MOD_C0"; |
| 140 | case X86_FPU_FLAGS_MODIFY_C1cxx . . $ `include/capstone/x86.h:137:9`!: |
| 141 | return "MOD_C1"; |
| 142 | case X86_FPU_FLAGS_MODIFY_C2cxx . . $ `include/capstone/x86.h:138:9`!: |
| 143 | return "MOD_C2"; |
| 144 | case X86_FPU_FLAGS_MODIFY_C3cxx . . $ `include/capstone/x86.h:139:9`!: |
| 145 | return "MOD_C3"; |
| 146 | case X86_FPU_FLAGS_RESET_C0cxx . . $ `include/capstone/x86.h:140:9`!: |
| 147 | return "RESET_C0"; |
| 148 | case X86_FPU_FLAGS_RESET_C1cxx . . $ `include/capstone/x86.h:141:9`!: |
| 149 | return "RESET_C1"; |
| 150 | case X86_FPU_FLAGS_RESET_C2cxx . . $ `include/capstone/x86.h:142:9`!: |
| 151 | return "RESET_C2"; |
| 152 | case X86_FPU_FLAGS_RESET_C3cxx . . $ `include/capstone/x86.h:143:9`!: |
| 153 | return "RESET_C3"; |
| 154 | case X86_FPU_FLAGS_SET_C0cxx . . $ `include/capstone/x86.h:144:9`!: |
| 155 | return "SET_C0"; |
| 156 | case X86_FPU_FLAGS_SET_C1cxx . . $ `include/capstone/x86.h:145:9`!: |
| 157 | return "SET_C1"; |
| 158 | case X86_FPU_FLAGS_SET_C2cxx . . $ `include/capstone/x86.h:146:9`!: |
| 159 | return "SET_C2"; |
| 160 | case X86_FPU_FLAGS_SET_C3cxx . . $ `include/capstone/x86.h:147:9`!: |
| 161 | return "SET_C3"; |
| 162 | case X86_FPU_FLAGS_UNDEFINED_C0cxx . . $ `include/capstone/x86.h:148:9`!: |
| 163 | return "UNDEF_C0"; |
| 164 | case X86_FPU_FLAGS_UNDEFINED_C1cxx . . $ `include/capstone/x86.h:149:9`!: |
| 165 | return "UNDEF_C1"; |
| 166 | case X86_FPU_FLAGS_UNDEFINED_C2cxx . . $ `include/capstone/x86.h:150:9`!: |
| 167 | return "UNDEF_C2"; |
| 168 | case X86_FPU_FLAGS_UNDEFINED_C3cxx . . $ `include/capstone/x86.h:151:9`!: |
| 169 | return "UNDEF_C3"; |
| 170 | case X86_FPU_FLAGS_TEST_C0cxx . . $ `include/capstone/x86.h:152:9`!: |
| 171 | return "TEST_C0"; |
| 172 | case X86_FPU_FLAGS_TEST_C1cxx . . $ `include/capstone/x86.h:153:9`!: |
| 173 | return "TEST_C1"; |
| 174 | case X86_FPU_FLAGS_TEST_C2cxx . . $ `include/capstone/x86.h:154:9`!: |
| 175 | return "TEST_C2"; |
| 176 | case X86_FPU_FLAGS_TEST_C3cxx . . $ `include/capstone/x86.h:155:9`!: |
| 177 | return "TEST_C3"; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | void print_insn_detail_x86cxx . . $ print_insn_detail_x86(cd3d2a1a07155122).(cshcxx . . $ csh# ud, cs_modecxx . . $ cs_mode# mode, cs_insncxx . . $ cs_insn# *ins) |
| 182 | { |
| 183 | int count, i; |
| 184 | cs_x86cxx . . $ cs_x86# *x86; |
| 185 | cs_regscxx . . $ cs_regs# regs_read, regs_write; |
| 186 | uint8_tcxx . . $ uint8_t# regs_read_count, regs_write_count; |
| 187 | |
| 188 | // detail can be NULL on "data" instruction if SKIPDATA option is turned ON |
| 189 | if (ins->detailcxx . . $ cs_insn#detail. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 190 | return; |
| 191 | |
| 192 | x86 = &(ins->detailcxx . . $ cs_insn#detail.->x86cxx . . $ cs_detail#$anonymous_type_0#x86.); |
| 193 | |
| 194 | print_string_hexcxx . . $ print_string_hex(24a4beb24605093f).("\tPrefix:", x86->prefixcxx . . $ cs_x86#prefix., 4); |
| 195 | print_string_hexcxx . . $ print_string_hex(24a4beb24605093f).("\tOpcode:", x86->opcodecxx . . $ cs_x86#opcode., 4); |
| 196 | printfcxx . . $ printf(581fddd72a8db8fc).("\trex: 0x%x\n", x86->rexcxx . . $ cs_x86#rex.); |
| 197 | printfcxx . . $ printf(581fddd72a8db8fc).("\taddr_size: %u\n", x86->addr_sizecxx . . $ cs_x86#addr_size.); |
| 198 | printfcxx . . $ printf(581fddd72a8db8fc).("\tmodrm: 0x%x\n", x86->modrmcxx . . $ cs_x86#modrm.); |
| 199 | printfcxx . . $ printf(581fddd72a8db8fc).("\tdisp: 0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`! "\n", x86->dispcxx . . $ cs_x86#disp.); |
| 200 | |
| 201 | // SIB is not available in 16-bit mode |
| 202 | if ((mode & CS_MODE_16cxx . . $ CS_MODE_16.) == 0) { |
| 203 | printfcxx . . $ printf(581fddd72a8db8fc).("\tsib: 0x%x\n", x86->sibcxx . . $ cs_x86#sib.); |
| 204 | if (x86->sib_basecxx . . $ cs_x86#sib_base. != X86_REG_INVALIDcxx . . $ X86_REG_INVALID.) |
| 205 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\tsib_base: %s\n", cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, x86->sib_basecxx . . $ cs_x86#sib_base.)); |
| 206 | if (x86->sib_indexcxx . . $ cs_x86#sib_index. != X86_REG_INVALIDcxx . . $ X86_REG_INVALID.) |
| 207 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\tsib_index: %s\n", cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, x86->sib_indexcxx . . $ cs_x86#sib_index.)); |
| 208 | if (x86->sib_scalecxx . . $ cs_x86#sib_scale. != 0) |
| 209 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\tsib_scale: %d\n", x86->sib_scalecxx . . $ cs_x86#sib_scale.); |
| 210 | } |
| 211 | |
| 212 | // XOP code condition |
| 213 | if (x86->xop_cccxx . . $ cs_x86#xop_cc. != X86_XOP_CC_INVALIDcxx . . $ X86_XOP_CC_INVALID.) { |
| 214 | printfcxx . . $ printf(581fddd72a8db8fc).("\txop_cc: %u\n", x86->xop_cccxx . . $ cs_x86#xop_cc.); |
| 215 | } |
| 216 | |
| 217 | // SSE code condition |
| 218 | if (x86->sse_cccxx . . $ cs_x86#sse_cc. != X86_SSE_CC_INVALIDcxx . . $ X86_SSE_CC_INVALID.) { |
| 219 | printfcxx . . $ printf(581fddd72a8db8fc).("\tsse_cc: %u\n", x86->sse_cccxx . . $ cs_x86#sse_cc.); |
| 220 | } |
| 221 | |
| 222 | // AVX code condition |
| 223 | if (x86->avx_cccxx . . $ cs_x86#avx_cc. != X86_AVX_CC_INVALIDcxx . . $ X86_AVX_CC_INVALID.) { |
| 224 | printfcxx . . $ printf(581fddd72a8db8fc).("\tavx_cc: %u\n", x86->avx_cccxx . . $ cs_x86#avx_cc.); |
| 225 | } |
| 226 | |
| 227 | // AVX Suppress All Exception |
| 228 | if (x86->avx_saecxx . . $ cs_x86#avx_sae.) { |
| 229 | printfcxx . . $ printf(581fddd72a8db8fc).("\tavx_sae: %u\n", x86->avx_saecxx . . $ cs_x86#avx_sae.); |
| 230 | } |
| 231 | |
| 232 | // AVX Rounding Mode |
| 233 | if (x86->avx_rmcxx . . $ cs_x86#avx_rm. != X86_AVX_RM_INVALIDcxx . . $ X86_AVX_RM_INVALID.) { |
| 234 | printfcxx . . $ printf(581fddd72a8db8fc).("\tavx_rm: %u\n", x86->avx_rmcxx . . $ cs_x86#avx_rm.); |
| 235 | } |
| 236 | |
| 237 | // Print out all immediate operands |
| 238 | count = cs_op_countcxx . . $ cs_op_count(2f5b4d866c2a3c8c).(ud, ins, X86_OP_IMMcxx . . $ X86_OP_IMM.); |
| 239 | if (count > 0) { |
| 240 | printfcxx . . $ printf(581fddd72a8db8fc).("\timm_count: %u\n", count); |
| 241 | for (i = 1; i < count + 1; i++) { |
| 242 | int index = cs_op_indexcxx . . $ cs_op_index(d588ccf4d27e4ce9).(ud, ins, X86_OP_IMMcxx . . $ X86_OP_IMM., i); |
| 243 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\timms[%u]: 0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`! "\n", i, x86->operandscxx . . $ cs_x86#operands.[index].immcxx . . $ cs_x86_op#$anonymous_type_0#imm.); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | if (x86->op_countcxx . . $ cs_x86#op_count.) |
| 248 | printfcxx . . $ printf(581fddd72a8db8fc).("\top_count: %u\n", x86->op_countcxx . . $ cs_x86#op_count.); |
| 249 | |
| 250 | // Print out all operands |
| 251 | for (i = 0; i < x86->op_countcxx . . $ cs_x86#op_count.; i++) { |
| 252 | cs_x86_opcxx . . $ cs_x86_op# *op = &(x86->operandscxx . . $ cs_x86#operands.[i]); |
| 253 | |
| 254 | switch((int)op->typecxx . . $ cs_x86_op#type.) { |
| 255 | case X86_OP_REGcxx . . $ X86_OP_REG.: |
| 256 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: REG = %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, op->regcxx . . $ cs_x86_op#$anonymous_type_0#reg.)); |
| 257 | break; |
| 258 | case X86_OP_IMMcxx . . $ X86_OP_IMM.: |
| 259 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: IMM = 0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`! "\n", i, op->immcxx . . $ cs_x86_op#$anonymous_type_0#imm.); |
| 260 | break; |
| 261 | case X86_OP_MEMcxx . . $ X86_OP_MEM.: |
| 262 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: MEM\n", i); |
| 263 | if (op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..segmentcxx . . $ x86_op_mem#segment. != X86_REG_INVALIDcxx . . $ X86_REG_INVALID.) |
| 264 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.segment: REG = %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..segmentcxx . . $ x86_op_mem#segment.)); |
| 265 | if (op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..basecxx . . $ x86_op_mem#base. != X86_REG_INVALIDcxx . . $ X86_REG_INVALID.) |
| 266 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.base: REG = %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..basecxx . . $ x86_op_mem#base.)); |
| 267 | if (op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..indexcxx . . $ x86_op_mem#index. != X86_REG_INVALIDcxx . . $ X86_REG_INVALID.) |
| 268 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.index: REG = %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..indexcxx . . $ x86_op_mem#index.)); |
| 269 | if (op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..scalecxx . . $ x86_op_mem#scale. != 1) |
| 270 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.scale: %u\n", i, op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..scalecxx . . $ x86_op_mem#scale.); |
| 271 | if (op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..dispcxx . . $ x86_op_mem#disp. != 0) |
| 272 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.disp: 0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`! "\n", i, op->memcxx . . $ cs_x86_op#$anonymous_type_0#mem..dispcxx . . $ x86_op_mem#disp.); |
| 273 | break; |
| 274 | default: |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | // AVX broadcast type |
| 279 | if (op->avx_bcastcxx . . $ cs_x86_op#avx_bcast. != X86_AVX_BCAST_INVALIDcxx . . $ X86_AVX_BCAST_INVALID.) |
| 280 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].avx_bcast: %u\n", i, op->avx_bcastcxx . . $ cs_x86_op#avx_bcast.); |
| 281 | |
| 282 | // AVX zero opmask {z} |
| 283 | if (op->avx_zero_opmaskcxx . . $ cs_x86_op#avx_zero_opmask. != falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!) |
| 284 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].avx_zero_opmask: TRUE\n", i); |
| 285 | |
| 286 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].size: %u\n", i, op->sizecxx . . $ cs_x86_op#size.); |
| 287 | |
| 288 | switch(op->accesscxx . . $ cs_x86_op#access.) { |
| 289 | default: |
| 290 | break; |
| 291 | case CS_AC_READcxx . . $ CS_AC_READ.: |
| 292 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].access: READ\n", i); |
| 293 | break; |
| 294 | case CS_AC_WRITEcxx . . $ CS_AC_WRITE.: |
| 295 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].access: WRITE\n", i); |
| 296 | break; |
| 297 | case CS_AC_READcxx . . $ CS_AC_READ. | CS_AC_WRITEcxx . . $ CS_AC_WRITE.: |
| 298 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].access: READ | WRITE\n", i); |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | // Print out all registers accessed by this instruction (either implicit or explicit) |
| 304 | if (!cs_regs_accesscxx . . $ cs_regs_access(4779ec53ff278361).(ud, ins, |
| 305 | regs_read, ®s_read_count, |
| 306 | regs_write, ®s_write_count)) { |
| 307 | if (regs_read_count) { |
| 308 | printfcxx . . $ printf(581fddd72a8db8fc).("\tRegisters read:"); |
| 309 | for(i = 0; i < regs_read_count; i++) { |
| 310 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, regs_read[i])); |
| 311 | } |
| 312 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 313 | } |
| 314 | |
| 315 | if (regs_write_count) { |
| 316 | printfcxx . . $ printf(581fddd72a8db8fc).("\tRegisters modified:"); |
| 317 | for(i = 0; i < regs_write_count; i++) { |
| 318 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(ud, regs_write[i])); |
| 319 | } |
| 320 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | if (x86->eflagscxx . . $ cs_x86#$anonymous_type_1#eflags. || x86->fpu_flagscxx . . $ cs_x86#$anonymous_type_1#fpu_flags.) { |
| 325 | for(i = 0; i < ins->detailcxx . . $ cs_insn#detail.->groups_countcxx . . $ cs_detail#groups_count.; i++) { |
| 326 | if (ins->detailcxx . . $ cs_insn#detail.->groupscxx . . $ cs_detail#groups.[i] == X86_GRP_FPUcxx . . $ X86_GRP_FPU.) { |
| 327 | printfcxx . . $ printf(581fddd72a8db8fc).("\tFPU_FLAGS:"); |
| 328 | for(i = 0; i <= 63; i++) |
| 329 | if (x86->fpu_flagscxx . . $ cs_x86#$anonymous_type_1#fpu_flags. & ((uint64_tcxx . . $ uint64_t#)1 << i)) { |
| 330 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", get_fpu_flag_namecxx . . $ get_fpu_flag_name(30dde979ed96a187).((uint64_tcxx . . $ uint64_t#)1 << i)); |
| 331 | } |
| 332 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 333 | break; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | if (i == ins->detailcxx . . $ cs_insn#detail.->groups_countcxx . . $ cs_detail#groups_count.) { |
| 338 | printfcxx . . $ printf(581fddd72a8db8fc).("\tEFLAGS:"); |
| 339 | for(i = 0; i <= 63; i++) |
| 340 | if (x86->eflagscxx . . $ cs_x86#$anonymous_type_1#eflags. & ((uint64_tcxx . . $ uint64_t#)1 << i)) { |
| 341 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", get_eflag_namecxx . . $ get_eflag_name(30dde979ed96a187).((uint64_tcxx . . $ uint64_t#)1 << i)); |
| 342 | } |
| 343 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 344 | } |
| 345 | } |
| 346 | } |