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