|
 |
f779e3 |
/***************************************************************/
|
|
 |
f779e3 |
/* perk: PE Resource Kit */
|
|
 |
6a5301 |
/* Copyright (C) 2015--2025 SysDeer Technologies, LLC */
|
|
 |
f779e3 |
/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
|
|
 |
f779e3 |
/***************************************************************/
|
|
 |
f779e3 |
|
|
 |
f779e3 |
#include <stdio.h>
|
|
 |
f779e3 |
#include <string.h>
|
|
 |
f779e3 |
|
|
 |
f779e3 |
#include <perk/perk.h>
|
|
 |
d6e02b |
#include <perk/perk_structs.h>
|
|
 |
f779e3 |
#include <perk/perk_output.h>
|
|
 |
f779e3 |
#include "perk_reader_impl.h"
|
|
 |
67bba7 |
#include "perk_driver_impl.h"
|
|
 |
67bba7 |
#include "perk_dprintf_impl.h"
|
|
 |
f779e3 |
#include "perk_errinfo_impl.h"
|
|
 |
f779e3 |
|
|
 |
ece10a |
static int pe_output_symbol_names(
|
|
 |
f779e3 |
const struct pe_driver_ctx * dctx,
|
|
 |
ece10a |
const struct pe_image_meta * meta,
|
|
 |
ece10a |
int fdout)
|
|
 |
f779e3 |
{
|
|
 |
f848fd |
struct pe_meta_coff_symbol * symrec;
|
|
 |
f779e3 |
|
|
 |
ece10a |
for (symrec=meta->m_symtbl; symrec->cs_name; symrec++)
|
|
 |
ece10a |
if (pe_dprintf(fdout,"%s\n",symrec->cs_name) < 0)
|
|
 |
f779e3 |
return PERK_FILE_ERROR(dctx);
|
|
 |
f779e3 |
|
|
 |
ece10a |
return 0;
|
|
 |
ece10a |
}
|
|
 |
ece10a |
|
|
 |
ece10a |
static int pe_output_symbol_names_yaml(
|
|
 |
ece10a |
const struct pe_driver_ctx * dctx,
|
|
 |
ece10a |
const struct pe_image_meta * meta,
|
|
 |
ece10a |
int fdout)
|
|
 |
ece10a |
{
|
|
 |
ece10a |
struct pe_meta_coff_symbol * symrec;
|
|
 |
ece10a |
|
|
 |
ece10a |
if (pe_dprintf(fdout," - Symbols:\n") < 0)
|
|
 |
ece10a |
return PERK_FILE_ERROR(dctx);
|
|
 |
f779e3 |
|
|
 |
f848fd |
for (symrec=meta->m_symtbl; symrec->cs_name; symrec++)
|
|
 |
ece10a |
if (pe_dprintf(fdout," - [ symbol: %s ]\n",symrec->cs_name) < 0)
|
|
 |
ea6b78 |
return PERK_FILE_ERROR(dctx);
|
|
 |
f779e3 |
|
|
 |
f779e3 |
return 0;
|
|
 |
f779e3 |
}
|
|
 |
ece10a |
|
|
 |
ece10a |
int pe_output_image_symbols(
|
|
 |
ece10a |
const struct pe_driver_ctx * dctx,
|
|
 |
ece10a |
const struct pe_image_meta * meta)
|
|
 |
ece10a |
{
|
|
 |
ece10a |
int fdout = pe_driver_fdout(dctx);
|
|
 |
ece10a |
|
|
 |
ece10a |
if (dctx->cctx->fmtflags & PERK_PRETTY_YAML) {
|
|
 |
ece10a |
if (pe_output_symbol_names_yaml(dctx,meta,fdout) < 0)
|
|
 |
ece10a |
return PERK_NESTED_ERROR(dctx);
|
|
 |
ece10a |
|
|
 |
ece10a |
} else {
|
|
 |
ece10a |
if (pe_output_symbol_names(dctx,meta,fdout) < 0)
|
|
 |
ece10a |
return PERK_NESTED_ERROR(dctx);
|
|
 |
ece10a |
}
|
|
 |
ece10a |
|
|
 |
ece10a |
return 0;
|
|
 |
ece10a |
}
|