[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: ntoskrnl/mm/section.c
|
|
|
|
* PURPOSE: Implements section objects
|
|
|
|
*
|
|
|
|
* PROGRAMMERS: Rex Jolliff
|
|
|
|
* David Welch
|
|
|
|
* Eric Kohl
|
|
|
|
* Emanuele Aliberti
|
|
|
|
* Eugene Ingerman
|
|
|
|
* Casper Hornstrup
|
|
|
|
* KJK::Hyperion
|
|
|
|
* Guido de Jong
|
|
|
|
* Ge van Geldorp
|
|
|
|
* Royce Mitchell III
|
|
|
|
* Filip Navara
|
|
|
|
* Aleksey Bragin
|
|
|
|
* Jason Filby
|
|
|
|
* Thomas Weidenmueller
|
|
|
|
* Gunnar Andre' Dalsnes
|
|
|
|
* Mike Nordell
|
|
|
|
* Alex Ionescu
|
|
|
|
* Gregor Anich
|
|
|
|
* Steven Edwards
|
|
|
|
* Herve Poussineau
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
|
|
|
#include "newmm.h"
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
#include <reactos/exeformat.h>
|
|
|
|
|
|
|
|
#if defined (ALLOC_PRAGMA)
|
|
|
|
#pragma alloc_text(INIT, MmCreatePhysicalMemorySection)
|
|
|
|
#pragma alloc_text(INIT, MmInitSectionImplementation)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
KEVENT CcpLazyWriteEvent;
|
|
|
|
|
|
|
|
PDEVICE_OBJECT
|
|
|
|
NTAPI
|
|
|
|
MmGetDeviceObjectForFile(IN PFILE_OBJECT FileObject)
|
|
|
|
{
|
|
|
|
return IoGetRelatedDeviceObject(FileObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MiSimpleReadComplete
|
|
|
|
(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp,
|
|
|
|
PVOID Context)
|
|
|
|
{
|
2011-06-06 19:08:39 +00:00
|
|
|
PMDL Mdl = Irp->MdlAddress;
|
|
|
|
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
/* Unlock MDL Pages, page 167. */
|
|
|
|
DPRINT("MiSimpleReadComplete %x\n", Irp);
|
|
|
|
while (Mdl)
|
|
|
|
{
|
|
|
|
DPRINT("MDL Unlock %x\n", Mdl);
|
|
|
|
MmUnlockPages(Mdl);
|
|
|
|
Mdl = Mdl->Next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if there's an MDL */
|
|
|
|
while ((Mdl = Irp->MdlAddress))
|
|
|
|
{
|
|
|
|
/* Clear all of them */
|
|
|
|
Irp->MdlAddress = Mdl->Next;
|
|
|
|
IoFreeMdl(Mdl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
MiSimpleRead
|
|
|
|
(PFILE_OBJECT FileObject,
|
|
|
|
PLARGE_INTEGER FileOffset,
|
|
|
|
PVOID Buffer,
|
|
|
|
ULONG Length,
|
2011-05-21 09:38:52 +00:00
|
|
|
#ifdef __ROS_CMAKE__
|
|
|
|
BOOLEAN Paging,
|
|
|
|
#endif
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
PIO_STATUS_BLOCK ReadStatus)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PIRP Irp = NULL;
|
|
|
|
KEVENT ReadWait;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PIO_STACK_LOCATION IrpSp;
|
|
|
|
|
|
|
|
ASSERT(FileObject);
|
|
|
|
ASSERT(FileOffset);
|
|
|
|
ASSERT(Buffer);
|
|
|
|
ASSERT(ReadStatus);
|
|
|
|
|
|
|
|
DeviceObject = MmGetDeviceObjectForFile(FileObject);
|
|
|
|
ReadStatus->Status = STATUS_INTERNAL_ERROR;
|
|
|
|
ReadStatus->Information = 0;
|
|
|
|
|
|
|
|
ASSERT(DeviceObject);
|
|
|
|
|
|
|
|
DPRINT
|
|
|
|
("PAGING READ: FileObject %x <%wZ> Offset %08x%08x Length %d\n",
|
|
|
|
&FileObject,
|
|
|
|
&FileObject->FileName,
|
|
|
|
FileOffset->HighPart,
|
|
|
|
FileOffset->LowPart,
|
|
|
|
Length);
|
|
|
|
|
|
|
|
KeInitializeEvent(&ReadWait, NotificationEvent, FALSE);
|
|
|
|
|
|
|
|
Irp = IoBuildAsynchronousFsdRequest
|
|
|
|
(IRP_MJ_READ,
|
|
|
|
DeviceObject,
|
|
|
|
Buffer,
|
|
|
|
Length,
|
|
|
|
FileOffset,
|
|
|
|
ReadStatus);
|
|
|
|
|
|
|
|
if (!Irp)
|
|
|
|
{
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
2011-05-21 09:38:52 +00:00
|
|
|
|
|
|
|
#ifndef __ROS_CMAKE__
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
Irp->Flags |= IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_API;
|
2011-05-21 09:38:52 +00:00
|
|
|
#else
|
|
|
|
Irp->Flags |= (Paging ? IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO | IRP_NOCACHE : 0) | IRP_SYNCHRONOUS_API;
|
|
|
|
#endif
|
|
|
|
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
Irp->UserEvent = &ReadWait;
|
|
|
|
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
|
|
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
|
|
|
IrpSp = IoGetNextIrpStackLocation(Irp);
|
|
|
|
IrpSp->Control |= SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR;
|
|
|
|
IrpSp->FileObject = FileObject;
|
|
|
|
IrpSp->CompletionRoutine = MiSimpleReadComplete;
|
2011-05-21 09:38:52 +00:00
|
|
|
|
|
|
|
#ifdef __ROS_CMAKE__
|
|
|
|
ObReferenceObject(FileObject);
|
|
|
|
#endif
|
|
|
|
|
[CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to. Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.
The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.
It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.
Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.
Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.
I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.
svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00
|
|
|
Status = IoCallDriver(DeviceObject, Irp);
|
|
|
|
if (Status == STATUS_PENDING)
|
|
|
|
{
|
|
|
|
DPRINT1("KeWaitForSingleObject(&ReadWait)\n");
|
|
|
|
if (!NT_SUCCESS
|
|
|
|
(KeWaitForSingleObject
|
|
|
|
(&ReadWait,
|
|
|
|
Suspended,
|
|
|
|
KernelMode,
|
|
|
|
FALSE,
|
|
|
|
NULL)))
|
|
|
|
{
|
|
|
|
DPRINT1("Warning: Failed to wait for synchronous IRP\n");
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("Paging IO Done: %08x\n", ReadStatus->Status);
|
|
|
|
Status =
|
|
|
|
ReadStatus->Status == STATUS_END_OF_FILE ?
|
|
|
|
STATUS_SUCCESS : ReadStatus->Status;
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
_MiSimpleWrite
|
|
|
|
(PFILE_OBJECT FileObject,
|
|
|
|
PLARGE_INTEGER FileOffset,
|
|
|
|
PVOID Buffer,
|
|
|
|
ULONG Length,
|
|
|
|
PIO_STATUS_BLOCK ReadStatus,
|
|
|
|
const char *File,
|
|
|
|
int Line)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PIRP Irp = NULL;
|
|
|
|
KEVENT ReadWait;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PIO_STACK_LOCATION IrpSp;
|
|
|
|
|
|
|
|
ASSERT(FileObject);
|
|
|
|
ASSERT(FileOffset);
|
|
|
|
ASSERT(Buffer);
|
|
|
|
ASSERT(ReadStatus);
|
|
|
|
|
|
|
|
ObReferenceObject(FileObject);
|
|
|
|
DeviceObject = MmGetDeviceObjectForFile(FileObject);
|
|
|
|
ASSERT(DeviceObject);
|
|
|
|
|
|
|
|
DPRINT
|
|
|
|
("PAGING WRITE: FileObject %x Offset %x Length %d (%s:%d)\n",
|
|
|
|
&FileObject,
|
|
|
|
FileOffset->LowPart,
|
|
|
|
Length,
|
|
|
|
File,
|
|
|
|
Line);
|
|
|
|
|
|
|
|
KeInitializeEvent(&ReadWait, NotificationEvent, FALSE);
|
|
|
|
|
|
|
|
Irp = IoBuildAsynchronousFsdRequest
|
|
|
|
(IRP_MJ_WRITE,
|
|
|
|
DeviceObject,
|
|
|
|
Buffer,
|
|
|
|
Length,
|
|
|
|
FileOffset,
|
|
|
|
ReadStatus);
|
|
|
|
|
|
|
|
if (!Irp)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(FileObject);
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
Irp->Flags = IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_API;
|
|
|
|
|
|
|
|
Irp->UserEvent = &ReadWait;
|
|
|
|
Irp->Tail.Overlay.OriginalFileObject = FileObject;
|
|
|
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
|
|
|
IrpSp = IoGetNextIrpStackLocation(Irp);
|
|
|
|
IrpSp->Control |= SL_INVOKE_ON_SUCCESS | SL_INVOKE_ON_ERROR;
|
|
|
|
IrpSp->FileObject = FileObject;
|
|
|
|
IrpSp->CompletionRoutine = MiSimpleReadComplete;
|
|
|
|
|
|
|
|
DPRINT("Call Driver\n");
|
|
|
|
Status = IoCallDriver(DeviceObject, Irp);
|
|
|
|
DPRINT("Status %x\n", Status);
|
|
|
|
|
|
|
|
ObDereferenceObject(FileObject);
|
|
|
|
|
|
|
|
if (Status == STATUS_PENDING)
|
|
|
|
{
|
|
|
|
DPRINT1("KeWaitForSingleObject(&ReadWait)\n");
|
|
|
|
if (!NT_SUCCESS
|
|
|
|
(KeWaitForSingleObject
|
|
|
|
(&ReadWait,
|
|
|
|
Suspended,
|
|
|
|
KernelMode,
|
|
|
|
FALSE,
|
|
|
|
NULL)))
|
|
|
|
{
|
|
|
|
DPRINT1("Warning: Failed to wait for synchronous IRP\n");
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("Paging IO Done: %08x\n", ReadStatus->Status);
|
|
|
|
return ReadStatus->Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern KEVENT MpwThreadEvent;
|
|
|
|
FAST_MUTEX MiWriteMutex;
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
_MiWriteBackPage
|
|
|
|
(PFILE_OBJECT FileObject,
|
|
|
|
PLARGE_INTEGER FileOffset,
|
|
|
|
ULONG Length,
|
|
|
|
PFN_NUMBER Page,
|
|
|
|
const char *File,
|
|
|
|
int Line)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PVOID Hyperspace;
|
|
|
|
IO_STATUS_BLOCK Iosb;
|
|
|
|
KIRQL OldIrql;
|
|
|
|
PVOID PageBuffer = ExAllocatePool(NonPagedPool, PAGE_SIZE);
|
|
|
|
|
|
|
|
if (!PageBuffer) return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
|
|
|
|
Hyperspace = MmCreateHyperspaceMapping(Page);
|
|
|
|
RtlCopyMemory(PageBuffer, Hyperspace, PAGE_SIZE);
|
|
|
|
MmDeleteHyperspaceMapping(Hyperspace);
|
|
|
|
KfLowerIrql(OldIrql);
|
|
|
|
|
|
|
|
DPRINT1("MiWriteBackPage(%wZ,%08x%08x,%s:%d)\n", &FileObject->FileName, FileOffset->u.HighPart, FileOffset->u.LowPart, File, Line);
|
|
|
|
Status = MiSimpleWrite
|
|
|
|
(FileObject,
|
|
|
|
FileOffset,
|
|
|
|
PageBuffer,
|
|
|
|
Length,
|
|
|
|
&Iosb);
|
|
|
|
|
|
|
|
ExFreePool(PageBuffer);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("MiSimpleWrite failed (%x)\n", Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|