2015-09-11 04:02:21 +00:00
|
|
|
/*++
|
|
|
|
|
|
|
|
Copyright (c) 1989-2000 Microsoft Corporation
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
|
|
|
|
FilObSup.c
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
|
|
|
|
This module implements the Cdfs File object support routines.
|
|
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
#include "cdprocs.h"
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// The Bug check file id for this module
|
|
|
|
//
|
|
|
|
|
|
|
|
#define BugCheckFileId (CDFS_BUG_CHECK_FILOBSUP)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Local constants.
|
|
|
|
//
|
|
|
|
|
|
|
|
#define TYPE_OF_OPEN_MASK (0x00000007)
|
|
|
|
|
|
|
|
#ifdef ALLOC_PRAGMA
|
|
|
|
#pragma alloc_text(PAGE, CdDecodeFileObject)
|
|
|
|
#pragma alloc_text(PAGE, CdFastDecodeFileObject)
|
|
|
|
#pragma alloc_text(PAGE, CdSetFileObject)
|
|
|
|
#endif
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
|
|
|
|
_When_(TypeOfOpen == UnopenedFileObject, _At_(Fcb, _In_opt_))
|
|
|
|
_When_(TypeOfOpen != UnopenedFileObject, _At_(Fcb, _In_))
|
2015-09-11 04:02:21 +00:00
|
|
|
VOID
|
|
|
|
CdSetFileObject (
|
2017-11-23 20:02:16 +00:00
|
|
|
_In_ PIRP_CONTEXT IrpContext,
|
|
|
|
_Inout_ PFILE_OBJECT FileObject,
|
|
|
|
_In_ TYPE_OF_OPEN TypeOfOpen,
|
|
|
|
PFCB Fcb,
|
|
|
|
_In_opt_ PCCB Ccb
|
2015-09-11 04:02:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
This routine will initialize the FileObject context fields based on the
|
|
|
|
input type and data structures.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
FileObject - Supplies the file object pointer being initialized.
|
|
|
|
|
|
|
|
TypeOfOpen - Sets the type of open.
|
|
|
|
|
|
|
|
Fcb - Fcb for this file object. Ignored for UnopenedFileObject.
|
|
|
|
|
|
|
|
Ccb - Ccb for the handle corresponding to this file object. Will not
|
|
|
|
be present for stream file objects.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
{
|
|
|
|
PAGED_CODE();
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
UNREFERENCED_PARAMETER( IrpContext );
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
//
|
|
|
|
// We only have values 0 to 7 available so make sure we didn't
|
|
|
|
// inadvertantly add a new type.
|
|
|
|
//
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
NT_ASSERTMSG( "FileObject types exceed available bits\n", BeyondValidType <= 8 );
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Setting a file object to type UnopenedFileObject means just
|
|
|
|
// clearing all of the context fields. All the other input
|
|
|
|
//
|
|
|
|
|
|
|
|
if (TypeOfOpen == UnopenedFileObject) {
|
|
|
|
|
|
|
|
FileObject->FsContext =
|
|
|
|
FileObject->FsContext2 = NULL;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check that the 3 low-order bits of the Ccb are clear.
|
|
|
|
//
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
NT_ASSERTMSG( "Ccb is not quad-aligned\n", !FlagOn( ((ULONG_PTR) Ccb), TYPE_OF_OPEN_MASK ));
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// We will or the type of open into the low order bits of FsContext2
|
|
|
|
// along with the Ccb value.
|
|
|
|
// The Fcb is stored into the FsContext field.
|
|
|
|
//
|
|
|
|
|
|
|
|
FileObject->FsContext = Fcb;
|
|
|
|
FileObject->FsContext2 = Ccb;
|
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
#ifdef _MSC_VER
|
2017-11-23 20:02:16 +00:00
|
|
|
#pragma warning( suppress: 4213 )
|
2017-11-23 20:05:28 +00:00
|
|
|
#endif
|
|
|
|
SetFlag( (*(PULONG_PTR)&FileObject->FsContext2), TypeOfOpen ); /* ReactOS Change: GCC "invalid lvalue in assignment" */
|
2015-09-11 04:02:21 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Set the Vpb field in the file object.
|
|
|
|
//
|
|
|
|
|
|
|
|
FileObject->Vpb = Fcb->Vcb->Vpb;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
_When_(return == UnopenedFileObject, _At_(*Fcb, _Post_null_))
|
|
|
|
_When_(return != UnopenedFileObject, _At_(Fcb, _Outptr_))
|
|
|
|
_When_(return == UnopenedFileObject, _At_(*Ccb, _Post_null_))
|
|
|
|
_When_(return != UnopenedFileObject, _At_(Ccb, _Outptr_))
|
2015-09-11 04:02:21 +00:00
|
|
|
TYPE_OF_OPEN
|
|
|
|
CdDecodeFileObject (
|
2017-11-23 20:02:16 +00:00
|
|
|
_In_ PIRP_CONTEXT IrpContext,
|
|
|
|
_In_ PFILE_OBJECT FileObject,
|
|
|
|
PFCB *Fcb,
|
|
|
|
PCCB *Ccb
|
2015-09-11 04:02:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
This routine takes a file object and extracts the Fcb and Ccb (possibly NULL)
|
|
|
|
and returns the type of open.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
FileObject - Supplies the file object pointer being initialized.
|
|
|
|
|
|
|
|
Fcb - Address to store the Fcb contained in the file object.
|
|
|
|
|
|
|
|
Ccb - Address to store the Ccb contained in the file object.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
TYPE_OF_OPEN - Indicates the type of file object.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
{
|
|
|
|
TYPE_OF_OPEN TypeOfOpen;
|
|
|
|
|
|
|
|
PAGED_CODE();
|
|
|
|
|
2017-11-23 20:02:16 +00:00
|
|
|
UNREFERENCED_PARAMETER( IrpContext );
|
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
//
|
|
|
|
// If this is an unopened file object then return NULL for the
|
|
|
|
// Fcb/Ccb. Don't trust any other values in the file object.
|
|
|
|
//
|
|
|
|
|
|
|
|
TypeOfOpen = (TYPE_OF_OPEN) FlagOn( (ULONG_PTR) FileObject->FsContext2,
|
|
|
|
TYPE_OF_OPEN_MASK );
|
|
|
|
|
|
|
|
if (TypeOfOpen == UnopenedFileObject) {
|
|
|
|
|
|
|
|
*Fcb = NULL;
|
|
|
|
*Ccb = NULL;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//
|
|
|
|
// The Fcb is pointed to by the FsContext field. The Ccb is in
|
|
|
|
// FsContext2 (after clearing the low three bits). The low three
|
|
|
|
// bits are the file object type.
|
|
|
|
//
|
|
|
|
|
|
|
|
*Fcb = FileObject->FsContext;
|
|
|
|
*Ccb = FileObject->FsContext2;
|
2021-06-11 12:29:21 +00:00
|
|
|
|
2017-11-23 20:05:28 +00:00
|
|
|
#ifdef _MSC_VER
|
2017-11-23 20:02:16 +00:00
|
|
|
#pragma warning( suppress: 4213 )
|
2017-11-23 20:05:28 +00:00
|
|
|
#endif
|
|
|
|
ClearFlag( (*(PULONG_PTR)Ccb), TYPE_OF_OPEN_MASK ); /* ReactOS Change: GCC "invalid lvalue in assignment" */
|
2015-09-11 04:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Now return the type of open.
|
|
|
|
//
|
|
|
|
|
|
|
|
return TypeOfOpen;
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:29:21 +00:00
|
|
|
|
2015-09-11 04:02:21 +00:00
|
|
|
TYPE_OF_OPEN
|
|
|
|
CdFastDecodeFileObject (
|
2017-11-23 20:02:16 +00:00
|
|
|
_In_ PFILE_OBJECT FileObject,
|
|
|
|
_Out_ PFCB *Fcb
|
2015-09-11 04:02:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
This procedure takes a pointer to a file object, that has already been
|
|
|
|
opened by Cdfs and does a quick decode operation. It will only return
|
|
|
|
a non null value if the file object is a user file open
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
FileObject - Supplies the file object pointer being interrogated
|
|
|
|
|
|
|
|
Fcb - Address to store Fcb if this is a user file object. NULL
|
|
|
|
otherwise.
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
TYPE_OF_OPEN - type of open of this file object.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
{
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
ASSERT_FILE_OBJECT( FileObject );
|
|
|
|
|
|
|
|
//
|
|
|
|
// The Fcb is in the FsContext field. The type of open is in the low
|
|
|
|
// bits of the Ccb.
|
|
|
|
//
|
|
|
|
|
|
|
|
*Fcb = FileObject->FsContext;
|
|
|
|
|
|
|
|
return (TYPE_OF_OPEN)
|
|
|
|
FlagOn( (ULONG_PTR) FileObject->FsContext2, TYPE_OF_OPEN_MASK );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|