| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | #include <capstone/capstone.h> |
| 5 | #include "cstool.h" |
| 6 | |
| 7 | void print_insn_detail_wasm(csh handle, cs_insn *ins) |
| 8 | { |
| 9 | cs_wasm *wasm; |
| 10 | |
| 11 | // detail can be NULL on "data" instruction if SKIPDATA option is turned ON |
| 12 | if (ins->detail == NULL) |
| 13 | return; |
| 14 | |
| 15 | wasm = &(ins->detail->wasm); |
| 16 | if (wasm->op_count > 0) { |
| 17 | unsigned int i; |
| 18 | |
| 19 | printf("\tOperand count: %d\n", wasm->op_count); |
| 20 | |
| 21 | for (i = 0; i < wasm->op_count; i++) { |
| 22 | switch (wasm->operands[i].type) { |
| 23 | default: |
| 24 | break; |
| 25 | case WASM_OP_INT7: |
| 26 | printf("\t\tOperand[%u] type: int7\n", i); |
| 27 | printf("\t\tOperand[%u] value: %d\n", i, wasm->operands[i].int7); |
| 28 | break; |
| 29 | case WASM_OP_UINT32: |
| 30 | printf("\t\tOperand[%u] type: uint32\n", i); |
| 31 | printf("\t\tOperand[%u] value: 0x%x\n", i, wasm->operands[i].uint32); |
| 32 | break; |
| 33 | case WASM_OP_UINT64: |
| 34 | printf("\t\tOperand[%u] type: uint64\n", i); |
| 35 | printf("\t\tOperand[%u] value: 0x%" PRIx64 "\n", i, wasm->operands[i].uint64); |
| 36 | break; |
| 37 | case WASM_OP_VARUINT32: |
| 38 | printf("\t\tOperand[%u] type: varuint32\n", i); |
| 39 | printf("\t\tOperand[%u] value: 0x%x\n", i, wasm->operands[i].varuint32); |
| 40 | break; |
| 41 | case WASM_OP_VARUINT64: |
| 42 | printf("\t\tOperand[%u] type: varuint64\n", i); |
| 43 | printf("\t\tOperand[%u] value: 0x%" PRIx64 "\n", i, wasm->operands[i].varuint64); |
| 44 | break; |
| 45 | } |
| 46 | |
| 47 | printf("\t\tOperand[%u] size: %u\n", i, wasm->operands[i].size); |
| 48 | } |
| 49 | } |
| 50 | } |