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