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