Sync with trunk (48237)
[reactos.git] / ntoskrnl / include / internal / mm.h
1 #pragma once
2
3 #include <internal/arch/mm.h>
4
5 /* TYPES *********************************************************************/
6
7 struct _EPROCESS;
8
9 extern PFN_NUMBER MiFreeSwapPages;
10 extern PFN_NUMBER MiUsedSwapPages;
11 extern SIZE_T MmPagedPoolSize;
12 extern SIZE_T MmTotalPagedPoolQuota;
13 extern SIZE_T MmTotalNonPagedPoolQuota;
14 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
15 extern PFN_NUMBER 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;
21
22 extern PVOID MmPagedPoolBase;
23 extern SIZE_T MmPagedPoolSize;
24
25 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
26 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
27
28 extern LIST_ENTRY MmLoadedUserImageList;
29
30 extern KMUTANT MmSystemLoadLock;
31
32 extern ULONG MmNumberOfPagingFiles;
33
34 extern PVOID MmUnloadedDrivers;
35 extern PVOID MmLastUnloadedDrivers;
36 extern PVOID MmTriageActionTaken;
37 extern PVOID KernelVerifier;
38 extern MM_DRIVER_VERIFIER_DATA MmVerifierData;
39
40 extern SIZE_T MmTotalCommitLimit;
41 extern SIZE_T MmTotalCommittedPages;
42 extern SIZE_T MmSharedCommit;
43 extern SIZE_T MmDriverCommit;
44 extern SIZE_T MmProcessCommit;
45 extern SIZE_T MmPagedPoolCommit;
46 extern SIZE_T MmPeakCommitment;
47 extern SIZE_T MmtotalCommitLimitMaximum;
48
49 extern PVOID MiDebugMapping;
50 extern PMMPTE MmDebugPte;
51
52 struct _KTRAP_FRAME;
53 struct _EPROCESS;
54 struct _MM_RMAP_ENTRY;
55 struct _MM_PAGEOP;
56 typedef ULONG SWAPENTRY;
57
58 //
59 // MmDbgCopyMemory Flags
60 //
61 #define MMDBG_COPY_WRITE 0x00000001
62 #define MMDBG_COPY_PHYSICAL 0x00000002
63 #define MMDBG_COPY_UNSAFE 0x00000004
64 #define MMDBG_COPY_CACHED 0x00000008
65 #define MMDBG_COPY_UNCACHED 0x00000010
66 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
67
68 //
69 // Maximum chunk size per copy
70 //
71 #define MMDBG_COPY_MAX_SIZE 0x8
72
73 #if defined(_X86_)
74 #define MI_STATIC_MEMORY_AREAS (14)
75 #else
76 #define MI_STATIC_MEMORY_AREAS (13)
77 #endif
78
79 #define MEMORY_AREA_INVALID (0)
80 #define MEMORY_AREA_SECTION_VIEW (1)
81 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
82 #define MEMORY_AREA_NO_CACHE (3)
83 #define MEMORY_AREA_IO_MAPPING (4)
84 #define MEMORY_AREA_SYSTEM (5)
85 #define MEMORY_AREA_MDL_MAPPING (7)
86 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
87 #define MEMORY_AREA_CACHE_SEGMENT (9)
88 #define MEMORY_AREA_SHARED_DATA (10)
89 #define MEMORY_AREA_KERNEL_STACK (11)
90 #define MEMORY_AREA_PAGED_POOL (12)
91 #define MEMORY_AREA_NO_ACCESS (13)
92 #define MEMORY_AREA_PEB_OR_TEB (14)
93 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
94 #define MEMORY_AREA_STATIC (0x80000000)
95
96 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
97
98 #define MM_CORE_DUMP_TYPE_NONE (0x0)
99 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
100 #define MM_CORE_DUMP_TYPE_FULL (0x2)
101
102 #define MM_PAGEOP_PAGEIN (1)
103 #define MM_PAGEOP_PAGEOUT (2)
104 #define MM_PAGEOP_PAGESYNCH (3)
105 #define MM_PAGEOP_ACCESSFAULT (4)
106
107 /* Number of list heads to use */
108 #define MI_FREE_POOL_LISTS 4
109
110
111 /* Signature of free pool blocks */
112 #define MM_FREE_POOL_TAG 'lprF'
113
114 /* Although Microsoft says this isn't hardcoded anymore,
115 they won't be able to change it. Stuff depends on it */
116 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
117
118 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
119
120 /*
121 * Additional flags for protection attributes
122 */
123 #define PAGE_WRITETHROUGH (1024)
124 #define PAGE_SYSTEM (2048)
125
126 #define SEC_PHYSICALMEMORY (0x80000000)
127
128 #define MM_PAGEFILE_SEGMENT (0x1)
129 #define MM_DATAFILE_SEGMENT (0x2)
130
131 #define MC_CACHE (0)
132 #define MC_USER (1)
133 #define MC_PPOOL (2)
134 #define MC_NPPOOL (3)
135 #define MC_SYSTEM (4)
136 #define MC_MAXIMUM (5)
137
138 #define PAGED_POOL_MASK 1
139 #define MUST_SUCCEED_POOL_MASK 2
140 #define CACHE_ALIGNED_POOL_MASK 4
141 #define QUOTA_POOL_MASK 8
142 #define SESSION_POOL_MASK 32
143 #define VERIFIER_POOL_MASK 64
144
145 #define MM_PAGED_POOL_SIZE (100*1024*1024)
146 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
147
148 /*
149 * Paged and non-paged pools are 8-byte aligned
150 */
151 #define MM_POOL_ALIGNMENT 8
152
153 #define MM_ROUND_UP(x,s) \
154 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
155
156 #define MM_ROUND_DOWN(x,s) \
157 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
158
159 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
160 (PAGE_READONLY | \
161 PAGE_READWRITE | \
162 PAGE_WRITECOPY | \
163 PAGE_EXECUTE | \
164 PAGE_EXECUTE_READ | \
165 PAGE_EXECUTE_READWRITE | \
166 PAGE_EXECUTE_WRITECOPY | \
167 PAGE_GUARD | \
168 PAGE_NOACCESS | \
169 PAGE_NOCACHE)
170
171 #define PAGE_FLAGS_VALID_FOR_SECTION \
172 (PAGE_READONLY | \
173 PAGE_READWRITE | \
174 PAGE_WRITECOPY | \
175 PAGE_EXECUTE | \
176 PAGE_EXECUTE_READ | \
177 PAGE_EXECUTE_READWRITE | \
178 PAGE_EXECUTE_WRITECOPY | \
179 PAGE_NOACCESS)
180
181 #define PAGE_IS_READABLE \
182 (PAGE_READONLY | \
183 PAGE_READWRITE | \
184 PAGE_WRITECOPY | \
185 PAGE_EXECUTE_READ | \
186 PAGE_EXECUTE_READWRITE | \
187 PAGE_EXECUTE_WRITECOPY)
188
189 #define PAGE_IS_WRITABLE \
190 (PAGE_READWRITE | \
191 PAGE_WRITECOPY | \
192 PAGE_EXECUTE_READWRITE | \
193 PAGE_EXECUTE_WRITECOPY)
194
195 #define PAGE_IS_EXECUTABLE \
196 (PAGE_EXECUTE | \
197 PAGE_EXECUTE_READ | \
198 PAGE_EXECUTE_READWRITE | \
199 PAGE_EXECUTE_WRITECOPY)
200
201 #define PAGE_IS_WRITECOPY \
202 (PAGE_WRITECOPY | \
203 PAGE_EXECUTE_WRITECOPY)
204
205
206 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
207 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
208
209 #define InterlockedExchangePte(PointerPte, Value) \
210 InterlockedExchange((PLONG)(PointerPte), Value)
211
212 typedef struct
213 {
214 ULONG Entry[NR_SECTION_PAGE_ENTRIES];
215 } SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
216
217 typedef struct
218 {
219 PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
220 } SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
221
222 typedef struct _MM_SECTION_SEGMENT
223 {
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 */
228 ULONG Protection;
229 FAST_MUTEX Lock; /* lock which protects the page directory */
230 ULONG ReferenceCount;
231 SECTION_PAGE_DIRECTORY PageDirectory;
232 ULONG Flags;
233 ULONG Characteristics;
234 BOOLEAN WriteCopy;
235 } MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
236
237 typedef struct _MM_IMAGE_SECTION_OBJECT
238 {
239 ULONG_PTR ImageBase;
240 ULONG_PTR StackReserve;
241 ULONG_PTR StackCommit;
242 ULONG_PTR EntryPoint;
243 USHORT Subsystem;
244 USHORT ImageCharacteristics;
245 USHORT MinorSubsystemVersion;
246 USHORT MajorSubsystemVersion;
247 USHORT Machine;
248 BOOLEAN Executable;
249 ULONG NrSegments;
250 ULONG ImageSize;
251 PMM_SECTION_SEGMENT Segments;
252 } MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
253
254 typedef struct _ROS_SECTION_OBJECT
255 {
256 CSHORT Type;
257 CSHORT Size;
258 LARGE_INTEGER MaximumSize;
259 ULONG SectionPageProtection;
260 ULONG AllocationAttributes;
261 PFILE_OBJECT FileObject;
262 union
263 {
264 PMM_IMAGE_SECTION_OBJECT ImageSection;
265 PMM_SECTION_SEGMENT Segment;
266 };
267 } ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT;
268
269 typedef struct _MEMORY_AREA
270 {
271 PVOID StartingAddress;
272 PVOID EndingAddress;
273 struct _MEMORY_AREA *Parent;
274 struct _MEMORY_AREA *LeftChild;
275 struct _MEMORY_AREA *RightChild;
276 ULONG Type;
277 ULONG Protect;
278 ULONG Flags;
279 BOOLEAN DeleteInProgress;
280 ULONG PageOpCount;
281 union
282 {
283 struct
284 {
285 ROS_SECTION_OBJECT* Section;
286 ULONG ViewOffset;
287 PMM_SECTION_SEGMENT Segment;
288 BOOLEAN WriteCopyView;
289 LIST_ENTRY RegionListHead;
290 } SectionData;
291 struct
292 {
293 LIST_ENTRY RegionListHead;
294 } VirtualMemoryData;
295 } Data;
296 } MEMORY_AREA, *PMEMORY_AREA;
297
298 //
299 // These two mappings are actually used by Windows itself, based on the ASSERTS
300 //
301 #define StartOfAllocation ReadInProgress
302 #define EndOfAllocation WriteInProgress
303
304 typedef struct _MMPFNENTRY
305 {
306 USHORT Modified:1;
307 USHORT ReadInProgress:1; // StartOfAllocation
308 USHORT WriteInProgress:1; // EndOfAllocation
309 USHORT PrototypePte:1; // Zero
310 USHORT PageColor:4; // LockCount
311 USHORT PageLocation:3; // Consumer
312 USHORT RemovalRequested:1;
313 USHORT CacheAttribute:2; // Type
314 USHORT Rom:1;
315 USHORT ParityError:1;
316 } MMPFNENTRY;
317
318 typedef struct _MMPFN
319 {
320 union
321 {
322 PFN_NUMBER Flink; // ListEntry.Flink
323 ULONG WsIndex;
324 PKEVENT Event;
325 NTSTATUS ReadStatus;
326 SINGLE_LIST_ENTRY NextStackPfn;
327 } u1;
328 PMMPTE PteAddress; // ListEntry.Blink
329 union
330 {
331 PFN_NUMBER Blink;
332 ULONG_PTR ShareCount; // MapCount
333 } u2;
334 union
335 {
336 struct
337 {
338 USHORT ReferenceCount; // ReferenceCount
339 MMPFNENTRY e1;
340 };
341 struct
342 {
343 USHORT ReferenceCount;
344 USHORT ShortFlags;
345 } e2;
346 } u3;
347 union
348 {
349 MMPTE OriginalPte;
350 LONG AweReferenceCount; // RmapListHead
351 };
352 union
353 {
354 ULONG_PTR EntireFrame; // SavedSwapEntry
355 struct
356 {
357 ULONG_PTR PteFrame:25;
358 ULONG_PTR InPageError:1;
359 ULONG_PTR VerifierAllocation:1;
360 ULONG_PTR AweAllocation:1;
361 ULONG_PTR Priority:3;
362 ULONG_PTR MustBeCached:1;
363 };
364 } u4;
365 } MMPFN, *PMMPFN;
366
367 extern PMMPFN MmPfnDatabase;
368
369 typedef struct _MMPFNLIST
370 {
371 PFN_NUMBER Total;
372 MMLISTS ListName;
373 PFN_NUMBER Flink;
374 PFN_NUMBER Blink;
375 } MMPFNLIST, *PMMPFNLIST;
376
377 extern MMPFNLIST MmZeroedPageListHead;
378 extern MMPFNLIST MmFreePageListHead;
379 extern MMPFNLIST MmStandbyPageListHead;
380 extern MMPFNLIST MmModifiedPageListHead;
381 extern MMPFNLIST MmModifiedNoWritePageListHead;
382
383 typedef struct _MM_PAGEOP
384 {
385 /* Type of operation. */
386 ULONG OpType;
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. */
392 NTSTATUS Status;
393 /* TRUE if the operation was abandoned. */
394 BOOLEAN Abandoned;
395 /* The memory area to be affected by the operation. */
396 PMEMORY_AREA MArea;
397 ULONG Hash;
398 struct _MM_PAGEOP* Next;
399 struct _ETHREAD* Thread;
400 /*
401 * These fields are used to identify the operation if it is against a
402 * virtual memory area.
403 */
404 HANDLE Pid;
405 PVOID Address;
406 /*
407 * These fields are used to identify the operation if it is against a
408 * section mapping.
409 */
410 PMM_SECTION_SEGMENT Segment;
411 ULONG Offset;
412 } MM_PAGEOP, *PMM_PAGEOP;
413
414 typedef struct _MM_MEMORY_CONSUMER
415 {
416 ULONG PagesUsed;
417 ULONG PagesTarget;
418 NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed);
419 } MM_MEMORY_CONSUMER, *PMM_MEMORY_CONSUMER;
420
421 typedef struct _MM_REGION
422 {
423 ULONG Type;
424 ULONG Protect;
425 ULONG Length;
426 LIST_ENTRY RegionListEntry;
427 } MM_REGION, *PMM_REGION;
428
429 /* Entry describing free pool memory */
430 typedef struct _MMFREE_POOL_ENTRY
431 {
432 LIST_ENTRY List;
433 PFN_NUMBER Size;
434 ULONG Signature;
435 struct _MMFREE_POOL_ENTRY *Owner;
436 } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
437
438 /* Paged pool information */
439 typedef struct _MM_PAGED_POOL_INFO
440 {
441 PRTL_BITMAP PagedPoolAllocationMap;
442 PRTL_BITMAP EndOfPagedPoolBitmap;
443 PMMPTE FirstPteForPagedPool;
444 PMMPTE LastPteForPagedPool;
445 PMMPTE NextPdeForPagedPoolExpansion;
446 ULONG PagedPoolHint;
447 SIZE_T PagedPoolCommit;
448 SIZE_T AllocatedPagedPool;
449 } MM_PAGED_POOL_INFO, *PMM_PAGED_POOL_INFO;
450
451 extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
452
453 typedef VOID
454 (*PMM_ALTER_REGION_FUNC)(
455 PMMSUPPORT AddressSpace,
456 PVOID BaseAddress,
457 ULONG Length,
458 ULONG OldType,
459 ULONG OldProtect,
460 ULONG NewType,
461 ULONG NewProtect
462 );
463
464 typedef VOID
465 (*PMM_FREE_PAGE_FUNC)(
466 PVOID Context,
467 PMEMORY_AREA MemoryArea,
468 PVOID Address,
469 PFN_NUMBER Page,
470 SWAPENTRY SwapEntry,
471 BOOLEAN Dirty
472 );
473
474 //
475 // Mm copy support for Kd
476 //
477 NTSTATUS
478 NTAPI
479 MmDbgCopyMemory(
480 IN ULONG64 Address,
481 IN PVOID Buffer,
482 IN ULONG Size,
483 IN ULONG Flags
484 );
485
486 //
487 // Determines if a given address is a session address
488 //
489 BOOLEAN
490 NTAPI
491 MmIsSessionAddress(
492 IN PVOID Address
493 );
494
495 /* marea.c *******************************************************************/
496
497 NTSTATUS
498 NTAPI
499 MmCreateMemoryArea(
500 PMMSUPPORT AddressSpace,
501 ULONG Type,
502 PVOID *BaseAddress,
503 ULONG_PTR Length,
504 ULONG Protection,
505 PMEMORY_AREA *Result,
506 BOOLEAN FixedAddress,
507 ULONG AllocationFlags,
508 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
509 );
510
511 PMEMORY_AREA
512 NTAPI
513 MmLocateMemoryAreaByAddress(
514 PMMSUPPORT AddressSpace,
515 PVOID Address
516 );
517
518 ULONG_PTR
519 NTAPI
520 MmFindGapAtAddress(
521 PMMSUPPORT AddressSpace,
522 PVOID Address
523 );
524
525 NTSTATUS
526 NTAPI
527 MmFreeMemoryArea(
528 PMMSUPPORT AddressSpace,
529 PMEMORY_AREA MemoryArea,
530 PMM_FREE_PAGE_FUNC FreePage,
531 PVOID FreePageContext
532 );
533
534 NTSTATUS
535 NTAPI
536 MmFreeMemoryAreaByPtr(
537 PMMSUPPORT AddressSpace,
538 PVOID BaseAddress,
539 PMM_FREE_PAGE_FUNC FreePage,
540 PVOID FreePageContext
541 );
542
543 VOID
544 NTAPI
545 MmDumpMemoryAreas(PMMSUPPORT AddressSpace);
546
547 PMEMORY_AREA
548 NTAPI
549 MmLocateMemoryAreaByRegion(
550 PMMSUPPORT AddressSpace,
551 PVOID Address,
552 ULONG_PTR Length
553 );
554
555 PVOID
556 NTAPI
557 MmFindGap(
558 PMMSUPPORT AddressSpace,
559 ULONG_PTR Length,
560 ULONG_PTR Granularity,
561 BOOLEAN TopDown
562 );
563
564 VOID
565 NTAPI
566 MmReleaseMemoryAreaIfDecommitted(
567 struct _EPROCESS *Process,
568 PMMSUPPORT AddressSpace,
569 PVOID BaseAddress
570 );
571
572 VOID
573 NTAPI
574 MmMapMemoryArea(PVOID BaseAddress,
575 ULONG Length,
576 ULONG Consumer,
577 ULONG Protection);
578
579 /* npool.c *******************************************************************/
580
581 VOID
582 NTAPI
583 MiDebugDumpNonPagedPool(BOOLEAN NewOnly);
584
585 VOID
586 NTAPI
587 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly);
588
589 VOID
590 NTAPI
591 MiInitializeNonPagedPool(VOID);
592
593 PVOID
594 NTAPI
595 MiAllocatePoolPages(
596 IN POOL_TYPE PoolType,
597 IN SIZE_T SizeInBytes
598 );
599
600 POOL_TYPE
601 NTAPI
602 MmDeterminePoolType(
603 IN PVOID VirtualAddress
604 );
605
606 ULONG
607 NTAPI
608 MiFreePoolPages(
609 IN PVOID StartingAddress
610 );
611
612 PVOID
613 NTAPI
614 MmGetMdlPageAddress(
615 PMDL Mdl,
616 PVOID Offset
617 );
618
619 /* pool.c *******************************************************************/
620
621 PVOID
622 NTAPI
623 ExAllocateNonPagedPoolWithTag(
624 POOL_TYPE type,
625 ULONG size,
626 ULONG Tag,
627 PVOID Caller
628 );
629
630 PVOID
631 NTAPI
632 ExAllocatePagedPoolWithTag(
633 POOL_TYPE Type,
634 ULONG size,
635 ULONG Tag
636 );
637
638 VOID
639 NTAPI
640 ExFreeNonPagedPool(PVOID block);
641
642 VOID
643 NTAPI
644 ExFreePagedPool(IN PVOID Block);
645
646 BOOLEAN
647 NTAPI
648 ExpIsPoolTagDebuggable(ULONG Tag);
649
650 PVOID
651 NTAPI
652 ExpAllocateDebugPool(
653 POOL_TYPE Type,
654 ULONG Size,
655 ULONG Tag,
656 PVOID Caller,
657 BOOLEAN EndOfPage
658 );
659
660 VOID
661 NTAPI
662 ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool);
663
664 VOID
665 NTAPI
666 MmInitializePagedPool(VOID);
667
668 PVOID
669 NTAPI
670 MiAllocateSpecialPool(
671 IN POOL_TYPE PoolType,
672 IN SIZE_T NumberOfBytes,
673 IN ULONG Tag,
674 IN ULONG Underrun
675 );
676
677 BOOLEAN
678 NTAPI
679 MiRaisePoolQuota(
680 IN POOL_TYPE PoolType,
681 IN ULONG CurrentMaxQuota,
682 OUT PULONG NewMaxQuota
683 );
684
685 /* mdl.c *********************************************************************/
686
687 VOID
688 NTAPI
689 MmBuildMdlFromPages(
690 PMDL Mdl,
691 PPFN_NUMBER Pages
692 );
693
694 /* mminit.c ******************************************************************/
695
696 VOID
697 NTAPI
698 MiShutdownMemoryManager(VOID);
699
700 VOID
701 NTAPI
702 MmInit1(
703 VOID
704 );
705
706 BOOLEAN
707 NTAPI
708 MmInitSystem(IN ULONG Phase,
709 IN PLOADER_PARAMETER_BLOCK LoaderBlock);
710
711 VOID
712 NTAPI
713 MiFreeInitMemory(VOID);
714
715 VOID
716 NTAPI
717 MmInitializeMdlImplementation(VOID);
718
719 /* pagefile.c ****************************************************************/
720
721 SWAPENTRY
722 NTAPI
723 MmAllocSwapPage(VOID);
724
725 VOID
726 NTAPI
727 MmDereserveSwapPages(ULONG Nr);
728
729 VOID
730 NTAPI
731 MmFreeSwapPage(SWAPENTRY Entry);
732
733 VOID
734 NTAPI
735 MmInitPagingFile(VOID);
736
737 NTSTATUS
738 NTAPI
739 MmReadFromSwapPage(
740 SWAPENTRY SwapEntry,
741 PFN_NUMBER Page
742 );
743
744 BOOLEAN
745 NTAPI
746 MmReserveSwapPages(ULONG Nr);
747
748 NTSTATUS
749 NTAPI
750 MmWriteToSwapPage(
751 SWAPENTRY SwapEntry,
752 PFN_NUMBER Page
753 );
754
755 NTSTATUS
756 NTAPI
757 MmDumpToPagingFile(
758 ULONG BugCode,
759 ULONG BugCodeParameter1,
760 ULONG BugCodeParameter2,
761 ULONG BugCodeParameter3,
762 ULONG BugCodeParameter4,
763 struct _KTRAP_FRAME* TrapFrame
764 );
765
766 BOOLEAN
767 NTAPI
768 MmIsAvailableSwapPage(VOID);
769
770 VOID
771 NTAPI
772 MmShowOutOfSpaceMessagePagingFile(VOID);
773
774 /* process.c ****************************************************************/
775
776 NTSTATUS
777 NTAPI
778 MmInitializeProcessAddressSpace(
779 IN PEPROCESS Process,
780 IN PEPROCESS Clone OPTIONAL,
781 IN PVOID Section OPTIONAL,
782 IN OUT PULONG Flags,
783 IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL
784 );
785
786 NTSTATUS
787 NTAPI
788 MmCreatePeb(
789 IN PEPROCESS Process,
790 IN PINITIAL_PEB InitialPeb,
791 OUT PPEB *BasePeb
792 );
793
794 NTSTATUS
795 NTAPI
796 MmCreateTeb(
797 IN PEPROCESS Process,
798 IN PCLIENT_ID ClientId,
799 IN PINITIAL_TEB InitialTeb,
800 OUT PTEB* BaseTeb
801 );
802
803 VOID
804 NTAPI
805 MmDeleteTeb(
806 struct _EPROCESS *Process,
807 PTEB Teb
808 );
809
810 VOID
811 NTAPI
812 MmCleanProcessAddressSpace(IN PEPROCESS Process);
813
814 NTSTATUS
815 NTAPI
816 MmDeleteProcessAddressSpace(IN PEPROCESS Process);
817
818 ULONG
819 NTAPI
820 MmGetSessionLocaleId(VOID);
821
822 NTSTATUS
823 NTAPI
824 MmSetMemoryPriorityProcess(
825 IN PEPROCESS Process,
826 IN UCHAR MemoryPriority
827 );
828
829 /* i386/pfault.c *************************************************************/
830
831 NTSTATUS
832 NTAPI
833 MmPageFault(
834 ULONG Cs,
835 PULONG Eip,
836 PULONG Eax,
837 ULONG Cr2,
838 ULONG ErrorCode
839 );
840
841 /* mm.c **********************************************************************/
842
843 NTSTATUS
844 NTAPI
845 MmAccessFault(
846 IN BOOLEAN StoreInstruction,
847 IN PVOID Address,
848 IN KPROCESSOR_MODE Mode,
849 IN PVOID TrapInformation
850 );
851
852 /* anonmem.c *****************************************************************/
853
854 NTSTATUS
855 NTAPI
856 MmNotPresentFaultVirtualMemory(
857 PMMSUPPORT AddressSpace,
858 MEMORY_AREA* MemoryArea,
859 PVOID Address,
860 BOOLEAN Locked
861 );
862
863 NTSTATUS
864 NTAPI
865 MmPageOutVirtualMemory(
866 PMMSUPPORT AddressSpace,
867 PMEMORY_AREA MemoryArea,
868 PVOID Address,
869 struct _MM_PAGEOP* PageOp
870 );
871
872 NTSTATUS
873 NTAPI
874 MmQueryAnonMem(
875 PMEMORY_AREA MemoryArea,
876 PVOID Address,
877 PMEMORY_BASIC_INFORMATION Info,
878 PSIZE_T ResultLength
879 );
880
881 VOID
882 NTAPI
883 MmFreeVirtualMemory(
884 struct _EPROCESS* Process,
885 PMEMORY_AREA MemoryArea
886 );
887
888 NTSTATUS
889 NTAPI
890 MmProtectAnonMem(
891 PMMSUPPORT AddressSpace,
892 PMEMORY_AREA MemoryArea,
893 PVOID BaseAddress,
894 ULONG Length,
895 ULONG Protect,
896 PULONG OldProtect
897 );
898
899 NTSTATUS
900 NTAPI
901 MmWritePageVirtualMemory(
902 PMMSUPPORT AddressSpace,
903 PMEMORY_AREA MArea,
904 PVOID Address,
905 PMM_PAGEOP PageOp
906 );
907
908 /* kmap.c ********************************************************************/
909
910 PVOID
911 NTAPI
912 ExAllocatePage(VOID);
913
914 VOID
915 NTAPI
916 ExUnmapPage(PVOID Addr);
917
918 PVOID
919 NTAPI
920 ExAllocatePageWithPhysPage(PFN_NUMBER Page);
921
922 NTSTATUS
923 NTAPI
924 MiCopyFromUserPage(
925 PFN_NUMBER Page,
926 PVOID SourceAddress
927 );
928
929 NTSTATUS
930 NTAPI
931 MiZeroPage(PFN_NUMBER Page);
932
933 /* memsafe.s *****************************************************************/
934
935 PVOID
936 FASTCALL
937 MmSafeReadPtr(PVOID Source);
938
939 /* pageop.c ******************************************************************/
940
941 VOID
942 NTAPI
943 MmReleasePageOp(PMM_PAGEOP PageOp);
944
945 PMM_PAGEOP
946 NTAPI
947 MmGetPageOp(
948 PMEMORY_AREA MArea,
949 HANDLE Pid,
950 PVOID Address,
951 PMM_SECTION_SEGMENT Segment,
952 ULONG Offset,
953 ULONG OpType,
954 BOOLEAN First
955 );
956
957 PMM_PAGEOP
958 NTAPI
959 MmCheckForPageOp(
960 PMEMORY_AREA MArea,
961 HANDLE Pid,
962 PVOID Address,
963 PMM_SECTION_SEGMENT Segment,
964 ULONG Offset
965 );
966
967 VOID
968 NTAPI
969 MmInitializePageOp(VOID);
970
971 /* process.c *****************************************************************/
972
973 PVOID
974 NTAPI
975 MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node);
976
977 VOID
978 NTAPI
979 MmDeleteKernelStack(PVOID Stack,
980 BOOLEAN GuiStack);
981
982 /* balace.c ******************************************************************/
983
984 VOID
985 NTAPI
986 MmInitializeMemoryConsumer(
987 ULONG Consumer,
988 NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)
989 );
990
991 VOID
992 NTAPI
993 MmInitializeBalancer(
994 ULONG NrAvailablePages,
995 ULONG NrSystemPages
996 );
997
998 NTSTATUS
999 NTAPI
1000 MmReleasePageMemoryConsumer(
1001 ULONG Consumer,
1002 PFN_NUMBER Page
1003 );
1004
1005 NTSTATUS
1006 NTAPI
1007 MmRequestPageMemoryConsumer(
1008 ULONG Consumer,
1009 BOOLEAN MyWait,
1010 PPFN_NUMBER AllocatedPage
1011 );
1012
1013 VOID
1014 NTAPI
1015 MiInitBalancerThread(VOID);
1016
1017 VOID
1018 NTAPI
1019 MmRebalanceMemoryConsumers(VOID);
1020
1021 /* rmap.c **************************************************************/
1022
1023 VOID
1024 NTAPI
1025 MmSetRmapListHeadPage(
1026 PFN_NUMBER Page,
1027 struct _MM_RMAP_ENTRY* ListHead
1028 );
1029
1030 struct _MM_RMAP_ENTRY*
1031 NTAPI
1032 MmGetRmapListHeadPage(PFN_NUMBER Page);
1033
1034 VOID
1035 NTAPI
1036 MmInsertRmap(
1037 PFN_NUMBER Page,
1038 struct _EPROCESS *Process,
1039 PVOID Address
1040 );
1041
1042 VOID
1043 NTAPI
1044 MmDeleteAllRmaps(
1045 PFN_NUMBER Page,
1046 PVOID Context,
1047 VOID (*DeleteMapping)(PVOID Context, struct _EPROCESS *Process, PVOID Address)
1048 );
1049
1050 VOID
1051 NTAPI
1052 MmDeleteRmap(
1053 PFN_NUMBER Page,
1054 struct _EPROCESS *Process,
1055 PVOID Address
1056 );
1057
1058 VOID
1059 NTAPI
1060 MmInitializeRmapList(VOID);
1061
1062 VOID
1063 NTAPI
1064 MmSetCleanAllRmaps(PFN_NUMBER Page);
1065
1066 VOID
1067 NTAPI
1068 MmSetDirtyAllRmaps(PFN_NUMBER Page);
1069
1070 BOOLEAN
1071 NTAPI
1072 MmIsDirtyPageRmap(PFN_NUMBER Page);
1073
1074 NTSTATUS
1075 NTAPI
1076 MmWritePagePhysicalAddress(PFN_NUMBER Page);
1077
1078 NTSTATUS
1079 NTAPI
1080 MmPageOutPhysicalAddress(PFN_NUMBER Page);
1081
1082 /* freelist.c **********************************************************/
1083
1084 FORCEINLINE
1085 PMMPFN
1086 MiGetPfnEntry(IN PFN_NUMBER Pfn)
1087 {
1088 PMMPFN Page;
1089 extern RTL_BITMAP MiPfnBitMap;
1090
1091 /* Make sure the PFN number is valid */
1092 if (Pfn > MmHighestPhysicalPage) return NULL;
1093
1094 /* Make sure this page actually has a PFN entry */
1095 if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, Pfn))) return NULL;
1096
1097 /* Get the entry */
1098 Page = &MmPfnDatabase[Pfn];
1099
1100 /* Return it */
1101 return Page;
1102 };
1103
1104 FORCEINLINE
1105 PFN_NUMBER
1106 MiGetPfnEntryIndex(IN PMMPFN Pfn1)
1107 {
1108 //
1109 // This will return the Page Frame Number (PFN) from the MMPFN
1110 //
1111 return Pfn1 - MmPfnDatabase;
1112 }
1113
1114 PFN_NUMBER
1115 NTAPI
1116 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage);
1117
1118 PFN_NUMBER
1119 NTAPI
1120 MmGetLRUFirstUserPage(VOID);
1121
1122 VOID
1123 NTAPI
1124 MmInsertLRULastUserPage(PFN_NUMBER Page);
1125
1126 VOID
1127 NTAPI
1128 MmRemoveLRUUserPage(PFN_NUMBER Page);
1129
1130 VOID
1131 NTAPI
1132 MmLockPage(PFN_NUMBER Page);
1133
1134 VOID
1135 NTAPI
1136 MmUnlockPage(PFN_NUMBER Page);
1137
1138 ULONG
1139 NTAPI
1140 MmGetLockCountPage(PFN_NUMBER Page);
1141
1142 VOID
1143 NTAPI
1144 MmInitializePageList(
1145 VOID
1146 );
1147
1148 VOID
1149 NTAPI
1150 MmDumpPfnDatabase(
1151 VOID
1152 );
1153
1154 PFN_NUMBER
1155 NTAPI
1156 MmGetContinuousPages(
1157 ULONG NumberOfBytes,
1158 PHYSICAL_ADDRESS LowestAcceptableAddress,
1159 PHYSICAL_ADDRESS HighestAcceptableAddress,
1160 PHYSICAL_ADDRESS BoundaryAddressMultiple,
1161 BOOLEAN ZeroPages
1162 );
1163
1164 NTSTATUS
1165 NTAPI
1166 MmZeroPageThreadMain(
1167 PVOID Context
1168 );
1169
1170 /* hypermap.c *****************************************************************/
1171
1172 extern PEPROCESS HyperProcess;
1173 extern KIRQL HyperIrql;
1174
1175 PVOID
1176 NTAPI
1177 MiMapPageInHyperSpace(IN PEPROCESS Process,
1178 IN PFN_NUMBER Page,
1179 IN PKIRQL OldIrql);
1180
1181 VOID
1182 NTAPI
1183 MiUnmapPageInHyperSpace(IN PEPROCESS Process,
1184 IN PVOID Address,
1185 IN KIRQL OldIrql);
1186
1187 PVOID
1188 NTAPI
1189 MiMapPagesToZeroInHyperSpace(IN PMMPFN *Pages,
1190 IN PFN_NUMBER NumberOfPages);
1191
1192 VOID
1193 NTAPI
1194 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress,
1195 IN PFN_NUMBER NumberOfPages);
1196
1197 //
1198 // ReactOS Compatibility Layer
1199 //
1200 FORCEINLINE
1201 PVOID
1202 MmCreateHyperspaceMapping(IN PFN_NUMBER Page)
1203 {
1204 HyperProcess = (PEPROCESS)KeGetCurrentThread()->ApcState.Process;
1205 return MiMapPageInHyperSpace(HyperProcess, Page, &HyperIrql);
1206 }
1207
1208 FORCEINLINE
1209 PVOID
1210 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page)
1211 {
1212 PMMPFN Pfn1 = MiGetPfnEntry(Page);
1213 return MiMapPagesToZeroInHyperSpace(&Pfn1, 1);
1214 }
1215
1216 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1217
1218 /* i386/page.c *********************************************************/
1219
1220 NTSTATUS
1221 NTAPI
1222 MmCreateVirtualMappingForKernel(
1223 PVOID Address,
1224 ULONG flProtect,
1225 PPFN_NUMBER Pages,
1226 ULONG PageCount
1227 );
1228
1229 NTSTATUS
1230 NTAPI
1231 MmCommitPagedPoolAddress(
1232 PVOID Address,
1233 BOOLEAN Locked
1234 );
1235
1236 NTSTATUS
1237 NTAPI
1238 MmCreateVirtualMapping(
1239 struct _EPROCESS* Process,
1240 PVOID Address,
1241 ULONG flProtect,
1242 PPFN_NUMBER Pages,
1243 ULONG PageCount
1244 );
1245
1246 NTSTATUS
1247 NTAPI
1248 MmCreateVirtualMappingUnsafe(
1249 struct _EPROCESS* Process,
1250 PVOID Address,
1251 ULONG flProtect,
1252 PPFN_NUMBER Pages,
1253 ULONG PageCount
1254 );
1255
1256 ULONG
1257 NTAPI
1258 MmGetPageProtect(
1259 struct _EPROCESS* Process,
1260 PVOID Address);
1261
1262 VOID
1263 NTAPI
1264 MmSetPageProtect(
1265 struct _EPROCESS* Process,
1266 PVOID Address,
1267 ULONG flProtect
1268 );
1269
1270 BOOLEAN
1271 NTAPI
1272 MmIsPagePresent(
1273 struct _EPROCESS* Process,
1274 PVOID Address
1275 );
1276
1277 VOID
1278 NTAPI
1279 MmInitGlobalKernelPageDirectory(VOID);
1280
1281 VOID
1282 NTAPI
1283 MmDisableVirtualMapping(
1284 struct _EPROCESS *Process,
1285 PVOID Address,
1286 BOOLEAN* WasDirty,
1287 PPFN_NUMBER Page
1288 );
1289
1290 VOID
1291 NTAPI
1292 MmEnableVirtualMapping(
1293 struct _EPROCESS *Process,
1294 PVOID Address
1295 );
1296
1297 VOID
1298 NTAPI
1299 MmRawDeleteVirtualMapping(PVOID Address);
1300
1301 VOID
1302 NTAPI
1303 MmDeletePageFileMapping(
1304 struct _EPROCESS *Process,
1305 PVOID Address,
1306 SWAPENTRY* SwapEntry
1307 );
1308
1309 NTSTATUS
1310 NTAPI
1311 MmCreatePageFileMapping(
1312 struct _EPROCESS *Process,
1313 PVOID Address,
1314 SWAPENTRY SwapEntry
1315 );
1316
1317 BOOLEAN
1318 NTAPI
1319 MmIsPageSwapEntry(
1320 struct _EPROCESS *Process,
1321 PVOID Address
1322 );
1323
1324 VOID
1325 NTAPI
1326 MmTransferOwnershipPage(
1327 PFN_NUMBER Page,
1328 ULONG NewConsumer
1329 );
1330
1331 VOID
1332 NTAPI
1333 MmSetDirtyPage(
1334 struct _EPROCESS *Process,
1335 PVOID Address
1336 );
1337
1338 PFN_NUMBER
1339 NTAPI
1340 MmAllocPage(
1341 ULONG Consumer
1342 );
1343
1344 LONG
1345 NTAPI
1346 MmAllocPagesSpecifyRange(
1347 ULONG Consumer,
1348 PHYSICAL_ADDRESS LowestAddress,
1349 PHYSICAL_ADDRESS HighestAddress,
1350 ULONG NumberOfPages,
1351 PPFN_NUMBER Pages
1352 );
1353
1354 VOID
1355 NTAPI
1356 MmDereferencePage(PFN_NUMBER Page);
1357
1358 VOID
1359 NTAPI
1360 MmReferencePage(PFN_NUMBER Page);
1361
1362 ULONG
1363 NTAPI
1364 MmGetReferenceCountPage(PFN_NUMBER Page);
1365
1366 BOOLEAN
1367 NTAPI
1368 MmIsPageInUse(PFN_NUMBER Page);
1369
1370 VOID
1371 NTAPI
1372 MmSetSavedSwapEntryPage(
1373 PFN_NUMBER Page,
1374 SWAPENTRY SavedSwapEntry);
1375
1376 SWAPENTRY
1377 NTAPI
1378 MmGetSavedSwapEntryPage(PFN_NUMBER Page);
1379
1380 VOID
1381 NTAPI
1382 MmSetCleanPage(
1383 struct _EPROCESS *Process,
1384 PVOID Address
1385 );
1386
1387 NTSTATUS
1388 NTAPI
1389 MmCreatePageTable(PVOID PAddress);
1390
1391 VOID
1392 NTAPI
1393 MmDeletePageTable(
1394 struct _EPROCESS *Process,
1395 PVOID Address
1396 );
1397
1398 PFN_NUMBER
1399 NTAPI
1400 MmGetPfnForProcess(
1401 struct _EPROCESS *Process,
1402 PVOID Address
1403 );
1404
1405 BOOLEAN
1406 NTAPI
1407 MmCreateProcessAddressSpace(
1408 IN ULONG MinWs,
1409 IN PEPROCESS Dest,
1410 IN PULONG_PTR DirectoryTableBase
1411 );
1412
1413 NTSTATUS
1414 NTAPI
1415 MmInitializeHandBuiltProcess(
1416 IN PEPROCESS Process,
1417 IN PULONG_PTR DirectoryTableBase
1418 );
1419
1420
1421 NTSTATUS
1422 NTAPI
1423 MmInitializeHandBuiltProcess2(
1424 IN PEPROCESS Process
1425 );
1426
1427 NTSTATUS
1428 NTAPI
1429 MmReleaseMmInfo(struct _EPROCESS *Process);
1430
1431 NTSTATUS
1432 NTAPI
1433 Mmi386ReleaseMmInfo(struct _EPROCESS *Process);
1434
1435 VOID
1436 NTAPI
1437 MmDeleteVirtualMapping(
1438 struct _EPROCESS *Process,
1439 PVOID Address,
1440 BOOLEAN FreePage,
1441 BOOLEAN* WasDirty,
1442 PPFN_NUMBER Page
1443 );
1444
1445 BOOLEAN
1446 NTAPI
1447 MmIsDirtyPage(
1448 struct _EPROCESS *Process,
1449 PVOID Address
1450 );
1451
1452 VOID
1453 NTAPI
1454 MmMarkPageMapped(PFN_NUMBER Page);
1455
1456 VOID
1457 NTAPI
1458 MmMarkPageUnmapped(PFN_NUMBER Page);
1459
1460 VOID
1461 NTAPI
1462 MmUpdatePageDir(
1463 struct _EPROCESS *Process,
1464 PVOID Address,
1465 ULONG Size
1466 );
1467
1468 VOID
1469 NTAPI
1470 MiInitPageDirectoryMap(VOID);
1471
1472 ULONG
1473 NTAPI
1474 MiGetUserPageDirectoryCount(VOID);
1475
1476 /* wset.c ********************************************************************/
1477
1478 NTSTATUS
1479 MmTrimUserMemory(
1480 ULONG Target,
1481 ULONG Priority,
1482 PULONG NrFreedPages
1483 );
1484
1485 /* region.c ************************************************************/
1486
1487 NTSTATUS
1488 NTAPI
1489 MmAlterRegion(
1490 PMMSUPPORT AddressSpace,
1491 PVOID BaseAddress,
1492 PLIST_ENTRY RegionListHead,
1493 PVOID StartAddress,
1494 ULONG Length,
1495 ULONG NewType,
1496 ULONG NewProtect,
1497 PMM_ALTER_REGION_FUNC AlterFunc
1498 );
1499
1500 VOID
1501 NTAPI
1502 MmInitializeRegion(
1503 PLIST_ENTRY RegionListHead,
1504 SIZE_T Length,
1505 ULONG Type,
1506 ULONG Protect
1507 );
1508
1509 PMM_REGION
1510 NTAPI
1511 MmFindRegion(
1512 PVOID BaseAddress,
1513 PLIST_ENTRY RegionListHead,
1514 PVOID Address,
1515 PVOID* RegionBaseAddress
1516 );
1517
1518 /* section.c *****************************************************************/
1519
1520 PFILE_OBJECT
1521 NTAPI
1522 MmGetFileObjectForSection(
1523 IN PROS_SECTION_OBJECT Section
1524 );
1525 NTSTATUS
1526 NTAPI
1527 MmGetFileNameForAddress(
1528 IN PVOID Address,
1529 OUT PUNICODE_STRING ModuleName
1530 );
1531
1532 NTSTATUS
1533 NTAPI
1534 MmGetFileNameForSection(
1535 IN PROS_SECTION_OBJECT Section,
1536 OUT POBJECT_NAME_INFORMATION *ModuleName
1537 );
1538
1539 PVOID
1540 NTAPI
1541 MmAllocateSection(
1542 IN ULONG Length,
1543 PVOID BaseAddress
1544 );
1545
1546 NTSTATUS
1547 NTAPI
1548 MmQuerySectionView(
1549 PMEMORY_AREA MemoryArea,
1550 PVOID Address,
1551 PMEMORY_BASIC_INFORMATION Info,
1552 PSIZE_T ResultLength
1553 );
1554
1555 NTSTATUS
1556 NTAPI
1557 MmProtectSectionView(
1558 PMMSUPPORT AddressSpace,
1559 PMEMORY_AREA MemoryArea,
1560 PVOID BaseAddress,
1561 ULONG Length,
1562 ULONG Protect,
1563 PULONG OldProtect
1564 );
1565
1566 NTSTATUS
1567 NTAPI
1568 MmWritePageSectionView(
1569 PMMSUPPORT AddressSpace,
1570 PMEMORY_AREA MArea,
1571 PVOID Address,
1572 PMM_PAGEOP PageOp
1573 );
1574
1575 NTSTATUS
1576 NTAPI
1577 MmInitSectionImplementation(VOID);
1578
1579 NTSTATUS
1580 NTAPI
1581 MmNotPresentFaultSectionView(
1582 PMMSUPPORT AddressSpace,
1583 MEMORY_AREA* MemoryArea,
1584 PVOID Address,
1585 BOOLEAN Locked
1586 );
1587
1588 NTSTATUS
1589 NTAPI
1590 MmPageOutSectionView(
1591 PMMSUPPORT AddressSpace,
1592 PMEMORY_AREA MemoryArea,
1593 PVOID Address,
1594 struct _MM_PAGEOP *PageOp
1595 );
1596
1597 NTSTATUS
1598 NTAPI
1599 MmCreatePhysicalMemorySection(VOID);
1600
1601 NTSTATUS
1602 NTAPI
1603 MmAccessFaultSectionView(
1604 PMMSUPPORT AddressSpace,
1605 MEMORY_AREA* MemoryArea,
1606 PVOID Address,
1607 BOOLEAN Locked
1608 );
1609
1610 VOID
1611 NTAPI
1612 MmFreeSectionSegments(PFILE_OBJECT FileObject);
1613
1614 /* mpw.c *********************************************************************/
1615
1616 NTSTATUS
1617 NTAPI
1618 MmInitMpwThread(VOID);
1619
1620 NTSTATUS
1621 NTAPI
1622 MmInitBsmThread(VOID);
1623
1624 /* pager.c *******************************************************************/
1625
1626 BOOLEAN
1627 NTAPI
1628 MiIsPagerThread(VOID);
1629
1630 VOID
1631 NTAPI
1632 MiStartPagerThread(VOID);
1633
1634 VOID
1635 NTAPI
1636 MiStopPagerThread(VOID);
1637
1638 NTSTATUS
1639 FASTCALL
1640 MiQueryVirtualMemory(
1641 IN HANDLE ProcessHandle,
1642 IN PVOID Address,
1643 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
1644 OUT PVOID VirtualMemoryInformation,
1645 IN SIZE_T Length,
1646 OUT PSIZE_T ResultLength
1647 );
1648
1649 /* sysldr.c ******************************************************************/
1650
1651 VOID
1652 NTAPI
1653 MiReloadBootLoadedDrivers(
1654 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1655 );
1656
1657 BOOLEAN
1658 NTAPI
1659 MiInitializeLoadedModuleList(
1660 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1661 );
1662
1663 NTSTATUS
1664 NTAPI
1665 MmLoadSystemImage(
1666 IN PUNICODE_STRING FileName,
1667 IN PUNICODE_STRING NamePrefix OPTIONAL,
1668 IN PUNICODE_STRING LoadedName OPTIONAL,
1669 IN ULONG Flags,
1670 OUT PVOID *ModuleObject,
1671 OUT PVOID *ImageBaseAddress
1672 );
1673
1674 NTSTATUS
1675 NTAPI
1676 MmUnloadSystemImage(
1677 IN PVOID ImageHandle
1678 );
1679
1680 NTSTATUS
1681 NTAPI
1682 MmCheckSystemImage(
1683 IN HANDLE ImageHandle,
1684 IN BOOLEAN PurgeSection
1685 );
1686
1687 NTSTATUS
1688 NTAPI
1689 MmCallDllInitialize(
1690 IN PLDR_DATA_TABLE_ENTRY LdrEntry,
1691 IN PLIST_ENTRY ListHead
1692 );
1693
1694 /* ReactOS Mm Hacks */
1695 VOID
1696 FASTCALL
1697 MiSyncForProcessAttach(
1698 IN PKTHREAD NextThread,
1699 IN PEPROCESS Process
1700 );
1701
1702 VOID
1703 FASTCALL
1704 MiSyncForContextSwitch(
1705 IN PKTHREAD Thread
1706 );
1707
1708 extern PMMSUPPORT MmKernelAddressSpace;
1709
1710 FORCEINLINE
1711 VOID
1712 MmLockAddressSpace(PMMSUPPORT AddressSpace)
1713 {
1714 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
1715 }
1716
1717 FORCEINLINE
1718 VOID
1719 MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
1720 {
1721 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
1722 }
1723
1724 FORCEINLINE
1725 PEPROCESS
1726 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
1727 {
1728 if (AddressSpace == MmKernelAddressSpace) return NULL;
1729 return CONTAINING_RECORD(AddressSpace, EPROCESS, Vm);
1730 }
1731
1732 FORCEINLINE
1733 PMMSUPPORT
1734 MmGetCurrentAddressSpace(VOID)
1735 {
1736 return &((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->Vm;
1737 }
1738
1739 FORCEINLINE
1740 PMMSUPPORT
1741 MmGetKernelAddressSpace(VOID)
1742 {
1743 return MmKernelAddressSpace;
1744 }