From 6a859fb0e65b91f27aabe600a8da62ec91f748c0 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 21 Feb 2007 21:55:15 +0100 Subject: [PATCH] dbghelp: Move PE module loading to Unicode. --- dlls/dbghelp/dbghelp_private.h | 8 +++---- dlls/dbghelp/module.c | 6 +++--- dlls/dbghelp/msc.c | 6 +++--- dlls/dbghelp/pe_module.c | 48 ++++++++++++++++++------------------------ 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 20846ace073..d1c439e3e6b 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -477,12 +477,12 @@ extern BOOL pdb_fetch_file_info(struct pdb_lookup* pdb_lookup); /* pe_module.c */ extern BOOL pe_load_nt_header(HANDLE hProc, DWORD base, IMAGE_NT_HEADERS* nth); extern struct module* - pe_load_module(struct process* pcs, const char* name, + pe_load_module(struct process* pcs, const WCHAR* name, HANDLE hFile, DWORD base, DWORD size); extern struct module* - pe_load_module_from_pcs(struct process* pcs, const char* name, - const char* mod_name, DWORD base, DWORD size); -extern BOOL pe_load_debug_info(const struct process* pcs, + pe_load_module_from_pcs(struct process* pcs, const WCHAR* name, + const WCHAR* mod_name, DWORD base, DWORD size); +extern BOOL pe_load_debug_info(const struct process* pcs, struct module* module); /* source.c */ extern unsigned source_new(struct module* module, const char* basedir, const char* source); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 9d56adbc6f4..5da2135b8a8 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -517,21 +517,21 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam 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, + if ((module = pe_load_module_from_pcs(pcs, wImageName, wModuleName, BaseOfDll, SizeOfDll))) goto done; WARN("Couldn't locate %s\n", debugstr_w(wImageName)); return 0; } TRACE("Assuming %s as native DLL\n", debugstr_w(wImageName)); - if (!(module = pe_load_module(pcs, ImageName, hFile, BaseOfDll, SizeOfDll))) + 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))) goto done; FIXME("Should have successfully loaded debug information for image %s\n", debugstr_w(wImageName)); - if ((module = pe_load_module_from_pcs(pcs, ImageName, ModuleName, + if ((module = pe_load_module_from_pcs(pcs, wImageName, wModuleName, BaseOfDll, SizeOfDll))) goto done; WARN("Couldn't locate %s\n", debugstr_w(wImageName)); diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 6c5181e578c..14114c62459 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2139,7 +2139,7 @@ static BOOL pdb_process_internal(const struct process* pcs, /* Open and map() .PDB file */ if ((hFile = open_pdb_file(pcs, pdb_lookup)) == NULL || - ((hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) || + ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) || ((image = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) == NULL)) { WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename); @@ -2267,9 +2267,9 @@ BOOL pdb_fetch_file_info(struct pdb_lookup* pdb_lookup) char* image = NULL; BOOL ret = TRUE; - if ((hFile = CreateFileA(pdb_lookup->filename, GENERIC_READ, FILE_SHARE_READ, NULL, + if ((hFile = CreateFileA(pdb_lookup->filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE || - ((hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) || + ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) || ((image = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) == NULL)) { WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename); diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 611533ae5d7..386338ce033 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -101,9 +101,9 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, WINE_TRACE("Processing DBG file %s\n", dbg_name); if (SymFindFileInPath(pcs->handle, NULL, dbg_name, NULL, 0, 0, 0, tmp, dbg_match, NULL) && - (hFile = CreateFileA(tmp, GENERIC_READ, FILE_SHARE_READ, NULL, + (hFile = CreateFileA(tmp, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE && - ((hMap = CreateFileMappingA(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)) { hdr = (const IMAGE_SEPARATE_DEBUG_HEADER*)dbg_mapping; @@ -323,38 +323,32 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module) * pe_load_module * */ -struct module* pe_load_module(struct process* pcs, const char* name, +struct module* pe_load_module(struct process* pcs, const WCHAR* name, HANDLE hFile, DWORD base, DWORD size) { struct module* module = NULL; BOOL opened = FALSE; HANDLE hMap; void* mapping; - char loaded_name[MAX_PATH]; + WCHAR loaded_name[MAX_PATH]; loaded_name[0] = '\0'; if (!hFile) { - unsigned len = WideCharToMultiByte(CP_ACP,0, pcs->search_path, -1, NULL, 0, NULL, NULL); - char* sp; - if (!name) { /* FIXME SetLastError */ return NULL; } - sp = HeapAlloc(GetProcessHeap(), 0, len); - if (!sp) return FALSE; - WideCharToMultiByte(CP_ACP,0, pcs->search_path, -1, sp, len, NULL, NULL); - if ((hFile = FindExecutableImage(name, sp, loaded_name)) == NULL) + if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == NULL) return NULL; opened = TRUE; } - else if (name) strcpy(loaded_name, name); + else if (name) strcpyW(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_nameA(pcs, loaded_name, DMT_PE)) && + if (!(module = module_find_by_name(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 +360,9 @@ struct module* pe_load_module(struct process* pcs, const char* name, if (!base) base = nth->OptionalHeader.ImageBase; if (!size) size = nth->OptionalHeader.SizeOfImage; - module = module_newA(pcs, loaded_name, DMT_PE, FALSE, base, size, - nth->FileHeader.TimeDateStamp, - nth->OptionalHeader.CheckSum); + module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size, + nth->FileHeader.TimeDateStamp, + nth->OptionalHeader.CheckSum); if (module) { if (dbghelp_options & SYMOPT_DEFERRED_LOADS) @@ -405,17 +399,17 @@ BOOL pe_load_nt_header(HANDLE hProc, DWORD base, IMAGE_NT_HEADERS* nth) * pe_load_module_from_pcs * */ -struct module* pe_load_module_from_pcs(struct process* pcs, const char* name, - const char* mod_name, DWORD base, DWORD size) +struct module* pe_load_module_from_pcs(struct process* pcs, const WCHAR* name, + const WCHAR* mod_name, DWORD base, DWORD size) { struct module* module; - const char* ptr; + const WCHAR* ptr; - if ((module = module_find_by_nameA(pcs, name, DMT_PE))) return module; + if ((module = module_find_by_name(pcs, name, DMT_PE))) return module; if (mod_name) ptr = mod_name; else { - for (ptr = name + strlen(name) - 1; ptr >= name; ptr--) + for (ptr = name + strlenW(name) - 1; ptr >= name; ptr--) { if (*ptr == '/' || *ptr == '\\') { @@ -424,7 +418,7 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name, } } } - if (ptr && (module = module_find_by_nameA(pcs, ptr, DMT_PE))) return module; + if (ptr && (module = module_find_by_name(pcs, ptr, DMT_PE))) return module; if (base) { if (pcs->dbg_hdr_addr) @@ -434,13 +428,13 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name, if (pe_load_nt_header(pcs->handle, base, &nth)) { if (!size) size = nth.OptionalHeader.SizeOfImage; - module = module_newA(pcs, name, DMT_PE, FALSE, base, size, - nth.FileHeader.TimeDateStamp, - nth.OptionalHeader.CheckSum); + module = module_new(pcs, name, DMT_PE, FALSE, base, size, + nth.FileHeader.TimeDateStamp, + nth.OptionalHeader.CheckSum); } } else if (size) - module = module_newA(pcs, name, DMT_PE, FALSE, base, size, - 0 /* FIXME */, 0 /* FIXME */); + module = module_new(pcs, name, DMT_PE, FALSE, base, size, + 0 /* FIXME */, 0 /* FIXME */); } return module; } -- 2.11.4.GIT