ReactOS  0.4.15-dev-2993-g14fbe80
fxobjectapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxObjectApi.cpp
8 
9 Abstract:
10 
11 
12 Author:
13 
14 
15 Environment:
16 
17  kernel mode only
18 
19 Revision History:
20 
21 --*/
22 
23 #include "fxobjectpch.hpp"
24 
25 extern "C" {
26 
27 #if defined(EVENT_TRACING)
28 #include "FxObjectAPI.tmh"
29 #endif
30 
31 }
32 
33 
34 extern "C" {
35 
37 WDFAPI
38 VOID
39 STDCALL
41  __in
43  __in
45  __in_opt
46  PVOID Tag,
47  __in
48  LONG Line,
49  __in
50  PSTR File
51  )
52 /*++
53 
54 Routine Description:
55  Adds an explicit reference that was taken on an object.
56 
57 Arguments:
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 
65 Return 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 
83 WDFAPI
84 VOID
85 STDCALL
87  __in
89  __in
91  __in_opt
92  PVOID Tag,
93  __in
94  LONG Line,
95  __in
96  PSTR File
97  )
98 /*++
99 
100 Routine Description:
101  Removes an explicit reference that was taken on an object.
102 
103 Arguments:
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 
111 Return 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 
135 Routine 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 
143 Arguments:
144 
145  Object - Pointer to object to retrieve the callback lock pointer for
146 
147 Returns:
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 
173 WDFAPI
174 VOID
175 STDCALL
176 WDFEXPORT(WdfObjectAcquireLock)(
177  __in
179  __in
181  _Acquires_lock_(_Curr_)
183  )
184 {
185  DDI_ENTRY();
186 
187  FxObject* pObject;
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);
219  (ULONG_PTR)Object,
220  (ULONG_PTR)NULL
221  );
222  return;
223  }
224 
225  pLock->Lock(&irql);
226  pLock->m_PreviousIrql = irql;
227 
228  return;
229 }
230 
231 
233 WDFAPI
234 VOID
235 STDCALL
236 WDFEXPORT(WdfObjectReleaseLock)(
237  __in
239  __in
241  _Releases_lock_(_Curr_)
243  )
244 {
245  DDI_ENTRY();
246 
248  FxObject* pObject;
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);
277  (ULONG_PTR)Object,
278  (ULONG_PTR)NULL
279  );
280  return;
281  }
282 
283  pLock->Unlock(pLock->m_PreviousIrql);
284 
285  return;
286 }
287 
289 WDFAPI
290 VOID
291 STDCALL
292 WDFEXPORT(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 
328 WDFAPI
329 NTSTATUS
330 STDCALL
331 WDFEXPORT(WdfObjectQuery)(
332  __in
334  __in
336  __in
337  CONST GUID* Guid,
338  __in
341  PVOID QueryBuffer
342  )
343 
344 /*++
345 
346 Routine 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 
355 Arguments:
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 
365 Returns:
366 
367  NTSTATUS
368 
369 --*/
370 
371 {
372  DDI_ENTRY();
373 
374  FxObject* p;
375 
377  Object,
379  (PVOID*)&p);
380 
381  return FxObject::_ObjectQuery(p,
382  Guid,
384  QueryBuffer);
385 }
386 
387 } // extern "C" for all functions
388 
389 
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
virtual VOID DeleteObject(VOID)
virtual _Must_inspect_result_ FxCallbackLock * GetCallbackLockPtr(__out_opt FxObject **LockObject)=0
FxObject * pObject
_Must_inspect_result_ __in WDFOBJECT __in CONST GUID __in ULONG QueryBufferLength
#define __in_opt
Definition: dbghelp.h:38
LONG NTSTATUS
Definition: precomp.h:26
PFX_DRIVER_GLOBALS pFxDriverGlobals
__drv_maxIRQL(DISPATCH_LEVEL) WDFAPI VOID STDCALL WDFEXPORT(WdfObjectReferenceActual)(__in PWDF_DRIVER_GLOBALS DriverGlobals
KIRQL irql
Definition: wave.h:1
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
DriverGlobals
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG QueryBufferLength
Definition: wdfobject.h:760
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
GLenum const GLfloat * params
Definition: glext.h:5645
long LONG
Definition: pedump.c:60
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define WDFAPI
Definition: wdftypes.h:53
#define _Releases_lock_(a)
Definition: btrfs_drv.h:208
FxCallbackLock * FxGetCallbackLock(FxObject *Object)
_Must_inspect_result_ __in WDFOBJECT __in CONST GUID * Guid
BOOLEAN FxVerifierLock
Definition: fxglobals.h:451
__in WDFOBJECT __in_opt PVOID __in LONG __in PSTR File
Definition: fxobjectapi.cpp:69
__in _Requires_lock_held_(_Curr_) _Releases_lock_(_Curr_) WDFOBJECT Object)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define STDCALL
Definition: wdf.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
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
BOOLEAN IsNoDeleteDDI(VOID)
Definition: fxobject.hpp:1135
static VOID __inline _ReferenceActual(__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
Definition: fxobject.hpp:673
Definition: ncftp.h:79
__in WDFOBJECT Object
Definition: fxobjectapi.cpp:44
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
FxSpinLock * pLock
__in WDFOBJECT __in_opt PVOID __in LONG Line
Definition: fxobjectapi.cpp:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
FxPointerNotNull(GetFxDriverGlobals(DriverGlobals), Object)
_Must_inspect_result_ __in WDFOBJECT __in CONST GUID __in ULONG __out_bcount(QueryBufferLength) PVOID QueryBuffer)
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
__in _Requires_lock_not_held_(_Curr_) _Acquires_lock_(_Curr_) WDFOBJECT Object)
FORCEINLINE VOID WdfObjectReferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
Definition: wdfobject.h:643
static VOID __inline _DereferenceActual(__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
Definition: fxobject.hpp:697
signed char * PSTR
Definition: retypes.h:7
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Object, FX_TYPE_OBJECT,(PVOID *)&pObject, &pFxDriverGlobals)
unsigned int ULONG
Definition: retypes.h:1
Definition: File.h:15
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
GLfloat GLfloat p
Definition: glext.h:8902
#define _Acquires_lock_(lock)
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
FORCEINLINE VOID WdfObjectDereferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
Definition: wdfobject.h:678
#define CONST
Definition: pedump.c:81
__in WDFOBJECT __in_opt PVOID Tag
Definition: fxobjectapi.cpp:44
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97