diff options
author | midipix <writeonce@midipix.org> | 2015-11-21 22:40:50 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-10 23:35:25 -0500 |
commit | ab024a80297e6c3ea6a7a0d77b5a8d51800ba203 (patch) | |
tree | f7532f2d695c929d4ca2bc1d17253f61d306920b | |
parent | a3de1cabbe842d10d38f6b6ba24ee44cf15c5dac (diff) | |
download | perk-ab024a80297e6c3ea6a7a0d77b5a8d51800ba203.tar.bz2 perk-ab024a80297e6c3ea6a7a0d77b5a8d51800ba203.tar.xz |
driver integration 3/9: adjust prototype of pe_output_export_symbols().
-rw-r--r-- | include/perk/perk.h | 2 | ||||
-rw-r--r-- | src/output/pe_output_export_symbols.c | 22 |
2 files changed, 21 insertions, 3 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h index ca51be4..22f7bd5 100644 --- a/include/perk/perk.h +++ b/include/perk/perk.h @@ -157,7 +157,7 @@ perk_api int pe_get_unit_ctx (struct pe_driver_ctx *, const char * name, struct perk_api int pe_free_unit_ctx (struct pe_unit_ctx *); /* utility api */ -perk_api int pe_output_export_symbols (const struct pe_image_meta *, uint32_t flags, FILE *); +perk_api int pe_output_export_symbols (const struct pe_image_meta *, const struct pe_common_ctx *, FILE *); /* high-level api */ perk_api int pe_map_raw_image (int fd, const char * name, int prot, struct pe_raw_image *); diff --git a/src/output/pe_output_export_symbols.c b/src/output/pe_output_export_symbols.c index 099b540..fde10c5 100644 --- a/src/output/pe_output_export_symbols.c +++ b/src/output/pe_output_export_symbols.c @@ -6,13 +6,28 @@ #include <perk/perk.h> -int pe_output_export_symbols (const struct pe_image_meta * m, uint32_t flags, FILE * f) +int pe_output_export_symbols (const struct pe_image_meta * m, const struct pe_common_ctx * cctx, FILE * f) { uint32_t offset; uint32_t * symrva; + int fdout; int i; - if (!m->hedata) return 0; + if (!m->hedata) + return 0; + else if (f) + fdout = -1; + else if (!cctx) + return -1; + else if (cctx->fdout < 0) { + f = stdout; + fdout = -1; + } else if ((fdout = dup(cctx->fdout)) < 0) + return -1; + else if (!(f = fdopen(fdout,"a"))) { + close(fdout); + return -1; + } 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)); @@ -20,5 +35,8 @@ int pe_output_export_symbols (const struct pe_image_meta * m, uint32_t flags, FI for (i=0; i<m->edata.num_of_name_ptrs; i++) fprintf(f,"%s\n",(char *)((uintptr_t)m->image.addr + symrva[i] - offset)); + if (fdout >= 0) + fclose(f); + return 0; } |