ReactOS 0.4.15-dev-7842-g558ab78
fxobjectapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxObjectApi.cpp
8
9Abstract:
10
11
12Author:
13
14
15Environment:
16
17 kernel mode only
18
19Revision History:
20
21--*/
22
23#include "fxobjectpch.hpp"
24
25extern "C" {
26
27#if defined(EVENT_TRACING)
28#include "FxObjectAPI.tmh"
29#endif
30
31}
32
33
34extern "C" {
35
38VOID
41 __in
43 __in
47 __in
49 __in
51 )
52/*++
53
54Routine Description:
55 Adds an explicit reference that was taken on an object.
56
57Arguments:
58 Object - the object to reference
59 Tag - The tag used to track this reference. If not matched on dereference,
60 a breakpoint is hit. Tags are only tracked when enabled via the
61 registry or WDF verifier.
62 Line - the caller's line number making the call
63 File - the caller's file name making the call
64
65Return Value:
66 None. We do not return the current reference count.
67
68 --*/
69{
70 DDI_ENTRY();
71
73
75 Object,
76 Tag,
77 Line,
78 File
79 );
80}
81
84VOID
87 __in
89 __in
92 PVOID Tag,
93 __in
94 LONG Line,
95 __in
97 )
98/*++
99
100Routine Description:
101 Removes an explicit reference that was taken on an object.
102
103Arguments:
104 Object - the object to dereference
105 Tag - The tag used when referencing the Object, if not matched, a breakpoint
106 is hit. Tags are only tracked when enabled via the registry or
107 WDF verifier.
108 Line - the caller's line number making the call
109 File - the caller's file name making the call
110
111Return Value:
112 None. We do not return the current reference count.
113
114 --*/
115{
116 DDI_ENTRY();
117
119
121 Object,
122 Tag,
123 Line,
124 File
125 );
126}
127
131 )
132
133/*++
134
135Routine Description:
136
137 This returns the proper FxCallbackLock pointer
138 for the object.
139
140 It returns NULL if an FxCallbackLock is not valid
141 for the object.
142
143Arguments:
144
145 Object - Pointer to object to retrieve the callback lock pointer for
146
147Returns:
148
149 FxCallbackLock*
150
151--*/
152
153{
155 IFxHasCallbacks* ihcb;
157
158 ihcb = NULL;
159
160 //
161 // Query the object for the IFxHasCallbacks interface. Objects that
162 // have callback locks must support this interface.
163 //
164 status = Object->QueryInterface(&params);
165 if (!NT_SUCCESS(status)) {
166 return NULL;
167 }
168
169 return ihcb->GetCallbackLockPtr(NULL);
170}
171
173WDFAPI
174VOID
176WDFEXPORT(WdfObjectAcquireLock)(
177 __in
179 __in
181 _Acquires_lock_(_Curr_)
183 )
184{
185 DDI_ENTRY();
186
190 KIRQL irql;
191
193 Object,
195 (PVOID*)&pObject,
197
198 //
199 // If Lock Verifier on, validate whether its correct to
200 // make this call
201 //
203 //
204 // Check IRQL Level, etc.
205 //
206 }
207
208 //
209 // Get the CallbackLock for the object
210 //
212
213 if (pLock == NULL) {
215 "Invalid to call on WDFOBJECT 0x%p", Object);
221 );
222 return;
223 }
224
225 pLock->Lock(&irql);
226 pLock->m_PreviousIrql = irql;
227
228 return;
229}
230
231
233WDFAPI
234VOID
236WDFEXPORT(WdfObjectReleaseLock)(
237 __in
239 __in
241 _Releases_lock_(_Curr_)
243 )
244{
245 DDI_ENTRY();
246
250
252 Object,
254 (PVOID*)&pObject,
256
257 //
258 // If Lock Verifier on, validate whether its correct to
259 // make this call
260 //
262 //
263 // Check IRQL Level, etc.
264 //
265 }
266
267 //
268 // Get the CallbackLock for the object
269 //
271 if (pLock == NULL) {
273 "Invalid to call on WDFOBJECT 0x%p",Object);
279 );
280 return;
281 }
282
283 pLock->Unlock(pLock->m_PreviousIrql);
284
285 return;
286}
287
289WDFAPI
290VOID
292WDFEXPORT(WdfObjectDelete)(
293 __in
295 __in
297 )
298{
299 DDI_ENTRY();
300
303
305 Object,
307 (PVOID*)&pObject,
309
310 //
311 // The object may not allow the Delete DDI
312 //
316 "Attempt to Delete an Object Which does not allow WdfDeleteObject "
317 "Handle 0x%p, %!STATUS!",
320 }
321 else {
323 }
324}
325
328WDFAPI
331WDFEXPORT(WdfObjectQuery)(
332 __in
334 __in
336 __in
338 __in
341 PVOID QueryBuffer
342 )
343
344/*++
345
346Routine Description:
347
348 Query the object handle for specific information
349
350 This allows dynamic extensions to DDI's.
351
352 Currently, it is used to allow test hooks for verification
353 which are not available in a production release.
354
355Arguments:
356
357 Object - Handle to object for the query
358
359 Guid - GUID to represent the information/DDI to query for
360
361 QueryBufferLength - Length of QueryBuffer to return data in
362
363 QueryBuffer - Pointer to QueryBuffer
364
365Returns:
366
367 NTSTATUS
368
369--*/
370
371{
372 DDI_ENTRY();
373
374 FxObject* p;
375
377 Object,
379 (PVOID*)&p);
380
382 Guid,
384 QueryBuffer);
385}
386
387} // extern "C" for all functions
388
389
LONG NTSTATUS
Definition: precomp.h:26
Definition: File.h:16
BOOLEAN IsNoDeleteDDI(VOID)
Definition: fxobject.hpp:1135
virtual VOID DeleteObject(VOID)
static VOID __inline _ReferenceActual(__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
Definition: fxobject.hpp:673
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
static _Must_inspect_result_ NTSTATUS _ObjectQuery(_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
Definition: fxobjectkm.cpp:39
static VOID __inline _DereferenceActual(__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
Definition: fxobject.hpp:697
virtual _Must_inspect_result_ FxCallbackLock * GetCallbackLockPtr(__out_opt FxObject **LockObject)=0
#define _Acquires_lock_(lock)
#define _Requires_lock_held_(lock)
#define _Requires_lock_not_held_(lock)
#define _Releases_lock_(lock)
#define __in
Definition: dbghelp.h:35
#define __out_bcount(x)
Definition: dbghelp.h:68
#define __in_opt
Definition: dbghelp.h:38
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KIRQL irql
Definition: wave.h:1
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
__in WDFOBJECT __in_opt PVOID __in LONG __in PSTR File
Definition: fxobjectapi.cpp:69
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Object, FX_TYPE_OBJECT,(PVOID *)&pObject, &pFxDriverGlobals)
__in WDFOBJECT __in_opt PVOID __in LONG Line
Definition: fxobjectapi.cpp:48
_Must_inspect_result_ __in WDFOBJECT __in CONST GUID __in ULONG QueryBufferLength
FxCallbackLock * FxGetCallbackLock(FxObject *Object)
__in WDFOBJECT Object
Definition: fxobjectapi.cpp:44
_Must_inspect_result_ __in WDFOBJECT __in CONST GUID * Guid
FxObject * pObject
__in WDFOBJECT __in_opt PVOID Tag
Definition: fxobjectapi.cpp:46
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxSpinLock * pLock
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_IHASCALLBACKS
Definition: fxtypes.h:114
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
GLenum const GLfloat * params
Definition: glext.h:5645
GLfloat GLfloat p
Definition: glext.h:8902
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define CONST
Definition: pedump.c:81
long LONG
Definition: pedump.c:60
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ncftp.h:79
BOOLEAN FxVerifierLock
Definition: fxglobals.h:451
Definition: ps.c:97
char * PSTR
Definition: typedefs.h:51
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STDCALL
Definition: wdf.h:45
@ WDF_INVALID_LOCK_OPERATION
Definition: wdfbugcodes.h:68
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
FORCEINLINE VOID WdfObjectDereferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
Definition: wdfobject.h:678
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG QueryBufferLength
Definition: wdfobject.h:764
FORCEINLINE VOID WdfObjectReferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
Definition: wdfobject.h:643
#define WDFAPI
Definition: wdftypes.h:53