diff options
author | midipix <writeonce@midipix.org> | 2015-05-08 23:22:07 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2015-05-08 23:22:07 -0400 |
commit | feffc7263bb2fd33ae467de2dd51f1ddbbb1b895 (patch) | |
tree | 983daec02a2d1833796ad8bd04d43d9b3ec42765 /src/imports | |
parent | 23329916dde5e0ffa056f74a81aeda1bfb7e54cc (diff) | |
download | pemagine-feffc7263bb2fd33ae467de2dd51f1ddbbb1b895.tar.bz2 pemagine-feffc7263bb2fd33ae467de2dd51f1ddbbb1b895.tar.xz |
initial commit.
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/pe_enum_image_import_hdrs.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/imports/pe_enum_image_import_hdrs.c b/src/imports/pe_enum_image_import_hdrs.c new file mode 100644 index 0000000..0a1a10e --- /dev/null +++ b/src/imports/pe_enum_image_import_hdrs.c @@ -0,0 +1,35 @@ +/*****************************************************************************/ +/* pemagination: a (virtual) tour into portable bits and executable bytes */ +/* Copyright (C) 2013,2014,2015 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.PEMAGINE. */ +/*****************************************************************************/ + +#include <psxtypes/psxtypes.h> +#include <pemagine/pe_structs.h> +#include <pemagine/pemagine.h> + +pe_api +int pe_enum_image_import_hdrs( + const void * base, + pe_enum_image_import_hdrs_callback * callback, + void * ctx) +{ + struct pe_import_hdr * imp_hdr; + int ret; + + if (!(imp_hdr = pe_get_image_import_dir_addr(base,0))) { + callback(base,0,PE_CALLBACK_REASON_ERROR,ctx); + return -1; + } + + if ((ret = callback(base,0,PE_CALLBACK_REASON_INIT,ctx)) <= 0) + return ret; + + while (imp_hdr->name_rva[0]) { + if ((ret = callback(base,imp_hdr,PE_CALLBACK_REASON_ITEM,ctx)) <= 0) + return ret; + imp_hdr++; + }; + + return callback(base,imp_hdr,PE_CALLBACK_REASON_DONE,ctx); +} |