50{
62
63 DPRINT(
"NtfsReadFile(%p, %p, %p, %lu, %lu, %lx, %p)\n", DeviceExt,
FileObject,
Buffer,
Length,
ReadOffset, IrpFlags, LengthRead);
64
65 *LengthRead = 0;
66
68 {
71 }
72
74
76 {
80 }
81
83 {
87 }
88
89 FileRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
90 if (FileRecord ==
NULL)
91 {
92 DPRINT1(
"Not enough memory!\n");
94 }
95
98 {
99 DPRINT1(
"Can't find record!\n");
100 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
102 }
103
104
107 {
111
113
116 {
118 {
120
125 }
126
128 }
130
132 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
134 }
135
138 {
139 DPRINT1(
"Reading beyond stream end!\n");
141 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
143 }
144
148
150 RealLength = ToRead;
151
152 if ((
ReadOffset % DeviceExt->NtfsInfo.BytesPerSector) != 0 || (ToRead % DeviceExt->NtfsInfo.BytesPerSector) != 0)
153 {
155 RealLength =
ROUND_UP(ToRead, DeviceExt->NtfsInfo.BytesPerSector);
156
158 {
159 if (RealReadOffset + RealLength + DeviceExt->NtfsInfo.BytesPerSector <=
AttributeAllocatedLength(DataContext->pRecord))
160 RealLength += DeviceExt->NtfsInfo.BytesPerSector;
161 }
162
163
166 {
167 DPRINT1(
"Not enough memory!\n");
169 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
171 }
172 AllocatedBuffer =
TRUE;
173 }
174
175 DPRINT(
"Effective read: %lu at %lu for stream '%S'\n", RealLength, RealReadOffset,
Fcb->
Stream);
177 if (RealLengthRead == 0)
178 {
181 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
182 if (AllocatedBuffer)
183 {
185 }
187 }
188
190 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
191
192 *LengthRead = ToRead;
193
194 DPRINT(
"%lu got read\n", *LengthRead);
195
196 if (AllocatedBuffer)
197 {
199 }
200
202 {
204 }
205
206 if (AllocatedBuffer)
207 {
209 }
210
212}
#define ReadBuffer(BaseIoAddress, Buffer, Count)
#define STATUS_NOT_IMPLEMENTED
NTSTATUS FindFirstAttribute(PFIND_ATTR_CONTXT Context, PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord, BOOLEAN OnlyResident, PNTFS_ATTR_RECORD *Attribute)
VOID FindCloseAttribute(PFIND_ATTR_CONTXT Context)
NTSTATUS FindNextAttribute(PFIND_ATTR_CONTXT Context, PNTFS_ATTR_RECORD *Attribute)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define ROUND_UP(n, align)
#define ROUND_DOWN(n, align)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS ReadFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG index, PFILE_RECORD_HEADER file)
VOID ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
ULONGLONG AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord)
NTSTATUS FindAttribute(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, ULONG Type, PCWSTR Name, ULONG NameLength, PNTFS_ATTR_CONTEXT *AttrCtx, PULONG Offset)
ULONG ReadAttribute(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR Buffer, ULONG Length)
ULONGLONG AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord)
#define ExFreePoolWithTag(_P, _T)
_In_ ULONG _In_ ULONG _In_ ULONG Length
BOOLEAN NtfsFCBIsEncrypted(PNTFS_FCB Fcb)
BOOLEAN NtfsFCBIsCompressed(PNTFS_FCB Fcb)
#define STATUS_END_OF_FILE
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INSUFFICIENT_RESOURCES