* rabin2 -x uses filename.arch_bits as output file
* store full path in dyld cache filenames
This commit is contained in:
parent
987d8599f9
commit
4b558bec3b
|
@ -119,11 +119,15 @@ static int rabin_show_main() {
|
|||
}
|
||||
|
||||
static int rabin_extract(int all) {
|
||||
char out[512];
|
||||
char out[512], *ptr;
|
||||
int i;
|
||||
|
||||
if (all) {
|
||||
for (i=0; i<bin->narch; i++) {
|
||||
snprintf (out, sizeof (out), "%s.%s_%i", output,
|
||||
if ((ptr = strrchr (bin->arch[i].file, '/')))
|
||||
ptr = ptr+1;
|
||||
else ptr = bin->arch[i].file;
|
||||
snprintf (out, sizeof (out), "%s.%s_%i", ptr,
|
||||
bin->arch[i].info->arch, bin->arch[i].info->bits);
|
||||
if (!r_file_dump (out, bin->arch[i].buf->buf, bin->arch[i].size)) {
|
||||
eprintf ("Error extracting %s\n", out);
|
||||
|
@ -131,11 +135,15 @@ static int rabin_extract(int all) {
|
|||
} else eprintf ("%s created\n", out);
|
||||
}
|
||||
} else {
|
||||
if (!r_file_dump (output, bin->curarch->buf->buf, bin->curarch->size)) {
|
||||
eprintf ("Error extracting %s_%i\n",
|
||||
bin->curarch->info->arch, bin->curarch->info->bits);
|
||||
if ((ptr = strrchr (bin->arch[i].file, '/')))
|
||||
ptr = ptr+1;
|
||||
else ptr = bin->arch[i].file;
|
||||
snprintf (out, sizeof (out), "%s.%s_%i", ptr,
|
||||
bin->arch[i].info->arch, bin->arch[i].info->bits);
|
||||
if (!r_file_dump (out, bin->curarch->buf->buf, bin->curarch->size)) {
|
||||
eprintf ("Error extracting %s\n", out);
|
||||
return R_FALSE;
|
||||
} else eprintf ("%s created\n", output);
|
||||
} else eprintf ("%s created\n", out);
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
@ -436,15 +444,12 @@ static int rabin_show_info() {
|
|||
}
|
||||
|
||||
static void rabin_list_archs() {
|
||||
RBinInfo *info;
|
||||
int i;
|
||||
|
||||
for (i=0; i<bin->narch; i++) {
|
||||
bin->curarch = &bin->arch[i];
|
||||
if ((info = r_bin_get_info (bin)) == NULL)
|
||||
return;
|
||||
printf ("%s_%i %s (%s - %s endian)\n", info->arch, info->bits, bin->curarch->file,
|
||||
info->machine, info->big_endian?"big":"litle");
|
||||
printf ("%s_%i %s (%s)\n", bin->arch[i].info->arch,
|
||||
bin->arch[i].info->bits, bin->arch[i].file,
|
||||
bin->arch[i].info->machine);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj
|
|||
struct r_bin_dyldcache_lib_t *ret;
|
||||
ut64 curoffset, liboff, libla, libpath, nextliboff;
|
||||
ut8 *buf;
|
||||
char *ptr, *libname;
|
||||
char *libname;
|
||||
int i, j, libsz;
|
||||
|
||||
if (bin->nlibs < 0)
|
||||
|
@ -32,12 +32,13 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj
|
|||
libla = *(ut64*)(bin->b->buf+curoffset);
|
||||
liboff = libla - *(ut64*)&bin->b->buf[bin->hdr.baseaddroff];
|
||||
libpath = *(ut64*)(bin->b->buf+curoffset + 24);
|
||||
/* TODO: Find the real size */
|
||||
if (i != bin->nlibs-1) {
|
||||
nextliboff = *(ut64*)(bin->b->buf+curoffset+32) - *(ut64*)&bin->b->buf[bin->hdr.baseaddroff];
|
||||
libsz = nextliboff - liboff;
|
||||
} else libsz = bin->size - liboff;
|
||||
if (libsz <= 0)
|
||||
libsz = 10240;
|
||||
if (libsz <= 0 || libsz > bin->size)
|
||||
libsz = bin->size - liboff;
|
||||
if (!(buf = malloc (libsz))) {
|
||||
perror ("malloc (buf)");
|
||||
return NULL;
|
||||
|
@ -58,8 +59,6 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj
|
|||
}
|
||||
free (buf);
|
||||
libname = (char*)(bin->b->buf+libpath);
|
||||
if ((ptr = strrchr (libname, '/')))
|
||||
libname = ptr+1;
|
||||
strncpy (ret[i].path, libname, sizeof (ret[j].path));
|
||||
ret[j].size = libsz;
|
||||
ret[j].last = 0;
|
||||
|
|
Loading…
Reference in New Issue