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 KMUTANT MmSystemLoadLock
;
33 extern ULONG MmNumberOfPagingFiles
;
35 extern PVOID MmUnloadedDrivers
;
36 extern PVOID MmLastUnloadedDrivers
;
37 extern PVOID MmTriageActionTaken
;
38 extern PVOID KernelVerifier
;
39 extern MM_DRIVER_VERIFIER_DATA MmVerifierData
;
41 extern SIZE_T MmTotalCommitLimit
;
42 extern SIZE_T MmTotalCommittedPages
;
43 extern SIZE_T MmSharedCommit
;
44 extern SIZE_T MmDriverCommit
;
45 extern SIZE_T MmProcessCommit
;
46 extern SIZE_T MmPagedPoolCommit
;
47 extern SIZE_T MmPeakCommitment
;
48 extern SIZE_T MmtotalCommitLimitMaximum
;
50 extern BOOLEAN MiDbgReadyForPhysical
;
54 struct _MM_RMAP_ENTRY
;
56 typedef ULONG SWAPENTRY
;
57 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
60 // MmDbgCopyMemory Flags
62 #define MMDBG_COPY_WRITE 0x00000001
63 #define MMDBG_COPY_PHYSICAL 0x00000002
64 #define MMDBG_COPY_UNSAFE 0x00000004
65 #define MMDBG_COPY_CACHED 0x00000008
66 #define MMDBG_COPY_UNCACHED 0x00000010
67 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
70 // Maximum chunk size per copy
72 #define MMDBG_COPY_MAX_SIZE 0x8
75 #define MI_STATIC_MEMORY_AREAS (14)
77 #define MI_STATIC_MEMORY_AREAS (13)
80 #define MEMORY_AREA_INVALID (0)
81 #define MEMORY_AREA_SECTION_VIEW (1)
82 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
83 #define MEMORY_AREA_NO_CACHE (3)
84 #define MEMORY_AREA_IO_MAPPING (4)
85 #define MEMORY_AREA_SYSTEM (5)
86 #define MEMORY_AREA_MDL_MAPPING (7)
87 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
88 #define MEMORY_AREA_CACHE_SEGMENT (9)
89 #define MEMORY_AREA_SHARED_DATA (10)
90 #define MEMORY_AREA_KERNEL_STACK (11)
91 #define MEMORY_AREA_PAGED_POOL (12)
92 #define MEMORY_AREA_NO_ACCESS (13)
93 #define MEMORY_AREA_PEB_OR_TEB (14)
94 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
95 #define MEMORY_AREA_STATIC (0x80000000)
97 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
99 #define MM_CORE_DUMP_TYPE_NONE (0x0)
100 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
101 #define MM_CORE_DUMP_TYPE_FULL (0x2)
103 #define MM_PAGEOP_PAGEIN (1)
104 #define MM_PAGEOP_PAGEOUT (2)
105 #define MM_PAGEOP_PAGESYNCH (3)
106 #define MM_PAGEOP_ACCESSFAULT (4)
108 /* Number of list heads to use */
109 #define MI_FREE_POOL_LISTS 4
111 #define MI_HYPERSPACE_PTES (256 - 1)
112 #define MI_ZERO_PTES (32)
113 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
114 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
115 MI_HYPERSPACE_PTES * PAGE_SIZE)
116 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
119 /* Signature of free pool blocks */
120 #define MM_FREE_POOL_TAG 'lprF'
122 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
123 ((x) / (4*1024*1024))
125 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
126 ((((x)) % (4*1024*1024)) / (4*1024))
128 #define NR_SECTION_PAGE_TABLES 1024
129 #define NR_SECTION_PAGE_ENTRIES 1024
131 #define TEB_BASE 0x7FFDE000
133 /* Although Microsoft says this isn't hardcoded anymore,
134 they won't be able to change it. Stuff depends on it */
135 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
137 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
140 * Additional flags for protection attributes
142 #define PAGE_WRITETHROUGH (1024)
143 #define PAGE_SYSTEM (2048)
145 #define SEC_PHYSICALMEMORY (0x80000000)
147 #define MM_PAGEFILE_SEGMENT (0x1)
148 #define MM_DATAFILE_SEGMENT (0x2)
153 #define MC_NPPOOL (3)
154 #define MC_SYSTEM (4)
155 #define MC_MAXIMUM (5)
157 #define PAGED_POOL_MASK 1
158 #define MUST_SUCCEED_POOL_MASK 2
159 #define CACHE_ALIGNED_POOL_MASK 4
160 #define QUOTA_POOL_MASK 8
161 #define SESSION_POOL_MASK 32
162 #define VERIFIER_POOL_MASK 64
164 #define MM_PAGED_POOL_SIZE (100*1024*1024)
165 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
168 * Paged and non-paged pools are 8-byte aligned
170 #define MM_POOL_ALIGNMENT 8
173 * Maximum size of the kmalloc area (this is totally arbitary)
175 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
176 #define MM_KERNEL_MAP_BASE (0xf0c00000)
179 * FIXME - different architectures have different cache line sizes...
181 #define MM_CACHE_LINE_SIZE 32
183 #define MM_ROUND_UP(x,s) \
184 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
186 #define MM_ROUND_DOWN(x,s) \
187 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
189 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
194 PAGE_EXECUTE_READ | \
195 PAGE_EXECUTE_READWRITE | \
196 PAGE_EXECUTE_WRITECOPY | \
201 #define PAGE_FLAGS_VALID_FOR_SECTION \
206 PAGE_EXECUTE_READ | \
207 PAGE_EXECUTE_READWRITE | \
208 PAGE_EXECUTE_WRITECOPY | \
211 #define PAGE_IS_READABLE \
215 PAGE_EXECUTE_READ | \
216 PAGE_EXECUTE_READWRITE | \
217 PAGE_EXECUTE_WRITECOPY)
219 #define PAGE_IS_WRITABLE \
222 PAGE_EXECUTE_READWRITE | \
223 PAGE_EXECUTE_WRITECOPY)
225 #define PAGE_IS_EXECUTABLE \
227 PAGE_EXECUTE_READ | \
228 PAGE_EXECUTE_READWRITE | \
229 PAGE_EXECUTE_WRITECOPY)
231 #define PAGE_IS_WRITECOPY \
233 PAGE_EXECUTE_WRITECOPY)
236 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
237 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
239 #define InterlockedExchangePte(PointerPte, Value) \
240 InterlockedExchange((PLONG)(PointerPte), Value)
244 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
245 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
249 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
250 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
252 typedef struct _MM_SECTION_SEGMENT
254 LONG FileOffset
; /* start offset into the file for image sections */
255 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
256 ULONG RawLength
; /* length of the segment which is part of the mapped file */
257 ULONG Length
; /* absolute length of the segment */
259 FAST_MUTEX Lock
; /* lock which protects the page directory */
260 ULONG ReferenceCount
;
261 SECTION_PAGE_DIRECTORY PageDirectory
;
263 ULONG Characteristics
;
265 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
267 typedef struct _MM_IMAGE_SECTION_OBJECT
270 ULONG_PTR StackReserve
;
271 ULONG_PTR StackCommit
;
272 ULONG_PTR EntryPoint
;
274 USHORT ImageCharacteristics
;
275 USHORT MinorSubsystemVersion
;
276 USHORT MajorSubsystemVersion
;
281 PMM_SECTION_SEGMENT Segments
;
282 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
284 typedef struct _ROS_SECTION_OBJECT
288 LARGE_INTEGER MaximumSize
;
289 ULONG SectionPageProtection
;
290 ULONG AllocationAttributes
;
291 PFILE_OBJECT FileObject
;
294 PMM_IMAGE_SECTION_OBJECT ImageSection
;
295 PMM_SECTION_SEGMENT Segment
;
297 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
299 typedef struct _MEMORY_AREA
301 PVOID StartingAddress
;
303 struct _MEMORY_AREA
*Parent
;
304 struct _MEMORY_AREA
*LeftChild
;
305 struct _MEMORY_AREA
*RightChild
;
309 BOOLEAN DeleteInProgress
;
315 ROS_SECTION_OBJECT
* Section
;
317 PMM_SECTION_SEGMENT Segment
;
318 BOOLEAN WriteCopyView
;
319 LIST_ENTRY RegionListHead
;
323 LIST_ENTRY RegionListHead
;
326 } MEMORY_AREA
, *PMEMORY_AREA
;
329 // These two mappings are actually used by Windows itself, based on the ASSERTS
331 #define StartOfAllocation ReadInProgress
332 #define EndOfAllocation WriteInProgress
334 typedef struct _MMPFNENTRY
337 USHORT ReadInProgress
:1; // StartOfAllocation
338 USHORT WriteInProgress
:1; // EndOfAllocation
339 USHORT PrototypePte
:1; // Zero
340 USHORT PageColor
:4; // LockCount
341 USHORT PageLocation
:3; // Consumer
342 USHORT RemovalRequested
:1;
343 USHORT CacheAttribute
:2; // Type
345 USHORT ParityError
:1;
348 typedef struct _MMPFN
352 PFN_NUMBER Flink
; // ListEntry.Flink
356 SINGLE_LIST_ENTRY NextStackPfn
;
358 PMMPTE PteAddress
; // ListEntry.Blink
362 ULONG_PTR ShareCount
; // MapCount
368 USHORT ReferenceCount
; // ReferenceCount
373 USHORT ReferenceCount
;
380 LONG AweReferenceCount
; // RmapListHead
384 ULONG_PTR EntireFrame
; // SavedSwapEntry
387 ULONG_PTR PteFrame
:25;
388 ULONG_PTR InPageError
:1;
389 ULONG_PTR VerifierAllocation
:1;
390 ULONG_PTR AweAllocation
:1;
391 ULONG_PTR Priority
:3;
392 ULONG_PTR MustBeCached
:1;
397 extern PMMPFN MmPfnDatabase
;
399 typedef struct _MMPFNLIST
405 } MMPFNLIST
, *PMMPFNLIST
;
407 extern MMPFNLIST MmZeroedPageListHead
;
408 extern MMPFNLIST MmFreePageListHead
;
409 extern MMPFNLIST MmStandbyPageListHead
;
410 extern MMPFNLIST MmModifiedPageListHead
;
411 extern MMPFNLIST MmModifiedNoWritePageListHead
;
413 typedef struct _MM_PAGEOP
415 /* Type of operation. */
417 /* Number of threads interested in this operation. */
418 ULONG ReferenceCount
;
419 /* Event that will be set when the operation is completed. */
420 KEVENT CompletionEvent
;
421 /* Status of the operation once it is completed. */
423 /* TRUE if the operation was abandoned. */
425 /* The memory area to be affected by the operation. */
428 struct _MM_PAGEOP
* Next
;
429 struct _ETHREAD
* Thread
;
431 * These fields are used to identify the operation if it is against a
432 * virtual memory area.
437 * These fields are used to identify the operation if it is against a
440 PMM_SECTION_SEGMENT Segment
;
442 } MM_PAGEOP
, *PMM_PAGEOP
;
444 typedef struct _MM_MEMORY_CONSUMER
448 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
449 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
451 typedef struct _MM_REGION
456 LIST_ENTRY RegionListEntry
;
457 } MM_REGION
, *PMM_REGION
;
459 /* Entry describing free pool memory */
460 typedef struct _MMFREE_POOL_ENTRY
465 struct _MMFREE_POOL_ENTRY
*Owner
;
466 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
468 /* Paged pool information */
469 typedef struct _MM_PAGED_POOL_INFO
471 PRTL_BITMAP PagedPoolAllocationMap
;
472 PRTL_BITMAP EndOfPagedPoolBitmap
;
473 PMMPTE FirstPteForPagedPool
;
474 PMMPTE LastPteForPagedPool
;
475 PMMPTE NextPdeForPagedPoolExpansion
;
477 SIZE_T PagedPoolCommit
;
478 SIZE_T AllocatedPagedPool
;
479 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
481 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
484 (*PMM_ALTER_REGION_FUNC
)(
485 PMMSUPPORT AddressSpace
,
495 (*PMM_FREE_PAGE_FUNC
)(
497 PMEMORY_AREA MemoryArea
,
505 // Mm copy support for Kd
517 // Determines if a given address is a session address
525 /* marea.c *******************************************************************/
530 PMMSUPPORT AddressSpace
,
535 PMEMORY_AREA
*Result
,
536 BOOLEAN FixedAddress
,
537 ULONG AllocationFlags
,
538 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
543 MmLocateMemoryAreaByAddress(
544 PMMSUPPORT AddressSpace
,
551 PMMSUPPORT AddressSpace
,
558 PMMSUPPORT AddressSpace
,
559 PMEMORY_AREA MemoryArea
,
560 PMM_FREE_PAGE_FUNC FreePage
,
561 PVOID FreePageContext
566 MmFreeMemoryAreaByPtr(
567 PMMSUPPORT AddressSpace
,
569 PMM_FREE_PAGE_FUNC FreePage
,
570 PVOID FreePageContext
575 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
579 MmLocateMemoryAreaByRegion(
580 PMMSUPPORT AddressSpace
,
588 PMMSUPPORT AddressSpace
,
590 ULONG_PTR Granularity
,
596 MmReleaseMemoryAreaIfDecommitted(
597 struct _EPROCESS
*Process
,
598 PMMSUPPORT AddressSpace
,
604 MmMapMemoryArea(PVOID BaseAddress
,
609 /* npool.c *******************************************************************/
613 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
617 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
621 MiInitializeNonPagedPool(VOID
);
626 IN POOL_TYPE PoolType
,
627 IN SIZE_T SizeInBytes
633 IN PVOID VirtualAddress
639 IN PVOID StartingAddress
649 /* pool.c *******************************************************************/
653 ExAllocateNonPagedPoolWithTag(
662 ExAllocatePagedPoolWithTag(
670 ExFreeNonPagedPool(PVOID block
);
674 ExFreePagedPool(IN PVOID Block
);
678 ExpIsPoolTagDebuggable(ULONG Tag
);
682 ExpAllocateDebugPool(
692 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
696 MmInitializePagedPool(VOID
);
700 MiAllocateSpecialPool(
701 IN POOL_TYPE PoolType
,
702 IN SIZE_T NumberOfBytes
,
710 IN POOL_TYPE PoolType
,
711 IN ULONG CurrentMaxQuota
,
712 OUT PULONG NewMaxQuota
715 /* mdl.c *********************************************************************/
724 /* mminit.c ******************************************************************/
728 MiShutdownMemoryManager(VOID
);
738 MmInitSystem(IN ULONG Phase
,
739 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
743 MiFreeInitMemory(VOID
);
747 MmInitializeMdlImplementation(VOID
);
749 /* pagefile.c ****************************************************************/
753 MmAllocSwapPage(VOID
);
757 MmDereserveSwapPages(ULONG Nr
);
761 MmFreeSwapPage(SWAPENTRY Entry
);
765 MmInitPagingFile(VOID
);
776 MmReserveSwapPages(ULONG Nr
);
789 ULONG BugCodeParameter1
,
790 ULONG BugCodeParameter2
,
791 ULONG BugCodeParameter3
,
792 ULONG BugCodeParameter4
,
793 struct _KTRAP_FRAME
* TrapFrame
798 MmIsAvailableSwapPage(VOID
);
802 MmShowOutOfSpaceMessagePagingFile(VOID
);
804 /* process.c ****************************************************************/
808 MmInitializeProcessAddressSpace(
809 IN PEPROCESS Process
,
810 IN PEPROCESS Clone OPTIONAL
,
811 IN PVOID Section OPTIONAL
,
813 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
819 IN PEPROCESS Process
,
820 IN PINITIAL_PEB InitialPeb
,
827 IN PEPROCESS Process
,
828 IN PCLIENT_ID ClientId
,
829 IN PINITIAL_TEB InitialTeb
,
836 struct _EPROCESS
*Process
,
842 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
846 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
850 MmGetSessionLocaleId(VOID
);
854 MmSetMemoryPriorityProcess(
855 IN PEPROCESS Process
,
856 IN UCHAR MemoryPriority
859 /* i386/pfault.c *************************************************************/
871 /* mm.c **********************************************************************/
876 IN BOOLEAN StoreInstruction
,
878 IN KPROCESSOR_MODE Mode
,
879 IN PVOID TrapInformation
882 /* anonmem.c *****************************************************************/
886 MmNotPresentFaultVirtualMemory(
887 PMMSUPPORT AddressSpace
,
888 MEMORY_AREA
* MemoryArea
,
895 MmPageOutVirtualMemory(
896 PMMSUPPORT AddressSpace
,
897 PMEMORY_AREA MemoryArea
,
899 struct _MM_PAGEOP
* PageOp
905 PMEMORY_AREA MemoryArea
,
907 PMEMORY_BASIC_INFORMATION Info
,
914 struct _EPROCESS
* Process
,
915 PMEMORY_AREA MemoryArea
921 PMMSUPPORT AddressSpace
,
922 PMEMORY_AREA MemoryArea
,
931 MmWritePageVirtualMemory(
932 PMMSUPPORT AddressSpace
,
938 /* kmap.c ********************************************************************/
942 ExAllocatePage(VOID
);
946 ExUnmapPage(PVOID Addr
);
950 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
961 MiZeroPage(PFN_TYPE Page
);
963 /* memsafe.s *****************************************************************/
967 MmSafeReadPtr(PVOID Source
);
969 /* pageop.c ******************************************************************/
973 MmReleasePageOp(PMM_PAGEOP PageOp
);
981 PMM_SECTION_SEGMENT Segment
,
993 PMM_SECTION_SEGMENT Segment
,
999 MmInitializePageOp(VOID
);
1001 /* process.c *****************************************************************/
1005 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1009 MmDeleteKernelStack(PVOID Stack
,
1012 /* balace.c ******************************************************************/
1016 MmInitializeMemoryConsumer(
1018 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1023 MmInitializeBalancer(
1024 ULONG NrAvailablePages
,
1030 MmReleasePageMemoryConsumer(
1037 MmRequestPageMemoryConsumer(
1040 PPFN_TYPE AllocatedPage
1045 MiInitBalancerThread(VOID
);
1049 MmRebalanceMemoryConsumers(VOID
);
1051 /* rmap.c **************************************************************/
1055 MmSetRmapListHeadPage(
1057 struct _MM_RMAP_ENTRY
* ListHead
1060 struct _MM_RMAP_ENTRY
*
1062 MmGetRmapListHeadPage(PFN_TYPE Page
);
1068 struct _EPROCESS
*Process
,
1077 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1084 struct _EPROCESS
*Process
,
1090 MmInitializeRmapList(VOID
);
1094 MmSetCleanAllRmaps(PFN_TYPE Page
);
1098 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1102 MmIsDirtyPageRmap(PFN_TYPE Page
);
1106 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1110 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1112 /* freelist.c **********************************************************/
1114 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1118 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1121 extern RTL_BITMAP MiPfnBitMap
;
1123 /* Make sure the PFN number is valid */
1124 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1126 /* Make sure this page actually has a PFN entry */
1127 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1130 Page
= &MmPfnDatabase
[Pfn
];
1132 /* Make sure it's valid */
1141 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1144 // This will return the Page Frame Number (PFN) from the MMPFN
1146 return Pfn1
- MmPfnDatabase
;
1151 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1155 MmGetLRUFirstUserPage(VOID
);
1159 MmInsertLRULastUserPage(PFN_TYPE Page
);
1163 MmRemoveLRUUserPage(PFN_TYPE Page
);
1167 MmLockPage(PFN_TYPE Page
);
1171 MmUnlockPage(PFN_TYPE Page
);
1175 MmGetLockCountPage(PFN_TYPE Page
);
1179 MmInitializePageList(
1191 MmGetContinuousPages(
1192 ULONG NumberOfBytes
,
1193 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1194 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1195 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1201 MmZeroPageThreadMain(
1205 /* hypermap.c *****************************************************************/
1207 extern PEPROCESS HyperProcess
;
1208 extern KIRQL HyperIrql
;
1212 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1218 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1224 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1225 IN PFN_NUMBER NumberOfPages
);
1229 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1230 IN PFN_NUMBER NumberOfPages
);
1233 // ReactOS Compatibility Layer
1237 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1239 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1240 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1245 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1247 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1248 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1251 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1253 /* i386/page.c *********************************************************/
1257 MmCreateVirtualMappingForKernel(
1266 MmCommitPagedPoolAddress(
1273 MmCreateVirtualMapping(
1274 struct _EPROCESS
* Process
,
1283 MmCreateVirtualMappingUnsafe(
1284 struct _EPROCESS
* Process
,
1294 struct _EPROCESS
* Process
,
1300 struct _EPROCESS
* Process
,
1308 struct _EPROCESS
* Process
,
1314 MmInitGlobalKernelPageDirectory(VOID
);
1318 MmDisableVirtualMapping(
1319 struct _EPROCESS
*Process
,
1327 MmEnableVirtualMapping(
1328 struct _EPROCESS
*Process
,
1334 MmRawDeleteVirtualMapping(PVOID Address
);
1338 MmDeletePageFileMapping(
1339 struct _EPROCESS
*Process
,
1341 SWAPENTRY
* SwapEntry
1346 MmCreatePageFileMapping(
1347 struct _EPROCESS
*Process
,
1355 struct _EPROCESS
*Process
,
1361 MmTransferOwnershipPage(
1369 struct _EPROCESS
*Process
,
1377 SWAPENTRY SavedSwapEntry
1382 MmAllocPagesSpecifyRange(
1384 PHYSICAL_ADDRESS LowestAddress
,
1385 PHYSICAL_ADDRESS HighestAddress
,
1386 ULONG NumberOfPages
,
1392 MmDereferencePage(PFN_TYPE Page
);
1396 MmReferencePage(PFN_TYPE Page
);
1400 MmGetReferenceCountPage(PFN_TYPE Page
);
1404 MmIsPageInUse(PFN_TYPE Page
);
1408 MmSetSavedSwapEntryPage(
1410 SWAPENTRY SavedSwapEntry
);
1414 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1419 struct _EPROCESS
*Process
,
1425 MmCreatePageTable(PVOID PAddress
);
1430 struct _EPROCESS
*Process
,
1437 struct _EPROCESS
*Process
,
1443 MmCreateProcessAddressSpace(
1446 IN PULONG DirectoryTableBase
1451 MmInitializeHandBuiltProcess(
1452 IN PEPROCESS Process
,
1453 IN PULONG DirectoryTableBase
1459 MmInitializeHandBuiltProcess2(
1460 IN PEPROCESS Process
1465 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1469 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1473 MmDeleteVirtualMapping(
1474 struct _EPROCESS
*Process
,
1484 struct _EPROCESS
*Process
,
1490 MmMarkPageMapped(PFN_TYPE Page
);
1494 MmMarkPageUnmapped(PFN_TYPE Page
);
1499 struct _EPROCESS
*Process
,
1506 MiInitPageDirectoryMap(VOID
);
1510 MiGetUserPageDirectoryCount(VOID
);
1512 /* wset.c ********************************************************************/
1521 /* region.c ************************************************************/
1526 PMMSUPPORT AddressSpace
,
1528 PLIST_ENTRY RegionListHead
,
1533 PMM_ALTER_REGION_FUNC AlterFunc
1539 PLIST_ENTRY RegionListHead
,
1549 PLIST_ENTRY RegionListHead
,
1551 PVOID
* RegionBaseAddress
1554 /* section.c *****************************************************************/
1558 MmGetFileObjectForSection(
1559 IN PROS_SECTION_OBJECT Section
1563 MmGetFileNameForAddress(
1565 OUT PUNICODE_STRING ModuleName
1570 MmGetFileNameForSection(
1571 IN PROS_SECTION_OBJECT Section
,
1572 OUT POBJECT_NAME_INFORMATION
*ModuleName
1585 PMEMORY_AREA MemoryArea
,
1587 PMEMORY_BASIC_INFORMATION Info
,
1593 MmProtectSectionView(
1594 PMMSUPPORT AddressSpace
,
1595 PMEMORY_AREA MemoryArea
,
1604 MmWritePageSectionView(
1605 PMMSUPPORT AddressSpace
,
1613 MmInitSectionImplementation(VOID
);
1617 MmNotPresentFaultSectionView(
1618 PMMSUPPORT AddressSpace
,
1619 MEMORY_AREA
* MemoryArea
,
1626 MmPageOutSectionView(
1627 PMMSUPPORT AddressSpace
,
1628 PMEMORY_AREA MemoryArea
,
1630 struct _MM_PAGEOP
*PageOp
1635 MmCreatePhysicalMemorySection(VOID
);
1639 MmAccessFaultSectionView(
1640 PMMSUPPORT AddressSpace
,
1641 MEMORY_AREA
* MemoryArea
,
1648 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1650 /* mpw.c *********************************************************************/
1654 MmInitMpwThread(VOID
);
1658 MmInitBsmThread(VOID
);
1660 /* pager.c *******************************************************************/
1664 MiIsPagerThread(VOID
);
1668 MiStartPagerThread(VOID
);
1672 MiStopPagerThread(VOID
);
1676 MiQueryVirtualMemory(
1677 IN HANDLE ProcessHandle
,
1679 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1680 OUT PVOID VirtualMemoryInformation
,
1682 OUT PULONG ResultLength
1685 /* sysldr.c ******************************************************************/
1689 MiReloadBootLoadedDrivers(
1690 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1695 MiInitializeLoadedModuleList(
1696 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1702 IN PUNICODE_STRING FileName
,
1703 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1704 IN PUNICODE_STRING LoadedName OPTIONAL
,
1706 OUT PVOID
*ModuleObject
,
1707 OUT PVOID
*ImageBaseAddress
1712 MmUnloadSystemImage(
1713 IN PVOID ImageHandle
1719 IN HANDLE ImageHandle
,
1720 IN BOOLEAN PurgeSection
1725 MmCallDllInitialize(
1726 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1727 IN PLIST_ENTRY ListHead
1730 /* ReactOS Mm Hacks */
1733 MiSyncForProcessAttach(
1734 IN PKTHREAD NextThread
,
1735 IN PEPROCESS Process
1740 MiSyncForContextSwitch(
1744 extern PMMSUPPORT MmKernelAddressSpace
;
1748 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1750 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1755 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1757 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1762 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1764 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1765 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1770 MmGetCurrentAddressSpace(VOID
)
1772 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1777 MmGetKernelAddressSpace(VOID
)
1779 return MmKernelAddressSpace
;