|
|
feffc7 |
/*****************************************************************************/
|
|
|
feffc7 |
/* pemagination: a (virtual) tour into portable bits and executable bytes */
|
|
|
feffc7 |
/* Copyright (C) 2013,2014,2015 Z. Gilboa */
|
|
|
feffc7 |
/* Released under GPLv2 and GPLv3; see COPYING.PEMAGINE. */
|
|
|
feffc7 |
/*****************************************************************************/
|
|
|
feffc7 |
|
|
|
feffc7 |
#include <psxtypes/psxtypes.h>
|
|
|
feffc7 |
#include <pemagine/pe_consts.h>
|
|
|
feffc7 |
#include <pemagine/pe_structs.h>
|
|
|
feffc7 |
#include <pemagine/pemagine.h>
|
|
|
feffc7 |
#include "pe_impl.h"
|
|
|
feffc7 |
|
|
|
feffc7 |
pe_api
|
|
|
feffc7 |
void * pe_get_image_special_hdr_addr(const void * base, uint32_t ordinal, uint32_t * sec_size)
|
|
|
feffc7 |
{
|
|
|
fb643b |
struct pe_raw_data_dirs*dirs;
|
|
|
feffc7 |
struct pe_block * dir;
|
|
|
feffc7 |
uint32_t * count;
|
|
|
feffc7 |
|
|
|
feffc7 |
if (!(dirs = pe_get_image_data_dirs_addr(base)))
|
|
|
feffc7 |
return 0;
|
|
|
feffc7 |
|
|
|
feffc7 |
count = (uint32_t *)dirs->rva_and_sizes;
|
|
|
feffc7 |
|
|
|
feffc7 |
if (*count < (ordinal+1))
|
|
|
feffc7 |
return 0;
|
|
|
feffc7 |
|
|
|
feffc7 |
dir = (struct pe_block *)dirs->export_tbl;
|
|
|
feffc7 |
dir += ordinal;
|
|
|
feffc7 |
|
|
|
feffc7 |
if (sec_size)
|
|
|
feffc7 |
*sec_size = dir->size;
|
|
|
feffc7 |
|
|
|
feffc7 |
return dir->rva
|
|
|
feffc7 |
? pe_va_from_rva(base,dir->rva)
|
|
|
feffc7 |
: 0;
|
|
|
feffc7 |
}
|
|
|
feffc7 |
|
|
|
feffc7 |
pe_api
|
|
|
149cda |
struct pe_raw_export_hdr * pe_get_image_export_hdr_addr(const void * base, uint32_t * sec_size)
|
|
|
feffc7 |
{
|
|
|
149cda |
return (struct pe_raw_export_hdr *)pe_get_image_special_hdr_addr(base,PE_IMAGE_DATA_DIR_ORDINAL_EXPORT,sec_size);
|
|
|
feffc7 |
}
|
|
|
feffc7 |
|
|
|
feffc7 |
pe_api
|
|
|
504536 |
struct pe_raw_import_hdr * pe_get_image_import_dir_addr(const void * base, uint32_t * sec_size)
|
|
|
feffc7 |
{
|
|
|
504536 |
return (struct pe_raw_import_hdr *)pe_get_image_special_hdr_addr(base,PE_IMAGE_DATA_DIR_ORDINAL_IMPORT,sec_size);
|
|
|
feffc7 |
}
|