ReactOS  0.4.15-dev-2964-ge2a8585
io.c File Reference
#include <ntoskrnl.h>
#include "newmm.h"
#include <debug.h>
#include <reactos/exeformat.h>
Include dependency graph for io.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PDEVICE_OBJECT NTAPI MmGetDeviceObjectForFile (IN PFILE_OBJECT FileObject)
 
 _Function_class_ (IO_COMPLETION_ROUTINE)
 
NTSTATUS NTAPI MiSimpleRead (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, BOOLEAN Paging, PIO_STATUS_BLOCK ReadStatus)
 

Variables

KEVENT CcpLazyWriteEvent
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 49 of file io.c.

Function Documentation

◆ _Function_class_()

_Function_class_ ( IO_COMPLETION_ROUTINE  )

Definition at line 69 of file io.c.

75 {
76  PMDL Mdl = Irp->MdlAddress;
77 
78  /* Unlock MDL Pages, page 167. */
79  DPRINT("MiSimpleReadComplete %p\n", Irp);
80  while (Mdl)
81  {
82  DPRINT("MDL Unlock %p\n", Mdl);
84  Mdl = Mdl->Next;
85  }
86 
87  /* Check if there's an MDL */
88  while ((Mdl = Irp->MdlAddress))
89  {
90  /* Clear all of them */
91  Irp->MdlAddress = Mdl->Next;
92  IoFreeMdl(Mdl);
93  }
94 
95  return STATUS_SUCCESS;
96 }
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1426
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ MiSimpleRead()

NTSTATUS NTAPI MiSimpleRead ( PFILE_OBJECT  FileObject,
PLARGE_INTEGER  FileOffset,
PVOID  Buffer,
ULONG  Length,
BOOLEAN  Paging,
PIO_STATUS_BLOCK  ReadStatus 
)

Definition at line 109 of file io.c.

115 {
117  PIRP Irp = NULL;
118  KEVENT ReadWait;
121 
124  ASSERT(Buffer);
126 
129  ReadStatus->Information = 0;
130 
132 
133  DPRINT("PAGING READ: FileObject %p <%wZ> Offset %08x%08x Length %ul\n",
134  FileObject,
135  &FileObject->FileName,
136  FileOffset->HighPart,
137  FileOffset->LowPart,
138  Length);
139 
141 
143  DeviceObject,
144  Buffer,
145  Length,
146  FileOffset,
147  ReadStatus);
148 
149  if (!Irp)
150  {
151  return STATUS_NO_MEMORY;
152  }
153 
155 
156  Irp->UserEvent = &ReadWait;
157  Irp->Tail.Overlay.OriginalFileObject = FileObject;
158  Irp->Tail.Overlay.Thread = PsGetCurrentThread();
162  IrpSp->CompletionRoutine = MiSimpleReadComplete;
163 
164  /* Non paging case, the FileObject will be dereferenced at completion */
165  if (!Paging)
167 
169  if (Status == STATUS_PENDING)
170  {
171  DPRINT("KeWaitForSingleObject(&ReadWait)\n");
172  if (!NT_SUCCESS(KeWaitForSingleObject(&ReadWait,
173  Suspended,
174  KernelMode,
175  FALSE,
176  NULL)))
177  {
178  DPRINT1("Warning: Failed to wait for synchronous IRP\n");
179  ASSERT(FALSE);
180  return Status;
181  }
182  }
183 
184  DPRINT("Paging IO Done: %08x\n", ReadStatus->Status);
185  /* When "ReadStatus->Information > 0" is false and "ReadStatus->Status == STATUS_END_OF_FILE" is true
186  * it means that read pointer is out of file, so we must fail */
187  Status = ReadStatus->Status == STATUS_END_OF_FILE && ReadStatus->Information > 0 ? STATUS_SUCCESS : ReadStatus->Status;
188  return Status;
189 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_NOCACHE
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:167
#define STATUS_END_OF_FILE
Definition: shellext.h:67
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
Definition: bufpool.h:45
PDEVICE_OBJECT NTAPI MmGetDeviceObjectForFile(IN PFILE_OBJECT FileObject)
Definition: io.c:57
PIO_COMPLETION_ROUTINE CompletionRoutine
Definition: iotypes.h:3314
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
PIRP NTAPI IoBuildAsynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:750
#define SL_INVOKE_ON_ERROR
Definition: iotypes.h:3329
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define SL_INVOKE_ON_SUCCESS
Definition: iotypes.h:3328
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_PAGING_IO
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define ObReferenceObject
Definition: obfuncs.h:204
#define IRP_SYNCHRONOUS_API
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define IRP_SYNCHRONOUS_PAGING_IO

Referenced by CcZeroData(), and ExeFmtpReadFile().

◆ MmGetDeviceObjectForFile()

PDEVICE_OBJECT NTAPI MmGetDeviceObjectForFile ( IN PFILE_OBJECT  FileObject)

Definition at line 57 of file io.c.

58 {
60 }
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547

Referenced by MiSimpleRead().

Variable Documentation

◆ CcpLazyWriteEvent

KEVENT CcpLazyWriteEvent

Definition at line 53 of file io.c.

Referenced by CcInitializeCacheManager().