From: Jérôme Gardou Date: Thu, 6 Feb 2014 22:10:44 +0000 (+0000) Subject: [KERNEL32] X-Git-Tag: ReactOS-0.3.16-CLT2014~282 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=116102fec2816d2f0a574848e3b41cd7571a745a [KERNEL32] - Use current directory for NULL parameter in GetDriveType Patch by Kenneth Deane (kde678 __AT__ gmail __DOT__ com), slightly modified by myself. Thanks! svn path=/trunk/; revision=62019 --- diff --git a/reactos/dll/win32/kernel32/client/file/disk.c b/reactos/dll/win32/kernel32/client/file/disk.c index 23972478ed6..2dbdb1636a9 100644 --- a/reactos/dll/win32/kernel32/client/file/disk.c +++ b/reactos/dll/win32/kernel32/client/file/disk.c @@ -360,6 +360,9 @@ GetDriveTypeA(IN LPCSTR lpRootPathName) { PWCHAR RootPathNameW; + if (!lpRootPathName) + return GetDriveTypeW(NULL); + if (!(RootPathNameW = FilenameA2W(lpRootPathName, FALSE))) return DRIVE_UNKNOWN; @@ -373,13 +376,31 @@ UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName) { - FILE_FS_DEVICE_INFORMATION FileFsDevice; - IO_STATUS_BLOCK IoStatusBlock; + FILE_FS_DEVICE_INFORMATION FileFsDevice; + IO_STATUS_BLOCK IoStatusBlock; + HANDLE hFile; + NTSTATUS errCode; - HANDLE hFile; - NTSTATUS errCode; + if (!lpRootPathName) + { + /* If NULL is passed, use current directory path */ + DWORD BufferSize = GetCurrentDirectoryW(0, NULL); + LPWSTR CurrentDir = HeapAlloc(GetProcessHeap(), 0, BufferSize * sizeof(WCHAR)); + if (!CurrentDir) + return DRIVE_UNKNOWN; + if (!GetCurrentDirectoryW(BufferSize, CurrentDir)) + { + HeapFree(GetProcessHeap(), 0, CurrentDir); + return DRIVE_UNKNOWN; + } + hFile = InternalOpenDirW(CurrentDir, FALSE); + HeapFree(GetProcessHeap(), 0, CurrentDir); + } + else + { + hFile = InternalOpenDirW(lpRootPathName, FALSE); + } - hFile = InternalOpenDirW(lpRootPathName, FALSE); if (hFile == INVALID_HANDLE_VALUE) { return DRIVE_NO_ROOT_DIR; /* According to WINE regression tests */