IoSetShareAccess function (wdm.h)
The IoSetShareAccess routine sets the access rights for sharing the given file object.
Syntax
void IoSetShareAccess(
[in] ACCESS_MASK DesiredAccess,
[in] ULONG DesiredShareAccess,
[in, out] PFILE_OBJECT FileObject,
[out] PSHARE_ACCESS ShareAccess
);
Parameters
[in] DesiredAccess
Specifies an ACCESS_MASK value that represents the type of access requested for the FileObject. See IoCreateFile for a complete list of system-defined DesiredAccess flags.
[in] DesiredShareAccess
Specifies the type of share access to be set for the file object. This value can be zero, or any combination of the following:
FILE_SHARE_READ
FILE_SHARE_WRITE
FILE_SHARE_DELETE
[in, out] FileObject
Pointer to the file object whose share access is being set or reset.
[out] ShareAccess
Pointer to the SHARE_ACCESS structure associated with FileObject. Drivers should treat this structure as opaque.
Return value
None
Remarks
Only highest-level kernel-mode drivers should call this routine. The call must occur in the context of the first thread that attempts to open the FileObject.
This routine sets the access and share access information when the FileObject is first opened. It returns a pointer to the common share-access data structure associated with FileObject. Callers should save this pointer for later use when updating the access or closing the file.
Generally, file system drivers (FSDs) are most likely to call this routine. However, other highest-level drivers can call IoSetShareAccess to control the kind of access allowed to a driver-created device object associated with the given FileObject.
IoSetShareAccess is not an atomic operation. Therefore, drivers calling this routine must protect the shared file object passed to IoSetShareAccess by means of some kind of lock, such as a mutex or a resource lock, in order to prevent corruption of the shared access counts.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Available starting with Windows 2000. |
Target Platform | Universal |
Header | wdm.h (include Wdm.h, Ntddk.h, Ntifs.h) |
Library | NtosKrnl.lib |
DLL | NtosKrnl.exe |
IRQL | PASSIVE_LEVEL |
DDI compliance rules | HwStorPortProhibitedDDIs(storport), IrqlIoPassive5(wdm) |