https://git.reactos.org/?p=reactos.git;a=commitdiff;h=32e65f2f8d0445fbb9389…
commit 32e65f2f8d0445fbb93893487fc6fc4fccc0f3ff
Author: Adam Słaboń <asaillen(a)protonmail.com>
AuthorDate: Sun Mar 3 21:02:06 2024 +0100
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 7 11:16:03 2024 +0200
[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,
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c5a9f22d4eab1b36a240e…
commit c5a9f22d4eab1b36a240ef306ec927784219d111
Author: Adam Słaboń <asaillen(a)protonmail.com>
AuthorDate: Sat Mar 2 23:56:51 2024 +0100
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Oct 7 11:16:03 2024 +0200
[FORMAT] Use QueryDeviceInformation for retrieving the volume size before formatting it
QueryDeviceInformation returns more reliable volume length and works
with unformatted volumes. It will return volume length only on ROS and Vista+ however,
so also keep the GetFreeDiskSpaceExW as a fallback for XP/2003.
---
base/system/format/format.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/base/system/format/format.c b/base/system/format/format.c
index 0d7e642c598..c8805af5e69 100644
--- a/base/system/format/format.c
+++ b/base/system/format/format.c
@@ -360,6 +360,7 @@ static VOID Usage(LPWSTR ProgramName)
int wmain(int argc, WCHAR *argv[])
{
int badArg;
+ DEVICE_INFORMATION DeviceInformation = {0};
FMIFS_MEDIA_FLAG media = FMIFS_HARDDISK;
DWORD driveType;
WCHAR fileSystem[1024];
@@ -479,7 +480,19 @@ int wmain(int argc, WCHAR *argv[])
return -1;
}
- if (!GetDiskFreeSpaceExW(RootDirectory,
+ if (QueryDeviceInformation(RootDirectory,
+ &DeviceInformation,
+ sizeof(DeviceInformation)))
+ {
+ totalNumberOfBytes.QuadPart = DeviceInformation.SectorSize *
+ DeviceInformation.SectorCount.QuadPart;
+ }
+
+ /* QueryDeviceInformation returns more accurate volume length and works with
+ * unformatted volumes, however it will NOT return volume length on XP/2003.
+ * Fallback to GetFreeDiskSpaceExW if we did not get any volume length. */
+ if (totalNumberOfBytes.QuadPart == 0 &&
+ !GetDiskFreeSpaceExW(RootDirectory,
&freeBytesAvailableToCaller,
&totalNumberOfBytes,
&totalNumberOfFreeBytes))