rabin2: add pdb print infortmation option
Conflicts: binr/rabin2/rabin2.c
This commit is contained in:
parent
d547b037c9
commit
621d757487
|
@ -25,6 +25,7 @@
|
|||
#define ACTION_CREATE 0x08000
|
||||
#define ACTION_CLASSES 0x10000
|
||||
#define ACTION_DWARF 0x20000
|
||||
#define ACTION_PDB 0x30000
|
||||
#define ACTION_SIZE 0x40000
|
||||
|
||||
static struct r_bin_t *bin = NULL;
|
||||
|
@ -52,6 +53,7 @@ static int rabin_show_help(int v) {
|
|||
" -c [fmt:C:D] create [elf,mach0,pe] with Code and Data hexpairs (see -a)\n"
|
||||
" -C list classes\n"
|
||||
" -d show debug/dwarf information\n"
|
||||
" -P show debug/pdb information\n"
|
||||
" -e entrypoint\n"
|
||||
" -f [str] select sub-bin named str\n"
|
||||
" -k [query] perform sdb query on loaded file\n"
|
||||
|
@ -378,7 +380,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
#define is_active(x) (action&x)
|
||||
#define set_action(x) actions++; action |=x
|
||||
while ((c = getopt (argc, argv, "jgqAf:a:B:b:c:Ck:K:dMm:n:N:@:isSIHelRwO:o:prvLhxzZ")) != -1) {
|
||||
while ((c = getopt (argc, argv, "jgqAf:a:B:b:c:Ck:K:dMm:n:N:@:isSIHelRwO:o:pPrvLhxzZ")) != -1) {
|
||||
switch (c) {
|
||||
case 'g':
|
||||
set_action (ACTION_CLASSES);
|
||||
|
@ -430,6 +432,7 @@ int main(int argc, char **argv) {
|
|||
case 'I': set_action (ACTION_INFO); break;
|
||||
case 'H': set_action (ACTION_FIELDS); break;
|
||||
case 'd': set_action (ACTION_DWARF); break;
|
||||
case 'P': set_action (ACTION_PDB); break;
|
||||
case 'e': set_action (ACTION_ENTRIES); break;
|
||||
case 'M': set_action (ACTION_MAIN); break;
|
||||
case 'l': set_action (ACTION_LIBS); break;
|
||||
|
@ -655,6 +658,7 @@ int main(int argc, char **argv) {
|
|||
run_action ("libs", ACTION_LIBS, R_CORE_BIN_ACC_LIBS);
|
||||
run_action ("relocs", ACTION_RELOCS, R_CORE_BIN_ACC_RELOCS);
|
||||
run_action ("dwarf", ACTION_DWARF, R_CORE_BIN_ACC_DWARF);
|
||||
run_action ("pdb", ACTION_PDB, R_CORE_BIN_ACC_PDB);
|
||||
run_action ("size", ACTION_SIZE, R_CORE_BIN_ACC_SIZE);
|
||||
if (action&ACTION_SRCLINE)
|
||||
rabin_show_srcline (at);
|
||||
|
|
|
@ -181,7 +181,7 @@ static int init_pdb7_root_stream(R_PDB *pdb, int *root_page_list, int pages_amou
|
|||
|
||||
free(sizes);
|
||||
free(data);
|
||||
printf("init_pdb7_root_stream()\n");
|
||||
// printf("init_pdb7_root_stream()\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ static int pdb_read_root(R_PDB *pdb)
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
static int pdb7_parse(R_PDB *pdb)
|
||||
{
|
||||
printf("pdb7_parse()\n");
|
||||
// printf("pdb7_parse()\n");
|
||||
|
||||
char signature[PDB7_SIGNATURE_LEN + 1];
|
||||
int page_size = 0;
|
||||
|
@ -576,13 +576,13 @@ static void finish_pdb_parse(R_PDB *pdb)
|
|||
free(pdb->stream_map);
|
||||
|
||||
fclose(pdb->fp);
|
||||
printf("finish_pdb_parse()\n");
|
||||
// printf("finish_pdb_parse()\n");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
static void print_types(R_PDB *pdb)
|
||||
{
|
||||
printf("print_types()\n");
|
||||
// printf("print_types()\n");
|
||||
char *name;
|
||||
int val = 0;
|
||||
int offset = 0;
|
||||
|
@ -729,7 +729,7 @@ int init_pdb_parser(R_PDB *pdb)
|
|||
pdb->finish_pdb_parse = finish_pdb_parse;
|
||||
pdb->print_types = print_types;
|
||||
pdb->print_gvars = print_gvars;
|
||||
printf("init_pdb_parser() finish with success\n");
|
||||
// printf("init_pdb_parser() finish with success\n");
|
||||
return 1;
|
||||
|
||||
error:
|
||||
|
|
|
@ -427,6 +427,26 @@ static int bin_dwarf (RCore *core, int mode) {
|
|||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int bin_pdb (RCore *core, int mode) {
|
||||
R_PDB pdb;
|
||||
|
||||
strcpy(&pdb.file_name, core->bin->file);
|
||||
if (!init_pdb_parser(&pdb)) {
|
||||
printf("initialization error of pdb parser");
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
pdb.pdb_parse(&pdb);
|
||||
printf("Types:\n");
|
||||
pdb.print_types(&pdb);
|
||||
|
||||
printf("\nGlobals:\n");
|
||||
pdb.print_gvars(&pdb, 0x0);
|
||||
pdb.finish_pdb_parse(&pdb);
|
||||
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int bin_main (RCore *r, int mode, ut64 baddr, int va) {
|
||||
RBinAddr *binmain = r_bin_get_sym (r->bin, R_BIN_SYM_MAIN);
|
||||
if (!binmain) return R_FALSE;
|
||||
|
@ -1271,6 +1291,8 @@ R_API int r_core_bin_info (RCore *core, int action, int mode, int va, RCoreBinFi
|
|||
ret &= bin_main (core, mode, baseaddr, va);
|
||||
if ((action & R_CORE_BIN_ACC_DWARF))
|
||||
ret &= bin_dwarf (core, mode);
|
||||
if ((action & R_CORE_BIN_ACC_PDB))
|
||||
ret &= bin_pdb (core, mode);
|
||||
if ((action & R_CORE_BIN_ACC_ENTRIES))
|
||||
ret &= bin_entry (core, mode, baseaddr, loadaddr, va);
|
||||
if ((action & R_CORE_BIN_ACC_RELOCS))
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <r_io.h>
|
||||
#include <r_list.h>
|
||||
#include <r_bin_dwarf.h>
|
||||
#include <r_pdb.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -364,6 +364,7 @@ R_API void r_core_sysenv_help(const RCore* core);
|
|||
#define R_CORE_BIN_ACC_LIBS 0x200
|
||||
#define R_CORE_BIN_ACC_CLASSES 0x400
|
||||
#define R_CORE_BIN_ACC_DWARF 0x800
|
||||
#define R_CORE_BIN_ACC_PDB 0x2000
|
||||
#define R_CORE_BIN_ACC_SIZE 0x1000
|
||||
#define R_CORE_BIN_ACC_ALL 0xFFF
|
||||
|
||||
|
|
Loading…
Reference in New Issue