List multidex as dependency libs ##bin

This commit is contained in:
pancake 2019-07-05 19:01:41 +02:00 committed by radare
parent baa91ca899
commit 4232ac1763
2 changed files with 38 additions and 15 deletions

View File

@ -2114,6 +2114,32 @@ static RList *dex_fields(RBinFile *bf) {
return ret;
}
static RList* libs(RBinFile *bf) {
r_return_val_if_fail (bf && bf->o && bf->o->bin_obj, NULL);
char *path = r_file_dirname (bf->file);
RList *files = r_sys_dir (path);
RList *ret = r_list_newf (free);
if (!ret) {
return NULL;
}
RListIter *iter;
char *file;
r_list_foreach (files, iter, file) {
if (!r_str_startswith (file, "classes")) {
continue;
}
if (r_str_endswith (file, ".dex")) {
char *n = r_str_newf ("%s%s%s", path, R_SYS_DIR, file);
if (strcmp (n, bf->file)) {
r_list_append (ret, n);
}
}
}
r_list_free (files);
free (path);
return ret;
}
RBinPlugin r_bin_plugin_dex = {
.name = "dex",
.desc = "dex format bin plugin",
@ -2132,6 +2158,7 @@ RBinPlugin r_bin_plugin_dex = {
.info = &info,
.header = dex_header,
.fields = dex_fields,
.libs = &libs,
.size = &size,
.get_offset = &getoffset,
.get_name = &getname,

View File

@ -538,25 +538,21 @@ static RList* imports(RBinFile *bf) {
}
static RList* libs(RBinFile *bf) {
struct r_bin_elf_lib_t *libs = NULL;
RList *ret = NULL;
char *ptr = NULL;
int i;
r_return_val_if_fail (bf && bf->o && bf->o->bin_obj, NULL);
if (!bf || !bf->o || !bf->o->bin_obj) {
RList *ret = r_list_newf (free);
if (!ret) {
return NULL;
}
if (!(ret = r_list_newf (free))) {
return NULL;
struct r_bin_elf_lib_t *libs = Elf_(r_bin_elf_get_libs) (bf->o->bin_obj);
if (libs) {
int i;
for (i = 0; !libs[i].last; i++) {
char *ptr = strdup (libs[i].name);
r_list_append (ret, ptr);
}
free (libs);
}
if (!(libs = Elf_(r_bin_elf_get_libs) (bf->o->bin_obj))) {
return ret;
}
for (i = 0; !libs[i].last; i++) {
ptr = strdup (libs[i].name);
r_list_append (ret, ptr);
}
free (libs);
return ret;
}