ReactOS 0.4.15-dev-7953-g1f49173
filobsup.c
Go to the documentation of this file.
1/*++
2
3Copyright (c) 1989-2000 Microsoft Corporation
4
5Module Name:
6
7 FilObSup.c
8
9Abstract:
10
11 This module implements the Cdfs File object support routines.
12
13
14--*/
15
16#include "cdprocs.h"
17
18//
19// The Bug check file id for this module
20//
21
22#define BugCheckFileId (CDFS_BUG_CHECK_FILOBSUP)
23
24//
25// Local constants.
26//
27
28#define TYPE_OF_OPEN_MASK (0x00000007)
29
30#ifdef ALLOC_PRAGMA
31#pragma alloc_text(PAGE, CdDecodeFileObject)
32#pragma alloc_text(PAGE, CdFastDecodeFileObject)
33#pragma alloc_text(PAGE, CdSetFileObject)
34#endif
35
36
39VOID
40CdSetFileObject (
41 _In_ PIRP_CONTEXT IrpContext,
44 PFCB Fcb,
46 )
47
48/*++
49
50Routine Description:
51
52 This routine will initialize the FileObject context fields based on the
53 input type and data structures.
54
55Arguments:
56
57 FileObject - Supplies the file object pointer being initialized.
58
59 TypeOfOpen - Sets the type of open.
60
61 Fcb - Fcb for this file object. Ignored for UnopenedFileObject.
62
63 Ccb - Ccb for the handle corresponding to this file object. Will not
64 be present for stream file objects.
65
66Return Value:
67
68 None.
69
70--*/
71
72{
73 PAGED_CODE();
74
75 UNREFERENCED_PARAMETER( IrpContext );
76
77 //
78 // We only have values 0 to 7 available so make sure we didn't
79 // inadvertantly add a new type.
80 //
81
82 NT_ASSERTMSG( "FileObject types exceed available bits\n", BeyondValidType <= 8 );
83
84 //
85 // Setting a file object to type UnopenedFileObject means just
86 // clearing all of the context fields. All the other input
87 //
88
90
91 FileObject->FsContext =
92 FileObject->FsContext2 = NULL;
93
94 return;
95 }
96
97 //
98 // Check that the 3 low-order bits of the Ccb are clear.
99 //
100
101 NT_ASSERTMSG( "Ccb is not quad-aligned\n", !FlagOn( ((ULONG_PTR) Ccb), TYPE_OF_OPEN_MASK ));
102
103 //
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.
107 //
108
109 FileObject->FsContext = Fcb;
110 FileObject->FsContext2 = Ccb;
111
112#ifdef _MSC_VER
113#pragma warning( suppress: 4213 )
114#endif
115 SetFlag( (*(PULONG_PTR)&FileObject->FsContext2), TypeOfOpen ); /* ReactOS Change: GCC "invalid lvalue in assignment" */
116
117 //
118 // Set the Vpb field in the file object.
119 //
120
121 FileObject->Vpb = Fcb->Vcb->Vpb;
122
123 return;
124}
125
126
132CdDecodeFileObject (
133 _In_ PIRP_CONTEXT IrpContext,
135 PFCB *Fcb,
136 PCCB *Ccb
137 )
138
139/*++
140
141Routine Description:
142
143 This routine takes a file object and extracts the Fcb and Ccb (possibly NULL)
144 and returns the type of open.
145
146Arguments:
147
148 FileObject - Supplies the file object pointer being initialized.
149
150 Fcb - Address to store the Fcb contained in the file object.
151
152 Ccb - Address to store the Ccb contained in the file object.
153
154Return Value:
155
156 TYPE_OF_OPEN - Indicates the type of file object.
157
158--*/
159
160{
162
163 PAGED_CODE();
164
165 UNREFERENCED_PARAMETER( IrpContext );
166
167 //
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.
170 //
171
174
176
177 *Fcb = NULL;
178 *Ccb = NULL;
179
180 } else {
181
182 //
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.
186 //
187
188 *Fcb = FileObject->FsContext;
189 *Ccb = FileObject->FsContext2;
190
191#ifdef _MSC_VER
192#pragma warning( suppress: 4213 )
193#endif
194 ClearFlag( (*(PULONG_PTR)Ccb), TYPE_OF_OPEN_MASK ); /* ReactOS Change: GCC "invalid lvalue in assignment" */
195 }
196
197 //
198 // Now return the type of open.
199 //
200
201 return TypeOfOpen;
202}
203
204
208 _Out_ PFCB *Fcb
209 )
210
211/*++
212
213Routine Description:
214
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
218
219Arguments:
220
221 FileObject - Supplies the file object pointer being interrogated
222
223 Fcb - Address to store Fcb if this is a user file object. NULL
224 otherwise.
225
226Return Value:
227
228 TYPE_OF_OPEN - type of open of this file object.
229
230--*/
231
232{
233 PAGED_CODE();
234
236
237 //
238 // The Fcb is in the FsContext field. The type of open is in the low
239 // bits of the Ccb.
240 //
241
242 *Fcb = FileObject->FsContext;
243
244 return (TYPE_OF_OPEN)
246}
247
248
249
#define PAGED_CODE()
#define ASSERT_FILE_OBJECT(FO)
Definition: cddata.h:252
return
Definition: dirsup.c:529
TYPE_OF_OPEN CdFastDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Out_ PFCB *Fcb)
Definition: filobsup.c:206
#define TYPE_OF_OPEN_MASK
Definition: filobsup.c:28
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:589
@ BeyondValidType
Definition: cdprocs.h:578
@ UnopenedFileObject
Definition: cdprocs.h:573
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
enum _TYPE_OF_OPEN TYPE_OF_OPEN
#define NULL
Definition: types.h:112
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define _Inout_
Definition: ms_sal.h:378
#define _Outptr_
Definition: ms_sal.h:427
#define _At_(target, annos)
Definition: ms_sal.h:244
#define _Out_
Definition: ms_sal.h:345
#define _When_(expr, annos)
Definition: ms_sal.h:254
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define _Post_null_
Definition: ms_sal.h:704
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
Definition: cdstruc.h:1067
Definition: cdstruc.h:902
PVCB Vcb
Definition: cdstruc.h:933
PVPB Vpb
Definition: cdstruc.h:511
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998
#define NT_ASSERTMSG
Definition: rtlfuncs.h:3311