xref: /reactos/sdk/include/wdf/kmdf/1.17/wdfdriver.h (revision 003b19dc)
1 /*++
2 
3 Copyright (c) Microsoft Corporation.  All rights reserved.
4 
5 _WdfVersionBuild_
6 
7 Module Name:
8 
9     wdfdriver.h
10 
11 Abstract:
12 
13     This is the interfaces for the Windows Driver Framework Driver object
14 
15 Environment:
16 
17     kernel mode only
18 
19 Revision History:
20 
21 --*/
22 
23 //
24 // NOTE: This header is generated by stubwork.  Please make any
25 //       modifications to the corresponding template files
26 //       (.x or .y) and use stubwork to regenerate the header
27 //
28 
29 #ifndef _WDFDRIVER_H_
30 #define _WDFDRIVER_H_
31 
32 #ifndef WDF_EXTERN_C
33   #ifdef __cplusplus
34     #define WDF_EXTERN_C       extern "C"
35     #define WDF_EXTERN_C_START extern "C" {
36     #define WDF_EXTERN_C_END   }
37   #else
38     #define WDF_EXTERN_C
39     #define WDF_EXTERN_C_START
40     #define WDF_EXTERN_C_END
41   #endif
42 #endif
43 
44 WDF_EXTERN_C_START
45 
46 
47 
48 #if (NTDDI_VERSION >= NTDDI_WIN2K)
49 
50 typedef enum _WDF_DRIVER_INIT_FLAGS {
51     WdfDriverInitNonPnpDriver = 0x00000001, //  If set, no Add Device routine is assigned.
52     WdfDriverInitNoDispatchOverride = 0x00000002, //  Useful for miniports.
53     WdfVerifyOn = 0x00000004, //  Controls whether WDFVERIFY macros are live.
54     WdfVerifierOn = 0x00000008, //  Top level verififer flag.
55 } WDF_DRIVER_INIT_FLAGS;
56 
57 
58 
59 #define WDF_TRACE_ID ('TRAC')
60 
61 //
62 // Callbacks for FxDriver
63 //
64 
65 typedef
66 _Function_class_(EVT_WDF_DRIVER_DEVICE_ADD)
67 _IRQL_requires_same_
68 _IRQL_requires_max_(PASSIVE_LEVEL)
69 NTSTATUS
70 STDCALL
71 EVT_WDF_DRIVER_DEVICE_ADD(
72     _In_
73     WDFDRIVER Driver,
74     _Inout_
75     PWDFDEVICE_INIT DeviceInit
76     );
77 
78 typedef EVT_WDF_DRIVER_DEVICE_ADD *PFN_WDF_DRIVER_DEVICE_ADD;
79 
80 typedef
81 _Function_class_(EVT_WDF_DRIVER_UNLOAD)
82 _IRQL_requires_same_
83 _IRQL_requires_max_(PASSIVE_LEVEL)
84 VOID
85 STDCALL
86 EVT_WDF_DRIVER_UNLOAD(
87     _In_
88     WDFDRIVER Driver
89     );
90 
91 typedef EVT_WDF_DRIVER_UNLOAD *PFN_WDF_DRIVER_UNLOAD;
92 
93 
94 //
95 // Used by WPP Tracing (modeled after WPP's WppTraceCallback (in km-init.tpl))
96 //
97 typedef
98 _Function_class_(EVT_WDF_TRACE_CALLBACK)
99 _IRQL_requires_same_
100 _IRQL_requires_max_(PASSIVE_LEVEL)
101 NTSTATUS
102 STDCALL
103 EVT_WDF_TRACE_CALLBACK(
104     _In_
105     UCHAR   minorFunction,
106     _In_opt_
107     PVOID   dataPath,
108     _In_
109     ULONG   bufferLength,
110     _Inout_updates_bytes_(bufferLength)
111     PVOID   buffer,
112     _In_
113     PVOID   context,
114     _Out_
115     PULONG  size
116     );
117 
118 typedef EVT_WDF_TRACE_CALLBACK *PFN_WDF_TRACE_CALLBACK;
119 
120 typedef struct _WDF_DRIVER_CONFIG {
121     //
122     // Size of this structure in bytes
123     //
124     ULONG Size;
125 
126     //
127     // Event callbacks
128     //
129     PFN_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd;
130 
131     PFN_WDF_DRIVER_UNLOAD    EvtDriverUnload;
132 
133     //
134     // Combination of WDF_DRIVER_INIT_FLAGS values
135     //
136     ULONG DriverInitFlags;
137 
138     //
139     // Pool tag to use for all allocations made by the framework on behalf of
140     // the client driver.
141     //
142     ULONG DriverPoolTag;
143 
144 } WDF_DRIVER_CONFIG, *PWDF_DRIVER_CONFIG;
145 
146 FORCEINLINE
147 VOID
148 WDF_DRIVER_CONFIG_INIT(
149     _Out_ PWDF_DRIVER_CONFIG Config,
150     _In_opt_ PFN_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd
151     )
152 {
153     RtlZeroMemory(Config, sizeof(WDF_DRIVER_CONFIG));
154 
155     Config->Size = sizeof(WDF_DRIVER_CONFIG);
156     Config->EvtDriverDeviceAdd = EvtDriverDeviceAdd;
157 }
158 
159 typedef struct _WDF_DRIVER_VERSION_AVAILABLE_PARAMS {
160     //
161     // Size of the structure in bytes
162     //
163     ULONG Size;
164 
165     //
166     // Major Version requested
167     //
168     ULONG MajorVersion;
169 
170     //
171     // Minor Version requested
172     //
173     ULONG MinorVersion;
174 
175 } WDF_DRIVER_VERSION_AVAILABLE_PARAMS, *PWDF_DRIVER_VERSION_AVAILABLE_PARAMS;
176 
177 FORCEINLINE
178 VOID
179 WDF_DRIVER_VERSION_AVAILABLE_PARAMS_INIT(
180     _Out_ PWDF_DRIVER_VERSION_AVAILABLE_PARAMS Params,
181     _In_ ULONG MajorVersion,
182     _In_ ULONG MinorVersion
183     )
184 {
185     RtlZeroMemory(Params, sizeof(WDF_DRIVER_VERSION_AVAILABLE_PARAMS));
186 
187     Params->Size = sizeof(WDF_DRIVER_VERSION_AVAILABLE_PARAMS);
188     Params->MajorVersion = MajorVersion;
189     Params->MinorVersion = MinorVersion;
190 }
191 
192 FORCEINLINE
193 WDFDRIVER
194 WdfGetDriver(
195     VOID
196     )
197 {
198     return WdfDriverGlobals->Driver;
199 }
200 
201 //
202 // WDF Function: WdfDriverCreate
203 //
204 typedef
205 _Must_inspect_result_
206 _IRQL_requires_max_(PASSIVE_LEVEL)
207 WDFAPI
208 NTSTATUS
209 (STDCALL *PFN_WDFDRIVERCREATE)(
210     _In_
211     PWDF_DRIVER_GLOBALS DriverGlobals,
212     _In_
213     PDRIVER_OBJECT DriverObject,
214     _In_
215     PCUNICODE_STRING RegistryPath,
216     _In_opt_
217     PWDF_OBJECT_ATTRIBUTES DriverAttributes,
218     _In_
219     PWDF_DRIVER_CONFIG DriverConfig,
220     _Out_opt_
221     WDFDRIVER* Driver
222     );
223 
224 _Must_inspect_result_
225 _IRQL_requires_max_(PASSIVE_LEVEL)
226 FORCEINLINE
227 NTSTATUS
228 WdfDriverCreate(
229     _In_
230     PDRIVER_OBJECT DriverObject,
231     _In_
232     PCUNICODE_STRING RegistryPath,
233     _In_opt_
234     PWDF_OBJECT_ATTRIBUTES DriverAttributes,
235     _In_
236     PWDF_DRIVER_CONFIG DriverConfig,
237     _Out_opt_
238     WDFDRIVER* Driver
239     )
240 {
241     return ((PFN_WDFDRIVERCREATE) WdfFunctions[WdfDriverCreateTableIndex])(WdfDriverGlobals, DriverObject, RegistryPath, DriverAttributes, DriverConfig, Driver);
242 }
243 
244 //
245 // WDF Function: WdfDriverGetRegistryPath
246 //
247 typedef
248 _IRQL_requires_max_(PASSIVE_LEVEL)
249 WDFAPI
250 PWSTR
251 (STDCALL *PFN_WDFDRIVERGETREGISTRYPATH)(
252     _In_
253     PWDF_DRIVER_GLOBALS DriverGlobals,
254     _In_
255     WDFDRIVER Driver
256     );
257 
258 _IRQL_requires_max_(PASSIVE_LEVEL)
259 FORCEINLINE
260 PWSTR
261 WdfDriverGetRegistryPath(
262     _In_
263     WDFDRIVER Driver
264     )
265 {
266     return ((PFN_WDFDRIVERGETREGISTRYPATH) WdfFunctions[WdfDriverGetRegistryPathTableIndex])(WdfDriverGlobals, Driver);
267 }
268 
269 //
270 // WDF Function: WdfDriverWdmGetDriverObject
271 //
272 typedef
273 _IRQL_requires_max_(DISPATCH_LEVEL)
274 WDFAPI
275 PDRIVER_OBJECT
276 (STDCALL *PFN_WDFDRIVERWDMGETDRIVEROBJECT)(
277     _In_
278     PWDF_DRIVER_GLOBALS DriverGlobals,
279     _In_
280     WDFDRIVER Driver
281     );
282 
283 _IRQL_requires_max_(DISPATCH_LEVEL)
284 FORCEINLINE
285 PDRIVER_OBJECT
286 WdfDriverWdmGetDriverObject(
287     _In_
288     WDFDRIVER Driver
289     )
290 {
291     return ((PFN_WDFDRIVERWDMGETDRIVEROBJECT) WdfFunctions[WdfDriverWdmGetDriverObjectTableIndex])(WdfDriverGlobals, Driver);
292 }
293 
294 //
295 // WDF Function: WdfDriverOpenParametersRegistryKey
296 //
297 typedef
298 _Must_inspect_result_
299 _IRQL_requires_max_(PASSIVE_LEVEL)
300 WDFAPI
301 NTSTATUS
302 (STDCALL *PFN_WDFDRIVEROPENPARAMETERSREGISTRYKEY)(
303     _In_
304     PWDF_DRIVER_GLOBALS DriverGlobals,
305     _In_
306     WDFDRIVER Driver,
307     _In_
308     ACCESS_MASK DesiredAccess,
309     _In_opt_
310     PWDF_OBJECT_ATTRIBUTES KeyAttributes,
311     _Out_
312     WDFKEY* Key
313     );
314 
315 _Must_inspect_result_
316 _IRQL_requires_max_(PASSIVE_LEVEL)
317 FORCEINLINE
318 NTSTATUS
319 WdfDriverOpenParametersRegistryKey(
320     _In_
321     WDFDRIVER Driver,
322     _In_
323     ACCESS_MASK DesiredAccess,
324     _In_opt_
325     PWDF_OBJECT_ATTRIBUTES KeyAttributes,
326     _Out_
327     WDFKEY* Key
328     )
329 {
330     return ((PFN_WDFDRIVEROPENPARAMETERSREGISTRYKEY) WdfFunctions[WdfDriverOpenParametersRegistryKeyTableIndex])(WdfDriverGlobals, Driver, DesiredAccess, KeyAttributes, Key);
331 }
332 
333 //
334 // WDF Function: WdfWdmDriverGetWdfDriverHandle
335 //
336 typedef
337 _IRQL_requires_max_(DISPATCH_LEVEL)
338 WDFAPI
339 WDFDRIVER
340 (STDCALL *PFN_WDFWDMDRIVERGETWDFDRIVERHANDLE)(
341     _In_
342     PWDF_DRIVER_GLOBALS DriverGlobals,
343     _In_
344     PDRIVER_OBJECT DriverObject
345     );
346 
347 _IRQL_requires_max_(DISPATCH_LEVEL)
348 FORCEINLINE
349 WDFDRIVER
350 WdfWdmDriverGetWdfDriverHandle(
351     _In_
352     PDRIVER_OBJECT DriverObject
353     )
354 {
355     return ((PFN_WDFWDMDRIVERGETWDFDRIVERHANDLE) WdfFunctions[WdfWdmDriverGetWdfDriverHandleTableIndex])(WdfDriverGlobals, DriverObject);
356 }
357 
358 //
359 // WDF Function: WdfDriverRegisterTraceInfo
360 //
361 typedef
362 _Must_inspect_result_
363 _IRQL_requires_max_(PASSIVE_LEVEL)
364 WDFAPI
365 NTSTATUS
366 (STDCALL *PFN_WDFDRIVERREGISTERTRACEINFO)(
367     _In_
368     PWDF_DRIVER_GLOBALS DriverGlobals,
369     _In_
370     PDRIVER_OBJECT DriverObject,
371     _In_
372     PFN_WDF_TRACE_CALLBACK EvtTraceCallback,
373     _In_
374     PVOID ControlBlock
375     );
376 
377 _Must_inspect_result_
378 _IRQL_requires_max_(PASSIVE_LEVEL)
379 FORCEINLINE
380 NTSTATUS
381 WdfDriverRegisterTraceInfo(
382     _In_
383     PDRIVER_OBJECT DriverObject,
384     _In_
385     PFN_WDF_TRACE_CALLBACK EvtTraceCallback,
386     _In_
387     PVOID ControlBlock
388     )
389 {
390     return ((PFN_WDFDRIVERREGISTERTRACEINFO) WdfFunctions[WdfDriverRegisterTraceInfoTableIndex])(WdfDriverGlobals, DriverObject, EvtTraceCallback, ControlBlock);
391 }
392 
393 //
394 // WDF Function: WdfDriverRetrieveVersionString
395 //
396 typedef
397 _Must_inspect_result_
398 _IRQL_requires_max_(PASSIVE_LEVEL)
399 WDFAPI
400 NTSTATUS
401 (STDCALL *PFN_WDFDRIVERRETRIEVEVERSIONSTRING)(
402     _In_
403     PWDF_DRIVER_GLOBALS DriverGlobals,
404     _In_
405     WDFDRIVER Driver,
406     _In_
407     WDFSTRING String
408     );
409 
410 _Must_inspect_result_
411 _IRQL_requires_max_(PASSIVE_LEVEL)
412 FORCEINLINE
413 NTSTATUS
414 WdfDriverRetrieveVersionString(
415     _In_
416     WDFDRIVER Driver,
417     _In_
418     WDFSTRING String
419     )
420 {
421     return ((PFN_WDFDRIVERRETRIEVEVERSIONSTRING) WdfFunctions[WdfDriverRetrieveVersionStringTableIndex])(WdfDriverGlobals, Driver, String);
422 }
423 
424 //
425 // WDF Function: WdfDriverIsVersionAvailable
426 //
427 typedef
428 _Must_inspect_result_
429 _IRQL_requires_max_(PASSIVE_LEVEL)
430 WDFAPI
431 BOOLEAN
432 (STDCALL *PFN_WDFDRIVERISVERSIONAVAILABLE)(
433     _In_
434     PWDF_DRIVER_GLOBALS DriverGlobals,
435     _In_
436     WDFDRIVER Driver,
437     _In_
438     PWDF_DRIVER_VERSION_AVAILABLE_PARAMS VersionAvailableParams
439     );
440 
441 _Must_inspect_result_
442 _IRQL_requires_max_(PASSIVE_LEVEL)
443 FORCEINLINE
444 BOOLEAN
445 WdfDriverIsVersionAvailable(
446     _In_
447     WDFDRIVER Driver,
448     _In_
449     PWDF_DRIVER_VERSION_AVAILABLE_PARAMS VersionAvailableParams
450     )
451 {
452     return ((PFN_WDFDRIVERISVERSIONAVAILABLE) WdfFunctions[WdfDriverIsVersionAvailableTableIndex])(WdfDriverGlobals, Driver, VersionAvailableParams);
453 }
454 
455 
456 
457 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
458 
459 
460 WDF_EXTERN_C_END
461 
462 #endif // _WDFDRIVER_H_
463 
464