PDB_SERVER is now RABIN2_PDBSERVER

This commit is contained in:
pancake 2017-10-30 12:46:33 +01:00
parent 708c39a3d0
commit de86371355
5 changed files with 72 additions and 62 deletions

View File

@ -91,8 +91,9 @@ static int rabin_show_help(int v) {
" RABIN2_MAXSTRBUF: e bin.maxstrbuf # specify maximum buffer size\n"
" RABIN2_STRFILTER: e bin.strfilter # r2 -qe bin.strfilter=? -c '' --\n"
" RABIN2_STRPURGE: e bin.strpurge # try to purge false positives\n"
" RABIN2_DEBASE64: e bin.debase64 # Try to debase64 all strings\n"
" RABIN2_DEBASE64: e bin.debase64 # try to debase64 all strings\n"
" RABIN2_DMNGLRCMD: e bin.demanglercmd # try to purge false positives\n"
" RABIN2_PDBSERVER: e pdb.server # use alternative PDB server\n"
" RABIN2_PREFIX: e bin.prefix # prefix symbols/sections/relocs with a specific string\n");
}
return 1;
@ -606,6 +607,10 @@ int main(int argc, char **argv) {
r_config_set (core.config, "bin.debase64", tmp);
free (tmp);
}
if ((tmp = r_sys_getenv ("RABIN2_PDBSERVER"))) {
r_config_set (core.config, "pdb.server", tmp);
free (tmp);
}
#define is_active(x) (action & x)
#define set_action(x) actions++; action |= x

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2011-2016 - pancake */
/* radare - LGPL - Copyright 2011-2017 - pancake */
#include <r_bin.h>
#include <cxx/demangle.h>
@ -11,7 +11,9 @@ R_API void r_bin_demangle_list(RBin *bin) {
RBinPlugin *plugin;
RListIter *it;
int i;
if (!bin) return;
if (!bin) {
return;
}
for (i = 0; langs[i]; i++) {
eprintf ("%s\n", langs[i]);
}
@ -25,12 +27,13 @@ R_API void r_bin_demangle_list(RBin *bin) {
R_API char *r_bin_demangle_plugin(RBin *bin, const char *name, const char *str) {
RBinPlugin *plugin;
RListIter *it;
if (!bin || !name || !str) return NULL;
if (bin && name && str) {
r_list_foreach (bin->plugins, it, plugin) {
if (plugin->demangle) {
return plugin->demangle (str);
}
}
}
return NULL;
}
@ -118,7 +121,6 @@ R_API char *r_bin_demangle_msvc(const char *str) {
}
R_API char *r_bin_demangle_cxx(RBinFile *binfile, const char *str, ut64 vaddr) {
char *out;
// DMGL_TYPES | DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE
// | DMGL_RET_POSTFIX | DMGL_TYPES;
int i;
@ -134,7 +136,7 @@ R_API char *r_bin_demangle_cxx(RBinFile *binfile, const char *str, ut64 vaddr) {
};
if (str[0] == str[1] && *str == '_') {
str++;
} {
}
for (i = 0; prefixes[i]; i++) {
int plen = strlen (prefixes[i]);
if (!strncmp (str, prefixes[i], plen)) {
@ -142,12 +144,11 @@ R_API char *r_bin_demangle_cxx(RBinFile *binfile, const char *str, ut64 vaddr) {
break;
}
}
}
#if WITH_GPL
out = cplus_demangle_v3 (str, flags);
char *out = cplus_demangle_v3 (str, flags);
#else
/* TODO: implement a non-gpl alternative to c++v3 demangler */
out = NULL;
char *out = NULL;
#endif
if (out) {
r_str_replace_char (out, ' ', 0);
@ -294,9 +295,10 @@ R_API char *r_bin_demangle_objc(RBinFile *binfile, const char *sym) {
args[0] = 0;
for (i = 0;i < nargs; i++) {
strcat (args, arg);
if (i + 1 < nargs)
if (i + 1 < nargs) {
strcat (args, ", ");
}
}
} else {
args = strdup ("");
}

View File

@ -9,6 +9,8 @@
#include <r_cons.h>
#include "elf/elf.h"
static RBinInfo* info(RBinFile *arch);
//TODO: implement r_bin_symbol_dup() and r_bin_symbol_free ?
static void setsymord(ELFOBJ* eobj, ut32 ord, RBinSymbol *ptr) {
if (!eobj->symbols_by_ord || ord >= eobj->symbols_by_ord_size) {
@ -177,7 +179,9 @@ static RList* entries(RBinFile *arch) {
}
}
r_list_append (ret, ptr);
// add entrypoint for jni libraries
// NOTE: this is slow, we shouldnt find for java constructors here
if (!(symbol = Elf_(r_bin_elf_get_symbols) (obj))) {
return ret;
}
@ -380,8 +384,6 @@ arm_symbol:
}
}
static RBinInfo* info(RBinFile *arch);
static RList* symbols(RBinFile *arch) {
struct Elf_(r_bin_elf_obj_t) *bin;
struct r_bin_elf_symbol_t *symbol = NULL;

View File

@ -1,25 +1,26 @@
#include "pdb_downloader.h"
/* radare - LGPL - Copyright 2014-2017 - inisider */
#include <string.h>
#include <r_util.h>
#include <r_core.h>
#include "pdb_downloader.h"
static int checkPrograms () {
static bool checkPrograms () {
#if __WINDOWS__ && !__CYGWIN__
char nul[] = "nul";
const char nul[] = "nul";
if (r_sys_cmd ("expand -? >nul") != 0) {
return 0;
return false;
}
#else
char nul[] = "/dev/null";
const char nul[] = "/dev/null";
if (r_sys_cmd ("cabextract -v > /dev/null") != 0) {
return 0;
return false;
}
#endif
if (r_sys_cmdf ("curl --version > %s", nul) != 0) {
return 0;
return false;
}
return 1;
return true;
}
static int download(struct SPDBDownloader *pd) {
@ -34,18 +35,20 @@ static int download(struct SPDBDownloader *pd) {
// no pdb debug file
return 0;
}
if (!checkPrograms ())
if (!checkPrograms ()) {
return 0;
}
// dbg_file len is > 0
archive_name_len = strlen (opt->dbg_file);
archive_name = malloc (archive_name_len+1);
if (!archive_name) return 0;
if (!archive_name) {
return 0;
}
memcpy (archive_name, opt->dbg_file, archive_name_len+1);
archive_name[archive_name_len - 1] = '_';
if (opt->path && *opt->path)
if (opt->path && *opt->path) {
basepath = opt->path;
}
abspath_to_archive = r_str_newf ("%s%s%s", basepath,
R_SYS_DIR, archive_name);
curl_cmd = r_str_newf ("curl -sA \"%s\" \"%s/%s/%s/%s\" -o \"%s\"",
@ -55,14 +58,14 @@ static int download(struct SPDBDownloader *pd) {
opt->guid,
archive_name,
abspath_to_archive);
// eprintf ("%s\n", curl_cmd);
#if __WINDOWS__ && !__CYGWIN__
{
const char *cabextractor = "expand";
const char *format = "%s %s %s";
char *abspath_to_file = strdup (abspath_to_archive);
if (abspath_to_file) {
int abspath_to_archive_len = archive_name_len + strlen (basepath) + 2;
abspath_to_file[abspath_to_archive_len - 2] = 'b';
// extact_cmd -> %1 %2 %3
// %1 - 'expand'
// %2 - absolute path to archive
@ -73,7 +76,6 @@ static int download(struct SPDBDownloader *pd) {
#else
const char *cabextractor = "cabextract";
const char *format = "%s -d \"%s\" \"%s\"";
// cabextract -d %1 %2
// %1 - path to directory where to extract all files from cab arhcive
// %2 - absolute path to cab archive
@ -81,19 +83,16 @@ static int download(struct SPDBDownloader *pd) {
cabextractor, basepath, abspath_to_archive);
#endif
if (r_sys_cmd (curl_cmd) != 0) {
eprintf("curl has not been finish with sucess\n");
eprintf("curl has not been finish with success\n");
res = 0;
}
if (opt->extract > 0) {
if (res && (r_sys_cmd (extractor_cmd) != 0)) {
eprintf ("cab extrach has not been finished with sucess\n");
eprintf ("cab extrach has not been finished with success\n");
res = 0;
}
r_file_rm (abspath_to_archive);
}
R_FREE (archive_name);
R_FREE (curl_cmd);
R_FREE (extractor_cmd);
@ -103,7 +102,9 @@ static int download(struct SPDBDownloader *pd) {
void init_pdb_downloader(SPDBDownloaderOpt *opt, SPDBDownloader *pd) {
pd->opt = R_NEW0 (SPDBDownloaderOpt);
if (!pd->opt) return;
if (!pd->opt) {
return;
}
pd->opt->dbg_file = strdup (opt->dbg_file);
pd->opt->guid = strdup (opt->guid);
pd->opt->symbol_server = strdup (opt->symbol_server);

View File

@ -188,7 +188,7 @@ R_API void r_core_sysenv_help(const RCore *core) {
"R2_BITS", "", "arch reg size (8, 16, 32, 64)",
"RABIN2_LANG", "", "assume this lang to demangle",
"RABIN2_DEMANGLE", "", "demangle or not",
"PDB_SERVER", "", "e pdb.server",
"RABIN2_PDBSERVER", "", "e pdb.server",
NULL
};
r_core_cmd_help (core, help_msg);
@ -224,7 +224,7 @@ R_API char *r_core_sysenv_begin(RCore * core, const char *cmd) {
r_sys_setenv ("R2_BYTES", s);
free (s);
}
r_sys_setenv ("PDB_SERVER", r_config_get (core->config, "pdb.server"));
r_sys_setenv ("RABIN2_PDBSERVER", r_config_get (core->config, "pdb.server"));
if (desc && desc->name) {
r_sys_setenv ("R2_FILE", desc->name);
r_sys_setenv ("R2_SIZE", sdb_fmt (0, "%"PFMT64d, r_io_desc_size (desc)));