Eric Pouech : dbghelp: Moved ELF module loading interfaces to Unicode.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Feb 22 05:56:44 CST 2007


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

Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date:   Wed Feb 21 21:55:20 2007 +0100

dbghelp: Moved ELF module loading interfaces to Unicode.

The core the code remains ANSI, as all the information is stored as ANSI.

---

 dlls/dbghelp/dbghelp_private.h |    7 +------
 dlls/dbghelp/elf_module.c      |   30 ++++++++++++++++++------------
 dlls/dbghelp/module.c          |   13 +------------
 3 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index d1c439e..e0bc12e 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -422,7 +422,7 @@ extern BOOL         elf_fetch_file_info(const char* name, DWORD* base, DWORD* si
 struct elf_file_map;
 extern BOOL         elf_load_debug_info(struct module* module, struct elf_file_map* fmap);
 extern struct module*
-                    elf_load_module(struct process* pcs, const char* name, unsigned long);
+                    elf_load_module(struct process* pcs, const WCHAR* name, unsigned long);
 extern BOOL         elf_read_wine_loader_dbg_info(struct process* pcs);
 extern BOOL         elf_synchronize_module_list(struct process* pcs);
 struct elf_thunk_area;
@@ -449,11 +449,6 @@ extern struct module*
                                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*
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 3986281..a404a73 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -1063,7 +1063,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
             dbg_link = (const BYTE*) elf_map_section(fmap, debuglink_sect);
             if (dbg_link != ELF_NO_MAP)
             {
-                lret = elf_debuglink_parse (module, pool, ht_symtab, dbg_link);
+                lret = elf_debuglink_parse(module, pool, ht_symtab, dbg_link);
                 if (!lret)
 		    WARN("Couldn't load linked debug file for %s\n",
                          debugstr_w(module->module.ModuleName));
@@ -1111,7 +1111,7 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap)
         char    LoadedImageName[MAX_PATH];
 
         fmap = &my_fmap;
-        WideCharToMultiByte(CP_ACP, 0, module->module.LoadedImageName, -1,
+        WideCharToMultiByte(CP_UNIXCP, 0, module->module.LoadedImageName, -1,
                             LoadedImageName, MAX_PATH, NULL, NULL);
         ret = elf_map_file(LoadedImageName, fmap);
     }
@@ -1209,12 +1209,14 @@ static BOOL elf_load_file(struct process* pcs, const char* filename,
 
     if (elf_info->flags & ELF_INFO_MODULE)
     {
+        WCHAR wfilename[MAX_PATH];
         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_newA(pcs, filename, DMT_ELF, FALSE,
-                                       (load_offset) ? load_offset : fmap.elf_start,
-                                       fmap.elf_size, 0, calc_crc32(&fmap));
+        MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, wfilename, sizeof(wfilename) / sizeof(WCHAR));
+        elf_info->module = module_new(pcs, wfilename, 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);
@@ -1508,7 +1510,7 @@ struct elf_load
 {
     struct process*     pcs;
     struct elf_info     elf_info;
-    const char*         name;
+    char                name[MAX_PATH];
     BOOL                ret;
 };
 
@@ -1543,23 +1545,26 @@ static BOOL elf_load_cb(const char* name, unsigned long addr, void* user)
  * Also, find module real name and load address from
  * the real loaded modules list in pcs address space
  */
-struct module*  elf_load_module(struct process* pcs, const char* name, unsigned long addr)
+struct module*  elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr)
 {
     struct elf_load     el;
 
-    TRACE("(%p %s %08lx)\n", pcs, name, addr);
+    TRACE("(%p %s %08lx)\n", pcs, debugstr_w(name), addr);
 
     el.elf_info.flags = ELF_INFO_MODULE;
     el.ret = FALSE;
 
     if (pcs->dbg_hdr_addr) /* we're debugging a life target */
     {
+        const WCHAR*  ptr;
+
         el.pcs = pcs;
         /* do only the lookup from the filename, not the path (as we lookup module
          * name in the process' loaded module list)
          */
-        el.name = strrchr(name, '/');
-        if (!el.name++) el.name = name;
+        ptr = strrchrW(name, '/');
+        if (!ptr++) ptr = name;
+        WideCharToMultiByte(CP_UNIXCP, 0, ptr, -1, el.name, sizeof(el.name), NULL, NULL);
         el.ret = FALSE;
 
         if (!elf_enum_modules_internal(pcs, NULL, elf_load_cb, &el))
@@ -1567,7 +1572,8 @@ struct module*  elf_load_module(struct process* pcs, const char* name, unsigned
     }
     else if (addr)
     {
-        el.ret = elf_search_and_load_file(pcs, name, addr, &el.elf_info);
+        WideCharToMultiByte(CP_UNIXCP, 0, name, -1, el.name, sizeof(el.name), NULL, NULL);
+        el.ret = elf_search_and_load_file(pcs, el.name, addr, &el.elf_info);
     }
     if (!el.ret) return NULL;
     assert(el.elf_info.module);
@@ -1597,7 +1603,7 @@ BOOL elf_enum_modules(HANDLE hProc, elf_enum_modules_cb cb, void* user)
     return FALSE;
 }
 
-struct module*  elf_load_module(struct process* pcs, const char* name, unsigned long addr)
+struct module*  elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr)
 {
     return NULL;
 }
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 5da2135..1edef49 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -177,17 +177,6 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
     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
  *
@@ -527,7 +516,7 @@ DWORD64 WINAPI  SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
     if (!(module = pe_load_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)))
     {
         if (module_get_type_by_name(ImageName) == DMT_ELF &&
-            (module = elf_load_module(pcs, ImageName, BaseOfDll)))
+            (module = elf_load_module(pcs, wImageName, BaseOfDll)))
             goto done;
         FIXME("Should have successfully loaded debug information for image %s\n",
               debugstr_w(wImageName));




More information about the wine-cvs mailing list