mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[core] fix VHD support
* Also fix various typos
This commit is contained in:
		
							parent
							
								
									9df63b3b2a
								
							
						
					
					
						commit
						c0d3f8e57c
					
				
					 7 changed files with 36 additions and 33 deletions
				
			
		|  | @ -724,7 +724,7 @@ BOOL UnmountVolume(HANDLE hDrive) | ||||||
| 	DWORD size; | 	DWORD size; | ||||||
| 
 | 
 | ||||||
| 	if (!DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &size, NULL)) { | 	if (!DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &size, NULL)) { | ||||||
| 		uprintf("Could not ummount drive: %s\n", WindowsErrorString()); | 		uprintf("Could not unmount drive: %s\n", WindowsErrorString()); | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	} | 	} | ||||||
| 	return TRUE; | 	return TRUE; | ||||||
|  | @ -877,8 +877,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m | ||||||
| 
 | 
 | ||||||
| 		DriveLayoutEx.PartitionStyle = PARTITION_STYLE_GPT; | 		DriveLayoutEx.PartitionStyle = PARTITION_STYLE_GPT; | ||||||
| 		DriveLayoutEx.PartitionCount = 1; | 		DriveLayoutEx.PartitionCount = 1; | ||||||
| 		// At the very least, a GPT disk has atv least 34 reserved (512 bytes) blocks at the beginning
 | 		// At the very least, a GPT disk has 34 reserved blocks (512 bytes) at the beginning and 33 at the end.
 | ||||||
| 		// and 33 at the end.
 |  | ||||||
| 		DriveLayoutEx.Type.Gpt.StartingUsableOffset.QuadPart = 34*512; | 		DriveLayoutEx.Type.Gpt.StartingUsableOffset.QuadPart = 34*512; | ||||||
| 		DriveLayoutEx.Type.Gpt.UsableLength.QuadPart = SelectedDrive.DiskSize - (34+33)*512; | 		DriveLayoutEx.Type.Gpt.UsableLength.QuadPart = SelectedDrive.DiskSize - (34+33)*512; | ||||||
| 		DriveLayoutEx.Type.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS; | 		DriveLayoutEx.Type.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS; | ||||||
|  |  | ||||||
|  | @ -122,7 +122,7 @@ const char* WinInetErrorString(void) | ||||||
| 	case ERROR_INTERNET_INVALID_OPERATION: | 	case ERROR_INTERNET_INVALID_OPERATION: | ||||||
| 		return "The requested operation is invalid."; | 		return "The requested operation is invalid."; | ||||||
| 	case ERROR_INTERNET_OPERATION_CANCELLED: | 	case ERROR_INTERNET_OPERATION_CANCELLED: | ||||||
| 		return "The operation was canceled, usually because the handle on which the request was operating was closed before the operation completed."; | 		return "The operation was cancelled, usually because the handle on which the request was operating was closed before the operation completed."; | ||||||
| 	case ERROR_INTERNET_INCORRECT_HANDLE_TYPE: | 	case ERROR_INTERNET_INCORRECT_HANDLE_TYPE: | ||||||
| 		return "The type of handle supplied is incorrect for this operation."; | 		return "The type of handle supplied is incorrect for this operation."; | ||||||
| 	case ERROR_INTERNET_INCORRECT_HANDLE_STATE: | 	case ERROR_INTERNET_INCORRECT_HANDLE_STATE: | ||||||
|  |  | ||||||
|  | @ -787,7 +787,7 @@ void parse_update(char* buf, size_t len) | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Insert entry 'data' under section 'section' of a config file |  * Insert entry 'data' under section 'section' of a config file | ||||||
|  * Section must include the relevant delimitors (eg '[', ']') if needed |  * Section must include the relevant delimiters (eg '[', ']') if needed | ||||||
|  */ |  */ | ||||||
| char* insert_section_data(const char* filename, const char* section, const char* data, BOOL dos2unix) | char* insert_section_data(const char* filename, const char* section, const char* data, BOOL dos2unix) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -141,11 +141,11 @@ static int64_t last_iso_blocking_status; | ||||||
|  * 0 means unused (no operation or no progress allocated to it) |  * 0 means unused (no operation or no progress allocated to it) | ||||||
|  * +n means allocate exactly n bars (n percent of the progress bar) |  * +n means allocate exactly n bars (n percent of the progress bar) | ||||||
|  * -n means allocate a weighted slot of n from all remaining |  * -n means allocate a weighted slot of n from all remaining | ||||||
|  *    bars. Eg if 80 slots remain and the sum of all negative entries |  *    bars. E.g. if 80 slots remain and the sum of all negative entries | ||||||
|  *    is 10, -4 will allocate 4/10*80 = 32 bars (32%) for OP progress |  *    is 10, -4 will allocate 4/10*80 = 32 bars (32%) for OP progress | ||||||
|  */ |  */ | ||||||
| static int nb_slots[OP_MAX]; | static int nb_slots[OP_MAX]; | ||||||
| static float slot_end[OP_MAX+1];	// shifted +1 so that we can substract 1 to OP indexes
 | static float slot_end[OP_MAX+1];	// shifted +1 so that we can subtract 1 to OP indexes
 | ||||||
