mirror of https://github.com/decompals/wibo.git
Handle GetCurrentDirectory required buffer size return value (#27)
When the output buffer size is too small, GetCurrentDirectory does nothing and simply returns the larger required size. https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory#return-value Needed to run Code Warrior 4 mwcc.exe with no arguments, displaying usage/help message. (Still unable to compile/preprocess with CW4 mwcc.exe)
This commit is contained in:
parent
681137902b
commit
635de4fa93
|
@ -932,7 +932,11 @@ namespace kernel32 {
|
||||||
std::filesystem::path cwd = std::filesystem::current_path();
|
std::filesystem::path cwd = std::filesystem::current_path();
|
||||||
std::string path = files::pathToWindows(cwd);
|
std::string path = files::pathToWindows(cwd);
|
||||||
|
|
||||||
assert(path.size() < uSize);
|
// If the buffer is too small, return the required buffer size.
|
||||||
|
// (Add 1 to include the NUL terminator)
|
||||||
|
if (path.size() + 1 > uSize) {
|
||||||
|
return path.size() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(lpBuffer, path.c_str());
|
strcpy(lpBuffer, path.c_str());
|
||||||
return path.size();
|
return path.size();
|
||||||
|
|
Loading…
Reference in New Issue