From 32e65f2f8d0445fbb93893487fc6fc4fccc0f3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20S=C5=82abo=C5=84?= Date: Sun, 3 Mar 2024 21:02:06 +0100 Subject: [PATCH] [KERNEL32] GetDriveTypeW: Fix the case with unformatted volumes and volume GUID names Fix the case when GetDriveTypeW would return DRIVE_NO_ROOT_DIR when it got a volume GUID name and had to access an unformatted volume. Fixes Rufus not being able to find an unformatted volume after writting new MBR. --- dll/win32/kernel32/client/file/disk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dll/win32/kernel32/client/file/disk.c b/dll/win32/kernel32/client/file/disk.c index 12751c6b1ad..07d0c15b85e 100644 --- a/dll/win32/kernel32/client/file/disk.c +++ b/dll/win32/kernel32/client/file/disk.c @@ -608,6 +608,9 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName) return DRIVE_NO_ROOT_DIR; } + /* We will work with a device object, so trim the trailing backslash now */ + PathName.Length -= sizeof(WCHAR); + /* Let's probe for it, by forcing open failure! */ RetryOpen = TRUE; InitializeObjectAttributes(&ObjectAttributes, &PathName,