dbghelp: Return a Unicode path in path_find_symbol_file().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Alexandre Julliard 2018-11-15 14:24:58 +01:00
parent 6030ee5f6f
commit 3e1a562901
4 changed files with 16 additions and 25 deletions

View File

@ -659,7 +659,7 @@ extern BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip,
/* path.c */ /* path.c */
extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module,
PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2,
PSTR buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN;
/* pe_module.c */ /* pe_module.c */
extern BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS* nth) DECLSPEC_HIDDEN; extern BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS* nth) DECLSPEC_HIDDEN;

View File

@ -2444,7 +2444,7 @@ static HANDLE map_pdb_file(const struct process* pcs,
struct module* module) struct module* module)
{ {
HANDLE hFile, hMap = NULL; HANDLE hFile, hMap = NULL;
char dbg_file_path[MAX_PATH]; WCHAR dbg_file_path[MAX_PATH];
BOOL ret = FALSE; BOOL ret = FALSE;
switch (lookup->kind) switch (lookup->kind)
@ -2463,7 +2463,7 @@ static HANDLE map_pdb_file(const struct process* pcs,
WARN("\tCouldn't find %s\n", lookup->filename); WARN("\tCouldn't find %s\n", lookup->filename);
return NULL; return NULL;
} }
if ((hFile = CreateFileA(dbg_file_path, GENERIC_READ, FILE_SHARE_READ, NULL, if ((hFile = CreateFileW(dbg_file_path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
{ {
hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL); hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);

View File

@ -623,11 +623,10 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, BOOL path_find_symbol_file(const struct process* pcs, const struct module* module,
PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2,
PSTR buffer, BOOL* is_unmatched) WCHAR *buffer, BOOL* is_unmatched)
{ {
struct module_find mf; struct module_find mf;
WCHAR full_pathW[MAX_PATH]; WCHAR full_pathW[MAX_PATH];
WCHAR tmp[MAX_PATH];
WCHAR* ptr; WCHAR* ptr;
const WCHAR* filename; const WCHAR* filename;
WCHAR* searchPath = pcs->search_path; WCHAR* searchPath = pcs->search_path;
@ -648,7 +647,7 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul
/* first check full path to file */ /* first check full path to file */
if (module_find_cb(full_pathW, &mf)) if (module_find_cb(full_pathW, &mf))
{ {
WideCharToMultiByte(CP_ACP, 0, full_pathW, -1, buffer, MAX_PATH, NULL, NULL); strcpyW( buffer, full_pathW );
return TRUE; return TRUE;
} }
@ -662,38 +661,30 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul
(dll may be exe, or sys depending on the file extension) */ (dll may be exe, or sys depending on the file extension) */
/* 2. check module-path */ /* 2. check module-path */
file_pathW(module->module.LoadedImageName, tmp); file_pathW(module->module.LoadedImageName, buffer);
if (do_searchW(filename, tmp, FALSE, module_find_cb, &mf)) if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE;
{
WideCharToMultiByte(CP_ACP, 0, tmp, -1, buffer, MAX_PATH, NULL, NULL);
return TRUE;
}
while (searchPath) while (searchPath)
{ {
ptr = strchrW(searchPath, ';'); ptr = strchrW(searchPath, ';');
if (ptr) if (ptr)
{ {
memcpy(tmp, searchPath, (ptr - searchPath) * sizeof(WCHAR)); memcpy(buffer, searchPath, (ptr - searchPath) * sizeof(WCHAR));
tmp[ptr - searchPath] = '\0'; buffer[ptr - searchPath] = '\0';
searchPath = ptr + 1; searchPath = ptr + 1;
} }
else else
{ {
strcpyW(tmp, searchPath); strcpyW(buffer, searchPath);
searchPath = NULL; searchPath = NULL;
} }
if (do_searchW(filename, tmp, FALSE, module_find_cb, &mf)) /* return first fully matched file */
{ if (do_searchW(filename, buffer, FALSE, module_find_cb, &mf)) return TRUE;
/* return first fully matched file */
WideCharToMultiByte(CP_ACP, 0, tmp, -1, buffer, MAX_PATH, NULL, NULL);
return TRUE;
}
} }
/* if no fully matching file is found, return the best matching file if any */ /* if no fully matching file is found, return the best matching file if any */
if ((dbghelp_options & SYMOPT_LOAD_ANYTHING) && mf.matched) if ((dbghelp_options & SYMOPT_LOAD_ANYTHING) && mf.matched)
{ {
WideCharToMultiByte(CP_ACP, 0, mf.filename, -1, buffer, MAX_PATH, NULL, NULL); strcpyW( buffer, mf.filename );
*is_unmatched = TRUE; *is_unmatched = TRUE;
return TRUE; return TRUE;
} }

View File

@ -524,7 +524,7 @@ static BOOL pe_load_dwarf(struct module* module)
static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module,
const char* dbg_name, DWORD timestamp) const char* dbg_name, DWORD timestamp)
{ {
char tmp[MAX_PATH]; WCHAR tmp[MAX_PATH];
HANDLE hFile = INVALID_HANDLE_VALUE, hMap = 0; HANDLE hFile = INVALID_HANDLE_VALUE, hMap = 0;
const BYTE* dbg_mapping = NULL; const BYTE* dbg_mapping = NULL;
BOOL ret = FALSE; BOOL ret = FALSE;
@ -532,7 +532,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module,
TRACE("Processing DBG file %s\n", debugstr_a(dbg_name)); TRACE("Processing DBG file %s\n", debugstr_a(dbg_name));
if (path_find_symbol_file(pcs, module, dbg_name, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) && if (path_find_symbol_file(pcs, module, dbg_name, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
(hFile = CreateFileA(tmp, GENERIC_READ, FILE_SHARE_READ, NULL, (hFile = CreateFileW(tmp, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE && OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE &&
((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) && ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
((dbg_mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)) ((dbg_mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL))
@ -555,7 +555,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module,
hdr->DebugDirectorySize / sizeof(*dbg)); hdr->DebugDirectorySize / sizeof(*dbg));
} }
else else
ERR("Couldn't find .DBG file %s (%s)\n", debugstr_a(dbg_name), debugstr_a(tmp)); ERR("Couldn't find .DBG file %s (%s)\n", debugstr_a(dbg_name), debugstr_w(tmp));
if (dbg_mapping) UnmapViewOfFile(dbg_mapping); if (dbg_mapping) UnmapViewOfFile(dbg_mapping);
if (hMap) CloseHandle(hMap); if (hMap) CloseHandle(hMap);