[Bug 49344] New: Implement kernelbase.GetModuleFileNameW using ntdll.LdrGetDllFullName
WineHQ Bugzilla
wine-bugs at winehq.org
Mon Jun 8 03:53:11 CDT 2020
https://bugs.winehq.org/show_bug.cgi?id=49344
Bug ID: 49344
Summary: Implement kernelbase.GetModuleFileNameW using
ntdll.LdrGetDllFullName
Product: Wine
Version: 5.10
Hardware: x86-64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: kernelbase
Assignee: wine-bugs at winehq.org
Reporter: focht at gmx.net
Distribution: ---
Hello folks,
saw this patchset:
https://www.winehq.org/pipermail/wine-devel/2020-June/thread.html#167607
--- quote ---
This will help tremendously with debugging null pointer segfaults.
--- quote ---
to be used in ntdll.LdrGetProcedureAddress() for diagnostics.
According to:
https://www.geoffchappell.com/studies/windows/win32/ntdll/history/names62.htm
this API function was added in Windows 8.
Actually the real benefactor could be kernelbase.GetModuleFileNameW(). It would
avoid unnecessary code duplication and streamlines with general usage of native
API.
Wine source:
https://source.winehq.org/git/wine.git/blob/3cc3b445752902e07231900befc296f74ad6576e:/dlls/kernelbase/loader.c#l297
--- snip ---
297 /***********************************************************************
298 * GetModuleFileNameW (kernelbase.@)
299 */
300 DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameW( HMODULE module, LPWSTR
filename, DWORD size )
301 {
302 ULONG len = 0;
303 ULONG_PTR magic;
304 LDR_DATA_TABLE_ENTRY *pldr;
305 WIN16_SUBSYSTEM_TIB *win16_tib;
306
307 if (!module && ((win16_tib = NtCurrentTeb()->Tib.SubSystemTib)) &&
win16_tib->exe_name)
308 {
309 len = min( size, win16_tib->exe_name->Length / sizeof(WCHAR) );
310 memcpy( filename, win16_tib->exe_name->Buffer, len * sizeof(WCHAR)
);
311 if (len < size) filename[len] = 0;
312 goto done;
313 }
314
315 LdrLockLoaderLock( 0, NULL, &magic );
316
317 if (!module) module = NtCurrentTeb()->Peb->ImageBaseAddress;
318 if (set_ntstatus( LdrFindEntryForAddress( module, &pldr )))
319 {
320 len = min( size, pldr->FullDllName.Length / sizeof(WCHAR) );
321 memcpy( filename, pldr->FullDllName.Buffer, len * sizeof(WCHAR) );
322 if (len < size)
323 {
324 filename[len] = 0;
325 SetLastError( 0 );
326 }
327 else SetLastError( ERROR_INSUFFICIENT_BUFFER );
328 }
329
330 LdrUnlockLoaderLock( 0, magic );
331 done:
332 TRACE( "%s\n", debugstr_wn(filename, len) );
333 return len;
334 }
--- snip ---
$ wine --version
wine-5.10
Regards
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list