The current implementation of the GetDriveTypeW/A function relies on native system calls (such as fstatfs() in Linux) to determine the actual type of the drive, disregarding any configuration set through the mounts manager (wincfg). This patch changes the priority, giving precedence to the mounts manager configuration, making the user responsible for mapping drives. System calls will only be used if the drive is not explicitly configured by the user. I acknowledge that this is a breaking change, but I believe it enforces the correct behavior for GetDriveType.
Resolves: https://forum.winehq.org/viewtopic.php?t=38909
-- v2: fix: passing wrong roots for get_mountmgr_drive_type
From: robert robert.ayrapetyan@gmail.com
--- dlls/kernelbase/volume.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/kernelbase/volume.c b/dlls/kernelbase/volume.c index d4895228525..1ee93d1e6b1 100644 --- a/dlls/kernelbase/volume.c +++ b/dlls/kernelbase/volume.c @@ -580,13 +580,13 @@ UINT WINAPI DECLSPEC_HOTPATCH GetDriveTypeW( LPCWSTR root ) HANDLE handle; UINT ret;
+ ret = get_mountmgr_drive_type( root ); + if (ret != DRIVE_UNKNOWN) { + return ret; + } + if (!open_device_root( root, &handle )) { - /* CD ROM devices do not necessarily have a volume, but a drive type */ - ret = get_mountmgr_drive_type( root ); - if (ret == DRIVE_CDROM || ret == DRIVE_REMOVABLE) - return ret; - return DRIVE_NO_ROOT_DIR; }
From: robert robert.ayrapetyan@gmail.com
--- dlls/kernelbase/volume.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/kernelbase/volume.c b/dlls/kernelbase/volume.c index 1ee93d1e6b1..3759a60dfa8 100644 --- a/dlls/kernelbase/volume.c +++ b/dlls/kernelbase/volume.c @@ -127,7 +127,11 @@ static DWORD get_mountmgr_drive_type( LPCWSTR root ) DWORD br;
memset( &data, 0, sizeof(data) ); - if (root) data.letter = root[0]; + if (root) + { + if (strlen(root) < 3 || root[1] != ':' || root[2] != '\') return DRIVE_UNKNOWN; + data.letter = root[0]; + } else { WCHAR curdir[MAX_PATH];