summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
Diffstat (limited to 'src/output')
-rw-r--r--src/output/pe_output_image_sections.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/output/pe_output_image_sections.c b/src/output/pe_output_image_sections.c
new file mode 100644
index 0000000..b538cdf
--- /dev/null
+++ b/src/output/pe_output_image_sections.c
@@ -0,0 +1,40 @@
+/***************************************************************/
+/* perk: PE Resource Kit */
+/* Copyright (C) 2015--2016 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
+/***************************************************************/
+
+#include <stdio.h>
+
+#include <perk/perk.h>
+#include <perk/perk_output.h>
+#include "perk_errinfo_impl.h"
+
+int pe_output_image_sections(
+ const struct pe_driver_ctx * dctx,
+ const struct pe_image_meta * meta,
+ FILE * fout)
+{
+ int i;
+ const char * dash = "";
+
+ if (!fout)
+ fout = stdout;
+
+ if (dctx->cctx->fmtflags & PERK_PRETTY_YAML) {
+ if (fputs("sections:\n",fout) < 0)
+ return PERK_FILE_ERROR(dctx);
+
+ dash = "- ";
+ }
+
+ for (i=0; i<meta->coff.num_of_sections; i++)
+ if (fprintf(fout,"%s%s\n",
+ dash,
+ meta->sectbl[i].long_name
+ ? meta->sectbl[i].long_name
+ : meta->sectbl[i].name) < 0)
+ return PERK_FILE_ERROR(dctx);
+
+ return 0;
+}