summaryrefslogtreecommitdiff
path: root/plugins/pe/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pe/format.c')
-rw-r--r--plugins/pe/format.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/pe/format.c b/plugins/pe/format.c
index f5bdac1..3839063 100644
--- a/plugins/pe/format.c
+++ b/plugins/pe/format.c
@@ -722,14 +722,23 @@ const image_data_directory *g_pe_format_get_directories(const GPeFormat *format,
{
const image_data_directory *result; /* Liste à retourner */
- if (count != NULL)
- *count = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
-
if (g_pe_format_get_is_32b(format))
+ {
result = format->nt_headers.optional_header.header_32.data_directory;
+
+ if (count != NULL)
+ *count = format->nt_headers.optional_header.header_32.number_of_rva_and_sizes;
+
+ }
else
+ {
result = format->nt_headers.optional_header.header_64.data_directory;
+ if (count != NULL)
+ *count = format->nt_headers.optional_header.header_64.number_of_rva_and_sizes;
+
+ }
+
return result;
}
@@ -751,6 +760,7 @@ const image_data_directory *g_pe_format_get_directories(const GPeFormat *format,
void *g_pe_format_get_directory(const GPeFormat *format, size_t index)
{
void *result; /* Données à retourner */
+ size_t max; /* Quantité de répertoires */
const image_data_directory *dir; /* Localisation du répertoire */
vmpa2t pos; /* Tête de lecture */
bool status; /* Bilan d'un traitement */
@@ -760,10 +770,11 @@ void *g_pe_format_get_directory(const GPeFormat *format, size_t index)
result = NULL;
- if (index >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES)
+ dir = g_pe_format_get_directories(format, &max);
+
+ if (index >= max)
goto exit;
- dir = g_pe_format_get_directories(format, NULL);
dir += index;
status = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), dir->virtual_address, &pos);