48 DPRINT1(
"Error: Unable to allocate memory for context!\n");
56 DPRINT1(
"Error: Unable to allocate memory for attribute record!\n");
74 Context->CacheRunLength = DataRunLength;
75 if (DataRunOffset != -1)
79 Context->CacheRunLastLCN = DataRunOffset;
87 Context->CacheRunCurrentOffset = 0;
92 DPRINT1(
"Unable to convert data runs to MCB!\n");
108 if (
Context->pRecord->IsNonResident)
145 DPRINT(
"FindAttribute(%p, %p, 0x%x, %S, %lu, %p, %p)\n",
Vcb, MftRecord,
Type,
Name, NameLength, AttrCtx,
Offset);
172 DPRINT(
"Found context\n");
217 RemoteHdr = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
219 if (RemoteHdr ==
NULL)
228 DPRINT1(
"Attribute list references missing attribute to this file entry !");
229 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, RemoteHdr);
236 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, RemoteHdr);
264 return AttrRecord->
Resident.ValueLength;
300 ULONG DataSizeDifference =
Vcb->NtfsInfo.BytesPerFileRecord * NewRecords;
312 DPRINT1(
"IncreaseMftSize(%p, %s)\n",
Vcb, CanWait ?
"TRUE" :
"FALSE");
322 if (!BlankFileRecord)
324 DPRINT1(
"Error: Unable to create empty file record!\n");
329 BlankFileRecord->
Flags = 0;
335 DPRINT1(
"ERROR: Couldn't find $BITMAP attribute of Mft!\n");
336 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
351 BitmapBytes =
DataSize.QuadPart /
Vcb->NtfsInfo.BytesPerFileRecord / 8;
352 if ((
DataSize.QuadPart /
Vcb->NtfsInfo.BytesPerFileRecord) % 8 != 0)
359 BitmapSizeDifference = BitmapBytes - BitmapSize.
QuadPart;
366 DPRINT1(
"ERROR: Unable to allocate memory for bitmap attribute!\n");
367 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
384 DPRINT1(
"ERROR: Bytes read != Bitmap size!\n");
385 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
396 DPRINT1(
"ERROR: Failed to set size of $MFT data attribute!\n");
397 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
409 DPRINT1(
"ERROR: Couldn't find $BITMAP attribute of Mft!\n");
410 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
416 if (BitmapSizeDifference > 0)
419 BitmapSize.
QuadPart = NewBitmapSize;
420 if (BitmapContext->pRecord->IsNonResident)
427 DPRINT1(
"ERROR: Failed to set size of bitmap attribute!\n");
428 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
442 DPRINT1(
"ERROR: Failed to update $MFT file record!\n");
443 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
454 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
458 DPRINT1(
"ERROR: Couldn't write to bitmap attribute of $MFT!\n");
463 for (
i = 0;
i < NewRecords;
i++)
468 DPRINT1(
"ERROR: Failed to write blank file record!\n");
469 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
481 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, BlankFileRecord);
514 ULONG FirstAttributeOffset,
518 ULONG MemBlockSize = 0;
520 ULONG CurrentOffset = FirstAttributeOffset;
523 while (CurrentAttribute->
Type !=
AttributeEnd && CurrentOffset < DeviceExt->NtfsInfo.BytesPerFileRecord)
525 CurrentOffset += CurrentAttribute->
Length;
526 MemBlockSize += CurrentAttribute->
Length;
531 MemBlockSize +=
sizeof(
ULONG) * 2;
538 return FinalAttribute;
552 ULONG NextAttributeOffset;
554 DPRINT1(
"InternalSetResidentAttributeLength( %p, %p, %p, %lu, %lu )\n", DeviceExt, AttrContext, FileRecord, AttrOffset,
DataSize);
556 ASSERT(!AttrContext->pRecord->IsNonResident);
576 if (!AttrContext->pRecord)
578 DPRINT1(
"Unable to allocate memory for attribute!\n");
599 AttrContext->pRecord->Resident.ValueLength =
DataSize;
624 DPRINT1(
"SetAttributeDataLength(%p, %p, %p, %lu, %p, %I64u)\n",
637 DPRINT1(
"Can't truncate a memory-mapped file!\n");
642 if (AttrContext->pRecord->IsNonResident)
662 DPRINT1(
"ERROR: Failed to set size of attribute!\n");
673 if (AttrContext->pRecord->IsNonResident)
717 AttrEnd->
Length = EndMarker;
763 ULONG BytesPerCluster =
Vcb->NtfsInfo.BytesPerCluster;
766 ULONG ExistingClusters = AttrContext->pRecord->NonResident.AllocatedSize / BytesPerCluster;
768 ASSERT(AttrContext->pRecord->IsNonResident);
771 if (AttrContext->pRecord->NonResident.AllocatedSize <
AllocationSize)
775 ULONG NextAssignedCluster;
776 ULONG AssignedClusters;
778 if (ExistingClusters == 0)
785 (
LONGLONG)AttrContext->pRecord->NonResident.HighestVCN,
792 DPRINT1(
"Error looking up final large MCB entry!\n");
795 DPRINT1(
"Highest VCN of record: %I64u\n", AttrContext->pRecord->NonResident.HighestVCN);
800 DPRINT(
"LastClusterInDataRun: %I64u\n", LastClusterInDataRun.
QuadPart);
801 DPRINT(
"Highest VCN of record: %I64u\n", AttrContext->pRecord->NonResident.HighestVCN);
803 while (ClustersNeeded > 0)
806 LastClusterInDataRun.
LowPart + 1,
808 &NextAssignedCluster,
813 DPRINT1(
"Error: Unable to allocate requested clusters!\n");
818 Status =
AddRun(
Vcb, AttrContext, AttrOffset, FileRecord, NextAssignedCluster, AssignedClusters);
821 DPRINT1(
"Error: Unable to add data run!\n");
825 ClustersNeeded -= AssignedClusters;
826 LastClusterInDataRun.
LowPart = NextAssignedCluster + AssignedClusters - 1;
829 else if (AttrContext->pRecord->NonResident.AllocatedSize >
AllocationSize)
839 AttrContext->pRecord->NonResident.DataSize =
DataSize->QuadPart;
840 AttrContext->pRecord->NonResident.InitializedSize =
DataSize->QuadPart;
849 DestinationAttribute->
NonResident.HighestVCN = AttrContext->pRecord->NonResident.HighestVCN;
851 DPRINT(
"Allocated Size: %I64u\n", DestinationAttribute->
NonResident.AllocatedSize);
900 ULONG NextAttributeOffset = AttrOffset + AttrContext->pRecord->Length;
903 ASSERT(!AttrContext->pRecord->IsNonResident);
908 if (
DataSize->QuadPart > AttrContext->pRecord->Resident.ValueLength)
911 ULONG MaxValueLength = AttrContext->pRecord->Length - AttrContext->pRecord->Resident.ValueOffset;
912 if (MaxValueLength < DataSize->LowPart)
915 MaxValueLength +=
Vcb->NtfsInfo.BytesPerFileRecord - NextAttributeOffset - (
sizeof(
ULONG) * 2);
917 if (MaxValueLength < DataSize->LowPart || NextAttribute->
Type !=
AttributeEnd)
924 ULONG NewRecordLength;
925 ULONG EndAttributeOffset;
928 DPRINT1(
"Converting attribute to non-resident.\n");
930 AttribDataSize.
QuadPart = AttrContext->pRecord->Resident.ValueLength;
936 if (AttribData ==
NULL)
938 DPRINT1(
"ERROR: Couldn't allocate memory for attribute data. Can't migrate to non-resident!\n");
946 DPRINT1(
"ERROR: Unable to read attribute before migrating!\n");
967 if (AttrContext->pRecord->NameLength != 0)
973 AttrContext->pRecord->NameLength *
sizeof(
WCHAR));
977 NewRecord->
NonResident.MappingPairsOffset = 0x40 + (AttrContext->pRecord->NameLength *
sizeof(
WCHAR));
981 EndAttributeOffset = AttrOffset + NewRecord->
NonResident.MappingPairsOffset + 1;
985 NewRecord->
Length = EndAttributeOffset - AttrOffset;
1004 DPRINT1(
"Unable to create LargeMcb!\n");
1018 DPRINT1(
"ERROR: Couldn't update file record to continue migration!\n");
1027 AttrContext->pRecord = NewRecord;
1033 DPRINT1(
"ERROR: Unable to migrate resident attribute!\n");
1045 DPRINT1(
"ERROR: Unable to write attribute data to non-resident clusters during migration!\n");
1058 if (!AttrContext->pRecord->IsNonResident)
1084 if (!
Context->pRecord->IsNonResident)
1115 LastLCN =
Context->CacheRunLastLCN;
1116 DataRunStartLCN =
Context->CacheRunStartLCN;
1117 DataRunLength =
Context->CacheRunLength;
1118 CurrentOffset =
Context->CacheRunCurrentOffset;
1123 ULONG UsedBufferSize;
1125 if (TempBuffer ==
NULL)
1136 Vcb->NtfsInfo.BytesPerFileRecord,
1139 DataRun = TempBuffer;
1143 DataRun =
DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
1144 if (DataRunOffset != -1)
1147 DataRunStartLCN = LastLCN + DataRunOffset;
1148 LastLCN = DataRunStartLCN;
1153 DataRunStartLCN = -1;
1156 if (
Offset >= CurrentOffset &&
1157 Offset < CurrentOffset + (DataRunLength *
Vcb->NtfsInfo.BytesPerCluster))
1168 CurrentOffset += DataRunLength *
Vcb->NtfsInfo.BytesPerCluster;
1177 if (DataRunStartLCN == -1)
1185 DataRunStartLCN *
Vcb->NtfsInfo.BytesPerCluster +
Offset - CurrentOffset,
1187 Vcb->NtfsInfo.BytesPerSector,
1197 if (
ReadLength == DataRunLength *
Vcb->NtfsInfo.BytesPerCluster - (
Offset - CurrentOffset))
1199 CurrentOffset += DataRunLength *
Vcb->NtfsInfo.BytesPerCluster;
1200 DataRun =
DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
1203 DataRunStartLCN = LastLCN + DataRunOffset;
1204 LastLCN = DataRunStartLCN;
1207 DataRunStartLCN = -1;
1213 if (DataRunStartLCN == -1)
1218 DataRunStartLCN *
Vcb->NtfsInfo.BytesPerCluster,
1220 Vcb->NtfsInfo.BytesPerSector,
1241 CurrentOffset += DataRunLength *
Vcb->NtfsInfo.BytesPerCluster;
1242 DataRun =
DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
1243 if (DataRunOffset != -1)
1246 DataRunStartLCN = LastLCN + DataRunOffset;
1247 LastLCN = DataRunStartLCN;
1252 DataRunStartLCN = -1;
1259 if (
Context->pRecord->IsNonResident)
1264 Context->CacheRunStartLCN = DataRunStartLCN;
1265 Context->CacheRunLength = DataRunLength;
1266 Context->CacheRunLastLCN = LastLCN;
1267 Context->CacheRunCurrentOffset = CurrentOffset;
1320 PULONG RealLengthWritten,
1339 DPRINT(
"WriteAttribute(%p, %p, %I64u, %p, %lu, %p, %p)\n",
Vcb,
Context,
Offset,
Buffer,
Length, RealLengthWritten, FileRecord);
1341 *RealLengthWritten = 0;
1344 if (!
Context->pRecord->IsNonResident)
1346 ULONG AttributeOffset;
1351 ASSERT(
Offset + Length <= Context->pRecord->Resident.ValueLength);
1355 DPRINT1(
"DRIVER ERROR: Attribute is too small!\n");
1360 if (FileRecord ==
NULL)
1362 FileRecord = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
1365 DPRINT1(
"Error: Couldn't allocate file record!\n");
1369 FileRecordAllocated =
TRUE;
1385 DPRINT1(
"ERROR: Couldn't find matching attribute!\n");
1386 if(FileRecordAllocated)
1387 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, FileRecord);
1393 DPRINT(
"Offset: %I64u, AttributeOffset: %u, ValueOffset: %u\n",
Offset, AttributeOffset,
Context->pRecord->Resident.ValueLength);
1396 if (
Offset +
Length + AttributeOffset +
Context->pRecord->Resident.ValueOffset >
Vcb->NtfsInfo.BytesPerFileRecord)
1398 DPRINT1(
"DRIVER ERROR: Data being written extends past end of file record!\n");
1400 if (FileRecordAllocated)
1401 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, FileRecord);
1415 if (FileRecordAllocated)
1416 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, FileRecord);
1419 *RealLengthWritten =
Length;
1440 ULONG UsedBufferSize;
1446 if (TempBuffer ==
NULL)
1453 Vcb->NtfsInfo.BytesPerFileRecord,
1456 DataRun = TempBuffer;
1460 DataRun =
DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
1461 if (DataRunOffset != -1)
1465 DataRunStartLCN = LastLCN + DataRunOffset;
1466 LastLCN = DataRunStartLCN;
1472 DataRunStartLCN = -1;
1473 DPRINT1(
"FIXME: Writing to sparse files is not supported yet!\n");
1479 if (
Offset >= CurrentOffset &&
1480 Offset < CurrentOffset + (DataRunLength *
Vcb->NtfsInfo.BytesPerCluster))
1491 DPRINT1(
"FIXME: Master File Table needs to be enlarged.\n");
1496 CurrentOffset += DataRunLength *
Vcb->NtfsInfo.BytesPerCluster;
1514 Vcb->NtfsInfo.BytesPerSector,
1515 (
PVOID)SourceBuffer);
1522 Context->CacheRunStartLCN = DataRunStartLCN;
1523 Context->CacheRunLength = DataRunLength;
1524 Context->CacheRunLastLCN = LastLCN;
1525 Context->CacheRunCurrentOffset = CurrentOffset;
1538 CurrentOffset += DataRunLength *
Vcb->NtfsInfo.BytesPerCluster;
1539 DataRun =
DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
1543 DataRunStartLCN = LastLCN + DataRunOffset;
1544 LastLCN = DataRunStartLCN;
1547 DataRunStartLCN = -1;
1557 if (DataRunStartLCN == -1)
1559 DPRINT1(
"FIXME: Don't know how to write to sparse files yet! (DataRunStartLCN == -1)\n");
1567 DataRunStartLCN *
Vcb->NtfsInfo.BytesPerCluster,
1569 Vcb->NtfsInfo.BytesPerSector,
1570 (
PVOID)SourceBuffer);
1591 DPRINT1(
"Encountered EOF before expected!\n");
1600 CurrentOffset += DataRunLength *
Vcb->NtfsInfo.BytesPerCluster;
1601 DataRun =
DecodeRun(DataRun, &DataRunOffset, &DataRunLength);
1602 if (DataRunOffset != -1)
1605 DataRunStartLCN = LastLCN + DataRunOffset;
1606 LastLCN = DataRunStartLCN;
1611 DataRunStartLCN = -1;
1617 Context->CacheRunStartLCN = DataRunStartLCN;
1618 Context->CacheRunLength = DataRunLength;
1619 Context->CacheRunLastLCN = LastLCN;
1620 Context->CacheRunCurrentOffset = CurrentOffset;
1624 if (
Context->pRecord->IsNonResident)
1642 DPRINT1(
"ReadFileRecord failed: %I64u read, %lu expected\n",
BytesRead,
Vcb->NtfsInfo.BytesPerFileRecord);
1647 DPRINT(
"Sequence number: %u\n",
file->SequenceNumber);
1674 ULONG CurrentEntry = 0;
1676 DPRINT(
"UpdateFileNameRecord(%p, %I64d, %wZ, %s, %I64u, %I64u, %s)\n",
1680 DirSearch ?
"TRUE" :
"FALSE",
1683 CaseSensitive ?
"TRUE" :
"FALSE");
1685 MftRecord = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
1686 if (MftRecord ==
NULL)
1694 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
1702 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
1707 if (IndexRecord ==
NULL)
1710 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
1717 DPRINT1(
"ERROR: Failed to read Index Root!\n");
1720 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
1729 DPRINT(
"IndexRecordSize: %x IndexBlockSize: %x\n",
Vcb->NtfsInfo.BytesPerIndexRecord, IndexRoot->
SizeOfEntry);
1748 ULONG LengthWritten;
1752 DPRINT1(
"ERROR: Couldn't update Index Root!\n");
1759 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
1773 ULONG IndexBlockSize,
1791 DPRINT(
"UpdateIndexEntrySize(%p, %p, %p, %lu, %p, %p, %wZ, %lu, %lu, %s, %I64u, %I64u, %s)\n",
1801 DirSearch ?
"TRUE" :
"FALSE",
1804 CaseSensitive ?
"TRUE" :
"FALSE");
1807 IndexEntry = FirstEntry;
1808 while (IndexEntry < LastEntry &&
1812 *CurrentEntry >= *StartEntry &&
1816 *StartEntry = *CurrentEntry;
1823 (*CurrentEntry) += 1;
1829 if (IndexRecord ==
NULL)
1843 DPRINT(
"Corrupted filesystem!\n");
1849 for (RecordOffset = 0; RecordOffset < IndexAllocationSize; RecordOffset += IndexBlockSize)
1851 ReadAttribute(
Vcb, IndexAllocationCtx, RecordOffset, IndexRecord, IndexBlockSize);
1887 DPRINT1(
"Error: Failed to update fixup sequence array!\n");
1894 DPRINT1(
"ERROR Performing write!\n");
1938 DPRINT(
"UpdateFileRecord(%p, 0x%I64x, %p)\n",
Vcb, MftIndex, FileRecord);
1946 MftIndex *
Vcb->NtfsInfo.BytesPerFileRecord,
1947 (
const PUCHAR)FileRecord,
1948 Vcb->NtfsInfo.BytesPerFileRecord,
1954 DPRINT1(
"UpdateFileRecord failed: %lu written, %lu expected\n",
BytesWritten,
Vcb->NtfsInfo.BytesPerFileRecord);
1974 USANumber = *(USA++);
1975 USACount =
Record->UsaCount - 1;
1978 DPRINT(
"FixupUpdateSequenceArray(%p, %p)\nUSANumber: %u\tUSACount: %u\n",
Vcb,
Record, USANumber, USACount);
1982 if (*Block != USANumber)
1984 DPRINT1(
"Mismatch with USA: %u read, %u expected\n" , *Block, USANumber);
2034 ULONG LengthWritten;
2037 UCHAR SystemReservedBits;
2039 DPRINT1(
"AddNewMftEntry(%p, %p, %p, %s)\n", FileRecord, DeviceExt, DestinationIndex, CanWait ?
"TRUE" :
"FALSE");
2047 DPRINT1(
"ERROR: Couldn't find $Bitmap attribute of master file table!\n");
2070 if (AttrBytesRead != BitmapDataSize)
2072 DPRINT1(
"ERROR: Unable to read $Bitmap attribute of master file table!\n");
2085 DeviceExt->NtfsInfo.BytesPerFileRecord;
2088 DPRINT1(
"\tFIXME: bitmap sizes beyond 32bits are not yet supported! (Your NTFS volume is too large)\n");
2100 if ((
LONG)MftIndex == -1)
2102 DPRINT1(
"Couldn't find free space in MFT for file record, increasing MFT size.\n");
2111 DPRINT1(
"ERROR: Couldn't find space in MFT for file or increase MFT size!\n");
2115 return AddNewMftEntry(FileRecord, DeviceExt, DestinationIndex, CanWait);
2118 DPRINT1(
"Creating file record at MFT index: %I64u\n", MftIndex);
2132 DPRINT1(
"ERROR encountered when writing $Bitmap attribute!\n");
2143 DPRINT1(
"ERROR: Unable to write file record!\n");
2149 *DestinationIndex = MftIndex;
2202 ULONG IndexRootOffset;
2204 ULONG LengthWritten;
2206 ULONG AttributeLength;
2209 ULONG BtreeIndexLength;
2210 ULONG MaxIndexRootSize;
2214 ULONG NewMaxIndexRootSize;
2218 ParentFileRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
2219 if (!ParentFileRecord)
2221 DPRINT1(
"ERROR: Couldn't allocate memory for file record!\n");
2229 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2230 DPRINT1(
"ERROR: Couldn't read parent directory with index %I64u\n",
2236 DPRINT1(
"Dumping old parent file record:\n");
2250 DPRINT1(
"ERROR: Couldn't find $I30 $INDEX_ROOT attribute for parent directory with MFT #: %I64u!\n",
2252 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2258 MaxIndexRootSize = DeviceExt->NtfsInfo.BytesPerFileRecord
2260 - IndexRootContext->pRecord->Resident.ValueOffset
2262 - (
sizeof(
ULONG) * 2);
2269 ULONG LengthOfAttributes = 0;
2273 LengthOfAttributes += CurrentAttribute->
Length;
2278 MaxIndexRootSize -= LengthOfAttributes;
2286 DPRINT1(
"ERROR: Couldn't allocate memory for index root attribute!\n");
2288 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2296 DPRINT1(
"ERROR: Couln't read index root attribute for Mft index #%I64u\n", DirectoryMftIndex);
2299 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2311 DPRINT1(
"ERROR: Failed to create B-Tree from Index!\n");
2314 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2324 FileReferenceNumber,
2334 DPRINT1(
"ERROR: Failed to insert key into B-Tree!\n");
2338 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2368 AttributeLength = MinIndexRootSize.
LowPart;
2383 DPRINT1(
"ERROR: Unable to set length of index root!\n");
2387 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2395 DPRINT1(
"ERROR: Failed to update index allocation from B-Tree!\n");
2399 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2404 DPRINT1(
"Index Allocation updated\n");
2410 NewMaxIndexRootSize =
2411 DeviceExt->NtfsInfo.BytesPerFileRecord
2413 - IndexRootContext->pRecord->Resident.ValueOffset
2415 - (
sizeof(
ULONG) * 2);
2422 ULONG LengthOfAttributes = 0;
2426 LengthOfAttributes += CurrentAttribute->
Length;
2431 NewMaxIndexRootSize -= LengthOfAttributes;
2437 if (NodeSize > NewMaxIndexRootSize)
2439 DPRINT1(
"Demoting index root.\nNodeSize: 0x%lx\nNewMaxIndexRootSize: 0x%lx\n", NodeSize, NewMaxIndexRootSize);
2444 DPRINT1(
"ERROR: Failed to demote index root!\n");
2448 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2456 DPRINT1(
"ERROR: Failed to update index allocation from B-Tree!\n");
2460 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2465 NewMaxIndexRootSize =
2468 DeviceExt->NtfsInfo.BytesPerFileRecord
2470 - IndexRootContext->pRecord->Resident.ValueOffset
2472 - (
sizeof(
ULONG) * 2);
2479 ULONG LengthOfAttributes = 0;
2483 LengthOfAttributes += CurrentAttribute->
Length;
2488 NewMaxIndexRootSize -= LengthOfAttributes;
2498 DPRINT1(
"ERROR: Failed to create Index root from B-Tree!\n");
2502 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2516 if (AttributeLength != IndexRootContext->pRecord->Resident.ValueLength)
2529 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2530 DPRINT1(
"ERROR: Unable to set resident attribute length!\n");
2541 DPRINT1(
"ERROR: Failed to update file record of directory with index: %llx\n", DirectoryMftIndex);
2542 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2559 DPRINT1(
"ERROR: Unable to write new index root attribute to parent directory!\n");
2563 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2571 DPRINT1(
"ERROR: Couldn't read parent directory after messing with it!\n");
2576 DPRINT1(
"Dumping new B-Tree:\n");
2581 DPRINT1(
"ERROR: Couldn't re-create b-tree\n");
2597 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, ParentFileRecord);
2613 DPRINT(
"AddFixupArray(%p, %p)\n fixupArray->USN: %u, ArrayEntryCount: %u\n",
Vcb,
Record, fixupArray->
USN, ArrayEntryCount);
2617 for (
i = 0;
i < ArrayEntryCount;
i++)
2622 fixupArray->
Array[
i] = *pShortToFixUp;
2623 *pShortToFixUp = fixupArray->
USN;
2641 DiskSector.
u.LowPart *
Vcb->NtfsInfo.SectorsPerCluster,
2642 count *
Vcb->NtfsInfo.SectorsPerCluster,
2643 Vcb->NtfsInfo.BytesPerSector,
2723 ULONG LengthWritten;
2726 MirrorFileRecord = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
2727 if (!MirrorFileRecord)
2729 DPRINT1(
"Error: Failed to allocate memory for $MFTMirr!\n");
2737 DPRINT1(
"ERROR: Failed to read $MFTMirr!\n");
2738 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MirrorFileRecord);
2746 DPRINT1(
"ERROR: Couldn't find $DATA attribute!\n");
2747 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MirrorFileRecord);
2755 DPRINT1(
"ERROR: Couldn't find $DATA attribute!\n");
2757 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MirrorFileRecord);
2770 DPRINT1(
"Error: Couldn't allocate memory for $DATA buffer!\n");
2773 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MirrorFileRecord);
2783 DPRINT1(
"Error: Failed to read $DATA for $MFTMirr!\n");
2787 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MirrorFileRecord);
2801 DPRINT1(
"ERROR: Failed to write $DATA attribute of $MFTMirr!\n");
2808 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MirrorFileRecord);
2818 DPRINT1(
"Entry: %p\n", IndexEntry);
2841 ULONG IndexBlockSize,
2861 DPRINT(
"BrowseSubNodeIndexEntries(%p, %p, %lu, %wZ, %p, %p, %I64d, %lu, %lu, %s, %s, %p)\n",
2866 IndexAllocationContext,
2872 DirSearch ?
"TRUE" :
"FALSE",
2873 CaseSensitive ?
"TRUE" :
"FALSE",
2877 NodeNumber = VCN / (
Vcb->NtfsInfo.BytesPerIndexRecord /
Vcb->NtfsInfo.BytesPerCluster);
2882 DPRINT1(
"File system corruption detected, node with VCN %I64u is marked as deleted.\n", VCN);
2890 DPRINT1(
"Unable to allocate memory for index record!\n");
2895 Offset = VCN *
Vcb->NtfsInfo.BytesPerCluster;
2901 DPRINT1(
"Unable to read index record!\n");
2914 DPRINT1(
"Failed to apply fixup array!\n");
2924 IndexEntry = FirstEntry;
2925 while (IndexEntry <= LastEntry)
2932 DPRINT1(
"Filesystem corruption detected!\n");
2940 IndexAllocationContext,
2962 *CurrentEntry >= *StartEntry &&
2966 *StartEntry = *CurrentEntry;
2973 (*CurrentEntry) += 1;
2987 ULONG IndexBlockSize,
3005 DPRINT(
"BrowseIndexEntries(%p, %p, %p, %lu, %p, %p, %wZ, %lu, %lu, %s, %s, %p)\n",
3015 DirSearch ?
"TRUE" :
"FALSE",
3016 CaseSensitive ?
"TRUE" :
"FALSE",
3028 DPRINT1(
"Potential file system corruption detected!\n");
3041 DPRINT1(
"Error: failed to allocate bitmap!");
3056 DPRINT1(
"ERROR: Failed to read bitmap attribute!\n");
3069 IndexAllocationContext =
NULL;
3074 IndexEntry = FirstEntry;
3075 while (IndexEntry <= LastEntry)
3082 DPRINT1(
"Filesystem corruption detected!\n");
3090 IndexAllocationContext,
3114 *CurrentEntry >= *StartEntry &&
3118 *StartEntry = *CurrentEntry;
3120 if (IndexAllocationContext)
3130 (*CurrentEntry) += 1;
3135 if (IndexAllocationContext)
3160 ULONG CurrentEntry = 0;
3162 DPRINT(
"NtfsFindMftRecord(%p, %I64d, %wZ, %lu, %s, %s, %p)\n",
3167 DirSearch ?
"TRUE" :
"FALSE",
3168 CaseSensitive ?
"TRUE" :
"FALSE",
3171 MftRecord = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
3172 if (MftRecord ==
NULL)
3180 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
3188 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
3193 if (IndexRecord ==
NULL)
3196 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
3207 DPRINT(
"IndexRecordSize: %x IndexBlockSize: %x\n",
Vcb->NtfsInfo.BytesPerIndexRecord, IndexRoot->
SizeOfEntry);
3223 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, MftRecord);
3238 ULONG FirstEntry = 0;
3240 DPRINT(
"NtfsLookupFileAt(%p, %wZ, %s, %p, %p, %I64x)\n",
3243 CaseSensitive ?
"TRUE" :
"FALSE",
3250 while (Current.
Length != 0)
3252 DPRINT(
"Current: %wZ\n", &Current);
3260 if (Remaining.
Length == 0)
3266 *FileRecord = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
3267 if (*FileRecord ==
NULL)
3269 DPRINT(
"NtfsLookupFileAt: Can't allocate MFT record\n");
3276 DPRINT(
"NtfsLookupFileAt: Can't read MFT record\n");
3277 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, *FileRecord);
3281 *MFTIndex = CurrentMFTIndex;
3308 for (
j = 0;
j < 8;
j++)
3346 for (
j = 0;
j < 8;
j++)
3365 DPRINT(
"NtfsFindFileAt(%p, %wZ, %lu, %p, %p, %I64x, %s)\n",
3372 (CaseSensitive ?
"TRUE" :
"FALSE"));
3377 DPRINT(
"NtfsFindFileAt: NtfsFindMftRecord() failed with status 0x%08lx\n",
Status);
3381 *FileRecord = ExAllocateFromNPagedLookasideList(&
Vcb->FileRecLookasideList);
3382 if (*FileRecord ==
NULL)
3384 DPRINT(
"NtfsFindFileAt: Can't allocate MFT record\n");
3391 DPRINT(
"NtfsFindFileAt: Can't read MFT record\n");
3392 ExFreeToNPagedLookasideList(&
Vcb->FileRecLookasideList, *FileRecord);
3396 *MFTIndex = CurrentMFTIndex;
#define ALIGN_UP_BY(size, align)
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
struct NTFS_ATTR_RECORD * PNTFS_ATTR_RECORD
#define NTFS_FILE_NAME_DOS
#define NTFS_INDEX_ENTRY_NODE
#define NTFS_INDEX_ENTRY_END
#define NTFS_FILE_MFTMIRR
NTSTATUS CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecordWithIndex, PNTFS_ATTR_CONTEXT IndexRootContext, PINDEX_ROOT_ATTRIBUTE IndexRoot, PB_TREE *NewTree)
ULONGLONG GetIndexEntryVCN(PINDEX_ENTRY_ATTRIBUTE IndexEntry)
NTSTATUS NtfsInsertKey(PB_TREE Tree, ULONGLONG FileReference, PFILENAME_ATTRIBUTE FileNameAttribute, PB_TREE_FILENAME_NODE Node, BOOLEAN CaseSensitive, ULONG MaxIndexRootSize, ULONG IndexRecordSize, PB_TREE_KEY *MedianKey, PB_TREE_FILENAME_NODE *NewRightHandSibling)
NTSTATUS UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt, PB_TREE Tree, ULONG IndexBufferSize, PFILE_RECORD_HEADER FileRecord)
VOID DestroyBTree(PB_TREE Tree)
NTSTATUS DemoteBTreeRoot(PB_TREE Tree)
ULONG GetSizeOfIndexEntries(PB_TREE_FILENAME_NODE Node)
VOID DumpBTree(PB_TREE Tree)
NTSTATUS CreateIndexRootFromBTree(PDEVICE_EXTENSION DeviceExt, PB_TREE Tree, ULONG MaxIndexSize, PINDEX_ROOT_ATTRIBUTE *IndexRoot, ULONG *Length)
_In_ PFCB _In_ LONGLONG StartingOffset
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
#define STATUS_NOT_IMPLEMENTED
#define RtlInitializeBitMap
#define RtlFindClearBitsAndSet
#define NT_SUCCESS(StatCode)
static const WCHAR Cleanup[]
NTSTATUS AddRun(PNTFS_VCB Vcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, ULONGLONG NextAssignedCluster, ULONG RunLength)
PUCHAR DecodeRun(PUCHAR DataRun, LONGLONG *DataRunOffset, ULONGLONG *DataRunLength)
NTSTATUS ConvertDataRunsToLargeMCB(PUCHAR DataRun, PLARGE_MCB DataRunsMCB, PULONGLONG pNextVBN)
NTSTATUS FindFirstAttribute(PFIND_ATTR_CONTXT Context, PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord, BOOLEAN OnlyResident, PNTFS_ATTR_RECORD *Attribute)
NTSTATUS FindFirstAttributeListItem(PFIND_ATTR_CONTXT Context, PNTFS_ATTRIBUTE_LIST_ITEM *Item)
NTSTATUS FreeClusters(PNTFS_VCB Vcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, ULONG ClustersToFree)
VOID FindCloseAttribute(PFIND_ATTR_CONTXT Context)
NTSTATUS ConvertLargeMCBToDataRuns(PLARGE_MCB DataRunsMCB, PUCHAR RunBuffer, ULONG MaxBufferSize, PULONG UsedBufferSize)
VOID NtfsDumpFileAttributes(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord)
NTSTATUS FindNextAttribute(PFIND_ATTR_CONTXT Context, PNTFS_ATTR_RECORD *Attribute)
NTSTATUS FindNextAttributeListItem(PFIND_ATTR_CONTXT Context, PNTFS_ATTRIBUTE_LIST_ITEM *Item)
PFILE_RECORD_HEADER NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt)
PNTFS_GLOBAL_DATA NtfsGlobalData
struct FIXUP_ARRAY * PFIXUP_ARRAY
struct INDEX_BUFFER * PINDEX_BUFFER
struct INDEX_ENTRY_ATTRIBUTE * PINDEX_ENTRY_ATTRIBUTE
#define NTFS_FILE_FIRST_USER_FILE
struct INDEX_ROOT_ATTRIBUTE * PINDEX_ROOT_ATTRIBUTE
@ AttributeIndexAllocation
#define ATTR_RECORD_ALIGNMENT
NTSTATUS NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt, ULONG FirstDesiredCluster, ULONG DesiredClusters, PULONG FirstAssignedCluster, PULONG AssignedClusters)
#define ExAllocatePoolWithTag(hernya, size, tag)
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
#define RtlCompareMemory(s1, s2, l)
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
#define ExAcquireResourceExclusiveLite(res, wait)
#define ROUND_UP(n, align)
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
struct _FileName FileName
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
GLuint GLuint GLsizei count
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static ULONG BitmapBuffer[(XMS_BLOCKS+31)/32]
#define EXCEPTION_EXECUTE_HANDLER
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType)
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
NTSTATUS BrowseSubNodeIndexEntries(PNTFS_VCB Vcb, PFILE_RECORD_HEADER MftRecord, ULONG IndexBlockSize, PUNICODE_STRING FileName, PNTFS_ATTR_CONTEXT IndexAllocationContext, PRTL_BITMAP Bitmap, ULONGLONG VCN, PULONG StartEntry, PULONG CurrentEntry, BOOLEAN DirSearch, BOOLEAN CaseSensitive, ULONGLONG *OutMFTIndex)
void NtfsDumpData(ULONG_PTR Buffer, ULONG Length)
NTSTATUS ReadFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG index, PFILE_RECORD_HEADER file)
NTSTATUS NtfsLookupFileAt(PDEVICE_EXTENSION Vcb, PUNICODE_STRING PathName, BOOLEAN CaseSensitive, PFILE_RECORD_HEADER *FileRecord, PULONGLONG MFTIndex, ULONGLONG CurrentMFTIndex)
NTSTATUS UpdateFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG MftIndex, PFILE_RECORD_HEADER FileRecord)
NTSTATUS NtfsLookupFile(PDEVICE_EXTENSION Vcb, PUNICODE_STRING PathName, BOOLEAN CaseSensitive, PFILE_RECORD_HEADER *FileRecord, PULONGLONG MFTIndex)
VOID ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
NTSTATUS UpdateFileNameRecord(PDEVICE_EXTENSION Vcb, ULONGLONG ParentMFTIndex, PUNICODE_STRING FileName, BOOLEAN DirSearch, ULONGLONG NewDataSize, ULONGLONG NewAllocationSize, BOOLEAN CaseSensitive)
NTSTATUS UpdateMftMirror(PNTFS_VCB Vcb)
PNTFS_ATTR_CONTEXT PrepareAttributeContext(PNTFS_ATTR_RECORD AttrRecord)
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)
NTSTATUS WriteAttribute(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, const PUCHAR Buffer, ULONG Length, PULONG RealLengthWritten, PFILE_RECORD_HEADER FileRecord)
NTSTATUS BrowseIndexEntries(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, PINDEX_ROOT_ATTRIBUTE IndexRecord, ULONG IndexBlockSize, PINDEX_ENTRY_ATTRIBUTE FirstEntry, PINDEX_ENTRY_ATTRIBUTE LastEntry, PUNICODE_STRING FileName, PULONG StartEntry, PULONG CurrentEntry, BOOLEAN DirSearch, BOOLEAN CaseSensitive, ULONGLONG *OutMFTIndex)
VOID SetFileRecordEnd(PFILE_RECORD_HEADER FileRecord, PNTFS_ATTR_RECORD AttrEnd, ULONG EndMarker)
NTSTATUS IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
NTSTATUS AddFixupArray(PDEVICE_EXTENSION Vcb, PNTFS_RECORD_HEADER Record)
NTSTATUS SetNonResidentAttributeDataLength(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, PLARGE_INTEGER DataSize)
PNTFS_ATTR_RECORD MoveAttributes(PDEVICE_EXTENSION DeviceExt, PNTFS_ATTR_RECORD FirstAttributeToMove, ULONG FirstAttributeOffset, ULONG_PTR MoveTo)
NTSTATUS NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt, ULONGLONG DirectoryMftIndex, ULONGLONG FileReferenceNumber, PFILENAME_ATTRIBUTE FilenameAttribute, BOOLEAN CaseSensitive)
NTSTATUS UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, PCHAR IndexRecord, ULONG IndexBlockSize, PINDEX_ENTRY_ATTRIBUTE FirstEntry, PINDEX_ENTRY_ATTRIBUTE LastEntry, PUNICODE_STRING FileName, PULONG StartEntry, PULONG CurrentEntry, BOOLEAN DirSearch, ULONGLONG NewDataSize, ULONGLONG NewAllocatedSize, BOOLEAN CaseSensitive)
ULONGLONG AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord)
NTSTATUS AddNewMftEntry(PFILE_RECORD_HEADER FileRecord, PDEVICE_EXTENSION DeviceExt, PULONGLONG DestinationIndex, BOOLEAN CanWait)
VOID NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord)
NTSTATUS SetResidentAttributeDataLength(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, PLARGE_INTEGER DataSize)
NTSTATUS NtfsFindMftRecord(PDEVICE_EXTENSION Vcb, ULONGLONG MFTIndex, PUNICODE_STRING FileName, PULONG FirstEntry, BOOLEAN DirSearch, BOOLEAN CaseSensitive, ULONGLONG *OutMFTIndex)
NTSTATUS ReadLCN(PDEVICE_EXTENSION Vcb, ULONGLONG lcn, ULONG count, PVOID buffer)
NTSTATUS FixupUpdateSequenceArray(PDEVICE_EXTENSION Vcb, PNTFS_RECORD_HEADER Record)
NTSTATUS InternalSetResidentAttributeLength(PDEVICE_EXTENSION DeviceExt, PNTFS_ATTR_CONTEXT AttrContext, PFILE_RECORD_HEADER FileRecord, ULONG AttrOffset, ULONG DataSize)
NTSTATUS NtfsFindFileAt(PDEVICE_EXTENSION Vcb, PUNICODE_STRING SearchPattern, PULONG FirstEntry, PFILE_RECORD_HEADER *FileRecord, PULONGLONG MFTIndex, ULONGLONG CurrentMFTIndex, BOOLEAN CaseSensitive)
BOOLEAN CompareFileName(PUNICODE_STRING FileName, PINDEX_ENTRY_ATTRIBUTE IndexEntry, BOOLEAN DirSearch, BOOLEAN CaseSensitive)
NTSTATUS SetAttributeDataLength(PFILE_OBJECT FileObject, PNTFS_FCB Fcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, PLARGE_INTEGER DataSize)
#define ExFreePoolWithTag(_P, _T)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
__GNU_EXTENSION typedef __int64 * PLONGLONG
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject, IN LONGLONG StartingOffset, IN ULONG Length, IN ULONG SectorSize, IN const PUCHAR Buffer)
NTSTATUS NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject, IN ULONG DiskSector, IN ULONG SectorCount, IN ULONG SectorSize, IN OUT PUCHAR Buffer, IN BOOLEAN Override)
NTSTATUS NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject, IN LONGLONG StartingOffset, IN ULONG Length, IN ULONG SectorSize, IN OUT PUCHAR Buffer, IN BOOLEAN Override)
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
VOID NTAPI FsRtlDissectName(IN UNICODE_STRING Name, OUT PUNICODE_STRING FirstPart, OUT PUNICODE_STRING RemainingPart)
#define STATUS_USER_MAPPED_FILE
#define STATUS_PARTIAL_COPY
#define STATUS_DATA_ERROR
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
BOOLEAN NTAPI MmCanFileBeTruncated(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER NewFileSize)
#define STATUS_END_OF_FILE
PB_TREE_FILENAME_NODE RootNode
ULONGLONG DirectoryFileReferenceNumber
INDEX_HEADER_ATTRIBUTE Header
struct INDEX_ENTRY_ATTRIBUTE::@774::@775 Directory
FILENAME_ATTRIBUTE FileName
union INDEX_ENTRY_ATTRIBUTE::@774 Data
INDEX_HEADER_ATTRIBUTE Header
struct NTFS_ATTR_RECORD::@169::@171 Resident
struct NTFS_ATTR_RECORD::@169::@172 NonResident
BOOLEAN EnableWriteSupport
NPAGED_LOOKASIDE_LIST AttrCtxtLookasideList
FSRTL_COMMON_FCB_HEADER RFCB
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_OBJECT_PATH_NOT_FOUND
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
struct _LARGE_INTEGER::@2304 u
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record