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