ReactOS  0.4.10-dev-244-gb941574
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_COUNT * PAGE_SIZE)
23 
24 /* Size of a page table */
25 #define PT_SIZE (PTE_COUNT * sizeof(MMPTE))
26 
27 /* Size of a page directory */
28 #define PD_SIZE (PDE_COUNT * sizeof(MMPDE))
29 
30 /* Stop using these! */
31 #define PD_COUNT PPE_PER_PAGE
32 #define PDE_COUNT PDE_PER_PAGE
33 #define PTE_COUNT PTE_PER_PAGE
34 
35 /* Size of all page directories for a process */
36 #define SYSTEM_PD_SIZE (PD_COUNT * PD_SIZE)
37 #ifdef _M_IX86
39 #endif
40 
41 //
42 // Protection Bits part of the internal memory manager Protection Mask, from:
43 // http://reactos.org/wiki/Techwiki:Memory_management_in_the_Windows_XP_kernel
44 // https://www.reactos.org/wiki/Techwiki:Memory_Protection_constants
45 // and public assertions.
46 //
47 #define MM_ZERO_ACCESS 0
48 #define MM_READONLY 1
49 #define MM_EXECUTE 2
50 #define MM_EXECUTE_READ 3
51 #define MM_READWRITE 4
52 #define MM_WRITECOPY 5
53 #define MM_EXECUTE_READWRITE 6
54 #define MM_EXECUTE_WRITECOPY 7
55 #define MM_PROTECT_ACCESS 7
56 
57 //
58 // These are flags on top of the actual protection mask
59 //
60 #define MM_NOCACHE 0x08
61 #define MM_GUARDPAGE 0x10
62 #define MM_WRITECOMBINE 0x18
63 #define MM_PROTECT_SPECIAL 0x18
64 
65 //
66 // These are special cases
67 //
68 #define MM_DECOMMIT (MM_ZERO_ACCESS | MM_GUARDPAGE)
69 #define MM_NOACCESS (MM_ZERO_ACCESS | MM_WRITECOMBINE)
70 #define MM_OUTSWAPPED_KSTACK (MM_EXECUTE_WRITECOPY | MM_WRITECOMBINE)
71 #define MM_INVALID_PROTECTION 0xFFFFFFFF
72 
73 //
74 // Specific PTE Definitions that map to the Memory Manager's Protection Mask Bits
75 // The Memory Manager's definition define the attributes that must be preserved
76 // and these PTE definitions describe the attributes in the hardware sense. This
77 // helps deal with hardware differences between the actual boolean expression of
78 // the argument.
79 //
80 // For example, in the logical attributes, we want to express read-only as a flag
81 // but on x86, it is writability that must be set. On the other hand, on x86, just
82 // like in the kernel, it is disabling the caches that requires a special flag,
83 // while on certain architectures such as ARM, it is enabling the cache which
84 // requires a flag.
85 //
86 #if defined(_M_IX86) || defined(_M_AMD64)
87 //
88 // Access Flags
89 //
90 #define PTE_READONLY 0 // Doesn't exist on x86
91 #define PTE_EXECUTE 0 // Not worrying about NX yet
92 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
93 #define PTE_READWRITE 0x2
94 #define PTE_WRITECOPY 0x200
95 #define PTE_EXECUTE_READWRITE 0x2 // Not worrying about NX yet
96 #define PTE_EXECUTE_WRITECOPY 0x200
97 #define PTE_PROTOTYPE 0x400
98 
99 //
100 // State Flags
101 //
102 #define PTE_VALID 0x1
103 #define PTE_ACCESSED 0x20
104 #define PTE_DIRTY 0x40
105 
106 //
107 // Cache flags
108 //
109 #define PTE_ENABLE_CACHE 0
110 #define PTE_DISABLE_CACHE 0x10
111 #define PTE_WRITECOMBINED_CACHE 0x10
112 #elif defined(_M_ARM)
113 #define PTE_READONLY 0x200
114 #define PTE_EXECUTE 0 // Not worrying about NX yet
115 #define PTE_EXECUTE_READ 0 // Not worrying about NX yet
116 #define PTE_READWRITE 0 // Doesn't exist on ARM
117 #define PTE_WRITECOPY 0 // Doesn't exist on ARM
118 #define PTE_EXECUTE_READWRITE 0 // Not worrying about NX yet
119 #define PTE_EXECUTE_WRITECOPY 0 // Not worrying about NX yet
120 #define PTE_PROTOTYPE 0x400 // Using the Shared bit
121 //
122 // Cache flags
123 //
124 #define PTE_ENABLE_CACHE 0
125 #define PTE_DISABLE_CACHE 0x10
126 #define PTE_WRITECOMBINED_CACHE 0x10
127 #else
128 #error Define these please!
129 #endif
130 
131 extern const ULONG_PTR MmProtectToPteMask[32];
132 extern const ULONG MmProtectToValue[32];
133 
134 //
135 // Assertions for session images, addresses, and PTEs
136 //
137 #define MI_IS_SESSION_IMAGE_ADDRESS(Address) \
138  (((Address) >= MiSessionImageStart) && ((Address) < MiSessionImageEnd))
139 
140 #define MI_IS_SESSION_ADDRESS(Address) \
141  (((Address) >= MmSessionBase) && ((Address) < MiSessionSpaceEnd))
142 
143 #define MI_IS_SESSION_PTE(Pte) \
144  ((((PMMPTE)Pte) >= MiSessionBasePte) && (((PMMPTE)Pte) < MiSessionLastPte))
145 
146 #define MI_IS_PAGE_TABLE_ADDRESS(Address) \
147  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)PTE_TOP))
148 
149 #define MI_IS_SYSTEM_PAGE_TABLE_ADDRESS(Address) \
150  (((Address) >= (PVOID)MiAddressToPte(MmSystemRangeStart)) && ((Address) <= (PVOID)PTE_TOP))
151 
152 #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(Address) \
153  (((PVOID)(Address) >= (PVOID)PTE_BASE) && ((PVOID)(Address) <= (PVOID)MmHyperSpaceEnd))
154 
155 //
156 // Creates a software PTE with the given protection
157 //
158 #define MI_MAKE_SOFTWARE_PTE(p, x) ((p)->u.Long = (x << MM_PTE_SOFTWARE_PROTECTION_BITS))
159 
160 //
161 // Marks a PTE as deleted
162 //
163 #define MI_SET_PFN_DELETED(x) ((x)->PteAddress = (PMMPTE)((ULONG_PTR)(x)->PteAddress | 1))
164 #define MI_IS_PFN_DELETED(x) ((ULONG_PTR)((x)->PteAddress) & 1)
165 
166 //
167 // Special values for LoadedImports
168 //
169 #ifdef _WIN64
170 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFFFFFFFFFEULL
171 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFFFFFFFFFFULL
172 #else
173 #define MM_SYSLDR_NO_IMPORTS (PVOID)0xFFFFFFFE
174 #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFF
175 #endif
176 #define MM_SYSLDR_SINGLE_ENTRY 0x1
177 
178 //
179 // Number of initial session IDs
180 //
181 #define MI_INITIAL_SESSION_IDS 64
182 
183 #if defined(_M_IX86) || defined(_M_ARM)
184 //
185 // PFN List Sentinel
186 //
187 #define LIST_HEAD 0xFFFFFFFF
188 
189 //
190 // Because GCC cannot automatically downcast 0xFFFFFFFF to lesser-width bits,
191 // we need a manual definition suited to the number of bits in the PteFrame.
192 // This is used as a LIST_HEAD for the colored list
193 //
194 #define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
195 #elif defined(_M_AMD64)
196 #define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
197 #define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
198 #else
199 #error Define these please!
200 #endif
201 
202 //
203 // Special IRQL value (found in assertions)
204 //
205 #define MM_NOIRQL (KIRQL)0xFFFFFFFF
206 
207 //
208 // Returns the color of a page
209 //
210 #define MI_GET_PAGE_COLOR(x) ((x) & MmSecondaryColorMask)
211 #define MI_GET_NEXT_COLOR() (MI_GET_PAGE_COLOR(++MmSystemPageColor))
212 #define MI_GET_NEXT_PROCESS_COLOR(x) (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
213 
214 //
215 // Prototype PTEs that don't yet have a pagefile association
216 //
217 #ifdef _WIN64
218 #define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
219 #else
220 #define MI_PTE_LOOKUP_NEEDED 0xFFFFF
221 #endif
222 
223 //
224 // Number of session data and tag pages
225 //
226 #define MI_SESSION_DATA_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
227 #define MI_SESSION_TAG_PAGES_MAXIMUM (MM_ALLOCATION_GRANULARITY / PAGE_SIZE)
228 
229 //
230 // Used by MiCheckSecuredVad
231 //
232 #define MM_READ_WRITE_ALLOWED 11
233 #define MM_READ_ONLY_ALLOWED 10
234 #define MM_NO_ACCESS_ALLOWED 01
235 #define MM_DELETE_CHECK 85
236 
237 //
238 // System views are binned into 64K chunks
239 //
240 #define MI_SYSTEM_VIEW_BUCKET_SIZE _64K
241 
242 //
243 // FIXFIX: These should go in ex.h after the pool merge
244 //
245 #ifdef _WIN64
246 #define POOL_BLOCK_SIZE 16
247 #else
248 #define POOL_BLOCK_SIZE 8
249 #endif
250 #define POOL_LISTS_PER_PAGE (PAGE_SIZE / POOL_BLOCK_SIZE)
251 #define BASE_POOL_TYPE_MASK 1
252 #define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + POOL_BLOCK_SIZE))
253 
254 //
255 // Pool debugging/analysis/tracing flags
256 //
257 #define POOL_FLAG_CHECK_TIMERS 0x1
258 #define POOL_FLAG_CHECK_WORKERS 0x2
259 #define POOL_FLAG_CHECK_RESOURCES 0x4
260 #define POOL_FLAG_VERIFIER 0x8
261 #define POOL_FLAG_CHECK_DEADLOCK 0x10
262 #define POOL_FLAG_SPECIAL_POOL 0x20
263 #define POOL_FLAG_DBGPRINT_ON_FAILURE 0x40
264 #define POOL_FLAG_CRASH_ON_FAILURE 0x80
265 
266 //
267 // BAD_POOL_HEADER codes during pool bugcheck
268 //
269 #define POOL_CORRUPTED_LIST 3
270 #define POOL_SIZE_OR_INDEX_MISMATCH 5
271 #define POOL_ENTRIES_NOT_ALIGNED_PREVIOUS 6
272 #define POOL_HEADER_NOT_ALIGNED 7
273 #define POOL_HEADER_IS_ZERO 8
274 #define POOL_ENTRIES_NOT_ALIGNED_NEXT 9
275 #define POOL_ENTRY_NOT_FOUND 10
276 
277 //
278 // BAD_POOL_CALLER codes during pool bugcheck
279 //
280 #define POOL_ENTRY_CORRUPTED 1
281 #define POOL_ENTRY_ALREADY_FREE 6
282 #define POOL_ENTRY_NOT_ALLOCATED 7
283 #define POOL_ALLOC_IRQL_INVALID 8
284 #define POOL_FREE_IRQL_INVALID 9
285 #define POOL_BILLED_PROCESS_INVALID 13
286 #define POOL_HEADER_SIZE_INVALID 32
287 
288 typedef struct _POOL_DESCRIPTOR
289 {
304 
305 typedef struct _POOL_HEADER
306 {
307  union
308  {
309  struct
310  {
311 #ifdef _WIN64
313  USHORT PoolIndex:8;
314  USHORT BlockSize:8;
315  USHORT PoolType:8;
316 #else
318  USHORT PoolIndex:7;
319  USHORT BlockSize:9;
320  USHORT PoolType:7;
321 #endif
322  };
323  ULONG Ulong1;
324  };
325 #ifdef _WIN64
326  ULONG PoolTag;
327 #endif
328  union
329  {
330 #ifdef _WIN64
331  PEPROCESS ProcessBilled;
332 #else
333  ULONG PoolTag;
334 #endif
335  struct
336  {
339  };
340  };
342 
345 
346 typedef struct _POOL_TRACKER_TABLE
347 {
356 
358 {
364 
367 extern PPOOL_DESCRIPTOR ExpPagedPoolDescriptor[16 + 1];
368 extern PPOOL_TRACKER_TABLE PoolTrackTable;
369 
370 //
371 // END FIXFIX
372 //
373 
375 {
379 
381 {
386 
388 {
394 
395 typedef struct _PHYSICAL_MEMORY_RUN
396 {
400 
402 {
407 
408 typedef struct _MMCOLOR_TABLES
409 {
414 
415 typedef struct _MI_LARGE_PAGE_RANGES
416 {
420 
421 typedef struct _MMVIEW
422 {
425 } MMVIEW, *PMMVIEW;
426 
427 typedef struct _MMSESSION
428 {
439 
441 {
446 
447 typedef struct _MM_SESSION_SPACE
448 {
451  union
452  {
455  } u;
483 #if defined (_M_AMD64)
484  MMPDE PageDirectory;
485 #else
487 #endif
488 #if defined (_M_AMD64)
489  PMMPTE SpecialPoolFirstPte;
490  PMMPTE SpecialPoolLastPte;
491  PMMPTE NextPdeForSpecialPoolExpansion;
492  PMMPTE LastPdeForSpecialPoolExpansion;
493  PFN_NUMBER SpecialPagesInUse;
494 #endif
497 
498 extern PMM_SESSION_SPACE MmSessionSpace;
499 extern MMPTE HyperTemplatePte;
500 extern MMPDE ValidKernelPde;
501 extern MMPTE ValidKernelPte;
504 extern MMPDE DemandZeroPde;
505 extern MMPTE DemandZeroPte;
506 extern MMPTE PrototypePte;
507 extern MMPTE MmDecommittedPte;
509 extern BOOLEAN MmZeroPageFile;
512 extern BOOLEAN MmTrackPtes;
513 extern BOOLEAN MmDynamicPfn;
514 extern BOOLEAN MmMirroring;
515 extern BOOLEAN MmMakeLowMemory;
521 extern WCHAR MmVerifyDriverBuffer[512];
522 extern WCHAR MmLargePageDriverBuffer[512];
534 extern PVOID MmNonPagedPoolEnd;
536 extern PVOID MmPagedPoolStart;
537 extern PVOID MmPagedPoolEnd;
538 extern PVOID MmSessionBase;
539 extern SIZE_T MmSessionSize;
543 extern PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock;
544 extern SIZE_T MmBootImageSize;
551 extern RTL_BITMAP MiPfnBitMap;
557 extern PVOID MiSystemViewStart;
558 extern SIZE_T MmSystemViewSize;
560 extern PVOID MiSessionSpaceEnd;
563 extern PMMPTE MiSessionBasePte;
564 extern PMMPTE MiSessionLastPte;
566 extern PMMPDE MmSystemPagePtes;
568 extern PVOID MmSystemCacheEnd;
571 extern ULONG MmSpecialPoolTag;
572 extern PVOID MmHyperSpaceEnd;
578 extern ULONG MmSecondaryColors;
582 extern ULONG MmLargeStackSize;
583 extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
585 extern ULONG MmProductType;
609 extern PVOID MiSessionImageEnd;
610 extern PMMPTE MiHighestUserPte;
611 extern PMMPDE MiHighestUserPde;
617 extern ULONG MmSystemPageColor;
619 extern PMMWSL MmWorkingSetList;
625 extern PVOID MiSessionPoolEnd; // 0xBE000000
626 extern PVOID MiSessionPoolStart; // 0xBD000000
627 extern PVOID MiSessionViewStart; // 0xBE000000
628 extern PVOID MiSessionSpaceWs;
633 extern PVOID MmHighSectionBase;
640 
642 BOOLEAN
644 {
645  return ((MemoryType == LoaderFree) ||
646  (MemoryType == LoaderLoadedProgram) ||
647  (MemoryType == LoaderFirmwareTemporary) ||
648  (MemoryType == LoaderOsloaderStack));
649 }
650 
652 BOOLEAN
654 {
655  return ((MemoryType == LoaderFirmwarePermanent) ||
656  (MemoryType == LoaderSpecialMemory) ||
657  (MemoryType == LoaderHALCachedMemory) ||
658  (MemoryType == LoaderBBTMemory));
659 }
660 
661 #ifdef _M_AMD64
663 BOOLEAN
664 MiIsUserPxe(PVOID Address)
665 {
666  return ((ULONG_PTR)Address >> 7) == 0x1FFFFEDF6FB7DA0ULL;
667 }
668 
670 BOOLEAN
671 MiIsUserPpe(PVOID Address)
672 {
673  return ((ULONG_PTR)Address >> 16) == 0xFFFFF6FB7DA0ULL;
674 }
675 
677 BOOLEAN
678 MiIsUserPde(PVOID Address)
679 {
680  return ((ULONG_PTR)Address >> 25) == 0x7FFFFB7DA0ULL;
681 }
682 
684 BOOLEAN
685 MiIsUserPte(PVOID Address)
686 {
687  return ((ULONG_PTR)Address >> 34) == 0x3FFFFDA0ULL;
688 }
689 #else
691 BOOLEAN
693 {
694  return ((Address >= (PVOID)MiAddressToPde(NULL)) &&
695  (Address <= (PVOID)MiHighestUserPde));
696 }
697 
699 BOOLEAN
701 {
702  return (Address <= (PVOID)MiHighestUserPte);
703 }
704 #endif
705 
706 //
707 // Figures out the hardware bits for a PTE
708 //
710 ULONG_PTR
712 {
713  MMPTE TempPte;
714 
715  /* Start fresh */
716  TempPte.u.Long = 0;
717 
718  /* Make it valid and accessed */
719  TempPte.u.Hard.Valid = TRUE;
720  MI_MAKE_ACCESSED_PAGE(&TempPte);
721 
722  /* Is this for user-mode? */
723  if (
724 #if (_MI_PAGING_LEVELS == 4)
725  MiIsUserPxe(PointerPte) ||
726 #endif
727 #if (_MI_PAGING_LEVELS >= 3)
728  MiIsUserPpe(PointerPte) ||
729 #endif
730  MiIsUserPde(PointerPte) ||
731  MiIsUserPte(PointerPte))
732  {
733  /* Set the owner bit */
734  MI_MAKE_OWNER_PAGE(&TempPte);
735  }
736 
737  /* FIXME: We should also set the global bit */
738 
739  /* Return the protection */
740  return TempPte.u.Long;
741 }
742 
743 //
744 // Creates a valid kernel PTE with the given protection
745 //
747 VOID
749  IN PMMPTE MappingPte,
750  IN ULONG_PTR ProtectionMask,
751  IN PFN_NUMBER PageFrameNumber)
752 {
753  /* Only valid for kernel, non-session PTEs */
754  ASSERT(MappingPte > MiHighestUserPte);
755  ASSERT(!MI_IS_SESSION_PTE(MappingPte));
756  ASSERT((MappingPte < (PMMPTE)PDE_BASE) || (MappingPte > (PMMPTE)PDE_TOP));
757 
758  /* Start fresh */
759  *NewPte = ValidKernelPte;
760 
761  /* Set the protection and page */
762  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
763  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
764 }
765 
766 //
767 // Creates a valid PTE with the given protection
768 //
770 VOID
772  IN PMMPTE MappingPte,
773  IN ULONG_PTR ProtectionMask,
774  IN PFN_NUMBER PageFrameNumber)
775 {
776  /* Set the protection and page */
777  NewPte->u.Long = MiDetermineUserGlobalPteMask(MappingPte);
778  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
779  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
780 }
781 
782 //
783 // Creates a valid user PTE with the given protection
784 //
786 VOID
788  IN PMMPTE MappingPte,
789  IN ULONG_PTR ProtectionMask,
790  IN PFN_NUMBER PageFrameNumber)
791 {
792  /* Only valid for kernel, non-session PTEs */
793  ASSERT(MappingPte <= MiHighestUserPte);
794 
795  /* Start fresh */
796  NewPte->u.Long = 0;
797 
798  /* Set the protection and page */
799  NewPte->u.Hard.Valid = TRUE;
800  NewPte->u.Hard.Owner = TRUE;
801  NewPte->u.Hard.PageFrameNumber = PageFrameNumber;
802  NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
803 }
804 
805 #ifndef _M_AMD64
806 //
807 // Builds a Prototype PTE for the address of the PTE
808 //
810 VOID
812  IN PMMPTE PointerPte)
813 {
815 
816  /* Mark this as a prototype */
817  NewPte->u.Long = 0;
818  NewPte->u.Proto.Prototype = 1;
819 
820  /*
821  * Prototype PTEs are only valid in paged pool by design, this little trick
822  * lets us only use 30 bits for the adress of the PTE, as long as the area
823  * stays 1024MB At most.
824  */
825  Offset = (ULONG_PTR)PointerPte - (ULONG_PTR)MmPagedPoolStart;
826 
827  /*
828  * 7 bits go in the "low" (but we assume the bottom 2 are zero)
829  * and the other 21 bits go in the "high"
830  */
831  NewPte->u.Proto.ProtoAddressLow = (Offset & 0x1FC) >> 2;
832  NewPte->u.Proto.ProtoAddressHigh = (Offset & 0x3FFFFE00) >> 9;
833 }
834 
835 //
836 // Builds a Subsection PTE for the address of the Segment
837 //
839 VOID
841  IN PVOID Segment)
842 {
844 
845  /* Mark this as a prototype */
846  NewPte->u.Long = 0;
847  NewPte->u.Subsect.Prototype = 1;
848 
849  /*
850  * Segments are only valid either in nonpaged pool. We store the 20 bit
851  * difference either from the top or bottom of nonpaged pool, giving a
852  * maximum of 128MB to each delta, meaning nonpaged pool cannot exceed
853  * 256MB.
854  */
855  if ((ULONG_PTR)Segment < ((ULONG_PTR)MmSubsectionBase + (128 * _1MB)))
856  {
857  Offset = (ULONG_PTR)Segment - (ULONG_PTR)MmSubsectionBase;
858  NewPte->u.Subsect.WhichPool = PagedPool;
859  }
860  else
861  {
862  Offset = (ULONG_PTR)MmNonPagedPoolEnd - (ULONG_PTR)Segment;
863  NewPte->u.Subsect.WhichPool = NonPagedPool;
864  }
865 
866  /*
867  * 4 bits go in the "low" (but we assume the bottom 3 are zero)
868  * and the other 20 bits go in the "high"
869  */
870  NewPte->u.Subsect.SubsectionAddressLow = (Offset & 0x78) >> 3;
871  NewPte->u.Subsect.SubsectionAddressHigh = (Offset & 0xFFFFF80) >> 7;
872 }
873 
875 BOOLEAN
877 {
879  return ((PointerPte->u.Long & 0xFFFFFC01) != 0);
880 }
881 
882 #endif
883 
885 VOID
887  _In_ PFN_NUMBER Page,
888  _In_ ULONG Protection)
889 {
890  NewPte->u.Long = 0;
891  NewPte->u.Trans.Transition = 1;
892  NewPte->u.Trans.Protection = Protection;
893  NewPte->u.Trans.PageFrameNumber = Page;
894 }
895 
896 //
897 // Returns if the page is physically resident (ie: a large page)
898 // FIXFIX: CISC/x86 only?
899 //
901 BOOLEAN
903 {
904  PMMPDE PointerPde;
905 
906  /* Large pages are never paged out, always physically resident */
907  PointerPde = MiAddressToPde(Address);
908  return ((PointerPde->u.Hard.LargePage) && (PointerPde->u.Hard.Valid));
909 }
910 
911 //
912 // Writes a valid PTE
913 //
915 VOID
917  IN MMPTE TempPte)
918 {
919  /* Write the valid PTE */
920  ASSERT(PointerPte->u.Hard.Valid == 0);
921  ASSERT(TempPte.u.Hard.Valid == 1);
922  *PointerPte = TempPte;
923 }
924 
925 //
926 // Updates a valid PTE
927 //
929 VOID
931  IN MMPTE TempPte)
932 {
933  /* Write the valid PTE */
934  ASSERT(PointerPte->u.Hard.Valid == 1);
935  ASSERT(TempPte.u.Hard.Valid == 1);
936  ASSERT(PointerPte->u.Hard.PageFrameNumber == TempPte.u.Hard.PageFrameNumber);
937  *PointerPte = TempPte;
938 }
939 
940 //
941 // Writes an invalid PTE
942 //
944 VOID
946  IN MMPTE InvalidPte)
947 {
948  /* Write the invalid PTE */
949  ASSERT(InvalidPte.u.Hard.Valid == 0);
950  ASSERT(InvalidPte.u.Long != 0);
951  *PointerPte = InvalidPte;
952 }
953 
954 //
955 // Erase the PTE completely
956 //
958 VOID
959 MI_ERASE_PTE(IN PMMPTE PointerPte)
960 {
961  /* Zero out the PTE */
962  ASSERT(PointerPte->u.Long != 0);
963  PointerPte->u.Long = 0;
964 }
965 
966 //
967 // Writes a valid PDE
968 //
970 VOID
972  IN MMPDE TempPde)
973 {
974  /* Write the valid PDE */
975  ASSERT(PointerPde->u.Hard.Valid == 0);
976  ASSERT(TempPde.u.Hard.Valid == 1);
977  *PointerPde = TempPde;
978 }
979 
980 //
981 // Writes an invalid PDE
982 //
984 VOID
986  IN MMPDE InvalidPde)
987 {
988  /* Write the invalid PDE */
989  ASSERT(InvalidPde.u.Hard.Valid == 0);
990  ASSERT(InvalidPde.u.Long != 0);
991  *PointerPde = InvalidPde;
992 }
993 
994 //
995 // Checks if the thread already owns a working set
996 //
998 BOOLEAN
1000 {
1001  /* If any of these are held, return TRUE */
1002  return ((Thread->OwnsProcessWorkingSetExclusive) ||
1003  (Thread->OwnsProcessWorkingSetShared) ||
1004  (Thread->OwnsSystemWorkingSetExclusive) ||
1005  (Thread->OwnsSystemWorkingSetShared) ||
1006  (Thread->OwnsSessionWorkingSetExclusive) ||
1007  (Thread->OwnsSessionWorkingSetShared));
1008 }
1009 
1010 //
1011 // Checks if the process owns the working set lock
1012 //
1014 BOOLEAN
1016 {
1017  /* Check if this process is the owner, and that the thread owns the WS */
1018  if (PsGetCurrentThread()->OwnsProcessWorkingSetExclusive == 0)
1019  {
1020  DPRINT("Thread: %p is not an owner\n", PsGetCurrentThread());
1021  }
1022  if (KeGetCurrentThread()->ApcState.Process != &Process->Pcb)
1023  {
1024  DPRINT("Current thread %p is attached to another process %p\n", PsGetCurrentThread(), Process);
1025  }
1026  return ((KeGetCurrentThread()->ApcState.Process == &Process->Pcb) &&
1027  ((PsGetCurrentThread()->OwnsProcessWorkingSetExclusive) ||
1028  (PsGetCurrentThread()->OwnsProcessWorkingSetShared)));
1029 }
1030 
1031 //
1032 // New ARM3<->RosMM PAGE Architecture
1033 //
1035 BOOLEAN
1037 {
1038  PROS_SECTION_OBJECT RosSection = Section;
1039  if ((RosSection->Type == 'SC') && (RosSection->Size == 'TN')) return TRUE;
1040  return FALSE;
1041 }
1042 
1043 #define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE)
1044 
1045 VOID
1046 NTAPI
1048  IN PMMPFN Pfn1,
1049  IN PFN_NUMBER PageFrameIndex
1050 );
1051 
1053 BOOLEAN
1055 {
1056  return (Process->Vm.Flags.AcquiredUnsafe == TRUE);
1057 }
1058 
1059 //
1060 // Locks the working set for the given process
1061 //
1063 VOID
1065  IN PETHREAD Thread)
1066 {
1067  /* Shouldn't already be owning the process working set */
1068  ASSERT(Thread->OwnsProcessWorkingSetShared == FALSE);
1069  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1070 
1071  /* Block APCs, make sure that still nothing is already held */
1073  ASSERT(!MM_ANY_WS_LOCK_HELD(Thread));
1074 
1075  /* Lock the working set */
1076  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1077 
1078  /* Now claim that we own the lock */
1079  ASSERT(!MI_IS_WS_UNSAFE(Process));
1080  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1081  Thread->OwnsProcessWorkingSetExclusive = TRUE;
1082 }
1083 
1085 VOID
1087  IN PETHREAD Thread)
1088 {
1089  /* Shouldn't already be owning the process working set */
1090  ASSERT(Thread->OwnsProcessWorkingSetShared == FALSE);
1091  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1092 
1093  /* Block APCs, make sure that still nothing is already held */
1095  ASSERT(!MM_ANY_WS_LOCK_HELD(Thread));
1096 
1097  /* Lock the working set */
1098  ExAcquirePushLockShared(&Process->Vm.WorkingSetMutex);
1099 
1100  /* Now claim that we own the lock */
1101  ASSERT(!MI_IS_WS_UNSAFE(Process));
1102  ASSERT(Thread->OwnsProcessWorkingSetShared == FALSE);
1103  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1104  Thread->OwnsProcessWorkingSetShared = TRUE;
1105 }
1106 
1108 VOID
1110  IN PETHREAD Thread)
1111 {
1112  /* Shouldn't already be owning the process working set */
1113  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1114 
1115  /* APCs must be blocked, make sure that still nothing is already held */
1117  ASSERT(!MM_ANY_WS_LOCK_HELD(Thread));
1118 
1119  /* Lock the working set */
1120  ExAcquirePushLockExclusive(&Process->Vm.WorkingSetMutex);
1121 
1122  /* Now claim that we own the lock */
1123  ASSERT(!MI_IS_WS_UNSAFE(Process));
1124  Process->Vm.Flags.AcquiredUnsafe = 1;
1125  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1126  Thread->OwnsProcessWorkingSetExclusive = TRUE;
1127 }
1128 
1129 //
1130 // Unlocks the working set for the given process
1131 //
1133 VOID
1135  IN PETHREAD Thread)
1136 {
1137  /* Make sure we are the owner of a safe acquisition */
1138  ASSERT(MI_WS_OWNER(Process));
1139  ASSERT(!MI_IS_WS_UNSAFE(Process));
1140 
1141  /* The thread doesn't own it anymore */
1142  ASSERT(Thread->OwnsProcessWorkingSetExclusive == TRUE);
1143  Thread->OwnsProcessWorkingSetExclusive = FALSE;
1144 
1145  /* Release the lock and re-enable APCs */
1146  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1148 }
1149 
1150 //
1151 // Unlocks the working set for the given process
1152 //
1154 VOID
1156  IN PETHREAD Thread)
1157 {
1158  /* Make sure we are the owner of a safe acquisition (because shared) */
1159  ASSERT(MI_WS_OWNER(Process));
1160  ASSERT(!MI_IS_WS_UNSAFE(Process));
1161 
1162  /* Ensure we are in a shared acquisition */
1163  ASSERT(Thread->OwnsProcessWorkingSetShared == TRUE);
1164  ASSERT(Thread->OwnsProcessWorkingSetExclusive == FALSE);
1165 
1166  /* Don't claim the lock anylonger */
1167  Thread->OwnsProcessWorkingSetShared = FALSE;
1168 
1169  /* Release the lock and re-enable APCs */
1170  ExReleasePushLockShared(&Process->Vm.WorkingSetMutex);
1172 }
1173 
1174 //
1175 // Unlocks the working set for the given process
1176 //
1178 VOID
1180  IN PETHREAD Thread)
1181 {
1182  /* Make sure we are the owner of an unsafe acquisition */
1185  ASSERT(MI_WS_OWNER(Process));
1186  ASSERT(MI_IS_WS_UNSAFE(Process));
1187 
1188  /* No longer unsafe */
1189  Process->Vm.Flags.AcquiredUnsafe = 0;
1190 
1191  /* The thread doesn't own it anymore */
1192  ASSERT(Thread->OwnsProcessWorkingSetExclusive == TRUE);
1193  Thread->OwnsProcessWorkingSetExclusive = FALSE;
1194 
1195  /* Release the lock but don't touch APC state */
1196  ExReleasePushLockExclusive(&Process->Vm.WorkingSetMutex);
1198 }
1199 
1200 //
1201 // Locks the working set
1202 //
1204 VOID
1206  IN PMMSUPPORT WorkingSet)
1207 {
1208  /* Block APCs */
1210 
1211  /* Working set should be in global memory */
1212  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1213 
1214  /* Thread shouldn't already be owning something */
1215  ASSERT(!MM_ANY_WS_LOCK_HELD(Thread));
1216 
1217  /* Lock this working set */
1218  ExAcquirePushLockExclusive(&WorkingSet->WorkingSetMutex);
1219 
1220  /* Which working set is this? */
1221  if (WorkingSet == &MmSystemCacheWs)
1222  {
1223  /* Own the system working set */
1224  ASSERT((Thread->OwnsSystemWorkingSetExclusive == FALSE) &&
1225  (Thread->OwnsSystemWorkingSetShared == FALSE));
1226  Thread->OwnsSystemWorkingSetExclusive = TRUE;
1227  }
1228  else if (WorkingSet->Flags.SessionSpace)
1229  {
1230  /* Own the session working set */
1231  ASSERT((Thread->OwnsSessionWorkingSetExclusive == FALSE) &&
1232  (Thread->OwnsSessionWorkingSetShared == FALSE));
1233  Thread->OwnsSessionWorkingSetExclusive = TRUE;
1234  }
1235  else
1236  {
1237  /* Own the process working set */
1238  ASSERT((Thread->OwnsProcessWorkingSetExclusive == FALSE) &&
1239  (Thread->OwnsProcessWorkingSetShared == FALSE));
1240  Thread->OwnsProcessWorkingSetExclusive = TRUE;
1241  }
1242 }
1243 
1244 //
1245 // Unlocks the working set
1246 //
1248 VOID
1250  IN PMMSUPPORT WorkingSet)
1251 {
1252  /* Working set should be in global memory */
1253  ASSERT(MI_IS_SESSION_ADDRESS((PVOID)WorkingSet) == FALSE);
1254 
1255  /* Which working set is this? */
1256  if (WorkingSet == &MmSystemCacheWs)
1257  {
1258  /* Release the system working set */
1259  ASSERT((Thread->OwnsSystemWorkingSetExclusive == TRUE) ||
1260  (Thread->OwnsSystemWorkingSetShared == TRUE));
1261  Thread->OwnsSystemWorkingSetExclusive = FALSE;
1262  }
1263  else if (WorkingSet->Flags.SessionSpace)
1264  {
1265  /* Release the session working set */
1266  ASSERT((Thread->OwnsSessionWorkingSetExclusive == TRUE) ||
1267  (Thread->OwnsSessionWorkingSetShared == TRUE));
1268  Thread->OwnsSessionWorkingSetExclusive = 0;
1269  }
1270  else
1271  {
1272  /* Release the process working set */
1273  ASSERT((Thread->OwnsProcessWorkingSetExclusive) ||
1274  (Thread->OwnsProcessWorkingSetShared));
1275  Thread->OwnsProcessWorkingSetExclusive = FALSE;
1276  }
1277 
1278  /* Release the working set lock */
1279  ExReleasePushLockExclusive(&WorkingSet->WorkingSetMutex);
1280 
1281  /* Unblock APCs */
1283 }
1284 
1286 VOID
1288  IN PETHREAD Thread,
1289  OUT PBOOLEAN Safe,
1290  OUT PBOOLEAN Shared)
1291 {
1292  ASSERT(MI_WS_OWNER(Process));
1293 
1294  /* Check if the current owner is unsafe */
1295  if (MI_IS_WS_UNSAFE(Process))
1296  {
1297  /* Release unsafely */
1298  MiUnlockProcessWorkingSetUnsafe(Process, Thread);
1299  *Safe = FALSE;
1300  *Shared = FALSE;
1301  }
1302  else if (Thread->OwnsProcessWorkingSetExclusive == 1)
1303  {
1304  /* Owner is safe and exclusive, release normally */
1305  MiUnlockProcessWorkingSet(Process, Thread);
1306  *Safe = TRUE;
1307  *Shared = FALSE;
1308  }
1309  else
1310  {
1311  /* Owner is shared (implies safe), release normally */
1312  MiUnlockProcessWorkingSetShared(Process, Thread);
1313  *Safe = TRUE;
1314  *Shared = TRUE;
1315  }
1316 }
1317 
1319 VOID
1321  IN PETHREAD Thread,
1322  IN BOOLEAN Safe,
1323  IN BOOLEAN Shared)
1324 {
1325  /* Check if this was a safe lock or not */
1326  if (Safe)
1327  {
1328  if (Shared)
1329  {
1330  /* Reacquire safely & shared */
1331  MiLockProcessWorkingSetShared(Process, Thread);
1332  }
1333  else
1334  {
1335  /* Reacquire safely */
1336  MiLockProcessWorkingSet(Process, Thread);
1337  }
1338  }
1339  else
1340  {
1341  /* Unsafe lock cannot be shared */
1342  ASSERT(Shared == FALSE);
1343  /* Reacquire unsafely */
1344  MiLockProcessWorkingSetUnsafe(Process, Thread);
1345  }
1346 }
1347 
1349 KIRQL
1351 {
1352  KIRQL OldIrql;
1353 
1355  KeAcquireSpinLock(&MmExpansionLock, &OldIrql);
1356  ASSERT(MiExpansionLockOwner == NULL);
1357  MiExpansionLockOwner = PsGetCurrentThread();
1358  return OldIrql;
1359 }
1360 
1362 VOID
1364 {
1365  ASSERT(MiExpansionLockOwner == PsGetCurrentThread());
1366  MiExpansionLockOwner = NULL;
1367  KeReleaseSpinLock(&MmExpansionLock, OldIrql);
1369 }
1370 
1371 //
1372 // Returns the ProtoPTE inside a VAD for the given VPN
1373 //
1375 PMMPTE
1377  IN ULONG_PTR Vpn)
1378 {
1379  PMMPTE ProtoPte;
1380 
1381  /* Find the offset within the VAD's prototype PTEs */
1382  ProtoPte = Vad->FirstPrototypePte + (Vpn - Vad->StartingVpn);
1383  ASSERT(ProtoPte <= Vad->LastContiguousPte);
1384  return ProtoPte;
1385 }
1386 
1387 //
1388 // Returns the PFN Database entry for the given page number
1389 // Warning: This is not necessarily a valid PFN database entry!
1390 //
1392 PMMPFN
1394 {
1395  /* Get the entry */
1396  return &MmPfnDatabase[Pfn];
1397 };
1398 
1399 //
1400 // Drops a locked page without dereferencing it
1401 //
1403 VOID
1405 {
1406  /* This page shouldn't be locked, but it should be valid */
1407  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1408  ASSERT(Pfn1->u2.ShareCount == 0);
1409 
1410  /* Is this the last reference to the page */
1411  if (Pfn1->u3.e2.ReferenceCount == 1)
1412  {
1413  /* It better not be valid */
1414  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1415 
1416  /* Is it a prototype PTE? */
1417  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1418  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1419  {
1420  /* FIXME: We should return commit */
1421  DPRINT1("Not returning commit for prototype PTE\n");
1422  }
1423 
1424  /* Update the counter */
1425  InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1426  }
1427 }
1428 
1429 //
1430 // Drops a locked page and dereferences it
1431 //
1433 VOID
1435 {
1436  USHORT RefCount, OldRefCount;
1437  PFN_NUMBER PageFrameIndex;
1438 
1439  /* Loop while we decrement the page successfully */
1440  do
1441  {
1442  /* There should be at least one reference */
1443  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1444  ASSERT(OldRefCount != 0);
1445 
1446  /* Are we the last one */
1447  if (OldRefCount == 1)
1448  {
1449  /* The page shoudln't be shared not active at this point */
1450  ASSERT(Pfn1->u3.e2.ReferenceCount == 1);
1451  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1452  ASSERT(Pfn1->u2.ShareCount == 0);
1453 
1454  /* Is it a prototype PTE? */
1455  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1456  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1457  {
1458  /* FIXME: We should return commit */
1459  DPRINT1("Not returning commit for prototype PTE\n");
1460  }
1461 
1462  /* Update the counter, and drop a reference the long way */
1463  InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1464  PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
1465  MiDecrementReferenceCount(Pfn1, PageFrameIndex);
1466  return;
1467  }
1468 
1469  /* Drop a reference the short way, and that's it */
1470  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1471  OldRefCount - 1,
1472  OldRefCount);
1473  ASSERT(RefCount != 0);
1474  } while (OldRefCount != RefCount);
1475 
1476  /* If we got here, there should be more than one reference */
1477  ASSERT(RefCount > 1);
1478  if (RefCount == 2)
1479  {
1480  /* Is it still being shared? */
1481  if (Pfn1->u2.ShareCount >= 1)
1482  {
1483  /* Then it should be valid */
1484  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1485 
1486  /* Is it a prototype PTE? */
1487  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1488  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1489  {
1490  /* We don't handle ethis */
1491  ASSERT(FALSE);
1492  }
1493 
1494  /* Update the counter */
1495  InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1496  }
1497  }
1498 }
1499 
1500 //
1501 // References a locked page and updates the counter
1502 // Used in MmProbeAndLockPages to handle different edge cases
1503 //
1505 VOID
1507 {
1508  USHORT RefCount, OldRefCount;
1509 
1510  /* Sanity check */
1511  ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
1512 
1513  /* Does ARM3 own the page? */
1514  if (MI_IS_ROS_PFN(Pfn1))
1515  {
1516  /* ReactOS Mm doesn't track share count */
1517  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1518  }
1519  else
1520  {
1521  /* On ARM3 pages, we should see a valid share count */
1522  ASSERT((Pfn1->u2.ShareCount != 0) && (Pfn1->u3.e1.PageLocation == ActiveAndValid));
1523 
1524  /* Is it a prototype PTE? */
1525  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1526  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1527  {
1528  /* FIXME: We should charge commit */
1529  DPRINT1("Not charging commit for prototype PTE\n");
1530  }
1531  }
1532 
1533  /* More locked pages! */
1534  InterlockedIncrementSizeT(&MmSystemLockPagesCount);
1535 
1536  /* Loop trying to update the reference count */
1537  do
1538  {
1539  /* Get the current reference count, make sure it's valid */
1540  OldRefCount = Pfn1->u3.e2.ReferenceCount;
1541  ASSERT(OldRefCount != 0);
1542  ASSERT(OldRefCount < 2500);
1543 
1544  /* Bump it up by one */
1545  RefCount = InterlockedCompareExchange16((PSHORT)&Pfn1->u3.e2.ReferenceCount,
1546  OldRefCount + 1,
1547  OldRefCount);
1548  ASSERT(RefCount != 0);
1549  } while (OldRefCount != RefCount);
1550 
1551  /* Was this the first lock attempt? If not, undo our bump */
1552  if (OldRefCount != 1) InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1553 }
1554 
1555 //
1556 // References a locked page and updates the counter
1557 // Used in all other cases except MmProbeAndLockPages
1558 //
1560 VOID
1562 {
1563  USHORT NewRefCount;
1564 
1565  /* Is it a prototype PTE? */
1566  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1567  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1568  {
1569  /* FIXME: We should charge commit */
1570  DPRINT1("Not charging commit for prototype PTE\n");
1571  }
1572 
1573  /* More locked pages! */
1574  InterlockedIncrementSizeT(&MmSystemLockPagesCount);
1575 
1576  /* Update the reference count */
1577  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1578  if (NewRefCount == 2)
1579  {
1580  /* Is it locked or shared? */
1581  if (Pfn1->u2.ShareCount)
1582  {
1583  /* It's shared, so make sure it's active */
1584  ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid);
1585  }
1586  else
1587  {
1588  /* It's locked, so we shouldn't lock again */
1589  InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1590  }
1591  }
1592  else
1593  {
1594  /* Someone had already locked the page, so undo our bump */
1595  ASSERT(NewRefCount < 2500);
1596  InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1597  }
1598 }
1599 
1600 //
1601 // References a locked page and updates the counter
1602 // Used in all other cases except MmProbeAndLockPages
1603 //
1605 VOID
1607 {
1608  USHORT NewRefCount;
1609 
1610  /* Make sure the page isn't used yet */
1611  ASSERT(Pfn1->u2.ShareCount == 0);
1612  ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid);
1613 
1614  /* Is it a prototype PTE? */
1615  if ((Pfn1->u3.e1.PrototypePte == 1) &&
1616  (Pfn1->OriginalPte.u.Soft.Prototype == 1))
1617  {
1618  /* FIXME: We should charge commit */
1619  DPRINT1("Not charging commit for prototype PTE\n");
1620  }
1621 
1622  /* More locked pages! */
1623  InterlockedIncrementSizeT(&MmSystemLockPagesCount);
1624 
1625  /* Update the reference count */
1626  NewRefCount = InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount);
1627  if (NewRefCount != 1)
1628  {
1629  /* Someone had already locked the page, so undo our bump */
1630  ASSERT(NewRefCount < 2500);
1631  InterlockedDecrementSizeT(&MmSystemLockPagesCount);
1632  }
1633 }
1634 
1636 VOID
1638 {
1639  PUSHORT RefCount;
1640 
1641  RefCount = &MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)];
1642 
1643  *RefCount += 1;
1644  ASSERT(*RefCount <= PTE_PER_PAGE);
1645 }
1646 
1648 VOID
1650 {
1651  PUSHORT RefCount;
1652 
1653  RefCount = &MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)];
1654 
1655  *RefCount -= 1;
1656  ASSERT(*RefCount < PTE_PER_PAGE);
1657 }
1658 
1660 USHORT
1662 {
1663  PUSHORT RefCount;
1664 
1665  RefCount = &MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)];
1666 
1667  return *RefCount;
1668 }
1669 
1670 BOOLEAN
1671 NTAPI
1673  IN ULONG Phase,
1674  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1675 );
1676 
1677 VOID
1678 NTAPI
1680 
1681 NTSTATUS
1682 NTAPI
1684  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1685 );
1686 
1687 VOID
1688 NTAPI
1690  VOID
1691 );
1692 
1693 VOID
1694 NTAPI
1696  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1697 );
1698 
1699 VOID
1700 NTAPI
1702  VOID
1703 );
1704 
1705 VOID
1706 NTAPI
1708  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1709 );
1710 
1711 VOID
1712 NTAPI
1714  VOID
1715 );
1716 
1717 VOID
1718 NTAPI
1720  VOID
1721 );
1722 
1723 BOOLEAN
1724 NTAPI
1726  VOID
1727 );
1728 
1729 PFN_NUMBER
1730 NTAPI
1732  IN PFN_NUMBER PageCount
1733 );
1734 
1735 PPHYSICAL_MEMORY_DESCRIPTOR
1736 NTAPI
1738  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1739  IN PBOOLEAN IncludeType
1740 );
1741 
1742 PFN_NUMBER
1743 NTAPI
1745  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1746  IN PBOOLEAN IncludeType
1747 );
1748 
1749 VOID
1750 FASTCALL
1752  IN PVOID AddressStart,
1753  IN PVOID AddressEnd
1754 );
1755 
1756 NTSTATUS
1757 NTAPI
1761  IN OUT PSIZE_T NumberOfBytesToProtect,
1762  IN ULONG NewAccessProtection,
1763  OUT PULONG OldAccessProtection OPTIONAL
1764 );
1765 
1766 NTSTATUS
1767 NTAPI
1769  IN ULONG FaultCode,
1770  IN PVOID Address,
1772  IN PVOID TrapInformation
1773 );
1774 
1775 NTSTATUS
1776 FASTCALL
1778  IN PVOID Address
1779 );
1780 
1781 VOID
1782 NTAPI
1784  VOID
1785 );
1786 
1787 VOID
1788 NTAPI
1790  VOID
1791 );
1792 
1793 VOID
1794 NTAPI
1796  VOID
1797 );
1798 
1799 VOID //
1800 NTAPI //
1801 InitializePool( //
1802  IN POOL_TYPE PoolType,// FIXFIX: This should go in ex.h after the pool merge
1803  IN ULONG Threshold //
1804 ); //
1805 
1806 // FIXFIX: THIS ONE TOO
1807 VOID
1808 NTAPI
1811  IN PPOOL_DESCRIPTOR PoolDescriptor,
1813  IN ULONG PoolIndex,
1814  IN ULONG Threshold,
1815  IN PVOID PoolLock
1816 );
1817 
1818 NTSTATUS
1819 NTAPI
1821  VOID
1822 );
1823 
1824 VOID
1825 NTAPI
1827  IN PMMPTE StartingPte,
1828  IN ULONG NumberOfPtes,
1830 );
1831 
1832 PMMPTE
1833 NTAPI
1835  IN ULONG NumberOfPtes,
1836  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1837 );
1838 
1839 VOID
1840 NTAPI
1842  IN PMMPTE StartingPte,
1843  IN ULONG NumberOfPtes,
1844  IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
1845 );
1846 
1847 
1848 PFN_NUMBER
1849 NTAPI
1851  IN PFN_NUMBER LowestPfn,
1852  IN PFN_NUMBER HighestPfn,
1853  IN PFN_NUMBER BoundaryPfn,
1854  IN PFN_NUMBER SizeInPages,
1856 );
1857 
1858 PVOID
1859 NTAPI
1862  IN PFN_NUMBER BaseAddressPages,
1863  IN PFN_NUMBER SizeInPages,
1864  IN PFN_NUMBER LowestPfn,
1865  IN PFN_NUMBER HighestPfn,
1866  IN PFN_NUMBER BoundaryPfn,
1867  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute
1868 );
1869 
1870 PMDL
1871 NTAPI
1873  IN PHYSICAL_ADDRESS LowAddress,
1877  IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
1878  IN ULONG Flags
1879 );
1880 
1881 VOID
1882 NTAPI
1884  IN PMMPFNLIST ListHead,
1885  IN PFN_NUMBER PageFrameIndex
1886 );
1887 
1888 VOID
1889 NTAPI
1891  IN PMMPFN Entry
1892 );
1893 
1894 VOID
1895 NTAPI
1897  IN PMMPFN Pfn
1898 );
1899 
1900 VOID
1901 NTAPI
1903  IN PFN_NUMBER PageFrameIndex,
1904  IN PMMPTE PointerPte,
1905  IN BOOLEAN Modified
1906 );
1907 
1908 NTSTATUS
1909 NTAPI
1911  OUT PPFN_NUMBER PageFrameIndex,
1912  IN PMMPDE PointerPde,
1913  IN PFN_NUMBER ContainingPageFrame,
1914  IN BOOLEAN SessionAllocation
1915 );
1916 
1917 VOID
1918 NTAPI
1920  IN PFN_NUMBER PageFrameIndex,
1921  IN PMMPTE PointerPte,
1922  IN MMPTE TempPte
1923 );
1924 
1925 VOID
1926 NTAPI
1928  IN PFN_NUMBER PageFrameIndex,
1929  IN PVOID PteAddress,
1930  IN PFN_NUMBER PteFrame
1931 );
1932 
1933 VOID
1934 NTAPI
1936  IN PMMPFN Pfn1,
1937  IN PFN_NUMBER PageFrameIndex
1938 );
1939 
1940 PFN_NUMBER
1941 NTAPI
1943  IN ULONG Color
1944 );
1945 
1946 PFN_NUMBER
1947 NTAPI
1949  IN ULONG Color
1950 );
1951 
1952 VOID
1953 NTAPI
1955  IN PFN_NUMBER PageFrameIndex
1956 );
1957 
1958 VOID
1959 NTAPI
1961  IN PFN_NUMBER PageFrameIndex
1962 );
1963 
1964 PFN_COUNT
1965 NTAPI
1967  IN PMMPTE PointerPte,
1968  IN PFN_NUMBER PageCount,
1969  IN ULONG Flags,
1970  OUT PPFN_NUMBER ValidPages
1971 );
1972 
1973 ULONG
1974 NTAPI
1976  IN PMMPTE PointerPte
1977 );
1978 
1980 NTAPI
1982  IN PVOID Address
1983 );
1984 
1985 VOID
1986 NTAPI
1988  VOID
1989 );
1990 
1991 VOID
1992 NTAPI
1994  VOID
1995 );
1996 
1997 VOID
1998 NTAPI
2000  VOID
2001 );
2002 
2003 BOOLEAN
2004 NTAPI
2005 MiIsPfnInUse(
2006  IN PMMPFN Pfn1
2007 );
2008 
2009 PMMVAD
2010 NTAPI
2013 );
2014 
2016 NTAPI
2018  IN ULONG_PTR StartVpn,
2019  IN ULONG_PTR EndVpn,
2021  OUT PMMADDRESS_NODE *NodeOrParent
2022 );
2023 
2025 NTAPI
2027  IN SIZE_T Length,
2028  IN ULONG_PTR BoundaryAddress,
2033 );
2034 
2035 NTSTATUS
2036 NTAPI
2038  IN SIZE_T Length,
2039  IN ULONG_PTR BoundaryAddress,
2043 );
2044 
2046 NTAPI
2048  IN SIZE_T Length,
2051  OUT PMMADDRESS_NODE *PreviousVad,
2053 );
2054 
2055 NTSTATUS
2056 NTAPI
2058  IN PMMVAD Vad,
2059  IN PVOID Base,
2060  IN SIZE_T Size,
2061  IN ULONG ProtectionMask
2062 );
2063 
2064 VOID
2065 NTAPI
2066 MiInsertVad(
2067  _Inout_ PMMVAD Vad,
2068  _Inout_ PMM_AVL_TABLE VadRoot);
2069 
2070 NTSTATUS
2071 NTAPI
2073  _Inout_ PMMVAD Vad,
2076  _In_ ULONG_PTR HighestAddress,
2079 
2080 VOID
2081 NTAPI
2083  IN PSECTION Section
2084 );
2085 
2086 NTSTATUS
2087 NTAPI
2091  IN ULONG Flags
2092 );
2093 
2094 NTSTATUS
2095 NTAPI
2099  IN BOOLEAN SkipDebuggerNotify
2100 );
2101 
2102 VOID
2103 NTAPI
2104 MiInsertNode(
2106  IN PMMADDRESS_NODE NewNode,
2109 );
2110 
2111 VOID
2112 NTAPI
2113 MiRemoveNode(
2116 );
2117 
2119 NTAPI
2122 );
2123 
2125 NTAPI
2128 );
2129 
2130 BOOLEAN
2131 NTAPI
2133  IN PMMSESSION InputSession OPTIONAL
2134 );
2135 
2136 VOID
2137 NTAPI
2139  VOID
2140 );
2141 
2142 VOID
2143 NTAPI
2145  IN PMM_SESSION_SPACE SessionGlobal
2146 );
2147 
2148 VOID
2149 NTAPI
2151  IN PEPROCESS NewProcess
2152 );
2153 
2154 NTSTATUS
2155 NTAPI
2157  IN PVOID StartVa,
2158  IN PVOID EndVa
2159 );
2160 
2161 ULONG
2162 NTAPI
2164  IN ULONG Protect
2165 );
2166 
2167 VOID
2168 NTAPI
2170  IN ULONG_PTR Va,
2171  IN ULONG_PTR EndingAddress,
2172  IN PMMVAD Vad
2173 );
2174 
2175 VOID
2176 NTAPI
2177 MiDeletePte(
2178  IN PMMPTE PointerPte,
2181  IN PMMPTE PrototypePte
2182 );
2183 
2184 ULONG
2185 NTAPI
2187  IN PVOID PageTableVirtualAddress,
2189 );
2190 
2191 ULONG
2192 NTAPI
2195  IN KIRQL OldIrql
2196 );
2197 
2198 VOID
2199 NTAPI
2202  IN PMMVAD Vad
2203 );
2204 
2206 NTAPI
2208  IN PMMVAD Vad,
2209  IN ULONG_PTR Vpn
2210 );
2211 
2212 VOID
2213 NTAPI
2215  PVOID ObjectBody
2216 );
2217 
2218 NTSTATUS
2219 NTAPI
2223  OUT PVOID MemoryInformation,
2224  IN SIZE_T MemoryInformationLength,
2226 );
2227 
2228 NTSTATUS
2229 NTAPI
2232 );
2233 
2234 POOL_TYPE
2235 NTAPI
2237  IN PVOID PoolAddress
2238 );
2239 
2240 VOID
2241 NTAPI
2243  IN PMMPDE PointerPde,
2244  IN PEPROCESS TargetProcess,
2245  IN KIRQL OldIrql
2246 );
2247 
2248 //
2249 // MiRemoveZeroPage will use inline code to zero out the page manually if only
2250 // free pages are available. In some scenarios, we don't/can't run that piece of
2251 // code and would rather only have a real zero page. If we can't have a zero page,
2252 // then we'd like to have our own code to grab a free page and zero it out, by
2253 // using MiRemoveAnyPage. This macro implements this.
2254 //
2256 PFN_NUMBER
2258 {
2259  if (MmFreePagesByColor[ZeroedPageList][Color].Flink != LIST_HEAD) return MiRemoveZeroPage(Color);
2260  return 0;
2261 }
2262 
2263 #if (_MI_PAGING_LEVELS == 2)
2265 BOOLEAN
2266 MiSynchronizeSystemPde(PMMPDE PointerPde)
2267 {
2268  MMPDE SystemPde;
2269  ULONG Index;
2270 
2271  /* Get the Index from the PDE */
2272  Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
2273 
2274  /* Copy the PDE from the double-mapped system page directory */
2275  SystemPde = MmSystemPagePtes[Index];
2276  *PointerPde = SystemPde;
2277 
2278  /* Make sure we re-read the PDE and PTE */
2280 
2281  /* Return, if we had success */
2282  return SystemPde.u.Hard.Valid != 0;
2283 }
2284 #endif
2285 
2286 /* EOF */
PVOID MiSessionImageStart
Definition: init.c:29
DWORD *typedef PVOID
Definition: winlogon.h:52
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
ACPI_EFI_MEMORY_TYPE
Definition: acefiex.h:128
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:479
ULONG MmProcessColorSeed
Definition: procsup.c:20
FORCEINLINE VOID MI_ERASE_PTE(IN PMMPTE PointerPte)
Definition: miarm.h:959
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:980
Definition: bidi.c:477
ULONG SessionId
Definition: miarm.h:456
LIST_ENTRY ProcessList
Definition: miarm.h:457
VOID NTAPI MiInitializePfn(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN BOOLEAN Modified)
Definition: pfnlist.c:969
#define IN
Definition: typedefs.h:38
MMPTE ValidKernelPte
Definition: init.c:31
#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
PVOID ULONG Address
Definition: oprghdlr.h:14
SIZE_T NonPageablePages
Definition: miarm.h:460
BOOLEAN MmMirroring
Definition: pfnlist.c:35
_MI_PFN_CACHE_ATTRIBUTE
Definition: miarm.h:387
USHORT PoolTagHash
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:396
PVOID Blink
Definition: miarm.h:411
PVOID PagedPoolStart
Definition: miarm.h:462
PVOID MmNonPagedPoolStart
Definition: init.c:24
ULONG NTAPI MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress, IN KIRQL OldIrql)
Definition: virtual.c:257
PFN_NUMBER StartFrame
Definition: miarm.h:417
LONG ReferenceCount
Definition: miarm.h:450
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:1179
BOOLEAN MmZeroPageFile
Definition: pagefile.c:88
#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:1350
VOID NTAPI MiUnlinkPageFromList(IN PMMPFN Pfn)
Definition: pfnlist.c:264
PFN_NUMBER MmMinimumFreePages
Definition: mminit.c:314
_In_ ULONG Mode
Definition: hubbusif.h:303
PPHYSICAL_MEMORY_DESCRIPTOR NTAPI MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
Definition: mminit.c:1622
FORCEINLINE VOID MiDereferencePfnAndDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1434
#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:870
#define MI_MAKE_ACCESSED_PAGE(x)
Definition: mm.h:96
signed short * PSHORT
Definition: retypes.h:6
PMMPDE PageTables
Definition: miarm.h:486
_MMSYSTEM_PTE_POOL_TYPE
Definition: miarm.h:380
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:1155
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:210
ULONG PFN_COUNT
Definition: mmtypes.h:102
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
LONG ProcessReferenceToSession
Definition: miarm.h:473
#define MI_MAKE_OWNER_PAGE(x)
Definition: mm.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
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:140
SIZE_T MmSessionViewSize
Definition: init.c:35
POOL_TYPE NTAPI MmDeterminePoolType(IN PVOID PoolAddress)
Definition: pool.c:406
VOID NTAPI MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
FORCEINLINE BOOLEAN MI_IS_MAPPED_PTE(PMMPTE PointerPte)
Definition: miarm.h:876
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
PFN_NUMBER PageCount
Definition: miarm.h:398
PMMPTE MiSessionLastPte
Definition: mminit.c:146
VOID NTAPI MiDeleteARM3Section(PVOID ObjectBody)
Definition: section.c:3244
PFN_NUMBER MmHighMemoryThreshold
Definition: mminit.c:301
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
struct _MI_LARGE_PAGE_RANGES MI_LARGE_PAGE_RANGES
FORCEINLINE VOID MiReferenceUnusedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1606
PLDR_DATA_TABLE_ENTRY NTAPI MiLookupDataTableEntry(IN PVOID Address)
Definition: sysldr.c:3365
SIZE_T MmSessionImageSize
Definition: init.c:37
HARDWARE_PDE_ARMV6 TempPde
Definition: winldr.c:77
PMM_SESSION_SPACE MmSessionSpace
Definition: session.c:21
PMMPDE MiHighestUserPde
Definition: mminit.c:234
FORCEINLINE USHORT MiQueryPageTableReferences(IN PVOID Address)
Definition: miarm.h:1661
#define SESSION_POOL_LOOKASIDES
Definition: mm.h:80
KSPIN_LOCK MmExpansionLock
Definition: session.c:32
FORCEINLINE VOID MiLockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1064
RTL_BITMAP MiPfnBitMap
Definition: init.c:44
SIZE_T TotalBytes
Definition: miarm.h:300
PCHAR SystemSpaceViewStart
Definition: miarm.h:431
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1280
PFN_NUMBER NumberOfPages
Definition: miarm.h:404
PVOID MiSessionSpaceWs
Definition: mminit.c:130
#define PD_COUNT
Definition: miarm.h:31
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:718
MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor
Definition: init.c:47
ULONG SystemSpaceHashEntries
Definition: miarm.h:434
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
_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
ULONG BitmapFailures
Definition: miarm.h:436
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:454
PVOID PMDL
Definition: usb.h:39
LARGE_INTEGER LastProcessSwappedOutTime
Definition: miarm.h:458
VOID NTAPI MiSyncCachedRanges(VOID)
Definition: largepag.c:54
SIZE_T MmMinimumStackCommitInBytes
Definition: mminit.c:370
#define FASTCALL
Definition: nt_native.h:50
union _MMPTE::@2171 u
ULONG MmProductType
Definition: mminit.c:325
struct _MMVIEW * PMMVIEW
ULONG RunningDeAllocs
Definition: miarm.h:293
LIST_ENTRY ListHeads[POOL_LISTS_PER_PAGE]
Definition: miarm.h:302
#define MiGetPdeOffset(x)
Definition: mm.h:184
VOID NTAPI MiInsertBasedSection(IN PSECTION Section)
Definition: vadnode.c:345
FORCEINLINE VOID MiReferenceUsedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1561
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:65
UNICODE_STRING BaseName
Definition: miarm.h:377
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(IN PMMPTE NewPte, IN PVOID Segment)
Definition: miarm.h:840
PPOOL_TRACKER_TABLE PoolTrackTable
Definition: expool.c:40
PMMPFN MmPfnDatabase
Definition: freelist.c:24
KGUARDED_MUTEX SystemSpaceViewLock
Definition: miarm.h:429
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:2139
MM_PAGED_POOL_INFO PagedPoolInfo
Definition: miarm.h:478
NTSTATUS NTAPI MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:672
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:39
SIZE_T MmSizeOfPagedPoolInBytes
Definition: miarm.h:565
PVOID MmNonPagedPoolEnd
Definition: mminit.c:99
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2043
FORCEINLINE BOOLEAN MI_IS_WS_UNSAFE(IN PEPROCESS Process)
Definition: miarm.h:1054
PMMPTE MmLastReservedMappingPte
Definition: hypermap.c:20
VOID NTAPI MiInitializeSessionWsSupport(VOID)
Definition: session.c:40
PVOID MmSessionBase
Definition: miarm.h:559
FORCEINLINE BOOLEAN MM_ANY_WS_LOCK_HELD(IN PETHREAD Thread)
Definition: miarm.h:999
enum _MM_SYSTEM_SIZE MM_SYSTEMSIZE
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:653
struct _MMSESSION * PMMSESSION
SIZE_T MmSystemLockPagesCount
Definition: mdlsup.c:22
PDRIVER_UNLOAD Win32KDriverUnload
Definition: miarm.h:481
ULONG * PPFN_NUMBER
Definition: ke.h:8
struct _POOL_DESCRIPTOR * PPOOL_DESCRIPTOR
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN MmDynamicPfn
Definition: pfnlist.c:34
VOID NTAPI INIT_FUNCTION ExInitializePoolDescriptor(IN PPOOL_DESCRIPTOR PoolDescriptor, IN POOL_TYPE PoolType, IN ULONG PoolIndex, IN ULONG Threshold, IN PVOID PoolLock)
Definition: expool.c:964
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:474
ULONG_PTR * PSIZE_T
Definition: typedefs.h:78
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
#define FALSE
Definition: types.h:117
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:916
ULONG MmVerifyDriverBufferLength
Definition: drvmgmt.c:24
LIST_ENTRY Links
Definition: miarm.h:376
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
PFN_NUMBER BasePage
Definition: miarm.h:397
#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:985
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:20
MMPDE ValidKernelPdeLocal
Definition: init.c:34
VOID NTAPI MiInitializeSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE PoolType)
Definition: syspte.c:399
PFN_NUMBER MmPlentyFreePages
Definition: mminit.c:322
PKEVENT MiLowNonPagedPoolEvent
Definition: mminit.c:296
struct _MMCOLOR_TABLES * PMMCOLOR_TABLES
struct _MI_LARGE_PAGE_DRIVER_ENTRY * PMI_LARGE_PAGE_DRIVER_ENTRY
FORCEINLINE BOOLEAN MiIsUserPde(PVOID Address)
Definition: miarm.h:692
PFN_NUMBER Flink
Definition: miarm.h:410
USHORT AllocatorBackTraceIndex
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1196
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:2257
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
POOL_DESCRIPTOR PagedPool
Definition: miarm.h:482
FORCEINLINE VOID MI_MAKE_TRANSITION_PTE(_Out_ PMMPTE NewPte, _In_ PFN_NUMBER Page, _In_ ULONG Protection)
Definition: miarm.h:886
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:46
PMMVAD NTAPI MiLocateAddress(IN PVOID VirtualAddress)
Definition: vadnode.c:48
struct _MM_SESSION_SPACE_FLAGS MM_SESSION_SPACE_FLAGS
FORCEINLINE VOID MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, IN PMMPTE PointerPte)
Definition: miarm.h:811
#define KeLeaveGuardedRegion()
Definition: ke_x.h:63
PFN_NUMBER MiHighPagedPoolThreshold
Definition: mminit.c:303
#define FORCEINLINE
Definition: ntbasedef.h:221
#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:624
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:1249
SIZE_T NonPagedBytes
Definition: miarm.h:351
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:971
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:374
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:432
ULONG SystemSpaceHashKey
Definition: miarm.h:435
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:297
PMMCOLOR_TABLES MmFreePagesByColor[FreePageList+1]
Definition: mminit.c:286
MMPTE PrototypePte
Definition: init.c:42
_Inout_ PVOID Segment
Definition: exfuncs.h:893
FORCEINLINE ULONG_PTR MiDetermineUserGlobalPteMask(IN PVOID PointerPte)
Definition: miarm.h:711
ULONG PoolIndex
Definition: miarm.h:291
UINTN Size
Definition: acefiex.h:555
ULONG LongFlags
Definition: miarm.h:453
NTSTATUS NTAPI MiRosUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:4872
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:1109
PVOID MmHyperSpaceEnd
Definition: init.c:56
MMPDE DemandZeroPde
Definition: init.c:38
unsigned char BOOLEAN
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:454
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:449
FORCEINLINE VOID MiDecrementPageTableReferences(IN PVOID Address)
Definition: miarm.h:1649
ULONG CurrentProcess
Definition: shell.c:125
LONG NTSTATUS
Definition: precomp.h:26
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:1287
ULONG RunningAllocs
Definition: miarm.h:292
SIZE_T CommittedPages
Definition: miarm.h:461
#define MI_IS_SESSION_PTE(Pte)
Definition: miarm.h:143
ULONG ExpNumberOfPagedPools
Definition: expool.c:33
struct _MM_SESSION_SPACE MM_SESSION_SPACE
INT POOL_TYPE
Definition: typedefs.h:76
BOOLEAN NTAPI MiInitializeSystemSpaceMap(IN PMMSESSION InputSession OPTIONAL)
Definition: section.c:240
MMSESSION Session
Definition: miarm.h:476
CSHORT Type
Definition: mm.h:192
ULONG64 Valid
Definition: mmtypes.h:150
LONG PendingFreeDepth
Definition: miarm.h:299
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ULONG MmMaximumNonPagedPoolPercent
Definition: init.c:20
static const UCHAR Index[8]
Definition: usbohci.c:11
enum _MMSYSTEM_PTE_POOL_TYPE MMSYSTEM_PTE_POOL_TYPE
unsigned short * PUSHORT
Definition: retypes.h:2
#define PTE_PER_PAGE
Definition: mm.h:19
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
struct _PHYSICAL_MEMORY_RUN PHYSICAL_MEMORY_RUN
LONG NonPagedFrees
Definition: miarm.h:350
#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:75
#define _Inout_
Definition: no_sal2.h:244
C_ASSERT(sizeof(POOL_HEADER)==POOL_BLOCK_SIZE)
PFN_NUMBER MiHighNonPagedPoolThreshold
Definition: mminit.c:305
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
PVOID MiSessionPoolStart
Definition: init.c:32
struct _MMVIEW MMVIEW
#define KeEnterGuardedRegion()
Definition: ke_x.h:34
ULONG SessionPoolAllocationFailures[4]
Definition: miarm.h:467
PMMADDRESS_NODE NTAPI MiGetNextNode(IN PMMADDRESS_NODE Node)
Definition: vadnode.c:467
PVOID MmHighSectionBase
Definition: section.c:111
ULONG Threshold
Definition: miarm.h:296
SIZE_T Spare0
Definition: miarm.h:301
FORCEINLINE VOID MiLockProcessWorkingSetShared(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1086
PVOID MiSessionSpaceEnd
Definition: init.c:27
SIZE_T PagedBytes
Definition: miarm.h:354
ULONG TotalPages
Definition: miarm.h:294
ULONG_PTR MxPfnAllocation
Definition: init.c:43
SIZE_T MmBootImageSize
Definition: init.c:49
FORCEINLINE BOOLEAN MiIsUserPte(PVOID Address)
Definition: miarm.h:700
GENERAL_LOOKASIDE Lookaside[SESSION_POOL_LOOKASIDES]
Definition: miarm.h:475
VOID NTAPI MiDecrementReferenceCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1222
#define PDE_TOP
Definition: mm.h:32
char * PBOOLEAN
Definition: retypes.h:11
FORCEINLINE PMMPFN MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
Definition: miarm.h:1393
PKGUARDED_MUTEX SystemSpaceViewLockPointer
Definition: miarm.h:430
PFN_NUMBER MmLowMemoryThreshold
Definition: mminit.c:300
IN REFCLSID IN PUNKNOWN IN POOL_TYPE PoolType
Definition: unknown.h:68
VOID UINTN Length
Definition: acefiex.h:744
PVOID PagedPoolEnd
Definition: miarm.h:463
KGUARDED_MUTEX PagedPoolMutex
Definition: miarm.h:477
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
PCONTROL_AREA ControlArea
Definition: miarm.h:424
PFN_NUMBER MmMaximumNonPagedPoolInPages
Definition: mminit.c:30
PMMPTE MiSessionImagePteStart
Definition: mminit.c:143
FORCEINLINE VOID MiDropLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1404
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:303
Definition: btrfs_drv.h:1762
ULONG MmMinAdditionNonPagedPoolPerMb
Definition: mminit.c:40
VOID NTAPI MiComputeColorInformation(VOID)
Definition: mminit.c:508
const ULONG MmProtectToValue[32]
Definition: page.c:81
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3773
struct _PHYSICAL_MEMORY_RUN * PPHYSICAL_MEMORY_RUN
#define _1MB
Definition: miarm.h:15
ULONG MmSecondaryColors
Definition: mminit.c:256
LIST_HEAD(acpi_bus_event_list)
struct _MI_LARGE_PAGE_RANGES * PMI_LARGE_PAGE_RANGES
BOOLEAN MmProtectFreedNonPagedPool
Definition: pool.c:29
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326
LIST_ENTRY ImageList
Definition: miarm.h:468
_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:472
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:554
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:787
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:295
PVOID PendingFrees
Definition: miarm.h:298
#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:1049
FORCEINLINE VOID MiLockProcessWorkingSetForFault(IN PEPROCESS Process, IN PETHREAD Thread, IN BOOLEAN Safe, IN BOOLEAN Shared)
Definition: miarm.h:1320
ULONG_PTR SIZE_T
Definition: typedefs.h:78
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define SYSTEM_PD_SIZE
Definition: miarm.h:36
FORCEINLINE VOID MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte, IN MMPTE InvalidPte)
Definition: miarm.h:945
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:471
DWORD *typedef HANDLE
Definition: winlogon.h:52
MMPTE HyperTemplatePte
Definition: hypermap.c:22
struct _MMSESSION MMSESSION
PRTL_BITMAP SystemSpaceBitMap
Definition: miarm.h:437
SIZE_T MmDefaultMaximumNonPagedPool
Definition: mminit.c:41
ULONG MmVerifyDriverBufferType
Definition: drvmgmt.c:25
USHORT PreviousSize
POOL_TYPE PoolType
Definition: miarm.h:290
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS HighAddress
Definition: mmfuncs.h:226
unsigned short USHORT
Definition: pedump.c:61
LIST_ENTRY MmProcessList
Definition: largepag.c:20
SIZE_T MmAllocationFragment
Definition: mminit.c:352
PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
PMMPTE MiFirstReservedZeroingPte
Definition: hypermap.c:21
SIZE_T MmSessionSize
Definition: init.c:34
BOOLEAN MiLargePageAllDrivers
Definition: largepag.c:27
ULONG NTAPI MiGetPageProtection(IN PMMPTE PointerPte)
Definition: virtual.c:1329
PMMWSLE Wsle
Definition: miarm.h:480
#define MI_IS_ROS_PFN(x)
Definition: miarm.h:1043
Definition: miarm.h:421
NTSTATUS NTAPI MiInitializeSessionPool(VOID)
Definition: pool.c:1276
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1452
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
LONG ResidentProcessCount
Definition: miarm.h:466
VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID)
Definition: pool.c:184
MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType]
Definition: iosup.c:27
VOID NTAPI InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold)
Definition: expool.c:1015
BOOLEAN NTAPI MiInitializeMemoryEvents(VOID)
Definition: mminit.c:1339
VOID NTAPI MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
PPOOL_DESCRIPTOR ExpPagedPoolDescriptor[16+1]
Definition: expool.c:35
unsigned int * PULONG
Definition: retypes.h:1
VOID NTAPI MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:672
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1363
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define InterlockedCompareExchange16
Definition: interlocked.h:109
PKEVENT MiLowPagedPoolEvent
Definition: mminit.c:294
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
VOID NTAPI MiInitializePoolEvents(VOID)
Definition: pool.c:201
SIZE_T MmSessionPoolSize
Definition: init.c:36
#define DPRINT1
Definition: precomp.h:8
#define POOL_LISTS_PER_PAGE
Definition: miarm.h:250
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:555
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:643
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:349
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:934
MMSUPPORT MmSystemCacheWs
Definition: init.c:55
#define OUT
Definition: typedefs.h:39
PVOID MiSessionPoolEnd
Definition: init.c:31
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1157
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:1637
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:63
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
CSHORT Size
Definition: mm.h:193
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:423
BOOLEAN NTAPI MiIsPfnInUse(IN PMMPFN Pfn1)
Definition: freelist.c:142
ULONG AttachCount
Definition: miarm.h:470
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:412
#define InterlockedDecrementSizeT(a)
Definition: interlocked.h:153
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:248
FORCEINLINE VOID MiReferenceProbedPageAndBumpLockCount(IN PMMPFN Pfn1)
Definition: miarm.h:1506
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:748
PMMPTE MiSessionBasePte
Definition: mminit.c:145
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1205
NTSTATUS NTAPI MmArmAccessFault(IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
Definition: pagfault.c:1629
PMMPTE MiHighestUserPte
Definition: mminit.c:233
MMPTE ValidKernelPteLocal
Definition: init.c:35
#define KeGetCurrentThread
Definition: hal.h:44
MMPDE ValidKernelPde
Definition: init.c:30
struct _POOL_TRACKER_TABLE * PPOOL_TRACKER_TABLE
union _MM_SESSION_SPACE::@1692 u
ULONG SystemSpaceHashSize
Definition: miarm.h:433
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE
KGUARDED_MUTEX MmSectionCommitMutex
Definition: section.c:108
VOID NTAPI MiInitializeNonPagedPool(VOID)
Definition: pool.c:276
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:902
FORCEINLINE VOID MI_UPDATE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:930
FORCEINLINE BOOLEAN MI_WS_OWNER(IN PEPROCESS Process)
Definition: miarm.h:1015
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:4108
PFN_NUMBER MmSystemPageDirectory[PD_COUNT]
Definition: init.c:40
PKEVENT MiHighMemoryEvent
Definition: mminit.c:293
PMMPDE PagedPoolBasePde
Definition: miarm.h:464
PFN_NUMBER LastFrame
Definition: miarm.h:418
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
IN HDEVINFO IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
Definition: devinst.c:44
LONG ImageLoadingCount
Definition: miarm.h:495
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:771
_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:1134
PMMPDE MmSystemPagePtes
Definition: init.c:41
FORCEINLINE PMMPTE MI_GET_PROTOTYPE_PTE_FOR_VPN(IN PMMVAD Vad, IN ULONG_PTR Vpn)
Definition: miarm.h:1376
#define INIT_FUNCTION
Definition: ntoskrnl.h:11
PFN_NUMBER SessionPageDirectoryIndex
Definition: miarm.h:459
Definition: mm.h:367
PVOID MiSessionViewStart
Definition: init.c:30
BOOLEAN MmTrackPtes
Definition: mdlsup.c:20
FORCEINLINE BOOLEAN MiIsRosSectionObject(IN PVOID Section)
Definition: miarm.h:1036
struct _POOL_DESCRIPTOR POOL_DESCRIPTOR
PVOID MmNonPagedSystemStart
Definition: miarm.h:556
PMMPTE MiSessionImagePteEnd
Definition: mminit.c:144