The IoSetShareAccess routine sets the access rights for sharing the given file object.
VOID IoSetShareAccess( _In_ ACCESS_MASK DesiredAccess, _In_ ULONG DesiredShareAccess, _Inout_ PFILE_OBJECT FileObject, _Out_ PSHARE_ACCESS ShareAccess );
Specifies the type of share access to be set for the file object. This value can be zero, or any combination of the following:
Pointer to the file object whose share access is being set or reset.
Pointer to the SHARE_ACCESS structure associated with FileObject. Drivers should treat this structure as opaque.
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.
|Windows Driver kit version|
|Minimum KMDF version|
|Minimum UMDF version|
|Header||wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)|
|DDI compliance rules||IrqlIoPassive5, HwStorPortProhibitedDDIs|