ReactOS 0.4.15-dev-5667-ged97270
read.c File Reference
#include "npfs.h"
Include dependency graph for read.c:

Go to the source code of this file.

Macros

#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_READ)
 

Functions

BOOLEAN NTAPI NpCommonRead (IN PFILE_OBJECT FileObject, IN PVOID Buffer, IN ULONG BufferSize, OUT PIO_STATUS_BLOCK IoStatus, IN PIRP Irp, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpFsdRead (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
 _Function_class_ (FAST_IO_READ)
 

Variables

LONG NpSlowReadCalls
 
ULONG NpFastReadTrue
 
ULONG NpFastReadFalse
 

Macro Definition Documentation

◆ NPFS_BUGCHECK_FILE_ID

#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_READ)

Definition at line 14 of file read.c.

Function Documentation

◆ _Function_class_()

_Function_class_ ( FAST_IO_READ  )

Definition at line 196 of file read.c.

209{
210 LIST_ENTRY DeferredList;
212 PAGED_CODE();
213
214 InitializeListHead(&DeferredList);
215
218
220 Buffer,
221 Length,
222 IoStatus,
223 NULL,
224 &DeferredList);
225 if (Result)
227 else
229
230 NpReleaseVcb();
231 NpCompleteDeferredIrps(&DeferredList);
233
234 return Result;
235}
#define PAGED_CODE()
unsigned char BOOLEAN
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
FORCEINLINE VOID NpReleaseVcb(VOID)
Definition: npfs.h:344
FORCEINLINE VOID NpAcquireSharedVcb(VOID)
Definition: npfs.h:328
FORCEINLINE VOID NpCompleteDeferredIrps(IN PLIST_ENTRY DeferredList)
Definition: npfs.h:356
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
ULONG NpFastReadFalse
Definition: read.c:20
BOOLEAN NTAPI NpCommonRead(IN PFILE_OBJECT FileObject, IN PVOID Buffer, IN ULONG BufferSize, OUT PIO_STATUS_BLOCK IoStatus, IN PIRP Irp, IN PLIST_ENTRY List)
Definition: read.c:26
ULONG NpFastReadTrue
Definition: read.c:19
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
Definition: typedefs.h:120
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426

◆ NpCommonRead()

BOOLEAN NTAPI NpCommonRead ( IN PFILE_OBJECT  FileObject,
IN PVOID  Buffer,
IN ULONG  BufferSize,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PIRP  Irp,
IN PLIST_ENTRY  List 
)

Definition at line 26 of file read.c.

32{
34 PNP_DATA_QUEUE ReadQueue;
35 PNP_EVENT_BUFFER EventBuffer;
37 ULONG NamedPipeEnd;
39 PNP_NONPAGED_CCB NonPagedCcb;
40 BOOLEAN ReadOk;
41 PAGED_CODE();
42
43 IoStatus->Information = 0;
44 NodeType = NpDecodeFileObject(FileObject, NULL, &Ccb, &NamedPipeEnd);
45
46 if (!NodeType)
47 {
49 return TRUE;
50 }
51
53 {
55 return TRUE;
56 }
57
58 NonPagedCcb = Ccb->NonPagedCcb;
60
61 if (Ccb->NamedPipeState == FILE_PIPE_DISCONNECTED_STATE || Ccb->NamedPipeState == FILE_PIPE_LISTENING_STATE)
62 {
64 ReadOk = TRUE;
65 goto Quickie;
66 }
67
68 ASSERT((Ccb->NamedPipeState == FILE_PIPE_CONNECTED_STATE) || (Ccb->NamedPipeState == FILE_PIPE_CLOSING_STATE));
69
70 if ((NamedPipeEnd == FILE_PIPE_SERVER_END && Ccb->Fcb->NamedPipeConfiguration == FILE_PIPE_OUTBOUND) ||
71 (NamedPipeEnd == FILE_PIPE_CLIENT_END && Ccb->Fcb->NamedPipeConfiguration == FILE_PIPE_INBOUND))
72 {
74 ReadOk = TRUE;
75 goto Quickie;
76 }
77
78 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
79 {
80 ReadQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
81 }
82 else
83 {
84 ReadQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
85 }
86
87 EventBuffer = NonPagedCcb->EventBuffer[NamedPipeEnd];
88
89 if (ReadQueue->QueueState == WriteEntries)
90 {
91 *IoStatus = NpReadDataQueue(ReadQueue,
92 FALSE,
93 FALSE,
94 Buffer,
96 Ccb->ReadMode[NamedPipeEnd],
97 Ccb,
98 List);
99 if (!NT_SUCCESS(IoStatus->Status))
100 {
101 ReadOk = TRUE;
102 goto Quickie;
103 }
104
105 ReadOk = TRUE;
106 if (EventBuffer) KeSetEvent(EventBuffer->Event, IO_NO_INCREMENT, FALSE);
107 goto Quickie;
108 }
109
110 if (Ccb->NamedPipeState == FILE_PIPE_CLOSING_STATE)
111 {
113 ReadOk = TRUE;
114 if (EventBuffer) KeSetEvent(EventBuffer->Event, IO_NO_INCREMENT, FALSE);
115 goto Quickie;
116 }
117
118 if (Ccb->CompletionMode[NamedPipeEnd] == FILE_PIPE_COMPLETE_OPERATION)
119 {
120 IoStatus->Status = STATUS_PIPE_EMPTY;
121 ReadOk = TRUE;
122 if (EventBuffer) KeSetEvent(EventBuffer->Event, IO_NO_INCREMENT, FALSE);
123 goto Quickie;
124 }
125
126 if (!Irp)
127 {
128 ReadOk = FALSE;
129 goto Quickie;
130 }
131
132 Status = NpAddDataQueueEntry(NamedPipeEnd,
133 Ccb,
134 ReadQueue,
136 Buffered,
138 Irp,
139 NULL,
140 0);
141 IoStatus->Status = Status;
142 if (!NT_SUCCESS(Status))
143 {
144 ReadOk = FALSE;
145 }
146 else
147 {
148 ReadOk = TRUE;
149 if (EventBuffer) KeSetEvent(EventBuffer->Event, IO_NO_INCREMENT, FALSE);
150 }
151
152Quickie:
153 ExReleaseResourceLite(&Ccb->NonPagedCcb->Lock);
154 return ReadOk;
155}
NodeType
Definition: Node.h:6
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI NpAddDataQueueEntry(IN ULONG NamedPipeEnd, IN PNP_CCB Ccb, IN PNP_DATA_QUEUE DataQueue, IN ULONG Who, IN ULONG Type, IN ULONG DataSize, IN PIRP Irp, IN PVOID Buffer, IN ULONG ByteOffset)
Definition: datasup.c:295
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
#define NodeType(P)
Definition: nodetype.h:51
IO_STATUS_BLOCK NTAPI NpReadDataQueue(IN PNP_DATA_QUEUE DataQueue, IN BOOLEAN Peek, IN BOOLEAN ReadOverflowOperation, IN PVOID Buffer, IN ULONG BufferSize, IN ULONG Mode, IN PNP_CCB Ccb, IN PLIST_ENTRY List)
Definition: readsup.c:20
@ Buffered
Definition: npfs.h:131
@ ReadEntries
Definition: npfs.h:123
@ WriteEntries
Definition: npfs.h:124
#define NPFS_NTC_CCB
Definition: npfs.h:115
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
NODE_TYPE_CODE NTAPI NpDecodeFileObject(IN PFILE_OBJECT FileObject, OUT PVOID *PrimaryContext OPTIONAL, OUT PNP_CCB *Ccb, OUT PULONG NamedPipeEnd OPTIONAL)
Definition: fileobsup.c:20
Status
Definition: gdiplustypes.h:25
#define FILE_PIPE_DISCONNECTED_STATE
Definition: winternl.h:790
#define FILE_PIPE_LISTENING_STATE
Definition: winternl.h:791
#define FILE_PIPE_CONNECTED_STATE
Definition: winternl.h:792
#define FILE_PIPE_CLOSING_STATE
Definition: winternl.h:793
#define ASSERT(a)
Definition: mode.c:44
#define FILE_PIPE_OUTBOUND
Definition: iotypes.h:82
#define FILE_PIPE_INBOUND
Definition: iotypes.h:81
#define FILE_PIPE_CLIENT_END
Definition: iotypes.h:84
#define FILE_PIPE_COMPLETE_OPERATION
Definition: iotypes.h:80
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:412
#define STATUS_PIPE_LISTENING
Definition: ntstatus.h:415
#define STATUS_PIPE_EMPTY
Definition: ntstatus.h:453
#define STATUS_PIPE_BROKEN
Definition: ntstatus.h:567
struct _FCB::@706::@709 Fcb
Definition: npfs.h:259
ULONG QueueState
Definition: npfs.h:139
PKEVENT Event
Definition: npfs.h:179
ERESOURCE Lock
Definition: npfs.h:254
PNP_EVENT_BUFFER EventBuffer[2]
Definition: npfs.h:253
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by _Function_class_(), and NpFsdRead().

◆ NpFsdRead()

NTSTATUS NTAPI NpFsdRead ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 159 of file read.c.

161{
162 PIO_STACK_LOCATION IoStack;
164 LIST_ENTRY DeferredList;
165 PAGED_CODE();
167
168 InitializeListHead(&DeferredList);
170
173
174 NpCommonRead(IoStack->FileObject,
175 Irp->UserBuffer,
176 IoStack->Parameters.Read.Length,
177 &IoStatus,
178 Irp,
179 &DeferredList);
180
181 NpReleaseVcb();
182 NpCompleteDeferredIrps(&DeferredList);
184
185 if (IoStatus.Status != STATUS_PENDING)
186 {
187 Irp->IoStatus.Information = IoStatus.Information;
188 Irp->IoStatus.Status = IoStatus.Status;
190 }
191
192 return IoStatus.Status;
193}
LONG NpSlowReadCalls
Definition: read.c:18
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_PENDING
Definition: ntstatus.h:82
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IO_NAMED_PIPE_INCREMENT
Definition: iotypes.h:604

Referenced by DriverEntry().

Variable Documentation

◆ NpFastReadFalse

ULONG NpFastReadFalse

Definition at line 20 of file read.c.

Referenced by _Function_class_().

◆ NpFastReadTrue

ULONG NpFastReadTrue

Definition at line 19 of file read.c.

Referenced by _Function_class_().

◆ NpSlowReadCalls

LONG NpSlowReadCalls

Definition at line 18 of file read.c.

Referenced by NpFsdRead().