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 PMMPTE 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
);
790 MmReserveSwapPages(ULONG Nr
);
803 ULONG BugCodeParameter1
,
804 ULONG BugCodeParameter2
,
805 ULONG BugCodeParameter3
,
806 ULONG BugCodeParameter4
,
807 struct _KTRAP_FRAME
* TrapFrame
812 MmIsAvailableSwapPage(VOID
);
816 MmShowOutOfSpaceMessagePagingFile(VOID
);
818 /* process.c ****************************************************************/
822 MmInitializeProcessAddressSpace(
823 IN PEPROCESS Process
,
824 IN PEPROCESS Clone OPTIONAL
,
825 IN PVOID Section OPTIONAL
,
827 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
833 IN PEPROCESS Process
,
834 IN PINITIAL_PEB InitialPeb
,
841 IN PEPROCESS Process
,
842 IN PCLIENT_ID ClientId
,
843 IN PINITIAL_TEB InitialTeb
,
850 struct _EPROCESS
*Process
,
856 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
860 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
864 MmGetSessionLocaleId(VOID
);
868 MmSetMemoryPriorityProcess(
869 IN PEPROCESS Process
,
870 IN UCHAR MemoryPriority
873 /* i386/pfault.c *************************************************************/
885 /* mm.c **********************************************************************/
890 IN BOOLEAN StoreInstruction
,
892 IN KPROCESSOR_MODE Mode
,
893 IN PVOID TrapInformation
896 /* anonmem.c *****************************************************************/
900 MmNotPresentFaultVirtualMemory(
901 PMMSUPPORT AddressSpace
,
902 MEMORY_AREA
* MemoryArea
,
909 MmPageOutVirtualMemory(
910 PMMSUPPORT AddressSpace
,
911 PMEMORY_AREA MemoryArea
,
913 struct _MM_PAGEOP
* PageOp
919 PMEMORY_AREA MemoryArea
,
921 PMEMORY_BASIC_INFORMATION Info
,
928 struct _EPROCESS
* Process
,
929 PMEMORY_AREA MemoryArea
935 PMMSUPPORT AddressSpace
,
936 PMEMORY_AREA MemoryArea
,
945 MmWritePageVirtualMemory(
946 PMMSUPPORT AddressSpace
,
952 /* kmap.c ********************************************************************/
956 ExAllocatePage(VOID
);
960 ExUnmapPage(PVOID Addr
);
964 ExAllocatePageWithPhysPage(PFN_NUMBER Page
);
975 MiZeroPage(PFN_NUMBER Page
);
977 /* memsafe.s *****************************************************************/
981 MmSafeReadPtr(PVOID Source
);
983 /* pageop.c ******************************************************************/
987 MmReleasePageOp(PMM_PAGEOP PageOp
);
995 PMM_SECTION_SEGMENT Segment
,
1007 PMM_SECTION_SEGMENT Segment
,
1013 MmInitializePageOp(VOID
);
1015 /* process.c *****************************************************************/
1019 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
1023 MmDeleteKernelStack(PVOID Stack
,
1026 /* balace.c ******************************************************************/
1030 MmInitializeMemoryConsumer(
1032 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1037 MmInitializeBalancer(
1038 ULONG NrAvailablePages
,
1044 MmReleasePageMemoryConsumer(
1051 MmRequestPageMemoryConsumer(
1054 PPFN_NUMBER AllocatedPage
1059 MiInitBalancerThread(VOID
);
1063 MmRebalanceMemoryConsumers(VOID
);
1065 /* rmap.c **************************************************************/
1069 MmSetRmapListHeadPage(
1071 struct _MM_RMAP_ENTRY
* ListHead
1074 struct _MM_RMAP_ENTRY
*
1076 MmGetRmapListHeadPage(PFN_NUMBER Page
);
1082 struct _EPROCESS
*Process
,
1091 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1098 struct _EPROCESS
*Process
,
1104 MmInitializeRmapList(VOID
);
1108 MmSetCleanAllRmaps(PFN_NUMBER Page
);
1112 MmSetDirtyAllRmaps(PFN_NUMBER Page
);
1116 MmIsDirtyPageRmap(PFN_NUMBER Page
);
1120 MmWritePagePhysicalAddress(PFN_NUMBER Page
);
1124 MmPageOutPhysicalAddress(PFN_NUMBER Page
);
1126 /* freelist.c **********************************************************/
1130 MiGetPfnEntry(IN PFN_NUMBER Pfn
)
1133 extern RTL_BITMAP MiPfnBitMap
;
1135 /* Make sure the PFN number is valid */
1136 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1138 /* Make sure this page actually has a PFN entry */
1139 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1142 Page
= &MmPfnDatabase
[Pfn
];
1150 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1153 // This will return the Page Frame Number (PFN) from the MMPFN
1155 return Pfn1
- MmPfnDatabase
;
1160 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage
);
1164 MmGetLRUFirstUserPage(VOID
);
1168 MmInsertLRULastUserPage(PFN_NUMBER Page
);
1172 MmRemoveLRUUserPage(PFN_NUMBER Page
);
1176 MmLockPage(PFN_NUMBER Page
);
1180 MmUnlockPage(PFN_NUMBER Page
);
1184 MmGetLockCountPage(PFN_NUMBER Page
);
1188 MmInitializePageList(
1194 MmDumpArmPfnDatabase(
1195 IN BOOLEAN StatusOnly
1200 MmGetContinuousPages(
1201 ULONG NumberOfBytes
,
1202 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1203 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1204 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1214 /* hypermap.c *****************************************************************/
1216 extern PEPROCESS HyperProcess
;
1217 extern KIRQL HyperIrql
;
1221 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1227 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1233 MiMapPagesToZeroInHyperSpace(IN PMMPFN Pfn1
,
1234 IN PFN_NUMBER NumberOfPages
);
1238 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1239 IN PFN_NUMBER NumberOfPages
);
1242 // ReactOS Compatibility Layer
1246 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1248 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1249 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1252 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1254 /* i386/page.c *********************************************************/
1258 MmCreateVirtualMappingForKernel(
1267 MmCommitPagedPoolAddress(
1274 MmCreateVirtualMapping(
1275 struct _EPROCESS
* Process
,
1284 MmCreateVirtualMappingUnsafe(
1285 struct _EPROCESS
* Process
,
1295 struct _EPROCESS
* Process
,
1301 struct _EPROCESS
* Process
,
1309 struct _EPROCESS
* Process
,
1315 MmInitGlobalKernelPageDirectory(VOID
);
1319 MmDisableVirtualMapping(
1320 struct _EPROCESS
*Process
,
1328 MmEnableVirtualMapping(
1329 struct _EPROCESS
*Process
,
1335 MmRawDeleteVirtualMapping(PVOID Address
);
1340 MmGetPageFileMapping(
1341 struct _EPROCESS
*Process
,
1343 SWAPENTRY
* SwapEntry
);
1347 MmDeletePageFileMapping(
1348 struct _EPROCESS
*Process
,
1350 SWAPENTRY
* SwapEntry
1355 MmCreatePageFileMapping(
1356 struct _EPROCESS
*Process
,
1364 struct _EPROCESS
*Process
,
1370 MmTransferOwnershipPage(
1378 struct _EPROCESS
*Process
,
1390 MmAllocPagesSpecifyRange(
1392 PHYSICAL_ADDRESS LowestAddress
,
1393 PHYSICAL_ADDRESS HighestAddress
,
1394 ULONG NumberOfPages
,
1400 MmDereferencePage(PFN_NUMBER Page
);
1404 MmReferencePage(PFN_NUMBER Page
);
1408 MmGetReferenceCountPage(PFN_NUMBER Page
);
1412 MmIsPageInUse(PFN_NUMBER Page
);
1416 MmSetSavedSwapEntryPage(
1418 SWAPENTRY SavedSwapEntry
);
1422 MmGetSavedSwapEntryPage(PFN_NUMBER Page
);
1427 struct _EPROCESS
*Process
,
1433 MmCreatePageTable(PVOID PAddress
);
1438 struct _EPROCESS
*Process
,
1445 struct _EPROCESS
*Process
,
1451 MmCreateProcessAddressSpace(
1454 IN PULONG_PTR DirectoryTableBase
1459 MmInitializeHandBuiltProcess(
1460 IN PEPROCESS Process
,
1461 IN PULONG_PTR DirectoryTableBase
1467 MmInitializeHandBuiltProcess2(
1468 IN PEPROCESS Process
1473 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1477 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1481 MmDeleteVirtualMapping(
1482 struct _EPROCESS
*Process
,
1492 struct _EPROCESS
*Process
,
1498 MmMarkPageMapped(PFN_NUMBER Page
);
1502 MmMarkPageUnmapped(PFN_NUMBER Page
);
1507 struct _EPROCESS
*Process
,
1514 MiInitPageDirectoryMap(VOID
);
1518 MiGetUserPageDirectoryCount(VOID
);
1520 /* wset.c ********************************************************************/
1529 /* region.c ************************************************************/
1534 PMMSUPPORT AddressSpace
,
1536 PLIST_ENTRY RegionListHead
,
1541 PMM_ALTER_REGION_FUNC AlterFunc
1547 PLIST_ENTRY RegionListHead
,
1557 PLIST_ENTRY RegionListHead
,
1559 PVOID
* RegionBaseAddress
1562 /* section.c *****************************************************************/
1566 MmGetFileObjectForSection(
1571 MmGetFileNameForAddress(
1573 OUT PUNICODE_STRING ModuleName
1578 MmGetFileNameForSection(
1580 OUT POBJECT_NAME_INFORMATION
*ModuleName
1593 PMEMORY_AREA MemoryArea
,
1595 PMEMORY_BASIC_INFORMATION Info
,
1596 PSIZE_T ResultLength
1601 MmProtectSectionView(
1602 PMMSUPPORT AddressSpace
,
1603 PMEMORY_AREA MemoryArea
,
1612 MmWritePageSectionView(
1613 PMMSUPPORT AddressSpace
,
1621 MmInitSectionImplementation(VOID
);
1625 MmNotPresentFaultSectionView(
1626 PMMSUPPORT AddressSpace
,
1627 MEMORY_AREA
* MemoryArea
,
1634 MmPageOutSectionView(
1635 PMMSUPPORT AddressSpace
,
1636 PMEMORY_AREA MemoryArea
,
1638 struct _MM_PAGEOP
*PageOp
1643 MmCreatePhysicalMemorySection(VOID
);
1647 MmAccessFaultSectionView(
1648 PMMSUPPORT AddressSpace
,
1649 MEMORY_AREA
* MemoryArea
,
1656 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1658 /* mpw.c *********************************************************************/
1662 MmInitMpwThread(VOID
);
1666 MmInitBsmThread(VOID
);
1668 /* pager.c *******************************************************************/
1672 MiIsPagerThread(VOID
);
1676 MiStartPagerThread(VOID
);
1680 MiStopPagerThread(VOID
);
1684 MiQueryVirtualMemory(
1685 IN HANDLE ProcessHandle
,
1687 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1688 OUT PVOID VirtualMemoryInformation
,
1690 OUT PSIZE_T ResultLength
1693 /* sysldr.c ******************************************************************/
1697 MiReloadBootLoadedDrivers(
1698 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1703 MiInitializeLoadedModuleList(
1704 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1710 IN PUNICODE_STRING FileName
,
1711 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1712 IN PUNICODE_STRING LoadedName OPTIONAL
,
1714 OUT PVOID
*ModuleObject
,
1715 OUT PVOID
*ImageBaseAddress
1720 MmUnloadSystemImage(
1721 IN PVOID ImageHandle
1727 IN HANDLE ImageHandle
,
1728 IN BOOLEAN PurgeSection
1733 MmCallDllInitialize(
1734 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1735 IN PLIST_ENTRY ListHead
1738 extern PMMSUPPORT MmKernelAddressSpace
;
1742 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1744 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1749 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1751 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1756 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1758 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1759 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1764 MmGetCurrentAddressSpace(VOID
)
1766 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1771 MmGetKernelAddressSpace(VOID
)
1773 return MmKernelAddressSpace
;