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