[PATCH 0/1] MR8086: wbemprox: Only use IOCTL_DISK_GET_DRIVE_GEOMETRY_EX if GetDiskFreeSpaceExW() fails.
From: Paul Gofman <pgofman(a)codeweavers.com> --- dlls/wbemprox/builtin.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 9e5161755a3..173cba2818f 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -2413,21 +2413,27 @@ done: static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize ) { WCHAR root[] = L"\\\\.\\A:"; - ULARGE_INTEGER free; + ULARGE_INTEGER free, total; DISK_GEOMETRY_EX info; HANDLE handle; DWORD bytes_returned; free.QuadPart = 512 * 1024 * 1024; - GetDiskFreeSpaceExW( dir, NULL, NULL, &free ); - - root[4] = dir[0]; - handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 ); - if (handle != INVALID_HANDLE_VALUE) + if (!GetDiskFreeSpaceExW( dir, NULL, &total, &free )) { - if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL )) - *disksize = info.DiskSize.QuadPart; - CloseHandle( handle ); + *disksize = 0; + root[4] = dir[0]; + handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 ); + if (handle != INVALID_HANDLE_VALUE) + { + if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL )) + *disksize = info.DiskSize.QuadPart; + CloseHandle( handle ); + } + } + else + { + *disksize = total.QuadPart; } return free.QuadPart; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8086
Currently IOCTL_DISK_GET_DRIVE_GEOMETRY_EX handling is a stub in mountmgr.sys returning a hardcoded size. I should've been fixing that part instead of course as that is a lower level query which could at least return a correct total size. But get_freespace() uses IOCTL_DISK_GET_DRIVE_GEOMETRY_EX for other disk types besides physical drive: partition, logical disk and for the latter IOCTL_DISK_GET_DRIVE_GEOMETRY_EX is not applicable. So it seems to me it worth changing in wbemprox regardless. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8086#note_103907
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8086
participants (3)
-
Hans Leidekker (@hans) -
Paul Gofman -
Paul Gofman (@gofman)