@apolukhin I believe this fix is incorrect. Per the documentation from GetModuleFileNameW (emphasis mine):
If the function succeeds, the return value is the length of the string that is copied to the buffer, in characters, not including the terminating null character. If the buffer is too small to hold the module name, the string is truncated to nSize characters including the terminating null character, the function returns nSize, and the function sets the last error to ERROR_INSUFFICIENT_BUFFER.
The important thing to note here is that the returned size can be non-zero even in failure cases. This appears to not be handled any more, which is the entire purpose of that loop which grows the buffer on each iteration afaict.
Likely the original structure of the code was correct, but what it meant to do instead of calling GetLastError was this:
SetLastError(0);
Previous issue: https://github.com/apolukhin/Boost.DLL/issues/57 PR which was intending to fix that issue: https://github.com/apolukhin/Boost.DLL/pull/59
@apolukhin I believe this fix is incorrect. Per the documentation from GetModuleFileNameW (emphasis mine):
The important thing to note here is that the returned size can be non-zero even in failure cases. This appears to not be handled any more, which is the entire purpose of that loop which grows the buffer on each iteration afaict.
Likely the original structure of the code was correct, but what it meant to do instead of calling GetLastError was this:
SetLastError(0);