Small fix for GetCurrentDirectoryA()

Felix Nawothnig felix.nawothnig at t-online.de
Fri Jun 10 14:12:08 CDT 2005


ChangeLog:
Add a workaround for Win9x apps which pass the parameters for 
GetCurrentDirectoryA in wrong order.
-------------- next part --------------
Index: path.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/path.c,v
retrieving revision 1.19
diff -u -r1.19 path.c
--- path.c	1 Mar 2005 10:42:22 -0000	1.19
+++ path.c	10 Jun 2005 19:10:48 -0000
@@ -1313,6 +1313,18 @@
     WCHAR bufferW[MAX_PATH];
     DWORD ret;
 
+    if (buflen && buf && (ULONG)buf < 0x10000)
+    {
+        /* 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;


More information about the wine-patches mailing list