Blame src/output/pe_output_image_sections.c

437706
/***************************************************************/
437706
/*  perk: PE Resource Kit                                      */
425fb8
/*  Copyright (C) 2015--2021  SysDeer Technologies, LLC        */
437706
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
437706
/***************************************************************/
437706
437706
#include <stdio.h>
437706
437706
#include <perk/perk.h>
437706
#include <perk/perk_output.h>
67bba7
#include "perk_driver_impl.h"
67bba7
#include "perk_dprintf_impl.h"
437706
#include "perk_errinfo_impl.h"
437706
437706
int pe_output_image_sections(
437706
	const struct pe_driver_ctx *	dctx,
67bba7
	const struct pe_image_meta *	meta)
437706
{
437706
	int		i;
67bba7
	int		fdout;
437706
	const char * 	dash = "";
437706
67bba7
	fdout = pe_driver_fdout(dctx);
437706
437706
	if (dctx->cctx->fmtflags & PERK_PRETTY_YAML) {
67bba7
		if (pe_dprintf(fdout,"sections:\n") < 0)
437706
			return PERK_FILE_ERROR(dctx);
437706
437706
		dash = "- ";
437706
	}
437706
58ced9
	for (i=0; i<meta->m_coff.cfh_num_of_sections; i++)
67bba7
		if (pe_dprintf(
67bba7
				fdout,
67bba7
				"%s%s\n",
437706
				dash,
58ced9
				meta->m_sectbl[i].sh_long_name
58ced9
					? meta->m_sectbl[i].sh_long_name
58ced9
					: meta->m_sectbl[i].sh_name) < 0)
437706
			return PERK_FILE_ERROR(dctx);
437706
437706
	return 0;
437706
}