[NTOSKRNL] Implement IoComputeDesiredAccessFileObject() based on checks performed in NtFlushBuffersFile()

CORE-14003
This commit is contained in:
Pierre Schweitzer 2017-11-12 22:26:18 +01:00
parent da8134527b
commit 7eefe70294
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
2 changed files with 34 additions and 0 deletions

View file

@ -1230,6 +1230,13 @@ IopDoNameTransmogrify(
IN PREPARSE_DATA_BUFFER DataBuffer
);
NTSTATUS
NTAPI
IoComputeDesiredAccessFileObject(
IN PFILE_OBJECT FileObject,
IN PACCESS_MASK DesiredAccess
);
//
// I/O Timer Routines
//

View file

@ -19,6 +19,33 @@ NTAPI
RtlpGetStackLimits(PULONG_PTR StackBase,
PULONG_PTR StackLimit);
/* PRIVATE FUNCTIONS *********************************************************/
NTSTATUS
NTAPI
IoComputeDesiredAccessFileObject(IN PFILE_OBJECT FileObject,
IN PACCESS_MASK DesiredAccess)
{
/* Assume failure */
*DesiredAccess = 0;
/* First check we really have a FileObject */
if (OBJECT_TO_OBJECT_HEADER(FileObject)->Type != IoFileObjectType)
{
return STATUS_OBJECT_TYPE_MISMATCH;
}
/* Then compute desired access:
* Check if the handle has either FILE_WRITE_DATA or FILE_APPEND_DATA was
* granted. However, if this is a named pipe, make sure we don't ask for
* FILE_APPEND_DATA as it interferes with the FILE_CREATE_PIPE_INSTANCE
* access right!
*/
*DesiredAccess = ((!(FileObject->Flags & FO_NAMED_PIPE) ? FILE_APPEND_DATA : 0) | FILE_WRITE_DATA);
return STATUS_SUCCESS;
}
/* FUNCTIONS *****************************************************************/
/*