1 /*++
2
3 Copyright (c) Microsoft Corporation
4
5 Module Name:
6
7 FxFileObjectApi.cpp
8
9 Abstract:
10
11 This modules implements the C API's for the FxFileObject.
12
13 Author:
14
15
16
17 Environment:
18
19 Both kernel and user mode
20
21 Revision History:
22
23
24 --*/
25
26 #include "coreprivshared.hpp"
27 #include "fxfileobject.hpp"
28
29 extern "C" {
30 // #include "FxFileObjectApi.tmh"
31 }
32
33 //
34 // Extern "C" the entire file
35 //
36 extern "C" {
37
__drv_maxIRQL(PASSIVE_LEVEL)38 __drv_maxIRQL(PASSIVE_LEVEL)
39 PUNICODE_STRING
40 STDCALL
41 WDFEXPORT(WdfFileObjectGetFileName)(
42 __in
43 PWDF_DRIVER_GLOBALS DriverGlobals,
44 __in
45 WDFFILEOBJECT FileObject
46 )
47
48 /*++
49
50 Routine Description:
51
52 This returns the UNICODE_STRING for the FileName inside
53 the WDM fileobject.
54
55 Arguments:
56
57 FileObject - WDFFILEOBJECT
58
59 Return Value:
60
61 PUNICODE_STRING (file name)
62
63 --*/
64
65 {
66 DDI_ENTRY();
67
68 PFX_DRIVER_GLOBALS pFxDriverGlobals;
69 NTSTATUS status;
70 FxFileObject* pFO;
71
72 //
73 // Validate the FileObject object handle, and get its FxFileObject*
74 //
75 FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals),
76 FileObject,
77 FX_TYPE_FILEOBJECT,
78 (PVOID*)&pFO,
79 &pFxDriverGlobals);
80
81 status = FxVerifierCheckIrqlLevel(pFxDriverGlobals, PASSIVE_LEVEL);
82 if (!NT_SUCCESS(status)) {
83 return NULL;
84 }
85
86 if (pFO->GetWdmFileObject() != NULL) {
87 return pFO->GetFileName();
88 }
89 else {
90 return NULL;
91 }
92 }
93
94
__drv_maxIRQL(DISPATCH_LEVEL)95 __drv_maxIRQL(DISPATCH_LEVEL)
96 ULONG
97 STDCALL
98 WDFEXPORT(WdfFileObjectGetFlags)(
99 __in
100 PWDF_DRIVER_GLOBALS DriverGlobals,
101 __in
102 WDFFILEOBJECT FileObject
103 )
104
105 /*++
106
107 Routine Description:
108
109 This returns the flags inside the WDM fileobject.
110
111 Arguments:
112
113 FileObject - WDFFILEOBJECT
114
115 Return Value:
116
117 ULONG (flags)
118
119 --*/
120
121 {
122 DDI_ENTRY();
123
124 FxFileObject* pFO;
125
126 //
127 // Validate the FileObject object handle, and get its FxFileObject*
128 //
129 FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals),
130 FileObject,
131 FX_TYPE_FILEOBJECT,
132 (PVOID*)&pFO);
133
134 if (pFO->GetWdmFileObject() != NULL) {
135 return pFO->GetFlags();
136 }
137 else {
138 return 0x0;
139 }
140 }
141
__drv_maxIRQL(DISPATCH_LEVEL)142 __drv_maxIRQL(DISPATCH_LEVEL)
143 WDFDEVICE
144 STDCALL
145 WDFEXPORT(WdfFileObjectGetDevice)(
146 __in
147 PWDF_DRIVER_GLOBALS DriverGlobals,
148 __in
149 WDFFILEOBJECT FileObject
150 )
151
152 /*++
153
154 Routine Description:
155
156 This returns the Device that the fileobject is associated with.
157
158 Arguments:
159
160 FileObject - WDFFILEOBJECT
161
162 Return Value:
163
164 WDFDEVICE
165
166 --*/
167
168 {
169 DDI_ENTRY();
170
171 FxFileObject* pFO;
172
173 //
174 // Validate the FileObject object handle, and get its FxFileObject*
175 //
176 FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals),
177 FileObject,
178 FX_TYPE_FILEOBJECT,
179 (PVOID*)&pFO);
180
181 return pFO->GetDevice()->GetHandle();
182 }
183
184 } // extern "C"
185