Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50829 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- v2: Don't leak si on failure. (Thanks Dmitry & Zhiyi)
dlls/dbghelp/dbghelp.spec | 2 +- dlls/dbghelp/symbol.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/dlls/dbghelp/dbghelp.spec b/dlls/dbghelp/dbghelp.spec index b17c7b18655..73455c547e8 100644 --- a/dlls/dbghelp/dbghelp.spec +++ b/dlls/dbghelp/dbghelp.spec @@ -75,7 +75,7 @@ @ stdcall SymFromIndex(long int64 long ptr) @ stdcall SymFromIndexW(long int64 long ptr) @ stdcall SymFromName(long str ptr) -@ stub SymFromNameW +@ stdcall SymFromNameW(long wstr ptr) @ stub SymFromToken @ stub SymFromTokenW @ stdcall SymFunctionTableAccess(long long) diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 706d088aec0..61081527a36 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1404,6 +1404,39 @@ BOOL WINAPI SymFromName(HANDLE hProcess, PCSTR Name, PSYMBOL_INFO Symbol) return FALSE; }
+/*********************************************************************** + * SymFromNameW (DBGHELP.@) + */ +BOOL WINAPI SymFromNameW(HANDLE process, const WCHAR *name, SYMBOL_INFOW *symbol) +{ + SYMBOL_INFO *si; + DWORD len; + char *tmp; + BOOL ret; + + TRACE("(%p, %s, %p)\n", process, debugstr_w(name), symbol); + + len = sizeof(*si) + symbol->MaxNameLen * sizeof(WCHAR); + if (!(si = HeapAlloc(GetProcessHeap(), 0, len))) return FALSE; + + len = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); + if (!(tmp = HeapAlloc(GetProcessHeap(), 0, len))) + { + HeapFree(GetProcessHeap(), 0, si); + return FALSE; + } + WideCharToMultiByte(CP_ACP, 0, name, -1, tmp, len, NULL, NULL); + + si->SizeOfStruct = sizeof(*si); + si->MaxNameLen = symbol->MaxNameLen; + if ((ret = SymFromName(process, tmp, si))) + copy_symbolW(symbol, si); + + HeapFree(GetProcessHeap(), 0, tmp); + HeapFree(GetProcessHeap(), 0, si); + return ret; +} + /*********************************************************************** * SymGetSymFromName64 (DBGHELP.@) */