| static float previous_end; | static float previous_end; | ||||||
| 
 | 
 | ||||||
| // TODO: Remember to update copyright year in both license.h and the RC when the year changes!
 | // TODO: Remember to update copyright year in both license.h and the RC when the year changes!
 | ||||||
|  | @ -1546,7 +1546,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 		// since last refresh/arm timer, and have that timer send DBT_CUSTOMEVENT when it expires.
 | 		// since last refresh/arm timer, and have that timer send DBT_CUSTOMEVENT when it expires.
 | ||||||
| 		// DO *NOT* USE WM_DEVICECHANGE AS THE MESSAGE FROM THE TIMER PROC, as it may be filtered!
 | 		// DO *NOT* USE WM_DEVICECHANGE AS THE MESSAGE FROM THE TIMER PROC, as it may be filtered!
 | ||||||
| 		// For instance filtering will occur when (un)plugging in a FreeBSD UFD on Windows 8.
 | 		// For instance filtering will occur when (un)plugging in a FreeBSD UFD on Windows 8.
 | ||||||
| 		// Intead, use a custom user message, such as UM_MEDIA_CHANGE, to set DBT_CUSTOMEVENT.
 | 		// Instead, use a custom user message, such as UM_MEDIA_CHANGE, to set DBT_CUSTOMEVENT.
 | ||||||
