ReactOS 0.4.15-dev-8127-g6338913
fxdpcapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxDpcApi.cpp
8
9Abstract:
10
11 This implements the WDFDPC API's
12
13Author:
14
15
16
17Environment:
18
19 Kernel mode only
20
21Revision History:
22
23
24--*/
25
26#include "fxcorepch.hpp"
27
28#include "fxdpc.hpp"
29
30extern "C" {
31// #include "FxDpcApi.tmh"
32}
33
34//
35// extern "C" the entire file
36//
37extern "C" {
38
43WDFEXPORT(WdfDpcCreate)(
44 __in
46 __in
48 __in
50 __out
51 WDFDPC * Dpc
52 )
53
54/*++
55
56Routine Description:
57
58 Create a DPC object that will call the supplied function with
59 context when it fires. It returns a handle to the WDFDPC object.
60
61Arguments:
62
63 Config - WDF_DPC_CONFIG structure.
64
65 Attributes - WDF_OBJECT_ATTRIBUTES to set the parent object and to request
66 a context memory allocation, and a DestroyCallback.
67
68 Dpc - Pointer to location to returnt he resulting WDFDPC handle.
69
70Returns:
71
72 STATUS_SUCCESS - A WDFDPC handle has been created.
73
74Notes:
75
76 The WDFDPC object is deleted either when the DEVICE or QUEUE it is
77 associated as its parent with is deleted, or WdfObjectDelete is called.
78
79 If the DPC is used to access WDM objects, a Cleanup callback should
80 be registered to allow references to be released.
81
82--*/
83
84{
88
94 return status;
95 }
96
98 Attributes->ParentObject,
100 (PVOID*)&pParent,
102
105
106 if (Config->Size != sizeof(WDF_DPC_CONFIG)) {
108
110 "WDF_DPC_CONFIG got Size %d, expected %d, %!STATUS!",
111 Config->Size, sizeof(WDF_DPC_CONFIG), status);
112
113 return status;
114 }
115
119 );
120
121 if (!NT_SUCCESS(status)) {
122 return status;
123 }
124
126
127 return status;
128}
129
130
132KDPC*
134WDFEXPORT(WdfDpcWdmGetDpc)(
135 __in
137 __in
138 WDFDPC Dpc
139 )
140/*++
141
142Routine Description:
143
144 Return the KDPC* object pointer so that it may be linked into
145 a DPC list.
146
147Arguments:
148
149 WDFDPC - Handle to WDFDPC object created with WdfDpcCreate.
150
151Returns:
152
153 KDPC*
154
155--*/
156
157{
158 FxDpc* pFxDpc;
159
161 Dpc,
163 (PVOID*)&pFxDpc);
164
165 return pFxDpc->GetDpcPtr();
166}
167
168
172WDFEXPORT(WdfDpcEnqueue)(
173 __in
175 __in
176 WDFDPC Dpc
177 )
178
179/*++
180
181Routine Description:
182
183 Enqueue the DPC to run at a system determined time
184
185Arguments:
186
187 WDFDPC - Handle to WDFDPC object created with WdfDpcCreate.
188
189Returns:
190
191--*/
192
193{
194 FxDpc* pFxDpc;
195
197 Dpc,
199 (PVOID*)&pFxDpc);
200
202}
203
204
209WDFEXPORT(WdfDpcCancel)(
210 __in
212 __in
213 WDFDPC Dpc,
214 __in
216 )
217
218/*++
219
220Routine Description:
221
222 Attempt to cancel the DPC and returns status
223
224Arguments:
225
226 WDFDPC - Handle to WDFDPC object created with WdfDpcCreate.
227
228Returns:
229
230 TRUE - DPC was cancelled, and was not run
231
232 FALSE - DPC was not cancelled, has run, is running, or will run
233
234--*/
235
236{
240
242 Dpc,
244 (PVOID*)&pFxDpc,
246
247 if (Wait) {
249 if (!NT_SUCCESS(status)) {
250 return FALSE;
251 }
252 }
253
255}
256
257
258
262WDFEXPORT(WdfDpcGetParentObject)(
263 __in
265 __in
266 WDFDPC Dpc
267 )
268
269/*++
270
271Routine Description:
272
273 Return the parent parent object supplied to WdfDpcCreate.
274
275Arguments:
276
277 WDFDPC - Handle to WDFDPC object created with WdfDpcCreate.
278
279Returns:
280
281--*/
282
283{
284 FxDpc* pFxDpc;
285
287 Dpc,
289 (PVOID*)&pFxDpc);
290
291 return pFxDpc->GetObject();
292}
293
294} // extern "C"
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxdpc.hpp:63
BOOLEAN Cancel(__in BOOLEAN Wait)
Definition: fxdpc.cpp:261
WDFOBJECT GetObject(VOID)
Definition: fxdpc.hpp:125
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_DPC_CONFIG Config, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObject *ParentObject, __out WDFDPC *Dpc)
Definition: fxdpc.cpp:79
KDPC * GetDpcPtr(VOID)
Definition: fxdpc.hpp:117
#define __in
Definition: dbghelp.h:35
#define __out
Definition: dbghelp.h:62
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_when(cond, annotes)
Definition: driverspecs.h:335
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_Must_inspect_result_ __in PWDF_DPC_CONFIG __in PWDF_OBJECT_ATTRIBUTES Attributes
Definition: fxdpcapi.cpp:49
return KeInsertQueueDpc(pFxDpc->GetDpcPtr(), NULL, NULL)
_Must_inspect_result_ __in PWDF_DPC_CONFIG __in PWDF_OBJECT_ATTRIBUTES __out WDFDPC * Dpc
Definition: fxdpcapi.cpp:84
FxDpc * pFxDpc
Definition: fxdpcapi.cpp:238
NTSTATUS status
Definition: fxdpcapi.cpp:87
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Dpc, FX_TYPE_DPC,(PVOID *)&pFxDpc)
FxObjectHandleGetPtrAndGlobals(pFxDriverGlobals, Attributes->ParentObject, FX_TYPE_OBJECT,(PVOID *)&pParent, &pFxDriverGlobals)
_Must_inspect_result_ __in PWDF_DPC_CONFIG Config
Definition: fxdpcapi.cpp:47
FxObject * pParent
Definition: fxdpcapi.cpp:86
__in WDFDPC __in BOOLEAN Wait
Definition: fxdpcapi.cpp:236
pFxDriverGlobals
Definition: fxdpcapi.cpp:89
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_DPC
Definition: fxtypes.h:68
@ FX_VALIDATE_OPTION_PARENT_REQUIRED
_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)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ketypes.h:699
Definition: ps.c:97
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170