summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/pe_driver_ctx.c13
-rw-r--r--src/output/pe_output_import_libraries.c29
2 files changed, 38 insertions, 4 deletions
diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c
index 97ff3fa..32e0819 100644
--- a/src/driver/pe_driver_ctx.c
+++ b/src/driver/pe_driver_ctx.c
@@ -8,6 +8,7 @@ enum app_tags {
TAG_HELP,
TAG_VERSION,
TAG_OUTPUT,
+ TAG_PRETTY,
TAG_EXPSYMS,
TAG_IMPLIBS,
TAG_IMPSYMS,
@@ -24,6 +25,9 @@ static const struct argv_option options[] = {
{"output", 'o',TAG_OUTPUT, ARGV_OPTARG_REQUIRED, 0,"<file>",
"write output to %s"},
+ {"pretty", 'p',TAG_PRETTY, ARGV_OPTARG_REQUIRED, "yaml",0,
+ "format output for parsing by %s"},
+
{"expsyms", 'e',TAG_EXPSYMS,ARGV_OPTARG_NONE, 0,0,
"print exported symbols" },
@@ -127,6 +131,7 @@ int pe_get_driver_ctx(
uint64_t fflags;
const char * program;
const char * output;
+ const char * pretty;
int fdout;
if (!(meta = argv_get(argv,options,pe_argv_flags(flags))))
@@ -135,6 +140,7 @@ int pe_get_driver_ctx(
dflags = 0;
fflags = 0;
output = 0;
+ pretty = 0;
nunits = 0;
program = argv_program_name(argv[0]);
@@ -157,6 +163,10 @@ int pe_get_driver_ctx(
output = entry->arg;
break;
+ case TAG_PRETTY:
+ pretty = entry->arg;
+ break;
+
case TAG_EXPSYMS:
fflags |= PERK_OUTPUT_EXPORT_SYMS;
break;
@@ -184,6 +194,9 @@ int pe_get_driver_ctx(
if (!ctx)
return pe_get_driver_ctx_fail(meta);
+ if (pretty && !strcmp(pretty,"yaml"))
+ fflags |= PERK_PRETTY_YAML;
+
ctx->program = program;
ctx->cctx.drvflags = dflags;
ctx->cctx.fmtflags = fflags;
diff --git a/src/output/pe_output_import_libraries.c b/src/output/pe_output_import_libraries.c
index 1e47d81..2b864fb 100644
--- a/src/output/pe_output_import_libraries.c
+++ b/src/output/pe_output_import_libraries.c
@@ -8,13 +8,32 @@
#include <perk/perk_output.h>
#include "perk_output_impl.h"
+enum impsym_prefix_tag {
+ IMPSYM_PREFIX_DEFAULT,
+ IMPSYM_PREFIX_YAML
+};
+
+static const char * const impsym_prefix_arr[] = {
+ "--> ",
+ "- "
+};
+
+static const char * pretty_impsym_prefix(const struct pe_common_ctx * cctx)
+{
+ if (cctx->fmtflags & PERK_PRETTY_YAML)
+ return impsym_prefix_arr[IMPSYM_PREFIX_YAML];
+ else
+ return impsym_prefix_arr[IMPSYM_PREFIX_DEFAULT];
+}
+
int pe_output_import_libraries(
const struct pe_image_meta * m,
const struct pe_common_ctx * cctx,
FILE * fout)
{
- FILE * ftmp;
- int i,j;
+ FILE * ftmp;
+ int i,j;
+ const char * impsym_prefix;
if (!m->summary.num_of_implibs)
return 0;
@@ -22,6 +41,8 @@ int pe_output_import_libraries(
if (!(fout = pe_output_prolog(cctx,fout,&ftmp)))
return -1;
+ impsym_prefix = pretty_impsym_prefix(cctx);
+
for (i=0; i<m->summary.num_of_implibs; i++) {
if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
fprintf(fout,"%s:\n",m->idata[i].name);
@@ -31,8 +52,8 @@ int pe_output_import_libraries(
if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
for (j=0; j<m->idata[i].count; j++)
if (m->idata[i].items[j].name)
- fprintf(fout,"==> %s\n",
- m->idata[i].items[j].name);
+ fprintf(fout,"%s%s\n",
+ impsym_prefix,m->idata[i].items[j].name);
}
return pe_output_epilog(0,ftmp);