[RTL/NDK/NTDLL]
[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 #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 // PTE Structures
381 //
382 typedef struct _MMPTE
383 {
384 union
385 {
386 ULONG_PTR Long;
387 HARDWARE_PTE Flush;
388 MMPTE_HARDWARE Hard;
389 MMPTE_PROTOTYPE Proto;
390 MMPTE_SOFTWARE Soft;
391 MMPTE_TRANSITION Trans;
392 MMPTE_SUBSECTION Subsect;
393 MMPTE_LIST List;
394 } u;
395 } MMPTE, *PMMPTE;
396
397 //
398 // Section Extension Information
399 //
400 typedef struct _MMEXTEND_INFO
401 {
402 ULONGLONG CommittedSize;
403 ULONG ReferenceCount;
404 } MMEXTEND_INFO, *PMMEXTEND_INFO;
405
406 //
407 // Segment and Segment Flags
408 //
409 typedef struct _SEGMENT_FLAGS
410 {
411 ULONG TotalNumberOfPtes4132:10;
412 ULONG ExtraSharedWowSubsections:1;
413 ULONG LargePages:1;
414 ULONG Spare:20;
415 } SEGMENT_FLAGS, *PSEGMENT_FLAGS;
416
417 typedef struct _SEGMENT
418 {
419 struct _CONTROL_AREA *ControlArea;
420 ULONG TotalNumberOfPtes;
421 ULONG NonExtendedPtes;
422 ULONG Spare0;
423 ULONGLONG SizeOfSegment;
424 MMPTE SegmentPteTemplate;
425 ULONG NumberOfCommittedPages;
426 PMMEXTEND_INFO ExtendInfo;
427 SEGMENT_FLAGS SegmentFlags;
428 PVOID BasedAddress;
429 union
430 {
431 SIZE_T ImageCommitment;
432 PEPROCESS CreatingProcess;
433 } u1;
434 union
435 {
436 PSECTION_IMAGE_INFORMATION ImageInformation;
437 PVOID FirstMappedVa;
438 } u2;
439 PMMPTE PrototypePte;
440 MMPTE ThePtes[1];
441 } SEGMENT, *PSEGMENT;
442
443 typedef struct _MAPPED_FILE_SEGMENT
444 {
445 struct _CONTROL_AREA *ControlArea;
446 ULONG TotalNumberOfPtes;
447 ULONG NonExtendedPtes;
448 ULONG Spare0;
449 UINT64 SizeOfSegment;
450 MMPTE SegmentPteTemplate;
451 SIZE_T NumberOfCommittedPages;
452 PMMEXTEND_INFO ExtendInfo;
453 SEGMENT_FLAGS SegmentFlags;
454 PVOID BasedAddress;
455 struct _MSUBSECTION *LastSubsectionHint;
456 } MAPPED_FILE_SEGMENT, *PMAPPED_FILE_SEGMENT;
457
458 //
459 // Event Counter Structure
460 //
461 typedef struct _EVENT_COUNTER
462 {
463 SLIST_ENTRY ListEntry;
464 ULONG RefCount;
465 KEVENT Event;
466 } EVENT_COUNTER, *PEVENT_COUNTER;
467
468 //
469 // Flags
470 //
471 typedef struct _MMSECTION_FLAGS
472 {
473 ULONG BeingDeleted:1;
474 ULONG BeingCreated:1;
475 ULONG BeingPurged:1;
476 ULONG NoModifiedWriting:1;
477 ULONG FailAllIo:1;
478 ULONG Image:1;
479 ULONG Based:1;
480 ULONG File:1;
481 ULONG Networked:1;
482 ULONG NoCache:1;
483 ULONG PhysicalMemory:1;
484 ULONG CopyOnWrite:1;
485 ULONG Reserve:1;
486 ULONG Commit:1;
487 ULONG FloppyMedia:1;
488 ULONG WasPurged:1;
489 ULONG UserReference:1;
490 ULONG GlobalMemory:1;
491 ULONG DeleteOnClose:1;
492 ULONG FilePointerNull:1;
493 ULONG DebugSymbolsLoaded:1;
494 ULONG SetMappedFileIoComplete:1;
495 ULONG CollidedFlush:1;
496 ULONG NoChange:1;
497 ULONG filler0:1;
498 ULONG ImageMappedInSystemSpace:1;
499 ULONG UserWritable:1;
500 ULONG Accessed:1;
501 ULONG GlobalOnlyPerSession:1;
502 ULONG Rom:1;
503 ULONG WriteCombined:1;
504 ULONG filler:1;
505 } MMSECTION_FLAGS, *PMMSECTION_FLAGS;
506
507 typedef struct _MMSUBSECTION_FLAGS
508 {
509 ULONG ReadOnly:1;
510 ULONG ReadWrite:1;
511 ULONG SubsectionStatic:1;
512 ULONG GlobalMemory:1;
513 ULONG Protection:5;
514 ULONG Spare:1;
515 ULONG StartingSector4132:10;
516 ULONG SectorEndOffset:12;
517 } MMSUBSECTION_FLAGS, *PMMSUBSECTION_FLAGS;
518
519 typedef struct _MMSUBSECTION_FLAGS2
520 {
521 ULONG SubsectionAccessed:1;
522 ULONG SubsectionConverted:1;
523 ULONG Reserved:30;
524 } MMSUBSECTION_FLAGS2;
525
526 //
527 // Control Area Structures
528 //
529 typedef struct _CONTROL_AREA
530 {
531 PSEGMENT Segment;
532 LIST_ENTRY DereferenceList;
533 ULONG NumberOfSectionReferences;
534 ULONG NumberOfPfnReferences;
535 ULONG NumberOfMappedViews;
536 ULONG NumberOfSystemCacheViews;
537 ULONG NumberOfUserReferences;
538 union
539 {
540 ULONG LongFlags;
541 MMSECTION_FLAGS Flags;
542 } u;
543 PFILE_OBJECT FilePointer;
544 PEVENT_COUNTER WaitingForDeletion;
545 USHORT ModifiedWriteCount;
546 USHORT FlushInProgressCount;
547 ULONG WritableUserReferences;
548 ULONG QuadwordPad;
549 } CONTROL_AREA, *PCONTROL_AREA;
550
551 typedef struct _LARGE_CONTROL_AREA
552 {
553 PSEGMENT Segment;
554 LIST_ENTRY DereferenceList;
555 ULONG NumberOfSectionReferences;
556 ULONG NumberOfPfnReferences;
557 ULONG NumberOfMappedViews;
558 ULONG NumberOfSystemCacheViews;
559 ULONG NumberOfUserReferences;
560 union
561 {
562 ULONG LongFlags;
563 MMSECTION_FLAGS Flags;
564 } u;
565 PFILE_OBJECT FilePointer;
566 PEVENT_COUNTER WaitingForDeletion;
567 USHORT ModifiedWriteCount;
568 USHORT FlushInProgressCount;
569 ULONG WritableUserReferences;
570 ULONG QuadwordPad;
571 ULONG StartingFrame;
572 LIST_ENTRY UserGlobalList;
573 ULONG SessionId;
574 } LARGE_CONTROL_AREA, *PLARGE_CONTROL_AREA;
575
576 //
577 // Subsection and Mapped Subsection
578 //
579 typedef struct _SUBSECTION
580 {
581 PCONTROL_AREA ControlArea;
582 union
583 {
584 ULONG LongFlags;
585 MMSUBSECTION_FLAGS SubsectionFlags;
586 } u;
587 ULONG StartingSector;
588 ULONG NumberOfFullSectors;
589 PMMPTE SubsectionBase;
590 ULONG UnusedPtes;
591 ULONG PtesInSubsection;
592 struct _SUBSECTION *NextSubsection;
593 } SUBSECTION, *PSUBSECTION;
594
595 typedef struct _MSUBSECTION
596 {
597 PCONTROL_AREA ControlArea;
598 union
599 {
600 ULONG LongFlags;
601 MMSUBSECTION_FLAGS SubsectionFlags;
602 } u;
603 ULONG StartingSector;
604 ULONG NumberOfFullSectors;
605 PMMPTE SubsectionBase;
606 ULONG UnusedPtes;
607 ULONG PtesInSubsection;
608 struct _SUBSECTION *NextSubsection;
609 LIST_ENTRY DereferenceList;
610 ULONG_PTR NumberOfMappedViews;
611 union
612 {
613 ULONG LongFlags2;
614 MMSUBSECTION_FLAGS2 SubsectionFlags2;
615 } u2;
616 } MSUBSECTION, *PMSUBSECTION;
617
618 //
619 // Segment Object
620 //
621 typedef struct _SEGMENT_OBJECT
622 {
623 PVOID BaseAddress;
624 ULONG TotalNumberOfPtes;
625 LARGE_INTEGER SizeOfSegment;
626 ULONG NonExtendedPtes;
627 ULONG ImageCommitment;
628 PCONTROL_AREA ControlArea;
629 PSUBSECTION Subsection;
630 PLARGE_CONTROL_AREA LargeControlArea;
631 PMMSECTION_FLAGS MmSectionFlags;
632 PMMSUBSECTION_FLAGS MmSubSectionFlags;
633 } SEGMENT_OBJECT, *PSEGMENT_OBJECT;
634
635 //
636 // Section Object
637 //
638 typedef struct _SECTION_OBJECT
639 {
640 PVOID StartingVa;
641 PVOID EndingVa;
642 PVOID LeftChild;
643 PVOID RightChild;
644 PSEGMENT_OBJECT Segment;
645 } SECTION_OBJECT, *PSECTION_OBJECT;
646
647 //
648 // Generic Address Range Structure
649 //
650 typedef struct _ADDRESS_RANGE
651 {
652 ULONG BaseAddrLow;
653 ULONG BaseAddrHigh;
654 ULONG LengthLow;
655 ULONG LengthHigh;
656 ULONG Type;
657 } ADDRESS_RANGE, *PADDRESS_RANGE;
658
659 //
660 // Node in Memory Manager's AVL Table
661 //
662 typedef struct _MMADDRESS_NODE
663 {
664 union
665 {
666 LONG_PTR Balance:2;
667 struct _MMADDRESS_NODE *Parent;
668 } u1;
669 struct _MMADDRESS_NODE *LeftChild;
670 struct _MMADDRESS_NODE *RightChild;
671 ULONG_PTR StartingVpn;
672 ULONG_PTR EndingVpn;
673 } MMADDRESS_NODE, *PMMADDRESS_NODE;
674
675 //
676 // Memory Manager AVL Table for VADs and other descriptors
677 //
678 typedef struct _MM_AVL_TABLE
679 {
680 MMADDRESS_NODE BalancedRoot;
681 ULONG_PTR DepthOfTree:5;
682 ULONG_PTR Unused:3;
683 #ifdef _WIN64
684 ULONG_PTR NumberGenericTableElements:56;
685 #else
686 ULONG_PTR NumberGenericTableElements:24;
687 #endif
688 PVOID NodeHint;
689 PVOID NodeFreeHint;
690 } MM_AVL_TABLE, *PMM_AVL_TABLE;
691
692 //
693 // Virtual Adress List used in VADs
694 //
695 typedef struct _MMADDRESS_LIST
696 {
697 ULONG_PTR StartVpn;
698 ULONG_PTR EndVpn;
699 } MMADDRESS_LIST, *PMMADDRESS_LIST;
700
701 //
702 // Flags used in the VAD
703 //
704 typedef struct _MMVAD_FLAGS
705 {
706 #ifdef _WIN64
707 ULONG_PTR CommitCharge:51;
708 #else
709 ULONG_PTR CommitCharge:19;
710 #endif
711 ULONG_PTR NoChange:1;
712 ULONG_PTR VadType:3;
713 ULONG_PTR MemCommit:1;
714 ULONG_PTR Protection:5;
715 ULONG_PTR Spare:2;
716 ULONG_PTR PrivateMemory:1;
717 } MMVAD_FLAGS, *PMMVAD_FLAGS;
718
719 //
720 // Extended flags used in the VAD
721 //
722 typedef struct _MMVAD_FLAGS2
723 {
724 ULONG FileOffset:24;
725 ULONG SecNoChange:1;
726 ULONG OneSecured:1;
727 ULONG MultipleSecured:1;
728 ULONG ReadOnly:1;
729 ULONG LongVad:1;
730 ULONG ExtendableFile:1;
731 ULONG Inherit:1;
732 ULONG CopyOnWrite:1;
733 } MMVAD_FLAGS2, *PMMVAD_FLAGS2;
734
735 //
736 // Virtual Address Descriptor (VAD) Structure
737 //
738 typedef struct _MMVAD
739 {
740 union
741 {
742 LONG_PTR Balance:2;
743 struct _MMVAD *Parent;
744 } u1;
745 struct _MMVAD *LeftChild;
746 struct _MMVAD *RightChild;
747 ULONG_PTR StartingVpn;
748 ULONG_PTR EndingVpn;
749 union
750 {
751 ULONG_PTR LongFlags;
752 MMVAD_FLAGS VadFlags;
753 } u;
754 PCONTROL_AREA ControlArea;
755 PMMPTE FirstPrototypePte;
756 PMMPTE LastContiguousPte;
757 union
758 {
759 ULONG LongFlags2;
760 MMVAD_FLAGS2 VadFlags2;
761 } u2;
762 } MMVAD, *PMMVAD;
763
764 //
765 // Long VAD used in section and private allocations
766 //
767 typedef struct _MMVAD_LONG
768 {
769 union
770 {
771 LONG_PTR Balance:2;
772 PMMVAD Parent;
773 } u1;
774 PMMVAD LeftChild;
775 PMMVAD RightChild;
776 ULONG_PTR StartingVpn;
777 ULONG_PTR EndingVpn;
778 union
779 {
780 ULONG_PTR LongFlags;
781 MMVAD_FLAGS VadFlags;
782 } u;
783 PCONTROL_AREA ControlArea;
784 PMMPTE FirstPrototypePte;
785 PMMPTE LastContiguousPte;
786 union
787 {
788 ULONG LongFlags2;
789 MMVAD_FLAGS2 VadFlags2;
790 } u2;
791 union
792 {
793 LIST_ENTRY List;
794 MMADDRESS_LIST Secured;
795 } u3;
796 union
797 {
798 PVOID Banked;
799 PMMEXTEND_INFO ExtendedInfo;
800 } u4;
801 } MMVAD_LONG, *PMMVAD_LONG;
802
803 //
804 // Short VAD used in virtual memory allocations
805 //
806 typedef struct _MMVAD_SHORT
807 {
808 union
809 {
810 LONG_PTR Balance:2;
811 PMMVAD Parent;
812 } u1;
813 PMMVAD LeftChild;
814 PMMVAD RightChild;
815 ULONG_PTR StartingVpn;
816 ULONG_PTR EndingVpn;
817 union
818 {
819 ULONG_PTR LongFlags;
820 MMVAD_FLAGS VadFlags;
821 } u;
822 } MMVAD_SHORT, *PMMVAD_SHORT;
823
824 //
825 // Actual Section Object
826 //
827 typedef struct _SECTION
828 {
829 MMADDRESS_NODE Address;
830 PSEGMENT Segment;
831 LARGE_INTEGER SizeOfSection;
832 union
833 {
834 ULONG LongFlags;
835 MMSECTION_FLAGS Flags;
836 } u;
837 ULONG InitialPageProtection;
838 } SECTION, *PSECTION;
839
840 //
841 // Memory Manager Working Set Structures
842 //
843 typedef struct _MMWSLENTRY
844 {
845 ULONG Valid:1;
846 ULONG LockedInWs:1;
847 ULONG LockedInMemory:1;
848 ULONG Protection:5;
849 ULONG Hashed:1;
850 ULONG Direct:1;
851 ULONG Age:2;
852 ULONG VirtualPageNumber:20;
853 } MMWSLENTRY, *PMMWSLENTRY;
854
855 typedef struct _MMWSLE
856 {
857 union
858 {
859 PVOID VirtualAddress;
860 ULONG Long;
861 MMWSLENTRY e1;
862 } u1;
863 } MMWSLE, *PMMWSLE;
864
865 typedef struct _MMWSLE_HASH
866 {
867 PVOID Key;
868 ULONG Index;
869 } MMWSLE_HASH, *PMMWSLE_HASH;
870
871 typedef struct _MMWSL
872 {
873 ULONG FirstFree;
874 ULONG FirstDynamic;
875 ULONG LastEntry;
876 ULONG NextSlot;
877 PMMWSLE Wsle;
878 ULONG LastInitializedWsle;
879 ULONG NonDirectCount;
880 PMMWSLE_HASH HashTable;
881 ULONG HashTableSize;
882 ULONG NumberOfCommittedPageTables;
883 PVOID HashTableStart;
884 PVOID HighestPermittedHashAddress;
885 ULONG NumberOfImageWaiters;
886 ULONG VadBitMapHint;
887 USHORT UsedPageTableEntries[768];
888 ULONG CommittedPageTables[24];
889 } MMWSL, *PMMWSL;
890
891 //
892 // Flags for Memory Support Structure
893 //
894 typedef struct _MMSUPPORT_FLAGS
895 {
896 ULONG SessionSpace:1;
897 ULONG BeingTrimmed:1;
898 ULONG SessionLeader:1;
899 ULONG TrimHard:1;
900 ULONG MaximumWorkingSetHard:1;
901 ULONG ForceTrim:1;
902 ULONG MinimumWorkingSetHard:1;
903 ULONG Available0:1;
904 ULONG MemoryPriority:8;
905 ULONG GrowWsleHash:1;
906 ULONG AcquiredUnsafe:1;
907 ULONG Available:14;
908 } MMSUPPORT_FLAGS, *PMMSUPPORT_FLAGS;
909
910 //
911 // Per-Process Memory Manager Data
912 //
913 typedef struct _MMSUPPORT
914 {
915 #if (NTDDI_VERSION >= NTDDI_WS03)
916 LIST_ENTRY WorkingSetExpansionLinks;
917 #endif
918 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
919 USHORT LastTrimpStamp;
920 USHORT NextPageColor;
921 #else
922 LARGE_INTEGER LastTrimTime;
923 #endif
924 MMSUPPORT_FLAGS Flags;
925 ULONG PageFaultCount;
926 ULONG PeakWorkingSetSize;
927 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
928 ULONG Spare0;
929 #else
930 ULONG GrowthSinceLastEstimate;
931 #endif
932 ULONG MinimumWorkingSetSize;
933 ULONG MaximumWorkingSetSize;
934 PMMWSL VmWorkingSetList;
935 #if (NTDDI_VERSION < NTDDI_WS03)
936 LIST_ENTRY WorkingSetExpansionLinks;
937 #endif
938 ULONG Claim;
939 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
940 ULONG Spare;
941 ULONG WorkingSetPrivateSize;
942 ULONG WorkingSetSizeOverhead;
943 #else
944 ULONG NextEstimationSlot;
945 ULONG NextAgingSlot;
946 ULONG EstimatedAvailable;
947 #endif
948 ULONG WorkingSetSize;
949 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
950 PKEVENT ExitEvent;
951 #endif
952 EX_PUSH_LOCK WorkingSetMutex;
953 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
954 PVOID AccessLog;
955 #endif
956 } MMSUPPORT, *PMMSUPPORT;
957
958 //
959 // Memory Information Types
960 //
961 typedef struct _MEMORY_BASIC_INFORMATION
962 {
963 PVOID BaseAddress;
964 PVOID AllocationBase;
965 ULONG AllocationProtect;
966 SIZE_T RegionSize;
967 ULONG State;
968 ULONG Protect;
969 ULONG Type;
970 } MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
971
972 //
973 // Driver Verifier Data
974 //
975 typedef struct _MM_DRIVER_VERIFIER_DATA
976 {
977 ULONG Level;
978 ULONG RaiseIrqls;
979 ULONG AcquireSpinLocks;
980 ULONG SynchronizeExecutions;
981 ULONG AllocationsAttempted;
982 ULONG AllocationsSucceeded;
983 ULONG AllocationsSucceededSpecialPool;
984 ULONG AllocationsWithNoTag;
985 ULONG TrimRequests;
986 ULONG Trims;
987 ULONG AllocationsFailed;
988 ULONG AllocationsFailedDeliberately;
989 ULONG Loads;
990 ULONG Unloads;
991 ULONG UnTrackedPool;
992 ULONG UserTrims;
993 ULONG CurrentPagedPoolAllocations;
994 ULONG CurrentNonPagedPoolAllocations;
995 ULONG PeakPagedPoolAllocations;
996 ULONG PeakNonPagedPoolAllocations;
997 ULONG PagedBytes;
998 ULONG NonPagedBytes;
999 ULONG PeakPagedBytes;
1000 ULONG PeakNonPagedBytes;
1001 ULONG BurstAllocationsFailedDeliberately;
1002 ULONG SessionTrims;
1003 ULONG Reserved[2];
1004 } MM_DRIVER_VERIFIER_DATA, *PMM_DRIVER_VERIFIER_DATA;
1005
1006 //
1007 // Internal Driver Verifier Table Data
1008 //
1009 typedef struct _DRIVER_SPECIFIED_VERIFIER_THUNKS
1010 {
1011 LIST_ENTRY ListEntry;
1012 struct _LDR_DATA_TABLE_ENTRY *DataTableEntry;
1013 ULONG NumberOfThunks;
1014 } DRIVER_SPECIFIED_VERIFIER_THUNKS, *PDRIVER_SPECIFIED_VERIFIER_THUNKS;
1015
1016 #ifdef __cplusplus
1017 extern "C" {
1018 #endif
1019
1020 //
1021 // Default heap size values. For user mode, these values are copied to a new
1022 // process's PEB by the kernel in MmCreatePeb. In kernel mode, RtlCreateHeap
1023 // reads these variables directly.
1024 //
1025 // These variables should be considered "const"; they are written only once,
1026 // during MmInitSystem.
1027 //
1028 extern SIZE_T MmHeapSegmentReserve;
1029 extern SIZE_T MmHeapSegmentCommit;
1030 extern SIZE_T MmHeapDeCommitTotalFreeThreshold;
1031 extern SIZE_T MmHeapDeCommitFreeBlockThreshold;
1032
1033 //
1034 // Section Object Type
1035 //
1036 extern POBJECT_TYPE NTSYSAPI MmSectionObjectType;
1037
1038 #ifdef __cplusplus
1039 }; // extern "C"
1040 #endif
1041
1042 #endif // !NTOS_MODE_USER
1043
1044 #ifdef __cplusplus
1045 } // extern "C"
1046 #endif
1047
1048 #endif // _MMTYPES_H