[PATCH 22/26] [DbgHelp]: move elf_fetch_file_info to unicode

Eric Pouech eric.pouech at wanadoo.fr
Wed Feb 21 14:56:22 CST 2007




A+
---

 dlls/dbghelp/dbghelp_private.h |    2 +-
 dlls/dbghelp/elf_module.c      |    9 ++++++---
 dlls/dbghelp/minidump.c        |    4 +---
 dlls/dbghelp/path.c            |   24 +++++++++---------------
 4 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 547cd86..816a540 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -418,7 +418,7 @@ extern void*        fetch_buffer(struct 
 #define ELF_NO_MAP      ((const void*)0xffffffff)
 typedef BOOL (*elf_enum_modules_cb)(const WCHAR*, unsigned long addr, void* user);
 extern BOOL         elf_enum_modules(HANDLE hProc, elf_enum_modules_cb, void*);
-extern BOOL         elf_fetch_file_info(const char* name, DWORD* base, DWORD* size, DWORD* checksum);
+extern BOOL         elf_fetch_file_info(const WCHAR* name, DWORD* base, DWORD* size, DWORD* checksum);
 struct elf_file_map;
 extern BOOL         elf_load_debug_info(struct module* module, struct elf_file_map* fmap);
 extern struct module*
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index bfcc75d..2d7a8e0 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -1128,11 +1128,14 @@ BOOL elf_load_debug_info(struct module* 
  *
  * Gathers some more information for an ELF module from a given file
  */
-BOOL elf_fetch_file_info(const char* name, DWORD* base,
+BOOL elf_fetch_file_info(const WCHAR* name, DWORD* base,
                          DWORD* size, DWORD* checksum)
 {
     struct elf_file_map fmap;
-    if (!elf_map_file(name, &fmap)) return FALSE;
+    char                tmp[MAX_PATH];
+
+    WideCharToMultiByte(CP_UNIXCP, 0, name, -1, tmp, sizeof(tmp), 0, 0);
+    if (!elf_map_file(tmp, &fmap)) return FALSE;
     if (base) *base = fmap.elf_start;
     *size = fmap.elf_size;
     *checksum = calc_crc32(&fmap);
@@ -1594,7 +1597,7 @@ BOOL	elf_synchronize_module_list(struct 
     return FALSE;
 }
 
-BOOL elf_fetch_file_info(const char* name, DWORD* base,
+BOOL elf_fetch_file_info(const WCHAR* name, DWORD* base,
                          DWORD* size, DWORD* checksum)
 {
     return FALSE;
diff --git a/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c
index 681e231..57e2fd9 100644
--- a/dlls/dbghelp/minidump.c
+++ b/dlls/dbghelp/minidump.c
@@ -275,15 +275,13 @@ static BOOL fetch_elf_module_info_cb(con
 {
     struct dump_context*        dc = (struct dump_context*)user;
     DWORD                       rbase, size, checksum;
-    char                        tmp[MAX_PATH];
 
     /* FIXME: there's no relevant timestamp on ELF modules */
     /* NB: if we have a non-null base from the live-target use it (whenever
      * the ELF module is relocatable or not). If we have a null base (ELF
      * module isn't relocatable) then grab its base address from ELF file
      */
-    WideCharToMultiByte(CP_UNIXCP, 0, name, -1, tmp, sizeof(tmp), 0, 0);
-    if (!elf_fetch_file_info(tmp, &rbase, &size, &checksum))
+    if (!elf_fetch_file_info(name, &rbase, &size, &checksum))
         size = checksum = 0;
     add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
     return TRUE;
diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c
index 5dda1c6..d051feb 100644
--- a/dlls/dbghelp/path.c
+++ b/dlls/dbghelp/path.c
@@ -392,26 +392,20 @@ static BOOL CALLBACK sffip_cb(LPCWSTR bu
         }
         break;
     case DMT_ELF:
+        if (elf_fetch_file_info(buffer, 0, &size, &checksum))
         {
-            char                fn[MAX_PATH];
-
-            WideCharToMultiByte(CP_ACP, 0, buffer, -1, fn, MAX_PATH, NULL, NULL);
-
-            if (elf_fetch_file_info(fn, 0, &size, &checksum))
-            {
-                if (checksum != (DWORD_PTR)s->id)
-                {
-                    WARN("Found %s, but wrong checksums: %08x %08lx\n",
-                         debugstr_w(buffer), checksum, (DWORD_PTR)s->id);
-                    return FALSE;
-                }
-            }
-            else
+            if (checksum != (DWORD_PTR)s->id)
             {
-                WARN("Couldn't read %s\n", debugstr_w(buffer));
+                WARN("Found %s, but wrong checksums: %08x %08lx\n",
+                     debugstr_w(buffer), checksum, (DWORD_PTR)s->id);
                 return FALSE;
             }
         }
+        else
+        {
+            WARN("Couldn't read %s\n", debugstr_w(buffer));
+            return FALSE;
+        }
         break;
     case DMT_PDB:
         {



More information about the wine-patches mailing list