1 /* 2 * wdm.h 3 * 4 * Windows NT WDM Driver Developer Kit 5 * 6 * This file is part of the ReactOS DDK package. 7 * 8 * Contributors: 9 * Amine Khaldi 10 * Timo Kreuzer (timo.kreuzer (at) reactos.org) 11 * 12 * THIS SOFTWARE IS NOT COPYRIGHTED 13 * 14 * This source code is offered for use in the public domain. You may 15 * use, modify or distribute it freely. 16 * 17 * This code is distributed in the hope that it will be useful but 18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 * DISCLAIMED. This includes but is not limited to warranties of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 * 22 */ 23 #pragma once 24 25 #ifndef _WDMDDK_ 26 #define _WDMDDK_ 27 28 #define WDM_MAJORVERSION 0x06 29 #define WDM_MINORVERSION 0x00 30 31 /* Included via ntddk.h? */ 32 #ifndef _NTDDK_ 33 #define _NTDDK_ 34 #define _WDM_INCLUDED_ 35 #define _DDK_DRIVER_ 36 #define NO_INTERLOCKED_INTRINSICS 37 #endif /* _NTDDK_ */ 38 39 /* Dependencies */ 40 #define NT_INCLUDED 41 #include <excpt.h> 42 #include <ntdef.h> 43 #include <ntstatus.h> 44 #include <ntiologc.h> 45 46 #ifndef GUID_DEFINED 47 #include <guiddef.h> 48 #endif 49 50 #ifdef _MAC 51 #ifndef _INC_STRING 52 #include <string.h> 53 #endif /* _INC_STRING */ 54 #else 55 #include <string.h> 56 #endif /* _MAC */ 57 58 #ifndef _KTMTYPES_ 59 typedef GUID UOW, *PUOW; 60 #endif 61 62 typedef GUID *PGUID; 63 64 #if (NTDDI_VERSION >= NTDDI_WINXP) 65 #include <dpfilter.h> 66 #endif 67 68 #include "intrin.h" 69 70 #ifdef __cplusplus 71 extern "C" { 72 #endif 73 74 #if !defined(_NTHALDLL_) && !defined(_BLDR_) 75 #define NTHALAPI DECLSPEC_IMPORT 76 #else 77 #define NTHALAPI 78 #endif 79 80 /* For ReactOS */ 81 #if !defined(_NTOSKRNL_) && !defined(_BLDR_) 82 #define NTKERNELAPI DECLSPEC_IMPORT 83 #else 84 #define NTKERNELAPI 85 #endif 86 87 #if defined(_X86_) && !defined(_NTHAL_) 88 #define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT 89 #elif defined(_X86_) 90 #define _DECL_HAL_KE_IMPORT 91 #else 92 #define _DECL_HAL_KE_IMPORT NTKERNELAPI 93 #endif 94 95 #if defined(_WIN64) 96 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8) 97 #else 98 #define POINTER_ALIGNMENT 99 #endif 100 101 #if defined(_MSC_VER) 102 /* Disable some warnings */ 103 #pragma warning(disable:4115) /* Named type definition in parentheses */ 104 #pragma warning(disable:4201) /* Nameless unions and structs */ 105 #pragma warning(disable:4214) /* Bit fields of other types than int */ 106 #pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ 107 108 /* Indicate if #pragma alloc_text() is supported */ 109 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) 110 #define ALLOC_PRAGMA 1 111 #endif 112 113 /* Indicate if #pragma data_seg() is supported */ 114 #if defined(_M_IX86) || defined(_M_AMD64) 115 #define ALLOC_DATA_PRAGMA 1 116 #endif 117 118 #endif /* _MSC_VER */ 119 120 #if defined(_WIN64) 121 #if !defined(USE_DMA_MACROS) && !defined(_NTHAL_) 122 #define USE_DMA_MACROS 123 #endif 124 #if !defined(NO_LEGACY_DRIVERS) && !defined(__REACTOS__) 125 #define NO_LEGACY_DRIVERS 126 #endif 127 #endif /* defined(_WIN64) */ 128 129 /* Forward declarations */ 130 struct _IRP; 131 struct _MDL; 132 struct _KAPC; 133 struct _KDPC; 134 struct _FILE_OBJECT; 135 struct _DMA_ADAPTER; 136 struct _DEVICE_OBJECT; 137 struct _DRIVER_OBJECT; 138 struct _IO_STATUS_BLOCK; 139 struct _DEVICE_DESCRIPTION; 140 struct _SCATTER_GATHER_LIST; 141 struct _DRIVE_LAYOUT_INFORMATION; 142 struct _COMPRESSED_DATA_INFO; 143 struct _IO_RESOURCE_DESCRIPTOR; 144 145 /* Structures not exposed to drivers */ 146 typedef struct _OBJECT_TYPE *POBJECT_TYPE; 147 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; 148 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; 149 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; 150 typedef struct _EPROCESS *PEPROCESS; 151 typedef struct _ETHREAD *PETHREAD; 152 typedef struct _IO_TIMER *PIO_TIMER; 153 typedef struct _KINTERRUPT *PKINTERRUPT; 154 typedef struct _KPROCESS *PKPROCESS; 155 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; 156 typedef struct _CONTEXT *PCONTEXT; 157 158 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) 159 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; 160 #elif defined(_WDM_INCLUDED_) 161 typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; 162 #else 163 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; 164 #endif 165 166 #ifndef DEFINE_GUIDEX 167 #ifdef _MSC_VER 168 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name 169 #else 170 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name 171 #endif 172 #endif /* DEFINE_GUIDEX */ 173 174 #ifndef STATICGUIDOF 175 #define STATICGUIDOF(guid) STATIC_##guid 176 #endif 177 178 /* GUID Comparison */ 179 #ifndef __IID_ALIGNED__ 180 #define __IID_ALIGNED__ 181 #ifdef __cplusplus 182 inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) 183 { 184 return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && 185 (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); 186 } 187 #else 188 #define IsEqualGUIDAligned(guid1, guid2) \ 189 ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ 190 (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) 191 #endif /* __cplusplus */ 192 #endif /* !__IID_ALIGNED__ */ 193 194 195 /****************************************************************************** 196 * INTERLOCKED Functions * 197 ******************************************************************************/ 198 // 199 // Intrinsics (note: taken from our winnt.h) 200 // FIXME: 64-bit 201 // 202 #if defined(__GNUC__) 203 204 static __inline__ BOOLEAN 205 InterlockedBitTestAndSet( 206 IN LONG volatile *Base, 207 IN LONG Bit) 208 { 209 #if defined(_M_IX86) 210 LONG OldBit; 211 __asm__ __volatile__("lock " 212 "btsl %2,%1\n\t" 213 "sbbl %0,%0\n\t" 214 :"=r" (OldBit),"+m" (*Base) 215 :"Ir" (Bit) 216 : "memory"); 217 return OldBit; 218 #else 219 return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; 220 #endif 221 } 222 223 static __inline__ BOOLEAN 224 InterlockedBitTestAndReset( 225 IN LONG volatile *Base, 226 IN LONG Bit) 227 { 228 #if defined(_M_IX86) 229 LONG OldBit; 230 __asm__ __volatile__("lock " 231 "btrl %2,%1\n\t" 232 "sbbl %0,%0\n\t" 233 :"=r" (OldBit),"+m" (*Base) 234 :"Ir" (Bit) 235 : "memory"); 236 return OldBit; 237 #else 238 return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; 239 #endif 240 } 241 242 #endif /* defined(__GNUC__) */ 243 244 #define BitScanForward _BitScanForward 245 #define BitScanReverse _BitScanReverse 246 #define BitTest _bittest 247 #define BitTestAndComplement _bittestandcomplement 248 #define BitTestAndSet _bittestandset 249 #define BitTestAndReset _bittestandreset 250 #define InterlockedBitTestAndSet _interlockedbittestandset 251 #define InterlockedBitTestAndReset _interlockedbittestandreset 252 253 #ifdef _M_AMD64 254 #define BitTest64 _bittest64 255 #define BitTestAndComplement64 _bittestandcomplement64 256 #define BitTestAndSet64 _bittestandset64 257 #define BitTestAndReset64 _bittestandreset64 258 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 259 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 260 #endif 261 262 #if !defined(__INTERLOCKED_DECLARED) 263 #define __INTERLOCKED_DECLARED 264 265 #if defined (_X86_) 266 #if defined(NO_INTERLOCKED_INTRINSICS) 267 NTKERNELAPI 268 LONG 269 FASTCALL 270 InterlockedIncrement( 271 IN OUT LONG volatile *Addend); 272 273 NTKERNELAPI 274 LONG 275 FASTCALL 276 InterlockedDecrement( 277 IN OUT LONG volatile *Addend); 278 279 NTKERNELAPI 280 LONG 281 FASTCALL 282 InterlockedCompareExchange( 283 IN OUT LONG volatile *Destination, 284 IN LONG Exchange, 285 IN LONG Comparand); 286 287 NTKERNELAPI 288 LONG 289 FASTCALL 290 InterlockedExchange( 291 IN OUT LONG volatile *Destination, 292 IN LONG Value); 293 294 NTKERNELAPI 295 LONG 296 FASTCALL 297 InterlockedExchangeAdd( 298 IN OUT LONG volatile *Addend, 299 IN LONG Value); 300 301 #else /* !defined(NO_INTERLOCKED_INTRINSICS) */ 302 303 #define InterlockedExchange _InterlockedExchange 304 #define InterlockedIncrement _InterlockedIncrement 305 #define InterlockedDecrement _InterlockedDecrement 306 #define InterlockedExchangeAdd _InterlockedExchangeAdd 307 #define InterlockedCompareExchange _InterlockedCompareExchange 308 #define InterlockedOr _InterlockedOr 309 #define InterlockedAnd _InterlockedAnd 310 #define InterlockedXor _InterlockedXor 311 312 #endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ 313 314 #endif /* defined (_X86_) */ 315 316 #if !defined (_WIN64) 317 /* 318 * PVOID 319 * InterlockedExchangePointer( 320 * IN OUT PVOID volatile *Target, 321 * IN PVOID Value) 322 */ 323 #define InterlockedExchangePointer(Target, Value) \ 324 ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value)) 325 326 /* 327 * PVOID 328 * InterlockedCompareExchangePointer( 329 * IN OUT PVOID *Destination, 330 * IN PVOID Exchange, 331 * IN PVOID Comparand) 332 */ 333 #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \ 334 ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand)) 335 336 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b) 337 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a) 338 #define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)a) 339 340 #endif // !defined (_WIN64) 341 342 #if defined (_M_AMD64) 343 344 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)a, (LONGLONG)b) 345 #define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)a) 346 #define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONGLONG *)a) 347 #define InterlockedAnd _InterlockedAnd 348 #define InterlockedOr _InterlockedOr 349 #define InterlockedXor _InterlockedXor 350 #define InterlockedIncrement _InterlockedIncrement 351 #define InterlockedDecrement _InterlockedDecrement 352 #define InterlockedAdd _InterlockedAdd 353 #define InterlockedExchange _InterlockedExchange 354 #define InterlockedExchangeAdd _InterlockedExchangeAdd 355 #define InterlockedCompareExchange _InterlockedCompareExchange 356 #define InterlockedAnd64 _InterlockedAnd64 357 #define InterlockedOr64 _InterlockedOr64 358 #define InterlockedXor64 _InterlockedXor64 359 #define InterlockedIncrement64 _InterlockedIncrement64 360 #define InterlockedDecrement64 _InterlockedDecrement64 361 #define InterlockedAdd64 _InterlockedAdd64 362 #define InterlockedExchange64 _InterlockedExchange64 363 #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64 364 #define InterlockedCompareExchange64 _InterlockedCompareExchange64 365 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer 366 #define InterlockedExchangePointer _InterlockedExchangePointer 367 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 368 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 369 370 #endif // _M_AMD64 371 372 #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS) 373 //#if !defined(_X86AMD64_) // FIXME: what's _X86AMD64_ used for? 374 FORCEINLINE 375 LONG64 376 InterlockedAdd64( 377 IN OUT LONG64 volatile *Addend, 378 IN LONG64 Value) 379 { 380 return InterlockedExchangeAdd64(Addend, Value) + Value; 381 } 382 //#endif 383 #endif 384 385 #endif /* !__INTERLOCKED_DECLARED */ 386 387 388 /****************************************************************************** 389 * Runtime Library Types * 390 ******************************************************************************/ 391 392 #define RTL_REGISTRY_ABSOLUTE 0 393 #define RTL_REGISTRY_SERVICES 1 394 #define RTL_REGISTRY_CONTROL 2 395 #define RTL_REGISTRY_WINDOWS_NT 3 396 #define RTL_REGISTRY_DEVICEMAP 4 397 #define RTL_REGISTRY_USER 5 398 #define RTL_REGISTRY_MAXIMUM 6 399 #define RTL_REGISTRY_HANDLE 0x40000000 400 #define RTL_REGISTRY_OPTIONAL 0x80000000 401 402 /* RTL_QUERY_REGISTRY_TABLE.Flags */ 403 #define RTL_QUERY_REGISTRY_SUBKEY 0x00000001 404 #define RTL_QUERY_REGISTRY_TOPKEY 0x00000002 405 #define RTL_QUERY_REGISTRY_REQUIRED 0x00000004 406 #define RTL_QUERY_REGISTRY_NOVALUE 0x00000008 407 #define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010 408 #define RTL_QUERY_REGISTRY_DIRECT 0x00000020 409 #define RTL_QUERY_REGISTRY_DELETE 0x00000040 410 411 #define HASH_STRING_ALGORITHM_DEFAULT 0 412 #define HASH_STRING_ALGORITHM_X65599 1 413 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff 414 415 typedef struct _RTL_BITMAP { 416 ULONG SizeOfBitMap; 417 PULONG Buffer; 418 } RTL_BITMAP, *PRTL_BITMAP; 419 420 typedef struct _RTL_BITMAP_RUN { 421 ULONG StartingIndex; 422 ULONG NumberOfBits; 423 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; 424 425 typedef NTSTATUS 426 (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( 427 IN PWSTR ValueName, 428 IN ULONG ValueType, 429 IN PVOID ValueData, 430 IN ULONG ValueLength, 431 IN PVOID Context, 432 IN PVOID EntryContext); 433 434 typedef struct _RTL_QUERY_REGISTRY_TABLE { 435 PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; 436 ULONG Flags; 437 PCWSTR Name; 438 PVOID EntryContext; 439 ULONG DefaultType; 440 PVOID DefaultData; 441 ULONG DefaultLength; 442 } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE; 443 444 typedef struct _TIME_FIELDS { 445 CSHORT Year; 446 CSHORT Month; 447 CSHORT Day; 448 CSHORT Hour; 449 CSHORT Minute; 450 CSHORT Second; 451 CSHORT Milliseconds; 452 CSHORT Weekday; 453 } TIME_FIELDS, *PTIME_FIELDS; 454 455 /* Slist Header */ 456 #ifndef _SLIST_HEADER_ 457 #define _SLIST_HEADER_ 458 459 #if defined(_WIN64) 460 461 typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { 462 struct _SLIST_ENTRY *Next; 463 } SLIST_ENTRY, *PSLIST_ENTRY; 464 465 typedef struct _SLIST_ENTRY32 { 466 ULONG Next; 467 } SLIST_ENTRY32, *PSLIST_ENTRY32; 468 469 typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { 470 _ANONYMOUS_STRUCT struct { 471 ULONGLONG Alignment; 472 ULONGLONG Region; 473 } DUMMYSTRUCTNAME; 474 struct { 475 ULONGLONG Depth:16; 476 ULONGLONG Sequence:9; 477 ULONGLONG NextEntry:39; 478 ULONGLONG HeaderType:1; 479 ULONGLONG Init:1; 480 ULONGLONG Reserved:59; 481 ULONGLONG Region:3; 482 } Header8; 483 struct { 484 ULONGLONG Depth:16; 485 ULONGLONG Sequence:48; 486 ULONGLONG HeaderType:1; 487 ULONGLONG Init:1; 488 ULONGLONG Reserved:2; 489 ULONGLONG NextEntry:60; 490 } Header16; 491 struct { 492 ULONGLONG Depth:16; 493 ULONGLONG Sequence:48; 494 ULONGLONG HeaderType:1; 495 ULONGLONG Reserved:3; 496 ULONGLONG NextEntry:60; 497 } HeaderX64; 498 } SLIST_HEADER, *PSLIST_HEADER; 499 500 typedef union _SLIST_HEADER32 { 501 ULONGLONG Alignment; 502 _ANONYMOUS_STRUCT struct { 503 SLIST_ENTRY32 Next; 504 USHORT Depth; 505 USHORT Sequence; 506 } DUMMYSTRUCTNAME; 507 } SLIST_HEADER32, *PSLIST_HEADER32; 508 509 #else 510 511 #define SLIST_ENTRY SINGLE_LIST_ENTRY 512 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY 513 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY 514 515 typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; 516 517 typedef union _SLIST_HEADER { 518 ULONGLONG Alignment; 519 _ANONYMOUS_STRUCT struct { 520 SLIST_ENTRY Next; 521 USHORT Depth; 522 USHORT Sequence; 523 } DUMMYSTRUCTNAME; 524 } SLIST_HEADER, *PSLIST_HEADER; 525 526 typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; 527 528 #endif /* defined(_WIN64) */ 529 530 #endif /* _SLIST_HEADER_ */ 531 532 /* MS definition is broken! */ 533 extern BOOLEAN NTSYSAPI NlsMbCodePageTag; 534 extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; 535 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag 536 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag 537 538 #define SHORT_LEAST_SIGNIFICANT_BIT 0 539 #define SHORT_MOST_SIGNIFICANT_BIT 1 540 541 #define LONG_LEAST_SIGNIFICANT_BIT 0 542 #define LONG_3RD_MOST_SIGNIFICANT_BIT 1 543 #define LONG_2ND_MOST_SIGNIFICANT_BIT 2 544 #define LONG_MOST_SIGNIFICANT_BIT 3 545 546 #define RTLVERLIB_DDI(x) Wdmlib##x 547 548 typedef BOOLEAN 549 (*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)( 550 IN ULONG Version); 551 552 typedef BOOLEAN 553 (*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)( 554 IN ULONG Version); 555 556 /****************************************************************************** 557 * Kernel Types * 558 ******************************************************************************/ 559 560 typedef UCHAR KIRQL, *PKIRQL; 561 typedef CCHAR KPROCESSOR_MODE; 562 typedef LONG KPRIORITY; 563 564 typedef enum _MODE { 565 KernelMode, 566 UserMode, 567 MaximumMode 568 } MODE; 569 570 #define CACHE_FULLY_ASSOCIATIVE 0xFF 571 #define MAXIMUM_SUSPEND_COUNT MAXCHAR 572 573 #define EVENT_QUERY_STATE (0x0001) 574 #define EVENT_MODIFY_STATE (0x0002) 575 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) 576 577 #define LTP_PC_SMT 0x1 578 579 #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) 580 #define SINGLE_GROUP_LEGACY_API 1 581 #endif 582 583 #define SEMAPHORE_QUERY_STATE (0x0001) 584 #define SEMAPHORE_MODIFY_STATE (0x0002) 585 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) 586 587 typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { 588 RelationProcessorCore, 589 RelationNumaNode, 590 RelationCache, 591 RelationProcessorPackage, 592 RelationGroup, 593 RelationAll = 0xffff 594 } LOGICAL_PROCESSOR_RELATIONSHIP; 595 596 typedef enum _PROCESSOR_CACHE_TYPE { 597 CacheUnified, 598 CacheInstruction, 599 CacheData, 600 CacheTrace 601 } PROCESSOR_CACHE_TYPE; 602 603 typedef struct _CACHE_DESCRIPTOR { 604 UCHAR Level; 605 UCHAR Associativity; 606 USHORT LineSize; 607 ULONG Size; 608 PROCESSOR_CACHE_TYPE Type; 609 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; 610 611 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { 612 ULONG_PTR ProcessorMask; 613 LOGICAL_PROCESSOR_RELATIONSHIP Relationship; 614 _ANONYMOUS_UNION union { 615 struct { 616 UCHAR Flags; 617 } ProcessorCore; 618 struct { 619 ULONG NodeNumber; 620 } NumaNode; 621 CACHE_DESCRIPTOR Cache; 622 ULONGLONG Reserved[2]; 623 } DUMMYUNIONNAME; 624 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; 625 626 typedef struct _PROCESSOR_RELATIONSHIP { 627 UCHAR Flags; 628 UCHAR Reserved[21]; 629 USHORT GroupCount; 630 GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; 631 } PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; 632 633 typedef struct _NUMA_NODE_RELATIONSHIP { 634 ULONG NodeNumber; 635 UCHAR Reserved[20]; 636 GROUP_AFFINITY GroupMask; 637 } NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; 638 639 typedef struct _CACHE_RELATIONSHIP { 640 UCHAR Level; 641 UCHAR Associativity; 642 USHORT LineSize; 643 ULONG CacheSize; 644 PROCESSOR_CACHE_TYPE Type; 645 UCHAR Reserved[20]; 646 GROUP_AFFINITY GroupMask; 647 } CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; 648 649 typedef struct _PROCESSOR_GROUP_INFO { 650 UCHAR MaximumProcessorCount; 651 UCHAR ActiveProcessorCount; 652 UCHAR Reserved[38]; 653 KAFFINITY ActiveProcessorMask; 654 } PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; 655 656 typedef struct _GROUP_RELATIONSHIP { 657 USHORT MaximumGroupCount; 658 USHORT ActiveGroupCount; 659 UCHAR Reserved[20]; 660 PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; 661 } GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; 662 663 typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { 664 LOGICAL_PROCESSOR_RELATIONSHIP Relationship; 665 ULONG Size; 666 _ANONYMOUS_UNION union { 667 PROCESSOR_RELATIONSHIP Processor; 668 NUMA_NODE_RELATIONSHIP NumaNode; 669 CACHE_RELATIONSHIP Cache; 670 GROUP_RELATIONSHIP Group; 671 } DUMMYUNIONNAME; 672 } SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;; 673 674 /* Processor features */ 675 #define PF_FLOATING_POINT_PRECISION_ERRATA 0 676 #define PF_FLOATING_POINT_EMULATED 1 677 #define PF_COMPARE_EXCHANGE_DOUBLE 2 678 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3 679 #define PF_PPC_MOVEMEM_64BIT_OK 4 680 #define PF_ALPHA_BYTE_INSTRUCTIONS 5 681 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 682 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 683 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8 684 #define PF_PAE_ENABLED 9 685 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 686 #define PF_SSE_DAZ_MODE_AVAILABLE 11 687 #define PF_NX_ENABLED 12 688 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 689 #define PF_COMPARE_EXCHANGE128 14 690 #define PF_COMPARE64_EXCHANGE128 15 691 #define PF_CHANNELS_ENABLED 16 692 #define PF_XSAVE_ENABLED 17 693 694 #define MAXIMUM_WAIT_OBJECTS 64 695 696 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) 697 698 #define ASSERT_DPC(Object) \ 699 ASSERT(((Object)->Type == 0) || \ 700 ((Object)->Type == DpcObject) || \ 701 ((Object)->Type == ThreadedDpcObject)) 702 703 #define ASSERT_GATE(object) \ 704 NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ 705 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) 706 707 #define ASSERT_DEVICE_QUEUE(Object) \ 708 NT_ASSERT((Object)->Type == DeviceQueueObject) 709 710 #define ASSERT_TIMER(E) \ 711 NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ 712 ((E)->Header.Type == TimerSynchronizationObject)) 713 714 #define ASSERT_MUTANT(E) \ 715 NT_ASSERT((E)->Header.Type == MutantObject) 716 717 #define ASSERT_SEMAPHORE(E) \ 718 NT_ASSERT((E)->Header.Type == SemaphoreObject) 719 720 #define ASSERT_EVENT(E) \ 721 NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ 722 ((E)->Header.Type == SynchronizationEvent)) 723 724 #define DPC_NORMAL 0 725 #define DPC_THREADED 1 726 727 #define GM_LOCK_BIT 0x1 728 #define GM_LOCK_BIT_V 0x0 729 #define GM_LOCK_WAITER_WOKEN 0x2 730 #define GM_LOCK_WAITER_INC 0x4 731 732 #define LOCK_QUEUE_WAIT_BIT 0 733 #define LOCK_QUEUE_OWNER_BIT 1 734 735 #define LOCK_QUEUE_WAIT 1 736 #define LOCK_QUEUE_OWNER 2 737 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 738 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT)) 739 740 #define PROCESSOR_FEATURE_MAX 64 741 742 #define DBG_STATUS_CONTROL_C 1 743 #define DBG_STATUS_SYSRQ 2 744 #define DBG_STATUS_BUGCHECK_FIRST 3 745 #define DBG_STATUS_BUGCHECK_SECOND 4 746 #define DBG_STATUS_FATAL 5 747 #define DBG_STATUS_DEBUG_CONTROL 6 748 #define DBG_STATUS_WORKER 7 749 750 #if defined(_WIN64) 751 #define MAXIMUM_PROC_PER_GROUP 64 752 #else 753 #define MAXIMUM_PROC_PER_GROUP 32 754 #endif 755 #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP 756 757 /* Exception Records */ 758 #define EXCEPTION_NONCONTINUABLE 1 759 #define EXCEPTION_MAXIMUM_PARAMETERS 15 760 761 #define EXCEPTION_DIVIDED_BY_ZERO 0 762 #define EXCEPTION_DEBUG 1 763 #define EXCEPTION_NMI 2 764 #define EXCEPTION_INT3 3 765 #define EXCEPTION_BOUND_CHECK 5 766 #define EXCEPTION_INVALID_OPCODE 6 767 #define EXCEPTION_NPX_NOT_AVAILABLE 7 768 #define EXCEPTION_DOUBLE_FAULT 8 769 #define EXCEPTION_NPX_OVERRUN 9 770 #define EXCEPTION_INVALID_TSS 0x0A 771 #define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B 772 #define EXCEPTION_STACK_FAULT 0x0C 773 #define EXCEPTION_GP_FAULT 0x0D 774 #define EXCEPTION_RESERVED_TRAP 0x0F 775 #define EXCEPTION_NPX_ERROR 0x010 776 #define EXCEPTION_ALIGNMENT_CHECK 0x011 777 778 typedef struct _EXCEPTION_RECORD { 779 NTSTATUS ExceptionCode; 780 ULONG ExceptionFlags; 781 struct _EXCEPTION_RECORD *ExceptionRecord; 782 PVOID ExceptionAddress; 783 ULONG NumberParameters; 784 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; 785 } EXCEPTION_RECORD, *PEXCEPTION_RECORD; 786 787 typedef struct _EXCEPTION_RECORD32 { 788 NTSTATUS ExceptionCode; 789 ULONG ExceptionFlags; 790 ULONG ExceptionRecord; 791 ULONG ExceptionAddress; 792 ULONG NumberParameters; 793 ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; 794 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32; 795 796 typedef struct _EXCEPTION_RECORD64 { 797 NTSTATUS ExceptionCode; 798 ULONG ExceptionFlags; 799 ULONG64 ExceptionRecord; 800 ULONG64 ExceptionAddress; 801 ULONG NumberParameters; 802 ULONG __unusedAlignment; 803 ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; 804 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; 805 806 typedef struct _EXCEPTION_POINTERS { 807 PEXCEPTION_RECORD ExceptionRecord; 808 PCONTEXT ContextRecord; 809 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; 810 811 typedef enum _KBUGCHECK_CALLBACK_REASON { 812 KbCallbackInvalid, 813 KbCallbackReserved1, 814 KbCallbackSecondaryDumpData, 815 KbCallbackDumpIo, 816 KbCallbackAddPages 817 } KBUGCHECK_CALLBACK_REASON; 818 819 struct _KBUGCHECK_REASON_CALLBACK_RECORD; 820 821 typedef VOID 822 (NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( 823 IN KBUGCHECK_CALLBACK_REASON Reason, 824 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, 825 IN OUT PVOID ReasonSpecificData, 826 IN ULONG ReasonSpecificDataLength); 827 typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; 828 829 typedef struct _KBUGCHECK_ADD_PAGES { 830 IN OUT PVOID Context; 831 IN OUT ULONG Flags; 832 IN ULONG BugCheckCode; 833 OUT ULONG_PTR Address; 834 OUT ULONG_PTR Count; 835 } KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES; 836 837 typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA { 838 IN PVOID InBuffer; 839 IN ULONG InBufferLength; 840 IN ULONG MaximumAllowed; 841 OUT GUID Guid; 842 OUT PVOID OutBuffer; 843 OUT ULONG OutBufferLength; 844 } KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA; 845 846 typedef enum _KBUGCHECK_DUMP_IO_TYPE { 847 KbDumpIoInvalid, 848 KbDumpIoHeader, 849 KbDumpIoBody, 850 KbDumpIoSecondaryData, 851 KbDumpIoComplete 852 } KBUGCHECK_DUMP_IO_TYPE; 853 854 typedef struct _KBUGCHECK_DUMP_IO { 855 IN ULONG64 Offset; 856 IN PVOID Buffer; 857 IN ULONG BufferLength; 858 IN KBUGCHECK_DUMP_IO_TYPE Type; 859 } KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO; 860 861 #define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL 862 #define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL 863 #define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL 864 865 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { 866 LIST_ENTRY Entry; 867 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; 868 PUCHAR Component; 869 ULONG_PTR Checksum; 870 KBUGCHECK_CALLBACK_REASON Reason; 871 UCHAR State; 872 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD; 873 874 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { 875 BufferEmpty, 876 BufferInserted, 877 BufferStarted, 878 BufferFinished, 879 BufferIncomplete 880 } KBUGCHECK_BUFFER_DUMP_STATE; 881 882 typedef VOID 883 (NTAPI KBUGCHECK_CALLBACK_ROUTINE)( 884 IN PVOID Buffer, 885 IN ULONG Length); 886 typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; 887 888 typedef struct _KBUGCHECK_CALLBACK_RECORD { 889 LIST_ENTRY Entry; 890 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; 891 PVOID Buffer; 892 ULONG Length; 893 PUCHAR Component; 894 ULONG_PTR Checksum; 895 UCHAR State; 896 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; 897 898 typedef BOOLEAN 899 (NTAPI NMI_CALLBACK)( 900 IN PVOID Context, 901 IN BOOLEAN Handled); 902 typedef NMI_CALLBACK *PNMI_CALLBACK; 903 904 typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE { 905 KeProcessorAddStartNotify = 0, 906 KeProcessorAddCompleteNotify, 907 KeProcessorAddFailureNotify 908 } KE_PROCESSOR_CHANGE_NOTIFY_STATE; 909 910 typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT { 911 KE_PROCESSOR_CHANGE_NOTIFY_STATE State; 912 ULONG NtNumber; 913 NTSTATUS Status; 914 #if (NTDDI_VERSION >= NTDDI_WIN7) 915 PROCESSOR_NUMBER ProcNumber; 916 #endif 917 } KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT; 918 919 typedef VOID 920 (NTAPI PROCESSOR_CALLBACK_FUNCTION)( 921 IN PVOID CallbackContext, 922 IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext, 923 IN OUT PNTSTATUS OperationStatus); 924 typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION; 925 926 #define KE_PROCESSOR_CHANGE_ADD_EXISTING 1 927 928 #define INVALID_PROCESSOR_INDEX 0xffffffff 929 930 typedef enum _KINTERRUPT_POLARITY { 931 InterruptPolarityUnknown, 932 InterruptActiveHigh, 933 InterruptActiveLow 934 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY; 935 936 typedef enum _KPROFILE_SOURCE { 937 ProfileTime, 938 ProfileAlignmentFixup, 939 ProfileTotalIssues, 940 ProfilePipelineDry, 941 ProfileLoadInstructions, 942 ProfilePipelineFrozen, 943 ProfileBranchInstructions, 944 ProfileTotalNonissues, 945 ProfileDcacheMisses, 946 ProfileIcacheMisses, 947 ProfileCacheMisses, 948 ProfileBranchMispredictions, 949 ProfileStoreInstructions, 950 ProfileFpInstructions, 951 ProfileIntegerInstructions, 952 Profile2Issue, 953 Profile3Issue, 954 Profile4Issue, 955 ProfileSpecialInstructions, 956 ProfileTotalCycles, 957 ProfileIcacheIssues, 958 ProfileDcacheAccesses, 959 ProfileMemoryBarrierCycles, 960 ProfileLoadLinkedIssues, 961 ProfileMaximum 962 } KPROFILE_SOURCE; 963 964 typedef enum _KWAIT_REASON { 965 Executive, 966 FreePage, 967 PageIn, 968 PoolAllocation, 969 DelayExecution, 970 Suspended, 971 UserRequest, 972 WrExecutive, 973 WrFreePage, 974 WrPageIn, 975 WrPoolAllocation, 976 WrDelayExecution, 977 WrSuspended, 978 WrUserRequest, 979 WrEventPair, 980 WrQueue, 981 WrLpcReceive, 982 WrLpcReply, 983 WrVirtualMemory, 984 WrPageOut, 985 WrRendezvous, 986 WrKeyedEvent, 987 WrTerminated, 988 WrProcessInSwap, 989 WrCpuRateControl, 990 WrCalloutStack, 991 WrKernel, 992 WrResource, 993 WrPushLock, 994 WrMutex, 995 WrQuantumEnd, 996 WrDispatchInt, 997 WrPreempted, 998 WrYieldExecution, 999 WrFastMutex, 1000 WrGuardedMutex, 1001 WrRundown, 1002 MaximumWaitReason 1003 } KWAIT_REASON; 1004 1005 typedef struct _KWAIT_BLOCK { 1006 LIST_ENTRY WaitListEntry; 1007 struct _KTHREAD *Thread; 1008 PVOID Object; 1009 struct _KWAIT_BLOCK *NextWaitBlock; 1010 USHORT WaitKey; 1011 UCHAR WaitType; 1012 volatile UCHAR BlockState; 1013 #if defined(_WIN64) 1014 LONG SpareLong; 1015 #endif 1016 } KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK; 1017 1018 typedef enum _KINTERRUPT_MODE { 1019 LevelSensitive, 1020 Latched 1021 } KINTERRUPT_MODE; 1022 1023 #define THREAD_WAIT_OBJECTS 3 1024 1025 typedef VOID 1026 (NTAPI KSTART_ROUTINE)( 1027 IN PVOID StartContext); 1028 typedef KSTART_ROUTINE *PKSTART_ROUTINE; 1029 1030 typedef VOID 1031 (NTAPI *PKINTERRUPT_ROUTINE)( 1032 VOID); 1033 1034 typedef BOOLEAN 1035 (NTAPI KSERVICE_ROUTINE)( 1036 IN struct _KINTERRUPT *Interrupt, 1037 IN PVOID ServiceContext); 1038 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; 1039 1040 typedef BOOLEAN 1041 (NTAPI KMESSAGE_SERVICE_ROUTINE)( 1042 IN struct _KINTERRUPT *Interrupt, 1043 IN PVOID ServiceContext, 1044 IN ULONG MessageID); 1045 typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE; 1046 1047 typedef enum _KD_OPTION { 1048 KD_OPTION_SET_BLOCK_ENABLE, 1049 } KD_OPTION; 1050 1051 typedef VOID 1052 (NTAPI *PKNORMAL_ROUTINE)( 1053 IN PVOID NormalContext OPTIONAL, 1054 IN PVOID SystemArgument1 OPTIONAL, 1055 IN PVOID SystemArgument2 OPTIONAL); 1056 1057 typedef VOID 1058 (NTAPI *PKRUNDOWN_ROUTINE)( 1059 IN struct _KAPC *Apc); 1060 1061 typedef VOID 1062 (NTAPI *PKKERNEL_ROUTINE)( 1063 IN struct _KAPC *Apc, 1064 IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, 1065 IN OUT PVOID *NormalContext OPTIONAL, 1066 IN OUT PVOID *SystemArgument1 OPTIONAL, 1067 IN OUT PVOID *SystemArgument2 OPTIONAL); 1068 1069 typedef struct _KAPC { 1070 UCHAR Type; 1071 UCHAR SpareByte0; 1072 UCHAR Size; 1073 UCHAR SpareByte1; 1074 ULONG SpareLong0; 1075 struct _KTHREAD *Thread; 1076 LIST_ENTRY ApcListEntry; 1077 PKKERNEL_ROUTINE KernelRoutine; 1078 PKRUNDOWN_ROUTINE RundownRoutine; 1079 PKNORMAL_ROUTINE NormalRoutine; 1080 PVOID NormalContext; 1081 PVOID SystemArgument1; 1082 PVOID SystemArgument2; 1083 CCHAR ApcStateIndex; 1084 KPROCESSOR_MODE ApcMode; 1085 BOOLEAN Inserted; 1086 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; 1087 1088 #define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0) 1089 #define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1) 1090 #define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0) 1091 #define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1) 1092 #define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2) 1093 #define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex) 1094 #define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN)) 1095 1096 typedef struct _KDEVICE_QUEUE_ENTRY { 1097 LIST_ENTRY DeviceListEntry; 1098 ULONG SortKey; 1099 BOOLEAN Inserted; 1100 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, 1101 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY; 1102 1103 typedef PVOID PKIPI_CONTEXT; 1104 1105 typedef VOID 1106 (NTAPI *PKIPI_WORKER)( 1107 IN OUT PKIPI_CONTEXT PacketContext, 1108 IN PVOID Parameter1 OPTIONAL, 1109 IN PVOID Parameter2 OPTIONAL, 1110 IN PVOID Parameter3 OPTIONAL); 1111 1112 typedef struct _KIPI_COUNTS { 1113 ULONG Freeze; 1114 ULONG Packet; 1115 ULONG DPC; 1116 ULONG APC; 1117 ULONG FlushSingleTb; 1118 ULONG FlushMultipleTb; 1119 ULONG FlushEntireTb; 1120 ULONG GenericCall; 1121 ULONG ChangeColor; 1122 ULONG SweepDcache; 1123 ULONG SweepIcache; 1124 ULONG SweepIcacheRange; 1125 ULONG FlushIoBuffers; 1126 ULONG GratuitousDPC; 1127 } KIPI_COUNTS, *PKIPI_COUNTS; 1128 1129 typedef ULONG_PTR 1130 (NTAPI KIPI_BROADCAST_WORKER)( 1131 IN ULONG_PTR Argument); 1132 typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER; 1133 1134 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK; 1135 1136 typedef struct _KSPIN_LOCK_QUEUE { 1137 struct _KSPIN_LOCK_QUEUE *volatile Next; 1138 PKSPIN_LOCK volatile Lock; 1139 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; 1140 1141 typedef struct _KLOCK_QUEUE_HANDLE { 1142 KSPIN_LOCK_QUEUE LockQueue; 1143 KIRQL OldIrql; 1144 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE; 1145 1146 #if defined(_AMD64_) 1147 1148 typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER; 1149 1150 #define LockQueueDispatcherLock 0 1151 #define LockQueueExpansionLock 1 1152 #define LockQueuePfnLock 2 1153 #define LockQueueSystemSpaceLock 3 1154 #define LockQueueVacbLock 4 1155 #define LockQueueMasterLock 5 1156 #define LockQueueNonPagedPoolLock 6 1157 #define LockQueueIoCancelLock 7 1158 #define LockQueueWorkQueueLock 8 1159 #define LockQueueIoVpbLock 9 1160 #define LockQueueIoDatabaseLock 10 1161 #define LockQueueIoCompletionLock 11 1162 #define LockQueueNtfsStructLock 12 1163 #define LockQueueAfdWorkQueueLock 13 1164 #define LockQueueBcbLock 14 1165 #define LockQueueMmNonPagedPoolLock 15 1166 #define LockQueueUnusedSpare16 16 1167 #define LockQueueTimerTableLock 17 1168 #define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS) 1169 1170 #else 1171 1172 typedef enum _KSPIN_LOCK_QUEUE_NUMBER { 1173 LockQueueDispatcherLock, 1174 LockQueueExpansionLock, 1175 LockQueuePfnLock, 1176 LockQueueSystemSpaceLock, 1177 LockQueueVacbLock, 1178 LockQueueMasterLock, 1179 LockQueueNonPagedPoolLock, 1180 LockQueueIoCancelLock, 1181 LockQueueWorkQueueLock, 1182 LockQueueIoVpbLock, 1183 LockQueueIoDatabaseLock, 1184 LockQueueIoCompletionLock, 1185 LockQueueNtfsStructLock, 1186 LockQueueAfdWorkQueueLock, 1187 LockQueueBcbLock, 1188 LockQueueMmNonPagedPoolLock, 1189 LockQueueUnusedSpare16, 1190 LockQueueTimerTableLock, 1191 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS 1192 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; 1193 1194 #endif /* defined(_AMD64_) */ 1195 1196 typedef VOID 1197 (NTAPI KDEFERRED_ROUTINE)( 1198 IN struct _KDPC *Dpc, 1199 IN PVOID DeferredContext OPTIONAL, 1200 IN PVOID SystemArgument1 OPTIONAL, 1201 IN PVOID SystemArgument2 OPTIONAL); 1202 typedef KDEFERRED_ROUTINE *PKDEFERRED_ROUTINE; 1203 1204 typedef enum _KDPC_IMPORTANCE { 1205 LowImportance, 1206 MediumImportance, 1207 HighImportance, 1208 MediumHighImportance 1209 } KDPC_IMPORTANCE; 1210 1211 typedef struct _KDPC { 1212 UCHAR Type; 1213 UCHAR Importance; 1214 volatile USHORT Number; 1215 LIST_ENTRY DpcListEntry; 1216 PKDEFERRED_ROUTINE DeferredRoutine; 1217 PVOID DeferredContext; 1218 PVOID SystemArgument1; 1219 PVOID SystemArgument2; 1220 volatile PVOID DpcData; 1221 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC; 1222 1223 typedef struct _KDPC_WATCHDOG_INFORMATION { 1224 ULONG DpcTimeLimit; 1225 ULONG DpcTimeCount; 1226 ULONG DpcWatchdogLimit; 1227 ULONG DpcWatchdogCount; 1228 ULONG Reserved; 1229 } KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION; 1230 1231 typedef struct _KDEVICE_QUEUE { 1232 CSHORT Type; 1233 CSHORT Size; 1234 LIST_ENTRY DeviceListHead; 1235 KSPIN_LOCK Lock; 1236 # if defined(_AMD64_) 1237 _ANONYMOUS_UNION union { 1238 BOOLEAN Busy; 1239 _ANONYMOUS_STRUCT struct { 1240 LONG64 Reserved:8; 1241 LONG64 Hint:56; 1242 } DUMMYSTRUCTNAME; 1243 } DUMMYUNIONNAME; 1244 # else 1245 BOOLEAN Busy; 1246 # endif 1247 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; 1248 1249 #define TIMER_EXPIRED_INDEX_BITS 6 1250 #define TIMER_PROCESSOR_INDEX_BITS 5 1251 1252 typedef struct _DISPATCHER_HEADER { 1253 _ANONYMOUS_UNION union { 1254 _ANONYMOUS_STRUCT struct { 1255 UCHAR Type; 1256 _ANONYMOUS_UNION union { 1257 _ANONYMOUS_UNION union { 1258 UCHAR TimerControlFlags; 1259 _ANONYMOUS_STRUCT struct { 1260 UCHAR Absolute:1; 1261 UCHAR Coalescable:1; 1262 UCHAR KeepShifting:1; 1263 UCHAR EncodedTolerableDelay:5; 1264 } DUMMYSTRUCTNAME; 1265 } DUMMYUNIONNAME; 1266 UCHAR Abandoned; 1267 #if (NTDDI_VERSION < NTDDI_WIN7) 1268 UCHAR NpxIrql; 1269 #endif 1270 BOOLEAN Signalling; 1271 } DUMMYUNIONNAME; 1272 _ANONYMOUS_UNION union { 1273 _ANONYMOUS_UNION union { 1274 UCHAR ThreadControlFlags; 1275 _ANONYMOUS_STRUCT struct { 1276 UCHAR CpuThrottled:1; 1277 UCHAR CycleProfiling:1; 1278 UCHAR CounterProfiling:1; 1279 UCHAR Reserved:5; 1280 } DUMMYSTRUCTNAME; 1281 } DUMMYUNIONNAME; 1282 UCHAR Size; 1283 UCHAR Hand; 1284 } DUMMYUNIONNAME2; 1285 _ANONYMOUS_UNION union { 1286 #if (NTDDI_VERSION >= NTDDI_WIN7) 1287 _ANONYMOUS_UNION union { 1288 UCHAR TimerMiscFlags; 1289 _ANONYMOUS_STRUCT struct { 1290 #if !defined(_X86_) 1291 UCHAR Index:TIMER_EXPIRED_INDEX_BITS; 1292 #else 1293 UCHAR Index:1; 1294 UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; 1295 #endif 1296 UCHAR Inserted:1; 1297 volatile UCHAR Expired:1; 1298 } DUMMYSTRUCTNAME; 1299 } DUMMYUNIONNAME; 1300 #else 1301 /* Pre Win7 compatibility fix to latest WDK */ 1302 UCHAR Inserted; 1303 #endif 1304 _ANONYMOUS_UNION union { 1305 BOOLEAN DebugActive; 1306 _ANONYMOUS_STRUCT struct { 1307 BOOLEAN ActiveDR7:1; 1308 BOOLEAN Instrumented:1; 1309 BOOLEAN Reserved2:4; 1310 BOOLEAN UmsScheduled:1; 1311 BOOLEAN UmsPrimary:1; 1312 } DUMMYSTRUCTNAME; 1313 } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ 1314 BOOLEAN DpcActive; 1315 } DUMMYUNIONNAME3; 1316 } DUMMYSTRUCTNAME; 1317 volatile LONG Lock; 1318 } DUMMYUNIONNAME; 1319 LONG SignalState; 1320 LIST_ENTRY WaitListHead; 1321 } DISPATCHER_HEADER, *PDISPATCHER_HEADER; 1322 1323 typedef struct _KEVENT { 1324 DISPATCHER_HEADER Header; 1325 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT; 1326 1327 typedef struct _KSEMAPHORE { 1328 DISPATCHER_HEADER Header; 1329 LONG Limit; 1330 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; 1331 1332 #define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG)) 1333 1334 typedef struct _KGATE { 1335 DISPATCHER_HEADER Header; 1336 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; 1337 1338 typedef struct _KGUARDED_MUTEX { 1339 volatile LONG Count; 1340 PKTHREAD Owner; 1341 ULONG Contention; 1342 KGATE Gate; 1343 _ANONYMOUS_UNION union { 1344 _ANONYMOUS_STRUCT struct { 1345 SHORT KernelApcDisable; 1346 SHORT SpecialApcDisable; 1347 } DUMMYSTRUCTNAME; 1348 ULONG CombinedApcDisable; 1349 } DUMMYUNIONNAME; 1350 } KGUARDED_MUTEX, *PKGUARDED_MUTEX; 1351 1352 typedef struct _KMUTANT { 1353 DISPATCHER_HEADER Header; 1354 LIST_ENTRY MutantListEntry; 1355 struct _KTHREAD *RESTRICTED_POINTER OwnerThread; 1356 BOOLEAN Abandoned; 1357 UCHAR ApcDisable; 1358 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX; 1359 1360 #define TIMER_TABLE_SIZE 512 1361 #define TIMER_TABLE_SHIFT 9 1362 1363 typedef struct _KTIMER { 1364 DISPATCHER_HEADER Header; 1365 ULARGE_INTEGER DueTime; 1366 LIST_ENTRY TimerListEntry; 1367 struct _KDPC *Dpc; 1368 # if !defined(_X86_) 1369 ULONG Processor; 1370 # endif 1371 ULONG Period; 1372 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; 1373 1374 typedef enum _LOCK_OPERATION { 1375 IoReadAccess, 1376 IoWriteAccess, 1377 IoModifyAccess 1378 } LOCK_OPERATION; 1379 1380 #define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)) 1381 1382 typedef BOOLEAN 1383 (NTAPI *PKSYNCHRONIZE_ROUTINE)( 1384 IN PVOID SynchronizeContext); 1385 1386 typedef enum _POOL_TYPE { 1387 NonPagedPool, 1388 PagedPool, 1389 NonPagedPoolMustSucceed, 1390 DontUseThisType, 1391 NonPagedPoolCacheAligned, 1392 PagedPoolCacheAligned, 1393 NonPagedPoolCacheAlignedMustS, 1394 MaxPoolType, 1395 NonPagedPoolSession = 32, 1396 PagedPoolSession, 1397 NonPagedPoolMustSucceedSession, 1398 DontUseThisTypeSession, 1399 NonPagedPoolCacheAlignedSession, 1400 PagedPoolCacheAlignedSession, 1401 NonPagedPoolCacheAlignedMustSSession 1402 } POOL_TYPE; 1403 1404 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { 1405 StandardDesign, 1406 NEC98x86, 1407 EndAlternatives 1408 } ALTERNATIVE_ARCHITECTURE_TYPE; 1409 1410 #ifndef _X86_ 1411 1412 #ifndef IsNEC_98 1413 #define IsNEC_98 (FALSE) 1414 #endif 1415 1416 #ifndef IsNotNEC_98 1417 #define IsNotNEC_98 (TRUE) 1418 #endif 1419 1420 #ifndef SetNEC_98 1421 #define SetNEC_98 1422 #endif 1423 1424 #ifndef SetNotNEC_98 1425 #define SetNotNEC_98 1426 #endif 1427 1428 #endif 1429 1430 typedef struct _KSYSTEM_TIME { 1431 ULONG LowPart; 1432 LONG High1Time; 1433 LONG High2Time; 1434 } KSYSTEM_TIME, *PKSYSTEM_TIME; 1435 1436 typedef struct DECLSPEC_ALIGN(16) _M128A { 1437 ULONGLONG Low; 1438 LONGLONG High; 1439 } M128A, *PM128A; 1440 1441 typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { 1442 USHORT ControlWord; 1443 USHORT StatusWord; 1444 UCHAR TagWord; 1445 UCHAR Reserved1; 1446 USHORT ErrorOpcode; 1447 ULONG ErrorOffset; 1448 USHORT ErrorSelector; 1449 USHORT Reserved2; 1450 ULONG DataOffset; 1451 USHORT DataSelector; 1452 USHORT Reserved3; 1453 ULONG MxCsr; 1454 ULONG MxCsr_Mask; 1455 M128A FloatRegisters[8]; 1456 #if defined(_WIN64) 1457 M128A XmmRegisters[16]; 1458 UCHAR Reserved4[96]; 1459 #else 1460 M128A XmmRegisters[8]; 1461 UCHAR Reserved4[192]; 1462 ULONG StackControl[7]; 1463 ULONG Cr0NpxState; 1464 #endif 1465 } XSAVE_FORMAT, *PXSAVE_FORMAT; 1466 1467 typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER { 1468 ULONG64 Mask; 1469 ULONG64 Reserved[7]; 1470 } XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER; 1471 1472 typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA { 1473 XSAVE_FORMAT LegacyState; 1474 XSAVE_AREA_HEADER Header; 1475 } XSAVE_AREA, *PXSAVE_AREA; 1476 1477 typedef struct _XSTATE_CONTEXT { 1478 ULONG64 Mask; 1479 ULONG Length; 1480 ULONG Reserved1; 1481 PXSAVE_AREA Area; 1482 #if defined(_X86_) 1483 ULONG Reserved2; 1484 #endif 1485 PVOID Buffer; 1486 #if defined(_X86_) 1487 ULONG Reserved3; 1488 #endif 1489 } XSTATE_CONTEXT, *PXSTATE_CONTEXT; 1490 1491 typedef struct _XSTATE_SAVE { 1492 #if defined(_AMD64_) 1493 struct _XSTATE_SAVE* Prev; 1494 struct _KTHREAD* Thread; 1495 UCHAR Level; 1496 XSTATE_CONTEXT XStateContext; 1497 #elif defined(_IA64_) 1498 ULONG Dummy; 1499 #elif defined(_X86_) 1500 _ANONYMOUS_UNION union { 1501 _ANONYMOUS_STRUCT struct { 1502 LONG64 Reserved1; 1503 ULONG Reserved2; 1504 struct _XSTATE_SAVE* Prev; 1505 PXSAVE_AREA Reserved3; 1506 struct _KTHREAD* Thread; 1507 PVOID Reserved4; 1508 UCHAR Level; 1509 } DUMMYSTRUCTNAME; 1510 XSTATE_CONTEXT XStateContext; 1511 } DUMMYUNIONNAME; 1512 #endif 1513 } XSTATE_SAVE, *PXSTATE_SAVE; 1514 1515 #ifdef _X86_ 1516 1517 #define MAXIMUM_SUPPORTED_EXTENSION 512 1518 1519 #if !defined(__midl) && !defined(MIDL_PASS) 1520 C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION); 1521 #endif 1522 1523 #endif /* _X86_ */ 1524 1525 #define XSAVE_ALIGN 64 1526 #define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA) 1527 1528 #if !defined(__midl) && !defined(MIDL_PASS) 1529 C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0); 1530 C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0); 1531 C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64); 1532 #endif 1533 1534 typedef struct _CONTEXT_CHUNK { 1535 LONG Offset; 1536 ULONG Length; 1537 } CONTEXT_CHUNK, *PCONTEXT_CHUNK; 1538 1539 typedef struct _CONTEXT_EX { 1540 CONTEXT_CHUNK All; 1541 CONTEXT_CHUNK Legacy; 1542 CONTEXT_CHUNK XState; 1543 } CONTEXT_EX, *PCONTEXT_EX; 1544 1545 #define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN) 1546 1547 #if (NTDDI_VERSION >= NTDDI_VISTA) 1548 extern NTSYSAPI volatile CCHAR KeNumberProcessors; 1549 #elif (NTDDI_VERSION >= NTDDI_WINXP) 1550 extern NTSYSAPI CCHAR KeNumberProcessors; 1551 #else 1552 extern PCCHAR KeNumberProcessors; 1553 #endif 1554 1555 1556 /****************************************************************************** 1557 * Memory manager Types * 1558 ******************************************************************************/ 1559 1560 #if (NTDDI_VERSION >= NTDDI_WIN2K) 1561 typedef ULONG NODE_REQUIREMENT; 1562 #define MM_ANY_NODE_OK 0x80000000 1563 #endif 1564 1565 #define MM_DONT_ZERO_ALLOCATION 0x00000001 1566 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 1567 #define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 1568 #define MM_ALLOCATE_NO_WAIT 0x00000008 1569 #define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 1570 #define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 1571 1572 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001 1573 #define MDL_PAGES_LOCKED 0x0002 1574 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004 1575 #define MDL_ALLOCATED_FIXED_SIZE 0x0008 1576 #define MDL_PARTIAL 0x0010 1577 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020 1578 #define MDL_IO_PAGE_READ 0x0040 1579 #define MDL_WRITE_OPERATION 0x0080 1580 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100 1581 #define MDL_FREE_EXTRA_PTES 0x0200 1582 #define MDL_DESCRIBES_AWE 0x0400 1583 #define MDL_IO_SPACE 0x0800 1584 #define MDL_NETWORK_HEADER 0x1000 1585 #define MDL_MAPPING_CAN_FAIL 0x2000 1586 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000 1587 #define MDL_INTERNAL 0x8000 1588 1589 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \ 1590 MDL_PAGES_LOCKED | \ 1591 MDL_SOURCE_IS_NONPAGED_POOL | \ 1592 MDL_PARTIAL_HAS_BEEN_MAPPED | \ 1593 MDL_PARENT_MAPPED_SYSTEM_VA | \ 1594 MDL_SYSTEM_VA | \ 1595 MDL_IO_SPACE) 1596 1597 #define FLUSH_MULTIPLE_MAXIMUM 32 1598 1599 /* Section access rights */ 1600 #define SECTION_QUERY 0x0001 1601 #define SECTION_MAP_WRITE 0x0002 1602 #define SECTION_MAP_READ 0x0004 1603 #define SECTION_MAP_EXECUTE 0x0008 1604 #define SECTION_EXTEND_SIZE 0x0010 1605 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020 1606 1607 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| \ 1608 SECTION_MAP_WRITE | \ 1609 SECTION_MAP_READ | \ 1610 SECTION_MAP_EXECUTE | \ 1611 SECTION_EXTEND_SIZE) 1612 1613 #define SESSION_QUERY_ACCESS 0x0001 1614 #define SESSION_MODIFY_ACCESS 0x0002 1615 1616 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \ 1617 SESSION_QUERY_ACCESS | \ 1618 SESSION_MODIFY_ACCESS) 1619 1620 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS 1621 1622 #define PAGE_NOACCESS 0x01 1623 #define PAGE_READONLY 0x02 1624 #define PAGE_READWRITE 0x04 1625 #define PAGE_WRITECOPY 0x08 1626 #define PAGE_EXECUTE 0x10 1627 #define PAGE_EXECUTE_READ 0x20 1628 #define PAGE_EXECUTE_READWRITE 0x40 1629 #define PAGE_EXECUTE_WRITECOPY 0x80 1630 #define PAGE_GUARD 0x100 1631 #define PAGE_NOCACHE 0x200 1632 #define PAGE_WRITECOMBINE 0x400 1633 1634 #define MEM_COMMIT 0x1000 1635 #define MEM_RESERVE 0x2000 1636 #define MEM_DECOMMIT 0x4000 1637 #define MEM_RELEASE 0x8000 1638 #define MEM_FREE 0x10000 1639 #define MEM_PRIVATE 0x20000 1640 #define MEM_MAPPED 0x40000 1641 #define MEM_RESET 0x80000 1642 #define MEM_TOP_DOWN 0x100000 1643 #define MEM_LARGE_PAGES 0x20000000 1644 #define MEM_4MB_PAGES 0x80000000 1645 1646 #define SEC_RESERVE 0x4000000 1647 #define SEC_COMMIT 0x8000000 1648 #define SEC_LARGE_PAGES 0x80000000 1649 1650 /* Section map options */ 1651 typedef enum _SECTION_INHERIT { 1652 ViewShare = 1, 1653 ViewUnmap = 2 1654 } SECTION_INHERIT; 1655 1656 typedef ULONG PFN_COUNT; 1657 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER; 1658 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER; 1659 1660 typedef struct _MDL { 1661 struct _MDL *Next; 1662 CSHORT Size; 1663 CSHORT MdlFlags; 1664 struct _EPROCESS *Process; 1665 PVOID MappedSystemVa; 1666 PVOID StartVa; 1667 ULONG ByteCount; 1668 ULONG ByteOffset; 1669 } MDL, *PMDL; 1670 typedef MDL *PMDLX; 1671 1672 typedef enum _MEMORY_CACHING_TYPE_ORIG { 1673 MmFrameBufferCached = 2 1674 } MEMORY_CACHING_TYPE_ORIG; 1675 1676 typedef enum _MEMORY_CACHING_TYPE { 1677 MmNonCached = FALSE, 1678 MmCached = TRUE, 1679 MmWriteCombined = MmFrameBufferCached, 1680 MmHardwareCoherentCached, 1681 MmNonCachedUnordered, 1682 MmUSWCCached, 1683 MmMaximumCacheType 1684 } MEMORY_CACHING_TYPE; 1685 1686 typedef enum _MM_PAGE_PRIORITY { 1687 LowPagePriority, 1688 NormalPagePriority = 16, 1689 HighPagePriority = 32 1690 } MM_PAGE_PRIORITY; 1691 1692 typedef enum _MM_SYSTEM_SIZE { 1693 MmSmallSystem, 1694 MmMediumSystem, 1695 MmLargeSystem 1696 } MM_SYSTEMSIZE; 1697 1698 extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; 1699 extern PVOID MmBadPointer; 1700 1701 1702 /****************************************************************************** 1703 * Executive Types * 1704 ******************************************************************************/ 1705 #define EX_RUNDOWN_ACTIVE 0x1 1706 #define EX_RUNDOWN_COUNT_SHIFT 0x1 1707 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) 1708 1709 typedef struct _FAST_MUTEX { 1710 volatile LONG Count; 1711 PKTHREAD Owner; 1712 ULONG Contention; 1713 KEVENT Event; 1714 ULONG OldIrql; 1715 } FAST_MUTEX, *PFAST_MUTEX; 1716 1717 typedef enum _SUITE_TYPE { 1718 SmallBusiness, 1719 Enterprise, 1720 BackOffice, 1721 CommunicationServer, 1722 TerminalServer, 1723 SmallBusinessRestricted, 1724 EmbeddedNT, 1725 DataCenter, 1726 SingleUserTS, 1727 Personal, 1728 Blade, 1729 EmbeddedRestricted, 1730 SecurityAppliance, 1731 StorageServer, 1732 ComputeServer, 1733 WHServer, 1734 MaxSuiteType 1735 } SUITE_TYPE; 1736 1737 typedef enum _EX_POOL_PRIORITY { 1738 LowPoolPriority, 1739 LowPoolPrioritySpecialPoolOverrun = 8, 1740 LowPoolPrioritySpecialPoolUnderrun = 9, 1741 NormalPoolPriority = 16, 1742 NormalPoolPrioritySpecialPoolOverrun = 24, 1743 NormalPoolPrioritySpecialPoolUnderrun = 25, 1744 HighPoolPriority = 32, 1745 HighPoolPrioritySpecialPoolOverrun = 40, 1746 HighPoolPrioritySpecialPoolUnderrun = 41 1747 } EX_POOL_PRIORITY; 1748 1749 #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) 1750 #define LOOKASIDE_ALIGN 1751 #else 1752 #define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN 1753 #endif 1754 1755 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; 1756 1757 typedef PVOID 1758 (NTAPI *PALLOCATE_FUNCTION)( 1759 IN POOL_TYPE PoolType, 1760 IN SIZE_T NumberOfBytes, 1761 IN ULONG Tag); 1762 1763 typedef PVOID 1764 (NTAPI *PALLOCATE_FUNCTION_EX)( 1765 IN POOL_TYPE PoolType, 1766 IN SIZE_T NumberOfBytes, 1767 IN ULONG Tag, 1768 IN OUT PLOOKASIDE_LIST_EX Lookaside); 1769 1770 typedef VOID 1771 (NTAPI *PFREE_FUNCTION)( 1772 IN PVOID Buffer); 1773 1774 typedef VOID 1775 (NTAPI *PFREE_FUNCTION_EX)( 1776 IN PVOID Buffer, 1777 IN OUT PLOOKASIDE_LIST_EX Lookaside); 1778 1779 typedef VOID 1780 (NTAPI CALLBACK_FUNCTION)( 1781 IN PVOID CallbackContext OPTIONAL, 1782 IN PVOID Argument1 OPTIONAL, 1783 IN PVOID Argument2 OPTIONAL); 1784 typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; 1785 1786 #define GENERAL_LOOKASIDE_LAYOUT \ 1787 _ANONYMOUS_UNION union { \ 1788 SLIST_HEADER ListHead; \ 1789 SINGLE_LIST_ENTRY SingleListHead; \ 1790 } DUMMYUNIONNAME; \ 1791 USHORT Depth; \ 1792 USHORT MaximumDepth; \ 1793 ULONG TotalAllocates; \ 1794 _ANONYMOUS_UNION union { \ 1795 ULONG AllocateMisses; \ 1796 ULONG AllocateHits; \ 1797 } DUMMYUNIONNAME2; \ 1798 ULONG TotalFrees; \ 1799 _ANONYMOUS_UNION union { \ 1800 ULONG FreeMisses; \ 1801 ULONG FreeHits; \ 1802 } DUMMYUNIONNAME3; \ 1803 POOL_TYPE Type; \ 1804 ULONG Tag; \ 1805 ULONG Size; \ 1806 _ANONYMOUS_UNION union { \ 1807 PALLOCATE_FUNCTION_EX AllocateEx; \ 1808 PALLOCATE_FUNCTION Allocate; \ 1809 } DUMMYUNIONNAME4; \ 1810 _ANONYMOUS_UNION union { \ 1811 PFREE_FUNCTION_EX FreeEx; \ 1812 PFREE_FUNCTION Free; \ 1813 } DUMMYUNIONNAME5; \ 1814 LIST_ENTRY ListEntry; \ 1815 ULONG LastTotalAllocates; \ 1816 _ANONYMOUS_UNION union { \ 1817 ULONG LastAllocateMisses; \ 1818 ULONG LastAllocateHits; \ 1819 } DUMMYUNIONNAME6; \ 1820 ULONG Future[2]; 1821 1822 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE { 1823 GENERAL_LOOKASIDE_LAYOUT 1824 } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; 1825 1826 typedef struct _GENERAL_LOOKASIDE_POOL { 1827 GENERAL_LOOKASIDE_LAYOUT 1828 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; 1829 1830 #define LOOKASIDE_CHECK(f) \ 1831 C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) 1832 1833 LOOKASIDE_CHECK(TotalFrees); 1834 LOOKASIDE_CHECK(Tag); 1835 LOOKASIDE_CHECK(Future); 1836 1837 typedef struct _PAGED_LOOKASIDE_LIST { 1838 GENERAL_LOOKASIDE L; 1839 #if !defined(_AMD64_) && !defined(_IA64_) 1840 FAST_MUTEX Lock__ObsoleteButDoNotDelete; 1841 #endif 1842 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; 1843 1844 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { 1845 GENERAL_LOOKASIDE L; 1846 #if !defined(_AMD64_) && !defined(_IA64_) 1847 KSPIN_LOCK Lock__ObsoleteButDoNotDelete; 1848 #endif 1849 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; 1850 1851 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) 1852 1853 typedef struct _LOOKASIDE_LIST_EX { 1854 GENERAL_LOOKASIDE_POOL L; 1855 } LOOKASIDE_LIST_EX; 1856 1857 #if (NTDDI_VERSION >= NTDDI_VISTA) 1858 1859 #define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL 1860 #define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL 1861 1862 #define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 1863 #define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 1864 1865 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 1866 1867 typedef struct _EX_RUNDOWN_REF { 1868 _ANONYMOUS_UNION union { 1869 volatile ULONG_PTR Count; 1870 volatile PVOID Ptr; 1871 } DUMMYUNIONNAME; 1872 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; 1873 1874 typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; 1875 1876 typedef enum _WORK_QUEUE_TYPE { 1877 CriticalWorkQueue, 1878 DelayedWorkQueue, 1879 HyperCriticalWorkQueue, 1880 MaximumWorkQueue 1881 } WORK_QUEUE_TYPE; 1882 1883 typedef VOID 1884 (NTAPI WORKER_THREAD_ROUTINE)( 1885 IN PVOID Parameter); 1886 typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; 1887 1888 typedef struct _WORK_QUEUE_ITEM { 1889 LIST_ENTRY List; 1890 PWORKER_THREAD_ROUTINE WorkerRoutine; 1891 volatile PVOID Parameter; 1892 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; 1893 1894 typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; 1895 1896 typedef struct _OWNER_ENTRY { 1897 ERESOURCE_THREAD OwnerThread; 1898 _ANONYMOUS_UNION union { 1899 _ANONYMOUS_STRUCT struct { 1900 ULONG IoPriorityBoosted:1; 1901 ULONG OwnerReferenced:1; 1902 ULONG OwnerCount:30; 1903 } DUMMYSTRUCTNAME; 1904 ULONG TableSize; 1905 } DUMMYUNIONNAME; 1906 } OWNER_ENTRY, *POWNER_ENTRY; 1907 1908 typedef struct _ERESOURCE { 1909 LIST_ENTRY SystemResourcesList; 1910 POWNER_ENTRY OwnerTable; 1911 SHORT ActiveCount; 1912 USHORT Flag; 1913 volatile PKSEMAPHORE SharedWaiters; 1914 volatile PKEVENT ExclusiveWaiters; 1915 OWNER_ENTRY OwnerEntry; 1916 ULONG ActiveEntries; 1917 ULONG ContentionCount; 1918 ULONG NumberOfSharedWaiters; 1919 ULONG NumberOfExclusiveWaiters; 1920 #if defined(_WIN64) 1921 PVOID Reserved2; 1922 #endif 1923 _ANONYMOUS_UNION union { 1924 PVOID Address; 1925 ULONG_PTR CreatorBackTraceIndex; 1926 } DUMMYUNIONNAME; 1927 KSPIN_LOCK SpinLock; 1928 } ERESOURCE, *PERESOURCE; 1929 1930 /* ERESOURCE.Flag */ 1931 #define ResourceNeverExclusive 0x0010 1932 #define ResourceReleaseByOtherThread 0x0020 1933 #define ResourceOwnedExclusive 0x0080 1934 1935 #define RESOURCE_HASH_TABLE_SIZE 64 1936 1937 typedef struct _RESOURCE_HASH_ENTRY { 1938 LIST_ENTRY ListEntry; 1939 PVOID Address; 1940 ULONG ContentionCount; 1941 ULONG Number; 1942 } RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; 1943 1944 typedef struct _RESOURCE_PERFORMANCE_DATA { 1945 ULONG ActiveResourceCount; 1946 ULONG TotalResourceCount; 1947 ULONG ExclusiveAcquire; 1948 ULONG SharedFirstLevel; 1949 ULONG SharedSecondLevel; 1950 ULONG StarveFirstLevel; 1951 ULONG StarveSecondLevel; 1952 ULONG WaitForExclusive; 1953 ULONG OwnerTableExpands; 1954 ULONG MaximumTableExpand; 1955 LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; 1956 } RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; 1957 1958 /* Global debug flag */ 1959 #if DEVL 1960 extern ULONG NtGlobalFlag; 1961 #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) 1962 #else 1963 #define IF_NTOS_DEBUG(FlagName) if(FALSE) 1964 #endif 1965 1966 /****************************************************************************** 1967 * Security Manager Types * 1968 ******************************************************************************/ 1969 1970 /* Simple types */ 1971 typedef PVOID PSECURITY_DESCRIPTOR; 1972 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION; 1973 typedef ULONG ACCESS_MASK, *PACCESS_MASK; 1974 typedef PVOID PACCESS_TOKEN; 1975 typedef PVOID PSID; 1976 1977 #define DELETE 0x00010000L 1978 #define READ_CONTROL 0x00020000L 1979 #define WRITE_DAC 0x00040000L 1980 #define WRITE_OWNER 0x00080000L 1981 #define SYNCHRONIZE 0x00100000L 1982 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L 1983 #define STANDARD_RIGHTS_READ READ_CONTROL 1984 #define STANDARD_RIGHTS_WRITE READ_CONTROL 1985 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL 1986 #define STANDARD_RIGHTS_ALL 0x001F0000L 1987 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL 1988 #define ACCESS_SYSTEM_SECURITY 0x01000000L 1989 #define MAXIMUM_ALLOWED 0x02000000L 1990 #define GENERIC_READ 0x80000000L 1991 #define GENERIC_WRITE 0x40000000L 1992 #define GENERIC_EXECUTE 0x20000000L 1993 #define GENERIC_ALL 0x10000000L 1994 1995 typedef struct _GENERIC_MAPPING { 1996 ACCESS_MASK GenericRead; 1997 ACCESS_MASK GenericWrite; 1998 ACCESS_MASK GenericExecute; 1999 ACCESS_MASK GenericAll; 2000 } GENERIC_MAPPING, *PGENERIC_MAPPING; 2001 2002 #define ACL_REVISION 2 2003 #define ACL_REVISION_DS 4 2004 2005 #define ACL_REVISION1 1 2006 #define ACL_REVISION2 2 2007 #define ACL_REVISION3 3 2008 #define ACL_REVISION4 4 2009 #define MIN_ACL_REVISION ACL_REVISION2 2010 #define MAX_ACL_REVISION ACL_REVISION4 2011 2012 typedef struct _ACL { 2013 UCHAR AclRevision; 2014 UCHAR Sbz1; 2015 USHORT AclSize; 2016 USHORT AceCount; 2017 USHORT Sbz2; 2018 } ACL, *PACL; 2019 2020 /* Current security descriptor revision value */ 2021 #define SECURITY_DESCRIPTOR_REVISION (1) 2022 #define SECURITY_DESCRIPTOR_REVISION1 (1) 2023 2024 /* Privilege attributes */ 2025 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L) 2026 #define SE_PRIVILEGE_ENABLED (0x00000002L) 2027 #define SE_PRIVILEGE_REMOVED (0X00000004L) 2028 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L) 2029 2030 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \ 2031 SE_PRIVILEGE_ENABLED | \ 2032 SE_PRIVILEGE_REMOVED | \ 2033 SE_PRIVILEGE_USED_FOR_ACCESS) 2034 2035 #include <pshpack4.h> 2036 typedef struct _LUID_AND_ATTRIBUTES { 2037 LUID Luid; 2038 ULONG Attributes; 2039 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; 2040 #include <poppack.h> 2041 2042 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; 2043 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; 2044 2045 /* Privilege sets */ 2046 #define PRIVILEGE_SET_ALL_NECESSARY (1) 2047 2048 typedef struct _PRIVILEGE_SET { 2049 ULONG PrivilegeCount; 2050 ULONG Control; 2051 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; 2052 } PRIVILEGE_SET,*PPRIVILEGE_SET; 2053 2054 typedef enum _SECURITY_IMPERSONATION_LEVEL { 2055 SecurityAnonymous, 2056 SecurityIdentification, 2057 SecurityImpersonation, 2058 SecurityDelegation 2059 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL; 2060 2061 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation 2062 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous 2063 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation 2064 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL)) 2065 2066 #define SECURITY_DYNAMIC_TRACKING (TRUE) 2067 #define SECURITY_STATIC_TRACKING (FALSE) 2068 2069 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE; 2070 2071 typedef struct _SECURITY_QUALITY_OF_SERVICE { 2072 ULONG Length; 2073 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 2074 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; 2075 BOOLEAN EffectiveOnly; 2076 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE; 2077 2078 typedef struct _SE_IMPERSONATION_STATE { 2079 PACCESS_TOKEN Token; 2080 BOOLEAN CopyOnOpen; 2081 BOOLEAN EffectiveOnly; 2082 SECURITY_IMPERSONATION_LEVEL Level; 2083 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE; 2084 2085 #define OWNER_SECURITY_INFORMATION (0x00000001L) 2086 #define GROUP_SECURITY_INFORMATION (0x00000002L) 2087 #define DACL_SECURITY_INFORMATION (0x00000004L) 2088 #define SACL_SECURITY_INFORMATION (0x00000008L) 2089 #define LABEL_SECURITY_INFORMATION (0x00000010L) 2090 2091 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L) 2092 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L) 2093 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L) 2094 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L) 2095 2096 typedef enum _SECURITY_OPERATION_CODE { 2097 SetSecurityDescriptor, 2098 QuerySecurityDescriptor, 2099 DeleteSecurityDescriptor, 2100 AssignSecurityDescriptor 2101 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE; 2102 2103 #define INITIAL_PRIVILEGE_COUNT 3 2104 2105 typedef struct _INITIAL_PRIVILEGE_SET { 2106 ULONG PrivilegeCount; 2107 ULONG Control; 2108 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; 2109 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET; 2110 2111 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2 2112 #define SE_CREATE_TOKEN_PRIVILEGE 2 2113 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3 2114 #define SE_LOCK_MEMORY_PRIVILEGE 4 2115 #define SE_INCREASE_QUOTA_PRIVILEGE 5 2116 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6 2117 #define SE_TCB_PRIVILEGE 7 2118 #define SE_SECURITY_PRIVILEGE 8 2119 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9 2120 #define SE_LOAD_DRIVER_PRIVILEGE 10 2121 #define SE_SYSTEM_PROFILE_PRIVILEGE 11 2122 #define SE_SYSTEMTIME_PRIVILEGE 12 2123 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13 2124 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14 2125 #define SE_CREATE_PAGEFILE_PRIVILEGE 15 2126 #define SE_CREATE_PERMANENT_PRIVILEGE 16 2127 #define SE_BACKUP_PRIVILEGE 17 2128 #define SE_RESTORE_PRIVILEGE 18 2129 #define SE_SHUTDOWN_PRIVILEGE 19 2130 #define SE_DEBUG_PRIVILEGE 20 2131 #define SE_AUDIT_PRIVILEGE 21 2132 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22 2133 #define SE_CHANGE_NOTIFY_PRIVILEGE 23 2134 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24 2135 #define SE_UNDOCK_PRIVILEGE 25 2136 #define SE_SYNC_AGENT_PRIVILEGE 26 2137 #define SE_ENABLE_DELEGATION_PRIVILEGE 27 2138 #define SE_MANAGE_VOLUME_PRIVILEGE 28 2139 #define SE_IMPERSONATE_PRIVILEGE 29 2140 #define SE_CREATE_GLOBAL_PRIVILEGE 30 2141 #define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31 2142 #define SE_RELABEL_PRIVILEGE 32 2143 #define SE_INC_WORKING_SET_PRIVILEGE 33 2144 #define SE_TIME_ZONE_PRIVILEGE 34 2145 #define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35 2146 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 2147 2148 typedef struct _SECURITY_SUBJECT_CONTEXT { 2149 PACCESS_TOKEN ClientToken; 2150 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 2151 PACCESS_TOKEN PrimaryToken; 2152 PVOID ProcessAuditId; 2153 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT; 2154 2155 typedef struct _ACCESS_STATE { 2156 LUID OperationID; 2157 BOOLEAN SecurityEvaluated; 2158 BOOLEAN GenerateAudit; 2159 BOOLEAN GenerateOnClose; 2160 BOOLEAN PrivilegesAllocated; 2161 ULONG Flags; 2162 ACCESS_MASK RemainingDesiredAccess; 2163 ACCESS_MASK PreviouslyGrantedAccess; 2164 ACCESS_MASK OriginalDesiredAccess; 2165 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; 2166 PSECURITY_DESCRIPTOR SecurityDescriptor; 2167 PVOID AuxData; 2168 union { 2169 INITIAL_PRIVILEGE_SET InitialPrivilegeSet; 2170 PRIVILEGE_SET PrivilegeSet; 2171 } Privileges; 2172 BOOLEAN AuditPrivileges; 2173 UNICODE_STRING ObjectName; 2174 UNICODE_STRING ObjectTypeName; 2175 } ACCESS_STATE, *PACCESS_STATE; 2176 2177 typedef VOID 2178 (NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( 2179 IN PVOID Vcb, 2180 IN PSECURITY_DESCRIPTOR SecurityDescriptor); 2181 2182 #ifndef _NTLSA_IFS_ 2183 2184 #ifndef _NTLSA_AUDIT_ 2185 #define _NTLSA_AUDIT_ 2186 2187 #define SE_MAX_AUDIT_PARAMETERS 32 2188 #define SE_MAX_GENERIC_AUDIT_PARAMETERS 28 2189 2190 #define SE_ADT_OBJECT_ONLY 0x1 2191 2192 #define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001 2193 #define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002 2194 #define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004 2195 #define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008 2196 #define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010 2197 2198 #define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \ 2199 ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \ 2200 (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) ) 2201 2202 typedef enum _SE_ADT_PARAMETER_TYPE { 2203 SeAdtParmTypeNone = 0, 2204 SeAdtParmTypeString, 2205 SeAdtParmTypeFileSpec, 2206 SeAdtParmTypeUlong, 2207 SeAdtParmTypeSid, 2208 SeAdtParmTypeLogonId, 2209 SeAdtParmTypeNoLogonId, 2210 SeAdtParmTypeAccessMask, 2211 SeAdtParmTypePrivs, 2212 SeAdtParmTypeObjectTypes, 2213 SeAdtParmTypeHexUlong, 2214 SeAdtParmTypePtr, 2215 SeAdtParmTypeTime, 2216 SeAdtParmTypeGuid, 2217 SeAdtParmTypeLuid, 2218 SeAdtParmTypeHexInt64, 2219 SeAdtParmTypeStringList, 2220 SeAdtParmTypeSidList, 2221 SeAdtParmTypeDuration, 2222 SeAdtParmTypeUserAccountControl, 2223 SeAdtParmTypeNoUac, 2224 SeAdtParmTypeMessage, 2225 SeAdtParmTypeDateTime, 2226 SeAdtParmTypeSockAddr, 2227 SeAdtParmTypeSD, 2228 SeAdtParmTypeLogonHours, 2229 SeAdtParmTypeLogonIdNoSid, 2230 SeAdtParmTypeUlongNoConv, 2231 SeAdtParmTypeSockAddrNoPort, 2232 SeAdtParmTypeAccessReason 2233 } SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE; 2234 2235 typedef struct _SE_ADT_OBJECT_TYPE { 2236 GUID ObjectType; 2237 USHORT Flags; 2238 USHORT Level; 2239 ACCESS_MASK AccessMask; 2240 } SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE; 2241 2242 typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY { 2243 SE_ADT_PARAMETER_TYPE Type; 2244 ULONG Length; 2245 ULONG_PTR Data[2]; 2246 PVOID Address; 2247 } SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY; 2248 2249 typedef struct _SE_ADT_ACCESS_REASON { 2250 ACCESS_MASK AccessMask; 2251 ULONG AccessReasons[32]; 2252 ULONG ObjectTypeIndex; 2253 ULONG AccessGranted; 2254 PSECURITY_DESCRIPTOR SecurityDescriptor; 2255 } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON; 2256 2257 typedef struct _SE_ADT_PARAMETER_ARRAY { 2258 ULONG CategoryId; 2259 ULONG AuditId; 2260 ULONG ParameterCount; 2261 ULONG Length; 2262 USHORT FlatSubCategoryId; 2263 USHORT Type; 2264 ULONG Flags; 2265 SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ]; 2266 } SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY; 2267 2268 #endif /* !_NTLSA_AUDIT_ */ 2269 #endif /* !_NTLSA_IFS_ */ 2270 2271 /****************************************************************************** 2272 * Power Management Support Types * 2273 ******************************************************************************/ 2274 2275 #ifndef _PO_DDK_ 2276 #define _PO_DDK_ 2277 2278 #define PO_CB_SYSTEM_POWER_POLICY 0 2279 #define PO_CB_AC_STATUS 1 2280 #define PO_CB_BUTTON_COLLISION 2 2281 #define PO_CB_SYSTEM_STATE_LOCK 3 2282 #define PO_CB_LID_SWITCH_STATE 4 2283 #define PO_CB_PROCESSOR_POWER_POLICY 5 2284 2285 /* Power States/Levels */ 2286 typedef enum _SYSTEM_POWER_STATE { 2287 PowerSystemUnspecified = 0, 2288 PowerSystemWorking, 2289 PowerSystemSleeping1, 2290 PowerSystemSleeping2, 2291 PowerSystemSleeping3, 2292 PowerSystemHibernate, 2293 PowerSystemShutdown, 2294 PowerSystemMaximum 2295 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE; 2296 2297 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum 2298 2299 typedef enum _POWER_INFORMATION_LEVEL { 2300 SystemPowerPolicyAc, 2301 SystemPowerPolicyDc, 2302 VerifySystemPolicyAc, 2303 VerifySystemPolicyDc, 2304 SystemPowerCapabilities, 2305 SystemBatteryState, 2306 SystemPowerStateHandler, 2307 ProcessorStateHandler, 2308 SystemPowerPolicyCurrent, 2309 AdministratorPowerPolicy, 2310 SystemReserveHiberFile, 2311 ProcessorInformation, 2312 SystemPowerInformation, 2313 ProcessorStateHandler2, 2314 LastWakeTime, 2315 LastSleepTime, 2316 SystemExecutionState, 2317 SystemPowerStateNotifyHandler, 2318 ProcessorPowerPolicyAc, 2319 ProcessorPowerPolicyDc, 2320 VerifyProcessorPowerPolicyAc, 2321 VerifyProcessorPowerPolicyDc, 2322 ProcessorPowerPolicyCurrent, 2323 SystemPowerStateLogging, 2324 SystemPowerLoggingEntry, 2325 SetPowerSettingValue, 2326 NotifyUserPowerSetting, 2327 PowerInformationLevelUnused0, 2328 PowerInformationLevelUnused1, 2329 SystemVideoState, 2330 TraceApplicationPowerMessage, 2331 TraceApplicationPowerMessageEnd, 2332 ProcessorPerfStates, 2333 ProcessorIdleStates, 2334 ProcessorCap, 2335 SystemWakeSource, 2336 SystemHiberFileInformation, 2337 TraceServicePowerMessage, 2338 ProcessorLoad, 2339 PowerShutdownNotification, 2340 MonitorCapabilities, 2341 SessionPowerInit, 2342 SessionDisplayState, 2343 PowerRequestCreate, 2344 PowerRequestAction, 2345 GetPowerRequestList, 2346 ProcessorInformationEx, 2347 NotifyUserModeLegacyPowerEvent, 2348 GroupPark, 2349 ProcessorIdleDomains, 2350 WakeTimerList, 2351 SystemHiberFileSize, 2352 PowerInformationLevelMaximum 2353 } POWER_INFORMATION_LEVEL; 2354 2355 typedef enum { 2356 PowerActionNone = 0, 2357 PowerActionReserved, 2358 PowerActionSleep, 2359 PowerActionHibernate, 2360 PowerActionShutdown, 2361 PowerActionShutdownReset, 2362 PowerActionShutdownOff, 2363 PowerActionWarmEject 2364 } POWER_ACTION, *PPOWER_ACTION; 2365 2366 typedef enum _DEVICE_POWER_STATE { 2367 PowerDeviceUnspecified = 0, 2368 PowerDeviceD0, 2369 PowerDeviceD1, 2370 PowerDeviceD2, 2371 PowerDeviceD3, 2372 PowerDeviceMaximum 2373 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; 2374 2375 typedef enum _MONITOR_DISPLAY_STATE { 2376 PowerMonitorOff = 0, 2377 PowerMonitorOn, 2378 PowerMonitorDim 2379 } MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; 2380 2381 typedef union _POWER_STATE { 2382 SYSTEM_POWER_STATE SystemState; 2383 DEVICE_POWER_STATE DeviceState; 2384 } POWER_STATE, *PPOWER_STATE; 2385 2386 typedef enum _POWER_STATE_TYPE { 2387 SystemPowerState = 0, 2388 DevicePowerState 2389 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE; 2390 2391 #if (NTDDI_VERSION >= NTDDI_VISTA) 2392 typedef struct _SYSTEM_POWER_STATE_CONTEXT { 2393 _ANONYMOUS_UNION union { 2394 _ANONYMOUS_STRUCT struct { 2395 ULONG Reserved1:8; 2396 ULONG TargetSystemState:4; 2397 ULONG EffectiveSystemState:4; 2398 ULONG CurrentSystemState:4; 2399 ULONG IgnoreHibernationPath:1; 2400 ULONG PseudoTransition:1; 2401 ULONG Reserved2:10; 2402 } DUMMYSTRUCTNAME; 2403 ULONG ContextAsUlong; 2404 } DUMMYUNIONNAME; 2405 } SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; 2406 #endif 2407 2408 #if (NTDDI_VERSION >= NTDDI_WIN7) 2409 typedef struct _COUNTED_REASON_CONTEXT { 2410 ULONG Version; 2411 ULONG Flags; 2412 _ANONYMOUS_UNION union { 2413 _ANONYMOUS_STRUCT struct { 2414 UNICODE_STRING ResourceFileName; 2415 USHORT ResourceReasonId; 2416 ULONG StringCount; 2417 PUNICODE_STRING ReasonStrings; 2418 } DUMMYSTRUCTNAME; 2419 UNICODE_STRING SimpleString; 2420 } DUMMYUNIONNAME; 2421 } COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT; 2422 #endif 2423 2424 #define IOCTL_QUERY_DEVICE_POWER_STATE \ 2425 CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS) 2426 2427 #define IOCTL_SET_DEVICE_WAKE \ 2428 CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS) 2429 2430 #define IOCTL_CANCEL_DEVICE_WAKE \ 2431 CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS) 2432 2433 #define ES_SYSTEM_REQUIRED 0x00000001 2434 #define ES_DISPLAY_REQUIRED 0x00000002 2435 #define ES_USER_PRESENT 0x00000004 2436 #define ES_CONTINUOUS 0x80000000 2437 2438 typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE; 2439 2440 typedef enum { 2441 LT_DONT_CARE, 2442 LT_LOWEST_LATENCY 2443 } LATENCY_TIME; 2444 2445 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) 2446 #define DIAGNOSTIC_REASON_VERSION 0 2447 #define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001 2448 #define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002 2449 #define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000 2450 #define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003) 2451 #endif 2452 2453 #define POWER_REQUEST_CONTEXT_VERSION 0 2454 #define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001 2455 #define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002 2456 2457 #define PowerRequestMaximum 3 2458 2459 typedef enum _POWER_REQUEST_TYPE { 2460 PowerRequestDisplayRequired, 2461 PowerRequestSystemRequired, 2462 PowerRequestAwayModeRequired 2463 } POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE; 2464 2465 #if (NTDDI_VERSION >= NTDDI_WINXP) 2466 2467 #define PDCAP_D0_SUPPORTED 0x00000001 2468 #define PDCAP_D1_SUPPORTED 0x00000002 2469 #define PDCAP_D2_SUPPORTED 0x00000004 2470 #define PDCAP_D3_SUPPORTED 0x00000008 2471 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 2472 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 2473 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 2474 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 2475 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 2476 2477 typedef struct CM_Power_Data_s { 2478 ULONG PD_Size; 2479 DEVICE_POWER_STATE PD_MostRecentPowerState; 2480 ULONG PD_Capabilities; 2481 ULONG PD_D1Latency; 2482 ULONG PD_D2Latency; 2483 ULONG PD_D3Latency; 2484 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; 2485 SYSTEM_POWER_STATE PD_DeepestSystemWake; 2486 } CM_POWER_DATA, *PCM_POWER_DATA; 2487 2488 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 2489 2490 typedef enum _SYSTEM_POWER_CONDITION { 2491 PoAc, 2492 PoDc, 2493 PoHot, 2494 PoConditionMaximum 2495 } SYSTEM_POWER_CONDITION; 2496 2497 typedef struct _SET_POWER_SETTING_VALUE { 2498 ULONG Version; 2499 GUID Guid; 2500 SYSTEM_POWER_CONDITION PowerCondition; 2501 ULONG DataLength; 2502 UCHAR Data[ANYSIZE_ARRAY]; 2503 } SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE; 2504 2505 #define POWER_SETTING_VALUE_VERSION (0x1) 2506 2507 typedef struct _NOTIFY_USER_POWER_SETTING { 2508 GUID Guid; 2509 } NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING; 2510 2511 typedef struct _APPLICATIONLAUNCH_SETTING_VALUE { 2512 LARGE_INTEGER ActivationTime; 2513 ULONG Flags; 2514 ULONG ButtonInstanceID; 2515 } APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE; 2516 2517 typedef enum _POWER_PLATFORM_ROLE { 2518 PlatformRoleUnspecified = 0, 2519 PlatformRoleDesktop, 2520 PlatformRoleMobile, 2521 PlatformRoleWorkstation, 2522 PlatformRoleEnterpriseServer, 2523 PlatformRoleSOHOServer, 2524 PlatformRoleAppliancePC, 2525 PlatformRolePerformanceServer, 2526 PlatformRoleMaximum 2527 } POWER_PLATFORM_ROLE; 2528 2529 #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) 2530 typedef struct { 2531 ULONG Granularity; 2532 ULONG Capacity; 2533 } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE; 2534 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */ 2535 2536 #endif /* !_PO_DDK_ */ 2537 2538 #define CORE_PARKING_POLICY_CHANGE_IDEAL 0 2539 #define CORE_PARKING_POLICY_CHANGE_SINGLE 1 2540 #define CORE_PARKING_POLICY_CHANGE_ROCKET 2 2541 #define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET 2542 2543 DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A); 2544 DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C); 2545 DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E); 2546 DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94); 2547 DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0); 2548 DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7); 2549 DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63); 2550 DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99); 2551 DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E); 2552 DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63); 2553 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64); 2554 DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); 2555 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B); 2556 DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA); 2557 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); 2558 DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); 2559 DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); 2560 DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); 2561 DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67); 2562 DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); 2563 DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23); 2564 DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42); 2565 DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E); 2566 DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63); 2567 DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67); 2568 DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20); 2569 DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70); 2570 DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA); 2571 DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0); 2572 DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64); 2573 DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E); 2574 DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); 2575 DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0); 2576 DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87); 2577 DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab); 2578 DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D); 2579 DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2); 2580 DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47); 2581 DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80); 2582 DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78); 2583 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB); 2584 DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93); 2585 DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5); 2586 DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36); 2587 DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B); 2588 DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4); 2589 DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F); 2590 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46); 2591 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69); 2592 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f); 2593 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06); 2594 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A); 2595 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58); 2596 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4); 2597 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA); 2598 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82); 2599 DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8); 2600 DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65); 2601 DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3); 2602 DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00); 2603 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36); 2604 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC); 2605 DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C); 2606 DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb); 2607 DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); 2608 DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); 2609 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d); 2610 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6); 2611 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); 2612 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); 2613 DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); 2614 DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); 2615 DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); 2616 DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); 2617 DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); 2618 DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); 2619 DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); 2620 DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); 2621 DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); 2622 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1); 2623 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); 2624 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); 2625 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); 2626 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); 2627 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); 2628 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); 2629 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); 2630 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); 2631 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); 2632 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); 2633 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); 2634 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); 2635 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); 2636 DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); 2637 DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); 2638 DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); 2639 DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); 2640 DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); 2641 DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51); 2642 DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19); 2643 DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48); 2644 DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3); 2645 DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1); 2646 DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1); 2647 DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E); 2648 DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA); 2649 DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20); 2650 DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5); 2651 DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6); 2652 2653 #define PERFSTATE_POLICY_CHANGE_IDEAL 0 2654 #define PERFSTATE_POLICY_CHANGE_SINGLE 1 2655 #define PERFSTATE_POLICY_CHANGE_ROCKET 2 2656 #define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET 2657 2658 #define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 2659 #define PROCESSOR_PERF_BOOST_POLICY_MAX 100 2660 2661 #define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 2662 #define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 2663 2664 typedef VOID 2665 (NTAPI REQUEST_POWER_COMPLETE)( 2666 IN struct _DEVICE_OBJECT *DeviceObject, 2667 IN UCHAR MinorFunction, 2668 IN POWER_STATE PowerState, 2669 IN PVOID Context, 2670 IN struct _IO_STATUS_BLOCK *IoStatus); 2671 typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; 2672 2673 typedef 2674 NTSTATUS 2675 (NTAPI POWER_SETTING_CALLBACK)( 2676 IN LPCGUID SettingGuid, 2677 IN PVOID Value, 2678 IN ULONG ValueLength, 2679 IN OUT PVOID Context OPTIONAL); 2680 typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; 2681 2682 /****************************************************************************** 2683 * Configuration Manager Types * 2684 ******************************************************************************/ 2685 2686 /* Resource list definitions */ 2687 typedef int CM_RESOURCE_TYPE; 2688 2689 #define CmResourceTypeNull 0 2690 #define CmResourceTypePort 1 2691 #define CmResourceTypeInterrupt 2 2692 #define CmResourceTypeMemory 3 2693 #define CmResourceTypeDma 4 2694 #define CmResourceTypeDeviceSpecific 5 2695 #define CmResourceTypeBusNumber 6 2696 #define CmResourceTypeNonArbitrated 128 2697 #define CmResourceTypeConfigData 128 2698 #define CmResourceTypeDevicePrivate 129 2699 #define CmResourceTypePcCardConfig 130 2700 #define CmResourceTypeMfCardConfig 131 2701 2702 /* KEY_VALUE_Xxx.Type */ 2703 #define REG_NONE 0 2704 #define REG_SZ 1 2705 #define REG_EXPAND_SZ 2 2706 #define REG_BINARY 3 2707 #define REG_DWORD 4 2708 #define REG_DWORD_LITTLE_ENDIAN 4 2709 #define REG_DWORD_BIG_ENDIAN 5 2710 #define REG_LINK 6 2711 #define REG_MULTI_SZ 7 2712 #define REG_RESOURCE_LIST 8 2713 #define REG_FULL_RESOURCE_DESCRIPTOR 9 2714 #define REG_RESOURCE_REQUIREMENTS_LIST 10 2715 #define REG_QWORD 11 2716 #define REG_QWORD_LITTLE_ENDIAN 11 2717 2718 /* Registry Access Rights */ 2719 #define KEY_QUERY_VALUE (0x0001) 2720 #define KEY_SET_VALUE (0x0002) 2721 #define KEY_CREATE_SUB_KEY (0x0004) 2722 #define KEY_ENUMERATE_SUB_KEYS (0x0008) 2723 #define KEY_NOTIFY (0x0010) 2724 #define KEY_CREATE_LINK (0x0020) 2725 #define KEY_WOW64_32KEY (0x0200) 2726 #define KEY_WOW64_64KEY (0x0100) 2727 #define KEY_WOW64_RES (0x0300) 2728 2729 #define KEY_READ ((STANDARD_RIGHTS_READ |\ 2730 KEY_QUERY_VALUE |\ 2731 KEY_ENUMERATE_SUB_KEYS |\ 2732 KEY_NOTIFY) \ 2733 & \ 2734 (~SYNCHRONIZE)) 2735 2736 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\ 2737 KEY_SET_VALUE |\ 2738 KEY_CREATE_SUB_KEY) \ 2739 & \ 2740 (~SYNCHRONIZE)) 2741 2742 #define KEY_EXECUTE ((KEY_READ) \ 2743 & \ 2744 (~SYNCHRONIZE)) 2745 2746 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\ 2747 KEY_QUERY_VALUE |\ 2748 KEY_SET_VALUE |\ 2749 KEY_CREATE_SUB_KEY |\ 2750 KEY_ENUMERATE_SUB_KEYS |\ 2751 KEY_NOTIFY |\ 2752 KEY_CREATE_LINK) \ 2753 & \ 2754 (~SYNCHRONIZE)) 2755 2756 /* Registry Open/Create Options */ 2757 #define REG_OPTION_RESERVED (0x00000000L) 2758 #define REG_OPTION_NON_VOLATILE (0x00000000L) 2759 #define REG_OPTION_VOLATILE (0x00000001L) 2760 #define REG_OPTION_CREATE_LINK (0x00000002L) 2761 #define REG_OPTION_BACKUP_RESTORE (0x00000004L) 2762 #define REG_OPTION_OPEN_LINK (0x00000008L) 2763 2764 #define REG_LEGAL_OPTION \ 2765 (REG_OPTION_RESERVED |\ 2766 REG_OPTION_NON_VOLATILE |\ 2767 REG_OPTION_VOLATILE |\ 2768 REG_OPTION_CREATE_LINK |\ 2769 REG_OPTION_BACKUP_RESTORE |\ 2770 REG_OPTION_OPEN_LINK) 2771 2772 #define REG_OPEN_LEGAL_OPTION \ 2773 (REG_OPTION_RESERVED |\ 2774 REG_OPTION_BACKUP_RESTORE |\ 2775 REG_OPTION_OPEN_LINK) 2776 2777 #define REG_STANDARD_FORMAT 1 2778 #define REG_LATEST_FORMAT 2 2779 #define REG_NO_COMPRESSION 4 2780 2781 /* Key creation/open disposition */ 2782 #define REG_CREATED_NEW_KEY (0x00000001L) 2783 #define REG_OPENED_EXISTING_KEY (0x00000002L) 2784 2785 /* Key restore & hive load flags */ 2786 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L) 2787 #define REG_REFRESH_HIVE (0x00000002L) 2788 #define REG_NO_LAZY_FLUSH (0x00000004L) 2789 #define REG_FORCE_RESTORE (0x00000008L) 2790 #define REG_APP_HIVE (0x00000010L) 2791 #define REG_PROCESS_PRIVATE (0x00000020L) 2792 #define REG_START_JOURNAL (0x00000040L) 2793 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) 2794 #define REG_HIVE_NO_RM (0x00000100L) 2795 #define REG_HIVE_SINGLE_LOG (0x00000200L) 2796 #define REG_BOOT_HIVE (0x00000400L) 2797 2798 /* Unload Flags */ 2799 #define REG_FORCE_UNLOAD 1 2800 2801 /* Notify Filter Values */ 2802 #define REG_NOTIFY_CHANGE_NAME (0x00000001L) 2803 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L) 2804 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L) 2805 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L) 2806 2807 #define REG_LEGAL_CHANGE_FILTER \ 2808 (REG_NOTIFY_CHANGE_NAME |\ 2809 REG_NOTIFY_CHANGE_ATTRIBUTES |\ 2810 REG_NOTIFY_CHANGE_LAST_SET |\ 2811 REG_NOTIFY_CHANGE_SECURITY) 2812 2813 #include <pshpack4.h> 2814 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { 2815 UCHAR Type; 2816 UCHAR ShareDisposition; 2817 USHORT Flags; 2818 union { 2819 struct { 2820 PHYSICAL_ADDRESS Start; 2821 ULONG Length; 2822 } Generic; 2823 struct { 2824 PHYSICAL_ADDRESS Start; 2825 ULONG Length; 2826 } Port; 2827 struct { 2828 #if defined(NT_PROCESSOR_GROUPS) 2829 USHORT Level; 2830 USHORT Group; 2831 #else 2832 ULONG Level; 2833 #endif 2834 ULONG Vector; 2835 KAFFINITY Affinity; 2836 } Interrupt; 2837 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 2838 struct { 2839 _ANONYMOUS_UNION union { 2840 struct { 2841 #if defined(NT_PROCESSOR_GROUPS) 2842 USHORT Group; 2843 #else 2844 USHORT Reserved; 2845 #endif 2846 USHORT MessageCount; 2847 ULONG Vector; 2848 KAFFINITY Affinity; 2849 } Raw; 2850 struct { 2851 #if defined(NT_PROCESSOR_GROUPS) 2852 USHORT Level; 2853 USHORT Group; 2854 #else 2855 ULONG Level; 2856 #endif 2857 ULONG Vector; 2858 KAFFINITY Affinity; 2859 } Translated; 2860 } DUMMYUNIONNAME; 2861 } MessageInterrupt; 2862 #endif 2863 struct { 2864 PHYSICAL_ADDRESS Start; 2865 ULONG Length; 2866 } Memory; 2867 struct { 2868 ULONG Channel; 2869 ULONG Port; 2870 ULONG Reserved1; 2871 } Dma; 2872 struct { 2873 ULONG Data[3]; 2874 } DevicePrivate; 2875 struct { 2876 ULONG Start; 2877 ULONG Length; 2878 ULONG Reserved; 2879 } BusNumber; 2880 struct { 2881 ULONG DataSize; 2882 ULONG Reserved1; 2883 ULONG Reserved2; 2884 } DeviceSpecificData; 2885 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 2886 struct { 2887 PHYSICAL_ADDRESS Start; 2888 ULONG Length40; 2889 } Memory40; 2890 struct { 2891 PHYSICAL_ADDRESS Start; 2892 ULONG Length48; 2893 } Memory48; 2894 struct { 2895 PHYSICAL_ADDRESS Start; 2896 ULONG Length64; 2897 } Memory64; 2898 #endif 2899 } u; 2900 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR; 2901 #include <poppack.h> 2902 2903 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */ 2904 #define CmResourceTypeNull 0 2905 #define CmResourceTypePort 1 2906 #define CmResourceTypeInterrupt 2 2907 #define CmResourceTypeMemory 3 2908 #define CmResourceTypeDma 4 2909 #define CmResourceTypeDeviceSpecific 5 2910 #define CmResourceTypeBusNumber 6 2911 #define CmResourceTypeMemoryLarge 7 2912 #define CmResourceTypeNonArbitrated 128 2913 #define CmResourceTypeConfigData 128 2914 #define CmResourceTypeDevicePrivate 129 2915 #define CmResourceTypePcCardConfig 130 2916 #define CmResourceTypeMfCardConfig 131 2917 2918 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ 2919 typedef enum _CM_SHARE_DISPOSITION { 2920 CmResourceShareUndetermined = 0, 2921 CmResourceShareDeviceExclusive, 2922 CmResourceShareDriverExclusive, 2923 CmResourceShareShared 2924 } CM_SHARE_DISPOSITION; 2925 2926 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */ 2927 #define CM_RESOURCE_PORT_MEMORY 0x0000 2928 #define CM_RESOURCE_PORT_IO 0x0001 2929 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004 2930 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008 2931 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010 2932 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020 2933 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040 2934 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080 2935 #define CM_RESOURCE_PORT_BAR 0x0100 2936 2937 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */ 2938 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000 2939 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001 2940 #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 2941 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 2942 2943 #define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 2944 2945 #define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) 2946 2947 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ 2948 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 2949 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 2950 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002 2951 #define CM_RESOURCE_MEMORY_WRITEABILITY_MASK 0x0003 2952 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004 2953 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008 2954 #define CM_RESOURCE_MEMORY_24 0x0010 2955 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020 2956 #define CM_RESOURCE_MEMORY_WINDOW_DECODE 0x0040 2957 #define CM_RESOURCE_MEMORY_BAR 0x0080 2958 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 2959 2960 #define CM_RESOURCE_MEMORY_LARGE 0x0E00 2961 #define CM_RESOURCE_MEMORY_LARGE_40 0x0200 2962 #define CM_RESOURCE_MEMORY_LARGE_48 0x0400 2963 #define CM_RESOURCE_MEMORY_LARGE_64 0x0800 2964 2965 #define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 2966 #define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 2967 #define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 2968 2969 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ 2970 #define CM_RESOURCE_DMA_8 0x0000 2971 #define CM_RESOURCE_DMA_16 0x0001 2972 #define CM_RESOURCE_DMA_32 0x0002 2973 #define CM_RESOURCE_DMA_8_AND_16 0x0004 2974 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008 2975 #define CM_RESOURCE_DMA_TYPE_A 0x0010 2976 #define CM_RESOURCE_DMA_TYPE_B 0x0020 2977 #define CM_RESOURCE_DMA_TYPE_F 0x0040 2978 2979 typedef struct _DEVICE_FLAGS { 2980 ULONG Failed:1; 2981 ULONG ReadOnly:1; 2982 ULONG Removable:1; 2983 ULONG ConsoleIn:1; 2984 ULONG ConsoleOut:1; 2985 ULONG Input:1; 2986 ULONG Output:1; 2987 } DEVICE_FLAGS, *PDEVICE_FLAGS; 2988 2989 typedef enum _INTERFACE_TYPE { 2990 InterfaceTypeUndefined = -1, 2991 Internal, 2992 Isa, 2993 Eisa, 2994 MicroChannel, 2995 TurboChannel, 2996 PCIBus, 2997 VMEBus, 2998 NuBus, 2999 PCMCIABus, 3000 CBus, 3001 MPIBus, 3002 MPSABus, 3003 ProcessorInternal, 3004 InternalPowerBus, 3005 PNPISABus, 3006 PNPBus, 3007 Vmcs, 3008 MaximumInterfaceType 3009 } INTERFACE_TYPE, *PINTERFACE_TYPE; 3010 3011 typedef struct _CM_COMPONENT_INFORMATION { 3012 DEVICE_FLAGS Flags; 3013 ULONG Version; 3014 ULONG Key; 3015 KAFFINITY AffinityMask; 3016 } CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION; 3017 3018 typedef struct _CM_ROM_BLOCK { 3019 ULONG Address; 3020 ULONG Size; 3021 } CM_ROM_BLOCK, *PCM_ROM_BLOCK; 3022 3023 typedef struct _CM_PARTIAL_RESOURCE_LIST { 3024 USHORT Version; 3025 USHORT Revision; 3026 ULONG Count; 3027 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; 3028 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; 3029 3030 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { 3031 INTERFACE_TYPE InterfaceType; 3032 ULONG BusNumber; 3033 CM_PARTIAL_RESOURCE_LIST PartialResourceList; 3034 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; 3035 3036 typedef struct _CM_RESOURCE_LIST { 3037 ULONG Count; 3038 CM_FULL_RESOURCE_DESCRIPTOR List[1]; 3039 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; 3040 3041 typedef struct _PNP_BUS_INFORMATION { 3042 GUID BusTypeGuid; 3043 INTERFACE_TYPE LegacyBusType; 3044 ULONG BusNumber; 3045 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; 3046 3047 #include <pshpack1.h> 3048 3049 typedef struct _CM_INT13_DRIVE_PARAMETER { 3050 USHORT DriveSelect; 3051 ULONG MaxCylinders; 3052 USHORT SectorsPerTrack; 3053 USHORT MaxHeads; 3054 USHORT NumberDrives; 3055 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER; 3056 3057 typedef struct _CM_MCA_POS_DATA { 3058 USHORT AdapterId; 3059 UCHAR PosData1; 3060 UCHAR PosData2; 3061 UCHAR PosData3; 3062 UCHAR PosData4; 3063 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; 3064 3065 typedef struct _CM_PNP_BIOS_DEVICE_NODE { 3066 USHORT Size; 3067 UCHAR Node; 3068 ULONG ProductId; 3069 UCHAR DeviceType[3]; 3070 USHORT DeviceAttributes; 3071 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE; 3072 3073 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { 3074 UCHAR Signature[4]; 3075 UCHAR Revision; 3076 UCHAR Length; 3077 USHORT ControlField; 3078 UCHAR Checksum; 3079 ULONG EventFlagAddress; 3080 USHORT RealModeEntryOffset; 3081 USHORT RealModeEntrySegment; 3082 USHORT ProtectedModeEntryOffset; 3083 ULONG ProtectedModeCodeBaseAddress; 3084 ULONG OemDeviceId; 3085 USHORT RealModeDataBaseAddress; 3086 ULONG ProtectedModeDataBaseAddress; 3087 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; 3088 3089 #include <poppack.h> 3090 3091 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { 3092 ULONG BytesPerSector; 3093 ULONG NumberOfCylinders; 3094 ULONG SectorsPerTrack; 3095 ULONG NumberOfHeads; 3096 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA; 3097 3098 typedef struct _CM_KEYBOARD_DEVICE_DATA { 3099 USHORT Version; 3100 USHORT Revision; 3101 UCHAR Type; 3102 UCHAR Subtype; 3103 USHORT KeyboardFlags; 3104 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA; 3105 3106 typedef struct _CM_SCSI_DEVICE_DATA { 3107 USHORT Version; 3108 USHORT Revision; 3109 UCHAR HostIdentifier; 3110 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA; 3111 3112 typedef struct _CM_VIDEO_DEVICE_DATA { 3113 USHORT Version; 3114 USHORT Revision; 3115 ULONG VideoClock; 3116 } CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA; 3117 3118 typedef struct _CM_SONIC_DEVICE_DATA { 3119 USHORT Version; 3120 USHORT Revision; 3121 USHORT DataConfigurationRegister; 3122 UCHAR EthernetAddress[8]; 3123 } CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA; 3124 3125 typedef struct _CM_SERIAL_DEVICE_DATA { 3126 USHORT Version; 3127 USHORT Revision; 3128 ULONG BaudClock; 3129 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA; 3130 3131 typedef struct _CM_MONITOR_DEVICE_DATA { 3132 USHORT Version; 3133 USHORT Revision; 3134 USHORT HorizontalScreenSize; 3135 USHORT VerticalScreenSize; 3136 USHORT HorizontalResolution; 3137 USHORT VerticalResolution; 3138 USHORT HorizontalDisplayTimeLow; 3139 USHORT HorizontalDisplayTime; 3140 USHORT HorizontalDisplayTimeHigh; 3141 USHORT HorizontalBackPorchLow; 3142 USHORT HorizontalBackPorch; 3143 USHORT HorizontalBackPorchHigh; 3144 USHORT HorizontalFrontPorchLow; 3145 USHORT HorizontalFrontPorch; 3146 USHORT HorizontalFrontPorchHigh; 3147 USHORT HorizontalSyncLow; 3148 USHORT HorizontalSync; 3149 USHORT HorizontalSyncHigh; 3150 USHORT VerticalBackPorchLow; 3151 USHORT VerticalBackPorch; 3152 USHORT VerticalBackPorchHigh; 3153 USHORT VerticalFrontPorchLow; 3154 USHORT VerticalFrontPorch; 3155 USHORT VerticalFrontPorchHigh; 3156 USHORT VerticalSyncLow; 3157 USHORT VerticalSync; 3158 USHORT VerticalSyncHigh; 3159 } CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA; 3160 3161 typedef struct _CM_FLOPPY_DEVICE_DATA { 3162 USHORT Version; 3163 USHORT Revision; 3164 CHAR Size[8]; 3165 ULONG MaxDensity; 3166 ULONG MountDensity; 3167 UCHAR StepRateHeadUnloadTime; 3168 UCHAR HeadLoadTime; 3169 UCHAR MotorOffTime; 3170 UCHAR SectorLengthCode; 3171 UCHAR SectorPerTrack; 3172 UCHAR ReadWriteGapLength; 3173 UCHAR DataTransferLength; 3174 UCHAR FormatGapLength; 3175 UCHAR FormatFillCharacter; 3176 UCHAR HeadSettleTime; 3177 UCHAR MotorSettleTime; 3178 UCHAR MaximumTrackValue; 3179 UCHAR DataTransferRate; 3180 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; 3181 3182 typedef enum _KEY_INFORMATION_CLASS { 3183 KeyBasicInformation, 3184 KeyNodeInformation, 3185 KeyFullInformation, 3186 KeyNameInformation, 3187 KeyCachedInformation, 3188 KeyFlagsInformation, 3189 KeyVirtualizationInformation, 3190 KeyHandleTagsInformation, 3191 MaxKeyInfoClass 3192 } KEY_INFORMATION_CLASS; 3193 3194 typedef struct _KEY_BASIC_INFORMATION { 3195 LARGE_INTEGER LastWriteTime; 3196 ULONG TitleIndex; 3197 ULONG NameLength; 3198 WCHAR Name[1]; 3199 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; 3200 3201 typedef struct _KEY_CONTROL_FLAGS_INFORMATION { 3202 ULONG ControlFlags; 3203 } KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; 3204 3205 typedef struct _KEY_FULL_INFORMATION { 3206 LARGE_INTEGER LastWriteTime; 3207 ULONG TitleIndex; 3208 ULONG ClassOffset; 3209 ULONG ClassLength; 3210 ULONG SubKeys; 3211 ULONG MaxNameLen; 3212 ULONG MaxClassLen; 3213 ULONG Values; 3214 ULONG MaxValueNameLen; 3215 ULONG MaxValueDataLen; 3216 WCHAR Class[1]; 3217 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION; 3218 3219 typedef struct _KEY_HANDLE_TAGS_INFORMATION { 3220 ULONG HandleTags; 3221 } KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION; 3222 3223 typedef struct _KEY_NODE_INFORMATION { 3224 LARGE_INTEGER LastWriteTime; 3225 ULONG TitleIndex; 3226 ULONG ClassOffset; 3227 ULONG ClassLength; 3228 ULONG NameLength; 3229 WCHAR Name[1]; 3230 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION; 3231 3232 typedef enum _KEY_SET_INFORMATION_CLASS { 3233 KeyWriteTimeInformation, 3234 KeyWow64FlagsInformation, 3235 KeyControlFlagsInformation, 3236 KeySetVirtualizationInformation, 3237 KeySetDebugInformation, 3238 KeySetHandleTagsInformation, 3239 MaxKeySetInfoClass 3240 } KEY_SET_INFORMATION_CLASS; 3241 3242 typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { 3243 ULONG VirtualTarget:1; 3244 ULONG VirtualStore:1; 3245 ULONG VirtualSource:1; 3246 ULONG Reserved:29; 3247 } KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; 3248 3249 typedef struct _KEY_VALUE_BASIC_INFORMATION { 3250 ULONG TitleIndex; 3251 ULONG Type; 3252 ULONG NameLength; 3253 WCHAR Name[1]; 3254 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; 3255 3256 typedef struct _KEY_VALUE_FULL_INFORMATION { 3257 ULONG TitleIndex; 3258 ULONG Type; 3259 ULONG DataOffset; 3260 ULONG DataLength; 3261 ULONG NameLength; 3262 WCHAR Name[1]; 3263 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; 3264 3265 typedef struct _KEY_VALUE_PARTIAL_INFORMATION { 3266 ULONG TitleIndex; 3267 ULONG Type; 3268 ULONG DataLength; 3269 UCHAR Data[1]; 3270 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; 3271 3272 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { 3273 ULONG Type; 3274 ULONG DataLength; 3275 UCHAR Data[1]; 3276 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; 3277 3278 typedef struct _KEY_VALUE_ENTRY { 3279 PUNICODE_STRING ValueName; 3280 ULONG DataLength; 3281 ULONG DataOffset; 3282 ULONG Type; 3283 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; 3284 3285 typedef enum _KEY_VALUE_INFORMATION_CLASS { 3286 KeyValueBasicInformation, 3287 KeyValueFullInformation, 3288 KeyValuePartialInformation, 3289 KeyValueFullInformationAlign64, 3290 KeyValuePartialInformationAlign64 3291 } KEY_VALUE_INFORMATION_CLASS; 3292 3293 typedef struct _KEY_WOW64_FLAGS_INFORMATION { 3294 ULONG UserFlags; 3295 } KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION; 3296 3297 typedef struct _KEY_WRITE_TIME_INFORMATION { 3298 LARGE_INTEGER LastWriteTime; 3299 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; 3300 3301 typedef enum _REG_NOTIFY_CLASS { 3302 RegNtDeleteKey, 3303 RegNtPreDeleteKey = RegNtDeleteKey, 3304 RegNtSetValueKey, 3305 RegNtPreSetValueKey = RegNtSetValueKey, 3306 RegNtDeleteValueKey, 3307 RegNtPreDeleteValueKey = RegNtDeleteValueKey, 3308 RegNtSetInformationKey, 3309 RegNtPreSetInformationKey = RegNtSetInformationKey, 3310 RegNtRenameKey, 3311 RegNtPreRenameKey = RegNtRenameKey, 3312 RegNtEnumerateKey, 3313 RegNtPreEnumerateKey = RegNtEnumerateKey, 3314 RegNtEnumerateValueKey, 3315 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey, 3316 RegNtQueryKey, 3317 RegNtPreQueryKey = RegNtQueryKey, 3318 RegNtQueryValueKey, 3319 RegNtPreQueryValueKey = RegNtQueryValueKey, 3320 RegNtQueryMultipleValueKey, 3321 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey, 3322 RegNtPreCreateKey, 3323 RegNtPostCreateKey, 3324 RegNtPreOpenKey, 3325 RegNtPostOpenKey, 3326 RegNtKeyHandleClose, 3327 RegNtPreKeyHandleClose = RegNtKeyHandleClose, 3328 RegNtPostDeleteKey, 3329 RegNtPostSetValueKey, 3330 RegNtPostDeleteValueKey, 3331 RegNtPostSetInformationKey, 3332 RegNtPostRenameKey, 3333 RegNtPostEnumerateKey, 3334 RegNtPostEnumerateValueKey, 3335 RegNtPostQueryKey, 3336 RegNtPostQueryValueKey, 3337 RegNtPostQueryMultipleValueKey, 3338 RegNtPostKeyHandleClose, 3339 RegNtPreCreateKeyEx, 3340 RegNtPostCreateKeyEx, 3341 RegNtPreOpenKeyEx, 3342 RegNtPostOpenKeyEx, 3343 RegNtPreFlushKey, 3344 RegNtPostFlushKey, 3345 RegNtPreLoadKey, 3346 RegNtPostLoadKey, 3347 RegNtPreUnLoadKey, 3348 RegNtPostUnLoadKey, 3349 RegNtPreQueryKeySecurity, 3350 RegNtPostQueryKeySecurity, 3351 RegNtPreSetKeySecurity, 3352 RegNtPostSetKeySecurity, 3353 RegNtCallbackObjectContextCleanup, 3354 RegNtPreRestoreKey, 3355 RegNtPostRestoreKey, 3356 RegNtPreSaveKey, 3357 RegNtPostSaveKey, 3358 RegNtPreReplaceKey, 3359 RegNtPostReplaceKey, 3360 MaxRegNtNotifyClass 3361 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; 3362 3363 typedef NTSTATUS 3364 (NTAPI EX_CALLBACK_FUNCTION)( 3365 IN PVOID CallbackContext, 3366 IN PVOID Argument1, 3367 IN PVOID Argument2); 3368 typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; 3369 3370 typedef struct _REG_DELETE_KEY_INFORMATION { 3371 PVOID Object; 3372 PVOID CallContext; 3373 PVOID ObjectContext; 3374 PVOID Reserved; 3375 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION 3376 #if (NTDDI_VERSION >= NTDDI_VISTA) 3377 , REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION 3378 #endif 3379 ; 3380 3381 typedef struct _REG_SET_VALUE_KEY_INFORMATION { 3382 PVOID Object; 3383 PUNICODE_STRING ValueName; 3384 ULONG TitleIndex; 3385 ULONG Type; 3386 PVOID Data; 3387 ULONG DataSize; 3388 PVOID CallContext; 3389 PVOID ObjectContext; 3390 PVOID Reserved; 3391 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION; 3392 3393 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION { 3394 PVOID Object; 3395 PUNICODE_STRING ValueName; 3396 PVOID CallContext; 3397 PVOID ObjectContext; 3398 PVOID Reserved; 3399 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION; 3400 3401 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION { 3402 PVOID Object; 3403 KEY_SET_INFORMATION_CLASS KeySetInformationClass; 3404 PVOID KeySetInformation; 3405 ULONG KeySetInformationLength; 3406 PVOID CallContext; 3407 PVOID ObjectContext; 3408 PVOID Reserved; 3409 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION; 3410 3411 typedef struct _REG_ENUMERATE_KEY_INFORMATION { 3412 PVOID Object; 3413 ULONG Index; 3414 KEY_INFORMATION_CLASS KeyInformationClass; 3415 PVOID KeyInformation; 3416 ULONG Length; 3417 PULONG ResultLength; 3418 PVOID CallContext; 3419 PVOID ObjectContext; 3420 PVOID Reserved; 3421 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION; 3422 3423 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION { 3424 PVOID Object; 3425 ULONG Index; 3426 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass; 3427 PVOID KeyValueInformation; 3428 ULONG Length; 3429 PULONG ResultLength; 3430 PVOID CallContext; 3431 PVOID ObjectContext; 3432 PVOID Reserved; 3433 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION; 3434 3435 typedef struct _REG_QUERY_KEY_INFORMATION { 3436 PVOID Object; 3437 KEY_INFORMATION_CLASS KeyInformationClass; 3438 PVOID KeyInformation; 3439 ULONG Length; 3440 PULONG ResultLength; 3441 PVOID CallContext; 3442 PVOID ObjectContext; 3443 PVOID Reserved; 3444 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION; 3445 3446 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION { 3447 PVOID Object; 3448 PUNICODE_STRING ValueName; 3449 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass; 3450 PVOID KeyValueInformation; 3451 ULONG Length; 3452 PULONG ResultLength; 3453 PVOID CallContext; 3454 PVOID ObjectContext; 3455 PVOID Reserved; 3456 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION; 3457 3458 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION { 3459 PVOID Object; 3460 PKEY_VALUE_ENTRY ValueEntries; 3461 ULONG EntryCount; 3462 PVOID ValueBuffer; 3463 PULONG BufferLength; 3464 PULONG RequiredBufferLength; 3465 PVOID CallContext; 3466 PVOID ObjectContext; 3467 PVOID Reserved; 3468 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION; 3469 3470 typedef struct _REG_RENAME_KEY_INFORMATION { 3471 PVOID Object; 3472 PUNICODE_STRING NewName; 3473 PVOID CallContext; 3474 PVOID ObjectContext; 3475 PVOID Reserved; 3476 } REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION; 3477 3478 typedef struct _REG_CREATE_KEY_INFORMATION { 3479 PUNICODE_STRING CompleteName; 3480 PVOID RootObject; 3481 PVOID ObjectType; 3482 ULONG CreateOptions; 3483 PUNICODE_STRING Class; 3484 PVOID SecurityDescriptor; 3485 PVOID SecurityQualityOfService; 3486 ACCESS_MASK DesiredAccess; 3487 ACCESS_MASK GrantedAccess; 3488 PULONG Disposition; 3489 PVOID *ResultObject; 3490 PVOID CallContext; 3491 PVOID RootObjectContext; 3492 PVOID Transaction; 3493 PVOID Reserved; 3494 } REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION; 3495 3496 typedef struct _REG_CREATE_KEY_INFORMATION_V1 { 3497 PUNICODE_STRING CompleteName; 3498 PVOID RootObject; 3499 PVOID ObjectType; 3500 ULONG Options; 3501 PUNICODE_STRING Class; 3502 PVOID SecurityDescriptor; 3503 PVOID SecurityQualityOfService; 3504 ACCESS_MASK DesiredAccess; 3505 ACCESS_MASK GrantedAccess; 3506 PULONG Disposition; 3507 PVOID *ResultObject; 3508 PVOID CallContext; 3509 PVOID RootObjectContext; 3510 PVOID Transaction; 3511 ULONG_PTR Version; 3512 PUNICODE_STRING RemainingName; 3513 ULONG Wow64Flags; 3514 ULONG Attributes; 3515 KPROCESSOR_MODE CheckAccessMode; 3516 } REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1; 3517 3518 typedef struct _REG_PRE_CREATE_KEY_INFORMATION { 3519 PUNICODE_STRING CompleteName; 3520 } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;; 3521 3522 typedef struct _REG_POST_CREATE_KEY_INFORMATION { 3523 PUNICODE_STRING CompleteName; 3524 PVOID Object; 3525 NTSTATUS Status; 3526 } REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION; 3527 3528 typedef struct _REG_POST_OPERATION_INFORMATION { 3529 PVOID Object; 3530 NTSTATUS Status; 3531 PVOID PreInformation; 3532 NTSTATUS ReturnStatus; 3533 PVOID CallContext; 3534 PVOID ObjectContext; 3535 PVOID Reserved; 3536 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION; 3537 3538 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { 3539 PVOID Object; 3540 PVOID CallContext; 3541 PVOID ObjectContext; 3542 PVOID Reserved; 3543 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION; 3544 3545 #if (NTDDI_VERSION >= NTDDI_VISTA) 3546 3547 typedef struct _REG_LOAD_KEY_INFORMATION { 3548 PVOID Object; 3549 PUNICODE_STRING KeyName; 3550 PUNICODE_STRING SourceFile; 3551 ULONG Flags; 3552 PVOID TrustClassObject; 3553 PVOID UserEvent; 3554 ACCESS_MASK DesiredAccess; 3555 PHANDLE RootHandle; 3556 PVOID CallContext; 3557 PVOID ObjectContext; 3558 PVOID Reserved; 3559 } REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION; 3560 3561 typedef struct _REG_UNLOAD_KEY_INFORMATION { 3562 PVOID Object; 3563 PVOID UserEvent; 3564 PVOID CallContext; 3565 PVOID ObjectContext; 3566 PVOID Reserved; 3567 } REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION; 3568 3569 typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION { 3570 PVOID Object; 3571 PVOID ObjectContext; 3572 PVOID Reserved; 3573 } REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION; 3574 3575 typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION { 3576 PVOID Object; 3577 PSECURITY_INFORMATION SecurityInformation; 3578 PSECURITY_DESCRIPTOR SecurityDescriptor; 3579 PULONG Length; 3580 PVOID CallContext; 3581 PVOID ObjectContext; 3582 PVOID Reserved; 3583 } REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION; 3584 3585 typedef struct _REG_SET_KEY_SECURITY_INFORMATION { 3586 PVOID Object; 3587 PSECURITY_INFORMATION SecurityInformation; 3588 PSECURITY_DESCRIPTOR SecurityDescriptor; 3589 PVOID CallContext; 3590 PVOID ObjectContext; 3591 PVOID Reserved; 3592 } REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION; 3593 3594 typedef struct _REG_RESTORE_KEY_INFORMATION { 3595 PVOID Object; 3596 HANDLE FileHandle; 3597 ULONG Flags; 3598 PVOID CallContext; 3599 PVOID ObjectContext; 3600 PVOID Reserved; 3601 } REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION; 3602 3603 typedef struct _REG_SAVE_KEY_INFORMATION { 3604 PVOID Object; 3605 HANDLE FileHandle; 3606 ULONG Format; 3607 PVOID CallContext; 3608 PVOID ObjectContext; 3609 PVOID Reserved; 3610 } REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION; 3611 3612 typedef struct _REG_REPLACE_KEY_INFORMATION { 3613 PVOID Object; 3614 PUNICODE_STRING OldFileName; 3615 PUNICODE_STRING NewFileName; 3616 PVOID CallContext; 3617 PVOID ObjectContext; 3618 PVOID Reserved; 3619 } REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION; 3620 3621 #endif /* NTDDI_VERSION >= NTDDI_VISTA */ 3622 3623 #define SERVICE_KERNEL_DRIVER 0x00000001 3624 #define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 3625 #define SERVICE_ADAPTER 0x00000004 3626 #define SERVICE_RECOGNIZER_DRIVER 0x00000008 3627 3628 #define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ 3629 SERVICE_FILE_SYSTEM_DRIVER | \ 3630 SERVICE_RECOGNIZER_DRIVER) 3631 3632 #define SERVICE_WIN32_OWN_PROCESS 0x00000010 3633 #define SERVICE_WIN32_SHARE_PROCESS 0x00000020 3634 #define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ 3635 SERVICE_WIN32_SHARE_PROCESS) 3636 3637 #define SERVICE_INTERACTIVE_PROCESS 0x00000100 3638 3639 #define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ 3640 SERVICE_ADAPTER | \ 3641 SERVICE_DRIVER | \ 3642 SERVICE_INTERACTIVE_PROCESS) 3643 3644 /* Service Start Types */ 3645 #define SERVICE_BOOT_START 0x00000000 3646 #define SERVICE_SYSTEM_START 0x00000001 3647 #define SERVICE_AUTO_START 0x00000002 3648 #define SERVICE_DEMAND_START 0x00000003 3649 #define SERVICE_DISABLED 0x00000004 3650 3651 #define SERVICE_ERROR_IGNORE 0x00000000 3652 #define SERVICE_ERROR_NORMAL 0x00000001 3653 #define SERVICE_ERROR_SEVERE 0x00000002 3654 #define SERVICE_ERROR_CRITICAL 0x00000003 3655 3656 typedef enum _CM_SERVICE_NODE_TYPE { 3657 DriverType = SERVICE_KERNEL_DRIVER, 3658 FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, 3659 Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, 3660 Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, 3661 AdapterType = SERVICE_ADAPTER, 3662 RecognizerType = SERVICE_RECOGNIZER_DRIVER 3663 } SERVICE_NODE_TYPE; 3664 3665 typedef enum _CM_SERVICE_LOAD_TYPE { 3666 BootLoad = SERVICE_BOOT_START, 3667 SystemLoad = SERVICE_SYSTEM_START, 3668 AutoLoad = SERVICE_AUTO_START, 3669 DemandLoad = SERVICE_DEMAND_START, 3670 DisableLoad = SERVICE_DISABLED 3671 } SERVICE_LOAD_TYPE; 3672 3673 typedef enum _CM_ERROR_CONTROL_TYPE { 3674 IgnoreError = SERVICE_ERROR_IGNORE, 3675 NormalError = SERVICE_ERROR_NORMAL, 3676 SevereError = SERVICE_ERROR_SEVERE, 3677 CriticalError = SERVICE_ERROR_CRITICAL 3678 } SERVICE_ERROR_TYPE; 3679 3680 #define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001 3681 #define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002 3682 #define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004 3683 3684 #define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | \ 3685 CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | \ 3686 CM_SERVICE_USB_DISK_BOOT_LOAD) 3687 3688 3689 /****************************************************************************** 3690 * I/O Manager Types * 3691 ******************************************************************************/ 3692 3693 #define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS 3694 3695 #define CONNECT_FULLY_SPECIFIED 0x1 3696 #define CONNECT_LINE_BASED 0x2 3697 #define CONNECT_MESSAGE_BASED 0x3 3698 #define CONNECT_FULLY_SPECIFIED_GROUP 0x4 3699 #define CONNECT_CURRENT_VERSION 0x4 3700 3701 #define POOL_COLD_ALLOCATION 256 3702 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8 3703 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16 3704 3705 #define IO_TYPE_ADAPTER 1 3706 #define IO_TYPE_CONTROLLER 2 3707 #define IO_TYPE_DEVICE 3 3708 #define IO_TYPE_DRIVER 4 3709 #define IO_TYPE_FILE 5 3710 #define IO_TYPE_IRP 6 3711 #define IO_TYPE_MASTER_ADAPTER 7 3712 #define IO_TYPE_OPEN_PACKET 8 3713 #define IO_TYPE_TIMER 9 3714 #define IO_TYPE_VPB 10 3715 #define IO_TYPE_ERROR_LOG 11 3716 #define IO_TYPE_ERROR_MESSAGE 12 3717 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13 3718 3719 #define IO_TYPE_CSQ_IRP_CONTEXT 1 3720 #define IO_TYPE_CSQ 2 3721 #define IO_TYPE_CSQ_EX 3 3722 3723 /* IO_RESOURCE_DESCRIPTOR.Option */ 3724 #define IO_RESOURCE_PREFERRED 0x01 3725 #define IO_RESOURCE_DEFAULT 0x02 3726 #define IO_RESOURCE_ALTERNATIVE 0x08 3727 3728 #define FILE_DEVICE_BEEP 0x00000001 3729 #define FILE_DEVICE_CD_ROM 0x00000002 3730 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 3731 #define FILE_DEVICE_CONTROLLER 0x00000004 3732 #define FILE_DEVICE_DATALINK 0x00000005 3733 #define FILE_DEVICE_DFS 0x00000006 3734 #define FILE_DEVICE_DISK 0x00000007 3735 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 3736 #define FILE_DEVICE_FILE_SYSTEM 0x00000009 3737 #define FILE_DEVICE_INPORT_PORT 0x0000000a 3738 #define FILE_DEVICE_KEYBOARD 0x0000000b 3739 #define FILE_DEVICE_MAILSLOT 0x0000000c 3740 #define FILE_DEVICE_MIDI_IN 0x0000000d 3741 #define FILE_DEVICE_MIDI_OUT 0x0000000e 3742 #define FILE_DEVICE_MOUSE 0x0000000f 3743 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 3744 #define FILE_DEVICE_NAMED_PIPE 0x00000011 3745 #define FILE_DEVICE_NETWORK 0x00000012 3746 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013 3747 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 3748 #define FILE_DEVICE_NULL 0x00000015 3749 #define FILE_DEVICE_PARALLEL_PORT 0x00000016 3750 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 3751 #define FILE_DEVICE_PRINTER 0x00000018 3752 #define FILE_DEVICE_SCANNER 0x00000019 3753 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a 3754 #define FILE_DEVICE_SERIAL_PORT 0x0000001b 3755 #define FILE_DEVICE_SCREEN 0x0000001c 3756 #define FILE_DEVICE_SOUND 0x0000001d 3757 #define FILE_DEVICE_STREAMS 0x0000001e 3758 #define FILE_DEVICE_TAPE 0x0000001f 3759 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 3760 #define FILE_DEVICE_TRANSPORT 0x00000021 3761 #define FILE_DEVICE_UNKNOWN 0x00000022 3762 #define FILE_DEVICE_VIDEO 0x00000023 3763 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024 3764 #define FILE_DEVICE_WAVE_IN 0x00000025 3765 #define FILE_DEVICE_WAVE_OUT 0x00000026 3766 #define FILE_DEVICE_8042_PORT 0x00000027 3767 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 3768 #define FILE_DEVICE_BATTERY 0x00000029 3769 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a 3770 #define FILE_DEVICE_MODEM 0x0000002b 3771 #define FILE_DEVICE_VDM 0x0000002c 3772 #define FILE_DEVICE_MASS_STORAGE 0x0000002d 3773 #define FILE_DEVICE_SMB 0x0000002e 3774 #define FILE_DEVICE_KS 0x0000002f 3775 #define FILE_DEVICE_CHANGER 0x00000030 3776 #define FILE_DEVICE_SMARTCARD 0x00000031 3777 #define FILE_DEVICE_ACPI 0x00000032 3778 #define FILE_DEVICE_DVD 0x00000033 3779 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 3780 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 3781 #define FILE_DEVICE_DFS_VOLUME 0x00000036 3782 #define FILE_DEVICE_SERENUM 0x00000037 3783 #define FILE_DEVICE_TERMSRV 0x00000038 3784 #define FILE_DEVICE_KSEC 0x00000039 3785 #define FILE_DEVICE_FIPS 0x0000003A 3786 #define FILE_DEVICE_INFINIBAND 0x0000003B 3787 #define FILE_DEVICE_VMBUS 0x0000003E 3788 #define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F 3789 #define FILE_DEVICE_WPD 0x00000040 3790 #define FILE_DEVICE_BLUETOOTH 0x00000041 3791 #define FILE_DEVICE_MT_COMPOSITE 0x00000042 3792 #define FILE_DEVICE_MT_TRANSPORT 0x00000043 3793 #define FILE_DEVICE_BIOMETRIC 0x00000044 3794 #define FILE_DEVICE_PMI 0x00000045 3795 3796 #if defined(NT_PROCESSOR_GROUPS) 3797 3798 typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; 3799 3800 typedef enum _IRQ_DEVICE_POLICY_USHORT { 3801 IrqPolicyMachineDefault = 0, 3802 IrqPolicyAllCloseProcessors = 1, 3803 IrqPolicyOneCloseProcessor = 2, 3804 IrqPolicyAllProcessorsInMachine = 3, 3805 IrqPolicyAllProcessorsInGroup = 3, 3806 IrqPolicySpecifiedProcessors = 4, 3807 IrqPolicySpreadMessagesAcrossAllProcessors = 5}; 3808 3809 #else /* defined(NT_PROCESSOR_GROUPS) */ 3810 3811 typedef enum _IRQ_DEVICE_POLICY { 3812 IrqPolicyMachineDefault = 0, 3813 IrqPolicyAllCloseProcessors, 3814 IrqPolicyOneCloseProcessor, 3815 IrqPolicyAllProcessorsInMachine, 3816 IrqPolicySpecifiedProcessors, 3817 IrqPolicySpreadMessagesAcrossAllProcessors 3818 } IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; 3819 3820 #endif 3821 3822 typedef enum _IRQ_PRIORITY { 3823 IrqPriorityUndefined = 0, 3824 IrqPriorityLow, 3825 IrqPriorityNormal, 3826 IrqPriorityHigh 3827 } IRQ_PRIORITY, *PIRQ_PRIORITY; 3828 3829 typedef enum _IRQ_GROUP_POLICY { 3830 GroupAffinityAllGroupZero = 0, 3831 GroupAffinityDontCare 3832 } IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY; 3833 3834 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) 3835 3836 typedef struct _OBJECT_HANDLE_INFORMATION { 3837 ULONG HandleAttributes; 3838 ACCESS_MASK GrantedAccess; 3839 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION; 3840 3841 typedef struct _CLIENT_ID { 3842 HANDLE UniqueProcess; 3843 HANDLE UniqueThread; 3844 } CLIENT_ID, *PCLIENT_ID; 3845 3846 typedef struct _VPB { 3847 CSHORT Type; 3848 CSHORT Size; 3849 USHORT Flags; 3850 USHORT VolumeLabelLength; 3851 struct _DEVICE_OBJECT *DeviceObject; 3852 struct _DEVICE_OBJECT *RealDevice; 3853 ULONG SerialNumber; 3854 ULONG ReferenceCount; 3855 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; 3856 } VPB, *PVPB; 3857 3858 typedef enum _IO_ALLOCATION_ACTION { 3859 KeepObject = 1, 3860 DeallocateObject, 3861 DeallocateObjectKeepRegisters 3862 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; 3863 3864 typedef IO_ALLOCATION_ACTION 3865 (NTAPI DRIVER_CONTROL)( 3866 IN struct _DEVICE_OBJECT *DeviceObject, 3867 IN struct _IRP *Irp, 3868 IN PVOID MapRegisterBase, 3869 IN PVOID Context); 3870 typedef DRIVER_CONTROL *PDRIVER_CONTROL; 3871 3872 typedef struct _WAIT_CONTEXT_BLOCK { 3873 KDEVICE_QUEUE_ENTRY WaitQueueEntry; 3874 PDRIVER_CONTROL DeviceRoutine; 3875 PVOID DeviceContext; 3876 ULONG NumberOfMapRegisters; 3877 PVOID DeviceObject; 3878 PVOID CurrentIrp; 3879 PKDPC BufferChainingDpc; 3880 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; 3881 3882 /* DEVICE_OBJECT.Flags */ 3883 #define DO_VERIFY_VOLUME 0x00000002 3884 #define DO_BUFFERED_IO 0x00000004 3885 #define DO_EXCLUSIVE 0x00000008 3886 #define DO_DIRECT_IO 0x00000010 3887 #define DO_MAP_IO_BUFFER 0x00000020 3888 #define DO_DEVICE_INITIALIZING 0x00000080 3889 #define DO_SHUTDOWN_REGISTERED 0x00000800 3890 #define DO_BUS_ENUMERATED_DEVICE 0x00001000 3891 #define DO_POWER_PAGABLE 0x00002000 3892 #define DO_POWER_INRUSH 0x00004000 3893 3894 /* DEVICE_OBJECT.Characteristics */ 3895 #define FILE_REMOVABLE_MEDIA 0x00000001 3896 #define FILE_READ_ONLY_DEVICE 0x00000002 3897 #define FILE_FLOPPY_DISKETTE 0x00000004 3898 #define FILE_WRITE_ONCE_MEDIA 0x00000008 3899 #define FILE_REMOTE_DEVICE 0x00000010 3900 #define FILE_DEVICE_IS_MOUNTED 0x00000020 3901 #define FILE_VIRTUAL_VOLUME 0x00000040 3902 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 3903 #define FILE_DEVICE_SECURE_OPEN 0x00000100 3904 #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 3905 #define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 3906 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 3907 3908 /* DEVICE_OBJECT.AlignmentRequirement */ 3909 #define FILE_BYTE_ALIGNMENT 0x00000000 3910 #define FILE_WORD_ALIGNMENT 0x00000001 3911 #define FILE_LONG_ALIGNMENT 0x00000003 3912 #define FILE_QUAD_ALIGNMENT 0x00000007 3913 #define FILE_OCTA_ALIGNMENT 0x0000000f 3914 #define FILE_32_BYTE_ALIGNMENT 0x0000001f 3915 #define FILE_64_BYTE_ALIGNMENT 0x0000003f 3916 #define FILE_128_BYTE_ALIGNMENT 0x0000007f 3917 #define FILE_256_BYTE_ALIGNMENT 0x000000ff 3918 #define FILE_512_BYTE_ALIGNMENT 0x000001ff 3919 3920 /* DEVICE_OBJECT.DeviceType */ 3921 #define DEVICE_TYPE ULONG 3922 3923 typedef struct _DEVICE_OBJECT { 3924 CSHORT Type; 3925 USHORT Size; 3926 LONG ReferenceCount; 3927 struct _DRIVER_OBJECT *DriverObject; 3928 struct _DEVICE_OBJECT *NextDevice; 3929 struct _DEVICE_OBJECT *AttachedDevice; 3930 struct _IRP *CurrentIrp; 3931 PIO_TIMER Timer; 3932 ULONG Flags; 3933 ULONG Characteristics; 3934 volatile PVPB Vpb; 3935 PVOID DeviceExtension; 3936 DEVICE_TYPE DeviceType; 3937 CCHAR StackSize; 3938 union { 3939 LIST_ENTRY ListEntry; 3940 WAIT_CONTEXT_BLOCK Wcb; 3941 } Queue; 3942 ULONG AlignmentRequirement; 3943 KDEVICE_QUEUE DeviceQueue; 3944 KDPC Dpc; 3945 ULONG ActiveThreadCount; 3946 PSECURITY_DESCRIPTOR SecurityDescriptor; 3947 KEVENT DeviceLock; 3948 USHORT SectorSize; 3949 USHORT Spare1; 3950 struct _DEVOBJ_EXTENSION *DeviceObjectExtension; 3951 PVOID Reserved; 3952 } DEVICE_OBJECT, *PDEVICE_OBJECT; 3953 3954 typedef enum _IO_SESSION_STATE { 3955 IoSessionStateCreated = 1, 3956 IoSessionStateInitialized, 3957 IoSessionStateConnected, 3958 IoSessionStateDisconnected, 3959 IoSessionStateDisconnectedLoggedOn, 3960 IoSessionStateLoggedOn, 3961 IoSessionStateLoggedOff, 3962 IoSessionStateTerminated, 3963 IoSessionStateMax 3964 } IO_SESSION_STATE, *PIO_SESSION_STATE; 3965 3966 typedef enum _IO_COMPLETION_ROUTINE_RESULT { 3967 ContinueCompletion = STATUS_CONTINUE_COMPLETION, 3968 StopCompletion = STATUS_MORE_PROCESSING_REQUIRED 3969 } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT; 3970 3971 typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY { 3972 PHYSICAL_ADDRESS MessageAddress; 3973 KAFFINITY TargetProcessorSet; 3974 PKINTERRUPT InterruptObject; 3975 ULONG MessageData; 3976 ULONG Vector; 3977 KIRQL Irql; 3978 KINTERRUPT_MODE Mode; 3979 KINTERRUPT_POLARITY Polarity; 3980 } IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY; 3981 3982 typedef struct _IO_INTERRUPT_MESSAGE_INFO { 3983 KIRQL UnifiedIrql; 3984 ULONG MessageCount; 3985 IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1]; 3986 } IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO; 3987 3988 typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS { 3989 IN PDEVICE_OBJECT PhysicalDeviceObject; 3990 OUT PKINTERRUPT *InterruptObject; 3991 IN PKSERVICE_ROUTINE ServiceRoutine; 3992 IN PVOID ServiceContext; 3993 IN PKSPIN_LOCK SpinLock OPTIONAL; 3994 IN KIRQL SynchronizeIrql; 3995 IN BOOLEAN FloatingSave; 3996 IN BOOLEAN ShareVector; 3997 IN ULONG Vector; 3998 IN KIRQL Irql; 3999 IN KINTERRUPT_MODE InterruptMode; 4000 IN KAFFINITY ProcessorEnableMask; 4001 IN USHORT Group; 4002 } IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS; 4003 4004 typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS { 4005 IN PDEVICE_OBJECT PhysicalDeviceObject; 4006 OUT PKINTERRUPT *InterruptObject; 4007 IN PKSERVICE_ROUTINE ServiceRoutine; 4008 IN PVOID ServiceContext; 4009 IN PKSPIN_LOCK SpinLock OPTIONAL; 4010 IN KIRQL SynchronizeIrql OPTIONAL; 4011 IN BOOLEAN FloatingSave; 4012 } IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS; 4013 4014 typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS { 4015 IN PDEVICE_OBJECT PhysicalDeviceObject; 4016 union { 4017 OUT PVOID *Generic; 4018 OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable; 4019 OUT PKINTERRUPT *InterruptObject; 4020 } ConnectionContext; 4021 IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine; 4022 IN PVOID ServiceContext; 4023 IN PKSPIN_LOCK SpinLock OPTIONAL; 4024 IN KIRQL SynchronizeIrql OPTIONAL; 4025 IN BOOLEAN FloatingSave; 4026 IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL; 4027 } IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS; 4028 4029 typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS { 4030 IN OUT ULONG Version; 4031 _ANONYMOUS_UNION union { 4032 IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified; 4033 IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased; 4034 IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased; 4035 } DUMMYUNIONNAME; 4036 } IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS; 4037 4038 typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS { 4039 IN ULONG Version; 4040 union { 4041 IN PVOID Generic; 4042 IN PKINTERRUPT InterruptObject; 4043 IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable; 4044 } ConnectionContext; 4045 } IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS; 4046 4047 typedef enum _IO_ACCESS_TYPE { 4048 ReadAccess, 4049 WriteAccess, 4050 ModifyAccess 4051 } IO_ACCESS_TYPE; 4052 4053 typedef enum _IO_ACCESS_MODE { 4054 SequentialAccess, 4055 RandomAccess 4056 } IO_ACCESS_MODE; 4057 4058 typedef enum _IO_CONTAINER_NOTIFICATION_CLASS { 4059 IoSessionStateNotification, 4060 IoMaxContainerNotificationClass 4061 } IO_CONTAINER_NOTIFICATION_CLASS; 4062 4063 typedef struct _IO_SESSION_STATE_NOTIFICATION { 4064 ULONG Size; 4065 ULONG Flags; 4066 PVOID IoObject; 4067 ULONG EventMask; 4068 PVOID Context; 4069 } IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION; 4070 4071 typedef enum _IO_CONTAINER_INFORMATION_CLASS { 4072 IoSessionStateInformation, 4073 IoMaxContainerInformationClass 4074 } IO_CONTAINER_INFORMATION_CLASS; 4075 4076 typedef struct _IO_SESSION_STATE_INFORMATION { 4077 ULONG SessionId; 4078 IO_SESSION_STATE SessionState; 4079 BOOLEAN LocalSession; 4080 } IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION; 4081 4082 #if (NTDDI_VERSION >= NTDDI_WIN7) 4083 4084 typedef NTSTATUS 4085 (NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)( 4086 VOID); 4087 4088 typedef NTSTATUS 4089 (NTAPI IO_SESSION_NOTIFICATION_FUNCTION)( 4090 IN PVOID SessionObject, 4091 IN PVOID IoObject, 4092 IN ULONG Event, 4093 IN PVOID Context, 4094 IN PVOID NotificationPayload, 4095 IN ULONG PayloadLength); 4096 4097 typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION; 4098 4099 #endif 4100 4101 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; 4102 4103 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { 4104 BOOLEAN Removed; 4105 BOOLEAN Reserved[3]; 4106 volatile LONG IoCount; 4107 KEVENT RemoveEvent; 4108 } IO_REMOVE_LOCK_COMMON_BLOCK; 4109 4110 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK { 4111 LONG Signature; 4112 LONG HighWatermark; 4113 LONGLONG MaxLockedTicks; 4114 LONG AllocateTag; 4115 LIST_ENTRY LockList; 4116 KSPIN_LOCK Spin; 4117 volatile LONG LowMemoryCount; 4118 ULONG Reserved1[4]; 4119 PVOID Reserved2; 4120 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; 4121 } IO_REMOVE_LOCK_DBG_BLOCK; 4122 4123 typedef struct _IO_REMOVE_LOCK { 4124 IO_REMOVE_LOCK_COMMON_BLOCK Common; 4125 #if DBG 4126 IO_REMOVE_LOCK_DBG_BLOCK Dbg; 4127 #endif 4128 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK; 4129 4130 typedef struct _IO_WORKITEM *PIO_WORKITEM; 4131 4132 typedef VOID 4133 (NTAPI IO_WORKITEM_ROUTINE)( 4134 IN PDEVICE_OBJECT DeviceObject, 4135 IN PVOID Context); 4136 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; 4137 4138 typedef VOID 4139 (NTAPI IO_WORKITEM_ROUTINE_EX)( 4140 IN PVOID IoObject, 4141 IN PVOID Context OPTIONAL, 4142 IN PIO_WORKITEM IoWorkItem); 4143 typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; 4144 4145 typedef struct _SHARE_ACCESS { 4146 ULONG OpenCount; 4147 ULONG Readers; 4148 ULONG Writers; 4149 ULONG Deleters; 4150 ULONG SharedRead; 4151 ULONG SharedWrite; 4152 ULONG SharedDelete; 4153 } SHARE_ACCESS, *PSHARE_ACCESS; 4154 4155 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as 4156 inheritance, even from a struct renders the type non-POD. So we use 4157 this hack */ 4158 #define PCI_COMMON_HEADER_LAYOUT \ 4159 USHORT VendorID; \ 4160 USHORT DeviceID; \ 4161 USHORT Command; \ 4162 USHORT Status; \ 4163 UCHAR RevisionID; \ 4164 UCHAR ProgIf; \ 4165 UCHAR SubClass; \ 4166 UCHAR BaseClass; \ 4167 UCHAR CacheLineSize; \ 4168 UCHAR LatencyTimer; \ 4169 UCHAR HeaderType; \ 4170 UCHAR BIST; \ 4171 union { \ 4172 struct /* _PCI_HEADER_TYPE_0 */ { \ 4173 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ 4174 ULONG CIS; \ 4175 USHORT SubVendorID; \ 4176 USHORT SubSystemID; \ 4177 ULONG ROMBaseAddress; \ 4178 UCHAR CapabilitiesPtr; \ 4179 UCHAR Reserved1[3]; \ 4180 ULONG Reserved2; \ 4181 UCHAR InterruptLine; \ 4182 UCHAR InterruptPin; \ 4183 UCHAR MinimumGrant; \ 4184 UCHAR MaximumLatency; \ 4185 } type0; \ 4186 struct /* _PCI_HEADER_TYPE_1 */ { \ 4187 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ 4188 UCHAR PrimaryBus; \ 4189 UCHAR SecondaryBus; \ 4190 UCHAR SubordinateBus; \ 4191 UCHAR SecondaryLatency; \ 4192 UCHAR IOBase; \ 4193 UCHAR IOLimit; \ 4194 USHORT SecondaryStatus; \ 4195 USHORT MemoryBase; \ 4196 USHORT MemoryLimit; \ 4197 USHORT PrefetchBase; \ 4198 USHORT PrefetchLimit; \ 4199 ULONG PrefetchBaseUpper32; \ 4200 ULONG PrefetchLimitUpper32; \ 4201 USHORT IOBaseUpper16; \ 4202 USHORT IOLimitUpper16; \ 4203 UCHAR CapabilitiesPtr; \ 4204 UCHAR Reserved1[3]; \ 4205 ULONG ROMBaseAddress; \ 4206 UCHAR InterruptLine; \ 4207 UCHAR InterruptPin; \ 4208 USHORT BridgeControl; \ 4209 } type1; \ 4210 struct /* _PCI_HEADER_TYPE_2 */ { \ 4211 ULONG SocketRegistersBaseAddress; \ 4212 UCHAR CapabilitiesPtr; \ 4213 UCHAR Reserved; \ 4214 USHORT SecondaryStatus; \ 4215 UCHAR PrimaryBus; \ 4216 UCHAR SecondaryBus; \ 4217 UCHAR SubordinateBus; \ 4218 UCHAR SecondaryLatency; \ 4219 struct { \ 4220 ULONG Base; \ 4221 ULONG Limit; \ 4222 } Range[PCI_TYPE2_ADDRESSES-1]; \ 4223 UCHAR InterruptLine; \ 4224 UCHAR InterruptPin; \ 4225 USHORT BridgeControl; \ 4226 } type2; \ 4227 } u; 4228 4229 typedef enum _CREATE_FILE_TYPE { 4230 CreateFileTypeNone, 4231 CreateFileTypeNamedPipe, 4232 CreateFileTypeMailslot 4233 } CREATE_FILE_TYPE; 4234 4235 #define IO_FORCE_ACCESS_CHECK 0x001 4236 #define IO_NO_PARAMETER_CHECKING 0x100 4237 4238 #define IO_REPARSE 0x0 4239 #define IO_REMOUNT 0x1 4240 4241 typedef struct _IO_STATUS_BLOCK { 4242 _ANONYMOUS_UNION union { 4243 NTSTATUS Status; 4244 PVOID Pointer; 4245 } DUMMYUNIONNAME; 4246 ULONG_PTR Information; 4247 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; 4248 4249 #if defined(_WIN64) 4250 typedef struct _IO_STATUS_BLOCK32 { 4251 NTSTATUS Status; 4252 ULONG Information; 4253 } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32; 4254 #endif 4255 4256 typedef VOID 4257 (NTAPI *PIO_APC_ROUTINE)( 4258 IN PVOID ApcContext, 4259 IN PIO_STATUS_BLOCK IoStatusBlock, 4260 IN ULONG Reserved); 4261 4262 #define PIO_APC_ROUTINE_DEFINED 4263 4264 typedef enum _IO_SESSION_EVENT { 4265 IoSessionEventIgnore = 0, 4266 IoSessionEventCreated, 4267 IoSessionEventTerminated, 4268 IoSessionEventConnected, 4269 IoSessionEventDisconnected, 4270 IoSessionEventLogon, 4271 IoSessionEventLogoff, 4272 IoSessionEventMax 4273 } IO_SESSION_EVENT, *PIO_SESSION_EVENT; 4274 4275 #define IO_SESSION_STATE_ALL_EVENTS 0xffffffff 4276 #define IO_SESSION_STATE_CREATION_EVENT 0x00000001 4277 #define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002 4278 #define IO_SESSION_STATE_CONNECT_EVENT 0x00000004 4279 #define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008 4280 #define IO_SESSION_STATE_LOGON_EVENT 0x00000010 4281 #define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020 4282 4283 #define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f 4284 4285 #define IO_SESSION_MAX_PAYLOAD_SIZE 256L 4286 4287 typedef struct _IO_SESSION_CONNECT_INFO { 4288 ULONG SessionId; 4289 BOOLEAN LocalSession; 4290 } IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO; 4291 4292 #define EVENT_INCREMENT 1 4293 #define IO_NO_INCREMENT 0 4294 #define IO_CD_ROM_INCREMENT 1 4295 #define IO_DISK_INCREMENT 1 4296 #define IO_KEYBOARD_INCREMENT 6 4297 #define IO_MAILSLOT_INCREMENT 2 4298 #define IO_MOUSE_INCREMENT 6 4299 #define IO_NAMED_PIPE_INCREMENT 2 4300 #define IO_NETWORK_INCREMENT 2 4301 #define IO_PARALLEL_INCREMENT 1 4302 #define IO_SERIAL_INCREMENT 2 4303 #define IO_SOUND_INCREMENT 8 4304 #define IO_VIDEO_INCREMENT 1 4305 #define SEMAPHORE_INCREMENT 1 4306 4307 #define MM_MAXIMUM_DISK_IO_SIZE (0x10000) 4308 4309 typedef struct _BOOTDISK_INFORMATION { 4310 LONGLONG BootPartitionOffset; 4311 LONGLONG SystemPartitionOffset; 4312 ULONG BootDeviceSignature; 4313 ULONG SystemDeviceSignature; 4314 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION; 4315 4316 typedef struct _BOOTDISK_INFORMATION_EX { 4317 LONGLONG BootPartitionOffset; 4318 LONGLONG SystemPartitionOffset; 4319 ULONG BootDeviceSignature; 4320 ULONG SystemDeviceSignature; 4321 GUID BootDeviceGuid; 4322 GUID SystemDeviceGuid; 4323 BOOLEAN BootDeviceIsGpt; 4324 BOOLEAN SystemDeviceIsGpt; 4325 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; 4326 4327 #if (NTDDI_VERSION >= NTDDI_WIN7) 4328 4329 typedef struct _LOADER_PARTITION_INFORMATION_EX { 4330 ULONG PartitionStyle; 4331 ULONG PartitionNumber; 4332 _ANONYMOUS_UNION union { 4333 ULONG Signature; 4334 GUID DeviceId; 4335 } DUMMYUNIONNAME; 4336 ULONG Flags; 4337 } LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; 4338 4339 typedef struct _BOOTDISK_INFORMATION_LITE { 4340 ULONG NumberEntries; 4341 LOADER_PARTITION_INFORMATION_EX Entries[1]; 4342 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; 4343 4344 #else 4345 4346 #if (NTDDI_VERSION >= NTDDI_VISTA) 4347 typedef struct _BOOTDISK_INFORMATION_LITE { 4348 ULONG BootDeviceSignature; 4349 ULONG SystemDeviceSignature; 4350 GUID BootDeviceGuid; 4351 GUID SystemDeviceGuid; 4352 BOOLEAN BootDeviceIsGpt; 4353 BOOLEAN SystemDeviceIsGpt; 4354 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; 4355 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 4356 4357 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 4358 4359 #include <pshpack1.h> 4360 4361 typedef struct _EISA_MEMORY_TYPE { 4362 UCHAR ReadWrite:1; 4363 UCHAR Cached:1; 4364 UCHAR Reserved0:1; 4365 UCHAR Type:2; 4366 UCHAR Shared:1; 4367 UCHAR Reserved1:1; 4368 UCHAR MoreEntries:1; 4369 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; 4370 4371 typedef struct _EISA_MEMORY_CONFIGURATION { 4372 EISA_MEMORY_TYPE ConfigurationByte; 4373 UCHAR DataSize; 4374 USHORT AddressLowWord; 4375 UCHAR AddressHighByte; 4376 USHORT MemorySize; 4377 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; 4378 4379 typedef struct _EISA_IRQ_DESCRIPTOR { 4380 UCHAR Interrupt:4; 4381 UCHAR Reserved:1; 4382 UCHAR LevelTriggered:1; 4383 UCHAR Shared:1; 4384 UCHAR MoreEntries:1; 4385 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; 4386 4387 typedef struct _EISA_IRQ_CONFIGURATION { 4388 EISA_IRQ_DESCRIPTOR ConfigurationByte; 4389 UCHAR Reserved; 4390 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; 4391 4392 typedef struct _DMA_CONFIGURATION_BYTE0 { 4393 UCHAR Channel:3; 4394 UCHAR Reserved:3; 4395 UCHAR Shared:1; 4396 UCHAR MoreEntries:1; 4397 } DMA_CONFIGURATION_BYTE0; 4398 4399 typedef struct _DMA_CONFIGURATION_BYTE1 { 4400 UCHAR Reserved0:2; 4401 UCHAR TransferSize:2; 4402 UCHAR Timing:2; 4403 UCHAR Reserved1:2; 4404 } DMA_CONFIGURATION_BYTE1; 4405 4406 typedef struct _EISA_DMA_CONFIGURATION { 4407 DMA_CONFIGURATION_BYTE0 ConfigurationByte0; 4408 DMA_CONFIGURATION_BYTE1 ConfigurationByte1; 4409 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; 4410 4411 typedef struct _EISA_PORT_DESCRIPTOR { 4412 UCHAR NumberPorts:5; 4413 UCHAR Reserved:1; 4414 UCHAR Shared:1; 4415 UCHAR MoreEntries:1; 4416 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; 4417 4418 typedef struct _EISA_PORT_CONFIGURATION { 4419 EISA_PORT_DESCRIPTOR Configuration; 4420 USHORT PortAddress; 4421 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; 4422 4423 typedef struct _CM_EISA_SLOT_INFORMATION { 4424 UCHAR ReturnCode; 4425 UCHAR ReturnFlags; 4426 UCHAR MajorRevision; 4427 UCHAR MinorRevision; 4428 USHORT Checksum; 4429 UCHAR NumberFunctions; 4430 UCHAR FunctionInformation; 4431 ULONG CompressedId; 4432 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; 4433 4434 typedef struct _CM_EISA_FUNCTION_INFORMATION { 4435 ULONG CompressedId; 4436 UCHAR IdSlotFlags1; 4437 UCHAR IdSlotFlags2; 4438 UCHAR MinorRevision; 4439 UCHAR MajorRevision; 4440 UCHAR Selections[26]; 4441 UCHAR FunctionFlags; 4442 UCHAR TypeString[80]; 4443 EISA_MEMORY_CONFIGURATION EisaMemory[9]; 4444 EISA_IRQ_CONFIGURATION EisaIrq[7]; 4445 EISA_DMA_CONFIGURATION EisaDma[4]; 4446 EISA_PORT_CONFIGURATION EisaPort[20]; 4447 UCHAR InitializationData[60]; 4448 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; 4449 4450 #include <poppack.h> 4451 4452 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */ 4453 4454 #define EISA_FUNCTION_ENABLED 0x80 4455 #define EISA_FREE_FORM_DATA 0x40 4456 #define EISA_HAS_PORT_INIT_ENTRY 0x20 4457 #define EISA_HAS_PORT_RANGE 0x10 4458 #define EISA_HAS_DMA_ENTRY 0x08 4459 #define EISA_HAS_IRQ_ENTRY 0x04 4460 #define EISA_HAS_MEMORY_ENTRY 0x02 4461 #define EISA_HAS_TYPE_ENTRY 0x01 4462 #define EISA_HAS_INFORMATION \ 4463 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \ 4464 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY) 4465 4466 #define EISA_MORE_ENTRIES 0x80 4467 #define EISA_SYSTEM_MEMORY 0x00 4468 #define EISA_MEMORY_TYPE_RAM 0x01 4469 4470 /* CM_EISA_SLOT_INFORMATION.ReturnCode */ 4471 4472 #define EISA_INVALID_SLOT 0x80 4473 #define EISA_INVALID_FUNCTION 0x81 4474 #define EISA_INVALID_CONFIGURATION 0x82 4475 #define EISA_EMPTY_SLOT 0x83 4476 #define EISA_INVALID_BIOS_CALL 0x86 4477 4478 /* 4479 ** Plug and Play structures 4480 */ 4481 4482 typedef VOID 4483 (NTAPI *PINTERFACE_REFERENCE)( 4484 PVOID Context); 4485 4486 typedef VOID 4487 (NTAPI *PINTERFACE_DEREFERENCE)( 4488 PVOID Context); 4489 4490 typedef BOOLEAN 4491 (NTAPI TRANSLATE_BUS_ADDRESS)( 4492 IN PVOID Context, 4493 IN PHYSICAL_ADDRESS BusAddress, 4494 IN ULONG Length, 4495 IN OUT PULONG AddressSpace, 4496 OUT PPHYSICAL_ADDRESS TranslatedAddress); 4497 typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; 4498 4499 typedef struct _DMA_ADAPTER* 4500 (NTAPI GET_DMA_ADAPTER)( 4501 IN PVOID Context, 4502 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, 4503 OUT PULONG NumberOfMapRegisters); 4504 typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; 4505 4506 typedef ULONG 4507 (NTAPI GET_SET_DEVICE_DATA)( 4508 IN PVOID Context, 4509 IN ULONG DataType, 4510 IN PVOID Buffer, 4511 IN ULONG Offset, 4512 IN ULONG Length); 4513 typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; 4514 4515 typedef enum _DEVICE_INSTALL_STATE { 4516 InstallStateInstalled, 4517 InstallStateNeedsReinstall, 4518 InstallStateFailedInstall, 4519 InstallStateFinishInstall 4520 } DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE; 4521 4522 typedef struct _LEGACY_BUS_INFORMATION { 4523 GUID BusTypeGuid; 4524 INTERFACE_TYPE LegacyBusType; 4525 ULONG BusNumber; 4526 } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION; 4527 4528 typedef enum _DEVICE_REMOVAL_POLICY { 4529 RemovalPolicyExpectNoRemoval = 1, 4530 RemovalPolicyExpectOrderlyRemoval = 2, 4531 RemovalPolicyExpectSurpriseRemoval = 3 4532 } DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY; 4533 4534 typedef VOID 4535 (NTAPI*PREENUMERATE_SELF)( 4536 IN PVOID Context); 4537 4538 typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD { 4539 USHORT Size; 4540 USHORT Version; 4541 PVOID Context; 4542 PINTERFACE_REFERENCE InterfaceReference; 4543 PINTERFACE_DEREFERENCE InterfaceDereference; 4544 PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf; 4545 } REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD; 4546 4547 typedef VOID 4548 (NTAPI *PIO_DEVICE_EJECT_CALLBACK)( 4549 IN NTSTATUS Status, 4550 IN OUT PVOID Context OPTIONAL); 4551 4552 #define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1 4553 4554 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ 4555 #define PCI_USE_SUBSYSTEM_IDS 0x00000001 4556 #define PCI_USE_REVISION 0x00000002 4557 #define PCI_USE_VENDEV_IDS 0x00000004 4558 #define PCI_USE_CLASS_SUBCLASS 0x00000008 4559 #define PCI_USE_PROGIF 0x00000010 4560 #define PCI_USE_LOCAL_BUS 0x00000020 4561 #define PCI_USE_LOCAL_DEVICE 0x00000040 4562 4563 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { 4564 ULONG Size; 4565 ULONG Flags; 4566 USHORT VendorID; 4567 USHORT DeviceID; 4568 UCHAR RevisionID; 4569 USHORT SubVendorID; 4570 USHORT SubSystemID; 4571 UCHAR BaseClass; 4572 UCHAR SubClass; 4573 UCHAR ProgIf; 4574 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; 4575 4576 typedef BOOLEAN 4577 (NTAPI PCI_IS_DEVICE_PRESENT)( 4578 IN USHORT VendorID, 4579 IN USHORT DeviceID, 4580 IN UCHAR RevisionID, 4581 IN USHORT SubVendorID, 4582 IN USHORT SubSystemID, 4583 IN ULONG Flags); 4584 typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; 4585 4586 typedef BOOLEAN 4587 (NTAPI PCI_IS_DEVICE_PRESENT_EX)( 4588 IN PVOID Context, 4589 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); 4590 typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; 4591 4592 typedef struct _BUS_INTERFACE_STANDARD { 4593 USHORT Size; 4594 USHORT Version; 4595 PVOID Context; 4596 PINTERFACE_REFERENCE InterfaceReference; 4597 PINTERFACE_DEREFERENCE InterfaceDereference; 4598 PTRANSLATE_BUS_ADDRESS TranslateBusAddress; 4599 PGET_DMA_ADAPTER GetDmaAdapter; 4600 PGET_SET_DEVICE_DATA SetBusData; 4601 PGET_SET_DEVICE_DATA GetBusData; 4602 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD; 4603 4604 typedef struct _PCI_DEVICE_PRESENT_INTERFACE { 4605 USHORT Size; 4606 USHORT Version; 4607 PVOID Context; 4608 PINTERFACE_REFERENCE InterfaceReference; 4609 PINTERFACE_DEREFERENCE InterfaceDereference; 4610 PPCI_IS_DEVICE_PRESENT IsDevicePresent; 4611 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; 4612 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE; 4613 4614 typedef struct _DEVICE_CAPABILITIES { 4615 USHORT Size; 4616 USHORT Version; 4617 ULONG DeviceD1:1; 4618 ULONG DeviceD2:1; 4619 ULONG LockSupported:1; 4620 ULONG EjectSupported:1; 4621 ULONG Removable:1; 4622 ULONG DockDevice:1; 4623 ULONG UniqueID:1; 4624 ULONG SilentInstall:1; 4625 ULONG RawDeviceOK:1; 4626 ULONG SurpriseRemovalOK:1; 4627 ULONG WakeFromD0:1; 4628 ULONG WakeFromD1:1; 4629 ULONG WakeFromD2:1; 4630 ULONG WakeFromD3:1; 4631 ULONG HardwareDisabled:1; 4632 ULONG NonDynamic:1; 4633 ULONG WarmEjectSupported:1; 4634 ULONG NoDisplayInUI:1; 4635 ULONG Reserved:14; 4636 ULONG Address; 4637 ULONG UINumber; 4638 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; 4639 SYSTEM_POWER_STATE SystemWake; 4640 DEVICE_POWER_STATE DeviceWake; 4641 ULONG D1Latency; 4642 ULONG D2Latency; 4643 ULONG D3Latency; 4644 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; 4645 4646 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION { 4647 USHORT Version; 4648 USHORT Size; 4649 GUID Event; 4650 GUID InterfaceClassGuid; 4651 PUNICODE_STRING SymbolicLinkName; 4652 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION; 4653 4654 typedef struct _HWPROFILE_CHANGE_NOTIFICATION { 4655 USHORT Version; 4656 USHORT Size; 4657 GUID Event; 4658 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION; 4659 4660 #undef INTERFACE 4661 4662 typedef struct _INTERFACE { 4663 USHORT Size; 4664 USHORT Version; 4665 PVOID Context; 4666 PINTERFACE_REFERENCE InterfaceReference; 4667 PINTERFACE_DEREFERENCE InterfaceDereference; 4668 } INTERFACE, *PINTERFACE; 4669 4670 typedef struct _PLUGPLAY_NOTIFICATION_HEADER { 4671 USHORT Version; 4672 USHORT Size; 4673 GUID Event; 4674 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER; 4675 4676 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; 4677 4678 /* PNP_DEVICE_STATE */ 4679 4680 #define PNP_DEVICE_DISABLED 0x00000001 4681 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002 4682 #define PNP_DEVICE_FAILED 0x00000004 4683 #define PNP_DEVICE_REMOVED 0x00000008 4684 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010 4685 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020 4686 4687 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION { 4688 USHORT Version; 4689 USHORT Size; 4690 GUID Event; 4691 struct _FILE_OBJECT *FileObject; 4692 LONG NameBufferOffset; 4693 UCHAR CustomDataBuffer[1]; 4694 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION; 4695 4696 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION { 4697 USHORT Version; 4698 USHORT Size; 4699 GUID Event; 4700 struct _FILE_OBJECT *FileObject; 4701 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION; 4702 4703 #if (NTDDI_VERSION >= NTDDI_VISTA) 4704 #include <devpropdef.h> 4705 #define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001 4706 #endif 4707 4708 #define PNP_REPLACE_NO_MAP MAXLONGLONG 4709 4710 typedef NTSTATUS 4711 (NTAPI *PREPLACE_MAP_MEMORY)( 4712 IN PHYSICAL_ADDRESS TargetPhysicalAddress, 4713 IN PHYSICAL_ADDRESS SparePhysicalAddress, 4714 IN OUT PLARGE_INTEGER NumberOfBytes, 4715 OUT PVOID *TargetAddress, 4716 OUT PVOID *SpareAddress); 4717 4718 typedef struct _PNP_REPLACE_MEMORY_LIST { 4719 ULONG AllocatedCount; 4720 ULONG Count; 4721 ULONGLONG TotalLength; 4722 struct { 4723 PHYSICAL_ADDRESS Address; 4724 ULONGLONG Length; 4725 } Ranges[ANYSIZE_ARRAY]; 4726 } PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST; 4727 4728 typedef struct _PNP_REPLACE_PROCESSOR_LIST { 4729 PKAFFINITY Affinity; 4730 ULONG GroupCount; 4731 ULONG AllocatedCount; 4732 ULONG Count; 4733 ULONG ApicIds[ANYSIZE_ARRAY]; 4734 } PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST; 4735 4736 typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 { 4737 KAFFINITY AffinityMask; 4738 ULONG AllocatedCount; 4739 ULONG Count; 4740 ULONG ApicIds[ANYSIZE_ARRAY]; 4741 } PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1; 4742 4743 #define PNP_REPLACE_PARAMETERS_VERSION 2 4744 4745 typedef struct _PNP_REPLACE_PARAMETERS { 4746 ULONG Size; 4747 ULONG Version; 4748 ULONG64 Target; 4749 ULONG64 Spare; 4750 PPNP_REPLACE_PROCESSOR_LIST TargetProcessors; 4751 PPNP_REPLACE_PROCESSOR_LIST SpareProcessors; 4752 PPNP_REPLACE_MEMORY_LIST TargetMemory; 4753 PPNP_REPLACE_MEMORY_LIST SpareMemory; 4754 PREPLACE_MAP_MEMORY MapMemory; 4755 } PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS; 4756 4757 typedef VOID 4758 (NTAPI *PREPLACE_UNLOAD)( 4759 VOID); 4760 4761 typedef NTSTATUS 4762 (NTAPI *PREPLACE_BEGIN)( 4763 IN PPNP_REPLACE_PARAMETERS Parameters, 4764 OUT PVOID *Context); 4765 4766 typedef NTSTATUS 4767 (NTAPI *PREPLACE_END)( 4768 IN PVOID Context); 4769 4770 typedef NTSTATUS 4771 (NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)( 4772 IN PVOID Context, 4773 IN PHYSICAL_ADDRESS PhysicalAddress, 4774 IN LARGE_INTEGER ByteCount); 4775 4776 typedef NTSTATUS 4777 (NTAPI *PREPLACE_SET_PROCESSOR_ID)( 4778 IN PVOID Context, 4779 IN ULONG ApicId, 4780 IN BOOLEAN Target); 4781 4782 typedef NTSTATUS 4783 (NTAPI *PREPLACE_SWAP)( 4784 IN PVOID Context); 4785 4786 typedef NTSTATUS 4787 (NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)( 4788 IN PVOID Context); 4789 4790 typedef NTSTATUS 4791 (NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)( 4792 IN PVOID Context); 4793 4794 typedef NTSTATUS 4795 (NTAPI *PREPLACE_GET_MEMORY_DESTINATION)( 4796 IN PVOID Context, 4797 IN PHYSICAL_ADDRESS SourceAddress, 4798 OUT PPHYSICAL_ADDRESS DestinationAddress); 4799 4800 typedef NTSTATUS 4801 (NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)( 4802 IN PVOID Context, 4803 IN BOOLEAN Enable); 4804 4805 #define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1 4806 #define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \ 4807 FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror) 4808 4809 #define PNP_REPLACE_MEMORY_SUPPORTED 0x0001 4810 #define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002 4811 #define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004 4812 #define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008 4813 #define PNP_REPLACE_HARDWARE_QUIESCE 0x0010 4814 4815 typedef struct _PNP_REPLACE_DRIVER_INTERFACE { 4816 ULONG Size; 4817 ULONG Version; 4818 ULONG Flags; 4819 PREPLACE_UNLOAD Unload; 4820 PREPLACE_BEGIN BeginReplace; 4821 PREPLACE_END EndReplace; 4822 PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory; 4823 PREPLACE_SET_PROCESSOR_ID SetProcessorId; 4824 PREPLACE_SWAP Swap; 4825 PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror; 4826 PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory; 4827 PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination; 4828 PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce; 4829 } PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE; 4830 4831 typedef NTSTATUS 4832 (NTAPI *PREPLACE_DRIVER_INIT)( 4833 IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface, 4834 IN PVOID Unused); 4835 4836 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { 4837 DeviceUsageTypeUndefined, 4838 DeviceUsageTypePaging, 4839 DeviceUsageTypeHibernation, 4840 DeviceUsageTypeDumpFile 4841 } DEVICE_USAGE_NOTIFICATION_TYPE; 4842 4843 typedef struct _POWER_SEQUENCE { 4844 ULONG SequenceD1; 4845 ULONG SequenceD2; 4846 ULONG SequenceD3; 4847 } POWER_SEQUENCE, *PPOWER_SEQUENCE; 4848 4849 typedef enum { 4850 DevicePropertyDeviceDescription = 0x0, 4851 DevicePropertyHardwareID = 0x1, 4852 DevicePropertyCompatibleIDs = 0x2, 4853 DevicePropertyBootConfiguration = 0x3, 4854 DevicePropertyBootConfigurationTranslated = 0x4, 4855 DevicePropertyClassName = 0x5, 4856 DevicePropertyClassGuid = 0x6, 4857 DevicePropertyDriverKeyName = 0x7, 4858 DevicePropertyManufacturer = 0x8, 4859 DevicePropertyFriendlyName = 0x9, 4860 DevicePropertyLocationInformation = 0xa, 4861 DevicePropertyPhysicalDeviceObjectName = 0xb, 4862 DevicePropertyBusTypeGuid = 0xc, 4863 DevicePropertyLegacyBusType = 0xd, 4864 DevicePropertyBusNumber = 0xe, 4865 DevicePropertyEnumeratorName = 0xf, 4866 DevicePropertyAddress = 0x10, 4867 DevicePropertyUINumber = 0x11, 4868 DevicePropertyInstallState = 0x12, 4869 DevicePropertyRemovalPolicy = 0x13, 4870 DevicePropertyResourceRequirements = 0x14, 4871 DevicePropertyAllocatedResources = 0x15, 4872 DevicePropertyContainerID = 0x16 4873 } DEVICE_REGISTRY_PROPERTY; 4874 4875 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { 4876 EventCategoryReserved, 4877 EventCategoryHardwareProfileChange, 4878 EventCategoryDeviceInterfaceChange, 4879 EventCategoryTargetDeviceChange 4880 } IO_NOTIFICATION_EVENT_CATEGORY; 4881 4882 typedef enum _IO_PRIORITY_HINT { 4883 IoPriorityVeryLow = 0, 4884 IoPriorityLow, 4885 IoPriorityNormal, 4886 IoPriorityHigh, 4887 IoPriorityCritical, 4888 MaxIoPriorityTypes 4889 } IO_PRIORITY_HINT; 4890 4891 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 4892 4893 typedef NTSTATUS 4894 (NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( 4895 IN PVOID NotificationStructure, 4896 IN PVOID Context); 4897 typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; 4898 4899 typedef VOID 4900 (NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( 4901 IN PVOID Context); 4902 typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; 4903 4904 typedef enum _FILE_INFORMATION_CLASS { 4905 FileDirectoryInformation = 1, 4906 FileFullDirectoryInformation, 4907 FileBothDirectoryInformation, 4908 FileBasicInformation, 4909 FileStandardInformation, 4910 FileInternalInformation, 4911 FileEaInformation, 4912 FileAccessInformation, 4913 FileNameInformation, 4914 FileRenameInformation, 4915 FileLinkInformation, 4916 FileNamesInformation, 4917 FileDispositionInformation, 4918 FilePositionInformation, 4919 FileFullEaInformation, 4920 FileModeInformation, 4921 FileAlignmentInformation, 4922 FileAllInformation, 4923 FileAllocationInformation, 4924 FileEndOfFileInformation, 4925 FileAlternateNameInformation, 4926 FileStreamInformation, 4927 FilePipeInformation, 4928 FilePipeLocalInformation, 4929 FilePipeRemoteInformation, 4930 FileMailslotQueryInformation, 4931 FileMailslotSetInformation, 4932 FileCompressionInformation, 4933 FileObjectIdInformation, 4934 FileCompletionInformation, 4935 FileMoveClusterInformation, 4936 FileQuotaInformation, 4937 FileReparsePointInformation, 4938 FileNetworkOpenInformation, 4939 FileAttributeTagInformation, 4940 FileTrackingInformation, 4941 FileIdBothDirectoryInformation, 4942 FileIdFullDirectoryInformation, 4943 FileValidDataLengthInformation, 4944 FileShortNameInformation, 4945 FileIoCompletionNotificationInformation, 4946 FileIoStatusBlockRangeInformation, 4947 FileIoPriorityHintInformation, 4948 FileSfioReserveInformation, 4949 FileSfioVolumeInformation, 4950 FileHardLinkInformation, 4951 FileProcessIdsUsingFileInformation, 4952 FileNormalizedNameInformation, 4953 FileNetworkPhysicalNameInformation, 4954 FileIdGlobalTxDirectoryInformation, 4955 FileIsRemoteDeviceInformation, 4956 FileAttributeCacheInformation, 4957 FileNumaNodeInformation, 4958 FileStandardLinkInformation, 4959 FileRemoteProtocolInformation, 4960 FileMaximumInformation 4961 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; 4962 4963 typedef struct _FILE_POSITION_INFORMATION { 4964 LARGE_INTEGER CurrentByteOffset; 4965 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; 4966 4967 typedef struct _FILE_BASIC_INFORMATION { 4968 LARGE_INTEGER CreationTime; 4969 LARGE_INTEGER LastAccessTime; 4970 LARGE_INTEGER LastWriteTime; 4971 LARGE_INTEGER ChangeTime; 4972 ULONG FileAttributes; 4973 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; 4974 4975 typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION { 4976 IO_PRIORITY_HINT PriorityHint; 4977 } FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION; 4978 4979 typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION { 4980 ULONG Flags; 4981 } FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION; 4982 4983 typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION { 4984 PUCHAR IoStatusBlockRange; 4985 ULONG Length; 4986 } FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION; 4987 4988 typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION { 4989 BOOLEAN IsRemote; 4990 } FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION; 4991 4992 typedef struct _FILE_NUMA_NODE_INFORMATION { 4993 USHORT NodeNumber; 4994 } FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION; 4995 4996 typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION { 4997 ULONG NumberOfProcessIdsInList; 4998 ULONG_PTR ProcessIdList[1]; 4999 } FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION; 5000 5001 typedef struct _FILE_STANDARD_INFORMATION { 5002 LARGE_INTEGER AllocationSize; 5003 LARGE_INTEGER EndOfFile; 5004 ULONG NumberOfLinks; 5005 BOOLEAN DeletePending; 5006 BOOLEAN Directory; 5007 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; 5008 5009 typedef struct _FILE_NETWORK_OPEN_INFORMATION { 5010 LARGE_INTEGER CreationTime; 5011 LARGE_INTEGER LastAccessTime; 5012 LARGE_INTEGER LastWriteTime; 5013 LARGE_INTEGER ChangeTime; 5014 LARGE_INTEGER AllocationSize; 5015 LARGE_INTEGER EndOfFile; 5016 ULONG FileAttributes; 5017 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; 5018 5019 typedef enum _FSINFOCLASS { 5020 FileFsVolumeInformation = 1, 5021 FileFsLabelInformation, 5022 FileFsSizeInformation, 5023 FileFsDeviceInformation, 5024 FileFsAttributeInformation, 5025 FileFsControlInformation, 5026 FileFsFullSizeInformation, 5027 FileFsObjectIdInformation, 5028 FileFsDriverPathInformation, 5029 FileFsVolumeFlagsInformation, 5030 FileFsMaximumInformation 5031 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; 5032 5033 typedef struct _FILE_FS_DEVICE_INFORMATION { 5034 DEVICE_TYPE DeviceType; 5035 ULONG Characteristics; 5036 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; 5037 5038 typedef struct _FILE_FULL_EA_INFORMATION { 5039 ULONG NextEntryOffset; 5040 UCHAR Flags; 5041 UCHAR EaNameLength; 5042 USHORT EaValueLength; 5043 CHAR EaName[1]; 5044 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; 5045 5046 typedef struct _FILE_SFIO_RESERVE_INFORMATION { 5047 ULONG RequestsPerPeriod; 5048 ULONG Period; 5049 BOOLEAN RetryFailures; 5050 BOOLEAN Discardable; 5051 ULONG RequestSize; 5052 ULONG NumOutstandingRequests; 5053 } FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION; 5054 5055 typedef struct _FILE_SFIO_VOLUME_INFORMATION { 5056 ULONG MaximumRequestsPerPeriod; 5057 ULONG MinimumPeriod; 5058 ULONG MinimumTransferSize; 5059 } FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION; 5060 5061 #define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 5062 #define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 5063 #define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4 5064 5065 #define FM_LOCK_BIT (0x1) 5066 #define FM_LOCK_BIT_V (0x0) 5067 #define FM_LOCK_WAITER_WOKEN (0x2) 5068 #define FM_LOCK_WAITER_INC (0x4) 5069 5070 typedef BOOLEAN 5071 (NTAPI FAST_IO_CHECK_IF_POSSIBLE)( 5072 IN struct _FILE_OBJECT *FileObject, 5073 IN PLARGE_INTEGER FileOffset, 5074 IN ULONG Length, 5075 IN BOOLEAN Wait, 5076 IN ULONG LockKey, 5077 IN BOOLEAN CheckForReadOperation, 5078 OUT PIO_STATUS_BLOCK IoStatus, 5079 IN struct _DEVICE_OBJECT *DeviceObject); 5080 typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; 5081 5082 typedef BOOLEAN 5083 (NTAPI FAST_IO_READ)( 5084 IN struct _FILE_OBJECT *FileObject, 5085 IN PLARGE_INTEGER FileOffset, 5086 IN ULONG Length, 5087 IN BOOLEAN Wait, 5088 IN ULONG LockKey, 5089 OUT PVOID Buffer, 5090 OUT PIO_STATUS_BLOCK IoStatus, 5091 IN struct _DEVICE_OBJECT *DeviceObject); 5092 typedef FAST_IO_READ *PFAST_IO_READ; 5093 5094 typedef BOOLEAN 5095 (NTAPI FAST_IO_WRITE)( 5096 IN struct _FILE_OBJECT *FileObject, 5097 IN PLARGE_INTEGER FileOffset, 5098 IN ULONG Length, 5099 IN BOOLEAN Wait, 5100 IN ULONG LockKey, 5101 IN PVOID Buffer, 5102 OUT PIO_STATUS_BLOCK IoStatus, 5103 IN struct _DEVICE_OBJECT *DeviceObject); 5104 typedef FAST_IO_WRITE *PFAST_IO_WRITE; 5105 5106 typedef BOOLEAN 5107 (NTAPI FAST_IO_QUERY_BASIC_INFO)( 5108 IN struct _FILE_OBJECT *FileObject, 5109 IN BOOLEAN Wait, 5110 OUT PFILE_BASIC_INFORMATION Buffer, 5111 OUT PIO_STATUS_BLOCK IoStatus, 5112 IN struct _DEVICE_OBJECT *DeviceObject); 5113 typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; 5114 5115 typedef BOOLEAN 5116 (NTAPI FAST_IO_QUERY_STANDARD_INFO)( 5117 IN struct _FILE_OBJECT *FileObject, 5118 IN BOOLEAN Wait, 5119 OUT PFILE_STANDARD_INFORMATION Buffer, 5120 OUT PIO_STATUS_BLOCK IoStatus, 5121 IN struct _DEVICE_OBJECT *DeviceObject); 5122 typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; 5123 5124 typedef BOOLEAN 5125 (NTAPI FAST_IO_LOCK)( 5126 IN struct _FILE_OBJECT *FileObject, 5127 IN PLARGE_INTEGER FileOffset, 5128 IN PLARGE_INTEGER Length, 5129 PEPROCESS ProcessId, 5130 ULONG Key, 5131 BOOLEAN FailImmediately, 5132 BOOLEAN ExclusiveLock, 5133 OUT PIO_STATUS_BLOCK IoStatus, 5134 IN struct _DEVICE_OBJECT *DeviceObject); 5135 typedef FAST_IO_LOCK *PFAST_IO_LOCK; 5136 5137 typedef BOOLEAN 5138 (NTAPI FAST_IO_UNLOCK_SINGLE)( 5139 IN struct _FILE_OBJECT *FileObject, 5140 IN PLARGE_INTEGER FileOffset, 5141 IN PLARGE_INTEGER Length, 5142 PEPROCESS ProcessId, 5143 ULONG Key, 5144 OUT PIO_STATUS_BLOCK IoStatus, 5145 IN struct _DEVICE_OBJECT *DeviceObject); 5146 typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; 5147 5148 typedef BOOLEAN 5149 (NTAPI FAST_IO_UNLOCK_ALL)( 5150 IN struct _FILE_OBJECT *FileObject, 5151 PEPROCESS ProcessId, 5152 OUT PIO_STATUS_BLOCK IoStatus, 5153 IN struct _DEVICE_OBJECT *DeviceObject); 5154 typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; 5155 5156 typedef BOOLEAN 5157 (NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( 5158 IN struct _FILE_OBJECT *FileObject, 5159 PVOID ProcessId, 5160 ULONG Key, 5161 OUT PIO_STATUS_BLOCK IoStatus, 5162 IN struct _DEVICE_OBJECT *DeviceObject); 5163 typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; 5164 5165 typedef BOOLEAN 5166 (NTAPI FAST_IO_DEVICE_CONTROL)( 5167 IN struct _FILE_OBJECT *FileObject, 5168 IN BOOLEAN Wait, 5169 IN PVOID InputBuffer OPTIONAL, 5170 IN ULONG InputBufferLength, 5171 OUT PVOID OutputBuffer OPTIONAL, 5172 IN ULONG OutputBufferLength, 5173 IN ULONG IoControlCode, 5174 OUT PIO_STATUS_BLOCK IoStatus, 5175 IN struct _DEVICE_OBJECT *DeviceObject); 5176 typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; 5177 5178 typedef VOID 5179 (NTAPI FAST_IO_ACQUIRE_FILE)( 5180 IN struct _FILE_OBJECT *FileObject); 5181 typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; 5182 5183 typedef VOID 5184 (NTAPI FAST_IO_RELEASE_FILE)( 5185 IN struct _FILE_OBJECT *FileObject); 5186 typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; 5187 5188 typedef VOID 5189 (NTAPI FAST_IO_DETACH_DEVICE)( 5190 IN struct _DEVICE_OBJECT *SourceDevice, 5191 IN struct _DEVICE_OBJECT *TargetDevice); 5192 typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; 5193 5194 typedef BOOLEAN 5195 (NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( 5196 IN struct _FILE_OBJECT *FileObject, 5197 IN BOOLEAN Wait, 5198 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, 5199 OUT struct _IO_STATUS_BLOCK *IoStatus, 5200 IN struct _DEVICE_OBJECT *DeviceObject); 5201 typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; 5202 5203 typedef NTSTATUS 5204 (NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( 5205 IN struct _FILE_OBJECT *FileObject, 5206 IN PLARGE_INTEGER EndingOffset, 5207 OUT struct _ERESOURCE **ResourceToRelease, 5208 IN struct _DEVICE_OBJECT *DeviceObject); 5209 typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; 5210 5211 typedef BOOLEAN 5212 (NTAPI FAST_IO_MDL_READ)( 5213 IN struct _FILE_OBJECT *FileObject, 5214 IN PLARGE_INTEGER FileOffset, 5215 IN ULONG Length, 5216 IN ULONG LockKey, 5217 OUT PMDL *MdlChain, 5218 OUT PIO_STATUS_BLOCK IoStatus, 5219 IN struct _DEVICE_OBJECT *DeviceObject); 5220 typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; 5221 5222 typedef BOOLEAN 5223 (NTAPI FAST_IO_MDL_READ_COMPLETE)( 5224 IN struct _FILE_OBJECT *FileObject, 5225 IN PMDL MdlChain, 5226 IN struct _DEVICE_OBJECT *DeviceObject); 5227 typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; 5228 5229 typedef BOOLEAN 5230 (NTAPI FAST_IO_PREPARE_MDL_WRITE)( 5231 IN struct _FILE_OBJECT *FileObject, 5232 IN PLARGE_INTEGER FileOffset, 5233 IN ULONG Length, 5234 IN ULONG LockKey, 5235 OUT PMDL *MdlChain, 5236 OUT PIO_STATUS_BLOCK IoStatus, 5237 IN struct _DEVICE_OBJECT *DeviceObject); 5238 typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; 5239 5240 typedef BOOLEAN 5241 (NTAPI FAST_IO_MDL_WRITE_COMPLETE)( 5242 IN struct _FILE_OBJECT *FileObject, 5243 IN PLARGE_INTEGER FileOffset, 5244 IN PMDL MdlChain, 5245 IN struct _DEVICE_OBJECT *DeviceObject); 5246 typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; 5247 5248 typedef BOOLEAN 5249 (NTAPI FAST_IO_READ_COMPRESSED)( 5250 IN struct _FILE_OBJECT *FileObject, 5251 IN PLARGE_INTEGER FileOffset, 5252 IN ULONG Length, 5253 IN ULONG LockKey, 5254 OUT PVOID Buffer, 5255 OUT PMDL *MdlChain, 5256 OUT PIO_STATUS_BLOCK IoStatus, 5257 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, 5258 IN ULONG CompressedDataInfoLength, 5259 IN struct _DEVICE_OBJECT *DeviceObject); 5260 typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; 5261 5262 typedef BOOLEAN 5263 (NTAPI FAST_IO_WRITE_COMPRESSED)( 5264 IN struct _FILE_OBJECT *FileObject, 5265 IN PLARGE_INTEGER FileOffset, 5266 IN ULONG Length, 5267 IN ULONG LockKey, 5268 IN PVOID Buffer, 5269 OUT PMDL *MdlChain, 5270 OUT PIO_STATUS_BLOCK IoStatus, 5271 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, 5272 IN ULONG CompressedDataInfoLength, 5273 IN struct _DEVICE_OBJECT *DeviceObject); 5274 typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; 5275 5276 typedef BOOLEAN 5277 (NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( 5278 IN struct _FILE_OBJECT *FileObject, 5279 IN PMDL MdlChain, 5280 IN struct _DEVICE_OBJECT *DeviceObject); 5281 typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; 5282 5283 typedef BOOLEAN 5284 (NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( 5285 IN struct _FILE_OBJECT *FileObject, 5286 IN PLARGE_INTEGER FileOffset, 5287 IN PMDL MdlChain, 5288 IN struct _DEVICE_OBJECT *DeviceObject); 5289 typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; 5290 5291 typedef BOOLEAN 5292 (NTAPI FAST_IO_QUERY_OPEN)( 5293 IN struct _IRP *Irp, 5294 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, 5295 IN struct _DEVICE_OBJECT *DeviceObject); 5296 typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; 5297 5298 typedef NTSTATUS 5299 (NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( 5300 IN struct _FILE_OBJECT *FileObject, 5301 IN struct _ERESOURCE *ResourceToRelease, 5302 IN struct _DEVICE_OBJECT *DeviceObject); 5303 typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; 5304 5305 typedef NTSTATUS 5306 (NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( 5307 IN struct _FILE_OBJECT *FileObject, 5308 IN struct _DEVICE_OBJECT *DeviceObject); 5309 typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; 5310 5311 typedef NTSTATUS 5312 (NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( 5313 IN struct _FILE_OBJECT *FileObject, 5314 IN struct _DEVICE_OBJECT *DeviceObject); 5315 typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; 5316 5317 typedef struct _FAST_IO_DISPATCH { 5318 ULONG SizeOfFastIoDispatch; 5319 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; 5320 PFAST_IO_READ FastIoRead; 5321 PFAST_IO_WRITE FastIoWrite; 5322 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; 5323 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; 5324 PFAST_IO_LOCK FastIoLock; 5325 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; 5326 PFAST_IO_UNLOCK_ALL FastIoUnlockAll; 5327 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; 5328 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; 5329 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; 5330 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; 5331 PFAST_IO_DETACH_DEVICE FastIoDetachDevice; 5332 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; 5333 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; 5334 PFAST_IO_MDL_READ MdlRead; 5335 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; 5336 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; 5337 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; 5338 PFAST_IO_READ_COMPRESSED FastIoReadCompressed; 5339 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; 5340 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; 5341 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; 5342 PFAST_IO_QUERY_OPEN FastIoQueryOpen; 5343 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; 5344 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; 5345 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; 5346 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH; 5347 5348 typedef struct _SECTION_OBJECT_POINTERS { 5349 PVOID DataSectionObject; 5350 PVOID SharedCacheMap; 5351 PVOID ImageSectionObject; 5352 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS; 5353 5354 typedef struct _IO_COMPLETION_CONTEXT { 5355 PVOID Port; 5356 PVOID Key; 5357 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT; 5358 5359 /* FILE_OBJECT.Flags */ 5360 #define FO_FILE_OPEN 0x00000001 5361 #define FO_SYNCHRONOUS_IO 0x00000002 5362 #define FO_ALERTABLE_IO 0x00000004 5363 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008 5364 #define FO_WRITE_THROUGH 0x00000010 5365 #define FO_SEQUENTIAL_ONLY 0x00000020 5366 #define FO_CACHE_SUPPORTED 0x00000040 5367 #define FO_NAMED_PIPE 0x00000080 5368 #define FO_STREAM_FILE 0x00000100 5369 #define FO_MAILSLOT 0x00000200 5370 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400 5371 #define FO_QUEUE_IRP_TO_THREAD 0x00000400 5372 #define FO_DIRECT_DEVICE_OPEN 0x00000800 5373 #define FO_FILE_MODIFIED 0x00001000 5374 #define FO_FILE_SIZE_CHANGED 0x00002000 5375 #define FO_CLEANUP_COMPLETE 0x00004000 5376 #define FO_TEMPORARY_FILE 0x00008000 5377 #define FO_DELETE_ON_CLOSE 0x00010000 5378 #define FO_OPENED_CASE_SENSITIVE 0x00020000 5379 #define FO_HANDLE_CREATED 0x00040000 5380 #define FO_FILE_FAST_IO_READ 0x00080000 5381 #define FO_RANDOM_ACCESS 0x00100000 5382 #define FO_FILE_OPEN_CANCELLED 0x00200000 5383 #define FO_VOLUME_OPEN 0x00400000 5384 #define FO_REMOTE_ORIGIN 0x01000000 5385 #define FO_DISALLOW_EXCLUSIVE 0x02000000 5386 #define FO_SKIP_COMPLETION_PORT 0x02000000 5387 #define FO_SKIP_SET_EVENT 0x04000000 5388 #define FO_SKIP_SET_FAST_IO 0x08000000 5389 #define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE 5390 5391 /* VPB.Flags */ 5392 #define VPB_MOUNTED 0x0001 5393 #define VPB_LOCKED 0x0002 5394 #define VPB_PERSISTENT 0x0004 5395 #define VPB_REMOVE_PENDING 0x0008 5396 #define VPB_RAW_MOUNT 0x0010 5397 #define VPB_DIRECT_WRITES_ALLOWED 0x0020 5398 5399 /* IRP.Flags */ 5400 5401 #define SL_FORCE_ACCESS_CHECK 0x01 5402 #define SL_OPEN_PAGING_FILE 0x02 5403 #define SL_OPEN_TARGET_DIRECTORY 0x04 5404 #define SL_STOP_ON_SYMLINK 0x08 5405 #define SL_CASE_SENSITIVE 0x80 5406 5407 #define SL_KEY_SPECIFIED 0x01 5408 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 5409 #define SL_WRITE_THROUGH 0x04 5410 #define SL_FT_SEQUENTIAL_WRITE 0x08 5411 #define SL_FORCE_DIRECT_WRITE 0x10 5412 #define SL_REALTIME_STREAM 0x20 5413 5414 #define SL_READ_ACCESS_GRANTED 0x01 5415 #define SL_WRITE_ACCESS_GRANTED 0x04 5416 5417 #define SL_FAIL_IMMEDIATELY 0x01 5418 #define SL_EXCLUSIVE_LOCK 0x02 5419 5420 #define SL_RESTART_SCAN 0x01 5421 #define SL_RETURN_SINGLE_ENTRY 0x02 5422 #define SL_INDEX_SPECIFIED 0x04 5423 5424 #define SL_WATCH_TREE 0x01 5425 5426 #define SL_ALLOW_RAW_MOUNT 0x01 5427 5428 #define CTL_CODE(DeviceType, Function, Method, Access) \ 5429 (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) 5430 5431 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) 5432 5433 #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) 5434 5435 #define IRP_NOCACHE 0x00000001 5436 #define IRP_PAGING_IO 0x00000002 5437 #define IRP_MOUNT_COMPLETION 0x00000002 5438 #define IRP_SYNCHRONOUS_API 0x00000004 5439 #define IRP_ASSOCIATED_IRP 0x00000008 5440 #define IRP_BUFFERED_IO 0x00000010 5441 #define IRP_DEALLOCATE_BUFFER 0x00000020 5442 #define IRP_INPUT_OPERATION 0x00000040 5443 #define IRP_SYNCHRONOUS_PAGING_IO 0x00000040 5444 #define IRP_CREATE_OPERATION 0x00000080 5445 #define IRP_READ_OPERATION 0x00000100 5446 #define IRP_WRITE_OPERATION 0x00000200 5447 #define IRP_CLOSE_OPERATION 0x00000400 5448 #define IRP_DEFER_IO_COMPLETION 0x00000800 5449 #define IRP_OB_QUERY_NAME 0x00001000 5450 #define IRP_HOLD_DEVICE_QUEUE 0x00002000 5451 #define IRP_RETRY_IO_COMPLETION 0x00004000 5452 #define IRP_CLASS_CACHE_OPERATION 0x00008000 5453 5454 #define IRP_QUOTA_CHARGED 0x01 5455 #define IRP_ALLOCATED_MUST_SUCCEED 0x02 5456 #define IRP_ALLOCATED_FIXED_SIZE 0x04 5457 #define IRP_LOOKASIDE_ALLOCATION 0x08 5458 5459 /* 5460 ** IRP function codes 5461 */ 5462 5463 #define IRP_MJ_CREATE 0x00 5464 #define IRP_MJ_CREATE_NAMED_PIPE 0x01 5465 #define IRP_MJ_CLOSE 0x02 5466 #define IRP_MJ_READ 0x03 5467 #define IRP_MJ_WRITE 0x04 5468 #define IRP_MJ_QUERY_INFORMATION 0x05 5469 #define IRP_MJ_SET_INFORMATION 0x06 5470 #define IRP_MJ_QUERY_EA 0x07 5471 #define IRP_MJ_SET_EA 0x08 5472 #define IRP_MJ_FLUSH_BUFFERS 0x09 5473 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a 5474 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b 5475 #define IRP_MJ_DIRECTORY_CONTROL 0x0c 5476 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d 5477 #define IRP_MJ_DEVICE_CONTROL 0x0e 5478 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f 5479 #define IRP_MJ_SCSI 0x0f 5480 #define IRP_MJ_SHUTDOWN 0x10 5481 #define IRP_MJ_LOCK_CONTROL 0x11 5482 #define IRP_MJ_CLEANUP 0x12 5483 #define IRP_MJ_CREATE_MAILSLOT 0x13 5484 #define IRP_MJ_QUERY_SECURITY 0x14 5485 #define IRP_MJ_SET_SECURITY 0x15 5486 #define IRP_MJ_POWER 0x16 5487 #define IRP_MJ_SYSTEM_CONTROL 0x17 5488 #define IRP_MJ_DEVICE_CHANGE 0x18 5489 #define IRP_MJ_QUERY_QUOTA 0x19 5490 #define IRP_MJ_SET_QUOTA 0x1a 5491 #define IRP_MJ_PNP 0x1b 5492 #define IRP_MJ_PNP_POWER 0x1b 5493 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b 5494 5495 #define IRP_MN_SCSI_CLASS 0x01 5496 5497 #define IRP_MN_START_DEVICE 0x00 5498 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01 5499 #define IRP_MN_REMOVE_DEVICE 0x02 5500 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03 5501 #define IRP_MN_STOP_DEVICE 0x04 5502 #define IRP_MN_QUERY_STOP_DEVICE 0x05 5503 #define IRP_MN_CANCEL_STOP_DEVICE 0x06 5504 5505 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07 5506 #define IRP_MN_QUERY_INTERFACE 0x08 5507 #define IRP_MN_QUERY_CAPABILITIES 0x09 5508 #define IRP_MN_QUERY_RESOURCES 0x0A 5509 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B 5510 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C 5511 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D 5512 5513 #define IRP_MN_READ_CONFIG 0x0F 5514 #define IRP_MN_WRITE_CONFIG 0x10 5515 #define IRP_MN_EJECT 0x11 5516 #define IRP_MN_SET_LOCK 0x12 5517 #define IRP_MN_QUERY_ID 0x13 5518 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14 5519 #define IRP_MN_QUERY_BUS_INFORMATION 0x15 5520 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 5521 #define IRP_MN_SURPRISE_REMOVAL 0x17 5522 #if (NTDDI_VERSION >= NTDDI_WIN7) 5523 #define IRP_MN_DEVICE_ENUMERATED 0x19 5524 #endif 5525 5526 #define IRP_MN_WAIT_WAKE 0x00 5527 #define IRP_MN_POWER_SEQUENCE 0x01 5528 #define IRP_MN_SET_POWER 0x02 5529 #define IRP_MN_QUERY_POWER 0x03 5530 5531 #define IRP_MN_QUERY_ALL_DATA 0x00 5532 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01 5533 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02 5534 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03 5535 #define IRP_MN_ENABLE_EVENTS 0x04 5536 #define IRP_MN_DISABLE_EVENTS 0x05 5537 #define IRP_MN_ENABLE_COLLECTION 0x06 5538 #define IRP_MN_DISABLE_COLLECTION 0x07 5539 #define IRP_MN_REGINFO 0x08 5540 #define IRP_MN_EXECUTE_METHOD 0x09 5541 5542 #define IRP_MN_REGINFO_EX 0x0b 5543 5544 typedef struct _FILE_OBJECT { 5545 CSHORT Type; 5546 CSHORT Size; 5547 PDEVICE_OBJECT DeviceObject; 5548 PVPB Vpb; 5549 PVOID FsContext; 5550 PVOID FsContext2; 5551 PSECTION_OBJECT_POINTERS SectionObjectPointer; 5552 PVOID PrivateCacheMap; 5553 NTSTATUS FinalStatus; 5554 struct _FILE_OBJECT *RelatedFileObject; 5555 BOOLEAN LockOperation; 5556 BOOLEAN DeletePending; 5557 BOOLEAN ReadAccess; 5558 BOOLEAN WriteAccess; 5559 BOOLEAN DeleteAccess; 5560 BOOLEAN SharedRead; 5561 BOOLEAN SharedWrite; 5562 BOOLEAN SharedDelete; 5563 ULONG Flags; 5564 UNICODE_STRING FileName; 5565 LARGE_INTEGER CurrentByteOffset; 5566 volatile ULONG Waiters; 5567 volatile ULONG Busy; 5568 PVOID LastLock; 5569 KEVENT Lock; 5570 KEVENT Event; 5571 volatile PIO_COMPLETION_CONTEXT CompletionContext; 5572 KSPIN_LOCK IrpListLock; 5573 LIST_ENTRY IrpList; 5574 volatile PVOID FileObjectExtension; 5575 } FILE_OBJECT, *PFILE_OBJECT; 5576 5577 typedef struct _IO_ERROR_LOG_PACKET { 5578 UCHAR MajorFunctionCode; 5579 UCHAR RetryCount; 5580 USHORT DumpDataSize; 5581 USHORT NumberOfStrings; 5582 USHORT StringOffset; 5583 USHORT EventCategory; 5584 NTSTATUS ErrorCode; 5585 ULONG UniqueErrorValue; 5586 NTSTATUS FinalStatus; 5587 ULONG SequenceNumber; 5588 ULONG IoControlCode; 5589 LARGE_INTEGER DeviceOffset; 5590 ULONG DumpData[1]; 5591 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET; 5592 5593 typedef struct _IO_ERROR_LOG_MESSAGE { 5594 USHORT Type; 5595 USHORT Size; 5596 USHORT DriverNameLength; 5597 LARGE_INTEGER TimeStamp; 5598 ULONG DriverNameOffset; 5599 IO_ERROR_LOG_PACKET EntryData; 5600 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE; 5601 5602 #define ERROR_LOG_LIMIT_SIZE 240 5603 5604 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \ 5605 sizeof(IO_ERROR_LOG_PACKET) + \ 5606 (sizeof(WCHAR) * 40)) 5607 5608 #define ERROR_LOG_MESSAGE_LIMIT_SIZE \ 5609 (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) 5610 5611 #define IO_ERROR_LOG_MESSAGE_LENGTH \ 5612 ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \ 5613 ERROR_LOG_MESSAGE_LIMIT_SIZE : \ 5614 PORT_MAXIMUM_MESSAGE_LENGTH) 5615 5616 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \ 5617 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) 5618 5619 #ifdef _WIN64 5620 #define PORT_MAXIMUM_MESSAGE_LENGTH 512 5621 #else 5622 #define PORT_MAXIMUM_MESSAGE_LENGTH 256 5623 #endif 5624 5625 typedef enum _DMA_WIDTH { 5626 Width8Bits, 5627 Width16Bits, 5628 Width32Bits, 5629 MaximumDmaWidth 5630 } DMA_WIDTH, *PDMA_WIDTH; 5631 5632 typedef enum _DMA_SPEED { 5633 Compatible, 5634 TypeA, 5635 TypeB, 5636 TypeC, 5637 TypeF, 5638 MaximumDmaSpeed 5639 } DMA_SPEED, *PDMA_SPEED; 5640 5641 /* DEVICE_DESCRIPTION.Version */ 5642 5643 #define DEVICE_DESCRIPTION_VERSION 0x0000 5644 #define DEVICE_DESCRIPTION_VERSION1 0x0001 5645 #define DEVICE_DESCRIPTION_VERSION2 0x0002 5646 5647 typedef struct _DEVICE_DESCRIPTION { 5648 ULONG Version; 5649 BOOLEAN Master; 5650 BOOLEAN ScatterGather; 5651 BOOLEAN DemandMode; 5652 BOOLEAN AutoInitialize; 5653 BOOLEAN Dma32BitAddresses; 5654 BOOLEAN IgnoreCount; 5655 BOOLEAN Reserved1; 5656 BOOLEAN Dma64BitAddresses; 5657 ULONG BusNumber; 5658 ULONG DmaChannel; 5659 INTERFACE_TYPE InterfaceType; 5660 DMA_WIDTH DmaWidth; 5661 DMA_SPEED DmaSpeed; 5662 ULONG MaximumLength; 5663 ULONG DmaPort; 5664 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION; 5665 5666 typedef enum _DEVICE_RELATION_TYPE { 5667 BusRelations, 5668 EjectionRelations, 5669 PowerRelations, 5670 RemovalRelations, 5671 TargetDeviceRelation, 5672 SingleBusRelations, 5673 TransportRelations 5674 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE; 5675 5676 typedef struct _DEVICE_RELATIONS { 5677 ULONG Count; 5678 PDEVICE_OBJECT Objects[1]; 5679 } DEVICE_RELATIONS, *PDEVICE_RELATIONS; 5680 5681 typedef struct _DEVOBJ_EXTENSION { 5682 CSHORT Type; 5683 USHORT Size; 5684 PDEVICE_OBJECT DeviceObject; 5685 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; 5686 5687 typedef struct _SCATTER_GATHER_ELEMENT { 5688 PHYSICAL_ADDRESS Address; 5689 ULONG Length; 5690 ULONG_PTR Reserved; 5691 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT; 5692 5693 #if defined(_MSC_EXTENSIONS) || defined(__GNUC__) 5694 5695 #if defined(_MSC_VER) 5696 #if _MSC_VER >= 1200 5697 #pragma warning(push) 5698 #endif 5699 #pragma warning(disable:4200) 5700 #endif /* _MSC_VER */ 5701 5702 typedef struct _SCATTER_GATHER_LIST { 5703 ULONG NumberOfElements; 5704 ULONG_PTR Reserved; 5705 SCATTER_GATHER_ELEMENT Elements[1]; 5706 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; 5707 5708 #if defined(_MSC_VER) 5709 #if _MSC_VER >= 1200 5710 #pragma warning(pop) 5711 #else 5712 #pragma warning(default:4200) 5713 #endif 5714 #endif /* _MSC_VER */ 5715 5716 #else /* defined(_MSC_EXTENSIONS) || defined(__GNUC__) */ 5717 5718 struct _SCATTER_GATHER_LIST; 5719 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; 5720 5721 #endif /* defined(_MSC_EXTENSIONS) || defined(__GNUC__) */ 5722 5723 typedef NTSTATUS 5724 (NTAPI DRIVER_ADD_DEVICE)( 5725 IN struct _DRIVER_OBJECT *DriverObject, 5726 IN struct _DEVICE_OBJECT *PhysicalDeviceObject); 5727 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; 5728 5729 typedef struct _DRIVER_EXTENSION { 5730 struct _DRIVER_OBJECT *DriverObject; 5731 PDRIVER_ADD_DEVICE AddDevice; 5732 ULONG Count; 5733 UNICODE_STRING ServiceKeyName; 5734 } DRIVER_EXTENSION, *PDRIVER_EXTENSION; 5735 5736 #define DRVO_UNLOAD_INVOKED 0x00000001 5737 #define DRVO_LEGACY_DRIVER 0x00000002 5738 #define DRVO_BUILTIN_DRIVER 0x00000004 5739 5740 typedef NTSTATUS 5741 (NTAPI DRIVER_INITIALIZE)( 5742 IN struct _DRIVER_OBJECT *DriverObject, 5743 IN PUNICODE_STRING RegistryPath); 5744 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; 5745 5746 typedef VOID 5747 (NTAPI DRIVER_STARTIO)( 5748 IN struct _DEVICE_OBJECT *DeviceObject, 5749 IN struct _IRP *Irp); 5750 typedef DRIVER_STARTIO *PDRIVER_STARTIO; 5751 5752 typedef VOID 5753 (NTAPI DRIVER_UNLOAD)( 5754 IN struct _DRIVER_OBJECT *DriverObject); 5755 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; 5756 5757 typedef NTSTATUS 5758 (NTAPI DRIVER_DISPATCH)( 5759 IN struct _DEVICE_OBJECT *DeviceObject, 5760 IN struct _IRP *Irp); 5761 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; 5762 5763 typedef struct _DRIVER_OBJECT { 5764 CSHORT Type; 5765 CSHORT Size; 5766 PDEVICE_OBJECT DeviceObject; 5767 ULONG Flags; 5768 PVOID DriverStart; 5769 ULONG DriverSize; 5770 PVOID DriverSection; 5771 PDRIVER_EXTENSION DriverExtension; 5772 UNICODE_STRING DriverName; 5773 PUNICODE_STRING HardwareDatabase; 5774 struct _FAST_IO_DISPATCH *FastIoDispatch; 5775 PDRIVER_INITIALIZE DriverInit; 5776 PDRIVER_STARTIO DriverStartIo; 5777 PDRIVER_UNLOAD DriverUnload; 5778 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; 5779 } DRIVER_OBJECT, *PDRIVER_OBJECT; 5780 5781 typedef struct _DMA_ADAPTER { 5782 USHORT Version; 5783 USHORT Size; 5784 struct _DMA_OPERATIONS* DmaOperations; 5785 } DMA_ADAPTER, *PDMA_ADAPTER; 5786 5787 typedef VOID 5788 (NTAPI *PPUT_DMA_ADAPTER)( 5789 IN PDMA_ADAPTER DmaAdapter); 5790 5791 typedef PVOID 5792 (NTAPI *PALLOCATE_COMMON_BUFFER)( 5793 IN PDMA_ADAPTER DmaAdapter, 5794 IN ULONG Length, 5795 OUT PPHYSICAL_ADDRESS LogicalAddress, 5796 IN BOOLEAN CacheEnabled); 5797 5798 typedef VOID 5799 (NTAPI *PFREE_COMMON_BUFFER)( 5800 IN PDMA_ADAPTER DmaAdapter, 5801 IN ULONG Length, 5802 IN PHYSICAL_ADDRESS LogicalAddress, 5803 IN PVOID VirtualAddress, 5804 IN BOOLEAN CacheEnabled); 5805 5806 typedef NTSTATUS 5807 (NTAPI *PALLOCATE_ADAPTER_CHANNEL)( 5808 IN PDMA_ADAPTER DmaAdapter, 5809 IN PDEVICE_OBJECT DeviceObject, 5810 IN ULONG NumberOfMapRegisters, 5811 IN PDRIVER_CONTROL ExecutionRoutine, 5812 IN PVOID Context); 5813 5814 typedef BOOLEAN 5815 (NTAPI *PFLUSH_ADAPTER_BUFFERS)( 5816 IN PDMA_ADAPTER DmaAdapter, 5817 IN PMDL Mdl, 5818 IN PVOID MapRegisterBase, 5819 IN PVOID CurrentVa, 5820 IN ULONG Length, 5821 IN BOOLEAN WriteToDevice); 5822 5823 typedef VOID 5824 (NTAPI *PFREE_ADAPTER_CHANNEL)( 5825 IN PDMA_ADAPTER DmaAdapter); 5826 5827 typedef VOID 5828 (NTAPI *PFREE_MAP_REGISTERS)( 5829 IN PDMA_ADAPTER DmaAdapter, 5830 PVOID MapRegisterBase, 5831 ULONG NumberOfMapRegisters); 5832 5833 typedef PHYSICAL_ADDRESS 5834 (NTAPI *PMAP_TRANSFER)( 5835 IN PDMA_ADAPTER DmaAdapter, 5836 IN PMDL Mdl, 5837 IN PVOID MapRegisterBase, 5838 IN PVOID CurrentVa, 5839 IN OUT PULONG Length, 5840 IN BOOLEAN WriteToDevice); 5841 5842 typedef ULONG 5843 (NTAPI *PGET_DMA_ALIGNMENT)( 5844 IN PDMA_ADAPTER DmaAdapter); 5845 5846 typedef ULONG 5847 (NTAPI *PREAD_DMA_COUNTER)( 5848 IN PDMA_ADAPTER DmaAdapter); 5849 5850 typedef VOID 5851 (NTAPI DRIVER_LIST_CONTROL)( 5852 IN struct _DEVICE_OBJECT *DeviceObject, 5853 IN struct _IRP *Irp, 5854 IN struct _SCATTER_GATHER_LIST *ScatterGather, 5855 IN PVOID Context); 5856 typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; 5857 5858 typedef NTSTATUS 5859 (NTAPI *PGET_SCATTER_GATHER_LIST)( 5860 IN PDMA_ADAPTER DmaAdapter, 5861 IN PDEVICE_OBJECT DeviceObject, 5862 IN PMDL Mdl, 5863 IN PVOID CurrentVa, 5864 IN ULONG Length, 5865 IN PDRIVER_LIST_CONTROL ExecutionRoutine, 5866 IN PVOID Context, 5867 IN BOOLEAN WriteToDevice); 5868 5869 typedef VOID 5870 (NTAPI *PPUT_SCATTER_GATHER_LIST)( 5871 IN PDMA_ADAPTER DmaAdapter, 5872 IN PSCATTER_GATHER_LIST ScatterGather, 5873 IN BOOLEAN WriteToDevice); 5874 5875 typedef NTSTATUS 5876 (NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( 5877 IN PDMA_ADAPTER DmaAdapter, 5878 IN PMDL Mdl OPTIONAL, 5879 IN PVOID CurrentVa, 5880 IN ULONG Length, 5881 OUT PULONG ScatterGatherListSize, 5882 OUT PULONG pNumberOfMapRegisters OPTIONAL); 5883 5884 typedef NTSTATUS 5885 (NTAPI *PBUILD_SCATTER_GATHER_LIST)( 5886 IN PDMA_ADAPTER DmaAdapter, 5887 IN PDEVICE_OBJECT DeviceObject, 5888 IN PMDL Mdl, 5889 IN PVOID CurrentVa, 5890 IN ULONG Length, 5891 IN PDRIVER_LIST_CONTROL ExecutionRoutine, 5892 IN PVOID Context, 5893 IN BOOLEAN WriteToDevice, 5894 IN PVOID ScatterGatherBuffer, 5895 IN ULONG ScatterGatherLength); 5896 5897 typedef NTSTATUS 5898 (NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( 5899 IN PDMA_ADAPTER DmaAdapter, 5900 IN PSCATTER_GATHER_LIST ScatterGather, 5901 IN PMDL OriginalMdl, 5902 OUT PMDL *TargetMdl); 5903 5904 typedef struct _DMA_OPERATIONS { 5905 ULONG Size; 5906 PPUT_DMA_ADAPTER PutDmaAdapter; 5907 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; 5908 PFREE_COMMON_BUFFER FreeCommonBuffer; 5909 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; 5910 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; 5911 PFREE_ADAPTER_CHANNEL FreeAdapterChannel; 5912 PFREE_MAP_REGISTERS FreeMapRegisters; 5913 PMAP_TRANSFER MapTransfer; 5914 PGET_DMA_ALIGNMENT GetDmaAlignment; 5915 PREAD_DMA_COUNTER ReadDmaCounter; 5916 PGET_SCATTER_GATHER_LIST GetScatterGatherList; 5917 PPUT_SCATTER_GATHER_LIST PutScatterGatherList; 5918 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; 5919 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; 5920 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; 5921 } DMA_OPERATIONS, *PDMA_OPERATIONS; 5922 5923 typedef struct _IO_RESOURCE_DESCRIPTOR { 5924 UCHAR Option; 5925 UCHAR Type; 5926 UCHAR ShareDisposition; 5927 UCHAR Spare1; 5928 USHORT Flags; 5929 USHORT Spare2; 5930 union { 5931 struct { 5932 ULONG Length; 5933 ULONG Alignment; 5934 PHYSICAL_ADDRESS MinimumAddress; 5935 PHYSICAL_ADDRESS MaximumAddress; 5936 } Port; 5937 struct { 5938 ULONG Length; 5939 ULONG Alignment; 5940 PHYSICAL_ADDRESS MinimumAddress; 5941 PHYSICAL_ADDRESS MaximumAddress; 5942 } Memory; 5943 struct { 5944 ULONG MinimumVector; 5945 ULONG MaximumVector; 5946 } Interrupt; 5947 struct { 5948 ULONG MinimumChannel; 5949 ULONG MaximumChannel; 5950 } Dma; 5951 struct { 5952 ULONG Length; 5953 ULONG Alignment; 5954 PHYSICAL_ADDRESS MinimumAddress; 5955 PHYSICAL_ADDRESS MaximumAddress; 5956 } Generic; 5957 struct { 5958 ULONG Data[3]; 5959 } DevicePrivate; 5960 struct { 5961 ULONG Length; 5962 ULONG MinBusNumber; 5963 ULONG MaxBusNumber; 5964 ULONG Reserved; 5965 } BusNumber; 5966 struct { 5967 ULONG Priority; 5968 ULONG Reserved1; 5969 ULONG Reserved2; 5970 } ConfigData; 5971 } u; 5972 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; 5973 5974 typedef struct _IO_RESOURCE_LIST { 5975 USHORT Version; 5976 USHORT Revision; 5977 ULONG Count; 5978 IO_RESOURCE_DESCRIPTOR Descriptors[1]; 5979 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST; 5980 5981 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { 5982 ULONG ListSize; 5983 INTERFACE_TYPE InterfaceType; 5984 ULONG BusNumber; 5985 ULONG SlotNumber; 5986 ULONG Reserved[3]; 5987 ULONG AlternativeLists; 5988 IO_RESOURCE_LIST List[1]; 5989 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; 5990 5991 typedef VOID 5992 (NTAPI DRIVER_CANCEL)( 5993 IN struct _DEVICE_OBJECT *DeviceObject, 5994 IN struct _IRP *Irp); 5995 typedef DRIVER_CANCEL *PDRIVER_CANCEL; 5996 5997 typedef struct _IRP { 5998 CSHORT Type; 5999 USHORT Size; 6000 struct _MDL *MdlAddress; 6001 ULONG Flags; 6002 union { 6003 struct _IRP *MasterIrp; 6004 volatile LONG IrpCount; 6005 PVOID SystemBuffer; 6006 } AssociatedIrp; 6007 LIST_ENTRY ThreadListEntry; 6008 IO_STATUS_BLOCK IoStatus; 6009 KPROCESSOR_MODE RequestorMode; 6010 BOOLEAN PendingReturned; 6011 CHAR StackCount; 6012 CHAR CurrentLocation; 6013 BOOLEAN Cancel; 6014 KIRQL CancelIrql; 6015 CCHAR ApcEnvironment; 6016 UCHAR AllocationFlags; 6017 PIO_STATUS_BLOCK UserIosb; 6018 PKEVENT UserEvent; 6019 union { 6020 struct { 6021 _ANONYMOUS_UNION union { 6022 PIO_APC_ROUTINE UserApcRoutine; 6023 PVOID IssuingProcess; 6024 } DUMMYUNIONNAME; 6025 PVOID UserApcContext; 6026 } AsynchronousParameters; 6027 LARGE_INTEGER AllocationSize; 6028 } Overlay; 6029 volatile PDRIVER_CANCEL CancelRoutine; 6030 PVOID UserBuffer; 6031 union { 6032 struct { 6033 _ANONYMOUS_UNION union { 6034 KDEVICE_QUEUE_ENTRY DeviceQueueEntry; 6035 _ANONYMOUS_STRUCT struct { 6036 PVOID DriverContext[4]; 6037 } DUMMYSTRUCTNAME; 6038 } DUMMYUNIONNAME; 6039 PETHREAD Thread; 6040 PCHAR AuxiliaryBuffer; 6041 _ANONYMOUS_STRUCT struct { 6042 LIST_ENTRY ListEntry; 6043 _ANONYMOUS_UNION union { 6044 struct _IO_STACK_LOCATION *CurrentStackLocation; 6045 ULONG PacketType; 6046 } DUMMYUNIONNAME; 6047 } DUMMYSTRUCTNAME; 6048 struct _FILE_OBJECT *OriginalFileObject; 6049 } Overlay; 6050 KAPC Apc; 6051 PVOID CompletionKey; 6052 } Tail; 6053 } IRP, *PIRP; 6054 6055 typedef enum _IO_PAGING_PRIORITY { 6056 IoPagingPriorityInvalid, 6057 IoPagingPriorityNormal, 6058 IoPagingPriorityHigh, 6059 IoPagingPriorityReserved1, 6060 IoPagingPriorityReserved2 6061 } IO_PAGING_PRIORITY; 6062 6063 typedef NTSTATUS 6064 (NTAPI IO_COMPLETION_ROUTINE)( 6065 IN struct _DEVICE_OBJECT *DeviceObject, 6066 IN struct _IRP *Irp, 6067 IN PVOID Context); 6068 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; 6069 6070 typedef VOID 6071 (NTAPI IO_DPC_ROUTINE)( 6072 IN struct _KDPC *Dpc, 6073 IN struct _DEVICE_OBJECT *DeviceObject, 6074 IN struct _IRP *Irp, 6075 IN PVOID Context); 6076 typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; 6077 6078 typedef NTSTATUS 6079 (NTAPI *PMM_DLL_INITIALIZE)( 6080 IN PUNICODE_STRING RegistryPath); 6081 6082 typedef NTSTATUS 6083 (NTAPI *PMM_DLL_UNLOAD)( 6084 VOID); 6085 6086 typedef VOID 6087 (NTAPI IO_TIMER_ROUTINE)( 6088 IN struct _DEVICE_OBJECT *DeviceObject, 6089 IN PVOID Context); 6090 typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; 6091 6092 typedef struct _IO_SECURITY_CONTEXT { 6093 PSECURITY_QUALITY_OF_SERVICE SecurityQos; 6094 PACCESS_STATE AccessState; 6095 ACCESS_MASK DesiredAccess; 6096 ULONG FullCreateOptions; 6097 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT; 6098 6099 struct _IO_CSQ; 6100 6101 typedef struct _IO_CSQ_IRP_CONTEXT { 6102 ULONG Type; 6103 struct _IRP *Irp; 6104 struct _IO_CSQ *Csq; 6105 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; 6106 6107 typedef VOID 6108 (NTAPI *PIO_CSQ_INSERT_IRP)( 6109 IN struct _IO_CSQ *Csq, 6110 IN PIRP Irp); 6111 6112 typedef NTSTATUS 6113 (NTAPI IO_CSQ_INSERT_IRP_EX)( 6114 IN struct _IO_CSQ *Csq, 6115 IN PIRP Irp, 6116 IN PVOID InsertContext); 6117 typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX; 6118 6119 typedef VOID 6120 (NTAPI *PIO_CSQ_REMOVE_IRP)( 6121 IN struct _IO_CSQ *Csq, 6122 IN PIRP Irp); 6123 6124 typedef PIRP 6125 (NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( 6126 IN struct _IO_CSQ *Csq, 6127 IN PIRP Irp, 6128 IN PVOID PeekContext); 6129 6130 typedef VOID 6131 (NTAPI *PIO_CSQ_ACQUIRE_LOCK)( 6132 IN struct _IO_CSQ *Csq, 6133 OUT PKIRQL Irql); 6134 6135 typedef VOID 6136 (NTAPI *PIO_CSQ_RELEASE_LOCK)( 6137 IN struct _IO_CSQ *Csq, 6138 IN KIRQL Irql); 6139 6140 typedef VOID 6141 (NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( 6142 IN struct _IO_CSQ *Csq, 6143 IN PIRP Irp); 6144 6145 typedef struct _IO_CSQ { 6146 ULONG Type; 6147 PIO_CSQ_INSERT_IRP CsqInsertIrp; 6148 PIO_CSQ_REMOVE_IRP CsqRemoveIrp; 6149 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; 6150 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; 6151 PIO_CSQ_RELEASE_LOCK CsqReleaseLock; 6152 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; 6153 PVOID ReservePointer; 6154 } IO_CSQ, *PIO_CSQ; 6155 6156 typedef enum _BUS_QUERY_ID_TYPE { 6157 BusQueryDeviceID, 6158 BusQueryHardwareIDs, 6159 BusQueryCompatibleIDs, 6160 BusQueryInstanceID, 6161 BusQueryDeviceSerialNumber 6162 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE; 6163 6164 typedef enum _DEVICE_TEXT_TYPE { 6165 DeviceTextDescription, 6166 DeviceTextLocationInformation 6167 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE; 6168 6169 typedef BOOLEAN 6170 (NTAPI *PGPE_SERVICE_ROUTINE)( 6171 PVOID, 6172 PVOID); 6173 6174 typedef NTSTATUS 6175 (NTAPI *PGPE_CONNECT_VECTOR)( 6176 PDEVICE_OBJECT, 6177 ULONG, 6178 KINTERRUPT_MODE, 6179 BOOLEAN, 6180 PGPE_SERVICE_ROUTINE, 6181 PVOID, 6182 PVOID); 6183 6184 typedef NTSTATUS 6185 (NTAPI *PGPE_DISCONNECT_VECTOR)( 6186 PVOID); 6187 6188 typedef NTSTATUS 6189 (NTAPI *PGPE_ENABLE_EVENT)( 6190 PDEVICE_OBJECT, 6191 PVOID); 6192 6193 typedef NTSTATUS 6194 (NTAPI *PGPE_DISABLE_EVENT)( 6195 PDEVICE_OBJECT, 6196 PVOID); 6197 6198 typedef NTSTATUS 6199 (NTAPI *PGPE_CLEAR_STATUS)( 6200 PDEVICE_OBJECT, 6201 PVOID); 6202 6203 typedef VOID 6204 (NTAPI *PDEVICE_NOTIFY_CALLBACK)( 6205 PVOID, 6206 ULONG); 6207 6208 typedef NTSTATUS 6209 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)( 6210 PDEVICE_OBJECT, 6211 PDEVICE_NOTIFY_CALLBACK, 6212 PVOID); 6213 6214 typedef VOID 6215 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( 6216 PDEVICE_OBJECT, 6217 PDEVICE_NOTIFY_CALLBACK); 6218 6219 typedef struct _ACPI_INTERFACE_STANDARD { 6220 USHORT Size; 6221 USHORT Version; 6222 PVOID Context; 6223 PINTERFACE_REFERENCE InterfaceReference; 6224 PINTERFACE_DEREFERENCE InterfaceDereference; 6225 PGPE_CONNECT_VECTOR GpeConnectVector; 6226 PGPE_DISCONNECT_VECTOR GpeDisconnectVector; 6227 PGPE_ENABLE_EVENT GpeEnableEvent; 6228 PGPE_DISABLE_EVENT GpeDisableEvent; 6229 PGPE_CLEAR_STATUS GpeClearStatus; 6230 PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; 6231 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; 6232 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; 6233 6234 typedef BOOLEAN 6235 (NTAPI *PGPE_SERVICE_ROUTINE2)( 6236 PVOID ObjectContext, 6237 PVOID ServiceContext); 6238 6239 typedef NTSTATUS 6240 (NTAPI *PGPE_CONNECT_VECTOR2)( 6241 PVOID Context, 6242 ULONG GpeNumber, 6243 KINTERRUPT_MODE Mode, 6244 BOOLEAN Shareable, 6245 PGPE_SERVICE_ROUTINE ServiceRoutine, 6246 PVOID ServiceContext, 6247 PVOID *ObjectContext); 6248 6249 typedef NTSTATUS 6250 (NTAPI *PGPE_DISCONNECT_VECTOR2)( 6251 PVOID Context, 6252 PVOID ObjectContext); 6253 6254 typedef NTSTATUS 6255 (NTAPI *PGPE_ENABLE_EVENT2)( 6256 PVOID Context, 6257 PVOID ObjectContext); 6258 6259 typedef NTSTATUS 6260 (NTAPI *PGPE_DISABLE_EVENT2)( 6261 PVOID Context, 6262 PVOID ObjectContext); 6263 6264 typedef NTSTATUS 6265 (NTAPI *PGPE_CLEAR_STATUS2)( 6266 PVOID Context, 6267 PVOID ObjectContext); 6268 6269 typedef VOID 6270 (NTAPI *PDEVICE_NOTIFY_CALLBACK2)( 6271 PVOID NotificationContext, 6272 ULONG NotifyCode); 6273 6274 typedef NTSTATUS 6275 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( 6276 PVOID Context, 6277 PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, 6278 PVOID NotificationContext); 6279 6280 typedef VOID 6281 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( 6282 PVOID Context); 6283 6284 typedef struct _ACPI_INTERFACE_STANDARD2 { 6285 USHORT Size; 6286 USHORT Version; 6287 PVOID Context; 6288 PINTERFACE_REFERENCE InterfaceReference; 6289 PINTERFACE_DEREFERENCE InterfaceDereference; 6290 PGPE_CONNECT_VECTOR2 GpeConnectVector; 6291 PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; 6292 PGPE_ENABLE_EVENT2 GpeEnableEvent; 6293 PGPE_DISABLE_EVENT2 GpeDisableEvent; 6294 PGPE_CLEAR_STATUS2 GpeClearStatus; 6295 PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; 6296 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; 6297 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; 6298 6299 #if !defined(_AMD64_) && !defined(_IA64_) 6300 #include <pshpack4.h> 6301 #endif 6302 typedef struct _IO_STACK_LOCATION { 6303 UCHAR MajorFunction; 6304 UCHAR MinorFunction; 6305 UCHAR Flags; 6306 UCHAR Control; 6307 union { 6308 struct { 6309 PIO_SECURITY_CONTEXT SecurityContext; 6310 ULONG Options; 6311 USHORT POINTER_ALIGNMENT FileAttributes; 6312 USHORT ShareAccess; 6313 ULONG POINTER_ALIGNMENT EaLength; 6314 } Create; 6315 struct { 6316 ULONG Length; 6317 ULONG POINTER_ALIGNMENT Key; 6318 LARGE_INTEGER ByteOffset; 6319 } Read; 6320 struct { 6321 ULONG Length; 6322 ULONG POINTER_ALIGNMENT Key; 6323 LARGE_INTEGER ByteOffset; 6324 } Write; 6325 struct { 6326 ULONG Length; 6327 PUNICODE_STRING FileName; 6328 FILE_INFORMATION_CLASS FileInformationClass; 6329 ULONG FileIndex; 6330 } QueryDirectory; 6331 struct { 6332 ULONG Length; 6333 ULONG CompletionFilter; 6334 } NotifyDirectory; 6335 struct { 6336 ULONG Length; 6337 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; 6338 } QueryFile; 6339 struct { 6340 ULONG Length; 6341 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; 6342 PFILE_OBJECT FileObject; 6343 _ANONYMOUS_UNION union { 6344 _ANONYMOUS_STRUCT struct { 6345 BOOLEAN ReplaceIfExists; 6346 BOOLEAN AdvanceOnly; 6347 } DUMMYSTRUCTNAME; 6348 ULONG ClusterCount; 6349 HANDLE DeleteHandle; 6350 } DUMMYUNIONNAME; 6351 } SetFile; 6352 struct { 6353 ULONG Length; 6354 PVOID EaList; 6355 ULONG EaListLength; 6356 ULONG EaIndex; 6357 } QueryEa; 6358 struct { 6359 ULONG Length; 6360 } SetEa; 6361 struct { 6362 ULONG Length; 6363 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; 6364 } QueryVolume; 6365 struct { 6366 ULONG Length; 6367 FS_INFORMATION_CLASS FsInformationClass; 6368 } SetVolume; 6369 struct { 6370 ULONG OutputBufferLength; 6371 ULONG InputBufferLength; 6372 ULONG FsControlCode; 6373 PVOID Type3InputBuffer; 6374 } FileSystemControl; 6375 struct { 6376 PLARGE_INTEGER Length; 6377 ULONG Key; 6378 LARGE_INTEGER ByteOffset; 6379 } LockControl; 6380 struct { 6381 ULONG OutputBufferLength; 6382 ULONG POINTER_ALIGNMENT InputBufferLength; 6383 ULONG POINTER_ALIGNMENT IoControlCode; 6384 PVOID Type3InputBuffer; 6385 } DeviceIoControl; 6386 struct { 6387 SECURITY_INFORMATION SecurityInformation; 6388 ULONG POINTER_ALIGNMENT Length; 6389 } QuerySecurity; 6390 struct { 6391 SECURITY_INFORMATION SecurityInformation; 6392 PSECURITY_DESCRIPTOR SecurityDescriptor; 6393 } SetSecurity; 6394 struct { 6395 PVPB Vpb; 6396 PDEVICE_OBJECT DeviceObject; 6397 } MountVolume; 6398 struct { 6399 PVPB Vpb; 6400 PDEVICE_OBJECT DeviceObject; 6401 } VerifyVolume; 6402 struct { 6403 struct _SCSI_REQUEST_BLOCK *Srb; 6404 } Scsi; 6405 struct { 6406 ULONG Length; 6407 PSID StartSid; 6408 struct _FILE_GET_QUOTA_INFORMATION *SidList; 6409 ULONG SidListLength; 6410 } QueryQuota; 6411 struct { 6412 ULONG Length; 6413 } SetQuota; 6414 struct { 6415 DEVICE_RELATION_TYPE Type; 6416 } QueryDeviceRelations; 6417 struct { 6418 CONST GUID *InterfaceType; 6419 USHORT Size; 6420 USHORT Version; 6421 PINTERFACE Interface; 6422 PVOID InterfaceSpecificData; 6423 } QueryInterface; 6424 struct { 6425 PDEVICE_CAPABILITIES Capabilities; 6426 } DeviceCapabilities; 6427 struct { 6428 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; 6429 } FilterResourceRequirements; 6430 struct { 6431 ULONG WhichSpace; 6432 PVOID Buffer; 6433 ULONG Offset; 6434 ULONG POINTER_ALIGNMENT Length; 6435 } ReadWriteConfig; 6436 struct { 6437 BOOLEAN Lock; 6438 } SetLock; 6439 struct { 6440 BUS_QUERY_ID_TYPE IdType; 6441 } QueryId; 6442 struct { 6443 DEVICE_TEXT_TYPE DeviceTextType; 6444 LCID POINTER_ALIGNMENT LocaleId; 6445 } QueryDeviceText; 6446 struct { 6447 BOOLEAN InPath; 6448 BOOLEAN Reserved[3]; 6449 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; 6450 } UsageNotification; 6451 struct { 6452 SYSTEM_POWER_STATE PowerState; 6453 } WaitWake; 6454 struct { 6455 PPOWER_SEQUENCE PowerSequence; 6456 } PowerSequence; 6457 struct { 6458 ULONG SystemContext; 6459 POWER_STATE_TYPE POINTER_ALIGNMENT Type; 6460 POWER_STATE POINTER_ALIGNMENT State; 6461 POWER_ACTION POINTER_ALIGNMENT ShutdownType; 6462 } Power; 6463 struct { 6464 PCM_RESOURCE_LIST AllocatedResources; 6465 PCM_RESOURCE_LIST AllocatedResourcesTranslated; 6466 } StartDevice; 6467 struct { 6468 ULONG_PTR ProviderId; 6469 PVOID DataPath; 6470 ULONG BufferSize; 6471 PVOID Buffer; 6472 } WMI; 6473 struct { 6474 PVOID Argument1; 6475 PVOID Argument2; 6476 PVOID Argument3; 6477 PVOID Argument4; 6478 } Others; 6479 } Parameters; 6480 PDEVICE_OBJECT DeviceObject; 6481 PFILE_OBJECT FileObject; 6482 PIO_COMPLETION_ROUTINE CompletionRoutine; 6483 PVOID Context; 6484 } IO_STACK_LOCATION, *PIO_STACK_LOCATION; 6485 #if !defined(_AMD64_) && !defined(_IA64_) 6486 #include <poppack.h> 6487 #endif 6488 6489 /* IO_STACK_LOCATION.Control */ 6490 6491 #define SL_PENDING_RETURNED 0x01 6492 #define SL_ERROR_RETURNED 0x02 6493 #define SL_INVOKE_ON_CANCEL 0x20 6494 #define SL_INVOKE_ON_SUCCESS 0x40 6495 #define SL_INVOKE_ON_ERROR 0x80 6496 6497 #define METHOD_BUFFERED 0 6498 #define METHOD_IN_DIRECT 1 6499 #define METHOD_OUT_DIRECT 2 6500 #define METHOD_NEITHER 3 6501 6502 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT 6503 #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT 6504 6505 #define FILE_SUPERSEDED 0x00000000 6506 #define FILE_OPENED 0x00000001 6507 #define FILE_CREATED 0x00000002 6508 #define FILE_OVERWRITTEN 0x00000003 6509 #define FILE_EXISTS 0x00000004 6510 #define FILE_DOES_NOT_EXIST 0x00000005 6511 6512 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe 6513 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff 6514 6515 /* also in winnt.h */ 6516 #define FILE_LIST_DIRECTORY 0x00000001 6517 #define FILE_READ_DATA 0x00000001 6518 #define FILE_ADD_FILE 0x00000002 6519 #define FILE_WRITE_DATA 0x00000002 6520 #define FILE_ADD_SUBDIRECTORY 0x00000004 6521 #define FILE_APPEND_DATA 0x00000004 6522 #define FILE_CREATE_PIPE_INSTANCE 0x00000004 6523 #define FILE_READ_EA 0x00000008 6524 #define FILE_WRITE_EA 0x00000010 6525 #define FILE_EXECUTE 0x00000020 6526 #define FILE_TRAVERSE 0x00000020 6527 #define FILE_DELETE_CHILD 0x00000040 6528 #define FILE_READ_ATTRIBUTES 0x00000080 6529 #define FILE_WRITE_ATTRIBUTES 0x00000100 6530 6531 #define FILE_SHARE_READ 0x00000001 6532 #define FILE_SHARE_WRITE 0x00000002 6533 #define FILE_SHARE_DELETE 0x00000004 6534 #define FILE_SHARE_VALID_FLAGS 0x00000007 6535 6536 #define FILE_ATTRIBUTE_READONLY 0x00000001 6537 #define FILE_ATTRIBUTE_HIDDEN 0x00000002 6538 #define FILE_ATTRIBUTE_SYSTEM 0x00000004 6539 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 6540 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 6541 #define FILE_ATTRIBUTE_DEVICE 0x00000040 6542 #define FILE_ATTRIBUTE_NORMAL 0x00000080 6543 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 6544 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 6545 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 6546 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 6547 #define FILE_ATTRIBUTE_OFFLINE 0x00001000 6548 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 6549 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 6550 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000 6551 6552 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 6553 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 6554 6555 #define FILE_VALID_OPTION_FLAGS 0x00ffffff 6556 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 6557 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 6558 #define FILE_VALID_SET_FLAGS 0x00000036 6559 6560 #define FILE_SUPERSEDE 0x00000000 6561 #define FILE_OPEN 0x00000001 6562 #define FILE_CREATE 0x00000002 6563 #define FILE_OPEN_IF 0x00000003 6564 #define FILE_OVERWRITE 0x00000004 6565 #define FILE_OVERWRITE_IF 0x00000005 6566 #define FILE_MAXIMUM_DISPOSITION 0x00000005 6567 6568 #define FILE_DIRECTORY_FILE 0x00000001 6569 #define FILE_WRITE_THROUGH 0x00000002 6570 #define FILE_SEQUENTIAL_ONLY 0x00000004 6571 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 6572 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 6573 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 6574 #define FILE_NON_DIRECTORY_FILE 0x00000040 6575 #define FILE_CREATE_TREE_CONNECTION 0x00000080 6576 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100 6577 #define FILE_NO_EA_KNOWLEDGE 0x00000200 6578 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400 6579 #define FILE_RANDOM_ACCESS 0x00000800 6580 #define FILE_DELETE_ON_CLOSE 0x00001000 6581 #define FILE_OPEN_BY_FILE_ID 0x00002000 6582 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 6583 #define FILE_NO_COMPRESSION 0x00008000 6584 #if (NTDDI_VERSION >= NTDDI_WIN7) 6585 #define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 6586 #define FILE_DISALLOW_EXCLUSIVE 0x00020000 6587 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 6588 #define FILE_RESERVE_OPFILTER 0x00100000 6589 #define FILE_OPEN_REPARSE_POINT 0x00200000 6590 #define FILE_OPEN_NO_RECALL 0x00400000 6591 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 6592 6593 #define FILE_ANY_ACCESS 0x00000000 6594 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS 6595 #define FILE_READ_ACCESS 0x00000001 6596 #define FILE_WRITE_ACCESS 0x00000002 6597 6598 #define FILE_ALL_ACCESS \ 6599 (STANDARD_RIGHTS_REQUIRED | \ 6600 SYNCHRONIZE | \ 6601 0x1FF) 6602 6603 #define FILE_GENERIC_EXECUTE \ 6604 (STANDARD_RIGHTS_EXECUTE | \ 6605 FILE_READ_ATTRIBUTES | \ 6606 FILE_EXECUTE | \ 6607 SYNCHRONIZE) 6608 6609 #define FILE_GENERIC_READ \ 6610 (STANDARD_RIGHTS_READ | \ 6611 FILE_READ_DATA | \ 6612 FILE_READ_ATTRIBUTES | \ 6613 FILE_READ_EA | \ 6614 SYNCHRONIZE) 6615 6616 #define FILE_GENERIC_WRITE \ 6617 (STANDARD_RIGHTS_WRITE | \ 6618 FILE_WRITE_DATA | \ 6619 FILE_WRITE_ATTRIBUTES | \ 6620 FILE_WRITE_EA | \ 6621 FILE_APPEND_DATA | \ 6622 SYNCHRONIZE) 6623 6624 /* end winnt.h */ 6625 6626 #define WMIREG_ACTION_REGISTER 1 6627 #define WMIREG_ACTION_DEREGISTER 2 6628 #define WMIREG_ACTION_REREGISTER 3 6629 #define WMIREG_ACTION_UPDATE_GUIDS 4 6630 #define WMIREG_ACTION_BLOCK_IRPS 5 6631 6632 #define WMIREGISTER 0 6633 #define WMIUPDATE 1 6634 6635 typedef VOID 6636 (NTAPI FWMI_NOTIFICATION_CALLBACK)( 6637 PVOID Wnode, 6638 PVOID Context); 6639 typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK; 6640 6641 #ifndef _PCI_X_ 6642 #define _PCI_X_ 6643 6644 typedef struct _PCI_SLOT_NUMBER { 6645 union { 6646 struct { 6647 ULONG DeviceNumber:5; 6648 ULONG FunctionNumber:3; 6649 ULONG Reserved:24; 6650 } bits; 6651 ULONG AsULONG; 6652 } u; 6653 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; 6654 6655 #define PCI_TYPE0_ADDRESSES 6 6656 #define PCI_TYPE1_ADDRESSES 2 6657 #define PCI_TYPE2_ADDRESSES 5 6658 6659 typedef struct _PCI_COMMON_HEADER { 6660 PCI_COMMON_HEADER_LAYOUT 6661 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; 6662 6663 #ifdef __cplusplus 6664 typedef struct _PCI_COMMON_CONFIG { 6665 PCI_COMMON_HEADER_LAYOUT 6666 UCHAR DeviceSpecific[192]; 6667 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; 6668 #else 6669 typedef struct _PCI_COMMON_CONFIG { 6670 __extension__ struct { 6671 PCI_COMMON_HEADER_LAYOUT 6672 }; 6673 UCHAR DeviceSpecific[192]; 6674 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; 6675 #endif 6676 6677 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) 6678 6679 #define PCI_EXTENDED_CONFIG_LENGTH 0x1000 6680 6681 #define PCI_MAX_DEVICES 32 6682 #define PCI_MAX_FUNCTION 8 6683 #define PCI_MAX_BRIDGE_NUMBER 0xFF 6684 #define PCI_INVALID_VENDORID 0xFFFF 6685 6686 /* PCI_COMMON_CONFIG.HeaderType */ 6687 #define PCI_MULTIFUNCTION 0x80 6688 #define PCI_DEVICE_TYPE 0x00 6689 #define PCI_BRIDGE_TYPE 0x01 6690 #define PCI_CARDBUS_BRIDGE_TYPE 0x02 6691 6692 #define PCI_CONFIGURATION_TYPE(PciData) \ 6693 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) 6694 6695 #define PCI_MULTIFUNCTION_DEVICE(PciData) \ 6696 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) 6697 6698 /* PCI_COMMON_CONFIG.Command */ 6699 #define PCI_ENABLE_IO_SPACE 0x0001 6700 #define PCI_ENABLE_MEMORY_SPACE 0x0002 6701 #define PCI_ENABLE_BUS_MASTER 0x0004 6702 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008 6703 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 6704 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 6705 #define PCI_ENABLE_PARITY 0x0040 6706 #define PCI_ENABLE_WAIT_CYCLE 0x0080 6707 #define PCI_ENABLE_SERR 0x0100 6708 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 6709 #define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 6710 6711 /* PCI_COMMON_CONFIG.Status */ 6712 #define PCI_STATUS_INTERRUPT_PENDING 0x0008 6713 #define PCI_STATUS_CAPABILITIES_LIST 0x0010 6714 #define PCI_STATUS_66MHZ_CAPABLE 0x0020 6715 #define PCI_STATUS_UDF_SUPPORTED 0x0040 6716 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 6717 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 6718 #define PCI_STATUS_DEVSEL 0x0600 6719 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 6720 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 6721 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 6722 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 6723 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 6724 6725 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ 6726 6727 #define PCI_WHICHSPACE_CONFIG 0x0 6728 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ 6729 6730 #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01 6731 #define PCI_CAPABILITY_ID_AGP 0x02 6732 #define PCI_CAPABILITY_ID_VPD 0x03 6733 #define PCI_CAPABILITY_ID_SLOT_ID 0x04 6734 #define PCI_CAPABILITY_ID_MSI 0x05 6735 #define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06 6736 #define PCI_CAPABILITY_ID_PCIX 0x07 6737 #define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08 6738 #define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09 6739 #define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A 6740 #define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B 6741 #define PCI_CAPABILITY_ID_SHPC 0x0C 6742 #define PCI_CAPABILITY_ID_P2P_SSID 0x0D 6743 #define PCI_CAPABILITY_ID_AGP_TARGET 0x0E 6744 #define PCI_CAPABILITY_ID_SECURE 0x0F 6745 #define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 6746 #define PCI_CAPABILITY_ID_MSIX 0x11 6747 6748 typedef struct _PCI_CAPABILITIES_HEADER { 6749 UCHAR CapabilityID; 6750 UCHAR Next; 6751 } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER; 6752 6753 typedef struct _PCI_PMC { 6754 UCHAR Version:3; 6755 UCHAR PMEClock:1; 6756 UCHAR Rsvd1:1; 6757 UCHAR DeviceSpecificInitialization:1; 6758 UCHAR Rsvd2:2; 6759 struct _PM_SUPPORT { 6760 UCHAR Rsvd2:1; 6761 UCHAR D1:1; 6762 UCHAR D2:1; 6763 UCHAR PMED0:1; 6764 UCHAR PMED1:1; 6765 UCHAR PMED2:1; 6766 UCHAR PMED3Hot:1; 6767 UCHAR PMED3Cold:1; 6768 } Support; 6769 } PCI_PMC, *PPCI_PMC; 6770 6771 typedef struct _PCI_PMCSR { 6772 USHORT PowerState:2; 6773 USHORT Rsvd1:6; 6774 USHORT PMEEnable:1; 6775 USHORT DataSelect:4; 6776 USHORT DataScale:2; 6777 USHORT PMEStatus:1; 6778 } PCI_PMCSR, *PPCI_PMCSR; 6779 6780 typedef struct _PCI_PMCSR_BSE { 6781 UCHAR Rsvd1:6; 6782 UCHAR D3HotSupportsStopClock:1; 6783 UCHAR BusPowerClockControlEnabled:1; 6784 } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE; 6785 6786 typedef struct _PCI_PM_CAPABILITY { 6787 PCI_CAPABILITIES_HEADER Header; 6788 union { 6789 PCI_PMC Capabilities; 6790 USHORT AsUSHORT; 6791 } PMC; 6792 union { 6793 PCI_PMCSR ControlStatus; 6794 USHORT AsUSHORT; 6795 } PMCSR; 6796 union { 6797 PCI_PMCSR_BSE BridgeSupport; 6798 UCHAR AsUCHAR; 6799 } PMCSR_BSE; 6800 UCHAR Data; 6801 } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY; 6802 6803 typedef struct { 6804 PCI_CAPABILITIES_HEADER Header; 6805 union { 6806 struct { 6807 USHORT DataParityErrorRecoveryEnable:1; 6808 USHORT EnableRelaxedOrdering:1; 6809 USHORT MaxMemoryReadByteCount:2; 6810 USHORT MaxOutstandingSplitTransactions:3; 6811 USHORT Reserved:9; 6812 } bits; 6813 USHORT AsUSHORT; 6814 } Command; 6815 union { 6816 struct { 6817 ULONG FunctionNumber:3; 6818 ULONG DeviceNumber:5; 6819 ULONG BusNumber:8; 6820 ULONG Device64Bit:1; 6821 ULONG Capable133MHz:1; 6822 ULONG SplitCompletionDiscarded:1; 6823 ULONG UnexpectedSplitCompletion:1; 6824 ULONG DeviceComplexity:1; 6825 ULONG DesignedMaxMemoryReadByteCount:2; 6826 ULONG DesignedMaxOutstandingSplitTransactions:3; 6827 ULONG DesignedMaxCumulativeReadSize:3; 6828 ULONG ReceivedSplitCompletionErrorMessage:1; 6829 ULONG CapablePCIX266:1; 6830 ULONG CapablePCIX533:1; 6831 } bits; 6832 ULONG AsULONG; 6833 } Status; 6834 } PCI_X_CAPABILITY, *PPCI_X_CAPABILITY; 6835 6836 #define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001 6837 #define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002 6838 #define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003 6839 #define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004 6840 #define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005 6841 #define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006 6842 #define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007 6843 #define PCI_EXPRESS_MFVC_CAP_ID 0x0008 6844 #define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009 6845 #define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A 6846 #define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010 6847 6848 typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER { 6849 USHORT CapabilityID; 6850 USHORT Version:4; 6851 USHORT Next:12; 6852 } PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER; 6853 6854 typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY { 6855 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; 6856 ULONG LowSerialNumber; 6857 ULONG HighSerialNumber; 6858 } PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY; 6859 6860 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS { 6861 _ANONYMOUS_STRUCT struct { 6862 ULONG Undefined:1; 6863 ULONG Reserved1:3; 6864 ULONG DataLinkProtocolError:1; 6865 ULONG SurpriseDownError:1; 6866 ULONG Reserved2:6; 6867 ULONG PoisonedTLP:1; 6868 ULONG FlowControlProtocolError:1; 6869 ULONG CompletionTimeout:1; 6870 ULONG CompleterAbort:1; 6871 ULONG UnexpectedCompletion:1; 6872 ULONG ReceiverOverflow:1; 6873 ULONG MalformedTLP:1; 6874 ULONG ECRCError:1; 6875 ULONG UnsupportedRequestError:1; 6876 ULONG Reserved3:11; 6877 } DUMMYSTRUCTNAME; 6878 ULONG AsULONG; 6879 } PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS; 6880 6881 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK { 6882 _ANONYMOUS_STRUCT struct { 6883 ULONG Undefined:1; 6884 ULONG Reserved1:3; 6885 ULONG DataLinkProtocolError:1; 6886 ULONG SurpriseDownError:1; 6887 ULONG Reserved2:6; 6888 ULONG PoisonedTLP:1; 6889 ULONG FlowControlProtocolError:1; 6890 ULONG CompletionTimeout:1; 6891 ULONG CompleterAbort:1; 6892 ULONG UnexpectedCompletion:1; 6893 ULONG ReceiverOverflow:1; 6894 ULONG MalformedTLP:1; 6895 ULONG ECRCError:1; 6896 ULONG UnsupportedRequestError:1; 6897 ULONG Reserved3:11; 6898 } DUMMYSTRUCTNAME; 6899 ULONG AsULONG; 6900 } PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK; 6901 6902 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY { 6903 _ANONYMOUS_STRUCT struct { 6904 ULONG Undefined:1; 6905 ULONG Reserved1:3; 6906 ULONG DataLinkProtocolError:1; 6907 ULONG SurpriseDownError:1; 6908 ULONG Reserved2:6; 6909 ULONG PoisonedTLP:1; 6910 ULONG FlowControlProtocolError:1; 6911 ULONG CompletionTimeout:1; 6912 ULONG CompleterAbort:1; 6913 ULONG UnexpectedCompletion:1; 6914 ULONG ReceiverOverflow:1; 6915 ULONG MalformedTLP:1; 6916 ULONG ECRCError:1; 6917 ULONG UnsupportedRequestError:1; 6918 ULONG Reserved3:11; 6919 } DUMMYSTRUCTNAME; 6920 ULONG AsULONG; 6921 } PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY; 6922 6923 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS { 6924 _ANONYMOUS_STRUCT struct { 6925 ULONG ReceiverError:1; 6926 ULONG Reserved1:5; 6927 ULONG BadTLP:1; 6928 ULONG BadDLLP:1; 6929 ULONG ReplayNumRollover:1; 6930 ULONG Reserved2:3; 6931 ULONG ReplayTimerTimeout:1; 6932 ULONG AdvisoryNonFatalError:1; 6933 ULONG Reserved3:18; 6934 } DUMMYSTRUCTNAME; 6935 ULONG AsULONG; 6936 } PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS; 6937 6938 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK { 6939 _ANONYMOUS_STRUCT struct { 6940 ULONG ReceiverError:1; 6941 ULONG Reserved1:5; 6942 ULONG BadTLP:1; 6943 ULONG BadDLLP:1; 6944 ULONG ReplayNumRollover:1; 6945 ULONG Reserved2:3; 6946 ULONG ReplayTimerTimeout:1; 6947 ULONG AdvisoryNonFatalError:1; 6948 ULONG Reserved3:18; 6949 } DUMMYSTRUCTNAME; 6950 ULONG AsULONG; 6951 } PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK; 6952 6953 typedef union _PCI_EXPRESS_AER_CAPABILITIES { 6954 _ANONYMOUS_STRUCT struct { 6955 ULONG FirstErrorPointer:5; 6956 ULONG ECRCGenerationCapable:1; 6957 ULONG ECRCGenerationEnable:1; 6958 ULONG ECRCCheckCapable:1; 6959 ULONG ECRCCheckEnable:1; 6960 ULONG Reserved:23; 6961 } DUMMYSTRUCTNAME; 6962 ULONG AsULONG; 6963 } PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES; 6964 6965 typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND { 6966 _ANONYMOUS_STRUCT struct { 6967 ULONG CorrectableErrorReportingEnable:1; 6968 ULONG NonFatalErrorReportingEnable:1; 6969 ULONG FatalErrorReportingEnable:1; 6970 ULONG Reserved:29; 6971 } DUMMYSTRUCTNAME; 6972 ULONG AsULONG; 6973 } PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND; 6974 6975 typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS { 6976 _ANONYMOUS_STRUCT struct { 6977 ULONG CorrectableErrorReceived:1; 6978 ULONG MultipleCorrectableErrorsReceived:1; 6979 ULONG UncorrectableErrorReceived:1; 6980 ULONG MultipleUncorrectableErrorsReceived:1; 6981 ULONG FirstUncorrectableFatal:1; 6982 ULONG NonFatalErrorMessagesReceived:1; 6983 ULONG FatalErrorMessagesReceived:1; 6984 ULONG Reserved:20; 6985 ULONG AdvancedErrorInterruptMessageNumber:5; 6986 } DUMMYSTRUCTNAME; 6987 ULONG AsULONG; 6988 } PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS; 6989 6990 typedef union _PCI_EXPRESS_ERROR_SOURCE_ID { 6991 _ANONYMOUS_STRUCT struct { 6992 USHORT CorrectableSourceIdFun:3; 6993 USHORT CorrectableSourceIdDev:5; 6994 USHORT CorrectableSourceIdBus:8; 6995 USHORT UncorrectableSourceIdFun:3; 6996 USHORT UncorrectableSourceIdDev:5; 6997 USHORT UncorrectableSourceIdBus:8; 6998 } DUMMYSTRUCTNAME; 6999 ULONG AsULONG; 7000 } PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID; 7001 7002 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS { 7003 _ANONYMOUS_STRUCT struct { 7004 ULONG TargetAbortOnSplitCompletion:1; 7005 ULONG MasterAbortOnSplitCompletion:1; 7006 ULONG ReceivedTargetAbort:1; 7007 ULONG ReceivedMasterAbort:1; 7008 ULONG RsvdZ:1; 7009 ULONG UnexpectedSplitCompletionError:1; 7010 ULONG UncorrectableSplitCompletion:1; 7011 ULONG UncorrectableDataError:1; 7012 ULONG UncorrectableAttributeError:1; 7013 ULONG UncorrectableAddressError:1; 7014 ULONG DelayedTransactionDiscardTimerExpired:1; 7015 ULONG PERRAsserted:1; 7016 ULONG SERRAsserted:1; 7017 ULONG InternalBridgeError:1; 7018 ULONG Reserved:18; 7019 } DUMMYSTRUCTNAME; 7020 ULONG AsULONG; 7021 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS; 7022 7023 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK { 7024 _ANONYMOUS_STRUCT struct { 7025 ULONG TargetAbortOnSplitCompletion:1; 7026 ULONG MasterAbortOnSplitCompletion:1; 7027 ULONG ReceivedTargetAbort:1; 7028 ULONG ReceivedMasterAbort:1; 7029 ULONG RsvdZ:1; 7030 ULONG UnexpectedSplitCompletionError:1; 7031 ULONG UncorrectableSplitCompletion:1; 7032 ULONG UncorrectableDataError:1; 7033 ULONG UncorrectableAttributeError:1; 7034 ULONG UncorrectableAddressError:1; 7035 ULONG DelayedTransactionDiscardTimerExpired:1; 7036 ULONG PERRAsserted:1; 7037 ULONG SERRAsserted:1; 7038 ULONG InternalBridgeError:1; 7039 ULONG Reserved:18; 7040 } DUMMYSTRUCTNAME; 7041 ULONG AsULONG; 7042 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK; 7043 7044 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY { 7045 _ANONYMOUS_STRUCT struct { 7046 ULONG TargetAbortOnSplitCompletion:1; 7047 ULONG MasterAbortOnSplitCompletion:1; 7048 ULONG ReceivedTargetAbort:1; 7049 ULONG ReceivedMasterAbort:1; 7050 ULONG RsvdZ:1; 7051 ULONG UnexpectedSplitCompletionError:1; 7052 ULONG UncorrectableSplitCompletion:1; 7053 ULONG UncorrectableDataError:1; 7054 ULONG UncorrectableAttributeError:1; 7055 ULONG UncorrectableAddressError:1; 7056 ULONG DelayedTransactionDiscardTimerExpired:1; 7057 ULONG PERRAsserted:1; 7058 ULONG SERRAsserted:1; 7059 ULONG InternalBridgeError:1; 7060 ULONG Reserved:18; 7061 } DUMMYSTRUCTNAME; 7062 ULONG AsULONG; 7063 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY; 7064 7065 typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES { 7066 _ANONYMOUS_STRUCT struct { 7067 ULONG SecondaryUncorrectableFirstErrorPtr:5; 7068 ULONG Reserved:27; 7069 } DUMMYSTRUCTNAME; 7070 ULONG AsULONG; 7071 } PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES; 7072 7073 #define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001 7074 #define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002 7075 #define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004 7076 7077 #define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \ 7078 (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \ 7079 ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \ 7080 ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING) 7081 7082 typedef struct _PCI_EXPRESS_AER_CAPABILITY { 7083 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; 7084 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; 7085 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; 7086 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; 7087 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; 7088 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; 7089 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; 7090 ULONG HeaderLog[4]; 7091 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; 7092 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; 7093 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; 7094 PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; 7095 ULONG SecHeaderLog[4]; 7096 } PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY; 7097 7098 typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY { 7099 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; 7100 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; 7101 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; 7102 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; 7103 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; 7104 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; 7105 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; 7106 ULONG HeaderLog[4]; 7107 PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand; 7108 PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus; 7109 PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId; 7110 } PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY; 7111 7112 typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY { 7113 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; 7114 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; 7115 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; 7116 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; 7117 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; 7118 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; 7119 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; 7120 ULONG HeaderLog[4]; 7121 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; 7122 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; 7123 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; 7124 PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; 7125 ULONG SecHeaderLog[4]; 7126 } PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY; 7127 7128 typedef union _PCI_EXPRESS_SRIOV_CAPS { 7129 _ANONYMOUS_STRUCT struct { 7130 ULONG VFMigrationCapable:1; 7131 ULONG Reserved1:20; 7132 ULONG VFMigrationInterruptNumber:11; 7133 } DUMMYSTRUCTNAME; 7134 ULONG AsULONG; 7135 } PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS; 7136 7137 typedef union _PCI_EXPRESS_SRIOV_CONTROL { 7138 _ANONYMOUS_STRUCT struct { 7139 USHORT VFEnable:1; 7140 USHORT VFMigrationEnable:1; 7141 USHORT VFMigrationInterruptEnable:1; 7142 USHORT VFMemorySpaceEnable:1; 7143 USHORT ARICapableHierarchy:1; 7144 USHORT Reserved1:11; 7145 } DUMMYSTRUCTNAME; 7146 USHORT AsUSHORT; 7147 } PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL; 7148 7149 typedef union _PCI_EXPRESS_SRIOV_STATUS { 7150 _ANONYMOUS_STRUCT struct { 7151 USHORT VFMigrationStatus:1; 7152 USHORT Reserved1:15; 7153 } DUMMYSTRUCTNAME; 7154 USHORT AsUSHORT; 7155 } PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS; 7156 7157 typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY { 7158 _ANONYMOUS_STRUCT struct { 7159 ULONG VFMigrationStateBIR:3; 7160 ULONG VFMigrationStateOffset:29; 7161 } DUMMYSTRUCTNAME; 7162 ULONG AsULONG; 7163 } PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY; 7164 7165 typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY { 7166 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; 7167 PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities; 7168 PCI_EXPRESS_SRIOV_CONTROL SRIOVControl; 7169 PCI_EXPRESS_SRIOV_STATUS SRIOVStatus; 7170 USHORT InitialVFs; 7171 USHORT TotalVFs; 7172 USHORT NumVFs; 7173 UCHAR FunctionDependencyLink; 7174 UCHAR RsvdP1; 7175 USHORT FirstVFOffset; 7176 USHORT VFStride; 7177 USHORT RsvdP2; 7178 USHORT VFDeviceId; 7179 ULONG SupportedPageSizes; 7180 ULONG SystemPageSize; 7181 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; 7182 PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset; 7183 } PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY; 7184 7185 /* PCI device classes */ 7186 #define PCI_CLASS_PRE_20 0x00 7187 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01 7188 #define PCI_CLASS_NETWORK_CTLR 0x02 7189 #define PCI_CLASS_DISPLAY_CTLR 0x03 7190 #define PCI_CLASS_MULTIMEDIA_DEV 0x04 7191 #define PCI_CLASS_MEMORY_CTLR 0x05 7192 #define PCI_CLASS_BRIDGE_DEV 0x06 7193 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 7194 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08 7195 #define PCI_CLASS_INPUT_DEV 0x09 7196 #define PCI_CLASS_DOCKING_STATION 0x0a 7197 #define PCI_CLASS_PROCESSOR 0x0b 7198 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c 7199 #define PCI_CLASS_WIRELESS_CTLR 0x0d 7200 #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e 7201 #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f 7202 #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 7203 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 7204 #define PCI_CLASS_NOT_DEFINED 0xff 7205 7206 /* PCI device subclasses for class 0 */ 7207 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 7208 #define PCI_SUBCLASS_PRE_20_VGA 0x01 7209 7210 /* PCI device subclasses for class 1 (mass storage controllers)*/ 7211 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 7212 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 7213 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 7214 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 7215 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 7216 #define PCI_SUBCLASS_MSC_OTHER 0x80 7217 7218 /* PCI device subclasses for class 2 (network controllers)*/ 7219 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 7220 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 7221 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 7222 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03 7223 #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 7224 #define PCI_SUBCLASS_NET_OTHER 0x80 7225 7226 /* PCI device subclasses for class 3 (display controllers)*/ 7227 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00 7228 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01 7229 #define PCI_SUBCLASS_VID_3D_CTLR 0x02 7230 #define PCI_SUBCLASS_VID_OTHER 0x80 7231 7232 /* PCI device subclasses for class 4 (multimedia device)*/ 7233 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 7234 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 7235 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 7236 #define PCI_SUBCLASS_MM_OTHER 0x80 7237 7238 /* PCI device subclasses for class 5 (memory controller)*/ 7239 #define PCI_SUBCLASS_MEM_RAM 0x00 7240 #define PCI_SUBCLASS_MEM_FLASH 0x01 7241 #define PCI_SUBCLASS_MEM_OTHER 0x80 7242 7243 /* PCI device subclasses for class 6 (bridge device)*/ 7244 #define PCI_SUBCLASS_BR_HOST 0x00 7245 #define PCI_SUBCLASS_BR_ISA 0x01 7246 #define PCI_SUBCLASS_BR_EISA 0x02 7247 #define PCI_SUBCLASS_BR_MCA 0x03 7248 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 7249 #define PCI_SUBCLASS_BR_PCMCIA 0x05 7250 #define PCI_SUBCLASS_BR_NUBUS 0x06 7251 #define PCI_SUBCLASS_BR_CARDBUS 0x07 7252 #define PCI_SUBCLASS_BR_RACEWAY 0x08 7253 #define PCI_SUBCLASS_BR_OTHER 0x80 7254 7255 #define PCI_SUBCLASS_COM_SERIAL 0x00 7256 #define PCI_SUBCLASS_COM_PARALLEL 0x01 7257 #define PCI_SUBCLASS_COM_MULTIPORT 0x02 7258 #define PCI_SUBCLASS_COM_MODEM 0x03 7259 #define PCI_SUBCLASS_COM_OTHER 0x80 7260 7261 #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00 7262 #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01 7263 #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02 7264 #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03 7265 #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04 7266 #define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05 7267 #define PCI_SUBCLASS_SYS_OTHER 0x80 7268 7269 #define PCI_SUBCLASS_INP_KEYBOARD 0x00 7270 #define PCI_SUBCLASS_INP_DIGITIZER 0x01 7271 #define PCI_SUBCLASS_INP_MOUSE 0x02 7272 #define PCI_SUBCLASS_INP_SCANNER 0x03 7273 #define PCI_SUBCLASS_INP_GAMEPORT 0x04 7274 #define PCI_SUBCLASS_INP_OTHER 0x80 7275 7276 #define PCI_SUBCLASS_DOC_GENERIC 0x00 7277 #define PCI_SUBCLASS_DOC_OTHER 0x80 7278 7279 #define PCI_SUBCLASS_PROC_386 0x00 7280 #define PCI_SUBCLASS_PROC_486 0x01 7281 #define PCI_SUBCLASS_PROC_PENTIUM 0x02 7282 #define PCI_SUBCLASS_PROC_ALPHA 0x10 7283 #define PCI_SUBCLASS_PROC_POWERPC 0x20 7284 #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40 7285 7286 /* PCI device subclasses for class C (serial bus controller)*/ 7287 #define PCI_SUBCLASS_SB_IEEE1394 0x00 7288 #define PCI_SUBCLASS_SB_ACCESS 0x01 7289 #define PCI_SUBCLASS_SB_SSA 0x02 7290 #define PCI_SUBCLASS_SB_USB 0x03 7291 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 7292 #define PCI_SUBCLASS_SB_SMBUS 0x05 7293 7294 #define PCI_SUBCLASS_WIRELESS_IRDA 0x00 7295 #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01 7296 #define PCI_SUBCLASS_WIRELESS_RF 0x10 7297 #define PCI_SUBCLASS_WIRELESS_OTHER 0x80 7298 7299 #define PCI_SUBCLASS_INTIO_I2O 0x00 7300 7301 #define PCI_SUBCLASS_SAT_TV 0x01 7302 #define PCI_SUBCLASS_SAT_AUDIO 0x02 7303 #define PCI_SUBCLASS_SAT_VOICE 0x03 7304 #define PCI_SUBCLASS_SAT_DATA 0x04 7305 7306 #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00 7307 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 7308 #define PCI_SUBCLASS_CRYPTO_OTHER 0x80 7309 7310 #define PCI_SUBCLASS_DASP_DPIO 0x00 7311 #define PCI_SUBCLASS_DASP_OTHER 0x80 7312 7313 #define PCI_ADDRESS_IO_SPACE 0x00000001 7314 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 7315 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 7316 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc 7317 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 7318 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 7319 7320 #define PCI_TYPE_32BIT 0 7321 #define PCI_TYPE_20BIT 2 7322 #define PCI_TYPE_64BIT 4 7323 7324 #define PCI_ROMADDRESS_ENABLED 0x00000001 7325 7326 #endif /* _PCI_X_ */ 7327 7328 #define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1 7329 7330 typedef NTSTATUS 7331 (NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)( 7332 IN OUT PVOID Context); 7333 typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE; 7334 7335 typedef NTSTATUS 7336 (NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)( 7337 IN OUT PVOID Context); 7338 typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE; 7339 7340 typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE { 7341 USHORT Size; 7342 USHORT Version; 7343 PVOID Context; 7344 PINTERFACE_REFERENCE InterfaceReference; 7345 PINTERFACE_DEREFERENCE InterfaceDereference; 7346 PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode; 7347 PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode; 7348 } PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE; 7349 7350 #define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1 7351 7352 typedef ULONG 7353 (NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)( 7354 IN PVOID Context, 7355 OUT PVOID Buffer, 7356 IN ULONG Offset, 7357 IN ULONG Length); 7358 7359 typedef ULONG 7360 (NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)( 7361 IN PVOID Context, 7362 IN PVOID Buffer, 7363 IN ULONG Offset, 7364 IN ULONG Length); 7365 7366 typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE { 7367 USHORT Size; 7368 USHORT Version; 7369 PVOID Context; 7370 PINTERFACE_REFERENCE InterfaceReference; 7371 PINTERFACE_DEREFERENCE InterfaceDereference; 7372 PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace; 7373 PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace; 7374 } PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE; 7375 7376 #define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1 7377 7378 typedef NTSTATUS 7379 (NTAPI PCI_MSIX_SET_ENTRY)( 7380 IN PVOID Context, 7381 IN ULONG TableEntry, 7382 IN ULONG MessageNumber); 7383 typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY; 7384 7385 typedef NTSTATUS 7386 (NTAPI PCI_MSIX_MASKUNMASK_ENTRY)( 7387 IN PVOID Context, 7388 IN ULONG TableEntry); 7389 typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY; 7390 7391 typedef NTSTATUS 7392 (NTAPI PCI_MSIX_GET_ENTRY)( 7393 IN PVOID Context, 7394 IN ULONG TableEntry, 7395 OUT PULONG MessageNumber, 7396 OUT PBOOLEAN Masked); 7397 typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY; 7398 7399 typedef NTSTATUS 7400 (NTAPI PCI_MSIX_GET_TABLE_SIZE)( 7401 IN PVOID Context, 7402 OUT PULONG TableSize); 7403 typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE; 7404 7405 typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE { 7406 USHORT Size; 7407 USHORT Version; 7408 PVOID Context; 7409 PINTERFACE_REFERENCE InterfaceReference; 7410 PINTERFACE_DEREFERENCE InterfaceDereference; 7411 PPCI_MSIX_SET_ENTRY SetTableEntry; 7412 PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry; 7413 PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry; 7414 PPCI_MSIX_GET_ENTRY GetTableEntry; 7415 PPCI_MSIX_GET_TABLE_SIZE GetTableSize; 7416 } PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE; 7417 7418 #define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \ 7419 RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry) 7420 7421 /****************************************************************************** 7422 * Object Manager Types * 7423 ******************************************************************************/ 7424 7425 #define MAXIMUM_FILENAME_LENGTH 256 7426 #define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') 7427 7428 #define OBJECT_TYPE_CREATE 0x0001 7429 #define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) 7430 7431 #define DIRECTORY_QUERY 0x0001 7432 #define DIRECTORY_TRAVERSE 0x0002 7433 #define DIRECTORY_CREATE_OBJECT 0x0004 7434 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008 7435 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) 7436 7437 #define SYMBOLIC_LINK_QUERY 0x0001 7438 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) 7439 7440 #define DUPLICATE_CLOSE_SOURCE 0x00000001 7441 #define DUPLICATE_SAME_ACCESS 0x00000002 7442 #define DUPLICATE_SAME_ATTRIBUTES 0x00000004 7443 7444 #define OB_FLT_REGISTRATION_VERSION_0100 0x0100 7445 #define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100 7446 7447 typedef ULONG OB_OPERATION; 7448 7449 #define OB_OPERATION_HANDLE_CREATE 0x00000001 7450 #define OB_OPERATION_HANDLE_DUPLICATE 0x00000002 7451 7452 typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION { 7453 IN OUT ACCESS_MASK DesiredAccess; 7454 IN ACCESS_MASK OriginalDesiredAccess; 7455 } OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION; 7456 7457 typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION { 7458 IN OUT ACCESS_MASK DesiredAccess; 7459 IN ACCESS_MASK OriginalDesiredAccess; 7460 IN PVOID SourceProcess; 7461 IN PVOID TargetProcess; 7462 } OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION; 7463 7464 typedef union _OB_PRE_OPERATION_PARAMETERS { 7465 IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation; 7466 IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; 7467 } OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS; 7468 7469 typedef struct _OB_PRE_OPERATION_INFORMATION { 7470 IN OB_OPERATION Operation; 7471 _ANONYMOUS_UNION union { 7472 IN ULONG Flags; 7473 _ANONYMOUS_STRUCT struct { 7474 IN ULONG KernelHandle:1; 7475 IN ULONG Reserved:31; 7476 } DUMMYSTRUCTNAME; 7477 } DUMMYUNIONNAME; 7478 IN PVOID Object; 7479 IN POBJECT_TYPE ObjectType; 7480 OUT PVOID CallContext; 7481 IN POB_PRE_OPERATION_PARAMETERS Parameters; 7482 } OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION; 7483 7484 typedef struct _OB_POST_CREATE_HANDLE_INFORMATION { 7485 IN ACCESS_MASK GrantedAccess; 7486 } OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION; 7487 7488 typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION { 7489 IN ACCESS_MASK GrantedAccess; 7490 } OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION; 7491 7492 typedef union _OB_POST_OPERATION_PARAMETERS { 7493 IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation; 7494 IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; 7495 } OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS; 7496 7497 typedef struct _OB_POST_OPERATION_INFORMATION { 7498 IN OB_OPERATION Operation; 7499 _ANONYMOUS_UNION union { 7500 IN ULONG Flags; 7501 _ANONYMOUS_STRUCT struct { 7502 IN ULONG KernelHandle:1; 7503 IN ULONG Reserved:31; 7504 } DUMMYSTRUCTNAME; 7505 } DUMMYUNIONNAME; 7506 IN PVOID Object; 7507 IN POBJECT_TYPE ObjectType; 7508 IN PVOID CallContext; 7509 IN NTSTATUS ReturnStatus; 7510 IN POB_POST_OPERATION_PARAMETERS Parameters; 7511 } OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION; 7512 7513 typedef enum _OB_PREOP_CALLBACK_STATUS { 7514 OB_PREOP_SUCCESS 7515 } OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS; 7516 7517 typedef OB_PREOP_CALLBACK_STATUS 7518 (NTAPI *POB_PRE_OPERATION_CALLBACK)( 7519 IN PVOID RegistrationContext, 7520 IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation); 7521 7522 typedef VOID 7523 (NTAPI *POB_POST_OPERATION_CALLBACK)( 7524 IN PVOID RegistrationContext, 7525 IN POB_POST_OPERATION_INFORMATION OperationInformation); 7526 7527 typedef struct _OB_OPERATION_REGISTRATION { 7528 IN POBJECT_TYPE *ObjectType; 7529 IN OB_OPERATION Operations; 7530 IN POB_PRE_OPERATION_CALLBACK PreOperation; 7531 IN POB_POST_OPERATION_CALLBACK PostOperation; 7532 } OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION; 7533 7534 typedef struct _OB_CALLBACK_REGISTRATION { 7535 IN USHORT Version; 7536 IN USHORT OperationRegistrationCount; 7537 IN UNICODE_STRING Altitude; 7538 IN PVOID RegistrationContext; 7539 IN OB_OPERATION_REGISTRATION *OperationRegistration; 7540 } OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION; 7541 7542 typedef struct _OBJECT_NAME_INFORMATION { 7543 UNICODE_STRING Name; 7544 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; 7545 7546 /* Exported object types */ 7547 extern POBJECT_TYPE NTSYSAPI *CmKeyObjectType; 7548 extern POBJECT_TYPE NTSYSAPI *ExEventObjectType; 7549 extern POBJECT_TYPE NTSYSAPI *ExSemaphoreObjectType; 7550 extern POBJECT_TYPE NTSYSAPI *IoFileObjectType; 7551 extern POBJECT_TYPE NTSYSAPI *PsThreadType; 7552 extern POBJECT_TYPE NTSYSAPI *SeTokenObjectType; 7553 extern POBJECT_TYPE NTSYSAPI *PsProcessType; 7554 extern POBJECT_TYPE NTSYSAPI *TmEnlistmentObjectType; 7555 extern POBJECT_TYPE NTSYSAPI *TmResourceManagerObjectType; 7556 extern POBJECT_TYPE NTSYSAPI *TmTransactionManagerObjectType; 7557 extern POBJECT_TYPE NTSYSAPI *TmTransactionObjectType; 7558 7559 /****************************************************************************** 7560 * Process Manager Types * 7561 ******************************************************************************/ 7562 7563 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 7564 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 7565 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 7566 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 7567 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 7568 7569 /* Thread Access Rights */ 7570 #define THREAD_TERMINATE 0x0001 7571 #define THREAD_SUSPEND_RESUME 0x0002 7572 #define THREAD_ALERT 0x0004 7573 #define THREAD_GET_CONTEXT 0x0008 7574 #define THREAD_SET_CONTEXT 0x0010 7575 #define THREAD_SET_INFORMATION 0x0020 7576 #define THREAD_SET_LIMITED_INFORMATION 0x0400 7577 #define THREAD_QUERY_LIMITED_INFORMATION 0x0800 7578 7579 #define PROCESS_DUP_HANDLE (0x0040) 7580 7581 #if (NTDDI_VERSION >= NTDDI_VISTA) 7582 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF) 7583 #else 7584 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF) 7585 #endif 7586 7587 #if (NTDDI_VERSION >= NTDDI_VISTA) 7588 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF) 7589 #else 7590 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF) 7591 #endif 7592 7593 #define LOW_PRIORITY 0 7594 #define LOW_REALTIME_PRIORITY 16 7595 #define HIGH_PRIORITY 31 7596 #define MAXIMUM_PRIORITY 32 7597 7598 7599 /****************************************************************************** 7600 * WMI Library Support Types * 7601 ******************************************************************************/ 7602 7603 #ifdef RUN_WPP 7604 #include <evntrace.h> 7605 #include <stdarg.h> 7606 #endif 7607 7608 #ifndef _TRACEHANDLE_DEFINED 7609 #define _TRACEHANDLE_DEFINED 7610 typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; 7611 #endif 7612 7613 #ifndef TRACE_INFORMATION_CLASS_DEFINE 7614 7615 typedef struct _ETW_TRACE_SESSION_SETTINGS { 7616 ULONG Version; 7617 ULONG BufferSize; 7618 ULONG MinimumBuffers; 7619 ULONG MaximumBuffers; 7620 ULONG LoggerMode; 7621 ULONG FlushTimer; 7622 ULONG FlushThreshold; 7623 ULONG ClockType; 7624 } ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS; 7625 7626 typedef enum _TRACE_INFORMATION_CLASS { 7627 TraceIdClass, 7628 TraceHandleClass, 7629 TraceEnableFlagsClass, 7630 TraceEnableLevelClass, 7631 GlobalLoggerHandleClass, 7632 EventLoggerHandleClass, 7633 AllLoggerHandlesClass, 7634 TraceHandleByNameClass, 7635 LoggerEventsLostClass, 7636 TraceSessionSettingsClass, 7637 LoggerEventsLoggedClass, 7638 MaxTraceInformationClass 7639 } TRACE_INFORMATION_CLASS; 7640 7641 #endif /* TRACE_INFORMATION_CLASS_DEFINE */ 7642 7643 #ifndef _ETW_KM_ 7644 #define _ETW_KM_ 7645 #endif 7646 7647 #include <evntprov.h> 7648 7649 typedef VOID 7650 (NTAPI *PETWENABLECALLBACK)( 7651 IN LPCGUID SourceId, 7652 IN ULONG ControlCode, 7653 IN UCHAR Level, 7654 IN ULONGLONG MatchAnyKeyword, 7655 IN ULONGLONG MatchAllKeyword, 7656 IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, 7657 IN OUT PVOID CallbackContext OPTIONAL); 7658 7659 #define EVENT_WRITE_FLAG_NO_FAULTING 0x00000001 7660 7661 7662 #if defined(_M_IX86) 7663 /** Kernel definitions for x86 **/ 7664 7665 /* Interrupt request levels */ 7666 #define PASSIVE_LEVEL 0 7667 #define LOW_LEVEL 0 7668 #define APC_LEVEL 1 7669 #define DISPATCH_LEVEL 2 7670 #define CMCI_LEVEL 5 7671 #define PROFILE_LEVEL 27 7672 #define CLOCK1_LEVEL 28 7673 #define CLOCK2_LEVEL 28 7674 #define IPI_LEVEL 29 7675 #define POWER_LEVEL 30 7676 #define HIGH_LEVEL 31 7677 #define CLOCK_LEVEL CLOCK2_LEVEL 7678 7679 #define KIP0PCRADDRESS 0xffdff000 7680 #define KI_USER_SHARED_DATA 0xffdf0000 7681 #define SharedUserData ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA) 7682 7683 #define PAGE_SIZE 0x1000 7684 #define PAGE_SHIFT 12L 7685 #define KeGetDcacheFillSize() 1L 7686 7687 #define EFLAG_SIGN 0x8000 7688 #define EFLAG_ZERO 0x4000 7689 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) 7690 7691 #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) 7692 #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) 7693 #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) 7694 7695 7696 typedef struct _KFLOATING_SAVE { 7697 ULONG ControlWord; 7698 ULONG StatusWord; 7699 ULONG ErrorOffset; 7700 ULONG ErrorSelector; 7701 ULONG DataOffset; 7702 ULONG DataSelector; 7703 ULONG Cr0NpxState; 7704 ULONG Spare1; 7705 } KFLOATING_SAVE, *PKFLOATING_SAVE; 7706 7707 extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; 7708 7709 #define YieldProcessor _mm_pause 7710 7711 FORCEINLINE 7712 VOID 7713 KeMemoryBarrier(VOID) 7714 { 7715 volatile LONG Barrier; 7716 #if defined(__GNUC__) 7717 __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax"); 7718 #elif defined(_MSC_VER) 7719 __asm xchg [Barrier], eax 7720 #endif 7721 } 7722 7723 NTHALAPI 7724 KIRQL 7725 NTAPI 7726 KeGetCurrentIrql(VOID); 7727 7728 NTHALAPI 7729 VOID 7730 FASTCALL 7731 KfLowerIrql( 7732 IN KIRQL NewIrql); 7733 #define KeLowerIrql(a) KfLowerIrql(a) 7734 7735 NTHALAPI 7736 KIRQL 7737 FASTCALL 7738 KfRaiseIrql( 7739 IN KIRQL NewIrql); 7740 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) 7741 7742 NTHALAPI 7743 KIRQL 7744 NTAPI 7745 KeRaiseIrqlToDpcLevel(VOID); 7746 7747 NTHALAPI 7748 KIRQL 7749 NTAPI 7750 KeRaiseIrqlToSynchLevel(VOID); 7751 7752 NTHALAPI 7753 KIRQL 7754 FASTCALL 7755 KfAcquireSpinLock( 7756 IN OUT PKSPIN_LOCK SpinLock); 7757 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) 7758 7759 NTHALAPI 7760 VOID 7761 FASTCALL 7762 KfReleaseSpinLock( 7763 IN OUT PKSPIN_LOCK SpinLock, 7764 IN KIRQL NewIrql); 7765 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) 7766 7767 NTKERNELAPI 7768 VOID 7769 FASTCALL 7770 KefAcquireSpinLockAtDpcLevel( 7771 IN OUT PKSPIN_LOCK SpinLock); 7772 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) 7773 7774 NTKERNELAPI 7775 VOID 7776 FASTCALL 7777 KefReleaseSpinLockFromDpcLevel( 7778 IN OUT PKSPIN_LOCK SpinLock); 7779 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) 7780 7781 NTSYSAPI 7782 PKTHREAD 7783 NTAPI 7784 KeGetCurrentThread(VOID); 7785 7786 NTKERNELAPI 7787 NTSTATUS 7788 NTAPI 7789 KeSaveFloatingPointState( 7790 OUT PKFLOATING_SAVE FloatSave); 7791 7792 NTKERNELAPI 7793 NTSTATUS 7794 NTAPI 7795 KeRestoreFloatingPointState( 7796 IN PKFLOATING_SAVE FloatSave); 7797 7798 /* VOID 7799 * KeFlushIoBuffers( 7800 * IN PMDL Mdl, 7801 * IN BOOLEAN ReadOperation, 7802 * IN BOOLEAN DmaOperation) 7803 */ 7804 #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) 7805 7806 /* x86 and x64 performs a 0x2C interrupt */ 7807 #define DbgRaiseAssertionFailure __int2c 7808 7809 FORCEINLINE 7810 VOID 7811 _KeQueryTickCount( 7812 OUT PLARGE_INTEGER CurrentCount) 7813 { 7814 for (;;) { 7815 #ifdef NONAMELESSUNION 7816 CurrentCount->s.HighPart = KeTickCount.High1Time; 7817 CurrentCount->s.LowPart = KeTickCount.LowPart; 7818 if (CurrentCount->s.HighPart == KeTickCount.High2Time) break; 7819 #else 7820 CurrentCount->HighPart = KeTickCount.High1Time; 7821 CurrentCount->LowPart = KeTickCount.LowPart; 7822 if (CurrentCount->HighPart == KeTickCount.High2Time) break; 7823 #endif 7824 YieldProcessor(); 7825 } 7826 } 7827 #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount) 7828 7829 7830 #elif defined(_M_AMD64) 7831 /** Kernel definitions for AMD64 **/ 7832 7833 /* Interrupt request levels */ 7834 #define PASSIVE_LEVEL 0 7835 #define LOW_LEVEL 0 7836 #define APC_LEVEL 1 7837 #define DISPATCH_LEVEL 2 7838 #define CMCI_LEVEL 5 7839 #define CLOCK_LEVEL 13 7840 #define IPI_LEVEL 14 7841 #define DRS_LEVEL 14 7842 #define POWER_LEVEL 14 7843 #define PROFILE_LEVEL 15 7844 #define HIGH_LEVEL 15 7845 7846 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL 7847 #define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA) 7848 #define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8) 7849 #define SharedSystemTime (KI_USER_SHARED_DATA + 0x14) 7850 #define SharedTickCount (KI_USER_SHARED_DATA + 0x320) 7851 7852 #define PAGE_SIZE 0x1000 7853 #define PAGE_SHIFT 12L 7854 7855 #define EFLAG_SIGN 0x8000 7856 #define EFLAG_ZERO 0x4000 7857 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) 7858 7859 typedef struct _KFLOATING_SAVE { 7860 ULONG Dummy; 7861 } KFLOATING_SAVE, *PKFLOATING_SAVE; 7862 7863 typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; 7864 7865 #define KeQueryInterruptTime() \ 7866 (*(volatile ULONG64*)SharedInterruptTime) 7867 7868 #define KeQuerySystemTime(CurrentCount) \ 7869 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime 7870 7871 #define KeQueryTickCount(CurrentCount) \ 7872 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount 7873 7874 #define KeGetDcacheFillSize() 1L 7875 7876 #define YieldProcessor _mm_pause 7877 7878 FORCEINLINE 7879 KIRQL 7880 KeGetCurrentIrql(VOID) 7881 { 7882 return (KIRQL)__readcr8(); 7883 } 7884 7885 FORCEINLINE 7886 VOID 7887 KeLowerIrql(IN KIRQL NewIrql) 7888 { 7889 //ASSERT(KeGetCurrentIrql() >= NewIrql); 7890 __writecr8(NewIrql); 7891 } 7892 7893 FORCEINLINE 7894 KIRQL 7895 KfRaiseIrql(IN KIRQL NewIrql) 7896 { 7897 KIRQL OldIrql; 7898 7899 OldIrql = (KIRQL)__readcr8(); 7900 //ASSERT(OldIrql <= NewIrql); 7901 __writecr8(NewIrql); 7902 return OldIrql; 7903 } 7904 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) 7905 7906 FORCEINLINE 7907 KIRQL 7908 KeRaiseIrqlToDpcLevel(VOID) 7909 { 7910 return KfRaiseIrql(DISPATCH_LEVEL); 7911 } 7912 7913 FORCEINLINE 7914 KIRQL 7915 KeRaiseIrqlToSynchLevel(VOID) 7916 { 7917 return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 7918 } 7919 7920 FORCEINLINE 7921 PKTHREAD 7922 KeGetCurrentThread(VOID) 7923 { 7924 return (struct _KTHREAD *)__readgsqword(0x188); 7925 } 7926 7927 /* VOID 7928 * KeFlushIoBuffers( 7929 * IN PMDL Mdl, 7930 * IN BOOLEAN ReadOperation, 7931 * IN BOOLEAN DmaOperation) 7932 */ 7933 #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) 7934 7935 /* x86 and x64 performs a 0x2C interrupt */ 7936 #define DbgRaiseAssertionFailure __int2c 7937 7938 #elif defined(_M_IA64) 7939 /** Kernel definitions for IA64 **/ 7940 7941 /* Interrupt request levels */ 7942 #define PASSIVE_LEVEL 0 7943 #define LOW_LEVEL 0 7944 #define APC_LEVEL 1 7945 #define DISPATCH_LEVEL 2 7946 #define CMC_LEVEL 3 7947 #define DEVICE_LEVEL_BASE 4 7948 #define PC_LEVEL 12 7949 #define IPI_LEVEL 14 7950 #define DRS_LEVEL 14 7951 #define CLOCK_LEVEL 13 7952 #define POWER_LEVEL 15 7953 #define PROFILE_LEVEL 15 7954 #define HIGH_LEVEL 15 7955 7956 #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) 7957 extern volatile LARGE_INTEGER KeTickCount; 7958 7959 #define PAUSE_PROCESSOR __yield(); 7960 7961 FORCEINLINE 7962 VOID 7963 KeFlushWriteBuffer(VOID) 7964 { 7965 __mf (); 7966 return; 7967 } 7968 7969 NTSYSAPI 7970 PKTHREAD 7971 NTAPI 7972 KeGetCurrentThread(VOID); 7973 7974 7975 #elif defined(_M_PPC) 7976 7977 /* Interrupt request levels */ 7978 #define PASSIVE_LEVEL 0 7979 #define LOW_LEVEL 0 7980 #define APC_LEVEL 1 7981 #define DISPATCH_LEVEL 2 7982 #define PROFILE_LEVEL 27 7983 #define CLOCK1_LEVEL 28 7984 #define CLOCK2_LEVEL 28 7985 #define IPI_LEVEL 29 7986 #define POWER_LEVEL 30 7987 #define HIGH_LEVEL 31 7988 7989 // 7990 // Used to contain PFNs and PFN counts 7991 // 7992 typedef ULONG PFN_COUNT; 7993 typedef ULONG PFN_NUMBER, *PPFN_NUMBER; 7994 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; 7995 7996 7997 typedef struct _KFLOATING_SAVE { 7998 ULONG Dummy; 7999 } KFLOATING_SAVE, *PKFLOATING_SAVE; 8000 8001 typedef struct _KPCR_TIB { 8002 PVOID ExceptionList; /* 00 */ 8003 PVOID StackBase; /* 04 */ 8004 PVOID StackLimit; /* 08 */ 8005 PVOID SubSystemTib; /* 0C */ 8006 _ANONYMOUS_UNION union { 8007 PVOID FiberData; /* 10 */ 8008 ULONG Version; /* 10 */ 8009 } DUMMYUNIONNAME; 8010 PVOID ArbitraryUserPointer; /* 14 */ 8011 struct _KPCR_TIB *Self; /* 18 */ 8012 } KPCR_TIB, *PKPCR_TIB; /* 1C */ 8013 8014 #define PCR_MINOR_VERSION 1 8015 #define PCR_MAJOR_VERSION 1 8016 8017 typedef struct _KPCR { 8018 KPCR_TIB Tib; /* 00 */ 8019 struct _KPCR *Self; /* 1C */ 8020 struct _KPRCB *Prcb; /* 20 */ 8021 KIRQL Irql; /* 24 */ 8022 ULONG IRR; /* 28 */ 8023 ULONG IrrActive; /* 2C */ 8024 ULONG IDR; /* 30 */ 8025 PVOID KdVersionBlock; /* 34 */ 8026 PUSHORT IDT; /* 38 */ 8027 PUSHORT GDT; /* 3C */ 8028 struct _KTSS *TSS; /* 40 */ 8029 USHORT MajorVersion; /* 44 */ 8030 USHORT MinorVersion; /* 46 */ 8031 KAFFINITY SetMember; /* 48 */ 8032 ULONG StallScaleFactor; /* 4C */ 8033 UCHAR SpareUnused; /* 50 */ 8034 UCHAR Number; /* 51 */ 8035 } KPCR, *PKPCR; /* 54 */ 8036 8037 #define KeGetPcr() PCR 8038 8039 #define YieldProcessor() __asm__ __volatile__("nop"); 8040 8041 FORCEINLINE 8042 ULONG 8043 NTAPI 8044 KeGetCurrentProcessorNumber(VOID) 8045 { 8046 ULONG Number; 8047 __asm__ __volatile__ ( 8048 "lwz %0, %c1(12)\n" 8049 : "=r" (Number) 8050 : "i" (FIELD_OFFSET(KPCR, Number)) 8051 ); 8052 return Number; 8053 } 8054 8055 NTHALAPI 8056 VOID 8057 FASTCALL 8058 KfLowerIrql( 8059 IN KIRQL NewIrql); 8060 #define KeLowerIrql(a) KfLowerIrql(a) 8061 8062 NTHALAPI 8063 KIRQL 8064 FASTCALL 8065 KfRaiseIrql( 8066 IN KIRQL NewIrql); 8067 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) 8068 8069 NTHALAPI 8070 KIRQL 8071 NTAPI 8072 KeRaiseIrqlToDpcLevel(VOID); 8073 8074 NTHALAPI 8075 KIRQL 8076 NTAPI 8077 KeRaiseIrqlToSynchLevel(VOID); 8078 8079 8080 8081 #elif defined(_M_MIPS) 8082 #error MIPS Headers are totally incorrect 8083 8084 // 8085 // Used to contain PFNs and PFN counts 8086 // 8087 typedef ULONG PFN_COUNT; 8088 typedef ULONG PFN_NUMBER, *PPFN_NUMBER; 8089 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; 8090 8091 #define PASSIVE_LEVEL 0 8092 #define APC_LEVEL 1 8093 #define DISPATCH_LEVEL 2 8094 #define PROFILE_LEVEL 27 8095 #define IPI_LEVEL 29 8096 #define HIGH_LEVEL 31 8097 8098 typedef struct _KPCR { 8099 struct _KPRCB *Prcb; /* 20 */ 8100 KIRQL Irql; /* 24 */ 8101 ULONG IRR; /* 28 */ 8102 ULONG IDR; /* 30 */ 8103 } KPCR, *PKPCR; 8104 8105 #define KeGetPcr() PCR 8106 8107 typedef struct _KFLOATING_SAVE { 8108 } KFLOATING_SAVE, *PKFLOATING_SAVE; 8109 8110 static __inline 8111 ULONG 8112 NTAPI 8113 KeGetCurrentProcessorNumber(VOID) 8114 { 8115 return 0; 8116 } 8117 8118 #define YieldProcessor() __asm__ __volatile__("nop"); 8119 8120 #define KeLowerIrql(a) KfLowerIrql(a) 8121 #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) 8122 8123 NTKERNELAPI 8124 VOID 8125 NTAPI 8126 KfLowerIrql( 8127 IN KIRQL NewIrql); 8128 8129 NTKERNELAPI 8130 KIRQL 8131 NTAPI 8132 KfRaiseIrql( 8133 IN KIRQL NewIrql); 8134 8135 NTKERNELAPI 8136 KIRQL 8137 NTAPI 8138 KeRaiseIrqlToDpcLevel(VOID); 8139 8140 NTKERNELAPI 8141 KIRQL 8142 NTAPI 8143 KeRaiseIrqlToSynchLevel(VOID); 8144 8145 8146 #elif defined(_M_ARM) 8147 #include <armddk.h> 8148 #else 8149 #error Unknown Architecture 8150 #endif 8151 8152 8153 /****************************************************************************** 8154 * Runtime Library Functions * 8155 ******************************************************************************/ 8156 8157 #if !defined(MIDL_PASS) && !defined(SORTPP_PASS) 8158 8159 #define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } 8160 8161 FORCEINLINE 8162 VOID 8163 InitializeListHead( 8164 OUT PLIST_ENTRY ListHead) 8165 { 8166 ListHead->Flink = ListHead->Blink = ListHead; 8167 } 8168 8169 FORCEINLINE 8170 BOOLEAN 8171 IsListEmpty( 8172 IN CONST LIST_ENTRY * ListHead) 8173 { 8174 return (BOOLEAN)(ListHead->Flink == ListHead); 8175 } 8176 8177 FORCEINLINE 8178 BOOLEAN 8179 RemoveEntryList( 8180 IN PLIST_ENTRY Entry) 8181 { 8182 PLIST_ENTRY OldFlink; 8183 PLIST_ENTRY OldBlink; 8184 8185 OldFlink = Entry->Flink; 8186 OldBlink = Entry->Blink; 8187 OldFlink->Blink = OldBlink; 8188 OldBlink->Flink = OldFlink; 8189 return (BOOLEAN)(OldFlink == OldBlink); 8190 } 8191 8192 FORCEINLINE 8193 PLIST_ENTRY 8194 RemoveHeadList( 8195 IN OUT PLIST_ENTRY ListHead) 8196 { 8197 PLIST_ENTRY Flink; 8198 PLIST_ENTRY Entry; 8199 8200 Entry = ListHead->Flink; 8201 Flink = Entry->Flink; 8202 ListHead->Flink = Flink; 8203 Flink->Blink = ListHead; 8204 return Entry; 8205 } 8206 8207 FORCEINLINE 8208 PLIST_ENTRY 8209 RemoveTailList( 8210 IN OUT PLIST_ENTRY ListHead) 8211 { 8212 PLIST_ENTRY Blink; 8213 PLIST_ENTRY Entry; 8214 8215 Entry = ListHead->Blink; 8216 Blink = Entry->Blink; 8217 ListHead->Blink = Blink; 8218 Blink->Flink = ListHead; 8219 return Entry; 8220 } 8221 8222 FORCEINLINE 8223 VOID 8224 InsertTailList( 8225 IN OUT PLIST_ENTRY ListHead, 8226 IN OUT PLIST_ENTRY Entry) 8227 { 8228 PLIST_ENTRY OldBlink; 8229 OldBlink = ListHead->Blink; 8230 Entry->Flink = ListHead; 8231 Entry->Blink = OldBlink; 8232 OldBlink->Flink = Entry; 8233 ListHead->Blink = Entry; 8234 } 8235 8236 FORCEINLINE 8237 VOID 8238 InsertHeadList( 8239 IN OUT PLIST_ENTRY ListHead, 8240 IN OUT PLIST_ENTRY Entry) 8241 { 8242 PLIST_ENTRY OldFlink; 8243 OldFlink = ListHead->Flink; 8244 Entry->Flink = OldFlink; 8245 Entry->Blink = ListHead; 8246 OldFlink->Blink = Entry; 8247 ListHead->Flink = Entry; 8248 } 8249 8250 FORCEINLINE 8251 VOID 8252 AppendTailList( 8253 IN OUT PLIST_ENTRY ListHead, 8254 IN OUT PLIST_ENTRY ListToAppend) 8255 { 8256 PLIST_ENTRY ListEnd = ListHead->Blink; 8257 8258 ListHead->Blink->Flink = ListToAppend; 8259 ListHead->Blink = ListToAppend->Blink; 8260 ListToAppend->Blink->Flink = ListHead; 8261 ListToAppend->Blink = ListEnd; 8262 } 8263 8264 FORCEINLINE 8265 PSINGLE_LIST_ENTRY 8266 PopEntryList( 8267 IN OUT PSINGLE_LIST_ENTRY ListHead) 8268 { 8269 PSINGLE_LIST_ENTRY FirstEntry; 8270 FirstEntry = ListHead->Next; 8271 if (FirstEntry != NULL) { 8272 ListHead->Next = FirstEntry->Next; 8273 } 8274 return FirstEntry; 8275 } 8276 8277 FORCEINLINE 8278 VOID 8279 PushEntryList( 8280 IN OUT PSINGLE_LIST_ENTRY ListHead, 8281 IN OUT PSINGLE_LIST_ENTRY Entry) 8282 { 8283 Entry->Next = ListHead->Next; 8284 ListHead->Next = Entry; 8285 } 8286 8287 #endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ 8288 8289 NTSYSAPI 8290 VOID 8291 NTAPI 8292 RtlAssert( 8293 IN PVOID FailedAssertion, 8294 IN PVOID FileName, 8295 IN ULONG LineNumber, 8296 IN PSTR Message); 8297 8298 /* VOID 8299 * RtlCopyMemory( 8300 * IN VOID UNALIGNED *Destination, 8301 * IN CONST VOID UNALIGNED *Source, 8302 * IN SIZE_T Length) 8303 */ 8304 #define RtlCopyMemory(Destination, Source, Length) \ 8305 memcpy(Destination, Source, Length) 8306 8307 #define RtlCopyBytes RtlCopyMemory 8308 8309 #if defined(_M_AMD64) 8310 NTSYSAPI 8311 VOID 8312 NTAPI 8313 RtlCopyMemoryNonTemporal( 8314 VOID UNALIGNED *Destination, 8315 CONST VOID UNALIGNED *Source, 8316 SIZE_T Length); 8317 #else 8318 #define RtlCopyMemoryNonTemporal RtlCopyMemory 8319 #endif 8320 8321 /* BOOLEAN 8322 * RtlEqualLuid( 8323 * IN PLUID Luid1, 8324 * IN PLUID Luid2) 8325 */ 8326 #define RtlEqualLuid(Luid1, Luid2) \ 8327 (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart)) 8328 8329 /* ULONG 8330 * RtlEqualMemory( 8331 * IN VOID UNALIGNED *Destination, 8332 * IN CONST VOID UNALIGNED *Source, 8333 * IN SIZE_T Length) 8334 */ 8335 #define RtlEqualMemory(Destination, Source, Length) \ 8336 (!memcmp(Destination, Source, Length)) 8337 8338 /* VOID 8339 * RtlFillMemory( 8340 * IN VOID UNALIGNED *Destination, 8341 * IN SIZE_T Length, 8342 * IN UCHAR Fill) 8343 */ 8344 #define RtlFillMemory(Destination, Length, Fill) \ 8345 memset(Destination, Fill, Length) 8346 8347 #define RtlFillBytes RtlFillMemory 8348 8349 NTSYSAPI 8350 VOID 8351 NTAPI 8352 RtlFreeUnicodeString( 8353 IN OUT PUNICODE_STRING UnicodeString); 8354 8355 NTSYSAPI 8356 NTSTATUS 8357 NTAPI 8358 RtlGUIDFromString( 8359 IN PUNICODE_STRING GuidString, 8360 OUT GUID *Guid); 8361 8362 NTSYSAPI 8363 VOID 8364 NTAPI 8365 RtlInitUnicodeString( 8366 IN OUT PUNICODE_STRING DestinationString, 8367 IN PCWSTR SourceString OPTIONAL); 8368 8369 /* VOID 8370 * RtlMoveMemory( 8371 * IN VOID UNALIGNED *Destination, 8372 * IN CONST VOID UNALIGNED *Source, 8373 * IN SIZE_T Length) 8374 */ 8375 #define RtlMoveMemory(Destination, Source, Length) \ 8376 memmove(Destination, Source, Length) 8377 8378 NTSYSAPI 8379 NTSTATUS 8380 NTAPI 8381 RtlStringFromGUID( 8382 IN REFGUID Guid, 8383 OUT PUNICODE_STRING GuidString); 8384 8385 /* VOID 8386 * RtlZeroMemory( 8387 * IN VOID UNALIGNED *Destination, 8388 * IN SIZE_T Length) 8389 */ 8390 #define RtlZeroMemory(Destination, Length) \ 8391 memset(Destination, 0, Length) 8392 8393 #define RtlZeroBytes RtlZeroMemory 8394 8395 #if (NTDDI_VERSION >= NTDDI_WIN2K) 8396 8397 NTSYSAPI 8398 BOOLEAN 8399 NTAPI 8400 RtlAreBitsClear( 8401 IN PRTL_BITMAP BitMapHeader, 8402 IN ULONG StartingIndex, 8403 IN ULONG Length); 8404 8405 NTSYSAPI 8406 BOOLEAN 8407 NTAPI 8408 RtlAreBitsSet( 8409 IN PRTL_BITMAP BitMapHeader, 8410 IN ULONG StartingIndex, 8411 IN ULONG Length); 8412 8413 NTSYSAPI 8414 NTSTATUS 8415 NTAPI 8416 RtlAnsiStringToUnicodeString( 8417 IN OUT PUNICODE_STRING DestinationString, 8418 IN PANSI_STRING SourceString, 8419 IN BOOLEAN AllocateDestinationString); 8420 8421 NTSYSAPI 8422 ULONG 8423 NTAPI 8424 RtlxAnsiStringToUnicodeSize( 8425 IN PCANSI_STRING AnsiString); 8426 8427 #define RtlAnsiStringToUnicodeSize(String) ( \ 8428 NLS_MB_CODE_PAGE_TAG ? \ 8429 RtlxAnsiStringToUnicodeSize(String) : \ 8430 ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \ 8431 ) 8432 8433 NTSYSAPI 8434 NTSTATUS 8435 NTAPI 8436 RtlAppendUnicodeStringToString( 8437 IN OUT PUNICODE_STRING Destination, 8438 IN PCUNICODE_STRING Source); 8439 8440 NTSYSAPI 8441 NTSTATUS 8442 NTAPI 8443 RtlAppendUnicodeToString( 8444 IN OUT PUNICODE_STRING Destination, 8445 IN PCWSTR Source); 8446 8447 NTSYSAPI 8448 NTSTATUS 8449 NTAPI 8450 RtlCheckRegistryKey( 8451 IN ULONG RelativeTo, 8452 IN PWSTR Path); 8453 8454 NTSYSAPI 8455 VOID 8456 NTAPI 8457 RtlClearAllBits( 8458 IN PRTL_BITMAP BitMapHeader); 8459 8460 NTSYSAPI 8461 VOID 8462 NTAPI 8463 RtlClearBits( 8464 IN PRTL_BITMAP BitMapHeader, 8465 IN ULONG StartingIndex, 8466 IN ULONG NumberToClear); 8467 8468 NTSYSAPI 8469 SIZE_T 8470 NTAPI 8471 RtlCompareMemory( 8472 IN CONST VOID *Source1, 8473 IN CONST VOID *Source2, 8474 IN SIZE_T Length); 8475 8476 NTSYSAPI 8477 LONG 8478 NTAPI 8479 RtlCompareUnicodeString( 8480 IN PCUNICODE_STRING String1, 8481 IN PCUNICODE_STRING String2, 8482 IN BOOLEAN CaseInSensitive); 8483 8484 NTSYSAPI 8485 LONG 8486 NTAPI 8487 RtlCompareUnicodeStrings( 8488 IN PCWCH String1, 8489 IN SIZE_T String1Length, 8490 IN PCWCH String2, 8491 IN SIZE_T String2Length, 8492 IN BOOLEAN CaseInSensitive); 8493 8494 NTSYSAPI 8495 VOID 8496 NTAPI 8497 RtlCopyUnicodeString( 8498 IN OUT PUNICODE_STRING DestinationString, 8499 IN PCUNICODE_STRING SourceString OPTIONAL); 8500 8501 NTSYSAPI 8502 NTSTATUS 8503 NTAPI 8504 RtlCreateRegistryKey( 8505 IN ULONG RelativeTo, 8506 IN PWSTR Path); 8507 8508 NTSYSAPI 8509 NTSTATUS 8510 NTAPI 8511 RtlCreateSecurityDescriptor( 8512 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, 8513 IN ULONG Revision); 8514 8515 NTSYSAPI 8516 NTSTATUS 8517 NTAPI 8518 RtlDeleteRegistryValue( 8519 IN ULONG RelativeTo, 8520 IN PCWSTR Path, 8521 IN PCWSTR ValueName); 8522 8523 NTSYSAPI 8524 BOOLEAN 8525 NTAPI 8526 RtlEqualUnicodeString( 8527 IN CONST UNICODE_STRING *String1, 8528 IN CONST UNICODE_STRING *String2, 8529 IN BOOLEAN CaseInSensitive); 8530 8531 #if !defined(_AMD64_) && !defined(_IA64_) 8532 NTSYSAPI 8533 LARGE_INTEGER 8534 NTAPI 8535 RtlExtendedIntegerMultiply( 8536 IN LARGE_INTEGER Multiplicand, 8537 IN LONG Multiplier); 8538 8539 NTSYSAPI 8540 LARGE_INTEGER 8541 NTAPI 8542 RtlExtendedLargeIntegerDivide( 8543 IN LARGE_INTEGER Dividend, 8544 IN ULONG Divisor, 8545 OUT PULONG Remainder OPTIONAL); 8546 #endif 8547 8548 #if defined(_X86_) || defined(_IA64_) 8549 NTSYSAPI 8550 LARGE_INTEGER 8551 NTAPI 8552 RtlExtendedMagicDivide( 8553 IN LARGE_INTEGER Dividend, 8554 IN LARGE_INTEGER MagicDivisor, 8555 IN CCHAR ShiftCount); 8556 #endif 8557 8558 NTSYSAPI 8559 VOID 8560 NTAPI 8561 RtlFreeAnsiString( 8562 IN PANSI_STRING AnsiString); 8563 8564 NTSYSAPI 8565 ULONG 8566 NTAPI 8567 RtlFindClearBits( 8568 IN PRTL_BITMAP BitMapHeader, 8569 IN ULONG NumberToFind, 8570 IN ULONG HintIndex); 8571 8572 NTSYSAPI 8573 ULONG 8574 NTAPI 8575 RtlFindClearBitsAndSet( 8576 IN PRTL_BITMAP BitMapHeader, 8577 IN ULONG NumberToFind, 8578 IN ULONG HintIndex); 8579 8580 NTSYSAPI 8581 ULONG 8582 NTAPI 8583 RtlFindFirstRunClear( 8584 IN PRTL_BITMAP BitMapHeader, 8585 OUT PULONG StartingIndex); 8586 8587 NTSYSAPI 8588 ULONG 8589 NTAPI 8590 RtlFindClearRuns( 8591 IN PRTL_BITMAP BitMapHeader, 8592 OUT PRTL_BITMAP_RUN RunArray, 8593 IN ULONG SizeOfRunArray, 8594 IN BOOLEAN LocateLongestRuns); 8595 8596 NTSYSAPI 8597 ULONG 8598 NTAPI 8599 RtlFindLastBackwardRunClear( 8600 IN PRTL_BITMAP BitMapHeader, 8601 IN ULONG FromIndex, 8602 OUT PULONG StartingRunIndex); 8603 8604 NTSYSAPI 8605 CCHAR 8606 NTAPI 8607 RtlFindLeastSignificantBit( 8608 IN ULONGLONG Set); 8609 8610 NTSYSAPI 8611 ULONG 8612 NTAPI 8613 RtlFindLongestRunClear( 8614 IN PRTL_BITMAP BitMapHeader, 8615 OUT PULONG StartingIndex); 8616 8617 NTSYSAPI 8618 CCHAR 8619 NTAPI 8620 RtlFindMostSignificantBit( 8621 IN ULONGLONG Set); 8622 8623 NTSYSAPI 8624 ULONG 8625 NTAPI 8626 RtlFindNextForwardRunClear( 8627 IN PRTL_BITMAP BitMapHeader, 8628 IN ULONG FromIndex, 8629 OUT PULONG StartingRunIndex); 8630 8631 NTSYSAPI 8632 ULONG 8633 NTAPI 8634 RtlFindSetBits( 8635 IN PRTL_BITMAP BitMapHeader, 8636 IN ULONG NumberToFind, 8637 IN ULONG HintIndex); 8638 8639 NTSYSAPI 8640 ULONG 8641 NTAPI 8642 RtlFindSetBitsAndClear( 8643 IN PRTL_BITMAP BitMapHeader, 8644 IN ULONG NumberToFind, 8645 IN ULONG HintIndex); 8646 8647 NTSYSAPI 8648 VOID 8649 NTAPI 8650 RtlInitAnsiString( 8651 IN OUT PANSI_STRING DestinationString, 8652 IN PCSZ SourceString); 8653 8654 NTSYSAPI 8655 VOID 8656 NTAPI 8657 RtlInitializeBitMap( 8658 IN PRTL_BITMAP BitMapHeader, 8659 IN PULONG BitMapBuffer, 8660 IN ULONG SizeOfBitMap); 8661 8662 NTSYSAPI 8663 VOID 8664 NTAPI 8665 RtlInitString( 8666 IN OUT PSTRING DestinationString, 8667 IN PCSZ SourceString); 8668 8669 NTSYSAPI 8670 NTSTATUS 8671 NTAPI 8672 RtlIntegerToUnicodeString( 8673 IN ULONG Value, 8674 IN ULONG Base OPTIONAL, 8675 IN OUT PUNICODE_STRING String); 8676 8677 NTSYSAPI 8678 NTSTATUS 8679 NTAPI 8680 RtlInt64ToUnicodeString( 8681 IN ULONGLONG Value, 8682 IN ULONG Base OPTIONAL, 8683 IN OUT PUNICODE_STRING String); 8684 8685 #ifdef _WIN64 8686 #define RtlIntPtrToUnicodeString(Value, Base, String) \ 8687 RtlInt64ToUnicodeString(Value, Base, String) 8688 #else 8689 #define RtlIntPtrToUnicodeString(Value, Base, String) \ 8690 RtlIntegerToUnicodeString(Value, Base, String) 8691 #endif 8692 8693 /* BOOLEAN 8694 * RtlIsZeroLuid( 8695 * IN PLUID L1); 8696 */ 8697 #define RtlIsZeroLuid(_L1) \ 8698 ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart))) 8699 8700 NTSYSAPI 8701 ULONG 8702 NTAPI 8703 RtlLengthSecurityDescriptor( 8704 IN PSECURITY_DESCRIPTOR SecurityDescriptor); 8705 8706 NTSYSAPI 8707 ULONG 8708 NTAPI 8709 RtlNumberOfClearBits( 8710 IN PRTL_BITMAP BitMapHeader); 8711 8712 NTSYSAPI 8713 ULONG 8714 NTAPI 8715 RtlNumberOfSetBits( 8716 IN PRTL_BITMAP BitMapHeader); 8717 8718 NTSYSAPI 8719 NTSTATUS 8720 NTAPI 8721 RtlQueryRegistryValues( 8722 IN ULONG RelativeTo, 8723 IN PCWSTR Path, 8724 IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, 8725 IN PVOID Context OPTIONAL, 8726 IN PVOID Environment OPTIONAL); 8727 8728 #define SHORT_SIZE (sizeof(USHORT)) 8729 #define SHORT_MASK (SHORT_SIZE - 1) 8730 #define LONG_SIZE (sizeof(LONG)) 8731 #define LONGLONG_SIZE (sizeof(LONGLONG)) 8732 #define LONG_MASK (LONG_SIZE - 1) 8733 #define LONGLONG_MASK (LONGLONG_SIZE - 1) 8734 #define LOWBYTE_MASK 0x00FF 8735 8736 #define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) 8737 #define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) 8738 #define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) 8739 #define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) 8740 8741 NTSYSAPI 8742 VOID 8743 NTAPI 8744 RtlSetAllBits( 8745 IN PRTL_BITMAP BitMapHeader); 8746 8747 NTSYSAPI 8748 VOID 8749 NTAPI 8750 RtlSetBits( 8751 IN PRTL_BITMAP BitMapHeader, 8752 IN ULONG StartingIndex, 8753 IN ULONG NumberToSet); 8754 8755 NTSYSAPI 8756 NTSTATUS 8757 NTAPI 8758 RtlSetDaclSecurityDescriptor( 8759 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, 8760 IN BOOLEAN DaclPresent, 8761 IN PACL Dacl OPTIONAL, 8762 IN BOOLEAN DaclDefaulted OPTIONAL); 8763 8764 #if defined(_AMD64_) 8765 8766 /* VOID 8767 * RtlStoreUlong( 8768 * IN PULONG Address, 8769 * IN ULONG Value); 8770 */ 8771 #define RtlStoreUlong(Address,Value) \ 8772 *(ULONG UNALIGNED *)(Address) = (Value) 8773 8774 /* VOID 8775 * RtlStoreUlonglong( 8776 * IN OUT PULONGLONG Address, 8777 * ULONGLONG Value); 8778 */ 8779 #define RtlStoreUlonglong(Address,Value) \ 8780 *(ULONGLONG UNALIGNED *)(Address) = (Value) 8781 8782 /* VOID 8783 * RtlStoreUshort( 8784 * IN PUSHORT Address, 8785 * IN USHORT Value); 8786 */ 8787 #define RtlStoreUshort(Address,Value) \ 8788 *(USHORT UNALIGNED *)(Address) = (Value) 8789 8790 /* VOID 8791 * RtlRetrieveUshort( 8792 * PUSHORT DestinationAddress, 8793 * PUSHORT SourceAddress); 8794 */ 8795 #define RtlRetrieveUshort(DestAddress,SrcAddress) \ 8796 *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) 8797 8798 /* VOID 8799 * RtlRetrieveUlong( 8800 * PULONG DestinationAddress, 8801 * PULONG SourceAddress); 8802 */ 8803 #define RtlRetrieveUlong(DestAddress,SrcAddress) \ 8804 *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) 8805 8806 #else 8807 8808 #define RtlStoreUlong(Address,Value) \ 8809 if ((ULONG_PTR)(Address) & LONG_MASK) { \ 8810 ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ 8811 ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ 8812 ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ 8813 ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ 8814 } \ 8815 else { \ 8816 *((PULONG)(Address)) = (ULONG) (Value); \ 8817 } 8818 8819 #define RtlStoreUlonglong(Address,Value) \ 8820 if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ 8821 RtlStoreUlong((ULONG_PTR)(Address), \ 8822 (ULONGLONG)(Value) & 0xFFFFFFFF); \ 8823 RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ 8824 (ULONGLONG)(Value) >> 32); \ 8825 } else { \ 8826 *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ 8827 } 8828 8829 #define RtlStoreUshort(Address,Value) \ 8830 if ((ULONG_PTR)(Address) & SHORT_MASK) { \ 8831 ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ 8832 ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ 8833 } \ 8834 else { \ 8835 *((PUSHORT) (Address)) = (USHORT)Value; \ 8836 } 8837 8838 #define RtlRetrieveUshort(DestAddress,SrcAddress) \ 8839 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ 8840 { \ 8841 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ 8842 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ 8843 } \ 8844 else \ 8845 { \ 8846 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ 8847 } 8848 8849 #define RtlRetrieveUlong(DestAddress,SrcAddress) \ 8850 if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ 8851 { \ 8852 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ 8853 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ 8854 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \ 8855 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \ 8856 } \ 8857 else \ 8858 { \ 8859 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ 8860 } 8861 8862 #endif /* defined(_AMD64_) */ 8863 8864 #ifdef _WIN64 8865 /* VOID 8866 * RtlStoreUlongPtr( 8867 * IN OUT PULONG_PTR Address, 8868 * IN ULONG_PTR Value); 8869 */ 8870 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) 8871 #else 8872 #define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) 8873 #endif /* _WIN64 */ 8874 8875 NTSYSAPI 8876 BOOLEAN 8877 NTAPI 8878 RtlTimeFieldsToTime( 8879 IN PTIME_FIELDS TimeFields, 8880 IN PLARGE_INTEGER Time); 8881 8882 NTSYSAPI 8883 VOID 8884 NTAPI 8885 RtlTimeToTimeFields( 8886 IN PLARGE_INTEGER Time, 8887 IN PTIME_FIELDS TimeFields); 8888 8889 NTSYSAPI 8890 ULONG 8891 FASTCALL 8892 RtlUlongByteSwap( 8893 IN ULONG Source); 8894 8895 NTSYSAPI 8896 ULONGLONG 8897 FASTCALL 8898 RtlUlonglongByteSwap( 8899 IN ULONGLONG Source); 8900 8901 NTSYSAPI 8902 NTSTATUS 8903 NTAPI 8904 RtlUnicodeStringToAnsiString( 8905 IN OUT PANSI_STRING DestinationString, 8906 IN PCUNICODE_STRING SourceString, 8907 IN BOOLEAN AllocateDestinationString); 8908 8909 NTSYSAPI 8910 ULONG 8911 NTAPI 8912 RtlxUnicodeStringToAnsiSize( 8913 IN PCUNICODE_STRING UnicodeString); 8914 8915 #define RtlUnicodeStringToAnsiSize(String) ( \ 8916 NLS_MB_CODE_PAGE_TAG ? \ 8917 RtlxUnicodeStringToAnsiSize(String) : \ 8918 ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \ 8919 ) 8920 8921 NTSYSAPI 8922 NTSTATUS 8923 NTAPI 8924 RtlUnicodeStringToInteger( 8925 IN PCUNICODE_STRING String, 8926 IN ULONG Base OPTIONAL, 8927 OUT PULONG Value); 8928 8929 NTSYSAPI 8930 WCHAR 8931 NTAPI 8932 RtlUpcaseUnicodeChar( 8933 IN WCHAR SourceCharacter); 8934 8935 NTSYSAPI 8936 USHORT 8937 FASTCALL 8938 RtlUshortByteSwap( 8939 IN USHORT Source); 8940 8941 NTSYSAPI 8942 BOOLEAN 8943 NTAPI 8944 RtlValidRelativeSecurityDescriptor( 8945 IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, 8946 IN ULONG SecurityDescriptorLength, 8947 IN SECURITY_INFORMATION RequiredInformation); 8948 8949 NTSYSAPI 8950 BOOLEAN 8951 NTAPI 8952 RtlValidSecurityDescriptor( 8953 IN PSECURITY_DESCRIPTOR SecurityDescriptor); 8954 8955 NTSYSAPI 8956 NTSTATUS 8957 NTAPI 8958 RtlWriteRegistryValue( 8959 IN ULONG RelativeTo, 8960 IN PCWSTR Path, 8961 IN PCWSTR ValueName, 8962 IN ULONG ValueType, 8963 IN PVOID ValueData, 8964 IN ULONG ValueLength); 8965 8966 8967 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 8968 8969 8970 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) 8971 NTSYSAPI 8972 VOID 8973 FASTCALL 8974 RtlPrefetchMemoryNonTemporal( 8975 IN PVOID Source, 8976 IN SIZE_T Length); 8977 #endif 8978 8979 8980 #if (NTDDI_VERSION >= NTDDI_WINXP) 8981 8982 8983 NTSYSAPI 8984 VOID 8985 NTAPI 8986 RtlClearBit( 8987 PRTL_BITMAP BitMapHeader, 8988 ULONG BitNumber); 8989 8990 NTSYSAPI 8991 WCHAR 8992 NTAPI 8993 RtlDowncaseUnicodeChar( 8994 IN WCHAR SourceCharacter); 8995 8996 NTSYSAPI 8997 VOID 8998 NTAPI 8999 RtlSetBit( 9000 PRTL_BITMAP BitMapHeader, 9001 ULONG BitNumber); 9002 9003 NTSYSAPI 9004 BOOLEAN 9005 NTAPI 9006 RtlTestBit( 9007 IN PRTL_BITMAP BitMapHeader, 9008 IN ULONG BitNumber); 9009 9010 NTSYSAPI 9011 NTSTATUS 9012 NTAPI 9013 RtlHashUnicodeString( 9014 IN CONST UNICODE_STRING *String, 9015 IN BOOLEAN CaseInSensitive, 9016 IN ULONG HashAlgorithm, 9017 OUT PULONG HashValue); 9018 9019 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 9020 9021 9022 #if (NTDDI_VERSION >= NTDDI_VISTA) 9023 9024 NTSYSAPI 9025 ULONG 9026 NTAPI 9027 RtlNumberOfSetBitsUlongPtr( 9028 IN ULONG_PTR Target); 9029 9030 NTSYSAPI 9031 ULONGLONG 9032 NTAPI 9033 RtlIoDecodeMemIoResource( 9034 IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, 9035 OUT PULONGLONG Alignment OPTIONAL, 9036 OUT PULONGLONG MinimumAddress OPTIONAL, 9037 OUT PULONGLONG MaximumAddress OPTIONAL); 9038 9039 NTSYSAPI 9040 NTSTATUS 9041 NTAPI 9042 RtlIoEncodeMemIoResource( 9043 IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, 9044 IN UCHAR Type, 9045 IN ULONGLONG Length, 9046 IN ULONGLONG Alignment, 9047 IN ULONGLONG MinimumAddress, 9048 IN ULONGLONG MaximumAddress); 9049 9050 NTSYSAPI 9051 ULONGLONG 9052 NTAPI 9053 RtlCmDecodeMemIoResource( 9054 IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, 9055 OUT PULONGLONG Start OPTIONAL); 9056 9057 NTSYSAPI 9058 NTSTATUS 9059 NTAPI 9060 RtlFindClosestEncodableLength( 9061 IN ULONGLONG SourceLength, 9062 OUT PULONGLONG TargetLength); 9063 9064 NTSYSAPI 9065 NTSTATUS 9066 NTAPI 9067 RtlCmEncodeMemIoResource( 9068 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, 9069 IN UCHAR Type, 9070 IN ULONGLONG Length, 9071 IN ULONGLONG Start); 9072 9073 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 9074 9075 #if (NTDDI_VERSION >= NTDDI_WIN7) 9076 9077 NTSYSAPI 9078 NTSTATUS 9079 NTAPI 9080 RtlUnicodeToUTF8N( 9081 OUT PCHAR UTF8StringDestination, 9082 IN ULONG UTF8StringMaxByteCount, 9083 OUT PULONG UTF8StringActualByteCount, 9084 IN PCWCH UnicodeStringSource, 9085 IN ULONG UnicodeStringByteCount); 9086 9087 NTSYSAPI 9088 NTSTATUS 9089 NTAPI 9090 RtlUTF8ToUnicodeN( 9091 OUT PWSTR UnicodeStringDestination, 9092 IN ULONG UnicodeStringMaxByteCount, 9093 OUT PULONG UnicodeStringActualByteCount, 9094 IN PCCH UTF8StringSource, 9095 IN ULONG UTF8StringByteCount); 9096 9097 NTSYSAPI 9098 ULONG64 9099 NTAPI 9100 RtlGetEnabledExtendedFeatures( 9101 IN ULONG64 FeatureMask); 9102 9103 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 9104 9105 9106 #if !defined(MIDL_PASS) 9107 /* inline funftions */ 9108 //DECLSPEC_DEPRECATED_DDK_WINXP 9109 static __inline 9110 LARGE_INTEGER 9111 NTAPI_INLINE 9112 RtlConvertLongToLargeInteger( 9113 IN LONG SignedInteger) 9114 { 9115 LARGE_INTEGER ret; 9116 ret.QuadPart = SignedInteger; 9117 return ret; 9118 } 9119 9120 //DECLSPEC_DEPRECATED_DDK_WINXP 9121 static __inline 9122 LARGE_INTEGER 9123 NTAPI_INLINE 9124 RtlConvertUlongToLargeInteger( 9125 IN ULONG UnsignedInteger) 9126 { 9127 LARGE_INTEGER ret; 9128 ret.QuadPart = UnsignedInteger; 9129 return ret; 9130 } 9131 9132 //DECLSPEC_DEPRECATED_DDK_WINXP 9133 static __inline 9134 LARGE_INTEGER 9135 NTAPI_INLINE 9136 RtlLargeIntegerShiftLeft( 9137 IN LARGE_INTEGER LargeInteger, 9138 IN CCHAR ShiftCount) 9139 { 9140 LARGE_INTEGER Result; 9141 9142 Result.QuadPart = LargeInteger.QuadPart << ShiftCount; 9143 return Result; 9144 } 9145 9146 //DECLSPEC_DEPRECATED_DDK_WINXP 9147 static __inline 9148 LARGE_INTEGER 9149 NTAPI_INLINE 9150 RtlLargeIntegerShiftRight( 9151 IN LARGE_INTEGER LargeInteger, 9152 IN CCHAR ShiftCount) 9153 { 9154 LARGE_INTEGER Result; 9155 9156 Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; 9157 return Result; 9158 } 9159 9160 //DECLSPEC_DEPRECATED_DDK 9161 static __inline 9162 ULONG 9163 NTAPI_INLINE 9164 RtlEnlargedUnsignedDivide( 9165 IN ULARGE_INTEGER Dividend, 9166 IN ULONG Divisor, 9167 IN OUT PULONG Remainder) 9168 { 9169 if (Remainder) 9170 *Remainder = (ULONG)(Dividend.QuadPart % Divisor); 9171 return (ULONG)(Dividend.QuadPart / Divisor); 9172 } 9173 9174 //DECLSPEC_DEPRECATED_DDK 9175 static __inline 9176 LARGE_INTEGER 9177 NTAPI_INLINE 9178 RtlLargeIntegerNegate( 9179 IN LARGE_INTEGER Subtrahend) 9180 { 9181 LARGE_INTEGER Difference; 9182 9183 Difference.QuadPart = -Subtrahend.QuadPart; 9184 return Difference; 9185 } 9186 9187 //DECLSPEC_DEPRECATED_DDK 9188 static __inline 9189 LARGE_INTEGER 9190 NTAPI_INLINE 9191 RtlLargeIntegerSubtract( 9192 IN LARGE_INTEGER Minuend, 9193 IN LARGE_INTEGER Subtrahend) 9194 { 9195 LARGE_INTEGER Difference; 9196 9197 Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; 9198 return Difference; 9199 } 9200 9201 //DECLSPEC_DEPRECATED_DDK 9202 static __inline 9203 LARGE_INTEGER 9204 NTAPI_INLINE 9205 RtlEnlargedUnsignedMultiply( 9206 IN ULONG Multiplicand, 9207 IN ULONG Multiplier) 9208 { 9209 LARGE_INTEGER ret; 9210 ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; 9211 return ret; 9212 } 9213 9214 //DECLSPEC_DEPRECATED_DDK 9215 static __inline 9216 LARGE_INTEGER 9217 NTAPI_INLINE 9218 RtlEnlargedIntegerMultiply( 9219 IN LONG Multiplicand, 9220 IN LONG Multiplier) 9221 { 9222 LARGE_INTEGER ret; 9223 ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; 9224 return ret; 9225 } 9226 9227 FORCEINLINE 9228 VOID 9229 RtlInitEmptyAnsiString( 9230 OUT PANSI_STRING AnsiString, 9231 IN PCHAR Buffer, 9232 IN USHORT BufferSize) 9233 { 9234 AnsiString->Length = 0; 9235 AnsiString->MaximumLength = BufferSize; 9236 AnsiString->Buffer = Buffer; 9237 } 9238 9239 FORCEINLINE 9240 VOID 9241 RtlInitEmptyUnicodeString( 9242 OUT PUNICODE_STRING UnicodeString, 9243 IN PWSTR Buffer, 9244 IN USHORT BufferSize) 9245 { 9246 UnicodeString->Length = 0; 9247 UnicodeString->MaximumLength = BufferSize; 9248 UnicodeString->Buffer = Buffer; 9249 } 9250 9251 #if defined(_AMD64_) || defined(_IA64_) 9252 9253 static __inline 9254 LARGE_INTEGER 9255 NTAPI_INLINE 9256 RtlExtendedIntegerMultiply( 9257 IN LARGE_INTEGER Multiplicand, 9258 IN LONG Multiplier) 9259 { 9260 LARGE_INTEGER ret; 9261 ret.QuadPart = Multiplicand.QuadPart * Multiplier; 9262 return ret; 9263 } 9264 9265 static __inline 9266 LARGE_INTEGER 9267 NTAPI_INLINE 9268 RtlExtendedLargeIntegerDivide( 9269 IN LARGE_INTEGER Dividend, 9270 IN ULONG Divisor, 9271 OUT PULONG Remainder OPTIONAL) 9272 { 9273 LARGE_INTEGER ret; 9274 ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; 9275 if (Remainder) 9276 *Remainder = (ULONG)(Dividend.QuadPart % Divisor); 9277 return ret; 9278 } 9279 9280 #endif /* defined(_AMD64_) || defined(_IA64_) */ 9281 9282 9283 #if defined(_AMD64_) 9284 9285 #define MultiplyHigh __mulh 9286 #define UnsignedMultiplyHigh __umulh 9287 9288 //DECLSPEC_DEPRECATED_DDK 9289 static __inline 9290 LARGE_INTEGER 9291 NTAPI_INLINE 9292 RtlExtendedMagicDivide( 9293 IN LARGE_INTEGER Dividend, 9294 IN LARGE_INTEGER MagicDivisor, 9295 IN CCHAR ShiftCount) 9296 { 9297 LARGE_INTEGER ret; 9298 ULONG64 ret64; 9299 BOOLEAN Pos; 9300 Pos = (Dividend.QuadPart >= 0); 9301 ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, 9302 MagicDivisor.QuadPart); 9303 ret64 >>= ShiftCount; 9304 ret.QuadPart = Pos ? ret64 : -(LONG64)ret64; 9305 return ret; 9306 } 9307 #endif 9308 9309 //DECLSPEC_DEPRECATED_DDK 9310 static __inline 9311 LARGE_INTEGER 9312 NTAPI_INLINE 9313 RtlLargeIntegerAdd( 9314 IN LARGE_INTEGER Addend1, 9315 IN LARGE_INTEGER Addend2) 9316 { 9317 LARGE_INTEGER ret; 9318 ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; 9319 return ret; 9320 } 9321 9322 /* VOID 9323 * RtlLargeIntegerAnd( 9324 * IN OUT LARGE_INTEGER Result, 9325 * IN LARGE_INTEGER Source, 9326 * IN LARGE_INTEGER Mask); 9327 */ 9328 #define RtlLargeIntegerAnd(Result, Source, Mask) \ 9329 Result.QuadPart = Source.QuadPart & Mask.QuadPart 9330 9331 //DECLSPEC_DEPRECATED_DDK 9332 static __inline 9333 LARGE_INTEGER 9334 NTAPI_INLINE 9335 RtlLargeIntegerArithmeticShift( 9336 IN LARGE_INTEGER LargeInteger, 9337 IN CCHAR ShiftCount) 9338 { 9339 LARGE_INTEGER ret; 9340 ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; 9341 return ret; 9342 } 9343 9344 /* BOOLEAN 9345 * RtlLargeIntegerEqualTo( 9346 * IN LARGE_INTEGER Operand1, 9347 * IN LARGE_INTEGER Operand2); 9348 */ 9349 #define RtlLargeIntegerEqualTo(X,Y) \ 9350 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart))) 9351 9352 FORCEINLINE 9353 PVOID 9354 RtlSecureZeroMemory( 9355 OUT PVOID Pointer, 9356 IN SIZE_T Size) 9357 { 9358 volatile char* vptr = (volatile char*)Pointer; 9359 #if defined(_M_AMD64) 9360 __stosb((PUCHAR)vptr, 0, Size); 9361 #else 9362 char * endptr = (char *)vptr + Size; 9363 while (vptr < endptr) { 9364 *vptr = 0; vptr++; 9365 } 9366 #endif 9367 return Pointer; 9368 } 9369 9370 #if defined(_M_AMD64) 9371 FORCEINLINE 9372 BOOLEAN 9373 RtlCheckBit( 9374 IN PRTL_BITMAP BitMapHeader, 9375 IN ULONG BitPosition) 9376 { 9377 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); 9378 } 9379 #else 9380 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) 9381 #endif /* defined(_M_AMD64) */ 9382 9383 #define RtlLargeIntegerGreaterThan(X,Y) ( \ 9384 (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ 9385 ((X).HighPart > (Y).HighPart) \ 9386 ) 9387 9388 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ 9389 (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ 9390 ((X).HighPart > (Y).HighPart) \ 9391 ) 9392 9393 #define RtlLargeIntegerNotEqualTo(X,Y) ( \ 9394 (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ 9395 ) 9396 9397 #define RtlLargeIntegerLessThan(X,Y) ( \ 9398 (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ 9399 ((X).HighPart < (Y).HighPart) \ 9400 ) 9401 9402 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ 9403 (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ 9404 ((X).HighPart < (Y).HighPart) \ 9405 ) 9406 9407 #define RtlLargeIntegerGreaterThanZero(X) ( \ 9408 (((X).HighPart == 0) && ((X).LowPart > 0)) || \ 9409 ((X).HighPart > 0 ) \ 9410 ) 9411 9412 #define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) 9413 9414 #define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) 9415 9416 #define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) 9417 9418 #define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) 9419 9420 #define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) 9421 9422 #endif /* !defined(MIDL_PASS) */ 9423 9424 /* Byte Swap Functions */ 9425 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \ 9426 ((defined(_M_AMD64) || defined(_M_IA64)) \ 9427 && (_MSC_FULL_VER > 13009175 || defined(__GNUC__))) 9428 9429 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x)) 9430 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x)) 9431 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x)) 9432 9433 #endif 9434 9435 #if DBG 9436 9437 #define ASSERT(exp) \ 9438 (VOID)((!(exp)) ? \ 9439 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE) 9440 9441 #define ASSERTMSG(msg, exp) \ 9442 (VOID)((!(exp)) ? \ 9443 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ), FALSE : TRUE) 9444 9445 #define RTL_SOFT_ASSERT(exp) \ 9446 (VOID)((!(exp)) ? \ 9447 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE) 9448 9449 #define RTL_SOFT_ASSERTMSG(msg, exp) \ 9450 (VOID)((!(exp)) ? \ 9451 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE) 9452 9453 #define RTL_VERIFY(exp) ASSERT(exp) 9454 #define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp) 9455 9456 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp) 9457 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp) 9458 9459 #if defined(_MSC_VER) 9460 9461 #define NT_ASSERT(exp) \ 9462 ((!(exp)) ? \ 9463 (__annotation(L"Debug", L"AssertFail", L#exp), \ 9464 DbgRaiseAssertionFailure(), FALSE) : TRUE) 9465 9466 #define NT_ASSERTMSG(msg, exp) \ 9467 ((!(exp)) ? \ 9468 (__annotation(L"Debug", L"AssertFail", L##msg), \ 9469 DbgRaiseAssertionFailure(), FALSE) : TRUE) 9470 9471 #define NT_ASSERTMSGW(msg, exp) \ 9472 ((!(exp)) ? \ 9473 (__annotation(L"Debug", L"AssertFail", msg), \ 9474 DbgRaiseAssertionFailure(), FALSE) : TRUE) 9475 9476 #define NT_VERIFY NT_ASSERT 9477 #define NT_VERIFYMSG NT_ASSERTMSG 9478 #define NT_VERIFYMSGW NT_ASSERTMSGW 9479 9480 #else 9481 9482 /* GCC doesn't support __annotation (nor PDB) */ 9483 #define NT_ASSERT(exp) \ 9484 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE) 9485 9486 #define NT_ASSERTMSG NT_ASSERT 9487 #define NT_ASSERTMSGW NT_ASSERT 9488 9489 #endif 9490 9491 #else /* !DBG */ 9492 9493 #define ASSERT(exp) ((VOID) 0) 9494 #define ASSERTMSG(msg, exp) ((VOID) 0) 9495 9496 #define RTL_SOFT_ASSERT(exp) ((VOID) 0) 9497 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0) 9498 9499 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE) 9500 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) 9501 9502 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE) 9503 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) 9504 9505 #define NT_ASSERT(exp) ((VOID)0) 9506 #define NT_ASSERTMSG(msg, exp) ((VOID)0) 9507 #define NT_ASSERTMSGW(msg, exp) ((VOID)0) 9508 9509 #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) 9510 #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) 9511 #define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) 9512 9513 #endif /* DBG */ 9514 9515 #define InitializeListHead32(ListHead) (\ 9516 (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) 9517 9518 #if !defined(_WINBASE_) 9519 9520 #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) 9521 9522 NTKERNELAPI 9523 VOID 9524 InitializeSListHead( 9525 OUT PSLIST_HEADER SListHead); 9526 9527 #else 9528 9529 FORCEINLINE 9530 VOID 9531 InitializeSListHead( 9532 OUT PSLIST_HEADER SListHead) 9533 { 9534 #if defined(_IA64_) 9535 ULONG64 FeatureBits; 9536 #endif 9537 9538 #if defined(_WIN64) 9539 if (((ULONG_PTR)SListHead & 0xf) != 0) { 9540 RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); 9541 } 9542 #endif 9543 RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); 9544 #if defined(_IA64_) 9545 FeatureBits = __getReg(CV_IA64_CPUID4); 9546 if ((FeatureBits & KF_16BYTE_INSTR) != 0) { 9547 SListHead->Header16.HeaderType = 1; 9548 SListHead->Header16.Init = 1; 9549 } 9550 #endif 9551 } 9552 9553 #endif 9554 9555 #if defined(_WIN64) 9556 9557 #define InterlockedPopEntrySList(Head) \ 9558 ExpInterlockedPopEntrySList(Head) 9559 9560 #define InterlockedPushEntrySList(Head, Entry) \ 9561 ExpInterlockedPushEntrySList(Head, Entry) 9562 9563 #define InterlockedFlushSList(Head) \ 9564 ExpInterlockedFlushSList(Head) 9565 9566 #define QueryDepthSList(Head) \ 9567 ExQueryDepthSList(Head) 9568 9569 #else /* !defined(_WIN64) */ 9570 9571 NTKERNELAPI 9572 PSLIST_ENTRY 9573 FASTCALL 9574 InterlockedPopEntrySList( 9575 IN PSLIST_HEADER ListHead); 9576 9577 NTKERNELAPI 9578 PSLIST_ENTRY 9579 FASTCALL 9580 InterlockedPushEntrySList( 9581 IN PSLIST_HEADER ListHead, 9582 IN PSLIST_ENTRY ListEntry); 9583 9584 #define InterlockedFlushSList(ListHead) \ 9585 ExInterlockedFlushSList(ListHead) 9586 9587 #define QueryDepthSList(Head) \ 9588 ExQueryDepthSList(Head) 9589 9590 #endif /* !defined(_WIN64) */ 9591 9592 #endif /* !defined(_WINBASE_) */ 9593 9594 #define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) 9595 #define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) 9596 #define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ 9597 ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) 9598 #define RTL_CONTEXT_OFFSET(Context, Chunk) \ 9599 RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) 9600 #define RTL_CONTEXT_LENGTH(Context, Chunk) \ 9601 RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) 9602 #define RTL_CONTEXT_CHUNK(Context, Chunk) \ 9603 RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ 9604 (PCONTEXT_EX)(Context + 1), \ 9605 Chunk) 9606 9607 BOOLEAN 9608 RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( 9609 IN ULONG Version); 9610 9611 BOOLEAN 9612 RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( 9613 IN ULONG Version); 9614 9615 #ifndef RtlIsNtDdiVersionAvailable 9616 #define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable 9617 #endif 9618 9619 #ifndef RtlIsServicePackVersionInstalled 9620 #define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled 9621 #endif 9622 9623 #define RtlInterlockedSetBits(Flags, Flag) \ 9624 InterlockedOr((PLONG)(Flags), Flag) 9625 9626 #define RtlInterlockedAndBits(Flags, Flag) \ 9627 InterlockedAnd((PLONG)(Flags), Flag) 9628 9629 #define RtlInterlockedClearBits(Flags, Flag) \ 9630 RtlInterlockedAndBits(Flags, ~(Flag)) 9631 9632 #define RtlInterlockedXorBits(Flags, Flag) \ 9633 InterlockedXor(Flags, Flag) 9634 9635 #define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ 9636 (VOID) RtlInterlockedSetBits(Flags, Flag) 9637 9638 #define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ 9639 (VOID) RtlInterlockedAndBits(Flags, Flag) 9640 9641 #define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ 9642 RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) 9643 9644 9645 /****************************************************************************** 9646 * Kernel Functions * 9647 ******************************************************************************/ 9648 NTKERNELAPI 9649 VOID 9650 NTAPI 9651 KeInitializeEvent( 9652 OUT PRKEVENT Event, 9653 IN EVENT_TYPE Type, 9654 IN BOOLEAN State); 9655 9656 NTKERNELAPI 9657 VOID 9658 NTAPI 9659 KeClearEvent( 9660 IN OUT PRKEVENT Event); 9661 9662 #if (NTDDI_VERSION >= NTDDI_WIN2K) 9663 9664 #if defined(_NTDDK_) || defined(_NTIFS_) 9665 NTKERNELAPI 9666 VOID 9667 NTAPI 9668 ProbeForRead( 9669 IN CONST VOID *Address, /* CONST is added */ 9670 IN SIZE_T Length, 9671 IN ULONG Alignment); 9672 #endif /* defined(_NTDDK_) || defined(_NTIFS_) */ 9673 9674 NTKERNELAPI 9675 VOID 9676 NTAPI 9677 ProbeForWrite( 9678 IN PVOID Address, 9679 IN SIZE_T Length, 9680 IN ULONG Alignment); 9681 9682 #if defined(SINGLE_GROUP_LEGACY_API) 9683 9684 NTKERNELAPI 9685 VOID 9686 NTAPI 9687 KeRevertToUserAffinityThread(VOID); 9688 9689 NTKERNELAPI 9690 VOID 9691 NTAPI 9692 KeSetSystemAffinityThread( 9693 IN KAFFINITY Affinity); 9694 9695 NTKERNELAPI 9696 VOID 9697 NTAPI 9698 KeSetTargetProcessorDpc( 9699 IN OUT PRKDPC Dpc, 9700 IN CCHAR Number); 9701 9702 NTKERNELAPI 9703 KAFFINITY 9704 NTAPI 9705 KeQueryActiveProcessors(VOID); 9706 #endif /* defined(SINGLE_GROUP_LEGACY_API) */ 9707 9708 #if !defined(_M_AMD64) 9709 NTKERNELAPI 9710 ULONGLONG 9711 NTAPI 9712 KeQueryInterruptTime(VOID); 9713 9714 NTKERNELAPI 9715 VOID 9716 NTAPI 9717 KeQuerySystemTime( 9718 OUT PLARGE_INTEGER CurrentTime); 9719 #endif /* !_M_AMD64 */ 9720 9721 #if !defined(_X86_) && !defined(_M_ARM) 9722 NTKERNELAPI 9723 KIRQL 9724 NTAPI 9725 KeAcquireSpinLockRaiseToDpc( 9726 IN OUT PKSPIN_LOCK SpinLock); 9727 9728 #define KeAcquireSpinLock(SpinLock, OldIrql) \ 9729 *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) 9730 9731 NTKERNELAPI 9732 VOID 9733 NTAPI 9734 KeAcquireSpinLockAtDpcLevel( 9735 IN OUT PKSPIN_LOCK SpinLock); 9736 9737 NTKERNELAPI 9738 VOID 9739 NTAPI 9740 KeReleaseSpinLock( 9741 IN OUT PKSPIN_LOCK SpinLock, 9742 IN KIRQL NewIrql); 9743 9744 NTKERNELAPI 9745 VOID 9746 NTAPI 9747 KeReleaseSpinLockFromDpcLevel( 9748 IN OUT PKSPIN_LOCK SpinLock); 9749 #endif /* !_X86_ */ 9750 9751 #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) 9752 NTKERNELAPI 9753 VOID 9754 NTAPI 9755 KeInitializeSpinLock( 9756 IN PKSPIN_LOCK SpinLock); 9757 #else 9758 FORCEINLINE 9759 VOID 9760 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock) 9761 { 9762 /* Clear the lock */ 9763 *SpinLock = 0; 9764 } 9765 #endif 9766 9767 NTKERNELAPI 9768 DECLSPEC_NORETURN 9769 VOID 9770 NTAPI 9771 KeBugCheckEx( 9772 IN ULONG BugCheckCode, 9773 IN ULONG_PTR BugCheckParameter1, 9774 IN ULONG_PTR BugCheckParameter2, 9775 IN ULONG_PTR BugCheckParameter3, 9776 IN ULONG_PTR BugCheckParameter4); 9777 9778 NTKERNELAPI 9779 BOOLEAN 9780 NTAPI 9781 KeCancelTimer( 9782 IN OUT PKTIMER); 9783 9784 NTKERNELAPI 9785 NTSTATUS 9786 NTAPI 9787 KeDelayExecutionThread( 9788 IN KPROCESSOR_MODE WaitMode, 9789 IN BOOLEAN Alertable, 9790 IN PLARGE_INTEGER Interval); 9791 9792 NTKERNELAPI 9793 BOOLEAN 9794 NTAPI 9795 KeDeregisterBugCheckCallback( 9796 IN OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord); 9797 9798 NTKERNELAPI 9799 VOID 9800 NTAPI 9801 KeEnterCriticalRegion(VOID); 9802 9803 NTKERNELAPI 9804 VOID 9805 NTAPI 9806 KeInitializeDeviceQueue( 9807 OUT PKDEVICE_QUEUE DeviceQueue); 9808 9809 NTKERNELAPI 9810 VOID 9811 NTAPI 9812 KeInitializeDpc( 9813 OUT PRKDPC Dpc, 9814 IN PKDEFERRED_ROUTINE DeferredRoutine, 9815 IN PVOID DeferredContext OPTIONAL); 9816 9817 NTKERNELAPI 9818 VOID 9819 NTAPI 9820 KeInitializeMutex( 9821 OUT PRKMUTEX Mutex, 9822 IN ULONG Level); 9823 9824 NTKERNELAPI 9825 VOID 9826 NTAPI 9827 KeInitializeSemaphore( 9828 OUT PRKSEMAPHORE Semaphore, 9829 IN LONG Count, 9830 IN LONG Limit); 9831 9832 NTKERNELAPI 9833 VOID 9834 NTAPI 9835 KeInitializeTimer( 9836 OUT PKTIMER Timer); 9837 9838 NTKERNELAPI 9839 VOID 9840 NTAPI 9841 KeInitializeTimerEx( 9842 OUT PKTIMER Timer, 9843 IN TIMER_TYPE Type); 9844 9845 NTKERNELAPI 9846 BOOLEAN 9847 NTAPI 9848 KeInsertByKeyDeviceQueue( 9849 IN OUT PKDEVICE_QUEUE DeviceQueue, 9850 IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, 9851 IN ULONG SortKey); 9852 9853 NTKERNELAPI 9854 BOOLEAN 9855 NTAPI 9856 KeInsertDeviceQueue( 9857 IN OUT PKDEVICE_QUEUE DeviceQueue, 9858 IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); 9859 9860 NTKERNELAPI 9861 BOOLEAN 9862 NTAPI 9863 KeInsertQueueDpc( 9864 IN OUT PRKDPC Dpc, 9865 IN PVOID SystemArgument1 OPTIONAL, 9866 IN PVOID SystemArgument2 OPTIONAL); 9867 9868 NTKERNELAPI 9869 VOID 9870 NTAPI 9871 KeLeaveCriticalRegion(VOID); 9872 9873 NTHALAPI 9874 LARGE_INTEGER 9875 NTAPI 9876 KeQueryPerformanceCounter( 9877 OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); 9878 9879 NTKERNELAPI 9880 KPRIORITY 9881 NTAPI 9882 KeQueryPriorityThread( 9883 IN PRKTHREAD Thread); 9884 9885 NTKERNELAPI 9886 ULONG 9887 NTAPI 9888 KeQueryTimeIncrement(VOID); 9889 9890 NTKERNELAPI 9891 LONG 9892 NTAPI 9893 KeReadStateEvent( 9894 IN PRKEVENT Event); 9895 9896 NTKERNELAPI 9897 LONG 9898 NTAPI 9899 KeReadStateMutex( 9900 IN PRKMUTEX Mutex); 9901 9902 NTKERNELAPI 9903 LONG 9904 NTAPI 9905 KeReadStateSemaphore( 9906 IN PRKSEMAPHORE Semaphore); 9907 9908 NTKERNELAPI 9909 BOOLEAN 9910 NTAPI 9911 KeReadStateTimer( 9912 IN PKTIMER Timer); 9913 9914 NTKERNELAPI 9915 BOOLEAN 9916 NTAPI 9917 KeRegisterBugCheckCallback( 9918 OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, 9919 IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, 9920 IN PVOID Buffer, 9921 IN ULONG Length, 9922 IN PUCHAR Component); 9923 9924 NTKERNELAPI 9925 LONG 9926 NTAPI 9927 KeReleaseMutex( 9928 IN OUT PRKMUTEX Mutex, 9929 IN BOOLEAN Wait); 9930 9931 NTKERNELAPI 9932 LONG 9933 NTAPI 9934 KeReleaseSemaphore( 9935 IN OUT PRKSEMAPHORE Semaphore, 9936 IN KPRIORITY Increment, 9937 IN LONG Adjustment, 9938 IN BOOLEAN Wait); 9939 9940 NTKERNELAPI 9941 PKDEVICE_QUEUE_ENTRY 9942 NTAPI 9943 KeRemoveByKeyDeviceQueue( 9944 IN OUT PKDEVICE_QUEUE DeviceQueue, 9945 IN ULONG SortKey); 9946 9947 NTKERNELAPI 9948 PKDEVICE_QUEUE_ENTRY 9949 NTAPI 9950 KeRemoveDeviceQueue( 9951 IN OUT PKDEVICE_QUEUE DeviceQueue); 9952 9953 NTKERNELAPI 9954 BOOLEAN 9955 NTAPI 9956 KeRemoveEntryDeviceQueue( 9957 IN OUT PKDEVICE_QUEUE DeviceQueue, 9958 IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); 9959 9960 NTKERNELAPI 9961 BOOLEAN 9962 NTAPI 9963 KeRemoveQueueDpc( 9964 IN OUT PRKDPC Dpc); 9965 9966 NTKERNELAPI 9967 LONG 9968 NTAPI 9969 KeResetEvent( 9970 IN OUT PRKEVENT Event); 9971 9972 NTKERNELAPI 9973 LONG 9974 NTAPI 9975 KeSetEvent( 9976 IN OUT PRKEVENT Event, 9977 IN KPRIORITY Increment, 9978 IN BOOLEAN Wait); 9979 9980 NTKERNELAPI 9981 VOID 9982 NTAPI 9983 KeSetImportanceDpc( 9984 IN OUT PRKDPC Dpc, 9985 IN KDPC_IMPORTANCE Importance); 9986 9987 NTKERNELAPI 9988 KPRIORITY 9989 NTAPI 9990 KeSetPriorityThread( 9991 IN OUT PKTHREAD Thread, 9992 IN KPRIORITY Priority); 9993 9994 NTKERNELAPI 9995 BOOLEAN 9996 NTAPI 9997 KeSetTimer( 9998 IN OUT PKTIMER Timer, 9999 IN LARGE_INTEGER DueTime, 10000 IN PKDPC Dpc OPTIONAL); 10001 10002 NTKERNELAPI 10003 BOOLEAN 10004 NTAPI 10005 KeSetTimerEx( 10006 IN OUT PKTIMER Timer, 10007 IN LARGE_INTEGER DueTime, 10008 IN LONG Period OPTIONAL, 10009 IN PKDPC Dpc OPTIONAL); 10010 10011 NTHALAPI 10012 VOID 10013 NTAPI 10014 KeStallExecutionProcessor( 10015 IN ULONG MicroSeconds); 10016 10017 NTKERNELAPI 10018 BOOLEAN 10019 NTAPI 10020 KeSynchronizeExecution( 10021 IN OUT PKINTERRUPT Interrupt, 10022 IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, 10023 IN PVOID SynchronizeContext OPTIONAL); 10024 10025 NTKERNELAPI 10026 NTSTATUS 10027 NTAPI 10028 KeWaitForMultipleObjects( 10029 IN ULONG Count, 10030 IN PVOID Object[], 10031 IN WAIT_TYPE WaitType, 10032 IN KWAIT_REASON WaitReason, 10033 IN KPROCESSOR_MODE WaitMode, 10034 IN BOOLEAN Alertable, 10035 IN PLARGE_INTEGER Timeout OPTIONAL, 10036 OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); 10037 10038 #define KeWaitForMutexObject KeWaitForSingleObject 10039 10040 NTKERNELAPI 10041 NTSTATUS 10042 NTAPI 10043 KeWaitForSingleObject( 10044 IN PVOID Object, 10045 IN KWAIT_REASON WaitReason, 10046 IN KPROCESSOR_MODE WaitMode, 10047 IN BOOLEAN Alertable, 10048 IN PLARGE_INTEGER Timeout OPTIONAL); 10049 10050 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 10051 10052 #if (NTDDI_VERSION >= NTDDI_WINXP) 10053 10054 _DECL_HAL_KE_IMPORT 10055 VOID 10056 FASTCALL 10057 KeAcquireInStackQueuedSpinLock( 10058 IN OUT PKSPIN_LOCK SpinLock, 10059 OUT PKLOCK_QUEUE_HANDLE LockHandle); 10060 10061 NTKERNELAPI 10062 VOID 10063 FASTCALL 10064 KeAcquireInStackQueuedSpinLockAtDpcLevel( 10065 IN OUT PKSPIN_LOCK SpinLock, 10066 OUT PKLOCK_QUEUE_HANDLE LockHandle); 10067 10068 NTKERNELAPI 10069 KIRQL 10070 NTAPI 10071 KeAcquireInterruptSpinLock( 10072 IN OUT PKINTERRUPT Interrupt); 10073 10074 NTKERNELAPI 10075 BOOLEAN 10076 NTAPI 10077 KeAreApcsDisabled(VOID); 10078 10079 NTKERNELAPI 10080 ULONG 10081 NTAPI 10082 KeGetRecommendedSharedDataAlignment(VOID); 10083 10084 NTKERNELAPI 10085 ULONG 10086 NTAPI 10087 KeQueryRuntimeThread( 10088 IN PKTHREAD Thread, 10089 OUT PULONG UserTime); 10090 10091 NTKERNELAPI 10092 VOID 10093 FASTCALL 10094 KeReleaseInStackQueuedSpinLockFromDpcLevel( 10095 IN PKLOCK_QUEUE_HANDLE LockHandle); 10096 10097 NTKERNELAPI 10098 VOID 10099 NTAPI 10100 KeReleaseInterruptSpinLock( 10101 IN OUT PKINTERRUPT Interrupt, 10102 IN KIRQL OldIrql); 10103 10104 NTKERNELAPI 10105 PKDEVICE_QUEUE_ENTRY 10106 NTAPI 10107 KeRemoveByKeyDeviceQueueIfBusy( 10108 IN OUT PKDEVICE_QUEUE DeviceQueue, 10109 IN ULONG SortKey); 10110 10111 _DECL_HAL_KE_IMPORT 10112 VOID 10113 FASTCALL 10114 KeReleaseInStackQueuedSpinLock( 10115 IN PKLOCK_QUEUE_HANDLE LockHandle); 10116 10117 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 10118 10119 #if (NTDDI_VERSION >= NTDDI_WINXPSP1) 10120 10121 NTKERNELAPI 10122 BOOLEAN 10123 NTAPI 10124 KeDeregisterBugCheckReasonCallback( 10125 IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord); 10126 10127 NTKERNELAPI 10128 BOOLEAN 10129 NTAPI 10130 KeRegisterBugCheckReasonCallback( 10131 OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord, 10132 IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine, 10133 IN KBUGCHECK_CALLBACK_REASON Reason, 10134 IN PUCHAR Component); 10135 10136 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ 10137 10138 #if (NTDDI_VERSION >= NTDDI_WINXPSP2) 10139 NTKERNELAPI 10140 VOID 10141 NTAPI 10142 KeFlushQueuedDpcs(VOID); 10143 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ 10144 #if (NTDDI_VERSION >= NTDDI_WS03) 10145 10146 NTKERNELAPI 10147 PVOID 10148 NTAPI 10149 KeRegisterNmiCallback( 10150 IN PNMI_CALLBACK CallbackRoutine, 10151 IN PVOID Context OPTIONAL); 10152 10153 NTKERNELAPI 10154 NTSTATUS 10155 NTAPI 10156 KeDeregisterNmiCallback( 10157 IN PVOID Handle); 10158 10159 NTKERNELAPI 10160 VOID 10161 NTAPI 10162 KeInitializeThreadedDpc( 10163 OUT PRKDPC Dpc, 10164 IN PKDEFERRED_ROUTINE DeferredRoutine, 10165 IN PVOID DeferredContext OPTIONAL); 10166 10167 NTKERNELAPI 10168 ULONG_PTR 10169 NTAPI 10170 KeIpiGenericCall( 10171 IN PKIPI_BROADCAST_WORKER BroadcastFunction, 10172 IN ULONG_PTR Context); 10173 10174 NTKERNELAPI 10175 KIRQL 10176 FASTCALL 10177 KeAcquireSpinLockForDpc( 10178 IN OUT PKSPIN_LOCK SpinLock); 10179 10180 NTKERNELAPI 10181 VOID 10182 FASTCALL 10183 KeReleaseSpinLockForDpc( 10184 IN OUT PKSPIN_LOCK SpinLock, 10185 IN KIRQL OldIrql); 10186 10187 NTKERNELAPI 10188 BOOLEAN 10189 FASTCALL 10190 KeTestSpinLock( 10191 IN PKSPIN_LOCK SpinLock); 10192 10193 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ 10194 10195 #if (NTDDI_VERSION >= NTDDI_WS03SP1) 10196 10197 NTKERNELAPI 10198 BOOLEAN 10199 FASTCALL 10200 KeTryToAcquireSpinLockAtDpcLevel( 10201 IN OUT PKSPIN_LOCK SpinLock); 10202 10203 NTKERNELAPI 10204 BOOLEAN 10205 NTAPI 10206 KeAreAllApcsDisabled(VOID); 10207 10208 NTKERNELAPI 10209 VOID 10210 FASTCALL 10211 KeAcquireGuardedMutex( 10212 IN OUT PKGUARDED_MUTEX GuardedMutex); 10213 10214 NTKERNELAPI 10215 VOID 10216 FASTCALL 10217 KeAcquireGuardedMutexUnsafe( 10218 IN OUT PKGUARDED_MUTEX GuardedMutex); 10219 10220 NTKERNELAPI 10221 VOID 10222 NTAPI 10223 KeEnterGuardedRegion(VOID); 10224 10225 NTKERNELAPI 10226 VOID 10227 NTAPI 10228 KeLeaveGuardedRegion(VOID); 10229 10230 NTKERNELAPI 10231 VOID 10232 FASTCALL 10233 KeInitializeGuardedMutex( 10234 OUT PKGUARDED_MUTEX GuardedMutex); 10235 10236 NTKERNELAPI 10237 VOID 10238 FASTCALL 10239 KeReleaseGuardedMutexUnsafe( 10240 IN OUT PKGUARDED_MUTEX GuardedMutex); 10241 10242 NTKERNELAPI 10243 VOID 10244 FASTCALL 10245 KeReleaseGuardedMutex( 10246 IN OUT PKGUARDED_MUTEX GuardedMutex); 10247 10248 NTKERNELAPI 10249 BOOLEAN 10250 FASTCALL 10251 KeTryToAcquireGuardedMutex( 10252 IN OUT PKGUARDED_MUTEX GuardedMutex); 10253 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ 10254 10255 #if (NTDDI_VERSION >= NTDDI_VISTA) 10256 NTKERNELAPI 10257 VOID 10258 FASTCALL 10259 KeAcquireInStackQueuedSpinLockForDpc( 10260 IN OUT PKSPIN_LOCK SpinLock, 10261 OUT PKLOCK_QUEUE_HANDLE LockHandle); 10262 10263 NTKERNELAPI 10264 VOID 10265 FASTCALL 10266 KeReleaseInStackQueuedSpinLockForDpc( 10267 IN PKLOCK_QUEUE_HANDLE LockHandle); 10268 10269 NTKERNELAPI 10270 NTSTATUS 10271 NTAPI 10272 KeQueryDpcWatchdogInformation( 10273 OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); 10274 #if defined(SINGLE_GROUP_LEGACY_API) 10275 10276 NTKERNELAPI 10277 KAFFINITY 10278 NTAPI 10279 KeSetSystemAffinityThreadEx( 10280 IN KAFFINITY Affinity); 10281 10282 NTKERNELAPI 10283 VOID 10284 NTAPI 10285 KeRevertToUserAffinityThreadEx( 10286 IN KAFFINITY Affinity); 10287 10288 NTKERNELAPI 10289 ULONG 10290 NTAPI 10291 KeQueryActiveProcessorCount( 10292 OUT PKAFFINITY ActiveProcessors OPTIONAL); 10293 10294 NTKERNELAPI 10295 ULONG 10296 NTAPI 10297 KeQueryMaximumProcessorCount(VOID); 10298 #endif /* SINGLE_GROUP_LEGACY_API */ 10299 10300 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 10301 10302 #if (NTDDI_VERSION >= NTDDI_WS08) 10303 10304 PVOID 10305 KeRegisterProcessorChangeCallback( 10306 IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction, 10307 IN PVOID CallbackContext OPTIONAL, 10308 IN ULONG Flags); 10309 10310 VOID 10311 KeDeregisterProcessorChangeCallback( 10312 IN PVOID CallbackHandle); 10313 10314 #endif /* (NTDDI_VERSION >= NTDDI_WS08) */ 10315 #if (NTDDI_VERSION >= NTDDI_WIN7) 10316 10317 ULONG64 10318 NTAPI 10319 KeQueryTotalCycleTimeProcess( 10320 IN OUT PKPROCESS Process, 10321 OUT PULONG64 CycleTimeStamp); 10322 10323 ULONG64 10324 NTAPI 10325 KeQueryTotalCycleTimeThread( 10326 IN OUT PKTHREAD Thread, 10327 OUT PULONG64 CycleTimeStamp); 10328 10329 NTKERNELAPI 10330 NTSTATUS 10331 NTAPI 10332 KeSetTargetProcessorDpcEx( 10333 IN OUT PKDPC Dpc, 10334 IN PPROCESSOR_NUMBER ProcNumber); 10335 10336 NTKERNELAPI 10337 VOID 10338 NTAPI 10339 KeSetSystemGroupAffinityThread( 10340 IN PGROUP_AFFINITY Affinity, 10341 OUT PGROUP_AFFINITY PreviousAffinity OPTIONAL); 10342 10343 NTKERNELAPI 10344 VOID 10345 NTAPI 10346 KeRevertToUserGroupAffinityThread( 10347 IN PGROUP_AFFINITY PreviousAffinity); 10348 10349 NTKERNELAPI 10350 BOOLEAN 10351 NTAPI 10352 KeSetCoalescableTimer( 10353 IN OUT PKTIMER Timer, 10354 IN LARGE_INTEGER DueTime, 10355 IN ULONG Period, 10356 IN ULONG TolerableDelay, 10357 IN PKDPC Dpc OPTIONAL); 10358 10359 NTKERNELAPI 10360 ULONGLONG 10361 NTAPI 10362 KeQueryUnbiasedInterruptTime(VOID); 10363 10364 NTKERNELAPI 10365 ULONG 10366 NTAPI 10367 KeQueryActiveProcessorCountEx( 10368 IN USHORT GroupNumber); 10369 10370 NTKERNELAPI 10371 ULONG 10372 NTAPI 10373 KeQueryMaximumProcessorCountEx( 10374 IN USHORT GroupNumber); 10375 10376 NTKERNELAPI 10377 USHORT 10378 NTAPI 10379 KeQueryActiveGroupCount(VOID); 10380 10381 NTKERNELAPI 10382 USHORT 10383 NTAPI 10384 KeQueryMaximumGroupCount(VOID); 10385 10386 NTKERNELAPI 10387 KAFFINITY 10388 NTAPI 10389 KeQueryGroupAffinity( 10390 IN USHORT GroupNumber); 10391 10392 NTKERNELAPI 10393 ULONG 10394 NTAPI 10395 KeGetCurrentProcessorNumberEx( 10396 OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); 10397 10398 NTKERNELAPI 10399 VOID 10400 NTAPI 10401 KeQueryNodeActiveAffinity( 10402 IN USHORT NodeNumber, 10403 OUT PGROUP_AFFINITY Affinity OPTIONAL, 10404 OUT PUSHORT Count OPTIONAL); 10405 10406 NTKERNELAPI 10407 USHORT 10408 NTAPI 10409 KeQueryNodeMaximumProcessorCount( 10410 IN USHORT NodeNumber); 10411 10412 NTKERNELAPI 10413 USHORT 10414 NTAPI 10415 KeQueryHighestNodeNumber(VOID); 10416 10417 NTKERNELAPI 10418 USHORT 10419 NTAPI 10420 KeGetCurrentNodeNumber(VOID); 10421 10422 NTKERNELAPI 10423 NTSTATUS 10424 NTAPI 10425 KeQueryLogicalProcessorRelationship( 10426 IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, 10427 IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, 10428 OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, 10429 IN OUT PULONG Length); 10430 10431 NTKERNELAPI 10432 NTSTATUS 10433 NTAPI 10434 KeSaveExtendedProcessorState( 10435 IN ULONG64 Mask, 10436 OUT PXSTATE_SAVE XStateSave); 10437 10438 NTKERNELAPI 10439 VOID 10440 NTAPI 10441 KeRestoreExtendedProcessorState( 10442 IN PXSTATE_SAVE XStateSave); 10443 10444 NTSTATUS 10445 NTAPI 10446 KeGetProcessorNumberFromIndex( 10447 IN ULONG ProcIndex, 10448 OUT PPROCESSOR_NUMBER ProcNumber); 10449 10450 ULONG 10451 NTAPI 10452 KeGetProcessorIndexFromNumber( 10453 IN PPROCESSOR_NUMBER ProcNumber); 10454 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 10455 #if !defined(_IA64_) 10456 NTHALAPI 10457 VOID 10458 NTAPI 10459 KeFlushWriteBuffer(VOID); 10460 #endif 10461 10462 /* VOID 10463 * KeInitializeCallbackRecord( 10464 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord) 10465 */ 10466 #define KeInitializeCallbackRecord(CallbackRecord) \ 10467 CallbackRecord->State = BufferEmpty; 10468 10469 #if DBG 10470 10471 #if (NTDDI_VERSION >= NTDDI_VISTA) 10472 #define PAGED_ASSERT( exp ) NT_ASSERT( exp ) 10473 #else 10474 #define PAGED_ASSERT( exp ) ASSERT( exp ) 10475 #endif 10476 10477 #define PAGED_CODE() { \ 10478 if (KeGetCurrentIrql() > APC_LEVEL) { \ 10479 KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \ 10480 PAGED_ASSERT(FALSE); \ 10481 } \ 10482 } 10483 10484 #else 10485 10486 #define PAGED_CODE() 10487 10488 #endif /* DBG */ 10489 10490 #define PAGED_CODE_LOCKED() NOP_FUNCTION; 10491 10492 /****************************************************************************** 10493 * Memory manager Functions * 10494 ******************************************************************************/ 10495 /* Alignment Macros */ 10496 #define ALIGN_DOWN_BY(size, align) \ 10497 ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) 10498 10499 #define ALIGN_UP_BY(size, align) \ 10500 (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align)) 10501 10502 #define ALIGN_DOWN_POINTER_BY(ptr, align) \ 10503 ((PVOID)ALIGN_DOWN_BY(ptr, align)) 10504 10505 #define ALIGN_UP_POINTER_BY(ptr, align) \ 10506 ((PVOID)ALIGN_UP_BY(ptr, align)) 10507 10508 #define ALIGN_DOWN(size, type) \ 10509 ALIGN_DOWN_BY(size, sizeof(type)) 10510 10511 #define ALIGN_UP(size, type) \ 10512 ALIGN_UP_BY(size, sizeof(type)) 10513 10514 #define ALIGN_DOWN_POINTER(ptr, type) \ 10515 ALIGN_DOWN_POINTER_BY(ptr, sizeof(type)) 10516 10517 #define ALIGN_UP_POINTER(ptr, type) \ 10518 ALIGN_UP_POINTER_BY(ptr, sizeof(type)) 10519 10520 #ifndef FIELD_OFFSET 10521 #define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field)) 10522 #endif 10523 10524 #ifndef FIELD_SIZE 10525 #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) 10526 #endif 10527 10528 #define POOL_TAGGING 1 10529 10530 #if DBG 10531 #define IF_DEBUG if (TRUE) 10532 #else 10533 #define IF_DEBUG if (FALSE) 10534 #endif /* DBG */ 10535 10536 /* ULONG 10537 * BYTE_OFFSET( 10538 * IN PVOID Va) 10539 */ 10540 #define BYTE_OFFSET(Va) \ 10541 ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1))) 10542 10543 /* ULONG 10544 * BYTES_TO_PAGES( 10545 * IN ULONG Size) 10546 * 10547 * Note: This needs to be like this to avoid overflows! 10548 */ 10549 #define BYTES_TO_PAGES(Size) \ 10550 (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) 10551 10552 /* PVOID 10553 * PAGE_ALIGN( 10554 * IN PVOID Va) 10555 */ 10556 #define PAGE_ALIGN(Va) \ 10557 ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1))) 10558 10559 /* ULONG_PTR 10560 * ROUND_TO_PAGES( 10561 * IN ULONG_PTR Size) 10562 */ 10563 #define ROUND_TO_PAGES(Size) \ 10564 (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) 10565 10566 /* ULONG 10567 * ADDRESS_AND_SIZE_TO_SPAN_PAGES( 10568 * IN PVOID Va, 10569 * IN ULONG Size) 10570 */ 10571 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \ 10572 ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ 10573 + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) 10574 10575 #define COMPUTE_PAGES_SPANNED(Va, Size) \ 10576 ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) 10577 10578 /* 10579 * ULONG 10580 * MmGetMdlByteCount( 10581 * IN PMDL Mdl) 10582 */ 10583 #define MmGetMdlByteCount(_Mdl) \ 10584 ((_Mdl)->ByteCount) 10585 10586 /* 10587 * ULONG 10588 * MmGetMdlByteOffset( 10589 * IN PMDL Mdl) 10590 */ 10591 #define MmGetMdlByteOffset(_Mdl) \ 10592 ((_Mdl)->ByteOffset) 10593 10594 #define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) 10595 10596 /* 10597 * PPFN_NUMBER 10598 * MmGetMdlPfnArray( 10599 * IN PMDL Mdl) 10600 */ 10601 #define MmGetMdlPfnArray(_Mdl) \ 10602 ((PPFN_NUMBER) ((_Mdl) + 1)) 10603 10604 /* 10605 * PVOID 10606 * MmGetMdlVirtualAddress( 10607 * IN PMDL Mdl) 10608 */ 10609 #define MmGetMdlVirtualAddress(_Mdl) \ 10610 ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset)) 10611 10612 #define MmGetProcedureAddress(Address) (Address) 10613 #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address) 10614 10615 /* PVOID MmGetSystemAddressForMdl( 10616 * IN PMDL Mdl); 10617 */ 10618 #define MmGetSystemAddressForMdl(Mdl) \ 10619 (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \ 10620 MDL_SOURCE_IS_NONPAGED_POOL)) ? \ 10621 ((Mdl)->MappedSystemVa) : \ 10622 (MmMapLockedPages((Mdl), KernelMode))) 10623 10624 /* PVOID 10625 * MmGetSystemAddressForMdlSafe( 10626 * IN PMDL Mdl, 10627 * IN MM_PAGE_PRIORITY Priority) 10628 */ 10629 #define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \ 10630 (((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \ 10631 | MDL_SOURCE_IS_NONPAGED_POOL)) ? \ 10632 (_Mdl)->MappedSystemVa : \ 10633 (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \ 10634 KernelMode, MmCached, NULL, FALSE, (_Priority))) 10635 10636 /* 10637 * VOID 10638 * MmInitializeMdl( 10639 * IN PMDL MemoryDescriptorList, 10640 * IN PVOID BaseVa, 10641 * IN SIZE_T Length) 10642 */ 10643 #define MmInitializeMdl(_MemoryDescriptorList, \ 10644 _BaseVa, \ 10645 _Length) \ 10646 { \ 10647 (_MemoryDescriptorList)->Next = (PMDL) NULL; \ 10648 (_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \ 10649 (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \ 10650 (_MemoryDescriptorList)->MdlFlags = 0; \ 10651 (_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \ 10652 (_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \ 10653 (_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \ 10654 } 10655 10656 /* 10657 * VOID 10658 * MmPrepareMdlForReuse( 10659 * IN PMDL Mdl) 10660 */ 10661 #define MmPrepareMdlForReuse(_Mdl) \ 10662 { \ 10663 if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \ 10664 ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \ 10665 MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \ 10666 } else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \ 10667 ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \ 10668 } \ 10669 } 10670 10671 #if (NTDDI_VERSION >= NTDDI_WIN2K) 10672 NTKERNELAPI 10673 PVOID 10674 NTAPI 10675 MmAllocateContiguousMemory( 10676 IN SIZE_T NumberOfBytes, 10677 IN PHYSICAL_ADDRESS HighestAcceptableAddress); 10678 10679 NTKERNELAPI 10680 PVOID 10681 NTAPI 10682 MmAllocateContiguousMemorySpecifyCache( 10683 IN SIZE_T NumberOfBytes, 10684 IN PHYSICAL_ADDRESS LowestAcceptableAddress, 10685 IN PHYSICAL_ADDRESS HighestAcceptableAddress, 10686 IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, 10687 IN MEMORY_CACHING_TYPE CacheType); 10688 10689 NTKERNELAPI 10690 PMDL 10691 NTAPI 10692 MmAllocatePagesForMdl( 10693 IN PHYSICAL_ADDRESS LowAddress, 10694 IN PHYSICAL_ADDRESS HighAddress, 10695 IN PHYSICAL_ADDRESS SkipBytes, 10696 IN SIZE_T TotalBytes); 10697 10698 NTKERNELAPI 10699 VOID 10700 NTAPI 10701 MmBuildMdlForNonPagedPool( 10702 IN OUT PMDLX MemoryDescriptorList); 10703 10704 //DECLSPEC_DEPRECATED_DDK 10705 NTKERNELAPI 10706 PMDL 10707 NTAPI 10708 MmCreateMdl( 10709 IN PMDL MemoryDescriptorList OPTIONAL, 10710 IN PVOID Base, 10711 IN SIZE_T Length); 10712 10713 NTKERNELAPI 10714 VOID 10715 NTAPI 10716 MmFreeContiguousMemory( 10717 IN PVOID BaseAddress); 10718 10719 NTKERNELAPI 10720 VOID 10721 NTAPI 10722 MmFreeContiguousMemorySpecifyCache( 10723 IN PVOID BaseAddress, 10724 IN SIZE_T NumberOfBytes, 10725 IN MEMORY_CACHING_TYPE CacheType); 10726 10727 NTKERNELAPI 10728 VOID 10729 NTAPI 10730 MmFreePagesFromMdl( 10731 IN PMDLX MemoryDescriptorList); 10732 10733 NTKERNELAPI 10734 PVOID 10735 NTAPI 10736 MmGetSystemRoutineAddress( 10737 IN PUNICODE_STRING SystemRoutineName); 10738 10739 NTKERNELAPI 10740 LOGICAL 10741 NTAPI 10742 MmIsDriverVerifying( 10743 IN struct _DRIVER_OBJECT *DriverObject); 10744 10745 NTKERNELAPI 10746 PVOID 10747 NTAPI 10748 MmLockPagableDataSection( 10749 IN PVOID AddressWithinSection); 10750 10751 NTKERNELAPI 10752 PVOID 10753 NTAPI 10754 MmMapIoSpace( 10755 IN PHYSICAL_ADDRESS PhysicalAddress, 10756 IN SIZE_T NumberOfBytes, 10757 IN MEMORY_CACHING_TYPE CacheEnable); 10758 10759 NTKERNELAPI 10760 PVOID 10761 NTAPI 10762 MmMapLockedPages( 10763 IN PMDL MemoryDescriptorList, 10764 IN KPROCESSOR_MODE AccessMode); 10765 10766 NTKERNELAPI 10767 PVOID 10768 NTAPI 10769 MmMapLockedPagesSpecifyCache( 10770 IN PMDLX MemoryDescriptorList, 10771 IN KPROCESSOR_MODE AccessMode, 10772 IN MEMORY_CACHING_TYPE CacheType, 10773 IN PVOID BaseAddress OPTIONAL, 10774 IN ULONG BugCheckOnFailure, 10775 IN MM_PAGE_PRIORITY Priority); 10776 10777 NTKERNELAPI 10778 PVOID 10779 NTAPI 10780 MmPageEntireDriver( 10781 IN PVOID AddressWithinSection); 10782 10783 NTKERNELAPI 10784 VOID 10785 NTAPI 10786 MmProbeAndLockPages( 10787 IN OUT PMDL MemoryDescriptorList, 10788 IN KPROCESSOR_MODE AccessMode, 10789 IN LOCK_OPERATION Operation); 10790 10791 NTKERNELAPI 10792 MM_SYSTEMSIZE 10793 NTAPI 10794 MmQuerySystemSize(VOID); 10795 10796 NTKERNELAPI 10797 VOID 10798 NTAPI 10799 MmResetDriverPaging( 10800 IN PVOID AddressWithinSection); 10801 10802 NTKERNELAPI 10803 SIZE_T 10804 NTAPI 10805 MmSizeOfMdl( 10806 IN PVOID Base, 10807 IN SIZE_T Length); 10808 10809 NTKERNELAPI 10810 VOID 10811 NTAPI 10812 MmUnlockPagableImageSection( 10813 IN PVOID ImageSectionHandle); 10814 10815 NTKERNELAPI 10816 VOID 10817 NTAPI 10818 MmUnlockPages( 10819 IN OUT PMDL MemoryDescriptorList); 10820 10821 NTKERNELAPI 10822 VOID 10823 NTAPI 10824 MmUnmapIoSpace( 10825 IN PVOID BaseAddress, 10826 IN SIZE_T NumberOfBytes); 10827 10828 NTKERNELAPI 10829 VOID 10830 NTAPI 10831 MmProbeAndLockProcessPages( 10832 IN OUT PMDL MemoryDescriptorList, 10833 IN PEPROCESS Process, 10834 IN KPROCESSOR_MODE AccessMode, 10835 IN LOCK_OPERATION Operation); 10836 10837 NTKERNELAPI 10838 VOID 10839 NTAPI 10840 MmUnmapLockedPages( 10841 IN PVOID BaseAddress, 10842 IN PMDL MemoryDescriptorList); 10843 10844 NTKERNELAPI 10845 PVOID 10846 NTAPI 10847 MmAllocateContiguousMemorySpecifyCacheNode( 10848 IN SIZE_T NumberOfBytes, 10849 IN PHYSICAL_ADDRESS LowestAcceptableAddress, 10850 IN PHYSICAL_ADDRESS HighestAcceptableAddress, 10851 IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, 10852 IN MEMORY_CACHING_TYPE CacheType, 10853 IN NODE_REQUIREMENT PreferredNode); 10854 10855 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 10856 10857 #if (NTDDI_VERSION >= NTDDI_WINXP) 10858 10859 NTKERNELAPI 10860 NTSTATUS 10861 NTAPI 10862 MmAdvanceMdl( 10863 IN OUT PMDL Mdl, 10864 IN ULONG NumberOfBytes); 10865 10866 NTKERNELAPI 10867 PVOID 10868 NTAPI 10869 MmAllocateMappingAddress( 10870 IN SIZE_T NumberOfBytes, 10871 IN ULONG PoolTag); 10872 10873 NTKERNELAPI 10874 VOID 10875 NTAPI 10876 MmFreeMappingAddress( 10877 IN PVOID BaseAddress, 10878 IN ULONG PoolTag); 10879 10880 NTKERNELAPI 10881 NTSTATUS 10882 NTAPI 10883 MmIsVerifierEnabled( 10884 OUT PULONG VerifierFlags); 10885 10886 NTKERNELAPI 10887 PVOID 10888 NTAPI 10889 MmMapLockedPagesWithReservedMapping( 10890 IN PVOID MappingAddress, 10891 IN ULONG PoolTag, 10892 IN PMDL MemoryDescriptorList, 10893 IN MEMORY_CACHING_TYPE CacheType); 10894 10895 NTKERNELAPI 10896 NTSTATUS 10897 NTAPI 10898 MmProtectMdlSystemAddress( 10899 IN PMDL MemoryDescriptorList, 10900 IN ULONG NewProtect); 10901 10902 NTKERNELAPI 10903 VOID 10904 NTAPI 10905 MmUnmapReservedMapping( 10906 IN PVOID BaseAddress, 10907 IN ULONG PoolTag, 10908 IN PMDL MemoryDescriptorList); 10909 10910 NTKERNELAPI 10911 NTSTATUS 10912 NTAPI 10913 MmAddVerifierThunks( 10914 IN PVOID ThunkBuffer, 10915 IN ULONG ThunkBufferSize); 10916 10917 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 10918 10919 #if (NTDDI_VERSION >= NTDDI_WS03) 10920 NTKERNELAPI 10921 LOGICAL 10922 NTAPI 10923 MmIsIoSpaceActive( 10924 IN PHYSICAL_ADDRESS StartAddress, 10925 IN SIZE_T NumberOfBytes); 10926 10927 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ 10928 #if (NTDDI_VERSION >= NTDDI_WS03SP1) 10929 NTKERNELAPI 10930 PMDL 10931 NTAPI 10932 MmAllocatePagesForMdlEx( 10933 IN PHYSICAL_ADDRESS LowAddress, 10934 IN PHYSICAL_ADDRESS HighAddress, 10935 IN PHYSICAL_ADDRESS SkipBytes, 10936 IN SIZE_T TotalBytes, 10937 IN MEMORY_CACHING_TYPE CacheType, 10938 IN ULONG Flags); 10939 #endif 10940 10941 #if (NTDDI_VERSION >= NTDDI_VISTA) 10942 NTKERNELAPI 10943 LOGICAL 10944 NTAPI 10945 MmIsDriverVerifyingByAddress( 10946 IN PVOID AddressWithinSection); 10947 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 10948 10949 /****************************************************************************** 10950 * Security Manager Functions * 10951 ******************************************************************************/ 10952 10953 #if (NTDDI_VERSION >= NTDDI_WIN2K) 10954 NTKERNELAPI 10955 BOOLEAN 10956 NTAPI 10957 SeAccessCheck( 10958 IN PSECURITY_DESCRIPTOR SecurityDescriptor, 10959 IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, 10960 IN BOOLEAN SubjectContextLocked, 10961 IN ACCESS_MASK DesiredAccess, 10962 IN ACCESS_MASK PreviouslyGrantedAccess, 10963 OUT PPRIVILEGE_SET *Privileges OPTIONAL, 10964 IN PGENERIC_MAPPING GenericMapping, 10965 IN KPROCESSOR_MODE AccessMode, 10966 OUT PACCESS_MASK GrantedAccess, 10967 OUT PNTSTATUS AccessStatus); 10968 10969 NTKERNELAPI 10970 NTSTATUS 10971 NTAPI 10972 SeAssignSecurity( 10973 IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, 10974 IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, 10975 OUT PSECURITY_DESCRIPTOR *NewDescriptor, 10976 IN BOOLEAN IsDirectoryObject, 10977 IN PSECURITY_SUBJECT_CONTEXT SubjectContext, 10978 IN PGENERIC_MAPPING GenericMapping, 10979 IN POOL_TYPE PoolType); 10980 10981 NTKERNELAPI 10982 NTSTATUS 10983 NTAPI 10984 SeAssignSecurityEx( 10985 IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, 10986 IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, 10987 OUT PSECURITY_DESCRIPTOR *NewDescriptor, 10988 IN GUID *ObjectType OPTIONAL, 10989 IN BOOLEAN IsDirectoryObject, 10990 IN ULONG AutoInheritFlags, 10991 IN PSECURITY_SUBJECT_CONTEXT SubjectContext, 10992 IN PGENERIC_MAPPING GenericMapping, 10993 IN POOL_TYPE PoolType); 10994 10995 NTKERNELAPI 10996 NTSTATUS 10997 NTAPI 10998 SeDeassignSecurity( 10999 IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor); 11000 11001 NTKERNELAPI 11002 BOOLEAN 11003 NTAPI 11004 SeValidSecurityDescriptor( 11005 IN ULONG Length, 11006 IN PSECURITY_DESCRIPTOR SecurityDescriptor); 11007 11008 NTKERNELAPI 11009 ULONG 11010 NTAPI 11011 SeObjectCreateSaclAccessBits( 11012 IN PSECURITY_DESCRIPTOR SecurityDescriptor); 11013 11014 NTKERNELAPI 11015 VOID 11016 NTAPI 11017 SeReleaseSubjectContext( 11018 IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); 11019 11020 NTKERNELAPI 11021 VOID 11022 NTAPI 11023 SeUnlockSubjectContext( 11024 IN PSECURITY_SUBJECT_CONTEXT SubjectContext); 11025 11026 NTKERNELAPI 11027 VOID 11028 NTAPI 11029 SeCaptureSubjectContext( 11030 OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); 11031 11032 NTKERNELAPI 11033 VOID 11034 NTAPI 11035 SeLockSubjectContext( 11036 IN PSECURITY_SUBJECT_CONTEXT SubjectContext); 11037 11038 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 11039 11040 #if (NTDDI_VERSION >= NTDDI_WS03SP1) 11041 11042 NTSTATUS 11043 NTAPI 11044 SeSetAuditParameter( 11045 IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters, 11046 IN SE_ADT_PARAMETER_TYPE Type, 11047 IN ULONG Index, 11048 IN PVOID Data); 11049 11050 NTSTATUS 11051 NTAPI 11052 SeReportSecurityEvent( 11053 IN ULONG Flags, 11054 IN PUNICODE_STRING SourceName, 11055 IN PSID UserSid OPTIONAL, 11056 IN PSE_ADT_PARAMETER_ARRAY AuditParameters); 11057 11058 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ 11059 11060 #if (NTDDI_VERSION >= NTDDI_VISTA) 11061 NTKERNELAPI 11062 ULONG 11063 NTAPI 11064 SeComputeAutoInheritByObjectType( 11065 IN PVOID ObjectType, 11066 IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, 11067 IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL); 11068 11069 #ifdef SE_NTFS_WORLD_CACHE 11070 VOID 11071 NTAPI 11072 SeGetWorldRights( 11073 IN PSECURITY_DESCRIPTOR SecurityDescriptor, 11074 IN PGENERIC_MAPPING GenericMapping, 11075 OUT PACCESS_MASK GrantedAccess); 11076 #endif /* SE_NTFS_WORLD_CACHE */ 11077 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 11078 11079 /****************************************************************************** 11080 * Configuration Manager Functions * 11081 ******************************************************************************/ 11082 11083 #if (NTDDI_VERSION >= NTDDI_WINXP) 11084 NTKERNELAPI 11085 NTSTATUS 11086 NTAPI 11087 CmRegisterCallback( 11088 IN PEX_CALLBACK_FUNCTION Function, 11089 IN PVOID Context OPTIONAL, 11090 OUT PLARGE_INTEGER Cookie); 11091 11092 NTKERNELAPI 11093 NTSTATUS 11094 NTAPI 11095 CmUnRegisterCallback( 11096 IN LARGE_INTEGER Cookie); 11097 #endif 11098 11099 #if (NTDDI_VERSION >= NTDDI_VISTA) 11100 11101 NTKERNELAPI 11102 NTSTATUS 11103 NTAPI 11104 CmRegisterCallbackEx( 11105 PEX_CALLBACK_FUNCTION Function, 11106 PCUNICODE_STRING Altitude, 11107 PVOID Driver, 11108 PVOID Context, 11109 PLARGE_INTEGER Cookie, 11110 PVOID Reserved); 11111 11112 NTKERNELAPI 11113 VOID 11114 NTAPI 11115 CmGetCallbackVersion( 11116 OUT PULONG Major OPTIONAL, 11117 OUT PULONG Minor OPTIONAL); 11118 11119 NTKERNELAPI 11120 NTSTATUS 11121 NTAPI 11122 CmSetCallbackObjectContext( 11123 IN OUT PVOID Object, 11124 IN PLARGE_INTEGER Cookie, 11125 IN PVOID NewContext, 11126 OUT PVOID *OldContext OPTIONAL); 11127 11128 NTKERNELAPI 11129 NTSTATUS 11130 NTAPI 11131 CmCallbackGetKeyObjectID( 11132 IN PLARGE_INTEGER Cookie, 11133 IN PVOID Object, 11134 OUT PULONG_PTR ObjectID OPTIONAL, 11135 OUT PCUNICODE_STRING *ObjectName OPTIONAL); 11136 11137 NTKERNELAPI 11138 PVOID 11139 NTAPI 11140 CmGetBoundTransaction( 11141 IN PLARGE_INTEGER Cookie, 11142 IN PVOID Object); 11143 11144 #endif // NTDDI_VERSION >= NTDDI_VISTA 11145 11146 11147 /****************************************************************************** 11148 * I/O Manager Functions * 11149 ******************************************************************************/ 11150 11151 /* 11152 * NTSTATUS 11153 * IoAcquireRemoveLock( 11154 * IN PIO_REMOVE_LOCK RemoveLock, 11155 * IN OPTIONAL PVOID Tag) 11156 */ 11157 #if DBG 11158 #define IoAcquireRemoveLock(RemoveLock, Tag) \ 11159 IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) 11160 #else 11161 #define IoAcquireRemoveLock(RemoveLock, Tag) \ 11162 IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) 11163 #endif 11164 11165 /* 11166 * VOID 11167 * IoAdjustPagingPathCount( 11168 * IN PLONG Count, 11169 * IN BOOLEAN Increment) 11170 */ 11171 #define IoAdjustPagingPathCount(_Count, \ 11172 _Increment) \ 11173 { \ 11174 if (_Increment) \ 11175 { \ 11176 InterlockedIncrement(_Count); \ 11177 } \ 11178 else \ 11179 { \ 11180 InterlockedDecrement(_Count); \ 11181 } \ 11182 } 11183 11184 #if !defined(_M_AMD64) 11185 NTHALAPI 11186 VOID 11187 NTAPI 11188 READ_PORT_BUFFER_UCHAR( 11189 IN PUCHAR Port, 11190 IN PUCHAR Buffer, 11191 IN ULONG Count); 11192 11193 NTHALAPI 11194 VOID 11195 NTAPI 11196 READ_PORT_BUFFER_ULONG( 11197 IN PULONG Port, 11198 IN PULONG Buffer, 11199 IN ULONG Count); 11200 11201 NTHALAPI 11202 VOID 11203 NTAPI 11204 READ_PORT_BUFFER_USHORT( 11205 IN PUSHORT Port, 11206 IN PUSHORT Buffer, 11207 IN ULONG Count); 11208 11209 NTHALAPI 11210 UCHAR 11211 NTAPI 11212 READ_PORT_UCHAR( 11213 IN PUCHAR Port); 11214 11215 NTHALAPI 11216 ULONG 11217 NTAPI 11218 READ_PORT_ULONG( 11219 IN PULONG Port); 11220 11221 NTHALAPI 11222 USHORT 11223 NTAPI 11224 READ_PORT_USHORT( 11225 IN PUSHORT Port); 11226 11227 NTKERNELAPI 11228 VOID 11229 NTAPI 11230 READ_REGISTER_BUFFER_UCHAR( 11231 IN PUCHAR Register, 11232 IN PUCHAR Buffer, 11233 IN ULONG Count); 11234 11235 NTKERNELAPI 11236 VOID 11237 NTAPI 11238 READ_REGISTER_BUFFER_ULONG( 11239 IN PULONG Register, 11240 IN PULONG Buffer, 11241 IN ULONG Count); 11242 11243 NTKERNELAPI 11244 VOID 11245 NTAPI 11246 READ_REGISTER_BUFFER_USHORT( 11247 IN PUSHORT Register, 11248 IN PUSHORT Buffer, 11249 IN ULONG Count); 11250 11251 NTKERNELAPI 11252 UCHAR 11253 NTAPI 11254 READ_REGISTER_UCHAR( 11255 IN PUCHAR Register); 11256 11257 NTKERNELAPI 11258 ULONG 11259 NTAPI 11260 READ_REGISTER_ULONG( 11261 IN PULONG Register); 11262 11263 NTKERNELAPI 11264 USHORT 11265 NTAPI 11266 READ_REGISTER_USHORT( 11267 IN PUSHORT Register); 11268 11269 NTHALAPI 11270 VOID 11271 NTAPI 11272 WRITE_PORT_BUFFER_UCHAR( 11273 IN PUCHAR Port, 11274 IN PUCHAR Buffer, 11275 IN ULONG Count); 11276 11277 NTHALAPI 11278 VOID 11279 NTAPI 11280 WRITE_PORT_BUFFER_ULONG( 11281 IN PULONG Port, 11282 IN PULONG Buffer, 11283 IN ULONG Count); 11284 11285 NTHALAPI 11286 VOID 11287 NTAPI 11288 WRITE_PORT_BUFFER_USHORT( 11289 IN PUSHORT Port, 11290 IN PUSHORT Buffer, 11291 IN ULONG Count); 11292 11293 NTHALAPI 11294 VOID 11295 NTAPI 11296 WRITE_PORT_UCHAR( 11297 IN PUCHAR Port, 11298 IN UCHAR Value); 11299 11300 NTHALAPI 11301 VOID 11302 NTAPI 11303 WRITE_PORT_ULONG( 11304 IN PULONG Port, 11305 IN ULONG Value); 11306 11307 NTHALAPI 11308 VOID 11309 NTAPI 11310 WRITE_PORT_USHORT( 11311 IN PUSHORT Port, 11312 IN USHORT Value); 11313 11314 NTKERNELAPI 11315 VOID 11316 NTAPI 11317 WRITE_REGISTER_BUFFER_UCHAR( 11318 IN PUCHAR Register, 11319 IN PUCHAR Buffer, 11320 IN ULONG Count); 11321 11322 NTKERNELAPI 11323 VOID 11324 NTAPI 11325 WRITE_REGISTER_BUFFER_ULONG( 11326 IN PULONG Register, 11327 IN PULONG Buffer, 11328 IN ULONG Count); 11329 11330 NTKERNELAPI 11331 VOID 11332 NTAPI 11333 WRITE_REGISTER_BUFFER_USHORT( 11334 IN PUSHORT Register, 11335 IN PUSHORT Buffer, 11336 IN ULONG Count); 11337 11338 NTKERNELAPI 11339 VOID 11340 NTAPI 11341 WRITE_REGISTER_UCHAR( 11342 IN PUCHAR Register, 11343 IN UCHAR Value); 11344 11345 NTKERNELAPI 11346 VOID 11347 NTAPI 11348 WRITE_REGISTER_ULONG( 11349 IN PULONG Register, 11350 IN ULONG Value); 11351 11352 NTKERNELAPI 11353 VOID 11354 NTAPI 11355 WRITE_REGISTER_USHORT( 11356 IN PUSHORT Register, 11357 IN USHORT Value); 11358 11359 #else 11360 11361 FORCEINLINE 11362 VOID 11363 READ_PORT_BUFFER_UCHAR( 11364 IN PUCHAR Port, 11365 IN PUCHAR Buffer, 11366 IN ULONG Count) 11367 { 11368 __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); 11369 } 11370 11371 FORCEINLINE 11372 VOID 11373 READ_PORT_BUFFER_ULONG( 11374 IN PULONG Port, 11375 IN PULONG Buffer, 11376 IN ULONG Count) 11377 { 11378 __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); 11379 } 11380 11381 FORCEINLINE 11382 VOID 11383 READ_PORT_BUFFER_USHORT( 11384 IN PUSHORT Port, 11385 IN PUSHORT Buffer, 11386 IN ULONG Count) 11387 { 11388 __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); 11389 } 11390 11391 FORCEINLINE 11392 UCHAR 11393 READ_PORT_UCHAR( 11394 IN PUCHAR Port) 11395 { 11396 return __inbyte((USHORT)(ULONG_PTR)Port); 11397 } 11398 11399 FORCEINLINE 11400 ULONG 11401 READ_PORT_ULONG( 11402 IN PULONG Port) 11403 { 11404 return __indword((USHORT)(ULONG_PTR)Port); 11405 } 11406 11407 FORCEINLINE 11408 USHORT 11409 READ_PORT_USHORT( 11410 IN PUSHORT Port) 11411 { 11412 return __inword((USHORT)(ULONG_PTR)Port); 11413 } 11414 11415 FORCEINLINE 11416 VOID 11417 READ_REGISTER_BUFFER_UCHAR( 11418 IN PUCHAR Register, 11419 IN PUCHAR Buffer, 11420 IN ULONG Count) 11421 { 11422 __movsb(Register, Buffer, Count); 11423 } 11424 11425 FORCEINLINE 11426 VOID 11427 READ_REGISTER_BUFFER_ULONG( 11428 IN PULONG Register, 11429 IN PULONG Buffer, 11430 IN ULONG Count) 11431 { 11432 __movsd(Register, Buffer, Count); 11433 } 11434 11435 FORCEINLINE 11436 VOID 11437 READ_REGISTER_BUFFER_USHORT( 11438 IN PUSHORT Register, 11439 IN PUSHORT Buffer, 11440 IN ULONG Count) 11441 { 11442 __movsw(Register, Buffer, Count); 11443 } 11444 11445 FORCEINLINE 11446 UCHAR 11447 READ_REGISTER_UCHAR( 11448 IN volatile UCHAR *Register) 11449 { 11450 return *Register; 11451 } 11452 11453 FORCEINLINE 11454 ULONG 11455 READ_REGISTER_ULONG( 11456 IN volatile ULONG *Register) 11457 { 11458 return *Register; 11459 } 11460 11461 FORCEINLINE 11462 USHORT 11463 READ_REGISTER_USHORT( 11464 IN volatile USHORT *Register) 11465 { 11466 return *Register; 11467 } 11468 11469 FORCEINLINE 11470 VOID 11471 WRITE_PORT_BUFFER_UCHAR( 11472 IN PUCHAR Port, 11473 IN PUCHAR Buffer, 11474 IN ULONG Count) 11475 { 11476 __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); 11477 } 11478 11479 FORCEINLINE 11480 VOID 11481 WRITE_PORT_BUFFER_ULONG( 11482 IN PULONG Port, 11483 IN PULONG Buffer, 11484 IN ULONG Count) 11485 { 11486 __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); 11487 } 11488 11489 FORCEINLINE 11490 VOID 11491 WRITE_PORT_BUFFER_USHORT( 11492 IN PUSHORT Port, 11493 IN PUSHORT Buffer, 11494 IN ULONG Count) 11495 { 11496 __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); 11497 } 11498 11499 FORCEINLINE 11500 VOID 11501 WRITE_PORT_UCHAR( 11502 IN PUCHAR Port, 11503 IN UCHAR Value) 11504 { 11505 __outbyte((USHORT)(ULONG_PTR)Port, Value); 11506 } 11507 11508 FORCEINLINE 11509 VOID 11510 WRITE_PORT_ULONG( 11511 IN PULONG Port, 11512 IN ULONG Value) 11513 { 11514 __outdword((USHORT)(ULONG_PTR)Port, Value); 11515 } 11516 11517 FORCEINLINE 11518 VOID 11519 WRITE_PORT_USHORT( 11520 IN PUSHORT Port, 11521 IN USHORT Value) 11522 { 11523 __outword((USHORT)(ULONG_PTR)Port, Value); 11524 } 11525 11526 FORCEINLINE 11527 VOID 11528 WRITE_REGISTER_BUFFER_UCHAR( 11529 IN PUCHAR Register, 11530 IN PUCHAR Buffer, 11531 IN ULONG Count) 11532 { 11533 LONG Synch; 11534 __movsb(Register, Buffer, Count); 11535 InterlockedOr(&Synch, 1); 11536 } 11537 11538 FORCEINLINE 11539 VOID 11540 WRITE_REGISTER_BUFFER_ULONG( 11541 IN PULONG Register, 11542 IN PULONG Buffer, 11543 IN ULONG Count) 11544 { 11545 LONG Synch; 11546 __movsd(Register, Buffer, Count); 11547 InterlockedOr(&Synch, 1); 11548 } 11549 11550 FORCEINLINE 11551 VOID 11552 WRITE_REGISTER_BUFFER_USHORT( 11553 IN PUSHORT Register, 11554 IN PUSHORT Buffer, 11555 IN ULONG Count) 11556 { 11557 LONG Synch; 11558 __movsw(Register, Buffer, Count); 11559 InterlockedOr(&Synch, 1); 11560 } 11561 11562 FORCEINLINE 11563 VOID 11564 WRITE_REGISTER_UCHAR( 11565 IN volatile UCHAR *Register, 11566 IN UCHAR Value) 11567 { 11568 LONG Synch; 11569 *Register = Value; 11570 InterlockedOr(&Synch, 1); 11571 } 11572 11573 FORCEINLINE 11574 VOID 11575 WRITE_REGISTER_ULONG( 11576 IN volatile ULONG *Register, 11577 IN ULONG Value) 11578 { 11579 LONG Synch; 11580 *Register = Value; 11581 InterlockedOr(&Synch, 1); 11582 } 11583 11584 FORCEINLINE 11585 VOID 11586 WRITE_REGISTER_USHORT( 11587 IN volatile USHORT *Register, 11588 IN USHORT Value) 11589 { 11590 LONG Sync; 11591 *Register = Value; 11592 InterlockedOr(&Sync, 1); 11593 } 11594 #endif 11595 11596 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && \ 11597 (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) 11598 11599 #define DMA_MACROS_DEFINED 11600 11601 FORCEINLINE 11602 NTSTATUS 11603 IoAllocateAdapterChannel( 11604 IN PDMA_ADAPTER DmaAdapter, 11605 IN PDEVICE_OBJECT DeviceObject, 11606 IN ULONG NumberOfMapRegisters, 11607 IN PDRIVER_CONTROL ExecutionRoutine, 11608 IN PVOID Context) 11609 { 11610 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; 11611 AllocateAdapterChannel = 11612 *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; 11613 ASSERT(AllocateAdapterChannel); 11614 return AllocateAdapterChannel(DmaAdapter, 11615 DeviceObject, 11616 NumberOfMapRegisters, 11617 ExecutionRoutine, 11618 Context ); 11619 } 11620 11621 FORCEINLINE 11622 BOOLEAN 11623 NTAPI 11624 IoFlushAdapterBuffers( 11625 IN PDMA_ADAPTER DmaAdapter, 11626 IN PMDL Mdl, 11627 IN PVOID MapRegisterBase, 11628 IN PVOID CurrentVa, 11629 IN ULONG Length, 11630 IN BOOLEAN WriteToDevice) 11631 { 11632 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; 11633 FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; 11634 ASSERT(FlushAdapterBuffers); 11635 return FlushAdapterBuffers(DmaAdapter, 11636 Mdl, 11637 MapRegisterBase, 11638 CurrentVa, 11639 Length, 11640 WriteToDevice); 11641 } 11642 11643 FORCEINLINE 11644 VOID 11645 NTAPI 11646 IoFreeAdapterChannel( 11647 IN PDMA_ADAPTER DmaAdapter) 11648 { 11649 PFREE_ADAPTER_CHANNEL FreeAdapterChannel; 11650 FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; 11651 ASSERT(FreeAdapterChannel); 11652 FreeAdapterChannel(DmaAdapter); 11653 } 11654 11655 FORCEINLINE 11656 VOID 11657 NTAPI 11658 IoFreeMapRegisters( 11659 IN PDMA_ADAPTER DmaAdapter, 11660 IN PVOID MapRegisterBase, 11661 IN ULONG NumberOfMapRegisters) 11662 { 11663 PFREE_MAP_REGISTERS FreeMapRegisters; 11664 FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; 11665 ASSERT(FreeMapRegisters); 11666 FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); 11667 } 11668 11669 FORCEINLINE 11670 PHYSICAL_ADDRESS 11671 NTAPI 11672 IoMapTransfer( 11673 IN PDMA_ADAPTER DmaAdapter, 11674 IN PMDL Mdl, 11675 IN PVOID MapRegisterBase, 11676 IN PVOID CurrentVa, 11677 IN OUT PULONG Length, 11678 IN BOOLEAN WriteToDevice) 11679 { 11680 PMAP_TRANSFER MapTransfer; 11681 11682 MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; 11683 ASSERT(MapTransfer); 11684 return MapTransfer(DmaAdapter, 11685 Mdl, 11686 MapRegisterBase, 11687 CurrentVa, 11688 Length, 11689 WriteToDevice); 11690 } 11691 #endif 11692 11693 #if (NTDDI_VERSION >= NTDDI_WIN2K) 11694 11695 NTKERNELAPI 11696 VOID 11697 NTAPI 11698 IoAcquireCancelSpinLock( 11699 OUT PKIRQL Irql); 11700 11701 NTKERNELAPI 11702 NTSTATUS 11703 NTAPI 11704 IoAcquireRemoveLockEx( 11705 IN PIO_REMOVE_LOCK RemoveLock, 11706 IN PVOID Tag OPTIONAL, 11707 IN PCSTR File, 11708 IN ULONG Line, 11709 IN ULONG RemlockSize); 11710 NTKERNELAPI 11711 NTSTATUS 11712 NTAPI 11713 IoAllocateDriverObjectExtension( 11714 IN PDRIVER_OBJECT DriverObject, 11715 IN PVOID ClientIdentificationAddress, 11716 IN ULONG DriverObjectExtensionSize, 11717 OUT PVOID *DriverObjectExtension); 11718 11719 NTKERNELAPI 11720 PVOID 11721 NTAPI 11722 IoAllocateErrorLogEntry( 11723 IN PVOID IoObject, 11724 IN UCHAR EntrySize); 11725 11726 NTKERNELAPI 11727 PIRP 11728 NTAPI 11729 IoAllocateIrp( 11730 IN CCHAR StackSize, 11731 IN BOOLEAN ChargeQuota); 11732 11733 NTKERNELAPI 11734 PMDL 11735 NTAPI 11736 IoAllocateMdl( 11737 IN PVOID VirtualAddress OPTIONAL, 11738 IN ULONG Length, 11739 IN BOOLEAN SecondaryBuffer, 11740 IN BOOLEAN ChargeQuota, 11741 IN OUT PIRP Irp OPTIONAL); 11742 11743 NTKERNELAPI 11744 PIO_WORKITEM 11745 NTAPI 11746 IoAllocateWorkItem( 11747 IN PDEVICE_OBJECT DeviceObject); 11748 11749 NTKERNELAPI 11750 NTSTATUS 11751 NTAPI 11752 IoAttachDevice( 11753 IN PDEVICE_OBJECT SourceDevice, 11754 IN PUNICODE_STRING TargetDevice, 11755 OUT PDEVICE_OBJECT *AttachedDevice); 11756 11757 NTKERNELAPI 11758 PDEVICE_OBJECT 11759 NTAPI 11760 IoAttachDeviceToDeviceStack( 11761 IN PDEVICE_OBJECT SourceDevice, 11762 IN PDEVICE_OBJECT TargetDevice); 11763 11764 NTKERNELAPI 11765 PIRP 11766 NTAPI 11767 IoBuildAsynchronousFsdRequest( 11768 IN ULONG MajorFunction, 11769 IN PDEVICE_OBJECT DeviceObject, 11770 IN OUT PVOID Buffer OPTIONAL, 11771 IN ULONG Length OPTIONAL, 11772 IN PLARGE_INTEGER StartingOffset OPTIONAL, 11773 IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); 11774 11775 NTKERNELAPI 11776 PIRP 11777 NTAPI 11778 IoBuildDeviceIoControlRequest( 11779 IN ULONG IoControlCode, 11780 IN PDEVICE_OBJECT DeviceObject, 11781 IN PVOID InputBuffer OPTIONAL, 11782 IN ULONG InputBufferLength, 11783 OUT PVOID OutputBuffer OPTIONAL, 11784 IN ULONG OutputBufferLength, 11785 IN BOOLEAN InternalDeviceIoControl, 11786 IN PKEVENT Event, 11787 OUT PIO_STATUS_BLOCK IoStatusBlock); 11788 11789 NTKERNELAPI 11790 VOID 11791 NTAPI 11792 IoBuildPartialMdl( 11793 IN PMDL SourceMdl, 11794 IN OUT PMDL TargetMdl, 11795 IN PVOID VirtualAddress, 11796 IN ULONG Length); 11797 11798 NTKERNELAPI 11799 PIRP 11800 NTAPI 11801 IoBuildSynchronousFsdRequest( 11802 IN ULONG MajorFunction, 11803 IN PDEVICE_OBJECT DeviceObject, 11804 IN OUT PVOID Buffer OPTIONAL, 11805 IN ULONG Length OPTIONAL, 11806 IN PLARGE_INTEGER StartingOffset OPTIONAL, 11807 IN PKEVENT Event, 11808 OUT PIO_STATUS_BLOCK IoStatusBlock); 11809 11810 NTKERNELAPI 11811 NTSTATUS 11812 FASTCALL 11813 IofCallDriver( 11814 IN PDEVICE_OBJECT DeviceObject, 11815 IN OUT PIRP Irp); 11816 #define IoCallDriver IofCallDriver 11817 11818 NTKERNELAPI 11819 VOID 11820 FASTCALL 11821 IofCompleteRequest( 11822 IN PIRP Irp, 11823 IN CCHAR PriorityBoost); 11824 #define IoCompleteRequest IofCompleteRequest 11825 11826 NTKERNELAPI 11827 BOOLEAN 11828 NTAPI 11829 IoCancelIrp( 11830 IN PIRP Irp); 11831 11832 NTKERNELAPI 11833 NTSTATUS 11834 NTAPI 11835 IoCheckShareAccess( 11836 IN ACCESS_MASK DesiredAccess, 11837 IN ULONG DesiredShareAccess, 11838 IN OUT PFILE_OBJECT FileObject, 11839 IN OUT PSHARE_ACCESS ShareAccess, 11840 IN BOOLEAN Update); 11841 11842 NTKERNELAPI 11843 VOID 11844 FASTCALL 11845 IofCompleteRequest( 11846 IN PIRP Irp, 11847 IN CCHAR PriorityBoost); 11848 11849 NTKERNELAPI 11850 NTSTATUS 11851 NTAPI 11852 IoConnectInterrupt( 11853 OUT PKINTERRUPT *InterruptObject, 11854 IN PKSERVICE_ROUTINE ServiceRoutine, 11855 IN PVOID ServiceContext OPTIONAL, 11856 IN PKSPIN_LOCK SpinLock OPTIONAL, 11857 IN ULONG Vector, 11858 IN KIRQL Irql, 11859 IN KIRQL SynchronizeIrql, 11860 IN KINTERRUPT_MODE InterruptMode, 11861 IN BOOLEAN ShareVector, 11862 IN KAFFINITY ProcessorEnableMask, 11863 IN BOOLEAN FloatingSave); 11864 11865 NTKERNELAPI 11866 NTSTATUS 11867 NTAPI 11868 IoCreateDevice( 11869 IN PDRIVER_OBJECT DriverObject, 11870 IN ULONG DeviceExtensionSize, 11871 IN PUNICODE_STRING DeviceName OPTIONAL, 11872 IN DEVICE_TYPE DeviceType, 11873 IN ULONG DeviceCharacteristics, 11874 IN BOOLEAN Exclusive, 11875 OUT PDEVICE_OBJECT *DeviceObject); 11876 11877 NTKERNELAPI 11878 NTSTATUS 11879 NTAPI 11880 IoCreateFile( 11881 OUT PHANDLE FileHandle, 11882 IN ACCESS_MASK DesiredAccess, 11883 IN POBJECT_ATTRIBUTES ObjectAttributes, 11884 OUT PIO_STATUS_BLOCK IoStatusBlock, 11885 IN PLARGE_INTEGER AllocationSize OPTIONAL, 11886 IN ULONG FileAttributes, 11887 IN ULONG ShareAccess, 11888 IN ULONG Disposition, 11889 IN ULONG CreateOptions, 11890 IN PVOID EaBuffer OPTIONAL, 11891 IN ULONG EaLength, 11892 IN CREATE_FILE_TYPE CreateFileType, 11893 IN PVOID InternalParameters OPTIONAL, 11894 IN ULONG Options); 11895 11896 NTKERNELAPI 11897 PKEVENT 11898 NTAPI 11899 IoCreateNotificationEvent( 11900 IN PUNICODE_STRING EventName, 11901 OUT PHANDLE EventHandle); 11902 11903 NTKERNELAPI 11904 NTSTATUS 11905 NTAPI 11906 IoCreateSymbolicLink( 11907 IN PUNICODE_STRING SymbolicLinkName, 11908 IN PUNICODE_STRING DeviceName); 11909 11910 NTKERNELAPI 11911 PKEVENT 11912 NTAPI 11913 IoCreateSynchronizationEvent( 11914 IN PUNICODE_STRING EventName, 11915 OUT PHANDLE EventHandle); 11916 11917 NTKERNELAPI 11918 NTSTATUS 11919 NTAPI 11920 IoCreateUnprotectedSymbolicLink( 11921 IN PUNICODE_STRING SymbolicLinkName, 11922 IN PUNICODE_STRING DeviceName); 11923 11924 NTKERNELAPI 11925 VOID 11926 NTAPI 11927 IoDeleteDevice( 11928 IN PDEVICE_OBJECT DeviceObject); 11929 11930 NTKERNELAPI 11931 NTSTATUS 11932 NTAPI 11933 IoDeleteSymbolicLink( 11934 IN PUNICODE_STRING SymbolicLinkName); 11935 11936 NTKERNELAPI 11937 VOID 11938 NTAPI 11939 IoDetachDevice( 11940 IN OUT PDEVICE_OBJECT TargetDevice); 11941 11942 NTKERNELAPI 11943 VOID 11944 NTAPI 11945 IoDisconnectInterrupt( 11946 IN PKINTERRUPT InterruptObject); 11947 11948 NTKERNELAPI 11949 VOID 11950 NTAPI 11951 IoFreeIrp( 11952 IN PIRP Irp); 11953 11954 NTKERNELAPI 11955 VOID 11956 NTAPI 11957 IoFreeMdl( 11958 IN PMDL Mdl); 11959 11960 NTKERNELAPI 11961 VOID 11962 NTAPI 11963 IoFreeWorkItem( 11964 IN PIO_WORKITEM IoWorkItem); 11965 11966 NTKERNELAPI 11967 PDEVICE_OBJECT 11968 NTAPI 11969 IoGetAttachedDevice( 11970 IN PDEVICE_OBJECT DeviceObject); 11971 11972 NTKERNELAPI 11973 PDEVICE_OBJECT 11974 NTAPI 11975 IoGetAttachedDeviceReference( 11976 IN PDEVICE_OBJECT DeviceObject); 11977 11978 NTKERNELAPI 11979 NTSTATUS 11980 NTAPI 11981 IoGetBootDiskInformation( 11982 IN OUT PBOOTDISK_INFORMATION BootDiskInformation, 11983 IN ULONG Size); 11984 11985 NTKERNELAPI 11986 NTSTATUS 11987 NTAPI 11988 IoGetDeviceInterfaceAlias( 11989 IN PUNICODE_STRING SymbolicLinkName, 11990 IN CONST GUID *AliasInterfaceClassGuid, 11991 OUT PUNICODE_STRING AliasSymbolicLinkName); 11992 11993 NTKERNELAPI 11994 PEPROCESS 11995 NTAPI 11996 IoGetCurrentProcess(VOID); 11997 11998 NTKERNELAPI 11999 NTSTATUS 12000 NTAPI 12001 IoGetDeviceInterfaces( 12002 IN CONST GUID *InterfaceClassGuid, 12003 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, 12004 IN ULONG Flags, 12005 OUT PWSTR *SymbolicLinkList); 12006 12007 NTKERNELAPI 12008 NTSTATUS 12009 NTAPI 12010 IoGetDeviceObjectPointer( 12011 IN PUNICODE_STRING ObjectName, 12012 IN ACCESS_MASK DesiredAccess, 12013 OUT PFILE_OBJECT *FileObject, 12014 OUT PDEVICE_OBJECT *DeviceObject); 12015 12016 NTKERNELAPI 12017 NTSTATUS 12018 NTAPI 12019 IoGetDeviceProperty( 12020 IN PDEVICE_OBJECT DeviceObject, 12021 IN DEVICE_REGISTRY_PROPERTY DeviceProperty, 12022 IN ULONG BufferLength, 12023 OUT PVOID PropertyBuffer, 12024 OUT PULONG ResultLength); 12025 12026 NTKERNELAPI 12027 PDMA_ADAPTER 12028 NTAPI 12029 IoGetDmaAdapter( 12030 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, 12031 IN PDEVICE_DESCRIPTION DeviceDescription, 12032 IN OUT PULONG NumberOfMapRegisters); 12033 12034 NTKERNELAPI 12035 PVOID 12036 NTAPI 12037 IoGetDriverObjectExtension( 12038 IN PDRIVER_OBJECT DriverObject, 12039 IN PVOID ClientIdentificationAddress); 12040 12041 NTKERNELAPI 12042 PVOID 12043 NTAPI 12044 IoGetInitialStack(VOID); 12045 12046 NTKERNELAPI 12047 PDEVICE_OBJECT 12048 NTAPI 12049 IoGetRelatedDeviceObject( 12050 IN PFILE_OBJECT FileObject); 12051 12052 NTKERNELAPI 12053 VOID 12054 NTAPI 12055 IoQueueWorkItem( 12056 IN PIO_WORKITEM IoWorkItem, 12057 IN PIO_WORKITEM_ROUTINE WorkerRoutine, 12058 IN WORK_QUEUE_TYPE QueueType, 12059 IN PVOID Context OPTIONAL); 12060 12061 NTKERNELAPI 12062 VOID 12063 NTAPI 12064 IoInitializeIrp( 12065 IN OUT PIRP Irp, 12066 IN USHORT PacketSize, 12067 IN CCHAR StackSize); 12068 12069 NTKERNELAPI 12070 VOID 12071 NTAPI 12072 IoInitializeRemoveLockEx( 12073 IN PIO_REMOVE_LOCK Lock, 12074 IN ULONG AllocateTag, 12075 IN ULONG MaxLockedMinutes, 12076 IN ULONG HighWatermark, 12077 IN ULONG RemlockSize); 12078 12079 NTKERNELAPI 12080 NTSTATUS 12081 NTAPI 12082 IoInitializeTimer( 12083 IN PDEVICE_OBJECT DeviceObject, 12084 IN PIO_TIMER_ROUTINE TimerRoutine, 12085 IN PVOID Context OPTIONAL); 12086 12087 NTKERNELAPI 12088 VOID 12089 NTAPI 12090 IoInvalidateDeviceRelations( 12091 IN PDEVICE_OBJECT DeviceObject, 12092 IN DEVICE_RELATION_TYPE Type); 12093 12094 NTKERNELAPI 12095 VOID 12096 NTAPI 12097 IoInvalidateDeviceState( 12098 IN PDEVICE_OBJECT PhysicalDeviceObject); 12099 12100 NTKERNELAPI 12101 BOOLEAN 12102 NTAPI 12103 IoIsWdmVersionAvailable( 12104 IN UCHAR MajorVersion, 12105 IN UCHAR MinorVersion); 12106 12107 NTKERNELAPI 12108 NTSTATUS 12109 NTAPI 12110 IoOpenDeviceInterfaceRegistryKey( 12111 IN PUNICODE_STRING SymbolicLinkName, 12112 IN ACCESS_MASK DesiredAccess, 12113 OUT PHANDLE DeviceInterfaceKey); 12114 12115 NTKERNELAPI 12116 NTSTATUS 12117 NTAPI 12118 IoOpenDeviceRegistryKey( 12119 IN PDEVICE_OBJECT DeviceObject, 12120 IN ULONG DevInstKeyType, 12121 IN ACCESS_MASK DesiredAccess, 12122 OUT PHANDLE DevInstRegKey); 12123 12124 NTKERNELAPI 12125 NTSTATUS 12126 NTAPI 12127 IoRegisterDeviceInterface( 12128 IN PDEVICE_OBJECT PhysicalDeviceObject, 12129 IN CONST GUID *InterfaceClassGuid, 12130 IN PUNICODE_STRING ReferenceString OPTIONAL, 12131 OUT PUNICODE_STRING SymbolicLinkName); 12132 12133 NTKERNELAPI 12134 NTSTATUS 12135 NTAPI 12136 IoRegisterPlugPlayNotification( 12137 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, 12138 IN ULONG EventCategoryFlags, 12139 IN PVOID EventCategoryData OPTIONAL, 12140 IN PDRIVER_OBJECT DriverObject, 12141 IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, 12142 IN OUT PVOID Context OPTIONAL, 12143 OUT PVOID *NotificationEntry); 12144 12145 NTKERNELAPI 12146 NTSTATUS 12147 NTAPI 12148 IoRegisterShutdownNotification( 12149 IN PDEVICE_OBJECT DeviceObject); 12150 12151 NTKERNELAPI 12152 VOID 12153 NTAPI 12154 IoReleaseCancelSpinLock( 12155 IN KIRQL Irql); 12156 12157 NTKERNELAPI 12158 VOID 12159 NTAPI 12160 IoReleaseRemoveLockAndWaitEx( 12161 IN PIO_REMOVE_LOCK RemoveLock, 12162 IN PVOID Tag OPTIONAL, 12163 IN ULONG RemlockSize); 12164 12165 NTKERNELAPI 12166 VOID 12167 NTAPI 12168 IoReleaseRemoveLockEx( 12169 IN PIO_REMOVE_LOCK RemoveLock, 12170 IN PVOID Tag OPTIONAL, 12171 IN ULONG RemlockSize); 12172 12173 NTKERNELAPI 12174 VOID 12175 NTAPI 12176 IoRemoveShareAccess( 12177 IN PFILE_OBJECT FileObject, 12178 IN OUT PSHARE_ACCESS ShareAccess); 12179 12180 NTKERNELAPI 12181 NTSTATUS 12182 NTAPI 12183 IoReportTargetDeviceChange( 12184 IN PDEVICE_OBJECT PhysicalDeviceObject, 12185 IN PVOID NotificationStructure); 12186 12187 NTKERNELAPI 12188 NTSTATUS 12189 NTAPI 12190 IoReportTargetDeviceChangeAsynchronous( 12191 IN PDEVICE_OBJECT PhysicalDeviceObject, 12192 IN PVOID NotificationStructure, 12193 IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, 12194 IN PVOID Context OPTIONAL); 12195 12196 NTKERNELAPI 12197 VOID 12198 NTAPI 12199 IoRequestDeviceEject( 12200 IN PDEVICE_OBJECT PhysicalDeviceObject); 12201 12202 NTKERNELAPI 12203 VOID 12204 NTAPI 12205 IoReuseIrp( 12206 IN OUT PIRP Irp, 12207 IN NTSTATUS Status); 12208 12209 NTKERNELAPI 12210 NTSTATUS 12211 NTAPI 12212 IoSetDeviceInterfaceState( 12213 IN PUNICODE_STRING SymbolicLinkName, 12214 IN BOOLEAN Enable); 12215 12216 NTKERNELAPI 12217 VOID 12218 NTAPI 12219 IoSetShareAccess( 12220 IN ACCESS_MASK DesiredAccess, 12221 IN ULONG DesiredShareAccess, 12222 IN OUT PFILE_OBJECT FileObject, 12223 OUT PSHARE_ACCESS ShareAccess); 12224 12225 NTKERNELAPI 12226 VOID 12227 NTAPI 12228 IoStartNextPacket( 12229 IN PDEVICE_OBJECT DeviceObject, 12230 IN BOOLEAN Cancelable); 12231 12232 NTKERNELAPI 12233 VOID 12234 NTAPI 12235 IoStartNextPacketByKey( 12236 IN PDEVICE_OBJECT DeviceObject, 12237 IN BOOLEAN Cancelable, 12238 IN ULONG Key); 12239 12240 NTKERNELAPI 12241 VOID 12242 NTAPI 12243 IoStartPacket( 12244 IN PDEVICE_OBJECT DeviceObject, 12245 IN PIRP Irp, 12246 IN PULONG Key OPTIONAL, 12247 IN PDRIVER_CANCEL CancelFunction OPTIONAL); 12248 12249 NTKERNELAPI 12250 VOID 12251 NTAPI 12252 IoStartTimer( 12253 IN PDEVICE_OBJECT DeviceObject); 12254 12255 NTKERNELAPI 12256 VOID 12257 NTAPI 12258 IoStopTimer( 12259 IN PDEVICE_OBJECT DeviceObject); 12260 12261 NTKERNELAPI 12262 NTSTATUS 12263 NTAPI 12264 IoUnregisterPlugPlayNotification( 12265 IN PVOID NotificationEntry); 12266 12267 NTKERNELAPI 12268 VOID 12269 NTAPI 12270 IoUnregisterShutdownNotification( 12271 IN PDEVICE_OBJECT DeviceObject); 12272 12273 NTKERNELAPI 12274 VOID 12275 NTAPI 12276 IoUpdateShareAccess( 12277 IN PFILE_OBJECT FileObject, 12278 IN OUT PSHARE_ACCESS ShareAccess); 12279 12280 NTKERNELAPI 12281 NTSTATUS 12282 NTAPI 12283 IoWMIAllocateInstanceIds( 12284 IN GUID *Guid, 12285 IN ULONG InstanceCount, 12286 OUT ULONG *FirstInstanceId); 12287 12288 NTKERNELAPI 12289 NTSTATUS 12290 NTAPI 12291 IoWMIQuerySingleInstanceMultiple( 12292 IN PVOID *DataBlockObjectList, 12293 IN PUNICODE_STRING InstanceNames, 12294 IN ULONG ObjectCount, 12295 IN OUT ULONG *InOutBufferSize, 12296 OUT PVOID OutBuffer); 12297 12298 NTKERNELAPI 12299 NTSTATUS 12300 NTAPI 12301 IoWMIRegistrationControl( 12302 IN PDEVICE_OBJECT DeviceObject, 12303 IN ULONG Action); 12304 12305 NTKERNELAPI 12306 NTSTATUS 12307 NTAPI 12308 IoWMISuggestInstanceName( 12309 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, 12310 IN PUNICODE_STRING SymbolicLinkName OPTIONAL, 12311 IN BOOLEAN CombineNames, 12312 OUT PUNICODE_STRING SuggestedInstanceName); 12313 12314 NTKERNELAPI 12315 NTSTATUS 12316 NTAPI 12317 IoWMIWriteEvent( 12318 IN OUT PVOID WnodeEventItem); 12319 12320 NTKERNELAPI 12321 VOID 12322 NTAPI 12323 IoWriteErrorLogEntry( 12324 IN PVOID ElEntry); 12325 12326 NTKERNELAPI 12327 PIRP 12328 NTAPI 12329 IoGetTopLevelIrp(VOID); 12330 12331 NTKERNELAPI 12332 NTSTATUS 12333 NTAPI 12334 IoRegisterLastChanceShutdownNotification( 12335 IN PDEVICE_OBJECT DeviceObject); 12336 12337 NTKERNELAPI 12338 VOID 12339 NTAPI 12340 IoSetTopLevelIrp( 12341 IN PIRP Irp OPTIONAL); 12342 12343 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 12344 12345 12346 #if (NTDDI_VERSION >= NTDDI_WINXP) 12347 12348 NTKERNELAPI 12349 NTSTATUS 12350 NTAPI 12351 IoCsqInitialize( 12352 IN PIO_CSQ Csq, 12353 IN PIO_CSQ_INSERT_IRP CsqInsertIrp, 12354 IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, 12355 IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, 12356 IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, 12357 IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, 12358 IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); 12359 12360 NTKERNELAPI 12361 VOID 12362 NTAPI 12363 IoCsqInsertIrp( 12364 IN PIO_CSQ Csq, 12365 IN PIRP Irp, 12366 IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL); 12367 12368 NTKERNELAPI 12369 PIRP 12370 NTAPI 12371 IoCsqRemoveIrp( 12372 IN PIO_CSQ Csq, 12373 IN PIO_CSQ_IRP_CONTEXT Context); 12374 12375 NTKERNELAPI 12376 PIRP 12377 NTAPI 12378 IoCsqRemoveNextIrp( 12379 IN PIO_CSQ Csq, 12380 IN PVOID PeekContext OPTIONAL); 12381 12382 NTKERNELAPI 12383 BOOLEAN 12384 NTAPI 12385 IoForwardIrpSynchronously( 12386 IN PDEVICE_OBJECT DeviceObject, 12387 IN PIRP Irp); 12388 12389 #define IoForwardAndCatchIrp IoForwardIrpSynchronously 12390 12391 NTKERNELAPI 12392 VOID 12393 NTAPI 12394 IoFreeErrorLogEntry( 12395 PVOID ElEntry); 12396 12397 NTKERNELAPI 12398 NTSTATUS 12399 NTAPI 12400 IoSetCompletionRoutineEx( 12401 IN PDEVICE_OBJECT DeviceObject, 12402 IN PIRP Irp, 12403 IN PIO_COMPLETION_ROUTINE CompletionRoutine, 12404 IN PVOID Context, 12405 IN BOOLEAN InvokeOnSuccess, 12406 IN BOOLEAN InvokeOnError, 12407 IN BOOLEAN InvokeOnCancel); 12408 12409 VOID 12410 NTAPI 12411 IoSetStartIoAttributes( 12412 IN PDEVICE_OBJECT DeviceObject, 12413 IN BOOLEAN DeferredStartIo, 12414 IN BOOLEAN NonCancelable); 12415 12416 NTKERNELAPI 12417 NTSTATUS 12418 NTAPI 12419 IoWMIDeviceObjectToInstanceName( 12420 IN PVOID DataBlockObject, 12421 IN PDEVICE_OBJECT DeviceObject, 12422 OUT PUNICODE_STRING InstanceName); 12423 12424 NTKERNELAPI 12425 NTSTATUS 12426 NTAPI 12427 IoWMIExecuteMethod( 12428 IN PVOID DataBlockObject, 12429 IN PUNICODE_STRING InstanceName, 12430 IN ULONG MethodId, 12431 IN ULONG InBufferSize, 12432 IN OUT PULONG OutBufferSize, 12433 IN OUT PUCHAR InOutBuffer); 12434 12435 NTKERNELAPI 12436 NTSTATUS 12437 NTAPI 12438 IoWMIHandleToInstanceName( 12439 IN PVOID DataBlockObject, 12440 IN HANDLE FileHandle, 12441 OUT PUNICODE_STRING InstanceName); 12442 12443 NTKERNELAPI 12444 NTSTATUS 12445 NTAPI 12446 IoWMIOpenBlock( 12447 IN GUID *DataBlockGuid, 12448 IN ULONG DesiredAccess, 12449 OUT PVOID *DataBlockObject); 12450 12451 NTKERNELAPI 12452 NTSTATUS 12453 NTAPI 12454 IoWMIQueryAllData( 12455 IN PVOID DataBlockObject, 12456 IN OUT ULONG *InOutBufferSize, 12457 OUT PVOID OutBuffer); 12458 12459 NTKERNELAPI 12460 NTSTATUS 12461 NTAPI 12462 IoWMIQueryAllDataMultiple( 12463 IN PVOID *DataBlockObjectList, 12464 IN ULONG ObjectCount, 12465 IN OUT ULONG *InOutBufferSize, 12466 OUT PVOID OutBuffer); 12467 12468 NTKERNELAPI 12469 NTSTATUS 12470 NTAPI 12471 IoWMIQuerySingleInstance( 12472 IN PVOID DataBlockObject, 12473 IN PUNICODE_STRING InstanceName, 12474 IN OUT ULONG *InOutBufferSize, 12475 OUT PVOID OutBuffer); 12476 12477 NTKERNELAPI 12478 NTSTATUS 12479 NTAPI 12480 IoWMISetNotificationCallback( 12481 IN OUT PVOID Object, 12482 IN WMI_NOTIFICATION_CALLBACK Callback, 12483 IN PVOID Context OPTIONAL); 12484 12485 NTKERNELAPI 12486 NTSTATUS 12487 NTAPI 12488 IoWMISetSingleInstance( 12489 IN PVOID DataBlockObject, 12490 IN PUNICODE_STRING InstanceName, 12491 IN ULONG Version, 12492 IN ULONG ValueBufferSize, 12493 IN PVOID ValueBuffer); 12494 12495 NTKERNELAPI 12496 NTSTATUS 12497 NTAPI 12498 IoWMISetSingleItem( 12499 IN PVOID DataBlockObject, 12500 IN PUNICODE_STRING InstanceName, 12501 IN ULONG DataItemId, 12502 IN ULONG Version, 12503 IN ULONG ValueBufferSize, 12504 IN PVOID ValueBuffer); 12505 12506 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 12507 12508 #if (NTDDI_VERSION >= NTDDI_WINXPSP1) 12509 NTKERNELAPI 12510 NTSTATUS 12511 NTAPI 12512 IoValidateDeviceIoControlAccess( 12513 IN PIRP Irp, 12514 IN ULONG RequiredAccess); 12515 #endif 12516 12517 #if (NTDDI_VERSION >= NTDDI_WS03) 12518 NTKERNELAPI 12519 NTSTATUS 12520 NTAPI 12521 IoCsqInitializeEx( 12522 IN PIO_CSQ Csq, 12523 IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp, 12524 IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, 12525 IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, 12526 IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, 12527 IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, 12528 IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); 12529 12530 NTKERNELAPI 12531 NTSTATUS 12532 NTAPI 12533 IoCsqInsertIrpEx( 12534 IN PIO_CSQ Csq, 12535 IN PIRP Irp, 12536 IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, 12537 IN PVOID InsertContext OPTIONAL); 12538 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ 12539 12540 12541 #if (NTDDI_VERSION >= NTDDI_VISTA) 12542 NTKERNELAPI 12543 NTSTATUS 12544 NTAPI 12545 IoGetBootDiskInformationLite( 12546 OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); 12547 12548 NTKERNELAPI 12549 NTSTATUS 12550 NTAPI 12551 IoCheckShareAccessEx( 12552 IN ACCESS_MASK DesiredAccess, 12553 IN ULONG DesiredShareAccess, 12554 IN OUT PFILE_OBJECT FileObject, 12555 IN OUT PSHARE_ACCESS ShareAccess, 12556 IN BOOLEAN Update, 12557 IN PBOOLEAN WritePermission); 12558 12559 NTKERNELAPI 12560 NTSTATUS 12561 NTAPI 12562 IoConnectInterruptEx( 12563 IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); 12564 12565 NTKERNELAPI 12566 VOID 12567 NTAPI 12568 IoDisconnectInterruptEx( 12569 IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); 12570 12571 LOGICAL 12572 NTAPI 12573 IoWithinStackLimits( 12574 IN ULONG_PTR RegionStart, 12575 IN SIZE_T RegionSize); 12576 12577 NTKERNELAPI 12578 VOID 12579 NTAPI 12580 IoSetShareAccessEx( 12581 IN ACCESS_MASK DesiredAccess, 12582 IN ULONG DesiredShareAccess, 12583 IN OUT PFILE_OBJECT FileObject, 12584 OUT PSHARE_ACCESS ShareAccess, 12585 IN PBOOLEAN WritePermission); 12586 12587 ULONG 12588 NTAPI 12589 IoSizeofWorkItem(VOID); 12590 12591 VOID 12592 NTAPI 12593 IoInitializeWorkItem( 12594 IN PVOID IoObject, 12595 IN PIO_WORKITEM IoWorkItem); 12596 12597 VOID 12598 NTAPI 12599 IoUninitializeWorkItem( 12600 IN PIO_WORKITEM IoWorkItem); 12601 12602 VOID 12603 NTAPI 12604 IoQueueWorkItemEx( 12605 IN PIO_WORKITEM IoWorkItem, 12606 IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, 12607 IN WORK_QUEUE_TYPE QueueType, 12608 IN PVOID Context OPTIONAL); 12609 12610 IO_PRIORITY_HINT 12611 NTAPI 12612 IoGetIoPriorityHint( 12613 IN PIRP Irp); 12614 12615 NTSTATUS 12616 NTAPI 12617 IoSetIoPriorityHint( 12618 IN PIRP Irp, 12619 IN IO_PRIORITY_HINT PriorityHint); 12620 12621 NTSTATUS 12622 NTAPI 12623 IoAllocateSfioStreamIdentifier( 12624 IN PFILE_OBJECT FileObject, 12625 IN ULONG Length, 12626 IN PVOID Signature, 12627 OUT PVOID *StreamIdentifier); 12628 12629 PVOID 12630 NTAPI 12631 IoGetSfioStreamIdentifier( 12632 IN PFILE_OBJECT FileObject, 12633 IN PVOID Signature); 12634 12635 NTSTATUS 12636 NTAPI 12637 IoFreeSfioStreamIdentifier( 12638 IN PFILE_OBJECT FileObject, 12639 IN PVOID Signature); 12640 12641 NTKERNELAPI 12642 NTSTATUS 12643 NTAPI 12644 IoRequestDeviceEjectEx( 12645 IN PDEVICE_OBJECT PhysicalDeviceObject, 12646 IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, 12647 IN PVOID Context OPTIONAL, 12648 IN PDRIVER_OBJECT DriverObject OPTIONAL); 12649 12650 NTKERNELAPI 12651 NTSTATUS 12652 NTAPI 12653 IoSetDevicePropertyData( 12654 IN PDEVICE_OBJECT Pdo, 12655 IN CONST DEVPROPKEY *PropertyKey, 12656 IN LCID Lcid, 12657 IN ULONG Flags, 12658 IN DEVPROPTYPE Type, 12659 IN ULONG Size, 12660 IN PVOID Data OPTIONAL); 12661 12662 NTKERNELAPI 12663 NTSTATUS 12664 NTAPI 12665 IoGetDevicePropertyData( 12666 PDEVICE_OBJECT Pdo, 12667 CONST DEVPROPKEY *PropertyKey, 12668 LCID Lcid, 12669 ULONG Flags, 12670 ULONG Size, 12671 PVOID Data, 12672 PULONG RequiredSize, 12673 PDEVPROPTYPE Type); 12674 12675 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 12676 12677 #define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) 12678 12679 #if (NTDDI_VERSION >= NTDDI_WS08) 12680 NTKERNELAPI 12681 NTSTATUS 12682 NTAPI 12683 IoReplacePartitionUnit( 12684 IN PDEVICE_OBJECT TargetPdo, 12685 IN PDEVICE_OBJECT SparePdo, 12686 IN ULONG Flags); 12687 #endif 12688 12689 #if (NTDDI_VERSION >= NTDDI_WIN7) 12690 12691 NTKERNELAPI 12692 NTSTATUS 12693 NTAPI 12694 IoGetAffinityInterrupt( 12695 IN PKINTERRUPT InterruptObject, 12696 OUT PGROUP_AFFINITY GroupAffinity); 12697 12698 NTSTATUS 12699 NTAPI 12700 IoGetContainerInformation( 12701 IN IO_CONTAINER_INFORMATION_CLASS InformationClass, 12702 IN PVOID ContainerObject OPTIONAL, 12703 IN OUT PVOID Buffer OPTIONAL, 12704 IN ULONG BufferLength); 12705 12706 NTSTATUS 12707 NTAPI 12708 IoRegisterContainerNotification( 12709 IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, 12710 IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, 12711 IN PVOID NotificationInformation OPTIONAL, 12712 IN ULONG NotificationInformationLength, 12713 OUT PVOID CallbackRegistration); 12714 12715 VOID 12716 NTAPI 12717 IoUnregisterContainerNotification( 12718 IN PVOID CallbackRegistration); 12719 12720 NTKERNELAPI 12721 NTSTATUS 12722 NTAPI 12723 IoUnregisterPlugPlayNotificationEx( 12724 IN PVOID NotificationEntry); 12725 12726 NTKERNELAPI 12727 NTSTATUS 12728 NTAPI 12729 IoGetDeviceNumaNode( 12730 IN PDEVICE_OBJECT Pdo, 12731 OUT PUSHORT NodeNumber); 12732 12733 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 12734 12735 #if defined(_WIN64) 12736 NTKERNELAPI 12737 ULONG 12738 NTAPI 12739 IoWMIDeviceObjectToProviderId( 12740 IN PDEVICE_OBJECT DeviceObject); 12741 #else 12742 #define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject)) 12743 #endif 12744 12745 /* 12746 * USHORT 12747 * IoSizeOfIrp( 12748 * IN CCHAR StackSize) 12749 */ 12750 #define IoSizeOfIrp(_StackSize) \ 12751 ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION))))) 12752 12753 FORCEINLINE 12754 VOID 12755 IoSkipCurrentIrpStackLocation( 12756 IN OUT PIRP Irp) 12757 { 12758 ASSERT(Irp->CurrentLocation <= Irp->StackCount); 12759 Irp->CurrentLocation++; 12760 #ifdef NONAMELESSUNION 12761 Irp->Tail.Overlay.s.u.CurrentStackLocation++; 12762 #else 12763 Irp->Tail.Overlay.CurrentStackLocation++; 12764 #endif 12765 } 12766 12767 FORCEINLINE 12768 VOID 12769 IoSetNextIrpStackLocation( 12770 IN OUT PIRP Irp) 12771 { 12772 ASSERT(Irp->CurrentLocation > 0); 12773 Irp->CurrentLocation--; 12774 #ifdef NONAMELESSUNION 12775 Irp->Tail.Overlay.s.u.CurrentStackLocation--; 12776 #else 12777 Irp->Tail.Overlay.CurrentStackLocation--; 12778 #endif 12779 } 12780 12781 FORCEINLINE 12782 PIO_STACK_LOCATION 12783 IoGetNextIrpStackLocation( 12784 IN PIRP Irp) 12785 { 12786 ASSERT(Irp->CurrentLocation > 0); 12787 #ifdef NONAMELESSUNION 12788 return ((Irp)->Tail.Overlay.s.u.CurrentStackLocation - 1 ); 12789 #else 12790 return ((Irp)->Tail.Overlay.CurrentStackLocation - 1 ); 12791 #endif 12792 } 12793 12794 FORCEINLINE 12795 VOID 12796 IoSetCompletionRoutine( 12797 IN PIRP Irp, 12798 IN PIO_COMPLETION_ROUTINE CompletionRoutine OPTIONAL, 12799 IN PVOID Context OPTIONAL, 12800 IN BOOLEAN InvokeOnSuccess, 12801 IN BOOLEAN InvokeOnError, 12802 IN BOOLEAN InvokeOnCancel) 12803 { 12804 PIO_STACK_LOCATION irpSp; 12805 ASSERT( (InvokeOnSuccess || InvokeOnError || InvokeOnCancel) ? (CompletionRoutine != NULL) : TRUE ); 12806 irpSp = IoGetNextIrpStackLocation(Irp); 12807 irpSp->CompletionRoutine = CompletionRoutine; 12808 irpSp->Context = Context; 12809 irpSp->Control = 0; 12810 12811 if (InvokeOnSuccess) { 12812 irpSp->Control = SL_INVOKE_ON_SUCCESS; 12813 } 12814 12815 if (InvokeOnError) { 12816 irpSp->Control |= SL_INVOKE_ON_ERROR; 12817 } 12818 12819 if (InvokeOnCancel) { 12820 irpSp->Control |= SL_INVOKE_ON_CANCEL; 12821 } 12822 } 12823 12824 /* 12825 * PDRIVER_CANCEL 12826 * IoSetCancelRoutine( 12827 * IN PIRP Irp, 12828 * IN PDRIVER_CANCEL CancelRoutine) 12829 */ 12830 #define IoSetCancelRoutine(_Irp, \ 12831 _CancelRoutine) \ 12832 ((PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( \ 12833 (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (ULONG_PTR) (_CancelRoutine))) 12834 12835 /* 12836 * VOID 12837 * IoRequestDpc( 12838 * IN PDEVICE_OBJECT DeviceObject, 12839 * IN PIRP Irp, 12840 * IN PVOID Context); 12841 */ 12842 #define IoRequestDpc(DeviceObject, Irp, Context)( \ 12843 KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context))) 12844 12845 /* 12846 * VOID 12847 * IoReleaseRemoveLock( 12848 * IN PIO_REMOVE_LOCK RemoveLock, 12849 * IN PVOID Tag) 12850 */ 12851 #define IoReleaseRemoveLock(_RemoveLock, \ 12852 _Tag) \ 12853 IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) 12854 12855 /* 12856 * VOID 12857 * IoReleaseRemoveLockAndWait( 12858 * IN PIO_REMOVE_LOCK RemoveLock, 12859 * IN PVOID Tag) 12860 */ 12861 #define IoReleaseRemoveLockAndWait(_RemoveLock, \ 12862 _Tag) \ 12863 IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) 12864 12865 #if defined(_WIN64) 12866 NTKERNELAPI 12867 BOOLEAN 12868 IoIs32bitProcess( 12869 IN PIRP Irp OPTIONAL); 12870 #endif 12871 12872 #define PLUGPLAY_REGKEY_DEVICE 1 12873 #define PLUGPLAY_REGKEY_DRIVER 2 12874 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4 12875 12876 FORCEINLINE 12877 PIO_STACK_LOCATION 12878 IoGetCurrentIrpStackLocation( 12879 IN PIRP Irp) 12880 { 12881 ASSERT(Irp->CurrentLocation <= Irp->StackCount + 1); 12882 #ifdef NONAMELESSUNION 12883 return Irp->Tail.Overlay.s.u.CurrentStackLocation; 12884 #else 12885 return Irp->Tail.Overlay.CurrentStackLocation; 12886 #endif 12887 } 12888 12889 FORCEINLINE 12890 VOID 12891 IoMarkIrpPending( 12892 IN OUT PIRP Irp) 12893 { 12894 IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED; 12895 } 12896 12897 /* 12898 * BOOLEAN 12899 * IoIsErrorUserInduced( 12900 * IN NTSTATUS Status); 12901 */ 12902 #define IoIsErrorUserInduced(Status) \ 12903 ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \ 12904 ((Status) == STATUS_IO_TIMEOUT) || \ 12905 ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \ 12906 ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \ 12907 ((Status) == STATUS_VERIFY_REQUIRED) || \ 12908 ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \ 12909 ((Status) == STATUS_WRONG_VOLUME))) 12910 12911 /* VOID 12912 * IoInitializeRemoveLock( 12913 * IN PIO_REMOVE_LOCK Lock, 12914 * IN ULONG AllocateTag, 12915 * IN ULONG MaxLockedMinutes, 12916 * IN ULONG HighWatermark) 12917 */ 12918 #define IoInitializeRemoveLock( \ 12919 Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \ 12920 IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \ 12921 HighWatermark, sizeof(IO_REMOVE_LOCK)) 12922 12923 FORCEINLINE 12924 VOID 12925 IoInitializeDpcRequest( 12926 IN PDEVICE_OBJECT DeviceObject, 12927 IN PIO_DPC_ROUTINE DpcRoutine) 12928 { 12929 KeInitializeDpc( &DeviceObject->Dpc, 12930 (PKDEFERRED_ROUTINE) DpcRoutine, 12931 DeviceObject ); 12932 } 12933 12934 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001 12935 12936 /* 12937 * ULONG 12938 * IoGetFunctionCodeFromCtlCode( 12939 * IN ULONG ControlCode) 12940 */ 12941 #define IoGetFunctionCodeFromCtlCode(_ControlCode) \ 12942 (((_ControlCode) >> 2) & 0x00000FFF) 12943 12944 FORCEINLINE 12945 VOID 12946 IoCopyCurrentIrpStackLocationToNext( 12947 IN OUT PIRP Irp) 12948 { 12949 PIO_STACK_LOCATION irpSp; 12950 PIO_STACK_LOCATION nextIrpSp; 12951 irpSp = IoGetCurrentIrpStackLocation(Irp); 12952 nextIrpSp = IoGetNextIrpStackLocation(Irp); 12953 RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); 12954 nextIrpSp->Control = 0; 12955 } 12956 12957 NTKERNELAPI 12958 VOID 12959 NTAPI 12960 IoGetStackLimits( 12961 OUT PULONG_PTR LowLimit, 12962 OUT PULONG_PTR HighLimit); 12963 12964 FORCEINLINE 12965 ULONG_PTR 12966 IoGetRemainingStackSize(VOID) 12967 { 12968 ULONG_PTR End, Begin; 12969 ULONG_PTR Result; 12970 12971 IoGetStackLimits(&Begin, &End); 12972 Result = (ULONG_PTR)(&End) - Begin; 12973 return Result; 12974 } 12975 12976 #if (NTDDI_VERSION >= NTDDI_WS03) 12977 FORCEINLINE 12978 VOID 12979 IoInitializeThreadedDpcRequest( 12980 IN PDEVICE_OBJECT DeviceObject, 12981 IN PIO_DPC_ROUTINE DpcRoutine) 12982 { 12983 KeInitializeThreadedDpc(&DeviceObject->Dpc, 12984 (PKDEFERRED_ROUTINE) DpcRoutine, 12985 DeviceObject ); 12986 } 12987 #endif 12988 12989 /****************************************************************************** 12990 * Power Management Support Functions * 12991 ******************************************************************************/ 12992 12993 #define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0)) 12994 12995 #if (NTDDI_VERSION >= NTDDI_WIN2K) 12996 12997 NTKERNELAPI 12998 NTSTATUS 12999 NTAPI 13000 PoCallDriver( 13001 IN struct _DEVICE_OBJECT *DeviceObject, 13002 IN OUT struct _IRP *Irp); 13003 13004 NTKERNELAPI 13005 PULONG 13006 NTAPI 13007 PoRegisterDeviceForIdleDetection( 13008 IN struct _DEVICE_OBJECT *DeviceObject, 13009 IN ULONG ConservationIdleTime, 13010 IN ULONG PerformanceIdleTime, 13011 IN DEVICE_POWER_STATE State); 13012 13013 NTKERNELAPI 13014 PVOID 13015 NTAPI 13016 PoRegisterSystemState( 13017 IN OUT PVOID StateHandle OPTIONAL, 13018 IN EXECUTION_STATE Flags); 13019 13020 NTKERNELAPI 13021 NTSTATUS 13022 NTAPI 13023 PoRequestPowerIrp( 13024 IN struct _DEVICE_OBJECT *DeviceObject, 13025 IN UCHAR MinorFunction, 13026 IN POWER_STATE PowerState, 13027 IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, 13028 IN PVOID Context OPTIONAL, 13029 OUT struct _IRP **Irp OPTIONAL); 13030 13031 NTKERNELAPI 13032 POWER_STATE 13033 NTAPI 13034 PoSetPowerState( 13035 IN struct _DEVICE_OBJECT *DeviceObject, 13036 IN POWER_STATE_TYPE Type, 13037 IN POWER_STATE State); 13038 13039 NTKERNELAPI 13040 VOID 13041 NTAPI 13042 PoSetSystemState( 13043 IN EXECUTION_STATE Flags); 13044 13045 NTKERNELAPI 13046 VOID 13047 NTAPI 13048 PoStartNextPowerIrp( 13049 IN OUT struct _IRP *Irp); 13050 13051 NTKERNELAPI 13052 VOID 13053 NTAPI 13054 PoUnregisterSystemState( 13055 IN OUT PVOID StateHandle); 13056 13057 NTKERNELAPI 13058 NTSTATUS 13059 NTAPI 13060 PoRequestShutdownEvent( 13061 OUT PVOID *Event); 13062 13063 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 13064 13065 #if (NTDDI_VERSION >= NTDDI_VISTA) 13066 13067 NTKERNELAPI 13068 VOID 13069 NTAPI 13070 PoSetSystemWake( 13071 IN OUT struct _IRP *Irp); 13072 13073 NTKERNELAPI 13074 BOOLEAN 13075 NTAPI 13076 PoGetSystemWake( 13077 IN struct _IRP *Irp); 13078 13079 NTKERNELAPI 13080 NTSTATUS 13081 NTAPI 13082 PoRegisterPowerSettingCallback( 13083 IN PDEVICE_OBJECT DeviceObject OPTIONAL, 13084 IN LPCGUID SettingGuid, 13085 IN PPOWER_SETTING_CALLBACK Callback, 13086 IN PVOID Context OPTIONAL, 13087 OUT PVOID *Handle OPTIONAL); 13088 13089 NTKERNELAPI 13090 NTSTATUS 13091 NTAPI 13092 PoUnregisterPowerSettingCallback( 13093 IN OUT PVOID Handle); 13094 13095 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 13096 13097 #if (NTDDI_VERSION >= NTDDI_VISTASP1) 13098 NTKERNELAPI 13099 VOID 13100 NTAPI 13101 PoSetDeviceBusyEx( 13102 IN OUT PULONG IdlePointer); 13103 #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ 13104 13105 #if (NTDDI_VERSION >= NTDDI_WIN7) 13106 13107 NTKERNELAPI 13108 VOID 13109 NTAPI 13110 PoStartDeviceBusy( 13111 IN OUT PULONG IdlePointer); 13112 13113 NTKERNELAPI 13114 VOID 13115 NTAPI 13116 PoEndDeviceBusy( 13117 IN OUT PULONG IdlePointer); 13118 13119 NTKERNELAPI 13120 BOOLEAN 13121 NTAPI 13122 PoQueryWatchdogTime( 13123 IN PDEVICE_OBJECT Pdo, 13124 OUT PULONG SecondsRemaining); 13125 13126 NTKERNELAPI 13127 VOID 13128 NTAPI 13129 PoDeletePowerRequest( 13130 IN OUT PVOID PowerRequest); 13131 13132 NTKERNELAPI 13133 NTSTATUS 13134 NTAPI 13135 PoSetPowerRequest( 13136 IN OUT PVOID PowerRequest, 13137 IN POWER_REQUEST_TYPE Type); 13138 13139 NTKERNELAPI 13140 NTSTATUS 13141 NTAPI 13142 PoClearPowerRequest( 13143 IN OUT PVOID PowerRequest, 13144 IN POWER_REQUEST_TYPE Type); 13145 13146 NTKERNELAPI 13147 NTSTATUS 13148 NTAPI 13149 PoCreatePowerRequest( 13150 OUT PVOID *PowerRequest, 13151 IN PDEVICE_OBJECT DeviceObject, 13152 IN PCOUNTED_REASON_CONTEXT Context); 13153 13154 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 13155 13156 /****************************************************************************** 13157 * Executive Functions * 13158 ******************************************************************************/ 13159 13160 #define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend) 13161 #define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend) 13162 #define ExInterlockedExchangeUlong(Target, Value, Lock) Exfi386InterlockedExchangeUlong(Target, Value) 13163 13164 #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql)) 13165 #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql)) 13166 #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock) 13167 #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock) 13168 13169 #define ExInitializeSListHead InitializeSListHead 13170 13171 #if defined(_NTHAL_) && defined(_X86_) 13172 13173 NTKERNELAPI 13174 VOID 13175 FASTCALL 13176 ExiAcquireFastMutex( 13177 IN OUT PFAST_MUTEX FastMutex); 13178 13179 NTKERNELAPI 13180 VOID 13181 FASTCALL 13182 ExiReleaseFastMutex( 13183 IN OUT PFAST_MUTEX FastMutex); 13184 13185 NTKERNELAPI 13186 BOOLEAN 13187 FASTCALL 13188 ExiTryToAcquireFastMutex( 13189 IN OUT PFAST_MUTEX FastMutex); 13190 13191 #define ExAcquireFastMutex ExiAcquireFastMutex 13192 #define ExReleaseFastMutex ExiReleaseFastMutex 13193 #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex 13194 13195 #else 13196 13197 #if (NTDDI_VERSION >= NTDDI_WIN2K) 13198 13199 NTKERNELAPI 13200 VOID 13201 FASTCALL 13202 ExAcquireFastMutex( 13203 IN OUT PFAST_MUTEX FastMutex); 13204 13205 NTKERNELAPI 13206 VOID 13207 FASTCALL 13208 ExReleaseFastMutex( 13209 IN OUT PFAST_MUTEX FastMutex); 13210 13211 NTKERNELAPI 13212 BOOLEAN 13213 FASTCALL 13214 ExTryToAcquireFastMutex( 13215 IN OUT PFAST_MUTEX FastMutex); 13216 13217 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 13218 13219 #endif /* defined(_NTHAL_) && defined(_X86_) */ 13220 13221 #if defined(_X86_) 13222 #define ExInterlockedAddUlong ExfInterlockedAddUlong 13223 #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList 13224 #define ExInterlockedInsertTailList ExfInterlockedInsertTailList 13225 #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList 13226 #define ExInterlockedPopEntryList ExfInterlockedPopEntryList 13227 #define ExInterlockedPushEntryList ExfInterlockedPushEntryList 13228 #endif /* defined(_X86_) */ 13229 13230 #if defined(_WIN64) 13231 13232 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || \ 13233 defined(_NTHAL_) || defined(_NTOSP_) 13234 NTKERNELAPI 13235 USHORT 13236 ExQueryDepthSList(IN PSLIST_HEADER ListHead); 13237 #else 13238 FORCEINLINE 13239 USHORT 13240 ExQueryDepthSList(IN PSLIST_HEADER ListHead) 13241 { 13242 return (USHORT)(ListHead->Alignment & 0xffff); 13243 } 13244 #endif 13245 13246 NTKERNELAPI 13247 PSLIST_ENTRY 13248 ExpInterlockedFlushSList( 13249 PSLIST_HEADER ListHead); 13250 13251 NTKERNELAPI 13252 PSLIST_ENTRY 13253 ExpInterlockedPopEntrySList( 13254 PSLIST_HEADER ListHead); 13255 13256 NTKERNELAPI 13257 PSLIST_ENTRY 13258 ExpInterlockedPushEntrySList( 13259 PSLIST_HEADER ListHead, 13260 PSLIST_ENTRY ListEntry); 13261 13262 #define ExInterlockedFlushSList(Head) \ 13263 ExpInterlockedFlushSList(Head) 13264 #define ExInterlockedPopEntrySList(Head, Lock) \ 13265 ExpInterlockedPopEntrySList(Head) 13266 #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ 13267 ExpInterlockedPushEntrySList(Head, Entry) 13268 13269 #else /* !defined(_WIN64) */ 13270 13271 #ifdef NONAMELESSUNION 13272 #define ExQueryDepthSList(listhead) (listhead)->s.Depth 13273 #else 13274 #define ExQueryDepthSList(listhead) (listhead)->Depth 13275 #endif 13276 13277 NTKERNELAPI 13278 PSINGLE_LIST_ENTRY 13279 FASTCALL 13280 ExInterlockedFlushSList( 13281 IN OUT PSLIST_HEADER ListHead); 13282 13283 #endif /* !defined(_WIN64) */ 13284 13285 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) 13286 13287 NTKERNELAPI 13288 PSINGLE_LIST_ENTRY 13289 FASTCALL 13290 ExInterlockedPopEntrySList( 13291 IN PSLIST_HEADER ListHead, 13292 IN PKSPIN_LOCK Lock); 13293 13294 NTKERNELAPI 13295 PSINGLE_LIST_ENTRY 13296 FASTCALL 13297 ExInterlockedPushEntrySList( 13298 IN PSLIST_HEADER ListHead, 13299 IN PSINGLE_LIST_ENTRY ListEntry, 13300 IN PKSPIN_LOCK Lock); 13301 13302 NTKERNELAPI 13303 PVOID 13304 NTAPI 13305 ExAllocateFromPagedLookasideList( 13306 IN OUT PPAGED_LOOKASIDE_LIST Lookaside); 13307 13308 NTKERNELAPI 13309 VOID 13310 NTAPI 13311 ExFreeToPagedLookasideList( 13312 IN OUT PPAGED_LOOKASIDE_LIST Lookaside, 13313 IN PVOID Entry); 13314 13315 #else /* !_WIN2K_COMPAT_SLIST_USAGE */ 13316 13317 #if !defined(_WIN64) 13318 #define ExInterlockedPopEntrySList(_ListHead, _Lock) \ 13319 InterlockedPopEntrySList(_ListHead) 13320 #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ 13321 InterlockedPushEntrySList(_ListHead, _ListEntry) 13322 #endif 13323 13324 static __inline 13325 PVOID 13326 ExAllocateFromPagedLookasideList( 13327 IN OUT PPAGED_LOOKASIDE_LIST Lookaside) 13328 { 13329 PVOID Entry; 13330 13331 Lookaside->L.TotalAllocates++; 13332 #ifdef NONAMELESSUNION 13333 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead); 13334 if (Entry == NULL) { 13335 Lookaside->L.u2.AllocateMisses++; 13336 Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type, 13337 Lookaside->L.Size, 13338 Lookaside->L.Tag); 13339 } 13340 #else /* NONAMELESSUNION */ 13341 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); 13342 if (Entry == NULL) { 13343 Lookaside->L.AllocateMisses++; 13344 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, 13345 Lookaside->L.Size, 13346 Lookaside->L.Tag); 13347 } 13348 #endif /* NONAMELESSUNION */ 13349 return Entry; 13350 } 13351 13352 static __inline 13353 VOID 13354 ExFreeToPagedLookasideList( 13355 IN OUT PPAGED_LOOKASIDE_LIST Lookaside, 13356 IN PVOID Entry) 13357 { 13358 Lookaside->L.TotalFrees++; 13359 #ifdef NONAMELESSUNION 13360 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) { 13361 Lookaside->L.u3.FreeMisses++; 13362 (Lookaside->L.u5.Free)(Entry); 13363 } else { 13364 InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry); 13365 } 13366 #else /* NONAMELESSUNION */ 13367 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { 13368 Lookaside->L.FreeMisses++; 13369 (Lookaside->L.Free)(Entry); 13370 } else { 13371 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); 13372 } 13373 #endif /* NONAMELESSUNION */ 13374 } 13375 13376 #endif /* _WIN2K_COMPAT_SLIST_USAGE */ 13377 13378 13379 /* ERESOURCE_THREAD 13380 * ExGetCurrentResourceThread( 13381 * VOID); 13382 */ 13383 #define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread()) 13384 13385 #define ExReleaseResource(R) (ExReleaseResourceLite(R)) 13386 13387 /* VOID 13388 * ExInitializeWorkItem( 13389 * IN PWORK_QUEUE_ITEM Item, 13390 * IN PWORKER_THREAD_ROUTINE Routine, 13391 * IN PVOID Context) 13392 */ 13393 #define ExInitializeWorkItem(Item, Routine, Context) \ 13394 { \ 13395 (Item)->WorkerRoutine = Routine; \ 13396 (Item)->Parameter = Context; \ 13397 (Item)->List.Flink = NULL; \ 13398 } 13399 13400 FORCEINLINE 13401 VOID 13402 ExInitializeFastMutex( 13403 OUT PFAST_MUTEX FastMutex) 13404 { 13405 FastMutex->Count = FM_LOCK_BIT; 13406 FastMutex->Owner = NULL; 13407 FastMutex->Contention = 0; 13408 KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE); 13409 return; 13410 } 13411 13412 13413 #if (NTDDI_VERSION >= NTDDI_WIN2K) 13414 NTKERNELAPI 13415 VOID 13416 FASTCALL 13417 ExAcquireFastMutexUnsafe( 13418 IN OUT PFAST_MUTEX FastMutex); 13419 13420 NTKERNELAPI 13421 VOID 13422 FASTCALL 13423 ExReleaseFastMutexUnsafe( 13424 IN OUT PFAST_MUTEX FastMutex); 13425 13426 NTKERNELAPI 13427 BOOLEAN 13428 NTAPI 13429 ExAcquireResourceExclusiveLite( 13430 IN OUT PERESOURCE Resource, 13431 IN BOOLEAN Wait); 13432 13433 NTKERNELAPI 13434 BOOLEAN 13435 NTAPI 13436 ExAcquireResourceSharedLite( 13437 IN OUT PERESOURCE Resource, 13438 IN BOOLEAN Wait); 13439 13440 NTKERNELAPI 13441 BOOLEAN 13442 NTAPI 13443 ExAcquireSharedStarveExclusive( 13444 IN OUT PERESOURCE Resource, 13445 IN BOOLEAN Wait); 13446 13447 NTKERNELAPI 13448 BOOLEAN 13449 NTAPI 13450 ExAcquireSharedWaitForExclusive( 13451 IN OUT PERESOURCE Resource, 13452 IN BOOLEAN Wait); 13453 13454 NTKERNELAPI 13455 PVOID 13456 NTAPI 13457 ExAllocatePool( 13458 IN POOL_TYPE PoolType, 13459 IN SIZE_T NumberOfBytes); 13460 13461 NTKERNELAPI 13462 PVOID 13463 NTAPI 13464 ExAllocatePoolWithQuota( 13465 IN POOL_TYPE PoolType, 13466 IN SIZE_T NumberOfBytes); 13467 13468 NTKERNELAPI 13469 PVOID 13470 NTAPI 13471 ExAllocatePoolWithQuotaTag( 13472 IN POOL_TYPE PoolType, 13473 IN SIZE_T NumberOfBytes, 13474 IN ULONG Tag); 13475 13476 #ifndef POOL_TAGGING 13477 #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) 13478 #endif 13479 13480 NTKERNELAPI 13481 PVOID 13482 NTAPI 13483 ExAllocatePoolWithTag( 13484 IN POOL_TYPE PoolType, 13485 IN SIZE_T NumberOfBytes, 13486 IN ULONG Tag); 13487 13488 #ifndef POOL_TAGGING 13489 #define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b) 13490 #endif 13491 13492 NTKERNELAPI 13493 PVOID 13494 NTAPI 13495 ExAllocatePoolWithTagPriority( 13496 IN POOL_TYPE PoolType, 13497 IN SIZE_T NumberOfBytes, 13498 IN ULONG Tag, 13499 IN EX_POOL_PRIORITY Priority); 13500 13501 NTKERNELAPI 13502 VOID 13503 NTAPI 13504 ExConvertExclusiveToSharedLite( 13505 IN OUT PERESOURCE Resource); 13506 13507 NTKERNELAPI 13508 NTSTATUS 13509 NTAPI 13510 ExCreateCallback( 13511 OUT PCALLBACK_OBJECT *CallbackObject, 13512 IN POBJECT_ATTRIBUTES ObjectAttributes, 13513 IN BOOLEAN Create, 13514 IN BOOLEAN AllowMultipleCallbacks); 13515 13516 NTKERNELAPI 13517 VOID 13518 NTAPI 13519 ExDeleteNPagedLookasideList( 13520 IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); 13521 13522 NTKERNELAPI 13523 VOID 13524 NTAPI 13525 ExDeletePagedLookasideList( 13526 IN PPAGED_LOOKASIDE_LIST Lookaside); 13527 13528 NTKERNELAPI 13529 NTSTATUS 13530 NTAPI 13531 ExDeleteResourceLite( 13532 IN OUT PERESOURCE Resource); 13533 13534 NTKERNELAPI 13535 VOID 13536 NTAPI 13537 ExFreePool( 13538 IN PVOID P); 13539 13540 NTKERNELAPI 13541 VOID 13542 NTAPI 13543 ExFreePoolWithTag( 13544 IN PVOID P, 13545 IN ULONG Tag); 13546 13547 NTKERNELAPI 13548 ULONG 13549 NTAPI 13550 ExGetExclusiveWaiterCount( 13551 IN PERESOURCE Resource); 13552 13553 NTKERNELAPI 13554 KPROCESSOR_MODE 13555 NTAPI 13556 ExGetPreviousMode(VOID); 13557 13558 NTKERNELAPI 13559 ULONG 13560 NTAPI 13561 ExGetSharedWaiterCount( 13562 IN PERESOURCE Resource); 13563 13564 NTKERNELAPI 13565 VOID 13566 NTAPI 13567 ExInitializeNPagedLookasideList( 13568 IN PNPAGED_LOOKASIDE_LIST Lookaside, 13569 IN PALLOCATE_FUNCTION Allocate OPTIONAL, 13570 IN PFREE_FUNCTION Free OPTIONAL, 13571 IN ULONG Flags, 13572 IN SIZE_T Size, 13573 IN ULONG Tag, 13574 IN USHORT Depth); 13575 13576 NTKERNELAPI 13577 VOID 13578 NTAPI 13579 ExInitializePagedLookasideList( 13580 IN PPAGED_LOOKASIDE_LIST Lookaside, 13581 IN PALLOCATE_FUNCTION Allocate OPTIONAL, 13582 IN PFREE_FUNCTION Free OPTIONAL, 13583 IN ULONG Flags, 13584 IN SIZE_T Size, 13585 IN ULONG Tag, 13586 IN USHORT Depth); 13587 13588 NTKERNELAPI 13589 NTSTATUS 13590 NTAPI 13591 ExInitializeResourceLite( 13592 OUT PERESOURCE Resource); 13593 13594 NTKERNELAPI 13595 LARGE_INTEGER 13596 NTAPI 13597 ExInterlockedAddLargeInteger( 13598 IN PLARGE_INTEGER Addend, 13599 IN LARGE_INTEGER Increment, 13600 IN PKSPIN_LOCK Lock); 13601 13602 #if defined(_WIN64) 13603 #define ExInterlockedAddLargeStatistic(Addend, Increment) \ 13604 (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment) 13605 #else 13606 #define ExInterlockedAddLargeStatistic(Addend, Increment) \ 13607 _InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment) 13608 #endif 13609 13610 NTKERNELAPI 13611 ULONG 13612 FASTCALL 13613 ExInterlockedAddUlong( 13614 IN PULONG Addend, 13615 IN ULONG Increment, 13616 IN OUT PKSPIN_LOCK Lock); 13617 13618 #if defined(_AMD64_) || defined(_IA64_) 13619 13620 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ 13621 InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) 13622 13623 #elif defined(_X86_) 13624 13625 NTKERNELAPI 13626 LONGLONG 13627 FASTCALL 13628 ExfInterlockedCompareExchange64( 13629 IN OUT LONGLONG volatile *Destination, 13630 IN PLONGLONG Exchange, 13631 IN PLONGLONG Comperand); 13632 13633 #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ 13634 ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) 13635 13636 #else 13637 13638 NTKERNELAPI 13639 LONGLONG 13640 FASTCALL 13641 ExInterlockedCompareExchange64( 13642 IN OUT LONGLONG volatile *Destination, 13643 IN PLONGLONG Exchange, 13644 IN PLONGLONG Comparand, 13645 IN PKSPIN_LOCK Lock); 13646 13647 #endif /* defined(_AMD64_) || defined(_IA64_) */ 13648 13649 NTKERNELAPI 13650 PLIST_ENTRY 13651 FASTCALL 13652 ExInterlockedInsertHeadList( 13653 IN OUT PLIST_ENTRY ListHead, 13654 IN OUT PLIST_ENTRY ListEntry, 13655 IN OUT PKSPIN_LOCK Lock); 13656 13657 NTKERNELAPI 13658 PLIST_ENTRY 13659 FASTCALL 13660 ExInterlockedInsertTailList( 13661 IN OUT PLIST_ENTRY ListHead, 13662 IN OUT PLIST_ENTRY ListEntry, 13663 IN OUT PKSPIN_LOCK Lock); 13664 13665 NTKERNELAPI 13666 PSINGLE_LIST_ENTRY 13667 FASTCALL 13668 ExInterlockedPopEntryList( 13669 IN OUT PSINGLE_LIST_ENTRY ListHead, 13670 IN OUT PKSPIN_LOCK Lock); 13671 13672 NTKERNELAPI 13673 PSINGLE_LIST_ENTRY 13674 FASTCALL 13675 ExInterlockedPushEntryList( 13676 IN OUT PSINGLE_LIST_ENTRY ListHead, 13677 IN OUT PSINGLE_LIST_ENTRY ListEntry, 13678 IN OUT PKSPIN_LOCK Lock); 13679 13680 NTKERNELAPI 13681 PLIST_ENTRY 13682 FASTCALL 13683 ExInterlockedRemoveHeadList( 13684 IN OUT PLIST_ENTRY ListHead, 13685 IN OUT PKSPIN_LOCK Lock); 13686 13687 NTKERNELAPI 13688 BOOLEAN 13689 NTAPI 13690 ExIsProcessorFeaturePresent( 13691 IN ULONG ProcessorFeature); 13692 13693 NTKERNELAPI 13694 BOOLEAN 13695 NTAPI 13696 ExIsResourceAcquiredExclusiveLite( 13697 IN PERESOURCE Resource); 13698 13699 NTKERNELAPI 13700 ULONG 13701 NTAPI 13702 ExIsResourceAcquiredSharedLite( 13703 IN PERESOURCE Resource); 13704 13705 #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite 13706 13707 NTKERNELAPI 13708 VOID 13709 NTAPI 13710 ExLocalTimeToSystemTime( 13711 IN PLARGE_INTEGER LocalTime, 13712 OUT PLARGE_INTEGER SystemTime); 13713 13714 NTKERNELAPI 13715 VOID 13716 NTAPI 13717 ExNotifyCallback( 13718 IN PCALLBACK_OBJECT CallbackObject, 13719 IN PVOID Argument1 OPTIONAL, 13720 IN PVOID Argument2 OPTIONAL); 13721 13722 NTKERNELAPI 13723 VOID 13724 NTAPI 13725 ExQueueWorkItem( 13726 IN OUT PWORK_QUEUE_ITEM WorkItem, 13727 IN WORK_QUEUE_TYPE QueueType); 13728 13729 NTKERNELAPI 13730 DECLSPEC_NORETURN 13731 VOID 13732 NTAPI 13733 ExRaiseStatus( 13734 IN NTSTATUS Status); 13735 13736 NTKERNELAPI 13737 PVOID 13738 NTAPI 13739 ExRegisterCallback( 13740 IN PCALLBACK_OBJECT CallbackObject, 13741 IN PCALLBACK_FUNCTION CallbackFunction, 13742 IN PVOID CallbackContext OPTIONAL); 13743 13744 NTKERNELAPI 13745 NTSTATUS 13746 NTAPI 13747 ExReinitializeResourceLite( 13748 IN OUT PERESOURCE Resource); 13749 13750 NTKERNELAPI 13751 VOID 13752 NTAPI 13753 ExReleaseResourceForThreadLite( 13754 IN OUT PERESOURCE Resource, 13755 IN ERESOURCE_THREAD ResourceThreadId); 13756 13757 NTKERNELAPI 13758 VOID 13759 FASTCALL 13760 ExReleaseResourceLite( 13761 IN OUT PERESOURCE Resource); 13762 13763 NTKERNELAPI 13764 VOID 13765 NTAPI 13766 ExSetResourceOwnerPointer( 13767 IN OUT PERESOURCE Resource, 13768 IN PVOID OwnerPointer); 13769 13770 NTKERNELAPI 13771 ULONG 13772 NTAPI 13773 ExSetTimerResolution( 13774 IN ULONG DesiredTime, 13775 IN BOOLEAN SetResolution); 13776 13777 NTKERNELAPI 13778 VOID 13779 NTAPI 13780 ExSystemTimeToLocalTime( 13781 IN PLARGE_INTEGER SystemTime, 13782 OUT PLARGE_INTEGER LocalTime); 13783 13784 NTKERNELAPI 13785 VOID 13786 NTAPI 13787 ExUnregisterCallback( 13788 IN OUT PVOID CbRegistration); 13789 13790 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 13791 13792 #if (NTDDI_VERSION >= NTDDI_WINXP) 13793 13794 NTKERNELAPI 13795 BOOLEAN 13796 FASTCALL 13797 ExAcquireRundownProtection( 13798 IN OUT PEX_RUNDOWN_REF RunRef); 13799 13800 NTKERNELAPI 13801 VOID 13802 FASTCALL 13803 ExInitializeRundownProtection( 13804 OUT PEX_RUNDOWN_REF RunRef); 13805 13806 NTKERNELAPI 13807 VOID 13808 FASTCALL 13809 ExReInitializeRundownProtection( 13810 IN OUT PEX_RUNDOWN_REF RunRef); 13811 13812 NTKERNELAPI 13813 VOID 13814 FASTCALL 13815 ExReleaseRundownProtection( 13816 IN OUT PEX_RUNDOWN_REF RunRef); 13817 13818 NTKERNELAPI 13819 VOID 13820 FASTCALL 13821 ExRundownCompleted( 13822 OUT PEX_RUNDOWN_REF RunRef); 13823 13824 NTKERNELAPI 13825 BOOLEAN 13826 NTAPI 13827 ExVerifySuite( 13828 IN SUITE_TYPE SuiteType); 13829 13830 NTKERNELAPI 13831 VOID 13832 FASTCALL 13833 ExWaitForRundownProtectionRelease( 13834 IN OUT PEX_RUNDOWN_REF RunRef); 13835 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 13836 13837 #if (NTDDI_VERSION >= NTDDI_WINXPSP2) 13838 13839 NTKERNELAPI 13840 BOOLEAN 13841 FASTCALL 13842 ExAcquireRundownProtectionEx( 13843 IN OUT PEX_RUNDOWN_REF RunRef, 13844 IN ULONG Count); 13845 13846 NTKERNELAPI 13847 VOID 13848 FASTCALL 13849 ExReleaseRundownProtectionEx( 13850 IN OUT PEX_RUNDOWN_REF RunRef, 13851 IN ULONG Count); 13852 13853 #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ 13854 13855 #if (NTDDI_VERSION >= NTDDI_WS03SP1) 13856 13857 NTKERNELAPI 13858 PEX_RUNDOWN_REF_CACHE_AWARE 13859 NTAPI 13860 ExAllocateCacheAwareRundownProtection( 13861 IN POOL_TYPE PoolType, 13862 IN ULONG PoolTag); 13863 13864 NTKERNELAPI 13865 SIZE_T 13866 NTAPI 13867 ExSizeOfRundownProtectionCacheAware(VOID); 13868 13869 NTKERNELAPI 13870 PVOID 13871 NTAPI 13872 ExEnterCriticalRegionAndAcquireResourceShared( 13873 IN OUT PERESOURCE Resource); 13874 13875 NTKERNELAPI 13876 PVOID 13877 NTAPI 13878 ExEnterCriticalRegionAndAcquireResourceExclusive( 13879 IN OUT PERESOURCE Resource); 13880 13881 NTKERNELAPI 13882 PVOID 13883 NTAPI 13884 ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( 13885 IN OUT PERESOURCE Resource); 13886 13887 NTKERNELAPI 13888 VOID 13889 FASTCALL 13890 ExReleaseResourceAndLeaveCriticalRegion( 13891 IN OUT PERESOURCE Resource); 13892 13893 NTKERNELAPI 13894 VOID 13895 NTAPI 13896 ExInitializeRundownProtectionCacheAware( 13897 OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, 13898 IN SIZE_T RunRefSize); 13899 13900 NTKERNELAPI 13901 VOID 13902 NTAPI 13903 ExFreeCacheAwareRundownProtection( 13904 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); 13905 13906 NTKERNELAPI 13907 BOOLEAN 13908 FASTCALL 13909 ExAcquireRundownProtectionCacheAware( 13910 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); 13911 13912 NTKERNELAPI 13913 VOID 13914 FASTCALL 13915 ExReleaseRundownProtectionCacheAware( 13916 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); 13917 13918 NTKERNELAPI 13919 BOOLEAN 13920 FASTCALL 13921 ExAcquireRundownProtectionCacheAwareEx( 13922 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, 13923 IN ULONG Count); 13924 13925 NTKERNELAPI 13926 VOID 13927 FASTCALL 13928 ExReleaseRundownProtectionCacheAwareEx( 13929 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, 13930 IN ULONG Count); 13931 13932 NTKERNELAPI 13933 VOID 13934 FASTCALL 13935 ExWaitForRundownProtectionReleaseCacheAware( 13936 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); 13937 13938 NTKERNELAPI 13939 VOID 13940 FASTCALL 13941 ExReInitializeRundownProtectionCacheAware( 13942 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); 13943 13944 NTKERNELAPI 13945 VOID 13946 FASTCALL 13947 ExRundownCompletedCacheAware( 13948 IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); 13949 13950 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ 13951 13952 #if (NTDDI_VERSION >= NTDDI_VISTA) 13953 13954 NTKERNELAPI 13955 NTSTATUS 13956 NTAPI 13957 ExInitializeLookasideListEx( 13958 OUT PLOOKASIDE_LIST_EX Lookaside, 13959 IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, 13960 IN PFREE_FUNCTION_EX Free OPTIONAL, 13961 IN POOL_TYPE PoolType, 13962 IN ULONG Flags, 13963 IN SIZE_T Size, 13964 IN ULONG Tag, 13965 IN USHORT Depth); 13966 13967 NTKERNELAPI 13968 VOID 13969 NTAPI 13970 ExDeleteLookasideListEx( 13971 IN OUT PLOOKASIDE_LIST_EX Lookaside); 13972 13973 NTKERNELAPI 13974 VOID 13975 NTAPI 13976 ExFlushLookasideListEx( 13977 IN OUT PLOOKASIDE_LIST_EX Lookaside); 13978 13979 FORCEINLINE 13980 PVOID 13981 ExAllocateFromLookasideListEx( 13982 IN OUT PLOOKASIDE_LIST_EX Lookaside) 13983 { 13984 PVOID Entry; 13985 13986 Lookaside->L.TotalAllocates += 1; 13987 #ifdef NONAMELESSUNION 13988 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead); 13989 if (Entry == NULL) { 13990 Lookaside->L.u2.AllocateMisses += 1; 13991 Entry = (Lookaside->L.u4.AllocateEx)(Lookaside->L.Type, 13992 Lookaside->L.Size, 13993 Lookaside->L.Tag, 13994 Lookaside); 13995 } 13996 #else /* NONAMELESSUNION */ 13997 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); 13998 if (Entry == NULL) { 13999 Lookaside->L.AllocateMisses += 1; 14000 Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type, 14001 Lookaside->L.Size, 14002 Lookaside->L.Tag, 14003 Lookaside); 14004 } 14005 #endif /* NONAMELESSUNION */ 14006 return Entry; 14007 } 14008 14009 FORCEINLINE 14010 VOID 14011 ExFreeToLookasideListEx( 14012 IN OUT PLOOKASIDE_LIST_EX Lookaside, 14013 IN PVOID Entry) 14014 { 14015 Lookaside->L.TotalFrees += 1; 14016 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { 14017 Lookaside->L.FreeMisses += 1; 14018 (Lookaside->L.FreeEx)(Entry, Lookaside); 14019 } else { 14020 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); 14021 } 14022 return; 14023 } 14024 14025 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 14026 14027 #if (NTDDI_VERSION >= NTDDI_WIN7) 14028 14029 NTKERNELAPI 14030 VOID 14031 NTAPI 14032 ExSetResourceOwnerPointerEx( 14033 IN OUT PERESOURCE Resource, 14034 IN PVOID OwnerPointer, 14035 IN ULONG Flags); 14036 14037 #define FLAG_OWNER_POINTER_IS_THREAD 0x1 14038 14039 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 14040 14041 static __inline PVOID 14042 ExAllocateFromNPagedLookasideList( 14043 IN OUT PNPAGED_LOOKASIDE_LIST Lookaside) 14044 { 14045 PVOID Entry; 14046 14047 Lookaside->L.TotalAllocates++; 14048 #ifdef NONAMELESSUNION 14049 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) 14050 Entry = ExInterlockedPopEntrySList(&Lookaside->L.u.ListHead, 14051 &Lookaside->Lock__ObsoleteButDoNotDelete); 14052 #else 14053 Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead); 14054 #endif 14055 if (Entry == NULL) { 14056 Lookaside->L.u2.AllocateMisses++; 14057 Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type, 14058 Lookaside->L.Size, 14059 Lookaside->L.Tag); 14060 } 14061 #else /* NONAMELESSUNION */ 14062 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) 14063 Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, 14064 &Lookaside->Lock__ObsoleteButDoNotDelete); 14065 #else 14066 Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); 14067 #endif 14068 if (Entry == NULL) { 14069 Lookaside->L.AllocateMisses++; 14070 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, 14071 Lookaside->L.Size, 14072 Lookaside->L.Tag); 14073 } 14074 #endif /* NONAMELESSUNION */ 14075 return Entry; 14076 } 14077 14078 static __inline VOID 14079 ExFreeToNPagedLookasideList( 14080 IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, 14081 IN PVOID Entry) 14082 { 14083 Lookaside->L.TotalFrees++; 14084 #ifdef NONAMELESSUNION 14085 if (ExQueryDepthSList(&Lookaside->L.u.ListHead) >= Lookaside->L.Depth) { 14086 Lookaside->L.u3.FreeMisses++; 14087 (Lookaside->L.u5.Free)(Entry); 14088 } else { 14089 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) 14090 ExInterlockedPushEntrySList(&Lookaside->L.u.ListHead, 14091 (PSLIST_ENTRY)Entry, 14092 &Lookaside->Lock__ObsoleteButDoNotDelete); 14093 #else 14094 InterlockedPushEntrySList(&Lookaside->L.u.ListHead, (PSLIST_ENTRY)Entry); 14095 #endif 14096 } 14097 #else /* NONAMELESSUNION */ 14098 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { 14099 Lookaside->L.FreeMisses++; 14100 (Lookaside->L.Free)(Entry); 14101 } else { 14102 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) 14103 ExInterlockedPushEntrySList(&Lookaside->L.ListHead, 14104 (PSLIST_ENTRY)Entry, 14105 &Lookaside->Lock__ObsoleteButDoNotDelete); 14106 #else 14107 InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); 14108 #endif 14109 } 14110 #endif /* NONAMELESSUNION */ 14111 } 14112 14113 /****************************************************************************** 14114 * Object Manager Functions * 14115 ******************************************************************************/ 14116 14117 #if (NTDDI_VERSION >= NTDDI_WIN2K) 14118 NTKERNELAPI 14119 LONG_PTR 14120 FASTCALL 14121 ObfDereferenceObject( 14122 IN PVOID Object); 14123 #define ObDereferenceObject ObfDereferenceObject 14124 14125 NTKERNELAPI 14126 NTSTATUS 14127 NTAPI 14128 ObGetObjectSecurity( 14129 IN PVOID Object, 14130 OUT PSECURITY_DESCRIPTOR *SecurityDescriptor, 14131 OUT PBOOLEAN MemoryAllocated); 14132 14133 NTKERNELAPI 14134 LONG_PTR 14135 FASTCALL 14136 ObfReferenceObject( 14137 IN PVOID Object); 14138 #define ObReferenceObject ObfReferenceObject 14139 14140 NTKERNELAPI 14141 NTSTATUS 14142 NTAPI 14143 ObReferenceObjectByHandle( 14144 IN HANDLE Handle, 14145 IN ACCESS_MASK DesiredAccess, 14146 IN POBJECT_TYPE ObjectType OPTIONAL, 14147 IN KPROCESSOR_MODE AccessMode, 14148 OUT PVOID *Object, 14149 OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); 14150 14151 NTKERNELAPI 14152 NTSTATUS 14153 NTAPI 14154 ObReferenceObjectByPointer( 14155 IN PVOID Object, 14156 IN ACCESS_MASK DesiredAccess, 14157 IN POBJECT_TYPE ObjectType OPTIONAL, 14158 IN KPROCESSOR_MODE AccessMode); 14159 14160 NTKERNELAPI 14161 VOID 14162 NTAPI 14163 ObReleaseObjectSecurity( 14164 IN PSECURITY_DESCRIPTOR SecurityDescriptor, 14165 IN BOOLEAN MemoryAllocated); 14166 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 14167 14168 #if (NTDDI_VERSION >= NTDDI_VISTA) 14169 NTKERNELAPI 14170 VOID 14171 NTAPI 14172 ObDereferenceObjectDeferDelete( 14173 IN PVOID Object); 14174 #endif 14175 14176 #if (NTDDI_VERSION >= NTDDI_VISTASP1) 14177 NTKERNELAPI 14178 NTSTATUS 14179 NTAPI 14180 ObRegisterCallbacks( 14181 IN POB_CALLBACK_REGISTRATION CallbackRegistration, 14182 OUT PVOID *RegistrationHandle); 14183 14184 NTKERNELAPI 14185 VOID 14186 NTAPI 14187 ObUnRegisterCallbacks( 14188 IN PVOID RegistrationHandle); 14189 14190 NTKERNELAPI 14191 USHORT 14192 NTAPI 14193 ObGetFilterVersion(VOID); 14194 14195 #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ 14196 14197 #if (NTDDI_VERSION >= NTDDI_WIN7) 14198 NTKERNELAPI 14199 NTSTATUS 14200 NTAPI 14201 ObReferenceObjectByHandleWithTag( 14202 IN HANDLE Handle, 14203 IN ACCESS_MASK DesiredAccess, 14204 IN POBJECT_TYPE ObjectType OPTIONAL, 14205 IN KPROCESSOR_MODE AccessMode, 14206 IN ULONG Tag, 14207 OUT PVOID *Object, 14208 OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); 14209 14210 NTKERNELAPI 14211 LONG_PTR 14212 FASTCALL 14213 ObfReferenceObjectWithTag( 14214 IN PVOID Object, 14215 IN ULONG Tag); 14216 14217 NTKERNELAPI 14218 NTSTATUS 14219 NTAPI 14220 ObReferenceObjectByPointerWithTag( 14221 IN PVOID Object, 14222 IN ACCESS_MASK DesiredAccess, 14223 IN POBJECT_TYPE ObjectType OPTIONAL, 14224 IN KPROCESSOR_MODE AccessMode, 14225 IN ULONG Tag); 14226 14227 NTKERNELAPI 14228 LONG_PTR 14229 FASTCALL 14230 ObfDereferenceObjectWithTag( 14231 IN PVOID Object, 14232 IN ULONG Tag); 14233 14234 NTKERNELAPI 14235 VOID 14236 NTAPI 14237 ObDereferenceObjectDeferDeleteWithTag( 14238 IN PVOID Object, 14239 IN ULONG Tag); 14240 14241 #define ObDereferenceObject ObfDereferenceObject 14242 #define ObReferenceObject ObfReferenceObject 14243 #define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag 14244 #define ObReferenceObjectWithTag ObfReferenceObjectWithTag 14245 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 14246 14247 /****************************************************************************** 14248 * Process Manager Functions * 14249 ******************************************************************************/ 14250 14251 NTKERNELAPI 14252 NTSTATUS 14253 NTAPI 14254 PsWrapApcWow64Thread( 14255 IN OUT PVOID *ApcContext, 14256 IN OUT PVOID *ApcRoutine); 14257 14258 /* 14259 * PEPROCESS 14260 * PsGetCurrentProcess(VOID) 14261 */ 14262 #define PsGetCurrentProcess IoGetCurrentProcess 14263 14264 #if !defined(_PSGETCURRENTTHREAD_) 14265 #define _PSGETCURRENTTHREAD_ 14266 FORCEINLINE 14267 PETHREAD 14268 NTAPI 14269 PsGetCurrentThread(VOID) 14270 { 14271 return (PETHREAD)KeGetCurrentThread(); 14272 } 14273 #endif /* !_PSGETCURRENTTHREAD_ */ 14274 14275 14276 #if (NTDDI_VERSION >= NTDDI_WIN2K) 14277 14278 NTKERNELAPI 14279 NTSTATUS 14280 NTAPI 14281 PsCreateSystemThread( 14282 OUT PHANDLE ThreadHandle, 14283 IN ULONG DesiredAccess, 14284 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 14285 IN HANDLE ProcessHandle OPTIONAL, 14286 OUT PCLIENT_ID ClientId OPTIONAL, 14287 IN PKSTART_ROUTINE StartRoutine, 14288 IN PVOID StartContext OPTIONAL); 14289 14290 NTKERNELAPI 14291 NTSTATUS 14292 NTAPI 14293 PsTerminateSystemThread( 14294 IN NTSTATUS ExitStatus); 14295 14296 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 14297 14298 14299 /****************************************************************************** 14300 * WMI Library Support Functions * 14301 ******************************************************************************/ 14302 14303 #ifdef RUN_WPP 14304 #if (NTDDI_VERSION >= NTDDI_WINXP) 14305 NTKERNELAPI 14306 NTSTATUS 14307 __cdecl 14308 WmiTraceMessage( 14309 IN TRACEHANDLE LoggerHandle, 14310 IN ULONG MessageFlags, 14311 IN LPGUID MessageGuid, 14312 IN USHORT MessageNumber, 14313 IN ...); 14314 #endif 14315 #endif /* RUN_WPP */ 14316 14317 #if (NTDDI_VERSION >= NTDDI_WINXP) 14318 14319 NTKERNELAPI 14320 NTSTATUS 14321 NTAPI 14322 WmiQueryTraceInformation( 14323 IN TRACE_INFORMATION_CLASS TraceInformationClass, 14324 OUT PVOID TraceInformation, 14325 IN ULONG TraceInformationLength, 14326 OUT PULONG RequiredLength OPTIONAL, 14327 IN PVOID Buffer OPTIONAL); 14328 14329 #if 0 14330 /* FIXME: Get va_list from where? */ 14331 NTKERNELAPI 14332 NTSTATUS 14333 NTAPI 14334 WmiTraceMessageVa( 14335 IN TRACEHANDLE LoggerHandle, 14336 IN ULONG MessageFlags, 14337 IN LPGUID MessageGuid, 14338 IN USHORT MessageNumber, 14339 IN va_list MessageArgList); 14340 #endif 14341 14342 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 14343 14344 #ifndef TRACE_INFORMATION_CLASS_DEFINE 14345 14346 #if (NTDDI_VERSION >= NTDDI_WINXP) 14347 NTKERNELAPI 14348 NTSTATUS 14349 NTAPI 14350 WmiQueryTraceInformation( 14351 IN TRACE_INFORMATION_CLASS TraceInformationClass, 14352 OUT PVOID TraceInformation, 14353 IN ULONG TraceInformationLength, 14354 OUT PULONG RequiredLength OPTIONAL, 14355 IN PVOID Buffer OPTIONAL); 14356 #endif 14357 14358 #define TRACE_INFORMATION_CLASS_DEFINE 14359 14360 #endif /* TRACE_INFOPRMATION_CLASS_DEFINE */ 14361 14362 #if (NTDDI_VERSION >= NTDDI_VISTA) 14363 14364 NTSTATUS 14365 NTKERNELAPI 14366 NTAPI 14367 EtwRegister( 14368 IN LPCGUID ProviderId, 14369 IN PETWENABLECALLBACK EnableCallback OPTIONAL, 14370 IN PVOID CallbackContext OPTIONAL, 14371 OUT PREGHANDLE RegHandle); 14372 14373 NTSTATUS 14374 NTKERNELAPI 14375 NTAPI 14376 EtwUnregister( 14377 IN REGHANDLE RegHandle); 14378 14379 BOOLEAN 14380 NTKERNELAPI 14381 NTAPI 14382 EtwEventEnabled( 14383 IN REGHANDLE RegHandle, 14384 IN PCEVENT_DESCRIPTOR EventDescriptor); 14385 14386 BOOLEAN 14387 NTKERNELAPI 14388 NTAPI 14389 EtwProviderEnabled( 14390 IN REGHANDLE RegHandle, 14391 IN UCHAR Level, 14392 IN ULONGLONG Keyword); 14393 14394 NTSTATUS 14395 NTKERNELAPI 14396 NTAPI 14397 EtwActivityIdControl( 14398 IN ULONG ControlCode, 14399 IN OUT LPGUID ActivityId); 14400 14401 NTSTATUS 14402 NTKERNELAPI 14403 NTAPI 14404 EtwWrite( 14405 IN REGHANDLE RegHandle, 14406 IN PCEVENT_DESCRIPTOR EventDescriptor, 14407 IN LPCGUID ActivityId OPTIONAL, 14408 IN ULONG UserDataCount, 14409 IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); 14410 14411 NTSTATUS 14412 NTKERNELAPI 14413 NTAPI 14414 EtwWriteTransfer( 14415 IN REGHANDLE RegHandle, 14416 IN PCEVENT_DESCRIPTOR EventDescriptor, 14417 IN LPCGUID ActivityId OPTIONAL, 14418 IN LPCGUID RelatedActivityId OPTIONAL, 14419 IN ULONG UserDataCount, 14420 IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); 14421 14422 NTSTATUS 14423 NTKERNELAPI 14424 NTAPI 14425 EtwWriteString( 14426 IN REGHANDLE RegHandle, 14427 IN UCHAR Level, 14428 IN ULONGLONG Keyword, 14429 IN LPCGUID ActivityId OPTIONAL, 14430 IN PCWSTR String); 14431 14432 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 14433 14434 #if (NTDDI_VERSION >= NTDDI_WIN7) 14435 NTSTATUS 14436 NTKERNELAPI 14437 NTAPI 14438 EtwWriteEx( 14439 IN REGHANDLE RegHandle, 14440 IN PCEVENT_DESCRIPTOR EventDescriptor, 14441 IN ULONG64 Filter, 14442 IN ULONG Flags, 14443 IN LPCGUID ActivityId OPTIONAL, 14444 IN LPCGUID RelatedActivityId OPTIONAL, 14445 IN ULONG UserDataCount, 14446 IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); 14447 #endif 14448 14449 14450 14451 /****************************************************************************** 14452 * Kernel Debugger Functions * 14453 ******************************************************************************/ 14454 14455 #ifndef _DBGNT_ 14456 14457 ULONG 14458 __cdecl 14459 DbgPrint( 14460 IN PCSTR Format, 14461 IN ...); 14462 14463 #if (NTDDI_VERSION >= NTDDI_WIN2K) 14464 NTSYSAPI 14465 ULONG 14466 __cdecl 14467 DbgPrintReturnControlC( 14468 IN PCCH Format, 14469 IN ...); 14470 #endif 14471 14472 #if (NTDDI_VERSION >= NTDDI_WINXP) 14473 14474 NTSYSAPI 14475 ULONG 14476 __cdecl 14477 DbgPrintEx( 14478 IN ULONG ComponentId, 14479 IN ULONG Level, 14480 IN PCSTR Format, 14481 IN ...); 14482 14483 #ifdef _VA_LIST_DEFINED 14484 14485 NTSYSAPI 14486 ULONG 14487 NTAPI 14488 vDbgPrintEx( 14489 IN ULONG ComponentId, 14490 IN ULONG Level, 14491 IN PCCH Format, 14492 IN va_list ap); 14493 14494 NTSYSAPI 14495 ULONG 14496 NTAPI 14497 vDbgPrintExWithPrefix( 14498 IN PCCH Prefix, 14499 IN ULONG ComponentId, 14500 IN ULONG Level, 14501 IN PCCH Format, 14502 IN va_list ap); 14503 14504 #endif /* _VA_LIST_DEFINED */ 14505 14506 NTSYSAPI 14507 NTSTATUS 14508 NTAPI 14509 DbgQueryDebugFilterState( 14510 IN ULONG ComponentId, 14511 IN ULONG Level); 14512 14513 NTSYSAPI 14514 NTSTATUS 14515 NTAPI 14516 DbgSetDebugFilterState( 14517 IN ULONG ComponentId, 14518 IN ULONG Level, 14519 IN BOOLEAN State); 14520 14521 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ 14522 14523 #if (NTDDI_VERSION >= NTDDI_VISTA) 14524 14525 typedef VOID 14526 (*PDEBUG_PRINT_CALLBACK)( 14527 IN PSTRING Output, 14528 IN ULONG ComponentId, 14529 IN ULONG Level); 14530 14531 NTSYSAPI 14532 NTSTATUS 14533 NTAPI 14534 DbgSetDebugPrintCallback( 14535 IN PDEBUG_PRINT_CALLBACK DebugPrintCallback, 14536 IN BOOLEAN Enable); 14537 14538 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 14539 14540 #endif /* _DBGNT_ */ 14541 14542 #if DBG 14543 14544 #define KdPrint(_x_) DbgPrint _x_ 14545 #define KdPrintEx(_x_) DbgPrintEx _x_ 14546 #define vKdPrintEx(_x_) vDbgPrintEx _x_ 14547 #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ 14548 #define KdBreakPoint() DbgBreakPoint() 14549 #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) 14550 14551 #else /* !DBG */ 14552 14553 #define KdPrint(_x_) 14554 #define KdPrintEx(_x_) 14555 #define vKdPrintEx(_x_) 14556 #define vKdPrintExWithPrefix(_x_) 14557 #define KdBreakPoint() 14558 #define KdBreakPointWithStatus(s) 14559 14560 #endif /* !DBG */ 14561 14562 #if defined(__GNUC__) 14563 14564 extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; 14565 extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; 14566 #define KD_DEBUGGER_ENABLED KdDebuggerEnabled 14567 #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent 14568 14569 #elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) 14570 14571 extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; 14572 extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; 14573 #define KD_DEBUGGER_ENABLED *KdDebuggerEnabled 14574 #define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent 14575 14576 #else 14577 14578 extern BOOLEAN KdDebuggerNotPresent; 14579 extern BOOLEAN KdDebuggerEnabled; 14580 #define KD_DEBUGGER_ENABLED KdDebuggerEnabled 14581 #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent 14582 14583 #endif 14584 14585 #if (NTDDI_VERSION >= NTDDI_WIN2K) 14586 14587 NTKERNELAPI 14588 NTSTATUS 14589 NTAPI 14590 KdDisableDebugger(VOID); 14591 14592 NTKERNELAPI 14593 NTSTATUS 14594 NTAPI 14595 KdEnableDebugger(VOID); 14596 14597 #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) 14598 #define DbgBreakPoint __debugbreak 14599 #else 14600 VOID 14601 NTAPI 14602 DbgBreakPoint(VOID); 14603 #endif 14604 14605 NTSYSAPI 14606 VOID 14607 NTAPI 14608 DbgBreakPointWithStatus( 14609 IN ULONG Status); 14610 14611 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 14612 14613 #if (NTDDI_VERSION >= NTDDI_WS03) 14614 NTKERNELAPI 14615 BOOLEAN 14616 NTAPI 14617 KdRefreshDebuggerNotPresent(VOID); 14618 #endif 14619 14620 #if (NTDDI_VERSION >= NTDDI_WS03SP1) 14621 NTKERNELAPI 14622 NTSTATUS 14623 NTAPI 14624 KdChangeOption( 14625 IN KD_OPTION Option, 14626 IN ULONG InBufferBytes OPTIONAL, 14627 IN PVOID InBuffer, 14628 IN ULONG OutBufferBytes OPTIONAL, 14629 OUT PVOID OutBuffer, 14630 OUT PULONG OutBufferNeeded OPTIONAL); 14631 #endif 14632 /* Hardware Abstraction Layer Functions */ 14633 14634 #if (NTDDI_VERSION >= NTDDI_WIN2K) 14635 14636 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) 14637 14638 FORCEINLINE 14639 PVOID 14640 NTAPI 14641 HalAllocateCommonBuffer( 14642 IN PDMA_ADAPTER DmaAdapter, 14643 IN ULONG Length, 14644 OUT PPHYSICAL_ADDRESS LogicalAddress, 14645 IN BOOLEAN CacheEnabled) 14646 { 14647 PALLOCATE_COMMON_BUFFER allocateCommonBuffer; 14648 PVOID commonBuffer; 14649 14650 allocateCommonBuffer = *(DmaAdapter)->DmaOperations->AllocateCommonBuffer; 14651 ASSERT( allocateCommonBuffer != NULL ); 14652 commonBuffer = allocateCommonBuffer( DmaAdapter, Length, LogicalAddress, CacheEnabled ); 14653 return commonBuffer; 14654 } 14655 14656 FORCEINLINE 14657 VOID 14658 NTAPI 14659 HalFreeCommonBuffer( 14660 IN PDMA_ADAPTER DmaAdapter, 14661 IN ULONG Length, 14662 IN PHYSICAL_ADDRESS LogicalAddress, 14663 IN PVOID VirtualAddress, 14664 IN BOOLEAN CacheEnabled) 14665 { 14666 PFREE_COMMON_BUFFER freeCommonBuffer; 14667 14668 freeCommonBuffer = *(DmaAdapter)->DmaOperations->FreeCommonBuffer; 14669 ASSERT( freeCommonBuffer != NULL ); 14670 freeCommonBuffer( DmaAdapter, Length, LogicalAddress, VirtualAddress, CacheEnabled ); 14671 } 14672 14673 FORCEINLINE 14674 ULONG 14675 NTAPI 14676 HalReadDmaCounter( 14677 IN PDMA_ADAPTER DmaAdapter) 14678 { 14679 PREAD_DMA_COUNTER readDmaCounter; 14680 ULONG counter; 14681 14682 readDmaCounter = *(DmaAdapter)->DmaOperations->ReadDmaCounter; 14683 ASSERT( readDmaCounter != NULL ); 14684 counter = readDmaCounter( DmaAdapter ); 14685 return counter; 14686 } 14687 14688 FORCEINLINE 14689 ULONG 14690 HalGetDmaAlignment( 14691 IN PDMA_ADAPTER DmaAdapter) 14692 { 14693 PGET_DMA_ALIGNMENT getDmaAlignment; 14694 ULONG alignment; 14695 14696 getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment; 14697 ASSERT( getDmaAlignment != NULL ); 14698 alignment = getDmaAlignment( DmaAdapter ); 14699 return alignment; 14700 } 14701 14702 #endif /* USE_DMA_MACROS ... */ 14703 14704 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 14705 14706 #ifndef _NTTMAPI_ 14707 #define _NTTMAPI_ 14708 14709 #include <ktmtypes.h> 14710 14711 #define TRANSACTIONMANAGER_QUERY_INFORMATION (0x0001) 14712 #define TRANSACTIONMANAGER_SET_INFORMATION (0x0002) 14713 #define TRANSACTIONMANAGER_RECOVER (0x0004) 14714 #define TRANSACTIONMANAGER_RENAME (0x0008) 14715 #define TRANSACTIONMANAGER_CREATE_RM (0x0010) 14716 #define TRANSACTIONMANAGER_BIND_TRANSACTION (0x0020) 14717 14718 #define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ 14719 TRANSACTIONMANAGER_QUERY_INFORMATION) 14720 14721 #define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ 14722 TRANSACTIONMANAGER_SET_INFORMATION |\ 14723 TRANSACTIONMANAGER_RECOVER |\ 14724 TRANSACTIONMANAGER_RENAME |\ 14725 TRANSACTIONMANAGER_CREATE_RM) 14726 14727 #define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE) 14728 14729 #define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ 14730 TRANSACTIONMANAGER_GENERIC_READ |\ 14731 TRANSACTIONMANAGER_GENERIC_WRITE |\ 14732 TRANSACTIONMANAGER_GENERIC_EXECUTE |\ 14733 TRANSACTIONMANAGER_BIND_TRANSACTION) 14734 14735 #define TRANSACTION_QUERY_INFORMATION (0x0001) 14736 #define TRANSACTION_SET_INFORMATION (0x0002) 14737 #define TRANSACTION_ENLIST (0x0004) 14738 #define TRANSACTION_COMMIT (0x0008) 14739 #define TRANSACTION_ROLLBACK (0x0010) 14740 #define TRANSACTION_PROPAGATE (0x0020) 14741 #define TRANSACTION_RIGHT_RESERVED1 (0x0040) 14742 14743 #define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ |\ 14744 TRANSACTION_QUERY_INFORMATION |\ 14745 SYNCHRONIZE) 14746 14747 #define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ 14748 TRANSACTION_SET_INFORMATION |\ 14749 TRANSACTION_COMMIT |\ 14750 TRANSACTION_ENLIST |\ 14751 TRANSACTION_ROLLBACK |\ 14752 TRANSACTION_PROPAGATE |\ 14753 SYNCHRONIZE) 14754 14755 #define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ 14756 TRANSACTION_COMMIT |\ 14757 TRANSACTION_ROLLBACK |\ 14758 SYNCHRONIZE) 14759 14760 #define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ 14761 TRANSACTION_GENERIC_READ |\ 14762 TRANSACTION_GENERIC_WRITE |\ 14763 TRANSACTION_GENERIC_EXECUTE) 14764 14765 #define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ |\ 14766 STANDARD_RIGHTS_WRITE |\ 14767 TRANSACTION_SET_INFORMATION |\ 14768 TRANSACTION_ENLIST |\ 14769 TRANSACTION_ROLLBACK |\ 14770 TRANSACTION_PROPAGATE |\ 14771 SYNCHRONIZE) 14772 14773 #define RESOURCEMANAGER_QUERY_INFORMATION (0x0001) 14774 #define RESOURCEMANAGER_SET_INFORMATION (0x0002) 14775 #define RESOURCEMANAGER_RECOVER (0x0004) 14776 #define RESOURCEMANAGER_ENLIST (0x0008) 14777 #define RESOURCEMANAGER_GET_NOTIFICATION (0x0010) 14778 #define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020) 14779 #define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040) 14780 14781 #define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ 14782 RESOURCEMANAGER_QUERY_INFORMATION |\ 14783 SYNCHRONIZE) 14784 14785 #define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ 14786 RESOURCEMANAGER_SET_INFORMATION |\ 14787 RESOURCEMANAGER_RECOVER |\ 14788 RESOURCEMANAGER_ENLIST |\ 14789 RESOURCEMANAGER_GET_NOTIFICATION |\ 14790 RESOURCEMANAGER_REGISTER_PROTOCOL |\ 14791 RESOURCEMANAGER_COMPLETE_PROPAGATION |\ 14792 SYNCHRONIZE) 14793 14794 #define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ 14795 RESOURCEMANAGER_RECOVER |\ 14796 RESOURCEMANAGER_ENLIST |\ 14797 RESOURCEMANAGER_GET_NOTIFICATION |\ 14798 RESOURCEMANAGER_COMPLETE_PROPAGATION |\ 14799 SYNCHRONIZE) 14800 14801 #define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ 14802 RESOURCEMANAGER_GENERIC_READ |\ 14803 RESOURCEMANAGER_GENERIC_WRITE |\ 14804 RESOURCEMANAGER_GENERIC_EXECUTE) 14805 14806 #define ENLISTMENT_QUERY_INFORMATION (0x0001) 14807 #define ENLISTMENT_SET_INFORMATION (0x0002) 14808 #define ENLISTMENT_RECOVER (0x0004) 14809 #define ENLISTMENT_SUBORDINATE_RIGHTS (0x0008) 14810 #define ENLISTMENT_SUPERIOR_RIGHTS (0x0010) 14811 14812 #define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ |\ 14813 ENLISTMENT_QUERY_INFORMATION) 14814 14815 #define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ 14816 ENLISTMENT_SET_INFORMATION |\ 14817 ENLISTMENT_RECOVER |\ 14818 ENLISTMENT_SUBORDINATE_RIGHTS |\ 14819 ENLISTMENT_SUPERIOR_RIGHTS) 14820 14821 #define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ 14822 ENLISTMENT_RECOVER |\ 14823 ENLISTMENT_SUBORDINATE_RIGHTS |\ 14824 ENLISTMENT_SUPERIOR_RIGHTS) 14825 14826 #define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ 14827 ENLISTMENT_GENERIC_READ |\ 14828 ENLISTMENT_GENERIC_WRITE |\ 14829 ENLISTMENT_GENERIC_EXECUTE) 14830 14831 typedef enum _TRANSACTION_OUTCOME { 14832 TransactionOutcomeUndetermined = 1, 14833 TransactionOutcomeCommitted, 14834 TransactionOutcomeAborted, 14835 } TRANSACTION_OUTCOME; 14836 14837 14838 typedef enum _TRANSACTION_STATE { 14839 TransactionStateNormal = 1, 14840 TransactionStateIndoubt, 14841 TransactionStateCommittedNotify, 14842 } TRANSACTION_STATE; 14843 14844 14845 typedef struct _TRANSACTION_BASIC_INFORMATION { 14846 GUID TransactionId; 14847 ULONG State; 14848 ULONG Outcome; 14849 } TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION; 14850 14851 typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION { 14852 GUID TmIdentity; 14853 LARGE_INTEGER VirtualClock; 14854 } TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION; 14855 14856 typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION { 14857 GUID LogIdentity; 14858 } TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION; 14859 14860 typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION { 14861 ULONG LogPathLength; 14862 WCHAR LogPath[1]; 14863 } TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION; 14864 14865 typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION { 14866 ULONGLONG LastRecoveredLsn; 14867 } TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION; 14868 14869 typedef struct _TRANSACTION_PROPERTIES_INFORMATION { 14870 ULONG IsolationLevel; 14871 ULONG IsolationFlags; 14872 LARGE_INTEGER Timeout; 14873 ULONG Outcome; 14874 ULONG DescriptionLength; 14875 WCHAR Description[1]; 14876 } TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION; 14877 14878 typedef struct _TRANSACTION_BIND_INFORMATION { 14879 HANDLE TmHandle; 14880 } TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION; 14881 14882 typedef struct _TRANSACTION_ENLISTMENT_PAIR { 14883 GUID EnlistmentId; 14884 GUID ResourceManagerId; 14885 } TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR; 14886 14887 typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION { 14888 ULONG NumberOfEnlistments; 14889 TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1]; 14890 } TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION; 14891 14892 typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { 14893 TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair; 14894 } TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; 14895 14896 typedef struct _RESOURCEMANAGER_BASIC_INFORMATION { 14897 GUID ResourceManagerId; 14898 ULONG DescriptionLength; 14899 WCHAR Description[1]; 14900 } RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION; 14901 14902 typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION { 14903 HANDLE IoCompletionPortHandle; 14904 ULONG_PTR CompletionKey; 14905 } RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION; 14906 14907 typedef enum _KTMOBJECT_TYPE { 14908 KTMOBJECT_TRANSACTION, 14909 KTMOBJECT_TRANSACTION_MANAGER, 14910 KTMOBJECT_RESOURCE_MANAGER, 14911 KTMOBJECT_ENLISTMENT, 14912 KTMOBJECT_INVALID 14913 } KTMOBJECT_TYPE, *PKTMOBJECT_TYPE; 14914 14915 typedef struct _KTMOBJECT_CURSOR { 14916 GUID LastQuery; 14917 ULONG ObjectIdCount; 14918 GUID ObjectIds[1]; 14919 } KTMOBJECT_CURSOR, *PKTMOBJECT_CURSOR; 14920 14921 typedef enum _TRANSACTION_INFORMATION_CLASS { 14922 TransactionBasicInformation, 14923 TransactionPropertiesInformation, 14924 TransactionEnlistmentInformation, 14925 TransactionSuperiorEnlistmentInformation 14926 } TRANSACTION_INFORMATION_CLASS; 14927 14928 typedef enum _TRANSACTIONMANAGER_INFORMATION_CLASS { 14929 TransactionManagerBasicInformation, 14930 TransactionManagerLogInformation, 14931 TransactionManagerLogPathInformation, 14932 TransactionManagerRecoveryInformation = 4 14933 } TRANSACTIONMANAGER_INFORMATION_CLASS; 14934 14935 typedef enum _RESOURCEMANAGER_INFORMATION_CLASS { 14936 ResourceManagerBasicInformation, 14937 ResourceManagerCompletionInformation, 14938 } RESOURCEMANAGER_INFORMATION_CLASS; 14939 14940 typedef struct _ENLISTMENT_BASIC_INFORMATION { 14941 GUID EnlistmentId; 14942 GUID TransactionId; 14943 GUID ResourceManagerId; 14944 } ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION; 14945 14946 typedef struct _ENLISTMENT_CRM_INFORMATION { 14947 GUID CrmTransactionManagerId; 14948 GUID CrmResourceManagerId; 14949 GUID CrmEnlistmentId; 14950 } ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION; 14951 14952 typedef enum _ENLISTMENT_INFORMATION_CLASS { 14953 EnlistmentBasicInformation, 14954 EnlistmentRecoveryInformation, 14955 EnlistmentCrmInformation 14956 } ENLISTMENT_INFORMATION_CLASS; 14957 14958 typedef struct _TRANSACTION_LIST_ENTRY { 14959 /* UOW is typedef'ed as GUID just above. Changed type of UOW 14960 * member from UOW to GUID for C++ compat. Using ::UOW for C++ 14961 * works too but we were reported some problems in corner cases 14962 */ 14963 GUID UOW; 14964 } TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY; 14965 14966 typedef struct _TRANSACTION_LIST_INFORMATION { 14967 ULONG NumberOfTransactions; 14968 TRANSACTION_LIST_ENTRY TransactionInformation[1]; 14969 } TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION; 14970 14971 typedef NTSTATUS 14972 (NTAPI *PFN_NT_CREATE_TRANSACTION)( 14973 OUT PHANDLE TransactionHandle, 14974 IN ACCESS_MASK DesiredAccess, 14975 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 14976 IN LPGUID Uow OPTIONAL, 14977 IN HANDLE TmHandle OPTIONAL, 14978 IN ULONG CreateOptions OPTIONAL, 14979 IN ULONG IsolationLevel OPTIONAL, 14980 IN ULONG IsolationFlags OPTIONAL, 14981 IN PLARGE_INTEGER Timeout OPTIONAL, 14982 IN PUNICODE_STRING Description OPTIONAL); 14983 14984 typedef NTSTATUS 14985 (NTAPI *PFN_NT_OPEN_TRANSACTION)( 14986 OUT PHANDLE TransactionHandle, 14987 IN ACCESS_MASK DesiredAccess, 14988 IN POBJECT_ATTRIBUTES ObjectAttributes, 14989 IN LPGUID Uow OPTIONAL, 14990 IN HANDLE TmHandle OPTIONAL); 14991 14992 typedef NTSTATUS 14993 (NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)( 14994 IN HANDLE TransactionHandle, 14995 IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, 14996 OUT PVOID TransactionInformation, 14997 IN ULONG TransactionInformationLength, 14998 OUT PULONG ReturnLength OPTIONAL); 14999 15000 typedef NTSTATUS 15001 (NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)( 15002 IN HANDLE TransactionHandle, 15003 IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, 15004 IN PVOID TransactionInformation, 15005 IN ULONG TransactionInformationLength); 15006 15007 typedef NTSTATUS 15008 (NTAPI *PFN_NT_COMMIT_TRANSACTION)( 15009 IN HANDLE TransactionHandle, 15010 IN BOOLEAN Wait); 15011 15012 typedef NTSTATUS 15013 (NTAPI *PFN_NT_ROLLBACK_TRANSACTION)( 15014 IN HANDLE TransactionHandle, 15015 IN BOOLEAN Wait); 15016 15017 #if (NTDDI_VERSION >= NTDDI_VISTA) 15018 15019 NTSYSCALLAPI 15020 NTSTATUS 15021 NTAPI 15022 NtCreateTransactionManager( 15023 OUT PHANDLE TmHandle, 15024 IN ACCESS_MASK DesiredAccess, 15025 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15026 IN PUNICODE_STRING LogFileName OPTIONAL, 15027 IN ULONG CreateOptions OPTIONAL, 15028 IN ULONG CommitStrength OPTIONAL); 15029 15030 NTSYSCALLAPI 15031 NTSTATUS 15032 NTAPI 15033 NtOpenTransactionManager( 15034 OUT PHANDLE TmHandle, 15035 IN ACCESS_MASK DesiredAccess, 15036 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15037 IN PUNICODE_STRING LogFileName OPTIONAL, 15038 IN LPGUID TmIdentity OPTIONAL, 15039 IN ULONG OpenOptions OPTIONAL); 15040 15041 NTSYSCALLAPI 15042 NTSTATUS 15043 NTAPI 15044 NtRenameTransactionManager( 15045 IN PUNICODE_STRING LogFileName, 15046 IN LPGUID ExistingTransactionManagerGuid); 15047 15048 NTSYSCALLAPI 15049 NTSTATUS 15050 NTAPI 15051 NtRollforwardTransactionManager( 15052 IN HANDLE TransactionManagerHandle, 15053 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15054 15055 NTSYSCALLAPI 15056 NTSTATUS 15057 NTAPI 15058 NtRecoverTransactionManager( 15059 IN HANDLE TransactionManagerHandle); 15060 15061 NTSYSCALLAPI 15062 NTSTATUS 15063 NTAPI 15064 NtQueryInformationTransactionManager( 15065 IN HANDLE TransactionManagerHandle, 15066 IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, 15067 OUT PVOID TransactionManagerInformation, 15068 IN ULONG TransactionManagerInformationLength, 15069 OUT PULONG ReturnLength); 15070 15071 NTSYSCALLAPI 15072 NTSTATUS 15073 NTAPI 15074 NtSetInformationTransactionManager( 15075 IN HANDLE TmHandle OPTIONAL, 15076 IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, 15077 IN PVOID TransactionManagerInformation, 15078 IN ULONG TransactionManagerInformationLength); 15079 15080 NTSYSCALLAPI 15081 NTSTATUS 15082 NTAPI 15083 NtEnumerateTransactionObject( 15084 IN HANDLE RootObjectHandle OPTIONAL, 15085 IN KTMOBJECT_TYPE QueryType, 15086 IN OUT PKTMOBJECT_CURSOR ObjectCursor, 15087 IN ULONG ObjectCursorLength, 15088 OUT PULONG ReturnLength); 15089 15090 NTSYSCALLAPI 15091 NTSTATUS 15092 NTAPI 15093 NtCreateTransaction( 15094 OUT PHANDLE TransactionHandle, 15095 IN ACCESS_MASK DesiredAccess, 15096 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15097 IN LPGUID Uow OPTIONAL, 15098 IN HANDLE TmHandle OPTIONAL, 15099 IN ULONG CreateOptions OPTIONAL, 15100 IN ULONG IsolationLevel OPTIONAL, 15101 IN ULONG IsolationFlags OPTIONAL, 15102 IN PLARGE_INTEGER Timeout OPTIONAL, 15103 IN PUNICODE_STRING Description OPTIONAL); 15104 15105 NTSYSCALLAPI 15106 NTSTATUS 15107 NTAPI 15108 NtOpenTransaction( 15109 OUT PHANDLE TransactionHandle, 15110 IN ACCESS_MASK DesiredAccess, 15111 IN POBJECT_ATTRIBUTES ObjectAttributes, 15112 IN LPGUID Uow, 15113 IN HANDLE TmHandle OPTIONAL); 15114 15115 NTSYSCALLAPI 15116 NTSTATUS 15117 NTAPI 15118 NtQueryInformationTransaction( 15119 IN HANDLE TransactionHandle, 15120 IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, 15121 OUT PVOID TransactionInformation, 15122 IN ULONG TransactionInformationLength, 15123 OUT PULONG ReturnLength OPTIONAL); 15124 15125 NTSYSCALLAPI 15126 NTSTATUS 15127 NTAPI 15128 NtSetInformationTransaction( 15129 IN HANDLE TransactionHandle, 15130 IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, 15131 IN PVOID TransactionInformation, 15132 IN ULONG TransactionInformationLength); 15133 15134 NTSYSCALLAPI 15135 NTSTATUS 15136 NTAPI 15137 NtCommitTransaction( 15138 IN HANDLE TransactionHandle, 15139 IN BOOLEAN Wait); 15140 15141 NTSYSCALLAPI 15142 NTSTATUS 15143 NTAPI 15144 NtRollbackTransaction( 15145 IN HANDLE TransactionHandle, 15146 IN BOOLEAN Wait); 15147 15148 NTSYSCALLAPI 15149 NTSTATUS 15150 NTAPI 15151 NtCreateEnlistment( 15152 OUT PHANDLE EnlistmentHandle, 15153 IN ACCESS_MASK DesiredAccess, 15154 IN HANDLE ResourceManagerHandle, 15155 IN HANDLE TransactionHandle, 15156 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15157 IN ULONG CreateOptions OPTIONAL, 15158 IN NOTIFICATION_MASK NotificationMask, 15159 IN PVOID EnlistmentKey OPTIONAL); 15160 15161 NTSYSCALLAPI 15162 NTSTATUS 15163 NTAPI 15164 NtOpenEnlistment( 15165 OUT PHANDLE EnlistmentHandle, 15166 IN ACCESS_MASK DesiredAccess, 15167 IN HANDLE ResourceManagerHandle, 15168 IN LPGUID EnlistmentGuid, 15169 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); 15170 15171 NTSYSCALLAPI 15172 NTSTATUS 15173 NTAPI 15174 NtQueryInformationEnlistment( 15175 IN HANDLE EnlistmentHandle, 15176 IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, 15177 OUT PVOID EnlistmentInformation, 15178 IN ULONG EnlistmentInformationLength, 15179 OUT PULONG ReturnLength); 15180 15181 NTSYSCALLAPI 15182 NTSTATUS 15183 NTAPI 15184 NtSetInformationEnlistment( 15185 IN HANDLE EnlistmentHandle OPTIONAL, 15186 IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, 15187 IN PVOID EnlistmentInformation, 15188 IN ULONG EnlistmentInformationLength); 15189 15190 NTSYSCALLAPI 15191 NTSTATUS 15192 NTAPI 15193 NtRecoverEnlistment( 15194 IN HANDLE EnlistmentHandle, 15195 IN PVOID EnlistmentKey OPTIONAL); 15196 15197 NTSYSCALLAPI 15198 NTSTATUS 15199 NTAPI 15200 NtPrePrepareEnlistment( 15201 IN HANDLE EnlistmentHandle, 15202 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15203 15204 NTSYSCALLAPI 15205 NTSTATUS 15206 NTAPI 15207 NtPrepareEnlistment( 15208 IN HANDLE EnlistmentHandle, 15209 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15210 15211 NTSYSCALLAPI 15212 NTSTATUS 15213 NTAPI 15214 NtCommitEnlistment( 15215 IN HANDLE EnlistmentHandle, 15216 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15217 15218 NTSYSCALLAPI 15219 NTSTATUS 15220 NTAPI 15221 NtRollbackEnlistment( 15222 IN HANDLE EnlistmentHandle, 15223 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15224 15225 NTSYSCALLAPI 15226 NTSTATUS 15227 NTAPI 15228 NtPrePrepareComplete( 15229 IN HANDLE EnlistmentHandle, 15230 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15231 15232 NTSYSCALLAPI 15233 NTSTATUS 15234 NTAPI 15235 NtPrepareComplete( 15236 IN HANDLE EnlistmentHandle, 15237 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15238 15239 NTSYSCALLAPI 15240 NTSTATUS 15241 NTAPI 15242 NtCommitComplete( 15243 IN HANDLE EnlistmentHandle, 15244 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15245 15246 NTSYSCALLAPI 15247 NTSTATUS 15248 NTAPI 15249 NtReadOnlyEnlistment( 15250 IN HANDLE EnlistmentHandle, 15251 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15252 15253 NTSYSCALLAPI 15254 NTSTATUS 15255 NTAPI 15256 NtRollbackComplete( 15257 IN HANDLE EnlistmentHandle, 15258 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15259 15260 NTSYSCALLAPI 15261 NTSTATUS 15262 NTAPI 15263 NtSinglePhaseReject( 15264 IN HANDLE EnlistmentHandle, 15265 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15266 15267 NTSYSCALLAPI 15268 NTSTATUS 15269 NTAPI 15270 NtCreateResourceManager( 15271 OUT PHANDLE ResourceManagerHandle, 15272 IN ACCESS_MASK DesiredAccess, 15273 IN HANDLE TmHandle, 15274 IN LPGUID RmGuid, 15275 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15276 IN ULONG CreateOptions OPTIONAL, 15277 IN PUNICODE_STRING Description OPTIONAL); 15278 15279 NTSYSCALLAPI 15280 NTSTATUS 15281 NTAPI 15282 NtOpenResourceManager( 15283 OUT PHANDLE ResourceManagerHandle, 15284 IN ACCESS_MASK DesiredAccess, 15285 IN HANDLE TmHandle, 15286 IN LPGUID ResourceManagerGuid OPTIONAL, 15287 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); 15288 15289 NTSYSCALLAPI 15290 NTSTATUS 15291 NTAPI 15292 NtRecoverResourceManager( 15293 IN HANDLE ResourceManagerHandle); 15294 15295 NTSYSCALLAPI 15296 NTSTATUS 15297 NTAPI 15298 NtGetNotificationResourceManager( 15299 IN HANDLE ResourceManagerHandle, 15300 OUT PTRANSACTION_NOTIFICATION TransactionNotification, 15301 IN ULONG NotificationLength, 15302 IN PLARGE_INTEGER Timeout OPTIONAL, 15303 OUT PULONG ReturnLength OPTIONAL, 15304 IN ULONG Asynchronous, 15305 IN ULONG_PTR AsynchronousContext OPTIONAL); 15306 15307 NTSYSCALLAPI 15308 NTSTATUS 15309 NTAPI 15310 NtQueryInformationResourceManager( 15311 IN HANDLE ResourceManagerHandle, 15312 IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, 15313 OUT PVOID ResourceManagerInformation, 15314 IN ULONG ResourceManagerInformationLength, 15315 OUT PULONG ReturnLength OPTIONAL); 15316 15317 NTSYSCALLAPI 15318 NTSTATUS 15319 NTAPI 15320 NtSetInformationResourceManager( 15321 IN HANDLE ResourceManagerHandle, 15322 IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, 15323 IN PVOID ResourceManagerInformation, 15324 IN ULONG ResourceManagerInformationLength); 15325 15326 NTSYSCALLAPI 15327 NTSTATUS 15328 NTAPI 15329 NtRegisterProtocolAddressInformation( 15330 IN HANDLE ResourceManager, 15331 IN PCRM_PROTOCOL_ID ProtocolId, 15332 IN ULONG ProtocolInformationSize, 15333 IN PVOID ProtocolInformation, 15334 IN ULONG CreateOptions OPTIONAL); 15335 15336 NTSYSCALLAPI 15337 NTSTATUS 15338 NTAPI 15339 NtPropagationComplete( 15340 IN HANDLE ResourceManagerHandle, 15341 IN ULONG RequestCookie, 15342 IN ULONG BufferLength, 15343 IN PVOID Buffer); 15344 15345 NTSYSCALLAPI 15346 NTSTATUS 15347 NTAPI 15348 NtPropagationFailed( 15349 IN HANDLE ResourceManagerHandle, 15350 IN ULONG RequestCookie, 15351 IN NTSTATUS PropStatus); 15352 15353 #endif /* NTDDI_VERSION >= NTDDI_VISTA */ 15354 15355 #endif /* !_NTTMAPI_ */ 15356 15357 /****************************************************************************** 15358 * ZwXxx Functions * 15359 ******************************************************************************/ 15360 15361 /* Constants */ 15362 #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) 15363 #define ZwCurrentProcess() NtCurrentProcess() 15364 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) 15365 #define ZwCurrentThread() NtCurrentThread() 15366 15367 15368 #if (NTDDI_VERSION >= NTDDI_WIN2K) 15369 15370 NTSYSAPI 15371 NTSTATUS 15372 NTAPI 15373 ZwClose( 15374 IN HANDLE Handle); 15375 15376 NTSYSAPI 15377 NTSTATUS 15378 NTAPI 15379 ZwCreateDirectoryObject( 15380 OUT PHANDLE DirectoryHandle, 15381 IN ACCESS_MASK DesiredAccess, 15382 IN POBJECT_ATTRIBUTES ObjectAttributes); 15383 15384 NTSYSAPI 15385 NTSTATUS 15386 NTAPI 15387 ZwCreateFile( 15388 OUT PHANDLE FileHandle, 15389 IN ACCESS_MASK DesiredAccess, 15390 IN POBJECT_ATTRIBUTES ObjectAttributes, 15391 OUT PIO_STATUS_BLOCK IoStatusBlock, 15392 IN PLARGE_INTEGER AllocationSize OPTIONAL, 15393 IN ULONG FileAttributes, 15394 IN ULONG ShareAccess, 15395 IN ULONG CreateDisposition, 15396 IN ULONG CreateOptions, 15397 IN PVOID EaBuffer OPTIONAL, 15398 IN ULONG EaLength); 15399 15400 NTSYSAPI 15401 NTSTATUS 15402 NTAPI 15403 ZwCreateKey( 15404 OUT PHANDLE KeyHandle, 15405 IN ACCESS_MASK DesiredAccess, 15406 IN POBJECT_ATTRIBUTES ObjectAttributes, 15407 IN ULONG TitleIndex, 15408 IN PUNICODE_STRING Class OPTIONAL, 15409 IN ULONG CreateOptions, 15410 OUT PULONG Disposition OPTIONAL); 15411 15412 NTSYSAPI 15413 NTSTATUS 15414 NTAPI 15415 ZwCreateSection( 15416 OUT PHANDLE SectionHandle, 15417 IN ACCESS_MASK DesiredAccess, 15418 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15419 IN PLARGE_INTEGER MaximumSize OPTIONAL, 15420 IN ULONG SectionPageProtection, 15421 IN ULONG AllocationAttributes, 15422 IN HANDLE FileHandle OPTIONAL); 15423 15424 NTSYSAPI 15425 NTSTATUS 15426 NTAPI 15427 ZwDeleteKey( 15428 IN HANDLE KeyHandle); 15429 15430 NTSYSAPI 15431 NTSTATUS 15432 NTAPI 15433 ZwDeleteValueKey( 15434 IN HANDLE KeyHandle, 15435 IN PUNICODE_STRING ValueName); 15436 15437 NTSYSAPI 15438 NTSTATUS 15439 NTAPI 15440 ZwEnumerateKey( 15441 IN HANDLE KeyHandle, 15442 IN ULONG Index, 15443 IN KEY_INFORMATION_CLASS KeyInformationClass, 15444 OUT PVOID KeyInformation OPTIONAL, 15445 IN ULONG Length, 15446 OUT PULONG ResultLength); 15447 15448 NTSYSAPI 15449 NTSTATUS 15450 NTAPI 15451 ZwEnumerateValueKey( 15452 IN HANDLE KeyHandle, 15453 IN ULONG Index, 15454 IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, 15455 OUT PVOID KeyValueInformation OPTIONAL, 15456 IN ULONG Length, 15457 OUT PULONG ResultLength); 15458 15459 NTSYSAPI 15460 NTSTATUS 15461 NTAPI 15462 ZwFlushKey( 15463 IN HANDLE KeyHandle); 15464 15465 NTSYSAPI 15466 NTSTATUS 15467 NTAPI 15468 ZwLoadDriver( 15469 IN PUNICODE_STRING DriverServiceName); 15470 15471 NTSYSAPI 15472 NTSTATUS 15473 NTAPI 15474 ZwMakeTemporaryObject( 15475 IN HANDLE Handle); 15476 15477 NTSYSAPI 15478 NTSTATUS 15479 NTAPI 15480 ZwMapViewOfSection( 15481 IN HANDLE SectionHandle, 15482 IN HANDLE ProcessHandle, 15483 IN OUT PVOID *BaseAddress, 15484 IN ULONG_PTR ZeroBits, 15485 IN SIZE_T CommitSize, 15486 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, 15487 IN OUT PSIZE_T ViewSize, 15488 IN SECTION_INHERIT InheritDisposition, 15489 IN ULONG AllocationType, 15490 IN ULONG Protect); 15491 15492 NTSYSAPI 15493 NTSTATUS 15494 NTAPI 15495 ZwOpenFile( 15496 OUT PHANDLE FileHandle, 15497 IN ACCESS_MASK DesiredAccess, 15498 IN POBJECT_ATTRIBUTES ObjectAttributes, 15499 OUT PIO_STATUS_BLOCK IoStatusBlock, 15500 IN ULONG ShareAccess, 15501 IN ULONG OpenOptions); 15502 15503 NTSYSAPI 15504 NTSTATUS 15505 NTAPI 15506 ZwOpenKey( 15507 OUT PHANDLE KeyHandle, 15508 IN ACCESS_MASK DesiredAccess, 15509 IN POBJECT_ATTRIBUTES ObjectAttributes); 15510 15511 NTSYSAPI 15512 NTSTATUS 15513 NTAPI 15514 ZwOpenSection( 15515 OUT PHANDLE SectionHandle, 15516 IN ACCESS_MASK DesiredAccess, 15517 IN POBJECT_ATTRIBUTES ObjectAttributes); 15518 15519 NTSYSAPI 15520 NTSTATUS 15521 NTAPI 15522 ZwOpenSymbolicLinkObject( 15523 OUT PHANDLE LinkHandle, 15524 IN ACCESS_MASK DesiredAccess, 15525 IN POBJECT_ATTRIBUTES ObjectAttributes); 15526 15527 NTSYSAPI 15528 NTSTATUS 15529 NTAPI 15530 ZwQueryInformationFile( 15531 IN HANDLE FileHandle, 15532 OUT PIO_STATUS_BLOCK IoStatusBlock, 15533 OUT PVOID FileInformation, 15534 IN ULONG Length, 15535 IN FILE_INFORMATION_CLASS FileInformationClass); 15536 15537 NTSYSAPI 15538 NTSTATUS 15539 NTAPI 15540 ZwQueryKey( 15541 IN HANDLE KeyHandle, 15542 IN KEY_INFORMATION_CLASS KeyInformationClass, 15543 OUT PVOID KeyInformation OPTIONAL, 15544 IN ULONG Length, 15545 OUT PULONG ResultLength); 15546 15547 NTSYSAPI 15548 NTSTATUS 15549 NTAPI 15550 ZwQuerySymbolicLinkObject( 15551 IN HANDLE LinkHandle, 15552 IN OUT PUNICODE_STRING LinkTarget, 15553 OUT PULONG ReturnedLength OPTIONAL); 15554 15555 NTSYSAPI 15556 NTSTATUS 15557 NTAPI 15558 ZwQueryValueKey( 15559 IN HANDLE KeyHandle, 15560 IN PUNICODE_STRING ValueName, 15561 IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, 15562 OUT PVOID KeyValueInformation OPTIONAL, 15563 IN ULONG Length, 15564 OUT PULONG ResultLength); 15565 15566 NTSYSAPI 15567 NTSTATUS 15568 NTAPI 15569 ZwReadFile( 15570 IN HANDLE FileHandle, 15571 IN HANDLE Event OPTIONAL, 15572 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 15573 IN PVOID ApcContext OPTIONAL, 15574 OUT PIO_STATUS_BLOCK IoStatusBlock, 15575 OUT PVOID Buffer, 15576 IN ULONG Length, 15577 IN PLARGE_INTEGER ByteOffset OPTIONAL, 15578 IN PULONG Key OPTIONAL); 15579 15580 NTSYSAPI 15581 NTSTATUS 15582 NTAPI 15583 ZwSetInformationFile( 15584 IN HANDLE FileHandle, 15585 OUT PIO_STATUS_BLOCK IoStatusBlock, 15586 IN PVOID FileInformation, 15587 IN ULONG Length, 15588 IN FILE_INFORMATION_CLASS FileInformationClass); 15589 15590 NTSYSAPI 15591 NTSTATUS 15592 NTAPI 15593 ZwSetValueKey( 15594 IN HANDLE KeyHandle, 15595 IN PUNICODE_STRING ValueName, 15596 IN ULONG TitleIndex OPTIONAL, 15597 IN ULONG Type, 15598 IN PVOID Data OPTIONAL, 15599 IN ULONG DataSize); 15600 15601 NTSYSAPI 15602 NTSTATUS 15603 NTAPI 15604 ZwUnloadDriver( 15605 IN PUNICODE_STRING DriverServiceName); 15606 15607 NTSYSAPI 15608 NTSTATUS 15609 NTAPI 15610 ZwUnmapViewOfSection( 15611 IN HANDLE ProcessHandle, 15612 IN PVOID BaseAddress OPTIONAL); 15613 15614 NTSYSAPI 15615 NTSTATUS 15616 NTAPI 15617 ZwWriteFile( 15618 IN HANDLE FileHandle, 15619 IN HANDLE Event OPTIONAL, 15620 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 15621 IN PVOID ApcContext OPTIONAL, 15622 OUT PIO_STATUS_BLOCK IoStatusBlock, 15623 IN PVOID Buffer, 15624 IN ULONG Length, 15625 IN PLARGE_INTEGER ByteOffset OPTIONAL, 15626 IN PULONG Key OPTIONAL); 15627 15628 NTSYSAPI 15629 NTSTATUS 15630 NTAPI 15631 ZwQueryFullAttributesFile( 15632 IN POBJECT_ATTRIBUTES ObjectAttributes, 15633 OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); 15634 15635 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ 15636 15637 15638 #if (NTDDI_VERSION >= NTDDI_WS03) 15639 NTSYSCALLAPI 15640 NTSTATUS 15641 NTAPI 15642 ZwOpenEvent( 15643 OUT PHANDLE EventHandle, 15644 IN ACCESS_MASK DesiredAccess, 15645 IN POBJECT_ATTRIBUTES ObjectAttributes); 15646 #endif 15647 15648 #if (NTDDI_VERSION >= NTDDI_VISTA) 15649 15650 NTSYSAPI 15651 NTSTATUS 15652 ZwCreateKeyTransacted( 15653 OUT PHANDLE KeyHandle, 15654 IN ACCESS_MASK DesiredAccess, 15655 IN POBJECT_ATTRIBUTES ObjectAttributes, 15656 IN ULONG TitleIndex, 15657 IN PUNICODE_STRING Class OPTIONAL, 15658 IN ULONG CreateOptions, 15659 IN HANDLE TransactionHandle, 15660 OUT PULONG Disposition OPTIONAL); 15661 15662 NTSYSAPI 15663 NTSTATUS 15664 NTAPI 15665 ZwOpenKeyTransacted( 15666 OUT PHANDLE KeyHandle, 15667 IN ACCESS_MASK DesiredAccess, 15668 IN POBJECT_ATTRIBUTES ObjectAttributes, 15669 IN HANDLE TransactionHandle); 15670 15671 NTSYSCALLAPI 15672 NTSTATUS 15673 NTAPI 15674 ZwCreateTransactionManager( 15675 OUT PHANDLE TmHandle, 15676 IN ACCESS_MASK DesiredAccess, 15677 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15678 IN PUNICODE_STRING LogFileName OPTIONAL, 15679 IN ULONG CreateOptions OPTIONAL, 15680 IN ULONG CommitStrength OPTIONAL); 15681 15682 NTSYSCALLAPI 15683 NTSTATUS 15684 NTAPI 15685 ZwOpenTransactionManager( 15686 OUT PHANDLE TmHandle, 15687 IN ACCESS_MASK DesiredAccess, 15688 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15689 IN PUNICODE_STRING LogFileName OPTIONAL, 15690 IN LPGUID TmIdentity OPTIONAL, 15691 IN ULONG OpenOptions OPTIONAL); 15692 15693 NTSYSCALLAPI 15694 NTSTATUS 15695 NTAPI 15696 ZwRollforwardTransactionManager( 15697 IN HANDLE TransactionManagerHandle, 15698 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15699 15700 NTSYSCALLAPI 15701 NTSTATUS 15702 NTAPI 15703 ZwRecoverTransactionManager( 15704 IN HANDLE TransactionManagerHandle); 15705 15706 NTSYSCALLAPI 15707 NTSTATUS 15708 NTAPI 15709 ZwQueryInformationTransactionManager( 15710 IN HANDLE TransactionManagerHandle, 15711 IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, 15712 OUT PVOID TransactionManagerInformation, 15713 IN ULONG TransactionManagerInformationLength, 15714 OUT PULONG ReturnLength OPTIONAL); 15715 15716 NTSYSCALLAPI 15717 NTSTATUS 15718 NTAPI 15719 ZwSetInformationTransactionManager( 15720 IN HANDLE TmHandle, 15721 IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, 15722 IN PVOID TransactionManagerInformation, 15723 IN ULONG TransactionManagerInformationLength); 15724 15725 NTSYSCALLAPI 15726 NTSTATUS 15727 NTAPI 15728 ZwEnumerateTransactionObject( 15729 IN HANDLE RootObjectHandle OPTIONAL, 15730 IN KTMOBJECT_TYPE QueryType, 15731 IN OUT PKTMOBJECT_CURSOR ObjectCursor, 15732 IN ULONG ObjectCursorLength, 15733 OUT PULONG ReturnLength); 15734 15735 NTSYSCALLAPI 15736 NTSTATUS 15737 NTAPI 15738 ZwCreateTransaction( 15739 OUT PHANDLE TransactionHandle, 15740 IN ACCESS_MASK DesiredAccess, 15741 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15742 IN LPGUID Uow OPTIONAL, 15743 IN HANDLE TmHandle OPTIONAL, 15744 IN ULONG CreateOptions OPTIONAL, 15745 IN ULONG IsolationLevel OPTIONAL, 15746 IN ULONG IsolationFlags OPTIONAL, 15747 IN PLARGE_INTEGER Timeout OPTIONAL, 15748 IN PUNICODE_STRING Description OPTIONAL); 15749 15750 NTSYSCALLAPI 15751 NTSTATUS 15752 NTAPI 15753 ZwOpenTransaction( 15754 OUT PHANDLE TransactionHandle, 15755 IN ACCESS_MASK DesiredAccess, 15756 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15757 IN LPGUID Uow, 15758 IN HANDLE TmHandle OPTIONAL); 15759 15760 NTSYSCALLAPI 15761 NTSTATUS 15762 NTAPI 15763 ZwQueryInformationTransaction( 15764 IN HANDLE TransactionHandle, 15765 IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, 15766 OUT PVOID TransactionInformation, 15767 IN ULONG TransactionInformationLength, 15768 OUT PULONG ReturnLength OPTIONAL); 15769 15770 NTSYSCALLAPI 15771 NTSTATUS 15772 NTAPI 15773 ZwSetInformationTransaction( 15774 IN HANDLE TransactionHandle, 15775 IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, 15776 IN PVOID TransactionInformation, 15777 IN ULONG TransactionInformationLength); 15778 15779 NTSYSCALLAPI 15780 NTSTATUS 15781 NTAPI 15782 ZwCommitTransaction( 15783 IN HANDLE TransactionHandle, 15784 IN BOOLEAN Wait); 15785 15786 NTSYSCALLAPI 15787 NTSTATUS 15788 NTAPI 15789 ZwRollbackTransaction( 15790 IN HANDLE TransactionHandle, 15791 IN BOOLEAN Wait); 15792 15793 NTSYSCALLAPI 15794 NTSTATUS 15795 NTAPI 15796 ZwCreateResourceManager( 15797 OUT PHANDLE ResourceManagerHandle, 15798 IN ACCESS_MASK DesiredAccess, 15799 IN HANDLE TmHandle, 15800 IN LPGUID ResourceManagerGuid OPTIONAL, 15801 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15802 IN ULONG CreateOptions OPTIONAL, 15803 IN PUNICODE_STRING Description OPTIONAL); 15804 15805 NTSYSCALLAPI 15806 NTSTATUS 15807 NTAPI 15808 ZwOpenResourceManager( 15809 OUT PHANDLE ResourceManagerHandle, 15810 IN ACCESS_MASK DesiredAccess, 15811 IN HANDLE TmHandle, 15812 IN LPGUID ResourceManagerGuid, 15813 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); 15814 15815 NTSYSCALLAPI 15816 NTSTATUS 15817 NTAPI 15818 ZwRecoverResourceManager( 15819 IN HANDLE ResourceManagerHandle); 15820 15821 NTSYSCALLAPI 15822 NTSTATUS 15823 NTAPI 15824 ZwGetNotificationResourceManager( 15825 IN HANDLE ResourceManagerHandle, 15826 OUT PTRANSACTION_NOTIFICATION TransactionNotification, 15827 IN ULONG NotificationLength, 15828 IN PLARGE_INTEGER Timeout, 15829 IN PULONG ReturnLength OPTIONAL, 15830 IN ULONG Asynchronous, 15831 IN ULONG_PTR AsynchronousContext OPTIONAL); 15832 15833 NTSYSCALLAPI 15834 NTSTATUS 15835 NTAPI 15836 ZwQueryInformationResourceManager( 15837 IN HANDLE ResourceManagerHandle, 15838 IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, 15839 OUT PVOID ResourceManagerInformation, 15840 IN ULONG ResourceManagerInformationLength, 15841 IN PULONG ReturnLength OPTIONAL); 15842 15843 NTSYSCALLAPI 15844 NTSTATUS 15845 NTAPI 15846 ZwSetInformationResourceManager( 15847 IN HANDLE ResourceManagerHandle, 15848 IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, 15849 IN PVOID ResourceManagerInformation, 15850 IN ULONG ResourceManagerInformationLength); 15851 15852 NTSYSCALLAPI 15853 NTSTATUS 15854 NTAPI 15855 ZwCreateEnlistment( 15856 OUT PHANDLE EnlistmentHandle, 15857 IN ACCESS_MASK DesiredAccess, 15858 IN HANDLE ResourceManagerHandle, 15859 IN HANDLE TransactionHandle, 15860 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, 15861 IN ULONG CreateOptions OPTIONAL, 15862 IN NOTIFICATION_MASK NotificationMask, 15863 IN PVOID EnlistmentKey OPTIONAL); 15864 15865 NTSYSCALLAPI 15866 NTSTATUS 15867 NTAPI 15868 ZwOpenEnlistment( 15869 OUT PHANDLE EnlistmentHandle, 15870 IN ACCESS_MASK DesiredAccess, 15871 IN HANDLE RmHandle, 15872 IN LPGUID EnlistmentGuid, 15873 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); 15874 15875 NTSYSCALLAPI 15876 NTSTATUS 15877 NTAPI 15878 ZwQueryInformationEnlistment( 15879 IN HANDLE EnlistmentHandle, 15880 IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, 15881 OUT PVOID EnlistmentInformation, 15882 IN ULONG EnlistmentInformationLength, 15883 IN PULONG ReturnLength OPTIONAL); 15884 15885 NTSYSCALLAPI 15886 NTSTATUS 15887 NTAPI 15888 ZwSetInformationEnlistment( 15889 IN HANDLE EnlistmentHandle, 15890 IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, 15891 IN PVOID EnlistmentInformation, 15892 IN ULONG EnlistmentInformationLength); 15893 15894 NTSYSCALLAPI 15895 NTSTATUS 15896 NTAPI 15897 ZwRecoverEnlistment( 15898 IN HANDLE EnlistmentHandle, 15899 IN PVOID EnlistmentKey OPTIONAL); 15900 15901 NTSYSCALLAPI 15902 NTSTATUS 15903 NTAPI 15904 ZwPrePrepareEnlistment( 15905 IN HANDLE EnlistmentHandle, 15906 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15907 15908 NTSYSCALLAPI 15909 NTSTATUS 15910 NTAPI 15911 ZwPrepareEnlistment( 15912 IN HANDLE EnlistmentHandle, 15913 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15914 15915 NTSYSCALLAPI 15916 NTSTATUS 15917 NTAPI 15918 ZwCommitEnlistment( 15919 IN HANDLE EnlistmentHandle, 15920 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15921 15922 NTSYSCALLAPI 15923 NTSTATUS 15924 NTAPI 15925 ZwRollbackEnlistment( 15926 IN HANDLE EnlistmentHandle, 15927 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15928 15929 NTSYSCALLAPI 15930 NTSTATUS 15931 NTAPI 15932 ZwPrePrepareComplete( 15933 IN HANDLE EnlistmentHandle, 15934 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15935 15936 NTSYSCALLAPI 15937 NTSTATUS 15938 NTAPI 15939 ZwPrepareComplete( 15940 IN HANDLE EnlistmentHandle, 15941 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15942 15943 NTSYSCALLAPI 15944 NTSTATUS 15945 NTAPI 15946 ZwCommitComplete( 15947 IN HANDLE EnlistmentHandle, 15948 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15949 15950 NTSYSCALLAPI 15951 NTSTATUS 15952 NTAPI 15953 ZwReadOnlyEnlistment( 15954 IN HANDLE EnlistmentHandle, 15955 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15956 15957 NTSYSCALLAPI 15958 NTSTATUS 15959 NTAPI 15960 ZwRollbackComplete( 15961 IN HANDLE EnlistmentHandle, 15962 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15963 15964 NTSYSCALLAPI 15965 NTSTATUS 15966 NTAPI 15967 ZwSinglePhaseReject( 15968 IN HANDLE EnlistmentHandle, 15969 IN PLARGE_INTEGER TmVirtualClock OPTIONAL); 15970 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ 15971 15972 #if (NTDDI_VERSION >= NTDDI_WIN7) 15973 NTSYSAPI 15974 NTSTATUS 15975 NTAPI 15976 ZwOpenKeyEx( 15977 OUT PHANDLE KeyHandle, 15978 IN ACCESS_MASK DesiredAccess, 15979 IN POBJECT_ATTRIBUTES ObjectAttributes, 15980 IN ULONG OpenOptions); 15981 15982 NTSYSAPI 15983 NTSTATUS 15984 NTAPI 15985 ZwOpenKeyTransactedEx( 15986 OUT PHANDLE KeyHandle, 15987 IN ACCESS_MASK DesiredAccess, 15988 IN POBJECT_ATTRIBUTES ObjectAttributes, 15989 IN ULONG OpenOptions, 15990 IN HANDLE TransactionHandle); 15991 15992 NTSYSAPI 15993 NTSTATUS 15994 NTAPI 15995 ZwNotifyChangeMultipleKeys( 15996 IN HANDLE MasterKeyHandle, 15997 IN ULONG Count OPTIONAL, 15998 IN OBJECT_ATTRIBUTES SubordinateObjects[] OPTIONAL, 15999 IN HANDLE Event OPTIONAL, 16000 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 16001 IN PVOID ApcContext OPTIONAL, 16002 OUT PIO_STATUS_BLOCK IoStatusBlock, 16003 IN ULONG CompletionFilter, 16004 IN BOOLEAN WatchTree, 16005 OUT PVOID Buffer OPTIONAL, 16006 IN ULONG BufferSize, 16007 IN BOOLEAN Asynchronous); 16008 16009 NTSYSAPI 16010 NTSTATUS 16011 NTAPI 16012 ZwQueryMultipleValueKey( 16013 IN HANDLE KeyHandle, 16014 IN OUT PKEY_VALUE_ENTRY ValueEntries, 16015 IN ULONG EntryCount, 16016 OUT PVOID ValueBuffer, 16017 IN OUT PULONG BufferLength, 16018 OUT PULONG RequiredBufferLength OPTIONAL); 16019 16020 NTSYSAPI 16021 NTSTATUS 16022 NTAPI 16023 ZwRenameKey( 16024 IN HANDLE KeyHandle, 16025 IN PUNICODE_STRING NewName); 16026 16027 NTSYSAPI 16028 NTSTATUS 16029 NTAPI 16030 ZwSetInformationKey( 16031 IN HANDLE KeyHandle, 16032 IN KEY_SET_INFORMATION_CLASS KeySetInformationClass, 16033 IN PVOID KeySetInformation, 16034 IN ULONG KeySetInformationLength); 16035 16036 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 16037 16038 #ifdef __cplusplus 16039 } 16040 #endif 16041 16042 #endif /* !_WDMDDK_ */ 16043