[PATCH] [DbgHelp]: virtual modules

Eric Pouech eric.pouech at wanadoo.fr
Sun Feb 19 14:46:16 CST 2006


- rewrote virtual modules handling so that it's an option
  to either PE or ELF modules rather than a specific type

A+
---

 dlls/dbghelp/dbghelp_private.h |   10 +++++-----
 dlls/dbghelp/elf_module.c      |    9 +++++----
 dlls/dbghelp/module.c          |   33 ++++++++++++++++++---------------
 dlls/dbghelp/path.c            |    1 -
 dlls/dbghelp/pe_module.c       |    6 +++---
 5 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 3f5fcf6..d7371a2 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -258,14 +258,14 @@ enum module_type
     DMT_ELF,            /* a real ELF shared module */
     DMT_PE,             /* a native or builtin PE module */
     DMT_PDB,            /* PDB file */
-    DMT_VIRTUAL,        /* a virtual module (ie defined by caller) */
 };
 
 struct module
 {
     IMAGEHLP_MODULE             module;
     struct module*              next;
-    enum module_type		type;
+    enum module_type		type : 16;
+    unsigned short              is_virtual : 1;
     struct elf_module_info*	elf_info;
     
     /* memory allocation pool */
@@ -345,9 +345,9 @@ extern struct module*
                     module_get_debug(const struct process* pcs, struct module*);
 extern struct module*
                     module_new(struct process* pcs, const char* name, 
-                               enum module_type type, unsigned long addr, 
-                               unsigned long size, unsigned long stamp, 
-                               unsigned long checksum);
+                               enum module_type type, BOOL virtual,
+                               unsigned long addr, unsigned long size,
+                               unsigned long stamp, unsigned long checksum);
 extern struct module*
                     module_get_container(const struct process* pcs,
                                          const struct module* inner);
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 84ec0e1..a14d9e1 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -1095,7 +1095,7 @@ static BOOL elf_load_file(struct process
         struct elf_module_info *elf_module_info = 
             HeapAlloc(GetProcessHeap(), 0, sizeof(struct elf_module_info));
         if (!elf_module_info) goto leave;
-        elf_info->module = module_new(pcs, filename, DMT_ELF, 
+        elf_info->module = module_new(pcs, filename, DMT_ELF, FALSE,
                                       (load_offset) ? load_offset : fmap.elf_start, 
                                       fmap.elf_size, 0, calc_crc32(&fmap));
         if (!elf_info->module)
@@ -1296,7 +1296,8 @@ BOOL	elf_synchronize_module_list(struct 
 
     for (module = pcs->lmodules; module; module = module->next)
     {
-        if (module->type == DMT_ELF) module->elf_info->elf_mark = 0;
+        if (module->type == DMT_ELF && !module->is_virtual)
+            module->elf_info->elf_mark = 0;
     }
 
     es.pcs = pcs;
@@ -1307,8 +1308,8 @@ BOOL	elf_synchronize_module_list(struct 
     module = pcs->lmodules;
     while (module)
     {
-        if (module->type == DMT_ELF && !module->elf_info->elf_mark && 
-            !module->elf_info->elf_loader)
+        if (module->type == DMT_ELF && !module->is_virtual &&
+            !module->elf_info->elf_mark && !module->elf_info->elf_loader)
         {
             module_remove(pcs, module);
             /* restart all over */
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 17974ef..7f13167 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -78,13 +78,12 @@ static void module_fill_module(const cha
     while ((*out = tolower(*out))) out++;
 }
 
-static const char*      get_module_type(enum module_type type)
+static const char*      get_module_type(enum module_type type, BOOL virtual)
 {
     switch (type)
     {
-    case DMT_ELF: return "ELF";
-    case DMT_PE: return "PE";
-    case DMT_VIRTUAL: return "Virtual";
+    case DMT_ELF: return virtual ? "Virtual ELF" : "ELF";
+    case DMT_PE: return virtual ? "Virtual PE" : "PE";
     default: return "---";
     }
 }
@@ -93,13 +92,13 @@ static const char*      get_module_type(
  * Creates and links a new module to a process 
  */
 struct module* module_new(struct process* pcs, const char* name, 
-                          enum module_type type, 
+                          enum module_type type, BOOL virtual,
                           unsigned long mod_addr, unsigned long size,
                           unsigned long stamp, unsigned long checksum) 
 {
     struct module*      module;
 
-    assert(type == DMT_ELF || type == DMT_PE || type == DMT_VIRTUAL);
+    assert(type == DMT_ELF || type == DMT_PE);
     if (!(module = HeapAlloc(GetProcessHeap(), 0, sizeof(*module))))
 	return NULL;
 
@@ -109,7 +108,7 @@ struct module* module_new(struct process
     pcs->lmodules = module;
 
     TRACE("=> %s %08lx-%08lx %s\n", 
-          get_module_type(type), mod_addr, mod_addr + size, name);
+          get_module_type(type, virtual), mod_addr, mod_addr + size, name);
 
     pool_init(&module->pool, 65536);
     
@@ -126,6 +125,7 @@ struct module* module_new(struct process
     module->module.CheckSum = checksum;
 
     module->type              = type;
+    module->is_virtual        = virtual ? TRUE : FALSE;
     module->sortlist_valid    = FALSE;
     module->addr_sorttab      = NULL;
     /* FIXME: this seems a bit too high (on a per module basis)
@@ -154,8 +154,7 @@ struct module* module_find_by_name(const
     if (type == DMT_UNKNOWN)
     {
         if ((module = module_find_by_name(pcs, name, DMT_PE)) ||
-            (module = module_find_by_name(pcs, name, DMT_ELF)) ||
-            (module = module_find_by_name(pcs, name, DMT_VIRTUAL)))
+            (module = module_find_by_name(pcs, name, DMT_ELF)))
             return module;
     }
     else
@@ -243,8 +242,9 @@ struct module* module_get_debug(const st
     if (module->module.SymType == SymDeferred)
     {
         BOOL ret;
-
-        switch (module->type)
+        
+        if (module->is_virtual) ret = FALSE;
+        else switch (module->type)
         {
         case DMT_ELF:
             ret = elf_load_debug_info(module, NULL);
@@ -264,7 +264,6 @@ struct module* module_get_debug(const st
                          ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
                          &idsl64);
             break;
-        case DMT_VIRTUAL: /* fall through */
         default:
             ret = FALSE;
             break;
@@ -290,8 +289,7 @@ struct module* module_find_by_addr(const
     if (type == DMT_UNKNOWN)
     {
         if ((module = module_find_by_addr(pcs, addr, DMT_PE)) ||
-            (module = module_find_by_addr(pcs, addr, DMT_ELF)) ||
-            (module = module_find_by_addr(pcs, addr, DMT_VIRTUAL)))
+            (module = module_find_by_addr(pcs, addr, DMT_ELF)))
             return module;
     }
     else
@@ -436,6 +434,10 @@ DWORD64 WINAPI  SymLoadModuleEx(HANDLE h
                                 PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize,
                                 PMODLOAD_DATA Data, DWORD Flags)
 {
+    TRACE("(%p %p %s %s %s %08lx %p %08lx)\n", 
+          hProcess, hFile, debugstr_a(ImageName), debugstr_a(ModuleName), 
+          wine_dbgstr_longlong(BaseOfDll), DllSize, Data, Flags);
+
     if (Data)
         FIXME("Unsupported load data parameter %p for %s\n", Data, ImageName);
     if (!validate_addr64(BaseOfDll)) return FALSE;
@@ -445,7 +447,8 @@ DWORD64 WINAPI  SymLoadModuleEx(HANDLE h
         struct module* module;
         if (!pcs) return FALSE;
 
-        module = module_new(pcs, ImageName, DMT_VIRTUAL, (DWORD)BaseOfDll, DllSize, 0, 0);
+        module = module_new(pcs, ImageName, module_get_type_by_name(ImageName), TRUE, 
+                            (DWORD)BaseOfDll, DllSize, 0, 0);
         if (!module) return FALSE;
         if (ModuleName)
             lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName));
diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c
index 2362ca1..8033967 100644
--- a/dlls/dbghelp/path.c
+++ b/dlls/dbghelp/path.c
@@ -282,7 +282,6 @@ static BOOL CALLBACK sffip_cb(LPCSTR buf
         }
         break;
     case DMT_PDB:
-    case DMT_VIRTUAL:
         FIXME("NIY on '%s'\n", buffer);
         break;
     default:
diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c
index 417aadb..395f398 100644
--- a/dlls/dbghelp/pe_module.c
+++ b/dlls/dbghelp/pe_module.c
@@ -360,7 +360,7 @@ struct module* pe_load_module(struct pro
                 if (!base) base = nth->OptionalHeader.ImageBase;
                 if (!size) size = nth->OptionalHeader.SizeOfImage;
             
-                module = module_new(pcs, loaded_name, DMT_PE, base, size,
+                module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size,
                                     nth->FileHeader.TimeDateStamp, 
                                     nth->OptionalHeader.CheckSum);
                 if (module)
@@ -428,11 +428,11 @@ struct module* pe_load_module_from_pcs(s
             if (pe_load_nt_header(pcs->handle, base, &nth))
             {
                 if (!size) size = nth.OptionalHeader.SizeOfImage;
-                module = module_new(pcs, name, DMT_PE, base, size,
+                module = module_new(pcs, name, DMT_PE, FALSE, base, size,
                                     nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum);
             }
         } else if (size)
-            module = module_new(pcs, name, DMT_PE, base, size, 0 /* FIXME */, 0 /* FIXME */);
+            module = module_new(pcs, name, DMT_PE, FALSE, base, size, 0 /* FIXME */, 0 /* FIXME */);
     }
     return module;
 }





More information about the wine-patches mailing list