3 #include <internal/arch/mm.h>
5 /* TYPES *********************************************************************/
9 extern PMMSUPPORT MmKernelAddressSpace
;
10 extern PFN_NUMBER MiFreeSwapPages
;
11 extern PFN_NUMBER MiUsedSwapPages
;
12 extern SIZE_T MmTotalPagedPoolQuota
;
13 extern SIZE_T MmTotalNonPagedPoolQuota
;
14 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress
;
15 extern PFN_NUMBER MmNumberOfPhysicalPages
;
16 extern UCHAR MmDisablePagingExecutive
;
17 extern PFN_NUMBER MmLowestPhysicalPage
;
18 extern PFN_NUMBER MmHighestPhysicalPage
;
19 extern PFN_NUMBER MmAvailablePages
;
20 extern PFN_NUMBER MmResidentAvailablePages
;
22 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
23 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
25 extern LIST_ENTRY MmLoadedUserImageList
;
27 extern KMUTANT MmSystemLoadLock
;
29 extern ULONG MmNumberOfPagingFiles
;
31 extern PVOID MmUnloadedDrivers
;
32 extern PVOID MmLastUnloadedDrivers
;
33 extern PVOID MmTriageActionTaken
;
34 extern PVOID KernelVerifier
;
35 extern MM_DRIVER_VERIFIER_DATA MmVerifierData
;
37 extern SIZE_T MmTotalCommitLimit
;
38 extern SIZE_T MmTotalCommittedPages
;
39 extern SIZE_T MmSharedCommit
;
40 extern SIZE_T MmDriverCommit
;
41 extern SIZE_T MmProcessCommit
;
42 extern SIZE_T MmPagedPoolCommit
;
43 extern SIZE_T MmPeakCommitment
;
44 extern SIZE_T MmtotalCommitLimitMaximum
;
46 extern PVOID MiDebugMapping
;
47 extern PMMPTE MmDebugPte
;
51 struct _MM_RMAP_ENTRY
;
53 typedef ULONG SWAPENTRY
;
56 // MmDbgCopyMemory Flags
58 #define MMDBG_COPY_WRITE 0x00000001
59 #define MMDBG_COPY_PHYSICAL 0x00000002
60 #define MMDBG_COPY_UNSAFE 0x00000004
61 #define MMDBG_COPY_CACHED 0x00000008
62 #define MMDBG_COPY_UNCACHED 0x00000010
63 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
66 // Maximum chunk size per copy
68 #define MMDBG_COPY_MAX_SIZE 0x8
71 #define MI_STATIC_MEMORY_AREAS (14)
73 #define MI_STATIC_MEMORY_AREAS (13)
76 #define MEMORY_AREA_SECTION_VIEW (1)
77 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
78 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
79 #define MEMORY_AREA_STATIC (0x80000000)
81 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
83 #define MM_CORE_DUMP_TYPE_NONE (0x0)
84 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
85 #define MM_CORE_DUMP_TYPE_FULL (0x2)
87 #define MM_PAGEOP_PAGEIN (1)
88 #define MM_PAGEOP_PAGEOUT (2)
89 #define MM_PAGEOP_PAGESYNCH (3)
90 #define MM_PAGEOP_ACCESSFAULT (4)
92 /* Number of list heads to use */
93 #define MI_FREE_POOL_LISTS 4
96 /* Signature of free pool blocks */
97 #define MM_FREE_POOL_TAG 'lprF'
99 /* Although Microsoft says this isn't hardcoded anymore,
100 they won't be able to change it. Stuff depends on it */
101 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
103 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
106 * Additional flags for protection attributes
108 #define PAGE_WRITETHROUGH (1024)
109 #define PAGE_SYSTEM (2048)
111 #define SEC_PHYSICALMEMORY (0x80000000)
113 #define MM_PAGEFILE_SEGMENT (0x1)
114 #define MM_DATAFILE_SEGMENT (0x2)
118 #define MC_SYSTEM (2)
119 #define MC_MAXIMUM (3)
121 #define PAGED_POOL_MASK 1
122 #define MUST_SUCCEED_POOL_MASK 2
123 #define CACHE_ALIGNED_POOL_MASK 4
124 #define QUOTA_POOL_MASK 8
125 #define SESSION_POOL_MASK 32
126 #define VERIFIER_POOL_MASK 64
128 #define MM_PAGED_POOL_SIZE (100*1024*1024)
129 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
132 * Paged and non-paged pools are 8-byte aligned
134 #define MM_POOL_ALIGNMENT 8
136 #define MM_ROUND_UP(x,s) \
137 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
139 #define MM_ROUND_DOWN(x,s) \
140 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
142 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
147 PAGE_EXECUTE_READ | \
148 PAGE_EXECUTE_READWRITE | \
149 PAGE_EXECUTE_WRITECOPY | \
154 #define PAGE_FLAGS_VALID_FOR_SECTION \
159 PAGE_EXECUTE_READ | \
160 PAGE_EXECUTE_READWRITE | \
161 PAGE_EXECUTE_WRITECOPY | \
164 #define PAGE_IS_READABLE \
168 PAGE_EXECUTE_READ | \
169 PAGE_EXECUTE_READWRITE | \
170 PAGE_EXECUTE_WRITECOPY)
172 #define PAGE_IS_WRITABLE \
175 PAGE_EXECUTE_READWRITE | \
176 PAGE_EXECUTE_WRITECOPY)
178 #define PAGE_IS_EXECUTABLE \
180 PAGE_EXECUTE_READ | \
181 PAGE_EXECUTE_READWRITE | \
182 PAGE_EXECUTE_WRITECOPY)
184 #define PAGE_IS_WRITECOPY \
186 PAGE_EXECUTE_WRITECOPY)
189 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
190 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
192 #define InterlockedExchangePte(PointerPte, Value) \
193 InterlockedExchange((PLONG)(PointerPte), Value)
197 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
198 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
202 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
203 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
205 typedef struct _MM_SECTION_SEGMENT
207 LONG FileOffset
; /* start offset into the file for image sections */
208 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
209 ULONG RawLength
; /* length of the segment which is part of the mapped file */
210 ULONG Length
; /* absolute length of the segment */
212 FAST_MUTEX Lock
; /* lock which protects the page directory */
213 ULONG ReferenceCount
;
214 SECTION_PAGE_DIRECTORY PageDirectory
;
216 ULONG Characteristics
;
218 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
220 typedef struct _MM_IMAGE_SECTION_OBJECT
223 ULONG_PTR StackReserve
;
224 ULONG_PTR StackCommit
;
225 ULONG_PTR EntryPoint
;
227 USHORT ImageCharacteristics
;
228 USHORT MinorSubsystemVersion
;
229 USHORT MajorSubsystemVersion
;
234 PMM_SECTION_SEGMENT Segments
;
235 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
237 typedef struct _ROS_SECTION_OBJECT
241 LARGE_INTEGER MaximumSize
;
242 ULONG SectionPageProtection
;
243 ULONG AllocationAttributes
;
244 PFILE_OBJECT FileObject
;
247 PMM_IMAGE_SECTION_OBJECT ImageSection
;
248 PMM_SECTION_SEGMENT Segment
;
250 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
252 struct _MM_CACHE_SECTION_SEGMENT
;
254 typedef struct _MEMORY_AREA
256 PVOID StartingAddress
;
258 struct _MEMORY_AREA
*Parent
;
259 struct _MEMORY_AREA
*LeftChild
;
260 struct _MEMORY_AREA
*RightChild
;
264 BOOLEAN DeleteInProgress
;
271 ROS_SECTION_OBJECT
* Section
;
273 PMM_SECTION_SEGMENT Segment
;
274 LIST_ENTRY RegionListHead
;
278 LARGE_INTEGER ViewOffset
;
279 struct _MM_CACHE_SECTION_SEGMENT
*Segment
;
283 LIST_ENTRY RegionListHead
;
286 } MEMORY_AREA
, *PMEMORY_AREA
;
288 typedef struct _MM_RMAP_ENTRY
290 struct _MM_RMAP_ENTRY
* Next
;
297 MM_RMAP_ENTRY
, *PMM_RMAP_ENTRY
;
300 extern ULONG MI_PFN_CURRENT_USAGE
;
301 extern CHAR MI_PFN_CURRENT_PROCESS_NAME
[16];
302 #define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x
303 #define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, 16)
305 #define MI_SET_USAGE(x)
306 #define MI_SET_PROCESS2(x)
309 typedef enum _MI_PFN_USAGES
311 MI_USAGE_NOT_SET
= 0,
313 MI_USAGE_NONPAGED_POOL
,
314 MI_USAGE_NONPAGED_POOL_EXPANSION
,
315 MI_USAGE_KERNEL_STACK
,
316 MI_USAGE_KERNEL_STACK_EXPANSION
,
322 MI_USAGE_PAGE_DIRECTORY
,
323 MI_USAGE_LEGACY_PAGE_DIRECTORY
,
324 MI_USAGE_DRIVER_PAGE
,
325 MI_USAGE_CONTINOUS_ALLOCATION
,
327 MI_USAGE_DEMAND_ZERO
,
330 MI_USAGE_PFN_DATABASE
,
331 MI_USAGE_BOOT_DRIVER
,
332 MI_USAGE_INIT_MEMORY
,
337 // These two mappings are actually used by Windows itself, based on the ASSERTS
339 #define StartOfAllocation ReadInProgress
340 #define EndOfAllocation WriteInProgress
342 typedef struct _MMPFNENTRY
345 USHORT ReadInProgress
:1; // StartOfAllocation
346 USHORT WriteInProgress
:1; // EndOfAllocation
347 USHORT PrototypePte
:1;
349 USHORT PageLocation
:3;
350 USHORT RemovalRequested
:1;
351 USHORT CacheAttribute
:2;
353 USHORT ParityError
:1; // HasRmap
356 typedef struct _MMPFN
361 ULONG WsIndex
; // SavedSwapEntry
364 SINGLE_LIST_ENTRY NextStackPfn
;
370 ULONG_PTR ShareCount
;
376 USHORT ReferenceCount
; // ReferenceCount
381 USHORT ReferenceCount
;
388 LONG AweReferenceCount
; // RmapListHead
392 ULONG_PTR EntireFrame
;
395 ULONG_PTR PteFrame
:25;
396 ULONG_PTR InPageError
:1;
397 ULONG_PTR VerifierAllocation
:1;
398 ULONG_PTR AweAllocation
:1;
399 ULONG_PTR Priority
:3;
400 ULONG_PTR MustBeCached
:1;
404 MI_PFN_USAGES PfnUsage
;
405 CHAR ProcessName
[16];
409 extern PMMPFN MmPfnDatabase
;
411 typedef struct _MMPFNLIST
417 } MMPFNLIST
, *PMMPFNLIST
;
419 extern MMPFNLIST MmZeroedPageListHead
;
420 extern MMPFNLIST MmFreePageListHead
;
421 extern MMPFNLIST MmStandbyPageListHead
;
422 extern MMPFNLIST MmModifiedPageListHead
;
423 extern MMPFNLIST MmModifiedNoWritePageListHead
;
425 typedef struct _MM_PAGEOP
427 /* Type of operation. */
429 /* Number of threads interested in this operation. */
430 ULONG ReferenceCount
;
431 /* Event that will be set when the operation is completed. */
432 KEVENT CompletionEvent
;
433 /* Status of the operation once it is completed. */
435 /* TRUE if the operation was abandoned. */
437 /* The memory area to be affected by the operation. */
440 struct _MM_PAGEOP
* Next
;
441 struct _ETHREAD
* Thread
;
443 * These fields are used to identify the operation if it is against a
444 * virtual memory area.
449 * These fields are used to identify the operation if it is against a
452 PMM_SECTION_SEGMENT Segment
;
454 } MM_PAGEOP
, *PMM_PAGEOP
;
456 typedef struct _MM_MEMORY_CONSUMER
460 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
461 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
463 typedef struct _MM_REGION
468 LIST_ENTRY RegionListEntry
;
469 } MM_REGION
, *PMM_REGION
;
471 /* Entry describing free pool memory */
472 typedef struct _MMFREE_POOL_ENTRY
477 struct _MMFREE_POOL_ENTRY
*Owner
;
478 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
480 /* Signature of a freed block */
481 #define MM_FREE_POOL_SIGNATURE 'ARM3'
483 /* Paged pool information */
484 typedef struct _MM_PAGED_POOL_INFO
486 PRTL_BITMAP PagedPoolAllocationMap
;
487 PRTL_BITMAP EndOfPagedPoolBitmap
;
488 PMMPTE FirstPteForPagedPool
;
489 PMMPTE LastPteForPagedPool
;
490 PMMPDE NextPdeForPagedPoolExpansion
;
492 SIZE_T PagedPoolCommit
;
493 SIZE_T AllocatedPagedPool
;
494 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
496 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
499 (*PMM_ALTER_REGION_FUNC
)(
500 PMMSUPPORT AddressSpace
,
510 (*PMM_FREE_PAGE_FUNC
)(
512 PMEMORY_AREA MemoryArea
,
520 // Mm copy support for Kd
532 // Determines if a given address is a session address
540 /* marea.c *******************************************************************/
545 PMMSUPPORT AddressSpace
,
550 PMEMORY_AREA
*Result
,
551 BOOLEAN FixedAddress
,
552 ULONG AllocationFlags
,
553 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
558 MmLocateMemoryAreaByAddress(
559 PMMSUPPORT AddressSpace
,
566 PMMSUPPORT AddressSpace
,
573 PMMSUPPORT AddressSpace
,
574 PMEMORY_AREA MemoryArea
,
575 PMM_FREE_PAGE_FUNC FreePage
,
576 PVOID FreePageContext
581 MmFreeMemoryAreaByPtr(
582 PMMSUPPORT AddressSpace
,
584 PMM_FREE_PAGE_FUNC FreePage
,
585 PVOID FreePageContext
590 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
594 MmLocateMemoryAreaByRegion(
595 PMMSUPPORT AddressSpace
,
603 PMMSUPPORT AddressSpace
,
605 ULONG_PTR Granularity
,
611 MmReleaseMemoryAreaIfDecommitted(
612 struct _EPROCESS
*Process
,
613 PMMSUPPORT AddressSpace
,
619 MmMapMemoryArea(PVOID BaseAddress
,
624 /* npool.c *******************************************************************/
628 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
632 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
636 MiInitializeNonPagedPool(VOID
);
641 IN POOL_TYPE PoolType
,
642 IN SIZE_T SizeInBytes
648 IN PVOID VirtualAddress
654 IN PVOID StartingAddress
664 /* pool.c *******************************************************************/
668 ExAllocateNonPagedPoolWithTag(
677 ExAllocatePagedPoolWithTag(
685 ExFreeNonPagedPool(PVOID block
);
689 ExFreePagedPool(IN PVOID Block
);
693 ExpIsPoolTagDebuggable(ULONG Tag
);
697 ExpAllocateDebugPool(
707 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
711 MmInitializePagedPool(VOID
);
715 MiAllocateSpecialPool(
716 IN POOL_TYPE PoolType
,
717 IN SIZE_T NumberOfBytes
,
725 IN POOL_TYPE PoolType
,
726 IN ULONG CurrentMaxQuota
,
727 OUT PULONG NewMaxQuota
730 /* mdl.c *********************************************************************/
739 /* mminit.c ******************************************************************/
743 MiShutdownMemoryManager(VOID
);
753 MmInitSystem(IN ULONG Phase
,
754 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
758 MiFreeInitMemory(VOID
);
762 MmInitializeMdlImplementation(VOID
);
764 /* pagefile.c ****************************************************************/
768 MmAllocSwapPage(VOID
);
772 MmDereserveSwapPages(ULONG Nr
);
776 MmFreeSwapPage(SWAPENTRY Entry
);
780 MmInitPagingFile(VOID
);
784 MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject
);
795 MmReserveSwapPages(ULONG Nr
);
808 ULONG BugCodeParameter1
,
809 ULONG BugCodeParameter2
,
810 ULONG BugCodeParameter3
,
811 ULONG BugCodeParameter4
,
812 struct _KTRAP_FRAME
* TrapFrame
817 MmIsAvailableSwapPage(VOID
);
821 MmShowOutOfSpaceMessagePagingFile(VOID
);
823 /* process.c ****************************************************************/
827 MmInitializeProcessAddressSpace(
828 IN PEPROCESS Process
,
829 IN PEPROCESS Clone OPTIONAL
,
830 IN PVOID Section OPTIONAL
,
832 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
838 IN PEPROCESS Process
,
839 IN PINITIAL_PEB InitialPeb
,
846 IN PEPROCESS Process
,
847 IN PCLIENT_ID ClientId
,
848 IN PINITIAL_TEB InitialTeb
,
855 struct _EPROCESS
*Process
,
861 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
865 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
869 MmGetSessionLocaleId(VOID
);
873 MmSetMemoryPriorityProcess(
874 IN PEPROCESS Process
,
875 IN UCHAR MemoryPriority
878 /* i386/pfault.c *************************************************************/
890 /* mm.c **********************************************************************/
895 IN BOOLEAN StoreInstruction
,
897 IN KPROCESSOR_MODE Mode
,
898 IN PVOID TrapInformation
901 /* anonmem.c *****************************************************************/
905 MmNotPresentFaultVirtualMemory(
906 PMMSUPPORT AddressSpace
,
907 MEMORY_AREA
* MemoryArea
,
914 MmPageOutVirtualMemory(
915 PMMSUPPORT AddressSpace
,
916 PMEMORY_AREA MemoryArea
,
918 struct _MM_PAGEOP
* PageOp
924 PMEMORY_AREA MemoryArea
,
926 PMEMORY_BASIC_INFORMATION Info
,
933 struct _EPROCESS
* Process
,
934 PMEMORY_AREA MemoryArea
940 PMMSUPPORT AddressSpace
,
941 PMEMORY_AREA MemoryArea
,
950 MmWritePageVirtualMemory(
951 PMMSUPPORT AddressSpace
,
957 /* kmap.c ********************************************************************/
961 ExAllocatePage(VOID
);
965 ExUnmapPage(PVOID Addr
);
969 ExAllocatePageWithPhysPage(PFN_NUMBER Page
);
980 MiZeroPage(PFN_NUMBER Page
);
982 /* memsafe.s *****************************************************************/
986 MmSafeReadPtr(PVOID Source
);
988 /* pageop.c ******************************************************************/
992 MmReleasePageOp(PMM_PAGEOP PageOp
);
1000 PMM_SECTION_SEGMENT Segment
,
1012 PMM_SECTION_SEGMENT Segment
,
1018 MmInitializePageOp(VOID
);
1020 /* process.c *****************************************************************/
1024 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1028 MmDeleteKernelStack(PVOID Stack
,
1031 /* balace.c ******************************************************************/
1035 MmInitializeMemoryConsumer(
1037 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1042 MmInitializeBalancer(
1043 ULONG NrAvailablePages
,
1049 MmReleasePageMemoryConsumer(
1056 MmRequestPageMemoryConsumer(
1059 PPFN_NUMBER AllocatedPage
1064 MiInitBalancerThread(VOID
);
1068 MmRebalanceMemoryConsumers(VOID
);
1070 /* rmap.c **************************************************************/
1074 MmSetRmapListHeadPage(
1076 struct _MM_RMAP_ENTRY
* ListHead
1079 struct _MM_RMAP_ENTRY
*
1081 MmGetRmapListHeadPage(PFN_NUMBER Page
);
1087 struct _EPROCESS
*Process
,
1096 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1103 struct _EPROCESS
*Process
,
1109 MmInitializeRmapList(VOID
);
1113 MmSetCleanAllRmaps(PFN_NUMBER Page
);
1117 MmSetDirtyAllRmaps(PFN_NUMBER Page
);
1121 MmIsDirtyPageRmap(PFN_NUMBER Page
);
1125 MmPageOutPhysicalAddress(PFN_NUMBER Page
);
1127 /* freelist.c **********************************************************/
1131 MiGetPfnEntry(IN PFN_NUMBER Pfn
)
1134 extern RTL_BITMAP MiPfnBitMap
;
1136 /* Make sure the PFN number is valid */
1137 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1139 /* Make sure this page actually has a PFN entry */
1140 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, (ULONG
)Pfn
))) return NULL
;
1143 Page
= &MmPfnDatabase
[Pfn
];
1151 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1154 // This will return the Page Frame Number (PFN) from the MMPFN
1156 return Pfn1
- MmPfnDatabase
;
1161 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage
);
1165 MmGetLRUFirstUserPage(VOID
);
1169 MmInsertLRULastUserPage(PFN_NUMBER Page
);
1173 MmRemoveLRUUserPage(PFN_NUMBER Page
);
1177 MmLockPage(PFN_NUMBER Page
);
1181 MmUnlockPage(PFN_NUMBER Page
);
1185 MmGetLockCountPage(PFN_NUMBER Page
);
1189 MmInitializePageList(
1195 MmDumpArmPfnDatabase(
1196 IN BOOLEAN StatusOnly
1201 MmGetContinuousPages(
1202 ULONG NumberOfBytes
,
1203 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1204 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1205 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1215 /* hypermap.c *****************************************************************/
1217 extern PEPROCESS HyperProcess
;
1218 extern KIRQL HyperIrql
;
1222 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1228 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1234 MiMapPagesToZeroInHyperSpace(IN PMMPFN Pfn1
,
1235 IN PFN_NUMBER NumberOfPages
);
1239 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1240 IN PFN_NUMBER NumberOfPages
);
1243 // ReactOS Compatibility Layer
1247 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1249 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1250 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1253 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1255 /* i386/page.c *********************************************************/
1259 MmCreateVirtualMappingForKernel(
1268 MmCommitPagedPoolAddress(
1275 MmCreateVirtualMapping(
1276 struct _EPROCESS
* Process
,
1285 MmCreateVirtualMappingUnsafe(
1286 struct _EPROCESS
* Process
,
1296 struct _EPROCESS
* Process
,
1302 struct _EPROCESS
* Process
,
1310 struct _EPROCESS
* Process
,
1316 MmInitGlobalKernelPageDirectory(VOID
);
1320 MmDisableVirtualMapping(
1321 struct _EPROCESS
*Process
,
1329 MmEnableVirtualMapping(
1330 struct _EPROCESS
*Process
,
1336 MmRawDeleteVirtualMapping(PVOID Address
);
1341 MmGetPageFileMapping(
1342 struct _EPROCESS
*Process
,
1344 SWAPENTRY
* SwapEntry
);
1348 MmDeletePageFileMapping(
1349 struct _EPROCESS
*Process
,
1351 SWAPENTRY
* SwapEntry
1356 MmCreatePageFileMapping(
1357 struct _EPROCESS
*Process
,
1365 struct _EPROCESS
*Process
,
1371 MmTransferOwnershipPage(
1379 struct _EPROCESS
*Process
,
1391 MmAllocPagesSpecifyRange(
1393 PHYSICAL_ADDRESS LowestAddress
,
1394 PHYSICAL_ADDRESS HighestAddress
,
1395 ULONG NumberOfPages
,
1401 MmDereferencePage(PFN_NUMBER Page
);
1405 MmReferencePage(PFN_NUMBER Page
);
1409 MmGetReferenceCountPage(PFN_NUMBER Page
);
1413 MmIsPageInUse(PFN_NUMBER Page
);
1417 MmSetSavedSwapEntryPage(
1419 SWAPENTRY SavedSwapEntry
);
1423 MmGetSavedSwapEntryPage(PFN_NUMBER Page
);
1428 struct _EPROCESS
*Process
,
1434 MmCreatePageTable(PVOID PAddress
);
1439 struct _EPROCESS
*Process
,
1446 struct _EPROCESS
*Process
,
1452 MmCreateProcessAddressSpace(
1455 IN PULONG_PTR DirectoryTableBase
1460 MmInitializeHandBuiltProcess(
1461 IN PEPROCESS Process
,
1462 IN PULONG_PTR DirectoryTableBase
1468 MmInitializeHandBuiltProcess2(
1469 IN PEPROCESS Process
1474 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1478 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1482 MmDeleteVirtualMapping(
1483 struct _EPROCESS
*Process
,
1493 struct _EPROCESS
*Process
,
1499 MmMarkPageMapped(PFN_NUMBER Page
);
1503 MmMarkPageUnmapped(PFN_NUMBER Page
);
1508 struct _EPROCESS
*Process
,
1515 MiInitPageDirectoryMap(VOID
);
1519 MiGetUserPageDirectoryCount(VOID
);
1521 /* wset.c ********************************************************************/
1530 /* region.c ************************************************************/
1535 PMMSUPPORT AddressSpace
,
1537 PLIST_ENTRY RegionListHead
,
1542 PMM_ALTER_REGION_FUNC AlterFunc
1548 PLIST_ENTRY RegionListHead
,
1558 PLIST_ENTRY RegionListHead
,
1560 PVOID
* RegionBaseAddress
1563 /* section.c *****************************************************************/
1567 MmGetFileObjectForSection(
1572 MmGetFileNameForAddress(
1574 OUT PUNICODE_STRING ModuleName
1579 MmGetFileNameForSection(
1581 OUT POBJECT_NAME_INFORMATION
*ModuleName
1594 PMEMORY_AREA MemoryArea
,
1596 PMEMORY_BASIC_INFORMATION Info
,
1597 PSIZE_T ResultLength
1602 MmProtectSectionView(
1603 PMMSUPPORT AddressSpace
,
1604 PMEMORY_AREA MemoryArea
,
1613 MmWritePageSectionView(
1614 PMMSUPPORT AddressSpace
,
1622 MmInitSectionImplementation(VOID
);
1626 MmNotPresentFaultSectionView(
1627 PMMSUPPORT AddressSpace
,
1628 MEMORY_AREA
* MemoryArea
,
1635 MmPageOutSectionView(
1636 PMMSUPPORT AddressSpace
,
1637 PMEMORY_AREA MemoryArea
,
1639 struct _MM_PAGEOP
*PageOp
1644 MmCreatePhysicalMemorySection(VOID
);
1648 MmAccessFaultSectionView(
1649 PMMSUPPORT AddressSpace
,
1650 MEMORY_AREA
* MemoryArea
,
1657 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1659 /* mpw.c *********************************************************************/
1663 MmInitMpwThread(VOID
);
1667 MmInitBsmThread(VOID
);
1669 /* pager.c *******************************************************************/
1673 MiIsPagerThread(VOID
);
1677 MiStartPagerThread(VOID
);
1681 MiStopPagerThread(VOID
);
1685 MiQueryVirtualMemory(
1686 IN HANDLE ProcessHandle
,
1688 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1689 OUT PVOID VirtualMemoryInformation
,
1691 OUT PSIZE_T ResultLength
1694 /* sysldr.c ******************************************************************/
1698 MiReloadBootLoadedDrivers(
1699 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1704 MiInitializeLoadedModuleList(
1705 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1711 IN PUNICODE_STRING FileName
,
1712 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1713 IN PUNICODE_STRING LoadedName OPTIONAL
,
1715 OUT PVOID
*ModuleObject
,
1716 OUT PVOID
*ImageBaseAddress
1721 MmUnloadSystemImage(
1722 IN PVOID ImageHandle
1728 IN HANDLE ImageHandle
,
1729 IN BOOLEAN PurgeSection
1734 MmCallDllInitialize(
1735 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1736 IN PLIST_ENTRY ListHead
1740 /* procsup.c *****************************************************************/
1745 IN PVOID StackPointer
1751 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1753 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1758 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1760 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1765 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1767 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1768 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1773 MmGetCurrentAddressSpace(VOID
)
1775 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1780 MmGetKernelAddressSpace(VOID
)
1782 return MmKernelAddressSpace
;