19 if (
a->addr ==
b->addr) {
22 if (
a->addr <
b->addr) {
47 RzCoreAsmHit *
hit = _hit;
72 if (
h->name && !strcmp(
name,
h->name)) {
73 return h->esil ?
"Ae" :
"A_";
80 const char *feat2, *feat;
86 }
else if (ap->
bits == 0) {
116 switch (
state->mode) {
124 pj_ks(pj,
"license", license);
126 pj_ks(pj,
"features", feat);
157 rz_list_foreach (
a->plugins,
iter, ap) {
161 for (
i = 0;
i <
n;
i++) {
170 rz_list_foreach (
a->plugins,
iter, ap) {
171 const char *license = ap->
license
193 char *tok, *tokens[1024], *
code =
NULL, *ptr;
194 int idx, tidx = 0,
len = 0;
195 int tokcount, matchcount,
count = 0;
204 char *inp_arg = strchr(inp,
' ');
210 if (usrimm > usrimm2) {
211 eprintf(
"Error: /ci : Invalid range\n");
216 eprintf(
"error: block size too small\n");
232 for (tokcount = 0; tokcount <
RZ_ARRAY_SIZE(tokens) - 1; tokcount++) {
233 tok = strtok(tokcount ?
NULL : ptr,
";");
238 tokens[tokcount] = tok;
240 tokens[tokcount] =
NULL;
251 idx = 0, matchcount = 0;
270 for (
size_t i = 0;
i < 6; ++
i) {
294 if (
hit->len == -1) {
302 idx = (matchcount) ? tidx + 1 :
idx + 1;
310 }
else if (
mode ==
'e') {
324 idx = (matchcount) ? tidx + 1 :
idx + 1;
334 matches = strcmp(opst,
"invalid") && strcmp(opst,
"unaligned");
336 if (matches && tokens[matchcount]) {
338 matches = !
rz_str_ncasecmp(opst, tokens[matchcount], strlen(tokens[matchcount]));
339 }
else if (!regexp) {
340 matches = strstr(opst, tokens[matchcount]) !=
NULL;
347 if (align && align > 1) {
354 if (matchcount == tokcount - 1) {
365 if (
hit->len == -1) {
377 if (
count >= maxhits) {
382 }
else if (!matchcount) {
392 idx = matchcount ? tidx + 1 :
idx + 1;
449 RzCoreAsmHit *to_check_hit;
451 ut64 start_range, end_range;
455 start_range =
hit->addr;
456 end_range =
hit->addr +
hit->len;
457 rz_list_foreach_safe (hits,
iter, iter_tmp, to_check_hit) {
458 if (to_check_hit &&
is_hit_inrange(to_check_hit, start_range, end_range)) {
462 start_range, end_range, to_check_hit->addr,
463 to_check_hit->len, to_check_hit->valid, to_check_hit->addr,
464 to_check_hit->addr + to_check_hit->len);
478 RzCoreAsmHit dummy_value;
479 dummy_value.addr =
addr;
487 ut64 temp_instr_addr = current_instr_addr;
488 ut64 tmp_current_buf_pos = current_buf_pos;
489 ut64 start_range = current_instr_addr;
490 ut64 end_range = end_addr;
491 ut64 temp_instr_len = 0;
496 if (end_addr < current_instr_addr) {
501 while (tmp_current_buf_pos <
len && temp_instr_addr < end_addr) {
502 temp_instr_len =
len - tmp_current_buf_pos;
506 if (temp_instr_len == 0) {
514 found_addr =
find_addr(hits, temp_instr_addr);
515 start = temp_instr_addr;
516 end = temp_instr_addr + temp_instr_len;
521 ut32 prune_results = 0;
526 IFDBG eprintf(
"Pruned %u hits from list in fwd sweep.\n", prune_results);
532 temp_instr_addr += temp_instr_len;
533 tmp_current_buf_pos += temp_instr_len;
535 return temp_instr_addr;
541 ut64 next_buf_pos = current_buf_pos,
542 end_addr = current_instr_addr + (
len - current_buf_pos - 1);
546 next_buf_pos = current_buf_pos;
553 if (
start == start_range) {
556 if (
start <
end && start_range < end_range) {
558 if (start_range <=
start &&
start < end_range) {
560 }
else if (start_range <
end &&
end < end_range) {
562 }
else if (
start <= start_range && end_range <
end) {
567 }
else if (start_range > end_range) {
569 if (
start < end_range) {
571 }
else if (
end <= end_range) {
573 }
else if (start_range <=
start) {
575 }
else if (start_range <
end) {
580 if (
end < end_range) {
582 }
else if (
end <= end_range) {
584 }
else if (start_range <=
start) {
590 }
else if (start_range < end_range) {
591 if (
start < end_range) {
593 }
else if (
start <= start_range) {
595 }
else if (start_range <
end) {
607 start_range, end_range);
617 int numinstr, asmlen, ii;
650 if (strstr(
c->assembly,
"invalid") || strstr(
c->assembly,
".byte")) {
655 asmlen = strlen(
c->assembly);
656 for (ii = 0; ii < asmlen; ii++) {
657 if (
c->assembly[ii] ==
'\n') {
662 if (numinstr >=
n ||
idx > 16 *
n) {
668 for (hit_count = 0; hit_count <
n; hit_count++) {
680 RzCoreAsmHit dummy_value;
684 int current_instr_len = 0;
686 current_buf_pos =
len - 1,
689 memset(&dummy_value, 0,
sizeof(RzCoreAsmHit));
717 current_instr_len =
len - current_buf_pos + extra_padding;
718 IFDBG eprintf(
"current_buf_pos: 0x%" PFMT64x ", current_instr_len: %d\n", current_buf_pos, current_instr_len);
721 hit->addr = current_instr_addr;
722 hit->len = current_instr_len;
727 current_instr_addr--;
729 }
while (((
int)current_buf_pos >= 0) && (
int)(
len - current_buf_pos) >= 0 && hit_count <= max_hit_count);
740 ut8 max_invalid_b4_exit = 4,
741 last_num_invalid = 0;
742 int current_instr_len = 0;
747 RzCoreAsmHit dummy_value;
750 if (disassmble_each_addr) {
786 memset(&dummy_value, 0,
sizeof(RzCoreAsmHit));
789 current_buf_pos =
len - extra_padding - 1;
790 next_buf_pos =
len + extra_padding - 1;
791 current_instr_addr =
addr - 1;
798 current_instr_len = next_buf_pos - current_buf_pos;
801 ut32 byte_cnt = current_instr_len ? current_instr_len : 1;
802 eprintf(
"current_instr_addr: 0x%" PFMT64x ", current_buf_pos: 0x%" PFMT64x ", current_instr_len: %d \n", current_instr_addr, current_buf_pos, current_instr_len);
807 if (current_instr_len > 0) {
810 eprintf(
"op.buf_asm: <invalid>\n");
815 if (current_instr_len == 0 || strstr(
rz_strbuf_get(&
op.buf_asm),
"invalid")) {
816 if (current_instr_len == 0) {
817 current_instr_len = 1;
823 }
else if (current_buf_pos + current_instr_len == next_buf_pos) {
828 ut32 purge_results = 0;
830 IFDBG eprintf(
" handling underlap case: current_instr_addr: 0x%" PFMT64x ".\n", current_instr_addr);
839 next_buf_pos = current_buf_pos;
840 last_num_invalid = 0;
842 }
else if (current_buf_pos + current_instr_len < next_buf_pos) {
846 next_buf_pos = current_buf_pos;
849 last_num_invalid = 0;
851 }
else if (current_buf_pos + current_instr_len > next_buf_pos) {
853 next_buf_pos = current_buf_pos;
855 last_num_invalid = 0;
860 current_instr_addr, current_instr_len, next_buf_pos);
862 current_instr_addr -= 1;
863 current_buf_pos -= 1;
865 if (hit_count >= max_hit_count &&
866 (last_num_invalid >= max_invalid_b4_exit || last_num_invalid == 0)) {
869 }
while (((
int)current_buf_pos >= 0) && (
int)(
len - current_buf_pos) >= 0);
878 ut8 disassmble_each_addr =
false;
884 ut8 disassmble_each_addr =
true;
902 *start_addr =
hit->addr;
904 rz_list_foreach (hits,
iter,
hit) {
905 instr_run +=
hit->len;
908 *instr_len = instr_run;
RZ_API void * rz_asm_code_free(RzAsmCode *acode)
RZ_API char * rz_asm_code_get_hex(RzAsmCode *acode)
static int analop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
static bool is_valid(arm_reg reg)
RZ_API void rz_asm_op_fini(RzAsmOp *op)
RZ_API RzAsmCode * rz_asm_mdisassemble(RzAsm *a, const ut8 *buf, int len)
RZ_API int rz_asm_set_pc(RzAsm *a, ut64 pc)
RZ_API RzAsmCode * rz_asm_massemble(RzAsm *a, const char *assembly)
RZ_API int rz_asm_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
int bits(struct state *s, int need)
RZ_API char * rz_core_asm_search(RzCore *core, const char *input)
RZ_API ut32 rz_core_asm_bwdis_len(RzCore *core, int *instr_len, ut64 *start_addr, ut32 nb)
RZ_API RzList * rz_core_asm_back_disassemble_byte(RzCore *core, ut64 addr, int len, ut32 hit_count, ut32 extra_padding)
static const char * has_esil(RzCore *core, const char *name)
RZ_API RzList * rz_core_asm_strsearch(RzCore *core, const char *input, ut64 from, ut64 to, int maxhits, int regexp, int everyByte, int mode)
static int is_addr_in_range(ut64 start, ut64 end, ut64 start_range, ut64 end_range)
static int handle_forward_disassemble(RzCore *core, RzList *hits, ut8 *buf, ut64 len, ut64 current_buf_pos, ut64 current_instr_addr, ut64 end_addr)
RZ_API RzCoreAsmHit * rz_core_asm_hit_new(void)
static int is_hit_inrange(RzCoreAsmHit *hit, ut64 start_range, ut64 end_range)
static void add_hit_to_sorted_hits(RzList *hits, ut64 addr, int len, ut8 is_valid)
static int prune_hits_in_addr_range(RzList *hits, ut64 addr, ut64 len, ut8 is_valid)
RZ_API void rz_core_asm_hit_free(void *_hit)
static RzCoreAsmHit * find_addr(RzList *hits, ut64 addr)
static void add_hit_to_hits(RzList *hits, ut64 addr, int len, ut8 is_valid)
RZ_API RzCmdStatus rz_core_asm_plugins_print(RzCore *core, const char *arch, RzCmdStateOutput *state)
static int rcoreasm_address_comparator(RzCoreAsmHit *a, RzCoreAsmHit *b)
RZ_API RzList * rz_core_asm_hit_list_new(void)
static RzList * rz_core_asm_back_disassemble_all(RzCore *core, ut64 addr, ut64 len, ut64 max_hit_count, ut32 extra_padding)
RZ_API RzList * rz_core_asm_bwdisassemble(RzCore *core, ut64 addr, int n, int len)
RZ_API RzCmdStatus rz_core_asm_plugin_print(RzCore *core, RzAsmPlugin *ap, const char *arch, RzCmdStateOutput *state, const char *license)
static int prune_hits_in_hit_range(RzList *hits, RzCoreAsmHit *hit)
static RzList * rz_core_asm_back_disassemble(RzCore *core, ut64 addr, int len, ut64 max_hit_count, ut8 disassmble_each_addr, ut32 extra_padding)
RZ_API RzList * rz_core_asm_back_disassemble_instr(RzCore *core, ut64 addr, int len, ut32 hit_count, ut32 extra_padding)
RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state)
Mark the start of an array of elements in the output.
RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state)
Mark the end of an array of elements in the output.
RZ_API void rz_cons_newline(void)
RZ_API void rz_cons_break_pop(void)
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API bool rz_cons_is_breaked(void)
RZ_API void rz_cons_println(const char *str)
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
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 static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
static int hit(RzSearchKeyword *kw, void *user, ut64 addr)
static void list(RzEgg *egg)
RZ_API RZ_BORROW RzListIter * rz_list_find(RZ_NONNULL const RzList *list, const void *p, RZ_NONNULL RzListComparator cmp)
Returns RzListIter element which matches via the RzListComparator.
RZ_API RZ_BORROW void * rz_list_get_bottom(RZ_NONNULL const RzList *list)
Returns the first element of the list.
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
RZ_API void * rz_list_iter_get_data(RzListIter *list)
returns the value stored in the list element
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API RZ_BORROW RzListIter * rz_list_add_sorted(RZ_NONNULL RzList *list, void *data, RZ_NONNULL RzListComparator cmp)
Adds an element to a sorted list via the RzListComparator.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
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 const char struct stat static buf struct stat static buf static vhangup int status
RZ_API bool rz_analysis_op_fini(RzAnalysisOp *op)
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
@ RZ_ANALYSIS_OP_MASK_DISASM
@ RZ_ANALYSIS_OP_MASK_BASIC
@ RZ_ANALYSIS_OP_MASK_ESIL
#define rz_warn_if_reached()
#define rz_return_val_if_fail(expr, val)
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
@ RZ_CMD_STATUS_NONEXISTINGCMD
command does not exist
RZ_API char * rz_hex_bin2strdup(const ut8 *in, int len)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API bool rz_io_is_valid_offset(RzIO *io, ut64 offset, int hasperm)
int(* RzListComparator)(const void *value, const void *list_data)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API PJ * pj_ko(PJ *j, const char *k)
RZ_API PJ * pj_end(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API RzRegex * rz_regex_new(const char *pattern, const char *cflags)
RZ_API int rz_regex_exec(const RzRegex *preg, const char *string, size_t nmatch, RzRegexMatch __pmatch[], int eflags)
RZ_API void rz_regex_free(RzRegex *)
RZ_API char * rz_str_appendf(char *ptr, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API char * rz_str_new(const char *str)
RZ_API char * rz_str_trim_dup(const char *str)
RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str)
Removes whitespace characters (space, tab, newline etc.) from the beginning and end of a string.
RZ_API const char * rz_str_word_get0(const char *str, int idx)
RZ_API int rz_str_ncasecmp(const char *dst, const char *orig, size_t n)
RZ_API size_t rz_str_split(char *str, char ch)
Split string str in place by using ch as a delimiter.
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
@ RZ_OUTPUT_MODE_STANDARD
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
int(* assemble)(RzAsm *a, RzAsmOp *op, const char *buf)
int(* disassemble)(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Represent the output state of a command handler.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)