1 /*++ NDK Version: 0098 2 3 Copyright (c) Alex Ionescu. All rights reserved. 4 5 Header Name: 6 7 mmtypes.h 8 9 Abstract: 10 11 Type definitions for the Memory Manager 12 13 Author: 14 15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006 16 17 --*/ 18 19 #ifndef _MMTYPES_H 20 #define _MMTYPES_H 21 22 // 23 // Dependencies 24 // 25 #include <umtypes.h> 26 #include <arch/mmtypes.h> 27 #include <extypes.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 // 34 // Page-Rounding Macros 35 // 36 #define PAGE_ROUND_DOWN(x) \ 37 (((ULONG_PTR)(x))&(~(PAGE_SIZE-1))) 38 #define PAGE_ROUND_UP(x) \ 39 ( (((ULONG_PTR)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) ) 40 #ifdef NTOS_MODE_USER 41 #define ROUND_TO_PAGES(Size) \ 42 (((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) 43 #endif 44 #define ROUND_TO_ALLOCATION_GRANULARITY(Size) \ 45 (((ULONG_PTR)(Size) + MM_ALLOCATION_GRANULARITY - 1) \ 46 & ~(MM_ALLOCATION_GRANULARITY - 1)) 47 48 // 49 // PFN Identity Uses 50 // 51 #define MMPFNUSE_PROCESSPRIVATE 0 52 #define MMPFNUSE_FILE 1 53 #define MMPFNUSE_PAGEFILEMAPPED 2 54 #define MMPFNUSE_PAGETABLE 3 55 #define MMPFNUSE_PAGEDPOOL 4 56 #define MMPFNUSE_NONPAGEDPOOL 5 57 #define MMPFNUSE_SYSTEMPTE 6 58 #define MMPFNUSE_SESSIONPRIVATE 7 59 #define MMPFNUSE_METAFILE 8 60 #define MMPFNUSE_AWEPAGE 9 61 #define MMPFNUSE_DRIVERLOCKPAGE 10 62 #define MMPFNUSE_KERNELSTACK 11 63 64 // 65 // Lock/Unlock Virtuam Memory Flags 66 // 67 #define MAP_PROCESS 1 68 #define MAP_SYSTEM 2 69 70 // 71 // Flags for ProcessExecutionOptions 72 // 73 #define MEM_EXECUTE_OPTION_DISABLE 0x1 74 #define MEM_EXECUTE_OPTION_ENABLE 0x2 75 #define MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION 0x4 76 #define MEM_EXECUTE_OPTION_PERMANENT 0x8 77 #define MEM_EXECUTE_OPTION_EXECUTE_DISPATCH_ENABLE 0x10 78 #define MEM_EXECUTE_OPTION_IMAGE_DISPATCH_ENABLE 0x20 79 #define MEM_EXECUTE_OPTION_VALID_FLAGS 0x3F 80 81 #ifndef NTOS_MODE_USER 82 // 83 // Virtual Memory Flags 84 // 85 #define MEM_WRITE_WATCH 0x200000 86 #define MEM_PHYSICAL 0x400000 87 #define MEM_ROTATE 0x800000 88 #define MEM_IMAGE SEC_IMAGE 89 #define MEM_DOS_LIM 0x40000000 90 91 // 92 // Section Flags for NtCreateSection 93 // 94 #define SEC_NO_CHANGE 0x400000 95 #define SEC_FILE 0x800000 96 #define SEC_IMAGE 0x1000000 97 #define SEC_PROTECTED_IMAGE 0x2000000 98 #define SEC_RESERVE 0x4000000 99 #define SEC_COMMIT 0x8000000 100 #define SEC_NOCACHE 0x10000000 101 #define SEC_WRITECOMBINE 0x40000000 102 #define SEC_LARGE_PAGES 0x80000000 103 #else 104 #define SEC_BASED 0x200000 105 106 // 107 // Section Inherit Flags for NtCreateSection 108 // 109 typedef enum _SECTION_INHERIT 110 { 111 ViewShare = 1, 112 ViewUnmap = 2 113 } SECTION_INHERIT; 114 115 // 116 // Pool Types 117 // 118 typedef enum _POOL_TYPE 119 { 120 NonPagedPool, 121 PagedPool, 122 NonPagedPoolMustSucceed, 123 DontUseThisType, 124 NonPagedPoolCacheAligned, 125 PagedPoolCacheAligned, 126 NonPagedPoolCacheAlignedMustS, 127 MaxPoolType, 128 129 NonPagedPoolBase = 0, 130 NonPagedPoolBaseMustSucceed = NonPagedPoolBase + 2, 131 NonPagedPoolBaseCacheAligned = NonPagedPoolBase + 4, 132 NonPagedPoolBaseCacheAlignedMustS = NonPagedPoolBase + 6, 133 134 NonPagedPoolSession = 32, 135 PagedPoolSession, 136 NonPagedPoolMustSucceedSession, 137 DontUseThisTypeSession, 138 NonPagedPoolCacheAlignedSession, 139 PagedPoolCacheAlignedSession, 140 NonPagedPoolCacheAlignedMustSSession 141 } POOL_TYPE; 142 #endif 143 144 // 145 // Memory Manager Page Lists 146 // 147 typedef enum _MMLISTS 148 { 149 ZeroedPageList = 0, 150 FreePageList = 1, 151 StandbyPageList = 2, 152 ModifiedPageList = 3, 153 ModifiedNoWritePageList = 4, 154 BadPageList = 5, 155 ActiveAndValid = 6, 156 TransitionPage = 7 157 } MMLISTS; 158 159 // 160 // Per Processor Non Paged Lookaside List IDs 161 // 162 typedef enum _PP_NPAGED_LOOKASIDE_NUMBER 163 { 164 LookasideSmallIrpList = 0, 165 LookasideLargeIrpList = 1, 166 LookasideMdlList = 2, 167 LookasideCreateInfoList = 3, 168 LookasideNameBufferList = 4, 169 LookasideTwilightList = 5, 170 LookasideCompletionList = 6, 171 LookasideMaximumList = 7 172 } PP_NPAGED_LOOKASIDE_NUMBER; 173 174 // 175 // Memory Information Classes for NtQueryVirtualMemory 176 // 177 typedef enum _MEMORY_INFORMATION_CLASS 178 { 179 MemoryBasicInformation, 180 MemoryWorkingSetList, 181 MemorySectionName, 182 MemoryBasicVlmInformation, 183 MemoryWorkingSetExList 184 } MEMORY_INFORMATION_CLASS; 185 186 // 187 // Section Information Clasess for NtQuerySection 188 // 189 typedef enum _SECTION_INFORMATION_CLASS 190 { 191 SectionBasicInformation, 192 SectionImageInformation, 193 } SECTION_INFORMATION_CLASS; 194 195 // 196 // Kinds of VADs 197 // 198 typedef enum _MI_VAD_TYPE 199 { 200 VadNone, 201 VadDevicePhysicalMemory, 202 VadImageMap, 203 VadAwe, 204 VadWriteWatch, 205 VadLargePages, 206 VadRotatePhysical, 207 VadLargePageSection 208 } MI_VAD_TYPE, *PMI_VAD_TYPE; 209 210 #ifdef NTOS_MODE_USER 211 212 // 213 // Virtual Memory Counters 214 // 215 typedef struct _VM_COUNTERS 216 { 217 SIZE_T PeakVirtualSize; 218 SIZE_T VirtualSize; 219 ULONG PageFaultCount; 220 SIZE_T PeakWorkingSetSize; 221 SIZE_T WorkingSetSize; 222 SIZE_T QuotaPeakPagedPoolUsage; 223 SIZE_T QuotaPagedPoolUsage; 224 SIZE_T QuotaPeakNonPagedPoolUsage; 225 SIZE_T QuotaNonPagedPoolUsage; 226 SIZE_T PagefileUsage; 227 SIZE_T PeakPagefileUsage; 228 } VM_COUNTERS, *PVM_COUNTERS; 229 230 typedef struct _VM_COUNTERS_EX 231 { 232 SIZE_T PeakVirtualSize; 233 SIZE_T VirtualSize; 234 ULONG PageFaultCount; 235 SIZE_T PeakWorkingSetSize; 236 SIZE_T WorkingSetSize; 237 SIZE_T QuotaPeakPagedPoolUsage; 238 SIZE_T QuotaPagedPoolUsage; 239 SIZE_T QuotaPeakNonPagedPoolUsage; 240 SIZE_T QuotaNonPagedPoolUsage; 241 SIZE_T PagefileUsage; 242 SIZE_T PeakPagefileUsage; 243 SIZE_T PrivateUsage; 244 } VM_COUNTERS_EX, *PVM_COUNTERS_EX; 245 #endif 246 247 // 248 // Sub-Information Types for PFN Identity 249 // 250 typedef struct _MEMORY_FRAME_INFORMATION 251 { 252 ULONGLONG UseDescription:4; 253 ULONGLONG ListDescription:3; 254 ULONGLONG Reserved0:1; 255 ULONGLONG Pinned:1; 256 ULONGLONG DontUse:48; 257 ULONGLONG Priority:3; 258 ULONGLONG Reserved:4; 259 } MEMORY_FRAME_INFORMATION, *PMEMORY_FRAME_INFORMATION; 260 261 typedef struct _FILEOFFSET_INFORMATION 262 { 263 ULONGLONG DontUse:9; 264 ULONGLONG Offset:48; 265 ULONGLONG Reserved:7; 266 } FILEOFFSET_INFORMATION, *PFILEOFFSET_INFORMATION; 267 268 typedef struct _PAGEDIR_INFORMATION 269 { 270 ULONGLONG DontUse:9; 271 ULONGLONG PageDirectoryBase:48; 272 ULONGLONG Reserved:7; 273 } PAGEDIR_INFORMATION, *PPAGEDIR_INFORMATION; 274 275 typedef struct _UNIQUE_PROCESS_INFORMATION 276 { 277 ULONGLONG DontUse:9; 278 ULONGLONG UniqueProcessKey:48; 279 ULONGLONG Reserved:7; 280 } UNIQUE_PROCESS_INFORMATION, *PUNIQUE_PROCESS_INFORMATION; 281 282 // 283 // PFN Identity Data Structure 284 // 285 typedef struct _MMPFN_IDENTITY 286 { 287 union 288 { 289 MEMORY_FRAME_INFORMATION e1; 290 FILEOFFSET_INFORMATION e2; 291 PAGEDIR_INFORMATION e3; 292 UNIQUE_PROCESS_INFORMATION e4; 293 } u1; 294 SIZE_T PageFrameIndex; 295 union 296 { 297 struct 298 { 299 ULONG Image:1; 300 ULONG Mismatch:1; 301 } e1; 302 PVOID FileObject; 303 PVOID UniqueFileObjectKey; 304 PVOID ProtoPteAddress; 305 PVOID VirtualAddress; 306 } u2; 307 } MMPFN_IDENTITY, *PMMPFN_IDENTITY; 308 309 // 310 // List of Working Sets 311 // 312 typedef struct _MEMORY_WORKING_SET_LIST 313 { 314 ULONG NumberOfPages; 315 ULONG WorkingSetList[1]; 316 } MEMORY_WORKING_SET_LIST, *PMEMORY_WORKING_SET_LIST; 317 318 // 319 // Memory Information Structures for NtQueryVirtualMemory 320 // 321 typedef struct 322 { 323 UNICODE_STRING SectionFileName; 324 } MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME; 325 326 // 327 // Section Information Structures for NtQuerySection 328 // 329 typedef struct _SECTION_BASIC_INFORMATION 330 { 331 PVOID BaseAddress; 332 ULONG Attributes; 333 LARGE_INTEGER Size; 334 } SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION; 335 336 typedef struct _SECTION_IMAGE_INFORMATION 337 { 338 PVOID TransferAddress; 339 ULONG ZeroBits; 340 SIZE_T MaximumStackSize; 341 SIZE_T CommittedStackSize; 342 ULONG SubSystemType; 343 union 344 { 345 struct 346 { 347 USHORT SubSystemMinorVersion; 348 USHORT SubSystemMajorVersion; 349 }; 350 ULONG SubSystemVersion; 351 }; 352 ULONG GpValue; 353 USHORT ImageCharacteristics; 354 USHORT DllCharacteristics; 355 USHORT Machine; 356 BOOLEAN ImageContainsCode; 357 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 358 union 359 { 360 struct 361 { 362 UCHAR ComPlusNativeReady:1; 363 UCHAR ComPlusILOnly:1; 364 UCHAR ImageDynamicallyRelocated:1; 365 UCHAR ImageMappedFlat:1; 366 UCHAR Reserved:4; 367 }; 368 UCHAR ImageFlags; 369 }; 370 #else 371 BOOLEAN Spare1; 372 #endif 373 ULONG LoaderFlags; 374 ULONG ImageFileSize; 375 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 376 ULONG CheckSum; 377 #else 378 ULONG Reserved[1]; 379 #endif 380 } SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION; 381 382 #ifndef NTOS_MODE_USER 383 384 // 385 // Section Extension Information 386 // 387 typedef struct _MMEXTEND_INFO 388 { 389 ULONGLONG CommittedSize; 390 ULONG ReferenceCount; 391 } MMEXTEND_INFO, *PMMEXTEND_INFO; 392 393 // 394 // Segment and Segment Flags 395 // 396 typedef struct _SEGMENT_FLAGS 397 { 398 ULONG TotalNumberOfPtes4132:10; 399 ULONG ExtraSharedWowSubsections:1; 400 ULONG LargePages:1; 401 ULONG Spare:20; 402 } SEGMENT_FLAGS, *PSEGMENT_FLAGS; 403 404 typedef struct _SEGMENT 405 { 406 struct _CONTROL_AREA *ControlArea; 407 ULONG TotalNumberOfPtes; 408 ULONG NonExtendedPtes; 409 ULONG Spare0; 410 ULONGLONG SizeOfSegment; 411 MMPTE SegmentPteTemplate; 412 ULONG NumberOfCommittedPages; 413 PMMEXTEND_INFO ExtendInfo; 414 SEGMENT_FLAGS SegmentFlags; 415 PVOID BasedAddress; 416 union 417 { 418 SIZE_T ImageCommitment; 419 PEPROCESS CreatingProcess; 420 } u1; 421 union 422 { 423 PSECTION_IMAGE_INFORMATION ImageInformation; 424 PVOID FirstMappedVa; 425 } u2; 426 PMMPTE PrototypePte; 427 MMPTE ThePtes[1]; 428 } SEGMENT, *PSEGMENT; 429 430 typedef struct _MAPPED_FILE_SEGMENT 431 { 432 struct _CONTROL_AREA *ControlArea; 433 ULONG TotalNumberOfPtes; 434 ULONG NonExtendedPtes; 435 ULONG Spare0; 436 UINT64 SizeOfSegment; 437 MMPTE SegmentPteTemplate; 438 SIZE_T NumberOfCommittedPages; 439 PMMEXTEND_INFO ExtendInfo; 440 SEGMENT_FLAGS SegmentFlags; 441 PVOID BasedAddress; 442 struct _MSUBSECTION *LastSubsectionHint; 443 } MAPPED_FILE_SEGMENT, *PMAPPED_FILE_SEGMENT; 444 445 // 446 // Event Counter Structure 447 // 448 typedef struct _EVENT_COUNTER 449 { 450 SLIST_ENTRY ListEntry; 451 ULONG RefCount; 452 KEVENT Event; 453 } EVENT_COUNTER, *PEVENT_COUNTER; 454 455 // 456 // Flags 457 // 458 typedef struct _MMSECTION_FLAGS 459 { 460 ULONG BeingDeleted:1; 461 ULONG BeingCreated:1; 462 ULONG BeingPurged:1; 463 ULONG NoModifiedWriting:1; 464 ULONG FailAllIo:1; 465 ULONG Image:1; 466 ULONG Based:1; 467 ULONG File:1; 468 ULONG Networked:1; 469 ULONG NoCache:1; 470 ULONG PhysicalMemory:1; 471 ULONG CopyOnWrite:1; 472 ULONG Reserve:1; 473 ULONG Commit:1; 474 ULONG FloppyMedia:1; 475 ULONG WasPurged:1; 476 ULONG UserReference:1; 477 ULONG GlobalMemory:1; 478 ULONG DeleteOnClose:1; 479 ULONG FilePointerNull:1; 480 ULONG DebugSymbolsLoaded:1; 481 ULONG SetMappedFileIoComplete:1; 482 ULONG CollidedFlush:1; 483 ULONG NoChange:1; 484 ULONG filler0:1; 485 ULONG ImageMappedInSystemSpace:1; 486 ULONG UserWritable:1; 487 ULONG Accessed:1; 488 ULONG GlobalOnlyPerSession:1; 489 ULONG Rom:1; 490 ULONG WriteCombined:1; 491 ULONG filler:1; 492 } MMSECTION_FLAGS, *PMMSECTION_FLAGS; 493 494 typedef struct _MMSUBSECTION_FLAGS 495 { 496 ULONG ReadOnly:1; 497 ULONG ReadWrite:1; 498 ULONG SubsectionStatic:1; 499 ULONG GlobalMemory:1; 500 ULONG Protection:5; 501 ULONG Spare:1; 502 ULONG StartingSector4132:10; 503 ULONG SectorEndOffset:12; 504 } MMSUBSECTION_FLAGS, *PMMSUBSECTION_FLAGS; 505 506 typedef struct _MMSUBSECTION_FLAGS2 507 { 508 ULONG SubsectionAccessed:1; 509 ULONG SubsectionConverted:1; 510 ULONG Reserved:30; 511 } MMSUBSECTION_FLAGS2; 512 513 // 514 // Control Area Structures (8-byte aligned) 515 // 516 typedef struct _CONTROL_AREA 517 { 518 PSEGMENT Segment; 519 LIST_ENTRY DereferenceList; 520 ULONG NumberOfSectionReferences; 521 ULONG NumberOfPfnReferences; 522 ULONG NumberOfMappedViews; 523 ULONG NumberOfSystemCacheViews; 524 ULONG NumberOfUserReferences; 525 union 526 { 527 ULONG LongFlags; 528 MMSECTION_FLAGS Flags; 529 } u; 530 PFILE_OBJECT FilePointer; 531 PEVENT_COUNTER WaitingForDeletion; 532 USHORT ModifiedWriteCount; 533 USHORT FlushInProgressCount; 534 ULONG WritableUserReferences; 535 ULONG QuadwordPad; 536 } CONTROL_AREA, *PCONTROL_AREA; 537 C_ASSERT((sizeof(CONTROL_AREA) % 8) == 0); 538 539 typedef struct _LARGE_CONTROL_AREA 540 { 541 PSEGMENT Segment; 542 LIST_ENTRY DereferenceList; 543 ULONG NumberOfSectionReferences; 544 ULONG NumberOfPfnReferences; 545 ULONG NumberOfMappedViews; 546 ULONG NumberOfSystemCacheViews; 547 ULONG NumberOfUserReferences; 548 union 549 { 550 ULONG LongFlags; 551 MMSECTION_FLAGS Flags; 552 } u; 553 PFILE_OBJECT FilePointer; 554 PEVENT_COUNTER WaitingForDeletion; 555 USHORT ModifiedWriteCount; 556 USHORT FlushInProgressCount; 557 ULONG WritableUserReferences; 558 ULONG QuadwordPad; 559 ULONG StartingFrame; 560 LIST_ENTRY UserGlobalList; 561 ULONG SessionId; 562 } LARGE_CONTROL_AREA, *PLARGE_CONTROL_AREA; 563 C_ASSERT((sizeof(LARGE_CONTROL_AREA) % 8) == 0); 564 565 // 566 // Subsection and Mapped Subsection (8-byte aligned) 567 // 568 typedef struct _SUBSECTION 569 { 570 PCONTROL_AREA ControlArea; 571 union 572 { 573 ULONG LongFlags; 574 MMSUBSECTION_FLAGS SubsectionFlags; 575 } u; 576 ULONG StartingSector; 577 ULONG NumberOfFullSectors; 578 PMMPTE SubsectionBase; 579 ULONG UnusedPtes; 580 ULONG PtesInSubsection; 581 struct _SUBSECTION *NextSubsection; 582 } SUBSECTION, *PSUBSECTION; 583 C_ASSERT((sizeof(SUBSECTION) % 8) == 0); 584 585 typedef struct _MSUBSECTION 586 { 587 PCONTROL_AREA ControlArea; 588 union 589 { 590 ULONG LongFlags; 591 MMSUBSECTION_FLAGS SubsectionFlags; 592 } u; 593 ULONG StartingSector; 594 ULONG NumberOfFullSectors; 595 PMMPTE SubsectionBase; 596 ULONG UnusedPtes; 597 ULONG PtesInSubsection; 598 struct _SUBSECTION *NextSubsection; 599 LIST_ENTRY DereferenceList; 600 ULONG_PTR NumberOfMappedViews; 601 union 602 { 603 ULONG LongFlags2; 604 MMSUBSECTION_FLAGS2 SubsectionFlags2; 605 } u2; 606 } MSUBSECTION, *PMSUBSECTION; 607 C_ASSERT((sizeof(MSUBSECTION) % 8) == 0); 608 609 // 610 // Segment Object 611 // 612 typedef struct _SEGMENT_OBJECT 613 { 614 PVOID BaseAddress; 615 ULONG TotalNumberOfPtes; 616 LARGE_INTEGER SizeOfSegment; 617 ULONG NonExtendedPtes; 618 ULONG ImageCommitment; 619 PCONTROL_AREA ControlArea; 620 PSUBSECTION Subsection; 621 PLARGE_CONTROL_AREA LargeControlArea; 622 PMMSECTION_FLAGS MmSectionFlags; 623 PMMSUBSECTION_FLAGS MmSubSectionFlags; 624 } SEGMENT_OBJECT, *PSEGMENT_OBJECT; 625 626 // 627 // Section Object 628 // 629 typedef struct _SECTION_OBJECT 630 { 631 PVOID StartingVa; 632 PVOID EndingVa; 633 PVOID Parent; 634 PVOID LeftChild; 635 PVOID RightChild; 636 PSEGMENT_OBJECT Segment; 637 } SECTION_OBJECT, *PSECTION_OBJECT; 638 639 // 640 // Generic Address Range Structure 641 // 642 typedef struct _ADDRESS_RANGE 643 { 644 ULONG BaseAddrLow; 645 ULONG BaseAddrHigh; 646 ULONG LengthLow; 647 ULONG LengthHigh; 648 ULONG Type; 649 } ADDRESS_RANGE, *PADDRESS_RANGE; 650 651 // 652 // Node in Memory Manager's AVL Table 653 // 654 typedef struct _MMADDRESS_NODE 655 { 656 union 657 { 658 LONG_PTR Balance:2; 659 struct _MMADDRESS_NODE *Parent; 660 } u1; 661 struct _MMADDRESS_NODE *LeftChild; 662 struct _MMADDRESS_NODE *RightChild; 663 ULONG_PTR StartingVpn; 664 ULONG_PTR EndingVpn; 665 } MMADDRESS_NODE, *PMMADDRESS_NODE; 666 667 // 668 // Memory Manager AVL Table for VADs and other descriptors 669 // 670 typedef struct _MM_AVL_TABLE 671 { 672 MMADDRESS_NODE BalancedRoot; 673 ULONG_PTR DepthOfTree:5; 674 ULONG_PTR Unused:3; 675 #ifdef _WIN64 676 ULONG_PTR NumberGenericTableElements:56; 677 #else 678 ULONG_PTR NumberGenericTableElements:24; 679 #endif 680 PVOID NodeHint; 681 PVOID NodeFreeHint; 682 } MM_AVL_TABLE, *PMM_AVL_TABLE; 683 684 // 685 // Virtual Adress List used in VADs 686 // 687 typedef struct _MMADDRESS_LIST 688 { 689 ULONG_PTR StartVpn; 690 ULONG_PTR EndVpn; 691 } MMADDRESS_LIST, *PMMADDRESS_LIST; 692 693 // 694 // Flags used in the VAD 695 // 696 typedef struct _MMVAD_FLAGS 697 { 698 #ifdef _WIN64 699 ULONG_PTR CommitCharge:51; 700 #else 701 ULONG_PTR CommitCharge:19; 702 #endif 703 ULONG_PTR NoChange:1; 704 ULONG_PTR VadType:3; 705 ULONG_PTR MemCommit:1; 706 ULONG_PTR Protection:5; 707 ULONG_PTR Spare:2; 708 ULONG_PTR PrivateMemory:1; 709 } MMVAD_FLAGS, *PMMVAD_FLAGS; 710 711 // 712 // Extended flags used in the VAD 713 // 714 typedef struct _MMVAD_FLAGS2 715 { 716 ULONG FileOffset:24; 717 ULONG SecNoChange:1; 718 ULONG OneSecured:1; 719 ULONG MultipleSecured:1; 720 ULONG ReadOnly:1; 721 ULONG LongVad:1; 722 ULONG ExtendableFile:1; 723 ULONG Inherit:1; 724 ULONG CopyOnWrite:1; 725 } MMVAD_FLAGS2, *PMMVAD_FLAGS2; 726 727 // 728 // Virtual Address Descriptor (VAD) Structure 729 // 730 typedef struct _MMVAD 731 { 732 union 733 { 734 LONG_PTR Balance:2; 735 struct _MMVAD *Parent; 736 } u1; 737 struct _MMVAD *LeftChild; 738 struct _MMVAD *RightChild; 739 ULONG_PTR StartingVpn; 740 ULONG_PTR EndingVpn; 741 union 742 { 743 ULONG_PTR LongFlags; 744 MMVAD_FLAGS VadFlags; 745 } u; 746 PCONTROL_AREA ControlArea; 747 PMMPTE FirstPrototypePte; 748 PMMPTE LastContiguousPte; 749 union 750 { 751 ULONG LongFlags2; 752 MMVAD_FLAGS2 VadFlags2; 753 } u2; 754 } MMVAD, *PMMVAD; 755 756 // 757 // Long VAD used in section and private allocations 758 // 759 typedef struct _MMVAD_LONG 760 { 761 union 762 { 763 LONG_PTR Balance:2; 764 PMMVAD Parent; 765 } u1; 766 PMMVAD LeftChild; 767 PMMVAD RightChild; 768 ULONG_PTR StartingVpn; 769 ULONG_PTR EndingVpn; 770 union 771 { 772 ULONG_PTR LongFlags; 773 MMVAD_FLAGS VadFlags; 774 } u; 775 PCONTROL_AREA ControlArea; 776 PMMPTE FirstPrototypePte; 777 PMMPTE LastContiguousPte; 778 union 779 { 780 ULONG LongFlags2; 781 MMVAD_FLAGS2 VadFlags2; 782 } u2; 783 union 784 { 785 LIST_ENTRY List; 786 MMADDRESS_LIST Secured; 787 } u3; 788 union 789 { 790 PVOID Banked; 791 PMMEXTEND_INFO ExtendedInfo; 792 } u4; 793 } MMVAD_LONG, *PMMVAD_LONG; 794 795 // 796 // Short VAD used in virtual memory allocations 797 // 798 typedef struct _MMVAD_SHORT 799 { 800 union 801 { 802 LONG_PTR Balance:2; 803 PMMVAD Parent; 804 } u1; 805 PMMVAD LeftChild; 806 PMMVAD RightChild; 807 ULONG_PTR StartingVpn; 808 ULONG_PTR EndingVpn; 809 union 810 { 811 ULONG_PTR LongFlags; 812 MMVAD_FLAGS VadFlags; 813 } u; 814 } MMVAD_SHORT, *PMMVAD_SHORT; 815 816 // 817 // Actual Section Object 818 // 819 typedef struct _SECTION 820 { 821 MMADDRESS_NODE Address; 822 PSEGMENT Segment; 823 LARGE_INTEGER SizeOfSection; 824 union 825 { 826 ULONG LongFlags; 827 MMSECTION_FLAGS Flags; 828 } u; 829 ULONG InitialPageProtection; 830 } SECTION, *PSECTION; 831 832 // 833 // Memory Manager Working Set Structures 834 // 835 typedef struct _MMWSLENTRY 836 { 837 ULONG_PTR Valid:1; 838 ULONG_PTR LockedInWs:1; 839 ULONG_PTR LockedInMemory:1; 840 ULONG_PTR Protection:5; 841 ULONG_PTR Hashed:1; 842 ULONG_PTR Direct:1; 843 ULONG_PTR Age:2; 844 ULONG_PTR VirtualPageNumber: MM_PAGE_FRAME_NUMBER_SIZE; 845 } MMWSLENTRY, *PMMWSLENTRY; 846 847 typedef struct _MMWSLE 848 { 849 union 850 { 851 PVOID VirtualAddress; 852 ULONG_PTR Long; 853 MMWSLENTRY e1; 854 } u1; 855 } MMWSLE, *PMMWSLE; 856 857 typedef struct _MMWSLE_HASH 858 { 859 PVOID Key; 860 ULONG Index; 861 } MMWSLE_HASH, *PMMWSLE_HASH; 862 863 typedef struct _MMWSL 864 { 865 ULONG FirstFree; 866 ULONG FirstDynamic; 867 ULONG LastEntry; 868 ULONG NextSlot; 869 PMMWSLE Wsle; 870 ULONG LastInitializedWsle; 871 ULONG NonDirectCount; 872 PMMWSLE_HASH HashTable; 873 ULONG HashTableSize; 874 ULONG NumberOfCommittedPageTables; 875 PVOID HashTableStart; 876 PVOID HighestPermittedHashAddress; 877 ULONG NumberOfImageWaiters; 878 ULONG VadBitMapHint; 879 USHORT UsedPageTableEntries[768]; 880 ULONG CommittedPageTables[24]; 881 } MMWSL, *PMMWSL; 882 883 // 884 // Flags for Memory Support Structure 885 // 886 typedef struct _MMSUPPORT_FLAGS 887 { 888 ULONG SessionSpace:1; 889 ULONG BeingTrimmed:1; 890 ULONG SessionLeader:1; 891 ULONG TrimHard:1; 892 ULONG MaximumWorkingSetHard:1; 893 ULONG ForceTrim:1; 894 ULONG MinimumWorkingSetHard:1; 895 ULONG Available0:1; 896 ULONG MemoryPriority:8; 897 ULONG GrowWsleHash:1; 898 ULONG AcquiredUnsafe:1; 899 ULONG Available:14; 900 } MMSUPPORT_FLAGS, *PMMSUPPORT_FLAGS; 901 902 // 903 // Per-Process Memory Manager Data 904 // 905 typedef struct _MMSUPPORT 906 { 907 #if (NTDDI_VERSION >= NTDDI_WS03) 908 LIST_ENTRY WorkingSetExpansionLinks; 909 #endif 910 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 911 USHORT LastTrimpStamp; 912 USHORT NextPageColor; 913 #else 914 LARGE_INTEGER LastTrimTime; 915 #endif 916 MMSUPPORT_FLAGS Flags; 917 ULONG PageFaultCount; 918 ULONG PeakWorkingSetSize; 919 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 920 ULONG Spare0; 921 #else 922 ULONG GrowthSinceLastEstimate; 923 #endif 924 ULONG MinimumWorkingSetSize; 925 ULONG MaximumWorkingSetSize; 926 PMMWSL VmWorkingSetList; 927 #if (NTDDI_VERSION < NTDDI_WS03) 928 LIST_ENTRY WorkingSetExpansionLinks; 929 #endif 930 ULONG Claim; 931 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 932 ULONG Spare; 933 ULONG WorkingSetPrivateSize; 934 ULONG WorkingSetSizeOverhead; 935 #else 936 ULONG NextEstimationSlot; 937 ULONG NextAgingSlot; 938 ULONG EstimatedAvailable; 939 #endif 940 ULONG WorkingSetSize; 941 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 942 PKEVENT ExitEvent; 943 #endif 944 EX_PUSH_LOCK WorkingSetMutex; 945 #if (NTDDI_VERSION >= NTDDI_LONGHORN) 946 PVOID AccessLog; 947 #endif 948 } MMSUPPORT, *PMMSUPPORT; 949 950 // 951 // Memory Information Types 952 // 953 typedef struct _MEMORY_BASIC_INFORMATION 954 { 955 PVOID BaseAddress; 956 PVOID AllocationBase; 957 ULONG AllocationProtect; 958 SIZE_T RegionSize; 959 ULONG State; 960 ULONG Protect; 961 ULONG Type; 962 } MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION; 963 964 // 965 // Driver Verifier Data 966 // 967 typedef struct _MM_DRIVER_VERIFIER_DATA 968 { 969 ULONG Level; 970 ULONG RaiseIrqls; 971 ULONG AcquireSpinLocks; 972 ULONG SynchronizeExecutions; 973 ULONG AllocationsAttempted; 974 ULONG AllocationsSucceeded; 975 ULONG AllocationsSucceededSpecialPool; 976 ULONG AllocationsWithNoTag; 977 ULONG TrimRequests; 978 ULONG Trims; 979 ULONG AllocationsFailed; 980 ULONG AllocationsFailedDeliberately; 981 ULONG Loads; 982 ULONG Unloads; 983 ULONG UnTrackedPool; 984 ULONG UserTrims; 985 ULONG CurrentPagedPoolAllocations; 986 ULONG CurrentNonPagedPoolAllocations; 987 ULONG PeakPagedPoolAllocations; 988 ULONG PeakNonPagedPoolAllocations; 989 ULONG PagedBytes; 990 ULONG NonPagedBytes; 991 ULONG PeakPagedBytes; 992 ULONG PeakNonPagedBytes; 993 ULONG BurstAllocationsFailedDeliberately; 994 ULONG SessionTrims; 995 ULONG Reserved[2]; 996 } MM_DRIVER_VERIFIER_DATA, *PMM_DRIVER_VERIFIER_DATA; 997 998 // 999 // Internal Driver Verifier Table Data 1000 // 1001 typedef struct _DRIVER_SPECIFIED_VERIFIER_THUNKS 1002 { 1003 LIST_ENTRY ListEntry; 1004 struct _LDR_DATA_TABLE_ENTRY *DataTableEntry; 1005 ULONG NumberOfThunks; 1006 } DRIVER_SPECIFIED_VERIFIER_THUNKS, *PDRIVER_SPECIFIED_VERIFIER_THUNKS; 1007 1008 #ifdef __cplusplus 1009 extern "C" { 1010 #endif 1011 1012 // 1013 // Default heap size values. For user mode, these values are copied to a new 1014 // process's PEB by the kernel in MmCreatePeb. In kernel mode, RtlCreateHeap 1015 // reads these variables directly. 1016 // 1017 // These variables should be considered "const"; they are written only once, 1018 // during MmInitSystem. 1019 // 1020 extern SIZE_T MmHeapSegmentReserve; 1021 extern SIZE_T MmHeapSegmentCommit; 1022 extern SIZE_T MmHeapDeCommitTotalFreeThreshold; 1023 extern SIZE_T MmHeapDeCommitFreeBlockThreshold; 1024 1025 // 1026 // Section Object Type 1027 // 1028 extern POBJECT_TYPE NTSYSAPI MmSectionObjectType; 1029 1030 #ifdef __cplusplus 1031 }; // extern "C" 1032 #endif 1033 1034 #endif // !NTOS_MODE_USER 1035 1036 #ifdef __cplusplus 1037 } // extern "C" 1038 #endif 1039 1040 #endif // _MMTYPES_H 1041