From 43dffcd05d84be91c055bbbd31db380fc4460d78 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 21 Feb 2007 21:55:04 +0100 Subject: [PATCH] dbghelp: Now storing module information in Unicode form. --- dlls/dbghelp/dbghelp_private.h | 29 ++++-- dlls/dbghelp/elf_module.c | 42 ++++---- dlls/dbghelp/module.c | 175 +++++++++++++++++---------------- dlls/dbghelp/msc.c | 4 +- dlls/dbghelp/pe_module.c | 30 +++--- dlls/dbghelp/source.c | 2 +- dlls/dbghelp/symbol.c | 2 +- 7 files changed, 156 insertions(+), 128 deletions(-) diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 2ec675bc4a4..20846ace073 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -4,7 +4,7 @@ * Copyright (C) 1995, Alexandre Julliard * Copyright (C) 1996, Eric Youngdale. * Copyright (C) 1999-2000, Ulrich Weigand. - * Copyright (C) 2004, Eric Pouech. + * Copyright (C) 2004-2007, Eric Pouech. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,6 +28,8 @@ #include "dbghelp.h" #include "objbase.h" #include "oaidl.h" +#include "winnls.h" +#include "wine/unicode.h" #include "cvconst.h" @@ -310,7 +312,7 @@ struct process; struct module { - IMAGEHLP_MODULE64 module; + IMAGEHLP_MODULEW64 module; /* ANSI copy of module.ModuleName for efficiency */ char module_name[MAX_PATH]; struct module* next; @@ -428,18 +430,29 @@ extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_th extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr); /* module.c */ +extern const WCHAR S_ElfW[]; +extern const WCHAR S_WineLoaderW[]; + extern struct module* module_find_by_addr(const struct process* pcs, unsigned long addr, enum module_type type); extern struct module* - module_find_by_name(const struct process* pcs, - const char* name, enum module_type type); + module_find_by_name(const struct process* pcs, + const WCHAR* name, enum module_type type); +extern struct module* + module_find_by_nameA(const struct process* pcs, + const char* name, enum module_type type); extern BOOL module_get_debug(struct module_pair*); extern struct module* - module_new(struct process* pcs, const char* name, + module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, 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); @@ -449,12 +462,12 @@ extern struct module* extern enum module_type module_get_type_by_name(const char* name); extern void module_reset_debug_info(struct module* module); -extern BOOL module_remove(struct process* pcs, +extern BOOL module_remove(struct process* pcs, struct module* module); -extern void module_set_module(struct module* module, const char* name); +extern void module_set_module(struct module* module, const WCHAR* name); /* msc.c */ -extern BOOL pe_load_debug_directory(const struct process* pcs, +extern BOOL pe_load_debug_directory(const struct process* pcs, struct module* module, const BYTE* mapping, const IMAGE_SECTION_HEADER* sectp, DWORD nsect, diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index e534013619c..3986281b0d9 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -2,7 +2,7 @@ * File elf.c - processing of ELF files * * Copyright (C) 1996, Eric Youngdale. - * 1999-2004 Eric Pouech + * 1999-2007 Eric Pouech * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -802,21 +802,23 @@ static BOOL elf_load_debug_info_from_map(struct module* module, * is the global debug file directory, and execdir has been turned * into a relative path)." (from GDB manual) */ -static char* elf_locate_debug_link(const char* filename, const char* loaded_file, +static char* elf_locate_debug_link(const char* filename, const WCHAR* loaded_file, struct elf_file_map* fmap_link) { static const char globalDebugDir[] = "/usr/lib/debug/"; const size_t globalDebugDirLen = strlen(globalDebugDir); + size_t loaded_file_len; char* p; char* slash; + loaded_file_len = WideCharToMultiByte(CP_UNIXCP, 0, loaded_file, -1, NULL, 0, NULL, NULL); p = HeapAlloc(GetProcessHeap(), 0, - globalDebugDirLen + strlen(loaded_file) + 1 + 6 + 1 + strlen(filename) + 1); + globalDebugDirLen + loaded_file_len + 6 + 1 + strlen(filename) + 1); if (!p) return FALSE; /* we prebuild the string with "execdir" */ - strcpy(p, loaded_file); + WideCharToMultiByte(CP_UNIXCP, 0, loaded_file, -1, p, loaded_file_len, NULL, NULL); slash = strrchr(p, '/'); if (slash == NULL) slash = p; else slash++; @@ -879,7 +881,9 @@ static BOOL elf_debuglink_parse (struct module* module, ret = elf_load_debug_info_from_map(module, &fmap_link, pool, ht_symtab); if (ret) - strcpy(module->module.LoadedPdbName, link_file); + MultiByteToWideChar(CP_ACP, 0, link_file, -1, + module->module.LoadedPdbName, + sizeof(module->module.LoadedPdbName)); else WARN("Couldn't load debug information from %s\n", link_file); elf_unmap_file(&fmap_link); @@ -928,7 +932,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, if (fmap->with_crc && (fmap->crc != calc_crc32(fmap))) { ERR("Bad CRC for module %s (got %08x while expecting %08lx)\n", - module->module.LoadedImageName, calc_crc32(fmap), fmap->crc); + debugstr_w(module->module.LoadedImageName), calc_crc32(fmap), fmap->crc); /* we don't tolerate mis-matched files */ return FALSE; } @@ -1062,14 +1066,14 @@ static BOOL elf_load_debug_info_from_map(struct module* module, lret = elf_debuglink_parse (module, pool, ht_symtab, dbg_link); if (!lret) WARN("Couldn't load linked debug file for %s\n", - module->module.ModuleName); + debugstr_w(module->module.ModuleName)); ret = ret || lret; } elf_unmap_section(fmap, debuglink_sect); } } - if (strstr(module->module.ModuleName, "") || - !strcmp(module->module.ModuleName, "")) + if (strstrW(module->module.ModuleName, S_ElfW) || + !strcmpW(module->module.ModuleName, S_WineLoaderW)) { /* add the thunks for native libraries */ if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY)) @@ -1095,7 +1099,7 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap) if (module->type != DMT_ELF || !module->elf_info) { - ERR("Bad elf module '%s'\n", module->module.LoadedImageName); + ERR("Bad elf module '%s'\n", debugstr_w(module->module.LoadedImageName)); return FALSE; } @@ -1104,8 +1108,12 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap) if (!fmap) { + char LoadedImageName[MAX_PATH]; + fmap = &my_fmap; - ret = elf_map_file(module->module.LoadedImageName, fmap); + WideCharToMultiByte(CP_ACP, 0, module->module.LoadedImageName, -1, + LoadedImageName, MAX_PATH, NULL, NULL); + ret = elf_map_file(LoadedImageName, fmap); } if (ret) ret = elf_load_debug_info_from_map(module, fmap, &pool, &ht_symtab); @@ -1201,12 +1209,12 @@ static BOOL elf_load_file(struct process* pcs, const char* filename, if (elf_info->flags & ELF_INFO_MODULE) { - struct elf_module_info *elf_module_info = + 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_new(pcs, filename, DMT_ELF, FALSE, - (load_offset) ? load_offset : fmap.elf_start, - fmap.elf_size, 0, calc_crc32(&fmap)); + elf_info->module = module_newA(pcs, filename, 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); @@ -1313,7 +1321,7 @@ static BOOL elf_search_and_load_file(struct process* pcs, const char* filename, struct module* module; if (filename == NULL || *filename == '\0') return FALSE; - if ((module = module_find_by_name(pcs, filename, DMT_ELF))) + if ((module = module_find_by_nameA(pcs, filename, DMT_ELF))) { elf_info->module = module; module->elf_info->elf_mark = 1; @@ -1469,7 +1477,7 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs) elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE; if (!elf_search_loader(pcs, &elf_info)) return FALSE; elf_info.module->elf_info->elf_loader = 1; - strcpy(elf_info.module->module.ModuleName, ""); + module_set_module(elf_info.module, S_WineLoaderW); return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0; } diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index de50f0e0084..9d56adbc6f4 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -2,7 +2,7 @@ * File module.c - module handling for the wine debugger * * Copyright (C) 1993, Eric Youngdale. - * 2000-2004, Eric Pouech + * 2000-2007, Eric Pouech * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,60 +30,73 @@ #include "winreg.h" #include "winternl.h" #include "wine/debug.h" -#include "winnls.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); -static const char * const ext[] = {".acm", ".dll", ".drv", ".exe", ".ocx", ".vxd", NULL}; +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_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'}; -static int match_ext(const char* ptr, size_t len) +static const WCHAR S_AcmW[] = {'.','a','c','m','\0'}; +static const WCHAR S_DllW[] = {'.','d','l','l','\0'}; +static const WCHAR S_DrvW[] = {'.','d','r','v','\0'}; +static const WCHAR S_ExeW[] = {'.','e','x','e','\0'}; +static const WCHAR S_OcxW[] = {'.','o','c','x','\0'}; +static const WCHAR S_VxdW[] = {'.','v','x','d','\0'}; +static const WCHAR * const ext[] = {S_AcmW, S_DllW, S_DrvW, S_ExeW, S_OcxW, S_VxdW, NULL}; + +static int match_ext(const WCHAR* ptr, size_t len) { - const char * const *e; + const WCHAR* const *e; size_t l; for (e = ext; *e; e++) { - l = strlen(*e); + l = strlenW(*e); if (l >= len) return FALSE; - if (strncasecmp(&ptr[len - l], *e, l)) continue; + if (strncmpiW(&ptr[len - l], *e, l)) continue; return l; } return 0; } - -static void module_fill_module(const char* in, char* out, size_t size) + +static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) { - const char *ptr,*endptr; + const WCHAR *ptr,*endptr; size_t len, l; - endptr = in + strlen(in); + endptr = in + strlenW(in); for (ptr = endptr - 1; ptr >= in && *ptr != '/' && *ptr != '\\'; ptr--); ptr++; len = min(endptr-ptr,size-1); - memcpy(out, ptr, len); + memcpy(out, ptr, len * sizeof(WCHAR)); out[len] = '\0'; if (len > 4 && (l = match_ext(out, len))) out[len - l] = '\0'; else if (len > 12 && - (!strcasecmp(out + len - 12, "wine-pthread") || - !strcasecmp(out + len - 12, "wine-kthread"))) - lstrcpynA(out, "", size); + (!strcmpiW(out + len - 12, S_WinePThreadW) || + !strcmpiW(out + len - 12, S_WineKThreadW))) + lstrcpynW(out, S_WineLoaderW, size); else { - if (len > 3 && !strcasecmp(&out[len - 3], ".so") && + if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && (l = match_ext(out, len - 3))) - strcpy(&out[len - l - 3], ""); + strcpyW(&out[len - l - 3], S_ElfW); } - while ((*out = tolower(*out))) out++; + while ((*out = tolowerW(*out))) out++; } -void module_set_module(struct module* module, const char* name) +void module_set_module(struct module* module, const WCHAR* name) { module_fill_module(name, module->module.ModuleName, sizeof(module->module.ModuleName)); - strcpy(module->module_name, module->module.ModuleName); + WideCharToMultiByte(CP_ACP, 0, module->module.ModuleName, -1, + module->module_name, sizeof(module->module_name), + NULL, NULL); } static const char* get_module_type(enum module_type type, BOOL virtual) @@ -97,12 +110,12 @@ static const char* get_module_type(enum module_type type, BOOL virtual) } /*********************************************************************** - * Creates and links a new module to a process + * Creates and links a new module to a process */ -struct module* module_new(struct process* pcs, const char* name, +struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, unsigned long mod_addr, unsigned long size, - unsigned long stamp, unsigned long checksum) + unsigned long stamp, unsigned long checksum) { struct module* module; @@ -115,17 +128,18 @@ struct module* module_new(struct process* pcs, const char* name, module->next = pcs->lmodules; pcs->lmodules = module; - TRACE("=> %s %08lx-%08lx %s\n", - get_module_type(type, virtual), mod_addr, mod_addr + size, name); + TRACE("=> %s %08lx-%08lx %s\n", + get_module_type(type, virtual), mod_addr, mod_addr + size, + debugstr_w(name)); pool_init(&module->pool, 65536); - + module->module.SizeOfStruct = sizeof(module->module); module->module.BaseOfImage = mod_addr; module->module.ImageSize = size; module_set_module(module, name); module->module.ImageName[0] = '\0'; - lstrcpynA(module->module.LoadedImageName, name, sizeof(module->module.LoadedImageName)); + lstrcpynW(module->module.LoadedImageName, name, sizeof(module->module.LoadedImageName) / sizeof(WCHAR)); module->module.SymType = SymNone; module->module.NumSyms = 0; module->module.TimeDateStamp = stamp; @@ -163,12 +177,23 @@ struct module* module_new(struct process* pcs, const char* 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 * */ -struct module* module_find_by_name(const struct process* pcs, - const char* name, enum module_type type) +struct module* module_find_by_name(const struct process* pcs, + const WCHAR* name, enum module_type type) { struct module* module; @@ -180,19 +205,19 @@ struct module* module_find_by_name(const struct process* pcs, } else { - char modname[MAX_PATH]; + WCHAR modname[MAX_PATH]; for (module = pcs->lmodules; module; module = module->next) { if (type == module->type && - !strcasecmp(name, module->module.LoadedImageName)) + !strcmpiW(name, module->module.LoadedImageName)) return module; } module_fill_module(name, modname, sizeof(modname)); for (module = pcs->lmodules; module; module = module->next) { if (type == module->type && - !strcasecmp(modname, module->module.ModuleName)) + !strcmpiW(modname, module->module.ModuleName)) return module; } } @@ -200,6 +225,15 @@ struct module* module_find_by_name(const struct process* pcs, return NULL; } +struct module* module_find_by_nameA(const struct process* pcs, + const char* name, enum module_type type) +{ + WCHAR wname[MAX_PATH]; + + MultiByteToWideChar(CP_ACP, 0, name, -1, wname, sizeof(wname) / sizeof(WCHAR)); + return module_find_by_name(pcs, wname, type); +} + /*********************************************************************** * module_get_container * @@ -274,7 +308,8 @@ BOOL module_get_debug(struct module_pair* pair) idsl64.BaseOfImage = pair->effective->module.BaseOfImage; idsl64.CheckSum = pair->effective->module.CheckSum; idsl64.TimeDateStamp = pair->effective->module.TimeDateStamp; - strcpy(idsl64.FileName, pair->effective->module.ImageName); + WideCharToMultiByte(CP_ACP, 0, pair->effective->module.ImageName, -1, + idsl64.FileName, sizeof(idsl64.FileName), NULL, NULL); idsl64.Reparse = FALSE; idsl64.hFile = INVALID_HANDLE_VALUE; @@ -325,10 +360,11 @@ struct module* module_find_by_addr(const struct process* pcs, unsigned long addr return module; } -static BOOL module_is_elf_container_loaded(struct process* pcs, const char* ImageName, - const char* ModuleName) +static BOOL module_is_elf_container_loaded(struct process* pcs, + const WCHAR* ImageName, + const WCHAR* ModuleName) { - char buffer[MAX_PATH]; + WCHAR buffer[MAX_PATH]; size_t len; struct module* module; @@ -337,12 +373,12 @@ static BOOL module_is_elf_container_loaded(struct process* pcs, const char* Imag module_fill_module(ImageName, buffer, sizeof(buffer)); ModuleName = buffer; } - len = strlen(ModuleName); + len = strlenW(ModuleName); for (module = pcs->lmodules; module; module = module->next) { - if (!strncasecmp(module->module.ModuleName, ModuleName, len) && + if (!strncmpiW(module->module.ModuleName, ModuleName, len) && module->type == DMT_ELF && - !strcmp(module->module.ModuleName + len, "")) + !strcmpW(module->module.ModuleName + len, S_ElfW)) return TRUE; } return FALSE; @@ -452,15 +488,10 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam { WideCharToMultiByte(CP_ACP,0, wImageName, -1, ImageName, MAX_PATH, NULL, NULL); - module = module_new(pcs, ImageName, module_get_type_by_name(ImageName), + module = module_new(pcs, wImageName, module_get_type_by_name(ImageName), TRUE, (DWORD)BaseOfDll, SizeOfDll, 0, 0); if (!module) return FALSE; - if (wModuleName) - { - WideCharToMultiByte(CP_ACP,0, wModuleName, -1, ModuleName = amodname, MAX_PATH, - NULL, NULL); - module_set_module(module, ModuleName); - } + if (wModuleName) module_set_module(module, wModuleName); module->module.SymType = SymVirtual; return TRUE; @@ -483,7 +514,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam else ModuleName = NULL; - if (module_is_elf_container_loaded(pcs, ImageName, ModuleName)) + 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, @@ -508,12 +539,13 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam } module->module.NumSyms = module->ht_symbols.num_elts; done: - /* by default pe_load_module fills module.ModuleName from a derivation + /* by default pe_load_module fills module.ModuleName from a derivation * of ImageName. Overwrite it, if we have better information */ - if (ModuleName) - module_set_module(module, ModuleName); - lstrcpynA(module->module.ImageName, ImageName, sizeof(module->module.ImageName)); + if (wModuleName) + module_set_module(module, wModuleName); + lstrcpynW(module->module.ImageName, wImageName, + sizeof(module->module.ImageName) / sizeof(CHAR)); return module->module.BaseOfImage; } @@ -712,8 +744,7 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PVOID UserContext) { HMODULE* hMods; - char base[256], mod[256]; - WCHAR modW[256]; + WCHAR baseW[256], modW[256]; DWORD i, sz; MODULEINFO mi; @@ -731,10 +762,9 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, for (i = 0; i < sz; i++) { if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) || - !GetModuleBaseNameA(hProcess, hMods[i], base, sizeof(base))) + !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR))) continue; - module_fill_module(base, mod, sizeof(mod)); - MultiByteToWideChar(CP_ACP, 0, mod, -1, modW, sizeof(modW) / sizeof(modW)); + module_fill_module(baseW, modW, sizeof(modW) / sizeof(CHAR)); EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage, UserContext); } @@ -875,36 +905,9 @@ BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN); if (!module) return FALSE; - miw64.SizeOfStruct = sizeof(miw64); - miw64.BaseOfImage = module->module.BaseOfImage; - miw64.ImageSize = module->module.ImageSize; - miw64.TimeDateStamp = module->module.TimeDateStamp; - miw64.CheckSum = module->module.CheckSum; - miw64.NumSyms = module->module.NumSyms; - miw64.SymType = module->module.SymType; - MultiByteToWideChar(CP_ACP, 0, module->module.ModuleName, -1, - miw64.ModuleName, sizeof(miw64.ModuleName) / sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, module->module.ImageName, -1, - miw64.ImageName, sizeof(miw64.ImageName) / sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, module->module.LoadedImageName, -1, - miw64.LoadedImageName, sizeof(miw64.LoadedImageName) / sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, module->module.LoadedPdbName, -1, - miw64.LoadedPdbName, sizeof(miw64.LoadedPdbName) / sizeof(WCHAR)); - - miw64.CVSig = module->module.CVSig; - MultiByteToWideChar(CP_ACP, 0, module->module.CVData, -1, - miw64.CVData, sizeof(miw64.CVData) / sizeof(WCHAR)); - miw64.PdbSig = module->module.PdbSig; - miw64.PdbSig70 = module->module.PdbSig70; - miw64.PdbAge = module->module.PdbAge; - miw64.PdbUnmatched = module->module.PdbUnmatched; - miw64.DbgUnmatched = module->module.DbgUnmatched; - miw64.LineNumbers = module->module.LineNumbers; - miw64.GlobalSymbols = module->module.GlobalSymbols; - miw64.TypeInfo = module->module.TypeInfo; - miw64.SourceIndexed = module->module.SourceIndexed; - miw64.Publics = module->module.Publics; + miw64 = module->module; + /* update debug information from container if any */ if (module->module.SymType == SymNone) { module = module_get_container(pcs, module); diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 203997faec3..6c5181e578c 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2248,7 +2248,9 @@ static BOOL pdb_process_file(const struct process* pcs, else msc_dbg->module->module.PdbSig70 = pdb_lookup->u.ds.guid; msc_dbg->module->module.PdbAge = pdb_lookup->age; - strcpy(msc_dbg->module->module.LoadedPdbName, pdb_lookup->filename); + MultiByteToWideChar(CP_ACP, 0, pdb_lookup->filename, -1, + msc_dbg->module->module.LoadedPdbName, + sizeof(msc_dbg->module->module.LoadedPdbName) / sizeof(WCHAR)); /* FIXME: we could have a finer grain here */ msc_dbg->module->module.LineNumbers = TRUE; msc_dbg->module->module.GlobalSymbols = TRUE; diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 7958bd06c42..611533ae5d7 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -3,7 +3,7 @@ * * Copyright (C) 1996, Eric Youngdale. * Copyright (C) 1999-2000, Ulrich Weigand. - * Copyright (C) 2004, Eric Pouech. + * Copyright (C) 2004-2007, Eric Pouech. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -289,10 +289,10 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module) void* mapping; IMAGE_NT_HEADERS* nth; - hFile = CreateFileA(module->module.LoadedImageName, GENERIC_READ, FILE_SHARE_READ, + hFile = CreateFileW(module->module.LoadedImageName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return ret; - if ((hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) + if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) { if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) { @@ -354,8 +354,8 @@ struct module* pe_load_module(struct process* pcs, const char* name, else if (name) strcpy(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_name(pcs, loaded_name, DMT_PE)) && - (hMap = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) + if (!(module = module_find_by_nameA(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) { @@ -365,10 +365,10 @@ 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_new(pcs, loaded_name, DMT_PE, FALSE, base, size, - nth->FileHeader.TimeDateStamp, - nth->OptionalHeader.CheckSum); + + module = module_newA(pcs, loaded_name, DMT_PE, FALSE, base, size, + nth->FileHeader.TimeDateStamp, + nth->OptionalHeader.CheckSum); if (module) { if (dbghelp_options & SYMOPT_DEFERRED_LOADS) @@ -411,7 +411,7 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name, struct module* module; const char* ptr; - if ((module = module_find_by_name(pcs, name, DMT_PE))) return module; + if ((module = module_find_by_nameA(pcs, name, DMT_PE))) return module; if (mod_name) ptr = mod_name; else { @@ -424,7 +424,7 @@ struct module* pe_load_module_from_pcs(struct process* pcs, const char* name, } } } - if (ptr && (module = module_find_by_name(pcs, ptr, DMT_PE))) return module; + if (ptr && (module = module_find_by_nameA(pcs, ptr, DMT_PE))) return module; if (base) { if (pcs->dbg_hdr_addr) @@ -434,11 +434,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_new(pcs, name, DMT_PE, FALSE, base, size, - nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum); + module = module_newA(pcs, name, DMT_PE, FALSE, base, size, + nth.FileHeader.TimeDateStamp, + nth.OptionalHeader.CheckSum); } } else if (size) - module = module_new(pcs, name, DMT_PE, FALSE, base, size, 0 /* FIXME */, 0 /* FIXME */); + module = module_newA(pcs, name, DMT_PE, FALSE, base, size, + 0 /* FIXME */, 0 /* FIXME */); } return module; } diff --git a/dlls/dbghelp/source.c b/dlls/dbghelp/source.c index fd0a9a889be..311a263d88f 100644 --- a/dlls/dbghelp/source.c +++ b/dlls/dbghelp/source.c @@ -133,7 +133,7 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask, { if (Mask[0] == '!') { - pair.requested = module_find_by_name(pair.pcs, Mask + 1, DMT_UNKNOWN); + pair.requested = module_find_by_nameA(pair.pcs, Mask + 1, DMT_UNKNOWN); if (!module_get_debug(&pair)) return FALSE; } else diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 8a89203e1ff..cf8abf3a29e 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1174,7 +1174,7 @@ BOOL WINAPI SymFromName(HANDLE hProcess, PCSTR Name, PSYMBOL_INFO Symbol) assert(name - Name < sizeof(tmp)); memcpy(tmp, Name, name - Name); tmp[name - Name] = '\0'; - module = module_find_by_name(pcs, tmp, DMT_UNKNOWN); + module = module_find_by_nameA(pcs, tmp, DMT_UNKNOWN); return find_name(pcs, module, name + 1, Symbol); } for (module = pcs->lmodules; module; module = module->next)