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 BOOLEAN MiDbgReadyForPhysical
;
52 struct _MM_RMAP_ENTRY
;
54 typedef ULONG SWAPENTRY
;
55 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
58 // MmDbgCopyMemory Flags
60 #define MMDBG_COPY_WRITE 0x00000001
61 #define MMDBG_COPY_PHYSICAL 0x00000002
62 #define MMDBG_COPY_UNSAFE 0x00000004
63 #define MMDBG_COPY_CACHED 0x00000008
64 #define MMDBG_COPY_UNCACHED 0x00000010
65 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
68 // Maximum chunk size per copy
70 #define MMDBG_COPY_MAX_SIZE 0x8
73 #define MI_STATIC_MEMORY_AREAS (14)
75 #define MI_STATIC_MEMORY_AREAS (13)
78 #define MEMORY_AREA_INVALID (0)
79 #define MEMORY_AREA_SECTION_VIEW (1)
80 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
81 #define MEMORY_AREA_NO_CACHE (3)
82 #define MEMORY_AREA_IO_MAPPING (4)
83 #define MEMORY_AREA_SYSTEM (5)
84 #define MEMORY_AREA_MDL_MAPPING (7)
85 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
86 #define MEMORY_AREA_CACHE_SEGMENT (9)
87 #define MEMORY_AREA_SHARED_DATA (10)
88 #define MEMORY_AREA_KERNEL_STACK (11)
89 #define MEMORY_AREA_PAGED_POOL (12)
90 #define MEMORY_AREA_NO_ACCESS (13)
91 #define MEMORY_AREA_PEB_OR_TEB (14)
92 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
93 #define MEMORY_AREA_STATIC (0x80000000)
95 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
97 #define MM_CORE_DUMP_TYPE_NONE (0x0)
98 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
99 #define MM_CORE_DUMP_TYPE_FULL (0x2)
101 #define MM_PAGEOP_PAGEIN (1)
102 #define MM_PAGEOP_PAGEOUT (2)
103 #define MM_PAGEOP_PAGESYNCH (3)
104 #define MM_PAGEOP_ACCESSFAULT (4)
106 /* Number of list heads to use */
107 #define MI_FREE_POOL_LISTS 4
109 #define MI_HYPERSPACE_PTES (256 - 1)
110 #define MI_ZERO_PTES (32)
111 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
112 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
113 MI_HYPERSPACE_PTES * PAGE_SIZE)
114 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
117 /* Signature of free pool blocks */
118 #define MM_FREE_POOL_TAG 'lprF'
120 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
121 ((x) / (4*1024*1024))
123 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
124 ((((x)) % (4*1024*1024)) / (4*1024))
126 #define NR_SECTION_PAGE_TABLES 1024
127 #define NR_SECTION_PAGE_ENTRIES 1024
129 #define TEB_BASE 0x7FFDE000
131 /* Although Microsoft says this isn't hardcoded anymore,
132 they won't be able to change it. Stuff depends on it */
133 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
135 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
138 * Additional flags for protection attributes
140 #define PAGE_WRITETHROUGH (1024)
141 #define PAGE_SYSTEM (2048)
143 #define SEC_PHYSICALMEMORY (0x80000000)
145 #define MM_PAGEFILE_SEGMENT (0x1)
146 #define MM_DATAFILE_SEGMENT (0x2)
151 #define MC_NPPOOL (3)
152 #define MC_SYSTEM (4)
153 #define MC_MAXIMUM (5)
155 #define PAGED_POOL_MASK 1
156 #define MUST_SUCCEED_POOL_MASK 2
157 #define CACHE_ALIGNED_POOL_MASK 4
158 #define QUOTA_POOL_MASK 8
159 #define SESSION_POOL_MASK 32
160 #define VERIFIER_POOL_MASK 64
162 #define MM_PAGED_POOL_SIZE (100*1024*1024)
163 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
166 * Paged and non-paged pools are 8-byte aligned
168 #define MM_POOL_ALIGNMENT 8
171 * Maximum size of the kmalloc area (this is totally arbitary)
173 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
174 #define MM_KERNEL_MAP_BASE (0xf0c00000)
177 * FIXME - different architectures have different cache line sizes...
179 #define MM_CACHE_LINE_SIZE 32
181 #define MM_ROUND_UP(x,s) \
182 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
184 #define MM_ROUND_DOWN(x,s) \
185 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
187 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
192 PAGE_EXECUTE_READ | \
193 PAGE_EXECUTE_READWRITE | \
194 PAGE_EXECUTE_WRITECOPY | \
199 #define PAGE_FLAGS_VALID_FOR_SECTION \
204 PAGE_EXECUTE_READ | \
205 PAGE_EXECUTE_READWRITE | \
206 PAGE_EXECUTE_WRITECOPY | \
209 #define PAGE_IS_READABLE \
213 PAGE_EXECUTE_READ | \
214 PAGE_EXECUTE_READWRITE | \
215 PAGE_EXECUTE_WRITECOPY)
217 #define PAGE_IS_WRITABLE \
220 PAGE_EXECUTE_READWRITE | \
221 PAGE_EXECUTE_WRITECOPY)
223 #define PAGE_IS_EXECUTABLE \
225 PAGE_EXECUTE_READ | \
226 PAGE_EXECUTE_READWRITE | \
227 PAGE_EXECUTE_WRITECOPY)
229 #define PAGE_IS_WRITECOPY \
231 PAGE_EXECUTE_WRITECOPY)
234 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
235 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
237 #define InterlockedExchangePte(PointerPte, Value) \
238 InterlockedExchange((PLONG)(PointerPte), Value)
242 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
243 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
247 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
248 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
250 typedef struct _MM_SECTION_SEGMENT
252 LONG FileOffset
; /* start offset into the file for image sections */
253 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
254 ULONG RawLength
; /* length of the segment which is part of the mapped file */
255 ULONG Length
; /* absolute length of the segment */
257 FAST_MUTEX Lock
; /* lock which protects the page directory */
258 ULONG ReferenceCount
;
259 SECTION_PAGE_DIRECTORY PageDirectory
;
261 ULONG Characteristics
;
263 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
265 typedef struct _MM_IMAGE_SECTION_OBJECT
268 ULONG_PTR StackReserve
;
269 ULONG_PTR StackCommit
;
270 ULONG_PTR EntryPoint
;
272 USHORT ImageCharacteristics
;
273 USHORT MinorSubsystemVersion
;
274 USHORT MajorSubsystemVersion
;
279 PMM_SECTION_SEGMENT Segments
;
280 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
282 typedef struct _ROS_SECTION_OBJECT
286 LARGE_INTEGER MaximumSize
;
287 ULONG SectionPageProtection
;
288 ULONG AllocationAttributes
;
289 PFILE_OBJECT FileObject
;
292 PMM_IMAGE_SECTION_OBJECT ImageSection
;
293 PMM_SECTION_SEGMENT Segment
;
295 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
297 typedef struct _MEMORY_AREA
299 PVOID StartingAddress
;
301 struct _MEMORY_AREA
*Parent
;
302 struct _MEMORY_AREA
*LeftChild
;
303 struct _MEMORY_AREA
*RightChild
;
307 BOOLEAN DeleteInProgress
;
313 ROS_SECTION_OBJECT
* Section
;
315 PMM_SECTION_SEGMENT Segment
;
316 BOOLEAN WriteCopyView
;
317 LIST_ENTRY RegionListHead
;
321 LIST_ENTRY RegionListHead
;
324 } MEMORY_AREA
, *PMEMORY_AREA
;
327 // These two mappings are actually used by Windows itself, based on the ASSERTS
329 #define StartOfAllocation ReadInProgress
330 #define EndOfAllocation WriteInProgress
332 typedef struct _MMPFNENTRY
335 USHORT ReadInProgress
:1; // StartOfAllocation
336 USHORT WriteInProgress
:1; // EndOfAllocation
337 USHORT PrototypePte
:1; // Zero
338 USHORT PageColor
:4; // LockCount
339 USHORT PageLocation
:3; // Consumer
340 USHORT RemovalRequested
:1;
341 USHORT CacheAttribute
:2; // Type
343 USHORT ParityError
:1;
346 typedef struct _MMPFN
350 PFN_NUMBER Flink
; // ListEntry.Flink
354 SINGLE_LIST_ENTRY NextStackPfn
;
356 PMMPTE PteAddress
; // ListEntry.Blink
360 ULONG_PTR ShareCount
; // MapCount
366 USHORT ReferenceCount
; // ReferenceCount
371 USHORT ReferenceCount
;
378 LONG AweReferenceCount
; // RmapListHead
382 ULONG_PTR EntireFrame
; // SavedSwapEntry
385 ULONG_PTR PteFrame
:25;
386 ULONG_PTR InPageError
:1;
387 ULONG_PTR VerifierAllocation
:1;
388 ULONG_PTR AweAllocation
:1;
389 ULONG_PTR Priority
:3;
390 ULONG_PTR MustBeCached
:1;
395 extern PMMPFN MmPfnDatabase
;
397 typedef struct _MMPFNLIST
403 } MMPFNLIST
, *PMMPFNLIST
;
405 extern MMPFNLIST MmZeroedPageListHead
;
406 extern MMPFNLIST MmFreePageListHead
;
407 extern MMPFNLIST MmStandbyPageListHead
;
408 extern MMPFNLIST MmModifiedPageListHead
;
409 extern MMPFNLIST MmModifiedNoWritePageListHead
;
411 typedef struct _MM_PAGEOP
413 /* Type of operation. */
415 /* Number of threads interested in this operation. */
416 ULONG ReferenceCount
;
417 /* Event that will be set when the operation is completed. */
418 KEVENT CompletionEvent
;
419 /* Status of the operation once it is completed. */
421 /* TRUE if the operation was abandoned. */
423 /* The memory area to be affected by the operation. */
426 struct _MM_PAGEOP
* Next
;
427 struct _ETHREAD
* Thread
;
429 * These fields are used to identify the operation if it is against a
430 * virtual memory area.
435 * These fields are used to identify the operation if it is against a
438 PMM_SECTION_SEGMENT Segment
;
440 } MM_PAGEOP
, *PMM_PAGEOP
;
442 typedef struct _MM_MEMORY_CONSUMER
446 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
447 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
449 typedef struct _MM_REGION
454 LIST_ENTRY RegionListEntry
;
455 } MM_REGION
, *PMM_REGION
;
457 /* Entry describing free pool memory */
458 typedef struct _MMFREE_POOL_ENTRY
463 struct _MMFREE_POOL_ENTRY
*Owner
;
464 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
466 /* Paged pool information */
467 typedef struct _MM_PAGED_POOL_INFO
469 PRTL_BITMAP PagedPoolAllocationMap
;
470 PRTL_BITMAP EndOfPagedPoolBitmap
;
471 PMMPTE FirstPteForPagedPool
;
472 PMMPTE LastPteForPagedPool
;
473 PMMPTE NextPdeForPagedPoolExpansion
;
475 SIZE_T PagedPoolCommit
;
476 SIZE_T AllocatedPagedPool
;
477 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
479 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
482 (*PMM_ALTER_REGION_FUNC
)(
483 PMMSUPPORT AddressSpace
,
493 (*PMM_FREE_PAGE_FUNC
)(
495 PMEMORY_AREA MemoryArea
,
503 // Mm copy support for Kd
515 // Determines if a given address is a session address
523 /* marea.c *******************************************************************/
528 PMMSUPPORT AddressSpace
,
533 PMEMORY_AREA
*Result
,
534 BOOLEAN FixedAddress
,
535 ULONG AllocationFlags
,
536 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
541 MmLocateMemoryAreaByAddress(
542 PMMSUPPORT AddressSpace
,
549 PMMSUPPORT AddressSpace
,
556 PMMSUPPORT AddressSpace
,
557 PMEMORY_AREA MemoryArea
,
558 PMM_FREE_PAGE_FUNC FreePage
,
559 PVOID FreePageContext
564 MmFreeMemoryAreaByPtr(
565 PMMSUPPORT AddressSpace
,
567 PMM_FREE_PAGE_FUNC FreePage
,
568 PVOID FreePageContext
573 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
577 MmLocateMemoryAreaByRegion(
578 PMMSUPPORT AddressSpace
,
586 PMMSUPPORT AddressSpace
,
588 ULONG_PTR Granularity
,
594 MmReleaseMemoryAreaIfDecommitted(
595 struct _EPROCESS
*Process
,
596 PMMSUPPORT AddressSpace
,
602 MmMapMemoryArea(PVOID BaseAddress
,
607 /* npool.c *******************************************************************/
611 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
615 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
619 MiInitializeNonPagedPool(VOID
);
624 IN POOL_TYPE PoolType
,
625 IN SIZE_T SizeInBytes
631 IN PVOID VirtualAddress
637 IN PVOID StartingAddress
647 /* pool.c *******************************************************************/
651 ExAllocateNonPagedPoolWithTag(
660 ExAllocatePagedPoolWithTag(
668 ExFreeNonPagedPool(PVOID block
);
672 ExFreePagedPool(IN PVOID Block
);
676 ExpIsPoolTagDebuggable(ULONG Tag
);
680 ExpAllocateDebugPool(
690 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
694 MmInitializePagedPool(VOID
);
698 MiAllocateSpecialPool(
699 IN POOL_TYPE PoolType
,
700 IN SIZE_T NumberOfBytes
,
708 IN POOL_TYPE PoolType
,
709 IN ULONG CurrentMaxQuota
,
710 OUT PULONG NewMaxQuota
713 /* mdl.c *********************************************************************/
722 /* mminit.c ******************************************************************/
726 MiShutdownMemoryManager(VOID
);
736 MmInitSystem(IN ULONG Phase
,
737 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
741 MiFreeInitMemory(VOID
);
745 MmInitializeMdlImplementation(VOID
);
747 /* pagefile.c ****************************************************************/
751 MmAllocSwapPage(VOID
);
755 MmDereserveSwapPages(ULONG Nr
);
759 MmFreeSwapPage(SWAPENTRY Entry
);
763 MmInitPagingFile(VOID
);
774 MmReserveSwapPages(ULONG Nr
);
787 ULONG BugCodeParameter1
,
788 ULONG BugCodeParameter2
,
789 ULONG BugCodeParameter3
,
790 ULONG BugCodeParameter4
,
791 struct _KTRAP_FRAME
* TrapFrame
796 MmIsAvailableSwapPage(VOID
);
800 MmShowOutOfSpaceMessagePagingFile(VOID
);
802 /* process.c ****************************************************************/
806 MmInitializeProcessAddressSpace(
807 IN PEPROCESS Process
,
808 IN PEPROCESS Clone OPTIONAL
,
809 IN PVOID Section OPTIONAL
,
811 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
817 IN PEPROCESS Process
,
818 IN PINITIAL_PEB InitialPeb
,
825 IN PEPROCESS Process
,
826 IN PCLIENT_ID ClientId
,
827 IN PINITIAL_TEB InitialTeb
,
834 struct _EPROCESS
*Process
,
840 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
844 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
848 MmGetSessionLocaleId(VOID
);
852 MmSetMemoryPriorityProcess(
853 IN PEPROCESS Process
,
854 IN UCHAR MemoryPriority
857 /* i386/pfault.c *************************************************************/
869 /* mm.c **********************************************************************/
874 IN BOOLEAN StoreInstruction
,
876 IN KPROCESSOR_MODE Mode
,
877 IN PVOID TrapInformation
880 /* anonmem.c *****************************************************************/
884 MmNotPresentFaultVirtualMemory(
885 PMMSUPPORT AddressSpace
,
886 MEMORY_AREA
* MemoryArea
,
893 MmPageOutVirtualMemory(
894 PMMSUPPORT AddressSpace
,
895 PMEMORY_AREA MemoryArea
,
897 struct _MM_PAGEOP
* PageOp
903 PMEMORY_AREA MemoryArea
,
905 PMEMORY_BASIC_INFORMATION Info
,
912 struct _EPROCESS
* Process
,
913 PMEMORY_AREA MemoryArea
919 PMMSUPPORT AddressSpace
,
920 PMEMORY_AREA MemoryArea
,
929 MmWritePageVirtualMemory(
930 PMMSUPPORT AddressSpace
,
936 /* kmap.c ********************************************************************/
940 ExAllocatePage(VOID
);
944 ExUnmapPage(PVOID Addr
);
948 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
959 MiZeroPage(PFN_TYPE Page
);
961 /* memsafe.s *****************************************************************/
965 MmSafeReadPtr(PVOID Source
);
967 /* pageop.c ******************************************************************/
971 MmReleasePageOp(PMM_PAGEOP PageOp
);
979 PMM_SECTION_SEGMENT Segment
,
991 PMM_SECTION_SEGMENT Segment
,
997 MmInitializePageOp(VOID
);
999 /* process.c *****************************************************************/
1003 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1007 MmDeleteKernelStack(PVOID Stack
,
1010 /* balace.c ******************************************************************/
1014 MmInitializeMemoryConsumer(
1016 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1021 MmInitializeBalancer(
1022 ULONG NrAvailablePages
,
1028 MmReleasePageMemoryConsumer(
1035 MmRequestPageMemoryConsumer(
1038 PPFN_TYPE AllocatedPage
1043 MiInitBalancerThread(VOID
);
1047 MmRebalanceMemoryConsumers(VOID
);
1049 /* rmap.c **************************************************************/
1053 MmSetRmapListHeadPage(
1055 struct _MM_RMAP_ENTRY
* ListHead
1058 struct _MM_RMAP_ENTRY
*
1060 MmGetRmapListHeadPage(PFN_TYPE Page
);
1066 struct _EPROCESS
*Process
,
1075 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1082 struct _EPROCESS
*Process
,
1088 MmInitializeRmapList(VOID
);
1092 MmSetCleanAllRmaps(PFN_TYPE Page
);
1096 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1100 MmIsDirtyPageRmap(PFN_TYPE Page
);
1104 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1108 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1110 /* freelist.c **********************************************************/
1112 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1116 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1119 extern RTL_BITMAP MiPfnBitMap
;
1121 /* Make sure the PFN number is valid */
1122 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1124 /* Make sure this page actually has a PFN entry */
1125 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1128 Page
= &MmPfnDatabase
[Pfn
];
1130 /* Make sure it's valid */
1139 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1142 // This will return the Page Frame Number (PFN) from the MMPFN
1144 return Pfn1
- MmPfnDatabase
;
1149 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1153 MmGetLRUFirstUserPage(VOID
);
1157 MmInsertLRULastUserPage(PFN_TYPE Page
);
1161 MmRemoveLRUUserPage(PFN_TYPE Page
);
1165 MmLockPage(PFN_TYPE Page
);
1169 MmUnlockPage(PFN_TYPE Page
);
1173 MmGetLockCountPage(PFN_TYPE Page
);
1177 MmInitializePageList(
1189 MmGetContinuousPages(
1190 ULONG NumberOfBytes
,
1191 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1192 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1193 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1199 MmZeroPageThreadMain(
1203 /* hypermap.c *****************************************************************/
1205 extern PEPROCESS HyperProcess
;
1206 extern KIRQL HyperIrql
;
1210 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1216 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1222 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1223 IN PFN_NUMBER NumberOfPages
);
1227 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1228 IN PFN_NUMBER NumberOfPages
);
1231 // ReactOS Compatibility Layer
1235 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1237 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1238 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1243 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1245 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1246 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1249 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1251 /* i386/page.c *********************************************************/
1255 MmCreateVirtualMappingForKernel(
1264 MmCommitPagedPoolAddress(
1271 MmCreateVirtualMapping(
1272 struct _EPROCESS
* Process
,
1281 MmCreateVirtualMappingUnsafe(
1282 struct _EPROCESS
* Process
,
1292 struct _EPROCESS
* Process
,
1298 struct _EPROCESS
* Process
,
1306 struct _EPROCESS
* Process
,
1312 MmInitGlobalKernelPageDirectory(VOID
);
1316 MmDisableVirtualMapping(
1317 struct _EPROCESS
*Process
,
1325 MmEnableVirtualMapping(
1326 struct _EPROCESS
*Process
,
1332 MmRawDeleteVirtualMapping(PVOID Address
);
1336 MmDeletePageFileMapping(
1337 struct _EPROCESS
*Process
,
1339 SWAPENTRY
* SwapEntry
1344 MmCreatePageFileMapping(
1345 struct _EPROCESS
*Process
,
1353 struct _EPROCESS
*Process
,
1359 MmTransferOwnershipPage(
1367 struct _EPROCESS
*Process
,
1375 SWAPENTRY SavedSwapEntry
1380 MmAllocPagesSpecifyRange(
1382 PHYSICAL_ADDRESS LowestAddress
,
1383 PHYSICAL_ADDRESS HighestAddress
,
1384 ULONG NumberOfPages
,
1390 MmDereferencePage(PFN_TYPE Page
);
1394 MmReferencePage(PFN_TYPE Page
);
1398 MmGetReferenceCountPage(PFN_TYPE Page
);
1402 MmIsPageInUse(PFN_TYPE Page
);
1406 MmSetSavedSwapEntryPage(
1408 SWAPENTRY SavedSwapEntry
);
1412 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1417 struct _EPROCESS
*Process
,
1423 MmCreatePageTable(PVOID PAddress
);
1428 struct _EPROCESS
*Process
,
1435 struct _EPROCESS
*Process
,
1441 MmCreateProcessAddressSpace(
1444 IN PULONG_PTR DirectoryTableBase
1449 MmInitializeHandBuiltProcess(
1450 IN PEPROCESS Process
,
1451 IN PULONG_PTR DirectoryTableBase
1457 MmInitializeHandBuiltProcess2(
1458 IN PEPROCESS Process
1463 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1467 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1471 MmDeleteVirtualMapping(
1472 struct _EPROCESS
*Process
,
1482 struct _EPROCESS
*Process
,
1488 MmMarkPageMapped(PFN_TYPE Page
);
1492 MmMarkPageUnmapped(PFN_TYPE Page
);
1497 struct _EPROCESS
*Process
,
1504 MiInitPageDirectoryMap(VOID
);
1508 MiGetUserPageDirectoryCount(VOID
);
1510 /* wset.c ********************************************************************/
1519 /* region.c ************************************************************/
1524 PMMSUPPORT AddressSpace
,
1526 PLIST_ENTRY RegionListHead
,
1531 PMM_ALTER_REGION_FUNC AlterFunc
1537 PLIST_ENTRY RegionListHead
,
1547 PLIST_ENTRY RegionListHead
,
1549 PVOID
* RegionBaseAddress
1552 /* section.c *****************************************************************/
1556 MmGetFileObjectForSection(
1557 IN PROS_SECTION_OBJECT Section
1561 MmGetFileNameForAddress(
1563 OUT PUNICODE_STRING ModuleName
1568 MmGetFileNameForSection(
1569 IN PROS_SECTION_OBJECT Section
,
1570 OUT POBJECT_NAME_INFORMATION
*ModuleName
1583 PMEMORY_AREA MemoryArea
,
1585 PMEMORY_BASIC_INFORMATION Info
,
1586 PSIZE_T ResultLength
1591 MmProtectSectionView(
1592 PMMSUPPORT AddressSpace
,
1593 PMEMORY_AREA MemoryArea
,
1602 MmWritePageSectionView(
1603 PMMSUPPORT AddressSpace
,
1611 MmInitSectionImplementation(VOID
);
1615 MmNotPresentFaultSectionView(
1616 PMMSUPPORT AddressSpace
,
1617 MEMORY_AREA
* MemoryArea
,
1624 MmPageOutSectionView(
1625 PMMSUPPORT AddressSpace
,
1626 PMEMORY_AREA MemoryArea
,
1628 struct _MM_PAGEOP
*PageOp
1633 MmCreatePhysicalMemorySection(VOID
);
1637 MmAccessFaultSectionView(
1638 PMMSUPPORT AddressSpace
,
1639 MEMORY_AREA
* MemoryArea
,
1646 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1648 /* mpw.c *********************************************************************/
1652 MmInitMpwThread(VOID
);
1656 MmInitBsmThread(VOID
);
1658 /* pager.c *******************************************************************/
1662 MiIsPagerThread(VOID
);
1666 MiStartPagerThread(VOID
);
1670 MiStopPagerThread(VOID
);
1674 MiQueryVirtualMemory(
1675 IN HANDLE ProcessHandle
,
1677 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1678 OUT PVOID VirtualMemoryInformation
,
1680 OUT PSIZE_T ResultLength
1683 /* sysldr.c ******************************************************************/
1687 MiReloadBootLoadedDrivers(
1688 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1693 MiInitializeLoadedModuleList(
1694 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1700 IN PUNICODE_STRING FileName
,
1701 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1702 IN PUNICODE_STRING LoadedName OPTIONAL
,
1704 OUT PVOID
*ModuleObject
,
1705 OUT PVOID
*ImageBaseAddress
1710 MmUnloadSystemImage(
1711 IN PVOID ImageHandle
1717 IN HANDLE ImageHandle
,
1718 IN BOOLEAN PurgeSection
1723 MmCallDllInitialize(
1724 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1725 IN PLIST_ENTRY ListHead
1728 /* ReactOS Mm Hacks */
1731 MiSyncForProcessAttach(
1732 IN PKTHREAD NextThread
,
1733 IN PEPROCESS Process
1738 MiSyncForContextSwitch(
1742 extern PMMSUPPORT MmKernelAddressSpace
;
1746 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1748 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1753 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1755 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1760 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1762 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1763 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1768 MmGetCurrentAddressSpace(VOID
)
1770 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1775 MmGetKernelAddressSpace(VOID
)
1777 return MmKernelAddressSpace
;