[PATCH 07/26] [DbgHelp]: now storing module information in Unicode form

Eric Pouech eric.pouech at wanadoo.fr
Wed Feb 21 14:55:04 CST 2007




A+
---

 dlls/dbghelp/dbghelp_private.h |   23 ++++--
 dlls/dbghelp/elf_module.c      |   40 ++++++----
 dlls/dbghelp/module.c          |  161 ++++++++++++++++++++--------------------
 dlls/dbghelp/msc.c             |    4 +
 dlls/dbghelp/pe_module.c       |   28 ++++---
 dlls/dbghelp/source.c          |    2 
 dlls/dbghelp/symbol.c          |    2 
 7 files changed, 144 insertions(+), 116 deletions(-)

diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index ebf1acb..094318c 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -4,7 +4,7 @@
  * Copyright (C) 1995, Alexandre Julliard
  * Copyright (C) 1996, Eric Youngdale.
  * Copyright (C) 1999-2000, Ulrich Weigand.
- * Copyright (C) 2004, Eric Pouech.
+ * Copyright (C) 2004-2007, Eric Pouech.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,6 +28,8 @@ #include "winver.h"
 #include "dbghelp.h"
 #include "objbase.h"
 #include "oaidl.h"
+#include "winnls.h"
+#include "wine/unicode.h"
 
 #include "cvconst.h"
 
@@ -310,7 +312,7 @@ struct process;
 
 struct module
 {
-    IMAGEHLP_MODULE64           module;
+    IMAGEHLP_MODULEW64          module;
     /* ANSI copy of module.ModuleName for efficiency */
     char                        module_name[MAX_PATH];
     struct module*              next;
@@ -428,19 +430,30 @@ extern int          elf_is_in_thunk_area
 extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
 
 /* module.c */
+extern const WCHAR      S_ElfW[];
+extern const WCHAR      S_WineLoaderW[];
+
 extern struct module*
                     module_find_by_addr(const struct process* pcs, unsigned long addr,
                                         enum module_type type);
 extern struct module*
                     module_find_by_name(const struct process* pcs, 
-                                        const char* name, enum module_type type);
+                                        const WCHAR* name, enum module_type type);
+extern struct module*
+                    module_find_by_nameA(const struct process* pcs, 
+                                         const char* name, enum module_type type);
 extern BOOL         module_get_debug(struct module_pair*);
 extern struct module*
