ReactOS  0.4.15-dev-3331-g8ebe441
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 // Returns the color of a page
235 //
236 #define MI_GET_PAGE_COLOR(x) ((x) & MmSecondaryColorMask)
237 #define MI_GET_NEXT_COLOR() (MI_GET_PAGE_COLOR(++MmSystemPageColor))
238 #define MI_GET_NEXT_PROCESS_COLOR(x) (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
239 
240 //
241 // Prototype PTEs that don't yet have a pagefile association
242 //
243 #ifdef _WIN64
244 #define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
245 #else
246 #define MI_PTE_LOOKUP_NEEDED 0xFFFFF
247 #endif
248 
249 //
250 // Number of session data and tag pages
251 //
252 #define MI_SESSION_DATA_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
253 #define MI_SESSION_TAG_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
254 
255 //
256 // Used by MiCheckSecuredVad
257 //
258 #define MM_READ_WRITE_ALLOWED 11
259 #define MM_READ_ONLY_ALLOWED 10
260 #define MM_NO_ACCESS_ALLOWED 01
261 #define MM_DELETE_CHECK 85
262 
263 //
264 // System views are binned into 64K chunks
265 //
266 #define MI_SYSTEM_VIEW_BUCKET_SIZE _64K
267 
268 //
269 // FIXFIX: These should go in ex.h after the pool merge
270 //
271 #ifdef _WIN64
272 #define POOL_BLOCK_SIZE 16
273 #else
274 #define POOL_BLOCK_SIZE 8
275 #endif
276 #define POOL_LISTS_PER_PAGE (PAGE_SIZE / POOL_BLOCK_SIZE)
277 #define BASE_POOL_TYPE_MASK 1
278 #define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + POOL_BLOCK_SIZE))
279 
280 //
281 // Pool debugging/analysis/tracing flags
282 //
283 #define POOL_FLAG_CHECK_TIMERS 0x1
284 #define POOL_FLAG_CHECK_WORKERS 0x2
285 #define POOL_FLAG_CHECK_RESOURCES 0x4
286 #define POOL_FLAG_VERIFIER 0x8
287 #define POOL_FLAG_CHECK_DEADLOCK 0x10
288 #define POOL_FLAG_SPECIAL_POOL 0x20
289 #define POOL_FLAG_DBGPRINT_ON_FAILURE 0x40
290 #define POOL_FLAG_CRASH_ON_FAILURE 0x80
291 
292 //
293 // BAD_POOL_HEADER codes during pool bugcheck
294 //
295 #define POOL_CORRUPTED_LIST 3
296 #define POOL_SIZE_OR_INDEX_MISMATCH 5
297 #define POOL_ENTRIES_NOT_ALIGNED_PREVIOUS 6
298 #define POOL_HEADER_NOT_ALIGNED 7
299 #define POOL_HEADER_IS_ZERO 8
300 #define POOL_ENTRIES_NOT_ALIGNED_NEXT 9
301 #define POOL_ENTRY_NOT_FOUND 10
302 
303 //
304 // BAD_POOL_CALLER codes during pool bugcheck
305 //
306 #define POOL_ENTRY_CORRUPTED 1
307 #define POOL_ENTRY_ALREADY_FREE 6
308 #define POOL_ENTRY_NOT_ALLOCATED 7
309 #define POOL_ALLOC_IRQL_INVALID 8
310 #define POOL_FREE_IRQL_INVALID 9
311 #define POOL_BILLED_PROCESS_INVALID 13
312 #define POOL_HEADER_SIZE_INVALID 32
313 
314 typedef struct _POOL_DESCRIPTOR
315 {
330 
331 typedef struct _POOL_HEADER
332 {
333  union
334  {
335  struct
336  {
337 #ifdef _WIN64
339  USHORT PoolIndex:8;
340  USHORT BlockSize:8;
341  USHORT PoolType:8;
342 #else
344  USHORT PoolIndex:7;
345  USHORT BlockSize:9;
346  USHORT PoolType:7;
347 #endif
348  };
349  ULONG Ulong1;
350  };
351 #ifdef _WIN64
352  ULONG PoolTag;
353 #endif
354  union
355  {
356 #ifdef _WIN64
357  PEPROCESS ProcessBilled;
358 #else
359  ULONG PoolTag;
360 #endif
361  struct
362  {
365  };
366  };
368 
371 
372 typedef struct _POOL_TRACKER_TABLE
373 {
382 
384 {
390 
395 
396 //
397 // END FIXFIX
398 //
399 
401 {
405 
407 {
412 
414 {
420 
421 typedef struct _PHYSICAL_MEMORY_RUN
422 {
426 
428 {
433 
434 typedef struct _MMCOLOR_TABLES
435 {
440 
441 typedef struct _MI_LARGE_PAGE_RANGES
442 {
446 
447 typedef struct _MMVIEW
448 {
451 } MMVIEW, *PMMVIEW;
452 
453 typedef struct _MMSESSION
454 {
465 
467 {
472 
473 typedef struct _MM_SESSION_SPACE
474 {
477  union
478  {
481  } u;
509 #if defined (_M_AMD64)
510  MMPDE PageDirectory;
511 #else
513 #endif
514 #if defined (_M_AMD64)
515  PMMPTE SpecialPoolFirstPte;
516  PMMPTE SpecialPoolLastPte;
517  PMMPTE NextPdeForSpecialPoolExpansion;
518  PMMPTE LastPdeForSpecialPoolExpansion;
519  PFN_NUMBER SpecialPagesInUse;
520 #endif
523 
525 extern MMPTE HyperTemplatePte;
526 extern MMPDE ValidKernelPde;
527 extern MMPTE ValidKernelPte;
530 extern MMPDE DemandZeroPde;
531 extern MMPTE DemandZeroPte;
532 extern MMPTE PrototypePte;
533 extern MMPTE MmDecommittedPte;
535 extern BOOLEAN MmZeroPageFile;
538 extern BOOLEAN MmTrackPtes;
539 extern BOOLEAN MmDynamicPfn;
540 extern BOOLEAN MmMirroring;
541 extern BOOLEAN MmMakeLowMemory;
547 extern WCHAR MmVerifyDriverBuffer[512];
548 extern WCHAR MmLargePageDriverBuffer[512];
560 extern PVOID MmNonPagedPoolEnd;
562 extern PVOID MmPagedPoolStart;
563 extern PVOID MmPagedPoolEnd;
564 extern PVOID MmSessionBase;
565 extern SIZE_T MmSessionSize;
570 extern SIZE_T MmBootImageSize;
582 extern PVOID MiSystemViewStart;
583 extern SIZE_T MmSystemViewSize;
585 extern PVOID MiSessionSpaceEnd;
588 extern PMMPTE MiSessionBasePte;
589 extern PMMPTE MiSessionLastPte;
591 extern PMMPDE MmSystemPagePtes;
593 extern PVOID MmSystemCacheEnd;
596 extern ULONG MmSpecialPoolTag;
597 extern PVOID MmHyperSpaceEnd;
603 extern ULONG MmSecondaryColors;
607 extern ULONG MmLargeStackSize;
610 extern ULONG MmProductType;
633 extern PVOID MiSessionImageEnd;
634 extern PMMPTE MiHighestUserPte;
635 extern PMMPDE MiHighestUserPde;
640 extern ULONG MmSystemPageColor;
642 extern PMMWSL MmWorkingSetList;
648 extern PVOID MiSessionPoolEnd; // 0xBE000000
649 extern PVOID MiSessionPoolStart; // 0xBD000000
650 extern PVOID MiSessionViewStart; // 0xBE000000
651 extern PVOID MiSessionSpaceWs;
656 extern PVOID MmHighSectionBase;
663 
665 BOOLEAN
667 {
668  return (WorkingSet != &MmSystemCacheWs) && !WorkingSet->Flags.SessionSpace;
669 }
670 
672 BOOLEAN
674 {
675  return ((MemoryType == LoaderFree) ||
676  (MemoryType == LoaderLoadedProgram) ||
677  (MemoryType == LoaderFirmwareTemporary) ||
678  (MemoryType == LoaderOsloaderStack));
679 }
680 
682 BOOLEAN
684 {
685  return ((MemoryType == LoaderFirmwarePermanent) ||
686  (MemoryType == LoaderSpecialMemory) ||
687  (MemoryType == LoaderHALCachedMemory) ||
688  (MemoryType == LoaderBBTMemory));
689 }
690 
691 #ifdef _M_AMD64
693 BOOLEAN
694 MiIsUserPxe(PVOID Address)
695 {
696  return ((ULONG_PTR)Address >> 7) == 0x1FFFFEDF6FB7DA0ULL;
697 }
698 
700 BOOLEAN
701 MiIsUserPpe(PVOID Address)
702 {
703  return ((ULONG_PTR)Address >> 16) == 0xFFFFF6FB7DA0ULL;
704 }
705 
707 BOOLEAN
709 {
710  return ((ULONG_PTR)Address >> 25) == 0x7FFFFB7DA0ULL;
711 }
712 
714 BOOLEAN
716 {
717  return ((ULONG_PTR)Address >> 34) == 0x3FFFFDA0ULL;
718 }
719 #else
721 BOOLEAN
723 {
724  return ((Address >= (PVOID)MiAddressToPde(NULL)) &&
726 }
727 
729 BOOLEAN
731 {
732  return (Address >= (PVOID)PTE_BASE) && (Address <= (PVOID)MiHighestUserPte);
733 }
734 #endif
735 
736 //
737 // Figures out the hardware bits for a PTE
738 //
740 ULONG_PTR
742 {
743  MMPTE TempPte;
744 
745  /* Start fresh */
746  TempPte.u.Long = 0;
747 
748  /* Make it valid and accessed */
749  TempPte.u.Hard.Valid = TRUE;
751 
752  /* Is this for user-mode? */
753  if (
754 #if (_MI_PAGING_LEVELS == 4)
755  MiIsUserPxe(PointerPte) ||
756 #endif
757 #if (_MI_PAGING_LEVELS >= 3)
758  MiIsUserPpe(PointerPte) ||
759 #endif
760  MiIsUserPde(PointerPte) ||
761  MiIsUserPte(PointerPte))
762  {
763  /* Set the owner bit */
765  }
766 
767  /* FIXME: We should also set the global bit */
768 
769  /* Return the protection */
770  return TempPte.u.Long;
771 }
772 
773 //
774 // Creates a valid kernel PTE with the given protection
775 //
777 VOID
779  IN PMMPTE MappingPte,
780  IN ULONG_PTR ProtectionMask,
781  IN PFN_NUMBER PageFrameNumber)
782 {
783  /* Only valid for kernel, non-session PTEs */
784  ASSERT(MappingPte > MiHighestUserPte);
785  ASSERT(!MI_IS_SESSION_PTE(MappingPte));
786  ASSERT((MappingPte < (PMMPTE)PDE_BASE) || (MappingPte > (PMMPTE)PDE_TOP));
787 
788  /* Check that we are not setting valid a page that should not be */
789  ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
790  ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
791 
792  /* Start fresh */
793  NewPte->u.Long = 0;
794 
795  /* Set the protection and page */
796  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
797  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
798 
799  /* Make this valid & global */
800 #ifdef _GLOBAL_PAGES_ARE_AWESOME_
802  NewPte->u.Hard.Global = 1;
803 #endif
804  NewPte->u.Hard.Valid = 1;
805 }
806 
807 //
808 // Creates a valid PTE with the given protection
809 //
811 VOID
813  IN PMMPTE MappingPte,
814  IN ULONG_PTR ProtectionMask,
815  IN PFN_NUMBER PageFrameNumber)
816 {
817  /* Check that we are not setting valid a page that should not be */
818  ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
819  ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
820 
821  /* Set the protection and page */
822  NewPte->u.Long = MiDetermineUserGlobalPteMask(MappingPte);
823  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
824  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
825 }
826 
827 //
828 // Creates a valid user PTE with the given protection
829 //
831 VOID
833  IN PMMPTE MappingPte,
834  IN ULONG_PTR ProtectionMask,
835  IN PFN_NUMBER PageFrameNumber)
836 {
837  /* Only valid for kernel, non-session PTEs */
838  ASSERT(MappingPte <= MiHighestUserPte);
839 
840  /* Start fresh */
841  NewPte->u.Long = 0;
842 
843  /* Check that we are not setting valid a page that should not be */
844  ASSERT(ProtectionMask & MM_PROTECT_ACCESS);
845  ASSERT((ProtectionMask & MM_GUARDPAGE) == 0);
846 
847  NewPte->u.Hard.Valid = TRUE;
848  NewPte->u.Hard.Owner = TRUE;
849  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
850  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
851 }
852 
853 #ifndef _M_AMD64
854 //
855 // Builds a Prototype PTE for the address of the PTE
856 //
858 VOID
860  IN PMMPTE PointerPte)
861 {
863 
864  /* Mark this as a prototype */
865  NewPte->u.Long = 0;
866  NewPte->u.Proto.Prototype = 1;
867 
868  /*
869  * Prototype PTEs are only valid in paged pool by design, this little trick
870  * lets us only use 30 bits for the adress of the PTE, as long as the area
871  * stays 1024MB At most.
872  */
873  Offset = (ULONG_PTR)PointerPte - (ULONG_PTR)MmPagedPoolStart;
874 
875  /*
876  * 7 bits go in the "low" (but we assume the bottom 2 are zero)
877  * and the other 21 bits go in the "high"
878  */
879  NewPte->u.Proto.ProtoAddressLow = (Offset & 0x1FC) >> 2;
880  NewPte->u.Proto.ProtoAddressHigh = (Offset & 0x3FFFFE00) >> 9;
881 }
882 
883 //
884 // Builds a Subsection PTE for the address of the Segment
885 //
887 VOID
889  IN PVOID Segment)
890 {
892 
893  /* Mark this as a prototype */
894  NewPte->u.Long = 0;
895  NewPte->u.Subsect.Prototype = 1;
896 
897  /*
898  * Segments are only valid either in nonpaged pool. We store the 20 bit
899  * difference either from the top or bottom of nonpaged pool, giving a
900  * maximum of 128MB to each delta, meaning nonpaged pool cannot exceed
901  * 256MB.
902  */
903  if ((ULONG_PTR)Segment < ((ULONG_PTR)MmSubsectionBase + (128 * _1MB)))
904  {
906  NewPte->u.Subsect.WhichPool = PagedPool;
907  }
908  else
909  {
911  NewPte->u.Subsect.WhichPool = NonPagedPool;
912  }
913 
914  /*
915  * 4 bits go in the "low" (but we assume the bottom 3 are zero)
916  * and the other 20 bits go in the "high"
917  */
918  NewPte->u.Subsect.SubsectionAddressLow = (Offset & 0x78) >> 3;
919  NewPte->u.Subsect.SubsectionAddressHigh = (Offset & 0xFFFFF80) >> 7;
920 }
921 
923 BOOLEAN
925 {
927  return ((PointerPte->u.Long & 0xFFFFFC01) != 0);
928 }
929 
930 #endif
931 
933 VOID
936  _In_ ULONG Protection)
937 {
938  NewPte->u.Long = 0;
939  NewPte->u.Trans.Transition = 1;
940  NewPte->u.Trans.Protection = Protection;
941  NewPte->u.Trans.PageFrameNumber = Page;
942 }
943 
944 //
945 // Returns if the page is physically resident (ie: a large page)
946 // FIXFIX: CISC/x86 only?
947 //
949 BOOLEAN
951 {
952  PMMPDE PointerPde;
953 
954  /* Large pages are never paged out, always physically resident */
955  PointerPde = MiAddressToPde(Address);
956  return ((PointerPde->u.Hard.LargePage) && (PointerPde->u.Hard.Valid));
957 }
958 
959 //
960 // Writes a valid PTE
961 //
963 VOID
965  IN MMPTE TempPte)
966 {
967  /* Write the valid PTE */
968  ASSERT(PointerPte->u.Hard.Valid == 0);
969  ASSERT(TempPte.u.Hard.Valid == 1);
970 #if _M_AMD64
972  (TempPte.u.Hard.NoExecute == 0));
973 #endif
974  *PointerPte = TempPte;
975 }
976 
977 //
978 // Updates a valid PTE
979 //
981 VOID
983  IN MMPTE TempPte)
984 {
985  /* Write the valid PTE */
986  ASSERT(PointerPte->u.Hard.Valid == 1);
987  ASSERT(TempPte.u.Hard.Valid == 1);
988  ASSERT(PointerPte->u.Hard.PageFrameNumber == TempPte.u.Hard.PageFrameNumber);
989  *PointerPte = TempPte;
990 }
991 
992 //
993 // Writes an invalid PTE
994 //
996 VOID
998  IN MMPTE InvalidPte)
999 {
1000  /* Write the invalid PTE */
1001  ASSERT(InvalidPte.u.Hard.Valid == 0);
1002  ASSERT(InvalidPte.u.Long != 0);
1003  *PointerPte = InvalidPte;
1004 }
1005 
1006 //
1007 // Erase the PTE completely
1008 //
1010 VOID
1012 {
1013  /* Zero out the PTE */
1014  ASSERT(PointerPte->u.Long != 0);
1015  PointerPte->u.Long = 0;
1016 }
1017 
1018 //
1019 // Writes a valid PDE
1020 //
1022 VOID
1024  IN MMPDE TempPde)
1025 {
1026  /* Write the valid PDE */
1027  ASSERT(PointerPde->u.Hard.Valid == 0);
1028 #ifdef _M_AMD64
1029  ASSERT(PointerPde->u.Hard.NoExecute == 0);
1030 #endif
1031  ASSERT(TempPde.u.Hard.Valid == 1);
1032  *PointerPde = TempPde;
1033 }
1034 
1035 //
1036 // Writes an invalid PDE
1037 //
1039 VOID
1041  IN MMPDE InvalidPde)
1042 {
1043  /* Write the invalid PDE */
1044  ASSERT(InvalidPde.u.Hard.Valid == 0);
1045  ASSERT(InvalidPde.u.Long != 0);
1046 #ifdef _M_AMD64
1047  ASSERT(InvalidPde.u.Soft.Protection == MM_EXECUTE_READWRITE);
1048 #endif
1049  *PointerPde = InvalidPde;
1050 }
1051 
1052 //
1053 // Checks if the thread already owns a working set
1054 //
1056 BOOLEAN
1058 {
1059  /* If any of these are held, return TRUE */
1066 }
1067 
1069 BOOLEAN
1071 {
1075 }
1076 
1077 //
1078 // Checks if the process owns the working set lock
1079 //
1081 BOOLEAN
1083 {
1084  /* Check if this process is the owner, and that the thread owns the WS */
1085  if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0)
1086  {
1087  DPRINT("Thread: %p is not an owner\n", PsGetCurrentThread());
1088  }
1089  if (KeGetCurrentThread()->ApcState.Process != &Process->Pcb)
1090  {
1091  DPRINT("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
1092  }
1093  return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
1094  ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||
1095  (PsGetCurrentThread()->OwnsProcessWorkingSetShared)));
1096 }
1097 
1098 //
1099 // New ARM3<->RosMM PAGE Architecture
1100 //
1102 BOOLEAN
1104 {
1105  return Section->u.Flags.filler;
1106 }
1107 
1108 #define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE)
1109 
1110 VOID
1111 NTAPI
1113  IN PMMPFN Pfn1,
1114  IN PFN_NUMBER PageFrameIndex
1115 );
1116 
1118 BOOLEAN
1120 {
1121  return (Process->Vm.Flags.AcquiredUnsafe == TRUE);
1122 }
1123 
1124 //
1125 // Locks the working set for the given process
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  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1142 
1143  /* Now claim that we own the lock */
1147 }
1148 
1150 VOID
1152  IN PETHREAD Thread)
1153 {
1154  /* Shouldn't already be owning the process working set */
1157 
1158  /* Block APCs, make sure that still nothing is already held */
1161 
1162  /* Lock the working set */
1163  ExAcquirePushLockShared(&Process->Vm.WorkingSetMutex);
1164 
1165  /* Now claim that we own the lock */
1170 }
1171 
1173 VOID
1175  IN PETHREAD Thread)
1176 {
1177  /* Shouldn't already be owning the process working set */
1179 
1180  /* APCs must be blocked, make sure that still nothing is already held */
1183 
1184  /* Lock the working set */
1185  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1186 
1187  /* Now claim that we own the lock */
1189  Process->Vm.Flags.AcquiredUnsafe = 1;
1192 }
1193 
1194 //
1195 // Unlocks the working set for the given process
1196 //
1198 VOID
1200  IN PETHREAD Thread)
1201 {
1202  /* Make sure we are the owner of a safe acquisition */
1205 
1206  /* The thread doesn't own it anymore */
1209 
1210  /* Release the lock and re-enable APCs */
1211  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1213 }
1214 
1215 //
1216 // Unlocks the working set for the given process
1217 //
1219 VOID
1221  IN PETHREAD Thread)
1222 {
1223  /* Make sure we are the owner of a safe acquisition (because shared) */
1226 
1227  /* Ensure we are in a shared acquisition */
1230 
1231  /* Don't claim the lock anylonger */
1233 
1234  /* Release the lock and re-enable APCs */
1235  ExReleasePushLockShared(&Process->Vm.WorkingSetMutex);
1237 }
1238 
1239 //
1240 // Unlocks the working set for the given process
1241 //
1243 VOID
1245  IN PETHREAD Thread)
1246 {
1247  /* Make sure we are the owner of an unsafe acquisition */
1252 
1253  /* No longer unsafe */
1254  Process->Vm.Flags.AcquiredUnsafe = 0;
1255 
1256  /* The thread doesn't own it anymore */
1259 
1260  /* Release the lock but don't touch APC state */
1261  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1263 }
1264 
1265 //
1266 // Locks the working set
1267 //
1269 VOID
1271  IN PMMSUPPORT WorkingSet)
1272 {
1273  /* Block APCs */
1275 
1276  /* Working set should be in global memory */
1277  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1278 
1279  /* Thread shouldn't already be owning something */
1281 
1282  /* Lock this working set */
1283  ExAcquirePushLockExclusive(&WorkingSet->WorkingSetMutex);
1284 
1285  /* Which working set is this? */
1286  if (WorkingSet == &MmSystemCacheWs)
1287  {
1288  /* Own the system working set */
1292  }
1293  else if (WorkingSet->Flags.SessionSpace)
1294  {
1295  /* Own the session working set */
1299  }
1300  else
1301  {
1302  /* Own the process working set */
1306  }
1307 }
1308 
1310 VOID
1313  _In_ PMMSUPPORT WorkingSet)
1314 {
1315  /* Block APCs */
1317 
1318  /* Working set should be in global memory */
1319  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1320 
1321  /* Thread shouldn't already be owning something */
1323 
1324  /* Lock this working set */
1325  ExAcquirePushLockShared(&WorkingSet->WorkingSetMutex);
1326 
1327  /* Which working set is this? */
1328  if (WorkingSet == &MmSystemCacheWs)
1329  {
1330  /* Own the system working set */
1334  }
1335  else if (WorkingSet->Flags.SessionSpace)
1336  {
1337  /* Own the session working set */
1341  }
1342  else
1343  {
1344  /* Own the process working set */
1348  }
1349 }
1350 
1351 //
1352 // Unlocks the working set
1353 //
1355 VOID
1357  IN PMMSUPPORT WorkingSet)
1358 {
1359  /* Working set should be in global memory */
1360  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1361 
1362  /* Which working set is this? */
1363  if (WorkingSet == &MmSystemCacheWs)
1364  {
1365  /* Release the system working set */
1369  }
1370  else if (WorkingSet->Flags.SessionSpace)
1371  {
1372  /* Release the session working set */
1376  }
1377  else
1378  {
1379  /* Release the process working set */
1383  }
1384 
1385  /* Release the working set lock */
1386  ExReleasePushLockExclusive(&WorkingSet->WorkingSetMutex);
1387 
1388  /* Unblock APCs */
1390 }
1391 
1393 VOID
1396  _In_ PMMSUPPORT WorkingSet)
1397 {
1398  /* Working set should be in global memory */
1399  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1400 
1401  /* Which working set is this? */
1402  if (WorkingSet == &MmSystemCacheWs)
1403  {
1404  /* Release the system working set */
1408  }
1409  else if (WorkingSet->Flags.SessionSpace)
1410  {
1411  /* Release the session working set */
1415  }
1416  else
1417  {
1418  /* Release the process working set */
1422  }
1423 
1424  /* Release the working set lock */
1425  ExReleasePushLockShared(&WorkingSet->WorkingSetMutex);
1426 
1427  /* Unblock APCs */
1429 }
1430 
1432 BOOLEAN
1435  _In_ PMMSUPPORT Vm)
1436 {
1437  /* Sanity check: No exclusive lock. */
1441 
1442  /* And it should have one and only one shared lock */
1444 
1445  /* Try. */
1447  return FALSE;
1448 
1449  if (Vm == &MmSystemCacheWs)
1450  {
1454  }
1455  else if (Vm->Flags.SessionSpace)
1456  {
1460  }
1461  else
1462  {
1466  }
1467 
1468  return TRUE;
1469 }
1470 
1472 VOID
1474  IN PETHREAD Thread,
1475  OUT PBOOLEAN Safe,
1476  OUT PBOOLEAN Shared)
1477 {
1479 
1480  /* Check if the current owner is unsafe */
1481  if (MI_IS_WS_UNSAFE(Process))
1482  {
1483  /* Release unsafely */
1485  *Safe = FALSE;
1486  *Shared = FALSE;
1487  }
1488  else if (Thread->OwnsProcessWorkingSetExclusive == 1)
1489  {
1490  /* Owner is safe and exclusive, release normally */
1492  *Safe = TRUE;
1493  *Shared = FALSE;
1494  }
1495  else
1496  {
1497  /* Owner is shared (implies safe), release normally */
1499  *Safe = TRUE;
1500  *Shared = TRUE;
1501  }
1502 }
1503 
1505 VOID
1507  IN PETHREAD Thread,
1508  IN BOOLEAN Safe,
1509  IN BOOLEAN Shared)
1510 {
1511  /* Check if this was a safe lock or not */
1512  if (Safe)
1513  {
1514  if (Shared)
1515  {
1516  /* Reacquire safely & shared */
1518  }
1519  else
1520  {
1521  /* Reacquire safely */
1523  }
1524  }
1525  else
1526  {
1527  /* Unsafe lock cannot be shared */
1528  ASSERT(Shared == FALSE);
1529  /* Reacquire unsafely */
1531  }
1532 }
1533 
1535 KIRQL
1537 {
1538  KIRQL OldIrql;
1539 
1544  return OldIrql;
1545 }
1546 
1548 VOID
1550 {
1555 }
1556 
1557 //
1558 // Returns the ProtoPTE inside a VAD for the given VPN
1559 //
1561 PMMPTE
1563  IN ULONG_PTR Vpn)
1564 {
1565  PMMPTE ProtoPte;
1566 
1567  /* Find the offset within the VAD's prototype PTEs */
1568  ProtoPte = Vad->FirstPrototypePte + (Vpn - Vad->StartingVpn);
1569  ASSERT(ProtoPte <= Vad->LastContiguousPte);
1570  return ProtoPte;
1571 }
1572 
1573 //
1574 // Returns the PFN Database entry for the given page number
1575 // Warning: This is not necessarily a valid PFN database entry!
1576 //
1578 PMMPFN
1580 {
1581  /* Get the entry */
1582  return &MmPfnDatabase[Pfn];
1583 };
1584 
1585 //
1586 // Drops a locked page without dereferencing it
1587 //
1589 VOID
1591 {
1592  /* This page shouldn't be locked, but it should be valid */
1593  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1594  ASSERT(Pfn1->u2.ShareCount == 0);
1595 
1596  /* Is this the last reference to the page */
1597  if (Pfn1->u3.e2.ReferenceCount == 1)
1598  {
1599  /* It better not be valid */
1600  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1601 
1602  /* Is it a prototype PTE? */
1603  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1604  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1605  {
1606  /* FIXME: We should return commit */
1607  DPRINT1("Not returning commit for prototype PTE\n");
1608  }
1609 
1610  /* Update the counter */
1612  }
1613 }
1614 
1615 //
1616 // Drops a locked page and dereferences it
1617 //
1619 VOID
1621 {
1622  USHORT RefCount, OldRefCount;
1623  PFN_NUMBER PageFrameIndex;
1624 
1625  /* Loop while we decrement the page successfully */
1626  do
1627  {
1628  /* There should be at least one reference */
1629  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1630  ASSERT(OldRefCount != 0);
1631 
1632  /* Are we the last one */
1633  if (OldRefCount == 1)
1634  {
1635  /* The page shoudln't be shared not active at this point */
1636  ASSERT(Pfn1->u3.e2.ReferenceCount == 1);
1637  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1638  ASSERT(Pfn1->u2.ShareCount == 0);
1639 
1640  /* Is it a prototype PTE? */
1641  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1642  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1643  {
1644  /* FIXME: We should return commit */
1645  DPRINT1("Not returning commit for prototype PTE\n");
1646  }
1647 
1648  /* Update the counter, and drop a reference the long way */
1650  PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
1651  MiDecrementReferenceCount(Pfn1, PageFrameIndex);
1652  return;
1653  }
1654 
1655  /* Drop a reference the short way, and that's it */
1656  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1657  OldRefCount - 1,
1658  OldRefCount);
1659  ASSERT(RefCount != 0);
1660  } while (OldRefCount != RefCount);
1661 
1662  /* If we got here, there should be more than one reference */
1663  ASSERT(RefCount > 1);
1664  if (RefCount == 2)
1665  {
1666  /* Is it still being shared? */
1667  if (Pfn1->u2.ShareCount >= 1)
1668  {
1669  /* Then it should be valid */
1670  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1671 
1672  /* Is it a prototype PTE? */
1673  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1674  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1675  {
1676  /* We don't handle ethis */
1677  ASSERT(FALSE);
1678  }
1679 
1680  /* Update the counter */
1682  }
1683  }
1684 }
1685 
1686 //
1687 // References a locked page and updates the counter
1688 // Used in MmProbeAndLockPages to handle different edge cases
1689 //
1691 VOID
1693 {
1694  USHORT RefCount, OldRefCount;
1695 
1696  /* Sanity check */
1697  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1698 
1699  /* Does ARM3 own the page? */
1700  if (MI_IS_ROS_PFN(Pfn1))
1701  {
1702  /* ReactOS Mm doesn't track share count */
1703  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1704  }
1705  else
1706  {
1707  /* On ARM3 pages, we should see a valid share count */
1708  ASSERT((Pfn1->u2.ShareCount != 0) && (Pfn1->u3.e1.PageLocation == ActiveAndValid));
1709 
1710  /* Is it a prototype PTE? */
1711  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1712  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1713  {
1714  /* FIXME: We should charge commit */
1715  DPRINT1("Not charging commit for prototype PTE\n");
1716  }
1717  }
1718 
1719  /* More locked pages! */
1721 
1722  /* Loop trying to update the reference count */
1723  do
1724  {
1725  /* Get the current reference count, make sure it's valid */
1726  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1727  ASSERT(OldRefCount != 0);
1728  ASSERT(OldRefCount < 2500);
1729 
1730  /* Bump it up by one */
1731  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1732  OldRefCount + 1,
1733  OldRefCount);
1734  ASSERT(RefCount != 0);
1735  } while (OldRefCount != RefCount);
1736 
1737  /* Was this the first lock attempt? If not, undo our bump */
1738  if (OldRefCount != 1) InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1739 }
1740 
1741 //
1742 // References a locked page and updates the counter
1743 // Used in all other cases except MmProbeAndLockPages
1744 //
1746 VOID
1748 {
1749  USHORT NewRefCount;
1750 
1751  /* Is it a prototype PTE? */
1752  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1753  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1754  {
1755  /* FIXME: We should charge commit */
1756  DPRINT1("Not charging commit for prototype PTE\n");
1757  }
1758 
1759  /* More locked pages! */
1761 
1762  /* Update the reference count */
1763  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1764  if (NewRefCount == 2)
1765  {
1766  /* Is it locked or shared? */
1767  if (Pfn1->u2.ShareCount)
1768  {
1769  /* It's shared, so make sure it's active */
1770  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1771  }
1772  else
1773  {
1774  /* It's locked, so we shouldn't lock again */
1776  }
1777  }
1778  else
1779  {
1780  /* Someone had already locked the page, so undo our bump */
1781  ASSERT(NewRefCount < 2500);
1783  }
1784 }
1785 
1786 //
1787 // References a locked page and updates the counter
1788 // Used in all other cases except MmProbeAndLockPages
1789 //
1791 VOID
1793 {
1794  USHORT NewRefCount;
1795 
1796  /* Make sure the page isn't used yet */
1797  ASSERT(Pfn1->u2.ShareCount == 0);
1798  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1799 
1800  /* Is it a prototype PTE? */
1801  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1802  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1803  {
1804  /* FIXME: We should charge commit */
1805  DPRINT1("Not charging commit for prototype PTE\n");
1806  }
1807 
1808  /* More locked pages! */
1810 
1811  /* Update the reference count */
1812  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1813  if (NewRefCount != 1)
1814  {
1815  /* Someone had already locked the page, so undo our bump */
1816  ASSERT(NewRefCount < 2500);
1818  }
1819 }
1820 
1821 
1822 
1823 CODE_SEG("INIT")
1824 BOOLEAN
1825 NTAPI
1827  IN ULONG Phase,
1828  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1829 );
1830 
1831 CODE_SEG("INIT")
1832 VOID
1833 NTAPI
1835 
1836 CODE_SEG("INIT")
1837 NTSTATUS
1838 NTAPI
1840  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1841 );
1842 
1843 CODE_SEG("INIT")
1844 VOID
1845 NTAPI
1847  VOID
1848 );
1849 
1850 CODE_SEG("INIT")
1851 VOID
1852 NTAPI
1854  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1855 );
1856 
1857 CODE_SEG("INIT")
1858 VOID
1859 NTAPI
1861  VOID
1862 );
1863 
1864 CODE_SEG("INIT")
1865 VOID
1866 NTAPI
1868  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1869 );
1870 
1871 VOID
1872 NTAPI
1874  VOID
1875 );
1876 
1877 VOID
1878 NTAPI
1880  VOID
1881 );
1882 
1883 CODE_SEG("INIT")
1884 BOOLEAN
1885 NTAPI
1887  VOID
1888 );
1889 
1890 CODE_SEG("INIT")
1891 PFN_NUMBER
1892 NTAPI
1894  IN PFN_NUMBER PageCount
1895 );
1896 
1897 CODE_SEG("INIT")
1899 NTAPI
1901  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1902  IN PBOOLEAN IncludeType
1903 );
1904 
1905 PFN_NUMBER
1906 NTAPI
1908  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1909  IN PBOOLEAN IncludeType
1910 );
1911 
1912 VOID
1913 FASTCALL
1915  IN PVOID AddressStart,
1916  IN PVOID AddressEnd
1917 );
1918 
1919 NTSTATUS
1920 NTAPI
1924  IN OUT PSIZE_T NumberOfBytesToProtect,
1925  IN ULONG NewAccessProtection,
1926  OUT PULONG OldAccessProtection OPTIONAL
1927 );
1928 
1929 NTSTATUS
1930 NTAPI
1932  IN ULONG FaultCode,
1933  IN PVOID Address,
1935  IN PVOID TrapInformation
1936 );
1937 
1938 NTSTATUS
1939 FASTCALL
1941  IN PVOID Address
1942 );
1943 
1944 CODE_SEG("INIT")
1945 VOID
1946 NTAPI
1948  VOID
1949 );
1950 
1951 CODE_SEG("INIT")
1952 VOID
1953 NTAPI
1955  VOID
1956 );
1957 
1958 CODE_SEG("INIT")
1959 VOID //
1960 NTAPI //
1961 InitializePool( //
1962  IN POOL_TYPE PoolType,// FIXFIX: This should go in ex.h after the pool merge
1963  IN ULONG Threshold //
1964 ); //
1965 
1966 // FIXFIX: THIS ONE TOO
1967 CODE_SEG("INIT")
1968 VOID
1969 NTAPI
1971  IN PPOOL_DESCRIPTOR PoolDescriptor,
1973  IN ULONG PoolIndex,
1974  IN ULONG Threshold,
1975  IN PVOID PoolLock
1976 );
1977 
1978 NTSTATUS
1979 NTAPI
1981  VOID
1982 );
1983 
1984 CODE_SEG("INIT")
1985 VOID
1986 NTAPI
1988  IN PMMPTE StartingPte,
1989  IN ULONG NumberOfPtes,
1991 );
1992 
1993 PMMPTE
1994 NTAPI
1996  IN ULONG NumberOfPtes,
1997  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1998 );
1999 
2000 VOID
2001 NTAPI
2003  IN PMMPTE StartingPte,
2004  IN ULONG NumberOfPtes,
2005  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
2006 );
2007 
2008 
2009 PFN_NUMBER
2010 NTAPI
2012  IN PFN_NUMBER LowestPfn,
2013  IN PFN_NUMBER HighestPfn,
2014  IN PFN_NUMBER BoundaryPfn,
2015  IN PFN_NUMBER SizeInPages,
2017 );
2018 
2019 PVOID
2020 NTAPI
2023  IN PFN_NUMBER BaseAddressPages,
2024  IN PFN_NUMBER SizeInPages,
2025  IN PFN_NUMBER LowestPfn,
2026  IN PFN_NUMBER HighestPfn,
2027  IN PFN_NUMBER BoundaryPfn,
2028  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute
2029 );
2030 
2031 PMDL
2032 NTAPI
2034  IN PHYSICAL_ADDRESS LowAddress,
2038  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
2039  IN ULONG Flags
2040 );
2041 
2042 VOID
2043 NTAPI
2045  IN PMMPFNLIST ListHead,
2046  IN PFN_NUMBER PageFrameIndex
2047 );
2048 
2049 VOID
2050 NTAPI
2052  IN PMMPFN Entry
2053 );
2054 
2055 VOID
2056 NTAPI
2058  IN PMMPFN Pfn
2059 );
2060 
2061 VOID
2062 NTAPI
2064  IN PFN_NUMBER PageFrameIndex,
2065  IN PMMPTE PointerPte,
2066  IN BOOLEAN Modified
2067 );
2068 
2069 NTSTATUS
2070 NTAPI
2072  OUT PPFN_NUMBER PageFrameIndex,
2073  IN PMMPDE PointerPde,
2074  IN PFN_NUMBER ContainingPageFrame,
2075  IN BOOLEAN SessionAllocation
2076 );
2077 
2078 VOID
2079 NTAPI
2081  IN PFN_NUMBER PageFrameIndex,
2082  IN PMMPTE PointerPte,
2083  IN MMPTE TempPte
2084 );
2085 
2086 VOID
2087 NTAPI
2089  IN PFN_NUMBER PageFrameIndex,
2090  IN PVOID PteAddress,
2091  IN PFN_NUMBER PteFrame
2092 );
2093 
2094 VOID
2095 NTAPI
2097  IN PMMPFN Pfn1,
2098  IN PFN_NUMBER PageFrameIndex
2099 );
2100 
2101 PFN_NUMBER
2102 NTAPI
2104  IN ULONG Color
2105 );
2106 
2107 PFN_NUMBER
2108 NTAPI
2110  IN ULONG Color
2111 );
2112 
2113 VOID
2114 NTAPI
2116  IN PFN_NUMBER PageFrameIndex
2117 );
2118 
2119 VOID
2120 NTAPI
2122  IN PFN_NUMBER PageFrameIndex
2123 );
2124 
2125 PFN_COUNT
2126 NTAPI
2128  IN PMMPTE PointerPte,
2129  IN PFN_NUMBER PageCount,
2130  IN ULONG Flags,
2131  OUT PPFN_NUMBER ValidPages
2132 );
2133 
2134 ULONG
2135 NTAPI
2137  IN PMMPTE PointerPte
2138 );
2139 
2141 NTAPI
2143  IN PVOID Address
2144 );
2145 
2146 CODE_SEG("INIT")
2147 VOID
2148 NTAPI
2150  VOID
2151 );
2152 
2153 CODE_SEG("INIT")
2154 VOID
2155 NTAPI
2157  VOID
2158 );
2159 
2160 CODE_SEG("INIT")
2161 VOID
2162 NTAPI
2164  VOID
2165 );
2166 
2167 BOOLEAN
2168 NTAPI
2169 MiIsPfnInUse(
2170  IN PMMPFN Pfn1
2171 );
2172 
2173 PMMVAD
2174 NTAPI
2177 );
2178 
2180 NTAPI
2182  IN ULONG_PTR StartVpn,
2183  IN ULONG_PTR EndVpn,
2185  OUT PMMADDRESS_NODE *NodeOrParent
2186 );
2187 
2189 NTAPI
2191  IN SIZE_T Length,
2192  IN ULONG_PTR BoundaryAddress,
2197 );
2198 
2199 NTSTATUS
2200 NTAPI
2202  IN SIZE_T Length,
2203  IN ULONG_PTR BoundaryAddress,
2207 );
2208 
2210 NTAPI
2212  IN SIZE_T Length,
2215  OUT PMMADDRESS_NODE *PreviousVad,
2217 );
2218 
2219 NTSTATUS
2220 NTAPI
2222  IN PMMVAD Vad,
2223  IN PVOID Base,
2224  IN SIZE_T Size,
2225  IN ULONG ProtectionMask
2226 );
2227 
2228 VOID
2229 NTAPI
2230 MiInsertVad(
2231  _Inout_ PMMVAD Vad,
2232  _Inout_ PMM_AVL_TABLE VadRoot);
2233 
2234 NTSTATUS
2235 NTAPI
2237  _Inout_ PMMVAD Vad,
2240  _In_ ULONG_PTR HighestAddress,
2243 
2244 VOID
2245 NTAPI
2247  IN PSECTION Section
2248 );
2249 
2250 NTSTATUS
2251 NTAPI
2255  IN ULONG Flags
2256 );
2257 
2258 NTSTATUS
2259 NTAPI
2263  IN BOOLEAN SkipDebuggerNotify
2264 );
2265 
2266 VOID
2267 NTAPI
2268 MiInsertNode(
2270  IN PMMADDRESS_NODE NewNode,
2273 );
2274 
2275 VOID
2276 NTAPI
2277 MiRemoveNode(
2280 );
2281 
2283 NTAPI
2286 );
2287 
2289 NTAPI
2292 );
2293 
2294 BOOLEAN
2295 NTAPI
2297  IN PMMSESSION InputSession OPTIONAL
2298 );
2299 
2300 VOID
2301 NTAPI
2303  VOID
2304 );
2305 
2306 VOID
2307 NTAPI
2309  IN PMM_SESSION_SPACE SessionGlobal
2310 );
2311 
2312 VOID
2313 NTAPI
2315  IN PEPROCESS NewProcess
2316 );
2317 
2318 NTSTATUS
2319 NTAPI
2321  IN PVOID StartVa,
2322  IN PVOID EndVa
2323 );
2324 
2325 ULONG
2326 NTAPI
2328  IN ULONG Protect
2329 );
2330 
2331 VOID
2332 NTAPI
2334  IN ULONG_PTR Va,
2335  IN ULONG_PTR EndingAddress,
2336  IN PMMVAD Vad
2337 );
2338 
2339 VOID
2340 NTAPI
2341 MiDeletePte(
2342  IN PMMPTE PointerPte,
2346 );
2347 
2348 ULONG
2349 NTAPI
2351  IN PVOID PageTableVirtualAddress,
2353 );
2354 
2355 ULONG
2356 NTAPI
2359  IN KIRQL OldIrql
2360 );
2361 
2362 VOID
2363 NTAPI
2366  IN PMMVAD Vad
2367 );
2368 
2370 NTAPI
2372  IN PMMVAD Vad,
2373  IN ULONG_PTR Vpn
2374 );
2375 
2376 VOID
2377 NTAPI
2379  PVOID ObjectBody
2380 );
2381 
2382 NTSTATUS
2383 NTAPI
2387  OUT PVOID MemoryInformation,
2388  IN SIZE_T MemoryInformationLength,
2390 );
2391 
2392 NTSTATUS
2393 NTAPI
2396 );
2397 
2398 VOID
2399 NTAPI
2401  IN PMMPDE PointerPde,
2402  IN PEPROCESS TargetProcess,
2403  IN KIRQL OldIrql
2404 );
2405 
2406 VOID
2407 NTAPI
2409  _In_ PVOID ImageBase);
2410 
2411 //
2412 // MiRemoveZeroPage will use inline code to zero out the page manually if only
2413 // free pages are available. In some scenarios, we don't/can't run that piece of
2414 // code and would rather only have a real zero page. If we can't have a zero page,
2415 // then we'd like to have our own code to grab a free page and zero it out, by
2416 // using MiRemoveAnyPage. This macro implements this.
2417 //
2419 PFN_NUMBER
2421 {
2423  return 0;
2424 }
2425 
2426 #if (_MI_PAGING_LEVELS == 2)
2428 BOOLEAN
2429 MiSynchronizeSystemPde(PMMPDE PointerPde)
2430 {
2431  MMPDE SystemPde;
2432  ULONG Index;
2433 
2434  /* Get the Index from the PDE */
2435  Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
2436 
2437  /* Copy the PDE from the double-mapped system page directory */
2438  SystemPde = MmSystemPagePtes[Index];
2439  *PointerPde = SystemPde;
2440 
2441  /* Make sure we re-read the PDE and PTE */
2443 
2444  /* Return, if we had success */
2445  return SystemPde.u.Hard.Valid != 0;
2446 }
2447 #endif
2448 
2449 #if _MI_PAGING_LEVELS == 2
2451 USHORT
2453 {
2454  PUSHORT RefCount;
2455 
2457 
2458  *RefCount += 1;
2459  ASSERT(*RefCount <= PTE_PER_PAGE);
2460  return *RefCount;
2461 }
2462 
2464 USHORT
2466 {
2467  PUSHORT RefCount;
2468 
2470 
2471  *RefCount -= 1;
2472  ASSERT(*RefCount < PTE_PER_PAGE);
2473  return *RefCount;
2474 }
2475 #else
2477 USHORT
2479 {
2480  PMMPDE PointerPde = MiAddressToPde(Address);
2481  PMMPFN Pfn;
2482 
2483  /* We should not tinker with this one. */
2484  ASSERT(PointerPde != (PMMPDE)PXE_SELFMAP);
2485  DPRINT("Incrementing %p from %p\n", Address, _ReturnAddress());
2486 
2487  /* Make sure we're locked */
2488  ASSERT(PsGetCurrentThread()->OwnsProcessWorkingSetExclusive);
2489 
2490  /* If we're bumping refcount, then it must be valid! */
2491  ASSERT(PointerPde->u.Hard.Valid == 1);
2492 
2493  /* This lies on the PFN */
2494  Pfn = MiGetPfnEntry(PFN_FROM_PDE(PointerPde));
2496 
2498 
2499  return Pfn->OriginalPte.u.Soft.UsedPageTableEntries;
2500 }
2501 
2503 USHORT
2505 {
2506  PMMPDE PointerPde = MiAddressToPde(Address);
2507  PMMPFN Pfn;
2508 
2509  /* We should not tinker with this one. */
2510  ASSERT(PointerPde != (PMMPDE)PXE_SELFMAP);
2511 
2512  DPRINT("Decrementing %p from %p\n", PointerPde, _ReturnAddress());
2513 
2514  /* Make sure we're locked */
2515  ASSERT(PsGetCurrentThread()->OwnsProcessWorkingSetExclusive);
2516 
2517  /* If we're decreasing refcount, then it must be valid! */
2518  ASSERT(PointerPde->u.Hard.Valid == 1);
2519 
2520  /* This lies on the PFN */
2521  Pfn = MiGetPfnEntry(PFN_FROM_PDE(PointerPde));
2522 
2525 
2527 
2528  return Pfn->OriginalPte.u.Soft.UsedPageTableEntries;
2529 }
2530 #endif
2531 
2532 #ifdef __cplusplus
2533 } // extern "C"
2534 #endif
2535 
2537 VOID
2539  _In_ PMMPDE PointerPde,
2541 {
2542  /* Only for user-mode ones */
2543  ASSERT(MiIsUserPde(PointerPde));
2544 
2545  /* Kill this one as a PTE */
2546  MiDeletePte((PMMPTE)PointerPde, MiPdeToPte(PointerPde), CurrentProcess, NULL);
2547 #if _MI_PAGING_LEVELS >= 3
2548  /* Cascade down */
2549  if (MiDecrementPageTableReferences(MiPdeToPte(PointerPde)) == 0)
2550  {
2551  MiDeletePte(MiPdeToPpe(PointerPde), PointerPde, CurrentProcess, NULL);
2552 #if _MI_PAGING_LEVELS == 4
2553  if (MiDecrementPageTableReferences(PointerPde) == 0)
2554  {
2555  MiDeletePte(MiPdeToPxe(PointerPde), MiPdeToPpe(PointerPde), CurrentProcess, NULL);
2556  }
2557 #endif
2558  }
2559 #endif
2560 }
2561 
2562 /* 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:505
ULONG MmProcessColorSeed
Definition: procsup.c:20
FORCEINLINE VOID MI_ERASE_PTE(IN PMMPTE PointerPte)
Definition: miarm.h:1011
ULONG_PTR MmSubsectionBase
Definition: section.c:197
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1034
Definition: bidi.c:433
FORCEINLINE BOOLEAN MI_IS_PROCESS_WORKING_SET(PMMSUPPORT WorkingSet)
Definition: miarm.h:666
ULONG SessionId
Definition: miarm.h:482
LIST_ENTRY ProcessList
Definition: miarm.h:483
VOID NTAPI MiInitializePfn(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN BOOLEAN Modified)
Definition: pfnlist.c:962
#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:486
BOOLEAN MmMirroring
Definition: pfnlist.c:35
_MI_PFN_CACHE_ATTRIBUTE
Definition: miarm.h:413
USHORT PoolTagHash
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:392
PVOID Blink
Definition: miarm.h:437
#define PFN_FROM_PDE(v)
Definition: mm.h:93
PVOID PagedPoolStart
Definition: miarm.h:488
_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:235
PFN_NUMBER StartFrame
Definition: miarm.h:443
LONG ReferenceCount
Definition: miarm.h:476
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:603
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:1244
#define _Inout_
Definition: ms_sal.h:378
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:1536
VOID NTAPI MiUnlinkPageFromList(IN PMMPFN Pfn)
Definition: pfnlist.c:265
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:1620
#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:883
#define MI_MAKE_ACCESSED_PAGE(x)
Definition: mm.h:100
ULONG OwnsSystemWorkingSetShared
Definition: pstypes.h:1224
signed short * PSHORT
Definition: retypes.h:6
#define _Out_
Definition: ms_sal.h:345
PMMPDE PageTables
Definition: miarm.h:512
_MMSYSTEM_PTE_POOL_TYPE
Definition: miarm.h:406
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:1220
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:209
ULONG PFN_COUNT
Definition: mmtypes.h:102
LONG ProcessReferenceToSession
Definition: miarm.h:499
#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:924
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:424
union _MM_SESSION_SPACE::@1778 u
PMMPTE MiSessionLastPte
Definition: mminit.c:146
VOID NTAPI MiDeleteARM3Section(PVOID ObjectBody)
Definition: section.c:3308
PFN_NUMBER MmHighMemoryThreshold
Definition: mminit.c:301
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
struct _MI_LARGE_PAGE_RANGES MI_LARGE_PAGE_RANGES
FORCEINLINE VOID MiReferenceUnusedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1792
FORCEINLINE USHORT MiDecrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:2504
PLDR_DATA_TABLE_ENTRY NTAPI MiLookupDataTableEntry(IN PVOID Address)
Definition: sysldr.c:3427
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
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
#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:1129
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
SIZE_T TotalBytes
Definition: miarm.h:326
ULONG KeFeatureBits
Definition: krnlinit.c:22
PCHAR SystemSpaceViewStart
Definition: miarm.h:457
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1282
PFN_NUMBER NumberOfPages
Definition: miarm.h:430
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:460
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
ULONG BitmapFailures
Definition: miarm.h:462
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:484
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:319
LIST_ENTRY ListHeads[POOL_LISTS_PER_PAGE]
Definition: miarm.h:328
#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:1747
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:403
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(IN PMMPTE NewPte, IN PVOID Segment)
Definition: miarm.h:888
PPOOL_TRACKER_TABLE PoolTrackTable
Definition: expool.c:49
PMMPFN MmPfnDatabase
Definition: freelist.c:24
KGUARDED_MUTEX SystemSpaceViewLock
Definition: miarm.h:455
VOID NTAPI MiDeletePte(IN PMMPTE PointerPte, IN PVOID VirtualAddress, IN PEPROCESS CurrentProcess, IN PMMPTE PrototypePte)
Definition: virtual.c:369
struct _POOL_HEADER * PPOOL_HEADER
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2253
MM_PAGED_POOL_INFO PagedPoolInfo
Definition: miarm.h:504
NTSTATUS NTAPI MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:697
enum _MI_PFN_CACHE_ATTRIBUTE MI_PFN_CACHE_ATTRIBUTE
PFN_NUMBER NTAPI MiRemoveZeroPage(IN ULONG Color)
Definition: pfnlist.c:533
MMPTE DemandZeroPte
Definition: init.c:37
SIZE_T MmSizeOfPagedPoolInBytes
Definition: miarm.h:590
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:1119
PMMPTE MmLastReservedMappingPte
Definition: hypermap.c:20
VOID NTAPI MiInitializeSessionWsSupport(VOID)
Definition: session.c:40
PVOID MmSessionBase
Definition: miarm.h:584
FORCEINLINE BOOLEAN MM_ANY_WS_LOCK_HELD(IN PETHREAD Thread)
Definition: miarm.h:1057
enum _MM_SYSTEM_SIZE MM_SYSTEMSIZE
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:683
struct _MMSESSION * PMMSESSION
SIZE_T MmSystemLockPagesCount
Definition: mdlsup.c:22
PDRIVER_UNLOAD Win32KDriverUnload
Definition: miarm.h:507
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:500
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:964
ULONG MmVerifyDriverBufferLength
Definition: drvmgmt.c:24
LIST_ENTRY Links
Definition: miarm.h:402
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
PFN_NUMBER BasePage
Definition: miarm.h:423
#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:1040
long LONG
Definition: pedump.c:60
ULONG SessionSpace
Definition: mmtypes.h:902
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:722
PFN_NUMBER Flink
Definition: miarm.h:436
USHORT AllocatorBackTraceIndex
ULONG OwnsSessionWorkingSetExclusive
Definition: pstypes.h:1225
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1250
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:2420
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:1103
POOL_DESCRIPTOR PagedPool
Definition: miarm.h:508
FORCEINLINE VOID MI_MAKE_TRANSITION_PTE(_Out_ PMMPTE NewPte, _In_ PFN_NUMBER Page, _In_ ULONG Protection)
Definition: miarm.h:934
VOID NTAPI MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde, IN PEPROCESS TargetProcess, IN KIRQL OldIrql)
Definition: virtual.c:2470
FORCEINLINE PMMPTE MiPdeToPte(PMMPDE PointerPde)
Definition: mm.h:237
_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:859
#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 _In_
Definition: ms_sal.h:308
ULONG MmVerifyDriverLevel
Definition: drvmgmt.c:26
KEVENT MmZeroingPageEvent
Definition: zeropage.c:20
ULONG MmSecondaryColorMask
Definition: mminit.c:257
PVOID MiSystemViewStart
Definition: miarm.h:647
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:771
FORCEINLINE VOID MiUnlockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1356
SIZE_T NonPagedBytes
Definition: miarm.h:377
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1023
PFN_NUMBER Page
Definition: section.c:4923
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 * PVOID
Definition: retypes.h:9
VOID NTAPI MiReleaseSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:264
Definition: miarm.h:400
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:458
ULONG SystemSpaceHashKey
Definition: miarm.h:461
ULONG NTAPI MiMakeSystemAddressValid(IN PVOID PageTableVirtualAddress, IN PEPROCESS CurrentProcess)
Definition: virtual.c:183
_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:323
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:741
ULONG PoolIndex
Definition: miarm.h:317
KIRQL OldIrql
Definition: mm.h:1502
#define PXE_SELFMAP
ULONG LongFlags
Definition: miarm.h:479
NTSTATUS NTAPI MiRosUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:4446
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:1174
MMSUPPORT_FLAGS Flags
Definition: mmtypes.h:930
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:958
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:480
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:475
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:44
FORCEINLINE VOID MiUnlockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, OUT PBOOLEAN Safe, OUT PBOOLEAN Shared)
Definition: miarm.h:1473
ULONG RunningAllocs
Definition: miarm.h:318
SIZE_T CommittedPages
Definition: miarm.h:487
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MI_IS_SESSION_PTE(Pte)
Definition: miarm.h:174
ULONG64 UsedPageTableEntries
Definition: mmtypes.h:91
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:502
ULONG64 Valid
Definition: mmtypes.h:150
LONG PendingFreeDepth
Definition: miarm.h:325
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:2652
struct _PHYSICAL_MEMORY_RUN PHYSICAL_MEMORY_RUN
LONG NonPagedFrees
Definition: miarm.h:376
#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:1945
union _MMPTE::@2275 u
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
#define MM_PROTECT_ACCESS
Definition: miarm.h:51
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:493
PMMADDRESS_NODE NTAPI MiGetNextNode(IN PMMADDRESS_NODE Node)
Definition: vadnode.c:467
PVOID MmHighSectionBase
Definition: section.c:111
ULONG Threshold
Definition: miarm.h:322
SIZE_T Spare0
Definition: miarm.h:327
FORCEINLINE VOID MiLockProcessWorkingSetShared(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1151
PVOID MiSessionSpaceEnd
Definition: init.c:27
SIZE_T PagedBytes
Definition: miarm.h:380
ULONG TotalPages
Definition: miarm.h:320
ULONG_PTR MxPfnAllocation
Definition: init.c:43
SIZE_T MmBootImageSize
Definition: init.c:49
FORCEINLINE BOOLEAN MiIsUserPte(PVOID Address)
Definition: miarm.h:730
VOID NTAPI MiDecrementReferenceCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1224
#define PDE_TOP
Definition: mm.h:161
char * PBOOLEAN
Definition: retypes.h:11
FORCEINLINE USHORT MiIncrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:2478
FORCEINLINE PMMPFN MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
Definition: miarm.h:1579
PKGUARDED_MUTEX SystemSpaceViewLockPointer
Definition: miarm.h:456
PFN_NUMBER MmLowMemoryThreshold
Definition: mminit.c:300
PVOID PagedPoolEnd
Definition: miarm.h:489
KGUARDED_MUTEX PagedPoolMutex
Definition: miarm.h:503
PCONTROL_AREA ControlArea
Definition: miarm.h:450
PFN_NUMBER MmMaximumNonPagedPoolInPages
Definition: mminit.c:30
PMMPTE MiSessionImagePteStart
Definition: mminit.c:143
#define MM_GUARDPAGE
Definition: miarm.h:57
FORCEINLINE VOID MiDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1590
ULONG NTAPI MiMakeProtectionMask(IN ULONG Protect)
Definition: section.c:158
BOOLEAN MmMakeLowMemory
Definition: sysldr.c:46
SLIST_HEADER MmDeadStackSListHead
Definition: procsup.c:22
Definition: mm.h:362
Definition: btrfs_drv.h:1922
ULONG MmMinAdditionNonPagedPoolPerMb
Definition: mminit.c:40
FORCEINLINE VOID MiUnlockWorkingSetShared(_In_ PETHREAD Thread, _In_ PMMSUPPORT WorkingSet)
Definition: miarm.h:1394
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
#define PTE_BASE
Definition: mmx86.c:14
Definition: typedefs.h:119
struct _PHYSICAL_MEMORY_RUN * PPHYSICAL_MEMORY_RUN
ULONG OwnsSystemWorkingSetExclusive
Definition: pstypes.h:1223
FORCEINLINE VOID MiDeletePde(_In_ PMMPDE PointerPde, _In_ PEPROCESS CurrentProcess)
Definition: miarm.h:2538
#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:494
_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:498
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:1000
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:579
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:275
FORCEINLINE VOID MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte, IN PMMPTE MappingPte, IN ULONG_PTR ProtectionMask, IN PFN_NUMBER PageFrameNumber)
Definition: miarm.h:832
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:321
PVOID PendingFrees
Definition: miarm.h:324
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
VOID NTAPI MiDeleteVirtualAddresses(IN ULONG_PTR Va, IN ULONG_PTR EndingAddress, IN PMMVAD Vad)
Definition: virtual.c:530
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:477
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1103
FORCEINLINE VOID MiLockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, IN BOOLEAN Safe, IN BOOLEAN Shared)
Definition: miarm.h:1506
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:997
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:1311
KEVENT AttachEvent
Definition: miarm.h:497
MMPTE HyperTemplatePte
Definition: hypermap.c:22
struct _MMSESSION MMSESSION
PRTL_BITMAP SystemSpaceBitMap
Definition: miarm.h:463
SIZE_T MmDefaultMaximumNonPagedPool
Definition: mminit.c:41
ULONG MmVerifyDriverBufferType
Definition: drvmgmt.c:25
USHORT PreviousSize
FORCEINLINE PMMPDE MiPdeToPpe(PMMPDE PointerPde)
Definition: mm.h:285
POOL_TYPE PoolType
Definition: miarm.h:316
_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
FORCEINLINE PMMPXE MiPdeToPxe(PMMPDE PointerPde)
Definition: mm.h:293
ULONG NTAPI MiGetPageProtection(IN PMMPTE PointerPte)
Definition: virtual.c:1348
PMMWSLE Wsle
Definition: miarm.h:506
#define MI_IS_ROS_PFN(x)
Definition: miarm.h:1108
Definition: miarm.h:447
NTSTATUS NTAPI MiInitializeSessionPool(VOID)
Definition: pool.c:1289
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define FORCEINLINE
Definition: wdftypes.h:67
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
LONG ResidentProcessCount
Definition: miarm.h:492
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:1137
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
MMPTE_SOFTWARE Soft
Definition: mmtypes.h:219
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
MMPTE OriginalPte
Definition: mm.h:396
VOID NTAPI MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:672
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1549
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define InterlockedCompareExchange16
Definition: interlocked.h:109
FORCEINLINE BOOLEAN MM_ANY_WS_LOCK_HELD_EXCLUSIVE(_In_ PETHREAD Thread)
Definition: miarm.h:1070
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:276
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:580
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:673
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:2151
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
void * _ReturnAddress(void)
VOID NTAPI MiSessionAddProcess(IN PEPROCESS NewProcess)
Definition: session.c:423
LONG NonPagedAllocs
Definition: miarm.h:375
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:1020
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:1433
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1211
VOID NTAPI MiInitializePfnAndMakePteValid(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: pfnlist.c:1033
_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:21
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
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:449
BOOLEAN NTAPI MiIsPfnInUse(IN PMMPFN Pfn1)
Definition: freelist.c:174
ULONG AttachCount
Definition: miarm.h:496
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:438
#define InterlockedDecrementSizeT(a)
Definition: interlocked.h:153
ULONG OwnsProcessWorkingSetExclusive
Definition: pstypes.h:1221
PMMWSL MmWorkingSetList
Definition: wslist.cpp:19
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:274
FORCEINLINE VOID MiReferenceProbedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1692
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:778
#define KF_GLOBAL_PAGE
Definition: ketypes.h:147
PMMPTE MiSessionBasePte
Definition: mminit.c:145
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1270
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1679
PMMPTE MiHighestUserPte
Definition: mminit.c:233
#define DPRINT
Definition: sndvol32.h:71
MMPTE ValidKernelPteLocal
Definition: init.c:33
#define KeGetCurrentThread
Definition: hal.h:55
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:459
_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:950
FORCEINLINE VOID MI_UPDATE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:982
FORCEINLINE BOOLEAN MI_WS_OWNER(IN PEPROCESS Process)
Definition: miarm.h:1082
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:3555
PKEVENT MiHighMemoryEvent
Definition: mminit.c:293
PMMPDE PagedPoolBasePde
Definition: miarm.h:490
PFN_NUMBER LastFrame
Definition: miarm.h:444
PFN_NUMBER MmTotalSystemDriverPages
Definition: sysldr.c:41
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
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:521
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:812
_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:1199
PMMPDE MmSystemPagePtes
Definition: init.c:41
FORCEINLINE PMMPTE MI_GET_PROTOTYPE_PTE_FOR_VPN(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: miarm.h:1562
ULONG PageFrameNumber
Definition: mmtypes.h:109
Definition: dlist.c:348
PFN_NUMBER SessionPageDirectoryIndex
Definition: miarm.h:485
Definition: mm.h:430
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:581
PMMPTE MiSessionImagePteEnd
Definition: mminit.c:144