Module: wine Branch: master Commit: 70b8461bef2b12c5ddf868c14a56963c792b71d2 URL: https://gitlab.winehq.org/wine/wine/-/commit/70b8461bef2b12c5ddf868c14a56963...
Author: Ake Rehnman ake.rehnman@gmail.com Date: Thu Jan 5 12:58:23 2023 +0100
dbghelp: Store path to module image when passed through file handle.
Co-authored-by: Eric Pouech eric.pouech@gmail.com Signed-off-by: Eric Pouech eric.pouech@gmail.com
---
dlls/dbghelp/pe_module.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 91a018c526b..80c2f1a1f45 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -26,6 +26,8 @@ #include <string.h> #include <assert.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "dbghelp_private.h" #include "image_private.h" #include "winternl.h" @@ -796,7 +798,31 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, return NULL; opened = TRUE; } - else if (name) lstrcpyW(loaded_name, name); + else + { + ULONG sz = sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), needed; + OBJECT_NAME_INFORMATION *obj_name; + NTSTATUS nts; + + obj_name = RtlAllocateHeap(GetProcessHeap(), 0, sz); + if (obj_name) + { + nts = NtQueryObject(hFile, ObjectNameInformation, obj_name, sz, &needed); + if (nts == STATUS_BUFFER_OVERFLOW) + { + sz = needed; + obj_name = RtlReAllocateHeap(GetProcessHeap(), 0, obj_name, sz); + nts = NtQueryObject(hFile, ObjectNameInformation, obj_name, sz, &needed); + } + if (!nts) + { + obj_name->Name.Buffer[obj_name->Name.Length / sizeof(WCHAR)] = L'\0'; + real_path = wcsdup(obj_name->Name.Buffer); + } + RtlFreeHeap(GetProcessHeap(), 0, obj_name); + } + if (name) lstrcpyW(loaded_name, name); + } if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, sizeof(struct module_format) + sizeof(struct pe_module_info)))) return NULL; modfmt->u.pe_info = (struct pe_module_info*)(modfmt + 1);