3 #include <internal/arch/mm.h>
5 /* TYPES *********************************************************************/
9 extern PMMSUPPORT MmKernelAddressSpace
;
10 extern PFN_COUNT MiFreeSwapPages
;
11 extern PFN_COUNT MiUsedSwapPages
;
12 extern SIZE_T MmTotalPagedPoolQuota
;
13 extern SIZE_T MmTotalNonPagedPoolQuota
;
14 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress
;
15 extern PFN_COUNT 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_PTR 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_CACHE (2)
78 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
79 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
80 #define MEMORY_AREA_STATIC (0x80000000)
82 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
84 #define MM_CORE_DUMP_TYPE_NONE (0x0)
85 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
86 #define MM_CORE_DUMP_TYPE_FULL (0x2)
88 #define MM_PAGEOP_PAGEIN (1)
89 #define MM_PAGEOP_PAGEOUT (2)
90 #define MM_PAGEOP_PAGESYNCH (3)
91 #define MM_PAGEOP_ACCESSFAULT (4)
92 #define MM_PAGEOP_CHANGEPROTECT (5)
94 /* Number of list heads to use */
95 #define MI_FREE_POOL_LISTS 4
98 /* Signature of free pool blocks */
99 #define MM_FREE_POOL_TAG 'lprF'
101 /* Although Microsoft says this isn't hardcoded anymore,
102 they won't be able to change it. Stuff depends on it */
103 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
105 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
108 * Additional flags for protection attributes
110 #define PAGE_WRITETHROUGH (1024)
111 #define PAGE_SYSTEM (2048)
113 #define SEC_PHYSICALMEMORY (0x80000000)
115 #define MM_PAGEFILE_SEGMENT (0x1)
116 #define MM_DATAFILE_SEGMENT (0x2)
120 #define MC_SYSTEM (2)
121 #define MC_MAXIMUM (3)
123 #define PAGED_POOL_MASK 1
124 #define MUST_SUCCEED_POOL_MASK 2
125 #define CACHE_ALIGNED_POOL_MASK 4
126 #define QUOTA_POOL_MASK 8
127 #define SESSION_POOL_MASK 32
128 #define VERIFIER_POOL_MASK 64
130 #define MM_PAGED_POOL_SIZE (100*1024*1024)
131 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
134 * Paged and non-paged pools are 8-byte aligned
136 #define MM_POOL_ALIGNMENT 8
138 #define MM_ROUND_UP(x,s) \
139 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
141 #define MM_ROUND_DOWN(x,s) \
142 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
144 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
149 PAGE_EXECUTE_READ | \
150 PAGE_EXECUTE_READWRITE | \
151 PAGE_EXECUTE_WRITECOPY | \
156 #define PAGE_FLAGS_VALID_FOR_SECTION \
161 PAGE_EXECUTE_READ | \
162 PAGE_EXECUTE_READWRITE | \
163 PAGE_EXECUTE_WRITECOPY | \
166 #define PAGE_IS_READABLE \
170 PAGE_EXECUTE_READ | \
171 PAGE_EXECUTE_READWRITE | \
172 PAGE_EXECUTE_WRITECOPY)
174 #define PAGE_IS_WRITABLE \
177 PAGE_EXECUTE_READWRITE | \
178 PAGE_EXECUTE_WRITECOPY)
180 #define PAGE_IS_EXECUTABLE \
182 PAGE_EXECUTE_READ | \
183 PAGE_EXECUTE_READWRITE | \
184 PAGE_EXECUTE_WRITECOPY)
186 #define PAGE_IS_WRITECOPY \
188 PAGE_EXECUTE_WRITECOPY)
191 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
192 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
194 #define InterlockedExchangePte(PointerPte, Value) \
195 InterlockedExchange((PLONG)(PointerPte), Value)
197 typedef struct _MM_SECTION_SEGMENT
199 FAST_MUTEX Lock
; /* lock which protects the page directory */
200 PFILE_OBJECT FileObject
;
201 LARGE_INTEGER RawLength
; /* length of the segment which is part of the mapped file */
202 LARGE_INTEGER Length
; /* absolute length of the segment */
203 ULONG ReferenceCount
;
212 LONG FileOffset
; /* start offset into the file for image sections */
213 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
214 ULONG Characteristics
;
217 LIST_ENTRY ListOfSegments
;
218 RTL_GENERIC_TABLE PageTable
;
219 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
221 typedef struct _MM_IMAGE_SECTION_OBJECT
224 ULONG_PTR StackReserve
;
225 ULONG_PTR StackCommit
;
226 ULONG_PTR EntryPoint
;
228 USHORT ImageCharacteristics
;
229 USHORT MinorSubsystemVersion
;
230 USHORT MajorSubsystemVersion
;
235 PMM_SECTION_SEGMENT Segments
;
236 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
238 typedef struct _ROS_SECTION_OBJECT
242 LARGE_INTEGER MaximumSize
;
243 ULONG SectionPageProtection
;
244 ULONG AllocationAttributes
;
245 PFILE_OBJECT FileObject
;
248 PMM_IMAGE_SECTION_OBJECT ImageSection
;
249 PMM_SECTION_SEGMENT Segment
;
251 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
253 typedef struct _MEMORY_AREA
255 PVOID StartingAddress
;
257 struct _MEMORY_AREA
*Parent
;
258 struct _MEMORY_AREA
*LeftChild
;
259 struct _MEMORY_AREA
*RightChild
;
263 BOOLEAN DeleteInProgress
;
270 ROS_SECTION_OBJECT
* Section
;
271 LARGE_INTEGER ViewOffset
;
272 PMM_SECTION_SEGMENT Segment
;
273 LIST_ENTRY RegionListHead
;
277 LIST_ENTRY RegionListHead
;
280 } MEMORY_AREA
, *PMEMORY_AREA
;
282 typedef struct _MM_RMAP_ENTRY
284 struct _MM_RMAP_ENTRY
* Next
;
291 MM_RMAP_ENTRY
, *PMM_RMAP_ENTRY
;
294 extern ULONG MI_PFN_CURRENT_USAGE
;
295 extern CHAR MI_PFN_CURRENT_PROCESS_NAME
[16];
296 #define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x
297 #define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, 16)
299 #define MI_SET_USAGE(x)
300 #define MI_SET_PROCESS2(x)
303 typedef enum _MI_PFN_USAGES
305 MI_USAGE_NOT_SET
= 0,
307 MI_USAGE_NONPAGED_POOL
,
308 MI_USAGE_NONPAGED_POOL_EXPANSION
,
309 MI_USAGE_KERNEL_STACK
,
310 MI_USAGE_KERNEL_STACK_EXPANSION
,
316 MI_USAGE_PAGE_DIRECTORY
,
317 MI_USAGE_LEGACY_PAGE_DIRECTORY
,
318 MI_USAGE_DRIVER_PAGE
,
319 MI_USAGE_CONTINOUS_ALLOCATION
,
321 MI_USAGE_DEMAND_ZERO
,
324 MI_USAGE_PFN_DATABASE
,
325 MI_USAGE_BOOT_DRIVER
,
326 MI_USAGE_INIT_MEMORY
,
331 // These two mappings are actually used by Windows itself, based on the ASSERTS
333 #define StartOfAllocation ReadInProgress
334 #define EndOfAllocation WriteInProgress
336 typedef struct _MMPFNENTRY
339 USHORT ReadInProgress
:1; // StartOfAllocation
340 USHORT WriteInProgress
:1; // EndOfAllocation
341 USHORT PrototypePte
:1;
343 USHORT PageLocation
:3;
344 USHORT RemovalRequested
:1;
345 USHORT CacheAttribute
:2;
347 USHORT ParityError
:1; // HasRmap
350 typedef struct _MMPFN
355 ULONG WsIndex
; // SavedSwapEntry
358 SINGLE_LIST_ENTRY NextStackPfn
;
364 ULONG_PTR ShareCount
;
370 USHORT ReferenceCount
; // ReferenceCount
375 USHORT ReferenceCount
;
382 LONG AweReferenceCount
; // RmapListHead
386 ULONG_PTR EntireFrame
;
389 ULONG_PTR PteFrame
:25;
390 ULONG_PTR InPageError
:1;
391 ULONG_PTR VerifierAllocation
:1;
392 ULONG_PTR AweAllocation
:1;
393 ULONG_PTR Priority
:3;
394 ULONG_PTR MustBeCached
:1;
398 MI_PFN_USAGES PfnUsage
;
399 CHAR ProcessName
[16];
403 extern PMMPFN MmPfnDatabase
;
405 typedef struct _MMPFNLIST
411 } MMPFNLIST
, *PMMPFNLIST
;
413 extern MMPFNLIST MmZeroedPageListHead
;
414 extern MMPFNLIST MmFreePageListHead
;
415 extern MMPFNLIST MmStandbyPageListHead
;
416 extern MMPFNLIST MmModifiedPageListHead
;
417 extern MMPFNLIST MmModifiedNoWritePageListHead
;
419 typedef struct _MM_PAGEOP
421 /* Type of operation. */
423 /* Number of threads interested in this operation. */
424 ULONG ReferenceCount
;
425 /* Event that will be set when the operation is completed. */
426 KEVENT CompletionEvent
;
427 /* Status of the operation once it is completed. */
429 /* TRUE if the operation was abandoned. */
431 /* The memory area to be affected by the operation. */
434 struct _MM_PAGEOP
* Next
;
435 struct _ETHREAD
* Thread
;
437 * These fields are used to identify the operation if it is against a
438 * virtual memory area.
443 * These fields are used to identify the operation if it is against a
446 PMM_SECTION_SEGMENT Segment
;
448 } MM_PAGEOP
, *PMM_PAGEOP
;
450 typedef struct _MM_MEMORY_CONSUMER
454 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
455 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
457 typedef struct _MM_REGION
462 LIST_ENTRY RegionListEntry
;
463 } MM_REGION
, *PMM_REGION
;
465 /* Entry describing free pool memory */
466 typedef struct _MMFREE_POOL_ENTRY
471 struct _MMFREE_POOL_ENTRY
*Owner
;
472 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
474 /* Signature of a freed block */
475 #define MM_FREE_POOL_SIGNATURE 'ARM3'
477 /* Paged pool information */
478 typedef struct _MM_PAGED_POOL_INFO
480 PRTL_BITMAP PagedPoolAllocationMap
;
481 PRTL_BITMAP EndOfPagedPoolBitmap
;
482 PMMPTE FirstPteForPagedPool
;
483 PMMPTE LastPteForPagedPool
;
484 PMMPDE NextPdeForPagedPoolExpansion
;
486 SIZE_T PagedPoolCommit
;
487 SIZE_T AllocatedPagedPool
;
488 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
490 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
493 (*PMM_ALTER_REGION_FUNC
)(
494 PMMSUPPORT AddressSpace
,
504 (*PMM_FREE_PAGE_FUNC
)(
506 PMEMORY_AREA MemoryArea
,
514 // Mm copy support for Kd
526 // Determines if a given address is a session address
534 /* marea.c *******************************************************************/
539 PMMSUPPORT AddressSpace
,
544 PMEMORY_AREA
*Result
,
545 BOOLEAN FixedAddress
,
546 ULONG AllocationFlags
,
547 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
552 MmLocateMemoryAreaByAddress(
553 PMMSUPPORT AddressSpace
,
560 PMMSUPPORT AddressSpace
,
567 PMMSUPPORT AddressSpace
,
568 PMEMORY_AREA MemoryArea
,
569 PMM_FREE_PAGE_FUNC FreePage
,
570 PVOID FreePageContext
575 MmFreeMemoryAreaByPtr(
576 PMMSUPPORT AddressSpace
,
578 PMM_FREE_PAGE_FUNC FreePage
,
579 PVOID FreePageContext
584 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
588 MmLocateMemoryAreaByRegion(
589 PMMSUPPORT AddressSpace
,
597 PMMSUPPORT AddressSpace
,
599 ULONG_PTR Granularity
,
605 MmReleaseMemoryAreaIfDecommitted(
606 struct _EPROCESS
*Process
,
607 PMMSUPPORT AddressSpace
,
613 MmMapMemoryArea(PVOID BaseAddress
,
618 /* npool.c *******************************************************************/
622 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
626 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
630 MiInitializeNonPagedPool(VOID
);
635 IN POOL_TYPE PoolType
,
636 IN SIZE_T SizeInBytes
642 IN PVOID VirtualAddress
648 IN PVOID StartingAddress
658 /* pool.c *******************************************************************/
662 ExAllocateNonPagedPoolWithTag(
671 ExAllocatePagedPoolWithTag(
679 ExFreeNonPagedPool(PVOID block
);
683 ExFreePagedPool(IN PVOID Block
);
687 ExpIsPoolTagDebuggable(ULONG Tag
);
691 ExpAllocateDebugPool(
701 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
705 MmInitializePagedPool(VOID
);
709 MiAllocateSpecialPool(
710 IN POOL_TYPE PoolType
,
711 IN SIZE_T NumberOfBytes
,
719 IN POOL_TYPE PoolType
,
720 IN ULONG CurrentMaxQuota
,
721 OUT PULONG NewMaxQuota
724 /* mdl.c *********************************************************************/
733 /* mminit.c ******************************************************************/
737 MiShutdownMemoryManager(VOID
);
747 MmInitSystem(IN ULONG Phase
,
748 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
752 MiFreeInitMemory(VOID
);
756 MmInitializeMdlImplementation(VOID
);
758 /* pagefile.c ****************************************************************/
762 MmAllocSwapPage(VOID
);
766 MmDereserveSwapPages(ULONG Nr
);
770 MmFreeSwapPage(SWAPENTRY Entry
);
774 MmInitPagingFile(VOID
);
778 MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject
);
789 MmReserveSwapPages(ULONG Nr
);
802 ULONG BugCodeParameter1
,
803 ULONG BugCodeParameter2
,
804 ULONG BugCodeParameter3
,
805 ULONG BugCodeParameter4
,
806 struct _KTRAP_FRAME
* TrapFrame
811 MmIsAvailableSwapPage(VOID
);
815 MmShowOutOfSpaceMessagePagingFile(VOID
);
817 /* process.c ****************************************************************/
821 MmInitializeProcessAddressSpace(
822 IN PEPROCESS Process
,
823 IN PEPROCESS Clone OPTIONAL
,
824 IN PVOID Section OPTIONAL
,
826 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
832 IN PEPROCESS Process
,
833 IN PINITIAL_PEB InitialPeb
,
840 IN PEPROCESS Process
,
841 IN PCLIENT_ID ClientId
,
842 IN PINITIAL_TEB InitialTeb
,
849 struct _EPROCESS
*Process
,
855 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
859 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
863 MmGetSessionLocaleId(VOID
);
867 MmSetMemoryPriorityProcess(
868 IN PEPROCESS Process
,
869 IN UCHAR MemoryPriority
872 /* i386/pfault.c *************************************************************/
884 /* special.c *****************************************************************/
888 MiInitializeSpecialPool();
893 IN SIZE_T NumberOfBytes
,
898 MmIsSpecialPoolAddress(
903 MmAllocateSpecialPool(
904 IN SIZE_T NumberOfBytes
,
906 IN POOL_TYPE PoolType
,
907 IN ULONG SpecialType
);
914 /* mm.c **********************************************************************/
919 IN BOOLEAN StoreInstruction
,
921 IN KPROCESSOR_MODE Mode
,
922 IN PVOID TrapInformation
925 /* anonmem.c *****************************************************************/
929 MmNotPresentFaultVirtualMemory(
930 PMMSUPPORT AddressSpace
,
931 MEMORY_AREA
* MemoryArea
,
937 MmPageOutVirtualMemory(
938 PMMSUPPORT AddressSpace
,
939 PMEMORY_AREA MemoryArea
,
941 struct _MM_PAGEOP
* PageOp
947 PMEMORY_AREA MemoryArea
,
949 PMEMORY_BASIC_INFORMATION Info
,
956 struct _EPROCESS
* Process
,
957 PMEMORY_AREA MemoryArea
963 PMMSUPPORT AddressSpace
,
964 PMEMORY_AREA MemoryArea
,
973 MmWritePageVirtualMemory(
974 PMMSUPPORT AddressSpace
,
980 /* kmap.c ********************************************************************/
984 ExAllocatePage(VOID
);
988 ExUnmapPage(PVOID Addr
);
992 ExAllocatePageWithPhysPage(PFN_NUMBER Page
);
1003 MiZeroPage(PFN_NUMBER Page
);
1005 /* memsafe.s *****************************************************************/
1009 MmSafeReadPtr(PVOID Source
);
1011 /* pageop.c ******************************************************************/
1015 MmReleasePageOp(PMM_PAGEOP PageOp
);
1023 PMM_SECTION_SEGMENT Segment
,
1035 PMM_SECTION_SEGMENT Segment
,
1041 MmInitializePageOp(VOID
);
1043 /* process.c *****************************************************************/
1047 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1051 MmDeleteKernelStack(PVOID Stack
,
1054 /* balace.c ******************************************************************/
1058 MmInitializeMemoryConsumer(
1060 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1065 MmInitializeBalancer(
1066 ULONG NrAvailablePages
,
1072 MmReleasePageMemoryConsumer(
1079 MmRequestPageMemoryConsumer(
1082 PPFN_NUMBER AllocatedPage
1087 MiInitBalancerThread(VOID
);
1091 MmRebalanceMemoryConsumers(VOID
);
1093 /* rmap.c **************************************************************/
1097 MmSetRmapListHeadPage(
1099 struct _MM_RMAP_ENTRY
* ListHead
1102 struct _MM_RMAP_ENTRY
*
1104 MmGetRmapListHeadPage(PFN_NUMBER Page
);
1110 struct _EPROCESS
*Process
,
1119 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1126 struct _EPROCESS
*Process
,
1132 MmInitializeRmapList(VOID
);
1136 MmSetCleanAllRmaps(PFN_NUMBER Page
);
1140 MmSetDirtyAllRmaps(PFN_NUMBER Page
);
1144 MmIsDirtyPageRmap(PFN_NUMBER Page
);
1148 MmPageOutPhysicalAddress(PFN_NUMBER Page
);
1150 /* freelist.c **********************************************************/
1154 MiGetPfnEntry(IN PFN_NUMBER Pfn
)
1157 extern RTL_BITMAP MiPfnBitMap
;
1159 /* Make sure the PFN number is valid */
1160 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1162 /* Make sure this page actually has a PFN entry */
1163 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, (ULONG
)Pfn
))) return NULL
;
1166 Page
= &MmPfnDatabase
[Pfn
];
1174 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1177 // This will return the Page Frame Number (PFN) from the MMPFN
1179 return Pfn1
- MmPfnDatabase
;
1184 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage
);
1188 MmGetLRUFirstUserPage(VOID
);
1192 MmInsertLRULastUserPage(PFN_NUMBER Page
);
1196 MmRemoveLRUUserPage(PFN_NUMBER Page
);
1200 MmLockPage(PFN_NUMBER Page
);
1204 MmUnlockPage(PFN_NUMBER Page
);
1208 MmGetLockCountPage(PFN_NUMBER Page
);
1212 MmInitializePageList(
1218 MmDumpArmPfnDatabase(
1219 IN BOOLEAN StatusOnly
1224 MmGetContinuousPages(
1225 ULONG NumberOfBytes
,
1226 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1227 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1228 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1238 /* hypermap.c *****************************************************************/
1240 extern PEPROCESS HyperProcess
;
1241 extern KIRQL HyperIrql
;
1245 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1251 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1257 MiMapPagesInZeroSpace(IN PMMPFN Pfn1
,
1258 IN PFN_NUMBER NumberOfPages
);
1262 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1263 IN PFN_NUMBER NumberOfPages
);
1266 // ReactOS Compatibility Layer
1270 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1272 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1273 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1276 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1278 /* i386/page.c *********************************************************/
1282 MmCreateVirtualMappingForKernel(
1291 MmCommitPagedPoolAddress(
1298 MmCreateVirtualMapping(
1299 struct _EPROCESS
* Process
,
1308 MmCreateVirtualMappingUnsafe(
1309 struct _EPROCESS
* Process
,
1319 struct _EPROCESS
* Process
,
1325 struct _EPROCESS
* Process
,
1333 struct _EPROCESS
* Process
,
1339 MmInitGlobalKernelPageDirectory(VOID
);
1343 MmDisableVirtualMapping(
1344 struct _EPROCESS
*Process
,
1352 MmEnableVirtualMapping(
1353 struct _EPROCESS
*Process
,
1359 MmRawDeleteVirtualMapping(PVOID Address
);
1364 MmGetPageFileMapping(
1365 struct _EPROCESS
*Process
,
1367 SWAPENTRY
* SwapEntry
);
1371 MmDeletePageFileMapping(
1372 struct _EPROCESS
*Process
,
1374 SWAPENTRY
* SwapEntry
1379 MmCreatePageFileMapping(
1380 struct _EPROCESS
*Process
,
1388 struct _EPROCESS
*Process
,
1394 MmTransferOwnershipPage(
1402 struct _EPROCESS
*Process
,
1414 MmAllocPagesSpecifyRange(
1416 PHYSICAL_ADDRESS LowestAddress
,
1417 PHYSICAL_ADDRESS HighestAddress
,
1418 ULONG NumberOfPages
,
1424 MmDereferencePage(PFN_NUMBER Page
);
1428 MmReferencePage(PFN_NUMBER Page
);
1432 MmGetReferenceCountPage(PFN_NUMBER Page
);
1436 MmIsPageInUse(PFN_NUMBER Page
);
1440 MmSetSavedSwapEntryPage(
1442 SWAPENTRY SavedSwapEntry
);
1446 MmGetSavedSwapEntryPage(PFN_NUMBER Page
);
1451 struct _EPROCESS
*Process
,
1457 MmCreatePageTable(PVOID PAddress
);
1462 struct _EPROCESS
*Process
,
1469 struct _EPROCESS
*Process
,
1475 MmCreateProcessAddressSpace(
1478 IN PULONG_PTR DirectoryTableBase
1483 MmInitializeHandBuiltProcess(
1484 IN PEPROCESS Process
,
1485 IN PULONG_PTR DirectoryTableBase
1491 MmInitializeHandBuiltProcess2(
1492 IN PEPROCESS Process
1497 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1501 MmSetExecuteOptions(IN ULONG ExecuteOptions
);
1505 MmGetExecuteOptions(IN PULONG ExecuteOptions
);
1509 MmDeleteProcessPageDirectory(struct _EPROCESS
*Process
);
1513 MmDeleteVirtualMapping(
1514 struct _EPROCESS
*Process
,
1524 struct _EPROCESS
*Process
,
1530 MmMarkPageMapped(PFN_NUMBER Page
);
1534 MmMarkPageUnmapped(PFN_NUMBER Page
);
1539 struct _EPROCESS
*Process
,
1546 MiInitPageDirectoryMap(VOID
);
1550 MiGetUserPageDirectoryCount(VOID
);
1552 /* wset.c ********************************************************************/
1561 /* region.c ************************************************************/
1566 PMMSUPPORT AddressSpace
,
1568 PLIST_ENTRY RegionListHead
,
1573 PMM_ALTER_REGION_FUNC AlterFunc
1579 PLIST_ENTRY RegionListHead
,
1589 PLIST_ENTRY RegionListHead
,
1591 PVOID
* RegionBaseAddress
1594 /* section.c *****************************************************************/
1598 MmGetFileObjectForSection(
1603 MmGetFileNameForAddress(
1605 OUT PUNICODE_STRING ModuleName
1610 MmGetFileNameForSection(
1612 OUT POBJECT_NAME_INFORMATION
*ModuleName
1625 PMEMORY_AREA MemoryArea
,
1627 PMEMORY_BASIC_INFORMATION Info
,
1628 PSIZE_T ResultLength
1633 MmProtectSectionView(
1634 PMMSUPPORT AddressSpace
,
1635 PMEMORY_AREA MemoryArea
,
1644 MmInitSectionImplementation(VOID
);
1648 MmNotPresentFaultSectionView(
1649 PMMSUPPORT AddressSpace
,
1650 MEMORY_AREA
* MemoryArea
,
1657 MmPageOutSectionView(
1658 PMMSUPPORT AddressSpace
,
1659 PMEMORY_AREA MemoryArea
,
1661 struct _MM_PAGEOP
*PageOp
1666 MmCreatePhysicalMemorySection(VOID
);
1670 MmAccessFaultSectionView(
1671 PMMSUPPORT AddressSpace
,
1672 MEMORY_AREA
* MemoryArea
,
1678 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1680 /* mpw.c *********************************************************************/
1684 MmInitMpwThread(VOID
);
1688 MmInitBsmThread(VOID
);
1690 /* pager.c *******************************************************************/
1694 MiIsPagerThread(VOID
);
1698 MiStartPagerThread(VOID
);
1702 MiStopPagerThread(VOID
);
1706 MiQueryVirtualMemory(
1707 IN HANDLE ProcessHandle
,
1709 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1710 OUT PVOID VirtualMemoryInformation
,
1712 OUT PSIZE_T ResultLength
1715 /* sysldr.c ******************************************************************/
1719 MiReloadBootLoadedDrivers(
1720 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1725 MiInitializeLoadedModuleList(
1726 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1732 IN PUNICODE_STRING FileName
,
1733 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1734 IN PUNICODE_STRING LoadedName OPTIONAL
,
1736 OUT PVOID
*ModuleObject
,
1737 OUT PVOID
*ImageBaseAddress
1742 MmUnloadSystemImage(
1743 IN PVOID ImageHandle
1749 IN HANDLE ImageHandle
,
1750 IN BOOLEAN PurgeSection
1755 MmCallDllInitialize(
1756 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1757 IN PLIST_ENTRY ListHead
1761 /* procsup.c *****************************************************************/
1766 IN PVOID StackPointer
1772 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1774 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1779 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1781 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1786 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1788 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1789 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1794 MmGetCurrentAddressSpace(VOID
)
1796 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1801 MmGetKernelAddressSpace(VOID
)
1803 return MmKernelAddressSpace
;