From 89a7a3deb126649887e4e257b6a8641a88ad5397 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 9 Feb 2014 02:54:07 +0000 Subject: [PATCH] [core] add uncompressed DD image support * Also fix an issue with hotplug due to WM_DEVICECHANGE being filtered out * Also improve AnalyzeMBR() and prevent failure on WriteMBR * Also fix a couple issues with ISO and Syslinux handling * Also remove "smart" uncheck of disabled checkboxes - not worth it --- ChangeLog.txt | 9 ++ res/localization/ChangeLog.txt | 7 + res/localization/rufus.loc | 94 ++++++----- src/drive.c | 53 +++---- src/drive.h | 2 +- src/format.c | 61 ++++++- src/iso.c | 5 +- src/localization_data.h | 1 + src/resource.h | 3 +- src/rufus.c | 279 ++++++++++++++++++++------------- src/rufus.h | 2 + src/rufus.rc | 12 +- 12 files changed, 335 insertions(+), 193 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index dca613cd..b2b35c17 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,12 @@ +o Version 1.4.4 (2013.02.??) + Add *uncompressed* DD Image support (FreeBSD, FreeNAS, etc.) + Add right-to-left language support + Add NTFS Compression support (unofficial) + Improve Syslinux v5+ support (requires an internet connection) + Improve hotplug detection + Fix detection for Toshiba drives (again) + Fix support for latest gparted, ArchLinux, and other Syslinux v5+ based ISOs + o Version 1.4.3 (2013.01.21) [BUGFIX RELEASE] Fix format operation not starting on Windows XP (reported by ank91) diff --git a/res/localization/ChangeLog.txt b/res/localization/ChangeLog.txt index 34cf4a68..fa052cf1 100644 --- a/res/localization/ChangeLog.txt +++ b/res/localization/ChangeLog.txt @@ -12,6 +12,13 @@ content. PLEASE, do not just look at this Changelog when updating your translation, but always use the English section of rufus.loc as your base. For instance, MSG_114, that was introduced in v1.0.8 is MORE than one line! +o Version 1.0.10 (2014.02.09) + - *NEW* MSG_095 "DD Image" + - *NEW* MSG_261 "Writing image: %0.1f%% completed" + - *NEW* MSG_187 "Invalid image for selected boot option" + - *NEW* MSG_188 "The current image doesn't match the boot option selected..." (see rufus.loc for full text) + - Changed MSG_088 "ISO too big" -> "Image is too big" + - Changed MSG_089 "This ISO image is too big for the selected target." -> "The image is too big for the selected target." o Version 1.0.9 (2014.01.31) - *NEW* MSG_260 "NTFS compression" diff --git a/res/localization/rufus.loc b/res/localization/rufus.loc index eb843cad..39093ab4 100644 --- a/res/localization/rufus.loc +++ b/res/localization/rufus.loc @@ -53,7 +53,7 @@ # http://download.microsoft.com/download/9/5/E/95EF66AF-9026-4BB0-A41D-A4F81802D92C/%5BMS-LCID%5D.pdf # for the LCID (0x####) codes you should use l "en-US" "English (English)" 0x0409, 0x0809, 0x0c09, 0x1009, 0x1409, 0x1809, 0x1c09, 0x2009, 0x2409, 0x2809, 0x2c09, 0x3009, 0x3409, 0x3809, 0x3c09, 0x4009, 0x4409, 0x4809 -v 1.0.9 +v 1.0.10 # Main dialog g IDD_DIALOG @@ -248,8 +248,8 @@ t MSG_086 "No ISO image selected" # the beginning of the IDC_BOOT text t MSG_087 "Please click on the disc button to select a bootable ISO, " "or uncheck the \"Create a bootable disk...\" checkbox." -t MSG_088 "ISO too big" -t MSG_089 "This ISO image is too big for the selected target." +t MSG_088 "Image is too big" +t MSG_089 "The image is too big for the selected target." t MSG_090 "Unsupported ISO" t MSG_091 "When using UEFI Target Type, only EFI bootable ISO images are supported. " "Please select an EFI bootable ISO or set the Target Type to BIOS." @@ -258,6 +258,7 @@ t MSG_093 "IMPORTANT: THIS DRIVE CONTAINS MULTIPLE PARTITIONS!!\n\n" "This may include partitions/volumes that aren't listed or even visible from Windows. " "Should you wish to proceed, you are responsible for any data loss on these partitions." t MSG_094 "Multiple partitions detected" +t MSG_095 "DD Image" t MSG_096 "Only FAT/FAT32 is supported for this type of ISO. Please select FAT/FAT32 as the File system." t MSG_097 "Only 'bootmgr' or 'WinPE' based ISO images can currently be used with NTFS." t MSG_098 "FAT/FAT32 can only be used for isolinux based ISO images or when the Target Type is UEFI." @@ -349,6 +350,8 @@ t MSG_184 "For the purpose of generating private usage statistics, we may keep t t MSG_185 "Update Process:" t MSG_186 "Rufus does not install or run background services, therefore update checks are performed only when the main application is running.\\line\n" "Internet access is of course required when checking for updates." +t MSG_187 "Invalid image for selected boot option" +t MSG_188 "The current image doesn't match the boot option selected. Please use a different image or choose a different boot option." # Status messages - these messages will appear on the status bar t MSG_201 "Cancelling - Please wait..." @@ -428,6 +431,7 @@ t MSG_257 "Joliet support" t MSG_258 "Rock Ridge support" t MSG_259 "Force update" t MSG_260 "NTFS compression" +t MSG_261 "Writing image: %0.1f%% completed" ################################################################################ ############################# TRANSLATOR END COPY ############################## ################################################################################ @@ -1574,7 +1578,7 @@ t MSG_259 "Forceer update" ################################################################################ l "fr-FR" "French (Français)" 0x040c, 0x080c, 0x0c0c, 0x100c, 0x140c, 0x180c, 0x1c0c, 0x200c, 0x240c, 0x280c, 0x2c0c, 0x300c, 0x340c, 0x380c, 0xe40c -v 1.0.9 +v 1.0.10 b "en-US" g IDD_DIALOG @@ -1629,9 +1633,9 @@ t IDD_UPDATE_POLICY "Paramètres de mises à jour" s IDC_POLICY +30,0 t IDS_UPDATE_SETTINGS_GRP "Options" s IDS_UPDATE_SETTINGS_GRP +20,0 -t IDS_UPDATE_FREQUENCY_TXT "Recherche mises à jour:" +t IDS_UPDATE_FREQUENCY_TXT "Recherche mises à jour" s IDS_UPDATE_FREQUENCY_TXT -3,0 -t IDS_INCLUDE_BETAS_TXT "Inclure les bétas:" +t IDS_INCLUDE_BETAS_TXT "Inclure les bétas" m IDC_UPDATE_FREQUENCY -3,0 m IDC_INCLUDE_BETAS -3,0 s IDC_UPDATE_FREQUENCY +25,0 @@ -1661,7 +1665,7 @@ t IDC_ISO_ABORT "Annuler" t MSG_001 "Autre instance détectée" t MSG_002 "Une autre instance de Rufus est en cours d'exécution.\n" "Veuillez fermer la première instance avant d'en lancer une seconde." -t MSG_003 "ATTENTION: TOUTES LES DONNEES DU VOLUME '%s' VONT ETRE EFFACEES.\n" +t MSG_003 "ATTENTION : TOUTES LES DONNEES DU VOLUME '%s' VONT ETRE EFFACEES.\n" "Pour continuer cette opération, cliquez sur OK.\nPour quitter cliquez sur ANNULER." t MSG_004 "Mises à jour" t MSG_005 "Voulez-vous autoriser Rufus à chercher des mises à jour en ligne?" @@ -1670,16 +1674,16 @@ t MSG_007 "Annuler" t MSG_008 "Oui" t MSG_009 "Non" t MSG_010 "Blocs défectueux détectés" -t MSG_011 "Vérification complète: %u bloc(s) défectueux détecté(s)\n" +t MSG_011 "Vérification complète : %u bloc(s) défectueux détecté(s)\n" " %d erreur(s) de lecture\n %d erreur(s) d'écriture\n %d erreur(s) de corruption\n" -t MSG_012 "%s\nUn rapport plus détaillé peut être obtenu à:\n%s" +t MSG_012 "%s\nUn rapport plus détaillé peut être obtenu à :\n%s" t MSG_013 "Jamais" t MSG_014 "Quotidienne" t MSG_015 "Hebdomadaire" t MSG_016 "Mensuelle" t MSG_017 "Personnalisée" -t MSG_018 "Votre version: %d.%d.%d (Build %d)" -t MSG_019 "Dernière version: %d.%d.%d (Build %d)" +t MSG_018 "Votre version : %d.%d.%d (Build %d)" +t MSG_019 "Dernière version : %d.%d.%d (Build %d)" t MSG_020 "octets" t MSG_021 "Ko" t MSG_022 "Mo" @@ -1703,7 +1707,7 @@ t MSG_039 "Lancer" t MSG_040 "Télécharger" t MSG_041 "Opération annulée par l'utilisateur" t MSG_042 "Erreur" -t MSG_043 "Erreur: %s" +t MSG_043 "Erreur : %s" t MSG_044 "Téléchargement de fichier" t MSG_045 "Pérpih. de stockage USB (Générique)" t MSG_046 "%s (Disque %d)" @@ -1755,26 +1759,27 @@ t MSG_082 "Cette version de Rufus supporte uniquement les ISOs démarrables à b t MSG_083 "Remplacer %s?" t MSG_084 "Cette image ISO utilise une version obsolète du fichier '%s'.\n" "Les menus de démarrage peuvent de pas fonctionner à cause de cela.\n\n" - "Rufus peut télécharger une nouvelle version du fichier pour résoudre ce problème:\n" + "Rufus peut télécharger une nouvelle version du fichier pour résoudre ce problème :\n" "- Choisissez 'Oui' pour télécharger le fichier depuis Internet\n" "- Choisissez 'Non' pour garder le fichier de l'image ISO\n" "Si vous ne savez pas quoi faire, sélectionnez 'Oui'.\n\n" - "Note: Le nouveau fichier sera téléchargé dans le répertoire courant. " + "Note : Le nouveau fichier sera téléchargé dans le répertoire courant. " "Si un '%s' existe à cet endroit, il sera réutilisé automatiquement." t MSG_085 "Téléchargement de %s" t MSG_086 "Aucune image ISO sélectionnée" t MSG_087 "Veuillez cliquer sur le bouton avec un disque pour choisir une image ISO démarrable " "ou décochez l'option \"Disque de démarrage...\"." -t MSG_088 "Image ISO trop large" -t MSG_089 "Cette ISO image est trop large pour le périphérique sélectionné." +t MSG_088 "Image trop large" +t MSG_089 "L'image est trop large pour être copiée sur le périphérique sélectionné." t MSG_090 "Image ISO on supportée" t MSG_091 "Quand UEFI est sélectionné, seules les images ISO basées sur EFI sont supportées. " "Veuillez sélectionner une image ISO démarrable avec EFI ou sélectionner BIOS pour le système de destination." t MSG_092 "Système de fichiers non supporté" -t MSG_093 "IMPORTANT: CE PÉRIPHÉRIQUE CONTIENT PLUSIEURS PARTITIONS !!\n\n" +t MSG_093 "IMPORTANT : CE PÉRIPHÉRIQUE CONTIENT PLUSIEURS PARTITIONS !!\n\n" "Ceci peut inclure des partitions/volumes qui ne sont pas listées ou bien visibles depuis Windows. Si vous décidez " "de continuer, vous êtes responsable de toute perte de données intervenant sur ces partitions." t MSG_094 "Partitions multiples détectées" +t MSG_095 "Image DD" t MSG_096 "Seul FAT/FAT32 est supporté avec ce type d'image ISO. Veuillez sélectionner FAT/FAT32 pour le système de fichiers." t MSG_097 "Seules les images ISO utilisant 'bootmgr' ou 'WinPE' peuvent être utilisées avec NTFS." t MSG_098 "FAT/FAT32 peut seulement être utilisé pour les images ISO utilisant 'isolinux' ou lorsque que le système de destination est UEFI." @@ -1788,10 +1793,10 @@ t MSG_102 "Votre plateforme ne peut pas extraire les fichiers depuis les archive t MSG_103 "Télécharger %s?" t MSG_104 "Syslinux v5.0 ou plus récent requiert l'installation d'un fichier '%s'.\n" "Puisque ce fichier fait plus de 100 Ko et est toujours présent sur les images ISO à base de Syslinux v5+, " - "il n'est pas inclus dans l'application.\n\nRufus peut télécharger ce fichier pour vous:\n" + "il n'est pas inclus dans l'application.\n\nRufus peut télécharger ce fichier pour vous :\n" "- Choisissez 'Oui' pour télécharger le fichier depuis Internet\n" "- Choisissez 'Non' si vous compter copier ce fichier manuellement\n" - "Note: Ce fichier est téléchargé dans le répertoire courant. Une fois qu'un fichier" + "Note : Ce fichier est téléchargé dans le répertoire courant. Une fois qu'un fichier" "'%s' existe à cet endroit, il sera réutilisé automatiquement." t MSG_105 "Annuler peut laisser le périphérique dans un état inutilisable.\n" "Si vous êtes sûr de vouloir annuler, sélectionnez OUI. Sinon, sélectionnez NON." @@ -1803,14 +1808,14 @@ t MSG_110 "MS-DOS ne peut pas être utilisé sur un disque avec une Taille de cl "Veuillez changer la Taille de clusters ou utilisez FreeDOS." t MSG_111 "Taille de clusters incompatible" t MSG_112 "Le formatage d'un volume UDF de grande taille peut prendre beaucoup de temps. Aux vitesses USB 2.0, " - "la durée de formatage estimée est %d:%02d, pendant laquelle la barre de progrès semblera gelée. Veuillez être patient !" + "la durée de formatage estimée est %d :%02d, pendant laquelle la barre de progrès semblera gelée. Veuillez être patient !" t MSG_113 "Volume UDF de grand taille" t MSG_114 "Cette image utilise Syslinux %s mais l'application inclus seulement les fichiers d'installation pour Syslinux %s.\n\n" "Comme les nouvelles versions de Syslinux sont incompatibles entre elles, et il n'est pas possible à Rufus de toutes " - "les inclure, deux fichiers supplémentaires ('ldlinux.sys' et 'ldlinux.bss') doivent être téléchargés:\n" + "les inclure, deux fichiers supplémentaires ('ldlinux.sys' et 'ldlinux.bss') doivent être téléchargés :\n" "- Choisissez 'Oui' pour télécharger ces fichier depuis Internet\n" "- Choisissez 'Non' pour annuler l'opération\n" - "Note: Ces fichier seront téléchargés dans le répertoire courant et réutilisés automatiquement une fois présents." + "Note : Ces fichier seront téléchargés dans le répertoire courant et réutilisés automatiquement une fois présents." t MSG_115 "Téléchargement nécessaire" # Tootips @@ -1820,10 +1825,10 @@ t MSG_151 "Choisissez cette option si vous voulez installer un Système d’expl "mais aurez aussi besoin d’accéder au média depuis Windows XP" t MSG_152 "Option préférée pour installer un Système d’exploitation en mode EFI, " "quand l’accès au média depuis Windows XP n’est pas nécessaire" -t MSG_153 "Motif de test: 0x%02X" -t MSG_154 "Motif de test: 0x%02X, 0x%02X" -t MSG_155 "Motif de test: 0x%02X, 0x%02X, 0x%02X" -t MSG_156 "Motif de test: 0x%02X, 0x%02X, 0x%02X, 0x%02X" +t MSG_153 "Motif de test : 0x%02X" +t MSG_154 "Motif de test : 0x%02X, 0x%02X" +t MSG_155 "Motif de test : 0x%02X, 0x%02X, 0x%02X" +t MSG_156 "Motif de test : 0x%02X, 0x%02X, 0x%02X, 0x%02X" t MSG_157 "Sélectionne le système de fichiers" t MSG_158 "Taille minimum qu’un bloc de données occupera sur le système de fichiers" t MSG_159 "Utilisez ce champ pour mettre à jour le nom du volume.\n" @@ -1848,10 +1853,10 @@ t MSG_172 "Licence et remerciements" t MSG_173 "Cliquez pour sélectionner..." t MSG_174 "Rufus - The Reliable USB Formatting Utility" t MSG_175 "Version %d.%d.%d (Build %d)" -t MSG_176 "Traduction Française: Pete Batard " -t MSG_177 "Soumettre un bug ou une demande d'amélioration à:" -t MSG_178 "Copyrights supplémentaires:" -t MSG_179 "Politique de mises à jour:" +t MSG_176 "Traduction Française : Pete Batard " +t MSG_177 "Soumettre un bug ou une demande d'amélioration à :" +t MSG_178 "Copyrights supplémentaires :" +t MSG_179 "Politique de mises à jour :" t MSG_180 "Si vous autorisez ce programme à chercher les mises à jour, vous acceptez " "que les informations suivantes peuvent être collectées sur nos serveurs :" t MSG_181 "L’architecture de votre système d’exploitation ainsi que sa version" @@ -1860,17 +1865,19 @@ t MSG_183 "Votre adresse IP" t MSG_184 "Afin de générer des statistiques d’utilisation privées, il se peut que nous gardions " "les informations ainsi obtenues \\b au plus un an\\b0 . A moins d’y être contraint par la loi, " "nous nous engageons aussi à ne pas diffuser ces informations à de tierce parties." -t MSG_185 "Processus de mise à jour:" +t MSG_185 "Processus de mise à jour :" t MSG_186 "Aucun service ou tâche de fond n'est installé ou lancé par Rufus ; la vérification " "de mises à jour intervient seulement lorsque l’application principale s'exécute.\\line\n" "Bien entendu, un accès à internet est requis pour vérifier les mises à jour." +t MSG_187 "Image invalide pour l'option de démarrage sélectionnée" +t MSG_188 "L'image choisie ne correspond pas à l'option de démarrage sélectionnée. Veuillez utiliser une image ou une option de démarrage différente." # Status messages t MSG_201 "Annulation - Veuillez patienter..." t MSG_202 "Analyse de l'image ISO..." t MSG_203 "Echec d'analyse de l'image ISO" t MSG_204 "Fichier %s obsolète détecté" -t MSG_205 "ISO utilisée: %s" +t MSG_205 "ISO utilisée : %s" t MSG_206 "Fichier %s manquant" t MSG_207 "Nouveau volume" t MSG_208 "%d périphérique détecté" @@ -1882,10 +1889,10 @@ t MSG_213 "Lancement de la nouvelle application..." t MSG_214 "Echec de lancement de l'application" t MSG_215 "%s ouvert" t MSG_216 "%s sauvegardé" -t MSG_217 "Formatage: %0.1f%% complet" -t MSG_218 "Système de fichiers: Tâche %d/%d complète" -t MSG_219 "Finalisation NTFS: %d%% complète" -t MSG_220 "Formatage (%s) - durée estimée %d:%02d..." +t MSG_217 "Formatage : %0.1f%% complété" +t MSG_218 "Système de fichiers : Tâche %d/%d complétée" +t MSG_219 "Finalisation NTFS: %d%% complété" +t MSG_220 "Formatage (%s) - durée estimée %d :%02d..." t MSG_221 "Ecriture du label (peut prendre du temps)..." t MSG_222 "Formatage (%s)..." t MSG_223 "Finalisation NTFS (Checkdisk)..." @@ -1900,17 +1907,17 @@ t MSG_231 "Copie des fichiers ISO..." t MSG_232 "Ecriture boot Win7 EFI (peut prendre du temps)..." t MSG_233 "Finalisation, veuillez patienter..." t MSG_234 "Installation de Syslinux %s..." -t MSG_235 "Défauts: PASSE %d/%d - %0.2f%% (%d/%d/%d erreurs)" -t MSG_236 "Défauts: Test avec motif aléatoire" -t MSG_237 "Défauts: Test avec motif 0x%02X" +t MSG_235 "Défauts : PASSE %d/%d - %0.2f%% (%d/%d/%d erreurs)" +t MSG_236 "Défauts : Test avec motif aléatoire" +t MSG_237 "Défauts : Test avec motif 0x%02X" t MSG_238 "Partitionage (%s)..." t MSG_239 "Effacement des partitions..." -t MSG_240 "Téléchargement de %s: Connexion..." +t MSG_240 "Téléchargement de %s : Connexion..." t MSG_241 "Téléchargement: %0.1f%%" t MSG_242 "Echec de téléchargement du fichier" t MSG_243 "Recherche des mises à jour..." -t MSG_244 "MAJ: Impossible de se connecter" -t MSG_245 "MAJ: Pas d'accès aux données de mises à jour" +t MSG_244 "MAJ : Impossible de se connecter" +t MSG_245 "MAJ : Pas d'accès aux données de mises à jour" t MSG_246 "Une nouvelle version de Rufus est disponible !" t MSG_247 "Pas de nouvelle mise à jour" t MSG_248 "Clés de registre supprimées" @@ -1919,13 +1926,14 @@ t MSG_250 "%s activé" t MSG_251 "%s désactivé" t MSG_252 "Tests de dépassement de taille" t MSG_253 "Détection de disques fixes" -t MSG_254 "Force 'large FAT32'" +t MSG_254 "Force large FAT32'" t MSG_255 "NoDriveTypeAutorun sera effacé en sortie" t MSG_256 "Test de contrefaçons" t MSG_257 "Support Joliet" t MSG_258 "Support Rock Ridge" t MSG_259 "Forçage de mise à jour" t MSG_260 "Compression NTFS" +t MSG_261 "Ecriture d'image : %0.1f%% complété" ################################################################################ l "de-DE" "German (Deutsch)" 0x0407, 0x0807, 0x0c07, 0x1007, 0x1407 diff --git a/src/drive.c b/src/drive.c index f9a560a0..0687125a 100644 --- a/src/drive.c +++ b/src/drive.c @@ -476,42 +476,41 @@ BOOL IsMediaPresent(DWORD DriveIndex) return r; } -// TODO: use an (fn,str) table and simplify this whole thing -BOOL AnalyzeMBR(HANDLE hPhysicalDrive) +const struct {int (*fn)(FILE *fp); char* str; BOOL bootable;} known_mbr[] = { + { is_dos_mbr, "DOS/NT/95A", TRUE }, + { is_dos_f2_mbr, "DOS/NT/95A (F2)", TRUE }, + { is_95b_mbr, "Windows 95B/98/98SE/ME", TRUE }, + { is_2000_mbr, "Windows 2000/XP/2003", TRUE }, + { is_vista_mbr, "Windows Vista", TRUE }, + { is_win7_mbr, "Windows 7", TRUE }, + { is_rufus_mbr, "Rufus", TRUE }, + { is_syslinux_mbr, "Syslinux", TRUE }, + { is_reactos_mbr, "Reactos", TRUE }, + { is_zero_mbr, "Zeroed", FALSE }, +}; + +// Returns TRUE if the drive seems bootable, FALSE otherwise +BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName) { + const char* mbr_name = "Master Boot Record"; FILE fake_fd = { 0 }; + int i; fake_fd._ptr = (char*)hPhysicalDrive; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; if (!is_br(&fake_fd)) { - uprintf("Drive does not have an x86 master boot record\n"); + uprintf("%s does not have an x86 %s\n", TargetName, mbr_name); return FALSE; } - if (is_dos_mbr(&fake_fd)) { - uprintf("Drive has a DOS/NT/95A master boot record\n"); - } else if (is_dos_f2_mbr(&fake_fd)) { - uprintf("Drive has a DOS/NT/95A master boot record " - "with the undocumented F2 instruction\n"); - } else if (is_95b_mbr(&fake_fd)) { - uprintf("Drive has a Windows 95B/98/98SE/ME master boot record\n"); - } else if (is_2000_mbr(&fake_fd)) { - uprintf("Drive has a Windows 2000/XP/2003 master boot record\n"); - } else if (is_vista_mbr(&fake_fd)) { - uprintf("Drive has a Windows Vista master boot record\n"); - } else if (is_win7_mbr(&fake_fd)) { - uprintf("Drive has a Windows 7 master boot record\n"); - } else if (is_rufus_mbr(&fake_fd)) { - uprintf("Drive has a Rufus master boot record\n"); - } else if (is_syslinux_mbr(&fake_fd)) { - uprintf("Drive has a Syslinux master boot record\n"); - } else if (is_reactos_mbr(&fake_fd)) { - uprintf("Drive has a ReactOS master boot record\n"); - } else if (is_zero_mbr(&fake_fd)) { - uprintf("Drive has a zeroed master boot record\n"); - } else { - uprintf("Drive has an unknown master boot record\n"); + for (i=0; iMbr.Signature == MBR_UEFI_MARKER); uprintf("Disk ID: 0x%08X %s\n", DriveLayout->Mbr.Signature, SelectedDrive.has_mbr_uefi_marker?"(UEFI target)":""); - AnalyzeMBR(hPhysical); + AnalyzeMBR(hPhysical, "Drive"); for (i=0; iPartitionCount; i++) { if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) { uprintf("Partition %d:\n", i+1); diff --git a/src/drive.h b/src/drive.h index ee005b2c..454d8abe 100644 --- a/src/drive.h +++ b/src/drive.h @@ -35,7 +35,7 @@ char GetUnusedDriveLetter(void); BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label); uint64_t GetDriveSize(DWORD DriveIndex); BOOL IsMediaPresent(DWORD DriveIndex); -BOOL AnalyzeMBR(HANDLE hPhysicalDrive); +BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName); BOOL AnalyzePBR(HANDLE hLogicalVolume); int GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize); BOOL UnmountVolume(HANDLE hDrive); diff --git a/src/format.c b/src/format.c index 471a9239..1ce48596 100644 --- a/src/format.c +++ b/src/format.c @@ -827,7 +827,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) FILE fake_fd = { 0 }; const char* using_msg = "Using %s MBR\n"; - if (!AnalyzeMBR(hPhysicalDrive)) return FALSE; + AnalyzeMBR(hPhysicalDrive, "Drive"); // FormatEx rewrites the MBR and removes the LBA attribute of FAT16 // and FAT32 partitions - we need to correct this in the MBR @@ -1172,21 +1172,26 @@ DWORD WINAPI CloseFormatPromptThread(LPVOID param) { * Close the volume handle. */ #define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus)) goto out -DWORD WINAPI FormatThread(LPVOID param) +#define BSIZE 65536 // TODO: dual buffer and overlapped when writing an image +DWORD WINAPI FormatThread(void* param) { int i, r, pt, bt, fs, dt; - BOOL ret, use_large_fat32; - DWORD DriveIndex = (DWORD)(uintptr_t)param; + BOOL s, ret, use_large_fat32; + DWORD rSize, wSize, LastRefresh = 0, DriveIndex = (DWORD)(uintptr_t)param; HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE; HANDLE hLogicalVolume = INVALID_HANDLE_VALUE; + HANDLE hSourceImage = INVALID_HANDLE_VALUE; SYSTEMTIME lt; + FILE* log_fd; + LARGE_INTEGER li; + uint64_t wb; + uint8_t buffer[BSIZE]; char *bb_msg, *guid_volume = NULL; char drive_name[] = "?:\\"; char drive_letters[27]; char logfile[MAX_PATH], *userdir; char wim_image[] = "?:\\sources\\install.wim"; char efi_dst[] = "?:\\efi\\boot\\bootx64.efi"; - FILE* log_fd; PF_DECL(GetThreadUILanguage); PF_DECL(SetThreadUILanguage); PF_INIT(GetThreadUILanguage, kernel32); @@ -1247,7 +1252,7 @@ DWORD WINAPI FormatThread(LPVOID param) CHECK_FOR_USER_CANCEL; PrintStatus(0, TRUE, MSG_226); - AnalyzeMBR(hPhysicalDrive); + AnalyzeMBR(hPhysicalDrive, "Drive"); if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { AnalyzePBR(hLogicalVolume); } @@ -1316,6 +1321,50 @@ DWORD WINAPI FormatThread(LPVOID param) goto out; } } + + // Write an image file + if (dt == DT_IMG) { + // We poked the MBR, so we need to rewind + li.QuadPart = 0; + SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN); + hSourceImage = CreateFileU(iso_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (hSourceImage == INVALID_HANDLE_VALUE) { + uprintf("Could not open image '%s': %s", iso_path, WindowsErrorString()); + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED; + goto out; + } + + uprintf("Writing Image..."); + for (wb = 0; ; wb += wSize) { + s = ReadFile(hSourceImage, buffer, BSIZE, &rSize, NULL); + if (!s) { + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT; + uprintf("read error: %s", WindowsErrorString()); + } + if (rSize == 0) + break; + if (GetTickCount() > LastRefresh + 25) { + LastRefresh = GetTickCount(); + format_percent = (100.0f*wb)/(1.0f*iso_report.projected_size); + PrintStatus(0, FALSE, MSG_261, format_percent); + UpdateProgress(OP_FORMAT, format_percent); + } + CHECK_FOR_USER_CANCEL; + // TODO: add a retry on write? + s = WriteFile(hPhysicalDrive, buffer, rSize, &wSize, NULL); + if (!s || wSize != rSize) { + FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT; + if (s) + uprintf("write error: Wrote %d bytes, expected %d bytes\n", wSize, rSize); + else + uprintf("write error: %s", WindowsErrorString()); + goto out; + } + } + uprintf("Done"); + goto out; + } + // Close the (unmounted) volume before formatting if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { PrintStatus(0, TRUE, MSG_227); diff --git a/src/iso.c b/src/iso.c index acd89e2a..5a9ab0bb 100644 --- a/src/iso.c +++ b/src/iso.c @@ -478,7 +478,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan) int j; uint16_t sl_version; FILE* fd; - BOOL r = FALSE; + int r = 1; iso9660_t* p_iso = NULL; udf_t* p_udf = NULL; udf_dirent_t* p_udf_root; @@ -557,7 +557,8 @@ try_iso: p_iso = iso9660_open_ext(src_iso, iso_extension_mask); if (p_iso == NULL) { - uprintf("Unable to open image '%s'.\n", src_iso); + uprintf("Unable to open '%s' as an ISO image.\n", src_iso); + r = 1; goto out; } uprintf("Disc image is an ISO9660 image\n"); diff --git a/src/localization_data.h b/src/localization_data.h index ca937dd6..8d4a30f8 100644 --- a/src/localization_data.h +++ b/src/localization_data.h @@ -359,6 +359,7 @@ const loc_control_id control_id[] = { LOC_CTRL(MSG_258), LOC_CTRL(MSG_259), LOC_CTRL(MSG_260), + LOC_CTRL(MSG_261), LOC_CTRL(MSG_MAX), LOC_CTRL(IDOK), LOC_CTRL(IDCANCEL), diff --git a/src/resource.h b/src/resource.h index 7ec57295..f036d9d8 100644 --- a/src/resource.h +++ b/src/resource.h @@ -378,7 +378,8 @@ #define MSG_258 3258 #define MSG_259 3259 #define MSG_260 3260 -#define MSG_MAX 3261 +#define MSG_261 3261 +#define MSG_MAX 3262 // Next default values for new objects // diff --git a/src/rufus.c b/src/rufus.c index a5f597b2..114af8b4 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -492,7 +492,7 @@ static void EnableAdvancedBootOptions(BOOL enable) { BOOL actual_enable; int bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); - actual_enable = (bt==BT_UEFI)?FALSE:enable; + actual_enable = ((bt==BT_UEFI)||(selection_default==DT_IMG))?FALSE:enable; EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), actual_enable); EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), actual_enable); @@ -503,7 +503,7 @@ static void EnableBootOptions(BOOL enable) { BOOL actual_enable; int fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); - actual_enable = ((fs != FS_FAT16) && (fs != FS_FAT32) && (fs != FS_NTFS))?FALSE:enable; + actual_enable = ((fs != FS_FAT16) && (fs != FS_FAT32) && (fs != FS_NTFS) && (selection_default == DT_IMG))?FALSE:enable; EnableWindow(hBoot, actual_enable); EnableWindow(hBootType, actual_enable); @@ -896,11 +896,10 @@ static BOOL GetUSBDevices(DWORD devnum) */ static void InitProgress(void) { - int i, dt, fs; + int i, fs; float last_end = 0.0f, slots_discrete = 0.0f, slots_analog = 0.0f; fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); - dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); memset(&nb_slots, 0, sizeof(nb_slots)); memset(&slot_end, 0, sizeof(slot_end)); previous_end = 0.0f; @@ -910,19 +909,21 @@ static void InitProgress(void) previous_end = 0.0f; nb_slots[OP_ANALYZE_MBR] = 1; - nb_slots[OP_ZERO_MBR] = 1; if (IsChecked(IDC_BADBLOCKS)) { nb_slots[OP_BADBLOCKS] = -1; } if (IsChecked(IDC_BOOT)) { // 1 extra slot for PBR writing - switch (dt) { + switch (selection_default) { case DT_WINME: nb_slots[OP_DOS] = 3+1; break; case DT_FREEDOS: nb_slots[OP_DOS] = 5+1; break; + case DT_IMG: + nb_slots[OP_DOS] = 0; + break; case DT_ISO: nb_slots[OP_DOS] = -1; break; @@ -931,15 +932,20 @@ static void InitProgress(void) break; } } - nb_slots[OP_PARTITION] = 1; - nb_slots[OP_FIX_MBR] = 1; - nb_slots[OP_CREATE_FS] = - nb_steps[ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))]; - if ( (!IsChecked(IDC_QUICKFORMAT)) - || ((fs == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32))) ) { + if (selection_default == DT_IMG) { nb_slots[OP_FORMAT] = -1; + } else { + nb_slots[OP_ZERO_MBR] = 1; + nb_slots[OP_PARTITION] = 1; + nb_slots[OP_FIX_MBR] = 1; + nb_slots[OP_CREATE_FS] = + nb_steps[ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))]; + if ( (!IsChecked(IDC_QUICKFORMAT)) + || ((fs == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32))) ) { + nb_slots[OP_FORMAT] = -1; + } + nb_slots[OP_FINALIZE] = ((selection_default == DT_ISO) && (fs == FS_NTFS))?3:2; } - nb_slots[OP_FINALIZE] = ((dt == DT_ISO) && (fs == FS_NTFS))?3:2; for (i=0; i 0) { @@ -1016,22 +1022,24 @@ void UpdateProgress(int op, float percent) static void EnableControls(BOOL bEnable) { EnableWindow(GetDlgItem(hMainDialog, IDC_DEVICE), bEnable); + EnableWindow(GetDlgItem(hMainDialog, IDC_START), bEnable); + EnableWindow(GetDlgItem(hMainDialog, IDC_ABOUT), bEnable); + EnableWindow(GetDlgItem(hMainDialog, IDC_BADBLOCKS), bEnable); + EnableBootOptions(bEnable); + EnableWindow(hSelectISO, bEnable); + EnableWindow(hNBPasses, bEnable); + EnableWindow(GetDlgItem(hMainDialog, IDC_ADVANCED), bEnable); + EnableWindow(GetDlgItem(hMainDialog, IDC_LANG), bEnable); + EnableWindow(GetDlgItem(hMainDialog, IDC_ENABLE_FIXED_DISKS), bEnable); + SetDlgItemTextU(hMainDialog, IDCANCEL, lmprintf(bEnable?MSG_006:MSG_007)); + if (selection_default == DT_IMG) + return; EnableWindow(GetDlgItem(hMainDialog, IDC_PARTITION_TYPE), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_FILESYSTEM), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_CLUSTERSIZE), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), bEnable); - EnableBootOptions(bEnable); - EnableWindow(GetDlgItem(hMainDialog, IDC_BADBLOCKS), bEnable); - EnableWindow(GetDlgItem(hMainDialog, IDC_ABOUT), bEnable); - EnableWindow(GetDlgItem(hMainDialog, IDC_START), bEnable); - EnableWindow(hSelectISO, bEnable); - EnableWindow(hNBPasses, bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), bEnable); - EnableWindow(GetDlgItem(hMainDialog, IDC_ADVANCED), bEnable); - EnableWindow(GetDlgItem(hMainDialog, IDC_ENABLE_FIXED_DISKS), bEnable); - EnableWindow(GetDlgItem(hMainDialog, IDC_LANG), bEnable); - SetDlgItemTextU(hMainDialog, IDCANCEL, lmprintf(bEnable?MSG_006:MSG_007)); } /* Callback for the log window */ @@ -1111,7 +1119,8 @@ static void CALLBACK ClockTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dw */ static void CALLBACK RefreshTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { - SendMessage(hWnd, WM_DEVICECHANGE, DBT_CUSTOMEVENT, 0); + // DO NOT USE WM_DEVICECHANGE - IT MAY BE FILTERED OUT BY WINDOWS! + SendMessage(hWnd, UM_MEDIA_CHANGE, 0, 0); } /* @@ -1180,6 +1189,34 @@ BOOL CALLBACK ISOProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } +BOOL IsImage(const char* src_img) +{ + HANDLE handle = INVALID_HANDLE_VALUE; + LARGE_INTEGER liImageSize; + + handle = CreateFileU(src_img, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (handle == INVALID_HANDLE_VALUE) { + uprintf("Could not open image '%s'", src_img); + goto out; + } + iso_report.is_bootable_img = AnalyzeMBR(handle, "Image"); + + if (!GetFileSizeEx(handle, &liImageSize)) { + uprintf("Could not get image size: %s", WindowsErrorString()); + goto out; + } + iso_report.projected_size = (uint64_t)liImageSize.QuadPart; + + if (iso_report.is_bootable_img) { + uprintf("Using bootable disk image: '%s'", src_img); + selection_default = DT_IMG; + } + +out: + safe_closehandle(handle); + return iso_report.is_bootable_img; +} + // The scanning process can be blocking for message processing => use a thread DWORD WINAPI ISOScanThread(LPVOID param) { @@ -1192,7 +1229,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) PrintStatus(0, TRUE, MSG_202); user_notified = FALSE; EnableControls(FALSE); - r = ExtractISO(iso_path, "", TRUE); + r = ExtractISO(iso_path, "", TRUE) || IsImage(iso_path); EnableControls(TRUE); if (!r) { SendMessage(hISOProgressDlg, UM_ISO_EXIT, 0, 0); @@ -1200,38 +1237,46 @@ DWORD WINAPI ISOScanThread(LPVOID param) safe_free(iso_path); goto out; } - if (HAS_SYSLINUX(iso_report)) { - safe_sprintf(isolinux_str, sizeof(isolinux_str), "Yes (%s)", iso_report.sl_version_str); - } - uprintf("ISO label: '%s'\r\n Size: %lld bytes\r\n Has a >64 chars filename: %s\r\n Has a >4GB file: %s\r\n" - " ReactOS: %s\r\n Uses EFI: %s%s\r\n Uses Bootmgr: %s\r\n Uses WinPE: %s%s\r\n Uses isolinux: %s\r\n", - iso_report.label, iso_report.projected_size, iso_report.has_long_filename?"Yes":"No", iso_report.has_4GB_file?"Yes":"No", - IS_REACTOS(iso_report)?"Yes":"No", (iso_report.has_efi || iso_report.has_win7_efi)?"Yes":"No", - (iso_report.has_win7_efi && (!iso_report.has_efi))?" (win7_x64)":"", iso_report.has_bootmgr?"Yes":"No", - IS_WINPE(iso_report.winpe)?"Yes":"No", (iso_report.uses_minint)?" (with /minint)":"", isolinux_str); - if (HAS_SYSLINUX(iso_report) && (SL_MAJOR(iso_report.sl_version) < 5)) { - for (i=0; i64 chars filename: %s\r\n Has a >4GB file: %s\r\n" + " ReactOS: %s\r\n Uses EFI: %s%s\r\n Uses Bootmgr: %s\r\n Uses WinPE: %s%s\r\n Uses isolinux: %s\r\n", + iso_report.label, iso_report.projected_size, iso_report.has_long_filename?"Yes":"No", iso_report.has_4GB_file?"Yes":"No", + IS_REACTOS(iso_report)?"Yes":"No", (iso_report.has_efi || iso_report.has_win7_efi)?"Yes":"No", + (iso_report.has_win7_efi && (!iso_report.has_efi))?" (win7_x64)":"", iso_report.has_bootmgr?"Yes":"No", + IS_WINPE(iso_report.winpe)?"Yes":"No", (iso_report.uses_minint)?" (with /minint)":"", isolinux_str); + if (HAS_SYSLINUX(iso_report) && (SL_MAJOR(iso_report.sl_version) < 5)) { + for (i=0; i copy the one we got from the ISO image + if (iso_report.label[0] != 0) { + SetWindowTextU(hLabel, iso_report.label); + } + } else { + SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, + ComboBox_GetCurSel(hFileSystem)); + } for (i=(int)safe_strlen(iso_path); (i>0)&&(iso_path[i]!='\\'); i--); PrintStatus(0, TRUE, MSG_205, &iso_path[i+1]); - // Some Linux distros, such as Arch Linux, require the USB drive to have - // a specific label => copy the one we got from the ISO image - if (iso_report.label[0] != 0) { - SetWindowTextU(hLabel, iso_report.label); - } // Lose the focus on the select ISO (but place it on Close) SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0); // Lose the focus from Close and set it back to Start @@ -1312,6 +1357,18 @@ void ToggleAdvanced(void) SendMessage(GetDlgItem(hMainDialog, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)(advanced_mode?&bi_up:&bi_down)); } +// Toggle DD Image mode +void ToggleImage(BOOL enable) +{ + EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_PARTITION_TYPE), enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_FILESYSTEM), enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_CLUSTERSIZE), enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), enable); + EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), enable); +} + static BOOL BootCheck(void) { int i, fs, bt, dt, r; @@ -1324,7 +1381,7 @@ static BOOL BootCheck(void) syslinux_ldlinux_len[0] = 0; syslinux_ldlinux_len[1] = 0; dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); - if (dt == DT_ISO) { + if ((dt == DT_ISO) || (dt == DT_IMG)) { if (iso_path == NULL) { // Please click on the disc button to select a bootable ISO MessageBoxU(hMainDialog, lmprintf(MSG_087), lmprintf(MSG_086), MB_OK|MB_ICONERROR|MB_IS_RTL); @@ -1335,6 +1392,12 @@ static BOOL BootCheck(void) MessageBoxU(hMainDialog, lmprintf(MSG_089), lmprintf(MSG_088), MB_OK|MB_ICONERROR|MB_IS_RTL); return FALSE; } + if (dt == DT_IMG) { + if (!iso_report.is_bootable_img) + // The selected image doesn't match the boot option selected. + MessageBoxU(hMainDialog, lmprintf(MSG_188), lmprintf(MSG_187), MB_OK|MB_ICONERROR|MB_IS_RTL); + return (iso_report.is_bootable_img); + } fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); if (bt == BT_UEFI) { @@ -1687,6 +1750,43 @@ void ShowLanguageMenu(HWND hDlg) DestroyMenu(menu); } +void SetBoot(int fs, int bt) +{ + int i; + + IGNORE_RETVAL(ComboBox_ResetContent(hBootType)); + if ((bt == BT_BIOS) && ((fs == FS_FAT16) || (fs == FS_FAT32))) { + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), DT_WINME)); + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), DT_FREEDOS)); + } + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), DT_ISO)); + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_095)), DT_IMG)); + // If needed (advanced mode) also append a Syslinux option + if ( (bt == BT_BIOS) && (((fs == FS_FAT16) || (fs == FS_FAT32)) && (advanced_mode)) ) { + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "Syslinux 4"), DT_SYSLINUX_V4)); + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "Syslinux 5"), DT_SYSLINUX_V5)); + IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "ReactOS"), DT_REACTOS)); + } + if ((!advanced_mode) && (selection_default >= DT_SYSLINUX_V4)) { + selection_default = DT_FREEDOS; + CheckDlgButton(hMainDialog, IDC_DISK_ID, BST_UNCHECKED); + } + for (i=0; i LastRefresh + 1000) { LastRefresh = GetTickCount(); @@ -1922,20 +2023,16 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); + if (selection_default == DT_IMG) { + ToggleImage(FALSE); + EnableAdvancedBootOptions(FALSE); + SetBoot(fs, bt); + break; + } SetClusterSizes(fs); // Disable/restore the quick format control depending on large FAT32 - if ((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) { - if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_QUICKFORMAT))) { - uQFChecked = IsDlgButtonChecked(hMainDialog, IDC_QUICKFORMAT); - CheckDlgButton(hMainDialog, IDC_QUICKFORMAT, BST_CHECKED); - EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), FALSE); - } - } else { - if (!IsWindowEnabled(GetDlgItem(hMainDialog, IDC_QUICKFORMAT))) { - CheckDlgButton(hMainDialog, IDC_QUICKFORMAT, uQFChecked); - EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), TRUE); - } - } + EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), + !((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)))); if (fs < 0) { EnableBootOptions(TRUE); SetMBRProps(); @@ -1948,61 +2045,26 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; } if ((fs == FS_EXFAT) || (fs == FS_UDF)) { - if (IsWindowEnabled(hBoot)) { - // unlikely to be supported by BIOSes => don't bother - IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0)); - uBootChecked = IsDlgButtonChecked(hMainDialog, IDC_BOOT); - CheckDlgButton(hDlg, IDC_BOOT, BST_UNCHECKED); + if (IsWindowEnabled(hBoot)) EnableBootOptions(FALSE); - } else if (IsDlgButtonChecked(hMainDialog, IDC_BOOT)) { - uBootChecked = TRUE; - CheckDlgButton(hDlg, IDC_BOOT, BST_UNCHECKED); - } SetMBRProps(); break; } EnableAdvancedBootOptions(TRUE); - IGNORE_RETVAL(ComboBox_ResetContent(hBootType)); - if ((bt == BT_BIOS) && ((fs == FS_FAT16) || (fs == FS_FAT32))) { - IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), DT_WINME)); - IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), DT_FREEDOS)); - } - IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), DT_ISO)); - // If needed (advanced mode) also append a Syslinux option - if ( (bt == BT_BIOS) && (((fs == FS_FAT16) || (fs == FS_FAT32)) && (advanced_mode)) ) { - IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "Syslinux 4"), DT_SYSLINUX_V4)); - IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "Syslinux 5"), DT_SYSLINUX_V5)); - IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "ReactOS"), DT_REACTOS)); - } - if ((!advanced_mode) && (selection_default >= DT_SYSLINUX_V4)) { - selection_default = DT_FREEDOS; - CheckDlgButton(hDlg, IDC_DISK_ID, BST_UNCHECKED); - } - for (i=0; i