mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[iso] Syslinux support improvements
* Allow the use of vanilla Syslinux by creating a /syslinux.cfg that references isolinux.cfg * Fix #40 and #42 * Workaround for #44 by search and replace of ISO label in .cfg * ISO9660 Joliet fixes
This commit is contained in:
		
							parent
							
								
									3e51ed7160
								
							
						
					
					
						commit
						f5939d18ab
					
				
					 6 changed files with 259 additions and 208 deletions
				
			
		
							
								
								
									
										54
									
								
								src/format.c
									
										
									
									
									
								
							
							
						
						
									
										54
									
								
								src/format.c
									
										
									
									
									
								
							|  | @ -28,6 +28,7 @@ | |||
| #include <stdlib.h> | ||||
| #include <process.h> | ||||
| #include <stddef.h> | ||||
| #include <ctype.h> | ||||
| 
 | ||||
| #include "msapi_utf8.h" | ||||
| #include "rufus.h" | ||||
|  | @ -167,7 +168,7 @@ static void ToValidLabel(WCHAR* name, BOOL bFAT) | |||
| 			} | ||||
| 		} | ||||
| 		if (found) continue; | ||||
| 		name[k++] = name[i]; | ||||
| 		name[k++] = bFAT?toupper(name[i]):name[i]; | ||||
| 	} | ||||
| 	name[k] = 0; | ||||
| 	if (bFAT) { | ||||
|  | @ -175,6 +176,8 @@ static void ToValidLabel(WCHAR* name, BOOL bFAT) | |||
| 	} else { | ||||
| 		name[32] = 0; | ||||
| 	} | ||||
| 	/* Needed for disk by label isolinux.cfg workaround */ | ||||
| 	wchar_to_utf8_no_alloc(name, iso_report.usb_label, sizeof(iso_report.usb_label)); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -426,6 +429,34 @@ static BOOL WritePBR(HANDLE hLogicalVolume) | |||
| 	return FALSE; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Issue a complete remount of the volume | ||||
|  */ | ||||
| static BOOL RemountVolume(char drive_letter) | ||||
| { | ||||
| 	char drive_guid[50]; | ||||
| 	char drive_name[] = "?:\\"; | ||||
| 
 | ||||
| 	drive_name[0] = drive_letter; | ||||
| 	if (GetVolumeNameForVolumeMountPointA(drive_name, drive_guid, sizeof(drive_guid))) { | ||||
| 		if (DeleteVolumeMountPointA(drive_name)) { | ||||
| 			Sleep(200); | ||||
| 			if (SetVolumeMountPointA(drive_name, drive_guid)) { | ||||
| 				uprintf("Successfully remounted %s on %s\n", drive_guid, drive_name); | ||||
| 			} else { | ||||
| 				uprintf("Failed to remount %s on %s\n", drive_guid, drive_name); | ||||
| 				// This will leave the drive unaccessible and must be flagged as an error
 | ||||
| 				FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_REMOUNT_VOLUME); | ||||
| 				return FALSE; | ||||
| 			} | ||||
| 		} else { | ||||
| 			uprintf("Could not remount %s %s\n", drive_name, WindowsErrorString()); | ||||
| 			// Try to continue regardless
 | ||||
| 		} | ||||
| 	} | ||||
| 	return TRUE; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Standalone thread for the formatting operation | ||||
|  */ | ||||
|  | @ -436,7 +467,6 @@ DWORD WINAPI FormatThread(LPVOID param) | |||
| 	HANDLE hLogicalVolume = INVALID_HANDLE_VALUE; | ||||
| 	SYSTEMTIME lt; | ||||
| 	char drive_name[] = "?:\\"; | ||||
| 	char drive_guid[50]; | ||||
| 	char bb_msg[512]; | ||||
| 	char logfile[MAX_PATH], *userdir; | ||||
| 	FILE* log_fd; | ||||
|  | @ -591,22 +621,8 @@ DWORD WINAPI FormatThread(LPVOID param) | |||
| 	// We issue a complete remount of the filesystem at on account of:
 | ||||
| 	// - Ensuring the file explorer properly detects that the volume was updated
 | ||||
| 	// - Ensuring that an NTFS system will be reparsed so that it becomes bootable
 | ||||
