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