ReactOS 0.4.15-dev-7942-gd23573b
data.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 *
19 * PROJECT: ReactOS kernel
20 * FILE: ntoskrnl/cache/section/data.c
21 * PURPOSE: Implements section objects
22 *
23 * PROGRAMMERS: Rex Jolliff
24 * David Welch
25 * Eric Kohl
26 * Emanuele Aliberti
27 * Eugene Ingerman
28 * Casper Hornstrup
29 * KJK::Hyperion
30 * Guido de Jong
31 * Ge van Geldorp
32 * Royce Mitchell III
33 * Filip Navara
34 * Aleksey Bragin
35 * Jason Filby
36 * Thomas Weidenmueller
37 * Gunnar Andre' Dalsnes
38 * Mike Nordell
39 * Alex Ionescu
40 * Gregor Anich
41 * Steven Edwards
42 * Herve Poussineau
43 */
44
45/*
46
47A note on this code:
48
49Unlike the previous section code, this code does not rely on an active map
50for a page to exist in a data segment. Each mapping contains a large integer
51offset to map at, and the segment always represents the entire section space
52from zero to the maximum long long. This allows us to associate one single
53page map with each file object, and to let each mapping view an offset into
54the overall mapped file. Temporarily unmapping the file has no effect on the
55section membership.
56
57This necessitates a change in the section page table implementation, which is
58now an RtlGenericTable. This will be elaborated more in sptab.c. One upshot
59of this change is that a mapping of a small files takes a bit more than 1/4
60of the size in nonpaged kernel space as it did previously.
61
62When we need other threads that may be competing for the same page fault to
63wait, we have a mechanism seperate from PageOps for dealing with that, which
64was suggested by Travis Geiselbrecht after a conversation I had with Alex
65Ionescu. That mechanism is the MM_WAIT_ENTRY, which is the all-ones SWAPENTRY.
66
67When we wish for other threads to know that we're waiting and will finish
68handling a page fault, we place the swap entry MM_WAIT_ENTRY in the page table
69at the fault address (this works on either the section page table or a process
70address space), perform any blocking operations required, then replace the
71entry.
72
73*/
74
75/* INCLUDES *****************************************************************/
76
77#include <ntoskrnl.h>
78#include "newmm.h"
79#include <cache/newcc.h>
80#define NDEBUG
81#include <debug.h>
82#include <mm/ARM3/miarm.h>
83
84#define DPRINTC DPRINT
85
87
91
92/* FUNCTIONS *****************************************************************/
93
94/* Note: Mmsp prefix denotes "Memory Manager Section Private". */
95
96VOID
99{
100 //DPRINT("MmLockSectionSegment(%p,%s:%d)\n", Segment, file, line);
102 Segment->Locked = TRUE;
103}
104
105VOID
106NTAPI
108{
109 ASSERT(Segment->Locked);
110 Segment->Locked = FALSE;
112 //DPRINT("MmUnlockSectionSegment(%p,%s:%d)\n", Segment, file, line);
113}
114
115#ifdef NEWCC
116/*
117
118MiFlushMappedSection
119
120Called from cache code to cause dirty pages of a section
121to be written back. This doesn't affect the mapping.
122
123BaseOffset is the base at which to start writing in file space.
124FileSize is the length of the file as understood by the cache.
125
126 */
128NTAPI
130 PLARGE_INTEGER BaseOffset,
133 const char *File,
134 int Line)
135{
141 ULONG_PTR BeginningAddress, EndingAddress;
142 LARGE_INTEGER ViewOffset;
145 PPFN_NUMBER Pages;
147
148 DPRINT("MiFlushMappedSection(%p,%I64x,%I64x,%u,%s:%d)\n",
150 BaseOffset->QuadPart,
152 WriteData,
153 File,
154 Line);
155
158 if (!MemoryArea || MemoryArea->Type != MEMORY_AREA_CACHE || MemoryArea->DeleteInProgress)
159 {
161 DPRINT("STATUS_NOT_MAPPED_DATA\n");
163 }
166 Segment = MemoryArea->Data.SectionData.Segment;
167 ViewOffset.QuadPart = MemoryArea->Data.SectionData.ViewOffset.QuadPart;
168
169 ASSERT(ViewOffset.QuadPart == BaseOffset->QuadPart);
170
172
174 sizeof(PFN_NUMBER) * ((EndingAddress - BeginningAddress) >> PAGE_SHIFT));
175
176 if (!Pages)
177 {
178 ASSERT(FALSE);
179 }
180
181 //DPRINT("Getting pages in range %08x-%08x\n", BeginningAddress, EndingAddress);
182
183 for (PageAddress = BeginningAddress;
184 PageAddress < EndingAddress;
186 {
188 FileOffset.QuadPart = ViewOffset.QuadPart + PageAddress - BeginningAddress;
190 &FileOffset);
192 if (Entry != 0 && !IS_SWAP_FROM_SSE(Entry) &&
193 (MmIsDirtyPageRmap(Page) || IS_DIRTY_SSE(Entry)) &&
194 FileOffset.QuadPart < FileSize->QuadPart)
195 {
196 OldIrql = MiAcquirePfnLock();
198 MiReleasePfnLock(OldIrql);
199 Pages[(PageAddress - BeginningAddress) >> PAGE_SHIFT] = Entry;
200 }
201 else
202 {
203 Pages[(PageAddress - BeginningAddress) >> PAGE_SHIFT] = 0;
204 }
205 }
206
209
210 for (PageAddress = BeginningAddress;
211 PageAddress < EndingAddress;
213 {
215 FileOffset.QuadPart = ViewOffset.QuadPart + PageAddress - BeginningAddress;
216 Entry = Pages[(PageAddress - BeginningAddress) >> PAGE_SHIFT];
218 if (Page)
219 {
220 if (WriteData) {
221 //DPRINT("MiWriteBackPage(%wZ,addr %x,%08x%08x)\n", &Segment->FileObject->FileName, PageAddress, FileOffset.u.HighPart, FileOffset.u.LowPart);
223 } else
225
226 if (NT_SUCCESS(Status)) {
228 MmSetCleanAllRmaps(Page);
229
233
236
239
242 } else {
243 DPRINT("Writeback from section flush %08x%08x (%x) %x@%x (%08x%08x:%wZ) failed %x\n",
244 FileOffset.u.HighPart,
245 FileOffset.u.LowPart,
246 (ULONG)(FileSize->QuadPart - FileOffset.QuadPart),
248 Page,
249 FileSize->u.HighPart,
250 FileSize->u.LowPart,
251 &Segment->FileObject->FileName,
252 Status);
253 }
255 }
256 }
257
258 ExFreePool(Pages);
259
260 return Status;
261}
262
263/*
264
265This deletes a segment entirely including its page map.
266It must have been unmapped in every address space.
267
268 */
269VOID
270NTAPI
272{
273 KIRQL OldIrql = 0;
274
275 DPRINT("Finalize segment %p\n", Segment);
276
278 RemoveEntryList(&Segment->ListOfSegments);
279 if (Segment->Flags & MM_DATAFILE_SEGMENT) {
280 KeAcquireSpinLock(&Segment->FileObject->IrpListLock, &OldIrql);
281 if (Segment->Flags & MM_SEGMENT_FINALIZE) {
282 KeReleaseSpinLock(&Segment->FileObject->IrpListLock, OldIrql);
284 return;
285 }
287 DPRINTC("Finalizing data file segment %p\n", Segment);
288
289 Segment->FileObject->SectionObjectPointer->DataSectionObject = NULL;
290 KeReleaseSpinLock(&Segment->FileObject->IrpListLock, OldIrql);
293 DPRINT("Dereference file object %wZ\n", &Segment->FileObject->FileName);
294 ObDereferenceObject(Segment->FileObject);
295 DPRINT("Done with %wZ\n", &Segment->FileObject->FileName);
296 Segment->FileObject = NULL;
297 } else {
298 DPRINTC("Finalizing segment %p\n", Segment);
301 }
302 DPRINTC("Segment %p destroy\n", Segment);
304}
305
307NTAPI
308MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject,
311 PLARGE_INTEGER UMaximumSize,
315/*
316 * Create a section backed by a data file.
317 */
318{
319 PROS_SECTION_OBJECT Section;
327
328 DPRINT("MmCreateDataFileSection\n");
329
330 /* Create the section */
335 NULL,
336 sizeof(ROS_SECTION_OBJECT),
337 0,
338 0,
339 (PVOID*)(PVOID)&Section);
340 if (!NT_SUCCESS(Status))
341 {
342 DPRINT("Failed: %x\n", Status);
344 return Status;
345 }
346
347 /* Initialize it */
348 RtlZeroMemory(Section, sizeof(ROS_SECTION_OBJECT));
349 Section->Type = 'SC';
350 Section->Size = 'TN';
351 Section->SectionPageProtection = SectionPageProtection;
352 Section->AllocationAttributes = AllocationAttributes;
353 Section->Segment = NULL;
354
355 Section->FileObject = FileObject;
356
357 DPRINT("Getting original file size\n");
358 /* A hack: If we're cached, we can overcome deadlocking with the upper
359 * layer filesystem call by retriving the object sizes from the cache
360 * which is made to keep track. If I had to guess, they were figuring
361 * out a similar problem.
362 */
364 {
366 /*
367 * FIXME: This is propably not entirely correct. We can't look into
368 * the standard FCB header because it might not be initialized yet
369 * (as in case of the EXT2FS driver by Manoj Paul Joseph where the
370 * standard file information is filled on first request).
371 */
372 DPRINT("Querying info\n");
376 &FileInfo,
377 &Information);
378 Iosb.Information = Information;
379 DPRINT("Query => %x\n", Status);
381
382 if (!NT_SUCCESS(Status))
383 {
384 DPRINT("Status %x\n", Status);
385 ObDereferenceObject(Section);
387 return Status;
388 }
390
392 FileSizes.FileSize = FileInfo.EndOfFile;
393 }
395
396 /*
397 * FIXME: Revise this once a locking order for file size changes is
398 * decided
399 *
400 * We're handed down a maximum size in every case. Should we still check at all?
401 */
402 if (UMaximumSize != NULL && UMaximumSize->QuadPart)
403 {
404 DPRINT("Taking maximum %I64x\n", UMaximumSize->QuadPart);
405 MaximumSize.QuadPart = UMaximumSize->QuadPart;
406 }
407 else
408 {
409 DPRINT("Got file size %I64x\n", FileSizes.FileSize.QuadPart);
411 }
412
413 /* Mapping zero-sized files isn't allowed. */
414 if (MaximumSize.QuadPart == 0)
415 {
416 DPRINT("Zero size file\n");
417 ObDereferenceObject(Section);
419 return STATUS_FILE_INVALID;
420 }
421
423 sizeof(MM_SECTION_SEGMENT),
425 if (Segment == NULL)
426 {
427 DPRINT("Failed: STATUS_NO_MEMORY\n");
428 ObDereferenceObject(Section);
430 return STATUS_NO_MEMORY;
431 }
432
433 DPRINT("Zeroing %p\n", Segment);
436
437 Segment->ReferenceCount = 1;
438 Segment->Locked = TRUE;
439 RtlZeroMemory(&Segment->Image, sizeof(Segment->Image));
440 Section->Segment = Segment;
441
442 KeAcquireSpinLock(&FileObject->IrpListLock, &OldIrql);
443 /*
444 * If this file hasn't been mapped as a data file before then allocate a
445 * section segment to describe the data file mapping
446 */
447 if (FileObject->SectionObjectPointer->DataSectionObject == NULL)
448 {
449 FileObject->SectionObjectPointer->DataSectionObject = (PVOID)Segment;
450 KeReleaseSpinLock(&FileObject->IrpListLock, OldIrql);
451
452 /*
453 * Set the lock before assigning the segment to the file object
454 */
456
457 DPRINT("Filling out Segment info (No previous data section)\n");
459 Segment->FileObject = FileObject;
460 Segment->Protection = SectionPageProtection;
462 memset(&Segment->Image, 0, sizeof(Segment->Image));
463 Segment->WriteCopy = FALSE;
464
466 {
467 Segment->Length.QuadPart = Segment->RawLength.QuadPart = 0;
468 }
469 else
470 {
471 Segment->RawLength.QuadPart = MaximumSize.QuadPart;
472 Segment->Length.QuadPart = PAGE_ROUND_UP(Segment->RawLength.QuadPart);
473 }
475 InsertHeadList(&MiSegmentList, &Segment->ListOfSegments);
476 }
477 else
478 {
479 KeReleaseSpinLock(&FileObject->IrpListLock, OldIrql);
480 DPRINTC("Free Segment %p\n", Segment);
482
483 DPRINT("Filling out Segment info (previous data section)\n");
484
485 /*
486 * If the file is already mapped as a data file then we may need
487 * to extend it
488 */
489 Segment = (PMM_SECTION_SEGMENT)FileObject->SectionObjectPointer->DataSectionObject;
490 Section->Segment = Segment;
491 (void)InterlockedIncrementUL(&Segment->ReferenceCount);
492
494
495 if (MaximumSize.QuadPart > Segment->RawLength.QuadPart &&
497 {
498 Segment->RawLength.QuadPart = MaximumSize.QuadPart;
499 Segment->Length.QuadPart = PAGE_ROUND_UP(Segment->RawLength.QuadPart);
500 }
501 }
502
504
505 Section->MaximumSize.QuadPart = MaximumSize.QuadPart;
506
507 /* Extend file if section is longer */
508 DPRINT("MaximumSize %I64x ValidDataLength %I64x\n",
509 MaximumSize.QuadPart,
512 {
513 DPRINT("Changing file size to %I64x, segment %p\n",
514 MaximumSize.QuadPart,
515 Segment);
516
519 sizeof(LARGE_INTEGER),
520 &MaximumSize);
521
522 DPRINT("Change: Status %x\n", Status);
523 if (!NT_SUCCESS(Status))
524 {
525 DPRINT("Could not expand section\n");
526 ObDereferenceObject(Section);
527 return Status;
528 }
529 }
530
531 DPRINTC("Segment %p created (%x)\n", Segment, Segment->Flags);
532
533 *SectionObject = Section;
534 return STATUS_SUCCESS;
535}
536
538NTAPI
544 PLARGE_INTEGER ViewOffset,
546 const char *file,
547 int line)
548{
549 PMEMORY_AREA MArea;
551
553 MEMORY_AREA_CACHE,
555 ViewSize,
556 Protect,
557 &MArea,
559 *BaseAddress ?
561
562 if (!NT_SUCCESS(Status))
563 {
564 DPRINT("Mapping between 0x%p and 0x%p failed (%X).\n",
565 (*BaseAddress),
566 (char*)(*BaseAddress) + ViewSize,
567 Status);
568
569 return Status;
570 }
571
572 DPRINTC("MiMapViewOfSegment %p %p %p %I64x %Ix %wZ %s:%d\n",
575 Segment,
576 ViewOffset ? ViewOffset->QuadPart : 0,
577 ViewSize,
578 Segment->FileObject ? &Segment->FileObject->FileName : NULL,
579 file,
580 line);
581
582 MArea->Data.SectionData.Segment = Segment;
583 if (ViewOffset)
584 MArea->Data.SectionData.ViewOffset = *ViewOffset;
585 else
586 MArea->Data.SectionData.ViewOffset.QuadPart = 0;
587
588#if 0
589 MArea->NotPresent = MmNotPresentFaultPageFile;
590 MArea->AccessFault = MiCowSectionPage;
591 MArea->PageOut = MmPageOutPageFileView;
592#endif
593
594 MmInitializeRegion(&MArea->Data.SectionData.RegionListHead,
595 ViewSize,
596 0,
597 Protect);
598
599 DPRINTC("MiMapViewOfSegment(P %p, A %p, T %x)\n",
602 MArea->Type);
603
604 return STATUS_SUCCESS;
605}
606#endif
607
608/*
609
610Completely remove the page at FileOffset in Segment. The page must not
611be mapped.
612
613*/
614
615VOID
616NTAPI
619{
621 PFILE_OBJECT FileObject = Segment->FileObject;
622
624 DPRINTC("MiFreeSegmentPage(%p:%I64x -> Entry %Ix\n",
625 Segment,
626 FileOffset->QuadPart,
627 Entry);
628
630 {
631 // The segment is carrying a dirty page.
632 PFN_NUMBER OldPage = PFN_FROM_SSE(Entry);
634 {
635 DPRINT("MiWriteBackPage(%p,%wZ,%I64x)\n",
636 Segment,
637 &FileObject->FileName,
638 FileOffset->QuadPart);
639
641 }
642 DPRINTC("Free page %Ix (off %I64x from %p) (ref ct %lu, ent %Ix, dirty? %s)\n",
643 OldPage,
644 FileOffset->QuadPart,
645 Segment,
647 Entry,
648 IS_DIRTY_SSE(Entry) ? "true" : "false");
649
651 MmReleasePageMemoryConsumer(MC_CACHE, OldPage);
652 }
653 else if (IS_SWAP_FROM_SSE(Entry))
654 {
655 DPRINT("Free swap\n");
657 }
658
659 DPRINT("Done\n");
660}
661
662VOID
667 SWAPENTRY SwapEntry,
668 BOOLEAN Dirty)
669{
671 PVOID *ContextData = Context;
676
677 DPRINT("MmFreeSectionPage(%p,%p,%Ix,%Ix,%u)\n",
678 MmGetAddressSpaceOwner(ContextData[0]),
679 Address,
680 Page,
681 SwapEntry,
682 Dirty);
683
684 AddressSpace = ContextData[0];
687 Segment = ContextData[1];
689 MemoryArea->Data.SectionData.ViewOffset.QuadPart;
690
692
693 if (Page != 0 && PFN_FROM_SSE(Entry) == Page && Dirty)
694 {
695 DPRINT("Freeing section page %p:%I64x -> %Ix\n", Segment, Offset.QuadPart, Entry);
697 }
698 if (Page)
699 {
700 DPRINT("Removing page %p:%I64x -> %x\n", Segment, Offset.QuadPart, Entry);
705 }
706 if (SwapEntry != 0)
707 {
708 MmFreeSwapPage(SwapEntry);
709 }
710}
711
712#ifdef NEWCC
714NTAPI
717{
718 PVOID Context[2];
721
724 {
726 return STATUS_UNSUCCESSFUL;
727 }
728
730 Segment = MemoryArea->Data.SectionData.Segment;
731 MemoryArea->Data.SectionData.Segment = NULL;
732
734
736 Context[1] = Segment;
737
738 DPRINT("MmFreeMemoryArea(%p,%p)\n",
741
743
745
747
749
750 DPRINTC("MiUnmapViewOfSegment %p %p %p\n",
753 Segment);
754
755 return STATUS_SUCCESS;
756}
757
759NTAPI
760MmExtendCacheSection(PROS_SECTION_OBJECT Section,
762 BOOLEAN ExtendFile)
763{
764 LARGE_INTEGER OldSize;
765 PMM_SECTION_SEGMENT Segment = Section->Segment;
766 DPRINT("Extend Segment %p\n", Segment);
767
769 OldSize.QuadPart = Segment->RawLength.QuadPart;
771
772 DPRINT("OldSize 0x%I64x NewSize 0x%I64x\n",
773 OldSize.QuadPart,
774 NewSize->QuadPart);
775
776 if (ExtendFile && OldSize.QuadPart < NewSize->QuadPart)
777 {
779
780 Status = IoSetInformation(Segment->FileObject,
782 sizeof(LARGE_INTEGER),
783 NewSize);
784
785 if (!NT_SUCCESS(Status)) return Status;
786 }
787
789 Segment->RawLength.QuadPart = NewSize->QuadPart;
790 Segment->Length.QuadPart = MAX(Segment->Length.QuadPart,
791 (LONG64)PAGE_ROUND_UP(Segment->RawLength.QuadPart));
793 return STATUS_SUCCESS;
794}
795
797NTAPI
802{
805
806 DPRINT("MmMapViewInSystemSpaceAtOffset() called offset 0x%I64x\n",
807 FileOffset->QuadPart);
808
810
813
815 Segment,
817 *ViewSize,
820 0);
821
824
825 return Status;
826}
827
828/*
829 * @implemented
830 */
833{
836
837 DPRINT("MmUnmapViewInSystemSpace() called\n");
838
840
842
843 return Status;
844}
845#endif /* NEWCC */
846
847/* EOF */
static CC_FILE_SIZES FileSizes
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define MAX(x, y)
Definition: rdesktop.h:175
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: File.h:16
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PAGE_READONLY
Definition: compat.h:138
static VOID WriteData(_In_ UCHAR Data)
Definition: hardware.c:38
return Iosb
Definition: create.c:4402
#define ULONG_PTR
Definition: config.h:101
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExGetPreviousMode
Definition: ex.h:140
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1527
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
@ FileEndOfFileInformation
Definition: from_kernel.h:81
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
BOOLEAN NTAPI CcGetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:375
Status
Definition: gdiplustypes.h:25
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
NTSTATUS NTAPI IoQueryFileInformation(IN PFILE_OBJECT FileObject, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG Length, OUT PVOID FileInformation, OUT PULONG ReturnedLength)
Definition: iofunc.c:1274
NTSTATUS NTAPI IoSetInformation(IN PFILE_OBJECT FileObject, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG Length, IN PVOID FileInformation)
Definition: iofunc.c:1314
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define MM_ALLOCATION_GRANULARITY
Definition: mmtypes.h:36
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:362
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
Definition: mmfuncs.h:363
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
Definition: mmfuncs.h:364
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG AllocationType
Definition: mmfuncs.h:410
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
ULONG MmGetReferenceCountPageWithoutLock(PFN_NUMBER Page)
Definition: newcc.h:165
NTSTATUS NTAPI MmExtendCacheSection(PSECTION Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile)
NTSTATUS NTAPI MmCreateCacheSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, ULONG SectionPageProtection, ULONG AllocationAttributes, PFILE_OBJECT FileObject)
VOID NTAPI MmFinalizeSegment(PMM_SECTION_SEGMENT Segment)
VOID NTAPI MmFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment, FREE_SECTION_PAGE_FUN FreePage)
Definition: sptab.c:321
#define MM_SEGMENT_FINALIZE
Definition: newmm.h:6
#define MiWriteBackPage(F, O, L, P)
Definition: newmm.h:156
_In_ PMEMORY_AREA MemoryArea
Definition: newmm.h:207
NTSTATUS NTAPI MmMapCacheViewInSystemSpaceAtOffset(IN PMM_SECTION_SEGMENT Segment, OUT PVOID *MappedBase, IN PLARGE_INTEGER ViewOffset, IN OUT PULONG ViewSize)
NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
NTSTATUS NTAPI MmUnmapCacheViewInSystemSpace(PVOID Address)
NTSTATUS NTAPI _MiMapViewOfSegment(PMMSUPPORT AddressSpace, PMM_SECTION_SEGMENT Segment, PVOID *BaseAddress, SIZE_T ViewSize, ULONG Protect, PLARGE_INTEGER ViewOffset, ULONG AllocationType, const char *file, int line)
#define MiMapViewOfSegment(AddressSpace, Segment, BaseAddress, ViewSize, Protect, ViewOffset, AllocationType)
Definition: newmm.h:263
NTSTATUS NTAPI MmPageOutPageFileView(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, PMM_REQUIRED_RESOURCES Required)
NTSTATUS NTAPI _MiFlushMappedSection(PVOID BaseAddress, PLARGE_INTEGER BaseOffset, PLARGE_INTEGER FileSize, BOOLEAN Dirty, const char *File, int Line)
VOID NTAPI MiInitializeSectionPageTable(PMM_SECTION_SEGMENT Segment)
Definition: sptab.c:165
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define SEC_RESERVE
Definition: nt_native.h:1323
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PMMWSL MmWorkingSetList
Definition: wslist.cpp:19
#define DPRINTC
Definition: data.c:84
VOID NTAPI _MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line)
Definition: data.c:107
LIST_ENTRY MiSegmentList
Definition: data.c:86
VOID NTAPI _MmLockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line)
Definition: data.c:98
KSPIN_LOCK MiSectionPageTableLock
KEVENT MpwThreadEvent
VOID MmFreeCacheSectionPage(PVOID Context, MEMORY_AREA *MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
Definition: data.c:663
VOID NTAPI MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset)
Definition: data.c:617
#define MmGetPageEntrySectionSegment(S, O)
Definition: mm.h:1602
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1691
VOID NTAPI MmSetPageProtect(struct _EPROCESS *Process, PVOID Address, ULONG flProtect)
#define DIRTY_SSE(E)
Definition: mm.h:1375
#define MmLockSectionSegment(x)
Definition: mm.h:1397
NTSTATUS NTAPI MmCreateMemoryArea(PMMSUPPORT AddressSpace, ULONG Type, PVOID *BaseAddress, SIZE_T Length, ULONG Protection, PMEMORY_AREA *Result, ULONG AllocationFlags, ULONG AllocationGranularity)
Definition: marea.c:410
VOID NTAPI MmReferencePage(PFN_NUMBER Page)
Definition: freelist.c:518
#define CLEAN_SSE(E)
Definition: mm.h:1376
#define MmSetPageEntrySectionSegment(S, O, E)
Definition: mm.h:1600
NTSTATUS NTAPI MmFreeMemoryArea(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext)
Definition: marea.c:283
#define MmUnlockSectionSegment(x)
Definition: mm.h:1405
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address)
Definition: marea.c:60
#define IS_DIRTY_SSE(E)
Definition: mm.h:1377
#define SWAPENTRY_FROM_SSE(E)
Definition: mm.h:1373
VOID NTAPI MmInitializeRegion(PLIST_ENTRY RegionListHead, SIZE_T Length, ULONG Type, ULONG Protect)
Definition: region.c:239
ULONG_PTR SWAPENTRY
Definition: mm.h:57
#define MA_GetEndingAddress(_MemoryArea)
Definition: mm.h:245
#define MA_GetStartingAddress(_MemoryArea)
Definition: mm.h:244
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1704
FORCEINLINE PEPROCESS MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
Definition: mm.h:1711
VOID NTAPI MmFreeSwapPage(SWAPENTRY Entry)
Definition: pagefile.c:291
VOID NTAPI MmSetSavedSwapEntryPage(PFN_NUMBER Page, SWAPENTRY SavedSwapEntry)
Definition: freelist.c:483
#define PFN_FROM_SSE(E)
Definition: mm.h:1368
VOID NTAPI MmDeleteRmap(PFN_NUMBER Page, struct _EPROCESS *Process, PVOID Address)
struct _MM_SECTION_SEGMENT * PMM_SECTION_SEGMENT
#define IS_SWAP_FROM_SSE(E)
Definition: mm.h:1369
NTSTATUS NTAPI MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
Definition: balance.c:72
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1726
#define MM_DATAFILE_SEGMENT
Definition: mm.h:238
VOID NTAPI MmDeleteVirtualMapping(IN PEPROCESS Process, IN PVOID Address, OUT PBOOLEAN WasDirty, OUT PPFN_NUMBER Page)
Definition: page.c:177
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_FILE_INVALID
Definition: ntstatus.h:388
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:1039
static WCHAR Address[46]
Definition: ping.c:68
#define FileStandardInformation
Definition: propsheet.cpp:61
ULONG * PPFN_NUMBER
Definition: ke.h:9
ULONG PFN_NUMBER
Definition: ke.h:9
#define memset(x, y, z)
Definition: compat.h:39
POBJECT_TYPE MmSectionObjectType
Definition: section.c:194
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:83
Definition: ncftp.h:79
LARGE_INTEGER FileSize
Definition: cctypes.h:16
LARGE_INTEGER ValidDataLength
Definition: cctypes.h:17
Definition: typedefs.h:120
struct _MEMORY_AREA::@1792 SectionData
BOOLEAN DeleteInProgress
Definition: mm.h:253
ULONG Type
Definition: mm.h:251
Definition: fci.c:127
Definition: parser.c:49
#define TAG_MM_SECTION_SEGMENT
Definition: tag.h:114
uint32_t * PULONG
Definition: typedefs.h:59
int64_t LONG64
Definition: typedefs.h:68
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_NOT_MAPPED_DATA
Definition: udferr_usr.h:157
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2295 u
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274
* PFILE_OBJECT
Definition: iotypes.h:1998
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:492
_Must_inspect_result_ _In_ SIZE_T _In_ PVOID PageAddress
Definition: mmfuncs.h:472
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:221