3 Copyright (c) 1989-2000 Microsoft Corporation
11 This module implements the Cdfs File object support routines.
19 // The Bug check file id for this module
22 #define BugCheckFileId (CDFS_BUG_CHECK_FILOBSUP)
28 #define TYPE_OF_OPEN_MASK (0x00000007)
31 #pragma alloc_text(PAGE, CdDecodeFileObject)
32 #pragma alloc_text(PAGE, CdFastDecodeFileObject)
33 #pragma alloc_text(PAGE, CdSetFileObject)
37 _When_(TypeOfOpen
== UnopenedFileObject
, _At_(Fcb
, _In_opt_
))
38 _When_(TypeOfOpen
!= UnopenedFileObject
, _At_(Fcb
, _In_
))
41 _In_ PIRP_CONTEXT IrpContext
,
42 _Inout_ PFILE_OBJECT FileObject
,
43 _In_ TYPE_OF_OPEN TypeOfOpen
,
52 This routine will initialize the FileObject context fields based on the
53 input type and data structures.
57 FileObject - Supplies the file object pointer being initialized.
59 TypeOfOpen - Sets the type of open.
61 Fcb - Fcb for this file object. Ignored for UnopenedFileObject.
63 Ccb - Ccb for the handle corresponding to this file object. Will not
64 be present for stream file objects.
75 UNREFERENCED_PARAMETER( IrpContext
);
78 // We only have values 0 to 7 available so make sure we didn't
79 // inadvertantly add a new type.
82 NT_ASSERTMSG( "FileObject types exceed available bits\n", BeyondValidType
<= 8 );
85 // Setting a file object to type UnopenedFileObject means just
86 // clearing all of the context fields. All the other input
89 if (TypeOfOpen
== UnopenedFileObject
) {
91 FileObject
->FsContext
=
92 FileObject
->FsContext2
= NULL
;
98 // Check that the 3 low-order bits of the Ccb are clear.
101 NT_ASSERTMSG( "Ccb is not quad-aligned\n", !FlagOn( ((ULONG_PTR
) Ccb
), TYPE_OF_OPEN_MASK
));
104 // We will or the type of open into the low order bits of FsContext2
105 // along with the Ccb value.
106 // The Fcb is stored into the FsContext field.
109 FileObject
->FsContext
= Fcb
;
110 FileObject
->FsContext2
= Ccb
;
113 #pragma warning( suppress: 4213 )
115 SetFlag( (*(PULONG_PTR
)&FileObject
->FsContext2
), TypeOfOpen
); /* ReactOS Change: GCC "invalid lvalue in assignment" */
118 // Set the Vpb field in the file object.
121 FileObject
->Vpb
= Fcb
->Vcb
->Vpb
;
127 _When_(return == UnopenedFileObject
, _At_(*Fcb
, _Post_null_
))
128 _When_(return != UnopenedFileObject
, _At_(Fcb
, _Outptr_
))
129 _When_(return == UnopenedFileObject
, _At_(*Ccb
, _Post_null_
))
130 _When_(return != UnopenedFileObject
, _At_(Ccb
, _Outptr_
))
133 _In_ PIRP_CONTEXT IrpContext
,
134 _In_ PFILE_OBJECT FileObject
,
143 This routine takes a file object and extracts the Fcb and Ccb (possibly NULL)
144 and returns the type of open.
148 FileObject - Supplies the file object pointer being initialized.
150 Fcb - Address to store the Fcb contained in the file object.
152 Ccb - Address to store the Ccb contained in the file object.
156 TYPE_OF_OPEN - Indicates the type of file object.
161 TYPE_OF_OPEN TypeOfOpen
;
165 UNREFERENCED_PARAMETER( IrpContext
);
168 // If this is an unopened file object then return NULL for the
169 // Fcb/Ccb. Don't trust any other values in the file object.
172 TypeOfOpen
= (TYPE_OF_OPEN
) FlagOn( (ULONG_PTR
) FileObject
->FsContext2
,
175 if (TypeOfOpen
== UnopenedFileObject
) {
183 // The Fcb is pointed to by the FsContext field. The Ccb is in
184 // FsContext2 (after clearing the low three bits). The low three
185 // bits are the file object type.
188 *Fcb
= FileObject
->FsContext
;
189 *Ccb
= FileObject
->FsContext2
;
192 #pragma warning( suppress: 4213 )
194 ClearFlag( (*(PULONG_PTR
)Ccb
), TYPE_OF_OPEN_MASK
); /* ReactOS Change: GCC "invalid lvalue in assignment" */
198 // Now return the type of open.
206 CdFastDecodeFileObject (
207 _In_ PFILE_OBJECT FileObject
,
215 This procedure takes a pointer to a file object, that has already been
216 opened by Cdfs and does a quick decode operation. It will only return
217 a non null value if the file object is a user file open
221 FileObject - Supplies the file object pointer being interrogated
223 Fcb - Address to store Fcb if this is a user file object. NULL
228 TYPE_OF_OPEN - type of open of this file object.
235 ASSERT_FILE_OBJECT( FileObject
);
238 // The Fcb is in the FsContext field. The type of open is in the low
242 *Fcb
= FileObject
->FsContext
;
244 return (TYPE_OF_OPEN
)
245 FlagOn( (ULONG_PTR
) FileObject
->FsContext2
, TYPE_OF_OPEN_MASK
);