mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[locale] finalized DOS keyboard locale setup
* added FreeDOS support * closes #3
This commit is contained in:
		
							parent
							
								
									7fbee9d6d7
								
							
						
					
					
						commit
						75e94c1087
					
				
					 6 changed files with 990 additions and 376 deletions
				
			
		
							
								
								
									
										1
									
								
								TODO.txt
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO.txt
									
										
									
									
									
								
							|  | @ -1,6 +1,5 @@ | ||||||
| o Create a report file with failed block details on bad blocks | o Create a report file with failed block details on bad blocks | ||||||
| o Allow the provision of external DOS files | o Allow the provision of external DOS files | ||||||
| o Set DOS keyboard according to locale |  | ||||||
| o Allow selection of one of the existing compatible partitions (keep existing MBR) vs. full repartitioning (overwrite MBR) | o Allow selection of one of the existing compatible partitions (keep existing MBR) vs. full repartitioning (overwrite MBR) | ||||||
| o Bootable NTFS/exFAT (http://sourceforge.net/projects/grub4dos)? | o Bootable NTFS/exFAT (http://sourceforge.net/projects/grub4dos)? | ||||||
| o GPT support? | o GPT support? | ||||||
|  |  | ||||||
							
								
								
									
										73
									
								
								src/dos.c
									
										
									
									
									
								
							
							
						
						
									
										73
									
								
								src/dos.c
									
										
									
									
									
								
							|  | @ -174,6 +174,9 @@ static BOOL Patch_COMMAND_COM(size_t filestart, size_t filesize) | ||||||
| 		uprintf("  unexpected file size\n"); | 		uprintf("  unexpected file size\n"); | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	} | 	} | ||||||
|  | //	See #24: https://github.com/pbatard/rufus/issues/24
 | ||||||
|  | //	uprintf("&DiskImage[filestart(=%x)+0x650c] = %p\n", filestart, &DiskImage[filestart+0x650c]);
 | ||||||
|  | //	uprintf("&DiskImage[0] = %p\n", &DiskImage[0]);
 | ||||||
