ReactOS 0.4.15-dev-7693-gd0e2924
reqtools.c File Reference
#include <ntoskrnl.h>
#include "newmm.h"
#include <debug.h>
Include dependency graph for reqtools.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define DPRINTC   DPRINT
 

Functions

VOID NTAPI MmBuildMdlFromPages (PMDL Mdl, PPFN_NUMBER Pages)
 
NTSTATUS NTAPI MiGetOnePage (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES Required)
 
NTSTATUS NTAPI MiReadFilePage (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
 
NTSTATUS NTAPI MiSwapInPage (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES Resources)
 
NTSTATUS NTAPI MiWriteFilePage (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES Required)
 

Macro Definition Documentation

◆ DPRINTC

#define DPRINTC   DPRINT

Definition at line 59 of file reqtools.c.

◆ NDEBUG

#define NDEBUG

Definition at line 56 of file reqtools.c.

Function Documentation

◆ MiGetOnePage()

NTSTATUS NTAPI MiGetOnePage ( PMMSUPPORT  AddressSpace,
PMEMORY_AREA  MemoryArea,
PMM_REQUIRED_RESOURCES  Required 
)

Definition at line 83 of file reqtools.c.

86{
87 ULONG i;
89
90 for (i = 0; i < Required->Amount; i++)
91 {
92 DPRINTC("MiGetOnePage(%s:%d)\n", Required->File, Required->Line);
94 TRUE,
95 &Required->Page[i]);
96 if (!NT_SUCCESS(Status))
97 {
98 while (i > 0)
99 {
101 Required->Page[i-1]);
102 i--;
103 }
104 return Status;
105 }
106 }
107
108 return Status;
109}
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN _Inout_ PMM_REQUIRED_RESOURCES Required
Definition: newmm.h:210
NTSTATUS NTAPI MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN MyWait, PPFN_NUMBER AllocatedPage)
Definition: balance.c:313
NTSTATUS NTAPI MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
Definition: balance.c:72
#define DPRINTC
Definition: reqtools.c:59
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59

◆ MiReadFilePage()

NTSTATUS NTAPI MiReadFilePage ( PMMSUPPORT  AddressSpace,
PMEMORY_AREA  MemoryArea,
PMM_REQUIRED_RESOURCES  RequiredResources 
)

Definition at line 133 of file reqtools.c.

136{
137 PFILE_OBJECT FileObject = RequiredResources->Context;
138 PPFN_NUMBER Page = &RequiredResources->Page[RequiredResources->Offset];
139 PLARGE_INTEGER FileOffset = &RequiredResources->FileOffset;
141 PVOID PageBuf = NULL;
143 IO_STATUS_BLOCK IOSB;
144 UCHAR MdlBase[sizeof(MDL) + sizeof(ULONG)];
145 PMDL Mdl = (PMDL)MdlBase;
147
148 DPRINTC("Pulling page %I64x from %wZ to %Ix\n",
149 FileOffset->QuadPart,
150 &FileObject->FileName,
151 *Page);
152
153 Status = MmRequestPageMemoryConsumer(RequiredResources->Consumer,
154 TRUE,
155 Page);
156
157 if (!NT_SUCCESS(Status))
158 {
159 DPRINT1("Status: %x\n", Status);
160 return Status;
161 }
162
165 Mdl->MdlFlags |= MDL_PAGES_LOCKED;
166
169 if (Status == STATUS_PENDING)
170 {
172 Status = IOSB.Status;
173 }
174 if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
175 {
176 MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
177 }
178
180 if (!PageBuf)
181 {
182 MmReleasePageMemoryConsumer(RequiredResources->Consumer, *Page);
183 return STATUS_NO_MEMORY;
184 }
185
186 RtlZeroMemory((PCHAR)PageBuf+RequiredResources->Amount,
187 PAGE_SIZE-RequiredResources->Amount);
188
190
191 DPRINT("Read Status %x (Page %x)\n", Status, *Page);
192
193 if (!NT_SUCCESS(Status))
194 {
195 MmReleasePageMemoryConsumer(RequiredResources->Consumer, *Page);
196 DPRINT("Status: %x\n", Status);
197 return Status;
198 }
199
200 return STATUS_SUCCESS;
201}
#define DPRINT1
Definition: precomp.h:8
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define PAGE_SIZE
Definition: env_spec_w32.h:49
NTSTATUS NTAPI IoPageRead(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1201
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:837
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
VOID NTAPI MiUnmapPageInHyperSpace(IN PEPROCESS Process, IN PVOID Address, IN KIRQL OldIrql)
Definition: hypermap.c:91
PVOID NTAPI MiMapPageInHyperSpace(IN PEPROCESS Process, IN PFN_NUMBER Page, IN PKIRQL OldIrql)
Definition: hypermap.c:28
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:111
ULONG * PPFN_NUMBER
Definition: ke.h:9
#define DPRINT
Definition: sndvol32.h:71
LARGE_INTEGER FileOffset
Definition: newmm.h:60
PFN_NUMBER Page[2]
Definition: newmm.h:62
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * PCHAR
Definition: typedefs.h:51
PVOID PMDL
Definition: usb.h:39
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
* PFILE_OBJECT
Definition: iotypes.h:1998
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:415
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
MDL
Definition: mmtypes.h:117
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
#define PsGetCurrentProcess
Definition: psfuncs.h:17
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ MiSwapInPage()

NTSTATUS NTAPI MiSwapInPage ( PMMSUPPORT  AddressSpace,
PMEMORY_AREA  MemoryArea,
PMM_REQUIRED_RESOURCES  Resources 
)

Definition at line 220 of file reqtools.c.

223{
225
227 TRUE,
228 &Resources->Page[Resources->Offset]);
229 if (!NT_SUCCESS(Status))
230 {
231 DPRINT1("MmRequestPageMemoryConsumer failed, status = %x\n", Status);
232 return Status;
233 }
234
236 Resources->Page[Resources->Offset]);
237 if (!NT_SUCCESS(Status))
238 {
239 DPRINT1("MmReadFromSwapPage failed, status = %x\n", Status);
240 return Status;
241 }
242
244 Resources->SwapEntry);
245
246 DPRINT1("MiSwapInPage(%x,%x)\n",
247 Resources->Page[Resources->Offset],
248 Resources->SwapEntry);
249
250 return Status;
251}
NTSTATUS NTAPI MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
Definition: pagefile.c:204
VOID NTAPI MmSetSavedSwapEntryPage(PFN_NUMBER Page, SWAPENTRY SavedSwapEntry)
Definition: freelist.c:483

◆ MiWriteFilePage()

NTSTATUS NTAPI MiWriteFilePage ( PMMSUPPORT  AddressSpace,
PMEMORY_AREA  MemoryArea,
PMM_REQUIRED_RESOURCES  Required 
)

Definition at line 271 of file reqtools.c.

274{
275 DPRINT1("MiWriteFilePage(%x,%x)\n",
276 Required->Page[Required->Offset],
277 Required->FileOffset.LowPart);
278
279 return MiWriteBackPage(Required->Context,
280 &Required->FileOffset,
281 PAGE_SIZE,
282 Required->Page[Required->Offset]);
283}
#define MiWriteBackPage(F, O, L, P)
Definition: newmm.h:156

◆ MmBuildMdlFromPages()

VOID NTAPI MmBuildMdlFromPages ( PMDL  Mdl,
PPFN_NUMBER  Pages 
)

Definition at line 111 of file pagefile.c.

112{
113 memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
114}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
ULONG PFN_NUMBER
Definition: ke.h:9

Referenced by MiReadFilePage(), and MiWritePage().