18 #define MAXPSEUDOOPS 10
26 {
"adc",
"# += #", { 1, 2 } },
27 {
"add",
"# += #", { 1, 2 } },
28 {
"and",
"# &= #", { 1, 2 } },
29 {
"call",
"# ()", { 1 } },
30 {
"cmove",
"if (!var) # = #", { 1, 2 } },
31 {
"cmovl",
"if (var < 0) # = #", { 1, 2 } },
32 {
"cmp",
"var = # - #", { 1, 2 } },
33 {
"cmpsq",
"var = # - #", { 1, 2 } },
34 {
"cmpsb",
"while (CX != 0) { var = *(DS*16 + SI) - *(ES*16 + DI); SI++; DI++; CX--; if (!var) break; }", { 0 } },
35 {
"cmpsw",
"while (CX != 0) { var = *(DS*16 + SI) - *(ES*16 + DI); SI+=4; DI+=4; CX--; if (!var) break; }", { 0 } },
36 {
"dec",
"#--", { 1 } },
37 {
"div",
"# /= #", { 1, 2 } },
38 {
"fabs",
"abs(#)", { 1 } },
39 {
"fadd",
"# = # + #", { 1, 1, 2 } },
40 {
"fcomp",
"var = # - #", { 1, 2 } },
41 {
"fcos",
"# = cos(#)", { 1, 1 } },
42 {
"fdiv",
"# = # / #", { 1, 1, 2 } },
43 {
"fiadd",
"# = # / #", { 1, 1, 2 } },
44 {
"ficom",
"var = # - #", { 1, 2 } },
45 {
"fidiv",
"# = # / #", { 1, 1, 2 } },
46 {
"fidiv",
"# = # * #", { 1, 1, 2 } },
47 {
"fisub",
"# = # - #", { 1, 1, 2 } },
48 {
"fnul",
"# = # * #", { 1, 1, 2 } },
49 {
"fnop",
" ", { 0 } },
50 {
"frndint",
"# = (int) #", { 1, 1 } },
51 {
"fsin",
"# = sin(#)", { 1, 1 } },
52 {
"fsqrt",
"# = sqrt(#)", { 1, 1 } },
53 {
"fsub",
"# = # - #", { 1, 1, 2 } },
54 {
"fxch",
"#,# = #,#", { 1, 2, 2, 1 } },
55 {
"idiv",
"# /= #", { 1, 2 } },
56 {
"imul",
"# = # * #", { 1, 2, 3 } },
57 {
"in",
"# = io[#]", { 1, 2 } },
58 {
"inc",
"#++", { 1 } },
59 {
"ja",
"if (((unsigned) var) > 0) goto #", { 1 } },
60 {
"jb",
"if (((unsigned) var) < 0) goto #", { 1 } },
61 {
"jbe",
"if (((unsigned) var) <= 0) goto #", { 1 } },
62 {
"je",
"if (!var) goto #", { 1 } },
63 {
"jg",
"if (var > 0) goto #", { 1 } },
64 {
"jge",
"if (var >= 0) goto #", { 1 } },
65 {
"jle",
"if (var <= 0) goto #", { 1 } },
66 {
"jmp",
"goto #", { 1 } },
67 {
"jne",
"if (var) goto #", { 1 } },
68 {
"lea",
"# = #", { 1, 2 } },
69 {
"mov",
"# = #", { 1, 2 } },
70 {
"movabs",
"# = #", { 1, 2 } },
71 {
"movq",
"# = #", { 1, 2 } },
72 {
"movaps",
"# = #", { 1, 2 } },
73 {
"movups",
"# = #", { 1, 2 } },
74 {
"movsd",
"# = #", { 1, 2 } },
75 {
"movsx",
"# = #", { 1, 2 } },
76 {
"movsxd",
"# = #", { 1, 2 } },
77 {
"movzx",
"# = #", { 1, 2 } },
78 {
"movntdq",
"# = #", { 1, 2 } },
79 {
"movnti",
"# = #", { 1, 2 } },
80 {
"movntpd",
"# = #", { 1, 2 } },
81 {
"pcmpeqb",
"# == #", { 1, 2 } },
83 {
"movdqu",
"# = #", { 1, 2 } },
84 {
"movdqa",
"# = #", { 1, 2 } },
85 {
"pextrb",
"# = (byte) # [#]", { 1, 2, 3 } },
86 {
"palignr",
"# = # align #", { 1, 2, 3 } },
87 {
"pxor",
"# ^= #", { 1, 2 } },
88 {
"xorps",
"# ^= #", { 1, 2 } },
89 {
"mul",
"# = # * #", { 1, 2, 3 } },
90 {
"mulss",
"# = # * #", { 1, 2, 3 } },
91 {
"neg",
"# ~= #", { 1, 1 } },
93 {
"not",
"# = !#", { 1, 1 } },
94 {
"or",
"# |= #", { 1, 2 } },
95 {
"out",
"io[#] = #", { 1, 2 } },
96 {
"pop",
"pop #", { 1 } },
97 {
"push",
"push #", { 1 } },
98 {
"ret",
"return", { 0 } },
99 {
"sal",
"# <<= #", { 1, 2 } },
100 {
"sar",
"# >>= #", { 1, 2 } },
101 {
"sete",
"# = e", { 1 } },
102 {
"setne",
"# = ne", { 1 } },
103 {
"shl",
"# <<<= #", { 1, 2 } },
104 {
"shld",
"# <<<= #", { 1, 2 } },
105 {
"sbb",
"# = # - #", { 1, 1, 2 } },
106 {
"shr",
"# >>>= #", { 1, 2 } },
107 {
"shlr",
"# >>>= #", { 1, 2 } },
109 {
"sub",
"# -= #", { 1, 2 } },
110 {
"swap",
"var = #; # = #; # = var", { 1, 1, 2, 2 } },
111 {
"test",
"var = # & #", { 1, 2 } },
112 {
"xchg",
"#,# = #,#", { 1, 2, 2, 1 } },
113 {
"xadd",
"#,# = #,#+#", { 1, 2, 2, 1, 2 } },
114 {
"xor",
"# ^= #", { 1, 2 } },
118 if (argc > 2 && !strcmp(
argv[0],
"xor")) {
130 for (j = 0,
k = 0; ch !=
'\0'; j++,
k++) {
161 for (
i = 0;
i < argc;
i++) {
163 strcat(
newstr, (
i == 0 ||
i == argc - 1) ?
" " :
",");
170 char w0[256],
w1[256],
w2[256],
w3[256];
171 char str[1024] = { 0 };
173 size_t len = strlen(data);
175 char *
buf, *ptr, *optr, *
end;
176 if (
len >=
sizeof(
w0) || sz >=
sizeof(
w0)) {
186 ptr = strchr(
buf,
' ');
188 ptr = strchr(
buf,
'\t');
195 for (++ptr; *ptr ==
' '; ptr++) {
202 ptr = strchr(ptr,
',');
205 for (++ptr; *ptr ==
' '; ptr++) {
211 ptr = strchr(ptr,
',');
214 for (++ptr; *ptr ==
' '; ptr++) {
224 for (
i = 0;
i < 4;
i++) {
225 if (wa[
i][0] !=
'\0') {
231 if (strstr(
w0,
"mul")) {
243 if (strlen(wa[3]) > 2) {
249 if (wa[3][1] ==
'x' || wa[3][1] ==
'p' ||
250 wa[3][1] ==
'i' || wa[3][0] ==
'w') {
259 }
else if (nw == 3) {
266 }
else if (strstr(
w0,
"lea")) {
270 }
else if ((strstr(
w1,
"ax") || strstr(
w1,
"ah") || strstr(
w1,
"al")) && !
p->retleave_asm) {
271 if (!(
p->retleave_asm = (
char *)
malloc(sz))) {
276 }
else if ((strstr(
w0,
"leave") &&
p->retleave_asm) || (strstr(
w0,
"pop") && strstr(
w1,
"bp"))) {
280 }
else if (strstr(
w0,
"ret") &&
p->retleave_asm) {
283 }
else if (
p->retleave_asm) {
297 if (
p->localvar_only) {
312 if (
p->localvar_only) {
329 }
else if (
delta < 10) {
340 }
else if (
delta < 10) {
351 const int oplen =
op->size;
355 char oldstr[64],
newstr[64];
356 char *tstr =
strdup(data);
361 bool att = strchr(data,
'%');
371 while (word > tstr && *word !=
' ') {
389 char *ripend = strchr(
rip + 3,
']');
390 const char *plus = strchr(
rip,
'+');
391 const char *
neg = strchr(
rip,
'-');
417 bpargs =
p->varlist(
f,
'b');
418 spargs =
p->varlist(
f,
's');
420 bool ucase = *tstr >=
'A' && *tstr <=
'Z';
421 if (ucase && tstr[1]) {
422 ucase = tstr[1] >=
'A' && tstr[1] <=
'Z';
424 const char *ireg =
op->ireg;
426 rz_list_foreach (spargs, spiter, sparg) {
429 ?
p->get_ptr_at(
f, sparg->delta,
addr)
432 delta = sparg->delta;
442 reg =
p->get_reg_at(
f, sparg->delta,
addr);
453 char *ptr = strstr(tstr, oldstr);
454 if (ptr && (!att || *(ptr - 1) ==
' ')) {
456 char *
end = ptr + strlen(oldstr);
457 if (*
end !=
']' && *
end !=
'\0') {
465 ptr = strstr(tstr, oldstr);
466 if (ptr && (!att || *(ptr - 1) ==
' ')) {
473 rz_list_foreach (bpargs, bpargiter, bparg) {
476 ?
p->get_ptr_at(
f, bparg->delta,
addr)
479 delta = bparg->delta +
f->bp_off;
489 reg =
p->get_reg_at(
f, bparg->delta,
addr);
499 char *ptr = strstr(tstr, oldstr);
500 if (ptr && (!att || *(ptr - 1) ==
' ')) {
502 char *
end = ptr + strlen(oldstr);
503 if (*
end !=
']' && *
end !=
'\0') {
511 ptr = strstr(tstr, oldstr);
512 if (ptr && (!att || *(ptr - 1) ==
' ')) {
519 while (delta_first_digit >= 16) {
520 delta_first_digit /= 16;
523 snprintf(oldstr,
sizeof(oldstr) - 1,
"%s %c %s%xh",
reg, sign, delta_first_digit > 9 ?
"0" :
"", (
int)
delta);
530 if (strstr(tstr, oldstr) !=
NULL) {
542 bp[
sizeof(bp) - 1] = 0;
548 if (
len > strlen(tstr)) {
561 .
name =
"x86.pseudo",
562 .desc =
"X86 pseudo syntax",
567 #ifndef RZ_PLUGIN_INCORE
static ut32 neg(ArmOp *op)
static RASN1String * newstr(const char *string)
void rip(char *fname, off_t offset, unsigned int length)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static bool parse(RzParse *p, const char *data, RzStrBuf *sb)
static int replace(int argc, char *argv[], char *newstr)
static bool subvar(RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *data, char *str, int len)
RZ_API RzLibStruct rizin_plugin
static void mk_reg_str(const char *regname, int delta, bool sign, bool att, const char *ireg, char *dest, int len)
RzParsePlugin rz_parse_plugin_x86_pseudo
static void parse_localvar(RzParse *p, char *newstr, size_t newstr_len, const char *var, const char *reg, char sign, const char *ireg, bool att)
RZ_DEPRECATE struct rz_analysis_var_field_t RzAnalysisVarField
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API char * rz_str_replace_icase(char *str, const char *key, const char *val, int g, int keep_case)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API void rz_str_case(char *str, bool up)
RZ_API size_t rz_str_ncpy(char *dst, const char *src, size_t n)
Secure string copy with null terminator.
RZ_API int rz_snprintf(char *string, int len, const char *fmt,...) RZ_PRINTF_CHECK(3
RZ_API char * rz_str_replace(char *str, const char *key, const char *val, int g)
RZ_API int rz_str_replace_char(char *s, int a, int b)
RZ_API const char * rz_str_casestr(const char *a, const char *b)
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
RZ_API const char * rz_strbuf_setf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API void rz_strbuf_free(RzStrBuf *sb)
char * name[RZ_REG_NAME_LAST]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static char * regname(int reg)