Author: dchapyshev
Date: Tue Aug 30 19:22:00 2016
New Revision: 72512
URL:
http://svn.reactos.org/svn/reactos?rev=72512&view=rev
Log:
[KERNEL32]
- Failure if does not come to an end a way with a symbol '\' (exception - a path
of a looks like 'C:')
* Fixes 2 tests for kernel32_apitest GetDriveType (all tests for GetDriveType passed now)
Modified:
trunk/reactos/dll/win32/kernel32/client/file/disk.c
Modified: trunk/reactos/dll/win32/kernel32/client/file/disk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/file/disk.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/file/disk.c [iso-8859-1] Tue Aug 30 19:22:00
2016
@@ -19,6 +19,8 @@
*/
#include <k32.h>
+#include <strsafe.h>
+
#define NDEBUG
#include <debug.h>
DEBUG_CHANNEL(kernel32file);
@@ -401,12 +403,35 @@
if (wcslen(CurrentDir) > 3)
CurrentDir[3] = 0;
- lpRootPath = (PCWSTR)CurrentDir;
+ lpRootPath = CurrentDir;
}
else
{
+ size_t Length = wcslen(lpRootPathName);
+
TRACE("lpRootPathName: %S\n", lpRootPathName);
- lpRootPath = lpRootPathName;
+
+ if (Length == 2)
+ {
+ WCHAR DriveLetter = RtlUpcaseUnicodeChar(lpRootPathName[0]);
+
+ if (DriveLetter >= L'A' && DriveLetter <= L'Z'
&& lpRootPathName[1] == L':')
+ {
+ Length = (Length + 2) * sizeof(WCHAR);
+
+ CurrentDir = HeapAlloc(GetProcessHeap(), 0, Length);
+ if (!CurrentDir)
+ return DRIVE_UNKNOWN;
+
+ StringCbPrintfW(CurrentDir, Length, L"%s\\", lpRootPathName);
+
+ lpRootPath = CurrentDir;
+ }
+ }
+ else
+ {
+ lpRootPath = lpRootPathName;
+ }
}
TRACE("lpRootPath: %S\n", lpRootPath);
@@ -423,6 +448,11 @@
if (CurrentDir != NULL)
HeapFree(GetProcessHeap(), 0, CurrentDir);
+
+ if (PathName.Buffer[(PathName.Length >> 1) - 1] != L'\\')
+ {
+ return DRIVE_NO_ROOT_DIR;
+ }
InitializeObjectAttributes(&ObjectAttributes,
&PathName,
@@ -436,6 +466,7 @@
&IoStatusBlock,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_SYNCHRONOUS_IO_NONALERT);
+
RtlFreeHeap(RtlGetProcessHeap(), 0, PathName.Buffer);
if (!NT_SUCCESS(Status))
return DRIVE_NO_ROOT_DIR; /* According to WINE regression tests */
@@ -453,19 +484,19 @@
switch (FileFsDevice.DeviceType)
{
- case FILE_DEVICE_CD_ROM:
- case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
- return DRIVE_CDROM;
- case FILE_DEVICE_VIRTUAL_DISK:
- return DRIVE_RAMDISK;
- case FILE_DEVICE_NETWORK_FILE_SYSTEM:
- return DRIVE_REMOTE;
- case FILE_DEVICE_DISK:
- case FILE_DEVICE_DISK_FILE_SYSTEM:
- if (FileFsDevice.Characteristics & FILE_REMOTE_DEVICE)
+ case FILE_DEVICE_CD_ROM:
+ case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
+ return DRIVE_CDROM;
+ case FILE_DEVICE_VIRTUAL_DISK:
+ return DRIVE_RAMDISK;
+ case FILE_DEVICE_NETWORK_FILE_SYSTEM:
return DRIVE_REMOTE;
- if (FileFsDevice.Characteristics & FILE_REMOVABLE_MEDIA)
- return DRIVE_REMOVABLE;
+ case FILE_DEVICE_DISK:
+ case FILE_DEVICE_DISK_FILE_SYSTEM:
+ if (FileFsDevice.Characteristics & FILE_REMOTE_DEVICE)
+ return DRIVE_REMOTE;
+ if (FileFsDevice.Characteristics & FILE_REMOVABLE_MEDIA)
+ return DRIVE_REMOVABLE;
return DRIVE_FIXED;
}