ReactOS 0.4.15-dev-7711-g5627da4
fxcollectionapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxCollectionApi.cpp
8
9Abstract:
10
11 This module implements the "C" interface to the collection object.
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23--*/
24
25#include "fxsupportpch.hpp"
26
27extern "C" {
28// #include "FxCollectionApi.tmh"
29}
30
31//
32// Extern the entire file
33//
34extern "C" {
39WDFEXPORT(WdfCollectionCreate)(
40 __in
44 __out
45 WDFCOLLECTION *Collection
46 )
47{
48 DDI_ENTRY();
49
53 WDFCOLLECTION hCol;
54
56
57 //
58 // Get the parent's globals if it is present
59 //
63
67 (PVOID*)&pParent,
69 }
70
72
74
77 return status;
78 }
79
82
83 if (pCollection != NULL) {
85
86 if (NT_SUCCESS(status)) {
88 }
89 else {
91 "Could not create collection object: %!STATUS!",
92 status);
93
95 }
96 }
97 else {
99 "Could not create collection object: "
100 "STATUS_INSUFFICIENT_RESOURCES" );
102 }
103
104 return status;
105}
106
108ULONG
110WDFEXPORT(WdfCollectionGetCount)(
111 __in
113 __in
114 WDFCOLLECTION Collection
115 )
116{
117 DDI_ENTRY();
118
122
126 (PVOID *)&pCollection);
127
128 pCollection->Lock(&irql);
131
132 return count;
133}
134
139WDFEXPORT(WdfCollectionAdd)(
140 __in
142 __in
143 WDFCOLLECTION Collection,
144 __in
146 )
147{
148 DDI_ENTRY();
149
154 KIRQL irql;
155
159 (PVOID*) &pCollection,
161
163 Object,
165 (PVOID*) &pObject);
166
167 pCollection->Lock(&irql);
170
171 return status;
172}
173
175VOID
177WDFEXPORT(WdfCollectionRemoveItem)(
178 __in
180 __in
181 WDFCOLLECTION Collection,
182 __in
184 )
185{
186 DDI_ENTRY();
187
193 KIRQL irql;
194
198 (PVOID*) &pCollection,
200
201 pCollection->Lock(&irql);
202
204
205 if (pEntry != NULL) {
209 }
210 else {
211 pObject = NULL;
213 }
214
216
217 if (pObject != NULL) {
219 }
220
221 if (!NT_SUCCESS(status)) {
224 "Index %d is not valid in WDFCOLLECTION %p (count is %d), %!STATUS!",
227 }
228}
229
231VOID
233WDFEXPORT(WdfCollectionRemove)(
234 __in
236 __in
237 WDFCOLLECTION Collection,
238 __in
240 )
241{
242 DDI_ENTRY();
243
249 KIRQL irql;
250
254 (PVOID*) &pCollection,
256
258 Item,
260 (PVOID*) &pObject);
261
262 pCollection->Lock(&irql);
263
265
266 if (pEntry != NULL) {
269 }
270 else {
271 pObject = NULL;
273 }
274
276
277 if (pObject != NULL) {
279 }
280
281 if (!NT_SUCCESS(status)) {
283 "WDFOBJECT %p not in WDFCOLLECTION %p, %!STATUS!",
286 }
287}
288
292WDFEXPORT(WdfCollectionGetItem)(
293 __in
295 __in
296 WDFCOLLECTION Collection,
297 __in
299 )
300{
301 DDI_ENTRY();
302
305 KIRQL irql;
306
310 (PVOID*) &pCollection);
311
312 pCollection->Lock(&irql);
315
316 if (pObject == NULL) {
317 return NULL;
318 }
319
321}
322
326WDFEXPORT(WdfCollectionGetFirstItem)(
327 __in
329 __in
330 WDFCOLLECTION Collection
331 )
332{
333 DDI_ENTRY();
334
337 KIRQL irql;
338
342 (PVOID*) &pCollection);
343
344 pCollection->Lock(&irql);
347
348 if (pObject != NULL) {
349 return pObject->GetObjectHandle();
350 }
351 else {
352 return NULL;
353 }
354}
355
359WDFEXPORT(WdfCollectionGetLastItem)(
360 __in
362 __in
363 WDFCOLLECTION Collection
364 )
365{
366 DDI_ENTRY();
367
370 KIRQL irql;
371
375 (PVOID*) &pCollection);
376
377 pCollection->Lock(&irql);
380
381 if (pObject != NULL) {
382 return pObject->GetObjectHandle();
383 }
384 else {
385 return NULL;
386 }
387}
388
389} // extern "C" of entire file
LONG NTSTATUS
Definition: precomp.h:26
FxObject * m_Object
BOOLEAN Add(__in FxObject *Item)
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define TRACINGERROR
Definition: dbgtrace.h:63
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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)
NTSTATUS status
WDFCOLLECTION hCol
__in WDFCOLLECTION __in WDFOBJECT Item
FxObject * pObject
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Collection, FX_TYPE_COLLECTION,(PVOID *)&pCollection)
FxCollectionEntry * pEntry
__in WDFCOLLECTION __in ULONG Index
_Must_inspect_result_ __in WDFCOLLECTION __in WDFOBJECT Object
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Collection, FX_TYPE_COLLECTION,(PVOID *) &pCollection, &pFxDriverGlobals)
ULONG count
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES CollectionAttributes
FxCollection * pCollection
KIRQL irql
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFCOLLECTION * Collection
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxVerifierDbgBreakPoint(pFxDriverGlobals)
FxObject * pParent
Definition: fxdpcapi.cpp:86
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
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_COLLECTION
Definition: fxtypes.h:59
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_Must_inspect_result_ FxCollectionEntry * FindEntry(__in ULONG Index)
VOID CleanupEntry(__in FxCollectionEntry *Entry)
_Must_inspect_result_ FxObject * GetLastItem(VOID)
_Must_inspect_result_ FxObject * GetItem(__in ULONG Index)
_Must_inspect_result_ FxCollectionEntry * FindEntryByObject(__in FxObject *Object)
_Must_inspect_result_ FxObject * GetFirstItem(VOID)
VOID CleanupEntryObject(__in FxObject *Object)
WDFOBJECT ParentObject
Definition: wdfobject.h:130
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ WDFCOLLECTION Collection
Definition: wdfregistry.h:374