3 #include <internal/arch/mm.h>
5 /* TYPES *********************************************************************/
9 extern PFN_NUMBER MiFreeSwapPages
;
10 extern PFN_NUMBER MiUsedSwapPages
;
11 extern SIZE_T MmTotalPagedPoolQuota
;
12 extern SIZE_T MmTotalNonPagedPoolQuota
;
13 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress
;
14 extern PFN_NUMBER MmNumberOfPhysicalPages
;
15 extern UCHAR MmDisablePagingExecutive
;
16 extern PFN_NUMBER MmLowestPhysicalPage
;
17 extern PFN_NUMBER MmHighestPhysicalPage
;
18 extern PFN_NUMBER MmAvailablePages
;
19 extern PFN_NUMBER MmResidentAvailablePages
;
21 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
22 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
24 extern LIST_ENTRY MmLoadedUserImageList
;
26 extern KMUTANT MmSystemLoadLock
;
28 extern ULONG MmNumberOfPagingFiles
;
30 extern PVOID MmUnloadedDrivers
;
31 extern PVOID MmLastUnloadedDrivers
;
32 extern PVOID MmTriageActionTaken
;
33 extern PVOID KernelVerifier
;
34 extern MM_DRIVER_VERIFIER_DATA MmVerifierData
;
36 extern SIZE_T MmTotalCommitLimit
;
37 extern SIZE_T MmTotalCommittedPages
;
38 extern SIZE_T MmSharedCommit
;
39 extern SIZE_T MmDriverCommit
;
40 extern SIZE_T MmProcessCommit
;
41 extern SIZE_T MmPagedPoolCommit
;
42 extern SIZE_T MmPeakCommitment
;
43 extern SIZE_T MmtotalCommitLimitMaximum
;
45 extern PVOID MiDebugMapping
;
46 extern PMMPTE MmDebugPte
;
50 struct _MM_RMAP_ENTRY
;
52 typedef ULONG SWAPENTRY
;
55 // MmDbgCopyMemory Flags
57 #define MMDBG_COPY_WRITE 0x00000001
58 #define MMDBG_COPY_PHYSICAL 0x00000002
59 #define MMDBG_COPY_UNSAFE 0x00000004
60 #define MMDBG_COPY_CACHED 0x00000008
61 #define MMDBG_COPY_UNCACHED 0x00000010
62 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
65 // Maximum chunk size per copy
67 #define MMDBG_COPY_MAX_SIZE 0x8
70 #define MI_STATIC_MEMORY_AREAS (14)
72 #define MI_STATIC_MEMORY_AREAS (13)
75 #define MEMORY_AREA_SECTION_VIEW (1)
76 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
77 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
78 #define MEMORY_AREA_STATIC (0x80000000)
80 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
82 #define MM_CORE_DUMP_TYPE_NONE (0x0)
83 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
84 #define MM_CORE_DUMP_TYPE_FULL (0x2)
86 #define MM_PAGEOP_PAGEIN (1)
87 #define MM_PAGEOP_PAGEOUT (2)
88 #define MM_PAGEOP_PAGESYNCH (3)
89 #define MM_PAGEOP_ACCESSFAULT (4)
91 /* Number of list heads to use */
92 #define MI_FREE_POOL_LISTS 4
95 /* Signature of free pool blocks */
96 #define MM_FREE_POOL_TAG 'lprF'
98 /* Although Microsoft says this isn't hardcoded anymore,
99 they won't be able to change it. Stuff depends on it */
100 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
102 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
105 * Additional flags for protection attributes
107 #define PAGE_WRITETHROUGH (1024)
108 #define PAGE_SYSTEM (2048)
110 #define SEC_PHYSICALMEMORY (0x80000000)
112 #define MM_PAGEFILE_SEGMENT (0x1)
113 #define MM_DATAFILE_SEGMENT (0x2)
117 #define MC_SYSTEM (2)
118 #define MC_MAXIMUM (3)
120 #define PAGED_POOL_MASK 1
121 #define MUST_SUCCEED_POOL_MASK 2
122 #define CACHE_ALIGNED_POOL_MASK 4
123 #define QUOTA_POOL_MASK 8
124 #define SESSION_POOL_MASK 32
125 #define VERIFIER_POOL_MASK 64
127 #define MM_PAGED_POOL_SIZE (100*1024*1024)
128 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
131 * Paged and non-paged pools are 8-byte aligned
133 #define MM_POOL_ALIGNMENT 8
135 #define MM_ROUND_UP(x,s) \
136 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
138 #define MM_ROUND_DOWN(x,s) \
139 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
141 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
146 PAGE_EXECUTE_READ | \
147 PAGE_EXECUTE_READWRITE | \
148 PAGE_EXECUTE_WRITECOPY | \
153 #define PAGE_FLAGS_VALID_FOR_SECTION \
158 PAGE_EXECUTE_READ | \
159 PAGE_EXECUTE_READWRITE | \
160 PAGE_EXECUTE_WRITECOPY | \
163 #define PAGE_IS_READABLE \
167 PAGE_EXECUTE_READ | \
168 PAGE_EXECUTE_READWRITE | \
169 PAGE_EXECUTE_WRITECOPY)
171 #define PAGE_IS_WRITABLE \
174 PAGE_EXECUTE_READWRITE | \
175 PAGE_EXECUTE_WRITECOPY)
177 #define PAGE_IS_EXECUTABLE \
179 PAGE_EXECUTE_READ | \
180 PAGE_EXECUTE_READWRITE | \
181 PAGE_EXECUTE_WRITECOPY)
183 #define PAGE_IS_WRITECOPY \
185 PAGE_EXECUTE_WRITECOPY)
188 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
189 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
191 #define InterlockedExchangePte(PointerPte, Value) \
192 InterlockedExchange((PLONG)(PointerPte), Value)
196 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
197 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
201 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
202 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
204 typedef struct _MM_SECTION_SEGMENT
206 LONG FileOffset
; /* start offset into the file for image sections */
207 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
208 ULONG RawLength
; /* length of the segment which is part of the mapped file */
209 ULONG Length
; /* absolute length of the segment */
211 FAST_MUTEX Lock
; /* lock which protects the page directory */
212 ULONG ReferenceCount
;
213 SECTION_PAGE_DIRECTORY PageDirectory
;
215 ULONG Characteristics
;
217 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
219 typedef struct _MM_IMAGE_SECTION_OBJECT
222 ULONG_PTR StackReserve
;
223 ULONG_PTR StackCommit
;
224 ULONG_PTR EntryPoint
;
226 USHORT ImageCharacteristics
;
227 USHORT MinorSubsystemVersion
;
228 USHORT MajorSubsystemVersion
;
233 PMM_SECTION_SEGMENT Segments
;
234 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
236 typedef struct _ROS_SECTION_OBJECT
240 LARGE_INTEGER MaximumSize
;
241 ULONG SectionPageProtection
;
242 ULONG AllocationAttributes
;
243 PFILE_OBJECT FileObject
;
246 PMM_IMAGE_SECTION_OBJECT ImageSection
;
247 PMM_SECTION_SEGMENT Segment
;
249 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
251 struct _MM_CACHE_SECTION_SEGMENT
;
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
;
272 PMM_SECTION_SEGMENT Segment
;
273 LIST_ENTRY RegionListHead
;
277 LARGE_INTEGER ViewOffset
;
278 struct _MM_CACHE_SECTION_SEGMENT
*Segment
;
282 LIST_ENTRY RegionListHead
;
285 } MEMORY_AREA
, *PMEMORY_AREA
;
287 typedef struct _MM_RMAP_ENTRY
289 struct _MM_RMAP_ENTRY
* Next
;
296 MM_RMAP_ENTRY
, *PMM_RMAP_ENTRY
;
299 extern ULONG MI_PFN_CURRENT_USAGE
;
300 extern CHAR MI_PFN_CURRENT_PROCESS_NAME
[16];
301 #define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x
302 #define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, 16)
304 #define MI_SET_USAGE(x)
305 #define MI_SET_PROCESS2(x)
308 typedef enum _MI_PFN_USAGES
310 MI_USAGE_NOT_SET
= 0,
312 MI_USAGE_NONPAGED_POOL
,
313 MI_USAGE_NONPAGED_POOL_EXPANSION
,
314 MI_USAGE_KERNEL_STACK
,
315 MI_USAGE_KERNEL_STACK_EXPANSION
,
321 MI_USAGE_PAGE_DIRECTORY
,
322 MI_USAGE_LEGACY_PAGE_DIRECTORY
,
323 MI_USAGE_DRIVER_PAGE
,
324 MI_USAGE_CONTINOUS_ALLOCATION
,
326 MI_USAGE_DEMAND_ZERO
,
329 MI_USAGE_PFN_DATABASE
,
330 MI_USAGE_BOOT_DRIVER
,
331 MI_USAGE_INIT_MEMORY
,
336 // These two mappings are actually used by Windows itself, based on the ASSERTS
338 #define StartOfAllocation ReadInProgress
339 #define EndOfAllocation WriteInProgress
341 typedef struct _MMPFNENTRY
344 USHORT ReadInProgress
:1; // StartOfAllocation
345 USHORT WriteInProgress
:1; // EndOfAllocation
346 USHORT PrototypePte
:1;
348 USHORT PageLocation
:3;
349 USHORT RemovalRequested
:1;
350 USHORT CacheAttribute
:2;
352 USHORT ParityError
:1; // HasRmap
355 typedef struct _MMPFN
360 ULONG WsIndex
; // SavedSwapEntry
363 SINGLE_LIST_ENTRY NextStackPfn
;
369 ULONG_PTR ShareCount
;
375 USHORT ReferenceCount
; // ReferenceCount
380 USHORT ReferenceCount
;
387 LONG AweReferenceCount
; // RmapListHead
391 ULONG_PTR EntireFrame
;
394 ULONG_PTR PteFrame
:25;
395 ULONG_PTR InPageError
:1;
396 ULONG_PTR VerifierAllocation
:1;
397 ULONG_PTR AweAllocation
:1;
398 ULONG_PTR Priority
:3;
399 ULONG_PTR MustBeCached
:1;
403 MI_PFN_USAGES PfnUsage
;
404 CHAR ProcessName
[16];
408 extern PMMPFN MmPfnDatabase
;
410 typedef struct _MMPFNLIST
416 } MMPFNLIST
, *PMMPFNLIST
;
418 extern MMPFNLIST MmZeroedPageListHead
;
419 extern MMPFNLIST MmFreePageListHead
;
420 extern MMPFNLIST MmStandbyPageListHead
;
421 extern MMPFNLIST MmModifiedPageListHead
;
422 extern MMPFNLIST MmModifiedNoWritePageListHead
;
424 typedef struct _MM_PAGEOP
426 /* Type of operation. */
428 /* Number of threads interested in this operation. */
429 ULONG ReferenceCount
;
430 /* Event that will be set when the operation is completed. */
431 KEVENT CompletionEvent
;
432 /* Status of the operation once it is completed. */
434 /* TRUE if the operation was abandoned. */
436 /* The memory area to be affected by the operation. */
439 struct _MM_PAGEOP
* Next
;
440 struct _ETHREAD
* Thread
;
442 * These fields are used to identify the operation if it is against a
443 * virtual memory area.
448 * These fields are used to identify the operation if it is against a
451 PMM_SECTION_SEGMENT Segment
;
453 } MM_PAGEOP
, *PMM_PAGEOP
;
455 typedef struct _MM_MEMORY_CONSUMER
459 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
460 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
462 typedef struct _MM_REGION
467 LIST_ENTRY RegionListEntry
;
468 } MM_REGION
, *PMM_REGION
;
470 /* Entry describing free pool memory */
471 typedef struct _MMFREE_POOL_ENTRY
476 struct _MMFREE_POOL_ENTRY
*Owner
;
477 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
479 /* Signature of a freed block */
480 #define MM_FREE_POOL_SIGNATURE 'ARM3'
482 /* Paged pool information */
483 typedef struct _MM_PAGED_POOL_INFO
485 PRTL_BITMAP PagedPoolAllocationMap
;
486 PRTL_BITMAP EndOfPagedPoolBitmap
;
487 PMMPTE FirstPteForPagedPool
;
488 PMMPTE LastPteForPagedPool
;
489 PMMPDE NextPdeForPagedPoolExpansion
;
491 SIZE_T PagedPoolCommit
;
492 SIZE_T AllocatedPagedPool
;
493 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
495 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
498 (*PMM_ALTER_REGION_FUNC
)(
499 PMMSUPPORT AddressSpace
,
509 (*PMM_FREE_PAGE_FUNC
)(
511 PMEMORY_AREA MemoryArea
,
519 // Mm copy support for Kd
531 // Determines if a given address is a session address
539 /* marea.c *******************************************************************/
544 PMMSUPPORT AddressSpace
,
549 PMEMORY_AREA
*Result
,
550 BOOLEAN FixedAddress
,
551 ULONG AllocationFlags
,
552 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
557 MmLocateMemoryAreaByAddress(
558 PMMSUPPORT AddressSpace
,
565 PMMSUPPORT AddressSpace
,
572 PMMSUPPORT AddressSpace
,
573 PMEMORY_AREA MemoryArea
,
574 PMM_FREE_PAGE_FUNC FreePage
,
575 PVOID FreePageContext
580 MmFreeMemoryAreaByPtr(
581 PMMSUPPORT AddressSpace
,
583 PMM_FREE_PAGE_FUNC FreePage
,
584 PVOID FreePageContext
589 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
593 MmLocateMemoryAreaByRegion(
594 PMMSUPPORT AddressSpace
,
602 PMMSUPPORT AddressSpace
,
604 ULONG_PTR Granularity
,
610 MmReleaseMemoryAreaIfDecommitted(
611 struct _EPROCESS
*Process
,
612 PMMSUPPORT AddressSpace
,
618 MmMapMemoryArea(PVOID BaseAddress
,
623 /* npool.c *******************************************************************/
627 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
631 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
635 MiInitializeNonPagedPool(VOID
);
640 IN POOL_TYPE PoolType
,
641 IN SIZE_T SizeInBytes
647 IN PVOID VirtualAddress
653 IN PVOID StartingAddress
663 /* pool.c *******************************************************************/
667 ExAllocateNonPagedPoolWithTag(
676 ExAllocatePagedPoolWithTag(
684 ExFreeNonPagedPool(PVOID block
);
688 ExFreePagedPool(IN PVOID Block
);
692 ExpIsPoolTagDebuggable(ULONG Tag
);
696 ExpAllocateDebugPool(
706 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
710 MmInitializePagedPool(VOID
);
714 MiAllocateSpecialPool(
715 IN POOL_TYPE PoolType
,
716 IN SIZE_T NumberOfBytes
,
724 IN POOL_TYPE PoolType
,
725 IN ULONG CurrentMaxQuota
,
726 OUT PULONG NewMaxQuota
729 /* mdl.c *********************************************************************/
738 /* mminit.c ******************************************************************/
742 MiShutdownMemoryManager(VOID
);
752 MmInitSystem(IN ULONG Phase
,
753 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
757 MiFreeInitMemory(VOID
);
761 MmInitializeMdlImplementation(VOID
);
763 /* pagefile.c ****************************************************************/
767 MmAllocSwapPage(VOID
);
771 MmDereserveSwapPages(ULONG Nr
);
775 MmFreeSwapPage(SWAPENTRY Entry
);
779 MmInitPagingFile(VOID
);
783 MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject
);
794 MmReserveSwapPages(ULONG Nr
);
807 ULONG BugCodeParameter1
,
808 ULONG BugCodeParameter2
,
809 ULONG BugCodeParameter3
,
810 ULONG BugCodeParameter4
,
811 struct _KTRAP_FRAME
* TrapFrame
816 MmIsAvailableSwapPage(VOID
);
820 MmShowOutOfSpaceMessagePagingFile(VOID
);
822 /* process.c ****************************************************************/
826 MmInitializeProcessAddressSpace(
827 IN PEPROCESS Process
,
828 IN PEPROCESS Clone OPTIONAL
,
829 IN PVOID Section OPTIONAL
,
831 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
837 IN PEPROCESS Process
,
838 IN PINITIAL_PEB InitialPeb
,
845 IN PEPROCESS Process
,
846 IN PCLIENT_ID ClientId
,
847 IN PINITIAL_TEB InitialTeb
,
854 struct _EPROCESS
*Process
,
860 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
864 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
868 MmGetSessionLocaleId(VOID
);
872 MmSetMemoryPriorityProcess(
873 IN PEPROCESS Process
,
874 IN UCHAR MemoryPriority
877 /* i386/pfault.c *************************************************************/
889 /* mm.c **********************************************************************/
894 IN BOOLEAN StoreInstruction
,
896 IN KPROCESSOR_MODE Mode
,
897 IN PVOID TrapInformation
900 /* anonmem.c *****************************************************************/
904 MmNotPresentFaultVirtualMemory(
905 PMMSUPPORT AddressSpace
,
906 MEMORY_AREA
* MemoryArea
,
913 MmPageOutVirtualMemory(
914 PMMSUPPORT AddressSpace
,
915 PMEMORY_AREA MemoryArea
,
917 struct _MM_PAGEOP
* PageOp
923 PMEMORY_AREA MemoryArea
,
925 PMEMORY_BASIC_INFORMATION Info
,
932 struct _EPROCESS
* Process
,
933 PMEMORY_AREA MemoryArea
939 PMMSUPPORT AddressSpace
,
940 PMEMORY_AREA MemoryArea
,
949 MmWritePageVirtualMemory(
950 PMMSUPPORT AddressSpace
,
956 /* kmap.c ********************************************************************/
960 ExAllocatePage(VOID
);
964 ExUnmapPage(PVOID Addr
);
968 ExAllocatePageWithPhysPage(PFN_NUMBER Page
);
979 MiZeroPage(PFN_NUMBER Page
);
981 /* memsafe.s *****************************************************************/
985 MmSafeReadPtr(PVOID Source
);
987 /* pageop.c ******************************************************************/
991 MmReleasePageOp(PMM_PAGEOP PageOp
);
999 PMM_SECTION_SEGMENT Segment
,
1011 PMM_SECTION_SEGMENT Segment
,
1017 MmInitializePageOp(VOID
);
1019 /* process.c *****************************************************************/
1023 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1027 MmDeleteKernelStack(PVOID Stack
,
1030 /* balace.c ******************************************************************/
1034 MmInitializeMemoryConsumer(
1036 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1041 MmInitializeBalancer(
1042 ULONG NrAvailablePages
,
1048 MmReleasePageMemoryConsumer(
1055 MmRequestPageMemoryConsumer(
1058 PPFN_NUMBER AllocatedPage
1063 MiInitBalancerThread(VOID
);
1067 MmRebalanceMemoryConsumers(VOID
);
1069 /* rmap.c **************************************************************/
1073 MmSetRmapListHeadPage(
1075 struct _MM_RMAP_ENTRY
* ListHead
1078 struct _MM_RMAP_ENTRY
*
1080 MmGetRmapListHeadPage(PFN_NUMBER Page
);
1086 struct _EPROCESS
*Process
,
1095 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1102 struct _EPROCESS
*Process
,
1108 MmInitializeRmapList(VOID
);
1112 MmSetCleanAllRmaps(PFN_NUMBER Page
);
1116 MmSetDirtyAllRmaps(PFN_NUMBER Page
);
1120 MmIsDirtyPageRmap(PFN_NUMBER Page
);
1124 MmWritePagePhysicalAddress(PFN_NUMBER Page
);
1128 MmPageOutPhysicalAddress(PFN_NUMBER Page
);
1130 /* freelist.c **********************************************************/
1134 MiGetPfnEntry(IN PFN_NUMBER Pfn
)
1137 extern RTL_BITMAP MiPfnBitMap
;
1139 /* Make sure the PFN number is valid */
1140 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1142 /* Make sure this page actually has a PFN entry */
1143 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, (ULONG
)Pfn
))) return NULL
;
1146 Page
= &MmPfnDatabase
[Pfn
];
1154 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1157 // This will return the Page Frame Number (PFN) from the MMPFN
1159 return Pfn1
- MmPfnDatabase
;
1164 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage
);
1168 MmGetLRUFirstUserPage(VOID
);
1172 MmInsertLRULastUserPage(PFN_NUMBER Page
);
1176 MmRemoveLRUUserPage(PFN_NUMBER Page
);
1180 MmLockPage(PFN_NUMBER Page
);
1184 MmUnlockPage(PFN_NUMBER Page
);
1188 MmGetLockCountPage(PFN_NUMBER Page
);
1192 MmInitializePageList(
1198 MmDumpArmPfnDatabase(
1199 IN BOOLEAN StatusOnly
1204 MmGetContinuousPages(
1205 ULONG NumberOfBytes
,
1206 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1207 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1208 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1218 /* hypermap.c *****************************************************************/
1220 extern PEPROCESS HyperProcess
;
1221 extern KIRQL HyperIrql
;
1225 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1231 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1237 MiMapPagesToZeroInHyperSpace(IN PMMPFN Pfn1
,
1238 IN PFN_NUMBER NumberOfPages
);
1242 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1243 IN PFN_NUMBER NumberOfPages
);
1246 // ReactOS Compatibility Layer
1250 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1252 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1253 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1256 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1258 /* i386/page.c *********************************************************/
1262 MmCreateVirtualMappingForKernel(
1271 MmCommitPagedPoolAddress(
1278 MmCreateVirtualMapping(
1279 struct _EPROCESS
* Process
,
1288 MmCreateVirtualMappingUnsafe(
1289 struct _EPROCESS
* Process
,
1299 struct _EPROCESS
* Process
,
1305 struct _EPROCESS
* Process
,
1313 struct _EPROCESS
* Process
,
1319 MmInitGlobalKernelPageDirectory(VOID
);
1323 MmDisableVirtualMapping(
1324 struct _EPROCESS
*Process
,
1332 MmEnableVirtualMapping(
1333 struct _EPROCESS
*Process
,
1339 MmRawDeleteVirtualMapping(PVOID Address
);
1344 MmGetPageFileMapping(
1345 struct _EPROCESS
*Process
,
1347 SWAPENTRY
* SwapEntry
);
1351 MmDeletePageFileMapping(
1352 struct _EPROCESS
*Process
,
1354 SWAPENTRY
* SwapEntry
1359 MmCreatePageFileMapping(
1360 struct _EPROCESS
*Process
,
1368 struct _EPROCESS
*Process
,
1374 MmTransferOwnershipPage(
1382 struct _EPROCESS
*Process
,
1394 MmAllocPagesSpecifyRange(
1396 PHYSICAL_ADDRESS LowestAddress
,
1397 PHYSICAL_ADDRESS HighestAddress
,
1398 ULONG NumberOfPages
,
1404 MmDereferencePage(PFN_NUMBER Page
);
1408 MmReferencePage(PFN_NUMBER Page
);
1412 MmGetReferenceCountPage(PFN_NUMBER Page
);
1416 MmIsPageInUse(PFN_NUMBER Page
);
1420 MmSetSavedSwapEntryPage(
1422 SWAPENTRY SavedSwapEntry
);
1426 MmGetSavedSwapEntryPage(PFN_NUMBER Page
);
1431 struct _EPROCESS
*Process
,
1437 MmCreatePageTable(PVOID PAddress
);
1442 struct _EPROCESS
*Process
,
1449 struct _EPROCESS
*Process
,
1455 MmCreateProcessAddressSpace(
1458 IN PULONG_PTR DirectoryTableBase
1463 MmInitializeHandBuiltProcess(
1464 IN PEPROCESS Process
,
1465 IN PULONG_PTR DirectoryTableBase
1471 MmInitializeHandBuiltProcess2(
1472 IN PEPROCESS Process
1477 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1481 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1485 MmDeleteVirtualMapping(
1486 struct _EPROCESS
*Process
,
1496 struct _EPROCESS
*Process
,
1502 MmMarkPageMapped(PFN_NUMBER Page
);
1506 MmMarkPageUnmapped(PFN_NUMBER Page
);
1511 struct _EPROCESS
*Process
,
1518 MiInitPageDirectoryMap(VOID
);
1522 MiGetUserPageDirectoryCount(VOID
);
1524 /* wset.c ********************************************************************/
1533 /* region.c ************************************************************/
1538 PMMSUPPORT AddressSpace
,
1540 PLIST_ENTRY RegionListHead
,
1545 PMM_ALTER_REGION_FUNC AlterFunc
1551 PLIST_ENTRY RegionListHead
,
1561 PLIST_ENTRY RegionListHead
,
1563 PVOID
* RegionBaseAddress
1566 /* section.c *****************************************************************/
1570 MmGetFileObjectForSection(
1575 MmGetFileNameForAddress(
1577 OUT PUNICODE_STRING ModuleName
1582 MmGetFileNameForSection(
1584 OUT POBJECT_NAME_INFORMATION
*ModuleName
1597 PMEMORY_AREA MemoryArea
,
1599 PMEMORY_BASIC_INFORMATION Info
,
1600 PSIZE_T ResultLength
1605 MmProtectSectionView(
1606 PMMSUPPORT AddressSpace
,
1607 PMEMORY_AREA MemoryArea
,
1616 MmWritePageSectionView(
1617 PMMSUPPORT AddressSpace
,
1625 MmInitSectionImplementation(VOID
);
1629 MmNotPresentFaultSectionView(
1630 PMMSUPPORT AddressSpace
,
1631 MEMORY_AREA
* MemoryArea
,
1638 MmPageOutSectionView(
1639 PMMSUPPORT AddressSpace
,
1640 PMEMORY_AREA MemoryArea
,
1642 struct _MM_PAGEOP
*PageOp
1647 MmCreatePhysicalMemorySection(VOID
);
1651 MmAccessFaultSectionView(
1652 PMMSUPPORT AddressSpace
,
1653 MEMORY_AREA
* MemoryArea
,
1660 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1662 /* mpw.c *********************************************************************/
1666 MmInitMpwThread(VOID
);
1670 MmInitBsmThread(VOID
);
1672 /* pager.c *******************************************************************/
1676 MiIsPagerThread(VOID
);
1680 MiStartPagerThread(VOID
);
1684 MiStopPagerThread(VOID
);
1688 MiQueryVirtualMemory(
1689 IN HANDLE ProcessHandle
,
1691 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1692 OUT PVOID VirtualMemoryInformation
,
1694 OUT PSIZE_T ResultLength
1697 /* sysldr.c ******************************************************************/
1701 MiReloadBootLoadedDrivers(
1702 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1707 MiInitializeLoadedModuleList(
1708 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1714 IN PUNICODE_STRING FileName
,
1715 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1716 IN PUNICODE_STRING LoadedName OPTIONAL
,
1718 OUT PVOID
*ModuleObject
,
1719 OUT PVOID
*ImageBaseAddress
1724 MmUnloadSystemImage(
1725 IN PVOID ImageHandle
1731 IN HANDLE ImageHandle
,
1732 IN BOOLEAN PurgeSection
1737 MmCallDllInitialize(
1738 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1739 IN PLIST_ENTRY ListHead
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
;