ReactOS  0.4.15-dev-1377-ga59cecd
miarm.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: ntoskrnl/mm/ARM3/miarm.h
5  * PURPOSE: ARM Memory Manager Header
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 #pragma once
10 
11 #define MI_LOWEST_VAD_ADDRESS (PVOID)MM_LOWEST_USER_ADDRESS
12 
13 /* Make the code cleaner with some definitions for size multiples */
14 #define _1KB (1024u)
15 #define _1MB (1024 * _1KB)
16 #define _1GB (1024 * _1MB)
17 
18 /* Everyone loves 64K */
19 #define _64K (64 * _1KB)
20 
21 /* Size of a page table */
22 #define PT_SIZE (PTE_PER_PAGE * sizeof(MMPTE))
23 
24 /* Size of a page directory */
25 #define PD_SIZE (PDE_PER_PAGE * sizeof(MMPDE))
26 
27 /* Size of all page directories for a process */
28 #define SYSTEM_PD_SIZE (PPE_PER_PAGE * PD_SIZE)
29 #ifdef _M_IX86
31 #endif
32 
33 //
34 // Protection Bits part of the internal memory manager Protection Mask, from:
35 // http://reactos.org/wiki/Techwiki:Memory_management_in_the_Windows_XP_kernel
36 // https://www.reactos.org/wiki/Techwiki:Memory_Protection_constants
37 // and public assertions.
38 //
39 #define MM_ZERO_ACCESS 0
40 #define MM_READONLY 1
41 #define MM_EXECUTE 2
42 #define MM_EXECUTE_READ 3
43 #define MM_READWRITE 4
44 #define MM_WRITECOPY 5
45 #define MM_EXECUTE_READWRITE 6
46 #define MM_EXECUTE_WRITECOPY 7
47 #define MM_PROTECT_ACCESS 7
48 
49 //
50 // These are flags on top of the actual protection mask
51 //
52 #define MM_NOCACHE 0x08
53 #define MM_GUARDPAGE 0x10
54 #define MM_WRITECOMBINE 0x18
55 #define MM_PROTECT_SPECIAL 0x18
56 
57 //
58 // These are special cases
59 //
60 #define MM_DECOMMIT (MM_ZERO_ACCESS | MM_GUARDPAGE)
61 #define MM_NOACCESS (MM_ZERO_ACCESS | MM_WRITECOMBINE)
62 #define MM_OUTSWAPPED_KSTACK (MM_EXECUTE_WRITECOPY | MM_WRITECOMBINE)
63 #define MM_INVALID_PROTECTION 0xFFFFFFFF
64 
65 //
66 // Specific PTE Definitions that map to the Memory Manager's Protection Mask Bits
67 // The Memory Manager's definition define the attributes that must be preserved
68 // and these PTE definitions describe the attributes in the hardware sense. This
69 // helps deal with hardware differences between the actual boolean expression of
70 // the argument.
71 //
72 // For example, in the logical attributes, we want to express read-only as a flag
73 // but on x86, it is writability that must be set. On the other hand, on x86, just
74 // like in the kernel, it is disabling the caches that requires a special flag,
75 // while on certain architectures such as ARM, it is enabling the cache which
76 // requires a flag.
77 //
78 #if defined(_M_IX86)
79 //
80 // Access Flags
81 //
82 #define PTE_READONLY 0 // Doesn't exist on x86
83 #define PTE_EXECUTE 0 // Not worrying about NX yet
84 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
85 #define PTE_READWRITE 0x2
86 #define PTE_WRITECOPY 0x200
87 #define PTE_EXECUTE_READWRITE 0x2 // Not worrying about NX yet
88 #define PTE_EXECUTE_WRITECOPY 0x200
89 #define PTE_PROTOTYPE 0x400
90 
91 //
92 // State Flags
93 //
94 #define PTE_VALID 0x1
95 #define PTE_ACCESSED 0x20
96 #define PTE_DIRTY 0x40
97 
98 //
99 // Cache flags
100 //
101 #define PTE_ENABLE_CACHE 0
102 #define PTE_DISABLE_CACHE 0x10
103 #define PTE_WRITECOMBINED_CACHE 0x10
104 #define PTE_PROTECT_MASK 0x612
105 #elif defined(_M_AMD64)
106 //
107 // Access Flags
108 //
109 #define PTE_READONLY 0x8000000000000000ULL
110 #define PTE_EXECUTE 0x0000000000000000ULL
111 #define PTE_EXECUTE_READ PTE_EXECUTE /* EXECUTE implies READ on x64 */
112 #define PTE_READWRITE 0x8000000000000002ULL
113 #define PTE_WRITECOPY 0x8000000000000200ULL
114 #define PTE_EXECUTE_READWRITE 0x0000000000000002ULL
115 #define PTE_EXECUTE_WRITECOPY 0x0000000000000200ULL
116 #define PTE_PROTOTYPE 0x0000000000000400ULL
117 
118 //
119 // State Flags
120 //
121 #define PTE_VALID 0x0000000000000001ULL
122 #define PTE_ACCESSED 0x0000000000000020ULL
123 #define PTE_DIRTY 0x0000000000000040ULL
124 
125 //
126 // Cache flags
127 //
128 #define PTE_ENABLE_CACHE 0x0000000000000000ULL
129 #define PTE_DISABLE_CACHE 0x0000000000000010ULL
130 #define PTE_WRITECOMBINED_CACHE 0x0000000000000010ULL
131 #define PTE_PROTECT_MASK 0x8000000000000612ULL
132 #elif defined(_M_ARM)
133 #define PTE_READONLY 0x200
134 #define PTE_EXECUTE 0 // Not worrying about NX yet
135 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
136 #define PTE_READWRITE 0 // Doesn't exist on ARM
137 #define PTE_WRITECOPY 0 // Doesn't exist on ARM
138 #define PTE_EXECUTE_READWRITE 0 // Not worrying about NX yet
139 #define PTE_EXECUTE_WRITECOPY 0 // Not worrying about NX yet
140 #define PTE_PROTOTYPE 0x400 // Using the Shared bit
141 
142 //
143 // Cache flags
144 //
145 #define PTE_ENABLE_CACHE 0
146 #define PTE_DISABLE_CACHE 0x10
147 #define PTE_WRITECOMBINED_CACHE 0x10
148 #define PTE_PROTECT_MASK 0x610
149 #else
150 #error Define these please!
151 #endif
152 
153 //
154 // Mask for image section page protection
155 //
156 #define IMAGE_SCN_PROTECTION_MASK (IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE)
157 
158 extern const ULONG_PTR MmProtectToPteMask[32];
159 extern const ULONG MmProtectToValue[32];
160 
161 //
162 // Assertions for session images, addresses, and PTEs
163 //
164 #define MI_IS_SESSION_IMAGE_ADDRESS(Address) \
165  (((Address) >= MiSessionImageStart) && ((Address) < MiSessionImageEnd))
166 
167 #define MI_IS_SESSION_ADDRESS(Address) \
168  (((Address) >= MmSessionBase) && ((Address) < MiSessionSpaceEnd))
169 
170 #define MI_IS_SESSION_PTE(Pte) \
171  ((((PMMPTE)Pte) >= MiSessionBasePte) && (((PMMPTE)Pte) < MiSessionLastPte))
172 
173 #define MI_IS_PAGE_TABLE_ADDRESS(Address) \
174  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)PTE_TOP))
175 
176 #define MI_IS_SYSTEM_PAGE_TABLE_ADDRESS(Address) \
177  (((Address) >= (PVOID)MiAddressToPte(MmSystemRangeStart)) && ((Address) <= (PVOID)PTE_TOP))
178 
179 #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(Address) \
180  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)MmHyperSpaceEnd))
181 
182 //
183 // Creates a software PTE with the given protection
184 //
185 #define MI_MAKE_SOFTWARE_PTE(p, x) ((p)->u.Long = (x << MM_PTE_SOFTWARE_PROTECTION_BITS))
186 
187 //
188 // Marks a PTE as deleted
189 //
190 #define MI_SET_PFN_DELETED(x) ((x)->PteAddress = (PMMPTE)((ULONG_PTR)(x)->PteAddress | 1))
191 #define MI_IS_PFN_DELETED(x) ((ULONG_PTR)((x)->PteAddress) & 1)
192 
193 //
194 // Special values for LoadedImports
195 //
196 #ifdef _WIN64
197 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFFFFFFFFFEULL
198 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFFFFFFFFFFULL
199 #else
200 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFE
201 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFF
202 #endif
203 #define MM_SYSLDR_SINGLE_ENTRY 0x1
204 
205 //
206 // Number of initial session IDs
207 //
208 #define MI_INITIAL_SESSION_IDS 64
209 
210 #if defined(_M_IX86) || defined(_M_ARM)
211 //
212 // PFN List Sentinel
213 //
214 #define LIST_HEAD 0xFFFFFFFF
215 
216 //
217 // Because GCC cannot automatically downcast 0xFFFFFFFF to lesser-width bits,
218 // we need a manual definition suited to the number of bits in the PteFrame.
219 // This is used as a LIST_HEAD for the colored list
220 //
221 #define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
222 #elif defined(_M_AMD64)
223 #define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
224 #define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
225 #else
226 #error Define these please!
227 #endif
228 
229 //
230 // Special IRQL value (found in assertions)
231 //
232 #define MM_NOIRQL (KIRQL)0xFFFFFFFF
233 
234 //
235 // Returns the color of a page
236 //
237 #define MI_GET_PAGE_COLOR(x) ((x) & MmSecondaryColorMask)
238 #define MI_GET_NEXT_COLOR() (MI_GET_PAGE_COLOR(++MmSystemPageColor))
239 #define MI_GET_NEXT_PROCESS_COLOR(x) (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
240 
241 //
242 // Prototype PTEs that don't yet have a pagefile association
243 //
244 #ifdef _WIN64
245 #define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
246 #else
247 #define MI_PTE_LOOKUP_NEEDED 0xFFFFF
248 #endif
249 
250 //
251 // Number of session data and tag pages
252 //
253 #define MI_SESSION_DATA_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
254 #define MI_SESSION_TAG_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
255 
256 //
257 // Used by MiCheckSecuredVad
258 //
259 #define MM_READ_WRITE_ALLOWED 11
260 #define MM_READ_ONLY_ALLOWED 10
261 #define MM_NO_ACCESS_ALLOWED 01
262 #define MM_DELETE_CHECK 85
263 
264 //
265 // System views are binned into 64K chunks
266 //
267 #define MI_SYSTEM_VIEW_BUCKET_SIZE _64K
268 
269 //
270 // FIXFIX: These should go in ex.h after the pool merge
271 //
272 #ifdef _WIN64
273 #define POOL_BLOCK_SIZE 16
274 #else
275 #define POOL_BLOCK_SIZE 8
276 #endif
277 #define POOL_LISTS_PER_PAGE (PAGE_SIZE / POOL_BLOCK_SIZE)
278 #define BASE_POOL_TYPE_MASK 1
279 #define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + POOL_BLOCK_SIZE))
280 
281 //
282 // Pool debugging/analysis/tracing flags
283 //
284 #define POOL_FLAG_CHECK_TIMERS 0x1
285 #define POOL_FLAG_CHECK_WORKERS 0x2
286 #define POOL_FLAG_CHECK_RESOURCES 0x4
287 #define POOL_FLAG_VERIFIER 0x8
288 #define POOL_FLAG_CHECK_DEADLOCK 0x10
289 #define POOL_FLAG_SPECIAL_POOL 0x20
290 #define POOL_FLAG_DBGPRINT_ON_FAILURE 0x40
291 #define POOL_FLAG_CRASH_ON_FAILURE 0x80
292 
293 //
294 // BAD_POOL_HEADER codes during pool bugcheck
295 //
296 #define POOL_CORRUPTED_LIST 3
297 #define POOL_SIZE_OR_INDEX_MISMATCH 5
298 #define POOL_ENTRIES_NOT_ALIGNED_PREVIOUS 6
299 #define POOL_HEADER_NOT_ALIGNED 7
300 #define POOL_HEADER_IS_ZERO 8
301 #define POOL_ENTRIES_NOT_ALIGNED_NEXT 9
302 #define POOL_ENTRY_NOT_FOUND 10
303 
304 //
305 // BAD_POOL_CALLER codes during pool bugcheck
306 //
307 #define POOL_ENTRY_CORRUPTED 1
308 #define POOL_ENTRY_ALREADY_FREE 6
309 #define POOL_ENTRY_NOT_ALLOCATED 7
310 #define POOL_ALLOC_IRQL_INVALID 8
311 #define POOL_FREE_IRQL_INVALID 9
312 #define POOL_BILLED_PROCESS_INVALID 13
313 #define POOL_HEADER_SIZE_INVALID 32
314 
315 typedef struct _POOL_DESCRIPTOR
316 {
331 
332 typedef struct _POOL_HEADER
333 {
334  union
335  {
336  struct
337  {
338 #ifdef _WIN64
340  USHORT PoolIndex:8;
341  USHORT BlockSize:8;
342  USHORT PoolType:8;
343 #else
345  USHORT PoolIndex:7;
346  USHORT BlockSize:9;
347  USHORT PoolType:7;
348 #endif
349  };
350  ULONG Ulong1;
351  };
352 #ifdef _WIN64
353  ULONG PoolTag;
354 #endif
355  union
356  {
357 #ifdef _WIN64
358  PEPROCESS ProcessBilled;
359 #else
360  ULONG PoolTag;
361 #endif
362  struct
363  {
366  };
367  };
369 
372 
373 typedef struct _POOL_TRACKER_TABLE
374 {
383 
385 {
391 
396 
397 //
398 // END FIXFIX
399 //
400 
402 {
406 
408 {
413 
415 {
421 
422 typedef struct _PHYSICAL_MEMORY_RUN
423 {
427 
429 {
434 
435 typedef struct _MMCOLOR_TABLES
436 {
441 
442 typedef struct _MI_LARGE_PAGE_RANGES
443 {
447 
448 typedef struct _MMVIEW
449 {
452 } MMVIEW, *PMMVIEW;
453 
454 typedef struct _MMSESSION
455 {
466 
468 {
473 
474 typedef struct _MM_SESSION_SPACE
475 {
478  union
479  {
482  } u;
510 #if defined (_M_AMD64)
511  MMPDE PageDirectory;
512 #else
514 #endif
515 #if defined (_M_AMD64)
516  PMMPTE SpecialPoolFirstPte;
517  PMMPTE SpecialPoolLastPte;
518  PMMPTE NextPdeForSpecialPoolExpansion;
519  PMMPTE LastPdeForSpecialPoolExpansion;
520  PFN_NUMBER SpecialPagesInUse;
521 #endif
524 
526 extern MMPTE HyperTemplatePte;
527 extern MMPDE ValidKernelPde;
528 extern MMPTE ValidKernelPte;
531 extern MMPDE DemandZeroPde;
532 extern MMPTE DemandZeroPte;
533 extern MMPTE PrototypePte;
534 extern MMPTE MmDecommittedPte;
536 extern BOOLEAN MmZeroPageFile;
539 extern BOOLEAN MmTrackPtes;
540 extern BOOLEAN MmDynamicPfn;
541 extern BOOLEAN MmMirroring;
542 extern BOOLEAN MmMakeLowMemory;
548 extern WCHAR MmVerifyDriverBuffer[512];
549 extern WCHAR MmLargePageDriverBuffer[512];
561 extern PVOID MmNonPagedPoolEnd;
563 extern PVOID MmPagedPoolStart;
564 extern PVOID MmPagedPoolEnd;
565 extern PVOID MmSessionBase;
566 extern SIZE_T MmSessionSize;
571 extern SIZE_T MmBootImageSize;
578 extern RTL_BITMAP MiPfnBitMap;
584 extern PVOID MiSystemViewStart;
585 extern SIZE_T MmSystemViewSize;
587 extern PVOID MiSessionSpaceEnd;
590 extern PMMPTE MiSessionBasePte;
591 extern PMMPTE MiSessionLastPte;
593 extern PMMPDE MmSystemPagePtes;
595 extern PVOID MmSystemCacheEnd;
598 extern ULONG MmSpecialPoolTag;
599 extern PVOID MmHyperSpaceEnd;
605 extern ULONG MmSecondaryColors;
609 extern ULONG MmLargeStackSize;
612 extern ULONG MmProductType;
636 extern PVOID MiSessionImageEnd;
637 extern PMMPTE MiHighestUserPte;
638 extern PMMPDE MiHighestUserPde;
643 extern ULONG MmSystemPageColor;
645 extern PMMWSL MmWorkingSetList;
651 extern PVOID MiSessionPoolEnd; // 0xBE000000
652 extern PVOID MiSessionPoolStart; // 0xBD000000
653 extern PVOID MiSessionViewStart; // 0xBE000000
654 extern PVOID MiSessionSpaceWs;
659 extern PVOID MmHighSectionBase;
666 
668 BOOLEAN
670 {
671  return ((MemoryType == LoaderFree) ||
672  (MemoryType == LoaderLoadedProgram) ||
673  (MemoryType == LoaderFirmwareTemporary) ||
674  (MemoryType == LoaderOsloaderStack));
675 }
676 
678 BOOLEAN
680 {
681  return ((MemoryType == LoaderFirmwarePermanent) ||
682  (MemoryType == LoaderSpecialMemory) ||
683  (MemoryType == LoaderHALCachedMemory) ||
684  (MemoryType == LoaderBBTMemory));
685 }
686 
687 #ifdef _M_AMD64
689 BOOLEAN
690 MiIsUserPxe(PVOID Address)
691 {
692  return ((ULONG_PTR)Address >> 7) == 0x1FFFFEDF6FB7DA0ULL;
693 }
694 
696 BOOLEAN
697 MiIsUserPpe(PVOID Address)
698 {
699  return ((ULONG_PTR)Address >> 16) == 0xFFFFF6FB7DA0ULL;
700 }
701 
703 BOOLEAN
705 {
706  return ((ULONG_PTR)Address >> 25) == 0x7FFFFB7DA0ULL;
707 }
708 
710 BOOLEAN
712 {
713  return ((ULONG_PTR)Address >> 34) == 0x3FFFFDA0ULL;
714 }
715 #else
717 BOOLEAN
719 {
720  return ((Address >= (PVOID)MiAddressToPde(NULL)) &&
722 }
723 
725 BOOLEAN
727 {
728  return (Address <= (PVOID)MiHighestUserPte);
729 }
730 #endif
731 
732 //
733 // Figures out the hardware bits for a PTE
734 //
736 ULONG_PTR
738 {
739  MMPTE TempPte;
740 
741  /* Start fresh */
742  TempPte.u.Long = 0;
743 
744  /* Make it valid and accessed */
745  TempPte.u.Hard.Valid = TRUE;
747 
748  /* Is this for user-mode? */
749  if (
750 #if (_MI_PAGING_LEVELS == 4)
751  MiIsUserPxe(PointerPte) ||
752 #endif
753 #if (_MI_PAGING_LEVELS >= 3)
754  MiIsUserPpe(PointerPte) ||
755 #endif
756  MiIsUserPde(PointerPte) ||
757  MiIsUserPte(PointerPte))
758  {
759  /* Set the owner bit */
761  }
762 
763  /* FIXME: We should also set the global bit */
764 
765  /* Return the protection */
766  return TempPte.u.Long;
767 }
768 
769 //
770 // Creates a valid kernel PTE with the given protection
771 //
773 VOID
775  IN PMMPTE MappingPte,
776  IN ULONG_PTR ProtectionMask,
777  IN PFN_NUMBER PageFrameNumber)
778 {
779  /* Only valid for kernel, non-session PTEs */
780  ASSERT(MappingPte > MiHighestUserPte);
781  ASSERT(!MI_IS_SESSION_PTE(MappingPte));
782  ASSERT((MappingPte < (PMMPTE)PDE_BASE) || (MappingPte > (PMMPTE)PDE_TOP));
783 
784  /* Start fresh */
785  *NewPte = ValidKernelPte;
786 
787  /* Set the protection and page */
788  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
789  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
790 }
791 
792 //
793 // Creates a valid PTE with the given protection
794 //
796 VOID
798  IN PMMPTE MappingPte,
799  IN ULONG_PTR ProtectionMask,
800  IN PFN_NUMBER PageFrameNumber)
801 {
802  /* Set the protection and page */
803  NewPte->u.Long = MiDetermineUserGlobalPteMask(MappingPte);
804  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
805  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
806 }
807 
808 //
809 // Creates a valid user PTE with the given protection
810 //
812 VOID
814  IN PMMPTE MappingPte,
815  IN ULONG_PTR ProtectionMask,
816  IN PFN_NUMBER PageFrameNumber)
817 {
818  /* Only valid for kernel, non-session PTEs */
819  ASSERT(MappingPte <= MiHighestUserPte);
820 
821  /* Start fresh */
822  NewPte->u.Long = 0;
823 
824  /* Set the protection and page */
825  NewPte->u.Hard.Valid = TRUE;
826  NewPte->u.Hard.Owner = TRUE;
827  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
828  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
829 }
830 
831 #ifndef _M_AMD64
832 //
833 // Builds a Prototype PTE for the address of the PTE
834 //
836 VOID
838  IN PMMPTE PointerPte)
839 {
841 
842  /* Mark this as a prototype */
843  NewPte->u.Long = 0;
844  NewPte->u.Proto.Prototype = 1;
845 
846  /*
847  * Prototype PTEs are only valid in paged pool by design, this little trick
848  * lets us only use 30 bits for the adress of the PTE, as long as the area
849  * stays 1024MB At most.
850  */
851  Offset = (ULONG_PTR)PointerPte - (ULONG_PTR)MmPagedPoolStart;
852 
853  /*
854  * 7 bits go in the "low" (but we assume the bottom 2 are zero)
855  * and the other 21 bits go in the "high"
856  */
857  NewPte->u.Proto.ProtoAddressLow = (Offset & 0x1FC) >> 2;
858  NewPte->u.Proto.ProtoAddressHigh = (Offset & 0x3FFFFE00) >> 9;
859 }
860 
861 //
862 // Builds a Subsection PTE for the address of the Segment
863 //
865 VOID
867  IN PVOID Segment)
868 {
870 
871  /* Mark this as a prototype */
872  NewPte->u.Long = 0;
873  NewPte->u.Subsect.Prototype = 1;
874 
875  /*
876  * Segments are only valid either in nonpaged pool. We store the 20 bit
877  * difference either from the top or bottom of nonpaged pool, giving a
878  * maximum of 128MB to each delta, meaning nonpaged pool cannot exceed
879  * 256MB.
880  */
881  if ((ULONG_PTR)Segment < ((ULONG_PTR)MmSubsectionBase + (128 * _1MB)))
882  {
884  NewPte->u.Subsect.WhichPool = PagedPool;
885  }
886  else
887  {
889  NewPte->u.Subsect.WhichPool = NonPagedPool;
890  }
891 
892  /*
893  * 4 bits go in the "low" (but we assume the bottom 3 are zero)
894  * and the other 20 bits go in the "high"
895  */
896  NewPte->u.Subsect.SubsectionAddressLow = (Offset & 0x78) >> 3;
897  NewPte->u.Subsect.SubsectionAddressHigh = (Offset & 0xFFFFF80) >> 7;
898 }
899 
901 BOOLEAN
903 {
905  return ((PointerPte->u.Long & 0xFFFFFC01) != 0);
906 }
907 
908 #endif
909 
911 VOID
913  _In_ PFN_NUMBER Page,
914  _In_ ULONG Protection)
915 {
916  NewPte->u.Long = 0;
917  NewPte->u.Trans.Transition = 1;
918  NewPte->u.Trans.Protection = Protection;
919  NewPte->u.Trans.PageFrameNumber = Page;
920 }
921 
922 //
923 // Returns if the page is physically resident (ie: a large page)
924 // FIXFIX: CISC/x86 only?
925 //
927 BOOLEAN
929 {
930  PMMPDE PointerPde;
931 
932  /* Large pages are never paged out, always physically resident */
933  PointerPde = MiAddressToPde(Address);
934  return ((PointerPde->u.Hard.LargePage) && (PointerPde->u.Hard.Valid));
935 }
936 
937 //
938 // Writes a valid PTE
939 //
941 VOID
943  IN MMPTE TempPte)
944 {
945  /* Write the valid PTE */
946  ASSERT(PointerPte->u.Hard.Valid == 0);
947  ASSERT(TempPte.u.Hard.Valid == 1);
948 #if _M_AMD64
950  (TempPte.u.Hard.NoExecute == 0));
951 #endif
952  *PointerPte = TempPte;
953 }
954 
955 //
956 // Updates a valid PTE
957 //
959 VOID
961  IN MMPTE TempPte)
962 {
963  /* Write the valid PTE */
964  ASSERT(PointerPte->u.Hard.Valid == 1);
965  ASSERT(TempPte.u.Hard.Valid == 1);
966  ASSERT(PointerPte->u.Hard.PageFrameNumber == TempPte.u.Hard.PageFrameNumber);
967  *PointerPte = TempPte;
968 }
969 
970 //
971 // Writes an invalid PTE
972 //
974 VOID
976  IN MMPTE InvalidPte)
977 {
978  /* Write the invalid PTE */
979  ASSERT(InvalidPte.u.Hard.Valid == 0);
980  ASSERT(InvalidPte.u.Long != 0);
981  *PointerPte = InvalidPte;
982 }
983 
984 //
985 // Erase the PTE completely
986 //
988 VOID
989 MI_ERASE_PTE(IN PMMPTE PointerPte)
990 {
991  /* Zero out the PTE */
992  ASSERT(PointerPte->u.Long != 0);
993  PointerPte->u.Long = 0;
994 }
995 
996 //
997 // Writes a valid PDE
998 //
1000 VOID
1002  IN MMPDE TempPde)
1003 {
1004  /* Write the valid PDE */
1005  ASSERT(PointerPde->u.Hard.Valid == 0);
1006 #ifdef _M_AMD64
1007  ASSERT(PointerPde->u.Hard.NoExecute == 0);
1008 #endif
1009  ASSERT(TempPde.u.Hard.Valid == 1);
1010  *PointerPde = TempPde;
1011 }
1012 
1013 //
1014 // Writes an invalid PDE
1015 //
1017 VOID
1019  IN MMPDE InvalidPde)
1020 {
1021  /* Write the invalid PDE */
1022  ASSERT(InvalidPde.u.Hard.Valid == 0);
1023  ASSERT(InvalidPde.u.Long != 0);
1024 #ifdef _M_AMD64
1025  ASSERT(InvalidPde.u.Soft.Protection == MM_EXECUTE_READWRITE);
1026 #endif
1027  *PointerPde = InvalidPde;
1028 }
1029 
1030 //
1031 // Checks if the thread already owns a working set
1032 //
1034 BOOLEAN
1036 {
1037  /* If any of these are held, return TRUE */
1044 }
1045 
1046 //
1047 // Checks if the process owns the working set lock
1048 //
1050 BOOLEAN
1052 {
1053  /* Check if this process is the owner, and that the thread owns the WS */
1054  if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0)
1055  {
1056  DPRINT("Thread: %p is not an owner\n", PsGetCurrentThread());
1057  }
1058  if (KeGetCurrentThread()->ApcState.Process != &Process->Pcb)
1059  {
1060  DPRINT("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
1061  }
1062  return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
1063  ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||
1064  (PsGetCurrentThread()->OwnsProcessWorkingSetShared)));
1065 }
1066 
1067 //
1068 // New ARM3<->RosMM PAGE Architecture
1069 //
1071 BOOLEAN
1073 {
1074  PROS_SECTION_OBJECT RosSection = Section;
1075  if ((RosSection->Type == 'SC') && (RosSection->Size == 'TN')) return TRUE;
1076  return FALSE;
1077 }
1078 
1079 #define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE)
1080 
1081 VOID
1082 NTAPI
1084  IN PMMPFN Pfn1,
1085  IN PFN_NUMBER PageFrameIndex
1086 );
1087 
1089 BOOLEAN
1091 {
1092  return (Process->Vm.Flags.AcquiredUnsafe == TRUE);
1093 }
1094 
1095 //
1096 // Locks the working set for the given process
1097 //
1099 VOID
1101  IN PETHREAD Thread)
1102 {
1103  /* Shouldn't already be owning the process working set */
1106 
1107  /* Block APCs, make sure that still nothing is already held */
1110 
1111  /* Lock the working set */
1112  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1113 
1114  /* Now claim that we own the lock */
1118 }
1119 
1121 VOID
1123  IN PETHREAD Thread)
1124 {
1125  /* Shouldn't already be owning the process working set */
1128 
1129  /* Block APCs, make sure that still nothing is already held */
1132 
1133  /* Lock the working set */
1134  ExAcquirePushLockShared(&Process->Vm.WorkingSetMutex);
1135 
1136  /* Now claim that we own the lock */
1141 }
1142 
1144 VOID
1146  IN PETHREAD Thread)
1147 {
1148  /* Shouldn't already be owning the process working set */
1150 
1151  /* APCs must be blocked, make sure that still nothing is already held */
1154 
1155  /* Lock the working set */
1156  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1157 
1158  /* Now claim that we own the lock */
1160  Process->Vm.Flags.AcquiredUnsafe = 1;
1163 }
1164 
1165 //
1166 // Unlocks the working set for the given process
1167 //
1169 VOID
1171  IN PETHREAD Thread)
1172 {
1173  /* Make sure we are the owner of a safe acquisition */
1176 
1177  /* The thread doesn't own it anymore */
1180 
1181  /* Release the lock and re-enable APCs */
1182  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1184 }
1185 
1186 //
1187 // Unlocks the working set for the given process
1188 //
1190 VOID
1192  IN PETHREAD Thread)
1193 {
1194  /* Make sure we are the owner of a safe acquisition (because shared) */
1197 
1198  /* Ensure we are in a shared acquisition */
1201 
1202  /* Don't claim the lock anylonger */
1204 
1205  /* Release the lock and re-enable APCs */
1206  ExReleasePushLockShared(&Process->Vm.WorkingSetMutex);
1208 }
1209 
1210 //
1211 // Unlocks the working set for the given process
1212 //
1214 VOID
1216  IN PETHREAD Thread)
1217 {
1218  /* Make sure we are the owner of an unsafe acquisition */
1223 
1224  /* No longer unsafe */
1225  Process->Vm.Flags.AcquiredUnsafe = 0;
1226 
1227  /* The thread doesn't own it anymore */
1230 
1231  /* Release the lock but don't touch APC state */
1232  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1234 }
1235 
1236 //
1237 // Locks the working set
1238 //
1240 VOID
1242  IN PMMSUPPORT WorkingSet)
1243 {
1244  /* Block APCs */
1246 
1247  /* Working set should be in global memory */
1248  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1249 
1250  /* Thread shouldn't already be owning something */
1252 
1253  /* Lock this working set */
1254  ExAcquirePushLockExclusive(&WorkingSet->WorkingSetMutex);
1255 
1256  /* Which working set is this? */
1257  if (WorkingSet == &MmSystemCacheWs)
1258  {
1259  /* Own the system working set */
1263  }
1264  else if (WorkingSet->Flags.SessionSpace)
1265  {
1266  /* Own the session working set */
1270  }
1271  else
1272  {
1273  /* Own the process working set */
1277  }
1278 }
1279 
1280 //
1281 // Unlocks the working set
1282 //
1284 VOID
1286  IN PMMSUPPORT WorkingSet)
1287 {
1288  /* Working set should be in global memory */
1289  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1290 
1291  /* Which working set is this? */
1292  if (WorkingSet == &MmSystemCacheWs)
1293  {
1294  /* Release the system working set */
1298  }
1299  else if (WorkingSet->Flags.SessionSpace)
1300  {
1301  /* Release the session working set */
1305  }
1306  else
1307  {
1308  /* Release the process working set */
1312  }
1313 
1314  /* Release the working set lock */
1315  ExReleasePushLockExclusive(&WorkingSet->WorkingSetMutex);
1316 
1317  /* Unblock APCs */
1319 }
1320 
1322 VOID
1324  IN PETHREAD Thread,
1325  OUT PBOOLEAN Safe,
1326  OUT PBOOLEAN Shared)
1327 {
1329 
1330  /* Check if the current owner is unsafe */
1331  if (MI_IS_WS_UNSAFE(Process))
1332  {
1333  /* Release unsafely */
1335  *Safe = FALSE;
1336  *Shared = FALSE;
1337  }
1338  else if (Thread->OwnsProcessWorkingSetExclusive == 1)
1339  {
1340  /* Owner is safe and exclusive, release normally */
1342  *Safe = TRUE;
1343  *Shared = FALSE;
1344  }
1345  else
1346  {
1347  /* Owner is shared (implies safe), release normally */
1349  *Safe = TRUE;
1350  *Shared = TRUE;
1351  }
1352 }
1353 
1355 VOID
1357  IN PETHREAD Thread,
1358  IN BOOLEAN Safe,
1359  IN BOOLEAN Shared)
1360 {
1361  /* Check if this was a safe lock or not */
1362  if (Safe)
1363  {
1364  if (Shared)
1365  {
1366  /* Reacquire safely & shared */
1368  }
1369  else
1370  {
1371  /* Reacquire safely */
1373  }
1374  }
1375  else
1376  {
1377  /* Unsafe lock cannot be shared */
1378  ASSERT(Shared == FALSE);
1379  /* Reacquire unsafely */
1381  }
1382 }
1383 
1385 KIRQL
1387 {
1388  KIRQL OldIrql;
1389 
1394  return OldIrql;
1395 }
1396 
1398 VOID
1400 {
1405 }
1406 
1407 //
1408 // Returns the ProtoPTE inside a VAD for the given VPN
1409 //
1411 PMMPTE
1413  IN ULONG_PTR Vpn)
1414 {
1415  PMMPTE ProtoPte;
1416 
1417  /* Find the offset within the VAD's prototype PTEs */
1418  ProtoPte = Vad->FirstPrototypePte + (Vpn - Vad->StartingVpn);
1419  ASSERT(ProtoPte <= Vad->LastContiguousPte);
1420  return ProtoPte;
1421 }
1422 
1423 //
1424 // Returns the PFN Database entry for the given page number
1425 // Warning: This is not necessarily a valid PFN database entry!
1426 //
1428 PMMPFN
1430 {
1431  /* Get the entry */
1432  return &MmPfnDatabase[Pfn];
1433 };
1434 
1435 //
1436 // Drops a locked page without dereferencing it
1437 //
1439 VOID
1441 {
1442  /* This page shouldn't be locked, but it should be valid */
1443  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1444  ASSERT(Pfn1->u2.ShareCount == 0);
1445 
1446  /* Is this the last reference to the page */
1447  if (Pfn1->u3.e2.ReferenceCount == 1)
1448  {
1449  /* It better not be valid */
1450  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1451 
1452  /* Is it a prototype PTE? */
1453  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1454  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1455  {
1456  /* FIXME: We should return commit */
1457  DPRINT1("Not returning commit for prototype PTE\n");
1458  }
1459 
1460  /* Update the counter */
1462  }
1463 }
1464 
1465 //
1466 // Drops a locked page and dereferences it
1467 //
1469 VOID
1471 {
1472  USHORT RefCount, OldRefCount;
1473  PFN_NUMBER PageFrameIndex;
1474 
1475  /* Loop while we decrement the page successfully */
1476  do
1477  {
1478  /* There should be at least one reference */
1479  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1480  ASSERT(OldRefCount != 0);
1481 
1482  /* Are we the last one */
1483  if (OldRefCount == 1)
1484  {
1485  /* The page shoudln't be shared not active at this point */
1486  ASSERT(Pfn1->u3.e2.ReferenceCount == 1);
1487  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1488  ASSERT(Pfn1->u2.ShareCount == 0);
1489 
1490  /* Is it a prototype PTE? */
1491  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1492  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1493  {
1494  /* FIXME: We should return commit */
1495  DPRINT1("Not returning commit for prototype PTE\n");
1496  }
1497 
1498  /* Update the counter, and drop a reference the long way */
1500  PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
1501  MiDecrementReferenceCount(Pfn1, PageFrameIndex);
1502  return;
1503  }
1504 
1505  /* Drop a reference the short way, and that's it */
1506  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1507  OldRefCount - 1,
1508  OldRefCount);
1509  ASSERT(RefCount != 0);
1510  } while (OldRefCount != RefCount);
1511 
1512  /* If we got here, there should be more than one reference */
1513  ASSERT(RefCount > 1);
1514  if (RefCount == 2)
1515  {
1516  /* Is it still being shared? */
1517  if (Pfn1->u2.ShareCount >= 1)
1518  {
1519  /* Then it should be valid */
1520  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1521 
1522  /* Is it a prototype PTE? */
1523  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1524  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1525  {
1526  /* We don't handle ethis */
1527  ASSERT(FALSE);
1528  }
1529 
1530  /* Update the counter */
1532  }
1533  }
1534 }
1535 
1536 //
1537 // References a locked page and updates the counter
1538 // Used in MmProbeAndLockPages to handle different edge cases
1539 //
1541 VOID
1543 {
1544  USHORT RefCount, OldRefCount;
1545 
1546  /* Sanity check */
1547  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1548 
1549  /* Does ARM3 own the page? */
1550  if (MI_IS_ROS_PFN(Pfn1))
1551  {
1552  /* ReactOS Mm doesn't track share count */
1553  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1554  }
1555  else
1556  {
1557  /* On ARM3 pages, we should see a valid share count */
1558  ASSERT((Pfn1->u2.ShareCount != 0) && (Pfn1->u3.e1.PageLocation == ActiveAndValid));
1559 
1560  /* Is it a prototype PTE? */
1561  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1562  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1563  {
1564  /* FIXME: We should charge commit */
1565  DPRINT1("Not charging commit for prototype PTE\n");
1566  }
1567  }
1568 
1569  /* More locked pages! */
1571 
1572  /* Loop trying to update the reference count */
1573  do
1574  {
1575  /* Get the current reference count, make sure it's valid */
1576  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1577  ASSERT(OldRefCount != 0);
1578  ASSERT(OldRefCount < 2500);
1579 
1580  /* Bump it up by one */
1581  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1582  OldRefCount + 1,
1583  OldRefCount);
1584  ASSERT(RefCount != 0);
1585  } while (OldRefCount != RefCount);
1586 
1587  /* Was this the first lock attempt? If not, undo our bump */
1588  if (OldRefCount != 1) InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1589 }
1590 
1591 //
1592 // References a locked page and updates the counter
1593 // Used in all other cases except MmProbeAndLockPages
1594 //
1596 VOID
1598 {
1599  USHORT NewRefCount;
1600 
1601  /* Is it a prototype PTE? */
1602  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1603  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1604  {
1605  /* FIXME: We should charge commit */
1606  DPRINT1("Not charging commit for prototype PTE\n");
1607  }
1608 
1609  /* More locked pages! */
1611 
1612  /* Update the reference count */
1613  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1614  if (NewRefCount == 2)
1615  {
1616  /* Is it locked or shared? */
1617  if (Pfn1->u2.ShareCount)
1618  {
1619  /* It's shared, so make sure it's active */
1620  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1621  }
1622  else
1623  {
1624  /* It's locked, so we shouldn't lock again */
1626  }
1627  }
1628  else
1629  {
1630  /* Someone had already locked the page, so undo our bump */
1631  ASSERT(NewRefCount < 2500);
1633  }
1634 }
1635 
1636 //
1637 // References a locked page and updates the counter
1638 // Used in all other cases except MmProbeAndLockPages
1639 //
1641 VOID
1643 {
1644  USHORT NewRefCount;
1645 
1646  /* Make sure the page isn't used yet */
1647  ASSERT(Pfn1->u2.ShareCount == 0);
1648  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1649 
1650  /* Is it a prototype PTE? */
1651  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1652  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1653  {
1654  /* FIXME: We should charge commit */
1655  DPRINT1("Not charging commit for prototype PTE\n");
1656  }
1657 
1658  /* More locked pages! */
1660 
1661  /* Update the reference count */
1662  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1663  if (NewRefCount != 1)
1664  {
1665  /* Someone had already locked the page, so undo our bump */
1666  ASSERT(NewRefCount < 2500);
1668  }
1669 }
1670 
1672 VOID
1674 {
1675  PUSHORT RefCount;
1676 
1678 
1679  *RefCount += 1;
1680  ASSERT(*RefCount <= PTE_PER_PAGE);
1681 }
1682 
1684 VOID
1686 {
1687  PUSHORT RefCount;
1688 
1690 
1691  *RefCount -= 1;
1692  ASSERT(*RefCount < PTE_PER_PAGE);
1693 }
1694 
1696 USHORT
1698 {
1699  PUSHORT RefCount;
1700 
1702 
1703  return *RefCount;
1704 }
1705 
1706 BOOLEAN
1707 NTAPI
1709  IN ULONG Phase,
1710  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1711 );
1712 
1713 VOID
1714 NTAPI
1716 
1717 NTSTATUS
1718 NTAPI
1720  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1721 );
1722 
1723 VOID
1724 NTAPI
1726  VOID
1727 );
1728 
1729 VOID
1730 NTAPI
1732  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1733 );
1734 
1735 VOID
1736 NTAPI
1738  VOID
1739 );
1740 
1741 VOID
1742 NTAPI
1744  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1745 );
1746 
1747 VOID
1748 NTAPI
1750  VOID
1751 );
1752 
1753 VOID
1754 NTAPI
1756  VOID
1757 );
1758 
1759 BOOLEAN
1760 NTAPI
1762  VOID
1763 );
1764 
1765 PFN_NUMBER
1766 NTAPI
1768  IN PFN_NUMBER PageCount
1769 );
1770 
1772 NTAPI
1774  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1775  IN PBOOLEAN IncludeType
1776 );
1777 
1778 PFN_NUMBER
1779 NTAPI
1781  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1782  IN PBOOLEAN IncludeType
1783 );
1784 
1785 VOID
1786 FASTCALL
1788  IN PVOID AddressStart,
1789  IN PVOID AddressEnd
1790 );
1791 
1792 NTSTATUS
1793 NTAPI
1797  IN OUT PSIZE_T NumberOfBytesToProtect,
1798  IN ULONG NewAccessProtection,
1799  OUT PULONG OldAccessProtection OPTIONAL
1800 );
1801 
1802 NTSTATUS
1803 NTAPI
1805  IN ULONG FaultCode,
1806  IN PVOID Address,
1808  IN PVOID TrapInformation
1809 );
1810 
1811 NTSTATUS
1812 FASTCALL
1814  IN PVOID Address
1815 );
1816 
1817 VOID
1818 NTAPI
1820  VOID
1821 );
1822 
1823 VOID
1824 NTAPI
1826  VOID
1827 );
1828 
1829 VOID
1830 NTAPI
1832  VOID
1833 );
1834 
1835 VOID //
1836 NTAPI //
1837 InitializePool( //
1838  IN POOL_TYPE PoolType,// FIXFIX: This should go in ex.h after the pool merge
1839  IN ULONG Threshold //
1840 ); //
1841 
1842 // FIXFIX: THIS ONE TOO
1843 VOID
1844 NTAPI
1846  IN PPOOL_DESCRIPTOR PoolDescriptor,
1848  IN ULONG PoolIndex,
1849  IN ULONG Threshold,
1850  IN PVOID PoolLock
1851 );
1852 
1853 NTSTATUS
1854 NTAPI
1856  VOID
1857 );
1858 
1859 VOID
1860 NTAPI
1862  IN PMMPTE StartingPte,
1863  IN ULONG NumberOfPtes,
1865 );
1866 
1867 PMMPTE
1868 NTAPI
1870  IN ULONG NumberOfPtes,
1871  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1872 );
1873 
1874 VOID
1875 NTAPI
1877  IN PMMPTE StartingPte,
1878  IN ULONG NumberOfPtes,
1879  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1880 );
1881 
1882 
1883 PFN_NUMBER
1884 NTAPI
1886  IN PFN_NUMBER LowestPfn,
1887  IN PFN_NUMBER HighestPfn,
1888  IN PFN_NUMBER BoundaryPfn,
1889  IN PFN_NUMBER SizeInPages,
1891 );
1892 
1893 PVOID
1894 NTAPI
1897  IN PFN_NUMBER BaseAddressPages,
1898  IN PFN_NUMBER SizeInPages,
1899  IN PFN_NUMBER LowestPfn,
1900  IN PFN_NUMBER HighestPfn,
1901  IN PFN_NUMBER BoundaryPfn,
1902  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute
1903 );
1904 
1905 PMDL
1906 NTAPI
1908  IN PHYSICAL_ADDRESS LowAddress,
1912  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
1913  IN ULONG Flags
1914 );
1915 
1916 VOID
1917 NTAPI
1919  IN PMMPFNLIST ListHead,
1920  IN PFN_NUMBER PageFrameIndex
1921 );
1922 
1923 VOID
1924 NTAPI
1926  IN PMMPFN Entry
1927 );
1928 
1929 VOID
1930 NTAPI
1932  IN PMMPFN Pfn
1933 );
1934 
1935 VOID
1936 NTAPI
1938  IN PFN_NUMBER PageFrameIndex,
1939  IN PMMPTE PointerPte,
1940  IN BOOLEAN Modified
1941 );
1942 
1943 NTSTATUS
1944 NTAPI
1946  OUT PPFN_NUMBER PageFrameIndex,
1947  IN PMMPDE PointerPde,
1948  IN PFN_NUMBER ContainingPageFrame,
1949  IN BOOLEAN SessionAllocation
1950 );
1951 
1952 VOID
1953 NTAPI
1955  IN PFN_NUMBER PageFrameIndex,
1956  IN PMMPTE PointerPte,
1957  IN MMPTE TempPte
1958 );
1959 
1960 VOID
1961 NTAPI
1963  IN PFN_NUMBER PageFrameIndex,
1964  IN PVOID PteAddress,
1965  IN PFN_NUMBER PteFrame
1966 );
1967 
1968 VOID
1969 NTAPI
1971  IN PMMPFN Pfn1,
1972  IN PFN_NUMBER PageFrameIndex
1973 );
1974 
1975 PFN_NUMBER
1976 NTAPI
1978  IN ULONG Color
1979 );
1980 
1981 PFN_NUMBER
1982 NTAPI
1984  IN ULONG Color
1985 );
1986 
1987 VOID
1988 NTAPI
1990  IN PFN_NUMBER PageFrameIndex
1991 );
1992 
1993 VOID
1994 NTAPI
1996  IN PFN_NUMBER PageFrameIndex
1997 );
1998 
1999 PFN_COUNT
2000 NTAPI
2002  IN PMMPTE PointerPte,
2003  IN PFN_NUMBER PageCount,
2004  IN ULONG Flags,
2005  OUT PPFN_NUMBER ValidPages
2006 );
2007 
2008 ULONG
2009 NTAPI
2011  IN PMMPTE PointerPte
2012 );
2013 
2015 NTAPI
2017  IN PVOID Address
2018 );
2019 
2020 VOID
2021 NTAPI
2023  VOID
2024 );
2025 
2026 VOID
2027 NTAPI
2029  VOID
2030 );
2031 
2032 VOID
2033 NTAPI
2035  VOID
2036 );
2037 
2038 BOOLEAN
2039 NTAPI
2040 MiIsPfnInUse(
2041  IN PMMPFN Pfn1
2042 );
2043 
2044 PMMVAD
2045 NTAPI
2048 );
2049 
2051 NTAPI
2053  IN ULONG_PTR StartVpn,
2054  IN ULONG_PTR EndVpn,
2056  OUT PMMADDRESS_NODE *NodeOrParent
2057 );
2058 
2060 NTAPI
2062  IN SIZE_T Length,
2063  IN ULONG_PTR BoundaryAddress,
2068 );
2069 
2070 NTSTATUS
2071 NTAPI
2073  IN SIZE_T Length,
2074  IN ULONG_PTR BoundaryAddress,
2078 );
2079 
2081 NTAPI
2083  IN SIZE_T Length,
2086  OUT PMMADDRESS_NODE *PreviousVad,
2088 );
2089 
2090 NTSTATUS
2091 NTAPI
2093  IN PMMVAD Vad,
2094  IN PVOID Base,
2095  IN SIZE_T Size,
2096  IN ULONG ProtectionMask
2097 );
2098 
2099 VOID
2100 NTAPI
2101 MiInsertVad(
2102  _Inout_ PMMVAD Vad,
2103  _Inout_ PMM_AVL_TABLE VadRoot);
2104 
2105 NTSTATUS
2106 NTAPI
2108  _Inout_ PMMVAD Vad,
2111  _In_ ULONG_PTR HighestAddress,
2114 
2115 VOID
2116 NTAPI
2118  IN PSECTION Section
2119 );
2120 
2121 NTSTATUS
2122 NTAPI
2126  IN ULONG Flags
2127 );
2128 
2129 NTSTATUS
2130 NTAPI
2134  IN BOOLEAN SkipDebuggerNotify
2135 );
2136 
2137 VOID
2138 NTAPI
2139 MiInsertNode(
2141  IN PMMADDRESS_NODE NewNode,
2144 );
2145 
2146 VOID
2147 NTAPI
2148 MiRemoveNode(
2151 );
2152 
2154 NTAPI
2157 );
2158 
2160 NTAPI
2163 );
2164 
2165 BOOLEAN
2166 NTAPI
2168  IN PMMSESSION InputSession OPTIONAL
2169 );
2170 
2171 VOID
2172 NTAPI
2174  VOID
2175 );
2176 
2177 VOID
2178 NTAPI
2180  IN PMM_SESSION_SPACE SessionGlobal
2181 );
2182 
2183 VOID
2184 NTAPI
2186  IN PEPROCESS NewProcess
2187 );
2188 
2189 NTSTATUS
2190 NTAPI
2192  IN PVOID StartVa,
2193  IN PVOID EndVa
2194 );
2195 
2196 ULONG
2197 NTAPI
2199  IN ULONG Protect
2200 );
2201 
2202 VOID
2203 NTAPI
2205  IN ULONG_PTR Va,
2206  IN ULONG_PTR EndingAddress,
2207  IN PMMVAD Vad
2208 );
2209 
2210 VOID
2211 NTAPI
2212 MiDeletePte(
2213  IN PMMPTE PointerPte,
2217 );
2218 
2219 ULONG
2220 NTAPI
2222  IN PVOID PageTableVirtualAddress,
2224 );
2225 
2226 ULONG
2227 NTAPI
2230  IN KIRQL OldIrql
2231 );
2232 
2233 VOID
2234 NTAPI
2237  IN PMMVAD Vad
2238 );
2239 
2241 NTAPI
2243  IN PMMVAD Vad,
2244  IN ULONG_PTR Vpn
2245 );
2246 
2247 VOID
2248 NTAPI
2250  PVOID ObjectBody
2251 );
2252 
2253 NTSTATUS
2254 NTAPI
2258  OUT PVOID MemoryInformation,
2259  IN SIZE_T MemoryInformationLength,
2261 );
2262 
2263 NTSTATUS
2264 NTAPI
2267 );
2268 
2269 POOL_TYPE
2270 NTAPI
2272  IN PVOID PoolAddress
2273 );
2274 
2275 VOID
2276 NTAPI
2278  IN PMMPDE PointerPde,
2279  IN PEPROCESS TargetProcess,
2280  IN KIRQL OldIrql
2281 );
2282 
2283 VOID
2284 NTAPI
2286  _In_ PVOID ImageBase);
2287 
2288 //
2289 // MiRemoveZeroPage will use inline code to zero out the page manually if only
2290 // free pages are available. In some scenarios, we don't/can't run that piece of
2291 // code and would rather only have a real zero page. If we can't have a zero page,
2292 // then we'd like to have our own code to grab a free page and zero it out, by
2293 // using MiRemoveAnyPage. This macro implements this.
2294 //
2296 PFN_NUMBER
2298 {
2300  return 0;
2301 }
2302 
2303 #if (_MI_PAGING_LEVELS == 2)
2305 BOOLEAN
2306 MiSynchronizeSystemPde(PMMPDE PointerPde)
2307 {
2308  MMPDE SystemPde;
2309  ULONG Index;
2310 
2311  /* Get the Index from the PDE */
2312  Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
2313 
2314  /* Copy the PDE from the double-mapped system page directory */
2315  SystemPde = MmSystemPagePtes[Index];
2316  *PointerPde = SystemPde;
2317 
2318  /* Make sure we re-read the PDE and PTE */
2320 
2321  /* Return, if we had success */
2322  return SystemPde.u.Hard.Valid != 0;
2323 }
2324 #endif
2325 
2326 /* EOF */
PVOID MiSessionImageStart
Definition: init.c:29
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
#define MI_IS_PAGE_TABLE_ADDRESS(Address)
Definition: miarm.h:173
PFN_NUMBER MmResidentAvailableAtInit
Definition: freelist.c:28
PFN_NUMBER MiNumberOfFreePages
Definition: mminit.c:384
struct _PHYSICAL_MEMORY_DESCRIPTOR * PPHYSICAL_MEMORY_DESCRIPTOR
MMSUPPORT Vm
Definition: miarm.h:506
ULONG MmProcessColorSeed
Definition: procsup.c:20
union _MM_SESSION_SPACE::@1814 u
FORCEINLINE VOID MI_ERASE_PTE(IN PMMPTE PointerPte)
Definition: miarm.h:989
ULONG_PTR MmSubsectionBase
Definition: section.c:132
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1010
Definition: bidi.c:433
ULONG SessionId
Definition: miarm.h:483
LIST_ENTRY ProcessList
Definition: miarm.h:484
VOID NTAPI MiInitializePfn(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN BOOLEAN Modified)
Definition: pfnlist.c:969
#define IN
Definition: typedefs.h:39
MMPTE ValidKernelPte
Definition: init.c:29
ASMGENDATA Table[]
Definition: genincdata.c:61
#define _MI_PAGING_LEVELS
Definition: mm.h:6
TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, IN ULONG_PTR BoundaryAddress, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PULONG_PTR Base, OUT PMMADDRESS_NODE *Parent)
Definition: vadnode.c:597
MMPFNLIST MmStandbyPageListByPriority[8]
Definition: pfnlist.c:44
MM_AVL_TABLE MmSectionBasedRoot
Definition: section.c:109
SIZE_T NonPageablePages
Definition: miarm.h:487
BOOLEAN MmMirroring
Definition: pfnlist.c:35
_MI_PFN_CACHE_ATTRIBUTE
Definition: miarm.h:414
USHORT PoolTagHash
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:396
PVOID Blink
Definition: miarm.h:438
PVOID PagedPoolStart
Definition: miarm.h:489
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PVOID MmNonPagedPoolStart
Definition: init.c:24
ULONG NTAPI MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress, IN KIRQL OldIrql)
Definition: virtual.c:257
PFN_NUMBER StartFrame
Definition: miarm.h:444
LONG ReferenceCount
Definition: miarm.h:477
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:604
PVOID MiSessionImageEnd
Definition: init.c:28
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:407
FORCEINLINE VOID MiUnlockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1215
BOOLEAN MmZeroPageFile
Definition: pagefile.c:54
#define MiAddressToPde(x)
Definition: mmx86.c:20
BOOLEAN NTAPI KeAreAllApcsDisabled(VOID)
Definition: apc.c:985
VOID NTAPI MiInitializePfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:1074
FORCEINLINE KIRQL MiAcquireExpansionLock(VOID)
Definition: miarm.h:1386
VOID NTAPI MiUnlinkPageFromList(IN PMMPFN Pfn)
Definition: pfnlist.c:264
PFN_NUMBER MmMinimumFreePages
Definition: mminit.c:314
_In_ ULONG Mode
Definition: hubbusif.h:303
PPHYSICAL_MEMORY_DESCRIPTOR NTAPI MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
Definition: mminit.c:1622
FORCEINLINE VOID MiDereferencePfnAndDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1470
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
SIZE_T MmMinimumNonPagedPoolSize
Definition: mminit.c:39
ULONG MmSystemPageColor
Definition: pfnlist.c:36
PKEVENT MiHighNonPagedPoolEvent
Definition: mminit.c:297
KGUARDED_MUTEX MmSectionBasedMutex
Definition: section.c:110
USHORT UsedPageTableEntries[768]
Definition: mmtypes.h:879
#define MI_MAKE_ACCESSED_PAGE(x)
Definition: mm.h:100
ULONG OwnsSystemWorkingSetShared
Definition: pstypes.h:1166
signed short * PSHORT
Definition: retypes.h:6
PMMPDE PageTables
Definition: miarm.h:513
_MMSYSTEM_PTE_POOL_TYPE
Definition: miarm.h:407
PMMPTE MmSystemPtesEnd[MaximumPtePoolTypes]
Definition: syspte.c:23
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
FORCEINLINE VOID MiUnlockProcessWorkingSetShared(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1191
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:210
ULONG PFN_COUNT
Definition: mmtypes.h:102
LONG ProcessReferenceToSession
Definition: miarm.h:500
#define TRUE
Definition: types.h:120
#define MI_MAKE_OWNER_PAGE(x)
Definition: mm.h:113
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
union _MMPTE::@2312 u
struct _MMCOLOR_TABLES MMCOLOR_TABLES
#define MI_IS_SESSION_ADDRESS(Address)
Definition: miarm.h:167
SIZE_T MmSessionViewSize
Definition: init.c:35
POOL_TYPE NTAPI MmDeterminePoolType(IN PVOID PoolAddress)
Definition: pool.c:406
VOID NTAPI MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
VOID NTAPI MiWriteProtectSystemImage(_In_ PVOID ImageBase)
Definition: sysldr.c:2446
FORCEINLINE BOOLEAN MI_IS_MAPPED_PTE(PMMPTE PointerPte)
Definition: miarm.h:902
ULONG MmMaxAdditionNonPagedPoolPerMb
Definition: mminit.c:42
enum _TABLE_SEARCH_RESULT TABLE_SEARCH_RESULT
ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes]
Definition: syspte.c:25
NTSTATUS NTAPI MiInitializeAndChargePfn(OUT PPFN_NUMBER PageFrameIndex, IN PMMPDE PointerPde, IN PFN_NUMBER ContainingPageFrame, IN BOOLEAN SessionAllocation)
Definition: pfnlist.c:1093
LONG NTSTATUS
Definition: precomp.h:26
PFN_NUMBER PageCount
Definition: miarm.h:425
PMMPTE MiSessionLastPte
Definition: mminit.c:146
VOID NTAPI MiDeleteARM3Section(PVOID ObjectBody)
Definition: section.c:3248
PFN_NUMBER MmHighMemoryThreshold
Definition: mminit.c:301
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2373
struct _MI_LARGE_PAGE_RANGES MI_LARGE_PAGE_RANGES
FORCEINLINE VOID MiReferenceUnusedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1642
PLDR_DATA_TABLE_ENTRY NTAPI MiLookupDataTableEntry(IN PVOID Address)
Definition: sysldr.c:3345
SIZE_T MmSessionImageSize
Definition: init.c:37
HARDWARE_PDE_ARMV6 TempPde
Definition: winldr.c:78
PMM_SESSION_SPACE MmSessionSpace
Definition: session.c:21
PMMPDE MiHighestUserPde
Definition: mminit.c:234
FORCEINLINE USHORT MiQueryPageTableReferences(IN PVOID Address)
Definition: miarm.h:1697
#define SESSION_POOL_LOOKASIDES
Definition: mm.h:84
KSPIN_LOCK MmExpansionLock
Definition: session.c:32
FORCEINLINE VOID MiLockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1100
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
RTL_BITMAP MiPfnBitMap
Definition: init.c:44
SIZE_T TotalBytes
Definition: miarm.h:327
PCHAR SystemSpaceViewStart
Definition: miarm.h:458
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1280
PFN_NUMBER NumberOfPages
Definition: miarm.h:431
PVOID MiSessionSpaceWs
Definition: mminit.c:130
DWORD LCID
Definition: nls.h:13
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor
Definition: init.c:47
ULONG SystemSpaceHashEntries
Definition: miarm.h:461
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
ULONG BitmapFailures
Definition: miarm.h:463
NTSTATUS NTAPI MiFindEmptyAddressRangeDownBasedTree(IN SIZE_T Length, IN ULONG_PTR BoundaryAddress, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PULONG_PTR Base)
Definition: vadnode.c:713
ULONG MmLargePageDriverBufferLength
Definition: largepag.c:25
NTSTATUS FASTCALL MiCheckPdeForPagedPool(IN PVOID Address)
Definition: pagfault.c:475
#define PPE_PER_PAGE
Definition: mm.h:22
LARGE_INTEGER LastProcessSwappedOutTime
Definition: miarm.h:485
VOID NTAPI MiSyncCachedRanges(VOID)
Definition: largepag.c:54
SIZE_T MmMinimumStackCommitInBytes
Definition: mminit.c:370
#define FASTCALL
Definition: nt_native.h:50
ULONG MmProductType
Definition: mminit.c:325
struct _MMVIEW * PMMVIEW
ULONG RunningDeAllocs
Definition: miarm.h:320
LIST_ENTRY ListHeads[POOL_LISTS_PER_PAGE]
Definition: miarm.h:329
#define MiGetPdeOffset(x)
Definition: mm.h:188
VOID NTAPI MiInsertBasedSection(IN PSECTION Section)
Definition: vadnode.c:345
FORCEINLINE VOID MiReferenceUsedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1597
BOOLEAN MmLargeSystemCache
Definition: mminit.c:340
ULONG MmLargeStackSize
Definition: mminit.c:262
SIZE_T MmAllocatedNonPagedPool
Definition: pool.c:26
VOID NTAPI MiInitializeSessionSpaceLayout(VOID)
Definition: init.c:63
UNICODE_STRING BaseName
Definition: miarm.h:404
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(IN PMMPTE NewPte, IN PVOID Segment)
Definition: miarm.h:866
PPOOL_TRACKER_TABLE PoolTrackTable
Definition: expool.c:41
PMMPFN MmPfnDatabase
Definition: freelist.c:24
KGUARDED_MUTEX SystemSpaceViewLock
Definition: miarm.h:456
VOID NTAPI MiDeletePte(IN PMMPTE PointerPte, IN PVOID VirtualAddress, IN PEPROCESS CurrentProcess, IN PMMPTE PrototypePte)
Definition: virtual.c:391
struct _POOL_HEADER * PPOOL_HEADER
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2233
MM_PAGED_POOL_INFO PagedPoolInfo
Definition: miarm.h:505
NTSTATUS NTAPI MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:695
enum _MI_PFN_CACHE_ATTRIBUTE MI_PFN_CACHE_ATTRIBUTE
PFN_NUMBER NTAPI MiRemoveZeroPage(IN ULONG Color)
Definition: pfnlist.c:531
MMPTE DemandZeroPte
Definition: init.c:37
SIZE_T MmSizeOfPagedPoolInBytes
Definition: miarm.h:592
PVOID MmNonPagedPoolEnd
Definition: mminit.c:99
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2046
FORCEINLINE BOOLEAN MI_IS_WS_UNSAFE(IN PEPROCESS Process)
Definition: miarm.h:1090
PMMPTE MmLastReservedMappingPte
Definition: hypermap.c:20
VOID NTAPI MiInitializeSessionWsSupport(VOID)
Definition: session.c:40
PVOID MmSessionBase
Definition: miarm.h:586
FORCEINLINE BOOLEAN MM_ANY_WS_LOCK_HELD(IN PETHREAD Thread)
Definition: miarm.h:1035
enum _MM_SYSTEM_SIZE MM_SYSTEMSIZE
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:679
struct _MMSESSION * PMMSESSION
SIZE_T MmSystemLockPagesCount
Definition: mdlsup.c:22
PDRIVER_UNLOAD Win32KDriverUnload
Definition: miarm.h:508
ULONG * PPFN_NUMBER
Definition: ke.h:8
struct _POOL_DESCRIPTOR * PPOOL_DESCRIPTOR
ULONG OwnsSessionWorkingSetShared
Definition: pstypes.h:1168
BOOLEAN MmDynamicPfn
Definition: pfnlist.c:34
ULONG MmSpecialPoolTag
Definition: pool.c:27
struct _POOL_TRACKER_BIG_PAGES POOL_TRACKER_BIG_PAGES
ULONG PFN_NUMBER
Definition: ke.h:8
LIST_ENTRY WsListEntry
Definition: miarm.h:501
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
SIZE_T MmMaximumNonPagedPoolInBytes
Definition: init.c:22
PETHREAD MiExpansionLockOwner
Definition: session.c:33
VOID FASTCALL MiSyncARM3WithROS(IN PVOID AddressStart, IN PVOID AddressEnd)
SIZE_T MmSystemViewSize
Definition: init.c:39
#define FALSE
Definition: types.h:117
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
ULONG MmVerifyDriverBufferLength
Definition: drvmgmt.c:24
LIST_ENTRY Links
Definition: miarm.h:403
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
PFN_NUMBER BasePage
Definition: miarm.h:424
#define InterlockedIncrementSizeT(a)
Definition: interlocked.h:220
PFN_NUMBER NTAPI MiFindContiguousPages(IN PFN_NUMBER LowestPfn, IN PFN_NUMBER HighestPfn, IN PFN_NUMBER BoundaryPfn, IN PFN_NUMBER SizeInPages, IN MEMORY_CACHING_TYPE CacheType)
Definition: contmem.c:22
FORCEINLINE VOID MI_WRITE_INVALID_PDE(IN PMMPDE PointerPde, IN MMPDE InvalidPde)
Definition: miarm.h:1018
long LONG
Definition: pedump.c:60
PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor
Definition: init.c:46
LARGE_INTEGER MmCriticalSectionTimeout
Definition: mminit.c:388
#define PDE_BASE
Definition: winldr.c:21
MMPDE ValidKernelPdeLocal
Definition: init.c:32
VOID NTAPI MiInitializeSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE PoolType)
Definition: syspte.c:399
PFN_NUMBER MmPlentyFreePages
Definition: mminit.c:322
PKEVENT MiLowNonPagedPoolEvent
Definition: mminit.c:296
struct _MMCOLOR_TABLES * PMMCOLOR_TABLES
struct _MI_LARGE_PAGE_DRIVER_ENTRY * PMI_LARGE_PAGE_DRIVER_ENTRY
FORCEINLINE BOOLEAN MiIsUserPde(PVOID Address)
Definition: miarm.h:718
PFN_NUMBER Flink
Definition: miarm.h:437
USHORT AllocatorBackTraceIndex
ULONG OwnsSessionWorkingSetExclusive
Definition: pstypes.h:1167
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1226
PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock
Definition: init.c:45
VOID NTAPI MiInitializeSessionIds(VOID)
Definition: session.c:117
FORCEINLINE PFN_NUMBER MiRemoveZeroPageSafe(IN ULONG Color)
Definition: miarm.h:2297
TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeInTree(IN SIZE_T Length, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PMMADDRESS_NODE *PreviousVad, OUT PULONG_PTR Base)
Definition: vadnode.c:502
const ULONG_PTR MmProtectToPteMask[32]
Definition: page.c:32
MM_PAGED_POOL_INFO MmPagedPoolInfo
Definition: pool.c:25
unsigned char BOOLEAN
POOL_DESCRIPTOR PagedPool
Definition: miarm.h:509
FORCEINLINE VOID MI_MAKE_TRANSITION_PTE(_Out_ PMMPTE NewPte, _In_ PFN_NUMBER Page, _In_ ULONG Protection)
Definition: miarm.h:912
VOID NTAPI MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde, IN PEPROCESS TargetProcess, IN KIRQL OldIrql)
Definition: virtual.c:2411
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE CacheType
Definition: mmfuncs.h:214
MMPTE MmDecommittedPte
Definition: init.c:44
PMMVAD NTAPI MiLocateAddress(IN PVOID VirtualAddress)
Definition: vadnode.c:48
static WCHAR Address[46]
Definition: ping.c:68
struct _MM_SESSION_SPACE_FLAGS MM_SESSION_SPACE_FLAGS
FORCEINLINE VOID MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, IN PMMPTE PointerPte)
Definition: miarm.h:837
#define KeLeaveGuardedRegion()
Definition: ke_x.h:63
PFN_NUMBER MiHighPagedPoolThreshold
Definition: mminit.c:303
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define _Out_
Definition: no_sal2.h:160
ULONG MmVerifyDriverLevel
Definition: drvmgmt.c:26
KEVENT MmZeroingPageEvent
Definition: zeropage.c:20
ULONG MmSecondaryColorMask
Definition: mminit.c:257
PVOID MiSystemViewStart
Definition: miarm.h:650
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1133
VOID NTAPI MiInsertPageInList(IN PMMPFNLIST ListHead, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:778
FORCEINLINE VOID MiUnlockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1285
SIZE_T NonPagedBytes
Definition: miarm.h:378
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1001
PFN_NUMBER NTAPI MiPagesInLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
struct _POOL_TRACKER_TABLE POOL_TRACKER_TABLE
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
VOID NTAPI MiReleaseSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:275
Definition: miarm.h:401
TABLE_SEARCH_RESULT NTAPI MiCheckForConflictingNode(IN ULONG_PTR StartVpn, IN ULONG_PTR EndVpn, IN PMM_AVL_TABLE Table, OUT PMMADDRESS_NODE *NodeOrParent)
Definition: vadnode.c:78
PMMVIEW SystemSpaceViewTable
Definition: miarm.h:459
ULONG SystemSpaceHashKey
Definition: miarm.h:462
ULONG NTAPI MiMakeSystemAddressValid(IN PVOID PageTableVirtualAddress, IN PEPROCESS CurrentProcess)
Definition: virtual.c:205
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS SkipBytes
Definition: mmfuncs.h:226
#define ULL(a, b)
Definition: format_msg.c:27
PMMPTE MmSharedUserDataPte
Definition: mminit.c:28
PVOID LockAddress
Definition: miarm.h:324
PMMCOLOR_TABLES MmFreePagesByColor[FreePageList+1]
Definition: mminit.c:286
MMPTE PrototypePte
Definition: init.c:40
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
FORCEINLINE ULONG_PTR MiDetermineUserGlobalPteMask(IN PVOID PointerPte)
Definition: miarm.h:737
ULONG PoolIndex
Definition: miarm.h:318
ULONG LongFlags
Definition: miarm.h:480
NTSTATUS NTAPI MiRosUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:4899
NTSTATUS NTAPI MiCheckSecuredVad(IN PMMVAD Vad, IN PVOID Base, IN SIZE_T Size, IN ULONG ProtectionMask)
Definition: vadnode.c:815
ULONG MmConsumedPoolPercentage
Definition: pool.c:28
PMMPTE MmSystemPtesStart[MaximumPtePoolTypes]
Definition: syspte.c:22
FORCEINLINE VOID MiLockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1145
PVOID MmHyperSpaceEnd
Definition: init.c:56
MMPDE DemandZeroPde
Definition: init.c:36
struct _MI_LARGE_PAGE_DRIVER_ENTRY MI_LARGE_PAGE_DRIVER_ENTRY
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:481
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:476
FORCEINLINE VOID MiDecrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:1685
ULONG CurrentProcess
Definition: shell.c:125
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS NTAPI MiInsertVadEx(_Inout_ PMMVAD Vad, _In_ ULONG_PTR *BaseAddress, _In_ SIZE_T ViewSize, _In_ ULONG_PTR HighestAddress, _In_ ULONG_PTR Alignment, _In_ ULONG AllocationType)
Definition: vadnode.c:204
NTSTATUS NTAPI MiUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN ULONG Flags)
Definition: section.c:817
PVOID MmNonPagedPoolExpansionStart
Definition: init.c:25
PMMPTE MmFirstReservedMappingPte
Definition: hypermap.c:20
#define ASSERT(a)
Definition: mode.c:45
FORCEINLINE VOID MiUnlockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, OUT PBOOLEAN Safe, OUT PBOOLEAN Shared)
Definition: miarm.h:1323
ULONG RunningAllocs
Definition: miarm.h:319
SIZE_T CommittedPages
Definition: miarm.h:488
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MI_IS_SESSION_PTE(Pte)
Definition: miarm.h:170
ULONG ExpNumberOfPagedPools
Definition: expool.c:33
struct _MM_SESSION_SPACE MM_SESSION_SPACE
INT POOL_TYPE
Definition: typedefs.h:78
_In_ WDFCOLLECTION _In_ ULONG Index
BOOLEAN NTAPI MiInitializeSystemSpaceMap(IN PMMSESSION InputSession OPTIONAL)
Definition: section.c:240
MMSESSION Session
Definition: miarm.h:503
CSHORT Type
Definition: mm.h:200
ULONG64 Valid
Definition: mmtypes.h:150
LONG PendingFreeDepth
Definition: miarm.h:326
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ULONG MmMaximumNonPagedPoolPercent
Definition: init.c:20
enum _MMSYSTEM_PTE_POOL_TYPE MMSYSTEM_PTE_POOL_TYPE
#define PTE_PER_PAGE
Definition: mm.h:20
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
struct _PHYSICAL_MEMORY_RUN PHYSICAL_MEMORY_RUN
LONG NonPagedFrees
Definition: miarm.h:377
#define InterlockedIncrement16
Definition: interlocked.h:206
NTSTATUS NTAPI MiQueryMemorySectionName(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID MemoryInformation, IN SIZE_T MemoryInformationLength, OUT PSIZE_T ReturnLength)
Definition: section.c:1892
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
#define _Inout_
Definition: no_sal2.h:162
C_ASSERT(sizeof(POOL_HEADER)==POOL_BLOCK_SIZE)
PFN_NUMBER MiHighNonPagedPoolThreshold
Definition: mminit.c:305
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
PVOID MiSessionPoolStart
Definition: init.c:32
struct _MMVIEW MMVIEW
#define KeEnterGuardedRegion()
Definition: ke_x.h:34
ULONG SessionPoolAllocationFailures[4]
Definition: miarm.h:494
PMMADDRESS_NODE NTAPI MiGetNextNode(IN PMMADDRESS_NODE Node)
Definition: vadnode.c:467
PVOID MmHighSectionBase
Definition: section.c:111
ULONG Threshold
Definition: miarm.h:323
SIZE_T Spare0
Definition: miarm.h:328
FORCEINLINE VOID MiLockProcessWorkingSetShared(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1122
PVOID MiSessionSpaceEnd
Definition: init.c:27
SIZE_T PagedBytes
Definition: miarm.h:381
ULONG TotalPages
Definition: miarm.h:321
ULONG_PTR MxPfnAllocation
Definition: init.c:43
SIZE_T MmBootImageSize
Definition: init.c:49
FORCEINLINE BOOLEAN MiIsUserPte(PVOID Address)
Definition: miarm.h:726
VOID NTAPI MiDecrementReferenceCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1222
#define PDE_TOP
Definition: mm.h:161
char * PBOOLEAN
Definition: retypes.h:11
FORCEINLINE PMMPFN MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
Definition: miarm.h:1429
PKGUARDED_MUTEX SystemSpaceViewLockPointer
Definition: miarm.h:457
PFN_NUMBER MmLowMemoryThreshold
Definition: mminit.c:300
PVOID PagedPoolEnd
Definition: miarm.h:490
KGUARDED_MUTEX PagedPoolMutex
Definition: miarm.h:504
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
PCONTROL_AREA ControlArea
Definition: miarm.h:451
PFN_NUMBER MmMaximumNonPagedPoolInPages
Definition: mminit.c:30
PMMPTE MiSessionImagePteStart
Definition: mminit.c:143
FORCEINLINE VOID MiDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1440
ULONG NTAPI MiMakeProtectionMask(IN ULONG Protect)
Definition: section.c:158
BOOLEAN MmMakeLowMemory
Definition: sysldr.c:46
SLIST_HEADER MmDeadStackSListHead
Definition: procsup.c:23
Definition: mm.h:311
Definition: btrfs_drv.h:1922
ULONG MmMinAdditionNonPagedPoolPerMb
Definition: mminit.c:40
VOID NTAPI MiComputeColorInformation(VOID)
Definition: mminit.c:508
const ULONG MmProtectToValue[32]
Definition: page.c:81
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:119
struct _PHYSICAL_MEMORY_RUN * PPHYSICAL_MEMORY_RUN
ULONG OwnsSystemWorkingSetExclusive
Definition: pstypes.h:1165
#define _1MB
Definition: miarm.h:15
ULONG MmSecondaryColors
Definition: mminit.c:256
LIST_HEAD(acpi_bus_event_list)
struct _MI_LARGE_PAGE_RANGES * PMI_LARGE_PAGE_RANGES
BOOLEAN MmProtectFreedNonPagedPool
Definition: pool.c:29
VOID NTAPI ExInitializePoolDescriptor(IN PPOOL_DESCRIPTOR PoolDescriptor, IN POOL_TYPE PoolType, IN ULONG PoolIndex, IN ULONG Threshold, IN PVOID PoolLock)
Definition: expool.c:958
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326
LIST_ENTRY ImageList
Definition: miarm.h:495
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG AllocationType
Definition: mmfuncs.h:404
PEPROCESS LastProcess
Definition: miarm.h:499
LIST_ENTRY MmWorkingSetExpansionHead
Definition: session.c:30
VOID NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table)
Definition: vadnode.c:360
enum _MI_PFN_CACHE_ATTRIBUTE * PMI_PFN_CACHE_ATTRIBUTE
ULONG MmNumberOfSystemPtes
Definition: init.c:42
ULONG_PTR Long
Definition: mmtypes.h:215
PVOID MmPagedPoolStart
Definition: miarm.h:581
PFN_NUMBER MiLowPagedPoolThreshold
Definition: mminit.c:302
NTSTATUS NTAPI MiSessionCommitPageTables(IN PVOID StartVa, IN PVOID EndVa)
Definition: section.c:935
#define MM_EXECUTE_READWRITE
Definition: miarm.h:45
PFN_COUNT NTAPI MiDeleteSystemPageableVm(IN PMMPTE PointerPte, IN PFN_NUMBER PageCount, IN ULONG Flags, OUT PPFN_NUMBER ValidPages)
Definition: virtual.c:297
FORCEINLINE VOID MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte, IN PMMPTE MappingPte, IN ULONG_PTR ProtectionMask, IN PFN_NUMBER PageFrameNumber)
Definition: miarm.h:813
PVOID NTAPI MiCheckForContiguousMemory(IN PVOID BaseAddress, IN PFN_NUMBER BaseAddressPages, IN PFN_NUMBER SizeInPages, IN PFN_NUMBER LowestPfn, IN PFN_NUMBER HighestPfn, IN PFN_NUMBER BoundaryPfn, IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute)
Definition: contmem.c:214
ULONG TotalBigPages
Definition: miarm.h:322
PVOID PendingFrees
Definition: miarm.h:325
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _In_
Definition: no_sal2.h:158
VOID NTAPI MiDeleteVirtualAddresses(IN ULONG_PTR Va, IN ULONG_PTR EndingAddress, IN PMMVAD Vad)
Definition: virtual.c:540
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:475
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1079
FORCEINLINE VOID MiLockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, IN BOOLEAN Safe, IN BOOLEAN Shared)
Definition: miarm.h:1356
ULONG_PTR SIZE_T
Definition: typedefs.h:80
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define SYSTEM_PD_SIZE
Definition: miarm.h:28
FORCEINLINE VOID MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte, IN MMPTE InvalidPte)
Definition: miarm.h:975
WCHAR MmLargePageDriverBuffer[512]
Definition: largepag.c:24
PSUBSECTION NTAPI MiLocateSubsection(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: section.c:570
KEVENT AttachEvent
Definition: miarm.h:498
MMPTE HyperTemplatePte
Definition: hypermap.c:22
struct _MMSESSION MMSESSION
PRTL_BITMAP SystemSpaceBitMap
Definition: miarm.h:464
SIZE_T MmDefaultMaximumNonPagedPool
Definition: mminit.c:41
ULONG MmVerifyDriverBufferType
Definition: drvmgmt.c:25
USHORT PreviousSize
POOL_TYPE PoolType
Definition: miarm.h:317
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS HighAddress
Definition: mmfuncs.h:226
unsigned short USHORT
Definition: pedump.c:61
LIST_ENTRY MmProcessList
Definition: largepag.c:20
SIZE_T MmAllocationFragment
Definition: mminit.c:352
PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
PMMPTE MiFirstReservedZeroingPte
Definition: hypermap.c:21
SIZE_T MmSessionSize
Definition: init.c:34
BOOLEAN MiLargePageAllDrivers
Definition: largepag.c:27
ULONG NTAPI MiGetPageProtection(IN PMMPTE PointerPte)
Definition: virtual.c:1369
PMMWSLE Wsle
Definition: miarm.h:507
#define MI_IS_ROS_PFN(x)
Definition: miarm.h:1079
Definition: miarm.h:448
NTSTATUS NTAPI MiInitializeSessionPool(VOID)
Definition: pool.c:1280
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define FORCEINLINE
Definition: wdftypes.h:67
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
LONG ResidentProcessCount
Definition: miarm.h:493
VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID)
Definition: pool.c:184
PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE]
Definition: init.c:40
MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType]
Definition: iosup.c:27
ULONG OwnsProcessWorkingSetShared
Definition: pstypes.h:1164
VOID NTAPI InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold)
Definition: expool.c:1009
BOOLEAN NTAPI MiInitializeMemoryEvents(VOID)
Definition: mminit.c:1339
VOID NTAPI MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
PPOOL_DESCRIPTOR ExpPagedPoolDescriptor[16+1]
Definition: expool.c:35
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
VOID NTAPI MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:672
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1399
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define InterlockedCompareExchange16
Definition: interlocked.h:109
PKEVENT MiLowPagedPoolEvent
Definition: mminit.c:294
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
VOID NTAPI MiInitializePoolEvents(VOID)
Definition: pool.c:201
SIZE_T MmSessionPoolSize
Definition: init.c:36
#define DPRINT1
Definition: precomp.h:8
#define POOL_LISTS_PER_PAGE
Definition: miarm.h:277
SIZE_T MmSizeOfNonPagedPoolInBytes
Definition: init.c:21
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:492
PVOID MmPagedPoolEnd
Definition: miarm.h:582
WCHAR MmVerifyDriverBuffer[512]
Definition: drvmgmt.c:23
POOL_DESCRIPTOR NonPagedPoolDescriptor
Definition: expool.c:34
struct _MM_SESSION_SPACE * PMM_SESSION_SPACE
FORCEINLINE BOOLEAN MiIsMemoryTypeFree(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:669
NTSTATUS NTAPI MiRosProtectVirtualMemory(IN PEPROCESS Process, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T NumberOfBytesToProtect, IN ULONG NewAccessProtection, OUT PULONG OldAccessProtection OPTIONAL)
Definition: virtual.c:2092
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI MiSessionAddProcess(IN PEPROCESS NewProcess)
Definition: session.c:427
LONG NonPagedAllocs
Definition: miarm.h:376
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:959
MMSUPPORT MmSystemCacheWs
Definition: init.c:55
#define OUT
Definition: typedefs.h:40
PVOID MiSessionPoolEnd
Definition: init.c:31
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1187
VOID NTAPI MiInitializePfnAndMakePteValid(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: pfnlist.c:1036
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:22
FORCEINLINE VOID MiIncrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:1673
PKEVENT MiHighPagedPoolEvent
Definition: mminit.c:295
PMMWSL MmSystemCacheWorkingSetList
Definition: mminit.c:174
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI MiInitializeColorTables(VOID)
Definition: mminit.c:562
LIST_ENTRY MiLargePageDriverList
Definition: largepag.c:26
ULONG64 LargePage
Definition: mmtypes.h:165
#define ULONG_PTR
Definition: config.h:101
PMMADDRESS_NODE NTAPI MiGetPreviousNode(IN PMMADDRESS_NODE Node)
Definition: vadnode.c:431
uint32_t * PULONG_PTR
Definition: typedefs.h:65
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
CSHORT Size
Definition: mm.h:201
struct _POOL_TRACKER_BIG_PAGES * PPOOL_TRACKER_BIG_PAGES
VOID NTAPI MiRemoveMappedView(IN PEPROCESS CurrentProcess, IN PMMVAD Vad)
Definition: section.c:780
ULONG_PTR Entry
Definition: miarm.h:450
BOOLEAN NTAPI MiIsPfnInUse(IN PMMPFN Pfn1)
Definition: freelist.c:142
ULONG AttachCount
Definition: miarm.h:497
PFN_NUMBER MiLowNonPagedPoolThreshold
Definition: mminit.c:304
KGUARDED_MUTEX MmPagedPoolMutex
Definition: pool.c:24
VOID NTAPI MiInsertVad(_Inout_ PMMVAD Vad, _Inout_ PMM_AVL_TABLE VadRoot)
PFN_NUMBER Count
Definition: miarm.h:439
#define InterlockedDecrementSizeT(a)
Definition: interlocked.h:153
ULONG OwnsProcessWorkingSetExclusive
Definition: pstypes.h:1163
PMMWSL MmWorkingSetList
Definition: procsup.c:21
VOID NTAPI MiInsertNode(IN PMM_AVL_TABLE Table, IN PMMADDRESS_NODE NewNode, PMMADDRESS_NODE Parent, TABLE_SEARCH_RESULT Result)
ULONG MmCritsectTimeoutSeconds
Definition: mminit.c:387
struct _POOL_HEADER POOL_HEADER
#define POOL_BLOCK_SIZE
Definition: miarm.h:275
FORCEINLINE VOID MiReferenceProbedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1542
PVOID MmSystemCacheStart
Definition: init.c:53
struct _PHYSICAL_MEMORY_DESCRIPTOR PHYSICAL_MEMORY_DESCRIPTOR
PFN_NUMBER MmSizeOfPagedPoolInPages
Definition: mminit.c:111
PKEVENT MiLowMemoryEvent
Definition: mminit.c:292
FORCEINLINE VOID MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte, IN PMMPTE MappingPte, IN ULONG_PTR ProtectionMask, IN PFN_NUMBER PageFrameNumber)
Definition: miarm.h:774
PMMPTE MiSessionBasePte
Definition: mminit.c:145
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1241
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1650
PMMPTE MiHighestUserPte
Definition: mminit.c:233
MMPTE ValidKernelPteLocal
Definition: init.c:33
#define KeGetCurrentThread
Definition: hal.h:44
MMPDE ValidKernelPde
Definition: init.c:28
struct _POOL_TRACKER_TABLE * PPOOL_TRACKER_TABLE
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
ULONG SystemSpaceHashSize
Definition: miarm.h:460
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE
KGUARDED_MUTEX MmSectionCommitMutex
Definition: section.c:108
VOID NTAPI MiInitializeNonPagedPool(VOID)
Definition: pool.c:276
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:928
FORCEINLINE VOID MI_UPDATE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:960
FORCEINLINE BOOLEAN MI_WS_OWNER(IN PEPROCESS Process)
Definition: miarm.h:1051
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:4135
PKEVENT MiHighMemoryEvent
Definition: mminit.c:293
PMMPDE PagedPoolBasePde
Definition: miarm.h:491
PFN_NUMBER LastFrame
Definition: miarm.h:445
PFN_NUMBER MmTotalSystemDriverPages
Definition: sysldr.c:41
VOID NTAPI MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry)
Definition: pfnlist.c:137
PVOID MmSystemCacheEnd
Definition: init.c:54
#define APC_LEVEL
Definition: env_spec_w32.h:695
BOOLEAN MmEnforceWriteProtection
Definition: sysldr.c:47
unsigned short * PUSHORT
Definition: retypes.h:2
LONG ImageLoadingCount
Definition: miarm.h:522
PMDL NTAPI MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes, IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute, IN ULONG Flags)
Definition: freelist.c:150
base of all file and directory entries
Definition: entries.h:82
BOOLEAN MmTrackLockedPages
Definition: mdlsup.c:21
FORCEINLINE VOID MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte, IN PMMPTE MappingPte, IN ULONG_PTR ProtectionMask, IN PFN_NUMBER PageFrameNumber)
Definition: miarm.h:797
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_ SIZE_T TotalBytes
Definition: mmfuncs.h:226
FORCEINLINE VOID MiUnlockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1170
PMMPDE MmSystemPagePtes
Definition: init.c:41
FORCEINLINE PMMPTE MI_GET_PROTOTYPE_PTE_FOR_VPN(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: miarm.h:1412
ULONG PageFrameNumber
Definition: mmtypes.h:109
Definition: dlist.c:348
PFN_NUMBER SessionPageDirectoryIndex
Definition: miarm.h:486
Definition: mm.h:375
PVOID MiSessionViewStart
Definition: init.c:30
BOOLEAN MmTrackPtes
Definition: mdlsup.c:20
FORCEINLINE BOOLEAN MiIsRosSectionObject(IN PVOID Section)
Definition: miarm.h:1072
struct _POOL_DESCRIPTOR POOL_DESCRIPTOR
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PVOID MmNonPagedSystemStart
Definition: miarm.h:583
PMMPTE MiSessionImagePteEnd
Definition: mminit.c:144