Eric Pouech : dbghelp:
Added module_get_type_by_name in Unicode form and keep the ANSI form
for compatibility .
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 22 05:56:44 CST 2007
Module: wine
Branch: master
Commit: d707fe5ac368a4db6ee138dc8b37075f14ade69d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d707fe5ac368a4db6ee138dc8b37075f14ade69d
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Wed Feb 21 21:55:25 2007 +0100
dbghelp: Added module_get_type_by_name in Unicode form and keep the ANSI form for compatibility.
---
dlls/dbghelp/dbghelp_private.h | 4 +++-
dlls/dbghelp/module.c | 38 ++++++++++++++++++++++++++++++++++----
dlls/dbghelp/path.c | 2 +-
3 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index e0bc12e..c17c8d3 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -455,7 +455,9 @@ extern struct module*
module_get_containee(const struct process* pcs,
const struct module* inner);
extern enum module_type
- module_get_type_by_name(const char* name);
+ module_get_type_by_name(const WCHAR* name);
+extern enum module_type
+ module_get_type_by_nameA(const char* name);
extern void module_reset_debug_info(struct module* module);
extern BOOL module_remove(struct process* pcs,
struct module* module);
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 1edef49..56fff82 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -36,7 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
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_DotPdbW[] = {'.','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'};
@@ -378,7 +378,37 @@ static BOOL module_is_elf_container_loaded(struct process* pcs,
*
* Guesses a filename type from its extension
*/
-enum module_type module_get_type_by_name(const char* name)
+enum module_type module_get_type_by_name(const WCHAR* name)
+{
+ const WCHAR*ptr;
+ int len = strlenW(name);
+
+ /* check for terminating .so or .so.[digit] */
+ ptr = strrchrW(name, '.');
+ if (ptr)
+ {
+ if (!strcmpW(ptr, S_DotSoW) ||
+ (isdigit(ptr[1]) && !ptr[2] && ptr >= name + 3 && !memcmp(ptr - 3, S_DotSoW, 3)))
+ return DMT_ELF;
+ else if (!strcmpiW(ptr, S_DotPdbW))
+ return DMT_PDB;
+ }
+ /* wine-[kp]thread is also an ELF module */
+ else if (((len > 12 && name[len - 13] == '/') || len == 12) &&
+ (!strcmpiW(name + len - 12, S_WinePThreadW) ||
+ !strcmpiW(name + len - 12, S_WineKThreadW)))
+ {
+ return DMT_ELF;
+ }
+ return DMT_PE;
+}
+
+/******************************************************************
+ * module_get_type_by_nameA
+ *
+ * Guesses a filename type from its extension
+ */
+enum module_type module_get_type_by_nameA(const char* name)
{
const char* ptr;
int len = strlen(name);
@@ -477,7 +507,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
{
WideCharToMultiByte(CP_ACP,0, wImageName, -1, ImageName, MAX_PATH,
NULL, NULL);
- module = module_new(pcs, wImageName, module_get_type_by_name(ImageName),
+ module = module_new(pcs, wImageName, module_get_type_by_name(wImageName),
TRUE, (DWORD)BaseOfDll, SizeOfDll, 0, 0);
if (!module) return FALSE;
if (wModuleName) module_set_module(module, wModuleName);
@@ -515,7 +545,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
TRACE("Assuming %s as native DLL\n", debugstr_w(wImageName));
if (!(module = pe_load_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)))
{
- if (module_get_type_by_name(ImageName) == DMT_ELF &&
+ if (module_get_type_by_name(wImageName) == DMT_ELF &&
(module = elf_load_module(pcs, wImageName, BaseOfDll)))
goto done;
FIXME("Should have successfully loaded debug information for image %s\n",
diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c
index 7c4b2e0..331764d 100644
--- a/dlls/dbghelp/path.c
+++ b/dlls/dbghelp/path.c
@@ -404,7 +404,7 @@ BOOL WINAPI SymFindFileInPath(HANDLE hProcess, PCSTR inSearchPath, PCSTR full_pa
s.user = user;
filename = file_name(full_path);
- s.kind = module_get_type_by_name(filename);
+ s.kind = module_get_type_by_nameA(filename);
/* first check full path to file */
if (sffip_cb(full_path, &s))
More information about the wine-cvs
mailing list