| 	if (GetVolumeNameForVolumeMountPointA(drive_name, drive_guid, sizeof(drive_guid))) { | ||||
| 		if (DeleteVolumeMountPointA(drive_name)) { | ||||
| 			Sleep(200); | ||||
| 			if (SetVolumeMountPointA(drive_name, drive_guid)) { | ||||
| 				uprintf("Successfully remounted %s on %s\n", drive_guid, drive_name); | ||||
| 			} else { | ||||
| 				uprintf("Failed to remount %s on %s\n", drive_guid, drive_name); | ||||
| 				// This will leave the drive unaccessible and must be flagged as an error
 | ||||
| 				FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_REMOUNT_VOLUME); | ||||
| 	if (!RemountVolume(drive_name[0])) | ||||
| 		goto out; | ||||
| 			} | ||||
| 		} else { | ||||
| 			uprintf("Could not remount %s %s\n", drive_name, WindowsErrorString()); | ||||
| 			// Try to continue regardless
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if (IsChecked(IDC_DOS)) { | ||||
| 		UpdateProgress(OP_DOS, -1.0f); | ||||
|  | @ -622,7 +638,6 @@ DWORD WINAPI FormatThread(LPVOID param) | |||
| 			break; | ||||
| 		case DT_ISO_NTFS: | ||||
| 		case DT_ISO_FAT: | ||||
| 			// TODO: ISO_FAT: ensure the ISO doesn't have ldlinux.sys as it will break the existing one
 | ||||
| 			if (iso_path != NULL) { | ||||
| 				PrintStatus(0, TRUE, "Copying ISO files..."); | ||||
| 				drive_name[2] = 0; | ||||
|  | @ -630,10 +645,11 @@ DWORD WINAPI FormatThread(LPVOID param) | |||
| 					FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; | ||||
| 					goto out; | ||||
| 				} | ||||
| 				// TODO: ISO_FAT: create menu and stuff
 | ||||
| 			} | ||||
| 			break; | ||||
| 		} | ||||
| 		// Issue another complete remount before we exit, to ensure we're clean
 | ||||
| 		RemountVolume(drive_name[0]); | ||||
| 	} | ||||
| 
 | ||||