-                    module_new(struct process* pcs, const char* name, 
+                    module_new(struct process* pcs, const WCHAR* name,
                                enum module_type type, BOOL virtual,
                                unsigned long addr, unsigned long size,
                                unsigned long stamp, unsigned long checksum);
 extern struct module*
+                    module_newA(struct process* pcs, const char* name, 
+                                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);
 extern struct module*
@@ -451,7 +464,7 @@ extern enum module_type
 extern void         module_reset_debug_info(struct module* module);
 extern BOOL         module_remove(struct process* pcs, 
                                   struct module* module);
-extern void         module_set_module(struct module* module, const char* name);
+extern void         module_set_module(struct module* module, const WCHAR* name);
 
 /* msc.c */
 extern BOOL         pe_load_debug_directory(const struct process* pcs, 
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 88cf8eb..892bde6 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -2,7 +2,7 @@
  * File elf.c - processing of ELF files
  *
  * Copyright (C) 1996, Eric Youngdale.
- *		 1999-2004 Eric Pouech
+ *		 1999-2007 Eric Pouech
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -802,21 +802,23 @@ static BOOL elf_load_debug_info_from_map
  *    is the global debug file directory, and execdir has been turned
  *    into a relative path)." (from GDB manual)
  */
-static char* elf_locate_debug_link(const char* filename, const char* loaded_file,
+static char* elf_locate_debug_link(const char* filename, const WCHAR* loaded_file,
                                    struct elf_file_map* fmap_link)
 {
     static const char globalDebugDir[] = "/usr/lib/debug/";
     const size_t globalDebugDirLen = strlen(globalDebugDir);
+    size_t loaded_file_len;
     char* p;
     char* slash;
 
+    loaded_file_len = WideCharToMultiByte(CP_UNIXCP, 0, loaded_file, -1, NULL, 0, NULL, NULL);
     p = HeapAlloc(GetProcessHeap(), 0,
-                  globalDebugDirLen + strlen(loaded_file) + 1 + 6 + 1 + strlen(filename) + 1);
+                  globalDebugDirLen + loaded_file_len + 6 + 1 + strlen(filename) + 1);
 
     if (!p) return FALSE;
 
     /* we prebuild the string with "execdir" */
-    strcpy(p, loaded_file);
+    WideCharToMultiByte(CP_UNIXCP, 0, loaded_file, -1, p, loaded_file_len, NULL, NULL);
     slash = strrchr(p, '/');
     if (slash == NULL) slash = p; else slash++;
 
@@ -879,7 +881,9 @@ static BOOL elf_debuglink_parse (struct 
 	ret = elf_load_debug_info_from_map(module, &fmap_link, pool,
                                            ht_symtab);
 	if (ret)
-	    strcpy(module->module.LoadedPdbName, link_file);
+            MultiByteToWideChar(CP_ACP, 0, link_file, -1,
+                                module->module.LoadedPdbName,
+                                sizeof(module->module.LoadedPdbName));
 	else
 	    WARN("Couldn't load debug information from %s\n", link_file);
 	elf_unmap_file(&fmap_link);
@@ -928,7 +932,7 @@ static BOOL elf_load_debug_info_from_map
     if (fmap->with_crc && (fmap->crc != calc_crc32(fmap)))
     {
         ERR("Bad CRC for module %s (got %08x while expecting %08lx)\n",
-            module->module.LoadedImageName, calc_crc32(fmap), fmap->crc);
+            debugstr_w(module->module.LoadedImageName), calc_crc32(fmap), fmap->crc);
         /* we don't tolerate mis-matched files */
         return FALSE;
     }
@@ -1062,14 +1066,14 @@ static BOOL elf_load_debug_info_from_map
                 lret = elf_debuglink_parse (module, pool, ht_symtab, dbg_link);
                 if (!lret)
 		    WARN("Couldn't load linked debug file for %s\n",
-			  module->module.ModuleName);
+                         debugstr_w(module->module.ModuleName));
                 ret = ret || lret;
             }
             elf_unmap_section(fmap, debuglink_sect);
         }
     }
-    if (strstr(module->module.ModuleName, "<elf>") ||
-        !strcmp(module->module.ModuleName, "<wine-loader>"))
+    if (strstrW(module->module.ModuleName, S_ElfW) ||
+        !strcmpW(module->module.ModuleName, S_WineLoaderW))
     {
         /* add the thunks for native libraries */
         if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY))
