- Initialize the used page count for the non paged pool in MmInitializeBalancer.
[reactos.git] / reactos / ntoskrnl / include / internal / mm.h
1 /*
2 * Higher level memory managment definitions
3 */
4
5 #ifndef __INCLUDE_INTERNAL_MM_H
6 #define __INCLUDE_INTERNAL_MM_H
7
8 #include <internal/ntoskrnl.h>
9 #include <internal/arch/mm.h>
10
11 /* TYPES *********************************************************************/
12
13 struct _EPROCESS;
14
15 struct _MM_RMAP_ENTRY;
16 struct _MM_PAGEOP;
17 typedef ULONG SWAPENTRY;
18
19 #define MEMORY_AREA_INVALID (0)
20 #define MEMORY_AREA_SECTION_VIEW (1)
21 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
22 #define MEMORY_AREA_NO_CACHE (3)
23 #define MEMORY_AREA_IO_MAPPING (4)
24 #define MEMORY_AREA_SYSTEM (5)
25 #define MEMORY_AREA_MDL_MAPPING (7)
26 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
27 #define MEMORY_AREA_CACHE_SEGMENT (9)
28 #define MEMORY_AREA_SHARED_DATA (10)
29 #define MEMORY_AREA_KERNEL_STACK (11)
30 #define MEMORY_AREA_PAGED_POOL (12)
31 #define MEMORY_AREA_NO_ACCESS (13)
32
33 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
34 ((x) / (4*1024*1024))
35 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
36 ((((x)) % (4*1024*1024)) / (4*1024))
37
38 #define NR_SECTION_PAGE_TABLES (1024)
39 #define NR_SECTION_PAGE_ENTRIES (1024)
40
41
42 /*
43 * Additional flags for protection attributes
44 */
45 #define PAGE_WRITETHROUGH (1024)
46 #define PAGE_SYSTEM (2048)
47 #define PAGE_FLAGS_VALID_FROM_USER_MODE (PAGE_READONLY | \
48 PAGE_READWRITE | \
49 PAGE_WRITECOPY | \
50 PAGE_EXECUTE | \
51 PAGE_EXECUTE_READ | \
52 PAGE_EXECUTE_READWRITE | \
53 PAGE_EXECUTE_WRITECOPY | \
54 PAGE_GUARD | \
55 PAGE_NOACCESS | \
56 PAGE_NOCACHE)
57
58 typedef struct
59 {
60 ULONG Entry[NR_SECTION_PAGE_ENTRIES];
61 } SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
62
63 typedef struct
64 {
65 PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
66 } SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
67
68 #define SEC_PHYSICALMEMORY (0x80000000)
69
70 #define MM_PAGEFILE_SEGMENT (0x1)
71 #define MM_DATAFILE_SEGMENT (0x2)
72
73 #define MM_SECTION_SEGMENT_BSS (0x1)
74
75 typedef struct _MM_SECTION_SEGMENT
76 {
77 ULONG FileOffset;
78 ULONG Protection;
79 ULONG Attributes;
80 ULONG Length;
81 ULONG RawLength;
82 FAST_MUTEX Lock;
83 ULONG ReferenceCount;
84 SECTION_PAGE_DIRECTORY PageDirectory;
85 ULONG Flags;
86 PVOID VirtualAddress;
87 ULONG Characteristics;
88 BOOLEAN WriteCopy;
89 } MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
90
91 typedef struct _MM_IMAGE_SECTION_OBJECT
92 {
93 PVOID ImageBase;
94 PVOID EntryPoint;
95 ULONG StackReserve;
96 ULONG StackCommit;
97 ULONG Subsystem;
98 ULONG MinorSubsystemVersion;
99 ULONG MajorSubsystemVersion;
100 ULONG ImageCharacteristics;
101 USHORT Machine;
102 BOOLEAN Executable;
103 ULONG NrSegments;
104 MM_SECTION_SEGMENT Segments[0];
105 } MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
106
107 typedef struct _SECTION_OBJECT
108 {
109 CSHORT Type;
110 CSHORT Size;
111 LARGE_INTEGER MaximumSize;
112 ULONG SectionPageProtection;
113 ULONG AllocationAttributes;
114 PFILE_OBJECT FileObject;
115 LIST_ENTRY ViewListHead;
116 KSPIN_LOCK ViewListLock;
117 union
118 {
119 PMM_IMAGE_SECTION_OBJECT ImageSection;
120 PMM_SECTION_SEGMENT Segment;
121 };
122 } SECTION_OBJECT;
123
124 #ifndef __USE_W32API
125
126 typedef struct _SECTION_OBJECT *PSECTION_OBJECT;
127
128 #endif /* __USE_W32API */
129
130 typedef struct
131 {
132 ULONG Type;
133 PVOID BaseAddress;
134 ULONG Length;
135 ULONG Attributes;
136 LIST_ENTRY Entry;
137 ULONG LockCount;
138 struct _EPROCESS* Process;
139 BOOLEAN DeleteInProgress;
140 ULONG PageOpCount;
141 union
142 {
143 struct
144 {
145 SECTION_OBJECT* Section;
146 ULONG ViewOffset;
147 LIST_ENTRY ViewListEntry;
148 PMM_SECTION_SEGMENT Segment;
149 BOOLEAN WriteCopyView;
150 LIST_ENTRY RegionListHead;
151 } SectionData;
152 struct
153 {
154 LIST_ENTRY RegionListHead;
155 } VirtualMemoryData;
156 } Data;
157 } MEMORY_AREA, *PMEMORY_AREA;
158
159 typedef struct _MADDRESS_SPACE
160 {
161 LIST_ENTRY MAreaListHead;
162 FAST_MUTEX Lock;
163 ULONG LowestAddress;
164 struct _EPROCESS* Process;
165 PUSHORT PageTableRefCountTable;
166 ULONG PageTableRefCountTableSize;
167 } MADDRESS_SPACE, *PMADDRESS_SPACE;
168
169
170 #ifndef __USE_W32API
171 /* VARIABLES */
172
173 extern PVOID MmSystemRangeStart;
174
175 #endif /* __USE_W32API */
176
177
178 /* FUNCTIONS */
179
180 VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace);
181 VOID MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace);
182 VOID MmInitializeKernelAddressSpace(VOID);
183 PMADDRESS_SPACE MmGetCurrentAddressSpace(VOID);
184 PMADDRESS_SPACE MmGetKernelAddressSpace(VOID);
185 NTSTATUS MmInitializeAddressSpace(struct _EPROCESS* Process,
186 PMADDRESS_SPACE AddressSpace);
187 NTSTATUS MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace);
188 PVOID STDCALL MmAllocateSection (IN ULONG Length);
189 NTSTATUS MmCreateMemoryArea(struct _EPROCESS* Process,
190 PMADDRESS_SPACE AddressSpace,
191 ULONG Type,
192 PVOID* BaseAddress,
193 ULONG Length,
194 ULONG Attributes,
195 MEMORY_AREA** Result,
196 BOOL FixedAddress,
197 BOOL TopDown);
198 MEMORY_AREA* MmOpenMemoryAreaByAddress(PMADDRESS_SPACE AddressSpace,
199 PVOID Address);
200 NTSTATUS MmInitMemoryAreas(VOID);
201 VOID MiInitializeNonPagedPool(VOID);
202 NTSTATUS MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
203 PVOID BaseAddress,
204 ULONG Length,
205 VOID (*FreePage)(PVOID Context, MEMORY_AREA* MemoryArea,
206 PVOID Address, PHYSICAL_ADDRESS PhysAddr, SWAPENTRY SwapEntry,
207 BOOLEAN Dirty),
208 PVOID FreePageContext);
209 VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead);
210 NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea);
211 NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea);
212 NTSTATUS MmInitSectionImplementation(VOID);
213
214 #ifndef __USE_W32API
215 #define MM_LOWEST_USER_ADDRESS (4096)
216 #endif
217
218 PMEMORY_AREA MmSplitMemoryArea(struct _EPROCESS* Process,
219 PMADDRESS_SPACE AddressSpace,
220 PMEMORY_AREA OriginalMemoryArea,
221 PVOID BaseAddress,
222 ULONG Length,
223 ULONG NewType,
224 ULONG NewAttributes);
225 PVOID
226 MmInitializePageList(PVOID FirstPhysKernelAddress,
227 PVOID LastPhysKernelAddress,
228 ULONG MemorySizeInPages,
229 ULONG LastKernelBase,
230 PADDRESS_RANGE BIOSMemoryMap,
231 ULONG AddressRangeCount);
232 PHYSICAL_ADDRESS
233 MmAllocPage(ULONG Consumer, SWAPENTRY SavedSwapEntry);
234 VOID MmDereferencePage(PHYSICAL_ADDRESS PhysicalAddress);
235 VOID MmReferencePage(PHYSICAL_ADDRESS PhysicalAddress);
236 VOID MmDeletePageTable(struct _EPROCESS* Process,
237 PVOID Address);
238 NTSTATUS MmCopyMmInfo(struct _EPROCESS* Src,
239 struct _EPROCESS* Dest);
240 NTSTATUS MmReleaseMmInfo(struct _EPROCESS* Process);
241 NTSTATUS Mmi386ReleaseMmInfo(struct _EPROCESS* Process);
242 VOID
243 MmDeleteVirtualMapping(struct _EPROCESS* Process,
244 PVOID Address,
245 BOOL FreePage,
246 BOOL* WasDirty,
247 PHYSICAL_ADDRESS* PhysicalPage);
248 VOID MmUpdateStackPageDir(PULONG LocalPageDir, struct _KTHREAD* KThread);
249
250 #define MM_PAGE_CLEAN (0)
251 #define MM_PAGE_DIRTY (1)
252
253 VOID MmBuildMdlFromPages(PMDL Mdl, PULONG Pages);
254 PVOID MmGetMdlPageAddress(PMDL Mdl, PVOID Offset);
255 VOID MiShutdownMemoryManager(VOID);
256 PHYSICAL_ADDRESS
257 MmGetPhysicalAddressForProcess(struct _EPROCESS* Process,
258 PVOID Address);
259 NTSTATUS STDCALL
260 MmUnmapViewOfSection(struct _EPROCESS* Process, PVOID BaseAddress);
261 VOID MmInitPagingFile(VOID);
262
263 /* FIXME: it should be in ddk/mmfuncs.h */
264 NTSTATUS
265 STDCALL
266 MmCreateSection (
267 OUT PSECTION_OBJECT * SectionObject,
268 IN ACCESS_MASK DesiredAccess,
269 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
270 IN PLARGE_INTEGER MaximumSize,
271 IN ULONG SectionPageProtection,
272 IN ULONG AllocationAttributes,
273 IN HANDLE FileHandle OPTIONAL,
274 IN PFILE_OBJECT File OPTIONAL
275 );
276
277 NTSTATUS MmPageFault(ULONG Cs,
278 PULONG Eip,
279 PULONG Eax,
280 ULONG Cr2,
281 ULONG ErrorCode);
282
283 NTSTATUS
284 MmAccessFault(KPROCESSOR_MODE Mode,
285 ULONG Address,
286 BOOLEAN FromMdl);
287 NTSTATUS
288 MmNotPresentFault(KPROCESSOR_MODE Mode,
289 ULONG Address,
290 BOOLEAN FromMdl);
291 NTSTATUS
292 MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
293 MEMORY_AREA* MemoryArea,
294 PVOID Address,
295 BOOLEAN Locked);
296 NTSTATUS
297 MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
298 MEMORY_AREA* MemoryArea,
299 PVOID Address,
300 BOOLEAN Locked);
301 NTSTATUS MmWaitForPage(PVOID Page);
302 VOID MmClearWaitPage(PVOID Page);
303 VOID MmSetWaitPage(PVOID Page);
304 BOOLEAN MmIsDirtyPage(struct _EPROCESS* Process, PVOID Address);
305 BOOLEAN MmIsPageTablePresent(PVOID PAddress);
306 NTSTATUS
307 MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
308 PMEMORY_AREA MemoryArea,
309 PVOID Address,
310 struct _MM_PAGEOP* PageOp);
311 NTSTATUS
312 MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
313 PMEMORY_AREA MemoryArea,
314 PVOID Address,
315 struct _MM_PAGEOP* PageOp);
316 MEMORY_AREA* MmOpenMemoryAreaByRegion(PMADDRESS_SPACE AddressSpace,
317 PVOID Address,
318 ULONG Length);
319 PVOID MmFindGap(PMADDRESS_SPACE AddressSpace, ULONG Length, BOOL TopDown);
320 VOID ExUnmapPage(PVOID Addr);
321 PVOID ExAllocatePage(VOID);
322
323 BOOLEAN MmReserveSwapPages(ULONG Nr);
324 VOID MmDereserveSwapPages(ULONG Nr);
325 SWAPENTRY MmAllocSwapPage(VOID);
326 VOID MmFreeSwapPage(SWAPENTRY Entry);
327
328 VOID MmInit1(ULONG FirstKernelPhysAddress,
329 ULONG LastKernelPhysAddress,
330 ULONG LastKernelAddress,
331 PADDRESS_RANGE BIOSMemoryMap,
332 ULONG AddressRangeCount,
333 ULONG MaxMemInMeg);
334 VOID MmInit2(VOID);
335 VOID MmInit3(VOID);
336 VOID MiFreeInitMemory(VOID);
337 NTSTATUS MmInitPagerThread(VOID);
338 NTSTATUS MmInitZeroPageThread(VOID);
339
340 VOID MiInitKernelMap(VOID);
341 NTSTATUS MmCreatePageTable(PVOID PAddress);
342
343 typedef struct
344 {
345 ULONG NrTotalPages;
346 ULONG NrSystemPages;
347 ULONG NrReservedPages;
348 ULONG NrUserPages;
349 ULONG NrFreePages;
350 ULONG NrDirtyPages;
351 ULONG NrLockedPages;
352 ULONG PagingRequestsInLastMinute;
353 ULONG PagingRequestsInLastFiveMinutes;
354 ULONG PagingRequestsInLastFifteenMinutes;
355 } MM_STATS;
356
357 extern MM_STATS MmStats;
358
359 PVOID
360 MmGetDirtyPagesFromWorkingSet(struct _EPROCESS* Process);
361 NTSTATUS
362 MmWriteToSwapPage(SWAPENTRY SwapEntry, PMDL Mdl);
363 NTSTATUS
364 MmReadFromSwapPage(SWAPENTRY SwapEntry, PMDL Mdl);
365 VOID
366 MmSetFlagsPage(PHYSICAL_ADDRESS PhysicalAddress, ULONG Flags);
367 ULONG
368 MmGetFlagsPage(PHYSICAL_ADDRESS PhysicalAddress);
369 VOID MmSetSavedSwapEntryPage(PHYSICAL_ADDRESS PhysicalAddress,
370 SWAPENTRY SavedSwapEntry);
371 SWAPENTRY MmGetSavedSwapEntryPage(PHYSICAL_ADDRESS PhysicalAddress);
372 VOID MmSetCleanPage(struct _EPROCESS* Process, PVOID Address);
373 VOID MmLockPage(PHYSICAL_ADDRESS PhysicalPage);
374 VOID MmUnlockPage(PHYSICAL_ADDRESS PhysicalPage);
375 ULONG MmGetLockCountPage(PHYSICAL_ADDRESS PhysicalPage);
376
377 NTSTATUS MmSafeCopyFromUser(PVOID Dest, const VOID *Src, ULONG Count);
378 NTSTATUS MmSafeCopyToUser(PVOID Dest, const VOID *Src, ULONG Count);
379 NTSTATUS
380 MmCreatePhysicalMemorySection(VOID);
381 PHYSICAL_ADDRESS
382 MmGetContinuousPages(ULONG NumberOfBytes,
383 PHYSICAL_ADDRESS HighestAcceptableAddress,
384 ULONG Alignment);
385
386 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
387
388 NTSTATUS
389 MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
390 MEMORY_AREA* MemoryArea,
391 PVOID Address,
392 BOOLEAN Locked);
393 ULONG
394 MmGetPageProtect(struct _EPROCESS* Process, PVOID Address);
395 PVOID
396 ExAllocatePageWithPhysPage(PHYSICAL_ADDRESS PhysPage);
397 ULONG
398 MmGetReferenceCountPage(PHYSICAL_ADDRESS PhysicalAddress);
399 BOOLEAN
400 MmIsUsablePage(PHYSICAL_ADDRESS PhysicalAddress);
401
402 #define MM_PAGEOP_PAGEIN (1)
403 #define MM_PAGEOP_PAGEOUT (2)
404 #define MM_PAGEOP_PAGESYNCH (3)
405 #define MM_PAGEOP_ACCESSFAULT (4)
406
407 typedef struct _MM_PAGEOP
408 {
409 /* Type of operation. */
410 ULONG OpType;
411 /* Number of threads interested in this operation. */
412 ULONG ReferenceCount;
413 /* Event that will be set when the operation is completed. */
414 KEVENT CompletionEvent;
415 /* Status of the operation once it is completed. */
416 NTSTATUS Status;
417 /* TRUE if the operation was abandoned. */
418 BOOLEAN Abandoned;
419 /* The memory area to be affected by the operation. */
420 PMEMORY_AREA MArea;
421 ULONG Hash;
422 struct _MM_PAGEOP* Next;
423 struct _ETHREAD* Thread;
424 /*
425 * These fields are used to identify the operation if it is against a
426 * virtual memory area.
427 */
428 ULONG Pid;
429 PVOID Address;
430 /*
431 * These fields are used to identify the operation if it is against a
432 * section mapping.
433 */
434 PMM_SECTION_SEGMENT Segment;
435 ULONG Offset;
436 } MM_PAGEOP, *PMM_PAGEOP;
437
438 VOID
439 MmReleasePageOp(PMM_PAGEOP PageOp);
440
441 PMM_PAGEOP
442 MmGetPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
443 PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType);
444 PMM_PAGEOP
445 MmCheckForPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
446 PMM_SECTION_SEGMENT Segment, ULONG Offset);
447 VOID
448 MmInitializePageOp(VOID);
449 VOID
450 MiDebugDumpNonPagedPool(BOOLEAN NewOnly);
451 VOID
452 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly);
453 VOID
454 MmMarkPageMapped(PHYSICAL_ADDRESS PhysicalAddress);
455 VOID
456 MmMarkPageUnmapped(PHYSICAL_ADDRESS PhysicalAddress);
457 VOID
458 MmFreeSectionSegments(PFILE_OBJECT FileObject);
459
460
461
462 VOID
463 MmFreeVirtualMemory(struct _EPROCESS* Process, PMEMORY_AREA MemoryArea);
464 NTSTATUS
465 MiCopyFromUserPage(PHYSICAL_ADDRESS DestPhysPage, PVOID SourceAddress);
466 NTSTATUS
467 MiZeroPage(PHYSICAL_ADDRESS PhysPage);
468 BOOLEAN
469 MmIsAccessedAndResetAccessPage(struct _EPROCESS* Process, PVOID Address);
470
471 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
472
473 NTSTATUS
474 MmCreateVirtualMappingForKernel(PVOID Address,
475 ULONG flProtect,
476 PHYSICAL_ADDRESS PhysicalAddress);
477 NTSTATUS MmCommitPagedPoolAddress(PVOID Address);
478 NTSTATUS MmCreateVirtualMapping(struct _EPROCESS* Process,
479 PVOID Address,
480 ULONG flProtect,
481 PHYSICAL_ADDRESS PhysicalAddress,
482 BOOLEAN MayWait);
483 NTSTATUS
484 MmCreateVirtualMappingUnsafe(struct _EPROCESS* Process,
485 PVOID Address,
486 ULONG flProtect,
487 PHYSICAL_ADDRESS PhysicalAddress,
488 BOOLEAN MayWait);
489
490 VOID MmSetPageProtect(struct _EPROCESS* Process,
491 PVOID Address,
492 ULONG flProtect);
493 BOOLEAN MmIsPagePresent(struct _EPROCESS* Process,
494 PVOID Address);
495
496 VOID MmInitGlobalKernelPageDirectory(VOID);
497
498 /* Memory balancing. */
499 VOID
500 MmInitializeMemoryConsumer(ULONG Consumer,
501 NTSTATUS (*Trim)(ULONG Target, ULONG Priority,
502 PULONG NrFreed));
503 VOID
504 MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages);
505 NTSTATUS
506 MmReleasePageMemoryConsumer(ULONG Consumer, PHYSICAL_ADDRESS Page);
507 NTSTATUS
508 MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
509 PHYSICAL_ADDRESS* AllocatedPage);
510
511 #define MC_CACHE (0)
512 #define MC_USER (1)
513 #define MC_PPOOL (2)
514 #define MC_NPPOOL (3)
515 #define MC_MAXIMUM (4)
516
517 VOID
518 MmSetRmapListHeadPage(PHYSICAL_ADDRESS PhysicalAddress,
519 struct _MM_RMAP_ENTRY* ListHead);
520 struct _MM_RMAP_ENTRY*
521 MmGetRmapListHeadPage(PHYSICAL_ADDRESS PhysicalAddress);
522 VOID
523 MmInsertRmap(PHYSICAL_ADDRESS PhysicalAddress, PEPROCESS Process,
524 PVOID Address);
525 VOID
526 MmDeleteAllRmaps(PHYSICAL_ADDRESS PhysicalAddress, PVOID Context,
527 VOID (*DeleteMapping)(PVOID Context, PEPROCESS Process, PVOID Address));
528 VOID
529 MmDeleteRmap(PHYSICAL_ADDRESS PhysicalAddress, PEPROCESS Process,
530 PVOID Address);
531 VOID
532 MmInitializeRmapList(VOID);
533 PHYSICAL_ADDRESS
534 MmGetLRUNextUserPage(PHYSICAL_ADDRESS PreviousPhysicalAddress);
535 PHYSICAL_ADDRESS
536 MmGetLRUFirstUserPage(VOID);
537 NTSTATUS
538 MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress);
539 NTSTATUS
540 MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages);
541
542 VOID
543 MmDisableVirtualMapping(PEPROCESS Process, PVOID Address, BOOL* WasDirty, PHYSICAL_ADDRESS* PhysicalAddr);
544 VOID MmEnableVirtualMapping(PEPROCESS Process, PVOID Address);
545 VOID
546 MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
547 SWAPENTRY* SwapEntry);
548 NTSTATUS
549 MmCreatePageFileMapping(PEPROCESS Process,
550 PVOID Address,
551 SWAPENTRY SwapEntry);
552 BOOLEAN MmIsPageSwapEntry(PEPROCESS Process, PVOID Address);
553 VOID
554 MmTransferOwnershipPage(PHYSICAL_ADDRESS PhysicalAddress, ULONG NewConsumer);
555 VOID MmSetDirtyPage(PEPROCESS Process, PVOID Address);
556 VOID
557 MmInitializeMdlImplementation(VOID);
558 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
559 struct _KTRAP_FRAME;
560 NTSTATUS STDCALL
561 MmDumpToPagingFile(ULONG BugCode,
562 ULONG BugCodeParameter1,
563 ULONG BugCodeParameter2,
564 ULONG BugCodeParameter3,
565 ULONG BugCodeParameter4,
566 struct _KTRAP_FRAME* TrapFrame);
567
568 typedef VOID (*PMM_ALTER_REGION_FUNC)(PMADDRESS_SPACE AddressSpace,
569 PVOID BaseAddress, ULONG Length,
570 ULONG OldType, ULONG OldProtect,
571 ULONG NewType, ULONG NewProtect);
572
573 typedef struct _MM_REGION
574 {
575 ULONG Type;
576 ULONG Protect;
577 ULONG Length;
578 LIST_ENTRY RegionListEntry;
579 } MM_REGION, *PMM_REGION;
580
581 NTSTATUS
582 MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress,
583 PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length,
584 ULONG NewType, ULONG NewProtect,
585 PMM_ALTER_REGION_FUNC AlterFunc);
586 VOID
587 MmInitialiseRegion(PLIST_ENTRY RegionListHead, ULONG Length, ULONG Type,
588 ULONG Protect);
589 PMM_REGION
590 MmFindRegion(PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID Address,
591 PVOID* RegionBaseAddress);
592 NTSTATUS STDCALL
593 MmQueryAnonMem(PMEMORY_AREA MemoryArea,
594 PVOID Address,
595 PMEMORY_BASIC_INFORMATION Info,
596 PULONG ResultLength);
597 NTSTATUS STDCALL
598 MmQuerySectionView(PMEMORY_AREA MemoryArea,
599 PVOID Address,
600 PMEMORY_BASIC_INFORMATION Info,
601 PULONG ResultLength);
602 NTSTATUS
603 MmProtectAnonMem(PMADDRESS_SPACE AddressSpace,
604 PMEMORY_AREA MemoryArea,
605 PVOID BaseAddress,
606 ULONG Length,
607 ULONG Protect,
608 PULONG OldProtect);
609 NTSTATUS
610 MmProtectSectionView(PMADDRESS_SPACE AddressSpace,
611 PMEMORY_AREA MemoryArea,
612 PVOID BaseAddress,
613 ULONG Length,
614 ULONG Protect,
615 PULONG OldProtect);
616 NTSTATUS
617 MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
618 PMEMORY_AREA MArea,
619 PVOID Address,
620 PMM_PAGEOP PageOp);
621 NTSTATUS
622 MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
623 PMEMORY_AREA MArea,
624 PVOID Address,
625 PMM_PAGEOP PageOp);
626 VOID
627 MmSetCleanAllRmaps(PHYSICAL_ADDRESS PhysicalAddress);
628 VOID
629 MmSetDirtyAllRmaps(PHYSICAL_ADDRESS PhysicalAddress);
630 NTSTATUS
631 MmWritePagePhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress);
632 BOOL
633 MmIsDirtyPageRmap(PHYSICAL_ADDRESS PhysicalAddress);
634 NTSTATUS MmInitMpwThread(VOID);
635 BOOLEAN
636 MmIsAvailableSwapPage(VOID);
637 VOID
638 MmShowOutOfSpaceMessagePagingFile(VOID);
639 VOID
640 MmRebalanceMemoryConsumers(VOID);
641 BOOLEAN
642 MiIsPagerThread(VOID);
643 VOID
644 MiStartPagerThread(VOID);
645 VOID
646 MmSetLRULastPage(PHYSICAL_ADDRESS PhysicalAddress);
647 VOID
648 MmRawDeleteVirtualMapping(PVOID Address);
649 VOID
650 MiStopPagerThread(VOID);
651 NTSTATUS
652 MmCreateVirtualMappingDump(PVOID Address,
653 ULONG flProtect,
654 PHYSICAL_ADDRESS PhysicalAddress);
655
656 #endif