Eric Pouech : dbghelp: Added helper to image_file_map to map also directory out of PE executables .

Alexandre Julliard julliard at winehq.org
Mon Mar 22 11:12:01 CDT 2010


Module: wine
Branch: master
Commit: 2ed8b9f6b6aac5580d2ce5dd064e8bf26272bb9d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2ed8b9f6b6aac5580d2ce5dd064e8bf26272bb9d

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Sat Mar 20 09:47:18 2010 +0100

dbghelp: Added helper to image_file_map to map also directory out of PE executables.

---

 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 63a2b9a..61b8c5e 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-cvs mailing list