| 	if (memcmp(&DiskImage[filestart+0x650c], expected, sizeof(expected)) != 0) { | 	if (memcmp(&DiskImage[filestart+0x650c], expected, sizeof(expected)) != 0) { | ||||||
| 		uprintf("  unexpected binary data\n"); | 		uprintf("  unexpected binary data\n"); | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
|  | @ -336,14 +339,14 @@ static BOOL ExtractMSDOS(const char* path) | ||||||
| 		for (j=0; r && j<ARRAYSIZE(extractlist); j++) { | 		for (j=0; r && j<ARRAYSIZE(extractlist); j++) { | ||||||
| 			if (memcmp(extractlist[j], &DiskImage[FAT12_ROOTDIR_OFFSET + i*FAT_BYTES_PER_DIRENT], 8+3) == 0) { | 			if (memcmp(extractlist[j], &DiskImage[FAT12_ROOTDIR_OFFSET + i*FAT_BYTES_PER_DIRENT], 8+3) == 0) { | ||||||
| 				r = ExtractFAT(i, (j<3)?path:locale_path); | 				r = ExtractFAT(i, (j<3)?path:locale_path); | ||||||
| 				if ((j == 6) || (j == 12)) | 				if ((j == 2) || (j == 7) || (j == 12)) | ||||||
| 					UpdateProgress(OP_DOS, -1.0f); | 					UpdateProgress(OP_DOS, -1.0f); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	FreeLibrary(hDLL); | 	FreeLibrary(hDLL); | ||||||
| 	SetMSDOSLocale(path); | 	if (r) | ||||||
|  | 		r = SetDOSLocale(path, FALSE); | ||||||
| 
 | 
 | ||||||
| 	return r; | 	return r; | ||||||
| } | } | ||||||
|  | @ -351,13 +354,23 @@ static BOOL ExtractMSDOS(const char* path) | ||||||
| /* Extract the FreeDOS files embedded in the app */ | /* Extract the FreeDOS files embedded in the app */ | ||||||
| BOOL ExtractFreeDOS(const char* path) | BOOL ExtractFreeDOS(const char* path) | ||||||
| { | { | ||||||
| 	const char* res_name[2] = { "COMMAND.COM", "KERNEL.SYS" }; | 	const char* res_name[] = { "COMMAND.COM", "KERNEL.SYS", "DISPLAY.EXE", "KEYB.EXE", | ||||||
| 	const int res_id[2] = { IDR_FD_COMMAND_COM, IDR_FD_KERNEL_SYS }; | 		"MODE.COM", "KEYBOARD.SYS", "KEYBRD2.SYS", "KEYBRD3.SYS", "KEYBRD4.SYS", "ega.cpx", | ||||||
| 	char filename[MAX_PATH]; | 		"ega2.cpx", "ega3.cpx", "ega4.cpx", "ega5.cpx", "ega6.cpx", | ||||||
| 	HGLOBAL res_handle[2]; | 		"ega7.cpx", "ega8.cpx", "ega9.cpx", "ega10.cpx", "ega11.cpx", | ||||||
| 	HRSRC res[2]; | 		"ega12.cpx", "ega13.cpx", "ega14.cpx", "ega15.cpx", "ega16.cpx", | ||||||
| 	BYTE* res_data[2]; | 		"ega17.cpx", "ega18.cpx" }; | ||||||
| 	DWORD res_size[2], Size; | 	const int res_id[ARRAYSIZE(res_name)] = { IDR_FD_COMMAND_COM, IDR_FD_KERNEL_SYS, IDR_FD_DISPLAY_EXE, IDR_FD_KEYB_EXE, | ||||||
|  | 		IDR_FD_MODE_COM, IDR_FD_KB1_SYS, IDR_FD_KB2_SYS, IDR_FD_KB3_SYS, IDR_FD_KB4_SYS, IDR_FD_EGA1_CPX, | ||||||
|  | 		IDR_FD_EGA2_CPX, IDR_FD_EGA3_CPX, IDR_FD_EGA4_CPX, IDR_FD_EGA5_CPX, IDR_FD_EGA6_CPX, | ||||||
|  | 		IDR_FD_EGA7_CPX, IDR_FD_EGA8_CPX, IDR_FD_EGA9_CPX, IDR_FD_EGA10_CPX, IDR_FD_EGA11_CPX, | ||||||
|  | 		IDR_FD_EGA12_CPX, IDR_FD_EGA13_CPX, IDR_FD_EGA14_CPX, IDR_FD_EGA15_CPX, IDR_FD_EGA16_CPX, | ||||||
|  | 		IDR_FD_EGA17_CPX, IDR_FD_EGA18_CPX }; | ||||||
|  | 	char filename[MAX_PATH], locale_path[MAX_PATH]; | ||||||
|  | 	HGLOBAL res_handle; | ||||||
|  | 	HRSRC res; | ||||||
|  | 	BYTE* res_data; | ||||||
|  | 	DWORD res_size, Size; | ||||||
| 	HANDLE hFile; | 	HANDLE hFile; | ||||||
| 	int i; | 	int i; | ||||||
| 
 | 
 | ||||||
|  | @ -366,21 +379,26 @@ BOOL ExtractFreeDOS(const char* path) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for (i=0; i<2; i++) { | 	// Reduce the visible mess by placing all the locale files into a subdir
 | ||||||
| 		res[i] = FindResource(hMainInstance, MAKEINTRESOURCE(res_id[i]), RT_RCDATA); | 	safe_strcpy(locale_path, sizeof(locale_path), path); | ||||||
| 		if (res[i] == NULL) { | 	safe_strcat(locale_path, sizeof(locale_path), "\\LOCALE"); | ||||||
|  | 	CreateDirectoryA(locale_path, NULL); | ||||||
|  | 
 | ||||||
|  | 	for (i=0; i<ARRAYSIZE(res_name); i++) { | ||||||
|  | 		res = FindResource(hMainInstance, MAKEINTRESOURCE(res_id[i]), RT_RCDATA); | ||||||
|  | 		if (res == NULL) { | ||||||
| 			uprintf("Unable to locate FreeDOS resource %s: %s\n", res_name[i], WindowsErrorString()); | 			uprintf("Unable to locate FreeDOS resource %s: %s\n", res_name[i], WindowsErrorString()); | ||||||
| 			return FALSE; | 			return FALSE; | ||||||
| 		} | 		} | ||||||
| 		res_handle[i] = LoadResource(NULL, res[i]); | 		res_handle = LoadResource(NULL, res); | ||||||
| 		if (res_handle[i] == NULL) { | 		if (res_handle == NULL) { | ||||||
| 			uprintf("Unable to load FreeDOS resource %s: %s\n", res_name[i], WindowsErrorString()); | 			uprintf("Unable to load FreeDOS resource %s: %s\n", res_name[i], WindowsErrorString()); | ||||||
| 			return FALSE; | 			return FALSE; | ||||||
| 		} | 		} | ||||||
| 		res_data[i] = (BYTE*)LockResource(res_handle[i]); | 		res_data = (BYTE*)LockResource(res_handle); | ||||||
| 		res_size[i] = SizeofResource(NULL, res[i]); | 		res_size = SizeofResource(NULL, res); | ||||||
| 
 | 
 | ||||||
| 		strcpy(filename, path); | 		strcpy(filename, (i<3)?path:locale_path); | ||||||
| 		safe_strcat(filename, sizeof(filename), "\\"); | 		safe_strcat(filename, sizeof(filename), "\\"); | ||||||
| 		safe_strcat(filename, sizeof(filename), res_name[i]); | 		safe_strcat(filename, sizeof(filename), res_name[i]); | ||||||
| 
 | 
 | ||||||
|  | @ -391,7 +409,7 @@ BOOL ExtractFreeDOS(const char* path) | ||||||
| 			return FALSE; | 			return FALSE; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if ((!WriteFile(hFile, res_data[i], res_size[i], &Size, 0)) || (res_size[i] != Size)) { | 		if ((!WriteFile(hFile, res_data, res_size, &Size, 0)) || (res_size != Size)) { | ||||||
| 			uprintf("Couldn't write file '%s': %s.\n", filename, WindowsErrorString()); | 			uprintf("Couldn't write file '%s': %s.\n", filename, WindowsErrorString()); | ||||||
| 			safe_closehandle(hFile); | 			safe_closehandle(hFile); | ||||||
| 			return FALSE; | 			return FALSE; | ||||||
|  | @ -401,20 +419,13 @@ BOOL ExtractFreeDOS(const char* path) | ||||||
| 		// thus we would need to have a separate header with each file's timestamps
 | 		// thus we would need to have a separate header with each file's timestamps
 | ||||||
| 
 | 
 | ||||||
| 		safe_closehandle(hFile); | 		safe_closehandle(hFile); | ||||||
| 		uprintf("Succesfully wrote '%s' (%d bytes)\n", filename, res_size[i]); | 		uprintf("Succesfully wrote '%s' (%d bytes)\n", filename, res_size); | ||||||
|  | 
 | ||||||
|  | 		if ((i == 4) || (i == 10) || (i == 16) || (i == 22) || (i == ARRAYSIZE(res_name)-1)) | ||||||
|  | 			UpdateProgress(OP_DOS, -1.0f); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// There needs to be at least an AUTOEXEC.BAT to avoid the user being prompted for date and time
 | 	return SetDOSLocale(path, TRUE); | ||||||
| 	strcpy(filename, path); |  | ||||||
| 	safe_strcat(filename, sizeof(filename), "\\AUTOEXEC.BAT"); |  | ||||||
| 	hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, |  | ||||||
| 		NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); |  | ||||||
| 	if (hFile == INVALID_HANDLE_VALUE) { |  | ||||||
| 		uprintf("Unable to create 'AUTOEXEC.BAT': %s.\n", WindowsErrorString()); |  | ||||||
| 	} |  | ||||||
| 	safe_closehandle(hFile); |  | ||||||
| 
 |  | ||||||
| 	return TRUE; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BOOL ExtractDOS(const char* path, int dos_type) | BOOL ExtractDOS(const char* path, int dos_type) | ||||||
|  |  | ||||||
|  | @ -137,4 +137,4 @@ typedef struct _LONG_FILE_NAME_ENTRY { | ||||||
|                                           FAT_DIRENT_ATTR_SYSTEM |    \ |                                           FAT_DIRENT_ATTR_SYSTEM |    \ | ||||||
|                                           FAT_DIRENT_ATTR_VOLUME_ID) |                                           FAT_DIRENT_ATTR_VOLUME_ID) | ||||||
| 
 | 
 | ||||||
| extern BOOL SetMSDOSLocale(const char* path); | extern BOOL SetDOSLocale(const char* path, BOOL bFreeDOS); | ||||||
|  |  | ||||||
							
								
								
									
										1282
									
								
								src/dos_locale.c
									
										
									
									
									
								
							
							
						
						
									
										1282
									
								
								src/dos_locale.c
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -618,8 +618,8 @@ static void InitProgress(void) | ||||||
| 		nb_slots[OP_BADBLOCKS] = -1; | 		nb_slots[OP_BADBLOCKS] = -1; | ||||||
| 	} | 	} | ||||||
| 	if (IsChecked(IDC_DOS)) { | 	if (IsChecked(IDC_DOS)) { | ||||||
| 		// 3 slots + 1 for PBR writing
 | 		// 1 extra slot for PBR writing
 | ||||||
| 		nb_slots[OP_DOS] = 3+1; | 		nb_slots[OP_DOS] = ((ComboBox_GetCurSel(hDOSType) == DT_FREEDOS)?5:3)+1; | ||||||
| 	} | 	} | ||||||
| 	nb_slots[OP_PARTITION] = 1; | 	nb_slots[OP_PARTITION] = 1; | ||||||
| 	nb_slots[OP_FIX_MBR] = 1; | 	nb_slots[OP_FIX_MBR] = 1; | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 206, 278 | IDD_DIALOG DIALOGEX 12, 12, 206, 278 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_APPWINDOW | EXSTYLE WS_EX_APPWINDOW | ||||||
| CAPTION "Rufus v1.0.5.103" | CAPTION "Rufus v1.0.5.104" | ||||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||||
| BEGIN | BEGIN | ||||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,236,50,14 |     DEFPUSHBUTTON   "Start",IDC_START,94,236,50,14 | ||||||
|  | @ -65,7 +65,7 @@ BEGIN | ||||||
|     DEFPUSHBUTTON   "OK",IDOK,231,175,50,14,WS_GROUP |     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, |     CONTROL         "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL, | ||||||
|                     "SysLink",WS_TABSTOP,46,47,114,9 |                     "SysLink",WS_TABSTOP,46,47,114,9 | ||||||
|     LTEXT           "Version 1.0.5 (Build 103)",IDC_STATIC,46,19,78,8 |     LTEXT           "Version 1.0.5 (Build 104)",IDC_STATIC,46,19,78,8 | ||||||
|     PUSHBUTTON      "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP |     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 |     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 |     LTEXT           "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 | ||||||
|  | @ -170,8 +170,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 1,0,5,103 |  FILEVERSION 1,0,5,104 | ||||||
|  PRODUCTVERSION 1,0,5,103 |  PRODUCTVERSION 1,0,5,104 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -188,13 +188,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "akeo.ie" |             VALUE "CompanyName", "akeo.ie" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "1.0.5.103" |             VALUE "FileVersion", "1.0.5.104" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011 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.0.5.103" |             VALUE "ProductVersion", "1.0.5.104" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue