1 #ifndef __INCLUDE_INTERNAL_MM_H
2 #define __INCLUDE_INTERNAL_MM_H
4 #include <internal/arch/mm.h>
6 /* TYPES *********************************************************************/
10 extern ULONG MiFreeSwapPages
;
11 extern ULONG MiUsedSwapPages
;
12 extern ULONG MmPagedPoolSize
;
13 extern ULONG MmTotalPagedPoolQuota
;
14 extern ULONG MmTotalNonPagedPoolQuota
;
15 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress
;
16 extern ULONG MmNumberOfPhysicalPages
;
17 extern ULONG MmLowestPhysicalPage
;
18 extern ULONG MmHighestPhysicalPage
;
20 extern PVOID MmPagedPoolBase
;
21 extern ULONG MmPagedPoolSize
;
23 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
24 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
28 struct _MM_RMAP_ENTRY
;
30 typedef ULONG SWAPENTRY
;
31 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
34 //MmDbgCopyMemory Flags
36 #define MMDBG_COPY_WRITE 0x00000001
37 #define MMDBG_COPY_PHYSICAL 0x00000002
38 #define MMDBG_COPY_UNSAFE 0x00000004
39 #define MMDBG_COPY_CACHED 0x00000008
40 #define MMDBG_COPY_UNCACHED 0x00000010
41 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
44 // Maximum chunk size per copy
46 #define MMDBG_COPY_MAX_SIZE 0x8
49 #define MI_STATIC_MEMORY_AREAS (8)
51 #define MEMORY_AREA_INVALID (0)
52 #define MEMORY_AREA_SECTION_VIEW (1)
53 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
54 #define MEMORY_AREA_NO_CACHE (3)
55 #define MEMORY_AREA_IO_MAPPING (4)
56 #define MEMORY_AREA_SYSTEM (5)
57 #define MEMORY_AREA_MDL_MAPPING (7)
58 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
59 #define MEMORY_AREA_CACHE_SEGMENT (9)
60 #define MEMORY_AREA_SHARED_DATA (10)
61 #define MEMORY_AREA_KERNEL_STACK (11)
62 #define MEMORY_AREA_PAGED_POOL (12)
63 #define MEMORY_AREA_NO_ACCESS (13)
64 #define MEMORY_AREA_PEB_OR_TEB (14)
65 #define MEMORY_AREA_STATIC (0x80000000)
67 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
69 #define MM_CORE_DUMP_TYPE_NONE (0x0)
70 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
71 #define MM_CORE_DUMP_TYPE_FULL (0x2)
73 #define MM_PAGEOP_PAGEIN (1)
74 #define MM_PAGEOP_PAGEOUT (2)
75 #define MM_PAGEOP_PAGESYNCH (3)
76 #define MM_PAGEOP_ACCESSFAULT (4)
78 /* Number of list heads to use */
79 #define MI_FREE_POOL_LISTS 4
81 #define MI_HYPERSPACE_PTES (256 - 1)
82 #define MI_ZERO_PTES (32)
83 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
84 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
85 MI_HYPERSPACE_PTES * PAGE_SIZE)
86 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
89 /* Signature of free pool blocks */
90 #define MM_FREE_POOL_TAG 'lprF'
92 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
95 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
96 ((((x)) % (4*1024*1024)) / (4*1024))
98 #define NR_SECTION_PAGE_TABLES 1024
99 #define NR_SECTION_PAGE_ENTRIES 1024
101 #define TEB_BASE 0x7FFDE000
103 /* Although Microsoft says this isn't hardcoded anymore,
104 they won't be able to change it. Stuff depends on it */
105 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
107 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
110 * Additional flags for protection attributes
112 #define PAGE_WRITETHROUGH (1024)
113 #define PAGE_SYSTEM (2048)
115 #define SEC_PHYSICALMEMORY (0x80000000)
117 #define MM_PAGEFILE_SEGMENT (0x1)
118 #define MM_DATAFILE_SEGMENT (0x2)
123 #define MC_NPPOOL (3)
124 #define MC_SYSTEM (4)
125 #define MC_MAXIMUM (5)
127 #define PAGED_POOL_MASK 1
128 #define MUST_SUCCEED_POOL_MASK 2
129 #define CACHE_ALIGNED_POOL_MASK 4
130 #define QUOTA_POOL_MASK 8
131 #define SESSION_POOL_MASK 32
132 #define VERIFIER_POOL_MASK 64
134 #define MM_PAGED_POOL_SIZE (100*1024*1024)
135 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
138 * Paged and non-paged pools are 8-byte aligned
140 #define MM_POOL_ALIGNMENT 8
143 * Maximum size of the kmalloc area (this is totally arbitary)
145 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
146 #define MM_KERNEL_MAP_BASE (0xf0c00000)
149 * FIXME - different architectures have different cache line sizes...
151 #define MM_CACHE_LINE_SIZE 32
153 #define MM_ROUND_UP(x,s) \
154 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
156 #define MM_ROUND_DOWN(x,s) \
157 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
159 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
164 PAGE_EXECUTE_READ | \
165 PAGE_EXECUTE_READWRITE | \
166 PAGE_EXECUTE_WRITECOPY | \
171 #define PAGE_FLAGS_VALID_FOR_SECTION \
176 PAGE_EXECUTE_READ | \
177 PAGE_EXECUTE_READWRITE | \
178 PAGE_EXECUTE_WRITECOPY | \
181 #define PAGE_IS_READABLE \
185 PAGE_EXECUTE_READ | \
186 PAGE_EXECUTE_READWRITE | \
187 PAGE_EXECUTE_WRITECOPY)
189 #define PAGE_IS_WRITABLE \
192 PAGE_EXECUTE_READWRITE | \
193 PAGE_EXECUTE_WRITECOPY)
195 #define PAGE_IS_EXECUTABLE \
197 PAGE_EXECUTE_READ | \
198 PAGE_EXECUTE_READWRITE | \
199 PAGE_EXECUTE_WRITECOPY)
201 #define PAGE_IS_WRITECOPY \
203 PAGE_EXECUTE_WRITECOPY)
206 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
207 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
209 #define InterlockedExchangePte(PointerPte, Value) \
210 InterlockedExchange((PLONG)(PointerPte), Value)
214 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
215 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
219 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
220 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
222 typedef struct _MM_SECTION_SEGMENT
224 LONG FileOffset
; /* start offset into the file for image sections */
225 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
226 ULONG RawLength
; /* length of the segment which is part of the mapped file */
227 ULONG Length
; /* absolute length of the segment */
229 FAST_MUTEX Lock
; /* lock which protects the page directory */
230 ULONG ReferenceCount
;
231 SECTION_PAGE_DIRECTORY PageDirectory
;
233 ULONG Characteristics
;
235 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
237 typedef struct _MM_IMAGE_SECTION_OBJECT
240 ULONG_PTR StackReserve
;
241 ULONG_PTR StackCommit
;
242 ULONG_PTR EntryPoint
;
244 USHORT ImageCharacteristics
;
245 USHORT MinorSubsystemVersion
;
246 USHORT MajorSubsystemVersion
;
251 PMM_SECTION_SEGMENT Segments
;
252 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
254 typedef struct _ROS_SECTION_OBJECT
258 LARGE_INTEGER MaximumSize
;
259 ULONG SectionPageProtection
;
260 ULONG AllocationAttributes
;
261 PFILE_OBJECT FileObject
;
264 PMM_IMAGE_SECTION_OBJECT ImageSection
;
265 PMM_SECTION_SEGMENT Segment
;
267 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
269 typedef struct _MEMORY_AREA
271 PVOID StartingAddress
;
273 struct _MEMORY_AREA
*Parent
;
274 struct _MEMORY_AREA
*LeftChild
;
275 struct _MEMORY_AREA
*RightChild
;
279 BOOLEAN DeleteInProgress
;
285 ROS_SECTION_OBJECT
* Section
;
287 PMM_SECTION_SEGMENT Segment
;
288 BOOLEAN WriteCopyView
;
289 LIST_ENTRY RegionListHead
;
293 LIST_ENTRY RegionListHead
;
296 } MEMORY_AREA
, *PMEMORY_AREA
;
306 ULONG PagingRequestsInLastMinute
;
307 ULONG PagingRequestsInLastFiveMinutes
;
308 ULONG PagingRequestsInLastFifteenMinutes
;
312 // These two mappings are actually used by Windows itself, based on the ASSERTS
314 #define StartOfAllocation ReadInProgress
315 #define EndOfAllocation WriteInProgress
317 typedef struct _MMPFNENTRY
320 USHORT ReadInProgress
:1; // StartOfAllocation
321 USHORT WriteInProgress
:1; // EndOfAllocation
322 USHORT PrototypePte
:1; // Zero
323 USHORT PageColor
:4; // LockCount
324 USHORT PageLocation
:3; // Consumer
325 USHORT RemovalRequested
:1;
326 USHORT CacheAttribute
:2; // Type
328 USHORT ParityError
:1;
331 typedef struct _MMPFN
335 PFN_NUMBER Flink
; // ListEntry.Flink
339 SINGLE_LIST_ENTRY NextStackPfn
;
341 PMMPTE PteAddress
; // ListEntry.Blink
345 ULONG_PTR ShareCount
; // MapCount
351 USHORT ReferenceCount
; // ReferenceCount
356 USHORT ReferenceCount
;
363 LONG AweReferenceCount
; // RmapListHead
367 ULONG_PTR EntireFrame
; // SavedSwapEntry
370 ULONG_PTR PteFrame
:25;
371 ULONG_PTR InPageError
:1;
372 ULONG_PTR VerifierAllocation
:1;
373 ULONG_PTR AweAllocation
:1;
374 ULONG_PTR Priority
:3;
375 ULONG_PTR MustBeCached
:1;
380 extern PMMPFN MmPfnDatabase
;
381 extern MM_STATS MmStats
;
383 typedef struct _MM_PAGEOP
385 /* Type of operation. */
387 /* Number of threads interested in this operation. */
388 ULONG ReferenceCount
;
389 /* Event that will be set when the operation is completed. */
390 KEVENT CompletionEvent
;
391 /* Status of the operation once it is completed. */
393 /* TRUE if the operation was abandoned. */
395 /* The memory area to be affected by the operation. */
398 struct _MM_PAGEOP
* Next
;
399 struct _ETHREAD
* Thread
;
401 * These fields are used to identify the operation if it is against a
402 * virtual memory area.
407 * These fields are used to identify the operation if it is against a
410 PMM_SECTION_SEGMENT Segment
;
412 } MM_PAGEOP
, *PMM_PAGEOP
;
414 typedef struct _MM_MEMORY_CONSUMER
418 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
419 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
421 typedef struct _MM_REGION
426 LIST_ENTRY RegionListEntry
;
427 } MM_REGION
, *PMM_REGION
;
429 /* Entry describing free pool memory */
430 typedef struct _MMFREE_POOL_ENTRY
435 struct _MMFREE_POOL_ENTRY
*Owner
;
436 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
438 /* Paged pool information */
439 typedef struct _MM_PAGED_POOL_INFO
441 PRTL_BITMAP PagedPoolAllocationMap
;
442 PRTL_BITMAP EndOfPagedPoolBitmap
;
443 PMMPTE FirstPteForPagedPool
;
444 PMMPTE LastPteForPagedPool
;
445 PMMPTE NextPdeForPagedPoolExpansion
;
447 SIZE_T PagedPoolCommit
;
448 SIZE_T AllocatedPagedPool
;
449 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
451 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
454 (*PMM_ALTER_REGION_FUNC
)(
455 PMMSUPPORT AddressSpace
,
465 (*PMM_FREE_PAGE_FUNC
)(
467 PMEMORY_AREA MemoryArea
,
475 // Mm copy support for Kd
486 /* marea.c *******************************************************************/
491 PMMSUPPORT AddressSpace
,
496 PMEMORY_AREA
*Result
,
497 BOOLEAN FixedAddress
,
498 ULONG AllocationFlags
,
499 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
504 MmLocateMemoryAreaByAddress(
505 PMMSUPPORT AddressSpace
,
512 PMMSUPPORT AddressSpace
,
519 PMMSUPPORT AddressSpace
,
520 PMEMORY_AREA MemoryArea
,
521 PMM_FREE_PAGE_FUNC FreePage
,
522 PVOID FreePageContext
527 MmFreeMemoryAreaByPtr(
528 PMMSUPPORT AddressSpace
,
530 PMM_FREE_PAGE_FUNC FreePage
,
531 PVOID FreePageContext
536 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
540 MmLocateMemoryAreaByRegion(
541 PMMSUPPORT AddressSpace
,
549 PMMSUPPORT AddressSpace
,
551 ULONG_PTR Granularity
,
557 MmReleaseMemoryAreaIfDecommitted(
558 struct _EPROCESS
*Process
,
559 PMMSUPPORT AddressSpace
,
565 MmMapMemoryArea(PVOID BaseAddress
,
570 /* npool.c *******************************************************************/
574 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
578 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
582 MiInitializeNonPagedPool(VOID
);
587 IN POOL_TYPE PoolType
,
588 IN SIZE_T SizeInBytes
594 IN PVOID VirtualAddress
600 IN PVOID StartingAddress
610 /* pool.c *******************************************************************/
614 ExAllocateNonPagedPoolWithTag(
623 ExAllocatePagedPoolWithTag(
631 ExFreeNonPagedPool(PVOID block
);
635 ExFreePagedPool(IN PVOID Block
);
639 ExpIsPoolTagDebuggable(ULONG Tag
);
643 ExpAllocateDebugPool(
653 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
657 MmInitializePagedPool(VOID
);
661 MiAllocateSpecialPool(
662 IN POOL_TYPE PoolType
,
663 IN SIZE_T NumberOfBytes
,
671 IN POOL_TYPE PoolType
,
672 IN ULONG CurrentMaxQuota
,
673 OUT PULONG NewMaxQuota
676 /* mdl.c *********************************************************************/
685 /* mminit.c ******************************************************************/
689 MiShutdownMemoryManager(VOID
);
699 MmInitSystem(IN ULONG Phase
,
700 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
704 MiFreeInitMemory(VOID
);
708 MmInitializeMdlImplementation(VOID
);
710 /* pagefile.c ****************************************************************/
714 MmAllocSwapPage(VOID
);
718 MmDereserveSwapPages(ULONG Nr
);
722 MmFreeSwapPage(SWAPENTRY Entry
);
726 MmInitPagingFile(VOID
);
737 MmReserveSwapPages(ULONG Nr
);
750 ULONG BugCodeParameter1
,
751 ULONG BugCodeParameter2
,
752 ULONG BugCodeParameter3
,
753 ULONG BugCodeParameter4
,
754 struct _KTRAP_FRAME
* TrapFrame
759 MmIsAvailableSwapPage(VOID
);
763 MmShowOutOfSpaceMessagePagingFile(VOID
);
765 /* process.c ****************************************************************/
769 MmInitializeProcessAddressSpace(
770 IN PEPROCESS Process
,
771 IN PEPROCESS Clone OPTIONAL
,
772 IN PVOID Section OPTIONAL
,
774 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
779 MmCreatePeb(struct _EPROCESS
*Process
);
784 struct _EPROCESS
*Process
,
786 PINITIAL_TEB InitialTeb
792 struct _EPROCESS
*Process
,
798 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
802 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
806 MmGetSessionLocaleId(VOID
);
810 MmSetMemoryPriorityProcess(
811 IN PEPROCESS Process
,
812 IN UCHAR MemoryPriority
815 /* i386/pfault.c *************************************************************/
827 /* mm.c **********************************************************************/
832 IN BOOLEAN StoreInstruction
,
834 IN KPROCESSOR_MODE Mode
,
835 IN PVOID TrapInformation
838 /* anonmem.c *****************************************************************/
842 MmNotPresentFaultVirtualMemory(
843 PMMSUPPORT AddressSpace
,
844 MEMORY_AREA
* MemoryArea
,
851 MmPageOutVirtualMemory(
852 PMMSUPPORT AddressSpace
,
853 PMEMORY_AREA MemoryArea
,
855 struct _MM_PAGEOP
* PageOp
861 PMEMORY_AREA MemoryArea
,
863 PMEMORY_BASIC_INFORMATION Info
,
870 struct _EPROCESS
* Process
,
871 PMEMORY_AREA MemoryArea
877 PMMSUPPORT AddressSpace
,
878 PMEMORY_AREA MemoryArea
,
887 MmWritePageVirtualMemory(
888 PMMSUPPORT AddressSpace
,
894 /* kmap.c ********************************************************************/
898 ExAllocatePage(VOID
);
902 ExUnmapPage(PVOID Addr
);
906 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
917 MiZeroPage(PFN_TYPE Page
);
919 /* memsafe.s *****************************************************************/
923 MmSafeReadPtr(PVOID Source
);
925 /* pageop.c ******************************************************************/
929 MmReleasePageOp(PMM_PAGEOP PageOp
);
937 PMM_SECTION_SEGMENT Segment
,
949 PMM_SECTION_SEGMENT Segment
,
955 MmInitializePageOp(VOID
);
957 /* process.c *****************************************************************/
961 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
965 MmDeleteKernelStack(PVOID Stack
,
968 /* balace.c ******************************************************************/
972 MmInitializeMemoryConsumer(
974 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
979 MmInitializeBalancer(
980 ULONG NrAvailablePages
,
986 MmReleasePageMemoryConsumer(
993 MmRequestPageMemoryConsumer(
996 PPFN_TYPE AllocatedPage
1001 MiInitBalancerThread(VOID
);
1005 MmRebalanceMemoryConsumers(VOID
);
1007 /* rmap.c **************************************************************/
1011 MmSetRmapListHeadPage(
1013 struct _MM_RMAP_ENTRY
* ListHead
1016 struct _MM_RMAP_ENTRY
*
1018 MmGetRmapListHeadPage(PFN_TYPE Page
);
1024 struct _EPROCESS
*Process
,
1033 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1040 struct _EPROCESS
*Process
,
1046 MmInitializeRmapList(VOID
);
1050 MmSetCleanAllRmaps(PFN_TYPE Page
);
1054 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1058 MmIsDirtyPageRmap(PFN_TYPE Page
);
1062 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1066 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1068 /* freelist.c **********************************************************/
1070 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1074 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1077 extern RTL_BITMAP MiPfnBitMap
;
1079 /* Make sure the PFN number is valid */
1080 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1082 /* Make sure this page actually has a PFN entry */
1083 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1086 Page
= &MmPfnDatabase
[Pfn
];
1088 /* Make sure it's valid */
1097 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1100 // This will return the Page Frame Number (PFN) from the MMPFN
1102 return Pfn1
- MmPfnDatabase
;
1107 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1111 MmGetLRUFirstUserPage(VOID
);
1115 MmInsertLRULastUserPage(PFN_TYPE Page
);
1119 MmRemoveLRUUserPage(PFN_TYPE Page
);
1123 MmLockPage(PFN_TYPE Page
);
1127 MmUnlockPage(PFN_TYPE Page
);
1131 MmGetLockCountPage(PFN_TYPE Page
);
1135 MmInitializePageList(
1147 MmGetContinuousPages(
1148 ULONG NumberOfBytes
,
1149 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1150 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1151 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1157 MmZeroPageThreadMain(
1161 /* hypermap.c *****************************************************************/
1163 extern PEPROCESS HyperProcess
;
1164 extern KIRQL HyperIrql
;
1168 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1174 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1180 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1181 IN PFN_NUMBER NumberOfPages
);
1185 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1186 IN PFN_NUMBER NumberOfPages
);
1189 // ReactOS Compatibility Layer
1193 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1195 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1196 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1201 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1203 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1204 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1207 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1209 /* i386/page.c *********************************************************/
1213 MmCreateVirtualMappingForKernel(
1222 MmCommitPagedPoolAddress(
1229 MmCreateVirtualMapping(
1230 struct _EPROCESS
* Process
,
1239 MmCreateVirtualMappingUnsafe(
1240 struct _EPROCESS
* Process
,
1250 struct _EPROCESS
* Process
,
1256 struct _EPROCESS
* Process
,
1264 struct _EPROCESS
* Process
,
1270 MmInitGlobalKernelPageDirectory(VOID
);
1274 MmDisableVirtualMapping(
1275 struct _EPROCESS
*Process
,
1283 MmEnableVirtualMapping(
1284 struct _EPROCESS
*Process
,
1290 MmRawDeleteVirtualMapping(PVOID Address
);
1294 MmDeletePageFileMapping(
1295 struct _EPROCESS
*Process
,
1297 SWAPENTRY
* SwapEntry
1302 MmCreatePageFileMapping(
1303 struct _EPROCESS
*Process
,
1311 struct _EPROCESS
*Process
,
1317 MmTransferOwnershipPage(
1325 struct _EPROCESS
*Process
,
1333 SWAPENTRY SavedSwapEntry
1338 MmAllocPagesSpecifyRange(
1340 PHYSICAL_ADDRESS LowestAddress
,
1341 PHYSICAL_ADDRESS HighestAddress
,
1342 ULONG NumberOfPages
,
1348 MmDereferencePage(PFN_TYPE Page
);
1352 MmReferencePage(PFN_TYPE Page
);
1356 MmGetReferenceCountPage(PFN_TYPE Page
);
1360 MmIsPageInUse(PFN_TYPE Page
);
1364 MmSetSavedSwapEntryPage(
1366 SWAPENTRY SavedSwapEntry
);
1370 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1375 struct _EPROCESS
*Process
,
1381 MmCreatePageTable(PVOID PAddress
);
1386 struct _EPROCESS
*Process
,
1393 struct _EPROCESS
*Process
,
1399 MmCreateProcessAddressSpace(
1402 IN PULONG DirectoryTableBase
1407 MmInitializeHandBuiltProcess(
1408 IN PEPROCESS Process
,
1409 IN PULONG DirectoryTableBase
1415 MmInitializeHandBuiltProcess2(
1416 IN PEPROCESS Process
1421 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1425 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1429 MmDeleteVirtualMapping(
1430 struct _EPROCESS
*Process
,
1440 struct _EPROCESS
*Process
,
1446 MmMarkPageMapped(PFN_TYPE Page
);
1450 MmMarkPageUnmapped(PFN_TYPE Page
);
1455 struct _EPROCESS
*Process
,
1462 MiInitPageDirectoryMap(VOID
);
1466 MiGetUserPageDirectoryCount(VOID
);
1468 /* wset.c ********************************************************************/
1477 /* region.c ************************************************************/
1482 PMMSUPPORT AddressSpace
,
1484 PLIST_ENTRY RegionListHead
,
1489 PMM_ALTER_REGION_FUNC AlterFunc
1495 PLIST_ENTRY RegionListHead
,
1505 PLIST_ENTRY RegionListHead
,
1507 PVOID
* RegionBaseAddress
1510 /* section.c *****************************************************************/
1514 MmGetFileObjectForSection(
1515 IN PROS_SECTION_OBJECT Section
1519 MmGetFileNameForAddress(
1521 OUT PUNICODE_STRING ModuleName
1526 MmGetFileNameForSection(
1527 IN PROS_SECTION_OBJECT Section
,
1528 OUT POBJECT_NAME_INFORMATION
*ModuleName
1541 PMEMORY_AREA MemoryArea
,
1543 PMEMORY_BASIC_INFORMATION Info
,
1549 MmProtectSectionView(
1550 PMMSUPPORT AddressSpace
,
1551 PMEMORY_AREA MemoryArea
,
1560 MmWritePageSectionView(
1561 PMMSUPPORT AddressSpace
,
1569 MmInitSectionImplementation(VOID
);
1573 MmNotPresentFaultSectionView(
1574 PMMSUPPORT AddressSpace
,
1575 MEMORY_AREA
* MemoryArea
,
1582 MmPageOutSectionView(
1583 PMMSUPPORT AddressSpace
,
1584 PMEMORY_AREA MemoryArea
,
1586 struct _MM_PAGEOP
*PageOp
1591 MmCreatePhysicalMemorySection(VOID
);
1595 MmAccessFaultSectionView(
1596 PMMSUPPORT AddressSpace
,
1597 MEMORY_AREA
* MemoryArea
,
1604 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1606 /* mpw.c *********************************************************************/
1610 MmInitMpwThread(VOID
);
1614 MmInitBsmThread(VOID
);
1616 /* pager.c *******************************************************************/
1620 MiIsPagerThread(VOID
);
1624 MiStartPagerThread(VOID
);
1628 MiStopPagerThread(VOID
);
1632 MiQueryVirtualMemory(
1633 IN HANDLE ProcessHandle
,
1635 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1636 OUT PVOID VirtualMemoryInformation
,
1638 OUT PULONG ResultLength
1641 /* sysldr.c ******************************************************************/
1645 MiReloadBootLoadedDrivers(
1646 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1651 MiInitializeLoadedModuleList(
1652 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1658 IN PUNICODE_STRING FileName
,
1659 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1660 IN PUNICODE_STRING LoadedName OPTIONAL
,
1662 OUT PVOID
*ModuleObject
,
1663 OUT PVOID
*ImageBaseAddress
1668 MmUnloadSystemImage(
1669 IN PVOID ImageHandle
1675 IN HANDLE ImageHandle
,
1676 IN BOOLEAN PurgeSection
1681 MmCallDllInitialize(
1682 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1683 IN PLIST_ENTRY ListHead
1686 /* ReactOS Mm Hacks */
1689 MiSyncForProcessAttach(
1690 IN PKTHREAD NextThread
,
1691 IN PEPROCESS Process
1696 MiSyncForContextSwitch(
1700 extern PMMSUPPORT MmKernelAddressSpace
;
1704 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1706 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1711 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1713 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1718 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1720 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1721 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1726 MmGetCurrentAddressSpace(VOID
)
1728 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1733 MmGetKernelAddressSpace(VOID
)
1735 return MmKernelAddressSpace
;