[Wine-patches] [2/5] ntdll: Use mountmgr IOCTL handler for removable disks.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пн Дек 1 18:09:33 MSK 2008
----------- следующая часть -----------
From 051b5b94a0590e4772e20a120f9e617c423677e2 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 25 Nov 2008 19:46:38 +0300
Subject: [PATCH] ntdll: Use mountmgr IOCTL handler for removable disks.
---
dlls/ntdll/directory.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 068ed63..12857f8 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -68,6 +68,9 @@
#include "windef.h"
#include "winnt.h"
#include "winternl.h"
+#include "winioctl.h"
+#define WINE_MOUNTMGR_EXTENSIONS
+#include "ddk/mountmgr.h"
#include "ntdll_misc.h"
#include "wine/unicode.h"
#include "wine/server.h"
@@ -1808,6 +1811,46 @@ not_found:
/******************************************************************************
+ * get_drive_type
+ *
+ * Get the Win32 drive type from mountmgr.
+ */
+static DWORD get_drive_type( char letter )
+{
+ HANDLE mgr;
+ struct mountmgr_unix_drive data;
+ NTSTATUS status;
+ OBJECT_ATTRIBUTES attr;
+ UNICODE_STRING name;
+ IO_STATUS_BLOCK io;
+
+ memset( &data, 0, sizeof(data) );
+ data.letter = letter;
+ RtlInitUnicodeString( &name, MOUNTMGR_DEVICE_NAME );
+
+ attr.Length = sizeof(attr);
+ attr.RootDirectory = 0;
+ attr.Attributes = OBJ_CASE_INSENSITIVE;
+ attr.ObjectName = &name;
+ attr.SecurityDescriptor = NULL;
+ attr.SecurityQualityOfService = NULL;
+
+ status = NtCreateFile( &mgr, GENERIC_READ, &attr, &io, NULL, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, NULL, 0 );
+ if (status)
+ return DRIVE_UNKNOWN;
+
+ status = NtDeviceIoControlFile( mgr, NULL, NULL, NULL, &io,
+ IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE, &data,
+ sizeof(data), &data, sizeof(data) );
+ if (status && STATUS_MORE_ENTRIES != status)
+ data.type = DRIVE_UNKNOWN;
+ NtClose( mgr );
+ return data.type;
+}
+
+
+/******************************************************************************
* get_dos_device
*
* Get the Unix path of a DOS device.
@@ -1839,6 +1882,10 @@ static NTSTATUS get_dos_device( const WCHAR *name, UINT name_len, ANSI_STRING *u
/* special case for drive devices */
if (name_len == 2 && dev[1] == ':')
{
+ if (*dev >= 'c' && DRIVE_REMOVABLE == get_drive_type( *dev ))
+ /* return STATUS_BAD_DEVICE_TYPE for removable disk device
+ in order to handle IOCTL with mountmgr */
+ goto bad;
dev[i++] = ':';
dev[i] = 0;
}
@@ -1889,6 +1936,7 @@ static NTSTATUS get_dos_device( const WCHAR *name, UINT name_len, ANSI_STRING *u
unix_len = strlen(unix_name) + 1;
dev = NULL; /* last try */
}
+bad:
RtlFreeHeap( GetProcessHeap(), 0, unix_name );
return STATUS_BAD_DEVICE_TYPE;
}
--
1.6.0.2.GIT
Подробная информация о списке рассылки Wine-patches