@@ -1095,7 +1099,7 @@ BOOL elf_load_debug_info(struct module* 
 
     if (module->type != DMT_ELF || !module->elf_info)
     {
-	ERR("Bad elf module '%s'\n", module->module.LoadedImageName);
+	ERR("Bad elf module '%s'\n", debugstr_w(module->module.LoadedImageName));
 	return FALSE;
     }
 
@@ -1104,8 +1108,12 @@ BOOL elf_load_debug_info(struct module* 
 
     if (!fmap)
     {
+        char    LoadedImageName[MAX_PATH];
+
         fmap = &my_fmap;
-        ret = elf_map_file(module->module.LoadedImageName, fmap);
+        WideCharToMultiByte(CP_ACP, 0, module->module.LoadedImageName, -1,
+                            LoadedImageName, MAX_PATH, NULL, NULL);
+        ret = elf_map_file(LoadedImageName, fmap);
     }
     if (ret)
         ret = elf_load_debug_info_from_map(module, fmap, &pool, &ht_symtab);
@@ -1204,9 +1212,9 @@ 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, FALSE,
-                                      (load_offset) ? load_offset : fmap.elf_start, 
-                                      fmap.elf_size, 0, calc_crc32(&fmap));
+        elf_info->module = module_newA(pcs, filename, DMT_ELF, FALSE,
+                                       (load_offset) ? load_offset : fmap.elf_start, 
+                                       fmap.elf_size, 0, calc_crc32(&fmap));
         if (!elf_info->module)
         {
             HeapFree(GetProcessHeap(), 0, elf_module_info);
@@ -1313,7 +1321,7 @@ static BOOL elf_search_and_load_file(str
     struct module*      module;
 
     if (filename == NULL || *filename == '\0') return FALSE;
-    if ((module = module_find_by_name(pcs, filename, DMT_ELF)))
+    if ((module = module_find_by_nameA(pcs, filename, DMT_ELF)))
     {
         elf_info->module = module;
         module->elf_info->elf_mark = 1;
@@ -1469,7 +1477,7 @@ BOOL elf_read_wine_loader_dbg_info(struc
     elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE;
     if (!elf_search_loader(pcs, &elf_info)) return FALSE;
     elf_info.module->elf_info->elf_loader = 1;
-    strcpy(elf_info.module->module.ModuleName, "<wine-loader>");
+    module_set_module(elf_info.module, S_WineLoaderW);
     return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0;
 }
 
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 3d10f87..55e589d 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -2,7 +2,7 @@
  * File module.c - module handling for the wine debugger
  *
  * Copyright (C) 1993,      Eric Youngdale.
- * 		 2000-2004, Eric Pouech
+ * 		 2000-2007, Eric Pouech
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,60 +30,73 @@ #include "psapi.h"
 #include "winreg.h"
 #include "winternl.h"
 #include "wine/debug.h"
-#include "winnls.h"
-#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
-static const char * const ext[] = {".acm", ".dll", ".drv", ".exe", ".ocx", ".vxd", NULL};
+const WCHAR        S_ElfW[]         = {'<','e','l','f','>','\0'};
+const WCHAR        S_WineLoaderW[]  = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'};
+static const WCHAR S_DotSoW[]       = {'.','s','o','\0'};
+static const WCHAR S_PdbW[]         = {'.','p','d','b','\0'};
+static const WCHAR S_WinePThreadW[] = {'w','i','n','e','-','p','t','h','r','e','a','d','\0'};
+static const WCHAR S_WineKThreadW[] = {'w','i','n','e','-','k','t','h','r','e','a','d','\0'};
 
-static int match_ext(const char* ptr, size_t len)
+static const WCHAR S_AcmW[] = {'.','a','c','m','\0'};
+static const WCHAR S_DllW[] = {'.','d','l','l','\0'};
+static const WCHAR S_DrvW[] = {'.','d','r','v','\0'};
+static const WCHAR S_ExeW[] = {'.','e','x','e','\0'};
+static const WCHAR S_OcxW[] = {'.','o','c','x','\0'};
+static const WCHAR S_VxdW[] = {'.','v','x','d','\0'};
+static const WCHAR * const ext[] = {S_AcmW, S_DllW, S_DrvW, S_ExeW, S_OcxW, S_VxdW, NULL};
+
+static int match_ext(const WCHAR* ptr, size_t len)
 {
-    const char * const *e;
+    const WCHAR* const *e;
     size_t      l;
 
     for (e = ext; *e; e++)
     {
-        l = strlen(*e);
+        l = strlenW(*e);
         if (l >= len) return FALSE;
-        if (strncasecmp(&ptr[len - l], *e, l)) continue;
+        if (strncmpiW(&ptr[len - l], *e, l)) continue;
         return l;
     }
     return 0;
 }
         
-static void module_fill_module(const char* in, char* out, size_t size)
+static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size)
 {
-    const char  *ptr,*endptr;
+    const WCHAR *ptr,*endptr;
     size_t      len, l;
 
-    endptr = in + strlen(in);
+    endptr = in + strlenW(in);
     for (ptr = endptr - 1;
          ptr >= in && *ptr != '/' && *ptr != '\\';
          ptr--);
     ptr++;
     len = min(endptr-ptr,size-1);
-    memcpy(out, ptr, len);
+    memcpy(out, ptr, len * sizeof(WCHAR));
     out[len] = '\0';
     if (len > 4 && (l = match_ext(out, len)))
         out[len - l] = '\0';
     else if (len > 12 &&
-             (!strcasecmp(out + len - 12, "wine-pthread") || 
-              !strcasecmp(out + len - 12, "wine-kthread")))
-        lstrcpynA(out, "<wine-loader>", size);
+             (!strcmpiW(out + len - 12, S_WinePThreadW) || 
+              !strcmpiW(out + len - 12, S_WineKThreadW)))
+        lstrcpynW(out, S_WineLoaderW, size);
     else
     {
-        if (len > 3 && !strcasecmp(&out[len - 3], ".so") &&
+        if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) &&
             (l = match_ext(out, len - 3)))
-            strcpy(&out[len - l - 3], "<elf>");
+            strcpyW(&out[len - l - 3], S_ElfW);
     }
-    while ((*out = tolower(*out))) out++;
+    while ((*out = tolowerW(*out))) out++;
 }
 
-void module_set_module(struct module* module, const char* name)
+void module_set_module(struct module* module, const WCHAR* name)
 {
     module_fill_module(name, module->module.ModuleName, sizeof(module->module.ModuleName));
-    strcpy(module->module_name, module->module.ModuleName);
+    WideCharToMultiByte(CP_ACP, 0, module->module.ModuleName, -1,
+                        module->module_name, sizeof(module->module_name),
+                        NULL, NULL);
 }
 
 static const char*      get_module_type(enum module_type type, BOOL virtual)
@@ -99,7 +112,7 @@ 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, 
+struct module* module_new(struct process* pcs, const WCHAR* name, 
                           enum module_type type, BOOL virtual,
                           unsigned long mod_addr, unsigned long size,
                           unsigned long stamp, unsigned long checksum) 
@@ -116,7 +129,8 @@ struct module* module_new(struct process
     pcs->lmodules = module;
 
     TRACE("=> %s %08lx-%08lx %s\n", 
-          get_module_type(type, virtual), mod_addr, mod_addr + size, name);
+          get_module_type(type, virtual), mod_addr, mod_addr + size,
+          debugstr_w(name));
 
     pool_init(&module->pool, 65536);
     
@@ -125,7 +139,7 @@ struct module* module_new(struct process
     module->module.ImageSize = size;
     module_set_module(module, name);
     module->module.ImageName[0] = '\0';
-    lstrcpynA(module->module.LoadedImageName, name, sizeof(module->module.LoadedImageName));
+    lstrcpynW(module->module.LoadedImageName, name, sizeof(module->module.LoadedImageName) / sizeof(WCHAR));
     module->module.SymType = SymNone;
     module->module.NumSyms = 0;
     module->module.TimeDateStamp = stamp;
@@ -163,12 +177,23 @@ struct module* module_new(struct process
     return module;
 }
 
+struct module* module_newA(struct process* pcs, const char* name, 
+                          enum module_type type, BOOL virtual,
+                          unsigned long mod_addr, unsigned long size,
+                          unsigned long stamp, unsigned long checksum) 
+{
+    WCHAR wname[MAX_PATH];
+
+    MultiByteToWideChar(CP_ACP, 0, name, -1, wname, sizeof(wname) / sizeof(WCHAR));
+    return module_new(pcs, wname, type, virtual, mod_addr, size, stamp, checksum);
+}
+
 /***********************************************************************
  *	module_find_by_name
  *
  */
 struct module* module_find_by_name(const struct process* pcs, 
-                                   const char* name, enum module_type type)
+                                   const WCHAR* name, enum module_type type)
 {
     struct module*      module;
 
@@ -180,19 +205,19 @@ struct module* module_find_by_name(const
     }
     else
     {
-        char                modname[MAX_PATH];
+        WCHAR   modname[MAX_PATH];
 
         for (module = pcs->lmodules; module; module = module->next)
         {
             if (type == module->type &&
-                !strcasecmp(name, module->module.LoadedImageName)) 
+                !strcmpiW(name, module->module.LoadedImageName)) 
                 return module;
         }
         module_fill_module(name, modname, sizeof(modname));
         for (module = pcs->lmodules; module; module = module->next)
         {
             if (type == module->type &&
-                !strcasecmp(modname, module->module.ModuleName)) 
+                !strcmpiW(modname, module->module.ModuleName)) 
                 return module;
         }
     }
