68 DPRINT(
"VfatFormat(DriveRoot '%wZ')\n", DriveRoot);
110 DPRINT(
"IOCTL_DISK_GET_DRIVE_GEOMETRY failed with status 0x%08x\n",
Status);
121 DPRINT(
"DiskSize %I64d\n",
139 DPRINT(
"IOCTL_DISK_GET_PARTITION_INFO_EX failed with status 0x%08x\n",
Status);
185 if (
PartitionInfo.PartitionLength.QuadPart < (4200LL * 1024LL))
190 else if (
PartitionInfo.StartingOffset.QuadPart < (1024LL * 255LL * 63LL * 512LL))
194 if (
PartitionInfo.PartitionLength.QuadPart < (32LL * 1024LL * 1024LL))
199 else if (
PartitionInfo.PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
214 if (
PartitionInfo.PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
238 if (
PartitionInfo.PartitionLength.QuadPart < (4200LL * 1024LL))
243 else if (
PartitionInfo.PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
248 else if (
PartitionInfo.PartitionLength.QuadPart <= (32LL * 1024LL * 1024LL * 1024LL))
255 DPRINT1(
"The partition ist too large (> 32 GB) for the FAT file system!\n");
284 DPRINT1(
"WARNING: Failed to lock volume for formatting! Format may fail! (Status: 0x%x)\n", LockStatus);
298 else if (FatType ==
FAT_16)
309 else if (FatType ==
FAT_32)
338 DPRINT1(
"Failed to umount volume (Status: 0x%x)\n", LockStatus);
353 DPRINT1(
"Failed to unlock volume (Status: 0x%x)\n", LockStatus);
371 NewPercent = (
Context->CurrentSectorCount * 100ULL) /
Context->TotalSectorCount;
396 DPRINT1(
"VfatPrint -- %s", TextBuf);
435 WCHAR DriveLetter[2] =
L"0";
458 salvage_files =
TRUE;
477 if (CheckOnlyIfDirty && !fs_isdirty())
488 else if (CheckOnlyIfDirty && fs_isdirty())
501 VfatPrint(
"Starting check/repair pass.\n");
520 VfatPrint(
"Starting verification pass.\n");
544 VfatPrint(
"Leaving filesystem unchanged.\n");
548 if (DriveRoot->Buffer[0] ==
'\\' && DriveRoot->Buffer[1] ==
'?' &&
549 DriveRoot->Buffer[2] ==
'?' && DriveRoot->Buffer[3] ==
'\\')
551 DriveLetter[0] = DriveRoot->Buffer[4] & 0x5F;
552 VfatPrint(
"Chkdsk complete for Volume %S.\n", DriveLetter);
554 VfatPrint(
"%10u bytes per cluster.\n",
fs.cluster_size);
555 VfatPrint(
"%10lu total clusters on the disk.\n",
fs.data_clusters);
556 VfatPrint(
"%10lu clusters available on the disk.\n", free_clusters);
559 VfatPrint(
"%wZ: %u files, %lu/%lu clusters\n", DriveRoot,
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
_In_ ULONG _In_ ULONG _In_opt_ DXGKCB_MIRACAST_SEND_MESSAGE_CALLBACK Callback
#define NT_SUCCESS(StatCode)
err_t fs_open(struct fs_file *file, const char *name)
void fs_close(struct fs_file *file)
NTSTATUS Fat12Format(IN HANDLE FileHandle, IN PPARTITION_INFORMATION_EX PartitionInfo, IN PDISK_GEOMETRY DiskGeometry, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN OUT PFORMAT_CONTEXT Context)
NTSTATUS Fat16Format(IN HANDLE FileHandle, IN PPARTITION_INFORMATION_EX PartitionInfo, IN PDISK_GEOMETRY DiskGeometry, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN OUT PFORMAT_CONTEXT Context)
NTSTATUS Fat32Format(IN HANDLE FileHandle, IN PPARTITION_INFORMATION_EX PartitionInfo, IN PDISK_GEOMETRY DiskGeometry, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN OUT PFORMAT_CONTEXT Context)
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
#define IOCTL_DISK_GET_PARTITION_INFO_EX
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
BOOLEAN(NTAPI * PFMIFSCALLBACK)(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
#define FILE_SYNCHRONOUS_IO_ALERT
int scan_root(DOS_FS *fs)
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
#define FSCTL_LOCK_VOLUME
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FSCTL_UNLOCK_VOLUME
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define FSCTL_DISMOUNT_VOLUME
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FILE_GENERIC_READ
#define FILE_GENERIC_WRITE
#define UNREFERENCED_PARAMETER(P)
enum _MEDIA_TYPE MEDIA_TYPE
#define PARTITION_FAT32_XINT13
#define FSCHECK_READ_WRITE
#define FSCHECK_INTERACTIVE
#define FSCHECK_LIST_FILES
void read_boot(DOS_FS *fs)
char get_key(const char *valid, const char *prompt)
void reclaim_free(DOS_FS *fs)
uint32_t update_free(DOS_FS *fs)
void read_fat(DOS_FS *fs)
void reclaim_file(DOS_FS *fs)
#define RtlZeroMemory(Destination, Length)
#define STATUS_ACCESS_DENIED
#define STATUS_INVALID_PARAMETER
#define STATUS_DISK_CORRUPT_ERROR
PFMIFSCALLBACK ChkdskCallback
BOOLEAN NTAPI VfatChkdsk(_In_ PUNICODE_STRING DriveRoot, _In_ PFMIFSCALLBACK Callback, _In_ BOOLEAN FixErrors, _In_ BOOLEAN Verbose, _In_ BOOLEAN CheckOnlyIfDirty, _In_ BOOLEAN ScanDrive, _In_opt_ PVOID pUnknown1, _In_opt_ PVOID pUnknown2, _In_opt_ PVOID pUnknown3, _In_opt_ PVOID pUnknown4, _Out_ PULONG ExitStatus)
VOID VfatPrint(PCHAR Format,...)
BOOLEAN NTAPI VfatFormat(_In_ PUNICODE_STRING DriveRoot, _In_ PFMIFSCALLBACK Callback, _In_ BOOLEAN QuickFormat, _In_ BOOLEAN BackwardCompatible, _In_ MEDIA_TYPE MediaType, _In_ PUNICODE_STRING Label, _In_ ULONG ClusterSize)
VOID UpdateProgress(PFORMAT_CONTEXT Context, ULONG Increment)
VOID VfatPrintV(PCHAR Format, va_list args)
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo