diff options
-rw-r--r-- | include/perk/perk.h | 1 | ||||
-rw-r--r-- | include/perk/perk_output.h | 13 | ||||
-rw-r--r-- | src/driver/pe_driver_ctx.c | 37 | ||||
-rw-r--r-- | src/internal/perk_driver_impl.h | 1 | ||||
-rw-r--r-- | src/skin/pe_skin_default.c | 10 |
5 files changed, 62 insertions, 0 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h index 4c444d8..712526b 100644 --- a/include/perk/perk.h +++ b/include/perk/perk.h @@ -164,6 +164,7 @@ struct pe_common_ctx { uint64_t drvflags; uint64_t actflags; uint64_t fmtflags; + uint64_t hdrdump; }; struct pe_driver_ctx { diff --git a/include/perk/perk_output.h b/include/perk/perk_output.h index a036ef9..d6e2529 100644 --- a/include/perk/perk_output.h +++ b/include/perk/perk_output.h @@ -16,6 +16,19 @@ #define PERK_OUTPUT_MDSO_LIBS 0x00000200 #define PERK_OUTPUT_MDSO_SYMS 0x00000400 +#define PERK_OUTPUT_HEADER_DUMP 0X00010000 +#define PERK_OUTPUT_HEADER_INFO 0X00020000 +#define PERK_OUTPUT_SECTION_DUMP 0X00040000 +#define PERK_OUTPUT_SECTION_INFO 0X00080000 + +/* header dump constants */ +#define PERK_HDRDUMP_IMAGE_DOS_HEADER 0X00000001 +#define PERK_HDRDUMP_COFF_IMAGE_HEADER 0X00000002 +#define PERK_HDRDUMP_COFF_OBJECT_HEADER 0X00000004 +#define PERK_HDRDUMP_COFF_OPT_HEADER 0X00000008 +#define PERK_HDRDUMP_SECTION_TABLE 0X00000100 +#define PERK_HDRDUMP_EXPORT_HEADER 0X00001000 +#define PERK_HDRDUMP_IMPORT_TABLE 0X00010000 /* pretty-printer flags */ #define PERK_PRETTY_LIST PERK_PRETTY(0x00000001) diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c index 486284c..bc20b6d 100644 --- a/src/driver/pe_driver_ctx.c +++ b/src/driver/pe_driver_ctx.c @@ -215,6 +215,43 @@ int pe_get_driver_ctx( case TAG_DSOSYMS: cctx.fmtflags |= PERK_OUTPUT_MDSO_SYMS; break; + + case TAG_HDRDUMP: + if (!entry->arg) { + cctx.hdrdump = 0; + cctx.hdrdump = ~cctx.hdrdump; + } else if (!strcmp(entry->arg,"dos")) { + cctx.hdrdump = PERK_HDRDUMP_IMAGE_DOS_HEADER; + } else if (!strcmp(entry->arg,"image.dos")) { + cctx.hdrdump = PERK_HDRDUMP_IMAGE_DOS_HEADER; + } else if (!strcmp(entry->arg,"coff")) { + cctx.hdrdump = PERK_HDRDUMP_COFF_IMAGE_HEADER; + cctx.hdrdump |= PERK_HDRDUMP_COFF_OBJECT_HEADER; + cctx.hdrdump |= PERK_HDRDUMP_COFF_OPT_HEADER; + } else if (!strcmp(entry->arg,"coff.image")) { + cctx.hdrdump = PERK_HDRDUMP_COFF_IMAGE_HEADER; + } else if (!strcmp(entry->arg,"coff.obj")) { + cctx.hdrdump = PERK_HDRDUMP_COFF_OBJECT_HEADER; + } else if (!strcmp(entry->arg,"coff.object")) { + cctx.hdrdump = PERK_HDRDUMP_COFF_OBJECT_HEADER; + } else if (!strcmp(entry->arg,"coff.opt")) { + cctx.hdrdump = PERK_HDRDUMP_COFF_OPT_HEADER; + } else if (!strcmp(entry->arg,"coff.optional")) { + cctx.hdrdump = PERK_HDRDUMP_COFF_OPT_HEADER; + } else if (!strcmp(entry->arg,"sectbl")) { + cctx.hdrdump = PERK_HDRDUMP_SECTION_TABLE; + } else if (!strcmp(entry->arg,"section.table")) { + cctx.hdrdump = PERK_HDRDUMP_SECTION_TABLE; + } else if (!strcmp(entry->arg,"exphdr")) { + cctx.hdrdump = PERK_HDRDUMP_EXPORT_HEADER; + } else if (!strcmp(entry->arg,"export.header")) { + cctx.hdrdump = PERK_HDRDUMP_EXPORT_HEADER; + } else if (!strcmp(entry->arg,"imptbl")) { + cctx.hdrdump = PERK_HDRDUMP_IMPORT_TABLE; + } else if (!strcmp(entry->arg,"import.table")) { + cctx.hdrdump = PERK_HDRDUMP_IMPORT_TABLE; + } + break; } } else nunits++; diff --git a/src/internal/perk_driver_impl.h b/src/internal/perk_driver_impl.h index b17b7be..dafad86 100644 --- a/src/internal/perk_driver_impl.h +++ b/src/internal/perk_driver_impl.h @@ -27,6 +27,7 @@ enum app_tags { TAG_IMPSYMS, TAG_DSOLIBS, TAG_DSOSYMS, + TAG_HDRDUMP, }; struct pe_driver_ctx_impl { diff --git a/src/skin/pe_skin_default.c b/src/skin/pe_skin_default.c index 60663ea..963af6e 100644 --- a/src/skin/pe_skin_default.c +++ b/src/skin/pe_skin_default.c @@ -40,5 +40,15 @@ const struct argv_option pe_default_options[] = { "list .dsometa (mdso) dependency libraries " "along with referenced symbols"}, + {"hdrdump", 'X',TAG_HDRDUMP,ARGV_OPTARG_OPTIONAL,0, + "dos|image.dos|" + "coff|coff.image|coff.object|coff.optional|" + "sectbl|section.table|" + "exphdr|export.header|" + "imptbl|import.table",0, + "output struct-based information for " + "either all headers (the default) " + "or a specific header"}, + {0,0,0,0,0,0,0,0} }; |