mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-03 10:51:01 +00:00
Cleanup the pdb_downloader function (-40LOC)
This commit is contained in:
parent
9345a2e59f
commit
391676dc39
@ -14,7 +14,6 @@ R_API void r_anal_hint_del (RAnal *a, ut64 addr, int size) {
|
||||
if (size>1) {
|
||||
eprintf ("TODO: r_anal_hint_del: in range\n");
|
||||
} else {
|
||||
eprintf ("Unset at %llx\n", addr);
|
||||
setf (key, "hint.0x%08"PFMT64x, addr);
|
||||
sdb_unset (a->sdb_hints, key, 0);
|
||||
}
|
||||
|
@ -240,15 +240,14 @@ R_API int r_anal_fcn_var_del_bydelta (RAnal *a, ut64 fna, const char kind, int s
|
||||
}
|
||||
|
||||
R_API RList *r_anal_var_list(RAnal *a, RAnalFunction *fcn, int kind) {
|
||||
int count = 0;
|
||||
char *varlist;
|
||||
RList *list = r_list_new ();
|
||||
if (!a|| !fcn)
|
||||
return list;
|
||||
if (!kind) kind = 'v'; // by default show vars
|
||||
varlist = sdb_get (DB, sdb_fmt (0, "fcn.0x%"PFMT64x".%c", fcn->addr, kind), 0);
|
||||
varlist = sdb_get (DB, sdb_fmt (0, "fcn.0x%"PFMT64x".%c",
|
||||
fcn->addr, kind), 0);
|
||||
if (varlist) {
|
||||
count = sdb_alen (varlist);
|
||||
char *next, *ptr = varlist;
|
||||
if (varlist && *varlist) {
|
||||
do {
|
||||
|
@ -90,6 +90,7 @@ static RList* sections(RBinFile *arch) {
|
||||
return ret;
|
||||
strcpy (ptr->name, "bootblk");
|
||||
ptr->vsize = ptr->size = 0x10000;
|
||||
//printf ("SIZE %d\n", ptr->size);
|
||||
ptr->paddr = arch->buf->length - ptr->size;
|
||||
ptr->vaddr = 0xf0000;
|
||||
ptr->srwx = 7;
|
||||
@ -105,7 +106,7 @@ static RList* entries(RBinFile *arch) {
|
||||
ret->free = free;
|
||||
if (!(ptr = R_NEW0 (RBinAddr)))
|
||||
return ret;
|
||||
ptr->paddr = 0x70000;
|
||||
ptr->paddr = 0; //0x70000;
|
||||
ptr->vaddr = 0xffff0;
|
||||
r_list_append (ret, ptr);
|
||||
return ret;
|
||||
|
@ -9,107 +9,68 @@ static int download(struct SPDBDownloader *pdb_downloader)
|
||||
SPDBDownloaderOpt *opt = pdb_downloader->opt;
|
||||
int res = 1;
|
||||
char *curl_cmd = 0;
|
||||
int curl_cmd_len = 0;
|
||||
char *extractor_cmd = 0;
|
||||
int extractor_cmd_len = 0;
|
||||
char *abspath_to_archive = 0;
|
||||
int abspath_to_archive_len = 0;
|
||||
char *archive_name = strdup(opt->dbg_file);
|
||||
char *archive_name;
|
||||
int archive_name_len;
|
||||
if (!opt->dbg_file || !*opt->dbg_file) {
|
||||
// no pdb debug file
|
||||
return 0;
|
||||
}
|
||||
// dbg_file len is > 0
|
||||
archive_name_len = strlen (opt->dbg_file);
|
||||
archive_name = malloc (archive_name_len+1);
|
||||
memcpy (archive_name, opt->dbg_file, archive_name_len+1);
|
||||
|
||||
archive_name[strlen(archive_name) - 1] = '_';
|
||||
archive_name[archive_name_len-1] = '_';
|
||||
|
||||
abspath_to_archive_len = strlen(archive_name) + strlen(opt->path) + 1 + 1;
|
||||
abspath_to_archive = (char *) malloc(abspath_to_archive_len);
|
||||
|
||||
#ifdef WIN32
|
||||
snprintf(abspath_to_archive, abspath_to_archive_len, "%s\%s", opt->path, archive_name);
|
||||
#else
|
||||
snprintf(abspath_to_archive, abspath_to_archive_len, "%s/%s", opt->path, archive_name);
|
||||
#endif
|
||||
|
||||
// curl -A %1 %2/%3/%4/%5 -o %6
|
||||
// %1 - user_agent
|
||||
// %2 - symbol_server
|
||||
// %3 - dbg_file
|
||||
// %4 - guid
|
||||
// %5 - archive_name
|
||||
// %6 - absolute path to archive
|
||||
// 5 - spaces
|
||||
// 3 - /
|
||||
// 1 - for '\0'
|
||||
curl_cmd_len = strlen("curl-A-o")
|
||||
+ strlen(opt->user_agent)
|
||||
+ strlen(opt->symbol_server)
|
||||
+ strlen(opt->dbg_file)
|
||||
+ strlen(opt->guid)
|
||||
+ strlen(archive_name)
|
||||
+ strlen(abspath_to_archive)
|
||||
+ 5 + 3 + 1;
|
||||
|
||||
curl_cmd = (char *) malloc(curl_cmd_len + 1);
|
||||
snprintf(curl_cmd, curl_cmd_len, "curl -A %s %s/%s/%s/%s -o %s",
|
||||
abspath_to_archive_len = archive_name_len + strlen (opt->path) + 2;
|
||||
abspath_to_archive = r_str_newf ("%s%s%s", opt->path,
|
||||
R_SYS_DIR, archive_name);
|
||||
curl_cmd = r_str_newf ("curl -A %s %s/%s/%s/%s -o %s",
|
||||
opt->user_agent,
|
||||
opt->symbol_server,
|
||||
opt->dbg_file,
|
||||
opt->guid,
|
||||
archive_name,
|
||||
abspath_to_archive);
|
||||
|
||||
#ifdef WIN32
|
||||
char *cabextractor = "expand";
|
||||
char *format = "%s %s %s";
|
||||
char *abspath_to_file = strdup(abspath_to_archive);
|
||||
#if __WINDOWS__
|
||||
const char *cabextractor = "expand";
|
||||
const char *format = "%s %s %s";
|
||||
char *abspath_to_file = strdup (abspath_to_archive);
|
||||
abspath_to_file[abspath_to_archive_len - 2] = 'b';
|
||||
|
||||
// extact_cmd -> %1 %2 %3
|
||||
// %1 - 'expand'
|
||||
// %2 - absolute path to archive
|
||||
// %3 - absolute path to file that will be dearchive
|
||||
// 2 - two spaces
|
||||
// 1 - for '\0'
|
||||
extractor_cmd_len = strlen(cabextractor)
|
||||
+ strlen(abspath_to_file)
|
||||
+ strlen(abspath_to_archive)
|
||||
+ 2 + 1;
|
||||
|
||||
extractor_cmd = (char *) malloc(extractor_cmd_len);
|
||||
snprintf(extractor_cmd, extractor_cmd_len, format, cabextractor, abspath_to_archive, abspath_to_file);
|
||||
|
||||
R_FREE(tmp);
|
||||
extractor_cmd = r_str_newf (format, cabextractor,
|
||||
abspath_to_archive, abspath_to_file);
|
||||
#else
|
||||
char *cabextractor = "cabextract";
|
||||
char *format = "%s -d %s %s";
|
||||
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
|
||||
// 3 - spaces
|
||||
// 2 - '-d' option
|
||||
// 1 - for '\0'
|
||||
extractor_cmd_len = strlen(cabextractor)
|
||||
+ strlen(opt->path)
|
||||
+ strlen(abspath_to_archive) + 3 + 2 + 1;
|
||||
extractor_cmd = (char *) malloc(extractor_cmd_len);
|
||||
snprintf(extractor_cmd, extractor_cmd_len, format, cabextractor, opt->path, abspath_to_archive);
|
||||
extractor_cmd = r_str_newf (format,
|
||||
cabextractor, opt->path, abspath_to_archive);
|
||||
#endif
|
||||
|
||||
if (r_sys_cmd(curl_cmd) == -1) {
|
||||
printf("curl has not been finish with sucess\n");
|
||||
if (r_sys_cmd (curl_cmd) != 0) {
|
||||
eprintf("curl has not been finish with sucess\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if ((res) && (r_sys_cmd(extractor_cmd) == -1)) {
|
||||
printf("cab extrach has not been finished with sucess\n");
|
||||
if (res && (r_sys_cmd (extractor_cmd) != 0)) {
|
||||
eprintf ("cab extrach has not been finished with sucess\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
r_file_rm(abspath_to_archive);
|
||||
|
||||
R_FREE(archive_name);
|
||||
R_FREE(curl_cmd);
|
||||
R_FREE(extractor_cmd);
|
||||
R_FREE(abspath_to_archive);
|
||||
|
||||
r_file_rm (abspath_to_archive);
|
||||
R_FREE (archive_name);
|
||||
R_FREE (curl_cmd);
|
||||
R_FREE (extractor_cmd);
|
||||
R_FREE (abspath_to_archive);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user