1 #ifndef __INCLUDE_INTERNAL_MM_H
2 #define __INCLUDE_INTERNAL_MM_H
4 #include <internal/arch/mm.h>
6 /* TYPES *********************************************************************/
10 extern ULONG MiFreeSwapPages
;
11 extern ULONG MiUsedSwapPages
;
12 extern ULONG MmPagedPoolSize
;
13 extern ULONG MmTotalPagedPoolQuota
;
14 extern ULONG MmTotalNonPagedPoolQuota
;
15 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress
;
16 extern ULONG MmNumberOfPhysicalPages
;
17 extern UCHAR MmDisablePagingExecutive
;
18 extern ULONG MmLowestPhysicalPage
;
19 extern ULONG MmHighestPhysicalPage
;
20 extern ULONG MmAvailablePages
;
21 extern ULONG MmResidentAvailablePages
;
23 extern PVOID MmPagedPoolBase
;
24 extern ULONG MmPagedPoolSize
;
26 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
27 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
29 extern LIST_ENTRY MmLoadedUserImageList
;
31 extern ULONG MmNumberOfPagingFiles
;
33 extern PVOID MmUnloadedDrivers
;
34 extern PVOID MmLastUnloadedDrivers
;
35 extern PVOID MmTriageActionTaken
;
36 extern PVOID KernelVerifier
;
37 extern MM_DRIVER_VERIFIER_DATA MmVerifierData
;
39 extern SIZE_T MmTotalCommitLimit
;
40 extern SIZE_T MmTotalCommittedPages
;
41 extern SIZE_T MmSharedCommit
;
42 extern SIZE_T MmDriverCommit
;
43 extern SIZE_T MmProcessCommit
;
44 extern SIZE_T MmPagedPoolCommit
;
45 extern SIZE_T MmPeakCommitment
;
46 extern SIZE_T MmtotalCommitLimitMaximum
;
48 extern PVOID MiDebugMapping
;
49 extern PMMPTE MmDebugPte
;
53 struct _MM_RMAP_ENTRY
;
55 typedef ULONG SWAPENTRY
;
56 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
59 // MmDbgCopyMemory Flags
61 #define MMDBG_COPY_WRITE 0x00000001
62 #define MMDBG_COPY_PHYSICAL 0x00000002
63 #define MMDBG_COPY_UNSAFE 0x00000004
64 #define MMDBG_COPY_CACHED 0x00000008
65 #define MMDBG_COPY_UNCACHED 0x00000010
66 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
69 // Maximum chunk size per copy
71 #define MMDBG_COPY_MAX_SIZE 0x8
74 #define MI_STATIC_MEMORY_AREAS (14)
76 #define MI_STATIC_MEMORY_AREAS (13)
79 #define MEMORY_AREA_INVALID (0)
80 #define MEMORY_AREA_SECTION_VIEW (1)
81 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
82 #define MEMORY_AREA_NO_CACHE (3)
83 #define MEMORY_AREA_IO_MAPPING (4)
84 #define MEMORY_AREA_SYSTEM (5)
85 #define MEMORY_AREA_MDL_MAPPING (7)
86 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
87 #define MEMORY_AREA_CACHE_SEGMENT (9)
88 #define MEMORY_AREA_SHARED_DATA (10)
89 #define MEMORY_AREA_KERNEL_STACK (11)
90 #define MEMORY_AREA_PAGED_POOL (12)
91 #define MEMORY_AREA_NO_ACCESS (13)
92 #define MEMORY_AREA_PEB_OR_TEB (14)
93 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
94 #define MEMORY_AREA_STATIC (0x80000000)
96 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
98 #define MM_CORE_DUMP_TYPE_NONE (0x0)
99 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
100 #define MM_CORE_DUMP_TYPE_FULL (0x2)
102 #define MM_PAGEOP_PAGEIN (1)
103 #define MM_PAGEOP_PAGEOUT (2)
104 #define MM_PAGEOP_PAGESYNCH (3)
105 #define MM_PAGEOP_ACCESSFAULT (4)
107 /* Number of list heads to use */
108 #define MI_FREE_POOL_LISTS 4
110 #define MI_HYPERSPACE_PTES (256 - 1)
111 #define MI_ZERO_PTES (32)
112 #define MI_MAPPING_RANGE_START (ULONG_PTR)HYPER_SPACE
113 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
114 MI_HYPERSPACE_PTES * PAGE_SIZE)
115 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
118 /* Signature of free pool blocks */
119 #define MM_FREE_POOL_TAG 'lprF'
121 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
122 ((x) / (4*1024*1024))
124 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
125 ((((x)) % (4*1024*1024)) / (4*1024))
127 #define NR_SECTION_PAGE_TABLES 1024
128 #define NR_SECTION_PAGE_ENTRIES 1024
130 #define TEB_BASE 0x7FFDE000
132 /* Although Microsoft says this isn't hardcoded anymore,
133 they won't be able to change it. Stuff depends on it */
134 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
136 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
139 * Additional flags for protection attributes
141 #define PAGE_WRITETHROUGH (1024)
142 #define PAGE_SYSTEM (2048)
144 #define SEC_PHYSICALMEMORY (0x80000000)
146 #define MM_PAGEFILE_SEGMENT (0x1)
147 #define MM_DATAFILE_SEGMENT (0x2)
152 #define MC_NPPOOL (3)
153 #define MC_SYSTEM (4)
154 #define MC_MAXIMUM (5)
156 #define PAGED_POOL_MASK 1
157 #define MUST_SUCCEED_POOL_MASK 2
158 #define CACHE_ALIGNED_POOL_MASK 4
159 #define QUOTA_POOL_MASK 8
160 #define SESSION_POOL_MASK 32
161 #define VERIFIER_POOL_MASK 64
163 #define MM_PAGED_POOL_SIZE (100*1024*1024)
164 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
167 * Paged and non-paged pools are 8-byte aligned
169 #define MM_POOL_ALIGNMENT 8
172 * Maximum size of the kmalloc area (this is totally arbitary)
174 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
175 #define MM_KERNEL_MAP_BASE (0xf0c00000)
178 * FIXME - different architectures have different cache line sizes...
180 #define MM_CACHE_LINE_SIZE 32
182 #define MM_ROUND_UP(x,s) \
183 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
185 #define MM_ROUND_DOWN(x,s) \
186 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
188 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
193 PAGE_EXECUTE_READ | \
194 PAGE_EXECUTE_READWRITE | \
195 PAGE_EXECUTE_WRITECOPY | \
200 #define PAGE_FLAGS_VALID_FOR_SECTION \
205 PAGE_EXECUTE_READ | \
206 PAGE_EXECUTE_READWRITE | \
207 PAGE_EXECUTE_WRITECOPY | \
210 #define PAGE_IS_READABLE \
214 PAGE_EXECUTE_READ | \
215 PAGE_EXECUTE_READWRITE | \
216 PAGE_EXECUTE_WRITECOPY)
218 #define PAGE_IS_WRITABLE \
221 PAGE_EXECUTE_READWRITE | \
222 PAGE_EXECUTE_WRITECOPY)
224 #define PAGE_IS_EXECUTABLE \
226 PAGE_EXECUTE_READ | \
227 PAGE_EXECUTE_READWRITE | \
228 PAGE_EXECUTE_WRITECOPY)
230 #define PAGE_IS_WRITECOPY \
232 PAGE_EXECUTE_WRITECOPY)
235 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
236 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
238 #define InterlockedExchangePte(PointerPte, Value) \
239 InterlockedExchange((PLONG)(PointerPte), Value)
243 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
244 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
248 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
249 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
251 typedef struct _MM_SECTION_SEGMENT
253 LONG FileOffset
; /* start offset into the file for image sections */
254 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
255 ULONG RawLength
; /* length of the segment which is part of the mapped file */
256 ULONG Length
; /* absolute length of the segment */
258 FAST_MUTEX Lock
; /* lock which protects the page directory */
259 ULONG ReferenceCount
;
260 SECTION_PAGE_DIRECTORY PageDirectory
;
262 ULONG Characteristics
;
264 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
266 typedef struct _MM_IMAGE_SECTION_OBJECT
269 ULONG_PTR StackReserve
;
270 ULONG_PTR StackCommit
;
271 ULONG_PTR EntryPoint
;
273 USHORT ImageCharacteristics
;
274 USHORT MinorSubsystemVersion
;
275 USHORT MajorSubsystemVersion
;
280 PMM_SECTION_SEGMENT Segments
;
281 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
283 typedef struct _ROS_SECTION_OBJECT
287 LARGE_INTEGER MaximumSize
;
288 ULONG SectionPageProtection
;
289 ULONG AllocationAttributes
;
290 PFILE_OBJECT FileObject
;
293 PMM_IMAGE_SECTION_OBJECT ImageSection
;
294 PMM_SECTION_SEGMENT Segment
;
296 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
298 typedef struct _MEMORY_AREA
300 PVOID StartingAddress
;
302 struct _MEMORY_AREA
*Parent
;
303 struct _MEMORY_AREA
*LeftChild
;
304 struct _MEMORY_AREA
*RightChild
;
308 BOOLEAN DeleteInProgress
;
314 ROS_SECTION_OBJECT
* Section
;
316 PMM_SECTION_SEGMENT Segment
;
317 BOOLEAN WriteCopyView
;
318 LIST_ENTRY RegionListHead
;
322 LIST_ENTRY RegionListHead
;
325 } MEMORY_AREA
, *PMEMORY_AREA
;
328 // These two mappings are actually used by Windows itself, based on the ASSERTS
330 #define StartOfAllocation ReadInProgress
331 #define EndOfAllocation WriteInProgress
333 typedef struct _MMPFNENTRY
336 USHORT ReadInProgress
:1; // StartOfAllocation
337 USHORT WriteInProgress
:1; // EndOfAllocation
338 USHORT PrototypePte
:1; // Zero
339 USHORT PageColor
:4; // LockCount
340 USHORT PageLocation
:3; // Consumer
341 USHORT RemovalRequested
:1;
342 USHORT CacheAttribute
:2; // Type
344 USHORT ParityError
:1;
347 typedef struct _MMPFN
351 PFN_NUMBER Flink
; // ListEntry.Flink
355 SINGLE_LIST_ENTRY NextStackPfn
;
357 PMMPTE PteAddress
; // ListEntry.Blink
361 ULONG_PTR ShareCount
; // MapCount
367 USHORT ReferenceCount
; // ReferenceCount
372 USHORT ReferenceCount
;
379 LONG AweReferenceCount
; // RmapListHead
383 ULONG_PTR EntireFrame
; // SavedSwapEntry
386 ULONG_PTR PteFrame
:25;
387 ULONG_PTR InPageError
:1;
388 ULONG_PTR VerifierAllocation
:1;
389 ULONG_PTR AweAllocation
:1;
390 ULONG_PTR Priority
:3;
391 ULONG_PTR MustBeCached
:1;
396 extern PMMPFN MmPfnDatabase
;
398 typedef struct _MMPFNLIST
404 } MMPFNLIST
, *PMMPFNLIST
;
406 extern MMPFNLIST MmZeroedPageListHead
;
407 extern MMPFNLIST MmFreePageListHead
;
408 extern MMPFNLIST MmStandbyPageListHead
;
409 extern MMPFNLIST MmModifiedPageListHead
;
410 extern MMPFNLIST MmModifiedNoWritePageListHead
;
412 typedef struct _MM_PAGEOP
414 /* Type of operation. */
416 /* Number of threads interested in this operation. */
417 ULONG ReferenceCount
;
418 /* Event that will be set when the operation is completed. */
419 KEVENT CompletionEvent
;
420 /* Status of the operation once it is completed. */
422 /* TRUE if the operation was abandoned. */
424 /* The memory area to be affected by the operation. */
427 struct _MM_PAGEOP
* Next
;
428 struct _ETHREAD
* Thread
;
430 * These fields are used to identify the operation if it is against a
431 * virtual memory area.
436 * These fields are used to identify the operation if it is against a
439 PMM_SECTION_SEGMENT Segment
;
441 } MM_PAGEOP
, *PMM_PAGEOP
;
443 typedef struct _MM_MEMORY_CONSUMER
447 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
448 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
450 typedef struct _MM_REGION
455 LIST_ENTRY RegionListEntry
;
456 } MM_REGION
, *PMM_REGION
;
458 /* Entry describing free pool memory */
459 typedef struct _MMFREE_POOL_ENTRY
464 struct _MMFREE_POOL_ENTRY
*Owner
;
465 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
467 /* Paged pool information */
468 typedef struct _MM_PAGED_POOL_INFO
470 PRTL_BITMAP PagedPoolAllocationMap
;
471 PRTL_BITMAP EndOfPagedPoolBitmap
;
472 PMMPTE FirstPteForPagedPool
;
473 PMMPTE LastPteForPagedPool
;
474 PMMPTE NextPdeForPagedPoolExpansion
;
476 SIZE_T PagedPoolCommit
;
477 SIZE_T AllocatedPagedPool
;
478 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
480 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
483 (*PMM_ALTER_REGION_FUNC
)(
484 PMMSUPPORT AddressSpace
,
494 (*PMM_FREE_PAGE_FUNC
)(
496 PMEMORY_AREA MemoryArea
,
504 // Mm copy support for Kd
516 // Determines if a given address is a session address
524 /* marea.c *******************************************************************/
529 PMMSUPPORT AddressSpace
,
534 PMEMORY_AREA
*Result
,
535 BOOLEAN FixedAddress
,
536 ULONG AllocationFlags
,
537 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
542 MmLocateMemoryAreaByAddress(
543 PMMSUPPORT AddressSpace
,
550 PMMSUPPORT AddressSpace
,
557 PMMSUPPORT AddressSpace
,
558 PMEMORY_AREA MemoryArea
,
559 PMM_FREE_PAGE_FUNC FreePage
,
560 PVOID FreePageContext
565 MmFreeMemoryAreaByPtr(
566 PMMSUPPORT AddressSpace
,
568 PMM_FREE_PAGE_FUNC FreePage
,
569 PVOID FreePageContext
574 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
578 MmLocateMemoryAreaByRegion(
579 PMMSUPPORT AddressSpace
,
587 PMMSUPPORT AddressSpace
,
589 ULONG_PTR Granularity
,
595 MmReleaseMemoryAreaIfDecommitted(
596 struct _EPROCESS
*Process
,
597 PMMSUPPORT AddressSpace
,
603 MmMapMemoryArea(PVOID BaseAddress
,
608 /* npool.c *******************************************************************/
612 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
616 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
620 MiInitializeNonPagedPool(VOID
);
625 IN POOL_TYPE PoolType
,
626 IN SIZE_T SizeInBytes
632 IN PVOID VirtualAddress
638 IN PVOID StartingAddress
648 /* pool.c *******************************************************************/
652 ExAllocateNonPagedPoolWithTag(
661 ExAllocatePagedPoolWithTag(
669 ExFreeNonPagedPool(PVOID block
);
673 ExFreePagedPool(IN PVOID Block
);
677 ExpIsPoolTagDebuggable(ULONG Tag
);
681 ExpAllocateDebugPool(
691 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
695 MmInitializePagedPool(VOID
);
699 MiAllocateSpecialPool(
700 IN POOL_TYPE PoolType
,
701 IN SIZE_T NumberOfBytes
,
709 IN POOL_TYPE PoolType
,
710 IN ULONG CurrentMaxQuota
,
711 OUT PULONG NewMaxQuota
714 /* mdl.c *********************************************************************/
723 /* mminit.c ******************************************************************/
727 MiShutdownMemoryManager(VOID
);
737 MmInitSystem(IN ULONG Phase
,
738 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
742 MiFreeInitMemory(VOID
);
746 MmInitializeMdlImplementation(VOID
);
748 /* pagefile.c ****************************************************************/
752 MmAllocSwapPage(VOID
);
756 MmDereserveSwapPages(ULONG Nr
);
760 MmFreeSwapPage(SWAPENTRY Entry
);
764 MmInitPagingFile(VOID
);
775 MmReserveSwapPages(ULONG Nr
);
788 ULONG BugCodeParameter1
,
789 ULONG BugCodeParameter2
,
790 ULONG BugCodeParameter3
,
791 ULONG BugCodeParameter4
,
792 struct _KTRAP_FRAME
* TrapFrame
797 MmIsAvailableSwapPage(VOID
);
801 MmShowOutOfSpaceMessagePagingFile(VOID
);
803 /* process.c ****************************************************************/
807 MmInitializeProcessAddressSpace(
808 IN PEPROCESS Process
,
809 IN PEPROCESS Clone OPTIONAL
,
810 IN PVOID Section OPTIONAL
,
812 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
818 IN PEPROCESS Process
,
819 IN PINITIAL_PEB InitialPeb
,
826 IN PEPROCESS Process
,
827 IN PCLIENT_ID ClientId
,
828 IN PINITIAL_TEB InitialTeb
,
835 struct _EPROCESS
*Process
,
841 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
845 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
849 MmGetSessionLocaleId(VOID
);
853 MmSetMemoryPriorityProcess(
854 IN PEPROCESS Process
,
855 IN UCHAR MemoryPriority
858 /* i386/pfault.c *************************************************************/
870 /* mm.c **********************************************************************/
875 IN BOOLEAN StoreInstruction
,
877 IN KPROCESSOR_MODE Mode
,
878 IN PVOID TrapInformation
881 /* anonmem.c *****************************************************************/
885 MmNotPresentFaultVirtualMemory(
886 PMMSUPPORT AddressSpace
,
887 MEMORY_AREA
* MemoryArea
,
894 MmPageOutVirtualMemory(
895 PMMSUPPORT AddressSpace
,
896 PMEMORY_AREA MemoryArea
,
898 struct _MM_PAGEOP
* PageOp
904 PMEMORY_AREA MemoryArea
,
906 PMEMORY_BASIC_INFORMATION Info
,
913 struct _EPROCESS
* Process
,
914 PMEMORY_AREA MemoryArea
920 PMMSUPPORT AddressSpace
,
921 PMEMORY_AREA MemoryArea
,
930 MmWritePageVirtualMemory(
931 PMMSUPPORT AddressSpace
,
937 /* kmap.c ********************************************************************/
941 ExAllocatePage(VOID
);
945 ExUnmapPage(PVOID Addr
);
949 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
960 MiZeroPage(PFN_TYPE Page
);
962 /* memsafe.s *****************************************************************/
966 MmSafeReadPtr(PVOID Source
);
968 /* pageop.c ******************************************************************/
972 MmReleasePageOp(PMM_PAGEOP PageOp
);
980 PMM_SECTION_SEGMENT Segment
,
992 PMM_SECTION_SEGMENT Segment
,
998 MmInitializePageOp(VOID
);
1000 /* process.c *****************************************************************/
1004 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1008 MmDeleteKernelStack(PVOID Stack
,
1011 /* balace.c ******************************************************************/
1015 MmInitializeMemoryConsumer(
1017 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1022 MmInitializeBalancer(
1023 ULONG NrAvailablePages
,
1029 MmReleasePageMemoryConsumer(
1036 MmRequestPageMemoryConsumer(
1039 PPFN_TYPE AllocatedPage
1044 MiInitBalancerThread(VOID
);
1048 MmRebalanceMemoryConsumers(VOID
);
1050 /* rmap.c **************************************************************/
1054 MmSetRmapListHeadPage(
1056 struct _MM_RMAP_ENTRY
* ListHead
1059 struct _MM_RMAP_ENTRY
*
1061 MmGetRmapListHeadPage(PFN_TYPE Page
);
1067 struct _EPROCESS
*Process
,
1076 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1083 struct _EPROCESS
*Process
,
1089 MmInitializeRmapList(VOID
);
1093 MmSetCleanAllRmaps(PFN_TYPE Page
);
1097 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1101 MmIsDirtyPageRmap(PFN_TYPE Page
);
1105 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1109 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1111 /* freelist.c **********************************************************/
1113 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1117 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1120 extern RTL_BITMAP MiPfnBitMap
;
1122 /* Make sure the PFN number is valid */
1123 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1125 /* Make sure this page actually has a PFN entry */
1126 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1129 Page
= &MmPfnDatabase
[Pfn
];
1131 /* Make sure it's valid */
1140 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1143 // This will return the Page Frame Number (PFN) from the MMPFN
1145 return Pfn1
- MmPfnDatabase
;
1150 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1154 MmGetLRUFirstUserPage(VOID
);
1158 MmInsertLRULastUserPage(PFN_TYPE Page
);
1162 MmRemoveLRUUserPage(PFN_TYPE Page
);
1166 MmLockPage(PFN_TYPE Page
);
1170 MmUnlockPage(PFN_TYPE Page
);
1174 MmGetLockCountPage(PFN_TYPE Page
);
1178 MmInitializePageList(
1190 MmGetContinuousPages(
1191 ULONG NumberOfBytes
,
1192 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1193 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1194 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1200 MmZeroPageThreadMain(
1204 /* hypermap.c *****************************************************************/
1206 extern PEPROCESS HyperProcess
;
1207 extern KIRQL HyperIrql
;
1211 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1217 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1223 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1224 IN PFN_NUMBER NumberOfPages
);
1228 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1229 IN PFN_NUMBER NumberOfPages
);
1232 // ReactOS Compatibility Layer
1236 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1238 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1239 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1244 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1246 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1247 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1250 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1252 /* i386/page.c *********************************************************/
1256 MmCreateVirtualMappingForKernel(
1265 MmCommitPagedPoolAddress(
1272 MmCreateVirtualMapping(
1273 struct _EPROCESS
* Process
,
1282 MmCreateVirtualMappingUnsafe(
1283 struct _EPROCESS
* Process
,
1293 struct _EPROCESS
* Process
,
1299 struct _EPROCESS
* Process
,
1307 struct _EPROCESS
* Process
,
1313 MmInitGlobalKernelPageDirectory(VOID
);
1317 MmDisableVirtualMapping(
1318 struct _EPROCESS
*Process
,
1326 MmEnableVirtualMapping(
1327 struct _EPROCESS
*Process
,
1333 MmRawDeleteVirtualMapping(PVOID Address
);
1337 MmDeletePageFileMapping(
1338 struct _EPROCESS
*Process
,
1340 SWAPENTRY
* SwapEntry
1345 MmCreatePageFileMapping(
1346 struct _EPROCESS
*Process
,
1354 struct _EPROCESS
*Process
,
1360 MmTransferOwnershipPage(
1368 struct _EPROCESS
*Process
,
1376 SWAPENTRY SavedSwapEntry
1381 MmAllocPagesSpecifyRange(
1383 PHYSICAL_ADDRESS LowestAddress
,
1384 PHYSICAL_ADDRESS HighestAddress
,
1385 ULONG NumberOfPages
,
1391 MmDereferencePage(PFN_TYPE Page
);
1395 MmReferencePage(PFN_TYPE Page
);
1399 MmGetReferenceCountPage(PFN_TYPE Page
);
1403 MmIsPageInUse(PFN_TYPE Page
);
1407 MmSetSavedSwapEntryPage(
1409 SWAPENTRY SavedSwapEntry
);
1413 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1418 struct _EPROCESS
*Process
,
1424 MmCreatePageTable(PVOID PAddress
);
1429 struct _EPROCESS
*Process
,
1436 struct _EPROCESS
*Process
,
1442 MmCreateProcessAddressSpace(
1445 IN PULONG_PTR DirectoryTableBase
1450 MmInitializeHandBuiltProcess(
1451 IN PEPROCESS Process
,
1452 IN PULONG_PTR DirectoryTableBase
1458 MmInitializeHandBuiltProcess2(
1459 IN PEPROCESS Process
1464 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1468 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1472 MmDeleteVirtualMapping(
1473 struct _EPROCESS
*Process
,
1483 struct _EPROCESS
*Process
,
1489 MmMarkPageMapped(PFN_TYPE Page
);
1493 MmMarkPageUnmapped(PFN_TYPE Page
);
1498 struct _EPROCESS
*Process
,
1505 MiInitPageDirectoryMap(VOID
);
1509 MiGetUserPageDirectoryCount(VOID
);
1511 /* wset.c ********************************************************************/
1520 /* region.c ************************************************************/
1525 PMMSUPPORT AddressSpace
,
1527 PLIST_ENTRY RegionListHead
,
1532 PMM_ALTER_REGION_FUNC AlterFunc
1538 PLIST_ENTRY RegionListHead
,
1548 PLIST_ENTRY RegionListHead
,
1550 PVOID
* RegionBaseAddress
1553 /* section.c *****************************************************************/
1557 MmGetFileObjectForSection(
1558 IN PROS_SECTION_OBJECT Section
1562 MmGetFileNameForAddress(
1564 OUT PUNICODE_STRING ModuleName
1569 MmGetFileNameForSection(
1570 IN PROS_SECTION_OBJECT Section
,
1571 OUT POBJECT_NAME_INFORMATION
*ModuleName
1584 PMEMORY_AREA MemoryArea
,
1586 PMEMORY_BASIC_INFORMATION Info
,
1587 PSIZE_T ResultLength
1592 MmProtectSectionView(
1593 PMMSUPPORT AddressSpace
,
1594 PMEMORY_AREA MemoryArea
,
1603 MmWritePageSectionView(
1604 PMMSUPPORT AddressSpace
,
1612 MmInitSectionImplementation(VOID
);
1616 MmNotPresentFaultSectionView(
1617 PMMSUPPORT AddressSpace
,
1618 MEMORY_AREA
* MemoryArea
,
1625 MmPageOutSectionView(
1626 PMMSUPPORT AddressSpace
,
1627 PMEMORY_AREA MemoryArea
,
1629 struct _MM_PAGEOP
*PageOp
1634 MmCreatePhysicalMemorySection(VOID
);
1638 MmAccessFaultSectionView(
1639 PMMSUPPORT AddressSpace
,
1640 MEMORY_AREA
* MemoryArea
,
1647 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1649 /* mpw.c *********************************************************************/
1653 MmInitMpwThread(VOID
);
1657 MmInitBsmThread(VOID
);
1659 /* pager.c *******************************************************************/
1663 MiIsPagerThread(VOID
);
1667 MiStartPagerThread(VOID
);
1671 MiStopPagerThread(VOID
);
1675 MiQueryVirtualMemory(
1676 IN HANDLE ProcessHandle
,
1678 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1679 OUT PVOID VirtualMemoryInformation
,
1681 OUT PSIZE_T ResultLength
1684 /* sysldr.c ******************************************************************/
1688 MiReloadBootLoadedDrivers(
1689 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1694 MiInitializeLoadedModuleList(
1695 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1701 IN PUNICODE_STRING FileName
,
1702 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1703 IN PUNICODE_STRING LoadedName OPTIONAL
,
1705 OUT PVOID
*ModuleObject
,
1706 OUT PVOID
*ImageBaseAddress
1711 MmUnloadSystemImage(
1712 IN PVOID ImageHandle
1718 IN HANDLE ImageHandle
,
1719 IN BOOLEAN PurgeSection
1724 MmCallDllInitialize(
1725 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1726 IN PLIST_ENTRY ListHead
1729 /* ReactOS Mm Hacks */
1732 MiSyncForProcessAttach(
1733 IN PKTHREAD NextThread
,
1734 IN PEPROCESS Process
1739 MiSyncForContextSwitch(
1743 extern PMMSUPPORT MmKernelAddressSpace
;
1747 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1749 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1754 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1756 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1761 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1763 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1764 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1769 MmGetCurrentAddressSpace(VOID
)
1771 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1776 MmGetKernelAddressSpace(VOID
)
1778 return MmKernelAddressSpace
;