|
|
e2e2c2 |
/***************************************************************/
|
|
|
e2e2c2 |
|
|
|
ced38a |
|
|
|
e2e2c2 |
|
|
|
e2e2c2 |
/***************************************************************/
|
|
|
e2e2c2 |
|
|
|
c0fbae |
#include <stdint.h>
|
|
|
c0fbae |
#include <stdlib.h>
|
|
|
c0fbae |
#include <stdio.h>
|
|
|
c0fbae |
#include <string.h>
|
|
|
c0fbae |
#include <errno.h>
|
|
|
c0fbae |
|
|
|
c0fbae |
#include <perk/perk.h>
|
|
|
e343a6 |
#include <perk/perk_output.h>
|
|
|
67bba7 |
#include "perk_driver_impl.h"
|
|
|
67bba7 |
#include "perk_dprintf_impl.h"
|
|
|
f64a5b |
#include "perk_errinfo_impl.h"
|
|
|
c0fbae |
|
|
|
67bba7 |
static int pretty_header(
|
|
|
67bba7 |
int fdout,
|
|
|
67bba7 |
const struct pe_common_ctx * cctx)
|
|
|
e343a6 |
{
|
|
|
08a894 |
if (cctx->fmtflags & PERK_PRETTY_YAML)
|
|
|
67bba7 |
return pe_dprintf(fdout,"exports:\n");
|
|
|
08a894 |
else if (cctx->fmtflags & PERK_PRETTY_DLLTOOL)
|
|
|
67bba7 |
return pe_dprintf(fdout,"EXPORTS\n");
|
|
|
08a894 |
return 0;
|
|
|
e343a6 |
}
|
|
|
e343a6 |
|
|
|
67bba7 |
static int pretty_export_item(
|
|
|
67bba7 |
int fdout,
|
|
|
67bba7 |
const struct pe_common_ctx * cctx,
|
|
|
67bba7 |
const char * name)
|
|
|
e343a6 |
{
|
|
|
e343a6 |
if (cctx->fmtflags & PERK_PRETTY_YAML)
|
|
|
67bba7 |
return pe_dprintf(fdout,"- %s\n",name);
|
|
|
e343a6 |
else
|
|
|
67bba7 |
return pe_dprintf(fdout,"%s\n",name);
|
|
|
e343a6 |
}
|
|
|
e343a6 |
|
|
|
2b7f36 |
int pe_output_export_symbols(
|
|
|
f64a5b |
const struct pe_driver_ctx * dctx,
|
|
|
67bba7 |
const struct pe_image_meta * m)
|
|
|
c0fbae |
{
|
|
|
67bba7 |
int fdout;
|
|
|
c3af45 |
char * mark;
|
|
|
f64a5b |
uint32_t offset;
|
|
|
f64a5b |
uint32_t * symrva;
|
|
|
f64a5b |
unsigned i;
|
|
|
f64a5b |
const struct pe_common_ctx * cctx = dctx->cctx;
|
|
|
c0fbae |
|
|
|
67bba7 |
fdout = pe_driver_fdout(dctx);
|
|
|
67bba7 |
|
|
|
25e3c0 |
if (!m->h_edata)
|
|
|
ab024a |
return 0;
|
|
|
7cd8bc |
|
|
|
67bba7 |
if ((pretty_header(fdout,cctx)) < 0)
|
|
|
f11c1f |
return PERK_FILE_ERROR(dctx);
|
|
|
e343a6 |
|
|
|
ed06fb |
mark = m->r_image.map_addr;
|
|
|
25e3c0 |
offset = m->h_edata->sh_virtual_addr - m->h_edata->sh_ptr_to_raw_data;
|
|
|
58ced9 |
symrva = (uint32_t *)(mark + m->m_edata.eh_name_ptr_rva - offset);
|
|
|
c0fbae |
|
|
|
58ced9 |
for (i=0; i<m->m_edata.eh_num_of_name_ptrs; i++)
|
|
|
6025fb |
if ((pretty_export_item(
|
|
|
67bba7 |
fdout,cctx,
|
|
|
67bba7 |
&mark[symrva[i] - offset])) < 0)
|
|
|
f11c1f |
return PERK_FILE_ERROR(dctx);
|
|
|
ab024a |
|
|
|
f11c1f |
return 0;
|
|
|
c0fbae |
}
|