From f5eb13ba3a0d8f1ef1e170e41b7491210b3028d3 Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 13 Dec 2017 21:00:10 -0500 Subject: project: renamed pe_output_import_libraries.c -> pe_output_idata_libraries.c. --- project/common.mk | 2 +- src/output/pe_output_idata_libraries.c | 77 +++++++++++++++++++++++++++++++++ src/output/pe_output_import_libraries.c | 77 --------------------------------- 3 files changed, 78 insertions(+), 78 deletions(-) create mode 100644 src/output/pe_output_idata_libraries.c delete mode 100644 src/output/pe_output_import_libraries.c diff --git a/project/common.mk b/project/common.mk index 5ae9b5d..1dfe22c 100644 --- a/project/common.mk +++ b/project/common.mk @@ -14,7 +14,7 @@ API_SRCS = \ src/output/pe_output_image_sections.c \ src/output/pe_output_image_strings.c \ src/output/pe_output_image_symbols.c \ - src/output/pe_output_import_libraries.c \ + src/output/pe_output_idata_libraries.c \ src/reader/pe_read_coff_header.c \ src/reader/pe_read_coff_symbol.c \ src/reader/pe_read_dos_header.c \ diff --git a/src/output/pe_output_idata_libraries.c b/src/output/pe_output_idata_libraries.c new file mode 100644 index 0000000..a5c49bf --- /dev/null +++ b/src/output/pe_output_idata_libraries.c @@ -0,0 +1,77 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2017 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include +#include "perk_errinfo_impl.h" + +static int pretty_header(const struct pe_common_ctx * cctx, FILE * fout) +{ + return (cctx->fmtflags & PERK_PRETTY_YAML) + ? fputs("imports:\n",fout) + : 0; +} + +static int pretty_implib_header(const struct pe_common_ctx * cctx, const char * name, FILE * fout) +{ + if ((cctx->fmtflags & PERK_PRETTY_YAML) && (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)) + return fprintf(fout," %s:\n",name); + else if (cctx->fmtflags & PERK_PRETTY_YAML) + return fprintf(fout,"- %s:\n",name); + else if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS) + return fprintf(fout,"%s:\n",name); + else + return fprintf(fout,"%s\n",name); +} + +static int pretty_implib_item(const struct pe_common_ctx * cctx, const char * name, FILE * fout) +{ + if (cctx->fmtflags & PERK_PRETTY_YAML) + return fprintf(fout," - %s\n",name); + else + return fprintf(fout,"%s\n",name); +} + +int pe_output_import_libraries( + const struct pe_driver_ctx * dctx, + const struct pe_image_meta * m, + FILE * fout) +{ + int i; + unsigned j; + const struct pe_common_ctx * cctx = dctx->cctx; + + if (!m->m_stats.t_nimplibs) + return 0; + + if (!fout) + fout = stdout; + + if ((pretty_header(cctx,fout)) < 0) + return PERK_FILE_ERROR(dctx); + + for (i=0; im_stats.t_nimplibs; i++) { + if ((pretty_implib_header(cctx,m->m_idata[i].ih_name,fout)) < 0) + return PERK_FILE_ERROR(dctx); + + if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS) + for (j=0; jm_idata[i].ih_count; j++) + if (m->m_idata[i].ih_items[j].ii_name) + if ((pretty_implib_item( + cctx, + m->m_idata[i].ih_items[j].ii_name, + fout)) < 0) + return PERK_FILE_ERROR(dctx); + } + + return 0; +} diff --git a/src/output/pe_output_import_libraries.c b/src/output/pe_output_import_libraries.c deleted file mode 100644 index a5c49bf..0000000 --- a/src/output/pe_output_import_libraries.c +++ /dev/null @@ -1,77 +0,0 @@ -/***************************************************************/ -/* perk: PE Resource Kit */ -/* Copyright (C) 2015--2017 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ -/***************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include -#include "perk_errinfo_impl.h" - -static int pretty_header(const struct pe_common_ctx * cctx, FILE * fout) -{ - return (cctx->fmtflags & PERK_PRETTY_YAML) - ? fputs("imports:\n",fout) - : 0; -} - -static int pretty_implib_header(const struct pe_common_ctx * cctx, const char * name, FILE * fout) -{ - if ((cctx->fmtflags & PERK_PRETTY_YAML) && (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)) - return fprintf(fout," %s:\n",name); - else if (cctx->fmtflags & PERK_PRETTY_YAML) - return fprintf(fout,"- %s:\n",name); - else if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS) - return fprintf(fout,"%s:\n",name); - else - return fprintf(fout,"%s\n",name); -} - -static int pretty_implib_item(const struct pe_common_ctx * cctx, const char * name, FILE * fout) -{ - if (cctx->fmtflags & PERK_PRETTY_YAML) - return fprintf(fout," - %s\n",name); - else - return fprintf(fout,"%s\n",name); -} - -int pe_output_import_libraries( - const struct pe_driver_ctx * dctx, - const struct pe_image_meta * m, - FILE * fout) -{ - int i; - unsigned j; - const struct pe_common_ctx * cctx = dctx->cctx; - - if (!m->m_stats.t_nimplibs) - return 0; - - if (!fout) - fout = stdout; - - if ((pretty_header(cctx,fout)) < 0) - return PERK_FILE_ERROR(dctx); - - for (i=0; im_stats.t_nimplibs; i++) { - if ((pretty_implib_header(cctx,m->m_idata[i].ih_name,fout)) < 0) - return PERK_FILE_ERROR(dctx); - - if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS) - for (j=0; jm_idata[i].ih_count; j++) - if (m->m_idata[i].ih_items[j].ii_name) - if ((pretty_implib_item( - cctx, - m->m_idata[i].ih_items[j].ii_name, - fout)) < 0) - return PERK_FILE_ERROR(dctx); - } - - return 0; -} -- cgit v1.2.3