@@ -200,6 +225,15 @@ struct module* module_find_by_name(const
     return NULL;
 }
 
+struct module* module_find_by_nameA(const struct process* pcs, 
+                                    const char* name, enum module_type type)
+{
+    WCHAR wname[MAX_PATH];
+
+    MultiByteToWideChar(CP_ACP, 0, name, -1, wname, sizeof(wname) / sizeof(WCHAR));
+    return module_find_by_name(pcs, wname, type);
+}
+
 /***********************************************************************
  *           module_get_container
  *
@@ -274,7 +308,8 @@ BOOL module_get_debug(struct module_pair
             idsl64.BaseOfImage = pair->effective->module.BaseOfImage;
             idsl64.CheckSum = pair->effective->module.CheckSum;
             idsl64.TimeDateStamp = pair->effective->module.TimeDateStamp;
-            strcpy(idsl64.FileName, pair->effective->module.ImageName);
+            WideCharToMultiByte(CP_ACP, 0, pair->effective->module.ImageName, -1,
+                                idsl64.FileName, sizeof(idsl64.FileName), NULL, NULL);
             idsl64.Reparse = FALSE;
             idsl64.hFile = INVALID_HANDLE_VALUE;
 
@@ -325,10 +360,11 @@ struct module* module_find_by_addr(const
     return module;
 }
 
-static BOOL module_is_elf_container_loaded(struct process* pcs, const char* ImageName,
-                                           const char* ModuleName)
+static BOOL module_is_elf_container_loaded(struct process* pcs,
+                                           const WCHAR* ImageName,
+                                           const WCHAR* ModuleName)
 {
-    char                buffer[MAX_PATH];
+    WCHAR               buffer[MAX_PATH];
     size_t              len;
     struct module*      module;
 
@@ -337,12 +373,12 @@ static BOOL module_is_elf_container_load
         module_fill_module(ImageName, buffer, sizeof(buffer));
         ModuleName = buffer;
     }
-    len = strlen(ModuleName);
+    len = strlenW(ModuleName);
     for (module = pcs->lmodules; module; module = module->next)
     {
-        if (!strncasecmp(module->module.ModuleName, ModuleName, len) &&
+        if (!strncmpiW(module->module.ModuleName, ModuleName, len) &&
             module->type == DMT_ELF &&
-            !strcmp(module->module.ModuleName + len, "<elf>"))
+            !strcmpW(module->module.ModuleName + len, S_ElfW))
             return TRUE;
     }
     return FALSE;
@@ -452,15 +488,10 @@ DWORD64 WINAPI  SymLoadModuleExW(HANDLE 
     {
         WideCharToMultiByte(CP_ACP,0, wImageName, -1, ImageName, MAX_PATH,
                             NULL, NULL);
-        module = module_new(pcs, ImageName, module_get_type_by_name(ImageName),
+        module = module_new(pcs, wImageName, module_get_type_by_name(ImageName),
                             TRUE, (DWORD)BaseOfDll, SizeOfDll, 0, 0);
         if (!module) return FALSE;
-        if (wModuleName)
-        {
-            WideCharToMultiByte(CP_ACP,0, wModuleName, -1, ModuleName = amodname, MAX_PATH,
-                                NULL, NULL);
-            module_set_module(module, ModuleName);
-        }
+        if (wModuleName) module_set_module(module, wModuleName);
         module->module.SymType = SymVirtual;
 
         return TRUE;
@@ -483,7 +514,7 @@ DWORD64 WINAPI  SymLoadModuleExW(HANDLE 
     else
         ModuleName = NULL;
 
-    if (module_is_elf_container_loaded(pcs, ImageName, ModuleName))
+    if (module_is_elf_container_loaded(pcs, wImageName, wModuleName))
     {
         /* force the loading of DLL as builtin */
         if ((module = pe_load_module_from_pcs(pcs, ImageName, ModuleName,
@@ -511,9 +542,10 @@ done:
     /* by default pe_load_module fills module.ModuleName from a derivation 
      * of ImageName. Overwrite it, if we have better information
      */
-    if (ModuleName)
-        module_set_module(module, ModuleName);
-    lstrcpynA(module->module.ImageName, ImageName, sizeof(module->module.ImageName));
+    if (wModuleName)
+        module_set_module(module, wModuleName);
+    lstrcpynW(module->module.ImageName, wImageName,
+              sizeof(module->module.ImageName) / sizeof(CHAR));
 
     return module->module.BaseOfImage;
 }
@@ -714,8 +746,7 @@ BOOL  WINAPI EnumerateLoadedModulesW64(H
                                        PVOID UserContext)
 {
     HMODULE*    hMods;
-    char        base[256], mod[256];
-    WCHAR       modW[256];
+    WCHAR       baseW[256], modW[256];
     DWORD       i, sz;
     MODULEINFO  mi;
 
@@ -733,10 +764,9 @@ BOOL  WINAPI EnumerateLoadedModulesW64(H
     for (i = 0; i < sz; i++)
     {
         if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
-            !GetModuleBaseNameA(hProcess, hMods[i], base, sizeof(base)))
+            !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR)))
             continue;
-        module_fill_module(base, mod, sizeof(mod));
-        MultiByteToWideChar(CP_ACP, 0, mod, -1, modW, sizeof(modW) / sizeof(modW));
+        module_fill_module(baseW, modW, sizeof(modW) / sizeof(CHAR));
         EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
                                   UserContext);
     }
