WinKD/DMP: Implement winkd_download_module_and_pdb()
debug\meson.build add rz_bin
This commit is contained in:
parent
284c11134f
commit
8237987f2d
5 changed files with 94 additions and 5 deletions
|
|
@ -32,6 +32,7 @@ rz_debug_sources = [
|
|||
'snap.c',
|
||||
'trace.c',
|
||||
'p/bfvm.c',
|
||||
'p/common_winkd.c',
|
||||
'p/debug_bf.c',
|
||||
'p/debug_bochs.c',
|
||||
'p/debug_esil.c',
|
||||
|
|
@ -59,6 +60,7 @@ rz_debug_deps = [
|
|||
rz_cons_dep,
|
||||
rz_hash_dep,
|
||||
rz_io_dep,
|
||||
rz_bin_dep,
|
||||
rz_reg_dep,
|
||||
rz_bp_dep,
|
||||
rz_syscall_dep,
|
||||
|
|
@ -147,6 +149,7 @@ pkgconfig_mod.generate(rz_debug,
|
|||
'rz_syscall',
|
||||
'rz_analysis',
|
||||
'rz_io',
|
||||
'rz_bin',
|
||||
'rz_bp',
|
||||
'rz_cons',
|
||||
'rz_egg'
|
||||
|
|
@ -162,7 +165,7 @@ if not is_static_libs_only
|
|||
conf = configuration_data()
|
||||
conf.set('RZ_VERSION', rizin_version)
|
||||
conf.set('RIZIN_MODULE', rz_debug.name())
|
||||
conf.set('RIZIN_MODULE_DEPS', ' '.join(['rz_util', 'rz_hash', 'rz_reg', 'rz_syscall', 'rz_analysis', 'rz_io', 'rz_bp', 'rz_cons', 'rz_egg']))
|
||||
conf.set('RIZIN_MODULE_DEPS', ' '.join(['rz_util', 'rz_hash', 'rz_reg', 'rz_syscall', 'rz_analysis', 'rz_io', 'rz_bin', 'rz_bp', 'rz_cons', 'rz_egg']))
|
||||
conf.set('PACKAGE_RELATIVE_PATH', cmake_package_relative_path)
|
||||
conf.set('INSTALL_INCDIR', rizin_incdir)
|
||||
conf.set('INSTALL_LIBDIR', rizin_libdir)
|
||||
|
|
|
|||
79
librz/debug/p/common_winkd.c
Normal file
79
librz/debug/p/common_winkd.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
// SPDX-FileCopyrightText: 2022 GustavoLCR <gugulcr@gmail.com>
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
#include "common_winkd.h"
|
||||
#include <bin/pdb/pdb_downloader.h>
|
||||
|
||||
static char *download_pdb(const char *path, const char *symserver, const char *symstore) {
|
||||
PJ *pj = pj_new();
|
||||
if (!pj) {
|
||||
return NULL;
|
||||
}
|
||||
RzBin *bin = NULL;
|
||||
RzIO *io = rz_io_new();
|
||||
if (!io) {
|
||||
goto end;
|
||||
}
|
||||
bin = rz_bin_new();
|
||||
if (!bin) {
|
||||
goto end;
|
||||
}
|
||||
rz_io_bind(io, &bin->iob);
|
||||
|
||||
RzBinOptions opt = { 0 };
|
||||
bin->filter_rules = RZ_BIN_REQ_INFO;
|
||||
if (!rz_bin_open(bin, path, &opt)) {
|
||||
goto end;
|
||||
}
|
||||
pj_o(pj);
|
||||
SPDBOptions opts = { .extract = 1, .symbol_server = symserver, .symbol_store_path = symstore };
|
||||
rz_bin_pdb_download(bin, pj, true, &opts);
|
||||
pj_end(pj);
|
||||
end:
|
||||
rz_bin_free(bin);
|
||||
rz_io_free(io);
|
||||
return pj_drain(pj);
|
||||
}
|
||||
|
||||
bool winkd_download_module_and_pdb(WindModule *module, const char *symserver, const char *symstore, char **exepath, char **pdbpath) {
|
||||
if (exepath) {
|
||||
*exepath = NULL;
|
||||
}
|
||||
if (pdbpath) {
|
||||
*pdbpath = NULL;
|
||||
}
|
||||
char *sum = rz_str_newf("%08" PFMT32x "%" PFMT32x, module->timestamp, module->size);
|
||||
const char *file = rz_str_rchr(module->name, NULL, '\\') + 1;
|
||||
SPDBDownloaderOpt opts = {
|
||||
.dbg_file = file, .extract = true, .guid = sum, .symbol_server = symserver, .symbol_store_path = symstore
|
||||
};
|
||||
char *executable = rz_bin_symserver_download(&opts);
|
||||
free(sum);
|
||||
if (!executable) {
|
||||
return false;
|
||||
}
|
||||
char *res = download_pdb(executable, symserver, symstore);
|
||||
if (exepath) {
|
||||
*exepath = executable;
|
||||
} else {
|
||||
free(executable);
|
||||
}
|
||||
RzJson *json = rz_json_parse(res);
|
||||
if (!json) {
|
||||
return false;
|
||||
}
|
||||
const RzJson *pdb = rz_json_get(json, "pdb");
|
||||
if (!pdb) {
|
||||
return false;
|
||||
}
|
||||
const RzJson *ppath = rz_json_get(pdb, "path");
|
||||
if (!ppath) {
|
||||
return false;
|
||||
}
|
||||
if (pdbpath) {
|
||||
*pdbpath = strdup(ppath->str_value);
|
||||
}
|
||||
rz_json_free(json);
|
||||
free(res);
|
||||
return true;
|
||||
}
|
||||
7
librz/debug/p/common_winkd.h
Normal file
7
librz/debug/p/common_winkd.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2022 GustavoLCR <gugulcr@gmail.com>
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
#include <rz_analysis.h>
|
||||
#include <winkd.h>
|
||||
|
||||
bool winkd_download_module_and_pdb(WindModule *module, const char *symserver, const char *symstore, char **exepath, char **pdbpath);
|
||||
|
|
@ -478,8 +478,8 @@ RzList *winkd_list_modules(WindCtx *ctx) {
|
|||
break;
|
||||
}
|
||||
winkd_read_at_uva(ctx, (uint8_t *)&mod->addr, ptr + baseoff, 4 << ctx->is_64bit);
|
||||
winkd_read_at_uva(ctx, (uint8_t *)&mod->size, ptr + sizeoff, 4 << ctx->is_64bit);
|
||||
winkd_read_at_uva(ctx, (uint8_t *)&mod->timestamp, ptr + timestampoff, is_target_kernel ? 4 : 4 << ctx->is_64bit);
|
||||
winkd_read_at_uva(ctx, (uint8_t *)&mod->size, ptr + sizeoff, 4);
|
||||
winkd_read_at_uva(ctx, (uint8_t *)&mod->timestamp, ptr + timestampoff, 4);
|
||||
|
||||
ut16 length;
|
||||
winkd_read_at_uva(ctx, (uint8_t *)&length, ptr + nameoff, sizeof(ut16));
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ typedef struct WindThread {
|
|||
typedef struct WindModule {
|
||||
char *name;
|
||||
ut64 addr;
|
||||
ut64 size;
|
||||
ut64 timestamp;
|
||||
ut32 size;
|
||||
ut32 timestamp;
|
||||
} WindModule;
|
||||
|
||||
enum {
|
||||
|
|
|
|||
Loading…
Reference in a new issue