https://bugs.winehq.org/show_bug.cgi?id=49344
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- (In reply to Arne de Bruijn from comment #2)
This change 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);
Please file a bug report for that, we could probably min() it in ints, to avoid this 16bit overflow.