3 Copyright (c) Alex Ionescu. All rights reserved.
11 Type definitions for the Memory Manager
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
26 #include <arch/mmtypes.h>
29 // Page-Rounding Macros
31 #define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~(PAGE_SIZE-1)))
32 #define PAGE_ROUND_UP(x) \
33 ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) )
36 // Macro for generating pool tags
38 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
43 // Section Flags for NtCreateSection
45 #define SEC_BASED 0x00200000
46 #define SEC_NO_CHANGE 0x00400000
49 // Section Inherit Flags for NtCreateSection
51 typedef enum _SECTION_INHERIT
60 typedef enum _POOL_TYPE
64 NonPagedPoolMustSucceed
,
66 NonPagedPoolCacheAligned
,
67 PagedPoolCacheAligned
,
68 NonPagedPoolCacheAlignedMustS
,
70 NonPagedPoolSession
= 32,
72 NonPagedPoolMustSucceedSession
,
73 DontUseThisTypeSession
,
74 NonPagedPoolCacheAlignedSession
,
75 PagedPoolCacheAlignedSession
,
76 NonPagedPoolCacheAlignedMustSSession
81 // Per Processor Non Paged Lookaside List IDs
83 typedef enum _PP_NPAGED_LOOKASIDE_NUMBER
85 LookasideSmallIrpList
= 0,
86 LookasideLargeIrpList
= 1,
88 LookasideCreateInfoList
= 3,
89 LookasideNameBufferList
= 4,
90 LookasideTwilightList
= 5,
91 LookasideCompletionList
= 6,
92 LookasideMaximumList
= 7
93 } PP_NPAGED_LOOKASIDE_NUMBER
;
96 // Memory Information Classes for NtQueryVirtualMemory
98 typedef enum _MEMORY_INFORMATION_CLASS
100 MemoryBasicInformation
,
101 MemoryWorkingSetList
,
103 MemoryBasicVlmInformation
104 } MEMORY_INFORMATION_CLASS
;
107 // Section Information Clasess for NtQuerySection
109 typedef enum _SECTION_INFORMATION_CLASS
111 SectionBasicInformation
,
112 SectionImageInformation
,
113 } SECTION_INFORMATION_CLASS
;
115 #ifdef NTOS_MODE_USER
118 // Virtual Memory Counters
120 typedef struct _VM_COUNTERS
122 SIZE_T PeakVirtualSize
;
124 ULONG PageFaultCount
;
125 SIZE_T PeakWorkingSetSize
;
126 SIZE_T WorkingSetSize
;
127 SIZE_T QuotaPeakPagedPoolUsage
;
128 SIZE_T QuotaPagedPoolUsage
;
129 SIZE_T QuotaPeakNonPagedPoolUsage
;
130 SIZE_T QuotaNonPagedPoolUsage
;
131 SIZE_T PagefileUsage
;
132 SIZE_T PeakPagefileUsage
;
133 } VM_COUNTERS
, *PVM_COUNTERS
;
135 typedef struct _VM_COUNTERS_EX
137 SIZE_T PeakVirtualSize
;
139 ULONG PageFaultCount
;
140 SIZE_T PeakWorkingSetSize
;
141 SIZE_T WorkingSetSize
;
142 SIZE_T QuotaPeakPagedPoolUsage
;
143 SIZE_T QuotaPagedPoolUsage
;
144 SIZE_T QuotaPeakNonPagedPoolUsage
;
145 SIZE_T QuotaNonPagedPoolUsage
;
146 SIZE_T PagefileUsage
;
147 SIZE_T PeakPagefileUsage
;
149 } VM_COUNTERS_EX
, *PVM_COUNTERS_EX
;
153 // List of Working Sets
155 typedef struct _MEMORY_WORKING_SET_LIST
158 ULONG WorkingSetList
[1];
159 } MEMORY_WORKING_SET_LIST
, *PMEMORY_WORKING_SET_LIST
;
162 // Memory Information Structures for NtQueryVirtualMemory
166 UNICODE_STRING SectionFileName
;
167 WCHAR NameBuffer
[ANYSIZE_ARRAY
];
168 } MEMORY_SECTION_NAME
, *PMEMORY_SECTION_NAME
;
171 // Section Information Structures for NtQuerySection
173 typedef struct _SECTION_BASIC_INFORMATION
178 } SECTION_BASIC_INFORMATION
, *PSECTION_BASIC_INFORMATION
;
180 typedef struct _SECTION_IMAGE_INFORMATION
182 PVOID TransferAddress
;
184 ULONG MaximumStackSize
;
185 ULONG CommittedStackSize
;
187 USHORT SubSystemMinorVersion
;
188 USHORT SubSystemMajorVersion
;
190 USHORT ImageCharacteristics
;
191 USHORT DllChracteristics
;
193 UCHAR ImageContainsCode
;
198 } SECTION_IMAGE_INFORMATION
, *PSECTION_IMAGE_INFORMATION
;
200 #ifndef NTOS_MODE_USER
203 // FIXME: REACTOS SPECIFIC HACK IN EPROCESS
205 typedef struct _MADDRESS_SPACE
207 struct _MEMORY_AREA
*MemoryAreaRoot
;
210 struct _EPROCESS
* Process
;
211 PUSHORT PageTableRefCountTable
;
212 ULONG PageTableRefCountTableSize
;
213 } MADDRESS_SPACE
, *PMADDRESS_SPACE
;
216 // Generic Address Range Structure
218 typedef struct _ADDRESS_RANGE
225 } ADDRESS_RANGE
, *PADDRESS_RANGE
;
228 // Node in Memory Manager's AVL Table
230 typedef struct _MMADDRESS_NODE
235 struct _MMADDRESS_NODE
*Parent
;
237 struct _MMADDRESS_NODE
*LeftChild
;
238 struct _MMADDRESS_NODE
*RightChild
;
241 } MMADDRESS_NODE
, *PMMADDRESS_NODE
;
244 // Memory Manager AVL Table for VADs and other descriptors
246 typedef struct _MM_AVL_TABLE
248 MMADDRESS_NODE BalancedRoot
;
251 ULONG NumberGenericTableElements
:24;
254 } MM_AVL_TABLE
, *PMM_AVL_TABLE
;
257 // Memory Manager Working Set Structures
259 typedef struct _MMWSLENTRY
263 ULONG LockedInMemory
:1;
268 ULONG VirtualPageNumber
:14;
269 } MMWSLENTRY
, *PMMWSLENTRY
;
271 typedef struct _MMWSLE
275 PVOID VirtualAddress
;
281 typedef struct _MMWSLE_HASH
285 } MMWSLE_HASH
, *PMMWSLE_HASH
;
287 typedef struct _MMWSL
294 ULONG LastInitializedWsle
;
296 PMMWSLE_HASH HashTable
;
298 ULONG NumberOfCommittedPageTables
;
299 PVOID HashTableStart
;
300 PVOID HighestPermittedHashAddress
;
301 ULONG NumberOfImageWaiters
;
303 USHORT UsedPageTableEntries
[768];
304 ULONG CommittedPageTables
[24];
308 // Flags for Memory Support Structure
310 typedef struct _MMSUPPORT_FLAGS
312 ULONG SessionSpace
:1;
313 ULONG BeingTrimmed
:1;
314 ULONG SessionLeader
:1;
316 ULONG WorkingSetHard
:1;
317 ULONG AddressSpaceBeingDeleted
:1;
319 ULONG AllowWorkingSetAdjustment
:8;
320 ULONG MemoryPriority
:8;
321 } MMSUPPORT_FLAGS
, *PMMSUPPORT_FLAGS
;
324 // Per-Process Memory Manager Data
326 typedef struct _MMSUPPORT
328 LARGE_INTEGER LastTrimTime
;
329 MMSUPPORT_FLAGS Flags
;
330 ULONG PageFaultCount
;
331 ULONG PeakWorkingSetSize
;
332 ULONG WorkingSetSize
;
333 ULONG MinimumWorkingSetSize
;
334 ULONG MaximumWorkingSetSize
;
335 PMMWSL MmWorkingSetList
;
336 LIST_ENTRY WorkingSetExpansionLinks
;
338 ULONG NextEstimationSlot
;
340 ULONG EstimatedAvailable
;
341 ULONG GrowthSinceLastEstimate
;
342 } MMSUPPORT
, *PMMSUPPORT
;
344 #endif // !NTOS_MODE_USER