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