ReactOS 0.4.15-dev-7788-g1ad9096
readsup.c File Reference
#include "npfs.h"
Include dependency graph for readsup.c:

Go to the source code of this file.

Macros

#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_READSUP)
 

Functions

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)
 

Macro Definition Documentation

◆ NPFS_BUGCHECK_FILE_ID

#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_READSUP)

Definition at line 14 of file readsup.c.

Function Documentation

◆ NpReadDataQueue()

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 at line 20 of file readsup.c.

28{
29 PNP_DATA_QUEUE_ENTRY DataEntry, TempDataEntry;
30 PVOID DataBuffer;
31 ULONG DataSize, DataLength, TotalBytesCopied, RemainingSize, Offset;
32 PIRP Irp;
34 BOOLEAN CompleteWrites = FALSE;
35 PAGED_CODE();
36
37 if (ReadOverflowOperation) Peek = TRUE;
38
39 RemainingSize = BufferSize;
40 IoStatus.Status = STATUS_SUCCESS;
41 TotalBytesCopied = 0;
42
43 if (Peek)
44 {
45 DataEntry = CONTAINING_RECORD(DataQueue->Queue.Flink,
47 QueueEntry);
48 }
49 else
50 {
53 QueueEntry);
54 }
55
56 while ((&DataEntry->QueueEntry != &DataQueue->Queue) && (RemainingSize))
57 {
58 if (!Peek ||
59 DataEntry->DataEntryType == Buffered ||
60 DataEntry->DataEntryType == Unbuffered)
61 {
62 if (DataEntry->DataEntryType == Unbuffered)
63 {
64 DataBuffer = DataEntry->Irp->AssociatedIrp.SystemBuffer;
65 }
66 else
67 {
68 DataBuffer = &DataEntry[1];
69 }
70
71 DataSize = DataEntry->DataSize;
73
74 if (&DataEntry->QueueEntry == DataQueue->Queue.Flink)
75 {
76 Offset -= DataQueue->ByteOffset;
77 }
78
80 if (DataLength >= RemainingSize) DataLength = RemainingSize;
81
83 {
84 RtlCopyMemory((PVOID)((ULONG_PTR)Buffer + BufferSize - RemainingSize),
85 (PVOID)((ULONG_PTR)DataBuffer + DataSize - Offset),
87 }
89 {
91 }
93
94
95 RemainingSize -= DataLength;
97 TotalBytesCopied += DataLength;
98
99 if (!Peek)
100 {
101 DataEntry->QuotaInEntry -= DataLength;
102 DataQueue->QuotaUsed -= DataLength;
103 DataQueue->ByteOffset += DataLength;
104 CompleteWrites = TRUE;
105 }
106
107 NpCopyClientContext(Ccb, DataEntry);
108
109 if ((Offset) || (ReadOverflowOperation && !TotalBytesCopied))
110 {
112 {
114 break;
115 }
116 }
117 else
118 {
119 if (!Peek || ReadOverflowOperation)
120 {
121 if (ReadOverflowOperation)
122 {
123 TempDataEntry = CONTAINING_RECORD(NpGetNextRealDataQueueEntry(DataQueue, List),
125 QueueEntry);
126 ASSERT(TempDataEntry == DataEntry);
127 }
128
129 Irp = NpRemoveDataQueueEntry(DataQueue, TRUE, List);
130 if (Irp)
131 {
132 Irp->IoStatus.Information = DataSize;
133 Irp->IoStatus.Status = STATUS_SUCCESS;
134 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
135 }
136 }
137
139 {
140 IoStatus.Status = STATUS_SUCCESS;
141 break;
142 }
143
144 ASSERT(!ReadOverflowOperation);
145 }
146 }
147
148 if (Peek)
149 {
150 DataEntry = CONTAINING_RECORD(DataEntry->QueueEntry.Flink,
152 QueueEntry);
153 }
154 else
155 {
156 DataEntry = CONTAINING_RECORD(NpGetNextRealDataQueueEntry(DataQueue, List),
158 QueueEntry);
159 }
160 }
161
162 IoStatus.Information = TotalBytesCopied;
163 if (CompleteWrites) NpCompleteStalledWrites(DataQueue, List);
164 return IoStatus;
165}
#define PAGED_CODE()
unsigned char BOOLEAN
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
PIRP NTAPI NpRemoveDataQueueEntry(IN PNP_DATA_QUEUE DataQueue, IN BOOLEAN Flag, IN PLIST_ENTRY List)
Definition: datasup.c:105
VOID NTAPI NpCompleteStalledWrites(IN PNP_DATA_QUEUE DataQueue, IN PLIST_ENTRY List)
Definition: datasup.c:49
PLIST_ENTRY NTAPI NpGetNextRealDataQueueEntry(IN PNP_DATA_QUEUE DataQueue, IN PLIST_ENTRY List)
Definition: datasup.c:174
#define BufferSize
Definition: mmc.h:75
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static VOID Peek(_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
Definition: hardware.c:371
@ Buffered
Definition: npfs.h:131
@ Unbuffered
Definition: npfs.h:132
VOID NTAPI NpCopyClientContext(IN PNP_CCB Ccb, IN PNP_DATA_QUEUE_ENTRY DataQueueEntry)
Definition: secursup.c:58
#define InsertTailList(ListHead, Entry)
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
_In_ ULONG Mode
Definition: hubbusif.h:303
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ASSERT(a)
Definition: mode.c:44
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
#define FILE_PIPE_MESSAGE_MODE
Definition: iotypes.h:78
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: npfs.h:149
ULONG DataSize
Definition: npfs.h:155
ULONG QuotaInEntry
Definition: npfs.h:153
ULONG DataEntryType
Definition: npfs.h:151
LIST_ENTRY QueueEntry
Definition: npfs.h:150
PIRP Irp
Definition: npfs.h:152
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by NpCommonRead(), and NpPeek().