Add a workaround for Win9x apps which pass the parameters for

GetCurrentDirectoryA in wrong order.
This commit is contained in:
Felix Nawothnig 2005-06-12 10:41:22 +00:00 committed by Alexandre Julliard
parent db134ece39
commit 8b5c8f6d7f
1 changed files with 11 additions and 0 deletions

View File

@ -1313,6 +1313,17 @@ UINT WINAPI GetCurrentDirectoryA( UINT buflen, LPSTR buf )
WCHAR bufferW[MAX_PATH];
DWORD ret;
if (buflen && buf && !HIWORD(buf))
{
/* Win9x catches access violations here, returning zero.
* This behaviour resulted in some people not noticing
* that they got the argument order wrong. So let's be
* nice and fail gracefully if buf is invalid and looks
* more like a buflen (which is probably MAX_PATH). */
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
ret = GetCurrentDirectoryW(MAX_PATH, bufferW);
if (!ret) return 0;