ReactOS 0.4.15-dev-7958-gcd0bb1a
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;
93 }
94
95 return STATUS_SUCCESS;
96}
_In_ PIRP Irp
Definition: csq.h:116
#define IoFreeMdl
Definition: fxmdl.h:89
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl

◆ 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",
135 &FileObject->FileName,
136 FileOffset->HighPart,
137 FileOffset->LowPart,
138 Length);
139
141
144 Buffer,
145 Length,
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,
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}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:167
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
#define KernelMode
Definition: asm.h:34
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ NotificationEvent
PDEVICE_OBJECT NTAPI MmGetDeviceObjectForFile(IN PFILE_OBJECT FileObject)
Definition: io.c:57
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 IoCallDriver
Definition: irp.c:1225
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define STATUS_END_OF_FILE
Definition: shellext.h:67
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
PIO_COMPLETION_ROUTINE CompletionRoutine
Definition: iotypes.h:3314
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define IRP_SYNCHRONOUS_API
#define IRP_PAGING_IO
#define SL_INVOKE_ON_ERROR
Definition: iotypes.h:3329
#define IRP_SYNCHRONOUS_PAGING_IO
#define SL_INVOKE_ON_SUCCESS
Definition: iotypes.h:3328
#define IRP_NOCACHE
@ Suspended
Definition: ketypes.h:420
#define ObReferenceObject
Definition: obfuncs.h:204

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

Referenced by MiSimpleRead().

Variable Documentation

◆ CcpLazyWriteEvent

KEVENT CcpLazyWriteEvent

Definition at line 53 of file io.c.

Referenced by CcInitializeCacheManager().