ReactOS  0.4.15-dev-3299-gbe8e5fc
fxfileobject.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxFileObject.hpp
8 
9 Abstract:
10 
11  This module implements a frameworks managed FileObject
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 
24 --*/
25 
26 #ifndef _FXFILEOBJECT_H_
27 #define _FXFILEOBJECT_H_
28 
30 
31 private:
32 
33  // Pointer to WDM FileObject
36 
37 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
38  //
39  // KMDF retrieves the name unicode string directly from wdm file object,
40  // and returns it to caller. UMDF doesn't provide a unicode string and
41  // therefore we allocate it in this object and return that to caller after
42  // populating it with name string retrieved from host.
43  //
45 
46  //
47  // Framework related file object
48  //
50 
51 #endif
52 
53 public:
54 
55  // ListEntry for linking FileObjects off of the device
57 
58 private:
59 
60  VOID
62  _In_ MdFileObject WdmFileObject,
63  _In_ WDF_FILEOBJECT_CLASS NormalizedFileClass,
64  _In_ MdIrp Irp,
66  );
67 
68 public:
70  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
71  __in MdFileObject pWdmFileObject,
73  );
74 
75  virtual
77  );
78 
79  __inline
80  WDFFILEOBJECT
82  VOID
83  )
84  {
85  return (WDFFILEOBJECT) GetObjectHandle();
86  }
87 
88  __inline
91  VOID
92  )
93  {
94  return m_FileObject.GetFileObject();
95  }
96 
97  __inline
98  CfxDevice*
100  VOID
101  )
102  {
103  return m_Device;
104  }
105 
106  __inline
109  VOID
110  )
111  {
112  #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
113  return m_FileObject.GetFileName(NULL);
114  #else
116  #endif
117  }
118 
119  __inline
122  VOID
123  )
124  {
126  }
127 
128  __inline
129  ULONG
131  VOID
132  )
133  {
134  return m_FileObject.GetFlags();
135  }
136 
137  __inline
138  VOID
140  PVOID Context
141  )
142  {
144  }
145 
146  __inline
147  PVOID
149  VOID
150  )
151  {
152  return m_PkgContext;
153  }
154 
155  //
156  // Create a WDFFILEOBJECT from the WDM PFILE_OBJECT
157  // and associate it with the WDM PFILE_OBJECT according
158  // to the FileObjectClass.
159  //
161  static
162  NTSTATUS
165  __in MdIrp Irp,
166  __in WDF_FILEOBJECT_CLASS FileObjectClass,
167  __in_opt PWDF_OBJECT_ATTRIBUTES pObjectAttributes,
168  __in_opt MdFileObject pWdmFileObject,
169  __deref_out_opt FxFileObject** ppFxFileObject
170  );
171 
172  VOID
173  Initialize(
174  _In_ MdIrp CreateIrp
175  );
176 
177  //
178  // Destroy (dereference) the WDFFILEOBJECT related to the
179  // WDM PFILE_OBJECT according to its FileObjectClass.
180  //
181  static
182  VOID
185  __in WDF_FILEOBJECT_CLASS FileObjectClass,
186  __in_opt MdFileObject pWdmFileObject
187  );
188 
189  //
190  // Return the FxFileObject* for the given WDM PFILE_OBJECT
191  // based on the FileObjectClass.
192  //
194  static
195  NTSTATUS
198  __in WDF_FILEOBJECT_CLASS FileObjectClass,
199  __in_opt MdFileObject pWdmFileObject,
200  __deref_out_opt FxFileObject** ppFxFileObject
201  );
202 
203  VOID
205  VOID
206  );
207 
208  // begin FxObject overrides
210  NTSTATUS
213  );
214  // end FxObject overrides
215 
216  // begin IFxHasCallbacks overrides
217  VOID
219  __in WDF_EXECUTION_LEVEL* ExecutionLevel,
220  __in WDF_SYNCHRONIZATION_SCOPE* SynchronizationScope
221  ) ;
222 
227  );
228  // end IFxHasCallbacks overrides
229 
230  //
231  // Update the process keep-alive count
232  // TRUE: increment, FALSE: decrement
233  //
235  NTSTATUS
238  );
239 
240 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
241 
242  FxFileObject*
244  VOID
245  )
246  {
247  return m_RelatedFileObject;
248  }
249 
250 #endif
251 
252 };
253 
254 #endif // _FXFILEOBJECT_H_
255 
CfxDevice * m_Device
Definition: fxobject.hpp:329
__inline MdFileObject GetFileObject(VOID)
Definition: mxfileobject.h:45
FxFileObject * GetRelatedFileObject(VOID)
static _Must_inspect_result_ NTSTATUS _CreateFileObject(__in FxDevice *pDevice, __in MdIrp Irp, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt PWDF_OBJECT_ATTRIBUTES pObjectAttributes, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
ULONG GetFlags(VOID)
#define __in_opt
Definition: dbghelp.h:38
VOID SetFileObjectContext(_In_ MdFileObject WdmFileObject, _In_ WDF_FILEOBJECT_CLASS NormalizedFileClass, _In_ MdIrp Irp, _In_ FxDevice *Device)
__inline PUNICODE_STRING GetFileName(VOID)
LONG NTSTATUS
Definition: precomp.h:26
PLARGE_INTEGER GetCurrentByteOffset(VOID)
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
_Must_inspect_result_ FxCallbackLock * GetCallbackLockPtr(__deref_out_opt FxObject **LockObject)
FxFileObject * m_RelatedFileObject
__inline ULONG GetFlags(VOID)
UNICODE_STRING m_FileName
FxFileObject(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in MdFileObject pWdmFileObject, __in FxDevice *Device)
_In_ PIRP Irp
Definition: csq.h:116
enum _WDF_FILEOBJECT_CLASS WDF_FILEOBJECT_CLASS
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
unsigned char BOOLEAN
#define _In_
Definition: ms_sal.h:308
IWudfIrp * MdIrp
Definition: mxum.h:103
__inline MdFileObject GetWdmFileObject(VOID)
FxDevice * pDevice
__inline PVOID GetPkgCleanupCloseContext(VOID)
enum _WDF_SYNCHRONIZATION_SCOPE WDF_SYNCHRONIZATION_SCOPE
LIST_ENTRY m_Link
VOID GetConstraints(__in WDF_EXECUTION_LEVEL *ExecutionLevel, __in WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
virtual ~FxFileObject()
VOID Initialize(_In_ MdIrp CreateIrp)
static _Must_inspect_result_ NTSTATUS _GetFileObjectFromWdm(__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
__inline PLARGE_INTEGER GetCurrentByteOffset(VOID)
Definition: typedefs.h:119
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
static VOID _DestroyFileObject(__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject)
MxFileObject m_FileObject
_Must_inspect_result_ NTSTATUS UpdateProcessKeepAliveCount(_In_ BOOLEAN Increment)
__inline WDFFILEOBJECT GetHandle(VOID)
#define NULL
Definition: types.h:112
#define __deref_out_opt
Definition: dbghelp.h:29
PUNICODE_STRING GetFileName(_Inout_opt_ PUNICODE_STRING Filename)
struct tagContext Context
Definition: acpixf.h:1034
VOID DeleteFileObjectFromFailedCreate(VOID)
unsigned int ULONG
Definition: retypes.h:1
PVOID m_PkgContext
WDF_EXTERN_C_START enum _WDF_EXECUTION_LEVEL WDF_EXECUTION_LEVEL
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
#define __in
Definition: dbghelp.h:35
_Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
__inline VOID SetPkgCleanupCloseContext(PVOID Context)
__inline CfxDevice * GetDevice(VOID)
#define LockObject(Object)
Definition: titypes.h:34