mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[misc] add missing.h header
* Also clean up code
This commit is contained in:
		
							parent
							
								
									d3c9afa2fd
								
							
						
					
					
						commit
						c3f47ada06
					
				
					 23 changed files with 289 additions and 258 deletions
				
			
		|  | @ -209,6 +209,7 @@ | ||||||
|     <ClInclude Include="..\drive.h" /> |     <ClInclude Include="..\drive.h" /> | ||||||
|     <ClInclude Include="..\format.h" /> |     <ClInclude Include="..\format.h" /> | ||||||
|     <ClInclude Include="..\hdd_vs_ufd.h" /> |     <ClInclude Include="..\hdd_vs_ufd.h" /> | ||||||
|  |     <ClInclude Include="..\missing.h" /> | ||||||
|     <ClInclude Include="..\settings.h" /> |     <ClInclude Include="..\settings.h" /> | ||||||
|     <ClInclude Include="..\libcdio\cdio\cdio.h" /> |     <ClInclude Include="..\libcdio\cdio\cdio.h" /> | ||||||
|     <ClInclude Include="..\libcdio\cdio\iso9660.h" /> |     <ClInclude Include="..\libcdio\cdio\iso9660.h" /> | ||||||
|  |  | ||||||
|  | @ -137,6 +137,9 @@ | ||||||
|     <ClInclude Include="..\settings.h"> |     <ClInclude Include="..\settings.h"> | ||||||
|       <Filter>Header Files</Filter> |       <Filter>Header Files</Filter> | ||||||
|     </ClInclude> |     </ClInclude> | ||||||
|  |     <ClInclude Include="..\missing.h"> | ||||||
|  |       <Filter>Header Files</Filter> | ||||||
|  |     </ClInclude> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <None Include="..\..\res\rufus.ico"> |     <None Include="..\..\res\rufus.ico"> | ||||||
|  |  | ||||||
|  | @ -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-2015 by Pete Batard |  * Copyright 2011-2016 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> | ||||||
|  | @ -42,11 +42,12 @@ | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
|  | #include "localization.h" | ||||||
|  | 
 | ||||||
| #include "badblocks.h" | #include "badblocks.h" | ||||||
| #include "file.h" | #include "file.h" | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "resource.h" |  | ||||||
| #include "localization.h" |  | ||||||
| 
 | 
 | ||||||
| FILE* log_fd = NULL; | FILE* log_fd = NULL; | ||||||
| static const char* abort_msg = "Too many bad blocks, aborting test\n"; | static const char* abort_msg = "Too many bad blocks, aborting test\n"; | ||||||
|  | @ -257,7 +258,7 @@ static bb_badblocks_iterate bb_iter = NULL; | ||||||
| static __inline void *allocate_buffer(size_t size) { | static __inline void *allocate_buffer(size_t size) { | ||||||
| #ifdef __MINGW32__ | #ifdef __MINGW32__ | ||||||
| 	return __mingw_aligned_malloc(size, BB_SYS_PAGE_SIZE); | 	return __mingw_aligned_malloc(size, BB_SYS_PAGE_SIZE); | ||||||
| #else  | #else | ||||||
| 	return _aligned_malloc(size, BB_SYS_PAGE_SIZE); | 	return _aligned_malloc(size, BB_SYS_PAGE_SIZE); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -51,9 +51,10 @@ | ||||||
| #include <inttypes.h> | #include <inttypes.h> | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <windowsx.h> | #include <windowsx.h> | ||||||
| #include "msapi_utf8.h" | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
| #undef BIG_ENDIAN_HOST | #undef BIG_ENDIAN_HOST | ||||||
|  |  | ||||||
|  | @ -31,9 +31,10 @@ | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "dos.h" |  | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
| 
 | 
 | ||||||
|  | #include "dos.h" | ||||||
|  | 
 | ||||||
| static BYTE* DiskImage = NULL; | static BYTE* DiskImage = NULL; | ||||||
| static DWORD DiskImageSize; | static DWORD DiskImageSize; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								src/drive.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/drive.c
									
										
									
									
									
								
							|  | @ -26,17 +26,19 @@ | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "missing.h" | ||||||
|  | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
|  | #include "localization.h" | ||||||
|  | 
 | ||||||
| #include "file.h" | #include "file.h" | ||||||
| #include "drive.h" | #include "drive.h" | ||||||
| #include "resource.h" |  | ||||||
| #include "sys_types.h" | #include "sys_types.h" | ||||||
| #include "br.h" | #include "br.h" | ||||||
| #include "fat16.h" | #include "fat16.h" | ||||||
| #include "fat32.h" | #include "fat32.h" | ||||||
| #include "ntfs.h" | #include "ntfs.h" | ||||||
| #include "localization.h" |  | ||||||
| 
 | 
 | ||||||
| #if !defined(PARTITION_BASIC_DATA_GUID) | #if !defined(PARTITION_BASIC_DATA_GUID) | ||||||
| const GUID PARTITION_BASIC_DATA_GUID = | const GUID PARTITION_BASIC_DATA_GUID = | ||||||
|  | @ -1045,7 +1047,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m | ||||||
| 	// Compute the start offset of our first partition
 | 	// Compute the start offset of our first partition
 | ||||||
| 	if ((partition_style == PARTITION_STYLE_GPT) || (!IsChecked(IDC_EXTRA_PARTITION))) { | 	if ((partition_style == PARTITION_STYLE_GPT) || (!IsChecked(IDC_EXTRA_PARTITION))) { | ||||||
| 		// Go with the MS 1 MB wastage at the beginning...
 | 		// Go with the MS 1 MB wastage at the beginning...
 | ||||||
| 		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = 1024*1024; | 		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = MB; | ||||||
| 	} else { | 	} else { | ||||||
| 		// Align on Cylinder
 | 		// Align on Cylinder
 | ||||||
| 		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = bytes_per_track; | 		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = bytes_per_track; | ||||||
|  | @ -1054,7 +1056,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m | ||||||
| 	// If required, set the MSR partition (GPT only - must be created before the data part)
 | 	// If required, set the MSR partition (GPT only - must be created before the data part)
 | ||||||
| 	if ((partition_style == PARTITION_STYLE_GPT) && (extra_partitions & XP_MSR)) { | 	if ((partition_style == PARTITION_STYLE_GPT) && (extra_partitions & XP_MSR)) { | ||||||
| 		uprintf("Adding MSR partition"); | 		uprintf("Adding MSR partition"); | ||||||
| 		DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*1024*1024; | 		DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*MB; | ||||||
| 		DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MSFT_RESERVED_GUID; | 		DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MSFT_RESERVED_GUID; | ||||||
| 		IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId)); | 		IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId)); | ||||||
| 		// coverity[strcpy_overrun]
 | 		// coverity[strcpy_overrun]
 | ||||||
|  | @ -1090,11 +1092,11 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m | ||||||
| 			// The size of the EFI partition depends on the minimum size we're able to format in FAT32,
 | 			// The size of the EFI partition depends on the minimum size we're able to format in FAT32,
 | ||||||
| 			// which in turn depends on the cluster size used, which in turn depends on the disk sector size.
 | 			// which in turn depends on the cluster size used, which in turn depends on the disk sector size.
 | ||||||
| 			if (SelectedDrive.Geometry.BytesPerSector <= 1024) | 			if (SelectedDrive.Geometry.BytesPerSector <= 1024) | ||||||
| 				ms_efi_size = 100*1024*1024; | 				ms_efi_size = 100*MB; | ||||||
| 			else if (SelectedDrive.Geometry.BytesPerSector <= 4096) | 			else if (SelectedDrive.Geometry.BytesPerSector <= 4096) | ||||||
| 				ms_efi_size = 300*1024*1024; | 				ms_efi_size = 300*MB; | ||||||
| 			else | 			else | ||||||
| 				ms_efi_size = 1200*1024*1024;	// That'll teach you to have a nonstandard disk!
 | 				ms_efi_size = 1200*MB;	// That'll teach you to have a nonstandard disk!
 | ||||||
| 			extra_part_size_in_tracks = (ms_efi_size + bytes_per_track - 1) / bytes_per_track; | 			extra_part_size_in_tracks = (ms_efi_size + bytes_per_track - 1) / bytes_per_track; | ||||||
| 		} else if (extra_partitions & XP_UEFI_NTFS) | 		} else if (extra_partitions & XP_UEFI_NTFS) | ||||||
| 			extra_part_size_in_tracks = (MIN_EXTRA_PART_SIZE + bytes_per_track - 1) / bytes_per_track; | 			extra_part_size_in_tracks = (MIN_EXTRA_PART_SIZE + bytes_per_track - 1) / bytes_per_track; | ||||||
|  |  | ||||||
|  | @ -32,9 +32,12 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <locale.h> | #include <locale.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "missing.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
|  | #include "localization.h" | ||||||
|  | 
 | ||||||
