Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50829 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/dbghelp/dbghelp.spec | 2 +- dlls/dbghelp/symbol.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 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..8b32b06c327 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1404,6 +1404,35 @@ 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))) 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.@) */
Gijs Vermeulen gijsvrm@gmail.com wrote:
- 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))) return FALSE;
'si' is leaked on error path.
On 4/22/21 6:00 PM, Gijs Vermeulen wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50829 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com
dlls/dbghelp/dbghelp.spec | 2 +- dlls/dbghelp/symbol.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 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..8b32b06c327 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1404,6 +1404,35 @@ 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))) return FALSE;
si is leaked on failure.
- 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.@)
*/