14 #define isx86separator(x) ( \
15 (x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r' || (x) == ' ' || \
16 (x) == ',' || (x) == ';' || (x) == '[' || (x) == ']' || \
17 (x) == '(' || (x) == ')' || (x) == '{' || (x) == '}' || (x) == '\x1b')
21 if (strstr(flag->
name,
"main") || strstr(flag->
name,
"entry")) {
24 if (strchr(flag->
name,
'.')) {
42 strcpy(
dst + strlen(
src), endNum);
49 if (!strncmp(
p,
"0x", 2)) {
59 if (*
p ==
'h' || *
p ==
'H') {
73 char *
p = strstr(
s,
k);
77 char *
s =
p + strlen(
k);
78 char *
d =
p + strlen(
v);
79 memmove(
d,
s, strlen(
s) + 1);
80 memmove(
p,
v, strlen(
v));
88 bool ansi_found =
false;
92 if (
p[0] == 0x1b &&
p[1] ==
'[') {
95 for (; *
p && *
p !=
'J' && *
p !=
'm' && *
p !=
'H';
p++) {
111 isSpace = (*o ==
' ' || *o ==
',' || *o ==
'[');
121 for (; *t && *t !=
']'; t++) {
149 for (
i = 0;
i < 64;
i++) {
158 if (
x86 && *
k ==
'r') {
176 static bool is_lea(
const char *asm_str) {
178 bool colored = asm_str[0] ==
'\x1b';
186 char *ptr = data, *ptr2, *ptr_backup;
192 if (
p &&
p->cur &&
p->cur->name) {
193 if (strstr(
p->cur->name,
"x86")) {
196 if (strstr(
p->cur->name,
"m68k")) {
199 if (strstr(
p->cur->name,
"arm")) {
224 for (ptr2 = ptr;
IS_DIGIT(*ptr2); ptr2++) {
227 if (*ptr2 ==
'.' &&
IS_DIGIT(ptr2[1])) {
240 for (ptr2 = ptr; *ptr2 && (*ptr2 !=
']' && (*ptr2 !=
'\x1b') && !
IS_SEPARATOR(*ptr2)); ptr2++) {
245 if (
off >=
p->minval) {
246 fcn =
p->analb.get_fcn_in(
p->analb.analysis,
off, 0);
257 flag =
p->flag_get(
f,
off);
263 (ptr != ptr2) ? ptr2 :
"");
269 bool remove_brackets =
false;
270 flag =
p->flag_get(
f,
off);
271 if ((!flag ||
arm) &&
p->subrel_addr) {
272 remove_brackets = lea || (
arm &&
p->subrel_addr);
273 flag2 =
p->flag_get(
f,
p->subrel_addr);
278 if (flag && !strncmp(flag->
name,
"section.", 8)) {
283 if (
p->notin_flagspace) {
284 if (
p->flagspace == flag->
space) {
287 }
else if (
p->flagspace && (
p->flagspace != flag->
space)) {
297 if (remove_brackets && ptr != ptr2 && *ptr) {
300 for (ptr--; ptr > data && *ptr !=
'['; ptr--) {
315 int maxflagname =
p->maxflagnamelen;
316 if (maxflagname > 0 && strlen(flagname) > maxflagname) {
317 char *doublelower = (
char *)
rz_str_rstr(flagname,
"__");
318 char *doublecolon = (
char *)
rz_str_rstr(flagname,
"::");
320 if (doublelower && doublecolon) {
321 token =
RZ_MAX(doublelower, doublecolon);
323 token = doublelower ? doublelower : doublecolon;
326 const char *
mod = doublecolon ?
"(cxx)" :
"(...)";
342 snprintf(
str,
len,
"%s%s%s", data, flagname, (ptr != ptr2) ? ptr2 :
"");
346 const char *
p = strchr(
str,
'[');
347 const char *
a = strchr(
str,
'+');
348 const char *
m = strchr(
str,
'*');
353 if (
p->subrel_addr && !banned && lea) {
354 int flag_len = strlen(flag->
name);
355 char *ptr_end =
str + strlen(data) + flag_len - 1;
356 char *ptr_right = ptr_end + 1, *ptr_left, *ptr_esc;
357 bool ansi_found =
false;
362 if (*ptr_right == 0x1b) {
363 while (*ptr_right && *ptr_right !=
'm') {
372 if (*ptr_right ==
']') {
373 ptr_left = ptr_esc = ptr_end - flag_len;
374 while (ptr_left >=
str) {
375 if (*ptr_left ==
'[' &&
376 (ptr_left ==
str || *(ptr_left - 1) != 0x1b)) {
381 if (ptr_left <
str) {
384 for (; ptr_esc >=
str && *ptr_esc != 0x1b; ptr_esc--) {
388 ptr_esc = ptr_end - flag_len + 1;
390 int copied_len = ptr_end - ptr_esc + 1;
391 if (copied_len < 1) {
394 memmove(ptr_left, ptr_esc, copied_len);
395 char *dptr_left = strcpy(ptr_left + copied_len,
396 (ansi_found && ptr_right - ptr_end + 1 >= 4) ?
Color_RESET :
"");
397 int dlen = strlen(dptr_left);
399 char *dptr_end = ptr_right + 1;
403 int llen = dptr_end - (ptr_right + 1);
404 memmove(dptr_left, ptr_right + 1, llen);
429 const int nw = hint->
nword;
434 int pnumleft, immbase = hint->
immbase;
435 char num[256] = { 0 }, *pnum, *
tmp;
442 strncpy(
num, ptr,
sizeof(
num) - 2);
453 while (
tmp < ptr - 1 && *
tmp !=
'm') {
457 }
else if (*
tmp ==
'[') {
459 }
else if (*
tmp ==
']') {
470 pnumleft =
sizeof(
num) - 2;
480 ch =
off >> (8 * (
sizeof(
off) - 1));
485 if (
num[1] ==
'\0' && ch ==
'\0') {
492 int sz =
snprintf(pnum, pnumleft,
"\\x%2.2x", ch);
514 }
else if (
off >> 16) {
555 if (
p &&
p->analb.analysis &&
p->analb.analysis->syscall) {
581 eprintf(
"Invalid str/data inputs\n");
594 if (
p->cur &&
p->cur->filter) {
595 return p->cur->filter(
p,
addr,
f, data,
str,
len, big_endian);
602 const size_t out_len = 256;
static int opstr(RzAsm *a, ut8 *data, const Opcode *op)
static RASN1String * newstr(const char *string)
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
RZ_API RzFlagItem * rz_flag_get_i(RzFlag *f, ut64 off)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
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 void insert(char *dst, const char *src)
static void __replaceRegisters(RzReg *reg, char *s, bool x86)
static int parse_number(const char *str)
RZ_API char * rz_parse_filter_dup(RzParse *p, ut64 addr, const char *opstr)
static bool is_lea(const char *asm_str)
Checks if the given asm string is an x86 "lea" instruction.
static void replaceWords(char *s, const char *k, const char *v)
static bool isvalidflag(RzFlagItem *flag)
RZ_API bool rz_parse_filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
filter the opcode in data into str by following the flags and hints information
static char * findEnd(const char *s)
#define isx86separator(x)
static char * findNextNumber(char *op)
static bool filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
RZ_API const char * rz_reg_get_name(RzReg *reg, int role)
RZ_API const RzList * rz_reg_get_list(RzReg *reg, int type)
RZ_API const char * rz_reg_get_role(int role)
#define rz_return_val_if_fail(expr, val)
RZ_API void rz_mem_swapendian(ut8 *dest, const ut8 *orig, int size)
RZ_API ut64 rz_num_tail_base(RzNum *num, ut64 addr, ut64 off)
RZ_API int rz_num_to_bits(char *out, ut64 num)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API int rz_regex_match(const char *pattern, const char *flags, const char *text)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API bool rz_str_startswith_icase(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case insensitive)
RZ_API const char * rz_str_rstr(const char *base, const char *p)
RZ_API const char * rz_str_casestr(const char *a, const char *b)
RZ_API void rz_syscall_item_free(RzSyscallItem *si)
RZ_API RzSyscallItem * rz_syscall_get(RzSyscall *s, int num, int swi)
static int isSpace(char ch)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()