dbghelp: Added helper to image_file_map to map also directory out of PE executables.
authorEric Pouech <eric.pouech@orange.fr>
Sat, 20 Mar 2010 08:47:18 +0000 (09:47 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 22 Mar 2010 10:27:32 +0000 (11:27 +0100)
dlls/dbghelp/dbghelp_private.h
dlls/dbghelp/pe_module.c

index 5ea2e824b6e018e0ba060e9f0ebaeaa903584f1c..42234ee16cce2439c3375d2018c4a2dddfd84c32 100644 (file)
@@ -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);
index 63a2b9a9e4ee4c50be4cefdd5a318a85a591a684..61b8c5e650ddaf9d27865608c6855d951fb17cfd 100644 (file)
@@ -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);