From 8b5c8f6d7f74d9172254fe49c59dcb0a6c7a8213 Mon Sep 17 00:00:00 2001 From: Felix Nawothnig Date: Sun, 12 Jun 2005 10:41:22 +0000 Subject: [PATCH] Add a workaround for Win9x apps which pass the parameters for GetCurrentDirectoryA in wrong order. --- dlls/kernel/path.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dlls/kernel/path.c b/dlls/kernel/path.c index 8461ce9b3af..96db4ec34da 100644 --- a/dlls/kernel/path.c +++ b/dlls/kernel/path.c @@ -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;