"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/vhd.c" between
rufus-3.12.tar.gz and rufus-3.13.tar.gz

About: Rufus is a utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks, etc (for Linux and Windows).

vhd.c  (rufus-3.12):vhd.c  (rufus-3.13)
skipping to change at line 114 skipping to change at line 114
PF_TYPE_DECL(WINAPI, BOOL, WIMExtractImagePath, (HANDLE, PWSTR, PWSTR, DWORD)); PF_TYPE_DECL(WINAPI, BOOL, WIMExtractImagePath, (HANDLE, PWSTR, PWSTR, DWORD));
PF_TYPE_DECL(WINAPI, BOOL, WIMGetImageInformation, (HANDLE, PVOID, PDWORD)); PF_TYPE_DECL(WINAPI, BOOL, WIMGetImageInformation, (HANDLE, PVOID, PDWORD));
PF_TYPE_DECL(WINAPI, BOOL, WIMCloseHandle, (HANDLE)); PF_TYPE_DECL(WINAPI, BOOL, WIMCloseHandle, (HANDLE));
PF_TYPE_DECL(WINAPI, DWORD, WIMRegisterMessageCallback, (HANDLE, FARPROC, PVOID) ); PF_TYPE_DECL(WINAPI, DWORD, WIMRegisterMessageCallback, (HANDLE, FARPROC, PVOID) );
PF_TYPE_DECL(WINAPI, DWORD, WIMUnregisterMessageCallback, (HANDLE, FARPROC)); PF_TYPE_DECL(WINAPI, DWORD, WIMUnregisterMessageCallback, (HANDLE, FARPROC));
PF_TYPE_DECL(RPC_ENTRY, RPC_STATUS, UuidCreate, (UUID __RPC_FAR*)); PF_TYPE_DECL(RPC_ENTRY, RPC_STATUS, UuidCreate, (UUID __RPC_FAR*));
uint32_t wim_nb_files, wim_proc_files, wim_extra_files; uint32_t wim_nb_files, wim_proc_files, wim_extra_files;
HANDLE apply_wim_thread = NULL; HANDLE apply_wim_thread = NULL;
extern int default_thread_priority; extern int default_thread_priority;
extern BOOL ignore_boot_marker;
static uint8_t wim_flags = 0; static uint8_t wim_flags = 0;
static wchar_t wmount_path[MAX_PATH] = { 0 }; static wchar_t wmount_path[MAX_PATH] = { 0 };
static char sevenzip_path[MAX_PATH]; static char sevenzip_path[MAX_PATH];
static const char conectix_str[] = VHD_FOOTER_COOKIE; static const char conectix_str[] = VHD_FOOTER_COOKIE;
static BOOL count_files; static BOOL count_files;
static BOOL Get7ZipPath(void) static BOOL Get7ZipPath(void)
{ {
if ( (GetRegistryKeyStr(REGKEY_HKCU, "7-Zip\\Path", sevenzip_path, sizeof (sevenzip_path))) if ( (GetRegistryKeyStr(REGKEY_HKCU, "7-Zip\\Path", sevenzip_path, sizeof (sevenzip_path)))
skipping to change at line 280 skipping to change at line 281
} }
r = (buf[0x1FE] == 0x55) && (buf[0x1FF] == 0xAA); r = (buf[0x1FE] == 0x55) && (buf[0x1FF] == 0xAA);
free(buf); free(buf);
return r; return r;
} }
} }
return FALSE; return FALSE;
} }
BOOL IsBootableImage(const char* path) // 0: non-bootable, 1: bootable, 2: forced bootable
uint8_t IsBootableImage(const char* path)
{ {
HANDLE handle = INVALID_HANDLE_VALUE; HANDLE handle = INVALID_HANDLE_VALUE;
LARGE_INTEGER liImageSize; LARGE_INTEGER liImageSize;
vhd_footer* footer = NULL; vhd_footer* footer = NULL;
DWORD size; DWORD size;
size_t i; size_t i;
uint32_t checksum, old_checksum; uint32_t checksum, old_checksum;
uint64_t wim_magic = 0; uint64_t wim_magic = 0;
LARGE_INTEGER ptr = { 0 }; LARGE_INTEGER ptr = { 0 };
BOOL is_bootable_img = FALSE; uint8_t is_bootable_img = 0;
uprintf("Disk image analysis:"); uprintf("Disk image analysis:");
handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE) { if (handle == INVALID_HANDLE_VALUE) {
uprintf(" Could not open image '%s'", path); uprintf(" Could not open image '%s'", path);
goto out; goto out;
} }
is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path); is_bootable_img = IsCompressedBootableImage(path) ? 1 : 0;
if (img_report.compression_type == BLED_COMPRESSION_NONE) if (img_report.compression_type == BLED_COMPRESSION_NONE)
is_bootable_img = (BOOLEAN)AnalyzeMBR(handle, " Image", FALSE); is_bootable_img = AnalyzeMBR(handle, " Image", FALSE) ? 1 : (ign ore_boot_marker ? 2 : 0);
if (!GetFileSizeEx(handle, &liImageSize)) { if (!GetFileSizeEx(handle, &liImageSize)) {
uprintf(" Could not get image size: %s", WindowsErrorString()); uprintf(" Could not get image size: %s", WindowsErrorString());
goto out; goto out;
} }
img_report.image_size = (uint64_t)liImageSize.QuadPart; img_report.image_size = (uint64_t)liImageSize.QuadPart;
size = sizeof(wim_magic); size = sizeof(wim_magic);
IGNORE_RETVAL(SetFilePointerEx(handle, ptr, NULL, FILE_BEGIN)); IGNORE_RETVAL(SetFilePointerEx(handle, ptr, NULL, FILE_BEGIN));
img_report.is_windows_img = ReadFile(handle, &wim_magic, size, &size, NUL L) && (wim_magic == WIM_MAGIC); img_report.is_windows_img = ReadFile(handle, &wim_magic, size, &size, NUL L) && (wim_magic == WIM_MAGIC);
if (img_report.is_windows_img) if (img_report.is_windows_img)
skipping to change at line 329 skipping to change at line 331
if ( (footer == NULL) || (!SetFilePointerEx(handle, ptr, NULL, FI LE_BEGIN)) || if ( (footer == NULL) || (!SetFilePointerEx(handle, ptr, NULL, FI LE_BEGIN)) ||
(!ReadFile(handle, footer, size, &size, NULL)) || (size != sizeof(vhd_footer)) ) { (!ReadFile(handle, footer, size, &size, NULL)) || (size != sizeof(vhd_footer)) ) {
uprintf(" Could not read VHD footer"); uprintf(" Could not read VHD footer");
goto out; goto out;
} }
if (memcmp(footer->cookie, conectix_str, sizeof(footer->cookie)) == 0) { if (memcmp(footer->cookie, conectix_str, sizeof(footer->cookie)) == 0) {
img_report.image_size -= sizeof(vhd_footer); img_report.image_size -= sizeof(vhd_footer);
if ( (bswap_uint32(footer->file_format_version) != VHD_FO OTER_FILE_FORMAT_V1_0) if ( (bswap_uint32(footer->file_format_version) != VHD_FO OTER_FILE_FORMAT_V1_0)
|| (bswap_uint32(footer->disk_type) != VHD_FOOTER_TYPE_ FIXED_HARD_DISK)) { || (bswap_uint32(footer->disk_type) != VHD_FOOTER_TYPE_ FIXED_HARD_DISK)) {
uprintf(" Unsupported type of VHD image"); uprintf(" Unsupported type of VHD image");
is_bootable_img = FALSE; is_bootable_img = 0;
goto out; goto out;
} }
// Might as well validate the checksum while we're at it // Might as well validate the checksum while we're at it
old_checksum = bswap_uint32(footer->checksum); old_checksum = bswap_uint32(footer->checksum);
footer->checksum = 0; footer->checksum = 0;
for (checksum=0, i=0; i<sizeof(vhd_footer); i++) for (checksum=0, i=0; i<sizeof(vhd_footer); i++)
checksum += ((uint8_t*)footer)[i]; checksum += ((uint8_t*)footer)[i];
checksum = ~checksum; checksum = ~checksum;
if (checksum != old_checksum) if (checksum != old_checksum)
uprintf(" Warning: VHD footer seems corrupted (c hecksum: %04X, expected: %04X)", old_checksum, checksum); uprintf(" Warning: VHD footer seems corrupted (c hecksum: %04X, expected: %04X)", old_checksum, checksum);
skipping to change at line 750 skipping to change at line 752
goto out; goto out;
} }
hImage = pfWIMLoadImage(hWim, (DWORD)_index); hImage = pfWIMLoadImage(hWim, (DWORD)_index);
if (hImage == NULL) { if (hImage == NULL) {
uprintf(" Could not set index: %s", WindowsErrorString()); uprintf(" Could not set index: %s", WindowsErrorString());
goto out; goto out;
} }
uprintf("Applying Windows image..."); uprintf("Applying Windows image...");
UpdateProgressWithInfoInit(NULL, TRUE);
// Run a first pass using WIM_FLAG_NO_APPLY to count the files // Run a first pass using WIM_FLAG_NO_APPLY to count the files
wim_nb_files = 0; wim_nb_files = 0;
wim_proc_files = 0; wim_proc_files = 0;
wim_extra_files = 0; wim_extra_files = 0;
count_files = TRUE; count_files = TRUE;
if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_NO_APPLY)) { if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_NO_APPLY)) {
uprintf(" Could not count the files to apply: %s", WindowsErrorS tring()); uprintf(" Could not count the files to apply: %s", WindowsErrorS tring());
goto out; goto out;
} }
// The latest Windows 10 ISOs have a ~17.5% discrepancy between the numbe r of // The latest Windows 10 ISOs have a ~17.5% discrepancy between the numbe r of
 End of changes. 7 change blocks. 
5 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)