IoCheckShareAccess

NTSTATUS
    IoCheckShareAccess(

        IN ACCESS_MASK  DesiredAccess,
        IN ULONG  DesiredShareAccess,
        IN OUT PFILE_OBJECT  FileObject,
        IN OUT PSHARE_ACCESS  ShareAccess,
        IN BOOLEAN  Update
        );

IoCheckShareAccess is called by FSDs or other highest-level drivers to check whether shared access to a file object is permitted.

Parameters

DesiredAccess
Specifies the type(s) of access to the given FileObject for the current open request. Generally, the value of this parameter is equal to the DesiredAccess passed to the file system or highest-level driver by the I/O manager when an open request is made.
DesiredShareAccess
Specifies the type(s) of shared access to the file object for the current open request. This parameter is generally identical to the ShareAccess that was passed to the file system or highest-level driver by the I/O Manager when the open request was made.
FileObject
Points to the file object, to which accesses are to be checked for the current open request.
ShareAccess
Points to the common share-access data structure associated with the file object being opened. This structure is treated as an opaque type by drivers.
Update
Specifies whether or not the system should update the share-access status of the specified file object. A Boolean value of TRUE means the share access information for the file is to be updated if the open request is permitted.

Return Value

IoCheckShareAccess returns STATUS_SUCCESS if the requestor’s access to the file object is compatible with the way in which it is currently open. If the request is denied because of a sharing violation, then STATUS_SHARING_VIOLATION is returned.

Comments

IoCheckShareAccess checks a file object open request to determine whether the types of desired and shared accesses specified are compatible with the way in which the file object is currently being accessed by other opens.

File systems maintain state about files through structures called file control blocks (FCBs). The SHARE_ACCESS is a structure describing how the file is currently accessed by all opens. This state is contained in the FCB as part of the open state for each file object. Other highest-level drivers might call this routine to check the access requested when a file object representing such a driver’s device object is opened.

Callers of IoCheckShareAccess must be running at IRQL PASSIVE_LEVEL.

See Also

IoGetRelatedDeviceObject, IoRemoveShareAccess, IoSetShareAccess, IoUpdateShareAccess