Skip to content

Commit

Permalink
a cagar a la via
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae committed Feb 15, 2022
1 parent 7c5553a commit 506a454
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions libr/core/casm.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ static int is_hit_inrange(RCoreAsmHit *hit, ut64 start_range, ut64 end_range){
R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
RAsmOp op;
// if (n > core->blocksize) n = core->blocksize;
ut64 at;
ut32 idx = 0, hit_count;
int numinstr, asmlen, ii;
const int addrbytes = core->io->addrbytes;
Expand All @@ -494,8 +493,7 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
if (!hits) {
return NULL;
}

len = R_MIN (len - len % addrbytes, addrbytes * addr);
len = R_MIN (len - (len % addrbytes), addrbytes * addr);
if (len < 1) {
r_list_free (hits);
return NULL;
Expand All @@ -509,7 +507,7 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
free (buf);
return NULL;
}
if (!r_io_read_at (core->io, addr - len / addrbytes, buf, len)) {
if (!r_io_read_at (core->io, addr - (len / addrbytes), buf, len)) {
r_list_free (hits);
free (buf);
return NULL;
Expand All @@ -536,7 +534,9 @@ R_API RList *r_core_asm_bwdisassemble(RCore *core, ut64 addr, int n, int len) {
break;
}
}
at = addr - idx / addrbytes;

ut64 at = addr - idx / addrbytes;

r_asm_set_pc (core->rasm, at);
for (hit_count = 0; hit_count < n; hit_count++) {
int instrlen = r_asm_disassemble (core->rasm, &op,
Expand Down
12 changes: 7 additions & 5 deletions libr/core/cmd_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,9 +1221,11 @@ static void cmd_pdj(RCore *core, const char *arg, ut8* block, int len) {
}
pj_a (pj);
ut8 *data = malloc (core->blocksize);
memcpy (data, core->block, core->blocksize);
r_core_print_disasm_json (core, core->offset, data, core->blocksize, nblines, pj);
free (data);
if (data) {
memcpy (data, core->block, core->blocksize);
r_core_print_disasm_json (core, core->offset, data, core->blocksize, nblines, pj);
free (data);
}
pj_end (pj);
r_cons_println (pj_string (pj));
pj_free (pj);
Expand Down Expand Up @@ -5947,7 +5949,7 @@ static int cmd_print(void *data, const char *input) {
pd_result = false;
}
break;
case 'j': // pdj
case 'j': // "pdj"
processed_cmd = true;
if (*input == 'D') {
cmd_pDj (core, input + 2);
Expand Down Expand Up @@ -6039,7 +6041,7 @@ static int cmd_print(void *data, const char *input) {
bs1 - (bs - bs % addrbytes));
}
core->num->value = r_core_print_disasm (core,
off, block1,
addr - bs1, block1,
R_MAX (bs, bs1), l, 0, NULL,
false, formatted_json, NULL,
NULL);
Expand Down
5 changes: 2 additions & 3 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6271,7 +6271,6 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
eprintf ("Too many backward instructions\n");
return false;
}

if (r_core_prevop_addr (core, core->offset, nb_opcodes, &addr)) {
nbytes = old_offset - addr;
} else if (!r_core_asm_bwdis_len (core, &nbytes, &addr, nb_opcodes)) {
Expand All @@ -6291,10 +6290,10 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
count = R_MIN (nb_bytes, nbytes);
if (count > 0) {
r_io_read_at (core->io, addr, buf, count);
r_io_read_at (core->io, addr+count, buf+count, nb_bytes-count);
r_io_read_at (core->io, addr + count, buf + count, nb_bytes-count);
} else {
if (nb_bytes > 0) {
memset (buf, 0xff, nb_bytes);
memset (buf, core->io->Oxff, nb_bytes);
}
}
} else {
Expand Down

0 comments on commit 506a454

Please sign in to comment.