ReactOS  0.4.15-dev-2504-g2b52f3b
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 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #define MI_LOWEST_VAD_ADDRESS (PVOID)MM_LOWEST_USER_ADDRESS
16 
17 /* Make the code cleaner with some definitions for size multiples */
18 #define _1KB (1024u)
19 #define _1MB (1024 * _1KB)
20 #define _1GB (1024 * _1MB)
21 
22 /* Everyone loves 64K */
23 #define _64K (64 * _1KB)
24 
25 /* Size of a page table */
26 #define PT_SIZE (PTE_PER_PAGE * sizeof(MMPTE))
27 
28 /* Size of a page directory */
29 #define PD_SIZE (PDE_PER_PAGE * sizeof(MMPDE))
30 
31 /* Size of all page directories for a process */
32 #define SYSTEM_PD_SIZE (PPE_PER_PAGE * PD_SIZE)
33 #ifdef _M_IX86
35 #endif
36 
37 //
38 // Protection Bits part of the internal memory manager Protection Mask, from:
39 // http://reactos.org/wiki/Techwiki:Memory_management_in_the_Windows_XP_kernel
40 // https://www.reactos.org/wiki/Techwiki:Memory_Protection_constants
41 // and public assertions.
42 //
43 #define MM_ZERO_ACCESS 0
44 #define MM_READONLY 1
45 #define MM_EXECUTE 2
46 #define MM_EXECUTE_READ 3
47 #define MM_READWRITE 4
48 #define MM_WRITECOPY 5
49 #define MM_EXECUTE_READWRITE 6
50 #define MM_EXECUTE_WRITECOPY 7
51 #define MM_PROTECT_ACCESS 7
52 
53 //
54 // These are flags on top of the actual protection mask
55 //
56 #define MM_NOCACHE 0x08
57 #define MM_GUARDPAGE 0x10
58 #define MM_WRITECOMBINE 0x18
59 #define MM_PROTECT_SPECIAL 0x18
60 
61 //
62 // These are special cases
63 //
64 #define MM_DECOMMIT (MM_ZERO_ACCESS | MM_GUARDPAGE)
65 #define MM_NOACCESS (MM_ZERO_ACCESS | MM_WRITECOMBINE)
66 #define MM_OUTSWAPPED_KSTACK (MM_EXECUTE_WRITECOPY | MM_WRITECOMBINE)
67 #define MM_INVALID_PROTECTION 0xFFFFFFFF
68 
69 //
70 // Specific PTE Definitions that map to the Memory Manager's Protection Mask Bits
71 // The Memory Manager's definition define the attributes that must be preserved
72 // and these PTE definitions describe the attributes in the hardware sense. This
73 // helps deal with hardware differences between the actual boolean expression of
74 // the argument.
75 //
76 // For example, in the logical attributes, we want to express read-only as a flag
77 // but on x86, it is writability that must be set. On the other hand, on x86, just
78 // like in the kernel, it is disabling the caches that requires a special flag,
79 // while on certain architectures such as ARM, it is enabling the cache which
80 // requires a flag.
81 //
82 #if defined(_M_IX86)
83 //
84 // Access Flags
85 //
86 #define PTE_READONLY 0 // Doesn't exist on x86
87 #define PTE_EXECUTE 0 // Not worrying about NX yet
88 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
89 #define PTE_READWRITE 0x2
90 #define PTE_WRITECOPY 0x200
91 #define PTE_EXECUTE_READWRITE 0x2 // Not worrying about NX yet
92 #define PTE_EXECUTE_WRITECOPY 0x200
93 #define PTE_PROTOTYPE 0x400
94 
95 //
96 // State Flags
97 //
98 #define PTE_VALID 0x1
99 #define PTE_ACCESSED 0x20
100 #define PTE_DIRTY 0x40
101 
102 //
103 // Cache flags
104 //
105 #define PTE_ENABLE_CACHE 0
106 #define PTE_DISABLE_CACHE 0x10
107 #define PTE_WRITECOMBINED_CACHE 0x10
108 #define PTE_PROTECT_MASK 0x612
109 #elif defined(_M_AMD64)
110 //
111 // Access Flags
112 //
113 #define PTE_READONLY 0x8000000000000000ULL
114 #define PTE_EXECUTE 0x0000000000000000ULL
115 #define PTE_EXECUTE_READ PTE_EXECUTE /* EXECUTE implies READ on x64 */
116 #define PTE_READWRITE 0x8000000000000002ULL
117 #define PTE_WRITECOPY 0x8000000000000200ULL
118 #define PTE_EXECUTE_READWRITE 0x0000000000000002ULL
119 #define PTE_EXECUTE_WRITECOPY 0x0000000000000200ULL
120 #define PTE_PROTOTYPE 0x0000000000000400ULL
121 
122 //
123 // State Flags
124 //
125 #define PTE_VALID 0x0000000000000001ULL
126 #define PTE_ACCESSED 0x0000000000000020ULL
127 #define PTE_DIRTY 0x0000000000000040ULL
128 
129 //
130 // Cache flags
131 //
132 #define PTE_ENABLE_CACHE 0x0000000000000000ULL
133 #define PTE_DISABLE_CACHE 0x0000000000000010ULL
134 #define PTE_WRITECOMBINED_CACHE 0x0000000000000010ULL
135 #define PTE_PROTECT_MASK 0x8000000000000612ULL
136 #elif defined(_M_ARM)
137 #define PTE_READONLY 0x200
138 #define PTE_EXECUTE 0 // Not worrying about NX yet
139 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
140 #define PTE_READWRITE 0 // Doesn't exist on ARM
141 #define PTE_WRITECOPY 0 // Doesn't exist on ARM
142 #define PTE_EXECUTE_READWRITE 0 // Not worrying about NX yet
143 #define PTE_EXECUTE_WRITECOPY 0 // Not worrying about NX yet
144 #define PTE_PROTOTYPE 0x400 // Using the Shared bit
145 
146 //
147 // Cache flags
148 //
149 #define PTE_ENABLE_CACHE 0
150 #define PTE_DISABLE_CACHE 0x10
151 #define PTE_WRITECOMBINED_CACHE 0x10
152 #define PTE_PROTECT_MASK 0x610
153 #else
154 #error Define these please!
155 #endif
156 
157 //
158 // Mask for image section page protection
159 //
160 #define IMAGE_SCN_PROTECTION_MASK (IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE)
161 
162 extern const ULONG_PTR MmProtectToPteMask[32];
163 extern const ULONG MmProtectToValue[32];
164 
165 //
166 // Assertions for session images, addresses, and PTEs
167 //
168 #define MI_IS_SESSION_IMAGE_ADDRESS(Address) \
169  (((Address) >= MiSessionImageStart) && ((Address) < MiSessionImageEnd))
170 
171 #define MI_IS_SESSION_ADDRESS(Address) \
172  (((Address) >= MmSessionBase) && ((Address) < MiSessionSpaceEnd))
173 
174 #define MI_IS_SESSION_PTE(Pte) \
175  ((((PMMPTE)Pte) >= MiSessionBasePte) && (((PMMPTE)Pte) < MiSessionLastPte))
176 
177 #define MI_IS_PAGE_TABLE_ADDRESS(Address) \
178  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)PTE_TOP))
179 
180 #define MI_IS_SYSTEM_PAGE_TABLE_ADDRESS(Address) \
181  (((Address) >= (PVOID)MiAddressToPte(MmSystemRangeStart)) && ((Address) <= (PVOID)PTE_TOP))
182 
183 #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(Address) \
184  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)MmHyperSpaceEnd))
185 
186 //
187 // Creates a software PTE with the given protection
188 //
189 #define MI_MAKE_SOFTWARE_PTE(p, x) ((p)->u.Long = (x << MM_PTE_SOFTWARE_PROTECTION_BITS))
190 
191 //
192 // Marks a PTE as deleted
193 //
194 #define MI_SET_PFN_DELETED(x) ((x)->PteAddress = (PMMPTE)((ULONG_PTR)(x)->PteAddress | 1))
195 #define MI_IS_PFN_DELETED(x) ((ULONG_PTR)((x)->PteAddress) & 1)
196 
197 //
198 // Special values for LoadedImports
199 //
200 #ifdef _WIN64
201 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFFFFFFFFFEULL
202 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFFFFFFFFFFULL
203 #else
204 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFE
205 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFF
206 #endif
207 #define MM_SYSLDR_SINGLE_ENTRY 0x1
208 
209 //
210 // Number of initial session IDs
211 //
212 #define MI_INITIAL_SESSION_IDS 64
213 
214 #if defined(_M_IX86) || defined(_M_ARM)
215 //
216 // PFN List Sentinel
217 //
218 #define LIST_HEAD 0xFFFFFFFF
219 
220 //
221 // Because GCC cannot automatically downcast 0xFFFFFFFF to lesser-width bits,
222 // we need a manual definition suited to the number of bits in the PteFrame.
223 // This is used as a LIST_HEAD for the colored list
224 //
225 #define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
226 #elif defined(_M_AMD64)
227 #define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
228 #define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
229 #else
230 #error Define these please!
231 #endif
232 
233 //
234 // Special IRQL value (found in assertions)
235 //
236 #define MM_NOIRQL (KIRQL)0xFFFFFFFF
237 
238 //
239 // Returns the color of a page
240 //
241 #define MI_GET_PAGE_COLOR(x) ((x) & MmSecondaryColorMask)
242 #define MI_GET_NEXT_COLOR() (MI_GET_PAGE_COLOR(++MmSystemPageColor))
243 #define MI_GET_NEXT_PROCESS_COLOR(x) (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
244 
245 //
246 // Prototype PTEs that don't yet have a pagefile association
247 //
248 #ifdef _WIN64
249 #define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
250 #else
251 #define MI_PTE_LOOKUP_NEEDED 0xFFFFF
252 #endif
253 
254 //
255 // Number of session data and tag pages
256 //
257 #define MI_SESSION_DATA_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
258 #define MI_SESSION_TAG_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
259 
260 //
261 // Used by MiCheckSecuredVad
262 //
263 #define MM_READ_WRITE_ALLOWED 11
264 #define MM_READ_ONLY_ALLOWED 10
265 #define MM_NO_ACCESS_ALLOWED 01
266 #define MM_DELETE_CHECK 85
267 
268 //
269 // System views are binned into 64K chunks
270 //
271 #define MI_SYSTEM_VIEW_BUCKET_SIZE _64K
272 
273 //
274 // FIXFIX: These should go in ex.h after the pool merge
275 //
276 #ifdef _WIN64
277 #define POOL_BLOCK_SIZE 16
278 #else
279 #define POOL_BLOCK_SIZE 8
280 #endif
281 #define POOL_LISTS_PER_PAGE (PAGE_SIZE / POOL_BLOCK_SIZE)
282 #define BASE_POOL_TYPE_MASK 1
283 #define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + POOL_BLOCK_SIZE))
284 
285 //
286 // Pool debugging/analysis/tracing flags
287 //
288 #define POOL_FLAG_CHECK_TIMERS 0x1
289 #define POOL_FLAG_CHECK_WORKERS 0x2
290 #define POOL_FLAG_CHECK_RESOURCES 0x4
291 #define POOL_FLAG_VERIFIER 0x8
292 #define POOL_FLAG_CHECK_DEADLOCK 0x10
293 #define POOL_FLAG_SPECIAL_POOL 0x20
294 #define POOL_FLAG_DBGPRINT_ON_FAILURE 0x40
295 #define POOL_FLAG_CRASH_ON_FAILURE 0x80
296 
297 //
298 // BAD_POOL_HEADER codes during pool bugcheck
299 //
300 #define POOL_CORRUPTED_LIST 3
301 #define POOL_SIZE_OR_INDEX_MISMATCH 5
302 #define POOL_ENTRIES_NOT_ALIGNED_PREVIOUS 6
303 #define POOL_HEADER_NOT_ALIGNED 7
304 #define POOL_HEADER_IS_ZERO 8
305 #define POOL_ENTRIES_NOT_ALIGNED_NEXT 9
306 #define POOL_ENTRY_NOT_FOUND 10
307 
308 //
309 // BAD_POOL_CALLER codes during pool bugcheck
310 //
311 #define POOL_ENTRY_CORRUPTED 1
312 #define POOL_ENTRY_ALREADY_FREE 6
313 #define POOL_ENTRY_NOT_ALLOCATED 7
314 #define POOL_ALLOC_IRQL_INVALID 8
315 #define POOL_FREE_IRQL_INVALID 9
316 #define POOL_BILLED_PROCESS_INVALID 13
317 #define POOL_HEADER_SIZE_INVALID 32
318 
319 typedef struct _POOL_DESCRIPTOR
320 {
335 
336 typedef struct _POOL_HEADER
337 {
338  union
339  {
340  struct
341  {
342 #ifdef _WIN64
344  USHORT PoolIndex:8;
345  USHORT BlockSize:8;
346  USHORT PoolType:8;
347 #else
349  USHORT PoolIndex:7;
350  USHORT BlockSize:9;
351  USHORT PoolType:7;
352 #endif
353  };
354  ULONG Ulong1;
355  };
356 #ifdef _WIN64
357  ULONG PoolTag;
358 #endif
359  union
360  {
361 #ifdef _WIN64
362  PEPROCESS ProcessBilled;
363 #else
364  ULONG PoolTag;
365 #endif
366  struct
367  {
370  };
371  };
373 
376 
377 typedef struct _POOL_TRACKER_TABLE
378 {
387 
389 {
395 
400 
401 //
402 // END FIXFIX
403 //
404 
406 {
410 
412 {
417 
419 {
425 
426 typedef struct _PHYSICAL_MEMORY_RUN
427 {
431 
433 {
438 
439 typedef struct _MMCOLOR_TABLES
440 {
445 
446 typedef struct _MI_LARGE_PAGE_RANGES
447 {
451 
452 typedef struct _MMVIEW
453 {
456 } MMVIEW, *PMMVIEW;
457 
458 typedef struct _MMSESSION
459 {
470 
472 {
477 
478 typedef struct _MM_SESSION_SPACE
479 {
482  union
483  {
486  } u;
514 #if defined (_M_AMD64)
515  MMPDE PageDirectory;
516 #else
518 #endif
519 #if defined (_M_AMD64)
520  PMMPTE SpecialPoolFirstPte;
521  PMMPTE SpecialPoolLastPte;
522  PMMPTE NextPdeForSpecialPoolExpansion;
523  PMMPTE LastPdeForSpecialPoolExpansion;
524  PFN_NUMBER SpecialPagesInUse;
525 #endif
528 
530 extern MMPTE HyperTemplatePte;
531 extern MMPDE ValidKernelPde;
532 extern MMPTE ValidKernelPte;
535 extern MMPDE DemandZeroPde;
536 extern MMPTE DemandZeroPte;
537 extern MMPTE PrototypePte;
538 extern MMPTE MmDecommittedPte;
540 extern BOOLEAN MmZeroPageFile;
543 extern BOOLEAN MmTrackPtes;
544 extern BOOLEAN MmDynamicPfn;
545 extern BOOLEAN MmMirroring;
546 extern BOOLEAN MmMakeLowMemory;
552 extern WCHAR MmVerifyDriverBuffer[512];
553 extern WCHAR MmLargePageDriverBuffer[512];
565 extern PVOID MmNonPagedPoolEnd;
567 extern PVOID MmPagedPoolStart;
568 extern PVOID MmPagedPoolEnd;
569 extern PVOID MmSessionBase;
570 extern SIZE_T MmSessionSize;
575 extern SIZE_T MmBootImageSize;
587 extern PVOID MiSystemViewStart;
588 extern SIZE_T MmSystemViewSize;
590 extern PVOID MiSessionSpaceEnd;
593 extern PMMPTE MiSessionBasePte;
594 extern PMMPTE MiSessionLastPte;
596 extern PMMPDE MmSystemPagePtes;
598 extern PVOID MmSystemCacheEnd;
601 extern ULONG MmSpecialPoolTag;
602 extern PVOID MmHyperSpaceEnd;
608 extern ULONG MmSecondaryColors;
612 extern ULONG MmLargeStackSize;
615 extern ULONG MmProductType;
638 extern PVOID MiSessionImageEnd;
639 extern PMMPTE MiHighestUserPte;
640 extern PMMPDE MiHighestUserPde;
645 extern ULONG MmSystemPageColor;
647 extern PMMWSL MmWorkingSetList;
653 extern PVOID MiSessionPoolEnd; // 0xBE000000
654 extern PVOID MiSessionPoolStart; // 0xBD000000
655 extern PVOID MiSessionViewStart; // 0xBE000000
656 extern PVOID MiSessionSpaceWs;
661 extern PVOID MmHighSectionBase;
668 
670 BOOLEAN
672 {
673  return (WorkingSet != &MmSystemCacheWs) && !WorkingSet->Flags.SessionSpace;
674 }
675 
677 BOOLEAN
679 {
680  return ((MemoryType == LoaderFree) ||
681  (MemoryType == LoaderLoadedProgram) ||
682  (MemoryType == LoaderFirmwareTemporary) ||
683  (MemoryType == LoaderOsloaderStack));
684 }
685 
687 BOOLEAN
689 {
690  return ((MemoryType == LoaderFirmwarePermanent) ||
691  (MemoryType == LoaderSpecialMemory) ||
692  (MemoryType == LoaderHALCachedMemory) ||
693  (MemoryType == LoaderBBTMemory));
694 }
695 
696 #ifdef _M_AMD64
698 BOOLEAN
699 MiIsUserPxe(PVOID Address)
700 {
701  return ((ULONG_PTR)Address >> 7) == 0x1FFFFEDF6FB7DA0ULL;
702 }
703 
705 BOOLEAN
706 MiIsUserPpe(PVOID Address)
707 {
708  return ((ULONG_PTR)Address >> 16) == 0xFFFFF6FB7DA0ULL;
709 }
710 
712 BOOLEAN
714 {
715  return ((ULONG_PTR)Address >> 25) == 0x7FFFFB7DA0ULL;
716 }
717 
719 BOOLEAN
721 {
722  return ((ULONG_PTR)Address >> 34) == 0x3FFFFDA0ULL;
723 }
724 #else
726 BOOLEAN
728 {
729  return ((Address >= (PVOID)MiAddressToPde(NULL)) &&
731 }
732 
734 BOOLEAN
736 {
737  return (Address <= (PVOID)MiHighestUserPte);
738 }
739 #endif
740 
741 //
742 // Figures out the hardware bits for a PTE
743 //
745 ULONG_PTR
747 {
748  MMPTE TempPte;
749 
750  /* Start fresh */
751  TempPte.u.Long = 0;
752 
753  /* Make it valid and accessed */
754  TempPte.u.Hard.Valid = TRUE;
756 
757  /* Is this for user-mode? */
758  if (
759 #if (_MI_PAGING_LEVELS == 4)
760  MiIsUserPxe(PointerPte) ||
761 #endif
762 #if (_MI_PAGING_LEVELS >= 3)
763  MiIsUserPpe(PointerPte) ||
764 #endif
765  MiIsUserPde(PointerPte) ||
766  MiIsUserPte(PointerPte))
767  {
768  /* Set the owner bit */
770  }
771 
772  /* FIXME: We should also set the global bit */
773 
774  /* Return the protection */
775  return TempPte.u.Long;
776 }
777 
778 //
779 // Creates a valid kernel PTE with the given protection
780 //
782 VOID
784  IN PMMPTE MappingPte,
785  IN ULONG_PTR ProtectionMask,
786  IN PFN_NUMBER PageFrameNumber)
787 {
788  /* Only valid for kernel, non-session PTEs */
789  ASSERT(MappingPte > MiHighestUserPte);
790  ASSERT(!MI_IS_SESSION_PTE(MappingPte));
791  ASSERT((MappingPte < (PMMPTE)PDE_BASE) || (MappingPte > (PMMPTE)PDE_TOP));
792 
793  /* Start fresh */
794  *NewPte = ValidKernelPte;
795 
796  /* Set the protection and page */
797  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
798  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
799 }
800 
801 //
802 // Creates a valid PTE with the given protection
803 //
805 VOID
807  IN PMMPTE MappingPte,
808  IN ULONG_PTR ProtectionMask,
809  IN PFN_NUMBER PageFrameNumber)
810 {
811  /* Set the protection and page */
812  NewPte->u.Long = MiDetermineUserGlobalPteMask(MappingPte);
813  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
814  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
815 }
816 
817 //
818 // Creates a valid user PTE with the given protection
819 //
821 VOID
823  IN PMMPTE MappingPte,
824  IN ULONG_PTR ProtectionMask,
825  IN PFN_NUMBER PageFrameNumber)
826 {
827  /* Only valid for kernel, non-session PTEs */
828  ASSERT(MappingPte <= MiHighestUserPte);
829 
830  /* Start fresh */
831  NewPte->u.Long = 0;
832 
833  /* Set the protection and page */
834  NewPte->u.Hard.Valid = TRUE;
835  NewPte->u.Hard.Owner = TRUE;
836  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
837  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
838 }
839 
840 #ifndef _M_AMD64
841 //
842 // Builds a Prototype PTE for the address of the PTE
843 //
845 VOID
847  IN PMMPTE PointerPte)
848 {
850 
851  /* Mark this as a prototype */
852  NewPte->u.Long = 0;
853  NewPte->u.Proto.Prototype = 1;
854 
855  /*
856  * Prototype PTEs are only valid in paged pool by design, this little trick
857  * lets us only use 30 bits for the adress of the PTE, as long as the area
858  * stays 1024MB At most.
859  */
860  Offset = (ULONG_PTR)PointerPte - (ULONG_PTR)MmPagedPoolStart;
861 
862  /*
863  * 7 bits go in the "low" (but we assume the bottom 2 are zero)
864  * and the other 21 bits go in the "high"
865  */
866  NewPte->u.Proto.ProtoAddressLow = (Offset & 0x1FC) >> 2;
867  NewPte->u.Proto.ProtoAddressHigh = (Offset & 0x3FFFFE00) >> 9;
868 }
869 
870 //
871 // Builds a Subsection PTE for the address of the Segment
872 //
874 VOID
876  IN PVOID Segment)
877 {
879 
880  /* Mark this as a prototype */
881  NewPte->u.Long = 0;
882  NewPte->u.Subsect.Prototype = 1;
883 
884  /*
885  * Segments are only valid either in nonpaged pool. We store the 20 bit
886  * difference either from the top or bottom of nonpaged pool, giving a
887  * maximum of 128MB to each delta, meaning nonpaged pool cannot exceed
888  * 256MB.
889  */
890  if ((ULONG_PTR)Segment < ((ULONG_PTR)MmSubsectionBase + (128 * _1MB)))
891  {
893  NewPte->u.Subsect.WhichPool = PagedPool;
894  }
895  else
896  {
898  NewPte->u.Subsect.WhichPool = NonPagedPool;
899  }
900 
901  /*
902  * 4 bits go in the "low" (but we assume the bottom 3 are zero)
903  * and the other 20 bits go in the "high"
904  */
905  NewPte->u.Subsect.SubsectionAddressLow = (Offset & 0x78) >> 3;
906  NewPte->u.Subsect.SubsectionAddressHigh = (Offset & 0xFFFFF80) >> 7;
907 }
908 
910 BOOLEAN
912 {
914  return ((PointerPte->u.Long & 0xFFFFFC01) != 0);
915 }
916 
917 #endif
918 
920 VOID
923  _In_ ULONG Protection)
924 {
925  NewPte->u.Long = 0;
926  NewPte->u.Trans.Transition = 1;
927  NewPte->u.Trans.Protection = Protection;
928  NewPte->u.Trans.PageFrameNumber = Page;
929 }
930 
931 //
932 // Returns if the page is physically resident (ie: a large page)
933 // FIXFIX: CISC/x86 only?
934 //
936 BOOLEAN
938 {
939  PMMPDE PointerPde;
940 
941  /* Large pages are never paged out, always physically resident */
942  PointerPde = MiAddressToPde(Address);
943  return ((PointerPde->u.Hard.LargePage) && (PointerPde->u.Hard.Valid));
944 }
945 
946 //
947 // Writes a valid PTE
948 //
950 VOID
952  IN MMPTE TempPte)
953 {
954  /* Write the valid PTE */
955  ASSERT(PointerPte->u.Hard.Valid == 0);
956  ASSERT(TempPte.u.Hard.Valid == 1);
957 #if _M_AMD64
959  (TempPte.u.Hard.NoExecute == 0));
960 #endif
961  *PointerPte = TempPte;
962 }
963 
964 //
965 // Updates a valid PTE
966 //
968 VOID
970  IN MMPTE TempPte)
971 {
972  /* Write the valid PTE */
973  ASSERT(PointerPte->u.Hard.Valid == 1);
974  ASSERT(TempPte.u.Hard.Valid == 1);
975  ASSERT(PointerPte->u.Hard.PageFrameNumber == TempPte.u.Hard.PageFrameNumber);
976  *PointerPte = TempPte;
977 }
978 
979 //
980 // Writes an invalid PTE
981 //
983 VOID
985  IN MMPTE InvalidPte)
986 {
987  /* Write the invalid PTE */
988  ASSERT(InvalidPte.u.Hard.Valid == 0);
989  ASSERT(InvalidPte.u.Long != 0);
990  *PointerPte = InvalidPte;
991 }
992 
993 //
994 // Erase the PTE completely
995 //
997 VOID
998 MI_ERASE_PTE(IN PMMPTE PointerPte)
999 {
1000  /* Zero out the PTE */
1001  ASSERT(PointerPte->u.Long != 0);
1002  PointerPte->u.Long = 0;
1003 }
1004 
1005 //
1006 // Writes a valid PDE
1007 //
1009 VOID
1011  IN MMPDE TempPde)
1012 {
1013  /* Write the valid PDE */
1014  ASSERT(PointerPde->u.Hard.Valid == 0);
1015 #ifdef _M_AMD64
1016  ASSERT(PointerPde->u.Hard.NoExecute == 0);
1017 #endif
1018  ASSERT(TempPde.u.Hard.Valid == 1);
1019  *PointerPde = TempPde;
1020 }
1021 
1022 //
1023 // Writes an invalid PDE
1024 //
1026 VOID
1028  IN MMPDE InvalidPde)
1029 {
1030  /* Write the invalid PDE */
1031  ASSERT(InvalidPde.u.Hard.Valid == 0);
1032  ASSERT(InvalidPde.u.Long != 0);
1033 #ifdef _M_AMD64
1034  ASSERT(InvalidPde.u.Soft.Protection == MM_EXECUTE_READWRITE);
1035 #endif
1036  *PointerPde = InvalidPde;
1037 }
1038 
1039 //
1040 // Checks if the thread already owns a working set
1041 //
1043 BOOLEAN
1045 {
1046  /* If any of these are held, return TRUE */
1053 }
1054 
1055 //
1056 // Checks if the process owns the working set lock
1057 //
1059 BOOLEAN
1061 {
1062  /* Check if this process is the owner, and that the thread owns the WS */
1063  if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0)
1064  {
1065  DPRINT("Thread: %p is not an owner\n", PsGetCurrentThread());
1066  }
1067  if (KeGetCurrentThread()->ApcState.Process != &Process->Pcb)
1068  {
1069  DPRINT("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
1070  }
1071  return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
1072  ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||
1073  (PsGetCurrentThread()->OwnsProcessWorkingSetShared)));
1074 }
1075 
1076 //
1077 // New ARM3<->RosMM PAGE Architecture
1078 //
1080 BOOLEAN
1082 {
1083  return Section->u.Flags.filler;
1084 }
1085 
1086 #define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE)
1087 
1088 VOID
1089 NTAPI
1091  IN PMMPFN Pfn1,
1092  IN PFN_NUMBER PageFrameIndex
1093 );
1094 
1096 BOOLEAN
1098 {
1099  return (Process->Vm.Flags.AcquiredUnsafe == TRUE);
1100 }
1101 
1102 //
1103 // Locks the working set for the given process
1104 //
1106 VOID
1108  IN PETHREAD Thread)
1109 {
1110  /* Shouldn't already be owning the process working set */
1113 
1114  /* Block APCs, make sure that still nothing is already held */
1117 
1118  /* Lock the working set */
1119  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1120 
1121  /* Now claim that we own the lock */
1125 }
1126 
1128 VOID
1130  IN PETHREAD Thread)
1131 {
1132  /* Shouldn't already be owning the process working set */
1135 
1136  /* Block APCs, make sure that still nothing is already held */
1139 
1140  /* Lock the working set */
1141  ExAcquirePushLockShared(&Process->Vm.WorkingSetMutex);
1142 
1143  /* Now claim that we own the lock */
1148 }
1149 
1151 VOID
1153  IN PETHREAD Thread)
1154 {
1155  /* Shouldn't already be owning the process working set */
1157 
1158  /* APCs must be blocked, make sure that still nothing is already held */
1161 
1162  /* Lock the working set */
1163  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1164 
1165  /* Now claim that we own the lock */
1167  Process->Vm.Flags.AcquiredUnsafe = 1;
1170 }
1171 
1172 //
1173 // Unlocks the working set for the given process
1174 //
1176 VOID
1178  IN PETHREAD Thread)
1179 {
1180  /* Make sure we are the owner of a safe acquisition */
1183 
1184  /* The thread doesn't own it anymore */
1187 
1188  /* Release the lock and re-enable APCs */
1189  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1191 }
1192 
1193 //
1194 // Unlocks the working set for the given process
1195 //
1197 VOID
1199  IN PETHREAD Thread)
1200 {
1201  /* Make sure we are the owner of a safe acquisition (because shared) */
1204 
1205  /* Ensure we are in a shared acquisition */
1208 
1209  /* Don't claim the lock anylonger */
1211 
1212  /* Release the lock and re-enable APCs */
1213  ExReleasePushLockShared(&Process->Vm.WorkingSetMutex);
1215 }
1216 
1217 //
1218 // Unlocks the working set for the given process
1219 //
1221 VOID
1223  IN PETHREAD Thread)
1224 {
1225  /* Make sure we are the owner of an unsafe acquisition */
1230 
1231  /* No longer unsafe */
1232  Process->Vm.Flags.AcquiredUnsafe = 0;
1233 
1234  /* The thread doesn't own it anymore */
1237 
1238  /* Release the lock but don't touch APC state */
1239  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1241 }
1242 
1243 //
1244 // Locks the working set
1245 //
1247 VOID
1249  IN PMMSUPPORT WorkingSet)
1250 {
1251  /* Block APCs */
1253 
1254  /* Working set should be in global memory */
1255  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1256 
1257  /* Thread shouldn't already be owning something */
1259 
1260  /* Lock this working set */
1261  ExAcquirePushLockExclusive(&WorkingSet->WorkingSetMutex);
1262 
1263  /* Which working set is this? */
1264  if (WorkingSet == &MmSystemCacheWs)
1265  {
1266  /* Own the system working set */
1270  }
1271  else if (WorkingSet->Flags.SessionSpace)
1272  {
1273  /* Own the session working set */
1277  }
1278  else
1279  {
1280  /* Own the process working set */
1284  }
1285 }
1286 
1288 VOID
1291  _In_ PMMSUPPORT WorkingSet)
1292 {
1293  /* Block APCs */
1295 
1296  /* Working set should be in global memory */
1297  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1298 
1299  /* Thread shouldn't already be owning something */
1301 
1302  /* Lock this working set */
1303  ExAcquirePushLockShared(&WorkingSet->WorkingSetMutex);
1304 
1305  /* Which working set is this? */
1306  if (WorkingSet == &MmSystemCacheWs)
1307  {
1308  /* Own the system working set */
1312  }
1313  else if (WorkingSet->Flags.SessionSpace)
1314  {
1315  /* Own the session working set */
1319  }
1320  else
1321  {
1322  /* Own the process working set */
1326  }
1327 }
1328 
1329 //
1330 // Unlocks the working set
1331 //
1333 VOID
1335  IN PMMSUPPORT WorkingSet)
1336 {
1337  /* Working set should be in global memory */
1338  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1339 
1340  /* Which working set is this? */
1341  if (WorkingSet == &MmSystemCacheWs)
1342  {
1343  /* Release the system working set */
1347  }
1348  else if (WorkingSet->Flags.SessionSpace)
1349  {
1350  /* Release the session working set */
1354  }
1355  else
1356  {
1357  /* Release the process working set */
1361  }
1362 
1363  /* Release the working set lock */
1364  ExReleasePushLockExclusive(&WorkingSet->WorkingSetMutex);
1365 
1366  /* Unblock APCs */
1368 }
1369 
1371 VOID
1374  _In_ PMMSUPPORT WorkingSet)
1375 {
1376  /* Working set should be in global memory */
1377  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1378 
1379  /* Which working set is this? */
1380  if (WorkingSet == &MmSystemCacheWs)
1381  {
1382  /* Release the system working set */
1386  }
1387  else if (WorkingSet->Flags.SessionSpace)
1388  {
1389  /* Release the session working set */
1393  }
1394  else
1395  {
1396  /* Release the process working set */
1400  }
1401 
1402  /* Release the working set lock */
1403  ExReleasePushLockShared(&WorkingSet->WorkingSetMutex);
1404 
1405  /* Unblock APCs */
1407 }
1408 
1410 BOOLEAN
1413  _In_ PMMSUPPORT Vm)
1414 {
1415  /* Sanity check: No exclusive lock. */
1419 
1420  /* And it should have one and only one shared lock */
1422 
1423  /* Try. */
1425  return FALSE;
1426 
1427  if (Vm == &MmSystemCacheWs)
1428  {
1432  }
1433  else if (Vm->Flags.SessionSpace)
1434  {
1438  }
1439  else
1440  {
1444  }
1445 
1446  return TRUE;
1447 }
1448 
1450 VOID
1452  IN PETHREAD Thread,
1453  OUT PBOOLEAN Safe,
1454  OUT PBOOLEAN Shared)
1455 {
1457 
1458  /* Check if the current owner is unsafe */
1459  if (MI_IS_WS_UNSAFE(Process))
1460  {
1461  /* Release unsafely */
1463  *Safe = FALSE;
1464  *Shared = FALSE;
1465  }
1466  else if (Thread->OwnsProcessWorkingSetExclusive == 1)
1467  {
1468  /* Owner is safe and exclusive, release normally */
1470  *Safe = TRUE;
1471  *Shared = FALSE;
1472  }
1473  else
1474  {
1475  /* Owner is shared (implies safe), release normally */
1477  *Safe = TRUE;
1478  *Shared = TRUE;
1479  }
1480 }
1481 
1483 VOID
1485  IN PETHREAD Thread,
1486  IN BOOLEAN Safe,
1487  IN BOOLEAN Shared)
1488 {
1489  /* Check if this was a safe lock or not */
1490  if (Safe)
1491  {
1492  if (Shared)
1493  {
1494  /* Reacquire safely & shared */
1496  }
1497  else
1498  {
1499  /* Reacquire safely */
1501  }
1502  }
1503  else
1504  {
1505  /* Unsafe lock cannot be shared */
1506  ASSERT(Shared == FALSE);
1507  /* Reacquire unsafely */
1509  }
1510 }
1511 
1513 KIRQL
1515 {
1516  KIRQL OldIrql;
1517 
1522  return OldIrql;
1523 }
1524 
1526 VOID
1528 {
1533 }
1534 
1535 //
1536 // Returns the ProtoPTE inside a VAD for the given VPN
1537 //
1539 PMMPTE
1541  IN ULONG_PTR Vpn)
1542 {
1543  PMMPTE ProtoPte;
1544 
1545  /* Find the offset within the VAD's prototype PTEs */
1546  ProtoPte = Vad->FirstPrototypePte + (Vpn - Vad->StartingVpn);
1547  ASSERT(ProtoPte <= Vad->LastContiguousPte);
1548  return ProtoPte;
1549 }
1550 
1551 //
1552 // Returns the PFN Database entry for the given page number
1553 // Warning: This is not necessarily a valid PFN database entry!
1554 //
1556 PMMPFN
1558 {
1559  /* Get the entry */
1560  return &MmPfnDatabase[Pfn];
1561 };
1562 
1563 //
1564 // Drops a locked page without dereferencing it
1565 //
1567 VOID
1569 {
1570  /* This page shouldn't be locked, but it should be valid */
1571  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1572  ASSERT(Pfn1->u2.ShareCount == 0);
1573 
1574  /* Is this the last reference to the page */
1575  if (Pfn1->u3.e2.ReferenceCount == 1)
1576  {
1577  /* It better not be valid */
1578  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1579 
1580  /* Is it a prototype PTE? */
1581  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1582  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1583  {
1584  /* FIXME: We should return commit */
1585  DPRINT1("Not returning commit for prototype PTE\n");
1586  }
1587 
1588  /* Update the counter */
1590  }
1591 }
1592 
1593 //
1594 // Drops a locked page and dereferences it
1595 //
1597 VOID
1599 {
1600  USHORT RefCount, OldRefCount;
1601  PFN_NUMBER PageFrameIndex;
1602 
1603  /* Loop while we decrement the page successfully */
1604  do
1605  {
1606  /* There should be at least one reference */
1607  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1608  ASSERT(OldRefCount != 0);
1609 
1610  /* Are we the last one */
1611  if (OldRefCount == 1)
1612  {
1613  /* The page shoudln't be shared not active at this point */
1614  ASSERT(Pfn1->u3.e2.ReferenceCount == 1);
1615  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1616  ASSERT(Pfn1->u2.ShareCount == 0);
1617 
1618  /* Is it a prototype PTE? */
1619  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1620  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1621  {
1622  /* FIXME: We should return commit */
1623  DPRINT1("Not returning commit for prototype PTE\n");
1624  }
1625 
1626  /* Update the counter, and drop a reference the long way */
1628  PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
1629  MiDecrementReferenceCount(Pfn1, PageFrameIndex);
1630  return;
1631  }
1632 
1633  /* Drop a reference the short way, and that's it */
1634  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1635  OldRefCount - 1,
1636  OldRefCount);
1637  ASSERT(RefCount != 0);
1638  } while (OldRefCount != RefCount);
1639 
1640  /* If we got here, there should be more than one reference */
1641  ASSERT(RefCount > 1);
1642  if (RefCount == 2)
1643  {
1644  /* Is it still being shared? */
1645  if (Pfn1->u2.ShareCount >= 1)
1646  {
1647  /* Then it should be valid */
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  /* We don't handle ethis */
1655  ASSERT(FALSE);
1656  }
1657 
1658  /* Update the counter */
1660  }
1661  }
1662 }
1663 
1664 //
1665 // References a locked page and updates the counter
1666 // Used in MmProbeAndLockPages to handle different edge cases
1667 //
1669 VOID
1671 {
1672  USHORT RefCount, OldRefCount;
1673 
1674  /* Sanity check */
1675  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1676 
1677  /* Does ARM3 own the page? */
1678  if (MI_IS_ROS_PFN(Pfn1))
1679  {
1680  /* ReactOS Mm doesn't track share count */
1681  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1682  }
1683  else
1684  {
1685  /* On ARM3 pages, we should see a valid share count */
1686  ASSERT((Pfn1->u2.ShareCount != 0) && (Pfn1->u3.e1.PageLocation == ActiveAndValid));
1687 
1688  /* Is it a prototype PTE? */
1689  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1690  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1691  {
1692  /* FIXME: We should charge commit */
1693  DPRINT1("Not charging commit for prototype PTE\n");
1694  }
1695  }
1696 
1697  /* More locked pages! */
1699 
1700  /* Loop trying to update the reference count */
1701  do
1702  {
1703  /* Get the current reference count, make sure it's valid */
1704  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1705  ASSERT(OldRefCount != 0);
1706  ASSERT(OldRefCount < 2500);
1707 
1708  /* Bump it up by one */
1709  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1710  OldRefCount + 1,
1711  OldRefCount);
1712  ASSERT(RefCount != 0);
1713  } while (OldRefCount != RefCount);
1714 
1715  /* Was this the first lock attempt? If not, undo our bump */
1716  if (OldRefCount != 1) InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1717 }
1718 
1719 //
1720 // References a locked page and updates the counter
1721 // Used in all other cases except MmProbeAndLockPages
1722 //
1724 VOID
1726 {
1727  USHORT NewRefCount;
1728 
1729  /* Is it a prototype PTE? */
1730  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1731  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1732  {
1733  /* FIXME: We should charge commit */
1734  DPRINT1("Not charging commit for prototype PTE\n");
1735  }
1736 
1737  /* More locked pages! */
1739 
1740  /* Update the reference count */
1741  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1742  if (NewRefCount == 2)
1743  {
1744  /* Is it locked or shared? */
1745  if (Pfn1->u2.ShareCount)
1746  {
1747  /* It's shared, so make sure it's active */
1748  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1749  }
1750  else
1751  {
1752  /* It's locked, so we shouldn't lock again */
1754  }
1755  }
1756  else
1757  {
1758  /* Someone had already locked the page, so undo our bump */
1759  ASSERT(NewRefCount < 2500);
1761  }
1762 }
1763 
1764 //
1765 // References a locked page and updates the counter
1766 // Used in all other cases except MmProbeAndLockPages
1767 //
1769 VOID
1771 {
1772  USHORT NewRefCount;
1773 
1774  /* Make sure the page isn't used yet */
1775  ASSERT(Pfn1->u2.ShareCount == 0);
1776  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1777 
1778  /* Is it a prototype PTE? */
1779  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1780  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1781  {
1782  /* FIXME: We should charge commit */
1783  DPRINT1("Not charging commit for prototype PTE\n");
1784  }
1785 
1786  /* More locked pages! */
1788 
1789  /* Update the reference count */
1790  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1791  if (NewRefCount != 1)
1792  {
1793  /* Someone had already locked the page, so undo our bump */
1794  ASSERT(NewRefCount < 2500);
1796  }
1797 }
1798 
1800 VOID
1802 {
1803  PUSHORT RefCount;
1804 
1806 
1807  *RefCount += 1;
1808  ASSERT(*RefCount <= PTE_PER_PAGE);
1809 }
1810 
1812 VOID
1814 {
1815  PUSHORT RefCount;
1816 
1818 
1819  *RefCount -= 1;
1820  ASSERT(*RefCount < PTE_PER_PAGE);
1821 }
1822 
1824 USHORT
1826 {
1827  PUSHORT RefCount;
1828 
1830 
1831  return *RefCount;
1832 }
1833 
1834 BOOLEAN
1835 NTAPI
1837  IN ULONG Phase,
1838  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1839 );
1840 
1841 VOID
1842 NTAPI
1844 
1845 NTSTATUS
1846 NTAPI
1848  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1849 );
1850 
1851 VOID
1852 NTAPI
1854  VOID
1855 );
1856 
1857 VOID
1858 NTAPI
1860  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1861 );
1862 
1863 VOID
1864 NTAPI
1866  VOID
1867 );
1868 
1869 VOID
1870 NTAPI
1872  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1873 );
1874 
1875 VOID
1876 NTAPI
1878  VOID
1879 );
1880 
1881 VOID
1882 NTAPI
1884  VOID
1885 );
1886 
1887 BOOLEAN
1888 NTAPI
1890  VOID
1891 );
1892 
1893 PFN_NUMBER
1894 NTAPI
1896  IN PFN_NUMBER PageCount
1897 );
1898 
1900 NTAPI
1902  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1903  IN PBOOLEAN IncludeType
1904 );
1905 
1906 PFN_NUMBER
1907 NTAPI
1909  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1910  IN PBOOLEAN IncludeType
1911 );
1912 
1913 VOID
1914 FASTCALL
1916  IN PVOID AddressStart,
1917  IN PVOID AddressEnd
1918 );
1919 
1920 NTSTATUS
1921 NTAPI
1925  IN OUT PSIZE_T NumberOfBytesToProtect,
1926  IN ULONG NewAccessProtection,
1927  OUT PULONG OldAccessProtection OPTIONAL
1928 );
1929 
1930 NTSTATUS
1931 NTAPI
1933  IN ULONG FaultCode,
1934  IN PVOID Address,
1936  IN PVOID TrapInformation
1937 );
1938 
1939 NTSTATUS
1940 FASTCALL
1942  IN PVOID Address
1943 );
1944 
1945 VOID
1946 NTAPI
1948  VOID
1949 );
1950 
1951 VOID
1952 NTAPI
1954  VOID
1955 );
1956 
1957 VOID //
1958 NTAPI //
1959 InitializePool( //
1960  IN POOL_TYPE PoolType,// FIXFIX: This should go in ex.h after the pool merge
1961  IN ULONG Threshold //
1962 ); //
1963 
1964 // FIXFIX: THIS ONE TOO
1965 VOID
1966 NTAPI
1968  IN PPOOL_DESCRIPTOR PoolDescriptor,
1970  IN ULONG PoolIndex,
1971  IN ULONG Threshold,
1972  IN PVOID PoolLock
1973 );
1974 
1975 NTSTATUS
1976 NTAPI
1978  VOID
1979 );
1980 
1981 VOID
1982 NTAPI
1984  IN PMMPTE StartingPte,
1985  IN ULONG NumberOfPtes,
1987 );
1988 
1989 PMMPTE
1990 NTAPI
1992  IN ULONG NumberOfPtes,
1993  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1994 );
1995 
1996 VOID
1997 NTAPI
1999  IN PMMPTE StartingPte,
2000  IN ULONG NumberOfPtes,
2001  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
2002 );
2003 
2004 
2005 PFN_NUMBER
2006 NTAPI
2008  IN PFN_NUMBER LowestPfn,
2009  IN PFN_NUMBER HighestPfn,
2010  IN PFN_NUMBER BoundaryPfn,
2011  IN PFN_NUMBER SizeInPages,
2013 );
2014 
2015 PVOID
2016 NTAPI
2019  IN PFN_NUMBER BaseAddressPages,
2020  IN PFN_NUMBER SizeInPages,
2021  IN PFN_NUMBER LowestPfn,
2022  IN PFN_NUMBER HighestPfn,
2023  IN PFN_NUMBER BoundaryPfn,
2024  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute
2025 );
2026 
2027 PMDL
2028 NTAPI
2030  IN PHYSICAL_ADDRESS LowAddress,
2034  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
2035  IN ULONG Flags
2036 );
2037 
2038 VOID
2039 NTAPI
2041  IN PMMPFNLIST ListHead,
2042  IN PFN_NUMBER PageFrameIndex
2043 );
2044 
2045 VOID
2046 NTAPI
2048  IN PMMPFN Entry
2049 );
2050 
2051 VOID
2052 NTAPI
2054  IN PMMPFN Pfn
2055 );
2056 
2057 VOID
2058 NTAPI
2060  IN PFN_NUMBER PageFrameIndex,
2061  IN PMMPTE PointerPte,
2062  IN BOOLEAN Modified
2063 );
2064 
2065 NTSTATUS
2066 NTAPI
2068  OUT PPFN_NUMBER PageFrameIndex,
2069  IN PMMPDE PointerPde,
2070  IN PFN_NUMBER ContainingPageFrame,
2071  IN BOOLEAN SessionAllocation
2072 );
2073 
2074 VOID
2075 NTAPI
2077  IN PFN_NUMBER PageFrameIndex,
2078  IN PMMPTE PointerPte,
2079  IN MMPTE TempPte
2080 );
2081 
2082 VOID
2083 NTAPI
2085  IN PFN_NUMBER PageFrameIndex,
2086  IN PVOID PteAddress,
2087  IN PFN_NUMBER PteFrame
2088 );
2089 
2090 VOID
2091 NTAPI
2093  IN PMMPFN Pfn1,
2094  IN PFN_NUMBER PageFrameIndex
2095 );
2096 
2097 PFN_NUMBER
2098 NTAPI
2100  IN ULONG Color
2101 );
2102 
2103 PFN_NUMBER
2104 NTAPI
2106  IN ULONG Color
2107 );
2108 
2109 VOID
2110 NTAPI
2112  IN PFN_NUMBER PageFrameIndex
2113 );
2114 
2115 VOID
2116 NTAPI
2118  IN PFN_NUMBER PageFrameIndex
2119 );
2120 
2121 PFN_COUNT
2122 NTAPI
2124  IN PMMPTE PointerPte,
2125  IN PFN_NUMBER PageCount,
2126  IN ULONG Flags,
2127  OUT PPFN_NUMBER ValidPages
2128 );
2129 
2130 ULONG
2131 NTAPI
2133  IN PMMPTE PointerPte
2134 );
2135 
2137 NTAPI
2139  IN PVOID Address
2140 );
2141 
2142 VOID
2143 NTAPI
2145  VOID
2146 );
2147 
2148 VOID
2149 NTAPI
2151  VOID
2152 );
2153 
2154 VOID
2155 NTAPI
2157  VOID
2158 );
2159 
2160 BOOLEAN
2161 NTAPI
2162 MiIsPfnInUse(
2163  IN PMMPFN Pfn1
2164 );
2165 
2166 PMMVAD
2167 NTAPI
2170 );
2171 
2173 NTAPI
2175  IN ULONG_PTR StartVpn,
2176  IN ULONG_PTR EndVpn,
2178  OUT PMMADDRESS_NODE *NodeOrParent
2179 );
2180 
2182 NTAPI
2184  IN SIZE_T Length,
2185  IN ULONG_PTR BoundaryAddress,
2190 );
2191 
2192 NTSTATUS
2193 NTAPI
2195  IN SIZE_T Length,
2196  IN ULONG_PTR BoundaryAddress,
2200 );
2201 
2203 NTAPI
2205  IN SIZE_T Length,
2208  OUT PMMADDRESS_NODE *PreviousVad,
2210 );
2211 
2212 NTSTATUS
2213 NTAPI
2215  IN PMMVAD Vad,
2216  IN PVOID Base,
2217  IN SIZE_T Size,
2218  IN ULONG ProtectionMask
2219 );
2220 
2221 VOID
2222 NTAPI
2223 MiInsertVad(
2224  _Inout_ PMMVAD Vad,
2225  _Inout_ PMM_AVL_TABLE VadRoot);
2226 
2227 NTSTATUS
2228 NTAPI
2230  _Inout_ PMMVAD Vad,
2233  _In_ ULONG_PTR HighestAddress,
2236 
2237 VOID
2238 NTAPI
2240  IN PSECTION Section
2241 );
2242 
2243 NTSTATUS
2244 NTAPI
2248  IN ULONG Flags
2249 );
2250 
2251 NTSTATUS
2252 NTAPI
2256  IN BOOLEAN SkipDebuggerNotify
2257 );
2258 
2259 VOID
2260 NTAPI
2261 MiInsertNode(
2263  IN PMMADDRESS_NODE NewNode,
2266 );
2267 
2268 VOID
2269 NTAPI
2270 MiRemoveNode(
2273 );
2274 
2276 NTAPI
2279 );
2280 
2282 NTAPI
2285 );
2286 
2287 BOOLEAN
2288 NTAPI
2290  IN PMMSESSION InputSession OPTIONAL
2291 );
2292 
2293 VOID
2294 NTAPI
2296  VOID
2297 );
2298 
2299 VOID
2300 NTAPI
2302  IN PMM_SESSION_SPACE SessionGlobal
2303 );
2304 
2305 VOID
2306 NTAPI
2308  IN PEPROCESS NewProcess
2309 );
2310 
2311 NTSTATUS
2312 NTAPI
2314  IN PVOID StartVa,
2315  IN PVOID EndVa
2316 );
2317 
2318 ULONG
2319 NTAPI
2321  IN ULONG Protect
2322 );
2323 
2324 VOID
2325 NTAPI
2327  IN ULONG_PTR Va,
2328  IN ULONG_PTR EndingAddress,
2329  IN PMMVAD Vad
2330 );
2331 
2332 VOID
2333 NTAPI
2334 MiDeletePte(
2335  IN PMMPTE PointerPte,
2339 );
2340 
2341 ULONG
2342 NTAPI
2344  IN PVOID PageTableVirtualAddress,
2346 );
2347 
2348 ULONG
2349 NTAPI
2352  IN KIRQL OldIrql
2353 );
2354 
2355 VOID
2356 NTAPI
2359  IN PMMVAD Vad
2360 );
2361 
2363 NTAPI
2365  IN PMMVAD Vad,
2366  IN ULONG_PTR Vpn
2367 );
2368 
2369 VOID
2370 NTAPI
2372  PVOID ObjectBody
2373 );
2374 
2375 NTSTATUS
2376 NTAPI
2380  OUT PVOID MemoryInformation,
2381  IN SIZE_T MemoryInformationLength,
2383 );
2384 
2385 NTSTATUS
2386 NTAPI
2389 );
2390 
2391 VOID
2392 NTAPI
2394  IN PMMPDE PointerPde,
2395  IN PEPROCESS TargetProcess,
2396  IN KIRQL OldIrql
2397 );
2398 
2399 VOID
2400 NTAPI
2402  _In_ PVOID ImageBase);
2403 
2404 //
2405 // MiRemoveZeroPage will use inline code to zero out the page manually if only
2406 // free pages are available. In some scenarios, we don't/can't run that piece of
2407 // code and would rather only have a real zero page. If we can't have a zero page,
2408 // then we'd like to have our own code to grab a free page and zero it out, by
2409 // using MiRemoveAnyPage. This macro implements this.
2410 //
2412 PFN_NUMBER
2414 {
2416  return 0;
2417 }
2418 
2419 #if (_MI_PAGING_LEVELS == 2)
2421 BOOLEAN
2422 MiSynchronizeSystemPde(PMMPDE PointerPde)
2423 {
2424  MMPDE SystemPde;
2425  ULONG Index;
2426 
2427  /* Get the Index from the PDE */
2428  Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
2429 
2430  /* Copy the PDE from the double-mapped system page directory */
2431  SystemPde = MmSystemPagePtes[Index];
2432  *PointerPde = SystemPde;
2433 
2434  /* Make sure we re-read the PDE and PTE */
2436 
2437  /* Return, if we had success */
2438  return SystemPde.u.Hard.Valid != 0;
2439 }
2440 #endif
2441 
2442 #ifdef __cplusplus
2443 } // extern "C"
2444 #endif
2445 
2446 /* 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:177
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:510
ULONG MmProcessColorSeed
Definition: procsup.c:20
FORCEINLINE VOID MI_ERASE_PTE(IN PMMPTE PointerPte)
Definition: miarm.h:998
ULONG_PTR MmSubsectionBase
Definition: section.c:196
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1015
Definition: bidi.c:433
FORCEINLINE BOOLEAN MI_IS_PROCESS_WORKING_SET(PMMSUPPORT WorkingSet)
Definition: miarm.h:671
ULONG SessionId
Definition: miarm.h:487
LIST_ENTRY ProcessList
Definition: miarm.h:488
VOID NTAPI MiInitializePfn(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN BOOLEAN Modified)
Definition: pfnlist.c:968
#define IN
Definition: typedefs.h:39
MMPTE ValidKernelPte
Definition: init.c:29
union _MM_SESSION_SPACE::@1806 u
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:491
BOOLEAN MmMirroring
Definition: pfnlist.c:35
_MI_PFN_CACHE_ATTRIBUTE
Definition: miarm.h:418
USHORT PoolTagHash
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:395
PVOID Blink
Definition: miarm.h:442
PVOID PagedPoolStart
Definition: miarm.h:493
_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:448
LONG ReferenceCount
Definition: miarm.h:481
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:1222
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:1514
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:1598
#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
union _MMPTE::@2304 u
USHORT UsedPageTableEntries[768]
Definition: mmtypes.h:882
#define MI_MAKE_ACCESSED_PAGE(x)
Definition: mm.h:100
ULONG OwnsSystemWorkingSetShared
Definition: pstypes.h:1224
signed short * PSHORT
Definition: retypes.h:6
PMMPDE PageTables
Definition: miarm.h:517
_MMSYSTEM_PTE_POOL_TYPE
Definition: miarm.h:411
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:1198
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:209
ULONG PFN_COUNT
Definition: mmtypes.h:102
LONG ProcessReferenceToSession
Definition: miarm.h:504
#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
struct _MMCOLOR_TABLES MMCOLOR_TABLES
#define MI_IS_SESSION_ADDRESS(Address)
Definition: miarm.h:171
SIZE_T MmSessionViewSize
Definition: init.c:35
VOID NTAPI MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
VOID NTAPI MiWriteProtectSystemImage(_In_ PVOID ImageBase)
Definition: sysldr.c:2443
FORCEINLINE BOOLEAN MI_IS_MAPPED_PTE(PMMPTE PointerPte)
Definition: miarm.h:911
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:1092
LONG NTSTATUS
Definition: precomp.h:26
PFN_NUMBER PageCount
Definition: miarm.h:429
PMMPTE MiSessionLastPte
Definition: mminit.c:146
VOID NTAPI MiDeleteARM3Section(PVOID ObjectBody)
Definition: section.c:3306
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:1770
PLDR_DATA_TABLE_ENTRY NTAPI MiLookupDataTableEntry(IN PVOID Address)
Definition: sysldr.c:3427
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:1825
#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:1107
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
SIZE_T TotalBytes
Definition: miarm.h:331
PCHAR SystemSpaceViewStart
Definition: miarm.h:462
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1279
PFN_NUMBER NumberOfPages
Definition: miarm.h:435
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:465
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
ULONG BitmapFailures
Definition: miarm.h:467
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:489
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:324
LIST_ENTRY ListHeads[POOL_LISTS_PER_PAGE]
Definition: miarm.h:333
#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:1725
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:408
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(IN PMMPTE NewPte, IN PVOID Segment)
Definition: miarm.h:875
PPOOL_TRACKER_TABLE PoolTrackTable
Definition: expool.c:49
PMMPFN MmPfnDatabase
Definition: freelist.c:24
KGUARDED_MUTEX SystemSpaceViewLock
Definition: miarm.h:460
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:2253
MM_PAGED_POOL_INFO PagedPoolInfo
Definition: miarm.h:509
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:595
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:1097
PMMPTE MmLastReservedMappingPte
Definition: hypermap.c:20
VOID NTAPI MiInitializeSessionWsSupport(VOID)
Definition: session.c:40
PVOID MmSessionBase
Definition: miarm.h:589
FORCEINLINE BOOLEAN MM_ANY_WS_LOCK_HELD(IN PETHREAD Thread)
Definition: miarm.h:1044
enum _MM_SYSTEM_SIZE MM_SYSTEMSIZE
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:688
struct _MMSESSION * PMMSESSION
SIZE_T MmSystemLockPagesCount
Definition: mdlsup.c:22
PDRIVER_UNLOAD Win32KDriverUnload
Definition: miarm.h:512
ULONG * PPFN_NUMBER
Definition: ke.h:9
struct _POOL_DESCRIPTOR * PPOOL_DESCRIPTOR
ULONG OwnsSessionWorkingSetShared
Definition: pstypes.h:1226
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:9
LIST_ENTRY WsListEntry
Definition: miarm.h:505
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:951
ULONG MmVerifyDriverBufferLength
Definition: drvmgmt.c:24
LIST_ENTRY Links
Definition: miarm.h:407
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
PFN_NUMBER BasePage
Definition: miarm.h:428
#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:1027
long LONG
Definition: pedump.c:60
ULONG SessionSpace
Definition: mmtypes.h:891
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:388
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:727
PFN_NUMBER Flink
Definition: miarm.h:441
USHORT AllocatorBackTraceIndex
ULONG OwnsSessionWorkingSetExclusive
Definition: pstypes.h:1225
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1231
PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock
Definition: init.c:45
VOID NTAPI MiInitializeSessionIds(VOID)
Definition: session.c:116
FORCEINLINE PFN_NUMBER MiRemoveZeroPageSafe(IN ULONG Color)
Definition: miarm.h:2413
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:22
MM_PAGED_POOL_INFO MmPagedPoolInfo
Definition: pool.c:25
unsigned char BOOLEAN
FORCEINLINE BOOLEAN MiIsRosSectionObject(IN PSECTION Section)
Definition: miarm.h:1081
POOL_DESCRIPTOR PagedPool
Definition: miarm.h:513
FORCEINLINE VOID MI_MAKE_TRANSITION_PTE(_Out_ PMMPTE NewPte, _In_ PFN_NUMBER Page, _In_ ULONG Protection)
Definition: miarm.h:921
VOID NTAPI MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde, IN PEPROCESS TargetProcess, IN KIRQL OldIrql)
Definition: virtual.c:2409
_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:846
#define KeLeaveGuardedRegion()
Definition: ke_x.h:68
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:652
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1132
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:1334
SIZE_T NonPagedBytes
Definition: miarm.h:382
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1010
PFN_NUMBER Page
Definition: section.c:4756
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:264
Definition: miarm.h:405
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:463
ULONG SystemSpaceHashKey
Definition: miarm.h:466
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:26
PVOID LockAddress
Definition: miarm.h:328
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:746
ULONG PoolIndex
Definition: miarm.h:322
ULONG LongFlags
Definition: miarm.h:484
NTSTATUS NTAPI MiRosUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:4278
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:1152
MMSUPPORT_FLAGS Flags
Definition: mmtypes.h:919
PVOID MmHyperSpaceEnd
Definition: init.c:56
MMPDE DemandZeroPde
Definition: init.c:36
struct _MI_LARGE_PAGE_DRIVER_ENTRY MI_LARGE_PAGE_DRIVER_ENTRY
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:947
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:485
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:480
FORCEINLINE VOID MiDecrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:1813
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:821
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:1451
ULONG RunningAllocs
Definition: miarm.h:323
SIZE_T CommittedPages
Definition: miarm.h:492
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MI_IS_SESSION_PTE(Pte)
Definition: miarm.h:174
ULONG ExpNumberOfPagedPools
Definition: expool.c:41
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:507
ULONG64 Valid
Definition: mmtypes.h:150
LONG PendingFreeDepth
Definition: miarm.h:330
#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:381
#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:1943
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:39
ULONG SessionPoolAllocationFailures[4]
Definition: miarm.h:498
PMMADDRESS_NODE NTAPI MiGetNextNode(IN PMMADDRESS_NODE Node)
Definition: vadnode.c:467
PVOID MmHighSectionBase
Definition: section.c:111
ULONG Threshold
Definition: miarm.h:327
SIZE_T Spare0
Definition: miarm.h:332
FORCEINLINE VOID MiLockProcessWorkingSetShared(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1129
PVOID MiSessionSpaceEnd
Definition: init.c:27
SIZE_T PagedBytes
Definition: miarm.h:385
ULONG TotalPages
Definition: miarm.h:325
ULONG_PTR MxPfnAllocation
Definition: init.c:43
SIZE_T MmBootImageSize
Definition: init.c:49
FORCEINLINE BOOLEAN MiIsUserPte(PVOID Address)
Definition: miarm.h:735
VOID NTAPI MiDecrementReferenceCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1221
#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:1557
PKGUARDED_MUTEX SystemSpaceViewLockPointer
Definition: miarm.h:461
PFN_NUMBER MmLowMemoryThreshold
Definition: mminit.c:300
PVOID PagedPoolEnd
Definition: miarm.h:494
KGUARDED_MUTEX PagedPoolMutex
Definition: miarm.h:508
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
PCONTROL_AREA ControlArea
Definition: miarm.h:455
PFN_NUMBER MmMaximumNonPagedPoolInPages
Definition: mminit.c:30
PMMPTE MiSessionImagePteStart
Definition: mminit.c:143
FORCEINLINE VOID MiDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1568
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:345
Definition: btrfs_drv.h:1922
ULONG MmMinAdditionNonPagedPoolPerMb
Definition: mminit.c:40
FORCEINLINE VOID MiUnlockWorkingSetShared(_In_ PETHREAD Thread, _In_ PMMSUPPORT WorkingSet)
Definition: miarm.h:1372
VOID NTAPI MiComputeColorInformation(VOID)
Definition: mminit.c:508
const ULONG MmProtectToValue[32]
Definition: page.c:71
#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:1223
#define _1MB
Definition: miarm.h:19
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:966
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326
LIST_ENTRY ImageList
Definition: miarm.h:499
_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:503
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:584
PFN_NUMBER MiLowPagedPoolThreshold
Definition: mminit.c:302
NTSTATUS NTAPI MiSessionCommitPageTables(IN PVOID StartVa, IN PVOID EndVa)
Definition: section.c:941
#define MM_EXECUTE_READWRITE
Definition: miarm.h:49
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:822
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:326
PVOID PendingFrees
Definition: miarm.h:329
_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:1084
FORCEINLINE VOID MiLockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, IN BOOLEAN Safe, IN BOOLEAN Shared)
Definition: miarm.h:1484
ULONG_PTR SIZE_T
Definition: typedefs.h:80
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define SYSTEM_PD_SIZE
Definition: miarm.h:32
FORCEINLINE VOID MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte, IN MMPTE InvalidPte)
Definition: miarm.h:984
WCHAR MmLargePageDriverBuffer[512]
Definition: largepag.c:24
PSUBSECTION NTAPI MiLocateSubsection(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: section.c:574
FORCEINLINE VOID MiLockWorkingSetShared(_In_ PETHREAD Thread, _In_ PMMSUPPORT WorkingSet)
Definition: miarm.h:1289
KEVENT AttachEvent
Definition: miarm.h:502
MMPTE HyperTemplatePte
Definition: hypermap.c:22
struct _MMSESSION MMSESSION
PRTL_BITMAP SystemSpaceBitMap
Definition: miarm.h:468
SIZE_T MmDefaultMaximumNonPagedPool
Definition: mminit.c:41
ULONG MmVerifyDriverBufferType
Definition: drvmgmt.c:25
USHORT PreviousSize
POOL_TYPE PoolType
Definition: miarm.h:321
_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:1367
PMMWSLE Wsle
Definition: miarm.h:511
#define MI_IS_ROS_PFN(x)
Definition: miarm.h:1086
Definition: miarm.h:452
NTSTATUS NTAPI MiInitializeSessionPool(VOID)
Definition: pool.c:1293
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define FORCEINLINE
Definition: wdftypes.h:67
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1606
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
LONG ResidentProcessCount
Definition: miarm.h:497
VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID)
Definition: pool.c:184
PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE]
Definition: init.c:40
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
Definition: ex.h:1118
MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType]
Definition: iosup.c:27
ULONG OwnsProcessWorkingSetShared
Definition: pstypes.h:1222
VOID NTAPI InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold)
Definition: expool.c:1017
BOOLEAN NTAPI MiInitializeMemoryEvents(VOID)
Definition: mminit.c:1339
VOID NTAPI MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
PPOOL_DESCRIPTOR ExpPagedPoolDescriptor[16+1]
Definition: expool.c:43
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:1527
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define InterlockedCompareExchange16
Definition: interlocked.h:109
PKEVENT MiLowPagedPoolEvent
Definition: mminit.c:294
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:281
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:585
WCHAR MmVerifyDriverBuffer[512]
Definition: drvmgmt.c:23
POOL_DESCRIPTOR NonPagedPoolDescriptor
Definition: expool.c:42
struct _MM_SESSION_SPACE * PMM_SESSION_SPACE
FORCEINLINE BOOLEAN MiIsMemoryTypeFree(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:678
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:2090
_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:426
LONG NonPagedAllocs
Definition: miarm.h:380
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:982
MMSUPPORT MmSystemCacheWs
Definition: init.c:55
#define OUT
Definition: typedefs.h:40
PVOID MiSessionPoolEnd
Definition: init.c:31
FORCEINLINE BOOLEAN MiConvertSharedWorkingSetLockToExclusive(_In_ PETHREAD Thread, _In_ PMMSUPPORT Vm)
Definition: miarm.h:1411
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1192
VOID NTAPI MiInitializePfnAndMakePteValid(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: pfnlist.c:1035
_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:1801
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
struct _POOL_TRACKER_BIG_PAGES * PPOOL_TRACKER_BIG_PAGES
VOID NTAPI MiRemoveMappedView(IN PEPROCESS CurrentProcess, IN PMMVAD Vad)
Definition: section.c:784
ULONG_PTR Entry
Definition: miarm.h:454
BOOLEAN NTAPI MiIsPfnInUse(IN PMMPFN Pfn1)
Definition: freelist.c:174
ULONG AttachCount
Definition: miarm.h:501
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:443
#define InterlockedDecrementSizeT(a)
Definition: interlocked.h:153
ULONG OwnsProcessWorkingSetExclusive
Definition: pstypes.h:1221
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:279
FORCEINLINE VOID MiReferenceProbedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1670
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:783
PMMPTE MiSessionBasePte
Definition: mminit.c:145
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1248
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1656
PMMPTE MiHighestUserPte
Definition: mminit.c:233
#define DPRINT
Definition: sndvol32.h:71
MMPTE ValidKernelPteLocal
Definition: init.c:33
#define KeGetCurrentThread
Definition: hal.h:49
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:464
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE
KGUARDED_MUTEX MmSectionCommitMutex
Definition: section.c:108
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:937
FORCEINLINE VOID MI_UPDATE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:969
FORCEINLINE BOOLEAN MI_WS_OWNER(IN PEPROCESS Process)
Definition: miarm.h:1060
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:3502
PKEVENT MiHighMemoryEvent
Definition: mminit.c:293
PMMPDE PagedPoolBasePde
Definition: miarm.h:495
PFN_NUMBER LastFrame
Definition: miarm.h:449
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:526
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:182
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:806
_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:1177
PMMPDE MmSystemPagePtes
Definition: init.c:41
FORCEINLINE PMMPTE MI_GET_PROTOTYPE_PTE_FOR_VPN(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: miarm.h:1540
ULONG PageFrameNumber
Definition: mmtypes.h:109
Definition: dlist.c:348
PFN_NUMBER SessionPageDirectoryIndex
Definition: miarm.h:490
Definition: mm.h:412
PVOID MiSessionViewStart
Definition: init.c:30
BOOLEAN MmTrackPtes
Definition: mdlsup.c:20
struct _POOL_DESCRIPTOR POOL_DESCRIPTOR
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PVOID MmNonPagedSystemStart
Definition: miarm.h:586
PMMPTE MiSessionImagePteEnd
Definition: mminit.c:144