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@winehq.org Reporter: focht@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.ht...
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/3cc3b445752902e07231900befc296f7...
--- 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