| 		if (format_thid == NULL) { | 		if (format_thid == NULL) { | ||||||
| 			switch (wParam) { | 			switch (wParam) { | ||||||
| 			case DBT_DEVICEARRIVAL: | 			case DBT_DEVICEARRIVAL: | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| 
 | 
 | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 206, 329 | IDD_DIALOG DIALOGEX 12, 12, 206, 329 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| CAPTION "Rufus 1.4.8.470" | CAPTION "Rufus 1.4.8.471" | ||||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||||
| BEGIN | BEGIN | ||||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 |     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 | ||||||
|  | @ -165,7 +165,7 @@ END | ||||||
| RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 | RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | ||||||
| CAPTION "Rufus 1.4.8.470" | CAPTION "Rufus 1.4.8.471" | ||||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||||
| BEGIN | BEGIN | ||||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 |     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 | ||||||
|  | @ -427,8 +427,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 1,4,8,470 |  FILEVERSION 1,4,8,471 | ||||||
|  PRODUCTVERSION 1,4,8,470 |  PRODUCTVERSION 1,4,8,471 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -445,13 +445,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", "1.4.8.470" |             VALUE "FileVersion", "1.4.8.471" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2014 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", "1.4.8.470" |             VALUE "ProductVersion", "1.4.8.471" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
							
								
								
									
										37
									
								
								src/usb.c
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								src/usb.c
									
										
									
									
									
								
							|  | @ -199,22 +199,23 @@ BOOL GetUSBDevices(DWORD devnum) | ||||||
| 		if (list_size[s] != 0) | 		if (list_size[s] != 0) | ||||||
| 			full_list_size += list_size[s]-1;	// remove extra NUL terminator
 | 			full_list_size += list_size[s]-1;	// remove extra NUL terminator
 | ||||||
| 	} | 	} | ||||||
| 	full_list_size += 1;	// add extra NUL terminator
 | 	devid_list = NULL; | ||||||
| 	if (full_list_size < 2) | 	if (full_list_size != 0) { | ||||||
| 		return FALSE; | 		full_list_size += 1;	// add extra NUL terminator
 | ||||||
| 	devid_list = (char*)malloc(full_list_size); | 		devid_list = (char*)malloc(full_list_size); | ||||||
| 	if (devid_list == NULL) { | 		if (devid_list == NULL) { | ||||||
| 		uprintf("Could not allocate Device ID list\n"); | 			uprintf("Could not allocate Device ID list\n"); | ||||||
| 		return FALSE; | 			return FALSE; | ||||||
| 	} | 		} | ||||||
| 	for (s=0, i=0; s<ARRAYSIZE(storage_name); s++) { | 		for (s=0, i=0; s<ARRAYSIZE(storage_name); s++) { | ||||||
| 		if (list_size[s] > 1) { | 			if (list_size[s] > 1) { | ||||||
| 			CM_Get_Device_ID_ListA(storage_name[s], &devid_list[i], list_size[s], | 				CM_Get_Device_ID_ListA(storage_name[s], &devid_list[i], list_size[s], | ||||||
| 				CM_GETIDLIST_FILTER_SERVICE|CM_GETIDLIST_FILTER_PRESENT);	// 
 | 					CM_GETIDLIST_FILTER_SERVICE|CM_GETIDLIST_FILTER_PRESENT);	// 
 | ||||||
| 			// The list_size is sometimes larger than required thus we need to find the real end
 | 				// The list_size is sometimes larger than required thus we need to find the real end
 | ||||||
| 			for (i += list_size[s]; i > 2; i--) { | 				for (i += list_size[s]; i > 2; i--) { | ||||||
| 				if ((devid_list[i-2] != '\0') && (devid_list[i-1] == '\0') && (devid_list[i] == '\0')) | 					if ((devid_list[i-2] != '\0') && (devid_list[i-1] == '\0') && (devid_list[i] == '\0')) | ||||||
| 					break; | 						break; | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -246,11 +247,11 @@ BOOL GetUSBDevices(DWORD devnum) | ||||||
| 			safe_strcpy(buffer, sizeof(buffer), lmprintf(MSG_045)); | 			safe_strcpy(buffer, sizeof(buffer), lmprintf(MSG_045)); | ||||||
| 		} else if (safe_strstr(buffer, vhd_name) != NULL) { | 		} else if (safe_strstr(buffer, vhd_name) != NULL) { | ||||||
| 			props.is_VHD = TRUE; | 			props.is_VHD = TRUE; | ||||||
| 		} else { | 		} else if (devid_list != NULL) { | ||||||
| 			// Get the properties of the device. We could avoid doing this lookup every time by keeping
 | 			// Get the properties of the device. We could avoid doing this lookup every time by keeping
 | ||||||
| 			// a lookup table, but there shouldn't be that many USB storage devices connected...
 | 			// a lookup table, but there shouldn't be that many USB storage devices connected...
 | ||||||
| 			// NB: Each of these Device IDs have an _only_ child, from which we get the Device Instance match.
 | 			// NB: Each of these Device IDs have an _only_ child, from which we get the Device Instance match.
 | ||||||
| 			for (device_id = devid_list; *device_id; device_id += strlen(device_id) + 1) { | 			for (device_id = devid_list; *device_id != 0; device_id += strlen(device_id) + 1) { | ||||||
| 				if ( (CM_Locate_DevNodeA(&parent_inst, device_id, 0) == CR_SUCCESS) | 				if ( (CM_Locate_DevNodeA(&parent_inst, device_id, 0) == CR_SUCCESS) | ||||||
| 				  && (CM_Get_Child(&device_inst, parent_inst, 0) == CR_SUCCESS) | 				  && (CM_Get_Child(&device_inst, parent_inst, 0) == CR_SUCCESS) | ||||||
| 				  && (device_inst == dev_info_data.DevInst) ) { | 				  && (device_inst == dev_info_data.DevInst) ) { | ||||||
|  |  | ||||||
|  | @ -27,6 +27,9 @@ | ||||||
| static BOOL has_wimgapi = FALSE, has_7z = FALSE; | static BOOL has_wimgapi = FALSE, has_7z = FALSE; | ||||||
| static char sevenzip_path[MAX_PATH]; | static char sevenzip_path[MAX_PATH]; | ||||||
| 
 | 
 | ||||||
|  | // TODO: Add a call to generate a Fixed Hard Disk VHD footer, This would allow the saving of an existing USB to VHD. See VHD specs at:
 | ||||||
|  | // http://download.microsoft.com/download/f/f/e/ffef50a5-07dd-4cf8-aaa3-442c0673a029/Virtual%20Hard%20Disk%20Format%20Spec_10_18_06.doc
 | ||||||
|  | 
 | ||||||
| // WIM API Prototypes
 | // WIM API Prototypes
 | ||||||
| #define WIM_GENERIC_READ	GENERIC_READ | #define WIM_GENERIC_READ	GENERIC_READ | ||||||
| #define WIM_OPEN_EXISTING	OPEN_EXISTING | #define WIM_OPEN_EXISTING	OPEN_EXISTING | ||||||
|  | @ -46,7 +49,7 @@ static BOOL Get7ZipPath(void) | ||||||
| 	return FALSE; | 	return FALSE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Find out if we have any way to extraxt WIM files on this platform
 | // Find out if we have any way to extract WIM files on this platform
 | ||||||
| BOOL WimExtractCheck(void) | BOOL WimExtractCheck(void) | ||||||
| { | { | ||||||
| 	PF_INIT(WIMCreateFile, Wimgapi); | 	PF_INIT(WIMCreateFile, Wimgapi); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue