This commit is contained in:
Álvaro Felipe Melchor 2015-04-07 20:03:13 +02:00 committed by pancake
parent bbae76ce4d
commit e858a7c00a
2 changed files with 28 additions and 25 deletions

View File

@ -7,7 +7,7 @@
static void pair(const char *a, const char *b) {
char ws[16];
int al = strlen (a);
if (!b) b = "";
if (!b) return; //b = "";
memset (ws, ' ', sizeof (ws));
al = PAIR_WIDTH-al;
if (al<0) al = 0;
@ -288,8 +288,8 @@ static int bin_info (RCore *r, int mode) {
if (mode & R_CORE_BIN_JSON) {
r_cons_printf ("{\"type\":\"%s\","
"\"class\":\"%s\","
"\"endian\":\"%s\","
"\"machine\":\"%s\","
/*"\"endian\":\"%s\","*/
/*"\"machine\":\"%s\","*/
"\"arch\":\"%s\","
"\"os\":\"%s\","
"\"lang\":\"%s\","
@ -298,7 +298,7 @@ static int bin_info (RCore *r, int mode) {
"\"nx\":%s,"
"\"crypto\":%s,"
"\"va\":%s,"
"\"bits\":%d,"
/*"\"bits\":%d,"*/
"\"stripped\":%s,"
"\"static\":%s,"
"\"linenums\":%s,"
@ -306,8 +306,8 @@ static int bin_info (RCore *r, int mode) {
"\"relocs\":%s}",
STR(info->rclass), // type
STR(info->bclass), // class
info->big_endian? "big": "little",
STR(info->machine),
/*info->big_endian? "big": "little",*/
/*STR(info->machine),*/
STR(info->arch),
STR(info->os),
info->lang?info->lang:"",
@ -316,7 +316,7 @@ static int bin_info (RCore *r, int mode) {
r_str_bool (info->has_nx),
r_str_bool (info->has_crypto),
r_str_bool (info->has_va),
info->bits,
/*info->bits,*/
r_str_bool ((R_BIN_DBG_STRIPPED & info->dbg_info)),
r_str_bool (r_bin_is_static (r->bin)),//R_BIN_DBG_STATIC (info->dbg_info)),
r_str_bool ((R_BIN_DBG_LINENUMS & info->dbg_info)),
@ -378,9 +378,9 @@ static int bin_info (RCore *r, int mode) {
} else {
// if type is 'fs' show something different?
//r_cons_printf ("# File info\n");
pair ("file", info->file);
pair ("type", info->type);
/*pair ("file", info->file);*/
/*pair ("type", info->type);*/
pair ("pic", r_str_bool (info->has_pi));
pair ("canary", r_str_bool (info->has_canary));
pair ("nx", r_str_bool (info->has_nx));
@ -390,11 +390,11 @@ static int bin_info (RCore *r, int mode) {
pair ("class", info->bclass);
pair ("lang", info->lang? info->lang: "unknown");
pair ("arch", info->arch);
pair ("bits", sdb_fmt (0, "%d", info->bits));
pair ("machine", info->machine);
/*pair ("bits", sdb_fmt (0, "%d", info->bits));*/
/*pair ("machine", info->machine);*/
pair ("os", info->os);
pair ("subsys", info->subsystem);
pair ("endian", info->big_endian? "big": "little");
/*pair ("endian", info->big_endian? "big": "little");*/
pair ("strip", r_str_bool (R_BIN_DBG_STRIPPED &info->dbg_info));
pair ("static", r_str_bool (r_bin_is_static (r->bin)));
pair ("linenum", r_str_bool (R_BIN_DBG_LINENUMS &info->dbg_info));

View File

@ -4,7 +4,7 @@
static void pair(const char *a, const char *b) {
char ws[16];
int al = strlen (a);
if (!b) b = "";
if (!b) return; // b = "";
memset (ws, ' ', sizeof (ws));
al = PAIR_WIDTH - al;
if (al<0) al = 0;
@ -70,19 +70,19 @@ static void r_core_file_info (RCore *core, int mode) {
switch (mode) {
case R_CORE_BIN_JSON:
r_cons_printf ("\"type\":\"%s\","
"\"os\":\"%s\","
"\"arch\":\"%s\","
/*"\"os\":\"%s\","*/
"\"machine\":\"%s\","
"\"bits\":%d,"
"\"endian\":\"%s\","
, STR(info->type)
, STR(info->os)
/*, STR(info->os)*/
, STR(info->machine)
, info->bits
, info->big_endian? "big": "little");
break;
default:
pair ("type", info->type);
pair ("os", info->os);
/*pair ("os", info->os);*/
pair ("machine", info->machine);
pair ("bits", sdb_fmt (0, "%d", info->bits));
pair ("endian", info->big_endian? "big": "little");
@ -93,7 +93,7 @@ static void r_core_file_info (RCore *core, int mode) {
r_cons_printf ("\"file\":\"%s\"", fn);
if (dbg) dbg = R_IO_WRITE | R_IO_EXEC;
if (cf->desc) {
r_cons_printf (",\"uri\":\"%s\"", cf->desc->uri);
/*r_cons_printf (",\"uri\":\"%s\"", cf->desc->uri);*/
r_cons_printf (",\"fd\":%d", cf->desc->fd);
r_cons_printf (",\"size\":%"PFMT64d, r_io_desc_size (core->io, cf->desc));
r_cons_printf (",\"mode\":\"%s\"", r_str_rwx_i (
@ -123,7 +123,7 @@ static void r_core_file_info (RCore *core, int mode) {
pair ("blksz", sdb_fmt (0, "0x%"PFMT64x,
(ut64)core->io->desc->obsz));
pair ("mode", r_str_rwx_i (cf->desc->flags & 7));
pair ("uri", cf->desc->uri);
/*pair ("uri", cf->desc->uri);*/
}
pair ("block", sdb_fmt (0, "0x%x", core->blocksize));
if (binfile && binfile->curxtr)
@ -134,14 +134,17 @@ static void r_core_file_info (RCore *core, int mode) {
}
static void cmd_info_bin(RCore *core, ut64 offset, int va, int mode) {
RBinInfo *info = r_bin_get_info (core->bin);
if (core->file) {
if (mode == R_CORE_BIN_JSON)
r_cons_printf ("{\"bin\":");
r_core_bin_info (core, R_CORE_BIN_ACC_INFO,
mode, va, NULL, offset, NULL);
if (mode == R_CORE_BIN_JSON)
r_cons_printf (",\"core\":");
r_cons_printf ("{\"core\":");
r_core_file_info (core, mode);
if (!strncmp (info->type, "Executable file", 15)){
if (mode == R_CORE_BIN_JSON)
r_cons_printf (",\"bin\":");
r_core_bin_info (core, R_CORE_BIN_ACC_INFO,
mode, va, NULL, offset, NULL);
}
if (mode == R_CORE_BIN_JSON)
r_cons_printf ("}\n");
} else eprintf ("No selected file\n");