16#define WIN32_NO_STATUS
111 while (LineLength > 0)
198 Len =
PrintString(
"Press any key within %d second(s) to cancel and resume startup. \r", TimeOut);
261 DPRINT1(
"Could not open volume '%wZ' to obtain its file system, Status 0x%08lx\n",
275 DPRINT1(
"NtQueryVolumeInformationFile() failed, Status 0x%08lx\n",
Status);
345 DPRINT(
"INSUFFICIENTRIGHTS\n");
349 DPRINT(
"FSNOTSUPPORTED\n");
357 DPRINT(
"STRUCTUREPROGRESS\n");
361 DPRINT(
"DONEWITHSTRUCTURE\n");
365 DPRINT(
"CLUSTERSIZETOOSMALL\n");
369 Percent = (
PDWORD) Argument;
382 PrintString(
"The file system check was unable to complete successfully.\r\n\r\n");
406 if (
wcslen(VolumePath) == 6 &&
407 VolumePath[0] ==
L'\\' &&
408 VolumePath[1] ==
L'?' &&
409 VolumePath[2] ==
L'?' &&
410 VolumePath[3] ==
L'\\' &&
411 VolumePath[5] ==
L':')
414 DisplayName = &VolumePath[4];
418 DisplayName = VolumePath;
421 DPRINT1(
"AUTOCHK: Checking %wZ\n", &VolumePathU);
422 PrintString(
"Verifying the file system on %S\r\n", DisplayName);
431 PrintString(
" Unable to detect the file system of volume %S\r\n", DisplayName);
471 PrintString(
"The file system on volume %S needs to be checked for problems.\r\n", DisplayName);
472 PrintString(
"You may cancel this check, but it is recommended that you continue.\r\n");
476 PrintString(
"A volume check has been scheduled.\r\n");
481 PrintString(
"The system will now check the file system.\r\n\r\n");
497 PrintString(
"The file system check has been skipped.\r\n");
519 *TimeOut =
min(
max(*TimeOut, 0), 259200);
539 WCHAR VolumePath[128] =
L"";
561 if (
argv[
i][2] !=
':')
564 SkipDrives = &
argv[
i][3];
574 CheckOnlyIfDirty =
FALSE;
585 DPRINT(
"Parameter %d - Volume specification: %s\n",
i,
argv[
i]);
588 CheckAllVolumes =
TRUE;
592 RtlInitEmptyUnicodeString(&VolumePathU,
613 sizeof(DeviceMap.
Query),
617 DPRINT1(
"NtQueryInformationProcess() failed, Status 0x%08lx\n",
Status);
622 if (SkipDrives && *SkipDrives)
632 if (0 <=
i &&
i <=
'Z'-
'A')
633 DeviceMap.
Query.DriveMap &= ~(1 <<
i);
656 for (
i = 0;
i <=
'Z'-
'A';
i++)
658 if ((DeviceMap.
Query.DriveMap & (1 <<
i)) &&
662 CheckVolume(VolumePath, TimeOut, CheckOnlyIfDirty);
669 if (
wcslen(VolumePath) == 6 &&
670 VolumePath[0] ==
L'\\' &&
671 VolumePath[1] ==
L'?' &&
672 VolumePath[2] ==
L'?' &&
673 VolumePath[3] ==
L'\\' &&
674 VolumePath[5] ==
L':')
677 if ((DeviceMap.
Query.DriveMap & (1 <<
i)) &&
680 CheckVolume(VolumePath, TimeOut, CheckOnlyIfDirty);
687 CheckVolume(VolumePath, TimeOut, CheckOnlyIfDirty);
int strcmp(const char *String1, const char *String2)
static VOID EraseLine(IN INT LineLength)
static NTSTATUS CheckVolume(IN PCWSTR VolumePath, IN LONG TimeOut, IN BOOLEAN CheckOnlyIfDirty)
INT __cdecl _main(IN INT argc, IN PCHAR argv[], IN PCHAR envp[], IN ULONG DebugFlag)
static NTSTATUS GetFileSystem(IN PUNICODE_STRING VolumePathU, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
struct _FILESYSTEM_CHKDSK FILESYSTEM_CHKDSK
static VOID QueryTimeout(IN OUT PLONG TimeOut)
struct _FILESYSTEM_CHKDSK * PFILESYSTEM_CHKDSK
static INT PrintString(char *fmt,...)
FILESYSTEM_CHKDSK FileSystems[]
static NTSTATUS OpenKeyboard(OUT PHANDLE KeyboardHandle)
static NTSTATUS WaitForKeyboard(IN HANDLE KeyboardHandle, IN LONG TimeOut)
BOOLEAN NTAPI BtrfsChkdsk(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
BOOLEAN NTAPI CdfsChkdsk(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
BOOLEAN NTAPI Ext2Chkdsk(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
struct TEXTOUTPUT * PTEXTOUTPUT
BOOLEAN(NTAPI * PULIB_CHKDSK)(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
@ FileFsAttributeInformation
struct _FILE_FS_ATTRIBUTE_INFORMATION * PFILE_FS_ATTRIBUTE_INFORMATION
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
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
BOOLEAN NTAPI VfatChkdsk(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
BOOLEAN NTAPI VfatxChkdsk(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
#define DOSDEVICE_DRIVE_FIXED
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
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 RTL_REGISTRY_CONTROL
NTSTATUS NTAPI NtDisplayString(PUNICODE_STRING String)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
#define RTL_QUERY_REGISTRY_DIRECT
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define FILE_GENERIC_READ
_In_ ULONG _In_ ULONG Offset
BOOLEAN NTAPI NtfsChkdsk(IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
#define STATUS_DLL_NOT_FOUND
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define STATUS_BUFFER_TOO_SMALL
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_DISK_CORRUPT_ERROR
PFMIFSCALLBACK ChkdskCallback
void int int ULONGLONG int va_list * ap