https://bugs.winehq.org/show_bug.cgi?id=51833
Bug ID: 51833 Summary: GetModuleFileNameW no longer works with large buffers Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: wine@2ar.nl Regression SHA1: 43d14fd808bb965762bb6c76027bbe26ba936f82 Distribution: ---
The recent change 'Implement kernelbase.GetModuleFileNameW using ntdll.LdrGetDllFullName' (bug 49344) broke passing large buffers (>=32768 characters) to GetModuleFileNameW, as done by cygwin.
Possible fix:
name.MaximumLength = (size < 0xffff / sizeof(WCHAR) ? size : 0xffff / sizeof(WCHAR)) * sizeof(WCHAR);
Comment from Nikolay Sivov: we could probably min() it in ints, to avoid this 16bit overflow.