From 6def8f8abe411c0df4b87f90083f45670e9c61dd Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 15 Dec 2011 17:05:19 +0000 Subject: [PATCH] [freedos] finalize rufus and rufus_fd breakdown * closes #21 --- TODO | 1 - src/msdos.c | 9 +++------ src/rufus.c | 12 +++++++++++- src/rufus.h | 1 + src/rufus.rc | 16 ++++++++-------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 6fa88149..04ef5d17 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ o Create a report file with failed block details on bad blocks -o Integrate FreeDOS 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) diff --git a/src/msdos.c b/src/msdos.c index 69d7cb45..4f2ccf5f 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -378,9 +378,8 @@ BOOL ExtractFreeDOS(const char* path) filename[pos] = 0; safe_strcat(filename, sizeof(filename), res_name[i]); - // TODO: set attributes hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, CREATE_ALWAYS, 0, 0); + NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM, 0); if (hFile == INVALID_HANDLE_VALUE) { uprintf("Unable to create file '%s': %s.\n", filename, WindowsErrorString()); return FALSE; @@ -392,10 +391,8 @@ BOOL ExtractFreeDOS(const char* path) return FALSE; } - // TODO: Restore timestamps from resource -// if (!SetFileTime(hFile, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime)) { -// uprintf("Could not set timestamps: %s\n", WindowsErrorString()); -// } + // We don't restore timestamps for FreeDOS, as there's no metadata in the files, + // thus we would need to have a separate header with each file's timestamps safe_closehandle(hFile); uprintf("Succesfully wrote '%s' (%d bytes)\n", filename, res_size[i]); diff --git a/src/rufus.c b/src/rufus.c index 470ee252..47b7bde5 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -54,6 +54,7 @@ char szFolderPath[MAX_PATH]; float fScale = 1.0f; int default_fs; HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType; +BOOL bWithFreeDOS; static HWND hDeviceTooltip = NULL, hFSTooltip = NULL, hProgress = NULL; static StrArray DriveID, DriveLabel; @@ -920,7 +921,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA IGNORE_RETVAL(ComboBox_AddStringU(hDOSType, "WinMe")); // TODO: enable folder selection // IGNORE_RETVAL(ComboBox_AddStringU(hDOSType, "Custom")); - IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 0)); + IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, bWithFreeDOS?DT_FREEDOS:DT_WINME)); + if (bWithFreeDOS) { + SetDlgItemTextA(hDlg, IDC_DOS, "Create a DOS bootable disk:"); + ShowWindow(hDOSType, SW_SHOW); + } // Create the string array StrArrayCreate(&DriveID, MAX_DRIVES); StrArrayCreate(&DriveLabel, MAX_DRIVES); @@ -1104,6 +1109,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine SetLGP(FALSE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e); #endif + // Find out if the FreeDOS resources are embedded in the app + bWithFreeDOS = (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_FD_COMMAND_COM), RT_RCDATA) != NULL) && + (FindResource(hMainInstance, MAKEINTRESOURCE(IDR_FD_KERNEL_SYS), RT_RCDATA) != NULL); + uprintf("FreeDOS resources are %sembedded with this app\n", bWithFreeDOS?"":"NOT "); + // Create the main Window if ( (hDlg = CreateDialogA(hInstance, MAKEINTRESOURCEA(IDD_DIALOG), NULL, MainCallback)) == NULL ) { MessageBoxA(NULL, "Could not create Window", "DialogBox failure", MB_ICONSTOP); diff --git a/src/rufus.h b/src/rufus.h index 8581f722..9f3982da 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -146,6 +146,7 @@ extern char szFolderPath[MAX_PATH]; extern DWORD FormatStatus; extern RUFUS_DRIVE_INFO SelectedDrive; extern const int nb_steps[FS_MAX]; +extern BOOL bWithFreeDOS; /* * Shared prototypes diff --git a/src/rufus.rc b/src/rufus.rc index 0044cc25..21b1132c 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 278 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.0.3.97" +CAPTION "Rufus v1.0.3.98" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 @@ -48,10 +48,10 @@ BEGIN EDITTEXT IDC_LABEL,7,131,190,13,ES_AUTOHSCROLL CONTROL "Check device for bad blocks",IDC_BADBLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,161,171,10 CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,173,58,10 - CONTROL "Create a DOS bootable disk:",IDC_DOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,101,10 + CONTROL "Create a DOS bootable disk",IDC_DOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,101,10 LTEXT "New volume label",IDC_STATIC,9,121,105,10 CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,7,210,189,9 - COMBOBOX IDC_DOSTYPE,116,183,45,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_DOSTYPE,116,183,45,30,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP END IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195 @@ -65,7 +65,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "http://rufus.akeo.ie",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.0.3 (Build 97)",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.0.3 (Build 98)",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 @@ -170,8 +170,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,3,97 - PRODUCTVERSION 1,0,3,97 + FILEVERSION 1,0,3,98 + PRODUCTVERSION 1,0,3,98 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -188,13 +188,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.0.3.97" + VALUE "FileVersion", "1.0.3.98" 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.0.3.97" + VALUE "ProductVersion", "1.0.3.98" END END BLOCK "VarFileInfo"