Fix last covs, radiff crash and tweak the z64 bin plugin
This commit is contained in:
parent
b27326e891
commit
e5235f7d97
|
@ -244,7 +244,7 @@ static int cb(RDiff *d, void *user, RDiffOp *op) {
|
|||
}
|
||||
printf ("\n");
|
||||
if (core) {
|
||||
int len = R_MAX(4, op->b_len);
|
||||
int len = R_MAX (4, op->b_len);
|
||||
RAsmCode *ac = r_asm_mdisassemble (core->assembler, op->b_buf, len);
|
||||
if (quiet) {
|
||||
char *bufasm = r_str_prefix_all (strdup (ac->buf_asm), "+ ");
|
||||
|
@ -252,7 +252,7 @@ static int cb(RDiff *d, void *user, RDiffOp *op) {
|
|||
free (bufasm);
|
||||
} else {
|
||||
char *bufasm = r_str_prefix_all (strdup (ac->buf_asm), Color_GREEN"+ ");
|
||||
printf ("%s\n"Color_RESET, bufasm);
|
||||
printf ("%s\n" Color_RESET, bufasm);
|
||||
free (bufasm);
|
||||
}
|
||||
// r_asm_code_free (ac);
|
||||
|
@ -315,10 +315,11 @@ static int bcb(RDiff *d, void *user, RDiffOp *op) {
|
|||
int times = offset_diff / INT_MAX;
|
||||
int max = INT_MAX;
|
||||
size_t i;
|
||||
for(i = 0; i < times; i++) {
|
||||
print_bytes (&opcode, sizeof(opcode), true);
|
||||
print_bytes (&gdiff_start + i * max, sizeof(gdiff_start), true);
|
||||
print_bytes (&max, sizeof(max), true);
|
||||
for (i = 0; i < times; i++) {
|
||||
print_bytes (&opcode, sizeof (opcode), true);
|
||||
// XXX this is overflowingly wrong
|
||||
// XXX print_bytes (&gdiff_start + i * max, sizeof (gdiff_start), true);
|
||||
print_bytes (&max, sizeof (max), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,16 +339,16 @@ static int bcb(RDiff *d, void *user, RDiffOp *op) {
|
|||
switch (opcode) {
|
||||
case 249:
|
||||
case 252:
|
||||
print_bytes (&UCLen, sizeof(UCLen), true);
|
||||
print_bytes (&UCLen, sizeof (UCLen), true);
|
||||
break;
|
||||
case 250:
|
||||
case 253:
|
||||
print_bytes (&USLen, sizeof(USLen), true);
|
||||
print_bytes (&USLen, sizeof (USLen), true);
|
||||
break;
|
||||
case 251:
|
||||
case 254:
|
||||
case 255:
|
||||
print_bytes (&ILen, sizeof(ILen), true);
|
||||
print_bytes (&ILen, sizeof (ILen), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +358,7 @@ static int bcb(RDiff *d, void *user, RDiffOp *op) {
|
|||
ut8 data = op->b_len;
|
||||
write (1, &data, 1);
|
||||
} else if (op->b_len <= USHRT_MAX) {
|
||||
USLen = (unsigned short) op->b_len;
|
||||
USLen = (ut16) op->b_len;
|
||||
ut8 data = 247;
|
||||
write (1, &data, 1);
|
||||
print_bytes (&USLen, sizeof (USLen), true);
|
||||
|
@ -365,7 +366,7 @@ static int bcb(RDiff *d, void *user, RDiffOp *op) {
|
|||
ut8 data = 248;
|
||||
write (1, &data, 1);
|
||||
ILen = (int) op->b_len;
|
||||
print_bytes(&ILen, sizeof(ILen), true);
|
||||
print_bytes (&ILen, sizeof (ILen), true);
|
||||
} else {
|
||||
// split into multiple DATA, because op->b_len is greater than INT_MAX
|
||||
int times = op->b_len / INT_MAX;
|
||||
|
@ -374,7 +375,7 @@ static int bcb(RDiff *d, void *user, RDiffOp *op) {
|
|||
for(i = 0;i < times; i++) {
|
||||
ut8 data = 248;
|
||||
write (1, &data, 1);
|
||||
print_bytes (&max, sizeof(max), true);
|
||||
print_bytes (&max, sizeof (max), true);
|
||||
print_bytes (op->b_buf, max, false);
|
||||
op->b_buf += max;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ static RList* sections(RBinFile *bf) {
|
|||
hdroffset = 0x200;
|
||||
}
|
||||
#endif
|
||||
sfc_int_hdr sfchdr = {0};
|
||||
sfc_int_hdr sfchdr = {{0}};
|
||||
|
||||
int reat = r_buf_read_at (bf->buf, 0x7FC0 + hdroffset, (ut8*)&sfchdr, SFC_HDR_SIZE);
|
||||
if (reat != SFC_HDR_SIZE) {
|
||||
|
|
|
@ -70,11 +70,11 @@ static ut64 baddr(RBinFile *bf) {
|
|||
}
|
||||
|
||||
static bool check_bytes (const ut8 *buf, ut64 length) {
|
||||
ut32 magic = 0x80371240;
|
||||
ut32 magic = 0x37804012;
|
||||
if (length < N64_ROM_START) {
|
||||
return false;
|
||||
}
|
||||
return magic == r_read_be32(buf);
|
||||
return magic == r_read_be32 (buf);
|
||||
}
|
||||
|
||||
static void *load_bytes(RBinFile *bf, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb) {
|
||||
|
@ -86,7 +86,6 @@ static void *load_bytes(RBinFile *bf, const ut8 *buf, ut64 sz, ut64 loadaddr, Sd
|
|||
|
||||
static bool load(RBinFile *bf) {
|
||||
const ut8 *bytes = bf ? r_buf_buffer (bf->buf) : NULL;
|
||||
char *fname = bf->file;
|
||||
ut64 sz = bf ? r_buf_size (bf->buf) : 0;
|
||||
if (!bf || !bf->o) {
|
||||
return false;
|
||||
|
@ -100,13 +99,12 @@ static int destroy(RBinFile *bf) {
|
|||
}
|
||||
|
||||
static RList *entries(RBinFile *bf) {
|
||||
RList /*<RBinAddr>*/ *ret = r_list_new ();
|
||||
RBinAddr *ptr = NULL;
|
||||
if (!(ret = r_list_new ())) {
|
||||
RList /*<RBinAddr>*/ *ret = r_list_newf (free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
if ((ptr = R_NEW0 (RBinAddr))) {
|
||||
RBinAddr *ptr = R_NEW0 (RBinAddr);
|
||||
if (ptr) {
|
||||
ptr->paddr = N64_ROM_START;
|
||||
ptr->vaddr = baddr (bf);
|
||||
r_list_append (ret, ptr);
|
||||
|
|
|
@ -758,10 +758,14 @@ static void cmd_open_map(RCore *core, const char *input) {
|
|||
}
|
||||
|
||||
R_API void r_core_file_reopen_in_malloc (RCore *core) {
|
||||
RCoreFile *f;
|
||||
RListIter *iter;
|
||||
r_list_foreach (core->files, iter, f) {
|
||||
ut64 sz = r_io_fd_size (core->io, f->fd);
|
||||
RList *files = r_id_storage_list (core->io->files);
|
||||
RIODesc *desc;
|
||||
r_list_foreach (files, iter, desc) {
|
||||
if (strstr (desc->name, "://")) {
|
||||
continue;
|
||||
}
|
||||
ut64 sz = r_io_desc_size (desc);
|
||||
ut8 *buf = calloc (sz, 1);
|
||||
if (!buf) {
|
||||
eprintf ("Cannot allocate %d\n", (int)sz);
|
||||
|
@ -769,10 +773,10 @@ R_API void r_core_file_reopen_in_malloc (RCore *core) {
|
|||
}
|
||||
(void)r_io_pread_at (core->io, 0, buf, sz);
|
||||
char *url = r_str_newf ("malloc://%d", (int)sz);
|
||||
RIODesc *desc = r_io_open (core->io, url, R_IO_READ | R_IO_WRITE, 0); //use r_io_desc_exchange pls
|
||||
if (desc) {
|
||||
r_io_fd_close (core->io, f->fd);
|
||||
f->fd = desc->fd;
|
||||
// use r_io_desc_exchange pls
|
||||
RIODesc *newDesc = r_io_open (core->io, url, R_IO_READ | R_IO_WRITE, 0);
|
||||
if (newDesc) {
|
||||
r_io_desc_close (desc);
|
||||
(void)r_io_write_at (core->io, 0, buf, sz);
|
||||
} else {
|
||||
eprintf ("Cannot open %s\n", url);
|
||||
|
|
|
@ -883,6 +883,10 @@ R_API int r_core_file_list(RCore *core, int mode) {
|
|||
}
|
||||
r_list_foreach (core->files, iter, f) {
|
||||
desc = r_io_desc_get (core->io, f->fd);
|
||||
if (!desc) {
|
||||
// cannot find desc for this fd, RCoreFile inconsistency!!!1
|
||||
continue;
|
||||
}
|
||||
from = 0LL;
|
||||
switch (mode) {
|
||||
case 'j':
|
||||
|
|
|
@ -14,12 +14,12 @@ typedef struct r_diff_op_t {
|
|||
/* file A */
|
||||
ut64 a_off;
|
||||
const ut8 *a_buf;
|
||||
int a_len;
|
||||
ut32 a_len;
|
||||
|
||||
/* file B */
|
||||
ut64 b_off;
|
||||
const ut8 *b_buf;
|
||||
int b_len;
|
||||
ut32 b_len;
|
||||
} RDiffOp;
|
||||
|
||||
//typedef struct r_diff_t RDiff;
|
||||
|
|
Loading…
Reference in New Issue