| out: | ||||
|  |  | |||
							
								
								
									
										119
									
								
								src/iso.c
									
										
									
									
									
								
							
							
						
						
									
										119
									
								
								src/iso.c
									
										
									
									
									
								
							|  | @ -69,6 +69,7 @@ static const char *isolinux_name[] = { "isolinux.cfg", "syslinux.cfg", "extlinux | |||
| static uint8_t i_joliet_level = 0; | ||||
| static uint64_t total_blocks, nb_blocks; | ||||
| static BOOL scan_only = FALSE; | ||||
| static StrArray config_path; | ||||
| 
 | ||||
| // TODO: Timestamp & permissions preservation
 | ||||
| 
 | ||||
|  | @ -101,12 +102,61 @@ static void log_handler (cdio_log_level_t level, const char *message) | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Workaround for isolinux config files requiring an ISO label for kernel | ||||
|  * append that may be different from our USB label. | ||||
|  * NB: this is intended as a quick-and-dirty workaround, because it is the | ||||
|  * distro creator's job to make their config and labels also work with USB. | ||||
|  * As such, this process may fail if: | ||||
|  * - the label is on the block size limit, for cfg files of more than 2KB | ||||
|  * - the user changed the label to one that is larger than the one from the cfg | ||||
|  * - the cfg is weird (more than one label on the same line, etc.) | ||||
|  */ | ||||
| static void process_config(char* buf, size_t buf_size, const char* cfg_name) | ||||
| { | ||||
| 	char last_char, eol_char, *label; | ||||
| 	size_t i, j, k; | ||||
| 
 | ||||
| 	// Don't apply workaround if USB label is the same or longer than ISO
 | ||||
| 	if ( (strcmp(iso_report.label, iso_report.usb_label) == 0) | ||||
| 	  || (strlen(iso_report.label) < strlen(iso_report.usb_label)) ) | ||||
| 		return; | ||||
| 
 | ||||
| 	// Make sure our buffer is NUL terminated
 | ||||
| 	if (buf_size >= UDF_BLOCKSIZE)	// UDF_BLOCKSIZE = ISO_BLOCKSIZE = 2048
 | ||||
| 		buf_size = UDF_BLOCKSIZE-1; | ||||
| 	last_char = buf[buf_size]; | ||||
| 	buf[buf_size] = 0; | ||||
| 
 | ||||
| 	for (i=0; i<buf_size; i++) { | ||||
| 		// Check if there is a line starting with "append" (case insensitive)
 | ||||
| 		if (_strnicmp(&buf[i], "append", sizeof("append")-1) == 0) { | ||||
| 			for (j=i; (buf[j]!=0x00)&&(buf[j]!=0x0A)&&(buf[j]!=0x0D); j++);	// EOL
 | ||||
| 			eol_char = buf[j];	// Make sure the line is NUL terminated
 | ||||
| 			buf[j] = 0; | ||||
| 			label = strstr(&buf[i], iso_report.label); | ||||
| 			if (label != NULL) { | ||||
| 				// Since label is longer than usb_label we can replace it
 | ||||
| 				for (k=0; k<strlen(iso_report.label); k++) | ||||
| 					label[k] = (k<strlen(iso_report.usb_label))?iso_report.usb_label[k]:' '; | ||||
| 				uprintf("  Patched config file to use USB label '%s'\n", iso_report.usb_label); | ||||
| //				uprintf("  Patched line: '%s'\n", &buf[i]);
 | ||||
| 			} | ||||
| 			// Revert EOL
 | ||||
| 			buf[j] = eol_char; | ||||
| 			i = j; | ||||
| 		} | ||||
| 	} | ||||
| 	// Revert NUL terminator
 | ||||
| 	buf[buf_size] = last_char; | ||||
| } | ||||
| 
 | ||||
| // Returns 0 on success, nonzero on error
 | ||||
| static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz_path) | ||||
| { | ||||
| 	HANDLE file_handle = NULL; | ||||
| 	DWORD buf_size, wr_size; | ||||
| 	BOOL r; | ||||
| 	BOOL r, cfg_file; | ||||
| 	int i_length; | ||||
| 	size_t i, nul_pos; | ||||
| 	char* psz_fullpath = NULL; | ||||
|  | @ -140,14 +190,19 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha | |||
| 			} | ||||
| 		} else { | ||||
| 			i_file_length = udf_get_file_length(p_udf_dirent); | ||||
| 			// Check for an isolinux config file anywhere
 | ||||
| 			cfg_file = FALSE; | ||||
| 			for (i=0; i<ARRAYSIZE(isolinux_name); i++) { | ||||
| 				if (_stricmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 					cfg_file = TRUE; | ||||
| 			} | ||||
| 			if (scan_only) { | ||||
| 				// Check for a "bootmgr" file in root (psz_path = "")
 | ||||
| 				if ((*psz_path == 0) && (_stricmp(psz_basename, bootmgr_name) == 0)) | ||||
| 					iso_report.has_bootmgr = TRUE; | ||||
| 				// Check for a syslinux config file anywhere
 | ||||
| 				for (i=0; i<ARRAYSIZE(isolinux_name); i++) { | ||||
| 					if (_stricmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 				if (cfg_file) { | ||||
| 					iso_report.has_isolinux = TRUE; | ||||
| 					StrArrayAdd(&config_path, psz_fullpath); | ||||
| 				} | ||||
| 				if (i_file_length >= FOUR_GIGABYTES) | ||||
| 					iso_report.has_4GB_file = TRUE; | ||||
|  | @ -186,6 +241,8 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha | |||
| 					goto out; | ||||
| 				} | ||||
| 				buf_size = (DWORD)MIN(i_file_length, i_read); | ||||
| 				if (cfg_file) | ||||
| 					process_config((char*)buf, (size_t)buf_size, psz_fullpath); | ||||
| 				ISO_BLOCKING(r = WriteFile(file_handle, buf, buf_size, &wr_size, NULL)); | ||||
| 				if ((!r) || (buf_size != wr_size)) { | ||||
| 					uprintf("  Error writing file: %s\n", WindowsErrorString()); | ||||
|  | @ -220,7 +277,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) | |||
| { | ||||
| 	HANDLE file_handle = NULL; | ||||
| 	DWORD buf_size, wr_size; | ||||
| 	BOOL s; | ||||
| 	BOOL s, cfg_file; | ||||
| 	int i_length, r = 1; | ||||
| 	char psz_fullpath[1024], *psz_basename; | ||||
| 	const char *psz_iso_name = &psz_fullpath[strlen(psz_extract_dir)]; | ||||
|  | @ -260,14 +317,19 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) | |||
| 				goto out; | ||||
| 		} else { | ||||
| 			i_file_length = p_statbuf->size; | ||||
| 			// Check for an isolinux config file anywhere
 | ||||
| 			cfg_file = FALSE; | ||||
| 			for (i=0; i<ARRAYSIZE(isolinux_name); i++) { | ||||
| 				if (_stricmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 					cfg_file = TRUE; | ||||
| 			} | ||||
| 			if (scan_only) { | ||||
| 				// Check for a "bootmgr" file in root (psz_path = "")
 | ||||
| 				if ((*psz_path == 0) && (_stricmp(psz_basename, bootmgr_name) == 0)) | ||||
| 					iso_report.has_bootmgr = TRUE; | ||||
| 				// Check for a syslinux config file anywhere
 | ||||
| 				for (i=0; i<ARRAYSIZE(isolinux_name); i++) { | ||||
| 					if (_stricmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 				if (cfg_file) { | ||||
| 					iso_report.has_isolinux = TRUE; | ||||
| 					StrArrayAdd(&config_path, psz_fullpath); | ||||
| 				} | ||||
| 				if (i_file_length >= FOUR_GIGABYTES) | ||||
| 					iso_report.has_4GB_file = TRUE; | ||||
|  | @ -307,6 +369,8 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) | |||
| 					goto out; | ||||
| 				} | ||||
| 				buf_size = (DWORD)MIN(i_file_length, ISO_BLOCKSIZE); | ||||
| 				if (cfg_file) | ||||
| 					process_config((char*)buf, (size_t)buf_size, psz_fullpath); | ||||
| 				ISO_BLOCKING(s = WriteFile(file_handle, buf, buf_size, &wr_size, NULL)); | ||||
| 				if ((!s) || (buf_size != wr_size)) { | ||||
| 					uprintf("  Error writing file: %s\n", WindowsErrorString()); | ||||
|  | @ -330,13 +394,16 @@ out: | |||
| 
 | ||||
| BOOL ExtractISO(const char* src_iso, const char* dest_dir, bool scan) | ||||
| { | ||||
| 	size_t i; | ||||
| 	FILE* fd; | ||||
| 	BOOL r = FALSE; | ||||
| 	iso9660_t* p_iso = NULL; | ||||
| 	udf_t* p_udf = NULL;  | ||||
| 	udf_dirent_t* p_udf_root; | ||||
| 	LONG progress_style; | ||||
| 	char* vol_id; | ||||
| 	const char* scan_text = "Scanning ISO image...\n"; | ||||
| 	char syslinux_path[64]; | ||||
| 	const char* scan_text = "Scanning ISO image..."; | ||||
| 
 | ||||
| 	if ((src_iso == NULL) || (dest_dir == NULL)) | ||||
| 		return FALSE; | ||||
|  | @ -351,6 +418,8 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, bool scan) | |||
| 		iso_report.has_4GB_file = FALSE; | ||||
| 		iso_report.has_bootmgr = FALSE; | ||||
| 		iso_report.has_isolinux = FALSE; | ||||
| 		// String array of all isolinux/syslinux locations
 | ||||
| 		StrArrayCreate(&config_path, 8); | ||||
| 		// Change the Window title and static text
 | ||||
| 		SetWindowTextU(hISOProgressDlg, scan_text); | ||||
| 		SetWindowTextU(hISOFileName, scan_text); | ||||
|  | @ -412,6 +481,38 @@ out: | |||
| 	if (scan_only) { | ||||
| 		// We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here
 | ||||
| 		iso_report.projected_size = total_blocks * ISO_BLOCKSIZE; | ||||
| 		// We will link the existing isolinux.cfg from a syslinux.cfg we create
 | ||||
| 		// If multiple config file exist, choose the one with the shortest path
 | ||||
| 		if (iso_report.has_isolinux) { | ||||
| 			safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[0]); | ||||
| 			for (i=1; i<config_path.Index; i++) { | ||||
| 				if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.Table[i])) | ||||
| 					safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[i]); | ||||
| 			} | ||||
| 			uprintf("Will use %s for Syslinux\n", iso_report.cfg_path); | ||||
| 		} | ||||
| 		StrArrayDestroy(&config_path); | ||||
| 	} else if (iso_report.has_isolinux) { | ||||
| 		safe_sprintf(syslinux_path, sizeof(syslinux_path), "%s\\syslinux.cfg", dest_dir); | ||||
| 		// Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg
 | ||||
| 		fd = fopen(syslinux_path, "r"); | ||||
| 		if (fd == NULL) { | ||||
| 			fd = fopen(syslinux_path, "w");	// No "/syslinux.cfg" => create a new one
 | ||||
| 			if (fd == NULL) { | ||||
| 				uprintf("Unable to create %s - booting from USB will not work\n", syslinux_path); | ||||
| 				r = 1; | ||||
| 			} else { | ||||
| 				uprintf("Creating: %s\n", syslinux_path); | ||||
| 				fprintf(fd, "DEFAULT loadconfig\n\nLABEL loadconfig\n  CONFIG %s\n", iso_report.cfg_path); | ||||
| 				for (i=safe_strlen(iso_report.cfg_path); (i>0)&&(iso_report.cfg_path[i]!='/'); i--); | ||||
| 				if (i>0) { | ||||
| 					iso_report.cfg_path[i] = 0; | ||||
| 					fprintf(fd, "  APPEND %s/\n", iso_report.cfg_path); | ||||
| 					iso_report.cfg_path[i] = '/'; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		fclose(fd); | ||||
| 	} | ||||
| 	SendMessage(hISOProgressDlg, UM_ISO_EXIT, 0, 0); | ||||
| 	if (p_iso != NULL) | ||||
|  |  | |||
|  | @ -303,24 +303,26 @@ bool cdio_charset_to_utf8(char *src, size_t src_len, cdio_utf8_t **dst, | |||
|   if (src == NULL || dst == NULL || src_charset == NULL || strcmp(src_charset, "UCS-2BE") != 0) | ||||
|     return false; | ||||
| 
 | ||||
|   /* Compute UCS-2 src length */ | ||||
|   if (src_len == (size_t)-1) { | ||||
|     for (src_len = 0; ((uint16_t*)src)[src_len] !=0; src_len++); | ||||
|     src_len <<=2; | ||||
|   } else { | ||||
|     src_len >>=1; | ||||
|   } | ||||
| 
 | ||||
|   /* Eliminate empty strings */ | ||||
|   if ((src_len < 2) || ((src[0] == 0) && (src[1] == 0))) { | ||||
|   if ((src_len < 1) || ((src[0] == 0) && (src[1] == 0))) { | ||||
|     *dst = NULL; | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
|   /* Perform byte reversal */ | ||||
|   le_src = (wchar_t*)malloc(src_len+2); | ||||
|   for (i=0; i<src_len; i+=2) { | ||||
|     ((char*)le_src)[i] = src[i+1]; | ||||
|     ((char*)le_src)[i+1] = src[i]; | ||||
|   le_src = (wchar_t*)malloc(2*src_len+2); | ||||
|   for (i=0; i<src_len; i++) { | ||||
|     ((char*)le_src)[2*i] = src[2*i+1]; | ||||
|     ((char*)le_src)[2*i+1] = src[2*i]; | ||||
|   } | ||||
|   le_src[src_len/2] = 0; | ||||
|   le_src[src_len] = 0; | ||||
|   *dst = wchar_to_utf8(le_src); | ||||
|   free(le_src); | ||||
| 
 | ||||
|  |  | |||
|  | @ -85,33 +85,6 @@ struct _iso9660_s { | |||
| 			     */ | ||||
| }; | ||||
| 
 | ||||
| /*!
 | ||||
|    Change trailing blanks in null-terminated *str to nulls | ||||
|    If the end result is an empty string, *str is freed | ||||
| */ | ||||
| static void | ||||
| strip_trail (char** str) | ||||
| { | ||||
|   int j; | ||||
| 
 | ||||
|   if (*str == NULL) | ||||
|     return; | ||||
| 
 | ||||
|   for (j = strlen (*str) - 1; j >= 0; j--) | ||||
|     { | ||||
|       if ((*str)[j] != ' ') | ||||
|         break; | ||||
| 
 | ||||
|       (*str)[j] = '\0'; | ||||
|     } | ||||
| 
 | ||||
|   if ((*str)[0] == 0) | ||||
|     { | ||||
|       free(*str); | ||||
|       *str = NULL; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| static long int iso9660_seek_read_framesize (const iso9660_t *p_iso,  | ||||
| 					     void *ptr, lsn_t start,  | ||||
| 					     long int size,  | ||||
|  | @ -299,6 +272,72 @@ check_pvd (const iso9660_pvd_t *p_pvd, cdio_log_level_t log_level) | |||
|   return true; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*!
 | ||||
|   Core procedure for the iso9660_ifs_get_###_id() calls. | ||||
|   pvd_member/svd_member is a pointer to an achar_t or dchar_t | ||||
|   ID string which we can superset as char. | ||||
|   If the Joliet converted string is the same as the achar_t/dchar_t | ||||
|   one, we fall back to using the latter, as it may be longer. | ||||
| */ | ||||
| static inline bool | ||||
| get_member_id(iso9660_t *p_iso, cdio_utf8_t **p_psz_member_id, | ||||
|               char* pvd_member, char* svd_member, size_t max_size) | ||||
| { | ||||
|   int j; | ||||
|   bool strip; | ||||
| 
 | ||||
|   if (!p_iso) { | ||||
|     *p_psz_member_id = NULL; | ||||
|     return false; | ||||
|   } | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* Translate USC-2 string from Secondary Volume Descriptor */ | ||||
|     if (cdio_charset_to_utf8(svd_member, max_size, | ||||
|                             p_psz_member_id, "UCS-2BE")) { | ||||
|       /* NB: *p_psz_member_id is never NULL on success. */ | ||||
|       if (strncmp(*p_psz_member_id, pvd_member, | ||||
|                   strlen(*p_psz_member_id)) != 0) { | ||||
|         /* Strip trailing spaces */ | ||||
|         for (j = strlen(*p_psz_member_id)-1; j >= 0; j--) { | ||||
|           if ((*p_psz_member_id)[j] != ' ') | ||||
|             break; | ||||
|           (*p_psz_member_id)[j] = '\0'; | ||||
|         } | ||||
|         if ((*p_psz_member_id)[0] != 0) { | ||||
|           /* Joliet string is not empty and differs from
 | ||||
|              non Joliet one => use it */ | ||||
|           return true; | ||||
|         } | ||||
|       } | ||||
|       /* Joliet string was either empty or same */ | ||||
|       free(*p_psz_member_id); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_member_id = calloc(max_size+1, sizeof(cdio_utf8_t)); | ||||
|   if (!*p_psz_member_id) { | ||||
|     cdio_warn("Memory allocation error"); | ||||
|     return false; | ||||
|   } | ||||
|   /* Copy string while removing trailing spaces */ | ||||
|   (*p_psz_member_id)[max_size] = 0; | ||||
|   for (strip=true, j=max_size-1; j>=0; j--) { | ||||
|     if (strip && (pvd_member[j] == ' ')) | ||||
|       continue; | ||||
|     strip = false; | ||||
|     (*p_psz_member_id)[j] = pvd_member[j]; | ||||
|   } | ||||
|   if (strlen(*p_psz_member_id) == 0) { | ||||
|     free(*p_psz_member_id); | ||||
|     *p_psz_member_id = NULL; | ||||
|     return false; | ||||
|   } | ||||
|   return true; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*!  
 | ||||
|   Return the application ID.  NULL is returned in psz_app_id if there | ||||
|   is some problem in getting this. | ||||
|  | @ -307,32 +346,14 @@ bool | |||
| iso9660_ifs_get_application_id(iso9660_t *p_iso,  | ||||
| 			       /*out*/ cdio_utf8_t **p_psz_app_id) | ||||
| { | ||||
|   if (!p_iso) { | ||||
|     *p_psz_app_id = NULL; | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* TODO: check that we haven't reached the maximum size.
 | ||||
|        If we have, perhaps we've truncated and if we can get  | ||||
|        longer results *and* have the same character using | ||||
|        the PVD, do that. | ||||
|      */ | ||||
|   if ( cdio_charset_to_utf8(p_iso->svd.application_id, | ||||
|                             ISO_MAX_APPLICATION_ID, | ||||
|                             p_psz_app_id, "UCS-2BE")) { | ||||
|       strip_trail(p_psz_app_id); | ||||
|       return (*p_psz_app_id != NULL); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_app_id = iso9660_get_application_id( &(p_iso->pvd) ); | ||||
|   return *p_psz_app_id != NULL && strlen(*p_psz_app_id); | ||||
|   return get_member_id(p_iso, p_psz_app_id, | ||||
|                        (char*)p_iso->pvd.application_id, | ||||
|                        (char*)p_iso->svd.application_id, | ||||
|                        ISO_MAX_APPLICATION_ID); | ||||
| } | ||||
| 
 | ||||
| /*!  
 | ||||
|   Return the Joliet level recognaized for p_iso. | ||||
|   Return the Joliet level recognized for p_iso. | ||||
| */ | ||||
| uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso) | ||||
| { | ||||
|  | @ -348,27 +369,10 @@ bool | |||
| iso9660_ifs_get_preparer_id(iso9660_t *p_iso, | ||||
| 			/*out*/ cdio_utf8_t **p_psz_preparer_id) | ||||
| { | ||||
|   if (!p_iso) { | ||||
|     *p_psz_preparer_id = NULL; | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* TODO: check that we haven't reached the maximum size.
 | ||||
|        If we have, perhaps we've truncated and if we can get  | ||||
|        longer results *and* have the same character using | ||||
|        the PVD, do that. | ||||
|      */ | ||||
|     if ( cdio_charset_to_utf8(p_iso->svd.preparer_id, ISO_MAX_PREPARER_ID, | ||||
|                               p_psz_preparer_id, "UCS-2BE") ) { | ||||
|       strip_trail(p_psz_preparer_id); | ||||
|       return (*p_psz_preparer_id != NULL); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_preparer_id = iso9660_get_preparer_id( &(p_iso->pvd) ); | ||||
|   return *p_psz_preparer_id != NULL && strlen(*p_psz_preparer_id); | ||||
|   return get_member_id(p_iso, p_psz_preparer_id, | ||||
|                        (char*)p_iso->pvd.preparer_id, | ||||
|                        (char*)p_iso->svd.preparer_id, | ||||
|                        ISO_MAX_PREPARER_ID); | ||||
| } | ||||
| 
 | ||||
| /*!
 | ||||
|  | @ -378,30 +382,12 @@ iso9660_ifs_get_preparer_id(iso9660_t *p_iso, | |||
| bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso, | ||||
|                                   /*out*/ cdio_utf8_t **p_psz_publisher_id) | ||||
| { | ||||
|   if (!p_iso) { | ||||
|     *p_psz_publisher_id = NULL; | ||||
|     return false; | ||||
|   return get_member_id(p_iso, p_psz_publisher_id, | ||||
|                        (char*)p_iso->pvd.publisher_id, | ||||
|                        (char*)p_iso->svd.publisher_id, | ||||
|                        ISO_MAX_PUBLISHER_ID); | ||||
| } | ||||
| 
 | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* TODO: check that we haven't reached the maximum size.
 | ||||
|        If we have, perhaps we've truncated and if we can get  | ||||
|        longer results *and* have the same character using | ||||
|        the PVD, do that. | ||||
|      */ | ||||
|     if( cdio_charset_to_utf8(p_iso->svd.publisher_id, ISO_MAX_PUBLISHER_ID, | ||||
|                              p_psz_publisher_id, "UCS-2BE") ) { | ||||
|       strip_trail(p_psz_publisher_id); | ||||
|       return (*p_psz_publisher_id != NULL); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_publisher_id = iso9660_get_publisher_id( &(p_iso->pvd) ); | ||||
|   return *p_psz_publisher_id != NULL && strlen(*p_psz_publisher_id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*!
 | ||||
|    Return a string containing the PVD's publisher id with trailing | ||||
|    blanks removed. | ||||
|  | @ -409,30 +395,12 @@ bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso, | |||
| bool iso9660_ifs_get_system_id(iso9660_t *p_iso, | ||||
| 			       /*out*/ cdio_utf8_t **p_psz_system_id) | ||||
| { | ||||
|   if (!p_iso) { | ||||
|     *p_psz_system_id = NULL; | ||||
|     return false; | ||||
|   return get_member_id(p_iso, p_psz_system_id, | ||||
|                        (char*)p_iso->pvd.system_id, | ||||
|                        (char*)p_iso->svd.system_id, | ||||
|                        ISO_MAX_SYSTEM_ID); | ||||
| } | ||||
| 
 | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* TODO: check that we haven't reached the maximum size.
 | ||||
|        If we have, perhaps we've truncated and if we can get  | ||||
|        longer results *and* have the same character using | ||||
|        the PVD, do that. | ||||
|      */ | ||||
|     if ( cdio_charset_to_utf8(p_iso->svd.system_id, ISO_MAX_SYSTEM_ID, | ||||
|                               p_psz_system_id, "UCS-2BE") ) { | ||||
|       strip_trail(p_psz_system_id); | ||||
|       return (*p_psz_system_id != NULL); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_system_id = iso9660_get_system_id( &(p_iso->pvd) ); | ||||
|   return *p_psz_system_id != NULL && strlen(*p_psz_system_id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*!
 | ||||
|    Return a string containing the PVD's publisher id with trailing | ||||
|    blanks removed. | ||||
|  | @ -440,30 +408,12 @@ bool iso9660_ifs_get_system_id(iso9660_t *p_iso, | |||
| bool iso9660_ifs_get_volume_id(iso9660_t *p_iso, | ||||
| 			       /*out*/ cdio_utf8_t **p_psz_volume_id) | ||||
| { | ||||
|   if (!p_iso) { | ||||
|     *p_psz_volume_id = NULL; | ||||
|     return false; | ||||
|   return get_member_id(p_iso, p_psz_volume_id, | ||||
|                        (char*)p_iso->pvd.volume_id, | ||||
|                        (char*)p_iso->svd.volume_id, | ||||
|                        ISO_MAX_VOLUME_ID); | ||||
| } | ||||
| 
 | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* TODO: check that we haven't reached the maximum size.
 | ||||
|        If we have, perhaps we've truncated and if we can get  | ||||
|        longer results *and* have the same character using | ||||
|        the PVD, do that. | ||||
|      */ | ||||
|     if ( cdio_charset_to_utf8(p_iso->svd.volume_id, ISO_MAX_VOLUME_ID, | ||||
|                               p_psz_volume_id, "UCS-2BE") ) { | ||||
|       strip_trail(p_psz_volume_id); | ||||
|       return (*p_psz_volume_id != NULL); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_volume_id = iso9660_get_volume_id( &(p_iso->pvd) ); | ||||
|   return *p_psz_volume_id != NULL && strlen(*p_psz_volume_id); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*!
 | ||||
|    Return a string containing the PVD's publisher id with trailing | ||||
|    blanks removed. | ||||
|  | @ -471,29 +421,10 @@ bool iso9660_ifs_get_volume_id(iso9660_t *p_iso, | |||
| bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso, | ||||
| 				  /*out*/ cdio_utf8_t **p_psz_volumeset_id) | ||||
| { | ||||
|   if (!p_iso) { | ||||
|     *p_psz_volumeset_id = NULL; | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
| #ifdef HAVE_JOLIET   | ||||
|   if (p_iso->i_joliet_level) { | ||||
|     /* TODO: check that we haven't reached the maximum size.
 | ||||
|        If we have, perhaps we've truncated and if we can get  | ||||
|        longer results *and* have the same character using | ||||
|        the PVD, do that. | ||||
|      */ | ||||
|     if ( cdio_charset_to_utf8(p_iso->svd.volume_set_id,  | ||||
|                               ISO_MAX_VOLUMESET_ID,  | ||||
|                               p_psz_volumeset_id, | ||||
|                               "UCS-2BE") ) { | ||||
|       strip_trail(p_psz_volumeset_id); | ||||
|       return (*p_psz_volumeset_id != NULL); | ||||
|     } | ||||
|   } | ||||
| #endif /*HAVE_JOLIET*/ | ||||
|   *p_psz_volumeset_id = iso9660_get_volumeset_id( &(p_iso->pvd) ); | ||||
|   return *p_psz_volumeset_id != NULL && strlen(*p_psz_volumeset_id); | ||||
|   return get_member_id(p_iso, p_psz_volumeset_id, | ||||
|                        (char*)p_iso->pvd.volume_set_id, | ||||
|                        (char*)p_iso->svd.volume_set_id, | ||||
|                        ISO_MAX_VOLUMESET_ID); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -145,7 +145,9 @@ typedef struct { | |||
| 
 | ||||
| /* ISO details that the application may want */ | ||||
| typedef struct { | ||||
| 	char label[64]; | ||||
| 	char label[192];		/* 3*64 to account for UTF-8 */ | ||||
| 	char usb_label[192];	/* converted USB label for workaround */ | ||||
| 	char cfg_path[128];		/* path to the ISO's isolinux.cfg */ | ||||
| 	uint64_t projected_size; | ||||
| 	BOOL has_4GB_file; | ||||
| 	BOOL has_bootmgr; | ||||
|  | @ -204,9 +206,8 @@ __inline static BOOL UnlockDrive(HANDLE hDrive) | |||
| /* Basic String Array */ | ||||
| typedef struct { | ||||
| 	char** Table; | ||||
| 	size_t Size; | ||||
| 	size_t Index; | ||||
| 	size_t Max; | ||||
| 	size_t Index;	// Current array size
 | ||||
| 	size_t Max;		// Maximum array size
 | ||||
| } StrArray; | ||||
| extern void StrArrayCreate(StrArray* arr, size_t initial_size); | ||||
| extern void StrArrayAdd(StrArray* arr, const char* str); | ||||
|  |  | |||
							
								
								
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL | |||
| IDD_DIALOG DIALOGEX 12, 12, 206, 278 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_APPWINDOW | ||||
| CAPTION "Rufus v1.1.1.140" | ||||
| CAPTION "Rufus v1.1.1.141" | ||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||
| BEGIN | ||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,236,50,14 | ||||
|  | @ -71,7 +71,7 @@ BEGIN | |||
|     DEFPUSHBUTTON   "OK",IDOK,231,175,50,14,WS_GROUP | ||||
|     CONTROL         "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL, | ||||
|                     "SysLink",WS_TABSTOP,46,47,114,9 | ||||
|     LTEXT           "Version 1.1.1 (Build 140)",IDC_STATIC,46,19,78,8 | ||||
|     LTEXT           "Version 1.1.1 (Build 141)",IDC_STATIC,46,19,78,8 | ||||
|     PUSHBUTTON      "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP | ||||
|     EDITTEXT        IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL | ||||
|     LTEXT           "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 | ||||
|  | @ -220,8 +220,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 1,1,1,140 | ||||
|  PRODUCTVERSION 1,1,1,140 | ||||
|  FILEVERSION 1,1,1,141 | ||||
|  PRODUCTVERSION 1,1,1,141 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -238,13 +238,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "akeo.ie" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "1.1.1.140" | ||||
|             VALUE "FileVersion", "1.1.1.141" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "1.1.1.140" | ||||
|             VALUE "ProductVersion", "1.1.1.141" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue