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 EVT_WDF_DRIVER_DEVICE_ADD( 71 _In_ 72 WDFDRIVER Driver, 73 _Inout_ 74 PWDFDEVICE_INIT DeviceInit 75 ); 76 77 typedef EVT_WDF_DRIVER_DEVICE_ADD *PFN_WDF_DRIVER_DEVICE_ADD; 78 79 typedef 80 _Function_class_(EVT_WDF_DRIVER_UNLOAD) 81 _IRQL_requires_same_ 82 _IRQL_requires_max_(PASSIVE_LEVEL) 83 VOID 84 EVT_WDF_DRIVER_UNLOAD( 85 _In_ 86 WDFDRIVER Driver 87 ); 88 89 typedef EVT_WDF_DRIVER_UNLOAD *PFN_WDF_DRIVER_UNLOAD; 90 91 92 // 93 // Used by WPP Tracing (modeled after WPP's WppTraceCallback (in km-init.tpl)) 94 // 95 typedef 96 _Function_class_(EVT_WDF_TRACE_CALLBACK) 97 _IRQL_requires_same_ 98 _IRQL_requires_max_(PASSIVE_LEVEL) 99 NTSTATUS 100 EVT_WDF_TRACE_CALLBACK( 101 _In_ 102 UCHAR minorFunction, 103 _In_opt_ 104 PVOID dataPath, 105 _In_ 106 ULONG bufferLength, 107 _Inout_updates_bytes_(bufferLength) 108 PVOID buffer, 109 _In_ 110 PVOID context, 111 _Out_ 112 PULONG size 113 ); 114 115 typedef EVT_WDF_TRACE_CALLBACK *PFN_WDF_TRACE_CALLBACK; 116 117 typedef struct _WDF_DRIVER_CONFIG { 118 // 119 // Size of this structure in bytes 120 // 121 ULONG Size; 122 123 // 124 // Event callbacks 125 // 126 PFN_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd; 127 128 PFN_WDF_DRIVER_UNLOAD EvtDriverUnload; 129 130 // 131 // Combination of WDF_DRIVER_INIT_FLAGS values 132 // 133 ULONG DriverInitFlags; 134 135 // 136 // Pool tag to use for all allocations made by the framework on behalf of 137 // the client driver. 138 // 139 ULONG DriverPoolTag; 140 141 } WDF_DRIVER_CONFIG, *PWDF_DRIVER_CONFIG; 142 143 VOID 144 FORCEINLINE 145 WDF_DRIVER_CONFIG_INIT( 146 _Out_ PWDF_DRIVER_CONFIG Config, 147 _In_opt_ PFN_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd 148 ) 149 { 150 RtlZeroMemory(Config, sizeof(WDF_DRIVER_CONFIG)); 151 152 Config->Size = sizeof(WDF_DRIVER_CONFIG); 153 Config->EvtDriverDeviceAdd = EvtDriverDeviceAdd; 154 } 155 156 typedef struct _WDF_DRIVER_VERSION_AVAILABLE_PARAMS { 157 // 158 // Size of the structure in bytes 159 // 160 ULONG Size; 161 162 // 163 // Major Version requested 164 // 165 ULONG MajorVersion; 166 167 // 168 // Minor Version requested 169 // 170 ULONG MinorVersion; 171 172 } WDF_DRIVER_VERSION_AVAILABLE_PARAMS, *PWDF_DRIVER_VERSION_AVAILABLE_PARAMS; 173 174 VOID 175 FORCEINLINE 176 WDF_DRIVER_VERSION_AVAILABLE_PARAMS_INIT( 177 _Out_ PWDF_DRIVER_VERSION_AVAILABLE_PARAMS Params, 178 _In_ ULONG MajorVersion, 179 _In_ ULONG MinorVersion 180 ) 181 { 182 RtlZeroMemory(Params, sizeof(WDF_DRIVER_VERSION_AVAILABLE_PARAMS)); 183 184 Params->Size = sizeof(WDF_DRIVER_VERSION_AVAILABLE_PARAMS); 185 Params->MajorVersion = MajorVersion; 186 Params->MinorVersion = MinorVersion; 187 } 188 189 WDFDRIVER 190 FORCEINLINE 191 WdfGetDriver( 192 VOID 193 ) 194 { 195 return WdfDriverGlobals->Driver; 196 } 197 198 // 199 // WDF Function: WdfDriverCreate 200 // 201 typedef 202 _Must_inspect_result_ 203 _IRQL_requires_max_(PASSIVE_LEVEL) 204 WDFAPI 205 NTSTATUS 206 (*PFN_WDFDRIVERCREATE)( 207 _In_ 208 PWDF_DRIVER_GLOBALS DriverGlobals, 209 _In_ 210 PDRIVER_OBJECT DriverObject, 211 _In_ 212 PCUNICODE_STRING RegistryPath, 213 _In_opt_ 214 PWDF_OBJECT_ATTRIBUTES DriverAttributes, 215 _In_ 216 PWDF_DRIVER_CONFIG DriverConfig, 217 _Out_opt_ 218 WDFDRIVER* Driver 219 ); 220 221 _Must_inspect_result_ 222 _IRQL_requires_max_(PASSIVE_LEVEL) 223 NTSTATUS 224 FORCEINLINE 225 WdfDriverCreate( 226 _In_ 227 PDRIVER_OBJECT DriverObject, 228 _In_ 229 PCUNICODE_STRING RegistryPath, 230 _In_opt_ 231 PWDF_OBJECT_ATTRIBUTES DriverAttributes, 232 _In_ 233 PWDF_DRIVER_CONFIG DriverConfig, 234 _Out_opt_ 235 WDFDRIVER* Driver 236 ) 237 { 238 return ((PFN_WDFDRIVERCREATE) WdfFunctions[WdfDriverCreateTableIndex])(WdfDriverGlobals, DriverObject, RegistryPath, DriverAttributes, DriverConfig, Driver); 239 } 240 241 // 242 // WDF Function: WdfDriverGetRegistryPath 243 // 244 typedef 245 _IRQL_requires_max_(PASSIVE_LEVEL) 246 WDFAPI 247 PWSTR 248 (*PFN_WDFDRIVERGETREGISTRYPATH)( 249 _In_ 250 PWDF_DRIVER_GLOBALS DriverGlobals, 251 _In_ 252 WDFDRIVER Driver 253 ); 254 255 _IRQL_requires_max_(PASSIVE_LEVEL) 256 PWSTR 257 FORCEINLINE 258 WdfDriverGetRegistryPath( 259 _In_ 260 WDFDRIVER Driver 261 ) 262 { 263 return ((PFN_WDFDRIVERGETREGISTRYPATH) WdfFunctions[WdfDriverGetRegistryPathTableIndex])(WdfDriverGlobals, Driver); 264 } 265 266 // 267 // WDF Function: WdfDriverWdmGetDriverObject 268 // 269 typedef 270 _IRQL_requires_max_(DISPATCH_LEVEL) 271 WDFAPI 272 PDRIVER_OBJECT 273 (*PFN_WDFDRIVERWDMGETDRIVEROBJECT)( 274 _In_ 275 PWDF_DRIVER_GLOBALS DriverGlobals, 276 _In_ 277 WDFDRIVER Driver 278 ); 279 280 _IRQL_requires_max_(DISPATCH_LEVEL) 281 PDRIVER_OBJECT 282 FORCEINLINE 283 WdfDriverWdmGetDriverObject( 284 _In_ 285 WDFDRIVER Driver 286 ) 287 { 288 return ((PFN_WDFDRIVERWDMGETDRIVEROBJECT) WdfFunctions[WdfDriverWdmGetDriverObjectTableIndex])(WdfDriverGlobals, Driver); 289 } 290 291 // 292 // WDF Function: WdfDriverOpenParametersRegistryKey 293 // 294 typedef 295 _Must_inspect_result_ 296 _IRQL_requires_max_(PASSIVE_LEVEL) 297 WDFAPI 298 NTSTATUS 299 (*PFN_WDFDRIVEROPENPARAMETERSREGISTRYKEY)( 300 _In_ 301 PWDF_DRIVER_GLOBALS DriverGlobals, 302 _In_ 303 WDFDRIVER Driver, 304 _In_ 305 ACCESS_MASK DesiredAccess, 306 _In_opt_ 307 PWDF_OBJECT_ATTRIBUTES KeyAttributes, 308 _Out_ 309 WDFKEY* Key 310 ); 311 312 _Must_inspect_result_ 313 _IRQL_requires_max_(PASSIVE_LEVEL) 314 NTSTATUS 315 FORCEINLINE 316 WdfDriverOpenParametersRegistryKey( 317 _In_ 318 WDFDRIVER Driver, 319 _In_ 320 ACCESS_MASK DesiredAccess, 321 _In_opt_ 322 PWDF_OBJECT_ATTRIBUTES KeyAttributes, 323 _Out_ 324 WDFKEY* Key 325 ) 326 { 327 return ((PFN_WDFDRIVEROPENPARAMETERSREGISTRYKEY) WdfFunctions[WdfDriverOpenParametersRegistryKeyTableIndex])(WdfDriverGlobals, Driver, DesiredAccess, KeyAttributes, Key); 328 } 329 330 // 331 // WDF Function: WdfWdmDriverGetWdfDriverHandle 332 // 333 typedef 334 _IRQL_requires_max_(DISPATCH_LEVEL) 335 WDFAPI 336 WDFDRIVER 337 (*PFN_WDFWDMDRIVERGETWDFDRIVERHANDLE)( 338 _In_ 339 PWDF_DRIVER_GLOBALS DriverGlobals, 340 _In_ 341 PDRIVER_OBJECT DriverObject 342 ); 343 344 _IRQL_requires_max_(DISPATCH_LEVEL) 345 WDFDRIVER 346 FORCEINLINE 347 WdfWdmDriverGetWdfDriverHandle( 348 _In_ 349 PDRIVER_OBJECT DriverObject 350 ) 351 { 352 return ((PFN_WDFWDMDRIVERGETWDFDRIVERHANDLE) WdfFunctions[WdfWdmDriverGetWdfDriverHandleTableIndex])(WdfDriverGlobals, DriverObject); 353 } 354 355 // 356 // WDF Function: WdfDriverRegisterTraceInfo 357 // 358 typedef 359 _Must_inspect_result_ 360 _IRQL_requires_max_(PASSIVE_LEVEL) 361 WDFAPI 362 NTSTATUS 363 (*PFN_WDFDRIVERREGISTERTRACEINFO)( 364 _In_ 365 PWDF_DRIVER_GLOBALS DriverGlobals, 366 _In_ 367 PDRIVER_OBJECT DriverObject, 368 _In_ 369 PFN_WDF_TRACE_CALLBACK EvtTraceCallback, 370 _In_ 371 PVOID ControlBlock 372 ); 373 374 _Must_inspect_result_ 375 _IRQL_requires_max_(PASSIVE_LEVEL) 376 NTSTATUS 377 FORCEINLINE 378 WdfDriverRegisterTraceInfo( 379 _In_ 380 PDRIVER_OBJECT DriverObject, 381 _In_ 382 PFN_WDF_TRACE_CALLBACK EvtTraceCallback, 383 _In_ 384 PVOID ControlBlock 385 ) 386 { 387 return ((PFN_WDFDRIVERREGISTERTRACEINFO) WdfFunctions[WdfDriverRegisterTraceInfoTableIndex])(WdfDriverGlobals, DriverObject, EvtTraceCallback, ControlBlock); 388 } 389 390 // 391 // WDF Function: WdfDriverRetrieveVersionString 392 // 393 typedef 394 _Must_inspect_result_ 395 _IRQL_requires_max_(PASSIVE_LEVEL) 396 WDFAPI 397 NTSTATUS 398 (*PFN_WDFDRIVERRETRIEVEVERSIONSTRING)( 399 _In_ 400 PWDF_DRIVER_GLOBALS DriverGlobals, 401 _In_ 402 WDFDRIVER Driver, 403 _In_ 404 WDFSTRING String 405 ); 406 407 _Must_inspect_result_ 408 _IRQL_requires_max_(PASSIVE_LEVEL) 409 NTSTATUS 410 FORCEINLINE 411 WdfDriverRetrieveVersionString( 412 _In_ 413 WDFDRIVER Driver, 414 _In_ 415 WDFSTRING String 416 ) 417 { 418 return ((PFN_WDFDRIVERRETRIEVEVERSIONSTRING) WdfFunctions[WdfDriverRetrieveVersionStringTableIndex])(WdfDriverGlobals, Driver, String); 419 } 420 421 // 422 // WDF Function: WdfDriverIsVersionAvailable 423 // 424 typedef 425 _Must_inspect_result_ 426 _IRQL_requires_max_(PASSIVE_LEVEL) 427 WDFAPI 428 BOOLEAN 429 (*PFN_WDFDRIVERISVERSIONAVAILABLE)( 430 _In_ 431 PWDF_DRIVER_GLOBALS DriverGlobals, 432 _In_ 433 WDFDRIVER Driver, 434 _In_ 435 PWDF_DRIVER_VERSION_AVAILABLE_PARAMS VersionAvailableParams 436 ); 437 438 _Must_inspect_result_ 439 _IRQL_requires_max_(PASSIVE_LEVEL) 440 BOOLEAN 441 FORCEINLINE 442 WdfDriverIsVersionAvailable( 443 _In_ 444 WDFDRIVER Driver, 445 _In_ 446 PWDF_DRIVER_VERSION_AVAILABLE_PARAMS VersionAvailableParams 447 ) 448 { 449 return ((PFN_WDFDRIVERISVERSIONAVAILABLE) WdfFunctions[WdfDriverIsVersionAvailableTableIndex])(WdfDriverGlobals, Driver, VersionAvailableParams); 450 } 451 452 453 454 #endif // (NTDDI_VERSION >= NTDDI_WIN2K) 455 456 457 WDF_EXTERN_C_END 458 459 #endif // _WDFDRIVER_H_ 460 461