@@ -877,36 +907,9 @@ BOOL  WINAPI SymGetModuleInfoW64(HANDLE 
     module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
     if (!module) return FALSE;
 
-    miw64.SizeOfStruct  = sizeof(miw64);
-    miw64.BaseOfImage   = module->module.BaseOfImage;
-    miw64.ImageSize     = module->module.ImageSize;
-    miw64.TimeDateStamp = module->module.TimeDateStamp;
-    miw64.CheckSum      = module->module.CheckSum;
-    miw64.NumSyms       = module->module.NumSyms;
-    miw64.SymType       = module->module.SymType;
-    MultiByteToWideChar(CP_ACP, 0, module->module.ModuleName, -1,   
-                        miw64.ModuleName, sizeof(miw64.ModuleName) / sizeof(WCHAR));
-    MultiByteToWideChar(CP_ACP, 0, module->module.ImageName, -1,   
-                        miw64.ImageName, sizeof(miw64.ImageName) / sizeof(WCHAR));
-    MultiByteToWideChar(CP_ACP, 0, module->module.LoadedImageName, -1,   
-                        miw64.LoadedImageName, sizeof(miw64.LoadedImageName) / sizeof(WCHAR));
-    MultiByteToWideChar(CP_ACP, 0, module->module.LoadedPdbName, -1,   
-                        miw64.LoadedPdbName, sizeof(miw64.LoadedPdbName) / sizeof(WCHAR));
-
-    miw64.CVSig         = module->module.CVSig;
-    MultiByteToWideChar(CP_ACP, 0, module->module.CVData, -1,   
-                        miw64.CVData, sizeof(miw64.CVData) / sizeof(WCHAR));
-    miw64.PdbSig        = module->module.PdbSig;
-    miw64.PdbSig70      = module->module.PdbSig70;
-    miw64.PdbAge        = module->module.PdbAge;
-    miw64.PdbUnmatched  = module->module.PdbUnmatched;
-    miw64.DbgUnmatched  = module->module.DbgUnmatched;
-    miw64.LineNumbers   = module->module.LineNumbers;
-    miw64.GlobalSymbols = module->module.GlobalSymbols;
-    miw64.TypeInfo      = module->module.TypeInfo;
-    miw64.SourceIndexed = module->module.SourceIndexed;
-    miw64.Publics       = module->module.Publics;
+    miw64 = module->module;
 
+    /* update debug information from container if any */
     if (module->module.SymType == SymNone)
     {
         module = module_get_container(pcs, module);
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c
index 203997f..9ea618c 100644
--- a/dlls/dbghelp/msc.c
+++ b/dlls/dbghelp/msc.c
@@ -2248,7 +2248,9 @@ static BOOL pdb_process_file(const struc
         else
             msc_dbg->module->module.PdbSig70 = pdb_lookup->u.ds.guid;
         msc_dbg->module->module.PdbAge = pdb_lookup->age;
-        strcpy(msc_dbg->module->module.LoadedPdbName, pdb_lookup->filename);
+        MultiByteToWideChar(CP_ACP, 0, pdb_lookup->filename, -1,
+                            msc_dbg->module->module.LoadedPdbName, 
+                            sizeof(msc_dbg->module->module.LoadedPdbName) / sizeof(WCHAR));
         /* FIXME: we could have a finer grain here */
         msc_dbg->module->module.LineNumbers = TRUE;
         msc_dbg->module->module.GlobalSymbols = TRUE;
diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c
index 7958bd0..6eb4241 100644
--- a/dlls/dbghelp/pe_module.c
+++ b/dlls/dbghelp/pe_module.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1996,      Eric Youngdale.
  * Copyright (C) 1999-2000, Ulrich Weigand.
- * Copyright (C) 2004,      Eric Pouech.
+ * Copyright (C) 2004-2007, Eric Pouech.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -289,10 +289,10 @@ BOOL pe_load_debug_info(const struct pro
     void*               mapping;
     IMAGE_NT_HEADERS*   nth;
 
-    hFile = CreateFileA(module->module.LoadedImageName, GENERIC_READ, FILE_SHARE_READ,
+    hFile = CreateFileW(module->module.LoadedImageName, GENERIC_READ, FILE_SHARE_READ,
                         NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     if (hFile == INVALID_HANDLE_VALUE) return ret;
-    if ((hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0)
+    if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0)
     {
         if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
         {
@@ -354,8 +354,8 @@ struct module* pe_load_module(struct pro
     else if (name) strcpy(loaded_name, name);
     else if (dbghelp_options & SYMOPT_DEFERRED_LOADS)
         FIXME("Trouble ahead (no module name passed in deferred mode)\n");
-    if (!(module = module_find_by_name(pcs, loaded_name, DMT_PE)) &&
-        (hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
+    if (!(module = module_find_by_nameA(pcs, loaded_name, DMT_PE)) &&
+        (hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
     {
         if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
         {
@@ -366,9 +366,9 @@ 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, FALSE, base, size,
-                                    nth->FileHeader.TimeDateStamp, 
-                                    nth->OptionalHeader.CheckSum);
+                module = module_newA(pcs, loaded_name, DMT_PE, FALSE, base, size,
+                                     nth->FileHeader.TimeDateStamp, 
+                                     nth->OptionalHeader.CheckSum);
                 if (module)
                 {
                     if (dbghelp_options & SYMOPT_DEFERRED_LOADS)
@@ -411,7 +411,7 @@ struct module* pe_load_module_from_pcs(s
     struct module*      module;
     const char*         ptr;
 
-    if ((module = module_find_by_name(pcs, name, DMT_PE))) return module;
+    if ((module = module_find_by_nameA(pcs, name, DMT_PE))) return module;
     if (mod_name) ptr = mod_name;
     else
     {
@@ -424,7 +424,7 @@ struct module* pe_load_module_from_pcs(s
             }
         }
     }
-    if (ptr && (module = module_find_by_name(pcs, ptr, DMT_PE))) return module;
+    if (ptr && (module = module_find_by_nameA(pcs, ptr, DMT_PE))) return module;
     if (base)
     {
         if (pcs->dbg_hdr_addr)
@@ -434,11 +434,13 @@ 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, FALSE, base, size,
-                                    nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum);
+                module = module_newA(pcs, name, DMT_PE, FALSE, base, size,
+                                     nth.FileHeader.TimeDateStamp,
+                                     nth.OptionalHeader.CheckSum);
             }
         } else if (size)
-            module = module_new(pcs, name, DMT_PE, FALSE, base, size, 0 /* FIXME */, 0 /* FIXME */);
+            module = module_newA(pcs, name, DMT_PE, FALSE, base, size,
+                                 0 /* FIXME */, 0 /* FIXME */);
     }
     return module;
 }
diff --git a/dlls/dbghelp/source.c b/dlls/dbghelp/source.c
index fd0a9a8..311a263 100644
--- a/dlls/dbghelp/source.c
+++ b/dlls/dbghelp/source.c
@@ -133,7 +133,7 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hP
     {
         if (Mask[0] == '!')
         {
-            pair.requested = module_find_by_name(pair.pcs, Mask + 1, DMT_UNKNOWN);
+            pair.requested = module_find_by_nameA(pair.pcs, Mask + 1, DMT_UNKNOWN);
             if (!module_get_debug(&pair)) return FALSE;
         }
         else
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index 487ce0c..6e92b48 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -1174,7 +1174,7 @@ BOOL WINAPI SymFromName(HANDLE hProcess,
         assert(name - Name < sizeof(tmp));
         memcpy(tmp, Name, name - Name);
         tmp[name - Name] = '\0';
-        module = module_find_by_name(pcs, tmp, DMT_UNKNOWN);
+        module = module_find_by_nameA(pcs, tmp, DMT_UNKNOWN);
         return find_name(pcs, module, name + 1, Symbol);
     }
     for (module = pcs->lmodules; module; module = module->next)



More information about the wine-patches mailing list