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
;
52 typedef ULONG_PTR 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_CACHE (2)
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 /* Number of list heads to use */
87 #define MI_FREE_POOL_LISTS 4
90 /* Signature of free pool blocks */
91 #define MM_FREE_POOL_TAG 'lprF'
93 /* Although Microsoft says this isn't hardcoded anymore,
94 they won't be able to change it. Stuff depends on it */
95 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
97 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
100 * Additional flags for protection attributes
102 #define PAGE_WRITETHROUGH (1024)
103 #define PAGE_SYSTEM (2048)
105 #define SEC_PHYSICALMEMORY (0x80000000)
107 #define MM_PAGEFILE_SEGMENT (0x1)
108 #define MM_DATAFILE_SEGMENT (0x2)
112 #define MC_SYSTEM (2)
113 #define MC_MAXIMUM (3)
115 #define PAGED_POOL_MASK 1
116 #define MUST_SUCCEED_POOL_MASK 2
117 #define CACHE_ALIGNED_POOL_MASK 4
118 #define QUOTA_POOL_MASK 8
119 #define SESSION_POOL_MASK 32
120 #define VERIFIER_POOL_MASK 64
122 #define MM_PAGED_POOL_SIZE (100*1024*1024)
123 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
126 * Paged and non-paged pools are 8-byte aligned
128 #define MM_POOL_ALIGNMENT 8
130 #define MM_ROUND_UP(x,s) \
131 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
133 #define MM_ROUND_DOWN(x,s) \
134 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
136 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
141 PAGE_EXECUTE_READ | \
142 PAGE_EXECUTE_READWRITE | \
143 PAGE_EXECUTE_WRITECOPY | \
148 #define PAGE_FLAGS_VALID_FOR_SECTION \
153 PAGE_EXECUTE_READ | \
154 PAGE_EXECUTE_READWRITE | \
155 PAGE_EXECUTE_WRITECOPY | \
158 #define PAGE_IS_READABLE \
162 PAGE_EXECUTE_READ | \
163 PAGE_EXECUTE_READWRITE | \
164 PAGE_EXECUTE_WRITECOPY)
166 #define PAGE_IS_WRITABLE \
169 PAGE_EXECUTE_READWRITE | \
170 PAGE_EXECUTE_WRITECOPY)
172 #define PAGE_IS_EXECUTABLE \
174 PAGE_EXECUTE_READ | \
175 PAGE_EXECUTE_READWRITE | \
176 PAGE_EXECUTE_WRITECOPY)
178 #define PAGE_IS_WRITECOPY \
180 PAGE_EXECUTE_WRITECOPY)
183 // Wait entry for marking pages that are being serviced
185 #define MM_WAIT_ENTRY 0x7ffffc00
187 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
188 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
190 #define InterlockedExchangePte(PointerPte, Value) \
191 InterlockedExchange((PLONG)(PointerPte), Value)
193 typedef struct _MM_SECTION_SEGMENT
195 FAST_MUTEX Lock
; /* lock which protects the page directory */
196 PFILE_OBJECT FileObject
;
197 LARGE_INTEGER RawLength
; /* length of the segment which is part of the mapped file */
198 LARGE_INTEGER Length
; /* absolute length of the segment */
199 ULONG ReferenceCount
;
208 ULONGLONG FileOffset
; /* start offset into the file for image sections */
209 ULONG_PTR VirtualAddress
; /* start offset into the address range for image sections */
210 ULONG Characteristics
;
213 LIST_ENTRY ListOfSegments
;
214 RTL_GENERIC_TABLE PageTable
;
215 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
217 typedef struct _MM_IMAGE_SECTION_OBJECT
220 ULONG_PTR StackReserve
;
221 ULONG_PTR StackCommit
;
222 ULONG_PTR EntryPoint
;
224 USHORT ImageCharacteristics
;
225 USHORT MinorSubsystemVersion
;
226 USHORT MajorSubsystemVersion
;
231 PMM_SECTION_SEGMENT Segments
;
232 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
234 typedef struct _ROS_SECTION_OBJECT
238 LARGE_INTEGER MaximumSize
;
239 ULONG SectionPageProtection
;
240 ULONG AllocationAttributes
;
241 PFILE_OBJECT FileObject
;
244 PMM_IMAGE_SECTION_OBJECT ImageSection
;
245 PMM_SECTION_SEGMENT Segment
;
247 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
249 typedef struct _MEMORY_AREA
251 PVOID StartingAddress
;
253 struct _MEMORY_AREA
*Parent
;
254 struct _MEMORY_AREA
*LeftChild
;
255 struct _MEMORY_AREA
*RightChild
;
259 BOOLEAN DeleteInProgress
;
266 ROS_SECTION_OBJECT
* Section
;
267 LARGE_INTEGER ViewOffset
;
268 PMM_SECTION_SEGMENT Segment
;
269 LIST_ENTRY RegionListHead
;
273 LIST_ENTRY RegionListHead
;
276 } MEMORY_AREA
, *PMEMORY_AREA
;
278 typedef struct _MM_RMAP_ENTRY
280 struct _MM_RMAP_ENTRY
* Next
;
287 MM_RMAP_ENTRY
, *PMM_RMAP_ENTRY
;
290 extern ULONG MI_PFN_CURRENT_USAGE
;
291 extern CHAR MI_PFN_CURRENT_PROCESS_NAME
[16];
292 #define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x
293 #define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, 16)
295 #define MI_SET_USAGE(x)
296 #define MI_SET_PROCESS2(x)
299 typedef enum _MI_PFN_USAGES
301 MI_USAGE_NOT_SET
= 0,
303 MI_USAGE_NONPAGED_POOL
,
304 MI_USAGE_NONPAGED_POOL_EXPANSION
,
305 MI_USAGE_KERNEL_STACK
,
306 MI_USAGE_KERNEL_STACK_EXPANSION
,
312 MI_USAGE_PAGE_DIRECTORY
,
313 MI_USAGE_LEGACY_PAGE_DIRECTORY
,
314 MI_USAGE_DRIVER_PAGE
,
315 MI_USAGE_CONTINOUS_ALLOCATION
,
317 MI_USAGE_DEMAND_ZERO
,
320 MI_USAGE_PFN_DATABASE
,
321 MI_USAGE_BOOT_DRIVER
,
322 MI_USAGE_INIT_MEMORY
,
327 // These two mappings are actually used by Windows itself, based on the ASSERTS
329 #define StartOfAllocation ReadInProgress
330 #define EndOfAllocation WriteInProgress
332 typedef struct _MMPFNENTRY
335 USHORT ReadInProgress
:1; // StartOfAllocation
336 USHORT WriteInProgress
:1; // EndOfAllocation
337 USHORT PrototypePte
:1;
339 USHORT PageLocation
:3;
340 USHORT RemovalRequested
:1;
341 USHORT CacheAttribute
:2;
343 USHORT ParityError
:1; // HasRmap
346 typedef struct _MMPFN
351 ULONG WsIndex
; // SavedSwapEntry
354 SINGLE_LIST_ENTRY NextStackPfn
;
360 ULONG_PTR ShareCount
;
366 USHORT ReferenceCount
; // ReferenceCount
371 USHORT ReferenceCount
;
378 LONG AweReferenceCount
; // RmapListHead
382 ULONG_PTR EntireFrame
;
385 ULONG_PTR PteFrame
:25;
386 ULONG_PTR InPageError
:1;
387 ULONG_PTR VerifierAllocation
:1;
388 ULONG_PTR AweAllocation
:1;
389 ULONG_PTR Priority
:3;
390 ULONG_PTR MustBeCached
:1;
394 MI_PFN_USAGES PfnUsage
;
395 CHAR ProcessName
[16];
399 extern PMMPFN MmPfnDatabase
;
401 typedef struct _MMPFNLIST
407 } MMPFNLIST
, *PMMPFNLIST
;
409 extern MMPFNLIST MmZeroedPageListHead
;
410 extern MMPFNLIST MmFreePageListHead
;
411 extern MMPFNLIST MmStandbyPageListHead
;
412 extern MMPFNLIST MmModifiedPageListHead
;
413 extern MMPFNLIST MmModifiedNoWritePageListHead
;
415 typedef struct _MM_MEMORY_CONSUMER
419 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
420 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
422 typedef struct _MM_REGION
427 LIST_ENTRY RegionListEntry
;
428 } MM_REGION
, *PMM_REGION
;
430 /* Entry describing free pool memory */
431 typedef struct _MMFREE_POOL_ENTRY
436 struct _MMFREE_POOL_ENTRY
*Owner
;
437 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
439 /* Signature of a freed block */
440 #define MM_FREE_POOL_SIGNATURE 'ARM3'
442 /* Paged pool information */
443 typedef struct _MM_PAGED_POOL_INFO
445 PRTL_BITMAP PagedPoolAllocationMap
;
446 PRTL_BITMAP EndOfPagedPoolBitmap
;
447 PMMPTE FirstPteForPagedPool
;
448 PMMPTE LastPteForPagedPool
;
449 PMMPDE NextPdeForPagedPoolExpansion
;
451 SIZE_T PagedPoolCommit
;
452 SIZE_T AllocatedPagedPool
;
453 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
455 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
458 (*PMM_ALTER_REGION_FUNC
)(
459 PMMSUPPORT AddressSpace
,
469 (*PMM_FREE_PAGE_FUNC
)(
471 PMEMORY_AREA MemoryArea
,
479 // Mm copy support for Kd
491 // Determines if a given address is a session address
505 /* marea.c *******************************************************************/
510 PMMSUPPORT AddressSpace
,
515 PMEMORY_AREA
*Result
,
516 BOOLEAN FixedAddress
,
517 ULONG AllocationFlags
,
518 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
523 MmLocateMemoryAreaByAddress(
524 PMMSUPPORT AddressSpace
,
531 PMMSUPPORT AddressSpace
,
538 PMMSUPPORT AddressSpace
,
539 PMEMORY_AREA MemoryArea
,
540 PMM_FREE_PAGE_FUNC FreePage
,
541 PVOID FreePageContext
546 MmFreeMemoryAreaByPtr(
547 PMMSUPPORT AddressSpace
,
549 PMM_FREE_PAGE_FUNC FreePage
,
550 PVOID FreePageContext
555 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
559 MmLocateMemoryAreaByRegion(
560 PMMSUPPORT AddressSpace
,
568 PMMSUPPORT AddressSpace
,
570 ULONG_PTR Granularity
,
576 MmReleaseMemoryAreaIfDecommitted(
577 struct _EPROCESS
*Process
,
578 PMMSUPPORT AddressSpace
,
584 MmMapMemoryArea(PVOID BaseAddress
,
589 /* npool.c *******************************************************************/
593 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
597 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
601 MiInitializeNonPagedPool(VOID
);
606 IN POOL_TYPE PoolType
,
607 IN SIZE_T SizeInBytes
613 IN PVOID VirtualAddress
619 IN PVOID StartingAddress
629 /* pool.c *******************************************************************/
633 ExAllocateNonPagedPoolWithTag(
642 ExAllocatePagedPoolWithTag(
650 ExFreeNonPagedPool(PVOID block
);
654 ExFreePagedPool(IN PVOID Block
);
658 ExpIsPoolTagDebuggable(ULONG Tag
);
662 ExpAllocateDebugPool(
672 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
676 MmInitializePagedPool(VOID
);
680 MiAllocateSpecialPool(
681 IN POOL_TYPE PoolType
,
682 IN SIZE_T NumberOfBytes
,
690 IN POOL_TYPE PoolType
,
691 IN ULONG CurrentMaxQuota
,
692 OUT PULONG NewMaxQuota
695 /* mdl.c *********************************************************************/
704 /* mminit.c ******************************************************************/
708 MiShutdownMemoryManager(VOID
);
718 MmInitSystem(IN ULONG Phase
,
719 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
723 MiFreeInitMemory(VOID
);
727 MmInitializeMdlImplementation(VOID
);
729 /* pagefile.c ****************************************************************/
733 MmAllocSwapPage(VOID
);
737 MmDereserveSwapPages(ULONG Nr
);
741 MmFreeSwapPage(SWAPENTRY Entry
);
745 MmInitPagingFile(VOID
);
749 MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject
);
760 MmReserveSwapPages(ULONG Nr
);
773 ULONG BugCodeParameter1
,
774 ULONG BugCodeParameter2
,
775 ULONG BugCodeParameter3
,
776 ULONG BugCodeParameter4
,
777 struct _KTRAP_FRAME
* TrapFrame
782 MmIsAvailableSwapPage(VOID
);
786 MmShowOutOfSpaceMessagePagingFile(VOID
);
788 /* process.c ****************************************************************/
792 MmInitializeProcessAddressSpace(
793 IN PEPROCESS Process
,
794 IN PEPROCESS Clone OPTIONAL
,
795 IN PVOID Section OPTIONAL
,
797 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
803 IN PEPROCESS Process
,
804 IN PINITIAL_PEB InitialPeb
,
811 IN PEPROCESS Process
,
812 IN PCLIENT_ID ClientId
,
813 IN PINITIAL_TEB InitialTeb
,
820 struct _EPROCESS
*Process
,
826 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
830 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
834 MmGetSessionLocaleId(VOID
);
838 MmSetMemoryPriorityProcess(
839 IN PEPROCESS Process
,
840 IN UCHAR MemoryPriority
843 /* i386/pfault.c *************************************************************/
855 /* special.c *****************************************************************/
859 MiInitializeSpecialPool();
864 IN SIZE_T NumberOfBytes
,
869 MmIsSpecialPoolAddress(
874 MmAllocateSpecialPool(
875 IN SIZE_T NumberOfBytes
,
877 IN POOL_TYPE PoolType
,
878 IN ULONG SpecialType
);
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
,
908 MmPageOutVirtualMemory(
909 PMMSUPPORT AddressSpace
,
910 PMEMORY_AREA MemoryArea
,
918 PMEMORY_AREA MemoryArea
,
920 PMEMORY_BASIC_INFORMATION Info
,
927 struct _EPROCESS
* Process
,
928 PMEMORY_AREA MemoryArea
934 PMMSUPPORT AddressSpace
,
935 PMEMORY_AREA MemoryArea
,
944 MmWritePageVirtualMemory(
945 PMMSUPPORT AddressSpace
,
951 /* kmap.c ********************************************************************/
955 ExAllocatePage(VOID
);
959 ExUnmapPage(PVOID Addr
);
963 ExAllocatePageWithPhysPage(PFN_NUMBER Page
);
974 MiZeroPage(PFN_NUMBER Page
);
976 /* memsafe.s *****************************************************************/
980 MmSafeReadPtr(PVOID Source
);
982 /* process.c *****************************************************************/
986 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
990 MmDeleteKernelStack(PVOID Stack
,
993 /* balace.c ******************************************************************/
997 MmInitializeMemoryConsumer(
999 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1004 MmInitializeBalancer(
1005 ULONG NrAvailablePages
,
1011 MmReleasePageMemoryConsumer(
1018 MmRequestPageMemoryConsumer(
1021 PPFN_NUMBER AllocatedPage
1026 MiInitBalancerThread(VOID
);
1030 MmRebalanceMemoryConsumers(VOID
);
1032 /* rmap.c **************************************************************/
1036 MmSetRmapListHeadPage(
1038 struct _MM_RMAP_ENTRY
* ListHead
1041 struct _MM_RMAP_ENTRY
*
1043 MmGetRmapListHeadPage(PFN_NUMBER Page
);
1049 struct _EPROCESS
*Process
,
1058 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1065 struct _EPROCESS
*Process
,
1071 MmInitializeRmapList(VOID
);
1075 MmSetCleanAllRmaps(PFN_NUMBER Page
);
1079 MmSetDirtyAllRmaps(PFN_NUMBER Page
);
1083 MmIsDirtyPageRmap(PFN_NUMBER Page
);
1087 MmPageOutPhysicalAddress(PFN_NUMBER Page
);
1089 /* freelist.c **********************************************************/
1093 MiGetPfnEntry(IN PFN_NUMBER Pfn
)
1096 extern RTL_BITMAP MiPfnBitMap
;
1098 /* Make sure the PFN number is valid */
1099 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1101 /* Make sure this page actually has a PFN entry */
1102 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, (ULONG
)Pfn
))) return NULL
;
1105 Page
= &MmPfnDatabase
[Pfn
];
1113 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1116 // This will return the Page Frame Number (PFN) from the MMPFN
1118 return Pfn1
- MmPfnDatabase
;
1123 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage
);
1127 MmGetLRUFirstUserPage(VOID
);
1131 MmInsertLRULastUserPage(PFN_NUMBER Page
);
1135 MmRemoveLRUUserPage(PFN_NUMBER Page
);
1139 MmLockPage(PFN_NUMBER Page
);
1143 MmUnlockPage(PFN_NUMBER Page
);
1147 MmGetLockCountPage(PFN_NUMBER Page
);
1151 MmInitializePageList(
1157 MmDumpArmPfnDatabase(
1158 IN BOOLEAN StatusOnly
1163 MmGetContinuousPages(
1164 ULONG NumberOfBytes
,
1165 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1166 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1167 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1177 /* hypermap.c *****************************************************************/
1179 extern PEPROCESS HyperProcess
;
1180 extern KIRQL HyperIrql
;
1184 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1190 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1196 MiMapPagesInZeroSpace(IN PMMPFN Pfn1
,
1197 IN PFN_NUMBER NumberOfPages
);
1201 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1202 IN PFN_NUMBER NumberOfPages
);
1205 // ReactOS Compatibility Layer
1209 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1211 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1212 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1215 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1217 /* i386/page.c *********************************************************/
1221 MmCreateVirtualMappingForKernel(
1230 MmCommitPagedPoolAddress(
1237 MmCreateVirtualMapping(
1238 struct _EPROCESS
* Process
,
1247 MmCreateVirtualMappingUnsafe(
1248 struct _EPROCESS
* Process
,
1258 struct _EPROCESS
* Process
,
1264 struct _EPROCESS
* Process
,
1272 struct _EPROCESS
* Process
,
1279 struct _EPROCESS
* Process
,
1285 MmInitGlobalKernelPageDirectory(VOID
);
1289 MmDisableVirtualMapping(
1290 struct _EPROCESS
*Process
,
1298 MmEnableVirtualMapping(
1299 struct _EPROCESS
*Process
,
1305 MmRawDeleteVirtualMapping(PVOID Address
);
1310 MmGetPageFileMapping(
1311 struct _EPROCESS
*Process
,
1313 SWAPENTRY
* SwapEntry
);
1317 MmDeletePageFileMapping(
1318 struct _EPROCESS
*Process
,
1320 SWAPENTRY
* SwapEntry
1325 MmCreatePageFileMapping(
1326 struct _EPROCESS
*Process
,
1334 struct _EPROCESS
*Process
,
1340 MmTransferOwnershipPage(
1348 struct _EPROCESS
*Process
,
1360 MmAllocPagesSpecifyRange(
1362 PHYSICAL_ADDRESS LowestAddress
,
1363 PHYSICAL_ADDRESS HighestAddress
,
1364 ULONG NumberOfPages
,
1370 MmDereferencePage(PFN_NUMBER Page
);
1374 MmReferencePage(PFN_NUMBER Page
);
1378 MmGetReferenceCountPage(PFN_NUMBER Page
);
1382 MmIsPageInUse(PFN_NUMBER Page
);
1386 MmSetSavedSwapEntryPage(
1388 SWAPENTRY SavedSwapEntry
);
1392 MmGetSavedSwapEntryPage(PFN_NUMBER Page
);
1397 struct _EPROCESS
*Process
,
1403 MmCreatePageTable(PVOID PAddress
);
1408 struct _EPROCESS
*Process
,
1415 struct _EPROCESS
*Process
,
1421 MmCreateProcessAddressSpace(
1424 IN PULONG_PTR DirectoryTableBase
1429 MmInitializeHandBuiltProcess(
1430 IN PEPROCESS Process
,
1431 IN PULONG_PTR DirectoryTableBase
1437 MmInitializeHandBuiltProcess2(
1438 IN PEPROCESS Process
1443 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1447 MmSetExecuteOptions(IN ULONG ExecuteOptions
);
1451 MmGetExecuteOptions(IN PULONG ExecuteOptions
);
1455 MmDeleteProcessPageDirectory(struct _EPROCESS
*Process
);
1459 MmDeleteVirtualMapping(
1460 struct _EPROCESS
*Process
,
1470 struct _EPROCESS
*Process
,
1476 MmMarkPageMapped(PFN_NUMBER Page
);
1480 MmMarkPageUnmapped(PFN_NUMBER Page
);
1485 struct _EPROCESS
*Process
,
1492 MiInitPageDirectoryMap(VOID
);
1496 MiGetUserPageDirectoryCount(VOID
);
1498 /* wset.c ********************************************************************/
1507 /* region.c ************************************************************/
1512 PMMSUPPORT AddressSpace
,
1514 PLIST_ENTRY RegionListHead
,
1519 PMM_ALTER_REGION_FUNC AlterFunc
1525 PLIST_ENTRY RegionListHead
,
1535 PLIST_ENTRY RegionListHead
,
1537 PVOID
* RegionBaseAddress
1540 /* section.c *****************************************************************/
1544 MmGetFileObjectForSection(
1549 MmGetFileNameForAddress(
1551 OUT PUNICODE_STRING ModuleName
1556 MmGetFileNameForSection(
1558 OUT POBJECT_NAME_INFORMATION
*ModuleName
1571 PMEMORY_AREA MemoryArea
,
1573 PMEMORY_BASIC_INFORMATION Info
,
1574 PSIZE_T ResultLength
1579 MmProtectSectionView(
1580 PMMSUPPORT AddressSpace
,
1581 PMEMORY_AREA MemoryArea
,
1590 MmInitSectionImplementation(VOID
);
1594 MmNotPresentFaultSectionView(
1595 PMMSUPPORT AddressSpace
,
1596 MEMORY_AREA
* MemoryArea
,
1603 MmPageOutSectionView(
1604 PMMSUPPORT AddressSpace
,
1605 PMEMORY_AREA MemoryArea
,
1612 MmCreatePhysicalMemorySection(VOID
);
1616 MmAccessFaultSectionView(
1617 PMMSUPPORT AddressSpace
,
1618 MEMORY_AREA
* MemoryArea
,
1624 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1626 /* mpw.c *********************************************************************/
1630 MmInitMpwThread(VOID
);
1634 MmInitBsmThread(VOID
);
1636 /* pager.c *******************************************************************/
1640 MiIsPagerThread(VOID
);
1644 MiStartPagerThread(VOID
);
1648 MiStopPagerThread(VOID
);
1652 MiQueryVirtualMemory(
1653 IN HANDLE ProcessHandle
,
1655 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1656 OUT PVOID VirtualMemoryInformation
,
1658 OUT PSIZE_T ResultLength
1661 /* sysldr.c ******************************************************************/
1665 MiReloadBootLoadedDrivers(
1666 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1671 MiInitializeLoadedModuleList(
1672 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1678 IN PUNICODE_STRING FileName
,
1679 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1680 IN PUNICODE_STRING LoadedName OPTIONAL
,
1682 OUT PVOID
*ModuleObject
,
1683 OUT PVOID
*ImageBaseAddress
1688 MmUnloadSystemImage(
1689 IN PVOID ImageHandle
1695 IN HANDLE ImageHandle
,
1696 IN BOOLEAN PurgeSection
1701 MmCallDllInitialize(
1702 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1703 IN PLIST_ENTRY ListHead
1707 /* procsup.c *****************************************************************/
1712 IN PVOID StackPointer
1718 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1720 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1721 //ASSERT(Thread->OwnsProcessAddressSpaceExclusive == 0);
1722 //Thread->OwnsProcessAddressSpaceExclusive = TRUE;
1727 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1729 //ASSERT(Thread->OwnsProcessAddressSpaceExclusive == 1);
1730 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1731 //Thread->OwnsProcessAddressSpaceExclusive = 0;
1736 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1738 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1739 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1744 MmGetCurrentAddressSpace(VOID
)
1746 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1751 MmGetKernelAddressSpace(VOID
)
1753 return MmKernelAddressSpace
;