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