mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 16:10:29 +00:00
[SETUPLIB] Add UNICODE_STRING versions of the pOpenDevice helpers (#7310)
+ Use a FILE_SHARE_ALL define. Based on a suggestion from Whindmar Saksit.
This commit is contained in:
parent
1d3bce1a59
commit
ad5d9aa28a
2 changed files with 79 additions and 12 deletions
|
@ -31,21 +31,21 @@
|
||||||
* Specifies the type of share access for the device.
|
* Specifies the type of share access for the device.
|
||||||
*
|
*
|
||||||
* @return An NTSTATUS code indicating success or failure.
|
* @return An NTSTATUS code indicating success or failure.
|
||||||
|
*
|
||||||
|
* @see pOpenDeviceEx()
|
||||||
**/
|
**/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
pOpenDeviceEx(
|
pOpenDeviceEx_UStr(
|
||||||
_In_ PCWSTR DevicePath,
|
_In_ PCUNICODE_STRING DevicePath,
|
||||||
_Out_ PHANDLE DeviceHandle,
|
_Out_ PHANDLE DeviceHandle,
|
||||||
_In_ ACCESS_MASK DesiredAccess,
|
_In_ ACCESS_MASK DesiredAccess,
|
||||||
_In_ ULONG ShareAccess)
|
_In_ ULONG ShareAccess)
|
||||||
{
|
{
|
||||||
UNICODE_STRING Name;
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
|
||||||
RtlInitUnicodeString(&Name, DevicePath);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&Name,
|
(PUNICODE_STRING)DevicePath,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -66,22 +66,72 @@ pOpenDeviceEx(
|
||||||
*
|
*
|
||||||
* @param[in] DevicePath
|
* @param[in] DevicePath
|
||||||
* @param[out] DeviceHandle
|
* @param[out] DeviceHandle
|
||||||
* See the DevicePath and DeviceHandle parameters of pOpenDeviceEx().
|
* See the DevicePath and DeviceHandle parameters of pOpenDeviceEx_UStr().
|
||||||
*
|
*
|
||||||
* @return An NTSTATUS code indicating success or failure.
|
* @return An NTSTATUS code indicating success or failure.
|
||||||
*
|
*
|
||||||
* @see pOpenDeviceEx()
|
* @see pOpenDevice(), pOpenDeviceEx(), pOpenDeviceEx_UStr()
|
||||||
|
**/
|
||||||
|
NTSTATUS
|
||||||
|
pOpenDevice_UStr(
|
||||||
|
_In_ PCUNICODE_STRING DevicePath,
|
||||||
|
_Out_ PHANDLE DeviceHandle)
|
||||||
|
{
|
||||||
|
return pOpenDeviceEx_UStr(DevicePath,
|
||||||
|
DeviceHandle,
|
||||||
|
FILE_READ_DATA | FILE_READ_ATTRIBUTES,
|
||||||
|
FILE_SHARE_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Open an existing device given by its NT-style path, which is assumed to be
|
||||||
|
* for a disk device or a partition. The open is for synchronous I/O access.
|
||||||
|
*
|
||||||
|
* @param[in] DevicePath
|
||||||
|
* @param[out] DeviceHandle
|
||||||
|
* @param[in] DesiredAccess
|
||||||
|
* @param[in] ShareAccess
|
||||||
|
* See pOpenDeviceEx_UStr() parameters.
|
||||||
|
*
|
||||||
|
* @return An NTSTATUS code indicating success or failure.
|
||||||
|
*
|
||||||
|
* @see pOpenDeviceEx_UStr()
|
||||||
|
**/
|
||||||
|
NTSTATUS
|
||||||
|
pOpenDeviceEx(
|
||||||
|
_In_ PCWSTR DevicePath,
|
||||||
|
_Out_ PHANDLE DeviceHandle,
|
||||||
|
_In_ ACCESS_MASK DesiredAccess,
|
||||||
|
_In_ ULONG ShareAccess)
|
||||||
|
{
|
||||||
|
UNICODE_STRING Name;
|
||||||
|
RtlInitUnicodeString(&Name, DevicePath);
|
||||||
|
return pOpenDeviceEx_UStr(&Name, DeviceHandle, DesiredAccess, ShareAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Open an existing device given by its NT-style path, which is assumed to be
|
||||||
|
* for a disk device or a partition. The open is share read/write/delete, for
|
||||||
|
* synchronous I/O and read access.
|
||||||
|
*
|
||||||
|
* @param[in] DevicePath
|
||||||
|
* @param[out] DeviceHandle
|
||||||
|
* See the DevicePath and DeviceHandle parameters of pOpenDeviceEx_UStr().
|
||||||
|
*
|
||||||
|
* @return An NTSTATUS code indicating success or failure.
|
||||||
|
*
|
||||||
|
* @see pOpenDeviceEx(), pOpenDevice_UStr(), pOpenDeviceEx_UStr()
|
||||||
**/
|
**/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
pOpenDevice(
|
pOpenDevice(
|
||||||
_In_ PCWSTR DevicePath,
|
_In_ PCWSTR DevicePath,
|
||||||
_Out_ PHANDLE DeviceHandle)
|
_Out_ PHANDLE DeviceHandle)
|
||||||
{
|
{
|
||||||
return pOpenDeviceEx(DevicePath,
|
UNICODE_STRING Name;
|
||||||
DeviceHandle,
|
RtlInitUnicodeString(&Name, DevicePath);
|
||||||
FILE_READ_DATA | FILE_READ_ATTRIBUTES,
|
return pOpenDevice_UStr(&Name, DeviceHandle);
|
||||||
FILE_SHARE_VALID_FLAGS // FILE_SHARE_READ,WRITE,DELETE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -7,8 +7,25 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
/* Flags combination allowing all the read, write and delete share modes.
|
||||||
|
* Currently similar to FILE_SHARE_VALID_FLAGS. */
|
||||||
|
#define FILE_SHARE_ALL \
|
||||||
|
(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
pOpenDeviceEx_UStr(
|
||||||
|
_In_ PCUNICODE_STRING DevicePath,
|
||||||
|
_Out_ PHANDLE DeviceHandle,
|
||||||
|
_In_ ACCESS_MASK DesiredAccess,
|
||||||
|
_In_ ULONG ShareAccess);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
pOpenDevice_UStr(
|
||||||
|
_In_ PCUNICODE_STRING DevicePath,
|
||||||
|
_Out_ PHANDLE DeviceHandle);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
pOpenDeviceEx(
|
pOpenDeviceEx(
|
||||||
_In_ PCWSTR DevicePath,
|
_In_ PCWSTR DevicePath,
|
||||||
|
|
Loading…
Reference in a new issue