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