3131 * Specifies the type of share access for the device.
3232 *
3333 * @return An NTSTATUS code indicating success or failure.
34+ *
35+ * @see pOpenDeviceEx()
3436 **/
3537NTSTATUS
36- pOpenDeviceEx (
37- _In_ PCWSTR DevicePath ,
38+ pOpenDeviceEx_UStr (
39+ _In_ PCUNICODE_STRING DevicePath ,
3840 _Out_ PHANDLE DeviceHandle ,
3941 _In_ ACCESS_MASK DesiredAccess ,
4042 _In_ ULONG ShareAccess )
4143{
42- UNICODE_STRING Name ;
4344 OBJECT_ATTRIBUTES ObjectAttributes ;
4445 IO_STATUS_BLOCK IoStatusBlock ;
4546
46- RtlInitUnicodeString (& Name , DevicePath );
4747 InitializeObjectAttributes (& ObjectAttributes ,
48- & Name ,
48+ ( PUNICODE_STRING ) DevicePath ,
4949 OBJ_CASE_INSENSITIVE ,
5050 NULL ,
5151 NULL );
@@ -66,22 +66,72 @@ pOpenDeviceEx(
6666 *
6767 * @param[in] DevicePath
6868 * @param[out] DeviceHandle
69- * See the DevicePath and DeviceHandle parameters of pOpenDeviceEx ().
69+ * See the DevicePath and DeviceHandle parameters of pOpenDeviceEx_UStr ().
7070 *
7171 * @return An NTSTATUS code indicating success or failure.
7272 *
73- * @see pOpenDeviceEx()
73+ * @see pOpenDevice(), pOpenDeviceEx(), pOpenDeviceEx_UStr()
74+ **/
75+ NTSTATUS
76+ pOpenDevice_UStr (
77+ _In_ PCUNICODE_STRING DevicePath ,
78+ _Out_ PHANDLE DeviceHandle )
79+ {
80+ return pOpenDeviceEx_UStr (DevicePath ,
81+ DeviceHandle ,
82+ FILE_READ_DATA | FILE_READ_ATTRIBUTES ,
83+ FILE_SHARE_ALL );
84+ }
85+
86+ /**
87+ * @brief
88+ * Open an existing device given by its NT-style path, which is assumed to be
89+ * for a disk device or a partition. The open is for synchronous I/O access.
90+ *
91+ * @param[in] DevicePath
92+ * @param[out] DeviceHandle
93+ * @param[in] DesiredAccess
94+ * @param[in] ShareAccess
95+ * See pOpenDeviceEx_UStr() parameters.
96+ *
97+ * @return An NTSTATUS code indicating success or failure.
98+ *
99+ * @see pOpenDeviceEx_UStr()
100+ **/
101+ NTSTATUS
102+ pOpenDeviceEx (
103+ _In_ PCWSTR DevicePath ,
104+ _Out_ PHANDLE DeviceHandle ,
105+ _In_ ACCESS_MASK DesiredAccess ,
106+ _In_ ULONG ShareAccess )
107+ {
108+ UNICODE_STRING Name ;
109+ RtlInitUnicodeString (& Name , DevicePath );
110+ return pOpenDeviceEx_UStr (& Name , DeviceHandle , DesiredAccess , ShareAccess );
111+ }
112+
113+ /**
114+ * @brief
115+ * Open an existing device given by its NT-style path, which is assumed to be
116+ * for a disk device or a partition. The open is share read/write/delete, for
117+ * synchronous I/O and read access.
118+ *
119+ * @param[in] DevicePath
120+ * @param[out] DeviceHandle
121+ * See the DevicePath and DeviceHandle parameters of pOpenDeviceEx_UStr().
122+ *
123+ * @return An NTSTATUS code indicating success or failure.
124+ *
125+ * @see pOpenDeviceEx(), pOpenDevice_UStr(), pOpenDeviceEx_UStr()
74126 **/
75127NTSTATUS
76128pOpenDevice (
77129 _In_ PCWSTR DevicePath ,
78130 _Out_ PHANDLE DeviceHandle )
79131{
80- return pOpenDeviceEx (DevicePath ,
81- DeviceHandle ,
82- FILE_READ_DATA | FILE_READ_ATTRIBUTES ,
83- FILE_SHARE_VALID_FLAGS // FILE_SHARE_READ,WRITE,DELETE
84- );
132+ UNICODE_STRING Name ;
133+ RtlInitUnicodeString (& Name , DevicePath );
134+ return pOpenDevice_UStr (& Name , DeviceHandle );
85135}
86136
87137/* EOF */
0 commit comments