ReactOS  0.4.14-dev-1286-g61a54ae
miarm.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: ntoskrnl/mm/ARM3/miarm.h
5  * PURPOSE: ARM Memory Manager Header
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 #pragma once
10 
11 #define MI_LOWEST_VAD_ADDRESS (PVOID)MM_LOWEST_USER_ADDRESS
12 
13 /* Make the code cleaner with some definitions for size multiples */
14 #define _1KB (1024u)
15 #define _1MB (1024 * _1KB)
16 #define _1GB (1024 * _1MB)
17 
18 /* Everyone loves 64K */
19 #define _64K (64 * _1KB)
20 
21 /* Area mapped by a PDE */
22 #define PDE_MAPPED_VA (PTE_PER_PAGE * PAGE_SIZE)
23 
24 /* Size of a page table */
25 #define PT_SIZE (PTE_PER_PAGE * sizeof(MMPTE))
26 
27 /* Size of a page directory */
28 #define PD_SIZE (PDE_PER_PAGE * sizeof(MMPDE))
29 
30 /* Size of all page directories for a process */
31 #define SYSTEM_PD_SIZE (PPE_PER_PAGE * PD_SIZE)
32 #ifdef _M_IX86
34 #endif
35 
36 //
37 // Protection Bits part of the internal memory manager Protection Mask, from:
38 // http://reactos.org/wiki/Techwiki:Memory_management_in_the_Windows_XP_kernel
39 // https://www.reactos.org/wiki/Techwiki:Memory_Protection_constants
40 // and public assertions.
41 //
42 #define MM_ZERO_ACCESS 0
43 #define MM_READONLY 1
44 #define MM_EXECUTE 2
45 #define MM_EXECUTE_READ 3
46 #define MM_READWRITE 4
47 #define MM_WRITECOPY 5
48 #define MM_EXECUTE_READWRITE 6
49 #define MM_EXECUTE_WRITECOPY 7
50 #define MM_PROTECT_ACCESS 7
51 
52 //
53 // These are flags on top of the actual protection mask
54 //
55 #define MM_NOCACHE 0x08
56 #define MM_GUARDPAGE 0x10
57 #define MM_WRITECOMBINE 0x18
58 #define MM_PROTECT_SPECIAL 0x18
59 
60 //
61 // These are special cases
62 //
63 #define MM_DECOMMIT (MM_ZERO_ACCESS | MM_GUARDPAGE)
64 #define MM_NOACCESS (MM_ZERO_ACCESS | MM_WRITECOMBINE)
65 #define MM_OUTSWAPPED_KSTACK (MM_EXECUTE_WRITECOPY | MM_WRITECOMBINE)
66 #define MM_INVALID_PROTECTION 0xFFFFFFFF
67 
68 //
69 // Specific PTE Definitions that map to the Memory Manager's Protection Mask Bits
70 // The Memory Manager's definition define the attributes that must be preserved
71 // and these PTE definitions describe the attributes in the hardware sense. This
72 // helps deal with hardware differences between the actual boolean expression of
73 // the argument.
74 //
75 // For example, in the logical attributes, we want to express read-only as a flag
76 // but on x86, it is writability that must be set. On the other hand, on x86, just
77 // like in the kernel, it is disabling the caches that requires a special flag,
78 // while on certain architectures such as ARM, it is enabling the cache which
79 // requires a flag.
80 //
81 #if defined(_M_IX86)
82 //
83 // Access Flags
84 //
85 #define PTE_READONLY 0 // Doesn't exist on x86
86 #define PTE_EXECUTE 0 // Not worrying about NX yet
87 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
88 #define PTE_READWRITE 0x2
89 #define PTE_WRITECOPY 0x200
90 #define PTE_EXECUTE_READWRITE 0x2 // Not worrying about NX yet
91 #define PTE_EXECUTE_WRITECOPY 0x200
92 #define PTE_PROTOTYPE 0x400
93 
94 //
95 // State Flags
96 //
97 #define PTE_VALID 0x1
98 #define PTE_ACCESSED 0x20
99 #define PTE_DIRTY 0x40
100 
101 //
102 // Cache flags
103 //
104 #define PTE_ENABLE_CACHE 0
105 #define PTE_DISABLE_CACHE 0x10
106 #define PTE_WRITECOMBINED_CACHE 0x10
107 #define PTE_PROTECT_MASK 0x612
108 #elif defined(_M_AMD64)
109 //
110 // Access Flags
111 //
112 #define PTE_READONLY 0x8000000000000000ULL
113 #define PTE_EXECUTE 0x0000000000000000ULL
114 #define PTE_EXECUTE_READ PTE_EXECUTE /* EXECUTE implies READ on x64 */
115 #define PTE_READWRITE 0x8000000000000002ULL
116 #define PTE_WRITECOPY 0x8000000000000200ULL
117 #define PTE_EXECUTE_READWRITE 0x0000000000000002ULL
118 #define PTE_EXECUTE_WRITECOPY 0x0000000000000200ULL
119 #define PTE_PROTOTYPE 0x0000000000000400ULL
120 
121 //
122 // State Flags
123 //
124 #define PTE_VALID 0x0000000000000001ULL
125 #define PTE_ACCESSED 0x0000000000000020ULL
126 #define PTE_DIRTY 0x0000000000000040ULL
127 
128 //
129 // Cache flags
130 //
131 #define PTE_ENABLE_CACHE 0x0000000000000000ULL
132 #define PTE_DISABLE_CACHE 0x0000000000000010ULL
133 #define PTE_WRITECOMBINED_CACHE 0x0000000000000010ULL
134 #define PTE_PROTECT_MASK 0x8000000000000612ULL
135 #elif defined(_M_ARM)
136 #define PTE_READONLY 0x200
137 #define PTE_EXECUTE 0 // Not worrying about NX yet
138 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
139 #define PTE_READWRITE 0 // Doesn't exist on ARM
140 #define PTE_WRITECOPY 0 // Doesn't exist on ARM
141 #define PTE_EXECUTE_READWRITE 0 // Not worrying about NX yet
142 #define PTE_EXECUTE_WRITECOPY 0 // Not worrying about NX yet
143 #define PTE_PROTOTYPE 0x400 // Using the Shared bit
144 
145 //
146 // Cache flags
147 //
148 #define PTE_ENABLE_CACHE 0
149 #define PTE_DISABLE_CACHE 0x10
150 #define PTE_WRITECOMBINED_CACHE 0x10
151 #define PTE_PROTECT_MASK 0x610
152 #else
153 #error Define these please!
154 #endif
155 
156 //
157 // Mask for image section page protection
158 //
159 #define IMAGE_SCN_PROTECTION_MASK (IMAGE_SCN_MEM_WRITE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE)
160 
161 extern const ULONG_PTR MmProtectToPteMask[32];
162 extern const ULONG MmProtectToValue[32];
163 
164 //
165 // Assertions for session images, addresses, and PTEs
166 //
167 #define MI_IS_SESSION_IMAGE_ADDRESS(Address) \
168  (((Address) >= MiSessionImageStart) && ((Address) < MiSessionImageEnd))
169 
170 #define MI_IS_SESSION_ADDRESS(Address) \
171  (((Address) >= MmSessionBase) && ((Address) < MiSessionSpaceEnd))
172 
173 #define MI_IS_SESSION_PTE(Pte) \
174  ((((PMMPTE)Pte) >= MiSessionBasePte) && (((PMMPTE)Pte) < MiSessionLastPte))
175 
176 #define MI_IS_PAGE_TABLE_ADDRESS(Address) \
177  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)PTE_TOP))
178 
179 #define MI_IS_SYSTEM_PAGE_TABLE_ADDRESS(Address) \
180  (((Address) >= (PVOID)MiAddressToPte(MmSystemRangeStart)) && ((Address) <= (PVOID)PTE_TOP))
181 
182 #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(Address) \
183  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)MmHyperSpaceEnd))
184 
185 //
186 // Creates a software PTE with the given protection
187 //
188 #define MI_MAKE_SOFTWARE_PTE(p, x) ((p)->u.Long = (x << MM_PTE_SOFTWARE_PROTECTION_BITS))
189 
190 //
191 // Marks a PTE as deleted
192 //
193 #define MI_SET_PFN_DELETED(x) ((x)->PteAddress = (PMMPTE)((ULONG_PTR)(x)->PteAddress | 1))
194 #define MI_IS_PFN_DELETED(x) ((ULONG_PTR)((x)->PteAddress) & 1)
195 
196 //
197 // Special values for LoadedImports
198 //
199 #ifdef _WIN64
200 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFFFFFFFFFEULL
201 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFFFFFFFFFFULL
202 #else
203 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFE
204 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFF
205 #endif
206 #define MM_SYSLDR_SINGLE_ENTRY 0x1
207 
208 //
209 // Number of initial session IDs
210 //
211 #define MI_INITIAL_SESSION_IDS 64
212 
213 #if defined(_M_IX86) || defined(_M_ARM)
214 //
215 // PFN List Sentinel
216 //
217 #define LIST_HEAD 0xFFFFFFFF
218 
219 //
220 // Because GCC cannot automatically downcast 0xFFFFFFFF to lesser-width bits,
221 // we need a manual definition suited to the number of bits in the PteFrame.
222 // This is used as a LIST_HEAD for the colored list
223 //
224 #define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
225 #elif defined(_M_AMD64)
226 #define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
227 #define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
228 #else
229 #error Define these please!
230 #endif
231 
232 //
233 // Special IRQL value (found in assertions)
234 //
235 #define MM_NOIRQL (KIRQL)0xFFFFFFFF
236 
237 //
238 // Returns the color of a page
239 //
240 #define MI_GET_PAGE_COLOR(x) ((x) & MmSecondaryColorMask)
241 #define MI_GET_NEXT_COLOR() (MI_GET_PAGE_COLOR(++MmSystemPageColor))
242 #define MI_GET_NEXT_PROCESS_COLOR(x) (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
243 
244 //
245 // Prototype PTEs that don't yet have a pagefile association
246 //
247 #ifdef _WIN64
248 #define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
249 #else
250 #define MI_PTE_LOOKUP_NEEDED 0xFFFFF
251 #endif
252 
253 //
254 // Number of session data and tag pages
255 //
256 #define MI_SESSION_DATA_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
257 #define MI_SESSION_TAG_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
258 
259 //
260 // Used by MiCheckSecuredVad
261 //
262 #define MM_READ_WRITE_ALLOWED 11
263 #define MM_READ_ONLY_ALLOWED 10
264 #define MM_NO_ACCESS_ALLOWED 01
265 #define MM_DELETE_CHECK 85
266 
267 //
268 // System views are binned into 64K chunks
269 //
270 #define MI_SYSTEM_VIEW_BUCKET_SIZE _64K
271 
272 //
273 // FIXFIX: These should go in ex.h after the pool merge
274 //
275 #ifdef _WIN64
276 #define POOL_BLOCK_SIZE 16
277 #else
278 #define POOL_BLOCK_SIZE 8
279 #endif
280 #define POOL_LISTS_PER_PAGE (PAGE_SIZE / POOL_BLOCK_SIZE)
281 #define BASE_POOL_TYPE_MASK 1
282 #define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + POOL_BLOCK_SIZE))
283 
284 //
285 // Pool debugging/analysis/tracing flags
286 //
287 #define POOL_FLAG_CHECK_TIMERS 0x1
288 #define POOL_FLAG_CHECK_WORKERS 0x2
289 #define POOL_FLAG_CHECK_RESOURCES 0x4
290 #define POOL_FLAG_VERIFIER 0x8
291 #define POOL_FLAG_CHECK_DEADLOCK 0x10
292 #define POOL_FLAG_SPECIAL_POOL 0x20
293 #define POOL_FLAG_DBGPRINT_ON_FAILURE 0x40
294 #define POOL_FLAG_CRASH_ON_FAILURE 0x80
295 
296 //
297 // BAD_POOL_HEADER codes during pool bugcheck
298 //
299 #define POOL_CORRUPTED_LIST 3
300 #define POOL_SIZE_OR_INDEX_MISMATCH 5
301 #define POOL_ENTRIES_NOT_ALIGNED_PREVIOUS 6
302 #define POOL_HEADER_NOT_ALIGNED 7
303 #define POOL_HEADER_IS_ZERO 8
304 #define POOL_ENTRIES_NOT_ALIGNED_NEXT 9
305 #define POOL_ENTRY_NOT_FOUND 10
306 
307 //
308 // BAD_POOL_CALLER codes during pool bugcheck
309 //
310 #define POOL_ENTRY_CORRUPTED 1
311 #define POOL_ENTRY_ALREADY_FREE 6
312 #define POOL_ENTRY_NOT_ALLOCATED 7
313 #define POOL_ALLOC_IRQL_INVALID 8
314 #define POOL_FREE_IRQL_INVALID 9
315 #define POOL_BILLED_PROCESS_INVALID 13
316 #define POOL_HEADER_SIZE_INVALID 32
317 
318 typedef struct _POOL_DESCRIPTOR
319 {
334 
335 typedef struct _POOL_HEADER
336 {
337  union
338  {
339  struct
340  {
341 #ifdef _WIN64
343  USHORT PoolIndex:8;
344  USHORT BlockSize:8;
345  USHORT PoolType:8;
346 #else
348  USHORT PoolIndex:7;
349  USHORT BlockSize:9;
350  USHORT PoolType:7;
351 #endif
352  };
353  ULONG Ulong1;
354  };
355 #ifdef _WIN64
356  ULONG PoolTag;
357 #endif
358  union
359  {
360 #ifdef _WIN64
361  PEPROCESS ProcessBilled;
362 #else
363  ULONG PoolTag;
364 #endif
365  struct
366  {
369  };
370  };
372 
375 
376 typedef struct _POOL_TRACKER_TABLE
377 {
386 
388 {
394 
399 
400 //
401 // END FIXFIX
402 //
403 
405 {
409 
411 {
416 
418 {
424 
425 typedef struct _PHYSICAL_MEMORY_RUN
426 {
430 
432 {
437 
438 typedef struct _MMCOLOR_TABLES
439 {
444 
445 typedef struct _MI_LARGE_PAGE_RANGES
446 {
450 
451 typedef struct _MMVIEW
452 {
455 } MMVIEW, *PMMVIEW;
456 
457 typedef struct _MMSESSION
458 {
469 
471 {
476 
477 typedef struct _MM_SESSION_SPACE
478 {
481  union
482  {
485  } u;
513 #if defined (_M_AMD64)
514  MMPDE PageDirectory;
515 #else
517 #endif
518 #if defined (_M_AMD64)
519  PMMPTE SpecialPoolFirstPte;
520  PMMPTE SpecialPoolLastPte;
521  PMMPTE NextPdeForSpecialPoolExpansion;
522  PMMPTE LastPdeForSpecialPoolExpansion;
523  PFN_NUMBER SpecialPagesInUse;
524 #endif
527 
529 extern MMPTE HyperTemplatePte;
530 extern MMPDE ValidKernelPde;
531 extern MMPTE ValidKernelPte;
534 extern MMPDE DemandZeroPde;
535 extern MMPTE DemandZeroPte;
536 extern MMPTE PrototypePte;
537 extern MMPTE MmDecommittedPte;
539 extern BOOLEAN MmZeroPageFile;
542 extern BOOLEAN MmTrackPtes;
543 extern BOOLEAN MmDynamicPfn;
544 extern BOOLEAN MmMirroring;
545 extern BOOLEAN MmMakeLowMemory;
551 extern WCHAR MmVerifyDriverBuffer[512];
552 extern WCHAR MmLargePageDriverBuffer[512];
564 extern PVOID MmNonPagedPoolEnd;
566 extern PVOID MmPagedPoolStart;
567 extern PVOID MmPagedPoolEnd;
568 extern PVOID MmSessionBase;
569 extern SIZE_T MmSessionSize;
574 extern SIZE_T MmBootImageSize;
581 extern RTL_BITMAP MiPfnBitMap;
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;
639 extern PVOID MiSessionImageEnd;
640 extern PMMPTE MiHighestUserPte;
641 extern PMMPDE MiHighestUserPde;
647 extern ULONG MmSystemPageColor;
649 extern PMMWSL MmWorkingSetList;
655 extern PVOID MiSessionPoolEnd; // 0xBE000000
656 extern PVOID MiSessionPoolStart; // 0xBD000000
657 extern PVOID MiSessionViewStart; // 0xBE000000
658 extern PVOID MiSessionSpaceWs;
663 extern PVOID MmHighSectionBase;
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)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  /* Start fresh */
789  *NewPte = ValidKernelPte;
790 
791  /* Set the protection and page */
792  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
793  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
794 }
795 
796 //
797 // Creates a valid PTE with the given protection
798 //
800 VOID
802  IN PMMPTE MappingPte,
803  IN ULONG_PTR ProtectionMask,
804  IN PFN_NUMBER PageFrameNumber)
805 {
806  /* Set the protection and page */
807  NewPte->u.Long = MiDetermineUserGlobalPteMask(MappingPte);
808  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
809  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
810 }
811 
812 //
813 // Creates a valid user PTE with the given protection
814 //
816 VOID
818  IN PMMPTE MappingPte,
819  IN ULONG_PTR ProtectionMask,
820  IN PFN_NUMBER PageFrameNumber)
821 {
822  /* Only valid for kernel, non-session PTEs */
823  ASSERT(MappingPte <= MiHighestUserPte);
824 
825  /* Start fresh */
826  NewPte->u.Long = 0;
827 
828  /* Set the protection and page */
829  NewPte->u.Hard.Valid = TRUE;
830  NewPte->u.Hard.Owner = TRUE;
831  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
832  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
833 }
834 
835 #ifndef _M_AMD64
836 //
837 // Builds a Prototype PTE for the address of the PTE
838 //
840 VOID
842  IN PMMPTE PointerPte)
843 {
845 
846  /* Mark this as a prototype */
847  NewPte->u.Long = 0;
848  NewPte->u.Proto.Prototype = 1;
849 
850  /*
851  * Prototype PTEs are only valid in paged pool by design, this little trick
852  * lets us only use 30 bits for the adress of the PTE, as long as the area
853  * stays 1024MB At most.
854  */
855  Offset = (ULONG_PTR)PointerPte - (ULONG_PTR)MmPagedPoolStart;
856 
857  /*
858  * 7 bits go in the "low" (but we assume the bottom 2 are zero)
859  * and the other 21 bits go in the "high"
860  */
861  NewPte->u.Proto.ProtoAddressLow = (Offset & 0x1FC) >> 2;
862  NewPte->u.Proto.ProtoAddressHigh = (Offset & 0x3FFFFE00) >> 9;
863 }
864 
865 //
866 // Builds a Subsection PTE for the address of the Segment
867 //
869 VOID
871  IN PVOID Segment)
872 {
874 
875  /* Mark this as a prototype */
876  NewPte->u.Long = 0;
877  NewPte->u.Subsect.Prototype = 1;
878 
879  /*
880  * Segments are only valid either in nonpaged pool. We store the 20 bit
881  * difference either from the top or bottom of nonpaged pool, giving a
882  * maximum of 128MB to each delta, meaning nonpaged pool cannot exceed
883  * 256MB.
884  */
885  if ((ULONG_PTR)Segment < ((ULONG_PTR)MmSubsectionBase + (128 * _1MB)))
886  {
888  NewPte->u.Subsect.WhichPool = PagedPool;
889  }
890  else
891  {
893  NewPte->u.Subsect.WhichPool = NonPagedPool;
894  }
895 
896  /*
897  * 4 bits go in the "low" (but we assume the bottom 3 are zero)
898  * and the other 20 bits go in the "high"
899  */
900  NewPte->u.Subsect.SubsectionAddressLow = (Offset & 0x78) >> 3;
901  NewPte->u.Subsect.SubsectionAddressHigh = (Offset & 0xFFFFF80) >> 7;
902 }
903 
905 BOOLEAN
907 {
909  return ((PointerPte->u.Long & 0xFFFFFC01) != 0);
910 }
911 
912 #endif
913 
915 VOID
917  _In_ PFN_NUMBER Page,
918  _In_ ULONG Protection)
919 {
920  NewPte->u.Long = 0;
921  NewPte->u.Trans.Transition = 1;
922  NewPte->u.Trans.Protection = Protection;
923  NewPte->u.Trans.PageFrameNumber = Page;
924 }
925 
926 //
927 // Returns if the page is physically resident (ie: a large page)
928 // FIXFIX: CISC/x86 only?
929 //
931 BOOLEAN
933 {
934  PMMPDE PointerPde;
935 
936  /* Large pages are never paged out, always physically resident */
937  PointerPde = MiAddressToPde(Address);
938  return ((PointerPde->u.Hard.LargePage) && (PointerPde->u.Hard.Valid));
939 }
940 
941 //
942 // Writes a valid PTE
943 //
945 VOID
947  IN MMPTE TempPte)
948 {
949  /* Write the valid PTE */
950  ASSERT(PointerPte->u.Hard.Valid == 0);
951  ASSERT(TempPte.u.Hard.Valid == 1);
952  *PointerPte = TempPte;
953 }
954 
955 //
956 // Updates a valid PTE
957 //
959 VOID
961  IN MMPTE TempPte)
962 {
963  /* Write the valid PTE */
964  ASSERT(PointerPte->u.Hard.Valid == 1);
965  ASSERT(TempPte.u.Hard.Valid == 1);
966  ASSERT(PointerPte->u.Hard.PageFrameNumber == TempPte.u.Hard.PageFrameNumber);
967  *PointerPte = TempPte;
968 }
969 
970 //
971 // Writes an invalid PTE
972 //
974 VOID
976  IN MMPTE InvalidPte)
977 {
978  /* Write the invalid PTE */
979  ASSERT(InvalidPte.u.Hard.Valid == 0);
980  ASSERT(InvalidPte.u.Long != 0);
981  *PointerPte = InvalidPte;
982 }
983 
984 //
985 // Erase the PTE completely
986 //
988 VOID
989 MI_ERASE_PTE(IN PMMPTE PointerPte)
990 {
991  /* Zero out the PTE */
992  ASSERT(PointerPte->u.Long != 0);
993  PointerPte->u.Long = 0;
994 }
995 
996 //
997 // Writes a valid PDE
998 //
1000 VOID
1002  IN MMPDE TempPde)
1003 {
1004  /* Write the valid PDE */
1005  ASSERT(PointerPde->u.Hard.Valid == 0);
1006  ASSERT(TempPde.u.Hard.Valid == 1);
1007  *PointerPde = TempPde;
1008 }
1009 
1010 //
1011 // Writes an invalid PDE
1012 //
1014 VOID
1016  IN MMPDE InvalidPde)
1017 {
1018  /* Write the invalid PDE */
1019  ASSERT(InvalidPde.u.Hard.Valid == 0);
1020  ASSERT(InvalidPde.u.Long != 0);
1021  *PointerPde = InvalidPde;
1022 }
1023 
1024 //
1025 // Checks if the thread already owns a working set
1026 //
1028 BOOLEAN
1030 {
1031  /* If any of these are held, return TRUE */
1038 }
1039 
1040 //
1041 // Checks if the process owns the working set lock
1042 //
1044 BOOLEAN
1046 {
1047  /* Check if this process is the owner, and that the thread owns the WS */
1048  if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0)
1049  {
1050  DPRINT("Thread: %p is not an owner\n", PsGetCurrentThread());
1051  }
1052  if (KeGetCurrentThread()->ApcState.Process != &Process->Pcb)
1053  {
1054  DPRINT("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
1055  }
1056  return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
1057  ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||
1058  (PsGetCurrentThread()->OwnsProcessWorkingSetShared)));
1059 }
1060 
1061 //
1062 // New ARM3<->RosMM PAGE Architecture
1063 //
1065 BOOLEAN
1067 {
1068  PROS_SECTION_OBJECT RosSection = Section;
1069  if ((RosSection->Type == 'SC') && (RosSection->Size == 'TN')) return TRUE;
1070  return FALSE;
1071 }
1072 
1073 #define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE)
1074 
1075 VOID
1076 NTAPI
1078  IN PMMPFN Pfn1,
1079  IN PFN_NUMBER PageFrameIndex
1080 );
1081 
1083 BOOLEAN
1085 {
1086  return (Process->Vm.Flags.AcquiredUnsafe == TRUE);
1087 }
1088 
1089 //
1090 // Locks the working set for the given process
1091 //
1093 VOID
1095  IN PETHREAD Thread)
1096 {
1097  /* Shouldn't already be owning the process working set */
1100 
1101  /* Block APCs, make sure that still nothing is already held */
1104 
1105  /* Lock the working set */
1106  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1107 
1108  /* Now claim that we own the lock */
1112 }
1113 
1115 VOID
1117  IN PETHREAD Thread)
1118 {
1119  /* Shouldn't already be owning the process working set */
1122 
1123  /* Block APCs, make sure that still nothing is already held */
1126 
1127  /* Lock the working set */
1128  ExAcquirePushLockShared(&Process->Vm.WorkingSetMutex);
1129 
1130  /* Now claim that we own the lock */
1135 }
1136 
1138 VOID
1140  IN PETHREAD Thread)
1141 {
1142  /* Shouldn't already be owning the process working set */
1144 
1145  /* APCs must be blocked, make sure that still nothing is already held */
1148 
1149  /* Lock the working set */
1150  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1151 
1152  /* Now claim that we own the lock */
1154  Process->Vm.Flags.AcquiredUnsafe = 1;
1157 }
1158 
1159 //
1160 // Unlocks the working set for the given process
1161 //
1163 VOID
1165  IN PETHREAD Thread)
1166 {
1167  /* Make sure we are the owner of a safe acquisition */
1170 
1171  /* The thread doesn't own it anymore */
1174 
1175  /* Release the lock and re-enable APCs */
1176  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1178 }
1179 
1180 //
1181 // Unlocks the working set for the given process
1182 //
1184 VOID
1186  IN PETHREAD Thread)
1187 {
1188  /* Make sure we are the owner of a safe acquisition (because shared) */
1191 
1192  /* Ensure we are in a shared acquisition */
1195 
1196  /* Don't claim the lock anylonger */
1198 
1199  /* Release the lock and re-enable APCs */
1200  ExReleasePushLockShared(&Process->Vm.WorkingSetMutex);
1202 }
1203 
1204 //
1205 // Unlocks the working set for the given process
1206 //
1208 VOID
1210  IN PETHREAD Thread)
1211 {
1212  /* Make sure we are the owner of an unsafe acquisition */
1217 
1218  /* No longer unsafe */
1219  Process->Vm.Flags.AcquiredUnsafe = 0;
1220 
1221  /* The thread doesn't own it anymore */
1224 
1225  /* Release the lock but don't touch APC state */
1226  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1228 }
1229 
1230 //
1231 // Locks the working set
1232 //
1234 VOID
1236  IN PMMSUPPORT WorkingSet)
1237 {
1238  /* Block APCs */
1240 
1241  /* Working set should be in global memory */
1242  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1243 
1244  /* Thread shouldn't already be owning something */
1246 
1247  /* Lock this working set */
1248  ExAcquirePushLockExclusive(&WorkingSet->WorkingSetMutex);
1249 
1250  /* Which working set is this? */
1251  if (WorkingSet == &MmSystemCacheWs)
1252  {
1253  /* Own the system working set */
1257  }
1258  else if (WorkingSet->Flags.SessionSpace)
1259  {
1260  /* Own the session working set */
1264  }
1265  else
1266  {
1267  /* Own the process working set */
1271  }
1272 }
1273 
1274 //
1275 // Unlocks the working set
1276 //
1278 VOID
1280  IN PMMSUPPORT WorkingSet)
1281 {
1282  /* Working set should be in global memory */
1283  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1284 
1285  /* Which working set is this? */
1286  if (WorkingSet == &MmSystemCacheWs)
1287  {
1288  /* Release the system working set */
1292  }
1293  else if (WorkingSet->Flags.SessionSpace)
1294  {
1295  /* Release the session working set */
1299  }
1300  else
1301  {
1302  /* Release the process working set */
1306  }
1307 
1308  /* Release the working set lock */
1309  ExReleasePushLockExclusive(&WorkingSet->WorkingSetMutex);
1310 
1311  /* Unblock APCs */
1313 }
1314 
1316 VOID
1318  IN PETHREAD Thread,
1319  OUT PBOOLEAN Safe,
1320  OUT PBOOLEAN Shared)
1321 {
1323 
1324  /* Check if the current owner is unsafe */
1325  if (MI_IS_WS_UNSAFE(Process))
1326  {
1327  /* Release unsafely */
1329  *Safe = FALSE;
1330  *Shared = FALSE;
1331  }
1332  else if (Thread->OwnsProcessWorkingSetExclusive == 1)
1333  {
1334  /* Owner is safe and exclusive, release normally */
1336  *Safe = TRUE;
1337  *Shared = FALSE;
1338  }
1339  else
1340  {
1341  /* Owner is shared (implies safe), release normally */
1343  *Safe = TRUE;
1344  *Shared = TRUE;
1345  }
1346 }
1347 
1349 VOID
1351  IN PETHREAD Thread,
1352  IN BOOLEAN Safe,
1353  IN BOOLEAN Shared)
1354 {
1355  /* Check if this was a safe lock or not */
1356  if (Safe)
1357  {
1358  if (Shared)
1359  {
1360  /* Reacquire safely & shared */
1362  }
1363  else
1364  {
1365  /* Reacquire safely */
1367  }
1368  }
1369  else
1370  {
1371  /* Unsafe lock cannot be shared */
1372  ASSERT(Shared == FALSE);
1373  /* Reacquire unsafely */
1375  }
1376 }
1377 
1379 KIRQL
1381 {
1382  KIRQL OldIrql;
1383 
1388  return OldIrql;
1389 }
1390 
1392 VOID
1394 {
1399 }
1400 
1401 //
1402 // Returns the ProtoPTE inside a VAD for the given VPN
1403 //
1405 PMMPTE
1407  IN ULONG_PTR Vpn)
1408 {
1409  PMMPTE ProtoPte;
1410 
1411  /* Find the offset within the VAD's prototype PTEs */
1412  ProtoPte = Vad->FirstPrototypePte + (Vpn - Vad->StartingVpn);
1413  ASSERT(ProtoPte <= Vad->LastContiguousPte);
1414  return ProtoPte;
1415 }
1416 
1417 //
1418 // Returns the PFN Database entry for the given page number
1419 // Warning: This is not necessarily a valid PFN database entry!
1420 //
1422 PMMPFN
1424 {
1425  /* Get the entry */
1426  return &MmPfnDatabase[Pfn];
1427 };
1428 
1429 //
1430 // Drops a locked page without dereferencing it
1431 //
1433 VOID
1435 {
1436  /* This page shouldn't be locked, but it should be valid */
1437  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1438  ASSERT(Pfn1->u2.ShareCount == 0);
1439 
1440  /* Is this the last reference to the page */
1441  if (Pfn1->u3.e2.ReferenceCount == 1)
1442  {
1443  /* It better not be valid */
1444  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1445 
1446  /* Is it a prototype PTE? */
1447  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1448  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1449  {
1450  /* FIXME: We should return commit */
1451  DPRINT1("Not returning commit for prototype PTE\n");
1452  }
1453 
1454  /* Update the counter */
1456  }
1457 }
1458 
1459 //
1460 // Drops a locked page and dereferences it
1461 //
1463 VOID
1465 {
1466  USHORT RefCount, OldRefCount;
1467  PFN_NUMBER PageFrameIndex;
1468 
1469  /* Loop while we decrement the page successfully */
1470  do
1471  {
1472  /* There should be at least one reference */
1473  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1474  ASSERT(OldRefCount != 0);
1475 
1476  /* Are we the last one */
1477  if (OldRefCount == 1)
1478  {
1479  /* The page shoudln't be shared not active at this point */
1480  ASSERT(Pfn1->u3.e2.ReferenceCount == 1);
1481  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1482  ASSERT(Pfn1->u2.ShareCount == 0);
1483 
1484  /* Is it a prototype PTE? */
1485  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1486  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1487  {
1488  /* FIXME: We should return commit */
1489  DPRINT1("Not returning commit for prototype PTE\n");
1490  }
1491 
1492  /* Update the counter, and drop a reference the long way */
1494  PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
1495  MiDecrementReferenceCount(Pfn1, PageFrameIndex);
1496  return;
1497  }
1498 
1499  /* Drop a reference the short way, and that's it */
1500  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1501  OldRefCount - 1,
1502  OldRefCount);
1503  ASSERT(RefCount != 0);
1504  } while (OldRefCount != RefCount);
1505 
1506  /* If we got here, there should be more than one reference */
1507  ASSERT(RefCount > 1);
1508  if (RefCount == 2)
1509  {
1510  /* Is it still being shared? */
1511  if (Pfn1->u2.ShareCount >= 1)
1512  {
1513  /* Then it should be valid */
1514  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1515 
1516  /* Is it a prototype PTE? */
1517  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1518  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1519  {
1520  /* We don't handle ethis */
1521  ASSERT(FALSE);
1522  }
1523 
1524  /* Update the counter */
1526  }
1527  }
1528 }
1529 
1530 //
1531 // References a locked page and updates the counter
1532 // Used in MmProbeAndLockPages to handle different edge cases
1533 //
1535 VOID
1537 {
1538  USHORT RefCount, OldRefCount;
1539 
1540  /* Sanity check */
1541  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1542 
1543  /* Does ARM3 own the page? */
1544  if (MI_IS_ROS_PFN(Pfn1))
1545  {
1546  /* ReactOS Mm doesn't track share count */
1547  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1548  }
1549  else
1550  {
1551  /* On ARM3 pages, we should see a valid share count */
1552  ASSERT((Pfn1->u2.ShareCount != 0) && (Pfn1->u3.e1.PageLocation == ActiveAndValid));
1553 
1554  /* Is it a prototype PTE? */
1555  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1556  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1557  {
1558  /* FIXME: We should charge commit */
1559  DPRINT1("Not charging commit for prototype PTE\n");
1560  }
1561  }
1562 
1563  /* More locked pages! */
1565 
1566  /* Loop trying to update the reference count */
1567  do
1568  {
1569  /* Get the current reference count, make sure it's valid */
1570  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1571  ASSERT(OldRefCount != 0);
1572  ASSERT(OldRefCount < 2500);
1573 
1574  /* Bump it up by one */
1575  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1576  OldRefCount + 1,
1577  OldRefCount);
1578  ASSERT(RefCount != 0);
1579  } while (OldRefCount != RefCount);
1580 
1581  /* Was this the first lock attempt? If not, undo our bump */
1582  if (OldRefCount != 1) InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1583 }
1584 
1585 //
1586 // References a locked page and updates the counter
1587 // Used in all other cases except MmProbeAndLockPages
1588 //
1590 VOID
1592 {
1593  USHORT NewRefCount;
1594 
1595  /* Is it a prototype PTE? */
1596  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1597  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1598  {
1599  /* FIXME: We should charge commit */
1600  DPRINT1("Not charging commit for prototype PTE\n");
1601  }
1602 
1603  /* More locked pages! */
1605 
1606  /* Update the reference count */
1607  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1608  if (NewRefCount == 2)
1609  {
1610  /* Is it locked or shared? */
1611  if (Pfn1->u2.ShareCount)
1612  {
1613  /* It's shared, so make sure it's active */
1614  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1615  }
1616  else
1617  {
1618  /* It's locked, so we shouldn't lock again */
1620  }
1621  }
1622  else
1623  {
1624  /* Someone had already locked the page, so undo our bump */
1625  ASSERT(NewRefCount < 2500);
1627  }
1628 }
1629 
1630 //
1631 // References a locked page and updates the counter
1632 // Used in all other cases except MmProbeAndLockPages
1633 //
1635 VOID
1637 {
1638  USHORT NewRefCount;
1639 
1640  /* Make sure the page isn't used yet */
1641  ASSERT(Pfn1->u2.ShareCount == 0);
1642  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1643 
1644  /* Is it a prototype PTE? */
1645  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1646  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1647  {
1648  /* FIXME: We should charge commit */
1649  DPRINT1("Not charging commit for prototype PTE\n");
1650  }
1651 
1652  /* More locked pages! */
1654 
1655  /* Update the reference count */
1656  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1657  if (NewRefCount != 1)
1658  {
1659  /* Someone had already locked the page, so undo our bump */
1660  ASSERT(NewRefCount < 2500);
1662  }
1663 }
1664 
1666 VOID
1668 {
1669  PUSHORT RefCount;
1670 
1672 
1673  *RefCount += 1;
1674  ASSERT(*RefCount <= PTE_PER_PAGE);
1675 }
1676 
1678 VOID
1680 {
1681  PUSHORT RefCount;
1682 
1684 
1685  *RefCount -= 1;
1686  ASSERT(*RefCount < PTE_PER_PAGE);
1687 }
1688 
1690 USHORT
1692 {
1693  PUSHORT RefCount;
1694 
1696 
1697  return *RefCount;
1698 }
1699 
1700 INIT_FUNCTION
1701 BOOLEAN
1702 NTAPI
1704  IN ULONG Phase,
1705  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1706 );
1707 
1708 INIT_FUNCTION
1709 VOID
1710 NTAPI
1712 
1713 INIT_FUNCTION
1714 NTSTATUS
1715 NTAPI
1717  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1718 );
1719 
1720 INIT_FUNCTION
1721 VOID
1722 NTAPI
1724  VOID
1725 );
1726 
1727 INIT_FUNCTION
1728 VOID
1729 NTAPI
1731  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1732 );
1733 
1734 INIT_FUNCTION
1735 VOID
1736 NTAPI
1738  VOID
1739 );
1740 
1741 INIT_FUNCTION
1742 VOID
1743 NTAPI
1745  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1746 );
1747 
1748 VOID
1749 NTAPI
1751  VOID
1752 );
1753 
1754 VOID
1755 NTAPI
1757  VOID
1758 );
1759 
1760 INIT_FUNCTION
1761 BOOLEAN
1762 NTAPI
1764  VOID
1765 );
1766 
1767 INIT_FUNCTION
1768 PFN_NUMBER
1769 NTAPI
1771  IN PFN_NUMBER PageCount
1772 );
1773 
1774 INIT_FUNCTION
1776 NTAPI
1778  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1779  IN PBOOLEAN IncludeType
1780 );
1781 
1782 PFN_NUMBER
1783 NTAPI
1785  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1786  IN PBOOLEAN IncludeType
1787 );
1788 
1789 VOID
1790 FASTCALL
1792  IN PVOID AddressStart,
1793  IN PVOID AddressEnd
1794 );
1795 
1796 NTSTATUS
1797 NTAPI
1801  IN OUT PSIZE_T NumberOfBytesToProtect,
1802  IN ULONG NewAccessProtection,
1803  OUT PULONG OldAccessProtection OPTIONAL
1804 );
1805 
1806 NTSTATUS
1807 NTAPI
1809  IN ULONG FaultCode,
1810  IN PVOID Address,
1812  IN PVOID TrapInformation
1813 );
1814 
1815 NTSTATUS
1816 FASTCALL
1818  IN PVOID Address
1819 );
1820 
1821 INIT_FUNCTION
1822 VOID
1823 NTAPI
1825  VOID
1826 );
1827 
1828 INIT_FUNCTION
1829 VOID
1830 NTAPI
1832  VOID
1833 );
1834 
1835 INIT_FUNCTION
1836 VOID
1837 NTAPI
1839  VOID
1840 );
1841 
1842 INIT_FUNCTION
1843 VOID //
1844 NTAPI //
1845 InitializePool( //
1846  IN POOL_TYPE PoolType,// FIXFIX: This should go in ex.h after the pool merge
1847  IN ULONG Threshold //
1848 ); //
1849 
1850 // FIXFIX: THIS ONE TOO
1851 INIT_FUNCTION
1852 VOID
1853 NTAPI
1855  IN PPOOL_DESCRIPTOR PoolDescriptor,
1857  IN ULONG PoolIndex,
1858  IN ULONG Threshold,
1859  IN PVOID PoolLock
1860 );
1861 
1862 NTSTATUS
1863 NTAPI
1865  VOID
1866 );
1867 
1868 INIT_FUNCTION
1869 VOID
1870 NTAPI
1872  IN PMMPTE StartingPte,
1873  IN ULONG NumberOfPtes,
1875 );
1876 
1877 PMMPTE
1878 NTAPI
1880  IN ULONG NumberOfPtes,
1881  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1882 );
1883 
1884 VOID
1885 NTAPI
1887  IN PMMPTE StartingPte,
1888  IN ULONG NumberOfPtes,
1889  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1890 );
1891 
1892 
1893 PFN_NUMBER
1894 NTAPI
1896  IN PFN_NUMBER LowestPfn,
1897  IN PFN_NUMBER HighestPfn,
1898  IN PFN_NUMBER BoundaryPfn,
1899  IN PFN_NUMBER SizeInPages,
1901 );
1902 
1903 PVOID
1904 NTAPI
1907  IN PFN_NUMBER BaseAddressPages,
1908  IN PFN_NUMBER SizeInPages,
1909  IN PFN_NUMBER LowestPfn,
1910  IN PFN_NUMBER HighestPfn,
1911  IN PFN_NUMBER BoundaryPfn,
1912  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute
1913 );
1914 
1915 PMDL
1916 NTAPI
1918  IN PHYSICAL_ADDRESS LowAddress,
1922  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
1923  IN ULONG Flags
1924 );
1925 
1926 VOID
1927 NTAPI
1929  IN PMMPFNLIST ListHead,
1930  IN PFN_NUMBER PageFrameIndex
1931 );
1932 
1933 VOID
1934 NTAPI
1936  IN PMMPFN Entry
1937 );
1938 
1939 VOID
1940 NTAPI
1942  IN PMMPFN Pfn
1943 );
1944 
1945 VOID
1946 NTAPI
1948  IN PFN_NUMBER PageFrameIndex,
1949  IN PMMPTE PointerPte,
1950  IN BOOLEAN Modified
1951 );
1952 
1953 NTSTATUS
1954 NTAPI
1956  OUT PPFN_NUMBER PageFrameIndex,
1957  IN PMMPDE PointerPde,
1958  IN PFN_NUMBER ContainingPageFrame,
1959  IN BOOLEAN SessionAllocation
1960 );
1961 
1962 VOID
1963 NTAPI
1965  IN PFN_NUMBER PageFrameIndex,
1966  IN PMMPTE PointerPte,
1967  IN MMPTE TempPte
1968 );
1969 
1970 VOID
1971 NTAPI
1973  IN PFN_NUMBER PageFrameIndex,
1974  IN PVOID PteAddress,
1975  IN PFN_NUMBER PteFrame
1976 );
1977 
1978 VOID
1979 NTAPI
1981  IN PMMPFN Pfn1,
1982  IN PFN_NUMBER PageFrameIndex
1983 );
1984 
1985 PFN_NUMBER
1986 NTAPI
1988  IN ULONG Color
1989 );
1990 
1991 PFN_NUMBER
1992 NTAPI
1994  IN ULONG Color
1995 );
1996 
1997 VOID
1998 NTAPI
2000  IN PFN_NUMBER PageFrameIndex
2001 );
2002 
2003 VOID
2004 NTAPI
2006  IN PFN_NUMBER PageFrameIndex
2007 );
2008 
2009 PFN_COUNT
2010 NTAPI
2012  IN PMMPTE PointerPte,
2013  IN PFN_NUMBER PageCount,
2014  IN ULONG Flags,
2015  OUT PPFN_NUMBER ValidPages
2016 );
2017 
2018 ULONG
2019 NTAPI
2021  IN PMMPTE PointerPte
2022 );
2023 
2025 NTAPI
2027  IN PVOID Address
2028 );
2029 
2030 INIT_FUNCTION
2031 VOID
2032 NTAPI
2034  VOID
2035 );
2036 
2037 INIT_FUNCTION
2038 VOID
2039 NTAPI
2041  VOID
2042 );
2043 
2044 INIT_FUNCTION
2045 VOID
2046 NTAPI
2048  VOID
2049 );
2050 
2051 BOOLEAN
2052 NTAPI
2053 MiIsPfnInUse(
2054  IN PMMPFN Pfn1
2055 );
2056 
2057 PMMVAD
2058 NTAPI
2061 );
2062 
2064 NTAPI
2066  IN ULONG_PTR StartVpn,
2067  IN ULONG_PTR EndVpn,
2069  OUT PMMADDRESS_NODE *NodeOrParent
2070 );
2071 
2073 NTAPI
2075  IN SIZE_T Length,
2076  IN ULONG_PTR BoundaryAddress,
2081 );
2082 
2083 NTSTATUS
2084 NTAPI
2086  IN SIZE_T Length,
2087  IN ULONG_PTR BoundaryAddress,
2091 );
2092 
2094 NTAPI
2096  IN SIZE_T Length,
2099  OUT PMMADDRESS_NODE *PreviousVad,
2101 );
2102 
2103 NTSTATUS
2104 NTAPI
2106  IN PMMVAD Vad,
2107  IN PVOID Base,
2108  IN SIZE_T Size,
2109  IN ULONG ProtectionMask
2110 );
2111 
2112 VOID
2113 NTAPI
2114 MiInsertVad(
2115  _Inout_ PMMVAD Vad,
2116  _Inout_ PMM_AVL_TABLE VadRoot);
2117 
2118 NTSTATUS
2119 NTAPI
2121  _Inout_ PMMVAD Vad,
2124  _In_ ULONG_PTR HighestAddress,
2127 
2128 VOID
2129 NTAPI
2131  IN PSECTION Section
2132 );
2133 
2134 NTSTATUS
2135 NTAPI
2139  IN ULONG Flags
2140 );
2141 
2142 NTSTATUS
2143 NTAPI
2147  IN BOOLEAN SkipDebuggerNotify
2148 );
2149 
2150 VOID
2151 NTAPI
2152 MiInsertNode(
2154  IN PMMADDRESS_NODE NewNode,
2157 );
2158 
2159 VOID
2160 NTAPI
2161 MiRemoveNode(
2164 );
2165 
2167 NTAPI
2170 );
2171 
2173 NTAPI
2176 );
2177 
2178 BOOLEAN
2179 NTAPI
2181  IN PMMSESSION InputSession OPTIONAL
2182 );
2183 
2184 VOID
2185 NTAPI
2187  VOID
2188 );
2189 
2190 VOID
2191 NTAPI
2193  IN PMM_SESSION_SPACE SessionGlobal
2194 );
2195 
2196 VOID
2197 NTAPI
2199  IN PEPROCESS NewProcess
2200 );
2201 
2202 NTSTATUS
2203 NTAPI
2205  IN PVOID StartVa,
2206  IN PVOID EndVa
2207 );
2208 
2209 ULONG
2210 NTAPI
2212  IN ULONG Protect
2213 );
2214 
2215 VOID
2216 NTAPI
2218  IN ULONG_PTR Va,
2219  IN ULONG_PTR EndingAddress,
2220  IN PMMVAD Vad
2221 );
2222 
2223 VOID
2224 NTAPI
2225 MiDeletePte(
2226  IN PMMPTE PointerPte,
2230 );
2231 
2232 ULONG
2233 NTAPI
2235  IN PVOID PageTableVirtualAddress,
2237 );
2238 
2239 ULONG
2240 NTAPI
2243  IN KIRQL OldIrql
2244 );
2245 
2246 VOID
2247 NTAPI
2250  IN PMMVAD Vad
2251 );
2252 
2254 NTAPI
2256  IN PMMVAD Vad,
2257  IN ULONG_PTR Vpn
2258 );
2259 
2260 VOID
2261 NTAPI
2263  PVOID ObjectBody
2264 );
2265 
2266 NTSTATUS
2267 NTAPI
2271  OUT PVOID MemoryInformation,
2272  IN SIZE_T MemoryInformationLength,
2274 );
2275 
2276 NTSTATUS
2277 NTAPI
2280 );
2281 
2282 POOL_TYPE
2283 NTAPI
2285  IN PVOID PoolAddress
2286 );
2287 
2288 VOID
2289 NTAPI
2291  IN PMMPDE PointerPde,
2292  IN PEPROCESS TargetProcess,
2293  IN KIRQL OldIrql
2294 );
2295 
2296 VOID
2297 NTAPI
2299  _In_ PVOID ImageBase);
2300 
2301 //
2302 // MiRemoveZeroPage will use inline code to zero out the page manually if only
2303 // free pages are available. In some scenarios, we don't/can't run that piece of
2304 // code and would rather only have a real zero page. If we can't have a zero page,
2305 // then we'd like to have our own code to grab a free page and zero it out, by
2306 // using MiRemoveAnyPage. This macro implements this.
2307 //
2309 PFN_NUMBER
2311 {
2313  return 0;
2314 }
2315 
2316 #if (_MI_PAGING_LEVELS == 2)
2318 BOOLEAN
2319 MiSynchronizeSystemPde(PMMPDE PointerPde)
2320 {
2321  MMPDE SystemPde;
2322  ULONG Index;
2323 
2324  /* Get the Index from the PDE */
2325  Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
2326 
2327  /* Copy the PDE from the double-mapped system page directory */
2328  SystemPde = MmSystemPagePtes[Index];
2329  *PointerPde = SystemPde;
2330 
2331  /* Make sure we re-read the PDE and PTE */
2333 
2334  /* Return, if we had success */
2335  return SystemPde.u.Hard.Valid != 0;
2336 }
2337 #endif
2338 
2339 /* EOF */
PVOID MiSessionImageStart
Definition: init.c:29
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
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:509
ULONG MmProcessColorSeed
Definition: procsup.c:20
FORCEINLINE VOID MI_ERASE_PTE(IN PMMPTE PointerPte)
Definition: miarm.h:989
ULONG_PTR MmSubsectionBase
Definition: section.c:138
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1022
union _MM_SESSION_SPACE::@1780 u
Definition: bidi.c:433
INIT_FUNCTION PPHYSICAL_MEMORY_DESCRIPTOR NTAPI MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
Definition: mminit.c:1622
ULONG SessionId
Definition: miarm.h:486
LIST_ENTRY ProcessList
Definition: miarm.h:487
VOID NTAPI MiInitializePfn(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN BOOLEAN Modified)
Definition: pfnlist.c:969
#define IN
Definition: typedefs.h:39
MMPTE ValidKernelPte
Definition: init.c:29
ASMGENDATA Table[]
Definition: genincdata.c:61
#define _MI_PAGING_LEVELS
Definition: mm.h:6
TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, IN ULONG_PTR BoundaryAddress, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PULONG_PTR Base, OUT PMMADDRESS_NODE *Parent)
Definition: vadnode.c:597
#define TRUE
Definition: types.h:120
MMPFNLIST MmStandbyPageListByPriority[8]
Definition: pfnlist.c:44
MM_AVL_TABLE MmSectionBasedRoot
Definition: section.c:109
SIZE_T NonPageablePages
Definition: miarm.h:490
BOOLEAN MmMirroring
Definition: pfnlist.c:35
_MI_PFN_CACHE_ATTRIBUTE
Definition: miarm.h:417
USHORT PoolTagHash
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:396
PVOID Blink
Definition: miarm.h:441
PVOID PagedPoolStart
Definition: miarm.h:492
PVOID MmNonPagedPoolStart
Definition: init.c:24
ULONG NTAPI MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress, IN KIRQL OldIrql)
Definition: virtual.c:257
union _MMPTE::@2259 u
PFN_NUMBER StartFrame
Definition: miarm.h:447
LONG ReferenceCount
Definition: miarm.h:480
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:604
PVOID MiSessionImageEnd
Definition: init.c:28
FORCEINLINE VOID MiUnlockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1209
BOOLEAN MmZeroPageFile
Definition: pagefile.c:58
INIT_FUNCTION VOID NTAPI MiSyncCachedRanges(VOID)
Definition: largepag.c:54
#define MiAddressToPde(x)
Definition: mmx86.c:20
BOOLEAN NTAPI KeAreAllApcsDisabled(VOID)
Definition: apc.c:985
FORCEINLINE KIRQL MiAcquireExpansionLock(VOID)
Definition: miarm.h:1380
VOID NTAPI MiUnlinkPageFromList(IN PMMPFN Pfn)
Definition: pfnlist.c:264
PFN_NUMBER MmMinimumFreePages
Definition: mminit.c:314
_In_ ULONG Mode
Definition: hubbusif.h:303
FORCEINLINE VOID MiDereferencePfnAndDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1464
#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:869
INIT_FUNCTION VOID NTAPI MiComputeColorInformation(VOID)
Definition: mminit.c:508
#define MI_MAKE_ACCESSED_PAGE(x)
Definition: mm.h:97
ULONG OwnsSystemWorkingSetShared
Definition: pstypes.h:1155
signed short * PSHORT
Definition: retypes.h:6
PMMPDE PageTables
Definition: miarm.h:516
_MMSYSTEM_PTE_POOL_TYPE
Definition: miarm.h:410
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:1185
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:210
ULONG PFN_COUNT
Definition: mmtypes.h:102
LONG ProcessReferenceToSession
Definition: miarm.h:503
#define MI_MAKE_OWNER_PAGE(x)
Definition: mm.h:110
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:170
SIZE_T MmSessionViewSize
Definition: init.c:35
POOL_TYPE NTAPI MmDeterminePoolType(IN PVOID PoolAddress)
Definition: pool.c:406
VOID NTAPI MiWriteProtectSystemImage(_In_ PVOID ImageBase)
Definition: sysldr.c:2431
FORCEINLINE BOOLEAN MI_IS_MAPPED_PTE(PMMPTE PointerPte)
Definition: miarm.h:906
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:428
PMMPTE MiSessionLastPte
Definition: mminit.c:146
VOID NTAPI MiDeleteARM3Section(PVOID ObjectBody)
Definition: section.c:3248
PFN_NUMBER MmHighMemoryThreshold
Definition: mminit.c:301
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2374
struct _MI_LARGE_PAGE_RANGES MI_LARGE_PAGE_RANGES
FORCEINLINE VOID MiReferenceUnusedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1636
PLDR_DATA_TABLE_ENTRY NTAPI MiLookupDataTableEntry(IN PVOID Address)
Definition: sysldr.c:3330
INIT_FUNCTION NTSTATUS NTAPI MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:676
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:1691
#define SESSION_POOL_LOOKASIDES
Definition: mm.h:81
KSPIN_LOCK MmExpansionLock
Definition: session.c:32
FORCEINLINE VOID MiLockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1094
RTL_BITMAP MiPfnBitMap
Definition: init.c:44
SIZE_T TotalBytes
Definition: miarm.h:330
INIT_FUNCTION VOID NTAPI MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:672
PCHAR SystemSpaceViewStart
Definition: miarm.h:461
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1280
PFN_NUMBER NumberOfPages
Definition: miarm.h:434
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:464
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
ULONG BitmapFailures
Definition: miarm.h:466
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:488
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:323
LIST_ENTRY ListHeads[POOL_LISTS_PER_PAGE]
Definition: miarm.h:332
#define MiGetPdeOffset(x)
Definition: mm.h:185
VOID NTAPI MiInsertBasedSection(IN PSECTION Section)
Definition: vadnode.c:345
FORCEINLINE VOID MiReferenceUsedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1591
BOOLEAN MmLargeSystemCache
Definition: mminit.c:340
ULONG MmLargeStackSize
Definition: mminit.c:262
SIZE_T MmAllocatedNonPagedPool
Definition: pool.c:26
UNICODE_STRING BaseName
Definition: miarm.h:407
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(IN PMMPTE NewPte, IN PVOID Segment)
Definition: miarm.h:870
PPOOL_TRACKER_TABLE PoolTrackTable
Definition: expool.c:41
PMMPFN MmPfnDatabase
Definition: freelist.c:24
KGUARDED_MUTEX SystemSpaceViewLock
Definition: miarm.h:459
INIT_FUNCTION PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
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:2145
MM_PAGED_POOL_INFO PagedPoolInfo
Definition: miarm.h:508
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:64
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
FORCEINLINE BOOLEAN MI_IS_WS_UNSAFE(IN PEPROCESS Process)
Definition: miarm.h:1084
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:1029
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:511
ULONG * PPFN_NUMBER
Definition: ke.h:8
struct _POOL_DESCRIPTOR * PPOOL_DESCRIPTOR
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG OwnsSessionWorkingSetShared
Definition: pstypes.h:1157
BOOLEAN MmDynamicPfn
Definition: pfnlist.c:34
ULONG MmSpecialPoolTag
Definition: pool.c:27
struct _POOL_TRACKER_BIG_PAGES POOL_TRACKER_BIG_PAGES
BOOLEAN MmZeroingPageThreadActive
Definition: zeropage.c:20
ULONG PFN_NUMBER
Definition: ke.h:8
LIST_ENTRY WsListEntry
Definition: miarm.h:504
ULONG_PTR * PSIZE_T
Definition: typedefs.h:79
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
VOID FASTCALL MiSyncARM3WithROS(IN PVOID AddressStart, IN PVOID AddressEnd)
SIZE_T MmSystemViewSize
Definition: init.c:39
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:946
ULONG MmVerifyDriverBufferLength
Definition: drvmgmt.c:24
LIST_ENTRY Links
Definition: miarm.h:406
INIT_FUNCTION VOID NTAPI MiInitializePfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:1074
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
PFN_NUMBER BasePage
Definition: miarm.h:427
#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:1015
long LONG
Definition: pedump.c:60
PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor
Definition: init.c:46
LARGE_INTEGER MmCriticalSectionTimeout
Definition: mminit.c:388
#define PDE_BASE
Definition: winldr.c:21
MMPDE ValidKernelPdeLocal
Definition: init.c:32
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:440
USHORT AllocatorBackTraceIndex
ULONG OwnsSessionWorkingSetExclusive
Definition: pstypes.h:1156
INIT_FUNCTION VOID NTAPI ExInitializePoolDescriptor(IN PPOOL_DESCRIPTOR PoolDescriptor, IN POOL_TYPE PoolType, IN ULONG PoolIndex, IN ULONG Threshold, IN PVOID PoolLock)
Definition: expool.c:958
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1238
PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock
Definition: init.c:45
VOID NTAPI MiInitializeSessionIds(VOID)
Definition: session.c:117
FORCEINLINE PFN_NUMBER MiRemoveZeroPageSafe(IN ULONG Color)
Definition: miarm.h:2310
TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeInTree(IN SIZE_T Length, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PMMADDRESS_NODE *PreviousVad, OUT PULONG_PTR Base)
Definition: vadnode.c:502
const ULONG_PTR MmProtectToPteMask[32]
Definition: page.c:32
MM_PAGED_POOL_INFO MmPagedPoolInfo
Definition: pool.c:25
INIT_FUNCTION VOID NTAPI MiInitializeNonPagedPool(VOID)
Definition: pool.c:276
unsigned char BOOLEAN
POOL_DESCRIPTOR PagedPool
Definition: miarm.h:512
FORCEINLINE VOID MI_MAKE_TRANSITION_PTE(_Out_ PMMPTE NewPte, _In_ PFN_NUMBER Page, _In_ ULONG Protection)
Definition: miarm.h:916
VOID NTAPI MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde, IN PEPROCESS TargetProcess, IN KIRQL OldIrql)
Definition: virtual.c:2371
smooth NULL
Definition: ftsmooth.c:416
_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:841
#define KeLeaveGuardedRegion()
Definition: ke_x.h:63
PFN_NUMBER MiHighPagedPoolThreshold
Definition: mminit.c:303
#define FORCEINLINE
Definition: ntbasedef.h:221
_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:323
ULONG MmVerifyDriverLevel
Definition: drvmgmt.c:26
KEVENT MmZeroingPageEvent
Definition: zeropage.c:21
ULONG MmSecondaryColorMask
Definition: mminit.c:257
PVOID MiSystemViewStart
Definition: miarm.h:654
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1133
VOID NTAPI MiInsertPageInList(IN PMMPFNLIST ListHead, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:778
FORCEINLINE VOID MiUnlockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1279
SIZE_T NonPagedBytes
Definition: miarm.h:381
INIT_FUNCTION VOID NTAPI MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1001
PFN_NUMBER NTAPI MiPagesInLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
struct _POOL_TRACKER_TABLE POOL_TRACKER_TABLE
VOID NTAPI MiReleaseSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:275
Definition: miarm.h:404
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:462
ULONG SystemSpaceHashKey
Definition: miarm.h:465
ULONG NTAPI MiMakeSystemAddressValid(IN PVOID PageTableVirtualAddress, IN PEPROCESS CurrentProcess)
Definition: virtual.c:205
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS SkipBytes
Definition: mmfuncs.h:226
#define ULL(a, b)
Definition: format_msg.c:27
PMMPTE MmSharedUserDataPte
Definition: mminit.c:28
PVOID LockAddress
Definition: miarm.h:327
PMMCOLOR_TABLES MmFreePagesByColor[FreePageList+1]
Definition: mminit.c:286
MMPTE PrototypePte
Definition: init.c:40
_Inout_ PVOID Segment
Definition: exfuncs.h:893
FORCEINLINE ULONG_PTR MiDetermineUserGlobalPteMask(IN PVOID PointerPte)
Definition: miarm.h:741
ULONG PoolIndex
Definition: miarm.h:321
ULONG LongFlags
Definition: miarm.h:483
NTSTATUS NTAPI MiRosUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:4901
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:1139
PVOID MmHyperSpaceEnd
Definition: init.c:56
MMPDE DemandZeroPde
Definition: init.c:36
struct _MI_LARGE_PAGE_DRIVER_ENTRY MI_LARGE_PAGE_DRIVER_ENTRY
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:484
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:479
FORCEINLINE VOID MiDecrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:1679
ULONG CurrentProcess
Definition: shell.c:125
NTSTATUS NTAPI MiInsertVadEx(_Inout_ PMMVAD Vad, _In_ ULONG_PTR *BaseAddress, _In_ SIZE_T ViewSize, _In_ ULONG_PTR HighestAddress, _In_ ULONG_PTR Alignment, _In_ ULONG AllocationType)
Definition: vadnode.c:204
NTSTATUS NTAPI MiUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN ULONG Flags)
Definition: section.c:817
PVOID MmNonPagedPoolExpansionStart
Definition: init.c:25
PMMPTE MmFirstReservedMappingPte
Definition: hypermap.c:20
FORCEINLINE VOID MiUnlockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, OUT PBOOLEAN Safe, OUT PBOOLEAN Shared)
Definition: miarm.h:1317
ULONG RunningAllocs
Definition: miarm.h:322
SIZE_T CommittedPages
Definition: miarm.h:491
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MI_IS_SESSION_PTE(Pte)
Definition: miarm.h:173
ULONG ExpNumberOfPagedPools
Definition: expool.c:33
struct _MM_SESSION_SPACE MM_SESSION_SPACE
INT POOL_TYPE
Definition: typedefs.h:77
BOOLEAN NTAPI MiInitializeSystemSpaceMap(IN PMMSESSION InputSession OPTIONAL)
Definition: section.c:240
MMSESSION Session
Definition: miarm.h:506
CSHORT Type
Definition: mm.h:194
ULONG64 Valid
Definition: mmtypes.h:150
LONG PendingFreeDepth
Definition: miarm.h:329
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ULONG MmMaximumNonPagedPoolPercent
Definition: init.c:20
static const UCHAR Index[8]
Definition: usbohci.c:18
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:380
#define InterlockedIncrement16
Definition: interlocked.h:206
NTSTATUS NTAPI MiQueryMemorySectionName(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID MemoryInformation, IN SIZE_T MemoryInformationLength, OUT PSIZE_T ReturnLength)
Definition: section.c:1892
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
#define _Inout_
Definition: no_sal2.h:244
C_ASSERT(sizeof(POOL_HEADER)==POOL_BLOCK_SIZE)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PFN_NUMBER MiHighNonPagedPoolThreshold
Definition: mminit.c:305
INIT_FUNCTION VOID NTAPI MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
PVOID MiSessionPoolStart
Definition: init.c:32
struct _MMVIEW MMVIEW
#define KeEnterGuardedRegion()
Definition: ke_x.h:34
ULONG SessionPoolAllocationFailures[4]
Definition: miarm.h:497
PMMADDRESS_NODE NTAPI MiGetNextNode(IN PMMADDRESS_NODE Node)
Definition: vadnode.c:467
PVOID MmHighSectionBase
Definition: section.c:111
ULONG Threshold
Definition: miarm.h:326
SIZE_T Spare0
Definition: miarm.h:331
FORCEINLINE VOID MiLockProcessWorkingSetShared(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1116
PVOID MiSessionSpaceEnd
Definition: init.c:27
SIZE_T PagedBytes
Definition: miarm.h:384
ULONG TotalPages
Definition: miarm.h:324
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG_PTR MxPfnAllocation
Definition: init.c:43
SIZE_T MmBootImageSize
Definition: init.c:49
FORCEINLINE BOOLEAN MiIsUserPte(PVOID Address)
Definition: miarm.h:730
INIT_FUNCTION VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID)
Definition: pool.c:184
GENERAL_LOOKASIDE Lookaside[SESSION_POOL_LOOKASIDES]
Definition: miarm.h:505
VOID NTAPI MiDecrementReferenceCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1222
#define PDE_TOP
Definition: mm.h:34
char * PBOOLEAN
Definition: retypes.h:11
FORCEINLINE PMMPFN MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
Definition: miarm.h:1423
PKGUARDED_MUTEX SystemSpaceViewLockPointer
Definition: miarm.h:460
PFN_NUMBER MmLowMemoryThreshold
Definition: mminit.c:300
PVOID PagedPoolEnd
Definition: miarm.h:493
KGUARDED_MUTEX PagedPoolMutex
Definition: miarm.h:507
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
PCONTROL_AREA ControlArea
Definition: miarm.h:454
PFN_NUMBER MmMaximumNonPagedPoolInPages
Definition: mminit.c:30
PMMPTE MiSessionImagePteStart
Definition: mminit.c:143
FORCEINLINE VOID MiDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1434
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:305
Definition: btrfs_drv.h:1853
INIT_FUNCTION VOID NTAPI MiInitializeSessionSpaceLayout(VOID)
Definition: init.c:63
ULONG MmMinAdditionNonPagedPoolPerMb
Definition: mminit.c:40
const ULONG MmProtectToValue[32]
Definition: page.c:81
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:118
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
struct _PHYSICAL_MEMORY_RUN * PPHYSICAL_MEMORY_RUN
ULONG OwnsSystemWorkingSetExclusive
Definition: pstypes.h:1154
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define _1MB
Definition: miarm.h:15
ULONG MmSecondaryColors
Definition: mminit.c:256
LIST_HEAD(acpi_bus_event_list)
struct _MI_LARGE_PAGE_RANGES * PMI_LARGE_PAGE_RANGES
INIT_FUNCTION VOID NTAPI MiInitializeSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE PoolType)
Definition: syspte.c:399
BOOLEAN MmProtectFreedNonPagedPool
Definition: pool.c:29
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326
LIST_ENTRY ImageList
Definition: miarm.h:498
_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:502
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:935
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:817
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:325
PVOID PendingFrees
Definition: miarm.h:328
#define _In_
Definition: no_sal2.h:204
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:1091
FORCEINLINE VOID MiLockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, IN BOOLEAN Safe, IN BOOLEAN Shared)
Definition: miarm.h:1350
ULONG_PTR SIZE_T
Definition: typedefs.h:79
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define SYSTEM_PD_SIZE
Definition: miarm.h:31
INIT_FUNCTION VOID NTAPI InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold)
Definition: expool.c:1009
FORCEINLINE VOID MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte, IN MMPTE InvalidPte)
Definition: miarm.h:975
WCHAR MmLargePageDriverBuffer[512]
Definition: largepag.c:24
PSUBSECTION NTAPI MiLocateSubsection(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: section.c:570
KEVENT AttachEvent
Definition: miarm.h:501
MMPTE HyperTemplatePte
Definition: hypermap.c:22
struct _MMSESSION MMSESSION
PRTL_BITMAP SystemSpaceBitMap
Definition: miarm.h:467
SIZE_T MmDefaultMaximumNonPagedPool
Definition: mminit.c:41
ULONG MmVerifyDriverBufferType
Definition: drvmgmt.c:25
USHORT PreviousSize
POOL_TYPE PoolType
Definition: miarm.h:320
_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
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:1329
PMMWSLE Wsle
Definition: miarm.h:510
#define MI_IS_ROS_PFN(x)
Definition: miarm.h:1073
Definition: miarm.h:451
NTSTATUS NTAPI MiInitializeSessionPool(VOID)
Definition: pool.c:1280
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
LONG ResidentProcessCount
Definition: miarm.h:496
PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE]
Definition: init.c:40
MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType]
Definition: iosup.c:27
ULONG OwnsProcessWorkingSetShared
Definition: pstypes.h:1153
PPOOL_DESCRIPTOR ExpPagedPoolDescriptor[16+1]
Definition: expool.c:35
unsigned int * PULONG
Definition: retypes.h:1
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1393
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define InterlockedCompareExchange16
Definition: interlocked.h:109
PKEVENT MiLowPagedPoolEvent
Definition: mminit.c:294
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
SIZE_T MmSessionPoolSize
Definition: init.c:36
#define DPRINT1
Definition: precomp.h:8
#define POOL_LISTS_PER_PAGE
Definition: miarm.h:280
SIZE_T MmSizeOfNonPagedPoolInBytes
Definition: init.c:21
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:493
PVOID MmPagedPoolEnd
Definition: miarm.h:585
WCHAR MmVerifyDriverBuffer[512]
Definition: drvmgmt.c:23
POOL_DESCRIPTOR NonPagedPoolDescriptor
Definition: expool.c:34
struct _MM_SESSION_SPACE * PMM_SESSION_SPACE
FORCEINLINE BOOLEAN MiIsMemoryTypeFree(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h: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:2052
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI MiSessionAddProcess(IN PEPROCESS NewProcess)
Definition: session.c:427
LONG NonPagedAllocs
Definition: miarm.h:379
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:960
MMSUPPORT MmSystemCacheWs
Definition: init.c:55
#define OUT
Definition: typedefs.h:40
PVOID MiSessionPoolEnd
Definition: init.c:31
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1199
VOID NTAPI MiInitializePfnAndMakePteValid(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: pfnlist.c:1036
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:22
FORCEINLINE VOID MiIncrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:1667
PKEVENT MiHighPagedPoolEvent
Definition: mminit.c:295
PMMWSL MmSystemCacheWorkingSetList
Definition: mminit.c:174
unsigned int ULONG
Definition: retypes.h:1
INIT_FUNCTION BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2043
LIST_ENTRY MiLargePageDriverList
Definition: largepag.c:26
INIT_FUNCTION VOID NTAPI MiInitializePoolEvents(VOID)
Definition: pool.c:201
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:64
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
CSHORT Size
Definition: mm.h:195
struct _POOL_TRACKER_BIG_PAGES * PPOOL_TRACKER_BIG_PAGES
VOID NTAPI MiRemoveMappedView(IN PEPROCESS CurrentProcess, IN PMMVAD Vad)
Definition: section.c:780
ULONG_PTR Entry
Definition: miarm.h:453
BOOLEAN NTAPI MiIsPfnInUse(IN PMMPFN Pfn1)
Definition: freelist.c:142
ULONG AttachCount
Definition: miarm.h:500
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:442
#define InterlockedDecrementSizeT(a)
Definition: interlocked.h:153
ULONG OwnsProcessWorkingSetExclusive
Definition: pstypes.h:1152
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:278
FORCEINLINE VOID MiReferenceProbedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1536
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
PMMPTE MiSessionBasePte
Definition: mminit.c:145
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1235
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1650
INIT_FUNCTION BOOLEAN NTAPI MiInitializeMemoryEvents(VOID)
Definition: mminit.c:1339
PMMPTE MiHighestUserPte
Definition: mminit.c:233
MMPTE ValidKernelPteLocal
Definition: init.c:33
#define KeGetCurrentThread
Definition: hal.h:44
MMPDE ValidKernelPde
Definition: init.c:28
struct _POOL_TRACKER_TABLE * PPOOL_TRACKER_TABLE
ULONG SystemSpaceHashSize
Definition: miarm.h:463
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
INIT_FUNCTION VOID NTAPI MiInitializeColorTables(VOID)
Definition: mminit.c:562
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:932
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444
FORCEINLINE VOID MI_UPDATE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:960
FORCEINLINE BOOLEAN MI_WS_OWNER(IN PEPROCESS Process)
Definition: miarm.h:1045
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:4137
PKEVENT MiHighMemoryEvent
Definition: mminit.c:293
PMMPDE PagedPoolBasePde
Definition: miarm.h:494
PFN_NUMBER LastFrame
Definition: miarm.h:448
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:525
PMDL NTAPI MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes, IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute, IN ULONG Flags)
Definition: freelist.c:150
base of all file and directory entries
Definition: entries.h:82
BOOLEAN MmTrackLockedPages
Definition: mdlsup.c:21
FORCEINLINE VOID MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte, IN PMMPTE MappingPte, IN ULONG_PTR ProtectionMask, IN PFN_NUMBER PageFrameNumber)
Definition: miarm.h:801
_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:1164
PMMPDE MmSystemPagePtes
Definition: init.c:41
FORCEINLINE PMMPTE MI_GET_PROTOTYPE_PTE_FOR_VPN(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: miarm.h:1406
ULONG PageFrameNumber
Definition: mmtypes.h:109
Definition: dlist.c:348
PFN_NUMBER SessionPageDirectoryIndex
Definition: miarm.h:489
Definition: mm.h:369
PVOID MiSessionViewStart
Definition: init.c:30
BOOLEAN MmTrackPtes
Definition: mdlsup.c:20
FORCEINLINE BOOLEAN MiIsRosSectionObject(IN PVOID Section)
Definition: miarm.h:1066
struct _POOL_DESCRIPTOR POOL_DESCRIPTOR
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PVOID MmNonPagedSystemStart
Definition: miarm.h:586
PMMPTE MiSessionImagePteEnd
Definition: mminit.c:144