mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] improve readability of error code handling
* Also don't pass a read size value in WriteFileWithRetry() if we don't use it.
This commit is contained in:
parent
52ca79816f
commit
8a5a5a318a
25 changed files with 257 additions and 252 deletions
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -1,27 +1,40 @@
|
||||||
*.a
|
*.a
|
||||||
*.aps
|
*.aps
|
||||||
*.appx
|
*.appx
|
||||||
|
*.appxupload
|
||||||
|
*.bak
|
||||||
*.db
|
*.db
|
||||||
*.db-shm
|
*.db-shm
|
||||||
*.db-wal
|
*.db-wal
|
||||||
*.dep
|
*.dep
|
||||||
|
*.diff
|
||||||
|
*.dll
|
||||||
|
*.efi
|
||||||
*.exe
|
*.exe
|
||||||
*.htm
|
*.htm
|
||||||
*.idb
|
*.idb
|
||||||
*.ipch
|
*.ipch
|
||||||
*.la
|
*.la
|
||||||
|
*.lib
|
||||||
*.lo
|
*.lo
|
||||||
|
*.lock
|
||||||
*.log
|
*.log
|
||||||
*.mac
|
*.mac
|
||||||
*.mo
|
*.mo
|
||||||
|
*.mp4
|
||||||
*.ncb
|
*.ncb
|
||||||
|
*.nope
|
||||||
*.o
|
*.o
|
||||||
*.obj
|
*.obj
|
||||||
|
*.old
|
||||||
*.opendb
|
*.opendb
|
||||||
*.opt
|
*.opt
|
||||||
|
*.org
|
||||||
|
*.p7x
|
||||||
*.patch
|
*.patch
|
||||||
*.pc
|
*.pc
|
||||||
*.pdb
|
*.pdb
|
||||||
|
*.pdf
|
||||||
*.plg
|
*.plg
|
||||||
*.res
|
*.res
|
||||||
*.sig
|
*.sig
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright 1992-1994 Remy Card <card@masi.ibp.fr>
|
* Copyright 1992-1994 Remy Card <card@masi.ibp.fr>
|
||||||
* Copyright 1995-1999 Theodore Ts'o
|
* Copyright 1995-1999 Theodore Ts'o
|
||||||
* Copyright 1999 David Beattie
|
* Copyright 1999 David Beattie
|
||||||
* Copyright 2011-2023 Pete Batard <pete@akeo.ie>
|
* Copyright 2011-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This file is based on the minix file system programs fsck and mkfs
|
* This file is based on the minix file system programs fsck and mkfs
|
||||||
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
|
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
|
||||||
|
@ -318,7 +318,7 @@ static void CALLBACK alarm_intr(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dw
|
||||||
{
|
{
|
||||||
if (!num_blocks)
|
if (!num_blocks)
|
||||||
return;
|
return;
|
||||||
if (FormatStatus) {
|
if (ErrorStatus) {
|
||||||
uprintf("%sInterrupting at block %" PRIu64 "\n", bb_prefix,
|
uprintf("%sInterrupting at block %" PRIu64 "\n", bb_prefix,
|
||||||
(unsigned long long) currently_testing);
|
(unsigned long long) currently_testing);
|
||||||
cancel_ops = -1;
|
cancel_ops = -1;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o
|
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o
|
||||||
* Copyright 1999 by David Beattie
|
* Copyright 1999 by David Beattie
|
||||||
* Copyright 2011-2018 by Pete Batard
|
* Copyright 2011-2024 by Pete Batard
|
||||||
*
|
*
|
||||||
* This file is based on the minix file system programs fsck and mkfs
|
* This file is based on the minix file system programs fsck and mkfs
|
||||||
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
|
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
|
||||||
|
@ -28,12 +28,11 @@ typedef struct bb_struct_u64_iterate *bb_badblocks_iterate;
|
||||||
typedef struct bb_struct_u64_list *bb_u64_list;
|
typedef struct bb_struct_u64_list *bb_u64_list;
|
||||||
typedef struct bb_struct_u64_iterate *bb_u64_iterate;
|
typedef struct bb_struct_u64_iterate *bb_u64_iterate;
|
||||||
|
|
||||||
#define BB_ET_NO_MEMORY (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_ENOUGH_MEMORY)
|
#define BB_ET_NO_MEMORY RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY)
|
||||||
#define BB_ET_MAGIC_BADBLOCKS_LIST (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OBJECT_IN_LIST)
|
#define BB_ET_MAGIC_BADBLOCKS_LIST RUFUS_ERROR(ERROR_OBJECT_IN_LIST)
|
||||||
#define BB_ET_MAGIC_BADBLOCKS_ITERATE (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INVALID_BLOCK)
|
#define BB_ET_MAGIC_BADBLOCKS_ITERATE RUFUS_ERROR(ERROR_INVALID_BLOCK)
|
||||||
|
|
||||||
#define BB_CHECK_MAGIC(struct, code) \
|
#define BB_CHECK_MAGIC(struct, code) if ((struct)->magic != (code)) return (code)
|
||||||
if ((struct)->magic != (code)) return (code)
|
|
||||||
#define BB_BAD_BLOCKS_THRESHOLD 256
|
#define BB_BAD_BLOCKS_THRESHOLD 256
|
||||||
#define BB_BLOCKS_AT_ONCE 64
|
#define BB_BLOCKS_AT_ONCE 64
|
||||||
#define BB_SYS_PAGE_SIZE 4096
|
#define BB_SYS_PAGE_SIZE 4096
|
||||||
|
|
10
src/dos.c
10
src/dos.c
|
@ -2,7 +2,7 @@
|
||||||
* Rufus: The Reliable USB Formatting Utility
|
* Rufus: The Reliable USB Formatting Utility
|
||||||
* DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll
|
* DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll
|
||||||
* (MS WinME DOS) or from the embedded FreeDOS resource files
|
* (MS WinME DOS) or from the embedded FreeDOS resource files
|
||||||
* Copyright © 2011-2023 Pete Batard <pete@akeo.ie>
|
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -352,7 +352,7 @@ BOOL ExtractFreeDOS(const char* path)
|
||||||
IDR_FD_EGA17_CPX, IDR_FD_EGA18_CPX };
|
IDR_FD_EGA17_CPX, IDR_FD_EGA18_CPX };
|
||||||
char filename[MAX_PATH], locale_path[MAX_PATH];
|
char filename[MAX_PATH], locale_path[MAX_PATH];
|
||||||
BYTE* res_data;
|
BYTE* res_data;
|
||||||
DWORD res_size, Size;
|
DWORD res_size;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -366,10 +366,10 @@ BOOL ExtractFreeDOS(const char* path)
|
||||||
static_strcat(locale_path, "LOCALE\\");
|
static_strcat(locale_path, "LOCALE\\");
|
||||||
CreateDirectoryA(locale_path, NULL);
|
CreateDirectoryA(locale_path, NULL);
|
||||||
|
|
||||||
for (i=0; i<ARRAYSIZE(res_name); i++) {
|
for (i = 0; i < ARRAYSIZE(res_name); i++) {
|
||||||
res_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(res_id[i]), _RT_RCDATA, res_name[i], &res_size, FALSE);
|
res_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(res_id[i]), _RT_RCDATA, res_name[i], &res_size, FALSE);
|
||||||
|
|
||||||
static_strcpy(filename, ((i<2)?path:locale_path));
|
static_strcpy(filename, ((i<2) ? path : locale_path));
|
||||||
static_strcat(filename, res_name[i]);
|
static_strcat(filename, res_name[i]);
|
||||||
|
|
||||||
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL,
|
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL,
|
||||||
|
@ -379,7 +379,7 @@ BOOL ExtractFreeDOS(const char* path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WriteFileWithRetry(hFile, res_data, res_size, &Size, WRITE_RETRIES)) {
|
if (!WriteFileWithRetry(hFile, res_data, res_size, NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write file '%s': %s.", filename, WindowsErrorString());
|
uprintf("Could not write file '%s': %s.", filename, WindowsErrorString());
|
||||||
safe_closehandle(hFile);
|
safe_closehandle(hFile);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
10
src/drive.c
10
src/drive.c
|
@ -194,14 +194,14 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr
|
||||||
do {
|
do {
|
||||||
if (DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL))
|
if (DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL))
|
||||||
goto out;
|
goto out;
|
||||||
if (IS_ERROR(FormatStatus)) // User cancel
|
if (IS_ERROR(ErrorStatus)) // User cancel
|
||||||
break;
|
break;
|
||||||
Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES);
|
Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES);
|
||||||
} while (GetTickCount64() < EndTime);
|
} while (GetTickCount64() < EndTime);
|
||||||
// If we reached this section, either we didn't manage to get a lock or the user cancelled
|
// If we reached this section, either we didn't manage to get a lock or the user cancelled
|
||||||
uprintf("Could not lock access to %s: %s", Path, WindowsErrorString());
|
uprintf("Could not lock access to %s: %s", Path, WindowsErrorString());
|
||||||
// See if we can report the processes are accessing the drive
|
// See if we can report the processes are accessing the drive
|
||||||
if (!IS_ERROR(FormatStatus) && (access_mask == 0))
|
if (!IS_ERROR(ErrorStatus) && (access_mask == 0))
|
||||||
access_mask = GetProcessSearch(SEARCH_PROCESS_TIMEOUT, 0x07, FALSE);
|
access_mask = GetProcessSearch(SEARCH_PROCESS_TIMEOUT, 0x07, FALSE);
|
||||||
// Try to continue if the only access rights we saw were for read-only
|
// Try to continue if the only access rights we saw were for read-only
|
||||||
if ((access_mask & 0x07) != 0x01)
|
if ((access_mask & 0x07) != 0x01)
|
||||||
|
@ -1006,7 +1006,7 @@ BOOL WaitForLogical(DWORD DriveIndex, uint64_t PartitionOffset)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
free(LogicalPath);
|
free(LogicalPath);
|
||||||
if (IS_ERROR(FormatStatus)) // User cancel
|
if (IS_ERROR(ErrorStatus)) // User cancel
|
||||||
return FALSE;
|
return FALSE;
|
||||||
Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES);
|
Sleep(DRIVE_ACCESS_TIMEOUT / DRIVE_ACCESS_RETRIES);
|
||||||
} while (GetTickCount64() < EndTime);
|
} while (GetTickCount64() < EndTime);
|
||||||
|
@ -2219,7 +2219,7 @@ BOOL RemountVolume(char* drive_name, BOOL bSilent)
|
||||||
} else {
|
} else {
|
||||||
suprintf("Could not remount %s as %c: %s", volume_name, toupper(drive_name[0]), WindowsErrorString());
|
suprintf("Could not remount %s as %c: %s", volume_name, toupper(drive_name[0]), WindowsErrorString());
|
||||||
// This will leave the drive inaccessible and must be flagged as an error
|
// This will leave the drive inaccessible and must be flagged as an error
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_REMOUNT_VOLUME);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_REMOUNT_VOLUME));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2493,7 +2493,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
||||||
uprintf(" Could not access source image");
|
uprintf(" Could not access source image");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(!WriteFileWithRetry(hDrive, buffer, bufsize, &size, WRITE_RETRIES)) {
|
if(!WriteFileWithRetry(hDrive, buffer, bufsize, NULL, WRITE_RETRIES)) {
|
||||||
uprintf(" Write error: %s", WindowsErrorString());
|
uprintf(" Write error: %s", WindowsErrorString());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
#define VDS_RESCAN_REFRESH 0x00000001
|
#define VDS_RESCAN_REFRESH 0x00000001
|
||||||
#define VDS_RESCAN_REENUMERATE 0x00000002
|
#define VDS_RESCAN_REENUMERATE 0x00000002
|
||||||
|
|
||||||
#define VDS_SET_ERROR(hr) do { if (hr != S_OK) { SetLastError((DWORD)hr); FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_GEN_FAILURE; } } while(0)
|
#define VDS_SET_ERROR(hr) do { if (hr != S_OK) { SetLastError((DWORD)hr); ErrorStatus = RUFUS_ERROR(ERROR_GEN_FAILURE); } } while(0)
|
||||||
|
|
||||||
#if !defined(__MINGW32__)
|
#if !defined(__MINGW32__)
|
||||||
typedef enum _FSINFOCLASS {
|
typedef enum _FSINFOCLASS {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
|
||||||
* Copyright (C) 1998 Andrey Shedel <andreys@ns.cr.cyco.com>
|
* Copyright (C) 1998 Andrey Shedel <andreys@ns.cr.cyco.com>
|
||||||
* Copyright (C) 2018-2019 Pete Batard <pete@akeo.ie>
|
* Copyright (C) 2018-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Library
|
* This file may be redistributed under the terms of the GNU Library
|
||||||
|
@ -180,7 +180,7 @@ static __inline unsigned _MapNtStatus(IN NTSTATUS Status)
|
||||||
// Return the last Windows Error
|
// Return the last Windows Error
|
||||||
DWORD ext2_last_winerror(DWORD default_error)
|
DWORD ext2_last_winerror(DWORD default_error)
|
||||||
{
|
{
|
||||||
return ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | (LastWinError ? LastWinError : default_error);
|
return RUFUS_ERROR(LastWinError ? LastWinError : default_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
201
src/format.c
201
src/format.c
|
@ -65,7 +65,7 @@
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS", "ext2", "ext3", "ext4" };
|
const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS", "ext2", "ext3", "ext4" };
|
||||||
DWORD FormatStatus = 0, LastWriteError = 0;
|
DWORD ErrorStatus = 0, LastWriteError = 0;
|
||||||
badblocks_report report = { 0 };
|
badblocks_report report = { 0 };
|
||||||
static float format_percent = 0.0f;
|
static float format_percent = 0.0f;
|
||||||
static int task_number = 0, actual_fs_type;
|
static int task_number = 0, actual_fs_type;
|
||||||
|
@ -114,7 +114,7 @@ out:
|
||||||
static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, DWORD Action, PVOID pData)
|
static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, DWORD Action, PVOID pData)
|
||||||
{
|
{
|
||||||
char percent_str[8];
|
char percent_str[8];
|
||||||
if (IS_ERROR(FormatStatus))
|
if (IS_ERROR(ErrorStatus))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
assert((actual_fs_type >= 0) && (actual_fs_type < FS_MAX));
|
assert((actual_fs_type >= 0) && (actual_fs_type < FS_MAX));
|
||||||
|
@ -141,38 +141,38 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
|
||||||
UpdateProgress(OP_CREATE_FS, 100.0f);
|
UpdateProgress(OP_CREATE_FS, 100.0f);
|
||||||
if(*(BOOLEAN*)pData == FALSE) {
|
if(*(BOOLEAN*)pData == FALSE) {
|
||||||
uprintf("Error while formatting");
|
uprintf("Error while formatting");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_GEN_FAILURE;
|
ErrorStatus = RUFUS_ERROR(ERROR_GEN_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FCC_DONE_WITH_STRUCTURE:
|
case FCC_DONE_WITH_STRUCTURE:
|
||||||
break;
|
break;
|
||||||
case FCC_INCOMPATIBLE_FILE_SYSTEM:
|
case FCC_INCOMPATIBLE_FILE_SYSTEM:
|
||||||
uprintf("Incompatible File System");
|
uprintf("Incompatible File System");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_INCOMPATIBLE_FS);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_INCOMPATIBLE_FS));
|
||||||
break;
|
break;
|
||||||
case FCC_ACCESS_DENIED:
|
case FCC_ACCESS_DENIED:
|
||||||
uprintf("Access denied");
|
uprintf("Access denied");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_ACCESS_DENIED;
|
ErrorStatus = RUFUS_ERROR(ERROR_ACCESS_DENIED);
|
||||||
break;
|
break;
|
||||||
case FCC_MEDIA_WRITE_PROTECTED:
|
case FCC_MEDIA_WRITE_PROTECTED:
|
||||||
uprintf("Media is write protected");
|
uprintf("Media is write protected");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_PROTECT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_PROTECT);
|
||||||
break;
|
break;
|
||||||
case FCC_VOLUME_IN_USE:
|
case FCC_VOLUME_IN_USE:
|
||||||
uprintf("Volume is in use");
|
uprintf("Volume is in use");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_DEVICE_IN_USE;
|
ErrorStatus = RUFUS_ERROR(ERROR_DEVICE_IN_USE);
|
||||||
break;
|
break;
|
||||||
case FCC_DEVICE_NOT_READY:
|
case FCC_DEVICE_NOT_READY:
|
||||||
uprintf("The device is not ready");
|
uprintf("The device is not ready");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_READY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_READY);
|
||||||
break;
|
break;
|
||||||
case FCC_CANT_QUICK_FORMAT:
|
case FCC_CANT_QUICK_FORMAT:
|
||||||
uprintf("Cannot quick format this volume");
|
uprintf("Cannot quick format this volume");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_QUICK_FORMAT);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_QUICK_FORMAT));
|
||||||
break;
|
break;
|
||||||
case FCC_BAD_LABEL:
|
case FCC_BAD_LABEL:
|
||||||
uprintf("Bad label");
|
uprintf("Bad label");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_LABEL_TOO_LONG;
|
ErrorStatus = RUFUS_ERROR(ERROR_LABEL_TOO_LONG);
|
||||||
break;
|
break;
|
||||||
case FCC_OUTPUT:
|
case FCC_OUTPUT:
|
||||||
OutputUTF8Message(((PTEXTOUTPUT)pData)->Output);
|
OutputUTF8Message(((PTEXTOUTPUT)pData)->Output);
|
||||||
|
@ -180,27 +180,27 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
|
||||||
case FCC_CLUSTER_SIZE_TOO_BIG:
|
case FCC_CLUSTER_SIZE_TOO_BIG:
|
||||||
case FCC_CLUSTER_SIZE_TOO_SMALL:
|
case FCC_CLUSTER_SIZE_TOO_SMALL:
|
||||||
uprintf("Unsupported cluster size");
|
uprintf("Unsupported cluster size");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_INVALID_CLUSTER_SIZE);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_INVALID_CLUSTER_SIZE));
|
||||||
break;
|
break;
|
||||||
case FCC_VOLUME_TOO_BIG:
|
case FCC_VOLUME_TOO_BIG:
|
||||||
case FCC_VOLUME_TOO_SMALL:
|
case FCC_VOLUME_TOO_SMALL:
|
||||||
uprintf("Volume is too %s", (Command == FCC_VOLUME_TOO_BIG)?"big":"small");
|
uprintf("Volume is too %s", (Command == FCC_VOLUME_TOO_BIG) ? "big" : "small");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_INVALID_VOLUME_SIZE);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_INVALID_VOLUME_SIZE));
|
||||||
break;
|
break;
|
||||||
case FCC_NO_MEDIA_IN_DRIVE:
|
case FCC_NO_MEDIA_IN_DRIVE:
|
||||||
uprintf("No media in drive");
|
uprintf("No media in drive");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NO_MEDIA_IN_DRIVE;
|
ErrorStatus = RUFUS_ERROR(ERROR_NO_MEDIA_IN_DRIVE);
|
||||||
break;
|
break;
|
||||||
case FCC_ALIGNMENT_VIOLATION:
|
case FCC_ALIGNMENT_VIOLATION:
|
||||||
uprintf("Partition start offset is not aligned to the cluster size");
|
uprintf("Partition start offset is not aligned to the cluster size");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OFFSET_ALIGNMENT_VIOLATION;
|
ErrorStatus = RUFUS_ERROR(ERROR_OFFSET_ALIGNMENT_VIOLATION);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
uprintf("FormatExCallback: Received unhandled command 0x%02X - aborting", Command);
|
uprintf("FormatExCallback: Received unhandled command 0x%02X - aborting", Command);
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_SUPPORTED;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_SUPPORTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (!IS_ERROR(FormatStatus));
|
return (!IS_ERROR(ErrorStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -209,7 +209,7 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
|
||||||
static BOOLEAN __stdcall ChkdskCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, DWORD Action, PVOID pData)
|
static BOOLEAN __stdcall ChkdskCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, DWORD Action, PVOID pData)
|
||||||
{
|
{
|
||||||
DWORD* percent;
|
DWORD* percent;
|
||||||
if (IS_ERROR(FormatStatus))
|
if (IS_ERROR(ErrorStatus))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
switch (Command) {
|
switch (Command) {
|
||||||
|
@ -359,7 +359,7 @@ static BOOL FormatNativeVds(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Cl
|
||||||
wVolumeName = utf8_to_wchar(VolumeName);
|
wVolumeName = utf8_to_wchar(VolumeName);
|
||||||
if (wVolumeName == NULL) {
|
if (wVolumeName == NULL) {
|
||||||
uprintf("Could not read volume name");
|
uprintf("Could not read volume name");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_GEN_FAILURE;
|
ErrorStatus = RUFUS_ERROR(ERROR_GEN_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ static BOOL FormatNativeVds(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Cl
|
||||||
|
|
||||||
hr = IVdsVolumeMF3_FormatEx2(pVolumeMF3, wFSName, usFsVersion, ClusterSize, wLabel, Flags, &pAsync);
|
hr = IVdsVolumeMF3_FormatEx2(pVolumeMF3, wFSName, usFsVersion, ClusterSize, wLabel, Flags, &pAsync);
|
||||||
while (SUCCEEDED(hr)) {
|
while (SUCCEEDED(hr)) {
|
||||||
if (IS_ERROR(FormatStatus)) {
|
if (IS_ERROR(ErrorStatus)) {
|
||||||
IVdsAsync_Cancel(pAsync);
|
IVdsAsync_Cancel(pAsync);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ static BOOL FormatNativeVds(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Cl
|
||||||
IVdsAsync_Release(pAsync);
|
IVdsAsync_Release(pAsync);
|
||||||
IVdsVolumeMF3_Release(pVolumeMF3);
|
IVdsVolumeMF3_Release(pVolumeMF3);
|
||||||
|
|
||||||
if (!IS_ERROR(FormatStatus)) {
|
if (!IS_ERROR(ErrorStatus)) {
|
||||||
uprintf("Format completed.");
|
uprintf("Format completed.");
|
||||||
r = TRUE;
|
r = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -570,8 +570,8 @@ static BOOL FormatNativeVds(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Cl
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if ((!bFoundVolume) && (FormatStatus == 0))
|
if ((!bFoundVolume) && (ErrorStatus == 0))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_PATH_NOT_FOUND;
|
ErrorStatus = RUFUS_ERROR(ERROR_PATH_NOT_FOUND);
|
||||||
safe_free(VolumeName);
|
safe_free(VolumeName);
|
||||||
safe_free(wVolumeName);
|
safe_free(wVolumeName);
|
||||||
safe_free(wLabel);
|
safe_free(wLabel);
|
||||||
|
@ -603,7 +603,7 @@ static BOOL FormatNative(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Clust
|
||||||
wVolumeName = utf8_to_wchar(VolumeName);
|
wVolumeName = utf8_to_wchar(VolumeName);
|
||||||
if (wVolumeName == NULL) {
|
if (wVolumeName == NULL) {
|
||||||
uprintf("Could not read volume name (%s)", VolumeName);
|
uprintf("Could not read volume name (%s)", VolumeName);
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_GEN_FAILURE;
|
ErrorStatus = RUFUS_ERROR(ERROR_GEN_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
// Hey, nice consistency here, Microsoft! - FormatEx() fails if wVolumeName has
|
// Hey, nice consistency here, Microsoft! - FormatEx() fails if wVolumeName has
|
||||||
|
@ -632,12 +632,12 @@ static BOOL FormatNative(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Clust
|
||||||
for (i = 0; i < WRITE_RETRIES; i++) {
|
for (i = 0; i < WRITE_RETRIES; i++) {
|
||||||
pfFormatEx(wVolumeName, SelectedDrive.MediaType, wFSName, wLabel,
|
pfFormatEx(wVolumeName, SelectedDrive.MediaType, wFSName, wLabel,
|
||||||
(Flags & FP_QUICK), ClusterSize, FormatExCallback);
|
(Flags & FP_QUICK), ClusterSize, FormatExCallback);
|
||||||
if (!IS_ERROR(FormatStatus) || (HRESULT_CODE(FormatStatus) == ERROR_CANCELLED))
|
if (!IS_ERROR(ErrorStatus) || (HRESULT_CODE(ErrorStatus) == ERROR_CANCELLED))
|
||||||
break;
|
break;
|
||||||
uprintf("%s - Retrying...", WindowsErrorString());
|
uprintf("%s - Retrying...", WindowsErrorString());
|
||||||
Sleep(WRITE_TIMEOUT);
|
Sleep(WRITE_TIMEOUT);
|
||||||
}
|
}
|
||||||
if (IS_ERROR(FormatStatus))
|
if (IS_ERROR(ErrorStatus))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (Flags & FP_COMPRESSION) {
|
if (Flags & FP_COMPRESSION) {
|
||||||
|
@ -649,14 +649,14 @@ static BOOL FormatNative(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Clust
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_ERROR(FormatStatus)) {
|
if (!IS_ERROR(ErrorStatus)) {
|
||||||
uprintf("Format completed.");
|
uprintf("Format completed.");
|
||||||
r = TRUE;
|
r = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!r && !IS_ERROR(FormatStatus))
|
if (!r && !IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|SCODE_CODE(GetLastError());
|
ErrorStatus = RUFUS_ERROR(SCODE_CODE(GetLastError()));
|
||||||
safe_free(VolumeName);
|
safe_free(VolumeName);
|
||||||
safe_free(wVolumeName);
|
safe_free(wVolumeName);
|
||||||
safe_free(wLabel);
|
safe_free(wLabel);
|
||||||
|
@ -668,7 +668,7 @@ BOOL FormatPartition(DWORD DriveIndex, uint64_t PartitionOffset, DWORD UnitAlloc
|
||||||
{
|
{
|
||||||
if ((DriveIndex < 0x80) || (DriveIndex > 0x100) || (FSType >= FS_MAX) ||
|
if ((DriveIndex < 0x80) || (DriveIndex > 0x100) || (FSType >= FS_MAX) ||
|
||||||
((UnitAllocationSize != 0) && (!IS_POWER_OF_2(UnitAllocationSize)))) {
|
((UnitAllocationSize != 0) && (!IS_POWER_OF_2(UnitAllocationSize)))) {
|
||||||
ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_INVALID_PARAMETER;
|
ErrorStatus = RUFUS_ERROR(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
actual_fs_type = FSType;
|
actual_fs_type = FSType;
|
||||||
|
@ -708,7 +708,7 @@ static BOOL CheckDisk(char DriveLetter)
|
||||||
}
|
}
|
||||||
|
|
||||||
pfChkdsk(wDriveRoot, wFSType, FALSE, FALSE, FALSE, FALSE, NULL, NULL, ChkdskCallback);
|
pfChkdsk(wDriveRoot, wFSType, FALSE, FALSE, FALSE, FALSE, NULL, NULL, ChkdskCallback);
|
||||||
if (!IS_ERROR(FormatStatus)) {
|
if (!IS_ERROR(ErrorStatus)) {
|
||||||
uprintf("NTFS Fixup completed.");
|
uprintf("NTFS Fixup completed.");
|
||||||
r = TRUE;
|
r = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -742,7 +742,7 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi
|
||||||
uprintf("Erasing %llu sectors", num_sectors_to_clear);
|
uprintf("Erasing %llu sectors", num_sectors_to_clear);
|
||||||
pZeroBuf = calloc(SectorSize, (size_t)num_sectors_to_clear);
|
pZeroBuf = calloc(SectorSize, (size_t)num_sectors_to_clear);
|
||||||
if (pZeroBuf == NULL) {
|
if (pZeroBuf == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
liFilePointer.QuadPart = 0ULL;
|
liFilePointer.QuadPart = 0ULL;
|
||||||
|
@ -794,13 +794,13 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
|
||||||
buffer = (unsigned char*)_mm_malloc(SelectedDrive.SectorSize, 16);
|
buffer = (unsigned char*)_mm_malloc(SelectedDrive.SectorSize, 16);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
uprintf("Could not allocate memory for MBR");
|
uprintf("Could not allocate memory for MBR");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read_sectors(hPhysicalDrive, SelectedDrive.SectorSize, 0, 1, buffer)) {
|
if (!read_sectors(hPhysicalDrive, SelectedDrive.SectorSize, 0, 1, buffer)) {
|
||||||
uprintf("Could not read MBR");
|
uprintf("Could not read MBR");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,14 +824,13 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
|
||||||
}
|
}
|
||||||
if ((boot_type != BT_NON_BOOTABLE) && (target_type == TT_BIOS)) {
|
if ((boot_type != BT_NON_BOOTABLE) && (target_type == TT_BIOS)) {
|
||||||
// Set first partition bootable - masquerade as per the DiskID selected
|
// Set first partition bootable - masquerade as per the DiskID selected
|
||||||
buffer[0x1be] = IsChecked(IDC_RUFUS_MBR) ?
|
buffer[0x1be] = IsChecked(IDC_RUFUS_MBR) ? (BYTE)ComboBox_GetCurItemData(hDiskID) : 0x80;
|
||||||
(BYTE)ComboBox_GetCurItemData(hDiskID):0x80;
|
|
||||||
uprintf("Set bootable USB partition as 0x%02X", buffer[0x1be]);
|
uprintf("Set bootable USB partition as 0x%02X", buffer[0x1be]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!write_sectors(hPhysicalDrive, SelectedDrive.SectorSize, 0, 1, buffer)) {
|
if (!write_sectors(hPhysicalDrive, SelectedDrive.SectorSize, 0, 1, buffer)) {
|
||||||
uprintf("Could not write MBR");
|
uprintf("Could not write MBR");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,7 +1079,7 @@ BOOL WritePBR(HANDLE hLogicalVolume)
|
||||||
uprintf("Unsupported FS for FS BR processing - aborting");
|
uprintf("Unsupported FS for FS BR processing - aborting");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,7 +1176,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
buf_size = ((DD_BUFFER_SIZE + SelectedDrive.SectorSize - 1) / SelectedDrive.SectorSize) * SelectedDrive.SectorSize;
|
buf_size = ((DD_BUFFER_SIZE + SelectedDrive.SectorSize - 1) / SelectedDrive.SectorSize) * SelectedDrive.SectorSize;
|
||||||
buffer = (uint8_t*)_mm_malloc(buf_size, SelectedDrive.SectorSize);
|
buffer = (uint8_t*)_mm_malloc(buf_size, SelectedDrive.SectorSize);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
uprintf("Could not allocate disk zeroing buffer");
|
uprintf("Could not allocate disk zeroing buffer");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1189,7 +1188,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
if (fast_zeroing) {
|
if (fast_zeroing) {
|
||||||
cmp_buffer = (uint32_t*)_mm_malloc(buf_size, SelectedDrive.SectorSize);
|
cmp_buffer = (uint32_t*)_mm_malloc(buf_size, SelectedDrive.SectorSize);
|
||||||
if (cmp_buffer == NULL) {
|
if (cmp_buffer == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
uprintf("Could not allocate disk comparison buffer");
|
uprintf("Could not allocate disk comparison buffer");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1267,7 +1266,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
|
@ -1282,18 +1281,18 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
if (hSourceImage == INVALID_HANDLE_VALUE) {
|
if (hSourceImage == INVALID_HANDLE_VALUE) {
|
||||||
uprintf("Could not open image '%s': %s", image_path, WindowsErrorString());
|
uprintf("Could not open image '%s': %s", image_path, WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
sec_buf = (uint8_t*)_mm_malloc(SelectedDrive.SectorSize, SelectedDrive.SectorSize);
|
sec_buf = (uint8_t*)_mm_malloc(SelectedDrive.SectorSize, SelectedDrive.SectorSize);
|
||||||
if (sec_buf == NULL) {
|
if (sec_buf == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
uprintf("Could not allocate disk write buffer");
|
uprintf("Could not allocate disk write buffer");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
assert((uintptr_t)sec_buf % SelectedDrive.SectorSize == 0);
|
assert((uintptr_t)sec_buf % SelectedDrive.SectorSize == 0);
|
||||||
sec_buf_pos = 0;
|
sec_buf_pos = 0;
|
||||||
bled_init(256 * KB, uprintf, NULL, sector_write, update_progress, NULL, &FormatStatus);
|
bled_init(256 * KB, uprintf, NULL, sector_write, update_progress, NULL, &ErrorStatus);
|
||||||
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
|
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
uprintfs("\r\n");
|
uprintfs("\r\n");
|
||||||
|
@ -1306,10 +1305,10 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
WriteFile(hPhysicalDrive, sec_buf, SelectedDrive.SectorSize, &write_size, NULL);
|
WriteFile(hPhysicalDrive, sec_buf, SelectedDrive.SectorSize, &write_size, NULL);
|
||||||
}
|
}
|
||||||
safe_mm_free(sec_buf);
|
safe_mm_free(sec_buf);
|
||||||
if ((bled_ret < 0) && (SCODE_CODE(FormatStatus) != ERROR_CANCELLED)) {
|
if ((bled_ret < 0) && (SCODE_CODE(ErrorStatus) != ERROR_CANCELLED)) {
|
||||||
// Unfortunately, different compression backends return different negative error codes
|
// Unfortunately, different compression backends return different negative error codes
|
||||||
uprintf("Could not write compressed image: %lld", bled_ret);
|
uprintf("Could not write compressed image: %lld", bled_ret);
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1327,7 +1326,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN);
|
FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN);
|
||||||
if (hSourceImage == NULL) {
|
if (hSourceImage == NULL) {
|
||||||
uprintf("Could not open image '%s': %s", image_path, WindowsErrorString());
|
uprintf("Could not open image '%s': %s", image_path, WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,7 +1334,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
buf_size = ((DD_BUFFER_SIZE + SelectedDrive.SectorSize - 1) / SelectedDrive.SectorSize) * SelectedDrive.SectorSize;
|
buf_size = ((DD_BUFFER_SIZE + SelectedDrive.SectorSize - 1) / SelectedDrive.SectorSize) * SelectedDrive.SectorSize;
|
||||||
buffer = (uint8_t*)_mm_malloc(buf_size * NUM_BUFFERS, SelectedDrive.SectorSize);
|
buffer = (uint8_t*)_mm_malloc(buf_size * NUM_BUFFERS, SelectedDrive.SectorSize);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
uprintf("Could not allocate disk write buffer");
|
uprintf("Could not allocate disk write buffer");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1359,7 +1358,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
if ((!WaitFileAsync(hSourceImage, DRIVE_ACCESS_TIMEOUT)) ||
|
if ((!WaitFileAsync(hSourceImage, DRIVE_ACCESS_TIMEOUT)) ||
|
||||||
(!GetSizeAsync(hSourceImage, &read_size[read_bufnum]))) {
|
(!GetSizeAsync(hSourceImage, &read_size[read_bufnum]))) {
|
||||||
uprintf("\r\nRead error: %s", WindowsErrorString());
|
uprintf("\r\nRead error: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1398,7 +1397,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
|
@ -1496,14 +1495,14 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
PrintInfoDebug(0, MSG_225);
|
PrintInfoDebug(0, MSG_225);
|
||||||
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, FALSE, !actual_lock_drive);
|
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, FALSE, !actual_lock_drive);
|
||||||
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this stage we have both a handle and a lock to the physical drive
|
// At this stage we have both a handle and a lock to the physical drive
|
||||||
if (!GetDriveLetters(DriveIndex, drive_letters)) {
|
if (!GetDriveLetters(DriveIndex, drive_letters)) {
|
||||||
uprintf("Failed to get a drive letter");
|
uprintf("Failed to get a drive letter");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_ASSIGN_LETTER);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_ASSIGN_LETTER));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1511,7 +1510,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
drive_name[0] = RemoveDriveLetters(DriveIndex, TRUE, FALSE);
|
drive_name[0] = RemoveDriveLetters(DriveIndex, TRUE, FALSE);
|
||||||
if (drive_name[0] == 0) {
|
if (drive_name[0] == 0) {
|
||||||
uprintf("Unable to find a drive letter to use");
|
uprintf("Unable to find a drive letter to use");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_ASSIGN_LETTER);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_ASSIGN_LETTER));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
uprintf("Will use '%c:' as volume mountpoint", toupper(drive_name[0]));
|
uprintf("Will use '%c:' as volume mountpoint", toupper(drive_name[0]));
|
||||||
|
@ -1522,8 +1521,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
PrintInfo(0, MSG_239, lmprintf(MSG_307));
|
PrintInfo(0, MSG_239, lmprintf(MSG_307));
|
||||||
if (!is_vds_available || !DeletePartition(DriveIndex, 0, TRUE)) {
|
if (!is_vds_available || !DeletePartition(DriveIndex, 0, TRUE)) {
|
||||||
uprintf("Warning: Could not delete partition(s): %s", is_vds_available ? WindowsErrorString() : "VDS is not available");
|
uprintf("Warning: Could not delete partition(s): %s", is_vds_available ? WindowsErrorString() : "VDS is not available");
|
||||||
SetLastError(FormatStatus);
|
SetLastError(ErrorStatus);
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
// If we couldn't delete partitions, Windows give us trouble unless we
|
// If we couldn't delete partitions, Windows give us trouble unless we
|
||||||
// request access to the logical drive. Don't ask me why!
|
// request access to the logical drive. Don't ask me why!
|
||||||
need_logical = TRUE;
|
need_logical = TRUE;
|
||||||
|
@ -1537,7 +1536,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// Now get RW access to the physical drive
|
// Now get RW access to the physical drive
|
||||||
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
||||||
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
RefreshDriveLayout(hPhysicalDrive);
|
RefreshDriveLayout(hPhysicalDrive);
|
||||||
|
@ -1550,7 +1549,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
hLogicalVolume = GetLogicalHandle(DriveIndex, 0, TRUE, FALSE, !actual_lock_drive);
|
hLogicalVolume = GetLogicalHandle(DriveIndex, 0, TRUE, FALSE, !actual_lock_drive);
|
||||||
if (hLogicalVolume == INVALID_HANDLE_VALUE) {
|
if (hLogicalVolume == INVALID_HANDLE_VALUE) {
|
||||||
uprintf("Could not access logical volume");
|
uprintf("Could not access logical volume");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
// If the call succeeds (and we don't get a NULL logical handle as returned for
|
// If the call succeeds (and we don't get a NULL logical handle as returned for
|
||||||
// unpartitioned drives), try to unmount the volume.
|
// unpartitioned drives), try to unmount the volume.
|
||||||
|
@ -1579,7 +1578,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) ||
|
if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) ||
|
||||||
(!InitializeDisk(hPhysicalDrive))) {
|
(!InitializeDisk(hPhysicalDrive))) {
|
||||||
uprintf("Could not reset partitions");
|
uprintf("Could not reset partitions");
|
||||||
FormatStatus = (LastWriteError != 0) ? LastWriteError : (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE);
|
ErrorStatus = (LastWriteError != 0) ? LastWriteError : RUFUS_ERROR(ERROR_PARTITION_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1594,7 +1593,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
static_strcpy(logfile, userdir);
|
static_strcpy(logfile, userdir);
|
||||||
safe_free(userdir);
|
safe_free(userdir);
|
||||||
GetLocalTime(<);
|
GetLocalTime(<);
|
||||||
safe_sprintf(&logfile[strlen(logfile)], sizeof(logfile)-strlen(logfile)-1,
|
safe_sprintf(&logfile[strlen(logfile)], sizeof(logfile) - strlen(logfile) - 1,
|
||||||
"\\rufus_%04d%02d%02d_%02d%02d%02d.log",
|
"\\rufus_%04d%02d%02d_%02d%02d%02d.log",
|
||||||
lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond);
|
lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond);
|
||||||
log_fd = fopenU(logfile, "w+");
|
log_fd = fopenU(logfile, "w+");
|
||||||
|
@ -1609,8 +1608,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
|
|
||||||
if (!BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, (sel >= 2) ? 4 : sel +1, sel, &report, log_fd)) {
|
if (!BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, (sel >= 2) ? 4 : sel +1, sel, &report, log_fd)) {
|
||||||
uprintf("Bad blocks: Check failed.");
|
uprintf("Bad blocks: Check failed.");
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_BADBLOCKS_FAILURE);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_BADBLOCKS_FAILURE));
|
||||||
ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, FALSE);
|
ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, FALSE);
|
||||||
fclose(log_fd);
|
fclose(log_fd);
|
||||||
DeleteFileU(logfile);
|
DeleteFileU(logfile);
|
||||||
|
@ -1629,7 +1628,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond);
|
lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond);
|
||||||
fclose(log_fd);
|
fclose(log_fd);
|
||||||
r = MessageBoxExU(hMainDialog, lmprintf(MSG_012, bb_msg, logfile),
|
r = MessageBoxExU(hMainDialog, lmprintf(MSG_012, bb_msg, logfile),
|
||||||
lmprintf(MSG_010), MB_ABORTRETRYIGNORE|MB_ICONWARNING|MB_IS_RTL, selected_langid);
|
lmprintf(MSG_010), MB_ABORTRETRYIGNORE | MB_ICONWARNING | MB_IS_RTL, selected_langid);
|
||||||
} else {
|
} else {
|
||||||
// We didn't get any errors => delete the log file
|
// We didn't get any errors => delete the log file
|
||||||
fclose(log_fd);
|
fclose(log_fd);
|
||||||
|
@ -1637,7 +1636,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
}
|
}
|
||||||
} while (r == IDRETRY);
|
} while (r == IDRETRY);
|
||||||
if (r == IDABORT) {
|
if (r == IDABORT) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;
|
ErrorStatus = RUFUS_ERROR(ERROR_CANCELLED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1645,8 +1644,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// before repartitioning. Else, all kind of bad things happen.
|
// before repartitioning. Else, all kind of bad things happen.
|
||||||
if (!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) {
|
if (!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) {
|
||||||
uprintf("unable to zero MBR/GPT");
|
uprintf("unable to zero MBR/GPT");
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1664,10 +1663,10 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
safe_free(physical);
|
safe_free(physical);
|
||||||
uprintf("Running command: '%s", cmd);
|
uprintf("Running command: '%s", cmd);
|
||||||
cr = RunCommandWithProgress(cmd, sysnative_dir, TRUE, MSG_261);
|
cr = RunCommandWithProgress(cmd, sysnative_dir, TRUE, MSG_261);
|
||||||
if (cr != 0 && !IS_ERROR(FormatStatus)) {
|
if (cr != 0 && !IS_ERROR(ErrorStatus)) {
|
||||||
SetLastError(cr);
|
SetLastError(cr);
|
||||||
uprintf("Failed to apply FFU image: %s", WindowsErrorString());
|
uprintf("Failed to apply FFU image: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_WINDOWS) | SCODE_CODE(cr);
|
ErrorStatus = RUFUS_ERROR(SCODE_CODE(cr));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WriteDrive(hPhysicalDrive, FALSE);
|
WriteDrive(hPhysicalDrive, FALSE);
|
||||||
|
@ -1680,7 +1679,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
|
|
||||||
if (!CreatePartition(hPhysicalDrive, partition_type, fs_type, (partition_type == PARTITION_STYLE_MBR)
|
if (!CreatePartition(hPhysicalDrive, partition_type, fs_type, (partition_type == PARTITION_STYLE_MBR)
|
||||||
&& (target_type == TT_UEFI), extra_partitions)) {
|
&& (target_type == TT_UEFI), extra_partitions)) {
|
||||||
FormatStatus = (LastWriteError != 0) ? LastWriteError : (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE);
|
ErrorStatus = (LastWriteError != 0) ? LastWriteError : RUFUS_ERROR(ERROR_PARTITION_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
UpdateProgress(OP_PARTITION, -1.0f);
|
UpdateProgress(OP_PARTITION, -1.0f);
|
||||||
|
@ -1691,7 +1690,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
if (!CloseHandle(hLogicalVolume)) {
|
if (!CloseHandle(hLogicalVolume)) {
|
||||||
hLogicalVolume = INVALID_HANDLE_VALUE;
|
hLogicalVolume = INVALID_HANDLE_VALUE;
|
||||||
uprintf("Could not close volume: %s", WindowsErrorString());
|
uprintf("Could not close volume: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_ACCESS_DENIED;
|
ErrorStatus = RUFUS_ERROR(ERROR_ACCESS_DENIED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1724,14 +1723,14 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// Can't format ESPs or ext2/ext3 partitions unless we mount them ourselves
|
// Can't format ESPs or ext2/ext3 partitions unless we mount them ourselves
|
||||||
volume_name = AltMountVolume(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, FALSE);
|
volume_name = AltMountVolume(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, FALSE);
|
||||||
if (volume_name == NULL) {
|
if (volume_name == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_ASSIGN_LETTER);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_ASSIGN_LETTER));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!WaitForLogical(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset)) {
|
if (!WaitForLogical(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset)) {
|
||||||
uprintf("Logical drive was not found - aborting");
|
uprintf("Logical drive was not found - aborting");
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_TIMEOUT;
|
ErrorStatus = RUFUS_ERROR(ERROR_TIMEOUT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1748,8 +1747,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
img_report.uses_casper ? "casper-rw" : "persistence",
|
img_report.uses_casper ? "casper-rw" : "persistence",
|
||||||
(img_report.uses_casper ? 0 : FP_CREATE_PERSISTENCE_CONF) |
|
(img_report.uses_casper ? 0 : FP_CREATE_PERSISTENCE_CONF) |
|
||||||
(IsChecked(IDC_QUICK_FORMAT) ? FP_QUICK : 0))) {
|
(IsChecked(IDC_QUICK_FORMAT) ? FP_QUICK : 0))) {
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1771,8 +1770,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
|
|
||||||
ret = FormatPartition(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, ClusterSize, fs_type, label, Flags);
|
ret = FormatPartition(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, ClusterSize, fs_type, label, Flags);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
// Error will be set by FormatPartition() in FormatStatus
|
// Error will be set by FormatPartition() in ErrorStatus
|
||||||
uprintf("Format error: %s", StrError(FormatStatus, TRUE));
|
uprintf("Format error: %s", StrError(ErrorStatus, TRUE));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1780,7 +1779,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// Get RW access back to the physical drive...
|
// Get RW access back to the physical drive...
|
||||||
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
||||||
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1789,8 +1788,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
if ((partition_type == PARTITION_STYLE_MBR) || ((boot_type != BT_NON_BOOTABLE) && (partition_type == PARTITION_STYLE_GPT))) {
|
if ((partition_type == PARTITION_STYLE_MBR) || ((boot_type != BT_NON_BOOTABLE) && (partition_type == PARTITION_STYLE_GPT))) {
|
||||||
PrintInfoDebug(0, MSG_228); // "Writing master boot record..."
|
PrintInfoDebug(0, MSG_228); // "Writing master boot record..."
|
||||||
if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) {
|
if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) {
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
UpdateProgress(OP_FIX_MBR, -1.0f);
|
UpdateProgress(OP_FIX_MBR, -1.0f);
|
||||||
|
@ -1805,7 +1804,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
volume_name = GetLogicalName(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, TRUE, TRUE);
|
volume_name = GetLogicalName(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, TRUE, TRUE);
|
||||||
if (volume_name == NULL) {
|
if (volume_name == NULL) {
|
||||||
uprintf("Could not get volume name");
|
uprintf("Could not get volume name");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NO_VOLUME_ID;
|
ErrorStatus = RUFUS_ERROR(ERROR_NO_VOLUME_ID);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
uprintf("Found volume %s", volume_name);
|
uprintf("Found volume %s", volume_name);
|
||||||
|
@ -1816,7 +1815,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
RemoveDriveLetters(DriveIndex, FALSE, TRUE);
|
RemoveDriveLetters(DriveIndex, FALSE, TRUE);
|
||||||
if (!MountVolume(drive_name, volume_name)) {
|
if (!MountVolume(drive_name, volume_name)) {
|
||||||
uprintf("Could not remount %s as %c: %s", volume_name, toupper(drive_name[0]), WindowsErrorString());
|
uprintf("Could not remount %s as %c: %s", volume_name, toupper(drive_name[0]), WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_MOUNT_VOLUME);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_MOUNT_VOLUME));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
|
@ -1847,14 +1846,14 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// For once, no need to do anything - just check our sanity
|
// For once, no need to do anything - just check our sanity
|
||||||
assert((boot_type == BT_IMAGE) && IS_EFI_BOOTABLE(img_report) && (fs_type <= FS_NTFS));
|
assert((boot_type == BT_IMAGE) && IS_EFI_BOOTABLE(img_report) && (fs_type <= FS_NTFS));
|
||||||
if ( (boot_type != BT_IMAGE) || !IS_EFI_BOOTABLE(img_report) || (fs_type > FS_NTFS) ) {
|
if ( (boot_type != BT_IMAGE) || !IS_EFI_BOOTABLE(img_report) || (fs_type > FS_NTFS) ) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
|
ErrorStatus = RUFUS_ERROR(ERROR_INSTALL_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else if ( (boot_type == BT_SYSLINUX_V4) || (boot_type == BT_SYSLINUX_V6) ||
|
} else if ( (boot_type == BT_SYSLINUX_V4) || (boot_type == BT_SYSLINUX_V6) ||
|
||||||
((boot_type == BT_IMAGE) && (HAS_SYSLINUX(img_report) || HAS_REACTOS(img_report)) &&
|
((boot_type == BT_IMAGE) && (HAS_SYSLINUX(img_report) || HAS_REACTOS(img_report)) &&
|
||||||
(!HAS_WINDOWS(img_report) || !allow_dual_uefi_bios)) ) {
|
(!HAS_WINDOWS(img_report) || !allow_dual_uefi_bios)) ) {
|
||||||
if (!InstallSyslinux(DriveIndex, drive_name[0], fs_type)) {
|
if (!InstallSyslinux(DriveIndex, drive_name[0], fs_type)) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
|
ErrorStatus = RUFUS_ERROR(ERROR_INSTALL_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1863,15 +1862,15 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
hLogicalVolume = GetLogicalHandle(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, FALSE, TRUE, FALSE);
|
hLogicalVolume = GetLogicalHandle(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, FALSE, TRUE, FALSE);
|
||||||
if ((hLogicalVolume == INVALID_HANDLE_VALUE) || (hLogicalVolume == NULL)) {
|
if ((hLogicalVolume == INVALID_HANDLE_VALUE) || (hLogicalVolume == NULL)) {
|
||||||
uprintf("Could not re-mount volume for partition boot record access");
|
uprintf("Could not re-mount volume for partition boot record access");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
// NB: if you unmount the logical volume here, XP will report error:
|
// NB: if you unmount the logical volume here, XP will report error:
|
||||||
// [0x00000456] The media in the drive may have changed
|
// [0x00000456] The media in the drive may have changed
|
||||||
PrintInfoDebug(0, MSG_229);
|
PrintInfoDebug(0, MSG_229);
|
||||||
if (!WritePBR(hLogicalVolume)) {
|
if (!WritePBR(hLogicalVolume)) {
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
// We must close and unlock the volume to write files to it
|
// We must close and unlock the volume to write files to it
|
||||||
|
@ -1895,8 +1894,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
UpdateProgress(OP_FILE_COPY, -1.0f);
|
UpdateProgress(OP_FILE_COPY, -1.0f);
|
||||||
PrintInfoDebug(0, MSG_230);
|
PrintInfoDebug(0, MSG_230);
|
||||||
if (!ExtractDOS(drive_name)) {
|
if (!ExtractDOS(drive_name)) {
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY;
|
ErrorStatus = RUFUS_ERROR(ERROR_CANNOT_COPY);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else if (boot_type == BT_GRUB4DOS) {
|
} else if (boot_type == BT_GRUB4DOS) {
|
||||||
|
@ -1912,26 +1911,26 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
if (windows_to_go) {
|
if (windows_to_go) {
|
||||||
PrintInfoDebug(0, MSG_268);
|
PrintInfoDebug(0, MSG_268);
|
||||||
if (!SetupWinToGo(DriveIndex, drive_name, (extra_partitions & XP_ESP))) {
|
if (!SetupWinToGo(DriveIndex, drive_name, (extra_partitions & XP_ESP))) {
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_ISO_EXTRACT);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_ISO_EXTRACT));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (unattend_xml_path != NULL) {
|
if (unattend_xml_path != NULL) {
|
||||||
if (!ApplyWindowsCustomization(drive_name[0], unattend_xml_flags | UNATTEND_WINDOWS_TO_GO))
|
if (!ApplyWindowsCustomization(drive_name[0], unattend_xml_flags | UNATTEND_WINDOWS_TO_GO))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_PATCH);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_PATCH));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(!img_report.is_windows_img);
|
assert(!img_report.is_windows_img);
|
||||||
if (!ExtractISO(image_path, drive_name, FALSE)) {
|
if (!ExtractISO(image_path, drive_name, FALSE)) {
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_ISO_EXTRACT);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_ISO_EXTRACT));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (HAS_KOLIBRIOS(img_report)) {
|
if (HAS_KOLIBRIOS(img_report)) {
|
||||||
kolibri_dst[0] = drive_name[0];
|
kolibri_dst[0] = drive_name[0];
|
||||||
uprintf("Installing: %s (KolibriOS loader)", kolibri_dst);
|
uprintf("Installing: %s (KolibriOS loader)", kolibri_dst);
|
||||||
if (ExtractISOFile(image_path, "HD_Load/USB_Boot/MTLD_F32", kolibri_dst,
|
if (ExtractISOFile(image_path, "HD_Load/USB_Boot/MTLD_F32", kolibri_dst,
|
||||||
FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM) == 0) {
|
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM) == 0) {
|
||||||
uprintf("Warning: loader installation failed - KolibriOS will not boot!");
|
uprintf("Warning: loader installation failed - KolibriOS will not boot!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1944,12 +1943,12 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
efi_dst[sizeof(efi_dst) - sizeof("\\bootx64.efi")] = 0;
|
efi_dst[sizeof(efi_dst) - sizeof("\\bootx64.efi")] = 0;
|
||||||
if (!CreateDirectoryA(efi_dst, 0)) {
|
if (!CreateDirectoryA(efi_dst, 0)) {
|
||||||
uprintf("Could not create directory '%s': %s", efi_dst, WindowsErrorString());
|
uprintf("Could not create directory '%s': %s", efi_dst, WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_PATCH);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_PATCH));
|
||||||
} else {
|
} else {
|
||||||
efi_dst[sizeof(efi_dst) - sizeof("\\bootx64.efi")] = '\\';
|
efi_dst[sizeof(efi_dst) - sizeof("\\bootx64.efi")] = '\\';
|
||||||
if (!WimExtractFile(img_report.wininst_path[0], 1, "Windows\\Boot\\EFI\\bootmgfw.efi", efi_dst, FALSE)) {
|
if (!WimExtractFile(img_report.wininst_path[0], 1, "Windows\\Boot\\EFI\\bootmgfw.efi", efi_dst, FALSE)) {
|
||||||
uprintf("Failed to setup Win7 EFI boot");
|
uprintf("Failed to setup Win7 EFI boot");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_PATCH);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_PATCH));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1957,11 +1956,11 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
if ( (target_type == TT_BIOS) && HAS_WINPE(img_report) ) {
|
if ( (target_type == TT_BIOS) && HAS_WINPE(img_report) ) {
|
||||||
// Apply WinPE fixup
|
// Apply WinPE fixup
|
||||||
if (!SetupWinPE(drive_name[0]))
|
if (!SetupWinPE(drive_name[0]))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_PATCH);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_PATCH));
|
||||||
}
|
}
|
||||||
if (unattend_xml_path != NULL) {
|
if (unattend_xml_path != NULL) {
|
||||||
if (!ApplyWindowsCustomization(drive_name[0], unattend_xml_flags))
|
if (!ApplyWindowsCustomization(drive_name[0], unattend_xml_flags))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_PATCH);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_PATCH));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1988,10 +1987,10 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy any additonal files from an optional zip archive selected by the user
|
// Copy any additonal files from an optional zip archive selected by the user
|
||||||
if (!IS_ERROR(FormatStatus)) {
|
if (!IS_ERROR(ErrorStatus)) {
|
||||||
UpdateProgress(OP_EXTRACT_ZIP, 0.0f);
|
UpdateProgress(OP_EXTRACT_ZIP, 0.0f);
|
||||||
drive_name[2] = 0;
|
drive_name[2] = 0;
|
||||||
if (archive_path != NULL && fs_type < FS_EXT2 && !ExtractZip(archive_path, drive_name) && !IS_ERROR(FormatStatus))
|
if (archive_path != NULL && fs_type < FS_EXT2 && !ExtractZip(archive_path, drive_name) && !IS_ERROR(ErrorStatus))
|
||||||
uprintf("Warning: Could not copy additional files");
|
uprintf("Warning: Could not copy additional files");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2021,7 +2020,7 @@ out:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IS_ERROR(FormatStatus)) {
|
if (IS_ERROR(ErrorStatus)) {
|
||||||
volume_name = GetLogicalName(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, TRUE, TRUE);
|
volume_name = GetLogicalName(DriveIndex, SelectedDrive.Partition[partition_index[PI_MAIN]].Offset, TRUE, TRUE);
|
||||||
if (volume_name != NULL) {
|
if (volume_name != NULL) {
|
||||||
if (MountVolume(drive_name, volume_name))
|
if (MountVolume(drive_name, volume_name))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Rufus: The Reliable USB Formatting Utility
|
* Rufus: The Reliable USB Formatting Utility
|
||||||
* extfs formatting
|
* extfs formatting
|
||||||
* Copyright © 2019-2021 Pete Batard <pete@akeo.ie>
|
* Copyright © 2019-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -178,7 +178,7 @@ const char* error_message(errcode_t error_code)
|
||||||
if ((error_code > EXT2_ET_BASE) && error_code < (EXT2_ET_BASE + 1000)) {
|
if ((error_code > EXT2_ET_BASE) && error_code < (EXT2_ET_BASE + 1000)) {
|
||||||
static_sprintf(error_string, "Unknown ext2fs error %ld (EXT2_ET_BASE + %ld)", error_code, error_code - EXT2_ET_BASE);
|
static_sprintf(error_string, "Unknown ext2fs error %ld (EXT2_ET_BASE + %ld)", error_code, error_code - EXT2_ET_BASE);
|
||||||
} else {
|
} else {
|
||||||
SetLastError((FormatStatus == 0) ? (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | (error_code & 0xFFFF)) : FormatStatus);
|
SetLastError((ErrorStatus == 0) ? RUFUS_ERROR(error_code & 0xFFFF) : ErrorStatus);
|
||||||
static_sprintf(error_string, "%s", WindowsErrorString());
|
static_sprintf(error_string, "%s", WindowsErrorString());
|
||||||
}
|
}
|
||||||
return error_string;
|
return error_string;
|
||||||
|
@ -196,7 +196,7 @@ errcode_t ext2fs_print_progress(int64_t cur_value, int64_t max_value)
|
||||||
last_value = cur_value;
|
last_value = cur_value;
|
||||||
uprintfs("+");
|
uprintfs("+");
|
||||||
}
|
}
|
||||||
return IS_ERROR(FormatStatus) ? EXT2_ET_CANCEL_REQUESTED : 0;
|
return IS_ERROR(ErrorStatus) ? EXT2_ET_CANCEL_REQUESTED : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset)
|
const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset)
|
||||||
|
@ -223,7 +223,7 @@ const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset)
|
||||||
|
|
||||||
#define TEST_IMG_PATH "\\??\\C:\\tmp\\disk.img"
|
#define TEST_IMG_PATH "\\??\\C:\\tmp\\disk.img"
|
||||||
#define TEST_IMG_SIZE 4000 // Size in MB
|
#define TEST_IMG_SIZE 4000 // Size in MB
|
||||||
#define SET_EXT2_FORMAT_ERROR(x) if (!IS_ERROR(FormatStatus)) FormatStatus = ext2_last_winerror(x)
|
#define SET_EXT2_FORMAT_ERROR(x) if (!IS_ERROR(ErrorStatus)) ErrorStatus = ext2_last_winerror(x)
|
||||||
|
|
||||||
BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LPCSTR FSName, LPCSTR Label, DWORD Flags)
|
BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LPCSTR FSName, LPCSTR Label, DWORD Flags)
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP
|
||||||
volume_name = GetExtPartitionName(DriveIndex, PartitionOffset);
|
volume_name = GetExtPartitionName(DriveIndex, PartitionOffset);
|
||||||
#endif
|
#endif
|
||||||
if ((volume_name == NULL) | (strlen(FSName) != 4) || (strncmp(FSName, "ext", 3) != 0)) {
|
if ((volume_name == NULL) | (strlen(FSName) != 4) || (strncmp(FSName, "ext", 3) != 0)) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_INVALID_PARAMETER;
|
ErrorStatus = RUFUS_ERROR(ERROR_INVALID_PARAMETER);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (strchr(volume_name, ' ') != NULL)
|
if (strchr(volume_name, ' ') != NULL)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Rufus: The Reliable USB Formatting Utility
|
* Rufus: The Reliable USB Formatting Utility
|
||||||
* Large FAT32 formatting
|
* Large FAT32 formatting
|
||||||
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
|
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
|
||||||
* Copyright © 2011-2022 Pete Batard <pete@akeo.ie>
|
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -38,9 +38,7 @@
|
||||||
#include "msapi_utf8.h"
|
#include "msapi_utf8.h"
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
|
|
||||||
#define die(msg, err) do { uprintf(msg); \
|
#define die(msg, err) do { uprintf(msg); ErrorStatus = RUFUS_ERROR(err); goto out; } while(0)
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|err; \
|
|
||||||
goto out; } while(0)
|
|
||||||
|
|
||||||
extern BOOL write_as_esp;
|
extern BOOL write_as_esp;
|
||||||
|
|
||||||
|
@ -191,7 +189,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
|
||||||
ULONGLONG FatNeeded, ClusterCount;
|
ULONGLONG FatNeeded, ClusterCount;
|
||||||
|
|
||||||
if (safe_strncmp(FSName, "FAT", 3) != 0) {
|
if (safe_strncmp(FSName, "FAT", 3) != 0) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_INVALID_PARAMETER;
|
ErrorStatus = RUFUS_ERROR(ERROR_INVALID_PARAMETER);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
PrintInfoDebug(0, MSG_222, "Large FAT32");
|
PrintInfoDebug(0, MSG_222, "Large FAT32");
|
||||||
|
@ -202,7 +200,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
|
||||||
hLogicalVolume = write_as_esp ?
|
hLogicalVolume = write_as_esp ?
|
||||||
AltGetLogicalHandle(DriveIndex, PartitionOffset, TRUE, TRUE, FALSE) :
|
AltGetLogicalHandle(DriveIndex, PartitionOffset, TRUE, TRUE, FALSE) :
|
||||||
GetLogicalHandle(DriveIndex, PartitionOffset, TRUE, TRUE, FALSE);
|
GetLogicalHandle(DriveIndex, PartitionOffset, TRUE, TRUE, FALSE);
|
||||||
if (IS_ERROR(FormatStatus))
|
if (IS_ERROR(ErrorStatus))
|
||||||
goto out;
|
goto out;
|
||||||
if ((hLogicalVolume == INVALID_HANDLE_VALUE) || (hLogicalVolume == NULL))
|
if ((hLogicalVolume == INVALID_HANDLE_VALUE) || (hLogicalVolume == NULL))
|
||||||
die("Invalid logical volume handle", ERROR_INVALID_HANDLE);
|
die("Invalid logical volume handle", ERROR_INVALID_HANDLE);
|
||||||
|
@ -222,7 +220,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
|
||||||
}
|
}
|
||||||
if (dgDrive.BytesPerSector < 512)
|
if (dgDrive.BytesPerSector < 512)
|
||||||
dgDrive.BytesPerSector = 512;
|
dgDrive.BytesPerSector = 512;
|
||||||
if (IS_ERROR(FormatStatus)) goto out;
|
if (IS_ERROR(ErrorStatus)) goto out;
|
||||||
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &piDrive,
|
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &piDrive,
|
||||||
sizeof(piDrive), &cbRet, NULL)) {
|
sizeof(piDrive), &cbRet, NULL)) {
|
||||||
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &xpiDrive,
|
if (!DeviceIoControl (hLogicalVolume, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &xpiDrive,
|
||||||
|
@ -236,7 +234,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
|
||||||
piDrive.PartitionLength.QuadPart = xpiDrive.PartitionLength.QuadPart;
|
piDrive.PartitionLength.QuadPart = xpiDrive.PartitionLength.QuadPart;
|
||||||
piDrive.HiddenSectors = (DWORD)(xpiDrive.StartingOffset.QuadPart / dgDrive.BytesPerSector);
|
piDrive.HiddenSectors = (DWORD)(xpiDrive.StartingOffset.QuadPart / dgDrive.BytesPerSector);
|
||||||
}
|
}
|
||||||
if (IS_ERROR(FormatStatus)) goto out;
|
if (IS_ERROR(ErrorStatus)) goto out;
|
||||||
|
|
||||||
BytesPerSect = dgDrive.BytesPerSector;
|
BytesPerSect = dgDrive.BytesPerSector;
|
||||||
|
|
||||||
|
|
10
src/hash.c
10
src/hash.c
|
@ -5,7 +5,7 @@
|
||||||
* Copyright © 2004-2019 Tom St Denis
|
* Copyright © 2004-2019 Tom St Denis
|
||||||
* Copyright © 2004 g10 Code GmbH
|
* Copyright © 2004 g10 Code GmbH
|
||||||
* Copyright © 2002-2015 Wei Dai & Igor Pavlov
|
* Copyright © 2002-2015 Wei Dai & Igor Pavlov
|
||||||
* Copyright © 2015-2023 Pete Batard <pete@akeo.ie>
|
* Copyright © 2015-2024 Pete Batard <pete@akeo.ie>
|
||||||
* Copyright © 2022 Jeffrey Walton <noloader@gmail.com>
|
* Copyright © 2022 Jeffrey Walton <noloader@gmail.com>
|
||||||
* Copyright © 2016 Alexander Graf
|
* Copyright © 2016 Alexander Graf
|
||||||
*
|
*
|
||||||
|
@ -1468,7 +1468,7 @@ BOOL HashFile(const unsigned type, const char* path, uint8_t* hash)
|
||||||
h = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
h = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
uprintf("Could not open file: %s", WindowsErrorString());
|
uprintf("Could not open file: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1476,7 +1476,7 @@ BOOL HashFile(const unsigned type, const char* path, uint8_t* hash)
|
||||||
for (rb = 0; ; rb += rs) {
|
for (rb = 0; ; rb += rs) {
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
if (!ReadFile(h, buf, sizeof(buf), &rs, NULL)) {
|
if (!ReadFile(h, buf, sizeof(buf), &rs, NULL)) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
||||||
uprintf(" Read error: %s", WindowsErrorString());
|
uprintf(" Read error: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1983,7 +1983,7 @@ DWORD WINAPI HashThread(void* param)
|
||||||
fd = CreateFileAsync(image_path, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN);
|
fd = CreateFileAsync(image_path, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN);
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
uprintf("Could not open file: %s", WindowsErrorString());
|
uprintf("Could not open file: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2004,7 +2004,7 @@ DWORD WINAPI HashThread(void* param)
|
||||||
if ((!WaitFileAsync(fd, DRIVE_ACCESS_TIMEOUT)) ||
|
if ((!WaitFileAsync(fd, DRIVE_ACCESS_TIMEOUT)) ||
|
||||||
(!GetSizeAsync(fd, &read_size[read_bufnum]))) {
|
(!GetSizeAsync(fd, &read_size[read_bufnum]))) {
|
||||||
uprintf("Read error: %s", WindowsErrorString());
|
uprintf("Read error: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/icon.c
14
src/icon.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Rufus: The Reliable USB Formatting Utility
|
* Rufus: The Reliable USB Formatting Utility
|
||||||
* Extract icon from executable and set autorun.inf
|
* Extract icon from executable and set autorun.inf
|
||||||
* Copyright © 2012-2021 Pete Batard <pete@akeo.ie>
|
* Copyright © 2012-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -95,7 +95,7 @@ BOOL ExtractAppIcon(const char* path, BOOL bSilent)
|
||||||
HRSRC res;
|
HRSRC res;
|
||||||
WORD i;
|
WORD i;
|
||||||
BYTE* res_data;
|
BYTE* res_data;
|
||||||
DWORD res_size, Size, offset;
|
DWORD res_size, offset;
|
||||||
HANDLE hFile = INVALID_HANDLE_VALUE;
|
HANDLE hFile = INVALID_HANDLE_VALUE;
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE;
|
||||||
GRPICONDIR* icondir;
|
GRPICONDIR* icondir;
|
||||||
|
@ -110,22 +110,22 @@ BOOL ExtractAppIcon(const char* path, BOOL bSilent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write .ico header
|
// Write .ico header
|
||||||
if (!WriteFileWithRetry(hFile, icondir, 3*sizeof(WORD), &Size, WRITE_RETRIES)) {
|
if (!WriteFileWithRetry(hFile, icondir, 3 * sizeof(WORD), NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write icon header: %s.", WindowsErrorString());
|
uprintf("Could not write icon header: %s.", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write icon data
|
// Write icon data
|
||||||
offset = 3*sizeof(WORD) + icondir->idCount*sizeof(ICONDIRENTRY);
|
offset = 3*sizeof(WORD) + icondir->idCount * sizeof(ICONDIRENTRY);
|
||||||
for (i=0; i<icondir->idCount; i++) {
|
for (i=0; i<icondir->idCount; i++) {
|
||||||
// Write the common part of ICONDIRENTRY
|
// Write the common part of ICONDIRENTRY
|
||||||
if (!WriteFileWithRetry(hFile, &icondir->idEntries[i], sizeof(GRPICONDIRENTRY)-sizeof(WORD), &Size, WRITE_RETRIES)) {
|
if (!WriteFileWithRetry(hFile, &icondir->idEntries[i], sizeof(GRPICONDIRENTRY)-sizeof(WORD), NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write ICONDIRENTRY[%d]: %s.", i, WindowsErrorString());
|
uprintf("Could not write ICONDIRENTRY[%d]: %s.", i, WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
res = FindResourceA(hMainInstance, MAKEINTRESOURCEA(icondir->idEntries[i].nID), _RT_ICON);
|
res = FindResourceA(hMainInstance, MAKEINTRESOURCEA(icondir->idEntries[i].nID), _RT_ICON);
|
||||||
// Write the DWORD offset
|
// Write the DWORD offset
|
||||||
if (!WriteFileWithRetry(hFile, &offset, sizeof(offset), &Size, WRITE_RETRIES)) {
|
if (!WriteFileWithRetry(hFile, &offset, sizeof(offset), NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write ICONDIRENTRY[%d] offset: %s.", i, WindowsErrorString());
|
uprintf("Could not write ICONDIRENTRY[%d] offset: %s.", i, WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ BOOL ExtractAppIcon(const char* path, BOOL bSilent)
|
||||||
res_handle = LoadResource(NULL, res);
|
res_handle = LoadResource(NULL, res);
|
||||||
res_data = (BYTE*)LockResource(res_handle);
|
res_data = (BYTE*)LockResource(res_handle);
|
||||||
res_size = SizeofResource(NULL, res);
|
res_size = SizeofResource(NULL, res);
|
||||||
if (!WriteFileWithRetry(hFile, res_data, res_size, &Size, WRITE_RETRIES)) {
|
if (!WriteFileWithRetry(hFile, res_data, res_size, NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write icon data #%d: %s.", i, WindowsErrorString());
|
uprintf("Could not write icon data #%d: %s.", i, WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
34
src/iso.c
34
src/iso.c
|
@ -554,7 +554,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
|
||||||
if (psz_path[0] == 0)
|
if (psz_path[0] == 0)
|
||||||
UpdateProgressWithInfoInit(NULL, TRUE);
|
UpdateProgressWithInfoInit(NULL, TRUE);
|
||||||
while ((p_udf_dirent = udf_readdir(p_udf_dirent)) != NULL) {
|
while ((p_udf_dirent = udf_readdir(p_udf_dirent)) != NULL) {
|
||||||
if (FormatStatus) goto out;
|
if (ErrorStatus) goto out;
|
||||||
psz_basename = udf_get_filename(p_udf_dirent);
|
psz_basename = udf_get_filename(p_udf_dirent);
|
||||||
if (strlen(psz_basename) == 0)
|
if (strlen(psz_basename) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -621,7 +621,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
|
||||||
if (fd_md5sum != NULL)
|
if (fd_md5sum != NULL)
|
||||||
hash_init[HASH_MD5](&ctx);
|
hash_init[HASH_MD5](&ctx);
|
||||||
while (file_length > 0) {
|
while (file_length > 0) {
|
||||||
if (FormatStatus)
|
if (ErrorStatus)
|
||||||
goto out;
|
goto out;
|
||||||
nb = (size_t)MIN(ISO_BUFFER_SIZE / UDF_BLOCKSIZE, (file_length + UDF_BLOCKSIZE - 1) / UDF_BLOCKSIZE);
|
nb = (size_t)MIN(ISO_BUFFER_SIZE / UDF_BLOCKSIZE, (file_length + UDF_BLOCKSIZE - 1) / UDF_BLOCKSIZE);
|
||||||
read = udf_read_block(p_udf_dirent, buf, nb);
|
read = udf_read_block(p_udf_dirent, buf, nb);
|
||||||
|
@ -722,7 +722,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
|
||||||
if (psz_path[0] == 0)
|
if (psz_path[0] == 0)
|
||||||
UpdateProgressWithInfoInit(NULL, TRUE);
|
UpdateProgressWithInfoInit(NULL, TRUE);
|
||||||
_CDIO_LIST_FOREACH(p_entnode, p_entlist) {
|
_CDIO_LIST_FOREACH(p_entnode, p_entlist) {
|
||||||
if (FormatStatus) goto out;
|
if (ErrorStatus) goto out;
|
||||||
p_statbuf = (iso9660_stat_t*) _cdio_list_node_data(p_entnode);
|
p_statbuf = (iso9660_stat_t*) _cdio_list_node_data(p_entnode);
|
||||||
free_p_statbuf = FALSE;
|
free_p_statbuf = FALSE;
|
||||||
if (scan_only && (p_statbuf->rr.b3_rock == yep) && enable_rockridge) {
|
if (scan_only && (p_statbuf->rr.b3_rock == yep) && enable_rockridge) {
|
||||||
|
@ -887,7 +887,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
|
||||||
if (fd_md5sum != NULL)
|
if (fd_md5sum != NULL)
|
||||||
hash_init[HASH_MD5](&ctx);
|
hash_init[HASH_MD5](&ctx);
|
||||||
for (i = 0; file_length > 0; i += nb) {
|
for (i = 0; file_length > 0; i += nb) {
|
||||||
if (FormatStatus)
|
if (ErrorStatus)
|
||||||
goto out;
|
goto out;
|
||||||
lsn = p_statbuf->lsn + (lsn_t)i;
|
lsn = p_statbuf->lsn + (lsn_t)i;
|
||||||
nb = (size_t)MIN(ISO_BUFFER_SIZE / ISO_BLOCKSIZE, (file_length + ISO_BLOCKSIZE - 1) / ISO_BLOCKSIZE);
|
nb = (size_t)MIN(ISO_BUFFER_SIZE / ISO_BLOCKSIZE, (file_length + ISO_BLOCKSIZE - 1) / ISO_BLOCKSIZE);
|
||||||
|
@ -1067,7 +1067,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
|
||||||
IGNORE_RETVAL(_chdirU(app_data_dir));
|
IGNORE_RETVAL(_chdirU(app_data_dir));
|
||||||
if (total_blocks == 0) {
|
if (total_blocks == 0) {
|
||||||
uprintf("Error: ISO has not been properly scanned.");
|
uprintf("Error: ISO has not been properly scanned.");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_ISO_SCAN);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_ISO_SCAN));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
nb_blocks = 0;
|
nb_blocks = 0;
|
||||||
|
@ -1388,8 +1388,8 @@ out:
|
||||||
}
|
}
|
||||||
iso9660_close(p_iso);
|
iso9660_close(p_iso);
|
||||||
udf_close(p_udf);
|
udf_close(p_udf);
|
||||||
if ((r != 0) && (FormatStatus == 0))
|
if ((r != 0) && (ErrorStatus == 0))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR((scan_only?ERROR_ISO_SCAN:ERROR_ISO_EXTRACT));
|
ErrorStatus = RUFUS_ERROR(APPERR(scan_only ? ERROR_ISO_SCAN : ERROR_ISO_EXTRACT));
|
||||||
return (r == 0);
|
return (r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,8 +1766,8 @@ BOOL DumpFatDir(const char* path, int32_t cluster)
|
||||||
while ((s != 0) && (s < 0xFFFFFFFFULL) && (written < diritem.size)) {
|
while ((s != 0) && (s < 0xFFFFFFFFULL) && (written < diritem.size)) {
|
||||||
buf = libfat_get_sector(lf_fs, s);
|
buf = libfat_get_sector(lf_fs, s);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_SECTOR_NOT_FOUND;
|
ErrorStatus = RUFUS_ERROR(ERROR_SECTOR_NOT_FOUND);
|
||||||
if (IS_ERROR(FormatStatus))
|
if (IS_ERROR(ErrorStatus))
|
||||||
goto out;
|
goto out;
|
||||||
size = MIN(LIBFAT_SECTOR_SIZE, diritem.size - written);
|
size = MIN(LIBFAT_SECTOR_SIZE, diritem.size - written);
|
||||||
if (!WriteFileWithRetry(handle, buf, size, &size, WRITE_RETRIES) ||
|
if (!WriteFileWithRetry(handle, buf, size, &size, WRITE_RETRIES) ||
|
||||||
|
@ -1826,7 +1826,7 @@ static DWORD WINAPI IsoSaveImageThread(void* param)
|
||||||
hPhysicalDrive = CreateFileA(img_save->DevicePath, GENERIC_READ, FILE_SHARE_READ,
|
hPhysicalDrive = CreateFileA(img_save->DevicePath, GENERIC_READ, FILE_SHARE_READ,
|
||||||
NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1838,13 +1838,13 @@ static DWORD WINAPI IsoSaveImageThread(void* param)
|
||||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (hDestImage == INVALID_HANDLE_VALUE) {
|
if (hDestImage == INVALID_HANDLE_VALUE) {
|
||||||
uprintf("Could not open image '%s': %s", img_save->ImagePath, WindowsErrorString());
|
uprintf("Could not open image '%s': %s", img_save->ImagePath, WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
ErrorStatus = RUFUS_ERROR(ERROR_OPEN_FAILED);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = (uint8_t*)_mm_malloc(img_save->BufSize, 16);
|
buffer = (uint8_t*)_mm_malloc(img_save->BufSize, 16);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
uprintf("Could not allocate buffer");
|
uprintf("Could not allocate buffer");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1864,7 +1864,7 @@ static DWORD WINAPI IsoSaveImageThread(void* param)
|
||||||
s = ReadFile(hPhysicalDrive, buffer,
|
s = ReadFile(hPhysicalDrive, buffer,
|
||||||
(DWORD)MIN(img_save->BufSize, img_save->DeviceSize - wb), &rSize, NULL);
|
(DWORD)MIN(img_save->BufSize, img_save->DeviceSize - wb), &rSize, NULL);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
||||||
uprintf("Read error: %s", WindowsErrorString());
|
uprintf("Read error: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1889,7 +1889,7 @@ static DWORD WINAPI IsoSaveImageThread(void* param)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
|
@ -1900,7 +1900,7 @@ static DWORD WINAPI IsoSaveImageThread(void* param)
|
||||||
if (wb != img_save->DeviceSize) {
|
if (wb != img_save->DeviceSize) {
|
||||||
uprintf("Error: wrote %s, expected %s", SizeToHumanReadable(wb, FALSE, FALSE),
|
uprintf("Error: wrote %s, expected %s", SizeToHumanReadable(wb, FALSE, FALSE),
|
||||||
SizeToHumanReadable(img_save->DeviceSize, FALSE, FALSE));
|
SizeToHumanReadable(img_save->DeviceSize, FALSE, FALSE));
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
uprintf("Operation complete (Wrote %s).", SizeToHumanReadable(wb, FALSE, FALSE));
|
uprintf("Operation complete (Wrote %s).", SizeToHumanReadable(wb, FALSE, FALSE));
|
||||||
|
@ -1941,7 +1941,7 @@ void IsoSaveImage(void)
|
||||||
|
|
||||||
uprintf("ISO media size %s", SizeToHumanReadable(img_save.DeviceSize, FALSE, FALSE));
|
uprintf("ISO media size %s", SizeToHumanReadable(img_save.DeviceSize, FALSE, FALSE));
|
||||||
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
// Disable all controls except cancel
|
// Disable all controls except cancel
|
||||||
EnableControls(FALSE, FALSE);
|
EnableControls(FALSE, FALSE);
|
||||||
InitProgress(TRUE);
|
InitProgress(TRUE);
|
||||||
|
@ -1952,7 +1952,7 @@ void IsoSaveImage(void)
|
||||||
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Unable to start ISO save thread");
|
uprintf("Unable to start ISO save thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
safe_free(img_save.ImagePath);
|
safe_free(img_save.ImagePath);
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ int64_t write_sectors(HANDLE hDrive, uint64_t SectorSize,
|
||||||
LastWriteError = 0;
|
LastWriteError = 0;
|
||||||
if(!WriteFileWithRetry(hDrive, pBuf, Size, &Size, WRITE_RETRIES))
|
if(!WriteFileWithRetry(hDrive, pBuf, Size, &Size, WRITE_RETRIES))
|
||||||
{
|
{
|
||||||
LastWriteError = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|GetLastError();
|
LastWriteError = RUFUS_ERROR(GetLastError());
|
||||||
uprintf("write_sectors: Write error %s\n", WindowsErrorString());
|
uprintf("write_sectors: Write error %s\n", WindowsErrorString());
|
||||||
uprintf(" StartSector: 0x%08" PRIx64 ", nSectors: 0x%" PRIx64 ", SectorSize: 0x%" PRIx64 "\n", StartSector, nSectors, SectorSize);
|
uprintf(" StartSector: 0x%08" PRIx64 ", nSectors: 0x%" PRIx64 ", SectorSize: 0x%" PRIx64 "\n", StartSector, nSectors, SectorSize);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -63,7 +63,7 @@ int64_t write_sectors(HANDLE hDrive, uint64_t SectorSize,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uprintf("write_sectors: Write error\n");
|
uprintf("write_sectors: Write error\n");
|
||||||
LastWriteError = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
LastWriteError = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
uprintf(" Wrote: %d, Expected: %" PRIu64 "\n", Size, nSectors*SectorSize);
|
uprintf(" Wrote: %d, Expected: %" PRIu64 "\n", Size, nSectors*SectorSize);
|
||||||
uprintf(" StartSector: 0x%08" PRIx64 ", nSectors: 0x%" PRIx64 ", SectorSize: 0x%" PRIx64 "\n", StartSector, nSectors, SectorSize);
|
uprintf(" StartSector: 0x%08" PRIx64 ", nSectors: 0x%" PRIx64 ", SectorSize: 0x%" PRIx64 "\n", StartSector, nSectors, SectorSize);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
30
src/net.c
30
src/net.c
|
@ -204,7 +204,7 @@ uint64_t DownloadToFileOrBufferEx(const char* url, const char* file, const char*
|
||||||
PF_INIT_OR_OUT(HttpSendRequestA, WinInet);
|
PF_INIT_OR_OUT(HttpSendRequestA, WinInet);
|
||||||
PF_INIT_OR_OUT(HttpQueryInfoA, WinInet);
|
PF_INIT_OR_OUT(HttpQueryInfoA, WinInet);
|
||||||
|
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
DownloadStatus = 404;
|
DownloadStatus = 404;
|
||||||
if (hProgressDialog != NULL)
|
if (hProgressDialog != NULL)
|
||||||
UpdateProgressWithInfoInit(hProgressDialog, FALSE);
|
UpdateProgressWithInfoInit(hProgressDialog, FALSE);
|
||||||
|
@ -258,7 +258,7 @@ uint64_t DownloadToFileOrBufferEx(const char* url, const char* file, const char*
|
||||||
pfHttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&DownloadStatus, &dwSize, NULL);
|
pfHttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&DownloadStatus, &dwSize, NULL);
|
||||||
if (DownloadStatus != 200) {
|
if (DownloadStatus != 200) {
|
||||||
error_code = ERROR_INTERNET_ITEM_NOT_FOUND;
|
error_code = ERROR_INTERNET_ITEM_NOT_FOUND;
|
||||||
SetLastError(ERROR_SEVERITY_ERROR | FAC(FACILITY_HTTP) | error_code);
|
SetLastError(RUFUS_ERROR(error_code));
|
||||||
uprintf("%s: %d", (DownloadStatus == 404) ? "File not found" : "Unable to access file", DownloadStatus);
|
uprintf("%s: %d", (DownloadStatus == 404) ? "File not found" : "Unable to access file", DownloadStatus);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ uint64_t DownloadToFileOrBufferEx(const char* url, const char* file, const char*
|
||||||
// Keep checking for data until there is nothing left.
|
// Keep checking for data until there is nothing left.
|
||||||
while (1) {
|
while (1) {
|
||||||
// User may have cancelled the download
|
// User may have cancelled the download
|
||||||
if (IS_ERROR(FormatStatus))
|
if (IS_ERROR(ErrorStatus))
|
||||||
goto out;
|
goto out;
|
||||||
if (!pfInternetReadFile(hRequest, buf, sizeof(buf), &dwDownloaded) || (dwDownloaded == 0))
|
if (!pfInternetReadFile(hRequest, buf, sizeof(buf), &dwDownloaded) || (dwDownloaded == 0))
|
||||||
break;
|
break;
|
||||||
|
@ -322,7 +322,7 @@ uint64_t DownloadToFileOrBufferEx(const char* url, const char* file, const char*
|
||||||
|
|
||||||
if (size != total_size) {
|
if (size != total_size) {
|
||||||
uprintf("Could not download complete file - read: %lld bytes, expected: %lld bytes", size, total_size);
|
uprintf("Could not download complete file - read: %lld bytes, expected: %lld bytes", size, total_size);
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
|
ErrorStatus = RUFUS_ERROR(ERROR_WRITE_FAULT);
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
DownloadStatus = 200;
|
DownloadStatus = 200;
|
||||||
|
@ -383,7 +383,7 @@ DWORD DownloadSignedFile(const char* url, const char* file, HWND hProgressDialog
|
||||||
if ((sig_len != RSA_SIGNATURE_SIZE) || (!ValidateOpensslSignature(buf, buf_len, sig, sig_len))) {
|
if ((sig_len != RSA_SIGNATURE_SIZE) || (!ValidateOpensslSignature(buf, buf_len, sig, sig_len))) {
|
||||||
uprintf("FATAL: Download signature is invalid ✗");
|
uprintf("FATAL: Download signature is invalid ✗");
|
||||||
DownloadStatus = 403; // Forbidden
|
DownloadStatus = 403; // Forbidden
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_BAD_SIGNATURE);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_BAD_SIGNATURE));
|
||||||
SendMessage(GetDlgItem(hProgressDialog, IDC_PROGRESS), PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
SendMessage(GetDlgItem(hProgressDialog, IDC_PROGRESS), PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_ERROR);
|
SetTaskbarProgressState(TASKBAR_ERROR);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -413,7 +413,7 @@ out:
|
||||||
if ((bPromptOnError) && (DownloadStatus != 200)) {
|
if ((bPromptOnError) && (DownloadStatus != 200)) {
|
||||||
PrintInfo(0, MSG_242);
|
PrintInfo(0, MSG_242);
|
||||||
SetLastError(error_code);
|
SetLastError(error_code);
|
||||||
MessageBoxExU(hMainDialog, IS_ERROR(FormatStatus) ? StrError(FormatStatus, FALSE) : WindowsErrorString(),
|
MessageBoxExU(hMainDialog, IS_ERROR(ErrorStatus) ? StrError(ErrorStatus, FALSE) : WindowsErrorString(),
|
||||||
lmprintf(MSG_044), MB_OK | MB_ICONERROR | MB_IS_RTL, selected_langid);
|
lmprintf(MSG_044), MB_OK | MB_ICONERROR | MB_IS_RTL, selected_langid);
|
||||||
}
|
}
|
||||||
safe_closehandle(hFile);
|
safe_closehandle(hFile);
|
||||||
|
@ -768,7 +768,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
dwSize = (DWORD)DownloadToFileOrBuffer(sig_url, NULL, &sig, NULL, FALSE);
|
dwSize = (DWORD)DownloadToFileOrBuffer(sig_url, NULL, &sig, NULL, FALSE);
|
||||||
if ((dwSize != RSA_SIGNATURE_SIZE) || (!ValidateOpensslSignature(compressed, dwCompressedSize, sig, dwSize))) {
|
if ((dwSize != RSA_SIGNATURE_SIZE) || (!ValidateOpensslSignature(compressed, dwCompressedSize, sig, dwSize))) {
|
||||||
uprintf("FATAL: Download signature is invalid ✗");
|
uprintf("FATAL: Download signature is invalid ✗");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_BAD_SIGNATURE);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_BAD_SIGNATURE));
|
||||||
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_ERROR);
|
SetTaskbarProgressState(TASKBAR_ERROR);
|
||||||
safe_free(compressed);
|
safe_free(compressed);
|
||||||
|
@ -778,7 +778,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
free(sig);
|
free(sig);
|
||||||
uprintf("Download signature is valid ✓");
|
uprintf("Download signature is valid ✓");
|
||||||
uncompressed_size = *((uint64_t*)&compressed[5]);
|
uncompressed_size = *((uint64_t*)&compressed[5]);
|
||||||
if ((uncompressed_size < 1 * MB) && (bled_init(0, uprintf, NULL, NULL, NULL, NULL, &FormatStatus) >= 0)) {
|
if ((uncompressed_size < 1 * MB) && (bled_init(0, uprintf, NULL, NULL, NULL, NULL, &ErrorStatus) >= 0)) {
|
||||||
fido_script = malloc((size_t)uncompressed_size);
|
fido_script = malloc((size_t)uncompressed_size);
|
||||||
size = bled_uncompress_from_buffer_to_buffer(compressed, dwCompressedSize, fido_script, (size_t)uncompressed_size, BLED_COMPRESSION_LZMA);
|
size = bled_uncompress_from_buffer_to_buffer(compressed, dwCompressedSize, fido_script, (size_t)uncompressed_size, BLED_COMPRESSION_LZMA);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
|
@ -787,7 +787,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
if (size != uncompressed_size) {
|
if (size != uncompressed_size) {
|
||||||
uprintf("FATAL: Could not uncompressed download script");
|
uprintf("FATAL: Could not uncompressed download script");
|
||||||
safe_free(fido_script);
|
safe_free(fido_script);
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_INVALID_DATA;
|
ErrorStatus = RUFUS_ERROR(ERROR_INVALID_DATA);
|
||||||
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_ERROR);
|
SetTaskbarProgressState(TASKBAR_ERROR);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -840,7 +840,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
// signed, we also validate the Authenticode signature of the local script.
|
// signed, we also validate the Authenticode signature of the local script.
|
||||||
if (ValidateSignature(INVALID_HANDLE_VALUE, script_path) != NO_ERROR) {
|
if (ValidateSignature(INVALID_HANDLE_VALUE, script_path) != NO_ERROR) {
|
||||||
uprintf("FATAL: Script signature is invalid ✗");
|
uprintf("FATAL: Script signature is invalid ✗");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_BAD_SIGNATURE);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_BAD_SIGNATURE));
|
||||||
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_ERROR);
|
SetTaskbarProgressState(TASKBAR_ERROR);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -848,7 +848,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
uprintf("Script signature is valid ✓");
|
uprintf("Script signature is valid ✓");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
dwExitCode = RunCommand(cmdline, app_data_dir, TRUE);
|
dwExitCode = RunCommand(cmdline, app_data_dir, TRUE);
|
||||||
uprintf("Exited download script with code: %d", dwExitCode);
|
uprintf("Exited download script with code: %d", dwExitCode);
|
||||||
if ((dwExitCode == 0) && PeekNamedPipe(hPipe, NULL, dwPipeSize, NULL, &dwAvail, NULL) && (dwAvail != 0)) {
|
if ((dwExitCode == 0) && PeekNamedPipe(hPipe, NULL, dwPipeSize, NULL, &dwAvail, NULL) && (dwAvail != 0)) {
|
||||||
|
@ -876,11 +876,11 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
}
|
}
|
||||||
// Download the ISO and report errors if any
|
// Download the ISO and report errors if any
|
||||||
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
||||||
if (DownloadToFileOrBuffer(url, img_save.ImagePath, NULL, hMainDialog, TRUE) == 0) {
|
if (DownloadToFileOrBuffer(url, img_save.ImagePath, NULL, hMainDialog, TRUE) == 0) {
|
||||||
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
|
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
|
||||||
if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) {
|
if (SCODE_CODE(ErrorStatus) == ERROR_CANCELLED) {
|
||||||
uprintf("Download cancelled by user");
|
uprintf("Download cancelled by user");
|
||||||
Notification(MSG_INFO, NULL, NULL, lmprintf(MSG_211), lmprintf(MSG_041));
|
Notification(MSG_INFO, NULL, NULL, lmprintf(MSG_211), lmprintf(MSG_041));
|
||||||
PrintInfo(0, MSG_211);
|
PrintInfo(0, MSG_211);
|
||||||
|
@ -917,7 +917,7 @@ BOOL DownloadISO()
|
||||||
{
|
{
|
||||||
if (CreateThread(NULL, 0, DownloadISOThread, NULL, 0, NULL) == NULL) {
|
if (CreateThread(NULL, 0, DownloadISOThread, NULL, 0, NULL) == NULL) {
|
||||||
uprintf("Unable to start Windows ISO download thread");
|
uprintf("Unable to start Windows ISO download thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
SendMessage(hMainDialog, UM_ENABLE_CONTROLS, 0, 0);
|
SendMessage(hMainDialog, UM_ENABLE_CONTROLS, 0, 0);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -949,7 +949,7 @@ BOOL IsDownloadable(const char* url)
|
||||||
if (url == NULL)
|
if (url == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
DownloadStatus = 404;
|
DownloadStatus = 404;
|
||||||
|
|
||||||
if ((!pfInternetCrackUrlA(url, (DWORD)safe_strlen(url), 0, &UrlParts))
|
if ((!pfInternetCrackUrlA(url, (DWORD)safe_strlen(url), 0, &UrlParts))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Rufus: The Reliable USB Formatting Utility
|
* Rufus: The Reliable USB Formatting Utility
|
||||||
* PKI functions (code signing, etc.)
|
* PKI functions (code signing, etc.)
|
||||||
* Copyright © 2015-2023 Pete Batard <pete@akeo.ie>
|
* Copyright © 2015-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -652,7 +652,7 @@ LONG ValidateSignature(HWND hDlg, const char* path)
|
||||||
trust_file.pcwszFilePath = utf8_to_wchar(path);
|
trust_file.pcwszFilePath = utf8_to_wchar(path);
|
||||||
if (trust_file.pcwszFilePath == NULL) {
|
if (trust_file.pcwszFilePath == NULL) {
|
||||||
uprintf("PKI: Unable to convert '%s' to UTF16", path);
|
uprintf("PKI: Unable to convert '%s' to UTF16", path);
|
||||||
return ERROR_SEVERITY_ERROR | FAC(FACILITY_CERT) | ERROR_NOT_ENOUGH_MEMORY;
|
return RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
trust_data.cbStruct = sizeof(trust_data);
|
trust_data.cbStruct = sizeof(trust_data);
|
||||||
|
|
44
src/rufus.c
44
src/rufus.c
|
@ -1290,8 +1290,7 @@ DWORD WINAPI ImageScanThread(LPVOID param)
|
||||||
ComboBox_ResetContent(hImageOption);
|
ComboBox_ResetContent(hImageOption);
|
||||||
imop_win_sel = 0;
|
imop_win_sel = 0;
|
||||||
|
|
||||||
if ((FormatStatus == (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_CANCELLED)) ||
|
if ((ErrorStatus == RUFUS_ERROR(ERROR_CANCELLED)) || (img_report.image_size == 0) ||
|
||||||
(img_report.image_size == 0) ||
|
|
||||||
(!img_report.is_iso && (img_report.is_bootable_img <= 0) && !img_report.is_windows_img)) {
|
(!img_report.is_iso && (img_report.is_bootable_img <= 0) && !img_report.is_windows_img)) {
|
||||||
// Failed to scan image
|
// Failed to scan image
|
||||||
if (img_report.is_bootable_img < 0)
|
if (img_report.is_bootable_img < 0)
|
||||||
|
@ -2246,7 +2245,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDYES)) {
|
MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDYES)) {
|
||||||
// Operation may have completed in the meantime
|
// Operation may have completed in the meantime
|
||||||
if (format_thread != NULL) {
|
if (format_thread != NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;
|
ErrorStatus = RUFUS_ERROR(ERROR_CANCELLED);
|
||||||
PrintInfo(0, MSG_201);
|
PrintInfo(0, MSG_201);
|
||||||
uprintf("Cancelling");
|
uprintf("Cancelling");
|
||||||
// Start a timer to detect blocking operations during ISO file extraction
|
// Start a timer to detect blocking operations during ISO file extraction
|
||||||
|
@ -2262,7 +2261,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
} else if (op_in_progress) {
|
} else if (op_in_progress) {
|
||||||
// User might be trying to cancel during preliminary checks
|
// User might be trying to cancel during preliminary checks
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;
|
ErrorStatus = RUFUS_ERROR(ERROR_CANCELLED);
|
||||||
PrintInfo(0, MSG_201);
|
PrintInfo(0, MSG_201);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
|
EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
|
@ -2554,10 +2553,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
free(old_image_path);
|
free(old_image_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
if (CreateThread(NULL, 0, ImageScanThread, NULL, 0, NULL) == NULL) {
|
if (CreateThread(NULL, 0, ImageScanThread, NULL, 0, NULL) == NULL) {
|
||||||
uprintf("Unable to start ISO scanning thread");
|
uprintf("Unable to start ISO scanning thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2585,7 +2584,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
unattend_xml_flags = 0;
|
unattend_xml_flags = 0;
|
||||||
// Disable all controls except Cancel
|
// Disable all controls except Cancel
|
||||||
EnableControls(FALSE, FALSE);
|
EnableControls(FALSE, FALSE);
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
LastWriteError = 0;
|
LastWriteError = 0;
|
||||||
StrArrayClear(&BlockingProcessList);
|
StrArrayClear(&BlockingProcessList);
|
||||||
no_confirmation_on_cancel = FALSE;
|
no_confirmation_on_cancel = FALSE;
|
||||||
|
@ -2595,7 +2594,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
// On exit, this thread sends message UM_FORMAT_START back to this dialog.
|
// On exit, this thread sends message UM_FORMAT_START back to this dialog.
|
||||||
if (CreateThread(NULL, 0, BootCheckThread, NULL, 0, NULL) == NULL) {
|
if (CreateThread(NULL, 0, BootCheckThread, NULL, 0, NULL) == NULL) {
|
||||||
uprintf("Unable to start boot check thread");
|
uprintf("Unable to start boot check thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2612,7 +2611,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
case IDC_HASH:
|
case IDC_HASH:
|
||||||
// TODO: Move this as a fn call in hash.c?
|
// TODO: Move this as a fn call in hash.c?
|
||||||
if ((format_thread == NULL) && (image_path != NULL)) {
|
if ((format_thread == NULL) && (image_path != NULL)) {
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
no_confirmation_on_cancel = TRUE;
|
no_confirmation_on_cancel = TRUE;
|
||||||
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
||||||
// Disable all controls except cancel
|
// Disable all controls except cancel
|
||||||
|
@ -2626,7 +2625,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Unable to start hash thread");
|
uprintf("Unable to start hash thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2650,9 +2649,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
break;
|
break;
|
||||||
case UM_ENABLE_CONTROLS:
|
case UM_ENABLE_CONTROLS:
|
||||||
KillTimer(hMainDialog, TID_APP_TIMER);
|
KillTimer(hMainDialog, TID_APP_TIMER);
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
PrintInfo(0, MSG_210);
|
PrintInfo(0, MSG_210);
|
||||||
else switch (SCODE_CODE(FormatStatus)) {
|
else switch (SCODE_CODE(ErrorStatus)) {
|
||||||
case ERROR_CANCELLED:
|
case ERROR_CANCELLED:
|
||||||
PrintInfo(0, MSG_211);
|
PrintInfo(0, MSG_211);
|
||||||
break;
|
break;
|
||||||
|
@ -2935,9 +2934,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
if (isMarquee) {
|
if (isMarquee) {
|
||||||
SendMessage(hProgress, PBM_SETMARQUEE, FALSE, 0);
|
SendMessage(hProgress, PBM_SETMARQUEE, FALSE, 0);
|
||||||
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
||||||
} else if (!IS_ERROR(FormatStatus)) {
|
} else if (!IS_ERROR(ErrorStatus)) {
|
||||||
SetTaskbarProgressValue(MAX_PROGRESS, MAX_PROGRESS);
|
SetTaskbarProgressValue(MAX_PROGRESS, MAX_PROGRESS);
|
||||||
} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) {
|
} else if (SCODE_CODE(ErrorStatus) == ERROR_CANCELLED) {
|
||||||
tb_state = PBST_PAUSED;
|
tb_state = PBST_PAUSED;
|
||||||
tb_flags = TASKBAR_PAUSED;
|
tb_flags = TASKBAR_PAUSED;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3010,7 +3009,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
format_thread = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL);
|
format_thread = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL);
|
||||||
if (format_thread == NULL) {
|
if (format_thread == NULL) {
|
||||||
uprintf("Unable to start formatting thread");
|
uprintf("Unable to start formatting thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
} else {
|
} else {
|
||||||
SetThreadPriority(format_thread, default_thread_priority);
|
SetThreadPriority(format_thread, default_thread_priority);
|
||||||
|
@ -3033,8 +3032,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
EnableControls(TRUE, FALSE);
|
EnableControls(TRUE, FALSE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) |
|
ErrorStatus = RUFUS_ERROR((wParam == BOOTCHECK_DOWNLOAD_ERROR) ? APPERR(ERROR_CANT_DOWNLOAD) : ERROR_GEN_FAILURE);
|
||||||
((wParam == BOOTCHECK_DOWNLOAD_ERROR) ? APPERR(ERROR_CANT_DOWNLOAD) : ERROR_GEN_FAILURE);
|
|
||||||
// Fall through
|
// Fall through
|
||||||
|
|
||||||
case UM_FORMAT_COMPLETED:
|
case UM_FORMAT_COMPLETED:
|
||||||
|
@ -3055,13 +3053,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
uprintf("\r\n");
|
uprintf("\r\n");
|
||||||
GetDevices(DeviceNum);
|
GetDevices(DeviceNum);
|
||||||
}
|
}
|
||||||
if (!IS_ERROR(FormatStatus)) {
|
if (!IS_ERROR(ErrorStatus)) {
|
||||||
SendMessage(hProgress, PBM_SETPOS, MAX_PROGRESS, 0);
|
SendMessage(hProgress, PBM_SETPOS, MAX_PROGRESS, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_NOPROGRESS);
|
SetTaskbarProgressState(TASKBAR_NOPROGRESS);
|
||||||
PrintInfo(0, MSG_210);
|
PrintInfo(0, MSG_210);
|
||||||
MessageBeep(MB_OK);
|
MessageBeep(MB_OK);
|
||||||
FlashTaskbar(dialog_handle);
|
FlashTaskbar(dialog_handle);
|
||||||
} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) {
|
} else if (SCODE_CODE(ErrorStatus) == ERROR_CANCELLED) {
|
||||||
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_PAUSED, 0);
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_PAUSED, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_PAUSED);
|
SetTaskbarProgressState(TASKBAR_PAUSED);
|
||||||
PrintInfo(0, MSG_211);
|
PrintInfo(0, MSG_211);
|
||||||
|
@ -3085,7 +3083,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
"If (Get-Command -Commandtype Function Get-MpPreference -ErrorAction SilentlyContinue) { Exit 1 } Else { Exit 0 }",
|
"If (Get-Command -Commandtype Function Get-MpPreference -ErrorAction SilentlyContinue) { Exit 1 } Else { Exit 0 }",
|
||||||
// Return 1 if Controlled Folder Access is enabled
|
// Return 1 if Controlled Folder Access is enabled
|
||||||
"Exit (Get-MpPreference).EnableControlledFolderAccess" };
|
"Exit (Get-MpPreference).EnableControlledFolderAccess" };
|
||||||
switch (SCODE_CODE(FormatStatus)) {
|
switch (SCODE_CODE(ErrorStatus)) {
|
||||||
case ERROR_PARTITION_FAILURE:
|
case ERROR_PARTITION_FAILURE:
|
||||||
case ERROR_WRITE_FAULT:
|
case ERROR_WRITE_FAULT:
|
||||||
// Find if PowerShell is available at its expected location
|
// Find if PowerShell is available at its expected location
|
||||||
|
@ -3105,7 +3103,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SCODE_CODE(FormatStatus) == ERROR_NOT_READY) {
|
if (SCODE_CODE(ErrorStatus) == ERROR_NOT_READY) {
|
||||||
// A port cycle usually helps with a device not ready
|
// A port cycle usually helps with a device not ready
|
||||||
int index = ComboBox_GetCurSel(hDeviceList);
|
int index = ComboBox_GetCurSel(hDeviceList);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -3113,10 +3111,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
CyclePort(index);
|
CyclePort(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notification(MSG_ERROR, NULL, NULL, lmprintf(MSG_042), lmprintf(MSG_043, StrError(FormatStatus, FALSE)));
|
Notification(MSG_ERROR, NULL, NULL, lmprintf(MSG_042), lmprintf(MSG_043, StrError(ErrorStatus, FALSE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
LastWriteError = 0;
|
LastWriteError = 0;
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
#define PERCENTAGE(percent, value) ((1ULL * (percent) * (value)) / 100ULL)
|
#define PERCENTAGE(percent, value) ((1ULL * (percent) * (value)) / 100ULL)
|
||||||
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
|
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
|
||||||
#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0)
|
#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0)
|
||||||
#define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) goto out
|
#define CHECK_FOR_USER_CANCEL if (IS_ERROR(ErrorStatus) && (SCODE_CODE(ErrorStatus) == ERROR_CANCELLED)) goto out
|
||||||
// Bit masks used for the display of additional image options in the UI
|
// Bit masks used for the display of additional image options in the UI
|
||||||
#define IMOP_WINTOGO 0x01
|
#define IMOP_WINTOGO 0x01
|
||||||
#define IMOP_PERSISTENCE 0x02
|
#define IMOP_PERSISTENCE 0x02
|
||||||
|
@ -664,7 +664,7 @@ extern HWND hMainDialog, hLogDialog, hStatus, hDeviceList, hCapacity, hImageOpti
|
||||||
extern HWND hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType;
|
extern HWND hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType;
|
||||||
extern HWND hNBPasses, hLog, hInfo, hProgress, hDiskID;
|
extern HWND hNBPasses, hLog, hInfo, hProgress, hDiskID;
|
||||||
extern WORD selected_langid;
|
extern WORD selected_langid;
|
||||||
extern DWORD FormatStatus, DownloadStatus, MainThreadId, LastWriteError;
|
extern DWORD ErrorStatus, DownloadStatus, MainThreadId, LastWriteError;
|
||||||
extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, op_in_progress, right_to_left_mode;
|
extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, op_in_progress, right_to_left_mode;
|
||||||
extern BOOL allow_dual_uefi_bios, large_drive, usb_debug;
|
extern BOOL allow_dual_uefi_bios, large_drive, usb_debug;
|
||||||
extern uint8_t image_options, *pe256ssp;
|
extern uint8_t image_options, *pe256ssp;
|
||||||
|
@ -896,3 +896,5 @@ out:
|
||||||
#define ERROR_CANT_MOUNT_VOLUME 0x120C
|
#define ERROR_CANT_MOUNT_VOLUME 0x120C
|
||||||
#define ERROR_BAD_SIGNATURE 0x120D
|
#define ERROR_BAD_SIGNATURE 0x120D
|
||||||
#define ERROR_CANT_DOWNLOAD 0x120E
|
#define ERROR_CANT_DOWNLOAD 0x120E
|
||||||
|
|
||||||
|
#define RUFUS_ERROR(err) (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | (err))
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 4.5.2120"
|
CAPTION "Rufus 4.5.2121"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -397,8 +397,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 4,5,2120,0
|
FILEVERSION 4,5,2121,0
|
||||||
PRODUCTVERSION 4,5,2120,0
|
PRODUCTVERSION 4,5,2121,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -416,13 +416,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "4.5.2120"
|
VALUE "FileVersion", "4.5.2121"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "<22> 2011-2024 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "<22> 2011-2024 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-4.5.exe"
|
VALUE "OriginalFilename", "rufus-4.5.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "4.5.2120"
|
VALUE "ProductVersion", "4.5.2121"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -830,7 +830,7 @@ DWORD RunCommandWithProgress(const char* cmd, const char* dir, BOOL log, int msg
|
||||||
UpdateProgressWithInfoInit(NULL, FALSE);
|
UpdateProgressWithInfoInit(NULL, FALSE);
|
||||||
while (1) {
|
while (1) {
|
||||||
// Check for user cancel
|
// Check for user cancel
|
||||||
if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) {
|
if (IS_ERROR(ErrorStatus) && (SCODE_CODE(ErrorStatus) == ERROR_CANCELLED)) {
|
||||||
if (!TerminateProcess(pi.hProcess, ERROR_CANCELLED)) {
|
if (!TerminateProcess(pi.hProcess, ERROR_CANCELLED)) {
|
||||||
uprintf("Could not terminate command: %s", WindowsErrorString());
|
uprintf("Could not terminate command: %s", WindowsErrorString());
|
||||||
} else switch (WaitForSingleObject(pi.hProcess, 5000)) {
|
} else switch (WaitForSingleObject(pi.hProcess, 5000)) {
|
||||||
|
|
|
@ -569,7 +569,7 @@ BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr
|
||||||
uprintf("Wrote %d bytes but requested %d", *lpNumberOfBytesWritten, nNumberOfBytesToWrite);
|
uprintf("Wrote %d bytes but requested %d", *lpNumberOfBytesWritten, nNumberOfBytesToWrite);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Write error %s", WindowsErrorString());
|
uprintf("Write error %s", WindowsErrorString());
|
||||||
LastWriteError = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|GetLastError();
|
LastWriteError = RUFUS_ERROR(GetLastError());
|
||||||
}
|
}
|
||||||
// If we can't reposition for the next run, just abort
|
// If we can't reposition for the next run, just abort
|
||||||
if (!readFilePointer)
|
if (!readFilePointer)
|
||||||
|
@ -581,7 +581,7 @@ BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SCODE_CODE(GetLastError()) == ERROR_SUCCESS)
|
if (SCODE_CODE(GetLastError()) == ERROR_SUCCESS)
|
||||||
SetLastError(ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT);
|
SetLastError(RUFUS_ERROR(ERROR_WRITE_FAULT));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ BOOL ExtractZip(const char* src_zip, const char* dest_dir)
|
||||||
if (src_zip == NULL)
|
if (src_zip == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
archive_size = _filesizeU(src_zip);
|
archive_size = _filesizeU(src_zip);
|
||||||
if (bled_init(256 * KB, NULL, NULL, NULL, update_progress, print_extracted_file, &FormatStatus) != 0)
|
if (bled_init(256 * KB, NULL, NULL, NULL, update_progress, print_extracted_file, &ErrorStatus) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
uprintf("● Copying files from '%s'", src_zip);
|
uprintf("● Copying files from '%s'", src_zip);
|
||||||
extracted_bytes = bled_uncompress_to_dir(src_zip, dest_dir, BLED_COMPRESSION_ZIP);
|
extracted_bytes = bled_uncompress_to_dir(src_zip, dest_dir, BLED_COMPRESSION_ZIP);
|
||||||
|
|
|
@ -121,7 +121,7 @@ char* FileDialog(BOOL save, char* path, const ext_t* ext, UINT* selected_ext)
|
||||||
hr = CoCreateInstance(save ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
|
hr = CoCreateInstance(save ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
|
||||||
&IID_IFileDialog, (LPVOID)&pfd);
|
&IID_IFileDialog, (LPVOID)&pfd);
|
||||||
if (SUCCEEDED(hr) && (pfd == NULL)) // Never trust Microsoft APIs to do the right thing
|
if (SUCCEEDED(hr) && (pfd == NULL)) // Never trust Microsoft APIs to do the right thing
|
||||||
hr = ERROR_SEVERITY_ERROR | FAC(FACILITY_WINDOWS) | ERROR_API_UNAVAILABLE;
|
hr = RUFUS_ERROR(ERROR_API_UNAVAILABLE);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
SetLastError(hr);
|
SetLastError(hr);
|
||||||
|
@ -1590,7 +1590,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
|
||||||
case IDC_DOWNLOAD: // Also doubles as abort and launch function
|
case IDC_DOWNLOAD: // Also doubles as abort and launch function
|
||||||
switch(download_status) {
|
switch(download_status) {
|
||||||
case 1: // Abort
|
case 1: // Abort
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;
|
ErrorStatus = RUFUS_ERROR(ERROR_CANCELLED);
|
||||||
download_status = 0;
|
download_status = 0;
|
||||||
hThread = NULL;
|
hThread = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -1653,7 +1653,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
|
||||||
case UM_PROGRESS_INIT:
|
case UM_PROGRESS_INIT:
|
||||||
EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
|
||||||
SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), lmprintf(MSG_038));
|
SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), lmprintf(MSG_038));
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
download_status = 1;
|
download_status = 1;
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
case UM_PROGRESS_EXIT:
|
case UM_PROGRESS_EXIT:
|
||||||
|
@ -1665,7 +1665,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
|
||||||
SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), lmprintf(MSG_040));
|
SetWindowTextU(GetDlgItem(hDlg, IDC_DOWNLOAD), lmprintf(MSG_040));
|
||||||
// Disable the download button if we found an invalid signature
|
// Disable the download button if we found an invalid signature
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_DOWNLOAD),
|
EnableWindow(GetDlgItem(hDlg, IDC_DOWNLOAD),
|
||||||
FormatStatus != (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_BAD_SIGNATURE)));
|
ErrorStatus != RUFUS_ERROR(APPERR(ERROR_BAD_SIGNATURE)));
|
||||||
download_status = 0;
|
download_status = 0;
|
||||||
}
|
}
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* Copyright 2003 Lars Munch Christensen - All Rights Reserved
|
* Copyright 2003 Lars Munch Christensen - All Rights Reserved
|
||||||
* Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
|
* Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
|
||||||
* Copyright 2012-2023 Pete Batard
|
* Copyright 2012-2024 Pete Batard
|
||||||
*
|
*
|
||||||
* Based on the Linux installer program for SYSLINUX by H. Peter Anvin
|
* Based on the Linux installer program for SYSLINUX by H. Peter Anvin
|
||||||
*
|
*
|
||||||
|
@ -88,7 +88,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
|
||||||
const LARGE_INTEGER liZero = { {0, 0} };
|
const LARGE_INTEGER liZero = { {0, 0} };
|
||||||
HANDLE f_handle = INVALID_HANDLE_VALUE;
|
HANDLE f_handle = INVALID_HANDLE_VALUE;
|
||||||
HANDLE d_handle = INVALID_HANDLE_VALUE;
|
HANDLE d_handle = INVALID_HANDLE_VALUE;
|
||||||
DWORD bytes_read, bytes_written, err;
|
DWORD bytes_read, err;
|
||||||
S_NTFSSECT_VOLINFO vol_info = { 0 };
|
S_NTFSSECT_VOLINFO vol_info = { 0 };
|
||||||
LARGE_INTEGER vcn, lba, len;
|
LARGE_INTEGER vcn, lba, len;
|
||||||
S_NTFSSECT_EXTENT extent;
|
S_NTFSSECT_EXTENT extent;
|
||||||
|
@ -208,12 +208,11 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
|
||||||
|
|
||||||
/* Write ldlinux.sys file */
|
/* Write ldlinux.sys file */
|
||||||
if (!WriteFileWithRetry(f_handle, (const char _force *)syslinux_ldlinux[0],
|
if (!WriteFileWithRetry(f_handle, (const char _force *)syslinux_ldlinux[0],
|
||||||
syslinux_ldlinux_len[0], &bytes_written, WRITE_RETRIES)) {
|
syslinux_ldlinux_len[0], NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write '%s': %s", &path[3], WindowsErrorString());
|
uprintf("Could not write '%s': %s", &path[3], WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!WriteFileWithRetry(f_handle, syslinux_adv, 2 * ADV_SIZE,
|
if (!WriteFileWithRetry(f_handle, syslinux_adv, 2 * ADV_SIZE, NULL, WRITE_RETRIES)) {
|
||||||
&bytes_written, WRITE_RETRIES)) {
|
|
||||||
uprintf("Could not write ADV to '%s': %s", &path[3], WindowsErrorString());
|
uprintf("Could not write ADV to '%s': %s", &path[3], WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -302,8 +301,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
|
||||||
|
|
||||||
/* Rewrite the file */
|
/* Rewrite the file */
|
||||||
if (!SetFilePointerEx(f_handle, liZero, NULL, FILE_BEGIN) ||
|
if (!SetFilePointerEx(f_handle, liZero, NULL, FILE_BEGIN) ||
|
||||||
!WriteFileWithRetry(f_handle, syslinux_ldlinux[0], syslinux_ldlinux_len[0],
|
!WriteFileWithRetry(f_handle, syslinux_ldlinux[0], syslinux_ldlinux_len[0], NULL, WRITE_RETRIES)) {
|
||||||
&bytes_written, WRITE_RETRIES)) {
|
|
||||||
uprintf("Could not rewrite '%s': %s\n", &path[3], WindowsErrorString());
|
uprintf("Could not rewrite '%s': %s\n", &path[3], WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -328,8 +326,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
|
||||||
|
|
||||||
/* Write boot sector back */
|
/* Write boot sector back */
|
||||||
if (!SetFilePointerEx(d_handle, liZero, NULL, FILE_BEGIN) ||
|
if (!SetFilePointerEx(d_handle, liZero, NULL, FILE_BEGIN) ||
|
||||||
!WriteFileWithRetry(d_handle, sectbuf, SECTOR_SIZE,
|
!WriteFileWithRetry(d_handle, sectbuf, SECTOR_SIZE, NULL, WRITE_RETRIES)) {
|
||||||
&bytes_written, WRITE_RETRIES)) {
|
|
||||||
uprintf("Could not write Syslinux boot record: %s", WindowsErrorString());
|
uprintf("Could not write Syslinux boot record: %s", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -368,8 +365,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
|
||||||
uprintf("Unable to create '%s'\n", path);
|
uprintf("Unable to create '%s'\n", path);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!WriteFileWithRetry(f_handle, syslinux_mboot, syslinux_mboot_len,
|
if (!WriteFileWithRetry(f_handle, syslinux_mboot, syslinux_mboot_len, NULL, WRITE_RETRIES)) {
|
||||||
&bytes_written, WRITE_RETRIES)) {
|
|
||||||
uprintf("Could not write '%s'", path);
|
uprintf("Could not write '%s'", path);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
22
src/vhd.c
22
src/vhd.c
|
@ -120,9 +120,9 @@ static int8_t IsCompressedBootableImage(const char* path)
|
||||||
buf = malloc(MBR_SIZE);
|
buf = malloc(MBR_SIZE);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
if (img_report.compression_type < BLED_COMPRESSION_MAX) {
|
if (img_report.compression_type < BLED_COMPRESSION_MAX) {
|
||||||
bled_init(0, uprintf, NULL, NULL, NULL, NULL, &FormatStatus);
|
bled_init(0, uprintf, NULL, NULL, NULL, NULL, &ErrorStatus);
|
||||||
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
|
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
} else if (img_report.compression_type == BLED_COMPRESSION_MAX) {
|
} else if (img_report.compression_type == BLED_COMPRESSION_MAX) {
|
||||||
|
@ -258,7 +258,7 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
|
||||||
UpdateProgressWithInfo(progress_op, progress_msg, wim_proc_files, wim_nb_files);
|
UpdateProgressWithInfo(progress_op, progress_msg, wim_proc_files, wim_nb_files);
|
||||||
}
|
}
|
||||||
// Halt on error
|
// Halt on error
|
||||||
if (IS_ERROR(FormatStatus)) {
|
if (IS_ERROR(ErrorStatus)) {
|
||||||
pbCancel = (PBOOL)lParam;
|
pbCancel = (PBOOL)lParam;
|
||||||
*pbCancel = TRUE;
|
*pbCancel = TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -291,7 +291,7 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IS_ERROR(FormatStatus) ? WIM_MSG_ABORT_IMAGE : WIM_MSG_SUCCESS;
|
return IS_ERROR(ErrorStatus) ? WIM_MSG_ABORT_IMAGE : WIM_MSG_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out if we have any way to extract/apply WIM files on this platform
|
// Find out if we have any way to extract/apply WIM files on this platform
|
||||||
|
@ -1062,7 +1062,7 @@ static DWORD WINAPI VhdSaveImageThread(void* param)
|
||||||
|
|
||||||
if (r == ERROR_IO_PENDING) {
|
if (r == ERROR_IO_PENDING) {
|
||||||
while ((r = WaitForSingleObject(overlapped.hEvent, 100)) == WAIT_TIMEOUT) {
|
while ((r = WaitForSingleObject(overlapped.hEvent, 100)) == WAIT_TIMEOUT) {
|
||||||
if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) {
|
if (IS_ERROR(ErrorStatus) && (SCODE_CODE(ErrorStatus) == ERROR_CANCELLED)) {
|
||||||
CancelIoEx(handle, &overlapped);
|
CancelIoEx(handle, &overlapped);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1110,10 +1110,10 @@ static DWORD WINAPI FfuSaveImageThread(void* param)
|
||||||
img_save->DevicePath, img_save->ImagePath, label, APPLICATION_NAME, RUFUS_URL);
|
img_save->DevicePath, img_save->ImagePath, label, APPLICATION_NAME, RUFUS_URL);
|
||||||
uprintf("Running command: '%s", cmd);
|
uprintf("Running command: '%s", cmd);
|
||||||
r = RunCommandWithProgress(cmd, sysnative_dir, TRUE, MSG_261);
|
r = RunCommandWithProgress(cmd, sysnative_dir, TRUE, MSG_261);
|
||||||
if (r != 0 && !IS_ERROR(FormatStatus)) {
|
if (r != 0 && !IS_ERROR(ErrorStatus)) {
|
||||||
SetLastError(r);
|
SetLastError(r);
|
||||||
uprintf("Failed to capture FFU image: %s", WindowsErrorString());
|
uprintf("Failed to capture FFU image: %s", WindowsErrorString());
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_WINDOWS) | SCODE_CODE(r);
|
ErrorStatus = RUFUS_ERROR(SCODE_CODE(r));
|
||||||
}
|
}
|
||||||
safe_free(img_save->DevicePath);
|
safe_free(img_save->DevicePath);
|
||||||
safe_free(img_save->ImagePath);
|
safe_free(img_save->ImagePath);
|
||||||
|
@ -1172,21 +1172,21 @@ void VhdSaveImage(void)
|
||||||
if (img_save.DevicePath != NULL && img_save.ImagePath != NULL) {
|
if (img_save.DevicePath != NULL && img_save.ImagePath != NULL) {
|
||||||
// Reset all progress bars
|
// Reset all progress bars
|
||||||
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
SendMessage(hMainDialog, UM_PROGRESS_INIT, 0, 0);
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
if (img_save.Type == VIRTUAL_STORAGE_TYPE_DEVICE_VHD) {
|
if (img_save.Type == VIRTUAL_STORAGE_TYPE_DEVICE_VHD) {
|
||||||
free_space.QuadPart = 0;
|
free_space.QuadPart = 0;
|
||||||
if ((GetVolumePathNameA(img_save.ImagePath, path, sizeof(path)))
|
if ((GetVolumePathNameA(img_save.ImagePath, path, sizeof(path)))
|
||||||
&& (GetDiskFreeSpaceExA(path, &free_space, NULL, NULL))
|
&& (GetDiskFreeSpaceExA(path, &free_space, NULL, NULL))
|
||||||
&& ((LONGLONG)free_space.QuadPart < (SelectedDrive.DiskSize + 512))) {
|
&& ((LONGLONG)free_space.QuadPart < (SelectedDrive.DiskSize + 512))) {
|
||||||
uprintf("The VHD size is too large for the target drive");
|
uprintf("The VHD size is too large for the target drive");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_FILE_TOO_LARGE;
|
ErrorStatus = RUFUS_ERROR(ERROR_FILE_TOO_LARGE);
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Disable all controls except Cancel
|
// Disable all controls except Cancel
|
||||||
EnableControls(FALSE, FALSE);
|
EnableControls(FALSE, FALSE);
|
||||||
FormatStatus = 0;
|
ErrorStatus = 0;
|
||||||
InitProgress(TRUE);
|
InitProgress(TRUE);
|
||||||
format_thread = CreateThread(NULL, 0, img_save.Type == VIRTUAL_STORAGE_TYPE_DEVICE_FFU ?
|
format_thread = CreateThread(NULL, 0, img_save.Type == VIRTUAL_STORAGE_TYPE_DEVICE_FFU ?
|
||||||
FfuSaveImageThread : VhdSaveImageThread, &img_save, 0, NULL);
|
FfuSaveImageThread : VhdSaveImageThread, &img_save, 0, NULL);
|
||||||
|
@ -1196,7 +1196,7 @@ void VhdSaveImage(void)
|
||||||
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
SendMessage(hMainDialog, UM_TIMER_START, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Unable to start VHD save thread");
|
uprintf("Unable to start VHD save thread");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_START_THREAD));
|
||||||
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
src/wue.c
18
src/wue.c
|
@ -263,7 +263,7 @@ BOOL SetupWinPE(char drive_letter)
|
||||||
const LARGE_INTEGER liZero = { {0, 0} };
|
const LARGE_INTEGER liZero = { {0, 0} };
|
||||||
char setupsrcdev[64];
|
char setupsrcdev[64];
|
||||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||||
DWORD i, j, size, rw_size, index = 0;
|
DWORD i, j, size, read_size, index = 0;
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE;
|
||||||
char* buffer = NULL;
|
char* buffer = NULL;
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ BOOL SetupWinPE(char drive_letter)
|
||||||
buffer = (char*)malloc(size);
|
buffer = (char*)malloc(size);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
if ((!ReadFile(handle, buffer, size, &rw_size, NULL)) || (size != rw_size)) {
|
if ((!ReadFile(handle, buffer, size, &read_size, NULL)) || (size != read_size)) {
|
||||||
uprintf("Could not read file %s: %s\n", dst, WindowsErrorString());
|
uprintf("Could not read file %s: %s\n", dst, WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ BOOL SetupWinPE(char drive_letter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WriteFileWithRetry(handle, buffer, size, &rw_size, WRITE_RETRIES)) {
|
if (!WriteFileWithRetry(handle, buffer, size, NULL, WRITE_RETRIES)) {
|
||||||
uprintf("Could not write patched file: %s\n", WindowsErrorString());
|
uprintf("Could not write patched file: %s\n", WindowsErrorString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
|
||||||
uprintf("Windows To Go mode selected");
|
uprintf("Windows To Go mode selected");
|
||||||
// Additional sanity checks
|
// Additional sanity checks
|
||||||
if ((use_esp) && (SelectedDrive.MediaType != FixedMedia) && (WindowsVersion.BuildNumber < 15000)) {
|
if ((use_esp) && (SelectedDrive.MediaType != FixedMedia) && (WindowsVersion.BuildNumber < 15000)) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_SUPPORTED;
|
ErrorStatus = RUFUS_ERROR(ERROR_NOT_SUPPORTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
|
||||||
mounted_iso = VhdMountImage(image_path);
|
mounted_iso = VhdMountImage(image_path);
|
||||||
if (mounted_iso == NULL) {
|
if (mounted_iso == NULL) {
|
||||||
uprintf("Could not mount ISO for Windows To Go installation");
|
uprintf("Could not mount ISO for Windows To Go installation");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_ISO_EXTRACT);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_ISO_EXTRACT));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static_sprintf(mounted_image_path, "%s%s", mounted_iso, &img_report.wininst_path[wininst_index][2]);
|
static_sprintf(mounted_image_path, "%s%s", mounted_iso, &img_report.wininst_path[wininst_index][2]);
|
||||||
|
@ -668,8 +668,8 @@ BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
|
||||||
// Now we use the WIM API to apply that image
|
// Now we use the WIM API to apply that image
|
||||||
if (!WimApplyImage(img_report.is_windows_img ? image_path : mounted_image_path, wintogo_index, drive_name)) {
|
if (!WimApplyImage(img_report.is_windows_img ? image_path : mounted_image_path, wintogo_index, drive_name)) {
|
||||||
uprintf("Failed to apply Windows To Go image");
|
uprintf("Failed to apply Windows To Go image");
|
||||||
if (!IS_ERROR(FormatStatus))
|
if (!IS_ERROR(ErrorStatus))
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_ISO_EXTRACT);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_ISO_EXTRACT));
|
||||||
if (!img_report.is_windows_img)
|
if (!img_report.is_windows_img)
|
||||||
VhdUnmountImage();
|
VhdUnmountImage();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -702,7 +702,7 @@ BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
|
||||||
// Need to have the ESP mounted to invoke bcdboot
|
// Need to have the ESP mounted to invoke bcdboot
|
||||||
ms_efi = AltMountVolume(DriveIndex, SelectedDrive.Partition[partition_index[PI_ESP]].Offset, FALSE);
|
ms_efi = AltMountVolume(DriveIndex, SelectedDrive.Partition[partition_index[PI_ESP]].Offset, FALSE);
|
||||||
if (ms_efi == NULL) {
|
if (ms_efi == NULL) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_ASSIGN_LETTER);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_CANT_ASSIGN_LETTER));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ BOOL SetupWinToGo(DWORD DriveIndex, const char* drive_name, BOOL use_esp)
|
||||||
if (RunCommand(cmd, sysnative_dir, usb_debug) != 0) {
|
if (RunCommand(cmd, sysnative_dir, usb_debug) != 0) {
|
||||||
// Try to continue... but report a failure
|
// Try to continue... but report a failure
|
||||||
uprintf("Failed to enable boot");
|
uprintf("Failed to enable boot");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_ISO_EXTRACT);
|
ErrorStatus = RUFUS_ERROR(APPERR(ERROR_ISO_EXTRACT));
|
||||||
}
|
}
|
||||||
|
|
||||||
CopySKUSiPolicy((use_esp) ? ms_efi : drive_name);
|
CopySKUSiPolicy((use_esp) ? ms_efi : drive_name);
|
||||||
|
|
Loading…
Reference in a new issue