[core] fix VHD support

* Also fix various typos
This commit is contained in:
Pete Batard 2014-05-20 19:28:46 +01:00
parent 9df63b3b2a
commit c0d3f8e57c
7 changed files with 36 additions and 33 deletions

View File

@ -724,7 +724,7 @@ BOOL UnmountVolume(HANDLE hDrive)
DWORD size;
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 TRUE;
@ -877,8 +877,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
DriveLayoutEx.PartitionStyle = PARTITION_STYLE_GPT;
DriveLayoutEx.PartitionCount = 1;
// At the very least, a GPT disk has atv least 34 reserved (512 bytes) blocks at the beginning
// and 33 at the end.
// At the very least, a GPT disk has 34 reserved blocks (512 bytes) at the beginning and 33 at the end.
DriveLayoutEx.Type.Gpt.StartingUsableOffset.QuadPart = 34*512;
DriveLayoutEx.Type.Gpt.UsableLength.QuadPart = SelectedDrive.DiskSize - (34+33)*512;
DriveLayoutEx.Type.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS;

View File

@ -122,7 +122,7 @@ const char* WinInetErrorString(void)
case ERROR_INTERNET_INVALID_OPERATION:
return "The requested operation is invalid.";
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:
return "The type of handle supplied is incorrect for this operation.";
case ERROR_INTERNET_INCORRECT_HANDLE_STATE:

View File

@ -787,7 +787,7 @@ void parse_update(char* buf, size_t len)
/*
* 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)
{

View File

@ -141,11 +141,11 @@ static int64_t last_iso_blocking_status;
* 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 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
*/
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;
// 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.
// 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.
// 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) {
switch (wParam) {
case DBT_DEVICEARRIVAL:

View File

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
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
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -165,7 +165,7 @@ END
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
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
CAPTION "Rufus 1.4.8.470"
CAPTION "Rufus 1.4.8.471"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -427,8 +427,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,8,470
PRODUCTVERSION 1,4,8,470
FILEVERSION 1,4,8,471
PRODUCTVERSION 1,4,8,471
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -445,13 +445,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.8.470"
VALUE "FileVersion", "1.4.8.471"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.8.470"
VALUE "ProductVersion", "1.4.8.471"
END
END
BLOCK "VarFileInfo"

View File

@ -199,22 +199,23 @@ BOOL GetUSBDevices(DWORD devnum)
if (list_size[s] != 0)
full_list_size += list_size[s]-1; // remove extra NUL terminator
}
full_list_size += 1; // add extra NUL terminator
if (full_list_size < 2)
return FALSE;
devid_list = (char*)malloc(full_list_size);
if (devid_list == NULL) {
uprintf("Could not allocate Device ID list\n");
return FALSE;
}
for (s=0, i=0; s<ARRAYSIZE(storage_name); s++) {
if (list_size[s] > 1) {
CM_Get_Device_ID_ListA(storage_name[s], &devid_list[i], list_size[s],
CM_GETIDLIST_FILTER_SERVICE|CM_GETIDLIST_FILTER_PRESENT); //
// The list_size is sometimes larger than required thus we need to find the real end
for (i += list_size[s]; i > 2; i--) {
if ((devid_list[i-2] != '\0') && (devid_list[i-1] == '\0') && (devid_list[i] == '\0'))
break;
devid_list = NULL;
if (full_list_size != 0) {
full_list_size += 1; // add extra NUL terminator
devid_list = (char*)malloc(full_list_size);
if (devid_list == NULL) {
uprintf("Could not allocate Device ID list\n");
return FALSE;
}
for (s=0, i=0; s<ARRAYSIZE(storage_name); s++) {
if (list_size[s] > 1) {
CM_Get_Device_ID_ListA(storage_name[s], &devid_list[i], list_size[s],
CM_GETIDLIST_FILTER_SERVICE|CM_GETIDLIST_FILTER_PRESENT); //
// The list_size is sometimes larger than required thus we need to find the real end
for (i += list_size[s]; i > 2; i--) {
if ((devid_list[i-2] != '\0') && (devid_list[i-1] == '\0') && (devid_list[i] == '\0'))
break;
}
}
}
}
@ -246,11 +247,11 @@ BOOL GetUSBDevices(DWORD devnum)
safe_strcpy(buffer, sizeof(buffer), lmprintf(MSG_045));
} else if (safe_strstr(buffer, vhd_name) != NULL) {
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
// 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.
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)
&& (CM_Get_Child(&device_inst, parent_inst, 0) == CR_SUCCESS)
&& (device_inst == dev_info_data.DevInst) ) {

View File

@ -27,6 +27,9 @@
static BOOL has_wimgapi = FALSE, has_7z = FALSE;
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
#define WIM_GENERIC_READ GENERIC_READ
#define WIM_OPEN_EXISTING OPEN_EXISTING
@ -46,7 +49,7 @@ static BOOL Get7ZipPath(void)
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)
{
PF_INIT(WIMCreateFile, Wimgapi);