Go to the documentation of this file.
5 #if defined(_MSC_VER) && _MSC_VER < 1900
6 #define _CRT_SECURE_NO_WARNINGS
7 #define snprintf _snprintf
34 hex_out = (
char *) malloc(
len*2 + 1);
35 if (!hex_out) {
goto Exit; }
37 for (
i = 0;
i <
len; ++
i) {
38 snprintf(hex_out + (
i*2), 2,
"%02x",
str[
i]);
51 #define _this_printf(...) \
54 used = snprintf(buf + *cur, *left, __VA_ARGS__); \
63 if (ins->detail == NULL)
66 arm = &(ins->detail->arm);
71 for (
i = 0;
i <
arm->op_count;
i++) {
73 switch((
int)
op->type) {
93 if (
op->mem.scale != 1)
95 if (
op->mem.disp != 0)
123 if (
arm->update_flags) {
127 if (
arm->writeback) {
137 size_t cur=0, left=2048;
148 #define MAX_INVALID_CODES 16
166 (
unsigned char *)
"\xbd\xe8\x1e\xff",
168 "invalid thumb2 pop because sp used and because both pc and lr are "
169 "present at the same time"
181 printf(
"\nShould be invalid\n"
182 "-----------------\n");
184 for (
i = 0;
i <
sizeof(invalids)/
sizeof(invalids[0]);
i++) {
191 printf(
"Failed on cs_open() with error returned: %u\n",
err);
198 for (j = 0; j <
invalid->num_invalid_codes; ++j) {
200 char *hex_str = NULL;
219 printf(
" 0x%"PRIx64
":\t%s\t%s\n",
220 insn[
k].address, insn[
k].mnemonic, insn[
k].op_str);
226 printf(
" SUCCESS: invalid\n");
242 #define MAX_VALID_CODES 16
258 {{ (
unsigned char *)
"\x00\xf0\x26\xe8", 4, 0x352,
259 "0x352:\tblx\t#0x3a0\n"
261 "\t\toperands[0].type: IMM = 0x3a0\n",
263 "thumb2 blx with misaligned immediate"
264 }, { (
unsigned char *)
"\x05\xdd", 2, 0x1f0,
265 "0x1f0:\tble\t#0x1fe\n"
267 "\t\toperands[0].type: IMM = 0x1fe\n"
268 "\tCode condition: 14\n",
270 "thumb b cc with thumb-aligned target"
271 }, { (
unsigned char *)
"\xbd\xe8\xf0\x8f", 4, 0,
272 "0x0:\tpop.w\t{r4, r5, r6, r7, r8, r9, r10, r11, pc}\n"
274 "\t\toperands[0].type: REG = r4\n"
275 "\t\toperands[1].type: REG = r5\n"
276 "\t\toperands[2].type: REG = r6\n"
277 "\t\toperands[3].type: REG = r7\n"
278 "\t\toperands[4].type: REG = r8\n"
279 "\t\toperands[5].type: REG = r9\n"
280 "\t\toperands[6].type: REG = r10\n"
281 "\t\toperands[7].type: REG = r11\n"
282 "\t\toperands[8].type: REG = pc\n",
284 "thumb2 pop that should be valid"
298 for (
i = 0;
i <
sizeof(valids)/
sizeof(valids[0]);
i++) {
305 printf(
"Failed on cs_open() with error returned: %u\n",
err);
312 #define _this_printf(...) \
315 used = snprintf(tmp_buf + cur, left, __VA_ARGS__); \
319 printf(
"\nShould be valid\n"
320 "---------------\n");
322 for (j = 0; j <
valid->num_valid_codes; ++j) {
328 char * hex_str = NULL;
335 printf(
"%s %s @ 0x%04x: %s\n %s",
351 "0x%"PRIx64
":\t%s\t%s\n",
352 insn[
k].address, insn[
k].mnemonic,
359 max_len = strlen(tmp_buf);
361 if (tmp_len > max_len) {
367 " ERROR: '''\n%s''' does not match"
368 " expected '''\n%s'''\n",
372 printf(
" SUCCESS: valid\n");
378 printf(
"ERROR: invalid\n");
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close(csh *handle)
@ CS_OPT_SYNTAX_NOREGNAME
Prints register name with only number (CS_OPT_SYNTAX)
@ CS_OPT_SYNTAX
Assembly output syntax.
CAPSTONE_EXPORT size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn **insn)
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
static void test_valids()
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
#define MAX_INVALID_CODES
cs_arch
Architecture type.
@ CS_OPT_DETAIL
Break down instruction structure into details.
struct invalid_code invalid_codes[MAX_INVALID_CODES]
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
struct valid_code valid_codes[MAX_VALID_CODES]
static void test_invalids()
@ ARM_SFT_ASR_REG
shift with register
const CAPSTONE_EXPORT char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
unsigned __int64 uint64_t
@ ARM_OP_PIMM
P-Immediate (coprocessor registers)
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
#define _this_printf(...)
@ CS_MODE_THUMB
ARM's Thumb mode, including Thumb-2.
@ ARM_OP_REG
= CS_OP_REG (Register operand).
@ ARM_OP_FP
= CS_OP_FP (Floating-Point operand).
@ ARM_CC_AL
Always (unconditional) Always (unconditional)
static void snprint_insn_detail(char *buf, size_t *cur, size_t *left, cs_insn *ins)
@ CS_ARCH_ARM
ARM architecture (including Thumb, Thumb-2)
static void print_insn_detail(cs_insn *ins)
@ ARM_OP_IMM
= CS_OP_IMM (Immediate operand).
@ ARM_OP_CIMM
C-Immediate (coprocessor registers)
CAPSTONE_EXPORT void CAPSTONE_API cs_free(cs_insn *insn, size_t count)
@ ARM_OP_MEM
= CS_OP_MEM (Memory operand).
static char * hex_string(unsigned char *str, size_t len)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:31