| #include "br.h" | #include "br.h" | ||||||
| #include "fat16.h" | #include "fat16.h" | ||||||
| #include "fat32.h" | #include "fat32.h" | ||||||
|  | @ -44,7 +47,6 @@ | ||||||
| #include "drive.h" | #include "drive.h" | ||||||
| #include "format.h" | #include "format.h" | ||||||
| #include "badblocks.h" | #include "badblocks.h" | ||||||
| #include "localization.h" |  | ||||||
| #include "bled/bled.h" | #include "bled/bled.h" | ||||||
| #include "../res/grub/grub_version.h" | #include "../res/grub/grub_version.h" | ||||||
| 
 | 
 | ||||||
|  | @ -999,7 +1001,7 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive) | ||||||
| 	set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); | 	set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector); | ||||||
| 	// Ensure that we have sufficient space for the SBR
 | 	// Ensure that we have sufficient space for the SBR
 | ||||||
| 	max_size = IsChecked(IDC_EXTRA_PARTITION) ? | 	max_size = IsChecked(IDC_EXTRA_PARTITION) ? | ||||||
| 		(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1024 * 1024; | 		(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1*MB; | ||||||
| 	max_size -= mbr_size; | 	max_size -= mbr_size; | ||||||
| 	// Syslinux has precedence over Grub
 | 	// Syslinux has precedence over Grub
 | ||||||
| 	if ((bt == BT_ISO) && (!HAS_SYSLINUX(img_report))) { | 	if ((bt == BT_ISO) && (!HAS_SYSLINUX(img_report))) { | ||||||
|  |  | ||||||
|  | @ -27,9 +27,9 @@ | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| 
 | 
 | ||||||
| #pragma pack(push) | #pragma pack(push) | ||||||
| #pragma pack(2) | #pragma pack(2) | ||||||
|  |  | ||||||
							
								
								
									
										87
									
								
								src/iso.c
									
										
									
									
									
								
							
							
						
						
									
										87
									
								
								src/iso.c
									
										
									
									
									
								
							|  | @ -39,8 +39,9 @@ | ||||||
| #include <cdio/udf.h> | #include <cdio/udf.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "msapi_utf8.h" | #include "missing.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
| // How often should we update the progress bar (in 2K blocks) as updating
 | // How often should we update the progress bar (in 2K blocks) as updating
 | ||||||
|  | @ -1068,91 +1069,9 @@ out: | ||||||
| 	if (p_udf != NULL) | 	if (p_udf != NULL) | ||||||
| 		udf_close(p_udf); | 		udf_close(p_udf); | ||||||
| 	safe_free(wim_path); | 	safe_free(wim_path); | ||||||
| 	return bswap_32(r); | 	return bswap_uint32(r); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 |  | ||||||
|  * The following is used for native ISO mounting in Windows 8 or later |  | ||||||
|  */ |  | ||||||
| #define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \ |  | ||||||
| 	{ 0xEC984AECL, 0xA0F9, 0x47e9, { 0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B } } |  | ||||||
| 
 |  | ||||||
| typedef enum _VIRTUAL_DISK_ACCESS_MASK { |  | ||||||
| 	VIRTUAL_DISK_ACCESS_NONE = 0x00000000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_DETACH = 0x00040000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_CREATE = 0x00100000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_READ = 0x000d0000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_ALL = 0x003f0000, |  | ||||||
| 	VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000 |  | ||||||
| } VIRTUAL_DISK_ACCESS_MASK; |  | ||||||
| 
 |  | ||||||
| typedef enum _OPEN_VIRTUAL_DISK_FLAG { |  | ||||||
| 	OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000, |  | ||||||
| 	OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x00000001, |  | ||||||
| 	OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x00000002, |  | ||||||
| 	OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x00000004, |  | ||||||
| 	OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x00000008, |  | ||||||
| 	OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x00000010 |  | ||||||
| } OPEN_VIRTUAL_DISK_FLAG; |  | ||||||
| 
 |  | ||||||
| typedef enum _OPEN_VIRTUAL_DISK_VERSION { |  | ||||||
| 	OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, |  | ||||||
| 	OPEN_VIRTUAL_DISK_VERSION_1 = 1, |  | ||||||
| 	OPEN_VIRTUAL_DISK_VERSION_2 = 2 |  | ||||||
| } OPEN_VIRTUAL_DISK_VERSION; |  | ||||||
| 
 |  | ||||||
| typedef enum _ATTACH_VIRTUAL_DISK_FLAG { |  | ||||||
| 	ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000, |  | ||||||
| 	ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001, |  | ||||||
| 	ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = 0x00000002, |  | ||||||
| 	ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004, |  | ||||||
| 	ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = 0x00000008 |  | ||||||
| } ATTACH_VIRTUAL_DISK_FLAG; |  | ||||||
| 
 |  | ||||||
| typedef enum _ATTACH_VIRTUAL_DISK_VERSION { |  | ||||||
| 	ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, |  | ||||||
| 	ATTACH_VIRTUAL_DISK_VERSION_1 = 1 |  | ||||||
| } ATTACH_VIRTUAL_DISK_VERSION; |  | ||||||
| 
 |  | ||||||
| typedef enum _DETACH_VIRTUAL_DISK_FLAG { |  | ||||||
| 	DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000 |  | ||||||
| } DETACH_VIRTUAL_DISK_FLAG; |  | ||||||
| 
 |  | ||||||
| #ifndef _VIRTUAL_STORAGE_TYPE_DEFINED |  | ||||||
| #define _VIRTUAL_STORAGE_TYPE_DEFINED |  | ||||||
| typedef struct _VIRTUAL_STORAGE_TYPE { |  | ||||||
| 	ULONG DeviceId; |  | ||||||
| 	GUID  VendorId; |  | ||||||
| } VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE; |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS { |  | ||||||
| 	OPEN_VIRTUAL_DISK_VERSION Version; |  | ||||||
| 	union { |  | ||||||
| 		struct { |  | ||||||
| 			ULONG RWDepth; |  | ||||||
| 		} Version1; |  | ||||||
| 		struct { |  | ||||||
| 			BOOL GetInfoOnly; |  | ||||||
| 			BOOL ReadOnly; |  | ||||||
| 			GUID ResiliencyGuid; |  | ||||||
| 		} Version2; |  | ||||||
| 	}; |  | ||||||
| } OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS; |  | ||||||
| 
 |  | ||||||
| typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS { |  | ||||||
| 	ATTACH_VIRTUAL_DISK_VERSION Version; |  | ||||||
| 	union { |  | ||||||
| 		struct { |  | ||||||
| 			ULONG Reserved; |  | ||||||
| 		} Version1; |  | ||||||
| 	}; |  | ||||||
| } ATTACH_VIRTUAL_DISK_PARAMETERS, *PATTACH_VIRTUAL_DISK_PARAMETERS; |  | ||||||
| 
 |  | ||||||
| // VirtDisk API Prototypes - Only available for Windows 8 or later
 | // VirtDisk API Prototypes - Only available for Windows 8 or later
 | ||||||
| PF_TYPE_DECL(WINAPI, DWORD, OpenVirtualDisk, (PVIRTUAL_STORAGE_TYPE, PCWSTR, | PF_TYPE_DECL(WINAPI, DWORD, OpenVirtualDisk, (PVIRTUAL_STORAGE_TYPE, PCWSTR, | ||||||
| 	VIRTUAL_DISK_ACCESS_MASK, OPEN_VIRTUAL_DISK_FLAG, POPEN_VIRTUAL_DISK_PARAMETERS, PHANDLE)); | 	VIRTUAL_DISK_ACCESS_MASK, OPEN_VIRTUAL_DISK_FLAG, POPEN_VIRTUAL_DISK_PARAMETERS, PHANDLE)); | ||||||
|  |  | ||||||
							
								
								
									
										214
									
								
								src/missing.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										214
									
								
								src/missing.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,214 @@ | ||||||
|  | /*
 | ||||||
|  | * Rufus: The Reliable USB Formatting Utility | ||||||
|  | * Constants and defines missing from various toolchains | ||||||
|  | * Copyright © 2016 Pete Batard <pete@akeo.ie> | ||||||
|  | * | ||||||
|  | * 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 | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | #include <windows.h> | ||||||
|  | #include <commctrl.h> | ||||||
|  | #include <shlobj.h> | ||||||
|  | #include <wininet.h> | ||||||
|  | 
 | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | /* Convenient to have around */ | ||||||
|  | #define KB                   1024LL | ||||||
|  | #define MB                1048576LL | ||||||
|  | #define GB             1073741824LL | ||||||
|  | #define TB          1099511627776LL | ||||||
|  | 
 | ||||||
|  | #ifndef MIN | ||||||
|  | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #if defined(_MSC_VER) | ||||||
|  | #define bswap_uint64 _byteswap_uint64 | ||||||
|  | #define bswap_uint32 _byteswap_ulong | ||||||
|  | #define bswap_uint16 _byteswap_ushort | ||||||
|  | #else | ||||||
|  | #define bswap_uint64 __builtin_bswap64 | ||||||
|  | #define bswap_uint32 __builtin_bswap32 | ||||||
|  | #define bswap_uint16 __builtin_bswap16 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | static __inline void *_reallocf(void *ptr, size_t size) { | ||||||
|  | 	void *ret = realloc(ptr, size); | ||||||
|  | 	if (!ret) | ||||||
|  | 		free(ptr); | ||||||
|  | 	return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /* UI redefinitions for WDK and MinGW */ | ||||||
|  | #ifndef PBM_SETSTATE | ||||||
|  | #define PBM_SETSTATE (WM_USER+16) | ||||||
|  | #endif | ||||||
|  | #ifndef PBST_NORMAL | ||||||
|  | #define PBST_NORMAL 1 | ||||||
|  | #endif | ||||||
|  | #ifndef PBST_ERROR | ||||||
|  | #define PBST_ERROR 2 | ||||||
|  | #endif | ||||||
|  | #ifndef PBST_PAUSED | ||||||
|  | #define PBST_PAUSED 3 | ||||||
|  | #endif | ||||||
|  | #ifndef BUTTON_IMAGELIST_ALIGN_CENTER | ||||||
|  | #define BUTTON_IMAGELIST_ALIGN_CENTER 4 | ||||||
|  | #endif | ||||||
|  | #ifndef BCM_SETIMAGELIST | ||||||
|  | #define BCM_SETIMAGELIST 0x1602 | ||||||
|  | #endif | ||||||
|  | #ifndef DBT_CUSTOMEVENT | ||||||
|  | #define DBT_CUSTOMEVENT 0x8006 | ||||||
|  | #endif | ||||||
|  | #ifndef ERROR_FILE_TOO_LARGE | ||||||
|  | #define ERROR_FILE_TOO_LARGE 223 | ||||||
|  | #endif | ||||||
|  | #ifndef MSGFLT_ADD | ||||||
|  | #define MSGFLT_ADD 1 | ||||||
|  | #endif | ||||||
|  | #ifndef WM_CLIENTSHUTDOWN | ||||||
|  | #define WM_CLIENTSHUTDOWN 0x3B | ||||||
|  | #endif | ||||||
|  | #ifndef WM_COPYGLOBALDATA | ||||||
|  | #define WM_COPYGLOBALDATA 0x49 | ||||||
|  | #endif | ||||||
|  | #ifndef PBS_MARQUEE | ||||||
|  | #define PBS_MARQUEE 0x08 | ||||||
|  | #endif | ||||||
|  | #ifndef PBM_SETMARQUEE | ||||||
|  | #define PBM_SETMARQUEE (WM_USER+10) | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | typedef struct { | ||||||
|  | 	HIMAGELIST himl; | ||||||
|  | 	RECT margin; | ||||||
|  | 	UINT uAlign; | ||||||
|  | } MY_BUTTON_IMAGELIST; | ||||||
|  | 
 | ||||||
|  | typedef struct | ||||||
|  | { | ||||||
|  | 	LPCITEMIDLIST pidl; | ||||||
|  | 	BOOL fRecursive; | ||||||
|  | } MY_SHChangeNotifyEntry; | ||||||
|  | 
 | ||||||
|  | /* The following is used for native ISO mounting in Windows 8 or later */ | ||||||
|  | #define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \ | ||||||
|  | 	{ 0xEC984AECL, 0xA0F9, 0x47e9, { 0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B } } | ||||||
|  | 
 | ||||||
|  | typedef enum _VIRTUAL_DISK_ACCESS_MASK { | ||||||
|  | 	VIRTUAL_DISK_ACCESS_NONE = 0x00000000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_DETACH = 0x00040000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_CREATE = 0x00100000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_READ = 0x000d0000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_ALL = 0x003f0000, | ||||||
|  | 	VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000 | ||||||
|  | } VIRTUAL_DISK_ACCESS_MASK; | ||||||
|  | 
 | ||||||
|  | typedef enum _OPEN_VIRTUAL_DISK_FLAG { | ||||||
|  | 	OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000, | ||||||
|  | 	OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x00000001, | ||||||
|  | 	OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x00000002, | ||||||
|  | 	OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x00000004, | ||||||
|  | 	OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x00000008, | ||||||
|  | 	OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x00000010 | ||||||
|  | } OPEN_VIRTUAL_DISK_FLAG; | ||||||
|  | 
 | ||||||
|  | typedef enum _OPEN_VIRTUAL_DISK_VERSION { | ||||||
|  | 	OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, | ||||||
|  | 	OPEN_VIRTUAL_DISK_VERSION_1 = 1, | ||||||
|  | 	OPEN_VIRTUAL_DISK_VERSION_2 = 2 | ||||||
|  | } OPEN_VIRTUAL_DISK_VERSION; | ||||||
|  | 
 | ||||||
|  | typedef enum _ATTACH_VIRTUAL_DISK_FLAG { | ||||||
|  | 	ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000, | ||||||
|  | 	ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001, | ||||||
|  | 	ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = 0x00000002, | ||||||
|  | 	ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004, | ||||||
|  | 	ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = 0x00000008 | ||||||
|  | } ATTACH_VIRTUAL_DISK_FLAG; | ||||||
|  | 
 | ||||||
|  | typedef enum _ATTACH_VIRTUAL_DISK_VERSION { | ||||||
|  | 	ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, | ||||||
|  | 	ATTACH_VIRTUAL_DISK_VERSION_1 = 1 | ||||||
|  | } ATTACH_VIRTUAL_DISK_VERSION; | ||||||
|  | 
 | ||||||
|  | typedef enum _DETACH_VIRTUAL_DISK_FLAG { | ||||||
|  | 	DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000 | ||||||
|  | } DETACH_VIRTUAL_DISK_FLAG; | ||||||
|  | 
 | ||||||
|  | #ifndef _VIRTUAL_STORAGE_TYPE_DEFINED | ||||||
|  | #define _VIRTUAL_STORAGE_TYPE_DEFINED | ||||||
|  | typedef struct _VIRTUAL_STORAGE_TYPE { | ||||||
|  | 	ULONG DeviceId; | ||||||
|  | 	GUID  VendorId; | ||||||
|  | } VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE; | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS { | ||||||
|  | 	OPEN_VIRTUAL_DISK_VERSION Version; | ||||||
|  | 	union { | ||||||
|  | 		struct { | ||||||
|  | 			ULONG RWDepth; | ||||||
|  | 		} Version1; | ||||||
|  | 		struct { | ||||||
|  | 			BOOL GetInfoOnly; | ||||||
|  | 			BOOL ReadOnly; | ||||||
|  | 			GUID ResiliencyGuid; | ||||||
|  | 		} Version2; | ||||||
|  | 	}; | ||||||
|  | } OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS; | ||||||
|  | 
 | ||||||
|  | typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS { | ||||||
|  | 	ATTACH_VIRTUAL_DISK_VERSION Version; | ||||||
|  | 	union { | ||||||
|  | 		struct { | ||||||
|  | 			ULONG Reserved; | ||||||
|  | 		} Version1; | ||||||
|  | 	}; | ||||||
|  | } ATTACH_VIRTUAL_DISK_PARAMETERS, *PATTACH_VIRTUAL_DISK_PARAMETERS; | ||||||
|  | 
 | ||||||
|  | /* Networking constants missing from MinGW */ | ||||||
|  | #if !defined(ERROR_INTERNET_DISCONNECTED) | ||||||
|  | #define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_SERVER_UNREACHABLE) | ||||||
|  | #define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_PROXY_SERVER_UNREACHABLE) | ||||||
|  | #define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT) | ||||||
|  | #define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT) | ||||||
|  | #define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_FAILED_DUETOSECURITYCHECK) | ||||||
|  | #define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_NOT_INITIALIZED) | ||||||
|  | #define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_NEED_MSN_SSPI_PKG) | ||||||
|  | #define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173) | ||||||
|  | #endif | ||||||
|  | #if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY) | ||||||
|  | #define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) | ||||||
|  | #endif | ||||||
							
								
								
									
										34
									
								
								src/net.c
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								src/net.c
									
										
									
									
									
								
							|  | @ -30,12 +30,13 @@ | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <inttypes.h> | #include <inttypes.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "settings.h" |  | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
|  | #include "settings.h" | ||||||
|  | 
 | ||||||
| /* Maximum download chunk size, in bytes */ | /* Maximum download chunk size, in bytes */ | ||||||
| #define DOWNLOAD_BUFFER_SIZE    10240 | #define DOWNLOAD_BUFFER_SIZE    10240 | ||||||
| /* Default delay between update checks (1 day) */ | /* Default delay between update checks (1 day) */ | ||||||
|  | @ -49,35 +50,6 @@ static DWORD error_code; | ||||||
| static BOOL update_check_in_progress = FALSE; | static BOOL update_check_in_progress = FALSE; | ||||||
| static BOOL force_update_check = FALSE; | static BOOL force_update_check = FALSE; | ||||||
| 
 | 
 | ||||||
| /* MinGW is missing some of those */ |  | ||||||
| #if !defined(ERROR_INTERNET_DISCONNECTED) |  | ||||||
| #define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_SERVER_UNREACHABLE) |  | ||||||
| #define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_PROXY_SERVER_UNREACHABLE) |  | ||||||
| #define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT) |  | ||||||
| #define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT) |  | ||||||
| #define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_FAILED_DUETOSECURITYCHECK) |  | ||||||
| #define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_NOT_INITIALIZED) |  | ||||||
| #define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_NEED_MSN_SSPI_PKG) |  | ||||||
| #define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173) |  | ||||||
| #endif |  | ||||||
| #if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY) |  | ||||||
| #define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| /*
 | /*
 | ||||||
|  * FormatMessage does not handle internet errors |  * FormatMessage does not handle internet errors | ||||||
|  * https://msdn.microsoft.com/en-us/library/windows/desktop/aa385465.aspx
 |  * https://msdn.microsoft.com/en-us/library/windows/desktop/aa385465.aspx
 | ||||||
|  |  | ||||||
|  | @ -32,6 +32,7 @@ | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "missing.h" | ||||||
| #include "msapi_utf8.h" | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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 Pete Batard <pete@akeo.ie> |  * Copyright © 2015-2016 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 | ||||||
|  | @ -29,8 +29,8 @@ | ||||||
| #include <wintrust.h> | #include <wintrust.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
| #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING) | #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING) | ||||||
|  |  | ||||||
							
								
								
									
										68
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										68
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -35,69 +35,23 @@ | ||||||
| #include <io.h> | #include <io.h> | ||||||
| #include <getopt.h> | #include <getopt.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "resource.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "missing.h" | ||||||
|  | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
|  | #include "localization.h" | ||||||
|  | 
 | ||||||
| #include "drive.h" | #include "drive.h" | ||||||
| #include "settings.h" | #include "settings.h" | ||||||
| #include "localization.h" |  | ||||||
| #include "bled/bled.h" | #include "bled/bled.h" | ||||||
| #include "../res/grub/grub_version.h" | #include "../res/grub/grub_version.h" | ||||||
| #include "../res/grub2/grub2_version.h" | #include "../res/grub2/grub2_version.h" | ||||||
| 
 | 
 | ||||||
| /* Redefinitions for WDK and MinGW */ |  | ||||||
| // TODO: these would be better in a 'missing.h' file
 |  | ||||||
| #ifndef PBM_SETSTATE |  | ||||||
| #define PBM_SETSTATE (WM_USER+16) |  | ||||||
| #endif |  | ||||||
| #ifndef PBST_NORMAL |  | ||||||
| #define PBST_NORMAL 1 |  | ||||||
| #endif |  | ||||||
| #ifndef PBST_ERROR |  | ||||||
| #define PBST_ERROR 2 |  | ||||||
| #endif |  | ||||||
| #ifndef PBST_PAUSED |  | ||||||
| #define PBST_PAUSED 3 |  | ||||||
| #endif |  | ||||||
| #ifndef BUTTON_IMAGELIST_ALIGN_CENTER |  | ||||||
| #define BUTTON_IMAGELIST_ALIGN_CENTER 4 |  | ||||||
| #endif |  | ||||||
| #ifndef BCM_SETIMAGELIST |  | ||||||
| #define BCM_SETIMAGELIST 0x1602 |  | ||||||
| #endif |  | ||||||
| #ifndef DBT_CUSTOMEVENT |  | ||||||
| #define DBT_CUSTOMEVENT 0x8006 |  | ||||||
| #endif |  | ||||||
| #ifndef ERROR_FILE_TOO_LARGE |  | ||||||
| #define ERROR_FILE_TOO_LARGE 223 |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #ifndef MSGFLT_ADD |  | ||||||
| #define MSGFLT_ADD 1 |  | ||||||
| #endif |  | ||||||
| #ifndef WM_CLIENTSHUTDOWN |  | ||||||
| #define WM_CLIENTSHUTDOWN 0x3B |  | ||||||
| #endif |  | ||||||
| #ifndef WM_COPYGLOBALDATA |  | ||||||
| #define WM_COPYGLOBALDATA 0x49 |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| struct { |  | ||||||
| 	HIMAGELIST himl; |  | ||||||
| 	RECT margin; |  | ||||||
| 	UINT uAlign; |  | ||||||
| } bi_iso = {0}, bi_up = {0}, bi_down = {0};	// BUTTON_IMAGELIST
 |  | ||||||
| 
 |  | ||||||
| typedef struct |  | ||||||
| { |  | ||||||
| 	LPCITEMIDLIST pidl; |  | ||||||
| 	BOOL fRecursive; |  | ||||||
| } MY_SHChangeNotifyEntry; |  | ||||||
| 
 |  | ||||||
| // MinGW doesn't know these
 | // MinGW doesn't know these
 | ||||||
| PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int)); | PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int)); | ||||||
| PF_TYPE(WINAPI, int, ImageList_AddIcon, (HIMAGELIST, HICON)); | PF_TYPE(WINAPI, int, ImageList_AddIcon, (HIMAGELIST, HICON)); | ||||||
| PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON)); | PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON)); | ||||||
|  | 
 | ||||||
| // WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't.
 | // WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't.
 | ||||||
| PF_DECL(ImageList_Create); | PF_DECL(ImageList_Create); | ||||||
| PF_DECL(ImageList_AddIcon); | PF_DECL(ImageList_AddIcon); | ||||||
|  | @ -139,6 +93,7 @@ char msgbox[1024], msgbox_title[32], *ini_file = NULL; | ||||||
| OPENED_LIBRARIES_VARS; | OPENED_LIBRARIES_VARS; | ||||||
| HINSTANCE hMainInstance; | HINSTANCE hMainInstance; | ||||||
| HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL; | HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL; | ||||||
|  | MY_BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }; | ||||||
| char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH]; | char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH]; | ||||||
| char* image_path = NULL; | char* image_path = NULL; | ||||||
| float fScale = 1.0f; | float fScale = 1.0f; | ||||||
|  | @ -193,11 +148,6 @@ static __inline void SetComboEntry(HWND hDlg, int data) { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #define KB          1024LL |  | ||||||
| #define MB       1048576LL |  | ||||||
| #define GB    1073741824LL |  | ||||||
| #define TB 1099511627776LL |  | ||||||
| 
 |  | ||||||
| /*
 | /*
 | ||||||
|  * Fill in the cluster size names |  * Fill in the cluster size names | ||||||
|  */ |  */ | ||||||
|  | @ -370,10 +320,6 @@ static BOOL DefineClusterSizes(void) | ||||||
| 
 | 
 | ||||||
| 	return r; | 	return r; | ||||||
| } | } | ||||||
| #undef KB |  | ||||||
| #undef MB |  | ||||||
| #undef GB |  | ||||||
| #undef TB |  | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Populate the Allocation unit size field |  * Populate the Allocation unit size field | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								src/rufus.h
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								src/rufus.h
									
										
									
									
									
								
							|  | @ -469,25 +469,6 @@ static __inline BOOL UnlockDrive(HANDLE hDrive) { | ||||||
| 	return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL); | 	return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static __inline void *_reallocf(void *ptr, size_t size) { |  | ||||||
| 	void *ret = realloc(ptr, size); |  | ||||||
| 	if (!ret) |  | ||||||
| 		free(ptr); |  | ||||||
| 	return ret; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static __inline uint16_t bswap_16(uint16_t x) { |  | ||||||
| 	return (x >> 8) | (x << 8); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static __inline uint32_t bswap_32(uint32_t x) { |  | ||||||
| 	return (bswap_16(x & 0xffff) << 16) | (bswap_16(x >> 16)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static __inline uint64_t bswap_64(uint64_t x) { |  | ||||||
| 	return (((uint64_t) bswap_32(x & 0xffffffffull)) << 32) | (bswap_32(x >> 32)); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /* Hash tables */ | /* Hash tables */ | ||||||
| typedef struct htab_entry { | typedef struct htab_entry { | ||||||
| 	uint32_t used; | 	uint32_t used; | ||||||
|  | @ -580,17 +561,6 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) { | ||||||
| #define ERROR_CANT_ASSIGN_LETTER       0x120B | #define ERROR_CANT_ASSIGN_LETTER       0x120B | ||||||
| #define ERROR_CANT_MOUNT_VOLUME        0x120C | #define ERROR_CANT_MOUNT_VOLUME        0x120C | ||||||
| 
 | 
 | ||||||
| /* More niceties */ |  | ||||||
| #ifndef MIN |  | ||||||
| #define MIN(a,b) (((a) < (b)) ? (a) : (b)) |  | ||||||
| #endif |  | ||||||
| #ifndef PBS_MARQUEE |  | ||||||
| #define PBS_MARQUEE 0x08 |  | ||||||
| #endif |  | ||||||
| #ifndef PBM_SETMARQUEE |  | ||||||
| #define PBM_SETMARQUEE (WM_USER+10) |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| /* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */ | /* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */ | ||||||
| #define _RT_ICON			MAKEINTRESOURCEA(3) | #define _RT_ICON			MAKEINTRESOURCEA(3) | ||||||
| #define _RT_DIALOG			MAKEINTRESOURCEA(5) | #define _RT_DIALOG			MAKEINTRESOURCEA(5) | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 242, 376 | IDD_DIALOG DIALOGEX 12, 12, 242, 376 | ||||||
| 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 2.8.860" | CAPTION "Rufus 2.8.861" | ||||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 |     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||||
|  | @ -320,8 +320,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 2,8,860,0 |  FILEVERSION 2,8,861,0 | ||||||
|  PRODUCTVERSION 2,8,860,0 |  PRODUCTVERSION 2,8,861,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -338,13 +338,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" |             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "2.8.860" |             VALUE "FileVersion", "2.8.861" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus.exe" |             VALUE "OriginalFilename", "rufus.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "2.8.860" |             VALUE "ProductVersion", "2.8.861" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
							
								
								
									
										13
									
								
								src/smart.c
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								src/smart.c
									
										
									
									
									
								
							|  | @ -1,7 +1,7 @@ | ||||||
| /*
 | /*
 | ||||||
|  * Rufus: The Reliable USB Formatting Utility |  * Rufus: The Reliable USB Formatting Utility | ||||||
|  * SMART HDD vs Flash detection (using ATA over USB, S.M.A.R.T., etc.) |  * SMART HDD vs Flash detection (using ATA over USB, S.M.A.R.T., etc.) | ||||||
|  * Copyright © 2013-2014 Pete Batard <pete@akeo.ie> |  * Copyright © 2013-2016 Pete Batard <pete@akeo.ie> | ||||||
|  * |  * | ||||||
|  * Based in part on scsiata.cpp from Smartmontools: http://smartmontools.sourceforge.net
 |  * Based in part on scsiata.cpp from Smartmontools: http://smartmontools.sourceforge.net
 | ||||||
|  * Copyright © 2006-12 Douglas Gilbert <dgilbert@interlog.com> |  * Copyright © 2006-12 Douglas Gilbert <dgilbert@interlog.com> | ||||||
|  | @ -31,8 +31,10 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <stddef.h> | #include <stddef.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "missing.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
|  | 
 | ||||||
| #include "drive.h" | #include "drive.h" | ||||||
| #include "smart.h" | #include "smart.h" | ||||||
| #include "hdd_vs_ufd.h" | #include "hdd_vs_ufd.h" | ||||||
|  | @ -43,7 +45,7 @@ static uint8_t GetAtaDirection(uint8_t AtaCmd, uint8_t Features) { | ||||||
| 	// Far from complete -- only the commands we *may* use.
 | 	// Far from complete -- only the commands we *may* use.
 | ||||||
| 
 | 
 | ||||||
| 	// Most SMART commands require DATA_IN but there are a couple exceptions
 | 	// Most SMART commands require DATA_IN but there are a couple exceptions
 | ||||||
| 	BOOL smart_out = (AtaCmd == ATA_SMART_CMD) &&  | 	BOOL smart_out = (AtaCmd == ATA_SMART_CMD) && | ||||||
| 		((Features == ATA_SMART_STATUS) || (Features == ATA_SMART_WRITE_LOG_SECTOR)); | 		((Features == ATA_SMART_STATUS) || (Features == ATA_SMART_WRITE_LOG_SECTOR)); | ||||||
| 
 | 
 | ||||||
| 	switch (AtaCmd) { | 	switch (AtaCmd) { | ||||||
|  | @ -413,7 +415,7 @@ BOOL SmartGetVersion(HANDLE hdevice) | ||||||
|  * THUS, IF DATA LOSS IS INCURRED DUE TO THIS, OR ANY OTHER PART OF THIS APPLICATION, |  * THUS, IF DATA LOSS IS INCURRED DUE TO THIS, OR ANY OTHER PART OF THIS APPLICATION, | ||||||
|  * NOT BEHAVING IN THE MANNER YOU EXPECTED, THE RESPONSIBILITY IS ENTIRELY ON YOU! |  * NOT BEHAVING IN THE MANNER YOU EXPECTED, THE RESPONSIBILITY IS ENTIRELY ON YOU! | ||||||
|  * |  * | ||||||
|  * What you have below, then, is our *current best guess* at differentiating UFDs  |  * What you have below, then, is our *current best guess* at differentiating UFDs | ||||||
|  * from HDDs. But short of a crystal ball, this remains just a guess, which may be |  * from HDDs. But short of a crystal ball, this remains just a guess, which may be | ||||||
|  * way off mark. Still, you are also reminded that Rufus does produce PROMINENT |  * way off mark. Still, you are also reminded that Rufus does produce PROMINENT | ||||||
|  * warnings before you format a drive, and also provides extensive info about the |  * warnings before you format a drive, and also provides extensive info about the | ||||||
|  | @ -426,7 +428,7 @@ BOOL SmartGetVersion(HANDLE hdevice) | ||||||
|  * - some UFDs (SanDisk Extreme) have added S.M.A.R.T. support, which also used to be |  * - some UFDs (SanDisk Extreme) have added S.M.A.R.T. support, which also used to be | ||||||
|  *   reserved for HDDs => can't use that either |  *   reserved for HDDs => can't use that either | ||||||
|  * - even if S.M.A.R.T. was enough, not all USB->IDE or USB->SATA bridges support ATA |  * - even if S.M.A.R.T. was enough, not all USB->IDE or USB->SATA bridges support ATA | ||||||
|  *   passthrough, which is required S.M.A.R.T. data, and each manufacturer of an  |  *   passthrough, which is required S.M.A.R.T. data, and each manufacturer of an | ||||||
|  *   USB<->(S)ATA bridge seem to have their own method of implementing passthrough. |  *   USB<->(S)ATA bridge seem to have their own method of implementing passthrough. | ||||||
|  * - SSDs have also changed the deal completely, as you can get something that looks |  * - SSDs have also changed the deal completely, as you can get something that looks | ||||||
|  *   like Flash but that is really an HDD. |  *   like Flash but that is really an HDD. | ||||||
|  | @ -436,7 +438,6 @@ BOOL SmartGetVersion(HANDLE hdevice) | ||||||
|  *   from the above) => there is no magic API we can query that will tell us what we're |  *   from the above) => there is no magic API we can query that will tell us what we're | ||||||
|  *   really looking at. |  *   really looking at. | ||||||
|  */ |  */ | ||||||
| #define GB 1073741824LL |  | ||||||
| int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid) | int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid) | ||||||
| { | { | ||||||
| 	int score = 0; | 	int score = 0; | ||||||
|  |  | ||||||
|  | @ -24,12 +24,13 @@ | ||||||
| #include <windows.h> | #include <windows.h> | ||||||
| #include <sddl.h> | #include <sddl.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
| #include "settings.h" | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
|  | #include "settings.h" | ||||||
|  | 
 | ||||||
| int  nWindowsVersion = WINDOWS_UNDEFINED; | int  nWindowsVersion = WINDOWS_UNDEFINED; | ||||||
| char WindowsVersionStr[128] = "Windows "; | char WindowsVersionStr[128] = "Windows "; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,9 +29,9 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <math.h> | #include <math.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  |  | ||||||
|  | @ -35,12 +35,13 @@ | ||||||
| #include <richedit.h> | #include <richedit.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "resource.h" | ||||||
| #include "msapi_utf8.h" | #include "msapi_utf8.h" | ||||||
|  | #include "localization.h" | ||||||
|  | 
 | ||||||
| #include "registry.h" | #include "registry.h" | ||||||
| #include "settings.h" | #include "settings.h" | ||||||
| #include "resource.h" |  | ||||||
| #include "license.h" | #include "license.h" | ||||||
| #include "localization.h" |  | ||||||
| 
 | 
 | ||||||
| #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) | #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) | ||||||
| PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **)); | PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **)); | ||||||
|  |  | ||||||
|  | @ -27,10 +27,11 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "drive.h" |  | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
| #include "localization.h" |  | ||||||
| #include "msapi_utf8.h" | #include "msapi_utf8.h" | ||||||
|  | #include "localization.h" | ||||||
|  | 
 | ||||||
|  | #include "drive.h" | ||||||
| 
 | 
 | ||||||
| #include "syslinux.h" | #include "syslinux.h" | ||||||
| #include "syslxfs.h" | #include "syslxfs.h" | ||||||
|  |  | ||||||
|  | @ -33,11 +33,13 @@ | ||||||
| #include <commctrl.h> | #include <commctrl.h> | ||||||
| #include <setupapi.h> | #include <setupapi.h> | ||||||
| 
 | 
 | ||||||
| #include "msapi_utf8.h" |  | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
| #include "drive.h" | #include "missing.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
|  | #include "msapi_utf8.h" | ||||||
| #include "localization.h" | #include "localization.h" | ||||||
|  | 
 | ||||||
|  | #include "drive.h" | ||||||
| #include "usb.h" | #include "usb.h" | ||||||
| 
 | 
 | ||||||
| extern StrArray DriveID, DriveLabel; | extern StrArray DriveID, DriveLabel; | ||||||
|  | @ -537,7 +539,7 @@ BOOL GetUSBDevices(DWORD devnum) | ||||||
| 				safe_free(devint_detail_data); | 				safe_free(devint_detail_data); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			if (GetDriveSize(drive_index) < (MIN_DRIVE_SIZE*1024*1024)) { | 			if (GetDriveSize(drive_index) < (MIN_DRIVE_SIZE*MB)) { | ||||||
| 				uprintf("Device eliminated because it is smaller than %d MB\n", MIN_DRIVE_SIZE); | 				uprintf("Device eliminated because it is smaller than %d MB\n", MIN_DRIVE_SIZE); | ||||||
| 				safe_closehandle(hDrive); | 				safe_closehandle(hDrive); | ||||||
| 				safe_free(devint_detail_data); | 				safe_free(devint_detail_data); | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								src/vhd.c
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/vhd.c
									
										
									
									
									
								
							|  | @ -24,22 +24,14 @@ | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| #include "rufus.h" | #include "rufus.h" | ||||||
|  | #include "missing.h" | ||||||
| #include "resource.h" | #include "resource.h" | ||||||
| #include "msapi_utf8.h" | #include "msapi_utf8.h" | ||||||
|  | 
 | ||||||
| #include "drive.h" | #include "drive.h" | ||||||
| #include "registry.h" | #include "registry.h" | ||||||
| #include "bled/bled.h" | #include "bled/bled.h" | ||||||
| 
 | 
 | ||||||
| #if defined(_MSC_VER) |  | ||||||
| #define bswap_uint64 _byteswap_uint64 |  | ||||||
| #define bswap_uint32 _byteswap_ulong |  | ||||||
| #define bswap_uint16 _byteswap_ushort |  | ||||||
| #else |  | ||||||
| #define bswap_uint64 __builtin_bswap64 |  | ||||||
| #define bswap_uint32 __builtin_bswap32 |  | ||||||
| #define bswap_uint16 __builtin_bswap16 |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #define VHD_FOOTER_COOKIE					{ 'c', 'o', 'n', 'e', 'c', 't', 'i', 'x' } | #define VHD_FOOTER_COOKIE					{ 'c', 'o', 'n', 'e', 'c', 't', 'i', 'x' } | ||||||
| 
 | 
 | ||||||
| #define VHD_FOOTER_FEATURES_NONE			0x00000000 | #define VHD_FOOTER_FEATURES_NONE			0x00000000 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue