bb545ad14e4ef6ff4a13e6c964348230cf4429aa
[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 Balance:2;
611 struct _MMADDRESS_NODE *Parent;
612 } u1;
613 struct _MMADDRESS_NODE *LeftChild;
614 struct _MMADDRESS_NODE *RightChild;
615 ULONG StartingVpn;
616 ULONG 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 DepthOfTree:5;
626 ULONG Unused:3;
627 ULONG NumberGenericTableElements:24;
628 PVOID NodeHint;
629 PVOID NodeFreeHint;
630 } MM_AVL_TABLE, *PMM_AVL_TABLE;
631
632 //
633 // Virtual Adress List used in VADs
634 //
635 typedef struct _MMADDRESS_LIST
636 {
637 ULONG StartVpn;
638 ULONG EndVpn;
639 } MMADDRESS_LIST, *PMMADDRESS_LIST;
640
641 //
642 // Flags used in the VAD
643 //
644 typedef struct _MMVAD_FLAGS
645 {
646 ULONG CommitCharge:19;
647 ULONG NoChange:1;
648 ULONG VadType:3;
649 ULONG MemCommit:1;
650 ULONG Protection:5;
651 ULONG Spare:2;
652 ULONG PrivateMemory:1;
653 } MMVAD_FLAGS, *PMMVAD_FLAGS;
654
655 //
656 // Extended flags used in the VAD
657 //
658 typedef struct _MMVAD_FLAGS2
659 {
660 ULONG FileOffset:24;
661 ULONG SecNoChange:1;
662 ULONG OneSecured:1;
663 ULONG MultipleSecured:1;
664 ULONG ReadOnly:1;
665 ULONG LongVad:1;
666 ULONG ExtendableFile:1;
667 ULONG Inherit:1;
668 ULONG CopyOnWrite:1;
669 } MMVAD_FLAGS2, *PMMVAD_FLAGS2;
670
671 //
672 // Virtual Address Descriptor (VAD) Structure
673 //
674 typedef struct _MMVAD
675 {
676 union
677 {
678 LONG_PTR Balance:2;
679 struct _MMVAD *Parent;
680 } u1;
681 struct _MMVAD *LeftChild;
682 struct _MMVAD *RightChild;
683 ULONG StartingVpn;
684 ULONG EndingVpn;
685 union
686 {
687 ULONG LongFlags;
688 MMVAD_FLAGS VadFlags;
689 } u;
690 PCONTROL_AREA ControlArea;
691 PMMPTE FirstPrototypePte;
692 PMMPTE LastContiguousPte;
693 union
694 {
695 ULONG LongFlags2;
696 MMVAD_FLAGS2 VadFlags2;
697 } u2;
698 } MMVAD, *PMMVAD;
699
700 //
701 // Long VAD used in section and private allocations
702 //
703 typedef struct _MMVAD_LONG
704 {
705 union
706 {
707 LONG_PTR Balance:2;
708 PMMVAD Parent;
709 } u1;
710 PMMVAD LeftChild;
711 PMMVAD RightChild;
712 ULONG StartingVpn;
713 ULONG EndingVpn;
714 union
715 {
716 ULONG LongFlags;
717 MMVAD_FLAGS VadFlags;
718 } u;
719 PCONTROL_AREA ControlArea;
720 PMMPTE FirstPrototypePte;
721 PMMPTE LastContiguousPte;
722 union
723 {
724 ULONG LongFlags2;
725 MMVAD_FLAGS2 VadFlags2;
726 } u2;
727 union
728 {
729 LIST_ENTRY List;
730 MMADDRESS_LIST Secured;
731 } u3;
732 union
733 {
734 PVOID Banked;
735 PMMEXTEND_INFO ExtendedInfo;
736 } u4;
737 } MMVAD_LONG, *PMMVAD_LONG;
738
739 //
740 // Actual Section Object
741 //
742 typedef struct _SECTION
743 {
744 MMADDRESS_NODE Address;
745 PSEGMENT Segment;
746 LARGE_INTEGER SizeOfSection;
747 union
748 {
749 ULONG LongFlags;
750 MMSECTION_FLAGS Flags;
751 } u;
752 ULONG InitialPageProtection;
753 } SECTION, *PSECTION;
754
755 //
756 // Memory Manager Working Set Structures
757 //
758 typedef struct _MMWSLENTRY
759 {
760 ULONG Valid:1;
761 ULONG LockedInWs:1;
762 ULONG LockedInMemory:1;
763 ULONG Protection:5;
764 ULONG Hashed:1;
765 ULONG Direct:1;
766 ULONG Age:2;
767 ULONG VirtualPageNumber:20;
768 } MMWSLENTRY, *PMMWSLENTRY;
769
770 typedef struct _MMWSLE
771 {
772 union
773 {
774 PVOID VirtualAddress;
775 ULONG Long;
776 MMWSLENTRY e1;
777 } u1;
778 } MMWSLE, *PMMWSLE;
779
780 typedef struct _MMWSLE_HASH
781 {
782 PVOID Key;
783 ULONG Index;
784 } MMWSLE_HASH, *PMMWSLE_HASH;
785
786 typedef struct _MMWSL
787 {
788 ULONG FirstFree;
789 ULONG FirstDynamic;
790 ULONG LastEntry;
791 ULONG NextSlot;
792 PMMWSLE Wsle;
793 ULONG LastInitializedWsle;
794 ULONG NonDirectCount;
795 PMMWSLE_HASH HashTable;
796 ULONG HashTableSize;
797 ULONG NumberOfCommittedPageTables;
798 PVOID HashTableStart;
799 PVOID HighestPermittedHashAddress;
800 ULONG NumberOfImageWaiters;
801 ULONG VadBitMapHint;
802 USHORT UsedPageTableEntries[768];
803 ULONG CommittedPageTables[24];
804 } MMWSL, *PMMWSL;
805
806 //
807 // Flags for Memory Support Structure
808 //
809 typedef struct _MMSUPPORT_FLAGS
810 {
811 ULONG SessionSpace:1;
812 ULONG BeingTrimmed:1;
813 ULONG SessionLeader:1;
814 ULONG TrimHard:1;
815 ULONG MaximumWorkingSetHard:1;
816 ULONG ForceTrim:1;
817 ULONG MinimumWorkingSetHard:1;
818 ULONG Available0:1;
819 ULONG MemoryPriority:8;
820 ULONG GrowWsleHash:1;
821 ULONG AcquiredUnsafe:1;
822 ULONG Available:14;
823 } MMSUPPORT_FLAGS, *PMMSUPPORT_FLAGS;
824
825 //
826 // Per-Process Memory Manager Data
827 //
828 typedef struct _MMSUPPORT
829 {
830 #if (NTDDI_VERSION >= NTDDI_WS03)
831 LIST_ENTRY WorkingSetExpansionLinks;
832 #endif
833 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
834 USHORT LastTrimpStamp;
835 USHORT NextPageColor;
836 #else
837 LARGE_INTEGER LastTrimTime;
838 #endif
839 MMSUPPORT_FLAGS Flags;
840 ULONG PageFaultCount;
841 ULONG PeakWorkingSetSize;
842 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
843 ULONG Spare0;
844 #else
845 ULONG GrowthSinceLastEstimate;
846 #endif
847 ULONG MinimumWorkingSetSize;
848 ULONG MaximumWorkingSetSize;
849 PMMWSL VmWorkingSetList;
850 #if (NTDDI_VERSION < NTDDI_WS03)
851 LIST_ENTRY WorkingSetExpansionLinks;
852 #endif
853 ULONG Claim;
854 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
855 ULONG Spare;
856 ULONG WorkingSetPrivateSize;
857 ULONG WorkingSetSizeOverhead;
858 #else
859 ULONG NextEstimationSlot;
860 ULONG NextAgingSlot;
861 ULONG EstimatedAvailable;
862 #endif
863 ULONG WorkingSetSize;
864 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
865 PKEVENT ExitEvent;
866 #endif
867 EX_PUSH_LOCK WorkingSetMutex;
868 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
869 PVOID AccessLog;
870 #endif
871 } MMSUPPORT, *PMMSUPPORT;
872
873 //
874 // Memory Information Types
875 //
876 typedef struct _MEMORY_BASIC_INFORMATION
877 {
878 PVOID BaseAddress;
879 PVOID AllocationBase;
880 ULONG AllocationProtect;
881 SIZE_T RegionSize;
882 ULONG State;
883 ULONG Protect;
884 ULONG Type;
885 } MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
886
887 //
888 // Driver Verifier Data
889 //
890 typedef struct _MM_DRIVER_VERIFIER_DATA
891 {
892 ULONG Level;
893 ULONG RaiseIrqls;
894 ULONG AcquireSpinLocks;
895 ULONG SynchronizeExecutions;
896 ULONG AllocationsAttempted;
897 ULONG AllocationsSucceeded;
898 ULONG AllocationsSucceededSpecialPool;
899 ULONG AllocationsWithNoTag;
900 ULONG TrimRequests;
901 ULONG Trims;
902 ULONG AllocationsFailed;
903 ULONG AllocationsFailedDeliberately;
904 ULONG Loads;
905 ULONG Unloads;
906 ULONG UnTrackedPool;
907 ULONG UserTrims;
908 ULONG CurrentPagedPoolAllocations;
909 ULONG CurrentNonPagedPoolAllocations;
910 ULONG PeakPagedPoolAllocations;
911 ULONG PeakNonPagedPoolAllocations;
912 ULONG PagedBytes;
913 ULONG NonPagedBytes;
914 ULONG PeakPagedBytes;
915 ULONG PeakNonPagedBytes;
916 ULONG BurstAllocationsFailedDeliberately;
917 ULONG SessionTrims;
918 ULONG Reserved[2];
919 } MM_DRIVER_VERIFIER_DATA, *PMM_DRIVER_VERIFIER_DATA;
920
921 //
922 // Internal Driver Verifier Table Data
923 //
924 typedef struct _DRIVER_SPECIFIED_VERIFIER_THUNKS
925 {
926 LIST_ENTRY ListEntry;
927 struct _LDR_DATA_TABLE_ENTRY *DataTableEntry;
928 ULONG NumberOfThunks;
929 } DRIVER_SPECIFIED_VERIFIER_THUNKS, *PDRIVER_SPECIFIED_VERIFIER_THUNKS;
930
931 //
932 // Default heap size values. For user mode, these values are copied to a new
933 // process's PEB by the kernel in MmCreatePeb. In kernel mode, RtlCreateHeap
934 // reads these variables directly.
935 //
936 // These variables should be considered "const"; they are written only once,
937 // during MmInitSystem.
938 //
939 extern SIZE_T MmHeapSegmentReserve;
940 extern SIZE_T MmHeapSegmentCommit;
941 extern SIZE_T MmHeapDeCommitTotalFreeThreshold;
942 extern SIZE_T MmHeapDeCommitFreeBlockThreshold;
943
944 //
945 // Section Object Type
946 //
947 extern POBJECT_TYPE MmSectionObjectType;
948
949 #endif // !NTOS_MODE_USER
950
951 #endif // _MMTYPES_H