summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-24 21:54:55 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:53 -0500
commitf64a5b0864c52fcf372c12a92cf9ba5feaa13e77 (patch)
tree49cc1be35a75e4418e621ff79bc655496f073ddc /src/output
parent251206109d1c2d9c52dc63bbce431685fbabf0a7 (diff)
downloadperk-f64a5b0864c52fcf372c12a92cf9ba5feaa13e77.tar.bz2
perk-f64a5b0864c52fcf372c12a92cf9ba5feaa13e77.tar.xz
pe_output_export_symbols(): added error trace support.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/pe_output_export_symbols.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/output/pe_output_export_symbols.c b/src/output/pe_output_export_symbols.c
index 0ab3539..d47cb7a 100644
--- a/src/output/pe_output_export_symbols.c
+++ b/src/output/pe_output_export_symbols.c
@@ -13,6 +13,7 @@
#include <perk/perk.h>
#include <perk/perk_output.h>
#include "perk_output_impl.h"
+#include "perk_errinfo_impl.h"
static int pretty_header(const struct pe_common_ctx * cctx, FILE * fout)
{
@@ -32,23 +33,26 @@ static int pretty_export_item(const struct pe_common_ctx * cctx, const char * na
}
int pe_output_export_symbols(
+ const struct pe_driver_ctx * dctx,
const struct pe_image_meta * m,
- const struct pe_common_ctx * cctx,
FILE * fout)
{
- FILE * ftmp;
- uint32_t offset;
- uint32_t * symrva;
- unsigned i;
+ FILE * ftmp;
+ uint32_t offset;
+ uint32_t * symrva;
+ unsigned i;
+ const struct pe_common_ctx * cctx = dctx->cctx;
if (!m->hedata)
return 0;
if (!(fout = pe_output_prolog(cctx,fout,&ftmp)))
- return -1;
+ return PERK_SYSTEM_ERROR(dctx);
if ((pretty_header(cctx,fout)) < 0)
- return pe_output_epilog(-1,ftmp);
+ return pe_output_epilog(
+ PERK_FILE_ERROR(dctx),
+ ftmp);
offset = m->hedata->virtual_addr - m->hedata->ptr_to_raw_data;
symrva = (uint32_t *)((uintptr_t)m->image.addr + (m->edata.name_ptr_rva - offset));
@@ -58,7 +62,9 @@ int pe_output_export_symbols(
cctx,
(char *)((uintptr_t)m->image.addr + symrva[i] - offset),
fout)) < 0)
- return pe_output_epilog(-1,ftmp);
+ return pe_output_epilog(
+ PERK_FILE_ERROR(dctx),
+ ftmp);
return pe_output_epilog(0,ftmp);
}