[PATCH 15/16] [DbgHelp]: added helper to image_file_map to map also directory out of PE executables
Eric Pouech
eric.pouech at orange.fr
Mon Mar 15 15:14:00 CDT 2010
A+
---
dlls/dbghelp/dbghelp_private.h | 3 +++
dlls/dbghelp/pe_module.c | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 5ea2e82..42234ee 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -570,6 +570,9 @@ extern struct module*
DWORD64 base, DWORD64 size);
extern BOOL pe_load_debug_info(const struct process* pcs,
struct module* module);
+extern const char* pe_map_directory(struct module* module, int dirno, DWORD* size);
+extern void pe_unmap_directoy(struct module* module, int dirno);
+
/* source.c */
extern unsigned source_new(struct module* module, const char* basedir, const char* source);
extern const char* source_get(const struct module* module, unsigned idx);
diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c
index a34ae6d..89eee9a 100644
--- a/dlls/dbghelp/pe_module.c
+++ b/dlls/dbghelp/pe_module.c
@@ -257,6 +257,35 @@ static void pe_unmap_file(struct image_file_map* fmap)
}
}
+/******************************************************************
+ * pe_map_directory
+ *
+ * Maps a directory content out of a PE file
+ */
+const char* pe_map_directory(struct module* module, int dirno, DWORD* size)
+{
+ IMAGE_NT_HEADERS* nth;
+ void* mapping;
+
+ if (module->type != DMT_PE || !module->format_info[DFI_PE]) return NULL;
+ if (dirno >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ||
+ !(mapping = pe_map_full(&module->format_info[DFI_PE]->u.pe_info->fmap, &nth)))
+ return NULL;
+ if (size) *size = nth->OptionalHeader.DataDirectory[dirno].Size;
+ return RtlImageRvaToVa(nth, mapping,
+ nth->OptionalHeader.DataDirectory[dirno].VirtualAddress, NULL);
+}
+
+/******************************************************************
+ * pe_unmap_directory
+ *
+ * Unmaps a directory content
+ */
+void pe_unmap_directory(struct image_file_map* fmap, int dirno)
+{
+ pe_unmap_full(fmap);
+}
+
static void pe_module_remove(struct process* pcs, struct module_format* modfmt)
{
pe_unmap_file(&modfmt->u.pe_info->fmap);
More information about the wine-patches
mailing list