1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

Merge remote-tracking branch 'upstream/master' into FixJapanese

# Conflicts:
#	res/localization/rufus.loc
This commit is contained in:
Tiryoh 2016-05-13 02:04:40 +09:00
commit d04a79e9c5
77 changed files with 3452 additions and 1611 deletions

View file

@ -1,3 +1,29 @@
o Version 2.9 (2016.05.??)
Add ARM support for UEFI:NTFS
Fix UEFI:NTFS support for HP and Gigabyte firmwares (with thanks to Rod Smith and linnaea)
Fix unwanted listing of some internal removable drives
Fix missing default cluster size default on exFAT for >32GB drives
Fix the non-removal of the commandline hogger in some corner cases
Use "modern" file selection dialog on Vista or later (if you can spot the difference, good for you...)
o Version 2.8 (2016.03.22)
Enable listing of non-USB card readers (EXPERIMENTAL)
Major speed improvement for checksum computation
Fix UI flicker during progress actualization
Fix computation of FAT size for Large FAT32 (with thanks to Ady)
Syslinux improvements
Update GRUB to 2.02~beta3
o Version 2.7 (2016.02.14)
Add Thai translation, courtesy of Sippapas Wangsri
Add Drag and Drop support, courtesy of SeymourApps
Add a retry for most write operations
Update UEFI:NTFS, ms-sys and Grub4DOS to latest
Dual sign Rufus with both SHA-1 and SHA-256
Fix 2nd line of SHA-256 being hidden on some platforms
Fix shutdown prevention issues
Additional fixes & translation updates
o Version 2.6 (2015.12.22)
Add Serbian (Latin) translation, courtesy of Ivan Strugar
Add a cheat mode to zero a device (Alt-Z)

View file

@ -1,5 +1,5 @@
@echo off
set COV_DIR=E:\cov-analysis-win32-7.7.0
set COV_DIR=E:\cov-analysis-win32-7.7.0.4
set PATH=%PATH%;%COV_DIR%\bin
set PWD=%~dp0
rmdir cov-int /s /q >NUL 2>NUL

View file

@ -1,6 +1,9 @@
@echo off
:retry
@set /p password=Please enter PFX password:
@"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool" sign /v /fd SHA256 /f D:\Secured\akeo\akeo.p12 /p %password% /tr http://timestamp.comodoca.com/rfc3161 /td SHA256 %1 %2 %3 %4
@if ERRORLEVEL 1 goto retry
@set password=
@exit
set /p password=Please enter PFX password:
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool" sign /v /fd SHA1 /f D:\Secured\akeo\sha1\akeo.p12 /p %password% /tr http://timestamp.comodoca.com/rfc3161 /td SHA1 %1
if ERRORLEVEL 1 goto retry
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool" sign /as /v /fd SHA256 /f D:\Secured\akeo\akeo.p12 /p %password% /tr http://timestamp.comodoca.com/rfc3161 /td SHA256 %1
if ERRORLEVEL 1 goto retry
set password=
exit

23
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for rufus 2.7.
# Generated by GNU Autoconf 2.69 for rufus 2.9.
#
# Report bugs to <https://github.com/pbatard/rufus/issues>.
#
@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='2.7'
PACKAGE_STRING='rufus 2.7'
PACKAGE_VERSION='2.9'
PACKAGE_STRING='rufus 2.9'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='http://rufus.akeo.ie'
@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures rufus 2.7 to adapt to many kinds of systems.
\`configure' configures rufus 2.9 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1294,7 +1294,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of rufus 2.7:";;
short | recursive ) echo "Configuration of rufus 2.9:";;
esac
cat <<\_ACEOF
@ -1385,7 +1385,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
rufus configure 2.7
rufus configure 2.9
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -1440,7 +1440,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 2.7, which was
It was created by rufus $as_me 2.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2303,7 +2303,7 @@ fi
# Define the identity of the package.
PACKAGE='rufus'
VERSION='2.7'
VERSION='2.9'
cat >>confdefs.h <<_ACEOF
@ -3922,6 +3922,8 @@ ac_config_files="$ac_config_files src/syslinux/libfat/Makefile"
ac_config_files="$ac_config_files src/syslinux/libinstaller/Makefile"
ac_config_files="$ac_config_files src/syslinux/win/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@ -4480,7 +4482,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by rufus $as_me 2.7, which was
This file was extended by rufus $as_me 2.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -4534,7 +4536,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
rufus config.status 2.7
rufus config.status 2.9
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@ -4657,6 +4659,7 @@ do
"src/ms-sys/Makefile") CONFIG_FILES="$CONFIG_FILES src/ms-sys/Makefile" ;;
"src/syslinux/libfat/Makefile") CONFIG_FILES="$CONFIG_FILES src/syslinux/libfat/Makefile" ;;
"src/syslinux/libinstaller/Makefile") CONFIG_FILES="$CONFIG_FILES src/syslinux/libinstaller/Makefile" ;;
"src/syslinux/win/Makefile") CONFIG_FILES="$CONFIG_FILES src/syslinux/win/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac

View file

@ -1,4 +1,4 @@
AC_INIT([rufus], [2.7], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AC_INIT([rufus], [2.9], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4])
@ -80,4 +80,5 @@ AC_CONFIG_FILES([res/localization/Makefile])
AC_CONFIG_FILES([src/ms-sys/Makefile])
AC_CONFIG_FILES([src/syslinux/libfat/Makefile])
AC_CONFIG_FILES([src/syslinux/libinstaller/Makefile])
AC_CONFIG_FILES([src/syslinux/win/Makefile])
AC_OUTPUT

View file

@ -1,7 +1,7 @@
This directory contains the Grub4DOS boot records that are used by Rufus
* grldr.mbr was taken from the official 2015.10.21 release from
http://grub4dos.chenall.net/downloads/grub4dos-0.4.6a-2015-10-21/
* grldr.mbr was taken from the official 2016.01.19 release from
http://grub4dos.chenall.net/downloads/grub4dos-0.4.6a-2016-01-19/
* Note that, for convenience reasons, the first 512 bytes from this grldr.mbr are
*not* the ones that Rufus processes when writing the actual MBR (first 512 bytes).

Binary file not shown.

View file

@ -2,4 +2,4 @@
* This file contains the version string of the GRUB 2.x binary embedded in Rufus.
* Should be the same as GRUB's PACKAGE_VERSION in config.h.
*/
#define GRUB2_PACKAGE_VERSION "2.02~beta2"
#define GRUB2_PACKAGE_VERSION "2.02~beta3"

View file

@ -1,7 +1,7 @@
This directory contains the Grub 2.0 boot records that are used by Rufus
* boot.img and core.img were compiled from git://git.savannah.gnu.org/grub.git,
commit 72ec399ad8d6348b6c74ea63d80c79784c8b84ae, on a Debian 7.7.0 x64 system.
* boot.img and core.img were compiled from
http://alpha.gnu.org/gnu/grub/grub-2.02~beta3.tar.xz, on a Debian 8.3 x64 system.
This was done following the guide from:
http://pete.akeo.ie/2014/05/compiling-and-installing-grub2-for.html.

View file

@ -15,6 +15,14 @@ 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.20 (2016.05.09)
- *NEW* MSG_286 "Zeroing drive: %0.1f%% completed"
Used when filling a whole drive with zero bytes, to display progress in percent (e.g. "Zeroing drive: 12.3% completed")
Can be tested with Alt-Z (CAUTION: THIS WILL COMPLETELY ERASE THE SELECTED DRIVE!!)
- *NEW* MSG_287 "Detection of non-USB removable drives"
Note, this message is followed by either "enabled"/"disabled" (see MSG_250/251) and is similar to MSG_253
The message appears on the status bar and can be tested with Ctrl-Alt-F.
o Version 1.0.19 (2015.10.15)
Note: The following message can be tested by pressing Alt-, (That's the 'Alt' and 'comma' keys on your keyboard)
In case the message below is not clear, you can consider that it says "Exclusive locking of the USB drive"

View file

@ -77,7 +77,7 @@
# l "ru-RU" "Russian (Русский)" 0x0419
# l "sr-SP" "Serbian (Latin)" 0x241a
# l "sk-SK" "Slovak (Slovensky)" 0x041B
# l "sl-SI" "Slovene (Slovenščina)" 0x0424
# l "sl-SI" "Slovenian (Slovenščina)" 0x0424
# l "es-ES" "Spanish (Español)" 0x040a
# l "sv-SE" "Swedish (Svenska)" 0x041d
# l "th-TH" "Thai (ไทย)" 0x041e
@ -92,7 +92,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.19
v 1.0.20
# Main dialog
g IDD_DIALOG
@ -548,6 +548,7 @@ t MSG_284 "The downloaded executable is missing a digital signature."
t MSG_285 "The downloaded executable is signed by '%s'.\nThis is not a signature we recognize and could "
"indicate some form of malicious activity...\nAre you sure you want to run this file?"
t MSG_286 "Zeroing drive: %0.1f%% completed"
t MSG_287 "Detection of non-USB removable drives"
################################################################################
############################# TRANSLATOR END COPY ##############################
@ -988,7 +989,7 @@ t MSG_281 "(فضلا اختر صورة)"
################################################################################
l "az-AZ" "Azerbaijani (Azərbaycanca)" 0x042c, 0x782c
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -1464,6 +1465,8 @@ t MSG_283 "Keçərsiz imza"
t MSG_284 "Yüklənən aparıla faylın rəqəmsal imzası çatmır."
t MSG_285 "Yüklənən aparıla bilən fayl '%s' tərəfindən imzalanmışdır.\nBu tərifə və pis niyyətli "
"səmərəliliyini qeyd edəcəyimiz bir imza deyil...\nBu faylı işlətmək istədiyinizə əminsiniz?"
t MSG_286 "Sürücü sıfırlama: %0.1f%% tamamlandı"
t MSG_287 "Olmayan çıxarılabilən USB sürücülər"
######################################################################
l "bg-BG" "Bulgarian (Български)" 0x0402
@ -2387,7 +2390,7 @@ t MSG_285 "已下载的可执行文件是由 '%s' 签署的。\n这个不是我
################################################################################
l "zh-TW" "Chinese Traditional (正體中文)" 0x0404, 0x0c04, 0x1404, 0x7c04
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -2797,6 +2800,8 @@ t MSG_282 "鎖定 USB 磁碟"
t MSG_283 "無效簽章"
t MSG_284 "下載的檔案缺少數位簽章。"
t MSG_285 "下載的檔案簽章者為: '%s'.\n本軟體未使用此簽章代表檔案可能已遭受病毒感染...\n是否要執行檔案?"
t MSG_286 "寫入零: 已完成 %0.1f%%"
t MSG_287 "偵測非USB可移除磁碟"
################################################################################
l "hr-HR" "Croatian (Hrvatski)" 0x041a, 0x081a, 0x101a
@ -4584,7 +4589,7 @@ t MSG_286 "Nullen schrijven : %0.1f%% voltooid"
################################################################################
l "fi-FI" "Finnish (Suomi)" 0x040B
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -5030,10 +5035,12 @@ t MSG_283 "Epäkelpo allekirjoitus"
t MSG_284 "Ladatusta tiedostosta puuttuu digitaalinen allekirjoitus."
t MSG_285 "Ladatun tiedoston on allekirjoittanut '%s'.\nEmme tunnista kyseistä allekirjoitusta, mikä "
"saattaa viitata haitalliseen toimintaan...\nHaluatko varmasti suorittaa tämän tiedoston?"
t MSG_286 "Nollataan asemaa: %0.1f%% suoritettu"
t MSG_287 "Ei-USB-liitäntäisten irroitettavien asemien tunnistus"
################################################################################
l "fr-FR" "French (Français)" 0x040c, 0x080c, 0x0c0c, 0x100c, 0x140c, 0x180c, 0x1c0c, 0x200c, 0x240c, 0x280c, 0x2c0c, 0x300c, 0x340c, 0x380c, 0xe40c
v 1.0.19
v 1.0.20
b "en-US"
g IDD_DIALOG
@ -5236,11 +5243,11 @@ t MSG_095 "Image DD"
t MSG_096 "Le système de fichiers sélectionné ne peut pas être utilisé avec ce type d'image ISO. "
"Veuillez sélectionner un système de fichiers different file ou une autre ISO."
t MSG_097 "'%s' peut seulement être appliqué pour un système de fichiers NTFS."
t MSG_098 "IMPORTANT: Vous essayez d'installer 'Windows To Go', mais votre périphérique de destination ne possède pas "
t MSG_098 "IMPORTANT : Vous essayez d'installer 'Windows To Go', mais votre périphérique de destination ne possède pas "
"l'attribut 'FIXE'. A cause de cela, Windows va très probablement geler lors du démarrage, car Microsoft ne l'a pas "
"conçu pour fonctionner avec des périphériques qui possèdent l'attribut 'AMOVIBLE'.\n\n"
"Voulez vous continuer malgré celà?\n\n"
"Note: L'attribut 'FIXE/AMOVIBLE' est une propriété matérielle qui peut uniquement être changée avec des outils "
"Note : L'attribut 'FIXE/AMOVIBLE' est une propriété matérielle qui peut uniquement être changée avec des outils "
"propriétaires, que les fabriquants de périphériques ne fournissent PRESQUE JAMAIS au public..."
t MSG_099 "Limitation du système de fichiers"
t MSG_100 "Cette image ISO contient un fichier de plus de 4 Go, ce qui est plus que la taille maximum "
@ -5346,7 +5353,7 @@ t MSG_192 "Phase de lecture"
t MSG_193 "Téléchargement completé pour %s "
t MSG_194 "Impossible de télécharger %s"
t MSG_195 "La version par défaut du fichier %s sera utilisée"
t MSG_196 "IMPORTANT: CE PÉRIPHÉRIQUE UTILISE UNE TAILLE DE SECTEUR NON STANDARD !\n\n"
t MSG_196 "IMPORTANT : CE PÉRIPHÉRIQUE UTILISE UNE TAILLE DE SECTEUR NON STANDARD !\n\n"
"La majorité des disques utilisent une taille de secteur de 512 octets, mais celui ci utilise une taille de %d octets. "
"Dans la majorité des cas, cela veut dire que vous ne POUVEZ PAS démarrer un oridinateur depusi ce disque.\n"
"Rufus peut toujours essayer de créer un disque démarrable, mais il n'y a AUCUNE guarantie que cela marchera."
@ -5376,7 +5383,7 @@ t MSG_215 "%s ouvert"
t MSG_216 "%s sauvegardé"
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_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)..."
@ -5398,7 +5405,7 @@ t MSG_237 "Test de 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_241 "Téléchargement: %0.1f%%"
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 "Mises à jour : Impossible de se connecter"
@ -5424,11 +5431,11 @@ t MSG_263 "Affichage de tailles avec de VRAIES unités"
t MSG_264 "Suppression du dossier '%s'"
t MSG_265 "Détection de disque VMWare"
t MSG_266 "Mode dual UEFI/BIOS"
t MSG_267 "Application de l'image Windows: %0.1f%% complété"
t MSG_267 "Application de l'image Windows : %0.1f%% complété"
t MSG_268 "Application de l'image Windows..."
t MSG_269 "Préservation des dates de fichiers"
t MSG_270 "Debug USB"
t MSG_271 "Calculation des checksums de l'image: %0.1f%% complété"
t MSG_271 "Calculation des checksums de l'image : %0.1f%% complété"
t MSG_272 "Calcule les checksums MD5, SHA1 et SHA256 pour l'image sélectionée"
t MSG_273 "Change la langue de l'application"
t MSG_274 "Image ISOHybrid détectée"
@ -5449,10 +5456,12 @@ t MSG_283 "Signature invalide"
t MSG_284 "L'exécutable téléchargé ne possède pas de signature digitale."
t MSG_285 "L'exécutable téléchargé est signé par '%s'.\nCe nest pas une signature que nous reconnaissons et "
"pourrait indiquer une activité malicieuse...\nÊtes-vous certain de vouloir lancer ce fichier?"
t MSG_286 "Effacement à zéro : %0.1f%% complété"
t MSG_287 "Détection disques non-USB détachables"
################################################################################
l "de-DE" "German (Deutsch)" 0x0407, 0x0807, 0x0c07, 0x1007, 0x1407
v 1.0.19
v 1.0.20
b "en-US"
g IDD_DIALOG
@ -5894,10 +5903,12 @@ t MSG_283 "Ungültige Signatur"
t MSG_284 "Die heruntergeladene ausführbare Datei verfügt über keine Signatur."
t MSG_285 "Die heruntergeladene ausführbare Datei ist von '%s' signiert.\nDiese Signatur ist nicht akzeptiert und könnte "
"auf eine böswillige Aktivität hindeuten...\nSind Sie sicher, dass Sie diese Datei ausführen wollen?"
t MSG_286 "Überschreiben mit Nullen: %0.1f%% fertiggestellt"
t MSG_287 "Erkennung nicht wechselbarer USB-Laufwerke"
################################################################################
l "el-GR" "Greek (Ελληνικά)" 0x0408
v 1.0.18
v 1.0.19
b "en-US"
# Main dialog
@ -6369,6 +6380,12 @@ t MSG_278 "Τύπος εκκίνησης"
t MSG_279 "Δεν διαθέτει δυνατότητα εκκίνησης"
t MSG_280 "Επιλογή ειδώλου"
t MSG_281 "(Παρακαλώ επιλέξτε κάποιο είδωλο)"
t MSG_282 "Κλείδωμα μονάδας USB"
t MSG_283 "Μη έγκυρη ψηφιακή υπογραφή"
t MSG_284 "Το εκτελέσιμο αρχείο που κατεβάσατε δεν περιλαμβάνει ψηφιακή υπογραφή."
τ MSG_285 "Το εκτελέσιμο αρχείο που κατεβάσατε έχει υπογραφτεί από τον/την '%s'.\nΑύτη η υπογραφή δεν "
"αναγνωρίζεται από το Rufus. Ενδεχομένως να υπάρχει συσχέτιση με κάποια κακόβουλη προσπάθεια...\n"
"Είστε σίγουροι ότι θέλετε να εκτελέσετε αυτό το αρχείο?"
################################################################################
l "hu-HU" "Hungarian (Magyar)" 0x040e
@ -6812,7 +6829,7 @@ t MSG_286 "Meghajtó kinullázása: %0.1f%% kész"
################################################################################
l "id-ID" "Indonesian (Bahasa Indonesia)" 0x0421
v 1.0.18
v 1.0.20
b "en-US"
# Main dialog
@ -7132,7 +7149,7 @@ t MSG_158 "Ukuran minimal blok data yang akan menempati sistem berkas"
t MSG_159 "Gunakan bidang ini untuk menyetel karakter Internasional yang diperbolehkan\npada label perangkat"
t MSG_160 "Tombol untuk opsi lanjutan"
t MSG_161 "Periksa blok buruk pada perangkat menggunakan tes pola"
t MSG_162 "Hapus centang pada kotak ini untuk \"tampilkan\" metode format"
t MSG_162 "Hapus centang kotak ini untuk menggunakan metode format \"lambat\""
t MSG_163 "Centang kotak ini untuk membuat perangkat USB bootable"
t MSG_164 "Metode yang akan digunakan untuk membuat perangkat bootable"
t MSG_165 "Klik untuk memilih sebuah image..."
@ -7288,10 +7305,18 @@ t MSG_278 "Tipe Boot"
t MSG_279 "Non bootable"
t MSG_280 "Pemilihan image"
t MSG_281 "(Silakan pilih sebuah image)"
t MSG_282 "Penguncian perangkat USB khusus"
t MSG_283 "Tanda tangan digital tidak valid"
t MSG_284 "Berkas exe yang diunduh memiliki tanda tangan digital yang salah."
t MSG_285 "Berkas exe yang diunduh ditandatangani oleh '%s'.\nTanda tangan ini "
"tidak kami kenali dan bisa menjadi pertanda dari aktivitas berbahaya...\n"
"Apakah Anda yakin ingin menjalankan berkas ini?"
t MSG_286 "Mengosongkan perangkat: %0.1f%% selesai"
t MSG_287 "Deteksi selain perangkat USB yang dapat dilepas"
################################################################################
l "it-IT" "Italian (Italiano)" 0x0410, 0x0810
v 1.0.19
v 1.0.20
b "en-US"
g IDD_DIALOG
@ -7719,6 +7744,8 @@ t MSG_283 "Firma non valida"
t MSG_284 "L'eseguibile scaricato non ha una firma digitale."
t MSG_285 "L'eseguibile scaricato è firmato da '%s'.\nQuesta non è una firma riconosciuta e potrebbe "
"indicare qualche forma di attività malevola.\nSei sicuro di voler eseguire questo file?"
t MSG_286 "Azzeramento disco: %0.1f%% completato"
t MSG_287 "Rilevamento di unità rimuovibili non USB"
######################################################################
l "ja-JP" "Japanese (日本語)" 0x0411
@ -7994,8 +8021,11 @@ t MSG_102 "ご使用の環境ではWIMファイルからファイルを抽出で
"EFIでのブートを必要とするWindows 7とWindows Vista用のUSBドライブを作るためには、WIMファイルを展開できる必要があります。"
"7-Zipの最近のバージョンでは展開することができます。\n7-Zipのダウンロードページへ行きますか?"
t MSG_103 "ダウンロード %s?"
<<<<<<< HEAD
# Eg. "Grub4DOS v0.4 or later requires a 'grldr' file to be installed. Because this file
# is more than 100 KB in size, and always present on Grub4DOS ISO images, etc."
=======
>>>>>>> upstream/master
t MSG_104 "%s 以降の物が内包されており '%s' ファイルが必要になります。\n"
"このファイルは100KBより大きいのでRufusに内蔵していません。%s にISO イメージが常時あるためです。"
"\n\nRufus で不足しているファイルをダウンロードすることができます:\n"
@ -8027,8 +8057,11 @@ t MSG_114 "このイメージは Syslinux %s%s を使用しますが、このア
"注意: ファイルは現在のディレクトリへダウンロードされます。新しいファイルが既に現在のディレクトリにある場合、"
"ダウンロードせず自動的に再使用します。\n"
t MSG_115 "ダウンロードが必要"
<<<<<<< HEAD
# Note: You should be able to test this message with Super Grub2 Disk ISO:
# http://forja.cenatic.es/frs/download.php/file/1757/super_grub2_disk_hybrid_2.00s2.iso (11 MB)
=======
>>>>>>> upstream/master
t MSG_116 "このイメージはGrub %s を使いますが、このアプリケーションには Grub %sのインストールファイルのみ"
"内蔵しています。\n\n各々のGrubのバージョンは互いに互換性はなく、使用できません。"
"しかし、Rufusはイメージと一致したバージョンのGrubインストールファイル('core.img')"
@ -8165,7 +8198,10 @@ t MSG_234 "Syslinux %s をインストール中..."
t MSG_235 "不良ブロック:%s %d/%d - %0.2f%% (%d/%d/%d エラー)"
t MSG_236 "不良ブロック:ランダムパターンでテスト"
t MSG_237 "不良ブロック:パターン 0x%02X でテスト"
<<<<<<< HEAD
# eg. "Partitioning (MBR)..."
=======
>>>>>>> upstream/master
t MSG_238 "パーティション分割中 (%s)..."
t MSG_239 "パーティション削除中..."
t MSG_240 "ダウンロード中 %s: 接続中..."
@ -8206,13 +8242,19 @@ t MSG_271 "イメージのチェックサムを計算中 : %0.1f%% 完了"
t MSG_272 "選択したイメージのMD5、SHA1、SHA256チェックサムを計算します。"
t MSG_273 "アプリケーションの使用言語を変更"
t MSG_274 "「ISOHybrid」イメージを検出しました"
<<<<<<< HEAD
# '%s' below will be replaced with your translations for MSG_036 ("ISO Image") and MSG_095 ("DD Image")
=======
>>>>>>> upstream/master
t MSG_275 "選択されたイメージは「ISOHybrid」です。下記のいずれかの方法で書き込むことができます: "
"%s (ファイルコピー)モード又は %s (ディスクイメージ)モード。\n"
"書き込み後、ドライブへフルアクセスできる様、Rufusは %s を推奨します。\n"
"ブート中エラーが発生する場合には、%s モードで再度試してみてください。\n\n"
"このイメージを書き込む際に使用するモードを選択してください:"
<<<<<<< HEAD
# '%s' below will be replaced with your translation for MSG_036 ("ISO Image")
=======
>>>>>>> upstream/master
t MSG_276 "%sモードで書き込む(推奨)"
# '%s' below will be replaced with your translation for MSG_095 ("DD Image")
t MSG_277 "%sモードで書き込む"
@ -8233,7 +8275,7 @@ t MSG_286 "'0'をドライブへ書き込み初期化中: %0.1f%% 完了"
################################################################################
l "ko-KR" "Korean (한국어)" 0x0412
v 1.0.18
v 1.0.19
b "en-US"
# Main dialog
@ -8663,10 +8705,15 @@ t MSG_278 "부팅 유형"
t MSG_279 "부팅 안 됨"
t MSG_280 "이미지 선택"
t MSG_281 "(이미지를 선택하세요)"
t MSG_282 "전용 USB 드라이브 잠김"
t MSG_283 "유효하지 않은 디지털 서명"
t MSG_284 "다운로드 한 실행 파일에 디지털 서명이 없습니다."
t MSG_285 "다운로드 한 실행 파일은 '%s'에 의해 서명됩니다..\n이 파일은 정상적인 서명이 아니며 악성코드가 포함되어 있을 수 있습니다.\n"
"그래도 이 파일을 실행하시겠습니까?"
################################################################################
l "lv-LV" "Latvian (Latviešu)" 0x0426
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -9130,10 +9177,12 @@ t MSG_283 "Nederīgs paraksts"
t MSG_284 "Ielādētajam izpildfailam ir kļūdains ciparu paraksts."
t MSG_285 "Ielādētais izpildfails parakstīts kā '%s'.\nTas ir neatpazīts paraksts un iespējams, "
"var radīt aizdomīgas aktivitātes...\nVai tiešām vēlaties izpildīt šo failu?"
t MSG_286 "Nulles disks: %0.1f%% paveikts"
t MSG_287 "neUSB disku noteikšana"
################################################################################
l "lt-LT" "Lithuanian (Lietuvių)" 0x0427
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -9591,10 +9640,12 @@ t MSG_283 "Negaliojantis parašas"
t MSG_284 "Atsiųstas vykdomasis failas neturi skaitmeninio parašo."
t MSG_285 "Atsiųstą vykdomąjį failą pasirašė '%s'.\nŠio parašo mes neatpažįstame ir tai gali "
"būti tam tikros kenkėjiškos veiklos požymis...\nAr jūs tikrai norite vykdyti šį failą?"
t MSG_286 "Nulinamas diskas: %0.1f%% baigta"
t MSG_287 "Ne USB keičiamų diskų aptikimas"
################################################################################
l "ms-MY" "Malay (Bahasa Malaysia)" 0x043e, 0x083e
v 1.0.16
v 1.0.19
b "en-US"
# Main dialog
@ -9607,7 +9658,7 @@ s IDC_FILESYSTEM +30,0
s IDC_CLUSTERSIZE +30,0
s IDC_LABEL +30,0
t IDS_DEVICE_TXT "Peranti"
t IDS_PARTITION_TYPE_TXT "Skema partition dan jenis sistem sasaran"
t IDS_PARTITION_TYPE_TXT "Skema partisyen dan jenis sistem sasaran"
t IDS_FILESYSTEM_TXT "Sistem fail"
t IDS_CLUSTERSIZE_TXT "Saiz gugusan"
t IDS_LABEL_TXT "Label jilid baharu"
@ -9621,9 +9672,9 @@ m IDC_SELECT_ISO +30,0
s IDC_INFO +30,0
m IDC_BOOTTYPE +30,0
s IDC_BOOT +32,0
t IDC_BOOT "Cipta disk boleh-but menggunakan"
t IDC_SET_ICON "Cipta label lanjut dan fail icon"
t IDC_ABOUT "Tentang..."
t IDC_BOOT "Cipta disk boot menggunakan"
t IDC_SET_ICON "Cipta label lanjut dan fail ikon"
t IDC_ABOUT "Mengenai..."
t IDC_LOG "Log"
t IDCANCEL "Tutup"
m IDCANCEL +30,0
@ -9640,7 +9691,7 @@ t IDC_RUFUS_MBR "Guna MBR Rufus dengan BIOS ID"
# About dialog
g IDD_ABOUTBOX
t IDD_ABOUTBOX "Tentang Rufus"
t IDD_ABOUTBOX "Mengenai Rufus"
t IDC_ABOUT_LICENSE "Lesen"
t IDC_ABOUT_UPDATES "Kemas kini"
@ -9651,7 +9702,7 @@ t IDCANCEL "Tutup"
# Notifications. You can trigger one of these by using Alt-R and re-launching Rufus
g IDD_NOTIFICATION
t IDC_MORE_INFO "Informasi lanjut"
t IDC_MORE_INFO "Maklumat lanjut"
t IDYES "Ya"
t IDNO "Tidak"
@ -9691,8 +9742,8 @@ t IDCANCEL "Tutup"
g IDD_NEW_VERSION
t IDD_NEW_VERSION "Semak untuk versi baharu - Rufus"
t IDS_NEW_VERSION_AVAIL_TXT "Terdapat versi Rufus yang baharu. Sila muat turun versi yang terkini."
t IDC_WEBSITE "Klik di sini untuk ke laman web Rufus"
t IDS_NEW_VERSION_NOTES_GRP "Informasi versi terbaharu"
t IDC_WEBSITE "Klik di sini untuk ke laman sesawang Rufus"
t IDS_NEW_VERSION_NOTES_GRP "Maklumat versi terbaharu"
t IDS_NEW_VERSION_DOWNLOAD_GRP "Muat turun"
t IDC_DOWNLOAD "Muat turun"
t IDCANCEL "Tutup"
@ -9704,24 +9755,24 @@ t MSG_002 "Terdapat aplikasi Rufus sedang berjalan.\n"
t MSG_003 "AMARAN: SEMUA DATA DI DALAM PERANTI '%s' AKAN DIPADAM.\n"
"Jika hendak teruskan, klik OK. Untuk berhenti, klik BATAL."
t MSG_004 "Dasar kemas kini Rufus"
t MSG_005 "Adakah anda mahu membenarkan Rufus menyemak untuk versi baharu secara online?"
t MSG_005 "Adakah anda mahu membenarkan Rufus menyemak untuk versi baharu dalam talian?"
# Must be the same as IDD_DIALOG:IDCANCEL (i.e. "Close" - I know it's confusing)
t MSG_006 "Tutup"
t MSG_007 "batal"
t MSG_008 "Ya"
t MSG_009 "Tidak"
t MSG_010 "Blok rosak dijumpai"
t MSG_011 "Semak selsesai: %d blok rosak dijumpai\n"
" %d error membaca\n %d error menulis\n %d error korupsi\n"
t MSG_011 "Semak selesai: %d blok rosak dijumpai\n"
" %d kesilapan membaca\n %d kesilapan menulis\n %d kesilapan korupsi\n"
# The following will contain the formatted message above as well as the name of the bad blocks logfile
t MSG_012 "%s\nA more detailed report can be found in:\n%s"
t MSG_012 "%s\nLaporan lebih terperinci boleh dijumpai di:\n%s"
t MSG_013 "Tidak menyemak"
t MSG_014 "Harian"
t MSG_015 "Mingguan"
t MSG_016 "Bulanan"
t MSG_017 "Tetapan sendiri"
t MSG_018 "Versi anda: %d.%d (Build %d)"
t MSG_019 "Versi terkini: %d.%d (Build %d)"
t MSG_018 "Versi anda: %d.%d (Binaan %d)"
t MSG_019 "Versi terkini: %d.%d (Binaan %d)"
# *Short* size names. These can be used as suffixes
t MSG_020 "bait"
t MSG_021 "KB"
@ -9736,9 +9787,9 @@ t MSG_028 "megabait"
t MSG_029 "lalai"
# The following gets appended to the file system, cluster size, etc.
t MSG_030 "%s (Lalai)"
t MSG_031 "%s skema partition untuk BIOS dan %s"
t MSG_032 "%s skema partition untuk BIOS"
t MSG_033 "%s skema partition untuk UEFI"
t MSG_031 "%s skema partisyen untuk BIOS dan %s"
t MSG_032 "%s skema partisyen untuk BIOS"
t MSG_033 "%s skema partisyen untuk UEFI"
# Number of bad block check passes (singular for 1 pass, plural for 2 or more passes)
t MSG_034 "%d kali lulus"
@ -9749,23 +9800,23 @@ t MSG_038 "Batal"
t MSG_039 "Mula"
t MSG_040 "Muat Turun"
t MSG_041 "Operasi dibatalkan oleh pengguna"
t MSG_042 "Error"
t MSG_043 "Error: %s"
t MSG_042 "Kesilapan"
t MSG_043 "Kesilapan: %s"
t MSG_044 "Muat turun fail"
t MSG_045 "Peranti storan USB (Generik)"
t MSG_046 "%s (Disk %d) [%s]"
t MSG_047 "Beberapa Partition"
t MSG_048 "Rufus - Mengeflush buffer"
t MSG_046 "%s (Cakera %d) [%s]"
t MSG_047 "Beberapa Partisyen"
t MSG_048 "Rufus - 'Flush' penimbal"
t MSG_049 "Rufus - Dibatalkan"
# Error messages
t MSG_050 "Berjaya."
t MSG_051 "Error yang tidak dapat ditentukan ketika berformat."
t MSG_051 "Kesilapan yang tidak dapat ditentukan ketika memformat."
t MSG_052 "Tidak boleh menggunakan sistem fail yang dipilih untuk media ini."
t MSG_053 "Akses kepada peranti dinafikan."
t MSG_054 "Tidak boleh menulis data ke peranti (Dilindungi)"
t MSG_055 "Peranti ini digunakan oleh proses lain. "
"Sila tutup mana-mana proses yang mukin menggunakan peranti ini."
"Sila tutup mana-mana proses yang mungkin menggunakan peranti ini."
t MSG_056 "Format pantas tidak boleh digunakan pada peranti ini."
t MSG_057 "Label jilid tidak sah."
t MSG_058 "Pengendali peranti tidak sah."
@ -9773,36 +9824,35 @@ t MSG_059 "Saiz gugusan yang dipilih tidak boleh digunakan pada peranti ini."
t MSG_060 "Saiz jilid tidak sah."
t MSG_061 "Sila masukkan media boleh alih ke dalam pemacu."
t MSG_062 "Arahan yang tidak disokong diterima."
t MSG_063 "error peruntukkan memori."
t MSG_064 "Error membaca."
t MSG_065 "Error menulis."
t MSG_063 "Kesilapan peruntukkan memori."
t MSG_064 "Kesilapan membaca."
t MSG_065 "Kesilapan menulis."
t MSG_066 "Kegagalan memasang"
t MSG_067 "Media tidak boleh dibuka. Ia mungkin digunakan dalam proses yang lain. "
"Tolong cabut dan masukkan semula dan cuba sekali lagi."
t MSG_068 "Masalah semasa mempartition drive."
t MSG_069 "Tidak boleh meyalin fail kepada drive."
"Sila cabut dan masukkan semula dan cuba sekali lagi."
t MSG_068 "Masalah semasa pembahagian pemacu."
t MSG_069 "Tidak boleh meyalin fail kepada pemacu."
t MSG_070 "Dibatalkan oleh pengguna."
# See http://en.wikipedia.org/wiki/Thread_%28computing%29
t MSG_071 "\"Thread\" tidak boleh dimulakan'."
t MSG_072 "Penyemakan blok rosak tidak dapat dihabiskan."
t MSG_073 "Kegagalan imabasan imej ISO."
t MSG_071 "\"Bebenang\" tidak boleh dimulakan'."
t MSG_072 "Penyemakan blok rosak tidak dapat diselesaikan."
t MSG_073 "Kegagalan imbasan imej ISO."
t MSG_074 "Pengekstrakan imej ISO gagal."
t MSG_075 "Tidak dapat mount semula jilid."
t MSG_076 "Tidak dapat mengepatch/menyediakan fail untuk boot."
t MSG_077 "Tidak dapat menguntukkan huruf untuk drive."
t MSG_078 "Tidak boleh mount jilid GUID."
t MSG_075 "Tidak dapat melekap semula jilid."
t MSG_076 "Tidak dapat 'patch'/menyediakan fail untuk boot."
t MSG_077 "Tidak dapat memperuntukkan huruf untuk pemacu."
t MSG_078 "Tidak boleh lekap jilid GUID."
t MSG_079 "Peranti ini tidak sedia untuk digunakan"
t MSG_080 "Rufus mengesan bahawa Windows masih lagi mengeflush buffer ke dalam peranti USB.\n\n"
t MSG_080 "Rufus mengesan bahawa Windows masih lagi menarik penimbal ke dalam peranti USB.\n\n"
"Bergantung kepada kelajuan peranti USB anda, operasi ini mungkin mengambil masa yang amat lama."
"Terutamanya untuk fail besar .\n\nKami cadangkan anda biarkan Windows tamat dahulu untuk mengelakkan korupsi."
"Namun, jika anda kesuntukkan masa, anda boleh cabutkan peranti anda..."
t MSG_081 "ISO ini tidak disokong"
t MSG_082 "Versi Rufus ini hanya menyokong ISO boleh-but yang berdasarkan bootmgr, EFI, Grub4DOS, GRUB 2, isolinux atau WinPE.\n"
"ISO ini tidak menggunakan mana-mana antara tersebut..."
"Namun, jika anda kesuntukan masa, anda boleh cabutkan peranti anda..."
t MSG_081 "ISO tidak disokong" -> "Imej tidak disokong"
t MSG_082 "Imej ini sama ada tidak boleh boot, atau ia menggunakan kaedah boot atau mampatan yang tidak disokong oleh Rufus..."
t MSG_083 "Gantikan %s?"
t MSG_084 "Imej ISO ini menggunakan versi '%s' yang telah usang.\n"
"Oleh sebab ini, menu but mungkin tidak dipaparkan dengan betul.\n\n"
t MSG_084 "Imej ISO ini menggunakan versi '%s' yang telah lapuk.\n"
"Oleh sebab ini, menu boot mungkin tidak dipaparkan dengan betul.\n\n"
"Versi yang lebih baharu boleh dimuat turun oleh Rufus untuk memperbaiki isu ini:\n"
"- Pilih 'Ya' untuk menyambung ke internet dan muat turun fail tersebut\n"
"- Pilih 'Tidak' untuk tidak mengubahsuai fail ISO yang digunakan\n"
@ -9813,30 +9863,41 @@ t MSG_085 "Muat turun %s"
t MSG_086 "Tiada imej yang dipilih"
# The content between the quotes below (\"Create a bootable disk\") should match
# the beginning of the IDC_BOOT text
t MSG_087 "Sila kilik pada butang disk untuk memilih imej yang boleh boot, "
"atau nyahtandakan kotak semak \"Cipta disk boleh boot menggunakan\"."
t MSG_087 "Sila klik pada butang cakera untuk memilih imej yang boleh boot, "
"atau nyahtandakan kotak semak \"Cipta pemacu boleh boot menggunakan\"."
t MSG_088 "Imej terlalu besar"
t MSG_089 "Imej ini terlalu besar untuk sasaran yang dipilih."
t MSG_090 "ISO tidak disokong"
t MSG_091 "Apabila menggunakan jenis sasaran UEFI , hanya imej boleh boot jenis EFI sahaja disokong. "
"Tolong pilih ISO boleh boot jenis EFI atau tukarkan jenis sasaran kepada BIOS."
t MSG_091 "Apabila menggunakan jenis sasaran UEFI , hanya imej boot jenis EFI sahaja disokong. "
"Sila pilih ISO boot jenis EFI atau tukarkan jenis sasaran kepada BIOS."
t MSG_092 "Sistem fail tidak disokong"
t MSG_093 "PENTING: PERANTI INI MEMPUNYAI BEBERAPA PARTITION!!\n\n"
"Ini mungkin termasuk partition/jilid yang tidak disenaraikan atau tidak boleh dilihat dari Windows. "
"Jika anda mahu meneruskannya, anda bertanggungjawab ke atas kehilangan data dalam partition tersebut."
t MSG_094 "Beberapa partition dikesan"
t MSG_093 "PENTING: PERANTI INI MEMPUNYAI BEBERAPA PARTISYEN!!\n\n"
"Ini mungkin termasuk partisyen/jilid yang tidak disenaraikan atau tidak boleh dilihat dari Windows. "
"Jika anda mahu meneruskannya, anda bertanggungjawab ke atas kehilangan data dalam partisyen tersebut."
t MSG_094 "Beberapa partisyen dikesan"
t MSG_095 "DD Imej"
t MSG_096 "Sistem fail yang sedang dipilih tidak boleh digunakan dengan jenis ISO ini. "
"Sila pilih sistem fail berlainan atau gunakan ISO berlainan."
t MSG_097 "'Windows To Go' hanya boleh digunakan jika sistem fail adalah NTFS."
t MSG_098 "PENTING: Anda cuba memasang 'Windows To Go', tetapi "
"pemacu sasaran anda tidak mempunyai atribut 'FIXED'. Disebabkan "
"ini Windows akan berkemungkinan besar sangkut sepanjang but, kerana Microsoft "
"tidak merekanya untuk berfungsi dengan pemacu yang sebaliknya mempunyai "
"atribut 'REMOVABLE'.\n\nAdakah anda masih mahu teruskan?\n\n"
"Nota: Atribut 'FIXED/REMOVABLE'adalah sifat perkakasan yang "
"hanya boleh ditukar menggunakan alatan tersuai daripada pengilang pemacu. "
"Bagaimanapun alatan tersebut adalah HAMPIR TIDAK AKAN diberikan kepada umum..."
t MSG_099 "Had sistem fail"
t MSG_100 "Imej ISO ini mengandungi fail yang lebih besar daripada 4GB "
"iaitu saiz maksima yang dibenarakan untuk sistem fail FAT/FAT32."
"iaitu saiz maksima yang dibenarkan untuk sistem fail FAT/FAT32."
t MSG_101 "Tiada sokongan WIM"
t MSG_102 "Platform anda tidak boleh mengekstrak fail daripada arkib WIM. Ini diperlukan "
"untuk mencipta cakera boleh boot EFI Windows 7 dan Windows Vista. Anda boleh membaikinya dengan "
"untuk mencipta cakera boot EFI Windows 7 dan Windows Vista. Anda boleh membaikinya dengan "
"cara mendapatkan versi 7-Zip terbaharu.\nAdakah anda mahu ke halaman muat turun 7-zip?"
t MSG_103 "Muat turun %s?"
t MSG_104 "%s atau kemudian memerlukan fail '%s' di komputer anda.\n"
"Oleh sebab fail tersebut lebih besar daripada 100 KB dan sentiasa ada dalam imej %s, "
"Ia tidak termasuk dalam Rufus.\n\nRufus boleh memuat turunkan fail tersebut untuk anda:\n"
"Ia tidak termasuk dalam Rufus.\n\nRufus boleh memuat turun fail tersebut untuk anda:\n"
"- Pilih 'Ya' untuk muat turun fail tersebut\n"
"- Pilih 'Tidak' jika anda mahu menyalin fail tersebut secara manual ke cakera ini pada masa lain\n\n"
"Perhatian: Fail akan dimuat turun ke direktori bersamaan Rufus dan apabila "
@ -9846,30 +9907,39 @@ t MSG_105 "Pembatalan boleh menyebabkan peranti ini TIDAK BOLEH DIGUNAKAN SEMULA
t MSG_106 "Sila pilih folder"
t MSG_107 "Semua fail"
t MSG_108 "Log Rufus"
t MSG_109 "0x%02X (Disk %d)"
t MSG_109 "0x%02X (Cakera %d)"
# "Cluster size" below should be the same as the label for IDS_CLUSTERSIZE_TXT
# "kilobytes" should be the same as in MSG_027
t MSG_110 "MS-DOS tidak boleh-but daripada cakera yang menggunakan saiz gugusan 64 kilobait.\n"
"Tolong tukar saiz gugusan atau gunakan FreeDOS."
t MSG_111 "Incompatible Cluster size"
t MSG_110 "MS-DOS tidak boleh boot daripada cakera yang menggunakan saiz gugusan 64 kilobait.\n"
"Sila tukarkan saiz gugusan atau gunakan FreeDOS."
t MSG_111 "Saiz gugusan tidak sesuai"
# "%d:%02d" below is a duration (mins:secs)
t MSG_112 "Pemformattan jilid UDF yang besar mengambil masa yang amat lama. Pada kelajuan USB 2.0 anggaran masa pemformatan "
"adalah %d:%02d, di mana bar kemajuan akan lihat seperti ia tidak bergerak. Tolong bersabar"
t MSG_112 "Pemformatan jilid UDF yang besar mengambil masa yang amat lama. Pada kelajuan USB 2.0 anggaran masa pemformatan "
"adalah %d:%02d, di mana bar kemajuan akan kelihatan seperti ia tidak bergerak. Sila tunggu"
t MSG_113 "Jilid UDF besar"
t MSG_114 "Imej ini menggunakan Syslinux %s%s tetapi aplikasi ini hanya mempunyai fail pemasangan untuk"
"Syslinux %s%s.\n\nOleh kerana versi-versi baharu Syslinux tidak serasi dengan satu sama lain, maka tidak"
"wajarlah Rufus menyediakan semuanya, dua fail tambahan perlu dimuat turun dari"
"wajar Rufus menyediakan semuanya, dua fail tambahan perlu dimuat turun dari"
"Internet ('ldlinux.sys' dan 'ldlinux.bss'):\n"
"- Pilih 'Ya' untuk menyambung ke Internet dan memuat turun fail tersebut\n"
"- Pilih 'Tidak' untuk membatalkan operasi\n\n"
"NOTA:Fail akan dimuat turun ke dalam direktori aplikasi ini dan akan digunakan semula"
"secara automatik sekiranya sedia ada.\n"
t MSG_115 "Muat turun diperlukan"
t MSG_116 "Imej ini menggunakan Grub %s tetapi aplikasi hanya termasuk fail pemasangan untuk Grub %s.\n\n"
"Sepertimana versi Grub berlainan mungkin tidak sesuai antara satu sama lain, dan ianya tidak "
"mungkin untuk memasukkan mereka semua, Rufus akan cuba mengesan versi fail pemasangan Grub "
"('core.img') yang sepadan dengan salah satu daripada imej anda:\n"
"- Pilih 'Ya' untuk bersambung ke Internet dan cuba memuat turunnya\n"
"- Pilih 'Tidak' untuk menggunakan versi lalai dari Rufus\n"
"- Pilih 'Batal' untuk membatalkan operasi\n\n"
"Nota: Fail akan dimuat turun dalam direktori aplikasi semasa dan akan digunakan semula secara automatik "
"jika ada. Jika tiada padanan boleh dijumpai dalam talian, versi lalai akan digunakan."
# Tooltips
# Partition Scheme and Target Type
t MSG_150 "Selalunya pilihan ini paling selamat. Namun, jika anda ada komputer UEFI dan mahu "
"install OS dalam mod EFI, anda patut pilih pilihan yang lain"
t MSG_150 "Biasanya pilihan ini paling selamat. Namun, jika anda ada komputer UEFI dan mahu "
"memasang OS dalam mod EFI, anda patut pilih pilihan yang lain"
t MSG_151 "Gunakan ini jika anda mahu memasang OS dalam mod EFI, tetapi perlukan akses kepada "
"kandungan USB daripada Windows XP"
t MSG_152 "Pilihan yang disyorkan untuk memasang OS dalam mod EFI dan apabila "
@ -9881,100 +9951,118 @@ t MSG_156 "Uji corak: 0x%02X, 0x%02X, 0x%02X, 0x%02X"
t MSG_157 "Menetapkan sistem fail sasaran"
t MSG_158 "Saiz minima satu blok data akan gunakan dalam sistem fail"
t MSG_159 "Gunakan ini untuk tetapkan label cakera\nHuruf antarabangsa boleh digunakan"
t MSG_160 "Togol pilihan lanjutan"
t MSG_160 "Togel pilihan lanjutan"
t MSG_161 "Semak peranti untuk blok rosak menggunakan corak ujian"
t MSG_162 "Jangan tanda kotak ini untuk menggunakan kaedah pemformatan \"perlahan\""
t MSG_163 "Tanda kotak ini jika anda mahu membuat cakera USB yang boleh-but"
t MSG_164 "Kaedah yang digunakan untuk membuat cakera boleh-but"
t MSG_163 "Tanda kotak ini jika anda mahu membuat cakera USB boot"
t MSG_164 "Kaedah yang digunakan untuk membuat cakera boot"
t MSG_165 "Klik untuk memilih imej..."
t MSG_166 "Klik kotak ini untuk membenarkan paparan label antarabangsa "
"dan menetapkan ikon cakera (akan membuat fail autorun.inf)"
t MSG_167 "Memasang MBR yang membenarkan pilihan boot dan mampu menyamar ID BIOS USB"
t MSG_168 "Cuba menyamarkan cakera USB boleh-but (biasanya 0x80) sebagai disk lain.\n"
"Ini hanya diperlukan jika anda memsang Windows XP dan mempunyai lebih daripada satu cakera"
t MSG_169 "Ciptakan partition tambahan tersembunyi dan cuba melaraskan sempadan partition.\n"
"Ini boleh mempertingkatkan pengesanan but untuk BIOS lama"
t MSG_170 "Membolehkan penyenaraian pagaran cakera keras USB. GUNAKAN PADA RISIKO SENDIRI!!!"
t MSG_171 "Mulakan operasi pemformatan.\nIni akan MEMADAMKAN semua data di sasaran!"
t MSG_168 "Cuba menyamarkan cakera USB boot (biasanya 0x80) sebagai cakera lain.\n"
"Ini hanya diperlukan jika anda memasang Windows XP dan mempunyai lebih daripada satu cakera"
t MSG_169 "Ciptakan partisyen tambahan tersembunyi dan cuba melaraskan sempadan partisyen.\n"
"Ini boleh mempertingkatkan pengesanan boot untuk BIOS lama"
t MSG_170 "Membolehkan penyenaraian pagaran cakera keras USB. GUNAKAN ATAS RISIKO SENDIRI!!!"
t MSG_171 "Mulakan operasi pemformatan.\nIni akan MEMADAMKAN semua data pada sasaran!"
t MSG_172 "Maklumat pelesenan dan penghargaan"
t MSG_173 "Klik untuk memilih..."
# The following will appear in the about dialog
t MSG_174 "Rufus - Utiliti pemformatan USB yang dipercayai"
t MSG_175 "Versi %d.%d (Build %d)"
t MSG_176 "Terjemahan Bahasa Malaysia: Muhammad Aman <aman.tifli@gmail.com>"
t MSG_176 "Terjemahan Bahasa Malaysia:\\line\n"
"Muhammad Aman <mailto:aman.tifli@gmail.com>\\line\n"
"VGPlayer <mailto:razman90a@yahoo.com.my>"
t MSG_177 "Laporkan masalah atau cadangan penambahbaikan di:"
t MSG_178 "Hak cipta tambahan:"
t MSG_179 "Polisi mengemaskini:"
t MSG_180 "jika anda pilih untuk membenarakan program ini menyemak untuk versi baru, "
"anda bersetuju untuk membenarkan server kami mengumpulkan maklumat berikut:"
t MSG_181 "Versi dan arkitekture sistem operasi"
t MSG_179 "Polisi kemaskini:"
t MSG_180 "jika anda pilih untuk membenarkan aturcara ini menyemak untuk versi baru, "
"anda bersetuju untuk membenarkan pelayan kami mengumpulkan maklumat berikut:"
t MSG_181 "Versi dan kerangka sistem operasi"
t MSG_182 "Versi aplikasi yang anda gunakan"
t MSG_183 "IP address anda"
t MSG_184 "Untuk tujuan menjana statistik penggunaan peribadi , kami mungkin menyimpan informasi yang dikumpulkan, "
"\\b untuk sekurang-paling setahun\\b0 . Namun, kami tidak rela untuk mendedahkan informasi ini kepada mana-mana pihak ketiga."
t MSG_183 "Alamat IP anda"
t MSG_184 "Untuk tujuan menjana statistik penggunaan peribadi , kami mungkin menyimpan maklumat yang dikumpulkan, "
"\\b untuk sekurang-kurangnya setahun\\b0 . Namun, kami tidak rela untuk mendedahkan maklumat ini kepada mana-mana pihak ketiga."
t MSG_185 "Proses mengemas kini:"
t MSG_186 "Rufus tidak memasang atau menjalankan servis di latar belakang. Oleh itu, semakan kemas kini hanya dijalankan apabila aplikasi utama berjalan.\\line\n"
"Akses internet diperlukan untuk menymeak untuk versi baru."
"Akses internet diperlukan untuk menyemak untuk versi baru."
t MSG_187 "Imej tidak sah untuk pilihan boot yang dipilih"
t MSG_188 "Imej tidak serasi dengan pilihan boot yang dipilih. Tolong gunakan imej lain atau pilih pilihan boot lain."
t MSG_188 "Imej tidak serasi dengan pilihan boot yang dipilih. Sila gunakan imej lain atau pilih pilihan boot lain."
t MSG_189 "Imej ISO ini tidak serasi dengan sistem fail yang dipilih"
t MSG_190 "Pemacu tidak serasi dikesan"
t MSG_191 "Melepasi tulisan"
t MSG_192 "Melepasi bacaan"
t MSG_193 "Muat turun %s"
t MSG_194 "Tidak boleh muat turun %s"
t MSG_195 "Menggunakan %s fail versi dibenam"
t MSG_196 "PENTING: PEMACU INI MENGGUNAKAN SAIZ SEKTOR BUKAN PIAWAIAN!\n\n"
"Pemacu konvensional mengunakan saiz sektor 512 bait tetapi pemacu ini menggunakan "
"%d bait. Dalam banyak kes, ini bermaksud anda TIDAK akan mampu untuk but dari pemacu ini.\n"
"Rufus boleh cuba untuk mencipta pemacu boleh but, tetapi TIDAK ADA JAMINAN ianya akan berfungsi."
t MSG_197 "Saiz sektor bukan standard dikesan"
t MSG_198 "'Windows To Go' hanya boleh dipasang dalam pemacu berpartisyen GPT jika ia mempunyai "
"set atribut 'FIXED'. Pemacu semasa tidak dikesan sebagai 'FIXED'."
t MSG_199 "Pilih ini jika anda merancang untuk memasang Windows, ke cakera lain, "
"menggunakan peranti dipilih sebagai media pemasangan."
t MSG_200 "Pilih ini jika anda mahu untuk menjalankan Windows secara langsung dari peranti dipilih."
# Status messages - these messages will appear on the status bar
t MSG_201 "Sedang membatalkan - Sila tunggu..."
t MSG_202 "Mengimbas imej..."
t MSG_203 "Imbasan imej gagal"
# Parameter: the name of an obsolete Syslinux .c32 module. eg: "Obsolete vesamenu.c32 detected"
t MSG_204 "%s usang dikesan"
t MSG_204 "%s lapuk dikesan"
# Display the name of the ISO selected. eg: "Using ISO: en_win7_x64_sp1.iso"
t MSG_205 "Menggunakan ISO: %s"
t MSG_205 "Menggunakan ISO: %s" -> "Menggunakan imej: %s"
# Typically "Missing ldlinux.c32 file"
t MSG_206 "Tidak jumpa fail %s"
t MSG_206 "Tidak menjumpai fail %s"
# The name proposed by Windows' Computer Management -> Disk Management when you try to format a drive
# with an empty label. See http://rufus.akeo.ie/pics/default_name.png
t MSG_207 "Jilid baharu"
# Same message, once for singular and plural ("1 device found", "2 devices found")
t MSG_208 "%d peranti dijumpa"
t MSG_209 "%d peranti dijumpa"
t MSG_210 "SELESAI"
t MSG_208 "%d peranti dijumpai"
t MSG_209 "%d peranti dijumpai"
t MSG_210 "SELESAI" -> "SEDIA".
t MSG_211 "DIBATALKAN"
t MSG_212 "GAGAL"
# Used when a new update has been downloaded and launched
t MSG_213 "Melancarkan aplikasi baru..."
t MSG_214 "Gagal untuk melancakan aplikasi baru"
t MSG_214 "Gagal untuk melancarkan aplikasi baru"
# Open/Save file
t MSG_215 "%s dibuka"
t MSG_216 "%s disimpan"
# Formatting status (make sure you use a double % to print the percent sign)
t MSG_217 "Pemformatan: %0.1f%% selesai"
t MSG_218 "Mencipta sistem fail: Tugas %d/%d selesai"
t MSG_219 "NTFS Fixup: %d%% selesai"
t MSG_219 "Pembaikian NTFS: %d%% selesai"
# Parameter: the file system and an estimated duration in mins and secs.
# eg. "Formatting (UDF) - Jangka masa anggaran 3:21..."
# NB: if "estimated duration" is too long, just use "estimated" or an abbreviation
t MSG_220 "Pemformattan (%s) - Jangka masa anggaran %d:%02d..."
t MSG_220 "Pemformatan (%s) - Jangka masa anggaran %d:%02d..."
t MSG_221 "Menetapkan label (Ini mungkin mengambil sedikit masa)..."
# Parameter: the file system. eg. "Formatting (NTFS)..."
t MSG_222 "Pemformattan (%s)..."
t MSG_223 "NTFS Fixup (Checkdisk)..."
t MSG_222 "Pemformatan (%s)..."
t MSG_223 "Pembaikian NTFS (Periksa cakera)..."
t MSG_224 "Memadam struktur MBR/PBR/GPT..."
t MSG_225 "Meminta akses cakera..."
t MSG_226 "Menganalisis rekod but sedia ada..."
t MSG_226 "Menganalisis rekod boot sedia ada..."
t MSG_227 "Menutup jilid sedia ada..."
t MSG_228 "Menulis \"Master boot record\"..."
t MSG_229 "Menulis rekod but partition..."
t MSG_228 "Menulis \"Rekod master boot\"..."
t MSG_229 "Menulis rekod boot partisyen..."
t MSG_230 "Menyalin fail DOS..."
t MSG_231 "Menyalin fail ISO..."
t MSG_232 "Persediaan boot EFI Win7 (ini mungkin mengambil sedikit masa)..."
t MSG_233 "Memuktamadkan, sila tunggu..."
t MSG_233 "Menyiapkan, sila tunggu..."
# Takes the Syslinux version as parameter, eg. "Installing Syslinux v5..."
t MSG_234 "Memasang Syslinux %s..."
# Bad blocks status. eg: "Bad Blocks: PASS 1/2 - 12.34% (0/0/1 errors)"
t MSG_235 "Blok rosak: %s %d/%d - %0.2f%% (%d/%d/%d errors)"
t MSG_235 "Blok rosak: MELEPASI %d/%d - %0.2f%% (%d/%d/%d kesilapan)" -> "Blok rosak: %s %d/%d - %0.2f%% (%d/%d/%d kesilapan)"
t MSG_236 "Blok rosak: menguji dengan corak rawak"
t MSG_237 "Blok rosak: Menguji dengan corak 0x%02X"
# eg. "Partitioning (MBR)..."
t MSG_238 "Mempartition (%s)..."
t MSG_239 "Memadam partition..."
t MSG_238 "Mempartisyenkan (%s)..."
t MSG_239 "Memadam partisyen..."
t MSG_240 "Memuat turun %s: menyambung ke internet..."
t MSG_241 "memuat turun: %0.1f%%"
t MSG_242 "Gagal memuat turun fail."
@ -9983,13 +10071,13 @@ t MSG_244 "Kemas kini: Tidak dapat menyambung ke internet"
t MSG_245 "Kemsa kini: Tidak dapat mengakses data versi"
t MSG_246 "Versi baru Rufus boleh didapati!"
t MSG_247 "Tiada versi baru Rufus didapati"
t MSG_248 "Kekunci registry aplikasi berjaya dipadam"
t MSG_249 "Gagal memadam kekunci registry aplikasi"
t MSG_248 "Kekunci daftar aplikasi berjaya dipadam"
t MSG_249 "Gagal memadam kekunci daftar aplikasi"
# eg. "Fixed disk detection enabled" "ISO size check disabled"
t MSG_250 "%s dibolehkan"
t MSG_251 "%s tidak dibolehkan"
t MSG_252 "Menyemak saiz"
t MSG_253 "Pengesanan cakera tetap"
t MSG_253 "Pengesanan cakera tetap" -> "Pengesanan cakera keras"
t MSG_254 "Memaksa pemformatan FAT32 besar"
t MSG_255 "NoDriveTypeAutorun akan dipadam apabila keluar"
t MSG_256 "Pengesanan cakera palsu"
@ -10000,10 +10088,45 @@ t MSG_260 "Mampatan NTFS"
t MSG_261 "Menulis imej: %0.1f%% selesai"
t MSG_262 "Sokongan ISO"
t MSG_263 "Guna saiz seunit yang BETUL"
t MSG_264 "Memadam direktori '%s'"
t MSG_265 "Pengesanan cakera VMWare"
t MSG_266 "Mod dwi UEFI/BIOS"
t MSG_267 "Menggunakan imej Windows: %0.1f%% selesai"
t MSG_268 "Menggunakan imej Windows..."
t MSG_269 "Mengekalkan cap masa"
t MSG_270 "Nyahpijat USB"
t MSG_271 "Mengira semak tambah imej: %0.1f%% selesai"
t MSG_272 "Mengira semak tambah MD5, SHA1 dan SHA256 imej dipilih"
t MSG_273 "Menukar bahasa aplikasi"
t MSG_274 "Imej ISOHybrid dikesan"
# '%s' below will be replaced with your translations for MSG_036 ("ISO Image") and MSG_095 ("DD Image")
t MSG_275 "Imej yang anda telah pilih adalah imej 'ISOHybrid'. Ini bermaksud ia boleh ditulis sama ada dalam "
"%s mod (salinan fail) atau %s mod (imej cakera).\n"
"Rufus galakkan menggunakan mod %s, jadi anda selalu mempunyai akses penuh ke pemacu selepas menulisnya.\n"
"Bagaimanapun, jika anda menghadapi isu-isu semasa boot, anda boleh cuba menulis imej ini lagi dalam mod %s.\n\n"
"Sila pilih mod yang anda mahu guna untuk menulis imej ini:"
# '%s' below will be replaced with your translation for MSG_036 ("ISO Image")
t MSG_276 "Menulis dalam mod %s (Digalakkan)"
# '%s' below will be replaced with your translation for MSG_095 ("DD Image")
t MSG_277 "Menulis dalam mod %s"
# The following will be used for new controls of the Rufus 3.0 interface
# They are added as messages, so that I will have them available when needed.
# 278 & 280 will be dropdown titles, similar to how IDS_DEVICE_TXT or IDS_PARTITION_TYPE_TXT are used
# 279 & 281 will be items that can appear in the dropdowns
t MSG_278 "Jenis boot"
t MSG_279 "Tidak boleh boot"
t MSG_280 "Pilihan imej"
t MSG_281 "(Sila pilih satu imej)"
t MSG_282 "Penguncian pemacu USB eksklusif"
t MSG_283 "tandatangan tidak sah"
t MSG_284 "'Executable' yang dimuat turun kehilangan tandatangan digital."
t MSG_285 "'Executable' yang dimuat turun ditandatangani oleh '%s'.\nIni bukannya tandatangan yang kami kenal dan boleh "
"menunjukkan beberapa bentuk aktiviti berniat jahat...\nAdakah anda pasti anda mahu menjalankan fail ini?"
t MSG_286 "Mensifarkan pemacu: %0.1f%% selesai"
################################################################################
l "nb-NO" "Norwegian (Norsk)" 0x0414
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -10473,11 +10596,13 @@ t MSG_283 "Ugyldig signatur"
t MSG_284 "Den nedlastede programfil mangler en digital signatur."
t MSG_285 "Den nedlastede programfil er signert av '%s'.\nDette er en signatur vi ikke gjenkjenner, og kan "
"indikere en form for skadelig aktivitet...\nEr du sikker på at du vil kjøre denne filen?"
t MSG_286 "Skriver 0-er til stasjon: %0.1f%% ferdig"
t MSG_287 "Oppdagelse av ikke-USB flyttbare stasjoner"
################################################################################
l "fa-IR" "Persian (فارسی)" 0x0429
a "r"
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -11020,10 +11145,12 @@ t MSG_283 "امضای نامعتبر"
t MSG_284 "فایل اجرایی دانلود شده امضای دیجیتال ندارد."
t MSG_285 "این فایل اجرایی دانلود شده، توسط '%s' امضا شده است.\n ما این امضا را نمی‌شناسیم و "
"ناشناس بودن آن ممکن است نشانه نوعی فعالیت خرابکارانه باشد...\nآیا مطمئن هستید می‌خواهید این فایل را اجرا کنید؟"
t MSG_286 "درحال بازنويسي درايو با داده صفر؛ درصد پيشرفت: %0.1f%%"
t MSG_287 "شناسايي درايوهاي غير USB"
################################################################################
l "pl-PL" "Polish (Polski)" 0x0415
v 1.0.19
v 1.0.20
b "en-US"
# my info: 6.9.2015,22:39
@ -11495,10 +11622,12 @@ t MSG_283 "Nieprawidłowa sygnatura"
t MSG_284 "Pobrany plik wykonywalny nie posiada cyfrowej sygnatury."
t MSG_285 "Pobrany plik wykonywalny jest podpisany przez '%s'.\nTo nie jest rozpoznawana przez nas sygnatura i może "
"wskazywać na pewne formy złośliwych zachowań...\nCzy na pewno chcesz uruchomić ten plik?"
t MSG_286 "Zerowanie dysku: ukończono %0.1f%%"
t MSG_287 "Wykrywanie dysków wymiennych nie-USB"
################################################################################
l "pt-BR" "Portuguese Brazilian (Português do Brasil)" 0x0416
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -11930,10 +12059,12 @@ t MSG_283 "Assinatura digital inválida"
t MSG_284 "O executável baixado não contém uma assinatura digital."
t MSG_285 "O executável baixado é assinado por '%s'.\nEsta assinatura não é reconhecida e pode "
"indicar alguma forma de atividade maliciosa...\nVocê tem certeza que deseja executar este arquivo?"
t MSG_286 "Zerando HD: %0.1f%% concluído"
t MSG_287 "Detecção de drives não USB removíveis"
################################################################################
l "pt-PT" "Portuguese Standard (Português)" 0x0816
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -12390,10 +12521,12 @@ t MSG_283 "Assinatura inválida"
t MSG_284 "No executável transferido está a faltar uma assinatura digital."
t MSG_285 "O executável transferido está assinado por '%s'.\nNão é uma assinatura reconhecida e "
"poderá indicar algum tipo de actividade mal intencionada...\nTem certeza de que deseja executar este ficheiro?"
t MSG_286 "A limpar disco: %0.1f%% concluído"
t MSG_287 "Detecção de unidades removíveis não-USB"
################################################################################
l "ro-RO" "Romanian (Română)" 0x0418, 0x0818
v 1.0.19
v 1.0.20
b "en-US"
g IDD_DIALOG
@ -12805,10 +12938,12 @@ t MSG_283 "Semnătură invalidă"
t MSG_284 "Executabilul descărcat nu este semnat."
t MSG_285 "Executabilul descărcat este semnat de către '%s'.\nAceasta nu este o semnătură recunoscută și ar putea "
"indica o anumită formă de activitate dăunătoare...\nSunteți sigur că doriți să executați acest fișier?"
t MSG_286 "Unitatea zero: %0.1f%% finisat"
t MSG_287 "Detectarea unităților mobile de bază non-USB"
################################################################################
l "ru-RU" "Russian (Русский)" 0x0419, 0x0819
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -13241,6 +13376,8 @@ t MSG_283 "Неверная подпись"
t MSG_284 "У загруженного файла отсутствует цифровая подпись."
t MSG_285 "Загруженный файл подписан '%s'.\nЭто не та подпись, которая признается, что "
"указывает на некоторые формы вредоносных действий...\nВы уверены, что хотите запустить этот файл?"
t MSG_286 "Обнуление диска: %0.1f%% выполнено"
t MSG_287 "Выявление не-USB съемных дисков"
################################################################################
l "sr-SP" "Serbian (Srpski)" 0x241a, 0x081a, 0x181a, 0x2c1a, 0x701a, 0x7c1a
@ -14170,8 +14307,8 @@ t MSG_285 "Stiahnutý inštalátor podpísal '%s'.\nTento podpis nebol rozoznan
"nejakú formu škodlivej aktivity...\nSte si istý, že chcete spustiť tento súbor?"
################################################################################
l "sl-SI" "Slovene (Slovenščina)" 0x0424
v 1.0.19
l "sl-SI" "Slovenian (Slovenščina)" 0x0424
v 1.0.20
b "en-US"
# Main dialog
@ -14609,10 +14746,12 @@ t MSG_283 "Neveljaven podpis"
t MSG_284 "Prenesena datoteka nima digitalnega podpisa."
t MSG_285 "Oseba, ki je podpisala preneseno datoteko, je '%s'.\nTa podpis se ne ujema s pričakovanim, kar lahko pomeni, "
"da je to zlonamerna datoteka, ki jo vam je nekdo podtaknil.\nAli ste prepričani, da jo želite zagnati?"
t MSG_286 "Zapolnjujem nosilec z ničlami: %0.1f%%"
t MSG_287 "Zaznava neodstranljivih nosilcev"
################################################################################
l "es-ES" "Spanish (Español)" 0x040a, 0x080a, 0x0c0a, 0x100a, 0x140a, 0x180a, 0x1c0a, 0x200a, 0x240a, 0x280a, 0x2c0a, 0x300a, 0x340a, 0x380a, 0x3c0a, 0x400a, 0x440a, 0x480a, 0x4c0a, 0x500a, 0x540a, 0x580a
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -15078,10 +15217,12 @@ t MSG_283 "Firma no válida"
t MSG_284 "El ejecutable descargado carece de firma digital."
t MSG_285 "El ejecutable descargado está firmado por '%s'.\nNo reconocemos este tipo de firma y podría "
"indicar alguna forma de actividad maliciosa...\n¿Está seguro de que quieres ejecutar este fichero?"
t MSG_286 "Borrando a ceros la unidad: %0.1f%% completado"
t MSG_287 "Detección de unidades extraibles no USB"
################################################################################
l "sv-SE" "Swedish (Svenska)" 0x041d, 0x081d
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -15543,10 +15684,12 @@ t MSG_283 "Ogiltig signatur"
t MSG_284 "Den nedladdade körbara filen saknar digital signatur."
t MSG_285 "Den nedladdade körbara filen är signerad av '%s'.\nDetta är inte en signatur vi känner igen och "
"detta kan tyda på någon form av skadlig aktivitet...\nÄr du säker på att du vill köra filen?"
t MSG_286 "Nollställer enheten: %0.1f%% klart"
t MSG_287 "Visar även icke flyttbara USB-enheter"
################################################################################
l "th-TH" "Thai (ไทย)" 0x041e
v 1.0.19
v 1.0.20
# Main dialog
g IDD_DIALOG
@ -15681,8 +15824,8 @@ t MSG_045 "USB Storage Device (Generic)"
t MSG_046 "%s (Disk %d) [%s]"
# Used when a drive is detected that contains more than one partition
t MSG_047 "พบหลายพาร์ทิชั่น"
t MSG_048 "Rufus - Flushing buffers"
t MSG_049 "Rufus - Cancellation"
t MSG_048 "Rufus - กำลังล้างบัฟเฟอร์"
t MSG_049 "Rufus - กำลังยกเลิกการดำเนินการ"
# Error messages
t MSG_050 "สำเร็จ"
@ -15969,7 +16112,7 @@ t MSG_262 "การรองรับ ISO"
t MSG_263 "ใช้หน่วยของขนาดตามจริง (เช่น 1KB คือ 1024 bytes)"
t MSG_264 "กำลังลบไดเรคทอรี่ '%s'"
t MSG_265 "กำลังตรวจหาดิสก์ VMWare"
t MSG_266 "Dual UEFI/BIOS mode"
t MSG_266 "ระบบบูตคู่ UEFI/BIOS"
t MSG_267 "กำลังใช้อิมเมจ Windows: %0.1f%%"
t MSG_268 "กำลังใช้อิมเมจ Windows..."
t MSG_269 "Preserve timestamps"
@ -16001,11 +16144,12 @@ t MSG_283 "ใบรับรองผิดพลาด"
t MSG_284 "ไฟล์ที่ดาวน์โหลดมาไม่มีการรับรองดิจิทัล"
t MSG_285 "ไฟล์ที่ดาวน์โหลดมาถูกรับรองโดย '%s'.\nซึ่งไม่ใช่การรับรองที่เรารู้จัก ซึ่งอาจ"
"ทำให้เกิดกิจกรรมที่เกิดภัยคุกคามได้...\nคุณต้องการจะเปิดไฟล์นี้หรือไม่?"
t MSG_286 "Zeroing drive: %0.1f%%"
t MSG_286 "กำลังเขียนไดร์ฟด้วย zero byte: %0.1f%%"
t MSG_287 "กำลังตรวจสอบไดร์ฟที่ไม่ใช่ USB"
################################################################################
l "tr-TR" "Turkish (Türkçe)" 0x041F
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -16481,10 +16625,12 @@ t MSG_283 "Geçersiz imza"
t MSG_284 "İndirilen yürütülebilir dosyanın dijital imzası eksik."
t MSG_285 "İndirilen yürütülebilir dosya '%s' tarafından imzalanmış.\nBu tanımlayabildiğimiz ve kötü niyetli "
"etkinliğini belirtebileceğimiz bir imza değil...\nBu dosyayı çalıştırmak istediğinize emin misiniz?"
t MSG_286 "Sürücü sıfırlanıyor: %0.1f%% tamamlandı"
t MSG_287 "USB olmayan çıkarılabilir aygıtlar taranıyor"
################################################################################
l "uk-UA" "Ukrainian (Українська)" 0x0422
v 1.0.19
v 1.0.20
b "en-US"
# Main dialog
@ -16936,6 +17082,8 @@ t MSG_283 "Невірний підпис"
t MSG_284 "У завантаженого файлу відсутній цифровий підпис."
t MSG_285 "Завантажений файл підписаний '%s'.\nЦе не той підпис, який визнається, "
"що вказує на деякі форми шкідливих дій...\nВи впевнені, що хочете запустити цей файл?"
t MSG_286 "Обнуління диска: %0.1f%% завершено"
t MSG_287 "Виявлення знімних не-USB носіїв"
################################################################################
l "vi-VN" "Vietnamese (Tiếng Việt)" 0x042A

View file

@ -15,9 +15,26 @@ LastUpdateCheck = 13068056756
UpdateCheckInterval = 86400
; Whether the check for updates should also include new BETA releases
CheckForBetas = 1
; Use this to increases the log verbosity, for the update checks
VerboseUpdateCheck = 0
; Use this to increase the log verbosity for the updates check (0-2)
; VerboseUpdateCheck = 2
; If you are paranoid about apps writing to the registry, you can uncomment the
; following. It will disable the Local Group Policy calls that Rufus issues, to
; temporarily prevent the *annoying* notices Windows issues about new drives.
; DisableLGP = 1
; DisableLGP = 1
; Start with the 'Advanced Options' panel displayed
; AdvancedMode = 1
; Have Rufus to preserve timestamps when copying files (Alt-T)
; PreserveTimestamps = 1
; Disable the whole Kibi/Gibi nonsense (Alt-U)
; UseProperSizeUnits = 1
; Display extended information duringh USB enumeration (Alt-.)
; EnableUsbDebug = 1
; Don't perform a fake drive test during bad blocks check (Alt-B)
; DisableFakeDrivesCheck = 1
; Allow the creation of dual UEFI+BIOS bootable drives for Windows (Alt-E)
; EnableWindowsDualUefiBiosMode = 1
; Also use RidgeCrop's Large FAT32 format algorithm when formatting smaller drives (Alt-L)
; ForceLargeFat32Formatting = 1
; Enable listing of VMWare's VMDK drives when used in a virtual machine (Alt-W)
; EnableVmdkDetection = 1

View file

@ -4,13 +4,13 @@ Rufus for NTFS UEFI boot support. See https://github.com/pbatard/uefi-ntfs.
This image, which you can mount as FAT filesystem or open in 7-zip, contains
the following data:
o The NTFS UEFI drivers from efifs (https://github.com/pbatard/efifs) which were
compiled, with compression disabled, using Visual Studio 2013 Community Edition.
These are the \EFI\Rufus\ntfs_[x32|x64].efi files.
compiled, with compression disabled, using Visual Studio 2015 Community Edition.
These are the \EFI\Rufus\ntfs_[ia32|x64|arm].efi files.
o The UEFI:NTFS binaries (https://github.com/pbatard/uefi-ntfs), which were also
compiled using Visual Studio 2013 Community Edition.
These are the \EFI\Boot\boot[ia32|x64].efi files.
compiled using Visual Studio 2015 Community Edition.
These are the \EFI\Boot\boot[ia32|x64|arm].efi files.
The FAT partition was created on Debian GNU/Linux using the following commands
dd if=/dev/zero of=uefi-ntfs.img bs=512 count=512
dd if=/dev/zero of=uefi-ntfs.img bs=512 count=1024
mkfs.vfat -n UEFI_NTFS uefi-ntfs.img
and then mounting the uefi-ntfs.img image and copying the relevant files.

Binary file not shown.

View file

@ -1,7 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rufus", "src\.msvc\rufus.vcxproj", "{731858A7-0303-4988-877B-9C0DD6471864}"
EndProject
@ -11,6 +10,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "syslinux-libfat", "src\sysl
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "syslinux-libinstaller", "src\syslinux\libinstaller\.msvc\libinstaller.vcxproj", "{266502AC-CD74-4581-B707-938A7D05AD7A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "syslinux-win", "src\syslinux\win\.msvc\win.vcxproj", "{7D2E9784-DDF7-4988-A887-CF099BC3B340}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcdio-iso9660", "src\libcdio\iso9660\.msvc\iso9660.vcxproj", "{D4E80F35-2604-40AC-B436-97B052ECB572}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcdio-udf", "src\libcdio\udf\.msvc\udf.vcxproj", "{0CEC40A6-A195-4BE5-A88B-0AB00EB142EC}"
@ -61,6 +62,14 @@ Global
{266502AC-CD74-4581-B707-938A7D05AD7A}.Release|x86_32.Build.0 = Release|Win32
{266502AC-CD74-4581-B707-938A7D05AD7A}.Release|x86_64.ActiveCfg = Release|x64
{266502AC-CD74-4581-B707-938A7D05AD7A}.Release|x86_64.Build.0 = Release|x64
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Debug|x86_32.ActiveCfg = Debug|Win32
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Debug|x86_32.Build.0 = Debug|Win32
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Debug|x86_64.ActiveCfg = Debug|x64
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Debug|x86_64.Build.0 = Debug|x64
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Release|x86_32.ActiveCfg = Release|Win32
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Release|x86_32.Build.0 = Release|Win32
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Release|x86_64.ActiveCfg = Release|x64
{7D2E9784-DDF7-4988-A887-CF099BC3B340}.Release|x86_64.Build.0 = Release|x64
{D4E80F35-2604-40AC-B436-97B052ECB572}.Debug|x86_32.ActiveCfg = Debug|Win32
{D4E80F35-2604-40AC-B436-97B052ECB572}.Debug|x86_32.Build.0 = Debug|Win32
{D4E80F35-2604-40AC-B436-97B052ECB572}.Debug|x86_64.ActiveCfg = Debug|x64

View file

@ -84,7 +84,7 @@
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\syslinux\win;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>false</ExceptionHandling>
@ -108,7 +108,7 @@
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\syslinux\win;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
@ -136,7 +136,7 @@
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\syslinux\win;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>false</ExceptionHandling>
@ -163,7 +163,7 @@
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\msvc-missing;..\ms-sys\inc;..\syslinux\libinstaller;..\syslinux\libfat;..\syslinux\win;..\libcdio;..\getopt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>false</ExceptionHandling>
@ -200,7 +200,7 @@
<ClCompile Include="..\stdio.c" />
<ClCompile Include="..\stdlg.c" />
<ClCompile Include="..\syslinux.c" />
<ClCompile Include="..\usb.c" />
<ClCompile Include="..\dev.c" />
<ClCompile Include="..\vhd.c" />
</ItemGroup>
<ItemGroup>
@ -209,6 +209,7 @@
<ClInclude Include="..\drive.h" />
<ClInclude Include="..\format.h" />
<ClInclude Include="..\hdd_vs_ufd.h" />
<ClInclude Include="..\missing.h" />
<ClInclude Include="..\settings.h" />
<ClInclude Include="..\libcdio\cdio\cdio.h" />
<ClInclude Include="..\libcdio\cdio\iso9660.h" />
@ -223,7 +224,7 @@
<ClInclude Include="..\license.h" />
<ClInclude Include="..\smart.h" />
<ClInclude Include="..\sys_types.h" />
<ClInclude Include="..\usb.h" />
<ClInclude Include="..\dev.h" />
</ItemGroup>
<ItemGroup>
<Manifest Include="..\rufus.manifest" />
@ -261,6 +262,9 @@
<ProjectReference Include="..\syslinux\libinstaller\.msvc\libinstaller.vcxproj">
<Project>{266502ac-cd74-4581-b707-938a7d05ad7a}</Project>
</ProjectReference>
<ProjectReference Include="..\syslinux\win\.msvc\win.vcxproj">
<Project>{7d2e9784-ddf7-4988-a887-cf099bc3b340}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -66,15 +66,15 @@
<ClCompile Include="..\smart.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\usb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\checksum.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pki.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\dev.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\rufus.h">
@ -128,15 +128,18 @@
<ClInclude Include="..\drive.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\usb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\bled\bled.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\settings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\missing.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\dev.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\res\rufus.ico">

View file

@ -3,7 +3,7 @@ TARGETTYPE=PROGRAM
UMTYPE=windows
UMENTRY=winmain
INCLUDES=$(DDK_INC_PATH);.\ms-sys\inc;.\syslinux\libfat;.\syslinux\libinstaller;.\msvc-missing;.\libcdio;.\getopt;.\bled
INCLUDES=$(DDK_INC_PATH);.\ms-sys\inc;.\syslinux\libfat;.\syslinux\libinstaller;.\syslinux\win;.\msvc-missing;.\libcdio;.\getopt;.\bled
C_DEFINES = $(C_DEFINES) /DDDKBUILD /DUNICODE /D_UNICODE /DRUFUS_LOC /DISOLATION_AWARE_ENABLED
!IFNDEF MSC_WARNING_LEVEL
@ -25,6 +25,7 @@ TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
.\ms-sys\ms-sys.lib \
.\syslinux\libfat\libfat.lib \
.\syslinux\libinstaller\libinstaller.lib \
.\syslinux\win\win.lib \
.\libcdio\iso9660\iso9660.lib \
.\libcdio\udf\udf.lib \
.\libcdio\driver\driver.lib \
@ -35,6 +36,7 @@ SXS_APPLICATION_MANIFEST=..\rufus.manifest
SOURCES=badblocks.c \
checksum.c \
dev.c \
dos.c \
dos_locale.c \
drive.c \
@ -51,6 +53,5 @@ SOURCES=badblocks.c \
stdio.c \
stdlg.c \
syslinux.c \
usb.c \
vhd.c \
rufus.rc

View file

@ -1,4 +1,4 @@
SUBDIRS = bled ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/udf libcdio/driver ../res/localization
SUBDIRS = bled ms-sys syslinux/libfat syslinux/libinstaller syslinux/win libcdio/iso9660 libcdio/udf libcdio/driver ../res/localization
noinst_PROGRAMS = rufus
@ -10,9 +10,9 @@ AM_V_WINDRES = $(AM_V_WINDRES_$(V))
%_rc.o: %.rc ../res/localization/embedded.loc
$(AM_V_WINDRES) $(AM_RCFLAGS) -i $< -o $@
rufus_SOURCES = badblocks.c checksum.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c net.c parser.c \
pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c usb.c vhd.c
rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS)
rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c \
net.c parser.c pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c vhd.c
rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS)
rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows
rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \
libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust
rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \
libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -luuid

View file

@ -88,20 +88,20 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
PROGRAMS = $(noinst_PROGRAMS)
am_rufus_OBJECTS = rufus-badblocks.$(OBJEXT) rufus-checksum.$(OBJEXT) \
rufus-dos.$(OBJEXT) rufus-dos_locale.$(OBJEXT) \
rufus-drive.$(OBJEXT) rufus-format.$(OBJEXT) \
rufus-icon.$(OBJEXT) rufus-iso.$(OBJEXT) \
rufus-localization.$(OBJEXT) rufus-net.$(OBJEXT) \
rufus-parser.$(OBJEXT) rufus-pki.$(OBJEXT) \
rufus-dev.$(OBJEXT) rufus-dos.$(OBJEXT) \
rufus-dos_locale.$(OBJEXT) rufus-drive.$(OBJEXT) \
rufus-format.$(OBJEXT) rufus-icon.$(OBJEXT) \
rufus-iso.$(OBJEXT) rufus-localization.$(OBJEXT) \
rufus-net.$(OBJEXT) rufus-parser.$(OBJEXT) rufus-pki.$(OBJEXT) \
rufus-rufus.$(OBJEXT) rufus-smart.$(OBJEXT) \
rufus-stdfn.$(OBJEXT) rufus-stdio.$(OBJEXT) \
rufus-stdlg.$(OBJEXT) rufus-syslinux.$(OBJEXT) \
rufus-usb.$(OBJEXT) rufus-vhd.$(OBJEXT)
rufus-vhd.$(OBJEXT)
rufus_OBJECTS = $(am_rufus_OBJECTS)
rufus_DEPENDENCIES = rufus_rc.o bled/libbled.a ms-sys/libmssys.a \
syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \
libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a \
libcdio/driver/libdriver.a
syslinux/win/libwin.a libcdio/iso9660/libiso9660.a \
libcdio/udf/libudf.a libcdio/driver/libdriver.a
rufus_LINK = $(CCLD) $(rufus_CFLAGS) $(CFLAGS) $(rufus_LDFLAGS) \
$(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
@ -265,18 +265,18 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = bled ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/udf libcdio/driver ../res/localization
SUBDIRS = bled ms-sys syslinux/libfat syslinux/libinstaller syslinux/win libcdio/iso9660 libcdio/udf libcdio/driver ../res/localization
AM_V_WINDRES_0 = @echo " RC $@";$(WINDRES)
AM_V_WINDRES_1 = $(WINDRES)
AM_V_WINDRES_ = $(AM_V_WINDRES_$(AM_DEFAULT_VERBOSITY))
AM_V_WINDRES = $(AM_V_WINDRES_$(V))
rufus_SOURCES = badblocks.c checksum.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c net.c parser.c \
pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c usb.c vhd.c
rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c \
net.c parser.c pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c vhd.c
rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS)
rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS)
rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows
rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \
libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust
rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \
libcdio/iso9660/libiso9660.a libcdio/udf/libudf.a libcdio/driver/libdriver.a -lsetupapi -lole32 -lgdi32 -lwininet -lshlwapi -lcrypt32 -lwintrust -lcomdlg32 -luuid
all: all-recursive
@ -344,6 +344,12 @@ rufus-checksum.o: checksum.c
rufus-checksum.obj: checksum.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-checksum.obj `if test -f 'checksum.c'; then $(CYGPATH_W) 'checksum.c'; else $(CYGPATH_W) '$(srcdir)/checksum.c'; fi`
rufus-dev.o: dev.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dev.o `test -f 'dev.c' || echo '$(srcdir)/'`dev.c
rufus-dev.obj: dev.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dev.obj `if test -f 'dev.c'; then $(CYGPATH_W) 'dev.c'; else $(CYGPATH_W) '$(srcdir)/dev.c'; fi`
rufus-dos.o: dos.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dos.o `test -f 'dos.c' || echo '$(srcdir)/'`dos.c
@ -440,12 +446,6 @@ rufus-syslinux.o: syslinux.c
rufus-syslinux.obj: syslinux.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-syslinux.obj `if test -f 'syslinux.c'; then $(CYGPATH_W) 'syslinux.c'; else $(CYGPATH_W) '$(srcdir)/syslinux.c'; fi`
rufus-usb.o: usb.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-usb.o `test -f 'usb.c' || echo '$(srcdir)/'`usb.c
rufus-usb.obj: usb.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-usb.obj `if test -f 'usb.c'; then $(CYGPATH_W) 'usb.c'; else $(CYGPATH_W) '$(srcdir)/usb.c'; fi`
rufus-vhd.o: vhd.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-vhd.o `test -f 'vhd.c' || echo '$(srcdir)/'`vhd.c

View file

@ -7,7 +7,7 @@
*
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o
* Copyright 1999 by David Beattie
* Copyright 2011-2015 by Pete Batard
* Copyright 2011-2016 by Pete Batard
*
* This file is based on the minix file system programs fsck and mkfs
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
@ -42,11 +42,12 @@
#include <stdint.h>
#include "rufus.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "badblocks.h"
#include "file.h"
#include "msapi_utf8.h"
#include "resource.h"
#include "localization.h"
FILE* log_fd = NULL;
static const char* abort_msg = "Too many bad blocks, aborting test\n";
@ -257,7 +258,7 @@ static bb_badblocks_iterate bb_iter = NULL;
static __inline void *allocate_buffer(size_t size) {
#ifdef __MINGW32__
return __mingw_aligned_malloc(size, BB_SYS_PAGE_SIZE);
#else
#else
return _aligned_malloc(size, BB_SYS_PAGE_SIZE);
#endif
}

View file

@ -1,10 +1,10 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Message-Digest algorithms (sha1sum, md5sum)
* Message-Digest algorithms (md5sum, sha1sum, sha256sum)
* Copyright © 1998-2001 Free Software Foundation, Inc.
* Copyright © 2004 g10 Code GmbH
* Copyright © 2006-2012 Brad Conte <brad@bradconte.com>
* Copyright © 2015 Pete Batard <pete@akeo.ie>
* Copyright © 2002-2015 Wei Dai & Igor Pavlov
* Copyright © 2015-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,8 +23,7 @@
/*
* SHA-1 code taken from GnuPG, as per copyrights above.
*
* SHA-256 code modified from crypto-algorithms by Brad Conte:
* https://github.com/B-Con/crypto-algorithms - Public Domain
* SHA-256 taken from 7-zip's Sha256.c, itself based on Crypto++ - Public Domain
*
* MD5 code from various public domain sources sharing the following
* copyright declaration:
@ -51,47 +50,35 @@
#include <inttypes.h>
#include <errno.h>
#include <windowsx.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#undef BIG_ENDIAN_HOST
#define BUFFER_SIZE (64*KB)
#define WAIT_TIME 5000
/* Globals */
char sha1str[41], sha256str[65], md5str[33];
char sum_str[NUM_CHECKSUMS][65];
uint32_t bufnum, sum_count[NUM_CHECKSUMS] = { 16, 20, 32 };
HANDLE data_ready[NUM_CHECKSUMS], thread_ready[NUM_CHECKSUMS];
DWORD read_size[2];
char ALIGNED(64) buffer[2][BUFFER_SIZE];
#if defined(__GNUC__)
#define ALIGNED(m) __attribute__ ((__aligned__(m)))
#elif defined(_MSC_VER)
#define ALIGNED(m) __declspec(align(m))
#endif
/*
* Rotate 32 bit integers by n bytes.
* Don't bother trying to hand-optimize those, as the
* compiler usually does a pretty good job at that.
*/
#define ROL(a,b) (((a) << (b)) | ((a) >> (32-(b))))
#define ROR(a,b) (((a) >> (b)) | ((a) << (32-(b))))
/* Rotate a 32 bit integer by n bytes */
#if defined(__GNUC__) && defined(__i386__)
static inline uint32_t rol(uint32_t x, int n)
{
__asm__("roll %%cl,%0"
:"=r" (x)
:"0" (x),"c" (n));
return x;
}
#elif defined(_MSC_VER) && (_M_IX86 >= 300)
static __inline uint32_t rol(uint32_t x, int n)
{
__asm {
mov eax, x
mov ecx, n
rol eax, cl
}
/* returns with result in EAX */
}
#else
#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif
// For SHA-256
static const uint32_t k[64] = {
/* SHA-256 constants */
static const uint32_t K[64] = {
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
@ -102,27 +89,26 @@ static const uint32_t k[64] = {
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
};
typedef struct ALIGNED(8) {
unsigned char buf[64];
uint32_t state[5];
uint32_t count;
uint64_t nblocks;
} SHA1_CONTEXT;
typedef struct ALIGNED(8) {
/*
* For convenience, we use a common context for all the checksums algorithms,
* which means some elements may be unused...
*/
typedef struct ALIGNED(64) {
unsigned char buf[64];
uint32_t state[8];
uint32_t datalen;
uint64_t bitlen;
} SHA256_CONTEXT;
uint64_t bytecount;
} SUM_CONTEXT;
typedef struct ALIGNED(8) {
unsigned char buf[64];
uint32_t state[4];
uint64_t bitcount;
} MD5_CONTEXT;
static void md5_init(SUM_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xefcdab89;
ctx->state[2] = 0x98badcfe;
ctx->state[3] = 0x10325476;
}
static void sha1_init(SHA1_CONTEXT *ctx)
static void sha1_init(SUM_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x67452301;
@ -132,7 +118,7 @@ static void sha1_init(SHA1_CONTEXT *ctx)
ctx->state[4] = 0xc3d2e1f0;
}
static void sha256_init(SHA256_CONTEXT *ctx)
static void sha256_init(SUM_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x6a09e667;
@ -145,20 +131,10 @@ static void sha256_init(SHA256_CONTEXT *ctx)
ctx->state[7] = 0x5be0cd19;
}
static void md5_init(MD5_CONTEXT *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xefcdab89;
ctx->state[2] = 0x98badcfe;
ctx->state[3] = 0x10325476;
}
/* Transform the message X which consists of 16 32-bit-words (SHA-1) */
static void sha1_transform(SHA1_CONTEXT *ctx, const unsigned char *data)
static void sha1_transform(SUM_CONTEXT *ctx, const unsigned char *data)
{
uint32_t a, b, c, d, e, tm;
uint32_t x[16];
uint32_t a, b, c, d, e, tm, x[16];
/* get values from the chaining vars */
a = ctx->state[0];
@ -171,13 +147,13 @@ static void sha1_transform(SHA1_CONTEXT *ctx, const unsigned char *data)
memcpy(x, data, sizeof(x));
#else
{
int i;
unsigned char *p2;
for (i = 0, p2 = (unsigned char*)x; i < 16; i++, p2 += 4) {
p2[3] = *data++;
p2[2] = *data++;
p2[1] = *data++;
p2[0] = *data++;
unsigned k;
for (k = 0; k < 16; k += 4) {
const unsigned char *p2 = data + k * 4;
x[k] = read_swap32(p2);
x[k + 1] = read_swap32(p2 + 4);
x[k + 2] = read_swap32(p2 + 8);
x[k + 3] = read_swap32(p2 + 12);
}
}
#endif
@ -191,10 +167,10 @@ static void sha1_transform(SHA1_CONTEXT *ctx, const unsigned char *data)
#define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) )
#define F4(x,y,z) ( x ^ y ^ z )
#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f], (x[i&0x0f] = rol(tm,1)) )
#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f], (x[i&0x0f] = ROL(tm,1)) )
#define SHA1STEP(a,b,c,d,e,f,k,m) do { e += rol(a, 5) + f(b, c, d) + k + m; \
b = rol(b, 30); } while(0)
#define SHA1STEP(a,b,c,d,e,f,k,m) do { e += ROL(a, 5) + f(b, c, d) + k + m; \
b = ROL(b, 30); } while(0)
SHA1STEP(a, b, c, d, e, F1, K1, x[0]);
SHA1STEP(e, a, b, c, d, F1, K1, x[1]);
SHA1STEP(d, e, a, b, c, F1, K1, x[2]);
@ -289,9 +265,10 @@ static void sha1_transform(SHA1_CONTEXT *ctx, const unsigned char *data)
ctx->state[4] += e;
}
static void sha256_transform(SHA256_CONTEXT *ctx, const unsigned char *data)
/* Transform the message X which consists of 16 32-bit-words (SHA-256) */
static __inline void sha256_transform(SUM_CONTEXT *ctx, const unsigned char *data)
{
uint32_t a, b, c, d, e, f, g, h, i, t1, t2, m[64];
uint32_t a, b, c, d, e, f, g, h, j, x[16];
a = ctx->state[0];
b = ctx->state[1];
@ -302,47 +279,54 @@ static void sha256_transform(SHA256_CONTEXT *ctx, const unsigned char *data)
g = ctx->state[6];
h = ctx->state[7];
#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
#define CH(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define MAJ(x,y,z) (((x) & (y)) | ((z) & ((x) | (y))))
// Nesting the ROR allows for single register compiler optimizations
#define S0(x) (ROR(ROR(ROR(x,9)^(x),11)^(x),2))
#define S1(x) (ROR(ROR(ROR(x,14)^(x),5)^(x),6))
#define s0(x) (ROR(ROR(x,11)^(x),7)^((x)>>3))
#define s1(x) (ROR(ROR(x,2)^(x),17)^((x)>>10))
#define BLK0(i) (x[i])
#define BLK2(i) (x[i] += s1(x[((i)-2)&15]) + x[((i)-7)&15] + s0(x[((i)-15)&15]))
#define R(a,b,c,d,e,f,g,h,i) \
h += S1(e) + CH(e,f,g) + K[(i)+(j)] + (j ? BLK2(i) : BLK0(i)); \
d += h; \
h += S0(a) + MAJ(a, b, c)
#define RX_8(i) \
R(a,b,c,d,e,f,g,h, i); \
R(h,a,b,c,d,e,f,g, i+1); \
R(g,h,a,b,c,d,e,f, i+2); \
R(f,g,h,a,b,c,d,e, i+3); \
R(e,f,g,h,a,b,c,d, i+4); \
R(d,e,f,g,h,a,b,c, i+5); \
R(c,d,e,f,g,h,a,b, i+6); \
R(b,c,d,e,f,g,h,a, i+7)
#ifdef BIG_ENDIAN_HOST
memcpy(m, data, sizeof(m));
memcpy(x, data, sizeof(x));
#else
{
unsigned char *p2;
for (i = 0, p2 = (unsigned char*)m; i < 16; i++, p2 += 4) {
p2[3] = *data++;
p2[2] = *data++;
p2[1] = *data++;
p2[0] = *data++;
unsigned k;
for (k = 0; k < 16; k += 4) {
const unsigned char *p2 = data + k * 4;
x[k] = read_swap32(p2);
x[k + 1] = read_swap32(p2 + 4);
x[k + 2] = read_swap32(p2 + 8);
x[k + 3] = read_swap32(p2 + 12);
}
}
#endif
for (i = 16; i < 64; ++i)
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
for (i = 0; i < 64; ++i) {
t1 = h + EP1(e) + CH(e, f, g) + k[i] + m[i];
t2 = EP0(a) + MAJ(a, b, c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
for (j = 0; j < 64; j += 16) {
RX_8(0);
RX_8(8);
}
#undef S0
#undef S1
#undef s0
#undef s1
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
@ -354,29 +338,28 @@ static void sha256_transform(SHA256_CONTEXT *ctx, const unsigned char *data)
}
/* Transform the message X which consists of 16 32-bit-words (MD5) */
static void md5_transform(MD5_CONTEXT *ctx, const unsigned char *data)
static void md5_transform(SUM_CONTEXT *ctx, const unsigned char *data)
{
uint32_t a, b, c, d;
uint32_t x[16];
uint32_t a, b, c, d, x[16];
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
#ifndef BIG_ENDIAN_HOST
memcpy(x, data, sizeof(x));
#else
#ifdef BIG_ENDIAN_HOST
{
int i;
unsigned char *p;
for (i = 0, p = (unsigned char*)x; i < 16; i++, p += 4) {
p[3] = *data++;
p[2] = *data++;
p[1] = *data++;
p[0] = *data++;
unsigned k;
for (k = 0; k < 16; k += 4) {
const unsigned char *p2 = data + k * 4;
x[k] = read_swap32(p2);
x[k + 1] = read_swap32(p2 + 4);
x[k + 2] = read_swap32(p2 + 8);
x[k + 3] = read_swap32(p2 + 12);
}
}
#else
memcpy(x, data, sizeof(x));
#endif
#define F1(x, y, z) (z ^ (x & (y ^ z)))
@ -468,58 +451,88 @@ static void md5_transform(MD5_CONTEXT *ctx, const unsigned char *data)
}
/* Update the message digest with the contents of the buffer (SHA-1) */
static void sha1_write(SHA1_CONTEXT *ctx, const unsigned char *buf, size_t len)
static void sha1_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
if (ctx->count == 64) { /* flush the buffer */
sha1_transform(ctx, ctx->buf);
ctx->count = 0;
ctx->nblocks++;
}
if (!buf)
return;
if (ctx->count) {
for (; len && ctx->count < 64; len--)
ctx->buf[ctx->count++] = *buf++;
sha1_write(ctx, NULL, 0);
if (!len)
size_t t;
/* Update bytecount */
ctx->bytecount += len;
t = ctx->bytecount & 0x3f;
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = ctx->buf + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
sha1_transform(ctx, ctx->buf);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
PREFETCH64(buf + 64);
sha1_transform(ctx, buf);
ctx->count = 0;
ctx->nblocks++;
len -= 64;
buf += 64;
len -= 64;
}
for (; len && ctx->count < 64; len--)
ctx->buf[ctx->count++] = *buf++;
/* Handle any remaining bytes of data. */
memcpy(ctx->buf, buf, len);
}
static void sha256_write(SHA256_CONTEXT *ctx, const unsigned char *buf, size_t len)
/* Update the message digest with the contents of the buffer (SHA-256) */
static void sha256_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
uint32_t i;
size_t t;
for (i = 0; i < len; ++i) {
ctx->buf[ctx->datalen] = buf[i];
ctx->datalen++;
if (ctx->datalen == 64) {
sha256_transform(ctx, ctx->buf);
ctx->bitlen += 512;
ctx->datalen = 0;
/* Update bytecount */
ctx->bytecount += len;
t = ctx->bytecount & 0x3f;
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = ctx->buf + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
sha256_transform(ctx, ctx->buf);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
PREFETCH64(buf + 64);
sha256_transform(ctx, buf);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->buf, buf, len);
}
/* Update the message digest with the contents of the buffer (MD5) */
static void md5_write(MD5_CONTEXT *ctx, const unsigned char *buf, size_t len)
static void md5_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
uint32_t t;
size_t t;
/* Update bitcount */
ctx->bitcount += (len << 3);
/* Update bytecount */
ctx->bytecount += len;
t = (ctx->bitcount >> 3) & 0x3f;
t = ctx->bytecount & 0x3f;
/* Handle any leading odd-sized chunks */
if (t) {
@ -538,8 +551,8 @@ static void md5_write(MD5_CONTEXT *ctx, const unsigned char *buf, size_t len)
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->buf, buf, 64);
md5_transform(ctx, ctx->buf);
PREFETCH64(buf + 64);
md5_transform(ctx, buf);
buf += 64;
len -= 64;
}
@ -548,46 +561,40 @@ static void md5_write(MD5_CONTEXT *ctx, const unsigned char *buf, size_t len)
memcpy(ctx->buf, buf, len);
}
/* The routine final terminates the computation and returns the digest (SHA-1) */
static void sha1_final(SHA1_CONTEXT *ctx)
/* Finalize the computation and write the digest in ctx->state[] (SHA-1) */
static void sha1_final(SUM_CONTEXT *ctx)
{
uint64_t bitcount;
uint64_t bitcount = ctx->bytecount << 3;
size_t pos = ((size_t)ctx->bytecount) & 0x3F;
unsigned char *p;
sha1_write(ctx, NULL, 0); /* flush */;
ctx->buf[pos++] = 0x80;
bitcount = ctx->nblocks * 64 * 8;
if (ctx->count < 56) { /* enough room */
ctx->buf[ctx->count++] = 0x80; /* pad */
while (ctx->count < 56)
ctx->buf[ctx->count++] = 0; /* pad */
} else { /* need one extra block */
ctx->buf[ctx->count++] = 0x80; /* pad character */
while (ctx->count < 64)
ctx->buf[ctx->count++] = 0;
sha1_write(ctx, NULL, 0); /* flush */;
memset(ctx->buf, 0, 56); /* fill next block with zeroes */
/* Pad whatever data is left in the buffer */
while (pos != (64 - 8)) {
pos &= 0x3F;
if (pos == 0)
sha1_transform(ctx, ctx->buf);
ctx->buf[pos++] = 0;
}
/* append the 64 bit count (big-endian) */
ctx->buf[56] = (unsigned char) (bitcount >> 56);
ctx->buf[57] = (unsigned char) (bitcount >> 48);
ctx->buf[58] = (unsigned char) (bitcount >> 40);
ctx->buf[59] = (unsigned char) (bitcount >> 32);
ctx->buf[60] = (unsigned char) (bitcount >> 24);
ctx->buf[61] = (unsigned char) (bitcount >> 16);
ctx->buf[62] = (unsigned char) (bitcount >> 8);
/* Append to the padding the total message's length in bits and transform */
ctx->buf[63] = (unsigned char) bitcount;
ctx->buf[62] = (unsigned char) (bitcount >> 8);
ctx->buf[61] = (unsigned char) (bitcount >> 16);
ctx->buf[60] = (unsigned char) (bitcount >> 24);
ctx->buf[59] = (unsigned char) (bitcount >> 32);
ctx->buf[58] = (unsigned char) (bitcount >> 40);
ctx->buf[57] = (unsigned char) (bitcount >> 48);
ctx->buf[56] = (unsigned char) (bitcount >> 56);
sha1_transform(ctx, ctx->buf);
p = ctx->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *(uint32_t*)p = ctx->state[a]; p += 4; } while(0)
#else /* little endian */
#define X(a) do { *p++ = (unsigned char) (ctx->state[a] >> 24); *p++ = (unsigned char) (ctx->state[a] >> 16); \
*p++ = (unsigned char) (ctx->state[a] >> 8); *p++ = (unsigned char) ctx->state[a]; } while(0)
#else
#define X(a) do { write_swap32(p, ctx->state[a]); p += 4; } while(0);
#endif
X(0);
X(1);
@ -597,46 +604,40 @@ static void sha1_final(SHA1_CONTEXT *ctx)
#undef X
}
static void sha256_final(SHA256_CONTEXT *ctx)
/* Finalize the computation and write the digest in ctx->state[] (SHA-256) */
static void sha256_final(SUM_CONTEXT *ctx)
{
uint32_t i;
uint64_t bitcount = ctx->bytecount << 3;
size_t pos = ((size_t)ctx->bytecount) & 0x3F;
unsigned char *p;
i = ctx->datalen;
ctx->buf[pos++] = 0x80;
// Pad whatever data is left in the buffer.
if (ctx->datalen < 56) {
ctx->buf[i++] = 0x80;
while (i < 56)
ctx->buf[i++] = 0x00;
}
else {
ctx->buf[i++] = 0x80;
while (i < 64)
ctx->buf[i++] = 0x00;
sha256_transform(ctx, ctx->buf);
memset(ctx->buf, 0, 56);
/* Pad whatever data is left in the buffer */
while (pos != (64 - 8)) {
pos &= 0x3F;
if (pos == 0)
sha256_transform(ctx, ctx->buf);
ctx->buf[pos++] = 0;
}
// Append to the padding the total message's length in bits and transform.
ctx->bitlen += ctx->datalen * 8;
ctx->buf[63] = (unsigned char) (ctx->bitlen);
ctx->buf[62] = (unsigned char) (ctx->bitlen >> 8);
ctx->buf[61] = (unsigned char) (ctx->bitlen >> 16);
ctx->buf[60] = (unsigned char) (ctx->bitlen >> 24);
ctx->buf[59] = (unsigned char) (ctx->bitlen >> 32);
ctx->buf[58] = (unsigned char) (ctx->bitlen >> 40);
ctx->buf[57] = (unsigned char) (ctx->bitlen >> 48);
ctx->buf[56] = (unsigned char) (ctx->bitlen >> 56);
/* Append to the padding the total message's length in bits and transform */
ctx->buf[63] = (unsigned char) bitcount;
ctx->buf[62] = (unsigned char) (bitcount >> 8);
ctx->buf[61] = (unsigned char) (bitcount >> 16);
ctx->buf[60] = (unsigned char) (bitcount >> 24);
ctx->buf[59] = (unsigned char) (bitcount >> 32);
ctx->buf[58] = (unsigned char) (bitcount >> 40);
ctx->buf[57] = (unsigned char) (bitcount >> 48);
ctx->buf[56] = (unsigned char) (bitcount >> 56);
sha256_transform(ctx, ctx->buf);
p = ctx->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *(uint32_t*)p = ctx->state[a]; p += 4; } while(0)
#else /* little endian */
#define X(a) do { *p++ = (unsigned char) (ctx->state[a] >> 24); *p++ = (unsigned char) (ctx->state[a] >> 16); \
*p++ = (unsigned char) (ctx->state[a] >> 8); *p++ = (unsigned char) ctx->state[a]; } while(0)
#else
#define X(a) do { write_swap32(p, ctx->state[a]); p += 4; } while(0);
#endif
X(0);
X(1);
@ -649,15 +650,13 @@ static void sha256_final(SHA256_CONTEXT *ctx)
#undef X
}
/* The routine final terminates the computation and returns the digest (MD5) */
static void md5_final(MD5_CONTEXT *ctx)
/* Finalize the computation and write the digest in ctx->state[] (MD5) */
static void md5_final(SUM_CONTEXT *ctx)
{
uint32_t count;
size_t count = ((size_t)ctx->bytecount) & 0x3F;
uint64_t bitcount = ctx->bytecount << 3;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bitcount >> 3) & 0x3F;
/* Set the first char of padding to 0x80.
* This is safe since there is always at least one byte free
*/
@ -681,22 +680,21 @@ static void md5_final(MD5_CONTEXT *ctx)
}
/* append the 64 bit count (little endian) */
ctx->buf[56] = (unsigned char) ctx->bitcount;
ctx->buf[57] = (unsigned char) (ctx->bitcount >> 8);
ctx->buf[58] = (unsigned char) (ctx->bitcount >> 16);
ctx->buf[59] = (unsigned char) (ctx->bitcount >> 24);
ctx->buf[60] = (unsigned char) (ctx->bitcount >> 32);
ctx->buf[61] = (unsigned char) (ctx->bitcount >> 40);
ctx->buf[62] = (unsigned char) (ctx->bitcount >> 48);
ctx->buf[63] = (unsigned char) (ctx->bitcount >> 56);
ctx->buf[56] = (unsigned char) bitcount;
ctx->buf[57] = (unsigned char) (bitcount >> 8);
ctx->buf[58] = (unsigned char) (bitcount >> 16);
ctx->buf[59] = (unsigned char) (bitcount >> 24);
ctx->buf[60] = (unsigned char) (bitcount >> 32);
ctx->buf[61] = (unsigned char) (bitcount >> 40);
ctx->buf[62] = (unsigned char) (bitcount >> 48);
ctx->buf[63] = (unsigned char) (bitcount >> 56);
md5_transform(ctx, ctx->buf);
p = ctx->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *p++ = (unsigned char) (ctx->state[a] >> 24); *p++ = (unsigned char) (ctx->state[a] >> 16); \
*p++ = (unsigned char) (ctx->state[a] >> 8); *p++ = (unsigned char) ctx->state[a]; } while(0)
#else /* little endian */
#define X(a) do { write_swap32(p, ctx->state[a]); p += 4; } while(0);
#else
#define X(a) do { *(uint32_t*)p = ctx->state[a]; p += 4; } while(0)
#endif
X(0);
@ -706,12 +704,27 @@ static void md5_final(MD5_CONTEXT *ctx)
#undef X
}
//#define NULL_TEST
#ifdef NULL_TEST
// These 'null' calls are useful for testing load balancing and individual algorithm speed
static void null_init(SUM_CONTEXT *ctx) { memset(ctx, 0, sizeof(*ctx)); }
static void null_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len) { }
static void null_final(SUM_CONTEXT *ctx) { }
#endif
typedef void sum_init_t(SUM_CONTEXT *ctx);
typedef void sum_write_t(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len);
typedef void sum_final_t(SUM_CONTEXT *ctx);
sum_init_t *sum_init[NUM_CHECKSUMS] = { md5_init, sha1_init , sha256_init };
sum_write_t *sum_write[NUM_CHECKSUMS] = { md5_write, sha1_write , sha256_write };
sum_final_t *sum_final[NUM_CHECKSUMS] = { md5_final, sha1_final , sha256_final };
/*
* Checksum dialog callback
*/
INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int i, dw;
int i, dw, dh;
RECT rect;
HFONT hFont;
HDC hDC;
@ -727,9 +740,9 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
SendDlgItemMessageA(hDlg, IDC_MD5, WM_SETFONT, (WPARAM)hFont, TRUE);
SendDlgItemMessageA(hDlg, IDC_SHA1, WM_SETFONT, (WPARAM)hFont, TRUE);
SendDlgItemMessageA(hDlg, IDC_SHA256, WM_SETFONT, (WPARAM)hFont, TRUE);
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), md5str);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), sha1str);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA256), sha256str);
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), sum_str[0]);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), sum_str[1]);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA256), sum_str[2]);
// Move/Resize the controls as needed to fit our text
hDC = GetDC(GetDlgItem(hDlg, IDC_MD5));
@ -737,13 +750,15 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
GetWindowRect(GetDlgItem(hDlg, IDC_MD5), &rect);
dw = rect.right - rect.left;
DrawTextU(hDC, md5str, -1, &rect, DT_CALCRECT);
dh = rect.bottom - rect.top;
DrawTextU(hDC, sum_str[0], -1, &rect, DT_CALCRECT);
dw = rect.right - rect.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA256), 0, 0, dw, 0, 1.0f);
dh = rect.bottom - rect.top - dh + 6;
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA256), 0, 0, dw, dh, 1.0f);
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rect);
dw = rect.right - rect.left;
DrawTextU(hDC, sha1str, -1, &rect, DT_CALCRECT);
DrawTextU(hDC, sum_str[1], -1, &rect, DT_CALCRECT);
dw = rect.right - rect.left - dw + 12;
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MD5), 0, 0, dw, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA1), 0, 0, dw, 0, 1.0f);
@ -771,23 +786,80 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
return (INT_PTR)FALSE;
}
// Individual thread that computes one of MD5, SHA1 or SHA256 in parallel
DWORD WINAPI IndividualSumThread(void* param)
{
SUM_CONTEXT sum_ctx = { 0 }; // There's a memset in sum_init, but static analyzers still bug us
uint32_t i = (uint32_t)(uintptr_t)param, j;
sum_init[i](&sum_ctx);
// Signal that we're ready to service requests
if (!SetEvent(thread_ready[i]))
goto error;
// Wait for requests
while (1) {
if (WaitForSingleObject(data_ready[i], WAIT_TIME) != WAIT_OBJECT_0) {
uprintf("Failed to wait for event for checksum thread #%d: %s", i, WindowsErrorString());
return 1;
}
if (read_size[bufnum] != 0) {
sum_write[i](&sum_ctx, buffer[bufnum], (size_t)read_size[bufnum]);
if (!SetEvent(thread_ready[i]))
goto error;
} else {
sum_final[i](&sum_ctx);
memset(&sum_str[i], 0, ARRAYSIZE(sum_str[i]));
for (j = 0; j < sum_count[i]; j++)
safe_sprintf(&sum_str[i][2 * j], ARRAYSIZE(sum_str[i]) - 2 * j, "%02x", sum_ctx.buf[j]);
return 0;
}
}
error:
uprintf("Failed to set event for checksum thread #%d: %s", i, WindowsErrorString());
return 1;
}
DWORD WINAPI SumThread(void* param)
{
DWORD_PTR* thread_affinity = (DWORD_PTR*)param;
HANDLE sum_thread[NUM_CHECKSUMS] = { NULL, NULL, NULL };
HANDLE h = INVALID_HANDLE_VALUE;
DWORD rSize = 0, LastRefresh = 0;
uint64_t rb;
char buffer[4096];
SHA1_CONTEXT sha1_ctx;
SHA256_CONTEXT sha256_ctx;
MD5_CONTEXT md5_ctx;
int i, r = -1;
uint64_t rb, LastRefresh = 0;
int i, _bufnum, r = -1;
float format_percent = 0.0f;
if (image_path == NULL)
if ((image_path == NULL) || (thread_affinity == NULL))
goto out;
uprintf("\r\nComputing checksum for '%s'...", image_path);
if (thread_affinity[0] != 0)
// Use the first affinity mask, as our read thread is the least
// CPU intensive (mostly waits on disk I/O or on the other threads)
// whereas the OS is likely to requisition the first Core, which
// is usually in this first mask, for other tasks.
SetThreadAffinityMask(GetCurrentThread(), thread_affinity[0]);
for (i = 0; i < NUM_CHECKSUMS; i++) {
// NB: Can't use a single manual-reset event for data_ready as we
// wouldn't be able to ensure the event is reset before the thread
// gets into its next wait loop
data_ready[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
thread_ready[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
if ((data_ready[i] == NULL) || (thread_ready[i] == NULL)) {
uprintf("Unable to create checksum thread event: %s", WindowsErrorString());
goto out;
}
sum_thread[i] = CreateThread(NULL, 0, IndividualSumThread, (LPVOID)(uintptr_t)i, 0, NULL);
if (sum_thread[i] == NULL) {
uprintf("Unable to start checksum thread #%d", i);
goto out;
}
if (thread_affinity[i+1] != 0)
SetThreadAffinityMask(sum_thread[i], thread_affinity[i+1]);
}
h = CreateFileU(image_path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (h == INVALID_HANDLE_VALUE) {
@ -796,47 +868,70 @@ DWORD WINAPI SumThread(void* param)
goto out;
}
sha1_init(&sha1_ctx);
sha256_init(&sha256_ctx);
md5_init(&md5_ctx);
for (rb = 0; ; rb += rSize) {
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
bufnum = 0;
_bufnum = 0;
read_size[0] = 1; // Don't trigger the first loop break
for (rb = 0; ;rb += read_size[_bufnum]) {
// Update the progress and check for cancel
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*rb) / (1.0f*img_report.projected_size);
PrintInfo(0, MSG_271, format_percent);
SendMessage(hProgress, PBM_SETPOS, (WPARAM)((format_percent/100.0f)*MAX_PROGRESS), 0);
SendMessage(hProgress, PBM_SETPOS, (WPARAM)((format_percent / 100.0f)*MAX_PROGRESS), 0);
SetTaskbarProgressValue(rb, img_report.projected_size);
}
CHECK_FOR_USER_CANCEL;
if (!ReadFile(h, buffer, sizeof(buffer), &rSize, NULL)) {
// Signal the threads that we have data to process
if (rb != 0) {
bufnum = _bufnum;
// Toggle the read buffer
_bufnum = (bufnum + 1) % 2;
// Signal the waiting threads
for (i = 0; i < NUM_CHECKSUMS; i++) {
if (!SetEvent(data_ready[i])) {
uprintf("Could not signal checksum thread %d: %s", i, WindowsErrorString());
goto out;
}
}
}
// Break the loop when data has been exhausted
if (read_size[bufnum] == 0)
break;
// Read data (double buffered)
if (!ReadFile(h, buffer[_bufnum], BUFFER_SIZE, &read_size[_bufnum], NULL)) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
uprintf(" Read error: %s", WindowsErrorString());
uprintf("Read error: %s", WindowsErrorString());
goto out;
}
// Wait for the thread to signal they are ready to process data
if (WaitForMultipleObjects(NUM_CHECKSUMS, thread_ready, TRUE, WAIT_TIME) != WAIT_OBJECT_0) {
uprintf("Checksum threads failed to signal: %s", WindowsErrorString());
goto out;
}
if (rSize == 0)
break;
sha1_write(&sha1_ctx, buffer, (size_t)rSize);
sha256_write(&sha256_ctx, buffer, (size_t)rSize);
md5_write(&md5_ctx, buffer, (size_t)rSize);
}
sha1_final(&sha1_ctx);
sha256_final(&sha256_ctx);
md5_final(&md5_ctx);
// Our last event with read_size=0 signaled the threads to exit - wait for that to happen
if (WaitForMultipleObjects(NUM_CHECKSUMS, sum_thread, TRUE, WAIT_TIME) != WAIT_OBJECT_0) {
uprintf("Checksum threads did not finalize: %s", WindowsErrorString());
goto out;
}
for (i = 0; i < 16; i++)
safe_sprintf(&md5str[2*i], sizeof(md5str) - 2*i, "%02x", md5_ctx.buf[i]);
uprintf(" MD5:\t %s", md5str);
for (i = 0; i < 20; i++)
safe_sprintf(&sha1str[2*i], sizeof(sha1str) - 2*i, "%02x", sha1_ctx.buf[i]);
uprintf(" SHA1:\t %s", sha1str);
for (i = 0; i < 32; i++)
safe_sprintf(&sha256str[2*i], sizeof(sha256str) - 2*i, "%02x", sha256_ctx.buf[i]);
uprintf(" SHA256: %s", sha256str);
uprintf(" MD5:\t %s", sum_str[0]);
uprintf(" SHA1:\t %s", sum_str[1]);
uprintf(" SHA256: %s", sum_str[2]);
r = 0;
out:
for (i = 0; i < NUM_CHECKSUMS; i++) {
if (sum_thread[i] != NULL)
TerminateThread(sum_thread[i], 1);
CloseHandle(data_ready[i]);
CloseHandle(thread_ready[i]);
}
safe_closehandle(h);
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
if (r == 0)

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* USB device listing
* Copyright © 2014 Pete Batard <pete@akeo.ie>
* Device detection and enumeration
* Copyright © 2014-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,15 +33,17 @@
#include <commctrl.h>
#include <setupapi.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "drive.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "usb.h"
#include "drive.h"
#include "dev.h"
extern StrArray DriveID, DriveLabel;
extern BOOL enable_HDDs, use_fake_units, enable_vmdk, usb_debug;
extern BOOL enable_HDDs, use_fake_units, enable_vmdk, usb_debug, list_non_usb_removable_drives;
/*
* Get the VID, PID and current device speed
@ -133,6 +135,17 @@ static __inline BOOL IsVHD(const char* buffer)
return FALSE;
}
static __inline BOOL IsRemovable(const char* buffer)
{
switch (*((DWORD*)buffer)) {
case CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL:
case CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL:
return TRUE;
default:
return FALSE;
}
}
/* For debugging user reports of HDDs vs UFDs */
//#define FORCED_DEVICE
#ifdef FORCED_DEVICE
@ -144,31 +157,52 @@ static __inline BOOL IsVHD(const char* buffer)
/*
* Refresh the list of USB devices
*/
BOOL GetUSBDevices(DWORD devnum)
BOOL GetDevices(DWORD devnum)
{
// The first two are standard Microsoft drivers (including the Windows 8 UASP one).
// The rest are the vendor UASP drivers I know of so far - list may be incomplete!
const char* storage_name[] = { "USBSTOR", "UASPSTOR", "VUSBSTOR", "ETRONSTOR", "ASUSSTPT" };
const char* scsi_name = "SCSI";
// List of USB storage drivers we know - list may be incomplete!
const char* usbstor_name[] = {
// Standard MS USB storage driver
"USBSTOR",
// USB card readers, with proprietary drivers (Realtek,etc...)
// Mostly "guessed" from http://www.carrona.org/dvrref.php
"RTSUER", "CMIUCR", "EUCR",
// UASP Drivers *MUST* be listed after this, starting with "UASPSTOR"
// (which is Microsoft's native UASP driver for Windows 8 and later)
// as we use "UASPSTOR" as a delimiter
"UASPSTOR", "VUSBSTOR", "ETRONSTOR", "ASUSSTPT"
};
// These are the generic (non USB) storage enumerators we also test
const char* genstor_name[] = {
// Generic storage drivers (Careful now!)
"SCSI", // "STORAGE", // "STORAGE" is used by 'Storage Spaces" and stuff => DANGEROUS!
// Non-USB card reader drivers - *MUST* start with "SD" (delimiter)
// See http://itdoc.hitachi.co.jp/manuals/3021/30213B5200e/DMDS0094.HTM
// Also http://www.carrona.org/dvrref.php. NB: These should be reported
// as enumerators by Rufus when Enum Debug is enabled
"SD", "PCISTOR", "RTSOR", "JMCR", "JMCF", "RIMMPTSK", "RIMSPTSK", "RIXDPTSK",
"TI21SONY", "ESD7SK", "ESM7SK", "O2MD", "O2SD", "VIACR"
};
const char* usb_speed_name[USB_SPEED_MAX] = { "USB", "USB 1.0", "USB 1.1", "USB 2.0", "USB 3.0" };
// Hash table and String Array used to match a Device ID with the parent hub's Device Interface Path
htab_table htab_devid = HTAB_EMPTY;
StrArray dev_if_path;
char letter_name[] = " (?:)";
char drive_name[] = "?:\\";
char uefi_togo_check[] = "?:\\EFI\\Rufus\\ntfs_x64.efi";
BOOL r = FALSE, found = FALSE, is_SCSI, post_backslash;
BOOL r = FALSE, found = FALSE, post_backslash;
HDEVINFO dev_info = NULL;
SP_DEVINFO_DATA dev_info_data;
SP_DEVICE_INTERFACE_DATA devint_data;
PSP_DEVICE_INTERFACE_DETAIL_DATA_A devint_detail_data;
DEVINST parent_inst, grandparent_inst, device_inst;
DWORD size, i, j, k, l, datatype, drive_index;
ULONG list_size[ARRAYSIZE(storage_name)] = { 0 }, list_start[ARRAYSIZE(storage_name)] = { 0 }, full_list_size, ulFlags;
DWORD uasp_start = ARRAYSIZE(usbstor_name), card_start = ARRAYSIZE(genstor_name);
ULONG list_size[ARRAYSIZE(usbstor_name)] = { 0 }, list_start[ARRAYSIZE(usbstor_name)] = { 0 }, full_list_size, ulFlags;
HANDLE hDrive;
LONG maxwidth = 0;
int s, score, drive_number, remove_drive;
char drive_letters[27], *device_id, *devid_list = NULL, entry_msg[128];
char *label, *entry, buffer[MAX_PATH], str[MAX_PATH], *method_str;
char *p, *label, *entry, buffer[MAX_PATH], str[MAX_PATH], *method_str;
usb_device_props props;
IGNORE_RETVAL(ComboBox_ResetContent(hDeviceList));
@ -235,29 +269,47 @@ BOOL GetUSBDevices(DWORD devnum)
ulFlags = CM_GETIDLIST_FILTER_SERVICE;
if (nWindowsVersion >= WINDOWS_7)
ulFlags |= CM_GETIDLIST_FILTER_PRESENT;
for (s=0; s<ARRAYSIZE(storage_name); s++) {
for (s=0; s<ARRAYSIZE(usbstor_name); s++) {
// Get a list of device IDs for all USB storage devices
// This will be used to find if a device is UASP
if (CM_Get_Device_ID_List_SizeA(&list_size[s], storage_name[s], ulFlags) != CR_SUCCESS)
// Also compute the uasp_start index
if (strcmp(usbstor_name[s], "UASPSTOR") == 0)
uasp_start = s;
if (CM_Get_Device_ID_List_SizeA(&list_size[s], usbstor_name[s], ulFlags) != CR_SUCCESS)
list_size[s] = 0;
if (list_size[s] != 0)
full_list_size += list_size[s]-1; // remove extra NUL terminator
}
// Compute the card_start index
for (s=0; s<ARRAYSIZE(genstor_name); s++) {
if (strcmp(genstor_name[s], "SD") == 0)
card_start = s;
}
// Overkill, but better safe than sorry. And yeah, we could have used
// arrays of arrays to avoid this, but it's more readable this way.
if ((uasp_start <= 0) || (uasp_start >= ARRAYSIZE(usbstor_name))) {
uprintf("Spock gone crazy error in %s:%d", __FILE__, __LINE__);
goto out;
}
if ((card_start <= 0) || (card_start >= ARRAYSIZE(genstor_name))) {
uprintf("Spock gone crazy error in %s:%d", __FILE__, __LINE__);
goto out;
}
devid_list = NULL;
if (full_list_size != 0) {
full_list_size += 1; // add extra NUL terminator
devid_list = (char*)malloc(full_list_size);
if (devid_list == NULL) {
uprintf("Could not allocate Device ID list\n");
return FALSE;
goto out;
}
for (s=0, i=0; s<ARRAYSIZE(storage_name); s++) {
for (s=0, i=0; s<ARRAYSIZE(usbstor_name); s++) {
list_start[s] = i;
if (list_size[s] > 1) {
if (CM_Get_Device_ID_ListA(storage_name[s], &devid_list[i], list_size[s], ulFlags) != CR_SUCCESS)
if (CM_Get_Device_ID_ListA(usbstor_name[s], &devid_list[i], list_size[s], ulFlags) != CR_SUCCESS)
continue;
if (usb_debug) {
uprintf("Processing IDs belonging to %s:", storage_name[s]);
uprintf("Processing IDs belonging to '%s':", usbstor_name[s]);
for (device_id = &devid_list[i]; *device_id != 0; device_id += strlen(device_id) + 1)
uprintf(" %s", device_id);
}
@ -270,7 +322,7 @@ BOOL GetUSBDevices(DWORD devnum)
}
}
// Now use SetupDi to enumerate all our storage devices
// Now use SetupDi to enumerate all our disk storage devices
dev_info = SetupDiGetClassDevsA(&_GUID_DEVINTERFACE_DISK, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE);
if (dev_info == INVALID_HANDLE_VALUE) {
uprintf("SetupDiGetClassDevs (Interface) failed: %s\n", WindowsErrorString());
@ -279,24 +331,49 @@ BOOL GetUSBDevices(DWORD devnum)
dev_info_data.cbSize = sizeof(dev_info_data);
for (i=0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
memset(buffer, 0, sizeof(buffer));
memset(&props, 0, sizeof(props));
method_str = "";
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_ENUMERATOR_NAME,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
uprintf("SetupDiGetDeviceRegistryProperty (Enumerator Name) failed: %s\n", WindowsErrorString());
continue;
}
// UASP drives are listed under SCSI (along with regular SYSTEM drives => "DANGER, WILL ROBINSON!!!")
is_SCSI = (safe_stricmp(buffer, scsi_name) == 0);
if ((safe_stricmp(buffer, storage_name[0]) != 0) && (!is_SCSI))
for (j = 0; j < ARRAYSIZE(usbstor_name); j++) {
if (safe_stricmp(buffer, usbstor_name[0]) == 0) {
props.is_USB = TRUE;
if ((j != 0) && (j < uasp_start))
props.is_CARD = TRUE;
break;
}
}
// UASP drives are listed under SCSI, and we also have non USB card readers to populate
for (j = 0; j < ARRAYSIZE(genstor_name); j++) {
if (safe_stricmp(buffer, genstor_name[j]) == 0) {
props.is_SCSI = TRUE;
if (j >= card_start)
props.is_CARD = TRUE;
break;
}
}
uuprintf("Processing '%s' device:", buffer);
if ((!props.is_USB) && (!props.is_SCSI)) {
uuprintf(" Disabled by policy");
continue;
}
// We can't use the friendly name to find if a drive is a VHD, as friendly name string gets translated
// according to your locale, so we poke the Hardware ID
memset(&props, 0, sizeof(props));
memset(buffer, 0, sizeof(buffer));
props.is_VHD = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_HARDWAREID,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size) && IsVHD(buffer);
uuprintf("Processing Device: '%s'", buffer);
uuprintf(" Hardware ID: '%s'", buffer);
memset(buffer, 0, sizeof(buffer));
props.is_Removable = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_REMOVAL_POLICY,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size) && IsRemovable(buffer);
memset(buffer, 0, sizeof(buffer));
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
@ -307,72 +384,95 @@ BOOL GetUSBDevices(DWORD devnum)
} else if ((!props.is_VHD) && (devid_list != NULL)) {
// Get the properties of the device. We could avoid doing this lookup every time by keeping
// a lookup table, but there shouldn't be that many USB storage devices connected...
// NB: Each of these Device IDs have an _only_ child, from which we get the Device Instance match.
// NB: Each of these Device IDs should have a child, from which we get the Device Instance match.
for (device_id = devid_list; *device_id != 0; device_id += strlen(device_id) + 1) {
if ( (CM_Locate_DevNodeA(&parent_inst, device_id, 0) == CR_SUCCESS)
&& (CM_Get_Child(&device_inst, parent_inst, 0) == CR_SUCCESS)
&& (device_inst == dev_info_data.DevInst) ) {
post_backslash = FALSE;
method_str = "";
// If we're not dealing with the USBSTOR part of our list, then this is an UASP device
props.is_UASP = ((((uintptr_t)device_id)+2) >= ((uintptr_t)devid_list)+list_start[1]);
// Now get the properties of the device, and its Device ID, which we need to populate the properties
j = htab_hash(device_id, &htab_devid);
uuprintf(" Matched with ID[%03d]: %s", j, device_id);
// Try to parse the current device_id string for VID:PID
// We'll use that if we can't get anything better
for (k = 0, l = 0; (k<strlen(device_id)) && (l<2); k++) {
// The ID is in the form USB_VENDOR_BUSID\VID_xxxx&PID_xxxx\...
if (device_id[k] == '\\')
post_backslash = TRUE;
if (!post_backslash)
continue;
if (device_id[k] == '_') {
props.pid = (uint16_t)strtoul(&device_id[k + 1], NULL, 16);
if (l++ == 0)
props.vid = props.pid;
if (CM_Locate_DevNodeA(&parent_inst, device_id, 0) != CR_SUCCESS) {
uuprintf("Could not locate device node for '%s'", device_id);
continue;
}
if (CM_Get_Child(&device_inst, parent_inst, 0) != CR_SUCCESS) {
uuprintf("Could not get children of '%s'", device_id);
continue;
}
if (device_inst != dev_info_data.DevInst) {
// Try the siblings
while (CM_Get_Sibling(&device_inst, device_inst, 0) == CR_SUCCESS) {
if (device_inst == dev_info_data.DevInst) {
uuprintf("NOTE: Matched instance from sibling for '%s'", device_id);
break;
}
}
if (props.vid != 0)
method_str = "[ID]";
// If the hash didn't match a populated string in dev_if_path[] (htab_devid.table[j].data > 0),
// we might have an extra vendor driver in between (e.g. "ASUS USB 3.0 Boost Storage Driver"
// for UASP devices in ASUS "Turbo Mode" or "Apple Mobile Device USB Driver" for iPods)
// so try to see if we can match the grandparent.
if ( ((uintptr_t)htab_devid.table[j].data == 0)
&& (CM_Get_Parent(&grandparent_inst, parent_inst, 0) == CR_SUCCESS)
&& (CM_Get_Device_IDA(grandparent_inst, str, MAX_PATH, 0) == CR_SUCCESS) ) {
device_id = str;
method_str = "[GP]";
j = htab_hash(device_id, &htab_devid);
uuprintf(" Matched with (GP) ID[%03d]: %s", j, device_id);
}
if ((uintptr_t)htab_devid.table[j].data > 0) {
uuprintf(" Matched with Hub[%d]: '%s'", (uintptr_t)htab_devid.table[j].data,
dev_if_path.String[(uintptr_t)htab_devid.table[j].data]);
if (GetUSBProperties(dev_if_path.String[(uintptr_t)htab_devid.table[j].data], device_id, &props))
method_str = "";
#ifdef FORCED_DEVICE
props.vid = FORCED_VID;
props.pid = FORCED_PID;
safe_strcpy(buffer, sizeof(buffer), FORCED_NAME);
#endif
}
break;
if (device_inst != dev_info_data.DevInst)
continue;
}
post_backslash = FALSE;
method_str = "";
// If we're not dealing with the USBSTOR part of our list, then this is an UASP device
props.is_UASP = ((((uintptr_t)device_id)+2) >= ((uintptr_t)devid_list)+list_start[uasp_start]);
// Now get the properties of the device, and its Device ID, which we need to populate the properties
j = htab_hash(device_id, &htab_devid);
uuprintf(" Matched with ID[%03d]: %s", j, device_id);
// Try to parse the current device_id string for VID:PID
// We'll use that if we can't get anything better
for (k = 0, l = 0; (k<strlen(device_id)) && (l<2); k++) {
// The ID is in the form USB_VENDOR_BUSID\VID_xxxx&PID_xxxx\...
if (device_id[k] == '\\')
post_backslash = TRUE;
if (!post_backslash)
continue;
if (device_id[k] == '_') {
props.pid = (uint16_t)strtoul(&device_id[k + 1], NULL, 16);
if (l++ == 0)
props.vid = props.pid;
}
}
if (props.vid != 0)
method_str = "[ID]";
// If the hash didn't match a populated string in dev_if_path[] (htab_devid.table[j].data > 0),
// we might have an extra vendor driver in between (e.g. "ASUS USB 3.0 Boost Storage Driver"
// for UASP devices in ASUS "Turbo Mode" or "Apple Mobile Device USB Driver" for iPods)
// so try to see if we can match the grandparent.
if ( ((uintptr_t)htab_devid.table[j].data == 0)
&& (CM_Get_Parent(&grandparent_inst, parent_inst, 0) == CR_SUCCESS)
&& (CM_Get_Device_IDA(grandparent_inst, str, MAX_PATH, 0) == CR_SUCCESS) ) {
device_id = str;
method_str = "[GP]";
j = htab_hash(device_id, &htab_devid);
uuprintf(" Matched with (GP) ID[%03d]: %s", j, device_id);
}
if ((uintptr_t)htab_devid.table[j].data > 0) {
uuprintf(" Matched with Hub[%d]: '%s'", (uintptr_t)htab_devid.table[j].data,
dev_if_path.String[(uintptr_t)htab_devid.table[j].data]);
if (GetUSBProperties(dev_if_path.String[(uintptr_t)htab_devid.table[j].data], device_id, &props))
method_str = "";
#ifdef FORCED_DEVICE
props.vid = FORCED_VID;
props.pid = FORCED_PID;
safe_strcpy(buffer, sizeof(buffer), FORCED_NAME);
#endif
}
break;
}
}
if (props.is_VHD) {
uprintf("Found VHD device '%s'", buffer);
} else if ((props.is_CARD) && ((!props.is_USB) || ((props.vid == 0) && (props.pid == 0)))) {
uprintf("Found card reader device '%s'", buffer);
} else if ((!props.is_USB) && (!props.is_UASP) && (props.is_Removable)) {
uprintf("Found non-USB removable device '%s' => Eliminated", buffer);
if (!list_non_usb_removable_drives) {
uuprintf("If you *REALLY* need, you can enable listing of this device with <Ctrl><Alt><F>");
continue;
}
} else {
if ((props.vid == 0) && (props.pid == 0)) {
if (is_SCSI) {
// If we have an SCSI drive and couldn't get a VID:PID, we are most likely
// dealing with a system drive => eliminate it!
uuprintf(" Non USB => Eliminated");
if (!props.is_USB) {
// If we have a non removable SCSI drive and couldn't get a VID:PID,
// we are most likely dealing with a system drive => eliminate it!
uuprintf("Found non-USB non-removable device '%s' => Eliminated", buffer);
continue;
}
safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID
@ -442,13 +542,44 @@ BOOL GetUSBDevices(DWORD devnum)
safe_free(devint_detail_data);
break;
}
if (GetDriveSize(drive_index) < (MIN_DRIVE_SIZE*MB)) {
uprintf("Device eliminated because it is smaller than %d MB\n", MIN_DRIVE_SIZE);
safe_closehandle(hDrive);
safe_free(devint_detail_data);
break;
}
if (GetDriveLabel(drive_index, drive_letters, &label)) {
if ((!enable_HDDs) && (!props.is_VHD) &&
if ((props.is_SCSI) && (!props.is_UASP) && (!props.is_VHD)) {
if (!props.is_Removable) {
// Non removables should have been eliminated above, but since we
// are potentially dealing with system drives, better safe than sorry
safe_closehandle(hDrive);
safe_free(devint_detail_data);
break;
}
if (!list_non_usb_removable_drives) {
// Go over the mounted partitions and find if GetDriveType() says they are
// removable. If they are not removable, don't allow the drive to be listed
for (p = drive_letters; *p; p++) {
drive_name[0] = *p;
if (GetDriveTypeA(drive_name) != DRIVE_REMOVABLE)
break;
}
if (*p) {
uprintf("Device eliminated because it contains a mounted partition that is set as non-removable");
safe_closehandle(hDrive);
safe_free(devint_detail_data);
break;
}
}
}
if ((!enable_HDDs) && (!props.is_VHD) && (!props.is_CARD) &&
((score = IsHDD(drive_index, (uint16_t)props.vid, (uint16_t)props.pid, buffer)) > 0)) {
uprintf("Device eliminated because it was detected as an USB Hard Drive (score %d > 0)\n", score);
uprintf("If this device is not an USB Hard Drive, please e-mail the author of this application\n");
uprintf("NOTE: You can enable the listing of USB Hard Drives in 'Advanced Options' (after clicking the white triangle)");
uprintf("Device eliminated because it was detected as a Hard Drive (score %d > 0)", score);
if (!list_non_usb_removable_drives)
uprintf("If this device is not a Hard Drive, please e-mail the author of this application");
uprintf("NOTE: You can enable the listing of Hard Drives in 'Advanced Options' (after clicking the white triangle)");
safe_closehandle(hDrive);
safe_free(devint_detail_data);
break;

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* USB device listing
* Copyright © 2014 Pete Batard <pete@akeo.ie>
* Device listing
* Copyright © 2014-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,8 +32,12 @@ typedef struct usb_device_props {
uint32_t pid;
uint32_t speed;
uint32_t port;
BOOLEAN is_USB;
BOOLEAN is_SCSI;
BOOLEAN is_CARD;
BOOLEAN is_UASP;
BOOLEAN is_VHD;
BOOLEAN is_Removable;
BOOLEAN is_LowerSpeed;
} usb_device_props;
@ -46,12 +50,15 @@ typedef DWORD RETURN_TYPE;
typedef RETURN_TYPE CONFIGRET;
typedef CHAR *DEVINSTID_A;
#define CR_SUCCESS 0x00000000
#define CR_NO_SUCH_DEVNODE 0x0000000D
#define CM_GETIDLIST_FILTER_SERVICE 0x00000002
#define CR_SUCCESS 0x00000000
#define CR_NO_SUCH_DEVNODE 0x0000000D
#define CM_GETIDLIST_FILTER_SERVICE 0x00000002
#define CM_REMOVAL_POLICY_EXPECT_NO_REMOVAL 0x00000001
#define CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL 0x00000002
#define CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL 0x00000003
// /!\ The following flag is only available on Windows 7 or later!
#define CM_GETIDLIST_FILTER_PRESENT 0x00000100
#define CM_DRP_ADDRESS 0x0000001D
#define CM_GETIDLIST_FILTER_PRESENT 0x00000100
#define CM_DRP_ADDRESS 0x0000001D
#ifndef METHOD_BUFFERED
#define METHOD_BUFFERED 0

View file

@ -2,8 +2,8 @@
* Rufus: The Reliable USB Formatting Utility
* DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll
* (MS WinME DOS) or from the embedded FreeDOS resource files
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
*
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -31,9 +31,11 @@
#include <string.h>
#include "rufus.h"
#include "dos.h"
#include "missing.h"
#include "resource.h"
#include "dos.h"
static BYTE* DiskImage = NULL;
static DWORD DiskImageSize;
@ -257,8 +259,8 @@ static BOOL ExtractFAT(int entry, const char* path)
return FALSE;
}
if ((!WriteFile(hFile, &DiskImage[filestart], (DWORD)filesize, &Size, 0)) || (filesize != Size)) {
uprintf("Couldn't write file '%s': %s.\n", filename, WindowsErrorString());
if (!WriteFileWithRetry(hFile, &DiskImage[filestart], (DWORD)filesize, &Size, WRITE_RETRIES)) {
uprintf("Could not write file '%s': %s.\n", filename, WindowsErrorString());
safe_closehandle(hFile);
return FALSE;
}
@ -324,7 +326,7 @@ static BOOL ExtractMSDOS(const char* path)
goto out;
// Sanity check
if (DiskImageSize < 700*1024) {
if (DiskImageSize < 700*KB) {
uprintf("MS-DOS disk image is too small (%d bytes)\n", dllname, DiskImageSize);
goto out;
}
@ -394,8 +396,8 @@ BOOL ExtractFreeDOS(const char* path)
return FALSE;
}
if ((!WriteFile(hFile, res_data, res_size, &Size, 0)) || (res_size != Size)) {
uprintf("Couldn't write file '%s': %s.\n", filename, WindowsErrorString());
if (!WriteFileWithRetry(hFile, res_data, res_size, &Size, WRITE_RETRIES)) {
uprintf("Could not write file '%s': %s.\n", filename, WindowsErrorString());
safe_closehandle(hFile);
return FALSE;
}

View file

@ -26,17 +26,19 @@
#include <string.h>
#include <ctype.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "file.h"
#include "drive.h"
#include "resource.h"
#include "sys_types.h"
#include "br.h"
#include "fat16.h"
#include "fat32.h"
#include "ntfs.h"
#include "localization.h"
#if !defined(PARTITION_BASIC_DATA_GUID)
const GUID PARTITION_BASIC_DATA_GUID =
@ -55,7 +57,6 @@ const GUID PARTITION_SYSTEM_GUID =
* Globals
*/
RUFUS_DRIVE_INFO SelectedDrive;
size_t uefi_ntfs_size = 0;
/*
* The following methods get or set the AutoMount setting (which is different from AutoRun)
@ -395,10 +396,10 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
continue;
}
/* IOCTL_STORAGE_GET_DEVICE_NUMBER's STORAGE_DEVICE_NUMBER.DeviceNumber is
not unique! An HDD, a DVD and probably other drives can have the same
value there => Use GetDriveType() to filter out unwanted devices.
See https://github.com/pbatard/rufus/issues/32 for details. */
// IOCTL_STORAGE_GET_DEVICE_NUMBER's STORAGE_DEVICE_NUMBER.DeviceNumber is
// not unique! An HDD, a DVD and probably other drives can have the same
// value there => Use GetDriveType() to filter out unwanted devices.
// See https://github.com/pbatard/rufus/issues/32#issuecomment-3785956
_drive_type = GetDriveTypeA(drive);
if ((_drive_type != DRIVE_REMOVABLE) && (_drive_type != DRIVE_FIXED))
@ -682,9 +683,6 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
if (hPhysical == INVALID_HANDLE_VALUE)
return 0;
if (uefi_ntfs_size == 0)
uefi_ntfs_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_NTFS), _RT_RCDATA, "uefi-ntfs.img");
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL);
if (!r || size <= 0) {
@ -732,7 +730,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType;
isUefiNtfs = (i == 1) && (part_type == 0xef) &&
(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart == uefi_ntfs_size);
(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart <= 1*MB);
suprintf("Partition %d%s:\n", i+1, isUefiNtfs?" (UEFI:NTFS)":"");
for (j=0; j<ARRAYSIZE(mbr_mountable); j++) {
if (part_type == mbr_mountable[j]) {
@ -1027,6 +1025,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
{
const char* PartitionTypeName[2] = { "MBR", "GPT" };
unsigned char* buffer;
size_t uefi_ntfs_size = 0;
CREATE_DISK CreateDisk = {PARTITION_STYLE_RAW, {{0}}};
DRIVE_LAYOUT_INFORMATION_EX4 DriveLayoutEx = {0};
BOOL r;
@ -1036,7 +1035,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
PrintInfoDebug(0, MSG_238, PartitionTypeName[partition_style]);
if ((extra_partitions & XP_UEFI_NTFS) && (uefi_ntfs_size == 0)) {
if (extra_partitions & XP_UEFI_NTFS) {
uefi_ntfs_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_NTFS), _RT_RCDATA, "uefi-ntfs.img");
if (uefi_ntfs_size == 0)
return FALSE;
@ -1045,7 +1044,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// Compute the start offset of our first partition
if ((partition_style == PARTITION_STYLE_GPT) || (!IsChecked(IDC_EXTRA_PARTITION))) {
// Go with the MS 1 MB wastage at the beginning...
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = 1024*1024;
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = MB;
} else {
// Align on Cylinder
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = bytes_per_track;
@ -1054,7 +1053,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// If required, set the MSR partition (GPT only - must be created before the data part)
if ((partition_style == PARTITION_STYLE_GPT) && (extra_partitions & XP_MSR)) {
uprintf("Adding MSR partition");
DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*1024*1024;
DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*MB;
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MSFT_RESERVED_GUID;
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId));
// coverity[strcpy_overrun]
@ -1065,7 +1064,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
bufsize = 65536; // 64K should be enough for everyone
buffer = calloc(bufsize, 1);
if (buffer != NULL) {
if ((!WriteFile(hDrive, buffer, bufsize, &size, NULL)) || (size != bufsize))
if (!WriteFileWithRetry(hDrive, buffer, bufsize, &size, WRITE_RETRIES))
uprintf(" Could not zero MSR: %s", WindowsErrorString());
free(buffer);
}
@ -1090,11 +1089,11 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// The size of the EFI partition depends on the minimum size we're able to format in FAT32,
// which in turn depends on the cluster size used, which in turn depends on the disk sector size.
if (SelectedDrive.Geometry.BytesPerSector <= 1024)
ms_efi_size = 100*1024*1024;
ms_efi_size = 100*MB;
else if (SelectedDrive.Geometry.BytesPerSector <= 4096)
ms_efi_size = 300*1024*1024;
ms_efi_size = 300*MB;
else
ms_efi_size = 1200*1024*1024; // That'll teach you to have a nonstandard disk!
ms_efi_size = 1200*MB; // That'll teach you to have a nonstandard disk!
extra_part_size_in_tracks = (ms_efi_size + bytes_per_track - 1) / bytes_per_track;
} else if (extra_partitions & XP_UEFI_NTFS)
extra_part_size_in_tracks = (MIN_EXTRA_PART_SIZE + bytes_per_track - 1) / bytes_per_track;
@ -1165,12 +1164,8 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
uprintf("Could not access uefi-ntfs.img");
return FALSE;
}
r = WriteFile(hDrive, buffer, bufsize, &size, NULL);
if ((!r) || (size != bufsize)) {
if (!r)
uprintf("Write error: %s", WindowsErrorString());
else
uprintf("Write error: Wrote %d bytes, expected %d bytes\n", size, bufsize);
if(!WriteFileWithRetry(hDrive, buffer, bufsize, &size, WRITE_RETRIES)) {
uprintf("Write error: %s", WindowsErrorString());
return FALSE;
}
}
@ -1191,7 +1186,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// This helps us reselect the partition scheme option that was used when creating the
// drive in Rufus. As far as I can tell, Windows doesn't care much if this signature
// isn't unique for USB drives.
CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:GetTickCount();
CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:(DWORD)_GetTickCount64();
DriveLayoutEx.PartitionStyle = PARTITION_STYLE_MBR;
DriveLayoutEx.PartitionCount = 4; // Must be multiple of 4 for MBR

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Drive access function calls
* Copyright © 2011-2014 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@
#include <windows.h>
#include <stdint.h>
#include <winioctl.h> // for DISK_GEOMETRY
#pragma once
@ -26,7 +27,7 @@
#define MOUNTMGRCONTROLTYPE ((ULONG)'m')
#define MOUNTMGR_DOS_DEVICE_NAME "\\\\.\\MountPointManager"
#define IOCTL_MOUNTMGR_QUERY_AUTO_MOUNT \
CTL_CODE(MOUNTMGRCONTROLTYPE, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
CTL_CODE(MOUNTMGRCONTROLTYPE, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_MOUNTMGR_SET_AUTO_MOUNT \
CTL_CODE(MOUNTMGRCONTROLTYPE, 16, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
@ -48,6 +49,31 @@ typedef struct {
DISK_EXTENT Extents[8];
} VOLUME_DISK_EXTENTS_REDEF;
static __inline BOOL UnlockDrive(HANDLE hDrive) {
DWORD size;
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
}
#define safe_unlockclose(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
/* Current drive info */
typedef struct {
DWORD DeviceNumber;
LONGLONG DiskSize;
DISK_GEOMETRY Geometry;
DWORD FirstSector;
char proposed_label[16];
int PartitionType;
int nPartitions; // number of partitions we actually care about
int FSType;
BOOL has_protective_mbr;
BOOL has_mbr_uefi_marker;
struct {
ULONG Allowed;
ULONG Default;
} ClusterSize[FS_MAX];
} RUFUS_DRIVE_INFO;
extern RUFUS_DRIVE_INFO SelectedDrive;
BOOL SetAutoMount(BOOL enable);
BOOL GetAutoMount(BOOL* enabled);
char* GetPhysicalName(DWORD DriveIndex);

View file

@ -32,9 +32,12 @@
#include <ctype.h>
#include <locale.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "br.h"
#include "fat16.h"
#include "fat32.h"
@ -44,7 +47,6 @@
#include "drive.h"
#include "format.h"
#include "badblocks.h"
#include "localization.h"
#include "bled/bled.h"
#include "../res/grub/grub_version.h"
@ -53,7 +55,7 @@
*/
DWORD FormatStatus;
badblocks_report report;
static DWORD LastRefresh;
static uint64_t LastRefresh;
static float format_percent = 0.0f;
static int task_number = 0;
extern const int nb_steps[FS_MAX];
@ -345,31 +347,20 @@ static DWORD GetVolumeID(void)
}
/*
* This is the Microsoft calculation from FATGEN
*
* DWORD RootDirSectors = 0;
* DWORD TmpVal1, TmpVal2, FATSz;
*
* TmpVal1 = DskSize - (ReservedSecCnt + RootDirSectors);
* TmpVal2 = (256 * SecPerClus) + NumFATs;
* TmpVal2 = TmpVal2 / 2;
* FATSz = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
*
* return( FatSz );
* Proper computation of FAT size
* See: http://www.syslinux.org/archives/2016-February/024850.html
* and subsequent replies.
*/
static DWORD GetFATSizeSectors(DWORD DskSize, DWORD ReservedSecCnt, DWORD SecPerClus, DWORD NumFATs, DWORD BytesPerSect)
{
ULONGLONG Numerator, Denominator;
ULONGLONG FatElementSize = 4;
ULONGLONG ReservedClusCnt = 2;
ULONGLONG FatSz;
// This is based on
// http://hjem.get2net.dk/rune_moeller_barnkob/filesystems/fat.html
Numerator = FatElementSize * (DskSize - ReservedSecCnt);
Denominator = (SecPerClus * BytesPerSect) + (FatElementSize * NumFATs);
FatSz = Numerator / Denominator;
// round up
FatSz += 1;
Numerator = DskSize - ReservedSecCnt + ReservedClusCnt * SecPerClus;
Denominator = SecPerClus * BytesPerSect / FatElementSize + NumFATs;
FatSz = Numerator / Denominator + 1; // +1 to ensure we are rounded up
return (DWORD)FatSz;
}
@ -621,8 +612,8 @@ static BOOL FormatFAT32(DWORD DriveIndex)
format_percent = 0.0f;
for (i=0; i<(SystemAreaSize+BurstSize-1); i+=BurstSize) {
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*i)/(1.0f*(SystemAreaSize+BurstSize));
PrintInfo(0, MSG_217, format_percent);
UpdateProgress(OP_FORMAT, format_percent);
@ -917,7 +908,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
// What follows is really a case statement with complex conditions listed
// by order of preference
if (allow_dual_uefi_bios)
if ((allow_dual_uefi_bios) && (tt == TT_BIOS))
goto windows_mbr;
// Forced UEFI (by zeroing the MBR)
@ -999,7 +990,7 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
set_bytes_per_sector(SelectedDrive.Geometry.BytesPerSector);
// Ensure that we have sufficient space for the SBR
max_size = IsChecked(IDC_EXTRA_PARTITION) ?
(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1024 * 1024;
(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1*MB;
max_size -= mbr_size;
// Syslinux has precedence over Grub
if ((bt == BT_ISO) && (!HAS_SYSLINUX(img_report))) {
@ -1251,7 +1242,7 @@ static BOOL SetupWinPE(char drive_letter)
}
}
if ((!WriteFile(handle, buf, size, &rw_size, NULL)) || (size != rw_size)) {
if (!WriteFileWithRetry(handle, buf, size, &rw_size, WRITE_RETRIES)) {
uprintf("Could not write patched file: %s\n", WindowsErrorString());
goto out;
}
@ -1273,7 +1264,7 @@ out:
// incompatibilities from one version of Windows to the next.
// Maybe when we use wimlib we'll review this, but for now just turn it off.
//#define SET_INTERNAL_DRIVES_OFFLINE
BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
static BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
{
#ifdef SET_INTERNAL_DRIVES_OFFLINE
static char san_policy_path[] = "?:\\san_policy.xml";
@ -1441,7 +1432,7 @@ static BOOL CALLBACK FormatPromptCallback(HWND hWnd, LPARAM lParam)
* disk in drive X: before you can use it'. You will also get that popup if you start a
* bad blocks check and cancel it before it completes. We have to close that popup manually.
*/
DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
static DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
HWND hFormatPrompt;
while(format_op_in_progress) {
@ -1456,16 +1447,109 @@ DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
ExitThread(0);
}
void update_progress(const uint64_t processed_bytes)
static void update_progress(const uint64_t processed_bytes)
{
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*processed_bytes)/(1.0f*img_report.projected_size);
PrintInfo(0, MSG_261, format_percent);
UpdateProgress(OP_FORMAT, format_percent);
}
}
/* Write an image file or zero a drive */
static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
{
const DWORD SectorSize = SelectedDrive.Geometry.BytesPerSector;
BOOL s, ret = FALSE;
LARGE_INTEGER li;
DWORD rSize, wSize, BufSize;
uint64_t wb, target_size = hSourceImage?img_report.projected_size:SelectedDrive.DiskSize;
uint8_t *buffer = NULL, *aligned_buffer;
int i;
// We poked the MBR and other stuff, so we need to rewind
li.QuadPart = 0;
if (!SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN))
uprintf("Warning: Unable to rewind image position - wrong data might be copied!");
LastRefresh = 0;
if (img_report.compression_type != BLED_COMPRESSION_NONE) {
uprintf("Writing Compressed Image...");
bled_init(_uprintf, update_progress, &FormatStatus);
bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
bled_exit();
} else {
uprintf(hSourceImage?"Writing Image...":"Zeroing drive...");
// Our buffer size must be a multiple of the sector size
BufSize = ((DD_BUFFER_SIZE + SectorSize - 1) / SectorSize) * SectorSize;
buffer = (uint8_t*)calloc(BufSize + SectorSize, 1); // +1 sector for align
if (buffer == NULL) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
uprintf("could not allocate disk write buffer");
goto out;
}
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment
aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SectorSize)-1) & (~(((uintptr_t)(SectorSize)) - 1))));
// Don't bother trying for something clever, using double buffering overlapped and whatnot:
// With Windows' default optimizations, sync read + sync write for sequential operations
// will be as fast, if not faster, than whatever async scheme you can come up with.
rSize = BufSize;
for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) {
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb) / (1.0f*target_size);
PrintInfo(0, hSourceImage?MSG_261:MSG_286, format_percent);
UpdateProgress(OP_FORMAT, format_percent);
}
if (hSourceImage != NULL) {
s = ReadFile(hSourceImage, aligned_buffer, BufSize, &rSize, NULL);
if (!s) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
uprintf("read error: %s", WindowsErrorString());
goto out;
}
if (rSize == 0)
break;
}
// Don't overflow our projected size (mostly for VHDs)
if (wb + rSize > target_size) {
rSize = (DWORD)(target_size - wb);
}
// WriteFile fails unless the size is a multiple of sector size
if (rSize % SectorSize != 0)
rSize = ((rSize + SectorSize - 1) / SectorSize) * SectorSize;
for (i = 0; i < WRITE_RETRIES; i++) {
CHECK_FOR_USER_CANCEL;
s = WriteFile(hPhysicalDrive, aligned_buffer, rSize, &wSize, NULL);
if ((s) && (wSize == rSize))
break;
if (s)
uprintf("write error: Wrote %d bytes, expected %d bytes\n", wSize, rSize);
else
uprintf("write error: %s", WindowsErrorString());
if (i < WRITE_RETRIES - 1) {
li.QuadPart = wb;
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
uprintf(" RETRYING...\n");
} else {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
goto out;
}
}
if (i >= WRITE_RETRIES) goto out;
}
}
RefreshDriveLayout(hPhysicalDrive);
ret = TRUE;
out:
safe_free(buffer);
return ret;
}
/*
* Standalone thread for the formatting operation
* According to http://msdn.microsoft.com/en-us/library/windows/desktop/aa364562.aspx
@ -1480,20 +1564,18 @@ void update_progress(const uint64_t processed_bytes)
DWORD WINAPI FormatThread(void* param)
{
int i, r, pt, tt, fs, bt;
BOOL s, ret, use_large_fat32, windows_to_go;
BOOL ret, use_large_fat32, windows_to_go;
const DWORD SectorSize = SelectedDrive.Geometry.BytesPerSector;
DWORD rSize, wSize, BufSize, DriveIndex = (DWORD)(uintptr_t)param;
DWORD 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 = NULL, *aligned_buffer, extra_partitions = 0;
uint8_t *buffer = NULL, extra_partitions = 0;
char *bb_msg, *guid_volume = NULL;
char drive_name[] = "?:\\";
char drive_letters[27];
char drive_letters[27], fs_type[32];
char logfile[MAX_PATH], *userdir;
char efi_dst[] = "?:\\efi\\boot\\bootx64.efi";
char kolibri_dst[] = "?:\\MTLD_F32";
@ -1595,57 +1677,8 @@ DWORD WINAPI FormatThread(void* param)
}
CreateThread(NULL, 0, CloseFormatPromptThread, NULL, 0, NULL);
// TODO: factorize this with DD write?
if (zero_drive) {
li.QuadPart = 0;
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
uprintf("Zeroing drive...");
// Our buffer size must be a multiple of the sector size
BufSize = ((DD_BUFFER_SIZE + SectorSize - 1) / SectorSize) * SectorSize;
buffer = (uint8_t*)calloc(BufSize + SectorSize, 1); // +1 sector for align
if (buffer == NULL) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
uprintf("could not allocate zeroing buffer");
goto out;
}
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment
aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SectorSize)-1) & (~(((uintptr_t)(SectorSize)) - 1))));
for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) {
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
format_percent = (100.0f*wb) / (1.0f*SelectedDrive.DiskSize);
PrintInfo(0, MSG_286, format_percent);
UpdateProgress(OP_FORMAT, format_percent);
}
// Don't overflow our projected size
if (wb + BufSize > (uint64_t)SelectedDrive.DiskSize) {
BufSize = (DWORD)(SelectedDrive.DiskSize - wb);
}
// WriteFile fails unless the size is a multiple of sector size
if (BufSize % SectorSize != 0)
BufSize = ((BufSize + SectorSize - 1) / SectorSize) * SectorSize;
for (i = 0; i < WRITE_RETRIES; i++) {
CHECK_FOR_USER_CANCEL;
s = WriteFile(hPhysicalDrive, aligned_buffer, BufSize, &wSize, NULL);
if ((s) && (wSize == BufSize))
break;
if (s)
uprintf("write error: Wrote %d bytes, expected %d bytes\n", wSize, BufSize);
else
uprintf("write error: %s", WindowsErrorString());
if (i < WRITE_RETRIES - 1) {
li.QuadPart = wb;
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
uprintf(" RETRYING...\n");
}
else {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
goto out;
}
}
if (i >= WRITE_RETRIES) goto out;
}
RefreshDriveLayout(hPhysicalDrive);
WriteDrive(hPhysicalDrive, NULL);
goto out;
}
@ -1716,11 +1749,6 @@ DWORD WINAPI FormatThread(void* param)
// Write an image file
if (IsChecked(IDC_BOOT) && (bt == BT_IMG)) {
char fs_type[32];
// We poked the MBR and other stuff, so we need to rewind
li.QuadPart = 0;
if (!SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN))
uprintf("Warning: Unable to rewind image position - wrong data might be copied!");
hSourceImage = CreateFileU(image_path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hSourceImage == INVALID_HANDLE_VALUE) {
@ -1728,75 +1756,10 @@ DWORD WINAPI FormatThread(void* param)
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED;
goto out;
}
LastRefresh = 0;
if (img_report.compression_type != BLED_COMPRESSION_NONE) {
uprintf("Writing Compressed Image...");
bled_init(_uprintf, update_progress, &FormatStatus);
bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
bled_exit();
} else {
uprintf("Writing Image...");
// Our buffer size must be a multiple of the sector size
BufSize = ((DD_BUFFER_SIZE + SectorSize - 1) / SectorSize) * SectorSize;
buffer = (uint8_t*)malloc(BufSize + SectorSize); // +1 sector for align
if (buffer == NULL) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_ENOUGH_MEMORY;
uprintf("could not allocate DD buffer");
goto out;
}
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment
aligned_buffer = ((void *) ((((uintptr_t)(buffer)) + (SectorSize) - 1) & (~(((uintptr_t)(SectorSize)) - 1))));
// Don't bother trying for something clever, using double buffering overlapped and whatnot:
// With Windows' default optimizations, sync read + sync write for sequential operations
// will be as fast, if not faster, than whatever async scheme you can come up with.
for (wb = 0, wSize = 0; ; wb += wSize) {
s = ReadFile(hSourceImage, aligned_buffer, BufSize, &rSize, NULL);
if (!s) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_READ_FAULT;
uprintf("read error: %s", WindowsErrorString());
goto out;
}
if (rSize == 0)
break;
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
format_percent = (100.0f*wb)/(1.0f*img_report.projected_size);
PrintInfo(0, MSG_261, format_percent);
UpdateProgress(OP_FORMAT, format_percent);
}
// Don't overflow our projected size (mostly for VHDs)
if (wb + rSize > img_report.projected_size) {
rSize = (DWORD)(img_report.projected_size - wb);
}
// WriteFile fails unless the size is a multiple of sector size
if (rSize % SectorSize != 0)
rSize = ((rSize + SectorSize -1) / SectorSize) * SectorSize;
for (i=0; i < WRITE_RETRIES; i++) {
CHECK_FOR_USER_CANCEL;
s = WriteFile(hPhysicalDrive, aligned_buffer, rSize, &wSize, NULL);
if ((s) && (wSize == rSize))
break;
if (s)
uprintf("write error: Wrote %d bytes, expected %d bytes\n", wSize, rSize);
else
uprintf("write error: %s", WindowsErrorString());
if (i < WRITE_RETRIES-1) {
li.QuadPart = wb;
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
uprintf(" RETRYING...\n");
} else {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;
goto out;
}
}
if (i >= WRITE_RETRIES) goto out;
}
}
WriteDrive(hPhysicalDrive, hSourceImage);
// If the image contains a partition we might be able to access, try to re-mount it
RefreshDriveLayout(hPhysicalDrive);
safe_unlockclose(hPhysicalDrive);
safe_unlockclose(hLogicalVolume);
Sleep(200);
@ -1806,8 +1769,6 @@ DWORD WINAPI FormatThread(void* param)
if ((guid_volume != NULL) && (MountVolume(drive_name, guid_volume)))
uprintf("Remounted %s on %s\n", guid_volume, drive_name);
}
uprintf("Done");
goto out;
}
@ -1883,7 +1844,7 @@ DWORD WINAPI FormatThread(void* param)
} else if (tt == TT_UEFI) {
// For once, no need to do anything - just check our sanity
if ( (bt != BT_ISO) || (!img_report.has_efi) || (fs > FS_NTFS) ) {
uprintf("Spock gone crazy error!\n");
uprintf("Spock gone crazy error in %s:%d", __FILE__, __LINE__);
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
goto out;
}
@ -2082,8 +2043,8 @@ DWORD WINAPI SaveImageThread(void* param)
}
if (rSize == 0)
break;
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
if (_GetTickCount64() > LastRefresh + MAX_REFRESH) {
LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb)/(1.0f*SelectedDrive.DiskSize);
PrintInfo(0, MSG_261, format_percent);
UpdateProgress(OP_FORMAT, format_percent);

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Extract icon from executable and set autorun.inf
* Copyright © 2012-2013 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,9 +27,10 @@
#include <stdio.h>
#include <string.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#pragma pack(push)
#pragma pack(2)
@ -74,7 +75,7 @@ typedef struct
WORD nID; // the ID
} GRPICONDIRENTRY, *LPGRPICONDIRENTRY;
typedef struct
typedef struct
{
WORD idReserved; // Reserved (must be 0)
WORD idType; // Resource type (1 for icons)
@ -103,13 +104,13 @@ static BOOL SaveIcon(const char* filename)
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
uprintf("Unable to create icon '%s': %s.\n", filename, WindowsErrorString());
uprintf("Unable to create icon '%s': %s.", filename, WindowsErrorString());
goto out;
}
// Write .ico header
if ((!WriteFile(hFile, icondir, 3*sizeof(WORD), &Size, NULL)) || (Size != 3*sizeof(WORD))) {
uprintf("Couldn't write icon header: %s.\n", WindowsErrorString());
if (!WriteFileWithRetry(hFile, icondir, 3*sizeof(WORD), &Size, WRITE_RETRIES)) {
uprintf("Could not write icon header: %s.", WindowsErrorString());
goto out;
}
@ -117,15 +118,14 @@ static BOOL SaveIcon(const char* filename)
offset = 3*sizeof(WORD) + icondir->idCount*sizeof(ICONDIRENTRY);
for (i=0; i<icondir->idCount; i++) {
// Write the common part of ICONDIRENTRY
if ( (!WriteFile(hFile, &icondir->idEntries[i], sizeof(GRPICONDIRENTRY)-sizeof(WORD), &Size, NULL))
|| (Size != sizeof(GRPICONDIRENTRY)-sizeof(WORD)) ) {
uprintf("Couldn't write ICONDIRENTRY[%d]: %s.\n", i, WindowsErrorString());
if (!WriteFileWithRetry(hFile, &icondir->idEntries[i], sizeof(GRPICONDIRENTRY)-sizeof(WORD), &Size, WRITE_RETRIES)) {
uprintf("Could not write ICONDIRENTRY[%d]: %s.", i, WindowsErrorString());
goto out;
}
res = FindResourceA(hMainInstance, MAKEINTRESOURCEA(icondir->idEntries[i].nID), _RT_ICON);
// Write the DWORD offset
if ( (!WriteFile(hFile, &offset, sizeof(offset), &Size, NULL)) || (Size != sizeof(offset)) ) {
uprintf("Couldn't write ICONDIRENTRY[%d] offset: %s.\n", i, WindowsErrorString());
if (!WriteFileWithRetry(hFile, &offset, sizeof(offset), &Size, WRITE_RETRIES)) {
uprintf("Could not write ICONDIRENTRY[%d] offset: %s.", i, WindowsErrorString());
goto out;
}
offset += SizeofResource(NULL, res);
@ -136,12 +136,12 @@ static BOOL SaveIcon(const char* filename)
res_handle = LoadResource(NULL, res);
res_data = (BYTE*)LockResource(res_handle);
res_size = SizeofResource(NULL, res);
if ( (!WriteFile(hFile, res_data, res_size, &Size, NULL)) || (Size != res_size) ) {
uprintf("Couldn't write icon data #%d: %s.\n", i, WindowsErrorString());
if (!WriteFileWithRetry(hFile, res_data, res_size, &Size, WRITE_RETRIES)) {
uprintf("Could not write icon data #%d: %s.", i, WindowsErrorString());
goto out;
}
}
uprintf("Created: %s\n", filename);
uprintf("Created: %s", filename);
r = TRUE;
out:
@ -163,14 +163,14 @@ BOOL SetAutorun(const char* path)
safe_sprintf(filename, sizeof(filename), "%sautorun.inf", path);
fd = fopen(filename, "r"); // If there's an existing autorun, don't overwrite
if (fd != NULL) {
uprintf("%s already exists - keeping it\n", filename);
uprintf("%s already exists - keeping it", filename);
fclose(fd);
return FALSE;
}
// No "/autorun.inf" => create a new one in UTF-16 LE mode
fd = fopen(filename, "w, ccs=UTF-16LE");
if (fd == NULL) {
uprintf("Unable to create %s\n", filename);
uprintf("Unable to create %s", filename);
uprintf("NOTE: This may be caused by a poorly designed security solution. "
"See http://rufus.akeo.ie/compatibility.");
return FALSE;
@ -181,7 +181,7 @@ BOOL SetAutorun(const char* path)
fwprintf(fd, L"; Created by %s\n; " LTEXT(RUFUS_URL) L"\n", wRufusVersion);
fwprintf(fd, L"[autorun]\nicon = autorun.ico\nlabel = %s\n", wlabel);
fclose(fd);
uprintf("Created: %s\n", filename);
uprintf("Created: %s", filename);
// .inf -> .ico
filename[strlen(filename)-1] = 'o';

132
src/iso.c
View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* ISO file extraction
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
* Based on libcdio's iso & udf samples:
* Copyright © 2003-2014 Rocky Bernstein <rocky@gnu.org>
*
@ -39,8 +39,9 @@
#include <cdio/udf.h>
#include "rufus.h"
#include "msapi_utf8.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
// How often should we update the progress bar (in 2K blocks) as updating
@ -71,7 +72,7 @@ static const char* grldr_name = "grldr";
static const char* ldlinux_name = "ldlinux.sys";
static const char* ldlinux_c32 = "ldlinux.c32";
static const char* efi_dirname = "/efi/boot";
static const char* efi_bootname[] = { "bootia32.efi", "bootx64.efi", "bootia64.efi", "bootarm.efi" };
static const char* efi_bootname[] = { "bootia32.efi", "bootia64.efi", "bootx64.efi", "bootarm.efi", "bootaa64.efi" };
static const char* install_wim_path = "/sources";
static const char* install_wim_name[] = { "install.wim", "install.swm" };
static const char* grub_dirname = "/boot/grub"; // NB: We don't support nonstandard config dir such as AROS' "/boot/pc/grub/"
@ -306,8 +307,6 @@ static void print_extracted_file(char* psz_fullpath, int64_t i_file_length)
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, TRUE, FALSE));
uprintf("Extracting: %s\n", psz_fullpath);
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, FALSE, FALSE));
// TODO: I don't think we need both of these...
SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, psz_fullpath);
PrintStatus(0, MSG_000, psz_fullpath); // MSG_000 is "%s"
// ISO9660 cannot handle backslashes
for (i=0; i<nul_pos; i++)
@ -429,17 +428,11 @@ 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);
for (i=0; i<WRITE_RETRIES; i++) {
ISO_BLOCKING(r = WriteFile(file_handle, buf, buf_size, &wr_size, NULL));
if ((!r) || (buf_size != wr_size)) {
uprintf(" Error writing file: %s", WindowsErrorString());
if (i < WRITE_RETRIES-1)
uprintf(" RETRYING...\n");
} else {
break;
}
ISO_BLOCKING(r = WriteFileWithRetry(file_handle, buf, buf_size, &wr_size, WRITE_RETRIES));
if (!r) {
uprintf(" Error writing file: %s", WindowsErrorString());
goto out;
}
if (i >= WRITE_RETRIES) goto out;
i_file_length -= i_read;
if (nb_blocks++ % PROGRESS_THRESHOLD == 0)
UpdateProgress(OP_DOS, 100.0f*nb_blocks/total_blocks);
@ -476,7 +469,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
HANDLE file_handle = NULL;
DWORD buf_size, wr_size, err;
EXTRACT_PROPS props;
BOOL s, is_symlink, is_identical;
BOOL is_symlink, is_identical;
int i_length, r = 1;
char tmp[128], psz_fullpath[MAX_PATH], *psz_basename, *psz_sanpath;
const char *psz_iso_name = &psz_fullpath[strlen(psz_extract_dir)];
@ -484,7 +477,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
CdioListNode_t* p_entnode;
iso9660_stat_t *p_statbuf;
CdioList_t* p_entlist;
size_t i, j;
size_t i;
lsn_t lsn;
int64_t i_file_length;
@ -582,17 +575,11 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
goto out;
}
buf_size = (DWORD)MIN(i_file_length, ISO_BLOCKSIZE);
for (j=0; j<WRITE_RETRIES; j++) {
ISO_BLOCKING(s = WriteFile(file_handle, buf, buf_size, &wr_size, NULL));
if ((!s) || (buf_size != wr_size)) {
uprintf(" Error writing file: %s", WindowsErrorString());
if (j < WRITE_RETRIES-1)
uprintf(" RETRYING...\n");
} else {
break;
}
ISO_BLOCKING(r = WriteFileWithRetry(file_handle, buf, buf_size, &wr_size, WRITE_RETRIES));
if (!r) {
uprintf(" Error writing file: %s", WindowsErrorString());
goto out;
}
if (j >= WRITE_RETRIES) goto out;
i_file_length -= ISO_BLOCKSIZE;
if (nb_blocks++ % PROGRESS_THRESHOLD == 0)
UpdateProgress(OP_DOS, 100.0f*nb_blocks/total_blocks);
@ -918,7 +905,6 @@ int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_f
int64_t file_length, r = 0;
char buf[UDF_BLOCKSIZE];
DWORD buf_size, wr_size;
BOOL s;
iso9660_t* p_iso = NULL;
udf_t* p_udf = NULL;
udf_dirent_t *p_udf_root = NULL, *p_udf_file = NULL;
@ -957,8 +943,7 @@ int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_f
goto out;
}
buf_size = (DWORD)MIN(file_length, read_size);
s = WriteFile(file_handle, buf, buf_size, &wr_size, NULL);
if ((!s) || (buf_size != wr_size)) {
if (!WriteFileWithRetry(file_handle, buf, buf_size, &wr_size, WRITE_RETRIES)) {
uprintf(" Error writing file %s: %s\n", dest_file, WindowsErrorString());
goto out;
}
@ -989,8 +974,7 @@ try_iso:
goto out;
}
buf_size = (DWORD)MIN(file_length, ISO_BLOCKSIZE);
s = WriteFile(file_handle, buf, buf_size, &wr_size, NULL);
if ((!s) || (buf_size != wr_size)) {
if (!WriteFileWithRetry(file_handle, buf, buf_size, &wr_size, WRITE_RETRIES)) {
uprintf(" Error writing file %s: %s\n", dest_file, WindowsErrorString());
goto out;
}
@ -1083,91 +1067,9 @@ out:
if (p_udf != NULL)
udf_close(p_udf);
safe_free(wim_path);
return bswap_32(r);
return bswap_uint32(r);
}
/*
* The following is used for native ISO mounting in Windows 8 or later
*/
#define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \
{ 0xEC984AECL, 0xA0F9, 0x47e9, { 0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B } }
typedef enum _VIRTUAL_DISK_ACCESS_MASK {
VIRTUAL_DISK_ACCESS_NONE = 0x00000000,
VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000,
VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000,
VIRTUAL_DISK_ACCESS_DETACH = 0x00040000,
VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000,
VIRTUAL_DISK_ACCESS_CREATE = 0x00100000,
VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000,
VIRTUAL_DISK_ACCESS_READ = 0x000d0000,
VIRTUAL_DISK_ACCESS_ALL = 0x003f0000,
VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000
} VIRTUAL_DISK_ACCESS_MASK;
typedef enum _OPEN_VIRTUAL_DISK_FLAG {
OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x00000001,
OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x00000002,
OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x00000004,
OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x00000008,
OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x00000010
} OPEN_VIRTUAL_DISK_FLAG;
typedef enum _OPEN_VIRTUAL_DISK_VERSION {
OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
OPEN_VIRTUAL_DISK_VERSION_1 = 1,
OPEN_VIRTUAL_DISK_VERSION_2 = 2
} OPEN_VIRTUAL_DISK_VERSION;
typedef enum _ATTACH_VIRTUAL_DISK_FLAG {
ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001,
ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = 0x00000002,
ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004,
ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = 0x00000008
} ATTACH_VIRTUAL_DISK_FLAG;
typedef enum _ATTACH_VIRTUAL_DISK_VERSION {
ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
ATTACH_VIRTUAL_DISK_VERSION_1 = 1
} ATTACH_VIRTUAL_DISK_VERSION;
typedef enum _DETACH_VIRTUAL_DISK_FLAG {
DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000
} DETACH_VIRTUAL_DISK_FLAG;
#ifndef _VIRTUAL_STORAGE_TYPE_DEFINED
#define _VIRTUAL_STORAGE_TYPE_DEFINED
typedef struct _VIRTUAL_STORAGE_TYPE {
ULONG DeviceId;
GUID VendorId;
} VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE;
#endif
typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS {
OPEN_VIRTUAL_DISK_VERSION Version;
union {
struct {
ULONG RWDepth;
} Version1;
struct {
BOOL GetInfoOnly;
BOOL ReadOnly;
GUID ResiliencyGuid;
} Version2;
};
} OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS;
typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS {
ATTACH_VIRTUAL_DISK_VERSION Version;
union {
struct {
ULONG Reserved;
} Version1;
};
} ATTACH_VIRTUAL_DISK_PARAMETERS, *PATTACH_VIRTUAL_DISK_PARAMETERS;
// VirtDisk API Prototypes - Only available for Windows 8 or later
PF_TYPE_DECL(WINAPI, DWORD, OpenVirtualDisk, (PVIRTUAL_STORAGE_TYPE, PCWSTR,
VIRTUAL_DISK_ACCESS_MASK, OPEN_VIRTUAL_DISK_FLAG, POPEN_VIRTUAL_DISK_PARAMETERS, PHANDLE));

View file

@ -39,21 +39,8 @@
/* Define to 1 if you have the `fseeko64' function. */
#define HAVE_FSEEKO64 1
#if defined(_MSC_VER)
/* The equivalent of fseeko64 for MSVC is _fseeki64, however this */
/* is not available on XP when build with WDK (but _lseeki64 is) */
#if defined(DDKBUILD)
#include <windows.h>
#include <stdio.h>
#include <io.h>
static __inline int fseeko64(FILE *stream, __int64 offset, int origin) {
fflush(stream); /* VERY IMPORTANT! */
return (lseek64(_fileno(stream), offset, origin) == -1LL)?-1:0;
}
#else
/* The equivalent of fseeko64 for MSVC is _fseeki64 */
#define fseeko64 _fseeki64
#endif
#endif
/* Define to 1 if you have the `ftruncate' function. */
/* #undef HAVE_FTRUNCATE */

View file

@ -108,8 +108,9 @@ const char* additional_copyrights =
"https://www.gnupg.org\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"SHA-256 checksum from Brad Conte's crypto-algorithms:\\line\n"
"https://github.com/B-Con/crypto-algorithms\\line\n"
"SHA-256 checksum from 7-zip by Igor Pavlov and Crypto++ by Wei Dai:\\line\n"
"http://7-zip.org\\line\n"
"https://github.com/weidai11/cryptopp/\\line\n"
"Public Domain\\line\n"
"\\line\n"
"About and License dialogs inspired by WinSCP by Martin Prikryl\\line\n"

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Localization functions, a.k.a. "Everybody is doing it wrong but me!"
* Copyright © 2013-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -420,14 +420,54 @@ char* lmprintf(uint32_t msg_id, ...)
#define MSG_HIGH_PRI 1
char szMessage[2][2][MSG_LEN] = { {"", ""}, {"", ""} };
char* szStatusMessage = szMessage[MSG_STATUS][MSG_HIGH_PRI];
static BOOL bStatusTimerArmed = FALSE;
static BOOL bStatusTimerArmed = FALSE, bOutputTimerArmed[2] = { FALSE, FALSE };
static char *output_msg[2];
static uint64_t last_msg_time[2] = { 0, 0 };
static void __inline OutputMessage(BOOL info, char* msg)
static void PrintInfoMessage(char* msg) {
SetWindowTextU(hInfo, msg);
}
static void PrintStatusMessage(char* msg) {
SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, msg);
}
typedef void PRINT_FUNCTION(char*);
PRINT_FUNCTION *PrintMessage[2] = { PrintInfoMessage, PrintStatusMessage };
/*
* The following timer call is used, along with MAX_REFRESH, to prevent obnoxious flicker
* on the Info and Status fields due to messages being updated too quickly.
*/
static void CALLBACK OutputMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
if (info)
SetWindowTextU(hInfo, msg);
else
SendMessageLU(hStatus, SB_SETTEXTW, SBT_OWNERDRAW | SB_SECTION_LEFT, msg);
int i = (idEvent == TID_OUTPUT_INFO)? 0 : 1;
KillTimer(hMainDialog, idEvent);
bOutputTimerArmed[i] = FALSE;
PrintMessage[i](output_msg[i]);
last_msg_time[i] = _GetTickCount64();
}
static void OutputMessage(BOOL info, char* msg)
{
uint64_t delta;
int i = info ? 0 : 1;
if (bOutputTimerArmed[i]) {
// Already have a delayed message going - just change that message to latest
output_msg[i] = msg;
} else {
// Find if we need to arm a timer
delta = _GetTickCount64() - last_msg_time[i];
if (delta < (2 * MAX_REFRESH)) {
// Not enough time has elapsed since our last output => arm a timer
output_msg[i] = msg;
SetTimer(hMainDialog, TID_OUTPUT_INFO + i, (UINT)((2 * MAX_REFRESH) - delta), OutputMessageTimeout);
bOutputTimerArmed[i] = TRUE;
} else {
PrintMessage[i](msg);
last_msg_time[i] = _GetTickCount64();
}
}
}
static void CALLBACK PrintMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
@ -602,13 +642,15 @@ WORD get_language_id(loc_cmd* lcmd)
wchar_t wlang[5];
LANGID lang_id = GetUserDefaultUILanguage();
// Log will be reset, so we need to use the buffered uprintf() to get our messages to the user
ubclear();
if (lcmd == NULL)
return MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
// Find if the selected language is the user default
for (i = 0; i<lcmd->unum_size; i++) {
if (lcmd->unum[i] == lang_id) {
uprintf("localization: will use default UI language 0x%04X", lang_id);
ubpushf("Will use default UI locale 0x%04X", lang_id);
return MAKELANGID(lang_id, SUBLANG_DEFAULT);
}
}
@ -622,11 +664,12 @@ WORD get_language_id(loc_cmd* lcmd)
// boolean to tell us that we found what we were after.
EnumUILanguages(EnumUILanguagesProc, 0x4, (LONG_PTR)wlang); // 0x04 = MUI_LANGUAGE_ID
if (found_lang) {
uprintf("localization: detected installed language pack for 0x%04X", lcmd->unum[i]);
ubpushf("Detected installed Windows Language Pack for 0x%04X (%s)", lcmd->unum[i], lcmd->txt[1]);
return MAKELANGID(lcmd->unum[i], SUBLANG_DEFAULT);
}
}
uprintf("localization: no matching language pack - some messages will be displayed using default locale");
ubpushf("NOTE: No Windows Language Pack is installed for %s on this system.\r\n"
"This means that some controls may still be displayed using the system locale.", lcmd->txt[1]);
return MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
}

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Localization functions, a.k.a. "Everybody is doing it wrong but me!"
* Copyright © 2013-2014 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,8 +30,7 @@
// Attributes that can be set by a translation
#define LOC_RIGHT_TO_LEFT 0x00000001
#define LOC_ARABIC_NUMERALS 0x00000002
#define LOC_JAPANESE_NUMERALS 0x00000004
#define LOC_NEEDS_UPDATE 0x00000002
// The [v]ersion major from a translation must match this number or
// the translation will be ignored

571
src/missing.h Normal file
View file

@ -0,0 +1,571 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Constants and defines missing from various toolchains
* Copyright © 2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <windows.h>
#include <commctrl.h>
#include <shlobj.h>
#include <wininet.h>
#include <stdint.h>
#pragma once
/* Convenient to have around */
#define KB 1024LL
#define MB 1048576LL
#define GB 1073741824LL
#define TB 1099511627776LL
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#if defined(__GNUC__)
#define ALIGNED(m) __attribute__ ((__aligned__(m)))
#elif defined(_MSC_VER)
#define ALIGNED(m) __declspec(align(m))
#endif
/*
* Prefetch 64 bytes at address m, for read-only operation
* We account for these built-in calls doing nothing if the
* line has already been fetched, or if the address is invalid.
*/
#if defined(__GNUC__)
#define PREFETCH64(m) do { __builtin_prefetch(m, 0, 0); __builtin_prefetch(m+32, 0, 0); } while(0)
#elif defined(_MSC_VER)
#define PREFETCH64(m) do { _m_prefetch(m); _m_prefetch(m+32); } while(0)
#endif
/* Read/write with endianness swap */
#if defined (_MSC_VER) && (_MSC_VER >= 1300)
#include <stdlib.h>
#pragma intrinsic(_byteswap_ushort)
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
#define bswap_uint64 _byteswap_uint64
#define bswap_uint32 _byteswap_ulong
#define bswap_uint16 _byteswap_ushort
#elif defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
#define bswap_uint64 __builtin_bswap64
#define bswap_uint32 __builtin_bswap32
#define bswap_uint16 __builtin_bswap16
#endif
#define read_swap16(p) bswap_uint16(*(const uint16_t*)(const uint8_t*)(p))
#define read_swap32(p) bswap_uint32(*(const uint32_t*)(const uint8_t*)(p))
#define read_swap64(p) bswap_uint64(*(const uint64_t*)(const uint8_t*)(p))
#define write_swap16(p,v) (*(uint16_t*)(void*)(p)) = bswap_uint16(v)
#define write_swap32(p,v) (*(uint32_t*)(void*)(p)) = bswap_uint32(v)
#define write_swap64(p,v) (*(uint32_t*)(void*)(p)) = bswap_uint64(v)
/*
* Nibbled from https://github.com/hanji/popcnt/blob/master/populationcount.cpp
* Since MSVC x86_32 does not have intrinsic popcount64 and I don't have all day
*/
static __inline int popcnt64(register uint64_t u)
{
u = (u & 0x5555555555555555) + ((u >> 1) & 0x5555555555555555);
u = (u & 0x3333333333333333) + ((u >> 2) & 0x3333333333333333);
u = (u & 0x0f0f0f0f0f0f0f0f) + ((u >> 4) & 0x0f0f0f0f0f0f0f0f);
u = (u & 0x00ff00ff00ff00ff) + ((u >> 8) & 0x00ff00ff00ff00ff);
u = (u & 0x0000ffff0000ffff) + ((u >> 16) & 0x0000ffff0000ffff);
u = (u & 0x00000000ffffffff) + ((u >> 32) & 0x00000000ffffffff);
return (int)u;
}
static __inline void *_reallocf(void *ptr, size_t size) {
void *ret = realloc(ptr, size);
if (!ret)
free(ptr);
return ret;
}
/* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */
#define _RT_ICON MAKEINTRESOURCEA(3)
#define _RT_DIALOG MAKEINTRESOURCEA(5)
#define _RT_RCDATA MAKEINTRESOURCEA(10)
#define _RT_GROUP_ICON MAKEINTRESOURCEA((ULONG_PTR)(MAKEINTRESOURCEA(3) + 11))
/* UI redefinitions for WDK and MinGW */
#ifndef PBM_SETSTATE
#define PBM_SETSTATE (WM_USER+16)
#endif
#ifndef PBST_NORMAL
#define PBST_NORMAL 1
#endif
#ifndef PBST_ERROR
#define PBST_ERROR 2
#endif
#ifndef PBST_PAUSED
#define PBST_PAUSED 3
#endif
#ifndef BUTTON_IMAGELIST_ALIGN_CENTER
#define BUTTON_IMAGELIST_ALIGN_CENTER 4
#endif
#ifndef BCM_SETIMAGELIST
#define BCM_SETIMAGELIST 0x1602
#endif
#ifndef DBT_CUSTOMEVENT
#define DBT_CUSTOMEVENT 0x8006
#endif
#ifndef ERROR_FILE_TOO_LARGE
#define ERROR_FILE_TOO_LARGE 223
#endif
#ifndef MSGFLT_ADD
#define MSGFLT_ADD 1
#endif
#ifndef WM_CLIENTSHUTDOWN
#define WM_CLIENTSHUTDOWN 0x3B
#endif
#ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x49
#endif
#ifndef PBS_MARQUEE
#define PBS_MARQUEE 0x08
#endif
#ifndef PBM_SETMARQUEE
#define PBM_SETMARQUEE (WM_USER+10)
#endif
typedef struct {
HIMAGELIST himl;
RECT margin;
UINT uAlign;
} MY_BUTTON_IMAGELIST;
typedef struct
{
LPCITEMIDLIST pidl;
BOOL fRecursive;
} MY_SHChangeNotifyEntry;
/* The following is used for native ISO mounting in Windows 8 or later */
#define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \
{ 0xEC984AECL, 0xA0F9, 0x47e9, { 0x90, 0x1F, 0x71, 0x41, 0x5A, 0x66, 0x34, 0x5B } }
typedef enum _VIRTUAL_DISK_ACCESS_MASK {
VIRTUAL_DISK_ACCESS_NONE = 0x00000000,
VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000,
VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000,
VIRTUAL_DISK_ACCESS_DETACH = 0x00040000,
VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000,
VIRTUAL_DISK_ACCESS_CREATE = 0x00100000,
VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000,
VIRTUAL_DISK_ACCESS_READ = 0x000d0000,
VIRTUAL_DISK_ACCESS_ALL = 0x003f0000,
VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000
} VIRTUAL_DISK_ACCESS_MASK;
typedef enum _OPEN_VIRTUAL_DISK_FLAG {
OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x00000001,
OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x00000002,
OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x00000004,
OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x00000008,
OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x00000010
} OPEN_VIRTUAL_DISK_FLAG;
typedef enum _OPEN_VIRTUAL_DISK_VERSION {
OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
OPEN_VIRTUAL_DISK_VERSION_1 = 1,
OPEN_VIRTUAL_DISK_VERSION_2 = 2
} OPEN_VIRTUAL_DISK_VERSION;
typedef enum _ATTACH_VIRTUAL_DISK_FLAG {
ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000,
ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001,
ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = 0x00000002,
ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004,
ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = 0x00000008
} ATTACH_VIRTUAL_DISK_FLAG;
typedef enum _ATTACH_VIRTUAL_DISK_VERSION {
ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0,
ATTACH_VIRTUAL_DISK_VERSION_1 = 1
} ATTACH_VIRTUAL_DISK_VERSION;
typedef enum _DETACH_VIRTUAL_DISK_FLAG {
DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000
} DETACH_VIRTUAL_DISK_FLAG;
#ifndef _VIRTUAL_STORAGE_TYPE_DEFINED
#define _VIRTUAL_STORAGE_TYPE_DEFINED
typedef struct _VIRTUAL_STORAGE_TYPE {
ULONG DeviceId;
GUID VendorId;
} VIRTUAL_STORAGE_TYPE, *PVIRTUAL_STORAGE_TYPE;
#endif
typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS {
OPEN_VIRTUAL_DISK_VERSION Version;
union {
struct {
ULONG RWDepth;
} Version1;
struct {
BOOL GetInfoOnly;
BOOL ReadOnly;
GUID ResiliencyGuid;
} Version2;
};
} OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS;
typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS {
ATTACH_VIRTUAL_DISK_VERSION Version;
union {
struct {
ULONG Reserved;
} Version1;
};
} ATTACH_VIRTUAL_DISK_PARAMETERS, *PATTACH_VIRTUAL_DISK_PARAMETERS;
/* Networking constants missing from MinGW */
#if !defined(ERROR_INTERNET_DISCONNECTED)
#define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163)
#endif
#if !defined(ERROR_INTERNET_SERVER_UNREACHABLE)
#define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164)
#endif
#if !defined(ERROR_INTERNET_PROXY_SERVER_UNREACHABLE)
#define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165)
#endif
#if !defined(ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT)
#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166)
#endif
#if !defined(ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT)
#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167)
#endif
#if !defined(ERROR_INTERNET_FAILED_DUETOSECURITYCHECK)
#define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171)
#endif
#if !defined(ERROR_INTERNET_NOT_INITIALIZED)
#define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172)
#endif
#if !defined(ERROR_INTERNET_NEED_MSN_SSPI_PKG)
#define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173)
#endif
#if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY)
#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174)
#endif
/* Clang/MinGW32 has an issue with intptr_t */
#ifndef _UINTPTR_T_DEFINED
#define _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#endif
/*
* IFile[Open]Dialog interface for Vista and later (from MinGW headers)
*/
#ifndef __IFileDialog_INTERFACE_DEFINED__
#define __IFileDialog_INTERFACE_DEFINED__
enum _FILEOPENDIALOGOPTIONS {
FOS_OVERWRITEPROMPT = 0x2,
FOS_STRICTFILETYPES = 0x4,
FOS_NOCHANGEDIR = 0x8,
FOS_PICKFOLDERS = 0x20,
FOS_FORCEFILESYSTEM = 0x40,
FOS_ALLNONSTORAGEITEMS = 0x80,
FOS_NOVALIDATE = 0x100,
FOS_ALLOWMULTISELECT = 0x200,
FOS_PATHMUSTEXIST = 0x800,
FOS_FILEMUSTEXIST = 0x1000,
FOS_CREATEPROMPT = 0x2000,
FOS_SHAREAWARE = 0x4000,
FOS_NOREADONLYRETURN = 0x8000,
FOS_NOTESTFILECREATE = 0x10000,
FOS_HIDEMRUPLACES = 0x20000,
FOS_HIDEPINNEDPLACES = 0x40000,
FOS_NODEREFERENCELINKS = 0x100000,
FOS_DONTADDTORECENT = 0x2000000,
FOS_FORCESHOWHIDDEN = 0x10000000,
FOS_DEFAULTNOMINIMODE = 0x20000000,
FOS_FORCEPREVIEWPANEON = 0x40000000
};
typedef enum FDAP {
FDAP_BOTTOM = 0,
FDAP_TOP = 1
} FDAP;
typedef DWORD FILEOPENDIALOGOPTIONS;
DEFINE_GUID(IID_IFileDialog, 0x42f85136, 0xdb7e, 0x439c, 0x85, 0xf1, 0xe4, 0x07, 0x5d, 0x13, 0x5f, 0xc8);
typedef struct IFileDialogVtbl {
BEGIN_INTERFACE
/*** IUnknown methods ***/
HRESULT(STDMETHODCALLTYPE *QueryInterface)(
IFileDialog* This,
REFIID riid,
void **ppvObject);
ULONG(STDMETHODCALLTYPE *AddRef)(
IFileDialog* This);
ULONG(STDMETHODCALLTYPE *Release)(
IFileDialog* This);
/*** IModalWindow methods ***/
HRESULT(STDMETHODCALLTYPE *Show)(
IFileDialog* This,
HWND hwndOwner);
/*** IFileDialog methods ***/
HRESULT(STDMETHODCALLTYPE *SetFileTypes)(
IFileDialog* This,
UINT cFileTypes,
const COMDLG_FILTERSPEC *rgFilterSpec);
HRESULT(STDMETHODCALLTYPE *SetFileTypeIndex)(
IFileDialog* This,
UINT iFileType);
HRESULT(STDMETHODCALLTYPE *GetFileTypeIndex)(
IFileDialog* This,
UINT *piFileType);
HRESULT(STDMETHODCALLTYPE *Advise)(
IFileDialog* This,
IFileDialogEvents *pfde,
DWORD *pdwCookie);
HRESULT(STDMETHODCALLTYPE *Unadvise)(
IFileDialog* This,
DWORD dwCookie);
HRESULT(STDMETHODCALLTYPE *SetOptions)(
IFileDialog* This,
FILEOPENDIALOGOPTIONS fos);
HRESULT(STDMETHODCALLTYPE *GetOptions)(
IFileDialog* This,
FILEOPENDIALOGOPTIONS *pfos);
HRESULT(STDMETHODCALLTYPE *SetDefaultFolder)(
IFileDialog* This,
IShellItem *psi);
HRESULT(STDMETHODCALLTYPE *SetFolder)(
IFileDialog* This,
IShellItem *psi);
HRESULT(STDMETHODCALLTYPE *GetFolder)(
IFileDialog* This,
IShellItem **ppsi);
HRESULT(STDMETHODCALLTYPE *GetCurrentSelection)(
IFileDialog* This,
IShellItem **ppsi);
HRESULT(STDMETHODCALLTYPE *SetFileName)(
IFileDialog* This,
LPCWSTR pszName);
HRESULT(STDMETHODCALLTYPE *GetFileName)(
IFileDialog* This,
LPWSTR *pszName);
HRESULT(STDMETHODCALLTYPE *SetTitle)(
IFileDialog* This,
LPCWSTR pszTitle);
HRESULT(STDMETHODCALLTYPE *SetOkButtonLabel)(
IFileDialog* This,
LPCWSTR pszText);
HRESULT(STDMETHODCALLTYPE *SetFileNameLabel)(
IFileDialog* This,
LPCWSTR pszLabel);
HRESULT(STDMETHODCALLTYPE *GetResult)(
IFileDialog* This,
IShellItem **ppsi);
HRESULT(STDMETHODCALLTYPE *AddPlace)(
IFileDialog* This,
IShellItem *psi,
FDAP fdap);
HRESULT(STDMETHODCALLTYPE *SetDefaultExtension)(
IFileDialog* This,
LPCWSTR pszDefaultExtension);
HRESULT(STDMETHODCALLTYPE *Close)(
IFileDialog* This,
HRESULT hr);
HRESULT(STDMETHODCALLTYPE *SetClientGuid)(
IFileDialog* This,
REFGUID guid);
HRESULT(STDMETHODCALLTYPE *ClearClientData)(
IFileDialog* This);
HRESULT(STDMETHODCALLTYPE *SetFilter)(
IFileDialog* This,
IShellItemFilter *pFilter);
END_INTERFACE
} IFileDialogVtbl;
interface IFileDialog {
CONST_VTBL IFileDialogVtbl* lpVtbl;
};
#endif
#ifndef __IFileOpenDialog_INTERFACE_DEFINED__
#define __IFileOpenDialog_INTERFACE_DEFINED__
DEFINE_GUID(IID_IFileOpenDialog, 0xd57c7288, 0xd4ad, 0x4768, 0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60);
typedef struct IFileOpenDialogVtbl {
BEGIN_INTERFACE
/*** IUnknown methods ***/
HRESULT(STDMETHODCALLTYPE *QueryInterface)(
IFileOpenDialog* This,
REFIID riid,
void **ppvObject);
ULONG(STDMETHODCALLTYPE *AddRef)(
IFileOpenDialog* This);
ULONG(STDMETHODCALLTYPE *Release)(
IFileOpenDialog* This);
/*** IModalWindow methods ***/
HRESULT(STDMETHODCALLTYPE *Show)(
IFileOpenDialog* This,
HWND hwndOwner);
/*** IFileDialog methods ***/
HRESULT(STDMETHODCALLTYPE *SetFileTypes)(
IFileOpenDialog* This,
UINT cFileTypes,
const COMDLG_FILTERSPEC *rgFilterSpec);
HRESULT(STDMETHODCALLTYPE *SetFileTypeIndex)(
IFileOpenDialog* This,
UINT iFileType);
HRESULT(STDMETHODCALLTYPE *GetFileTypeIndex)(
IFileOpenDialog* This,
UINT *piFileType);
HRESULT(STDMETHODCALLTYPE *Advise)(
IFileOpenDialog* This,
IFileDialogEvents *pfde,
DWORD *pdwCookie);
HRESULT(STDMETHODCALLTYPE *Unadvise)(
IFileOpenDialog* This,
DWORD dwCookie);
HRESULT(STDMETHODCALLTYPE *SetOptions)(
IFileOpenDialog* This,
FILEOPENDIALOGOPTIONS fos);
HRESULT(STDMETHODCALLTYPE *GetOptions)(
IFileOpenDialog* This,
FILEOPENDIALOGOPTIONS *pfos);
HRESULT(STDMETHODCALLTYPE *SetDefaultFolder)(
IFileOpenDialog* This,
IShellItem *psi);
HRESULT(STDMETHODCALLTYPE *SetFolder)(
IFileOpenDialog* This,
IShellItem *psi);
HRESULT(STDMETHODCALLTYPE *GetFolder)(
IFileOpenDialog* This,
IShellItem **ppsi);
HRESULT(STDMETHODCALLTYPE *GetCurrentSelection)(
IFileOpenDialog* This,
IShellItem **ppsi);
HRESULT(STDMETHODCALLTYPE *SetFileName)(
IFileOpenDialog* This,
LPCWSTR pszName);
HRESULT(STDMETHODCALLTYPE *GetFileName)(
IFileOpenDialog* This,
LPWSTR *pszName);
HRESULT(STDMETHODCALLTYPE *SetTitle)(
IFileOpenDialog* This,
LPCWSTR pszTitle);
HRESULT(STDMETHODCALLTYPE *SetOkButtonLabel)(
IFileOpenDialog* This,
LPCWSTR pszText);
HRESULT(STDMETHODCALLTYPE *SetFileNameLabel)(
IFileOpenDialog* This,
LPCWSTR pszLabel);
HRESULT(STDMETHODCALLTYPE *GetResult)(
IFileOpenDialog* This,
IShellItem **ppsi);
HRESULT(STDMETHODCALLTYPE *AddPlace)(
IFileOpenDialog* This,
IShellItem *psi,
FDAP fdap);
HRESULT(STDMETHODCALLTYPE *SetDefaultExtension)(
IFileOpenDialog* This,
LPCWSTR pszDefaultExtension);
HRESULT(STDMETHODCALLTYPE *Close)(
IFileOpenDialog* This,
HRESULT hr);
HRESULT(STDMETHODCALLTYPE *SetClientGuid)(
IFileOpenDialog* This,
REFGUID guid);
HRESULT(STDMETHODCALLTYPE *ClearClientData)(
IFileOpenDialog* This);
HRESULT(STDMETHODCALLTYPE *SetFilter)(
IFileOpenDialog* This,
IShellItemFilter *pFilter);
/*** IFileOpenDialog methods ***/
HRESULT(STDMETHODCALLTYPE *GetResults)(
IFileOpenDialog* This,
IShellItemArray **ppenum);
HRESULT(STDMETHODCALLTYPE *GetSelectedItems)(
IFileOpenDialog* This,
IShellItemArray **ppsai);
END_INTERFACE
} IFileOpenDialogVtbl;
interface IFileOpenDialog {
CONST_VTBL IFileOpenDialogVtbl* lpVtbl;
};
#endif

View file

@ -46,6 +46,7 @@
<ClInclude Include="..\inc\fat32.h" />
<ClInclude Include="..\inc\file.h" />
<ClInclude Include="..\inc\label_11_char.h" />
<ClInclude Include="..\inc\libintl.h" />
<ClInclude Include="..\inc\mbr_2000.h" />
<ClInclude Include="..\inc\mbr_95b.h" />
<ClInclude Include="..\inc\mbr_dos.h" />
@ -59,6 +60,7 @@
<ClInclude Include="..\inc\mbr_vista.h" />
<ClInclude Include="..\inc\mbr_win7.h" />
<ClInclude Include="..\inc\mbr_zero.h" />
<ClInclude Include="..\inc\nls.h" />
<ClInclude Include="..\inc\ntfs.h" />
<ClInclude Include="..\inc\partition_info.h" />
</ItemGroup>

View file

@ -137,6 +137,12 @@
<ClInclude Include="..\inc\mbr_grub2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\inc\nls.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\inc\libintl.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\br.c">

View file

@ -18,6 +18,7 @@
#include <stdio.h>
#include "file.h"
#include "nls.h"
#include "br.h"
unsigned long ulBytesPerSector = 512;
@ -42,6 +43,28 @@ int write_windows_disk_signature(FILE *fp, uint32_t tWDS)
return write_data(fp, 0x1b8, &tWDS, 4);
} /* write_windows_disk_signature */
uint16_t read_mbr_copy_protect_bytes(FILE *fp)
{
uint16_t tOut;
if(!read_data(fp, 0x1bc, &tOut, 2))
return 0xffff;
return tOut;
} /* read_mbr_copy_protect_bytes */
const char *read_mbr_copy_protect_bytes_explained(FILE *fp)
{
uint16_t t = read_mbr_copy_protect_bytes(fp);
switch(t)
{
case 0:
return _("not copy protected");
case 0x5a5a:
return _("copy protected");
default:
return _("unknown value");
}
} /* read_mbr_copy_protect_bytes_explained */
int is_br(FILE *fp)
{
/* A "file" is probably some kind of boot record if it contains the magic
@ -189,17 +212,6 @@ int is_zero_mbr(FILE *fp)
/* Don't bother to check 55AA signature */
} /* is_zero_mbr */
int is_zero_mbr_with_other_windows_disk_signature(FILE *fp)
{
#include "mbr_zero.h"
return
(!contains_data(fp, 0x0, mbr_zero_0x0, sizeof(mbr_zero_0x0))) &&
contains_data(fp, 0x0, mbr_zero_0x0, 0x1b8);
contains_data(fp, 0x1bc, mbr_zero_0x0, 2);
/* Don't bother to check 55AA signature */
} /* is_zero_mbr_with_other_windows_disk_signature */
int is_zero_mbr_not_including_disk_signature_or_copy_protect(FILE *fp)
{
#include "mbr_zero.h"

View file

@ -13,6 +13,10 @@ uint32_t read_windows_disk_signature(FILE *fp);
/* Sets a new Windows Disk Signature to MBR */
int write_windows_disk_signature(FILE *fp, uint32_t tWDS);
/* Reads copy protect bytes after Windows Disk Signature from MBR */
uint16_t read_mbr_copy_protect_bytes(FILE *fp);
const char *read_mbr_copy_protect_bytes_explained(FILE *fp);
/* returns TRUE if the file has a boot record, otherwise FALSE.
The file position will change when this function is called! */
int is_br(FILE *fp);
@ -77,7 +81,6 @@ int is_syslinux_gpt_mbr(FILE *fp);
/* returns TRUE if the file has a zeroed master boot record, otherwise
FALSE.The file position will change when this function is called! */
int is_zero_mbr(FILE *fp);
int is_zero_mbr_with_other_windows_disk_signature(FILE *fp);
int is_zero_mbr_not_including_disk_signature_or_copy_protect(FILE *fp);
/* Writes a dos master boot record to a file, returns TRUE on success, otherwise

9
src/ms-sys/inc/libintl.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef LIBINTL_H
#define LIBINTL_H
/* This file is only supposed to be used on systems which doesn't have a
builtin libintl.h and which also miss gnu gettext */
#define NO_LIBINTL_OR_GETTEXT
#endif

17
src/ms-sys/inc/nls.h Normal file
View file

@ -0,0 +1,17 @@
#ifndef NLS_H
#define NLS_H
#include <libintl.h>
#ifdef NO_LIBINTL_OR_GETTEXT
#define _(String) (String)
#else
#define _(String) gettext(String)
#endif
#define gettext_noop(String) (String)
#define N_(String) gettext_noop(String)
/* Init Native language support */
void nls_init(void);
#endif

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Networking functionality (web file download, check for update, etc.)
* Copyright © 2012-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,14 +30,16 @@
#include <string.h>
#include <inttypes.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "settings.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "settings.h"
/* Maximum download chunk size, in bytes */
#define DOWNLOAD_BUFFER_SIZE 10240
#define DOWNLOAD_BUFFER_SIZE 10*KB
/* Default delay between update checks (1 day) */
#define DEFAULT_UPDATE_INTERVAL (24*3600)
@ -49,38 +51,9 @@ static DWORD error_code;
static BOOL update_check_in_progress = FALSE;
static BOOL force_update_check = FALSE;
/* MinGW is missing some of those */
#if !defined(ERROR_INTERNET_DISCONNECTED)
#define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163)
#endif
#if !defined(ERROR_INTERNET_SERVER_UNREACHABLE)
#define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164)
#endif
#if !defined(ERROR_INTERNET_PROXY_SERVER_UNREACHABLE)
#define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165)
#endif
#if !defined(ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT)
#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166)
#endif
#if !defined(ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT)
#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167)
#endif
#if !defined(ERROR_INTERNET_FAILED_DUETOSECURITYCHECK)
#define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171)
#endif
#if !defined(ERROR_INTERNET_NOT_INITIALIZED)
#define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172)
#endif
#if !defined(ERROR_INTERNET_NEED_MSN_SSPI_PKG)
#define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173)
#endif
#if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY)
#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174)
#endif
/*
* FormatMessage does not handle internet errors
* http://support.microsoft.com/kb/193625
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa385465.aspx
*/
const char* WinInetErrorString(void)
{
@ -300,7 +273,7 @@ DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog)
uprintf("Network is unavailable: %s\n", WinInetErrorString());
goto out;
}
_snprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (WinNT %d.%d%s)",
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)",
rufus_version[0], rufus_version[1], rufus_version[2],
nWindowsVersion>>4, nWindowsVersion&0x0F, is_x64()?"; WOW64":"");
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
@ -429,9 +402,9 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
BOOL releases_only, found_new_version = FALSE;
int status = 0;
const char* server_url = RUFUS_URL "/";
int i, j, k, verbose = 0, verpos[4];
int i, j, k, max_channel, verbose = 0, verpos[4];
static const char* archname[] = {"win_x86", "win_x64"};
static const char* channel[] = {"release", "beta"}; // release channel
static const char* channel[] = {"release", "beta", "test"}; // release channel
const char* accept_types[] = {"*/*\0", NULL};
DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize, dwStatus;
char* buf = NULL;
@ -474,8 +447,6 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
vvuprintf("Local time: %" PRId64 "\n", local_time);
if (local_time < reg_time + update_interval) {
vuprintf("Next update check in %" PRId64 " seconds.\n", reg_time + update_interval - local_time);
// This is as good a place as any to ask for translation help
LostTranslatorCheck();
goto out;
}
}
@ -493,7 +464,9 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
goto out;
hostname[sizeof(hostname)-1] = 0;
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d", rufus_version[0], rufus_version[1], rufus_version[2]);
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)",
rufus_version[0], rufus_version[1], rufus_version[2],
nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : "");
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hSession == NULL)
goto out;
@ -504,7 +477,13 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
status++; // 2
releases_only = !ReadSettingBool(SETTING_INCLUDE_BETAS);
for (k=0; (k<(releases_only?1:(int)ARRAYSIZE(channel))) && (!found_new_version); k++) {
// Test releases get their own distribution channel (and also force beta checks)
#if defined(TEST)
max_channel = (int)ARRAYSIZE(channel);
#else
max_channel = releases_only ? 1 : (int)ARRAYSIZE(channel) - 1;
#endif
for (k=0; (k<max_channel) && (!found_new_version); k++) {
uprintf("Checking %s channel...\n", channel[k]);
// At this stage we can query the server for various update version files.
// We first try to lookup for "<appname>_<os_arch>_<os_version_major>_<os_version_minor>.ver"

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Elementary Unicode compliant find/replace parser
* Copyright © 2012-2014 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,6 +32,7 @@
#include <fcntl.h>
#include "rufus.h"
#include "missing.h"
#include "msapi_utf8.h"
#include "localization.h"
@ -41,8 +42,6 @@ static const char* conversion_error = "Could not convert '%s' to UTF-16";
const struct {char c; int flag;} attr_parse[] = {
{ 'r', LOC_RIGHT_TO_LEFT },
{ 'a', LOC_ARABIC_NUMERALS }, // NOT IMPLEMENTED
{ 'j', LOC_JAPANESE_NUMERALS }, // NOT IMPLEMENTED
};
/*
@ -239,13 +238,12 @@ BOOL get_supported_locales(const char* filename)
FILE* fd = NULL;
BOOL r = FALSE;
char line[1024];
char* LT[] = LOST_TRANSLATORS; //just to get the arraysize...
size_t i, j, k;
loc_cmd *lcmd = NULL, *last_lcmd = NULL;
long end_of_block;
int version_line_nr = 0;
uint32_t loc_base_minor = -1, loc_base_micro = -1;
fd = open_loc_file(filename);
if (fd == NULL)
goto out;
@ -344,18 +342,11 @@ BOOL get_supported_locales(const char* filename)
LOC_FRAMEWORK_VERSION, loc_base_minor);
} else {
if (lcmd->unum[2] < loc_base_micro) {
last_lcmd->ctrl_id |= LOC_NEEDS_UPDATE;
luprintf("the version of this translation is older than the base one and may result in some messages not being properly translated.\n"
"If you are the translator, please update your translation with the changes that intervened between v%d.%d.%d and v%d.%d.%d.\n"
"See https://github.com/pbatard/rufus/blob/master/res/localization/ChangeLog.txt",
"See https://github.com/pbatard/rufus/blob/master/res/localization/ChangeLog.txt",
LOC_FRAMEWORK_VERSION, loc_base_minor, lcmd->unum[2], LOC_FRAMEWORK_VERSION, loc_base_minor, loc_base_micro);
} else if (lcmd->unum[2] >= loc_base_micro) {
// Don't bug users about a locale that may already have been upgraded
for (i=0; i<ARRAYSIZE(LT); i++) {
if (safe_strcmp(last_lcmd->txt[0], lost_translators[i]) == 0) {
uprintf("NOTE: This translation appears up to date - Removing it from LOST_TRANSLATORS");
lost_translators[i][0] = 0;
}
}
}
version_line_nr = loc_line_nr;
}
@ -374,7 +365,7 @@ BOOL get_supported_locales(const char* filename)
}
r = !list_empty(&locale_list);
if (r == FALSE)
uprintf("localization: '%s' contains no valid locale sections\n", filename);
uprintf("localization: '%s' contains no valid locale sections\n", filename);
out:
if (fd != NULL)
@ -576,7 +567,7 @@ out:
/*
* Parse a line of UTF-16 text and return the data if it matches the 'token'
* The parsed line is of the form: [ ]token[ ]=[ ]["]data["][ ] and is
* The parsed line is of the form: [ ]token[ ]=[ ]["]data["][ ] and is
* modified by the parser
*/
static wchar_t* get_token_data_line(const wchar_t* wtoken, wchar_t* wline)
@ -603,7 +594,7 @@ static wchar_t* get_token_data_line(const wchar_t* wtoken, wchar_t* wline)
i += wcsspn(&wline[i], wspace);
// Check for an equal sign
if (wline[i] != L'=')
if (wline[i] != L'=')
return NULL;
i++;
@ -1006,7 +997,7 @@ char* insert_section_data(const char* filename, const char* section, const char*
break;
}
fseek(fd_in, 0, SEEK_SET);
// duprintf("'%s' was detected as %s\n", filename,
// duprintf("'%s' was detected as %s\n", filename,
// (mode==0)?"ANSI/UTF8 (no BOM)":((mode==1)?"UTF8 (with BOM)":"UTF16 (with BOM"));
wtmpname = (wchar_t*)calloc(wcslen(wfilename)+2, sizeof(wchar_t));
@ -1145,7 +1136,7 @@ char* replace_in_token_data(const char* filename, const char* token, const char*
break;
}
fseek(fd_in, 0, SEEK_SET);
// duprintf("'%s' was detected as %s\n", filename,
// duprintf("'%s' was detected as %s\n", filename,
// (mode==0)?"ANSI/UTF8 (no BOM)":((mode==1)?"UTF8 (with BOM)":"UTF16 (with BOM"));

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* PKI functions (code signing, etc.)
* Copyright © 2015 Pete Batard <pete@akeo.ie>
* Copyright © 2015-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,8 +29,8 @@
#include <wintrust.h>
#include "rufus.h"
#include "msapi_utf8.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)

View file

@ -54,13 +54,14 @@ static __inline BOOL DeleteRegistryKey(HKEY key_root, const char* key_name)
the application and create the app subkey if required */
static __inline BOOL _GetRegistryKey(HKEY key_root, const char* key_name, DWORD reg_type, LPBYTE dest, DWORD dest_size)
{
const char software_prefix[] = "SOFTWARE\\";
char long_key_name[MAX_PATH] = { 0 };
BOOL r = FALSE;
size_t i = 0;
size_t i;
LONG s;
HKEY hSoftware = NULL, hApp = NULL;
DWORD dwDisp, dwType = -1, dwSize = dest_size;
// VS Code Analysis complains if we don't break our initialization into chars
char long_key_name[256] = { 0 };
memset(dest, 0, dest_size);
if (key_name == NULL)
@ -72,9 +73,15 @@ static __inline BOOL _GetRegistryKey(HKEY key_root, const char* key_name, DWORD
}
if (i != 0) {
strcpy(long_key_name, "SOFTWARE\\");
safe_strcat(long_key_name, sizeof(long_key_name), key_name);
long_key_name[sizeof("SOFTWARE\\") + i-1] = 0;
// Prefix with "SOFTWARE" if needed
if (_strnicmp(key_name, software_prefix, sizeof(software_prefix) - 1) != 0) {
strcpy(long_key_name, software_prefix);
safe_strcat(long_key_name, sizeof(long_key_name), key_name);
long_key_name[sizeof(software_prefix) + i - 1] = 0;
} else {
safe_strcpy(long_key_name, sizeof(long_key_name), key_name);
long_key_name[i] = 0;
}
i++;
if (RegOpenKeyExA(key_root, long_key_name, 0, KEY_READ, &hApp) != ERROR_SUCCESS) {
hApp = NULL;
@ -94,7 +101,7 @@ static __inline BOOL _GetRegistryKey(HKEY key_root, const char* key_name, DWORD
s = RegQueryValueExA(hApp, &key_name[i], NULL, &dwType, (LPBYTE)dest, &dwSize);
// No key means default value of 0 or empty string
if ((s == ERROR_FILE_NOT_FOUND) || ((s == ERROR_SUCCESS) && (dwType = reg_type) && (dwSize > 0))) {
if ((s == ERROR_FILE_NOT_FOUND) || ((s == ERROR_SUCCESS) && (dwType == reg_type) && (dwSize > 0))) {
r = TRUE;
}
out:
@ -108,25 +115,57 @@ out:
/* Write a generic registry key value (create the key if it doesn't exist) */
static __inline BOOL _SetRegistryKey(HKEY key_root, const char* key_name, DWORD reg_type, LPBYTE src, DWORD src_size)
{
const char software_prefix[] = "SOFTWARE\\";
char long_key_name[MAX_PATH] = { 0 };
BOOL r = FALSE;
HKEY hSoftware = NULL, hApp = NULL;
size_t i;
HKEY hRoot = NULL, hApp = NULL;
DWORD dwDisp, dwType = reg_type;
if (RegOpenKeyExA(key_root, "SOFTWARE", 0, KEY_READ|KEY_CREATE_SUB_KEY, &hSoftware) != ERROR_SUCCESS) {
hSoftware = NULL;
goto out;
}
if (RegCreateKeyExA(hSoftware, COMPANY_NAME "\\" APPLICATION_NAME, 0, NULL, 0,
KEY_SET_VALUE|KEY_QUERY_VALUE|KEY_CREATE_SUB_KEY, NULL, &hApp, &dwDisp) != ERROR_SUCCESS) {
hApp = NULL;
if (key_name == NULL)
return FALSE;
if (RegOpenKeyExA(key_root, NULL, 0, KEY_READ|KEY_CREATE_SUB_KEY, &hRoot) != ERROR_SUCCESS) {
hRoot = NULL;
goto out;
}
r = (RegSetValueExA(hApp, key_name, 0, dwType, src, src_size) == ERROR_SUCCESS);
// Find if we're dealing with a short key
for (i = safe_strlen(key_name); i>0; i--) {
if (key_name[i] == '\\')
break;
}
if (i == 0) {
// If this is a short key name, store the value under our app sub-hive
if (RegCreateKeyExA(hRoot, "SOFTWARE\\" COMPANY_NAME "\\" APPLICATION_NAME, 0, NULL, 0,
KEY_SET_VALUE | KEY_QUERY_VALUE | KEY_CREATE_SUB_KEY, NULL, &hApp, &dwDisp) != ERROR_SUCCESS) {
hApp = NULL;
goto out;
}
} else {
// Prefix with "SOFTWARE" if needed
if (_strnicmp(key_name, software_prefix, sizeof(software_prefix) - 1) != 0) {
strcpy(long_key_name, software_prefix);
safe_strcat(long_key_name, sizeof(long_key_name), key_name);
long_key_name[sizeof(software_prefix) + i - 1] = 0;
} else {
safe_strcpy(long_key_name, sizeof(long_key_name), key_name);
long_key_name[i] = 0;
}
i++;
if (RegCreateKeyExA(hRoot, long_key_name, 0, NULL, 0,
KEY_SET_VALUE | KEY_QUERY_VALUE | KEY_CREATE_SUB_KEY, NULL, &hApp, &dwDisp) != ERROR_SUCCESS) {
hApp = NULL;
goto out;
}
}
r = (RegSetValueExA(hApp, &key_name[i], 0, dwType, src, src_size) == ERROR_SUCCESS);
out:
if (hSoftware != NULL)
RegCloseKey(hSoftware);
if (hRoot != NULL)
RegCloseKey(hRoot);
if (hApp != NULL)
RegCloseKey(hApp);
return r;

View file

@ -35,59 +35,23 @@
#include <io.h>
#include <getopt.h>
#include "msapi_utf8.h"
#include "resource.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "drive.h"
#include "settings.h"
#include "localization.h"
#include "bled/bled.h"
#include "../res/grub/grub_version.h"
#include "../res/grub2/grub2_version.h"
/* Redefinitions for WDK and MinGW */
// TODO: these would be better in a 'missing.h' file
#ifndef PBM_SETSTATE
#define PBM_SETSTATE (WM_USER+16)
#endif
#ifndef PBST_NORMAL
#define PBST_NORMAL 1
#endif
#ifndef PBST_ERROR
#define PBST_ERROR 2
#endif
#ifndef PBST_PAUSED
#define PBST_PAUSED 3
#endif
#ifndef BUTTON_IMAGELIST_ALIGN_CENTER
#define BUTTON_IMAGELIST_ALIGN_CENTER 4
#endif
#ifndef BCM_SETIMAGELIST
#define BCM_SETIMAGELIST 0x1602
#endif
#ifndef DBT_CUSTOMEVENT
#define DBT_CUSTOMEVENT 0x8006
#endif
#ifndef ERROR_FILE_TOO_LARGE
#define ERROR_FILE_TOO_LARGE 223
#endif
struct {
HIMAGELIST himl;
RECT margin;
UINT uAlign;
} bi_iso = {0}, bi_up = {0}, bi_down = {0}; // BUTTON_IMAGELIST
typedef struct
{
LPCITEMIDLIST pidl;
BOOL fRecursive;
} MY_SHChangeNotifyEntry;
// MinGW doesn't know these
PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int));
PF_TYPE(WINAPI, int, ImageList_AddIcon, (HIMAGELIST, HICON));
PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON));
// WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't.
PF_DECL(ImageList_Create);
PF_DECL(ImageList_AddIcon);
@ -122,7 +86,6 @@ static HBRUSH hInfoBrush;
static WNDPROC info_original_proc = NULL;
char ClusterSizeLabel[MAX_CLUSTER_SIZES][64];
char msgbox[1024], msgbox_title[32], *ini_file = NULL;
char lost_translators[][6] = LOST_TRANSLATORS;
/*
* Globals
@ -130,6 +93,8 @@ char lost_translators[][6] = LOST_TRANSLATORS;
OPENED_LIBRARIES_VARS;
HINSTANCE hMainInstance;
HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL;
MY_BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 };
GetTickCount64_t pfGetTickCount64 = NULL;
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
char* image_path = NULL;
float fScale = 1.0f;
@ -143,7 +108,7 @@ BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, tog
BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE;
BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE;
BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps;
BOOL zero_drive = FALSE;
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE;
int dialog_showing = 0, lang_button_id = 0;
uint16_t rufus_version[3], embedded_sl_version[2];
char embedded_sl_version_str[2][12] = { "?.??", "?.??" };
@ -184,11 +149,6 @@ static __inline void SetComboEntry(HWND hDlg, int data) {
}
}
#define KB 1024LL
#define MB 1048576LL
#define GB 1073741824LL
#define TB 1099511627776LL
/*
* Fill in the cluster size names
*/
@ -218,10 +178,6 @@ static BOOL DefineClusterSizes(void)
default_fs = FS_UNKNOWN;
memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize));
if (SelectedDrive.DiskSize < 8*MB) {
uprintf("Device was eliminated because it is smaller than 8 MB\n");
goto out;
}
/*
* The following are MS's allowed cluster sizes for FAT16 and FAT32:
@ -286,7 +242,7 @@ static BOOL DefineClusterSizes(void)
if ((SelectedDrive.DiskSize >= 256*MB) && (SelectedDrive.DiskSize < 32*GB)) {
for (i=8; i<=32; i<<=1) { // 256 MB -> 32 GB
if (SelectedDrive.DiskSize*1.0f < i*GB*FAT32_CLUSTER_THRESHOLD) {
SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i/2)*1024;
SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i/2)*KB;
break;
}
}
@ -303,7 +259,7 @@ static BOOL DefineClusterSizes(void)
SelectedDrive.ClusterSize[FS_NTFS].Allowed = 0x0001FE00;
for (i=16; i<=256; i<<=1) { // 7 MB -> 256 TB
if (SelectedDrive.DiskSize < i*TB) {
SelectedDrive.ClusterSize[FS_NTFS].Default = ((ULONG)i/4)*1024;
SelectedDrive.ClusterSize[FS_NTFS].Default = ((ULONG)i/4)*KB;
break;
}
}
@ -312,11 +268,11 @@ static BOOL DefineClusterSizes(void)
if (nWindowsVersion > WINDOWS_XP) {
SelectedDrive.ClusterSize[FS_EXFAT].Allowed = 0x03FFFE00;
if (SelectedDrive.DiskSize < 256*MB) // < 256 MB
SelectedDrive.ClusterSize[FS_EXFAT].Default = 4*1024;
SelectedDrive.ClusterSize[FS_EXFAT].Default = 4*KB;
else if (SelectedDrive.DiskSize < 32*GB) // < 32 GB
SelectedDrive.ClusterSize[FS_EXFAT].Default = 32*1024;
SelectedDrive.ClusterSize[FS_EXFAT].Default = 32*KB;
else
SelectedDrive.ClusterSize[FS_EXFAT].Default = 28*1024;
SelectedDrive.ClusterSize[FS_EXFAT].Default = 128*KB;
}
// UDF (only supported for Vista and later)
@ -334,7 +290,6 @@ static BOOL DefineClusterSizes(void)
}
}
out:
// Only add the filesystems we can service
for (fs=0; fs<FS_MAX; fs++) {
// Remove all cluster sizes that are below the sector size
@ -366,10 +321,6 @@ out:
return r;
}
#undef KB
#undef MB
#undef GB
#undef TB
/*
* Populate the Allocation unit size field
@ -645,7 +596,7 @@ static void SetTargetSystem(void)
static void SetProposedLabel(int ComboIndex)
{
const char no_label[] = STR_NO_LABEL;
const char no_label[] = STR_NO_LABEL, empty[] = "";
int bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
app_changed_label = TRUE;
@ -671,7 +622,7 @@ static void SetProposedLabel(int ComboIndex)
}
// Else if no existing label is available, propose one according to the size (eg: "256MB", "8GB")
if ((safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0) || (safe_stricmp(no_label, "") == 0)
if ((safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0) || (safe_stricmp(no_label, empty) == 0)
|| (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0)) {
SetWindowTextU(hLabel, SelectedDrive.proposed_label);
} else {
@ -693,10 +644,12 @@ static BOOL PopulateProperties(int ComboIndex)
memset(&SelectedDrive, 0, sizeof(SelectedDrive));
if (ComboIndex < 0)
return TRUE;
goto out;
if (!SetDriveInfo(ComboIndex)) // This also populates FS
if (!SetDriveInfo(ComboIndex)) { // This also populates FS
SetProposedLabel(-1);
return FALSE;
}
SetTargetSystem();
SetFSFromISO();
EnableBootOptions(TRUE, TRUE);
@ -714,8 +667,8 @@ static BOOL PopulateProperties(int ComboIndex)
free(device_tooltip);
}
out:
SetProposedLabel(ComboIndex);
return TRUE;
}
@ -810,6 +763,7 @@ static void InitProgress(BOOL bOnlyFormat)
void UpdateProgress(int op, float percent)
{
int pos;
static uint64_t LastRefresh = 0;
if ((op < 0) || (op >= OP_MAX)) {
duprintf("UpdateProgress: invalid op %d\n", op);
@ -841,8 +795,12 @@ void UpdateProgress(int op, float percent)
pos = MAX_PROGRESS;
}
SendMessage(hProgress, PBM_SETPOS, (WPARAM)pos, 0);
SetTaskbarProgressValue(pos, MAX_PROGRESS);
// Reduce the refresh rate, to avoid weird effects on the sliding part of progress bar
if (_GetTickCount64() > LastRefresh + (2 * MAX_REFRESH)) {
LastRefresh = _GetTickCount64();
SendMessage(hProgress, PBM_SETPOS, (WPARAM)pos, 0);
SetTaskbarProgressValue(pos, MAX_PROGRESS);
}
}
/*
@ -879,7 +837,7 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
HFONT hf;
long lfHeight;
long lfHeight, style;
DWORD log_size;
char *log_buffer = NULL, *filepath;
EXT_DECL(log_ext, "rufus.log", __VA_GROUP__("*.log"), __VA_GROUP__("Rufus log"));
@ -887,6 +845,7 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
apply_localization(IDD_LOG, hDlg);
hLog = GetDlgItem(hDlg, IDC_LOG_EDIT);
// Increase the size of our log textbox to MAX_LOG_SIZE (unsigned word)
PostMessage(hLog, EM_LIMITTEXT, MAX_LOG_SIZE , 0);
// Set the font to Unicode so that we can display anything
@ -899,6 +858,18 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
SendDlgItemMessageA(hDlg, IDC_LOG_EDIT, WM_SETFONT, (WPARAM)hf, TRUE);
// Set 'Close Log' as the selected button
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDCANCEL), TRUE);
// Suppress any inherited RTL flags from our edit control's style. Otherwise
// the displayed text becomes a mess due to Windows trying to interpret
// dots, parenthesis, columns and so on in an RTL context...
// We also take this opportunity to fix the scroll bar and text alignment.
style = GetWindowLong(hLog, GWL_EXSTYLE);
style &= ~(WS_EX_RTLREADING | WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR);
SetWindowLong(hLog, GWL_EXSTYLE, style);
style = GetWindowLong(hLog, GWL_STYLE);
style &= ~(ES_RIGHT);
SetWindowLong(hLog, GWL_STYLE, style);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
@ -980,68 +951,41 @@ static void CALLBACK BlockingTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD
}
}
// Randomly nag users about translations that have been left behind
void LostTranslatorCheck(void)
{
char *p;
char* lang = safe_strdup(selected_locale->txt[1]);
int i, r = rand() * LOST_TRANSLATOR_PROBABILITY / RAND_MAX;
for (i=0; i<ARRAYSIZE(lost_translators); i++)
if (strcmp(selected_locale->txt[0], lost_translators[i]) == 0)
break;
if ((r == 0) && (i != ARRAYSIZE(lost_translators)) && (lang != NULL) && ((p = strchr(lang, '(')) != NULL)) {
p[-1] = 0;
safe_sprintf(msgbox, sizeof(msgbox), "Note: The %s translation requires an update, but the original "
"translator is no longer contributing to it...\nIf you can read English and want to help complete "
"this translation, please visit: http://rufus.akeo.ie/translate.", lang);
MessageBoxU(hMainDialog, msgbox, "Translation help needed", MB_OK|MB_ICONINFORMATION);
}
safe_free(lang);
}
// Report the features of the selected ISO images
static const char* YesNo(BOOL b) {
return (b) ? "Yes" : "No";
}
#define PRINT_ISO_PROP(b, ...) do {if (b) uprintf(__VA_ARGS__);} while(0)
static void DisplayISOProps(void)
{
int i;
char isolinux_str[16] = "No";
if (HAS_SYSLINUX(img_report)) {
safe_sprintf(isolinux_str, sizeof(isolinux_str), "Yes (%s)", img_report.sl_version_str);
}
// TODO: Only report features that are present
uprintf("ISO label: '%s'", img_report.label);
uprintf(" Size: %" PRIu64 " bytes", img_report.projected_size);
uprintf(" Has a >64 chars filename: %s", YesNo(img_report.has_long_filename));
uprintf(" Has Symlinks: %s", YesNo(img_report.has_symlinks));
uprintf(" Has a >4GB file: %s", YesNo(img_report.has_4GB_file));
uprintf(" Uses Bootmgr: %s", YesNo(img_report.has_bootmgr));
uprintf(" Uses EFI: %s%s", YesNo(img_report.has_efi), IS_WIN7_EFI(img_report) ? " (win7_x64)" : "");
uprintf(" Uses Grub 2: %s", YesNo(img_report.has_grub2));
uprintf(" Uses Grub4DOS: %s", YesNo(img_report.has_grub4dos));
uprintf(" Uses isolinux: %s", isolinux_str);
PRINT_ISO_PROP(img_report.has_4GB_file, " Has a >4GB file");
PRINT_ISO_PROP(img_report.has_long_filename, " Has a >64 chars filename");
PRINT_ISO_PROP(HAS_SYSLINUX(img_report), " Uses: Syslinux/Isolinux v%s", img_report.sl_version_str);
if (HAS_SYSLINUX(img_report) && (SL_MAJOR(img_report.sl_version) < 5)) {
for (i = 0; i<NB_OLD_C32; i++) {
uprintf(" With an old %s: %s\n", old_c32_name[i], img_report.has_old_c32[i] ? "Yes" : "No");
PRINT_ISO_PROP(img_report.has_old_c32[i], " With an old %s", old_c32_name[i]);
}
}
uprintf(" Uses KolibriOS: %s", YesNo(img_report.has_kolibrios));
uprintf(" Uses ReactOS: %s", YesNo(IS_REACTOS(img_report)));
uprintf(" Uses WinPE: %s%s", YesNo(IS_WINPE(img_report.winpe)), (img_report.uses_minint) ? " (with /minint)" : "");
PRINT_ISO_PROP(img_report.has_kolibrios, " Uses: KolibriOS");
PRINT_ISO_PROP(IS_REACTOS(img_report), " Uses: ReactOS");
PRINT_ISO_PROP(img_report.has_grub4dos, " Uses: Grub4DOS");
PRINT_ISO_PROP(img_report.has_grub2, " Uses: GRUB2");
PRINT_ISO_PROP(img_report.has_efi, " Uses: EFI %s", IS_WIN7_EFI(img_report) ? "(win7_x64)" : "");
PRINT_ISO_PROP(img_report.has_bootmgr, " Uses: Bootmgr");
PRINT_ISO_PROP(IS_WINPE(img_report.winpe), " Uses: WinPE %s", (img_report.uses_minint) ? "(with /minint)" : "");
if (HAS_INSTALL_WIM(img_report)) {
uprintf(" Uses Install.wim: Yes (version %d.%d.%d)", (img_report.install_wim_version >> 24) & 0xff,
uprintf(" Uses: Install.wim (version %d.%d.%d)", (img_report.install_wim_version >> 24) & 0xff,
(img_report.install_wim_version >> 16) & 0xff, (img_report.install_wim_version >> 8) & 0xff);
// Microsoft somehow managed to make their ESD WIMs incompatible with their own APIs
// (yes, EVEN the Windows 10 APIs), so we must filter them out...
if (img_report.install_wim_version >= MAX_WIM_VERSION)
uprintf(" Note: This WIM version is NOT compatible with Windows To Go");
}
PRINT_ISO_PROP(img_report.has_symlinks, " Note: This ISO uses symbolic links, which will not be replicated due to file system limitations.");
PRINT_ISO_PROP(img_report.has_symlinks, " Because of this, some features from this image may not work...");
// We don't support ToGo on Windows 7 or earlier, for lack of ISO mount capabilities
// TODO: add install.wim extraction workaround for Windows 7
// We don't support ToGo on Windows 7 or earlier, for lack of native ISO mounting capabilities
if (nWindowsVersion >= WINDOWS_8)
if ( ((!togo_mode) && (HAS_TOGO(img_report))) || ((togo_mode) && (!HAS_TOGO(img_report))) )
ToggleToGo();
@ -1060,6 +1004,7 @@ DWORD WINAPI ISOScanThread(LPVOID param)
img_report.is_iso = (BOOLEAN)ExtractISO(image_path, "", TRUE);
img_report.is_bootable_img = (BOOLEAN)IsBootableImage(image_path);
if (!img_report.is_iso && !img_report.is_bootable_img) {
// Failed to scan image
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
PrintInfoDebug(0, MSG_203);
safe_free(image_path);
@ -1075,15 +1020,24 @@ DWORD WINAPI ISOScanThread(LPVOID param)
(img_report.compression_type != BLED_COMPRESSION_NONE) ? "compressed " : "", img_report.is_vhd ? "VHD" : "disk");
selection_default = BT_IMG;
}
if (img_report.is_iso) {
// Will override BT_IMG above for ISOHybrid
selection_default = BT_ISO;
DisplayISOProps();
// If we have an ISOHybrid, but without an ISO method we support, disable ISO support altogether
if ((img_report.is_bootable_img) && (!img_report.has_bootmgr) && (!HAS_SYSLINUX(img_report)) && (!IS_WINPE(img_report.winpe))
&& (!IS_GRUB(img_report)) && (!img_report.has_efi) && (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios)) {
uprintf("This ISOHybrid is not compatible with any of the ISO boot methods we support");
img_report.is_iso = FALSE;
} else {
// Will override BT_IMG above for ISOHybrid
selection_default = BT_ISO;
}
}
// Only enable AFTER we have determined the image type
EnableControls(TRUE);
if ( (!img_report.has_bootmgr) && (!HAS_SYSLINUX(img_report)) && (!IS_WINPE(img_report.winpe)) && (!IS_GRUB(img_report))
&& (!img_report.has_efi) && (!IS_REACTOS(img_report) && (!img_report.has_kolibrios) && (!img_report.is_bootable_img)) ) {
&& (!img_report.has_efi) && (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios) && (!img_report.is_bootable_img) ) {
// No boot method that we support
PrintInfo(0, MSG_081);
safe_free(image_path);
EnableWindow(hStatusToolbar, FALSE);
@ -1519,8 +1473,13 @@ static BOOL BootCheck(void)
}
}
if (syslinux_ldlinux_len[i] == 0) {
uprintf("Could not download the file - cancelling\n");
return FALSE;
// If the version matches our embedded one, try to use that as a last ditch effort
if (img_report.sl_version == embedded_sl_version[1]) {
uprintf("Could not download the file - will try to use embedded %s version instead", img_report.sl_version_str);
} else {
uprintf("Could not download the file - cancelling\n");
return FALSE;
}
}
}
}
@ -1744,7 +1703,13 @@ void InitDialog(HWND hDlg)
uprintf("Syslinux versions: %s%s, %s%s", embedded_sl_version_str[0], embedded_sl_version_ext[0],
embedded_sl_version_str[1], embedded_sl_version_ext[1]);
uprintf("Grub versions: %s, %s", GRUB4DOS_VERSION, GRUB2_PACKAGE_VERSION);
uprintf("Locale ID: 0x%04X", GetUserDefaultUILanguage());
uprintf("System locale ID: 0x%04X", GetUserDefaultUILanguage());
ubpop();
if (selected_locale->ctrl_id & LOC_NEEDS_UPDATE) {
uprintf("NOTE: The %s translation requires an update, but the current translator hasn't submitted "
"one. Because of this, some messages will only be displayed in English.", selected_locale->txt[1]);
uprintf("If you think you can help update this translation, please e-mail the author of this application");
}
SetClusterSizeLabels();
@ -1855,9 +1820,8 @@ void InitDialog(HWND hDlg)
rcSelectImage.right - rcSelectImage.left, rcBootType.bottom - rcBootType.top + 2, SWP_NOZORDER);
// The things one needs to do to keep things looking good...
if (nWindowsVersion == WINDOWS_7) {
ResizeMoveCtrl(hDlg, GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), 0, -1, 0, 2, fScale);
ResizeMoveCtrl(hDlg, hProgress, 0, 1, 0, 0, fScale);
if (fScale > 1.4f) {
ResizeMoveCtrl(hDlg, GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), 0, +1, 0, 0, fScale);
}
// Subclass the Info box so that we can align its text vertically
@ -1925,9 +1889,9 @@ void InitDialog(HWND hDlg)
PrintInfo(0, MSG_210);
}
static void PrintStatus2000(const char* str, BOOL val)
static void PrintStatusTimeout(const char* str, BOOL val)
{
PrintStatus(2000, (val)?MSG_250:MSG_251, str);
PrintStatus(STATUS_MSG_TIMEOUT, (val)?MSG_250:MSG_251, str);
}
void ShowLanguageMenu(RECT rcExclude)
@ -2085,18 +2049,22 @@ void SaveVHD(void)
*/
static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static DWORD DeviceNum = 0, LastRefresh = 0;
static DWORD DeviceNum = 0;
static uint64_t LastRefresh = 0;
static BOOL first_log_display = TRUE, isMarquee = FALSE;
static ULONG ulRegister = 0;
static LPITEMIDLIST pidlDesktop = NULL;
static MY_SHChangeNotifyEntry NotifyEntry;
static DWORD_PTR thread_affinity[4];
DRAWITEMSTRUCT* pDI;
HDROP droppedFileInfo;
POINT Point;
RECT DialogRect, DesktopRect, LangToolbarRect;
LONG progress_style;
HDC hDC;
int nDeviceIndex, fs, tt, i, nWidth, nHeight, nb_devices, selected_language, offset;
char tmp[128];
wchar_t* wbuffer = NULL;
loc_cmd* lcmd = NULL;
EXT_DECL(img_ext, NULL, __VA_GROUP__("*.img;*.vhd;*.gz;*.bzip2;*.xz;*.lzma;*.Z;*.zip"), __VA_GROUP__(lmprintf(MSG_095)));
EXT_DECL(iso_ext, NULL, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036)));
@ -2123,15 +2091,15 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case DBT_DEVICEARRIVAL:
case DBT_DEVICEREMOVECOMPLETE:
case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change
LastRefresh = GetTickCount(); // Don't care about 49.7 days rollback of GetTickCount()
LastRefresh = _GetTickCount64();
KillTimer(hMainDialog, TID_REFRESH_TIMER);
GetUSBDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)));
GetDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)));
user_changed_label = FALSE;
return (INT_PTR)TRUE;
case DBT_DEVNODES_CHANGED:
// If it's been more than a second since last device refresh, arm a refresh timer
if (GetTickCount() > LastRefresh + 1000) {
LastRefresh = GetTickCount();
if (_GetTickCount64() > LastRefresh + 1000) {
LastRefresh = _GetTickCount64();
SetTimer(hMainDialog, TID_REFRESH_TIMER, 1000, RefreshTimer);
}
break;
@ -2156,7 +2124,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
log_displayed = FALSE;
hLogDlg = MyCreateDialog(hMainInstance, IDD_LOG, hDlg, (DLGPROC)LogProc);
InitDialog(hDlg);
GetUSBDevices(0);
GetDevices(0);
CheckForUpdates(FALSE);
// Register MEDIA_INSERTED/MEDIA_REMOVED notifications for card readers
if ((pfSHChangeNotifyRegister != NULL) && (SUCCEEDED(SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidlDesktop)))) {
@ -2426,7 +2394,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
return (INT_PTR)TRUE;
case IDC_SELECT_ISO:
if (iso_provided) {
uprintf("Image provided: '%s'\n", image_path);
uprintf("\r\nImage provided: '%s'", image_path);
iso_provided = FALSE; // One off thing...
} else {
safe_free(image_path);
@ -2460,8 +2428,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case IDC_ENABLE_FIXED_DISKS:
if ((HIWORD(wParam)) == BN_CLICKED) {
enable_HDDs = !enable_HDDs;
PrintStatus2000(lmprintf(MSG_253), enable_HDDs);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_253), enable_HDDs);
GetDevices(0);
}
break;
case IDC_START:
@ -2572,7 +2540,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
// Disable all controls except cancel
EnableControls(FALSE);
InitProgress(FALSE);
format_thid = CreateThread(NULL, 0, SumThread, NULL, 0, NULL);
SetThreadAffinity(thread_affinity, NUM_CHECKSUMS + 1);
format_thid = CreateThread(NULL, 0, SumThread, (LPVOID)thread_affinity, 0, NULL);
if (format_thid != NULL) {
PrintInfo(0, -1);
timer = 0;
@ -2613,12 +2582,42 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break;
case WM_DROPFILES:
droppedFileInfo = (HDROP)wParam;
wbuffer = calloc(MAX_PATH, sizeof(wchar_t));
if (wbuffer == NULL) {
uprintf("Failed to alloc buffer for drag-n-drop");
break;
}
DragQueryFileW(droppedFileInfo, 0, wbuffer, MAX_PATH);
safe_free(image_path);
image_path = wchar_to_utf8(wbuffer);
safe_free(wbuffer);
if (image_path != NULL) {
iso_provided = TRUE;
// Simulate ISO selection click
SendMessage(hDlg, WM_COMMAND, IDC_SELECT_ISO, 0);
}
break;
// This is >>>SUPER WEIRD<<<. After a successful ISO or DD write (e.g. Arch 2016.01)
// we no longer receive WM_QUERYENDSESSION messages, only WM_ENDSESSION.
// But if we do a FreeDOS format, WM_QUERYENDSESSION is still sent to us alright.
// What the heck is going on here?!?
// Also, even as we try to work around this, WM_ENDSESSION comes too late in the game
// to prevent shutdown block. So we need to handle the _undocumented_ WM_CLIENTSHUTDOWN.
case WM_CLOSE:
case WM_CLIENTSHUTDOWN:
case WM_QUERYENDSESSION:
case WM_ENDSESSION:
if (format_thid != NULL) {
// TODO: Do we want to use ShutdownBlockReasonCreate() in Vista and later to stop
// forced shutdown? See https://msdn.microsoft.com/en-us/library/ms700677.aspx
if (format_op_in_progress) {
// WM_QUERYENDSESSION uses this value to prevent shutdown
return (INT_PTR)TRUE;
}
PostQuitMessage(0);
SendMessage(hDlg, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0);
break;
case UM_PROGRESS_INIT:
@ -2670,7 +2669,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
EnableControls(TRUE);
if (wParam) {
uprintf("\r\n");
GetUSBDevices(DeviceNum);
GetDevices(DeviceNum);
}
if (!IS_ERROR(FormatStatus)) {
// This is the only way to achieve instantaneous progress transition to 100%
@ -2776,12 +2775,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
int wait_for_mutex = 0;
FILE* fd;
BOOL attached_console = FALSE, external_loc_file = FALSE, lgp_set = FALSE, automount, disable_hogger = FALSE;
BOOL previous_enable_HDDs = FALSE;
BYTE *loc_data;
DWORD loc_size, size;
char tmp_path[MAX_PATH] = "", loc_file[MAX_PATH] = "", ini_path[MAX_PATH], ini_flags[] = "rb";
char tmp_path[MAX_PATH] = "", loc_file[MAX_PATH] = "", ini_path[MAX_PATH] = "", ini_flags[] = "rb";
char *tmp, *locale_name = NULL, **argv = NULL;
wchar_t **wenv, **wargv;
PF_TYPE_DECL(CDECL, int, __wgetmainargs, (int*, wchar_t***, wchar_t***, int, int*));
PF_TYPE_DECL(WINAPI, BOOL, ChangeWindowMessageFilter, (UINT message, DWORD dwFlag));
HANDLE mutex = NULL, hogmutex = NULL, hFile = NULL;
HWND hDlg = NULL;
HDC hDC;
@ -2796,7 +2797,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
{0, 0, NULL, 0}
};
// Disable loading system DLLs from the current directory (sideloading mitigation)
SetDllDirectoryA("");
uprintf("*** " APPLICATION_NAME " init ***\n");
PF_INIT(GetTickCount64, kernel32);
// Reattach the console, if we were started from commandline
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
@ -2947,12 +2952,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
hFile = CreateFileU(loc_file, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if ((hFile == INVALID_HANDLE_VALUE) || (!WriteFile(hFile, loc_data, loc_size, &size, 0)) || (loc_size != size)) {
uprintf("localization: unable to extract '%s': %s.\n", loc_file, WindowsErrorString());
if ((hFile == INVALID_HANDLE_VALUE) || (!WriteFileWithRetry(hFile, loc_data, loc_size, &size, WRITE_RETRIES))) {
uprintf("localization: unable to extract '%s': %s", loc_file, WindowsErrorString());
safe_closehandle(hFile);
goto out;
}
uprintf("localization: extracted data to '%s'\n", loc_file);
uprintf("localization: extracted data to '%s'", loc_file);
safe_closehandle(hFile);
} else {
safe_sprintf(loc_file, sizeof(loc_file), "%s\\%s", app_dir, rufus_loc);
@ -2962,7 +2967,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if ( (!get_supported_locales(loc_file))
|| ((selected_locale = ((locale_name == NULL)?get_locale_from_lcid(lcid, TRUE):get_locale_from_name(locale_name, TRUE))) == NULL) ) {
uprintf("FATAL: Could not access locale!\n");
uprintf("FATAL: Could not access locale!");
MessageBoxU(NULL, "The locale data is missing or invalid. This application will now exit.",
"Fatal error", MB_ICONSTOP|MB_SYSTEMMODAL);
goto out;
@ -3017,7 +3022,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
uprintf("Failed to enable AutoMount");
}
}
srand((unsigned int)GetTickCount());
srand((unsigned int)_GetTickCount64());
relaunch:
uprintf("localization: using locale '%s'\n", selected_locale->txt[0]);
@ -3037,6 +3042,20 @@ relaunch:
}
if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536))
SetWindowPos(hDlg, HWND_TOP, relaunch_rc.left, relaunch_rc.top, 0, 0, SWP_NOSIZE);
// Enable drag-n-drop through the message filter (for Vista or later)
if (nWindowsVersion >= WINDOWS_VISTA) {
PF_INIT(ChangeWindowMessageFilter, user32);
if (pfChangeWindowMessageFilter != NULL) {
// NB: We use ChangeWindowMessageFilter() here because
// ChangeWindowMessageFilterEx() is not available on Vista
pfChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
pfChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
// CopyGlobalData is needed sine we are running elevated
pfChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);
}
}
ShowWindow(hDlg, SW_SHOWNORMAL);
UpdateWindow(hDlg);
@ -3053,14 +3072,14 @@ relaunch:
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_PERIOD)) {
usb_debug = !usb_debug;
WriteSettingBool(SETTING_ENABLE_USB_DEBUG, usb_debug);
PrintStatus2000(lmprintf(MSG_270), usb_debug);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_270), usb_debug);
GetDevices(0);
continue;
}
// Alt-, => Disable physical drive locking
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_COMMA)) {
lock_drive = !lock_drive;
PrintStatus2000(lmprintf(MSG_282), lock_drive);
PrintStatusTimeout(lmprintf(MSG_282), lock_drive);
continue;
}
// Alt-B => Toggle fake drive detection during bad blocks check
@ -3071,7 +3090,7 @@ relaunch:
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'B')) {
detect_fakes = !detect_fakes;
WriteSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK, !detect_fakes);
PrintStatus2000(lmprintf(MSG_256), detect_fakes);
PrintStatusTimeout(lmprintf(MSG_256), detect_fakes);
continue;
}
// Alt C => Force the update check to be successful
@ -3079,7 +3098,7 @@ relaunch:
// check, so that it always succeeds. This is useful for translators.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'C')) {
force_update = !force_update;
PrintStatus2000(lmprintf(MSG_259), force_update);
PrintStatusTimeout(lmprintf(MSG_259), force_update);
continue;
}
// Alt-D => Delete the NoDriveTypeAutorun key on exit (useful if the app crashed)
@ -3093,7 +3112,7 @@ relaunch:
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'E')) {
allow_dual_uefi_bios = !allow_dual_uefi_bios;
WriteSettingBool(SETTING_ENABLE_WIN_DUAL_EFI_BIOS, allow_dual_uefi_bios);
PrintStatus2000(lmprintf(MSG_266), allow_dual_uefi_bios);
PrintStatusTimeout(lmprintf(MSG_266), allow_dual_uefi_bios);
SetMBRForUEFI(TRUE);
continue;
}
@ -3103,8 +3122,8 @@ relaunch:
// When enabled, Rufus will list and allow the formatting of USB HDDs.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'F')) {
enable_HDDs = !enable_HDDs;
PrintStatus2000(lmprintf(MSG_253), enable_HDDs);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_253), enable_HDDs);
GetDevices(0);
CheckDlgButton(hMainDialog, IDC_ENABLE_FIXED_DISKS, enable_HDDs?BST_CHECKED:BST_UNCHECKED);
continue;
}
@ -3113,7 +3132,7 @@ relaunch:
// DD-mode when writing the data.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'I')) {
enable_iso = !enable_iso;
PrintStatus2000(lmprintf(MSG_262), enable_iso);
PrintStatusTimeout(lmprintf(MSG_262), enable_iso);
if (image_path != NULL) {
iso_provided = TRUE;
dont_display_image_name = TRUE;
@ -3127,27 +3146,27 @@ relaunch:
// a file name). This option allows users to ignore Joliet when using such images.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'J')) {
enable_joliet = !enable_joliet;
PrintStatus2000(lmprintf(MSG_257), enable_joliet);
PrintStatusTimeout(lmprintf(MSG_257), enable_joliet);
continue;
}
// Alt K => Toggle Rock Ridge support for ISO9660 images
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'K')) {
enable_rockridge = !enable_rockridge;
PrintStatus2000(lmprintf(MSG_258), enable_rockridge);
PrintStatusTimeout(lmprintf(MSG_258), enable_rockridge);
continue;
}
// Alt-L => Force Large FAT32 format to be used on < 32 GB drives
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'L')) {
force_large_fat32 = !force_large_fat32;
WriteSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT, force_large_fat32);
PrintStatus2000(lmprintf(MSG_254), force_large_fat32);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_254), force_large_fat32);
GetDevices(0);
continue;
}
// Alt N => Enable NTFS compression
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'N')) {
enable_ntfs_compression = !enable_ntfs_compression;
PrintStatus2000(lmprintf(MSG_260), enable_ntfs_compression);
PrintStatusTimeout(lmprintf(MSG_260), enable_ntfs_compression);
continue;
}
// Alt-R => Remove all the registry keys that may have been created by Rufus
@ -3162,23 +3181,23 @@ relaunch:
// the target USB drive. If this is enabled, the size check is disabled.
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'S')) {
size_check = !size_check;
PrintStatus2000(lmprintf(MSG_252), size_check);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_252), size_check);
GetDevices(0);
continue;
}
// Alt-T => Preserve timestamps when extracting ISO files
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'T')) {
preserve_timestamps = !preserve_timestamps;
WriteSettingBool(SETTING_PRESERVE_TIMESTAMPS, preserve_timestamps);
PrintStatus2000(lmprintf(MSG_269), preserve_timestamps);
PrintStatusTimeout(lmprintf(MSG_269), preserve_timestamps);
continue;
}
// Alt-U => Use PROPER size units, instead of this whole Kibi/Gibi nonsense
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'U')) {
use_fake_units = !use_fake_units;
WriteSettingBool(SETTING_USE_PROPER_SIZE_UNITS, !use_fake_units);
PrintStatus2000(lmprintf(MSG_263), !use_fake_units);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_263), !use_fake_units);
GetDevices(0);
continue;
}
// Alt-V => Save selected device to *UNCOMPRESSED* VHD
@ -3190,8 +3209,8 @@ relaunch:
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'W')) {
enable_vmdk = !enable_vmdk;
WriteSettingBool(SETTING_ENABLE_VMDK_DETECTION, enable_vmdk);
PrintStatus2000(lmprintf(MSG_265), enable_vmdk);
GetUSBDevices(0);
PrintStatusTimeout(lmprintf(MSG_265), enable_vmdk);
GetDevices(0);
continue;
}
// Alt-X => Delete the 'rufus_files' subdirectory
@ -3208,6 +3227,27 @@ relaunch:
PostMessage(hDlg, WM_COMMAND, (WPARAM)IDC_START, 0);
}
// Hazardous cheat modes require Ctrl + Alt
// Ctrl-Alt-F => List non USB removable drives such as eSATA, etc - CAUTION!!!
if ((msg.message == WM_KEYDOWN) && (msg.wParam == 'F') &&
(GetKeyState(VK_CONTROL) & 0x8000) && (GetKeyState(VK_MENU) & 0x8000)) {
list_non_usb_removable_drives = !list_non_usb_removable_drives;
if (list_non_usb_removable_drives) {
previous_enable_HDDs = enable_HDDs;
enable_HDDs = TRUE;
} else {
enable_HDDs = previous_enable_HDDs;
}
CheckDlgButton(hMainDialog, IDC_ENABLE_FIXED_DISKS, enable_HDDs ? BST_CHECKED : BST_UNCHECKED);
PrintStatusTimeout(lmprintf(MSG_287), list_non_usb_removable_drives);
uprintf("%sListing of non-USB removable drives %s",
(list_non_usb_removable_drives)?"CAUTION: ":"", (list_non_usb_removable_drives)?"enabled":"disabled");
if (list_non_usb_removable_drives)
uprintf("By using this unofficial cheat mode you forfeit ANY RIGHT to complain if you lose valuable data!");
GetDevices(0);
continue;
}
// Let the system handle dialog messages (e.g. those from the tab key)
if (!IsDialogMessage(hDlg, &msg) && !IsDialogMessage(hLogDlg, &msg)) {
TranslateMessage(&msg);
@ -3243,14 +3283,15 @@ out:
SetLGP(TRUE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0);
if ((nWindowsVersion > WINDOWS_XP) && (!automount) && (!SetAutoMount(FALSE)))
uprintf("Failed to restore AutoMount to disabled");
// Unconditional delete with retry, just in case...
for (i = 0; (!DeleteFileA(cmdline_hogger)) && (i <= 10); i++)
Sleep(200);
CloseHandle(mutex);
CLOSE_OPENED_LIBRARIES;
if (attached_console) {
SetWindowPos(GetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
FreeConsole();
}
// Unconditional delete, just in case...
DeleteFileA(cmdline_hogger);
CloseHandle(mutex);
CLOSE_OPENED_LIBRARIES;
uprintf("*** " APPLICATION_NAME " exit ***\n");
#ifdef _CRTDBG_MAP_ALLOC
_CrtDumpMemoryLeaks();

View file

@ -1,6 +1,6 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,15 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <windows.h>
#include <winioctl.h> // for DISK_GEOMETRY
#include <malloc.h>
#include <inttypes.h>
#if defined(_MSC_VER)
// Disable some VS2012 Code Analysis warnings
#pragma warning(disable: 4996) // Ignore deprecated (eg. GetVersionEx()), as we have to contend with XP
#pragma warning(disable: 28159) // VS2012 wants us to use GetTickCount64(), but it's not available on XP
#pragma warning(disable: 28159) // We use GetTickCount64() where possible, but it's not available on XP
#pragma warning(disable: 6258) // I know what I'm using TerminateThread for
// Burn in HELL Windows XP!!!
#ifdef DDKBUILD
#if (_WIN32_WINNT < _WIN32_WINNT_VISTA)
#error The Windows XP target is no longer supported for WDK compilation.
#endif
#endif
#endif
#pragma once
@ -33,10 +38,6 @@
#define RUFUS_DEBUG // print debug info to Debug facility
/* Features not ready for prime time and that may *DESTROY* your data - USE AT YOUR OWN RISKS! */
// #define RUFUS_TEST
/* Languages for which translators are M.I.A. and that we could use help with */
#define LOST_TRANSLATORS { "ms-MY" } // NB: locales MUST be <= 5 chars
/* Probability of getting the M.I.A. translator message. For more on this, see LostTranslatorCheck() */
#define LOST_TRANSLATOR_PROBABILITY 1000
#define APPLICATION_NAME "Rufus"
#define COMPANY_NAME "Akeo Consulting"
@ -52,6 +53,7 @@
#define DRIVE_ACCESS_RETRIES 60 // How many times we should retry
#define DRIVE_INDEX_MIN 0x00000080
#define DRIVE_INDEX_MAX 0x000000C0
#define MIN_DRIVE_SIZE 8 // Minimum size a drive must have, to be formattable (in MB)
#define MIN_EXTRA_PART_SIZE (1024*1024) // Minimum size of the extra partition, in bytes
#define MAX_DRIVES (DRIVE_INDEX_MAX - DRIVE_INDEX_MIN)
#define MAX_TOOLTIPS 128
@ -59,11 +61,14 @@
#define MAX_CLUSTER_SIZES 18
#define MAX_PROGRESS (0xFFFF-1) // leave room for 1 more for insta-progress workaround
#define MAX_LOG_SIZE 0x7FFFFFFE
#define MAX_REFRESH 25 // How long we should wait to refresh UI elements (in ms)
#define MAX_GUID_STRING_LENGTH 40
#define MAX_GPT_PARTITIONS 128
#define MAX_SECTORS_TO_CLEAR 128 // nb sectors to zap when clearing the MBR/GPT (must be >34)
#define MBR_UEFI_MARKER 0x49464555 // 'U', 'E', 'F', 'I', as a 32 bit little endian longword
#define STATUS_MSG_TIMEOUT 3500 // How long should cheat mode messages appear for on the status bar
#define WRITE_RETRIES 3
#define NUM_CHECKSUMS 3 // Number of checksum algorithms we support (MD5, SHA1, SHA256)
#define FS_DEFAULT FS_FAT32
#define SINGLE_CLUSTERSIZE_DEFAULT 0x00000100
#define BADBLOCK_PATTERNS {0xaa, 0x55, 0xff, 0x00}
@ -102,7 +107,6 @@
#define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
#define safe_closehandle(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
#define safe_unlockclose(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
#define safe_release_dc(hDlg, hDC) do {if ((hDC != INVALID_HANDLE_VALUE) && (hDC != NULL)) {ReleaseDC(hDlg, hDC); hDC = NULL;}} while(0)
#define safe_sprintf(dst, count, ...) do {_snprintf(dst, count, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0)
#define static_sprintf(dst, ...) safe_sprintf(dst, sizeof(dst), __VA_ARGS__)
@ -117,6 +121,9 @@
#ifdef RUFUS_DEBUG
extern void _uprintf(const char *format, ...);
#define uprintf(...) _uprintf(__VA_ARGS__)
#define ubclear() do { ubuffer[0] = 0; } while (0);
#define ubpushf(...) static_sprintf(ubuffer, __VA_ARGS__)
#define ubpop() uprintf("%s", ubuffer)
#define vuprintf(...) if (verbose) _uprintf(__VA_ARGS__)
#define vvuprintf(...) if (verbose > 1) _uprintf(__VA_ARGS__)
#define suprintf(...) if (!bSilent) _uprintf(__VA_ARGS__)
@ -168,6 +175,8 @@ typedef struct {
enum timer_type {
TID_MESSAGE_INFO = 0x1000,
TID_MESSAGE_STATUS,
TID_OUTPUT_INFO,
TID_OUTPUT_STATUS,
TID_BADBLOCKS_UPDATE,
TID_APP_TIMER,
TID_BLOCKING_TIMER,
@ -223,24 +232,6 @@ enum target_type {
#define GETTARGETTYPE(x) (((x)>0)?(((x) >> 16) & 0xFFFF):0)
#define GETPARTTYPE(x) (((x)>0)?((x) & 0xFFFF):0);
/* Current drive info */
typedef struct {
DWORD DeviceNumber;
LONGLONG DiskSize;
DISK_GEOMETRY Geometry;
DWORD FirstSector;
char proposed_label[16];
int PartitionType;
int nPartitions; // number of partitions we actually care about
int FSType;
BOOL has_protective_mbr;
BOOL has_mbr_uefi_marker;
struct {
ULONG Allowed;
ULONG Default;
} ClusterSize[FS_MAX];
} RUFUS_DRIVE_INFO;
/* Special handling for old .c32 files we need to replace */
#define NB_OLD_C32 2
#define OLD_C32_NAMES { "menu.c32", "vesamenu.c32" }
@ -369,8 +360,7 @@ extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sys
extern char* image_path;
extern DWORD FormatStatus, DownloadStatus;
extern BOOL PromptOnError;
extern DWORD syslinux_ldlinux_len[2];
extern RUFUS_DRIVE_INFO SelectedDrive;
extern unsigned long syslinux_ldlinux_len[2];
extern const int nb_steps[FS_MAX];
extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, iso_op_in_progress, format_op_in_progress, right_to_left_mode;
extern BOOL allow_dual_uefi_bios, togo_mode;
@ -379,6 +369,7 @@ extern int64_t iso_blocking_status;
extern uint16_t rufus_version[3], embedded_sl_version[2];
extern int nWindowsVersion;
extern char WindowsVersionStr[128];
extern char ubuffer[256];
extern char embedded_sl_version_str[2][12];
extern RUFUS_UPDATE update;
extern int dialog_showing;
@ -431,7 +422,7 @@ extern unsigned char* GetResource(HMODULE module, char* name, char* type, const
extern DWORD GetResourceSize(HMODULE module, char* name, char* type, const char* desc);
extern DWORD RunCommand(const char* cmdline, const char* dir, BOOL log);
extern BOOL CompareGUID(const GUID *guid1, const GUID *guid2);
extern BOOL GetUSBDevices(DWORD devnum);
extern BOOL GetDevices(DWORD devnum);
extern BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* szPolicy, DWORD dwValue);
extern LONG GetEntryWidth(HWND hDropDown, const char* entry);
extern DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog);
@ -454,38 +445,19 @@ extern BOOL WimApplyImage(const char* image, int index, const char* dst);
extern BOOL IsBootableImage(const char* path);
extern BOOL AppendVHDFooter(const char* vhd_path);
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);
extern void LostTranslatorCheck(void);
extern LONG ValidateSignature(HWND hDlg, const char* path);
extern BOOL IsFontAvailable(const char* font_name);
extern BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, DWORD nNumRetries);
extern BOOL SetThreadAffinity(DWORD_PTR* thread_affinity, size_t num_threads);
#define printbits(x) _printbits(sizeof(x), &x, 0)
#define printbitslz(x) _printbits(sizeof(x), &x, 1)
extern char* _printbits(size_t const size, void const * const ptr, int leading_zeroes);
DWORD WINAPI FormatThread(void* param);
DWORD WINAPI SaveImageThread(void* param);
DWORD WINAPI SumThread(void* param);
static __inline BOOL UnlockDrive(HANDLE hDrive) {
DWORD size;
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
}
static __inline void *_reallocf(void *ptr, size_t size) {
void *ret = realloc(ptr, size);
if (!ret)
free(ptr);
return ret;
}
static __inline uint16_t bswap_16(uint16_t x) {
return (x >> 8) | (x << 8);
}
static __inline uint32_t bswap_32(uint32_t x) {
return (bswap_16(x & 0xffff) << 16) | (bswap_16(x >> 16));
}
static __inline uint64_t bswap_64(uint64_t x) {
return (((uint64_t) bswap_32(x & 0xffffffffull)) << 32) | (bswap_32(x >> 32));
}
/* Hash tables */
typedef struct htab_entry {
uint32_t used;
@ -552,16 +524,6 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \
#proc, #name, WindowsErrorString()); goto out;} } while(0)
/* Clang/MinGW32 has an issue with intptr_t */
#ifndef _UINTPTR_T_DEFINED
#define _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#endif
/* Custom application errors */
#define FAC(f) (f<<16)
#define APPERR(err) (APPLICATION_ERROR_MASK|err)
@ -578,19 +540,7 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
#define ERROR_CANT_ASSIGN_LETTER 0x120B
#define ERROR_CANT_MOUNT_VOLUME 0x120C
/* More niceties */
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef PBS_MARQUEE
#define PBS_MARQUEE 0x08
#endif
#ifndef PBM_SETMARQUEE
#define PBM_SETMARQUEE (WM_USER+10)
#endif
/* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */
#define _RT_ICON MAKEINTRESOURCEA(3)
#define _RT_DIALOG MAKEINTRESOURCEA(5)
#define _RT_RCDATA MAKEINTRESOURCEA(10)
#define _RT_GROUP_ICON MAKEINTRESOURCEA((ULONG_PTR)(MAKEINTRESOURCEA(3) + 11))
/* GetTickCount64 not being available on XP is a massive bother */
PF_TYPE(WINAPI, ULONGLONG, GetTickCount64, (void));
extern GetTickCount64_t pfGetTickCount64;
#define _GetTickCount64() ((pfGetTickCount64 != NULL)?(uint64_t)pfGetTickCount64():(uint64_t)GetTickCount())

View file

@ -32,7 +32,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.7.830"
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.9.921"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -319,8 +320,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,7,830,0
PRODUCTVERSION 2,7,830,0
FILEVERSION 2,9,921,0
PRODUCTVERSION 2,9,921,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -337,13 +338,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.7.830"
VALUE "FileVersion", "2.9.921"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.7.830"
VALUE "ProductVersion", "2.9.921"
END
END
BLOCK "VarFileInfo"

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Settings access, through either registry or INI file
* Copyright © 2015 Pete Batard <pete@akeo.ie>
* Copyright © 2015-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,11 +27,11 @@ extern char* ini_file;
/*
* List of setting names used by this application
*/
#define SETTING_VERBOSE_UPDATES "VerboseUpdateCheck"
#define SETTING_VERBOSE_UPDATES "VerboseUpdateCheck"
#define SETTING_LAST_UPDATE "LastUpdateCheck"
#define SETTING_UPDATE_INTERVAL "UpdateCheckInterval"
#define SETTING_INCLUDE_BETAS "CheckForBetas"
#define SETTING_COMM_CHECK "CommCheck"
#define SETTING_COMM_CHECK "CommCheck64"
#define SETTING_LOCALE "Locale"
#define SETTING_DISABLE_LGP "DisableLGP"

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* SMART HDD vs Flash detection (using ATA over USB, S.M.A.R.T., etc.)
* Copyright © 2013-2014 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
*
* Based in part on scsiata.cpp from Smartmontools: http://smartmontools.sourceforge.net
* Copyright © 2006-12 Douglas Gilbert <dgilbert@interlog.com>
@ -31,8 +31,10 @@
#include <ctype.h>
#include <stddef.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "missing.h"
#include "msapi_utf8.h"
#include "drive.h"
#include "smart.h"
#include "hdd_vs_ufd.h"
@ -43,7 +45,7 @@ static uint8_t GetAtaDirection(uint8_t AtaCmd, uint8_t Features) {
// Far from complete -- only the commands we *may* use.
// Most SMART commands require DATA_IN but there are a couple exceptions
BOOL smart_out = (AtaCmd == ATA_SMART_CMD) &&
BOOL smart_out = (AtaCmd == ATA_SMART_CMD) &&
((Features == ATA_SMART_STATUS) || (Features == ATA_SMART_WRITE_LOG_SECTOR));
switch (AtaCmd) {
@ -413,7 +415,7 @@ BOOL SmartGetVersion(HANDLE hdevice)
* THUS, IF DATA LOSS IS INCURRED DUE TO THIS, OR ANY OTHER PART OF THIS APPLICATION,
* NOT BEHAVING IN THE MANNER YOU EXPECTED, THE RESPONSIBILITY IS ENTIRELY ON YOU!
*
* What you have below, then, is our *current best guess* at differentiating UFDs
* What you have below, then, is our *current best guess* at differentiating UFDs
* from HDDs. But short of a crystal ball, this remains just a guess, which may be
* way off mark. Still, you are also reminded that Rufus does produce PROMINENT
* warnings before you format a drive, and also provides extensive info about the
@ -426,7 +428,7 @@ BOOL SmartGetVersion(HANDLE hdevice)
* - some UFDs (SanDisk Extreme) have added S.M.A.R.T. support, which also used to be
* reserved for HDDs => can't use that either
* - even if S.M.A.R.T. was enough, not all USB->IDE or USB->SATA bridges support ATA
* passthrough, which is required S.M.A.R.T. data, and each manufacturer of an
* passthrough, which is required S.M.A.R.T. data, and each manufacturer of an
* USB<->(S)ATA bridge seem to have their own method of implementing passthrough.
* - SSDs have also changed the deal completely, as you can get something that looks
* like Flash but that is really an HDD.
@ -436,7 +438,6 @@ BOOL SmartGetVersion(HANDLE hdevice)
* from the above) => there is no magic API we can query that will tell us what we're
* really looking at.
*/
#define GB 1073741824LL
int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid)
{
int score = 0;

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Standard Windows function calls
* Copyright © 2013-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,12 +24,15 @@
#include <windows.h>
#include <sddl.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "settings.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "settings.h"
extern BOOL usb_debug; // For uuprintf
int nWindowsVersion = WINDOWS_UNDEFINED;
char WindowsVersionStr[128] = "Windows ";
@ -800,7 +803,7 @@ BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* s
uprintf("SetLGP: Unable to start thread");
return FALSE;
}
if (WaitForSingleObject(thread_id, 2500) != WAIT_OBJECT_0) {
if (WaitForSingleObject(thread_id, 5000) != WAIT_OBJECT_0) {
uprintf("SetLGP: Killing stuck thread!");
TerminateThread(thread_id, 0);
CloseHandle(thread_id);
@ -810,3 +813,37 @@ BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* s
return FALSE;
return (BOOL) r;
}
/*
* This call tries to evenly balance the affinities for an array of
* num_threads, according to the number of cores at our disposal...
*/
BOOL SetThreadAffinity(DWORD_PTR* thread_affinity, size_t num_threads)
{
size_t i, j, pc;
DWORD_PTR affinity, dummy;
memset(thread_affinity, 0, num_threads * sizeof(DWORD_PTR));
if (!GetProcessAffinityMask(GetCurrentProcess(), &affinity, &dummy))
return FALSE;
uuprintf("\r\nThread affinities:");
uuprintf(" avail:\t%s", printbitslz(affinity));
// If we don't have enough virtual cores to evenly spread our load forget it
pc = popcnt64(affinity);
if (pc < num_threads)
return FALSE;
// Spread the affinity as evenly as we can
thread_affinity[num_threads - 1] = affinity;
for (i = 0; i < num_threads - 1; i++) {
for (j = 0; j < pc / num_threads; j++) {
thread_affinity[i] |= affinity & (-1LL * affinity);
affinity ^= affinity & (-1LL * affinity);
}
uuprintf(" thr_%d:\t%s", i, printbitslz(thread_affinity[i]));
thread_affinity[num_threads - 1] ^= thread_affinity[i];
}
uuprintf(" thr_%d:\t%s", i, printbitslz(thread_affinity[i]));
return TRUE;
}

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Standard User I/O Routines (logging, status, etc.)
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,15 +29,16 @@
#include <ctype.h>
#include <math.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "localization.h"
/*
* Globals
*/
HWND hStatus;
char ubuffer[256]; // Buffer for ubpushf() messages we don't log right away
#ifdef RUFUS_DEBUG
void _uprintf(const char *format, ...)
@ -62,15 +63,45 @@ void _uprintf(const char *format, ...)
// Send output to Windows debug facility
OutputDebugStringA(buf);
// Send output to our log Window
Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE);
Edit_ReplaceSelU(hLog, buf);
// Make sure the message scrolls into view
// (Or see code commented in LogProc:WM_SHOWWINDOW for a less forceful scroll)
SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0));
if ((hLog != NULL) && (hLog != INVALID_HANDLE_VALUE)) {
// Send output to our log Window
Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE);
Edit_ReplaceSelU(hLog, buf);
// Make sure the message scrolls into view
// (Or see code commented in LogProc:WM_SHOWWINDOW for a less forceful scroll)
SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0));
}
}
#endif
// Prints a bitstring of a number of any size, with or without leading zeroes.
// See also the printbits() and printbitslz() helper macros in rufus.h
char *_printbits(size_t const size, void const * const ptr, int leading_zeroes)
{
// sizeof(uintmax_t) so that we have enough space to store whatever is thrown at us
static char str[sizeof(uintmax_t) * 8 + 3];
size_t i;
uint8_t* b = (uint8_t*)ptr;
uintmax_t mask, lzmask = 0, val = 0;
// Little endian, the SCOURGE of any rational computing
for (i = 0; i < size; i++)
val |= ((uintmax_t)b[i]) << (8 * i);
str[0] = '0';
str[1] = 'b';
if (leading_zeroes)
lzmask = 1ULL << (size * 8 - 1);
for (i = 2, mask = 1ULL << (sizeof(uintmax_t) * 8 - 1); mask != 0; mask >>= 1) {
if ((i > 2) || (lzmask & mask))
str[i++] = (val & mask) ? '1' : '0';
else if (val & mask)
str[i++] = '1';
}
str[i] = '\0';
return str;
}
void DumpBufferHex(void *buf, size_t size)
{
unsigned char* buffer = (unsigned char*)buf;
@ -280,3 +311,43 @@ const char* StrError(DWORD error_code, BOOL use_default_locale)
toggle_default_locale();
return ret;
}
BOOL WriteFileWithRetry(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, DWORD nNumRetries)
{
DWORD nTry;
BOOL readFilePointer;
LARGE_INTEGER liFilePointer, liZero = { { 0,0 } };
static char* retry_msg = " - retrying...";
// Need to get the current file pointer in case we need to retry
readFilePointer = SetFilePointerEx(hFile, liZero, &liFilePointer, FILE_CURRENT);
if (!readFilePointer)
uprintf(" Warning - Could not read file pointer: %s", WindowsErrorString());
if (nNumRetries == 0)
nNumRetries = 1;
for (nTry = 1; nTry <= nNumRetries; nTry++) {
// Need to rewind our file position on retry - if we can't even do that, just give up
if ((nTry > 1) && (!SetFilePointerEx(hFile, liFilePointer, NULL, FILE_BEGIN))) {
uprintf(" Could not set file pointer - aborting");
break;
}
if (WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, NULL)) {
if (nNumberOfBytesToWrite == *lpNumberOfBytesWritten)
return TRUE;
uprintf(" Wrote %d bytes but requested %d%s", *lpNumberOfBytesWritten,
nNumberOfBytesToWrite, nTry < nNumRetries ? retry_msg : "");
}
else {
uprintf(" Write error [0x%8X]%s", GetLastError(), nTry < nNumRetries ? retry_msg : "");
}
// If we can't reposition for the next run, just abort
if (!readFilePointer)
break;
Sleep(200);
}
if (SCODE_CODE(GetLastError()) == ERROR_SUCCESS)
SetLastError(ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT);
return FALSE;
}

View file

@ -35,16 +35,16 @@
#include <richedit.h>
#include "rufus.h"
#include "msapi_utf8.h"
#include "registry.h"
#include "settings.h"
#include "missing.h"
#include "resource.h"
#include "license.h"
#include "msapi_utf8.h"
#include "localization.h"
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
#include "registry.h"
#include "settings.h"
#include "license.h"
PF_TYPE_DECL(WINAPI, HRESULT, SHCreateItemFromParsingName, (PCWSTR, IBindCtx*, REFIID, void **));
#endif
PF_TYPE_DECL(WINAPI, LPITEMIDLIST, SHSimpleIDListFromPath, (PCWSTR pszPath));
#define INIT_VISTA_SHELL32 PF_INIT(SHCreateItemFromParsingName, Shell32)
#define INIT_XP_SHELL32 PF_INIT(SHSimpleIDListFromPath, Shell32)
@ -133,8 +133,6 @@ void BrowseForFolder(void) {
BROWSEINFOW bi;
LPITEMIDLIST pidl;
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
WCHAR *wpath;
size_t i;
HRESULT hr;
@ -145,79 +143,77 @@ void BrowseForFolder(void) {
char* tmp_path = NULL;
dialog_showing++;
// Even if we have Vista support with the compiler,
// it does not mean we have the Vista API available
INIT_VISTA_SHELL32;
if (IS_VISTA_SHELL32_AVAILABLE) {
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileOpenDialog, (LPVOID)&pfod);
if (FAILED(hr)) {
uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr);
pfod = NULL; // Just in case
goto fallback;
}
hr = pfod->lpVtbl->SetOptions(pfod, FOS_PICKFOLDERS);
if (FAILED(hr)) {
uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr);
goto fallback;
}
// Set the initial folder (if the path is invalid, will simply use last)
wpath = utf8_to_wchar(szFolderPath);
// The new IFileOpenDialog makes us split the path
fname = NULL;
if ((wpath != NULL) && (wcslen(wpath) >= 1)) {
for (i=wcslen(wpath)-1; i!=0; i--) {
if (wpath[i] == L'\\') {
wpath[i] = 0;
fname = &wpath[i+1];
break;
}
if (nWindowsVersion >= WINDOWS_VISTA) {
INIT_VISTA_SHELL32;
if (IS_VISTA_SHELL32_AVAILABLE) {
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileOpenDialog, (LPVOID)&pfod);
if (FAILED(hr)) {
uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr);
pfod = NULL; // Just in case
goto fallback;
}
}
hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) {
if (wpath != NULL) {
hr = pfod->lpVtbl->SetFolder(pfod, si_path);
}
if (fname != NULL) {
hr = pfod->lpVtbl->SetFileName(pfod, fname);
}
}
safe_free(wpath);
hr = pfod->lpVtbl->Show(pfod, hMainDialog);
if (SUCCEEDED(hr)) {
hr = pfod->lpVtbl->GetResult(pfod, &psi);
if (SUCCEEDED(hr)) {
psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath);
tmp_path = wchar_to_utf8(wpath);
CoTaskMemFree(wpath);
if (tmp_path == NULL) {
uprintf("Could not convert path\n");
} else {
safe_strcpy(szFolderPath, MAX_PATH, tmp_path);
safe_free(tmp_path);
}
} else {
hr = pfod->lpVtbl->SetOptions(pfod, FOS_PICKFOLDERS);
if (FAILED(hr)) {
uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr);
goto fallback;
}
} else if ((hr & 0xFFFF) != ERROR_CANCELLED) {
// If it's not a user cancel, assume the dialog didn't show and fallback
uprintf("Could not show FileOpenDialog: error %X\n", hr);
goto fallback;
// Set the initial folder (if the path is invalid, will simply use last)
wpath = utf8_to_wchar(szFolderPath);
// The new IFileOpenDialog makes us split the path
fname = NULL;
if ((wpath != NULL) && (wcslen(wpath) >= 1)) {
for (i = wcslen(wpath) - 1; i != 0; i--) {
if (wpath[i] == L'\\') {
wpath[i] = 0;
fname = &wpath[i + 1];
break;
}
}
}
hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) {
if (wpath != NULL) {
pfod->lpVtbl->SetFolder(pfod, si_path);
}
if (fname != NULL) {
pfod->lpVtbl->SetFileName(pfod, fname);
}
}
safe_free(wpath);
hr = pfod->lpVtbl->Show(pfod, hMainDialog);
if (SUCCEEDED(hr)) {
hr = pfod->lpVtbl->GetResult(pfod, &psi);
if (SUCCEEDED(hr)) {
psi->lpVtbl->GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath);
tmp_path = wchar_to_utf8(wpath);
CoTaskMemFree(wpath);
if (tmp_path == NULL) {
uprintf("Could not convert path\n");
} else {
safe_strcpy(szFolderPath, MAX_PATH, tmp_path);
safe_free(tmp_path);
}
} else {
uprintf("Failed to set folder option for FileOpenDialog: error %X\n", hr);
}
} else if ((hr & 0xFFFF) != ERROR_CANCELLED) {
// If it's not a user cancel, assume the dialog didn't show and fallback
uprintf("Could not show FileOpenDialog: error %X\n", hr);
goto fallback;
}
pfod->lpVtbl->Release(pfod);
dialog_showing--;
return;
}
pfod->lpVtbl->Release(pfod);
dialog_showing--;
return;
}
fallback:
if (pfod != NULL) {
pfod->lpVtbl->Release(pfod);
if (pfod != NULL) {
pfod->lpVtbl->Release(pfod);
}
}
#else
dialog_showing++;
#endif
INIT_XP_SHELL32;
memset(&bi, 0, sizeof(BROWSEINFOW));
bi.hwndOwner = hMainDialog;
@ -251,101 +247,98 @@ char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options)
size_t i, j, ext_strlen;
BOOL r;
char* filepath = NULL;
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
HRESULT hr = FALSE;
IFileDialog *pfd = NULL;
IShellItem *psiResult;
COMDLG_FILTERSPEC* filter_spec;
COMDLG_FILTERSPEC* filter_spec = NULL;
wchar_t *wpath = NULL, *wfilename = NULL;
IShellItem *si_path = NULL; // Automatically freed
#endif
if ((ext == NULL) || (ext->count == 0) || (ext->extension == NULL) || (ext->description == NULL))
return NULL;
dialog_showing++;
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
INIT_VISTA_SHELL32;
filter_spec = (COMDLG_FILTERSPEC*)calloc(ext->count + 1, sizeof(COMDLG_FILTERSPEC));
if ((IS_VISTA_SHELL32_AVAILABLE) && (filter_spec != NULL)) {
// Setup the file extension filter table
for (i=0; i<ext->count; i++) {
filter_spec[i].pszSpec = utf8_to_wchar(ext->extension[i]);
filter_spec[i].pszName = utf8_to_wchar(ext->description[i]);
}
filter_spec[i].pszSpec = L"*.*";
filter_spec[i].pszName = utf8_to_wchar(lmprintf(MSG_107));
hr = CoCreateInstance(save?&CLSID_FileSaveDialog:&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileDialog, (LPVOID)&pfd);
if (FAILED(hr)) {
SetLastError(hr);
uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString());
pfd = NULL; // Just in case
goto fallback;
}
// Set the file extension filters
pfd->lpVtbl->SetFileTypes(pfd, (UINT)ext->count+1, filter_spec);
// Set the default directory
wpath = utf8_to_wchar(path);
hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID) &si_path);
if (SUCCEEDED(hr)) {
pfd->lpVtbl->SetFolder(pfd, si_path);
}
safe_free(wpath);
// Set the default filename
wfilename = utf8_to_wchar((ext->filename == NULL)?"":ext->filename);
if (wfilename != NULL) {
pfd->lpVtbl->SetFileName(pfd, wfilename);
}
// Display the dialog
hr = pfd->lpVtbl->Show(pfd, hMainDialog);
// Cleanup
safe_free(wfilename);
for (i=0; i<ext->count; i++) {
safe_free(filter_spec[i].pszSpec);
safe_free(filter_spec[i].pszName);
}
safe_free(filter_spec[i].pszName);
safe_free(filter_spec);
if (SUCCEEDED(hr)) {
// Obtain the result of the user's interaction with the dialog.
hr = pfd->lpVtbl->GetResult(pfd, &psiResult);
if (SUCCEEDED(hr)) {
hr = psiResult->lpVtbl->GetDisplayName(psiResult, SIGDN_FILESYSPATH, &wpath);
if (SUCCEEDED(hr)) {
filepath = wchar_to_utf8(wpath);
CoTaskMemFree(wpath);
} else {
SetLastError(hr);
uprintf("Unable to access file path: %s\n", WindowsErrorString());
}
psiResult->lpVtbl->Release(psiResult);
if (nWindowsVersion >= WINDOWS_VISTA) {
INIT_VISTA_SHELL32;
filter_spec = (COMDLG_FILTERSPEC*)calloc(ext->count + 1, sizeof(COMDLG_FILTERSPEC));
if ((IS_VISTA_SHELL32_AVAILABLE) && (filter_spec != NULL)) {
// Setup the file extension filter table
for (i = 0; i < ext->count; i++) {
filter_spec[i].pszSpec = utf8_to_wchar(ext->extension[i]);
filter_spec[i].pszName = utf8_to_wchar(ext->description[i]);
}
} else if ((hr & 0xFFFF) != ERROR_CANCELLED) {
// If it's not a user cancel, assume the dialog didn't show and fallback
SetLastError(hr);
uprintf("Could not show FileOpenDialog: %s\n", WindowsErrorString());
goto fallback;
}
pfd->lpVtbl->Release(pfd);
dialog_showing--;
return filepath;
}
filter_spec[i].pszSpec = L"*.*";
filter_spec[i].pszName = utf8_to_wchar(lmprintf(MSG_107));
fallback:
if (pfd != NULL) {
pfd->lpVtbl->Release(pfd);
hr = CoCreateInstance(save ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileDialog, (LPVOID)&pfd);
if (FAILED(hr)) {
SetLastError(hr);
uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString());
pfd = NULL; // Just in case
goto fallback;
}
// Set the file extension filters
pfd->lpVtbl->SetFileTypes(pfd, (UINT)ext->count + 1, filter_spec);
// Set the default directory
wpath = utf8_to_wchar(path);
hr = (*pfSHCreateItemFromParsingName)(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) {
pfd->lpVtbl->SetFolder(pfd, si_path);
}
safe_free(wpath);
// Set the default filename
wfilename = utf8_to_wchar((ext->filename == NULL) ? "" : ext->filename);
if (wfilename != NULL) {
pfd->lpVtbl->SetFileName(pfd, wfilename);
}
// Display the dialog
hr = pfd->lpVtbl->Show(pfd, hMainDialog);
// Cleanup
safe_free(wfilename);
for (i = 0; i < ext->count; i++) {
safe_free(filter_spec[i].pszSpec);
safe_free(filter_spec[i].pszName);
}
safe_free(filter_spec[i].pszName);
safe_free(filter_spec);
if (SUCCEEDED(hr)) {
// Obtain the result of the user's interaction with the dialog.
hr = pfd->lpVtbl->GetResult(pfd, &psiResult);
if (SUCCEEDED(hr)) {
hr = psiResult->lpVtbl->GetDisplayName(psiResult, SIGDN_FILESYSPATH, &wpath);
if (SUCCEEDED(hr)) {
filepath = wchar_to_utf8(wpath);
CoTaskMemFree(wpath);
} else {
SetLastError(hr);
uprintf("Unable to access file path: %s\n", WindowsErrorString());
}
psiResult->lpVtbl->Release(psiResult);
}
} else if ((hr & 0xFFFF) != ERROR_CANCELLED) {
// If it's not a user cancel, assume the dialog didn't show and fallback
SetLastError(hr);
uprintf("Could not show FileOpenDialog: %s\n", WindowsErrorString());
goto fallback;
}
pfd->lpVtbl->Release(pfd);
dialog_showing--;
return filepath;
}
fallback:
safe_free(filter_spec);
if (pfd != NULL) {
pfd->lpVtbl->Release(pfd);
}
}
#endif
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
@ -1357,14 +1350,14 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
BOOL SetUpdateCheck(void)
{
BOOL enable_updates;
DWORD commcheck = GetTickCount();
uint64_t commcheck = _GetTickCount64();
notification_info more_info = { IDD_UPDATE_POLICY, UpdateCallback };
char filename[MAX_PATH] = "", exename[] = APPLICATION_NAME ".exe";
size_t fn_len, exe_len;
// Test if we can read and write settings. If not, forget it.
WriteSetting32(SETTING_COMM_CHECK, commcheck);
if (ReadSetting32(SETTING_COMM_CHECK) != commcheck)
WriteSetting64(SETTING_COMM_CHECK, commcheck);
if (ReadSetting64(SETTING_COMM_CHECK) != commcheck)
return FALSE;
settings_commcheck = TRUE;
@ -1648,6 +1641,7 @@ out:
LPCDLGTEMPLATE GetDialogTemplate(int Dialog_ID)
{
int i;
const char thai_id[] = "th-TH";
size_t len;
DWORD size;
DWORD* dwBuf;
@ -1672,7 +1666,7 @@ LPCDLGTEMPLATE GetDialogTemplate(int Dialog_ID)
// If 'Segoe UI Symbol' is available, and we are using Thai, we're done here
if (IsFontAvailable("Segoe UI Symbol") && (selected_locale != NULL)
&& (safe_strcmp(selected_locale->txt[0], "th-TH") == 0))
&& (safe_strcmp(selected_locale->txt[0], thai_id) == 0))
return rcTemplate;
// 'Segoe UI Symbol' cannot be used => Fall back to the best we have

View file

@ -2,7 +2,7 @@
*
* Copyright 2003 Lars Munch Christensen - All Rights Reserved
* Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
* Copyright 2012-2015 Pete Batard
* Copyright 2012-2016 Pete Batard
*
* Based on the Linux installer program for SYSLINUX by H. Peter Anvin
*
@ -27,10 +27,12 @@
#include <ctype.h>
#include "rufus.h"
#include "drive.h"
#include "missing.h"
#include "resource.h"
#include "localization.h"
#include "msapi_utf8.h"
#include "localization.h"
#include "drive.h"
#include "syslinux.h"
#include "syslxfs.h"
@ -39,9 +41,9 @@
#include "ntfssect.h"
unsigned char* syslinux_ldlinux[2] = { NULL, NULL };
DWORD syslinux_ldlinux_len[2];
unsigned long syslinux_ldlinux_len[2];
unsigned char* syslinux_mboot = NULL;
DWORD syslinux_mboot_len;
unsigned long syslinux_mboot_len;
// Workaround for 4K support
uint32_t SECTOR_SHIFT = 9;
@ -137,16 +139,16 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
img_report.sl_version_ext, ldlinux, i==0?"sys":"bss");
fd = fopen(path, "rb");
if (fd == NULL) {
uprintf("Could not open %s\n", path);
uprintf("Could not open %s", path);
goto out;
}
length = fread(syslinux_ldlinux[i], 1, (size_t)syslinux_ldlinux_len[i], fd);
fclose(fd);
if (length != (size_t)syslinux_ldlinux_len[i]) {
uprintf("Could not read %s\n", path);
uprintf("Could not read %s", path);
goto out;
}
uprintf("Using existing './%s'\n", path);
uprintf("Using existing './%s'", path);
}
} else {
for (i=0; i<2; i++) {
@ -167,38 +169,36 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
FILE_ATTRIBUTE_HIDDEN, NULL);
if (f_handle == INVALID_HANDLE_VALUE) {
uprintf("Unable to create '%s'\n", &path[3]);
uprintf("Unable to create '%s'", &path[3]);
goto out;
}
/* Write ldlinux.sys file */
if (!WriteFile(f_handle, (const char _force *)syslinux_ldlinux[0],
syslinux_ldlinux_len[0], &bytes_written, NULL) ||
bytes_written != syslinux_ldlinux_len[0]) {
uprintf("Could not write '%s'\n", &path[3]);
if (!WriteFileWithRetry(f_handle, (const char _force *)syslinux_ldlinux[0],
syslinux_ldlinux_len[0], &bytes_written, WRITE_RETRIES)) {
uprintf("Could not write '%s': %s", &path[3], WindowsErrorString());
goto out;
}
if (!WriteFile(f_handle, syslinux_adv, 2 * ADV_SIZE,
&bytes_written, NULL) ||
bytes_written != 2 * ADV_SIZE) {
uprintf("Could not write ADV to '%s'\n", &path[3]);
if (!WriteFileWithRetry(f_handle, syslinux_adv, 2 * ADV_SIZE,
&bytes_written, WRITE_RETRIES)) {
uprintf("Could not write ADV to '%s': %s", &path[3], WindowsErrorString());
goto out;
}
uprintf("Successfully wrote '%s'\n", &path[3]);
uprintf("Successfully wrote '%s'", &path[3]);
if (bt != BT_ISO)
UpdateProgress(OP_DOS, -1.0f);
/* Now flush the media */
if (!FlushFileBuffers(f_handle)) {
uprintf("FlushFileBuffers failed\n");
uprintf("FlushFileBuffers failed");
goto out;
}
/* Reopen the volume (we already have a lock) */
d_handle = GetLogicalHandle(drive_index, TRUE, FALSE);
if (d_handle == INVALID_HANDLE_VALUE) {
uprintf("Could open volume for Syslinux installation\n");
uprintf("Could open volume for Syslinux installation");
goto out;
}
@ -242,7 +242,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
case FS_EXFAT:
fs = libfat_open(libfat_readfile, (intptr_t) d_handle);
if (fs == NULL) {
uprintf("Syslinux FAT access error\n");
uprintf("Syslinux FAT access error");
goto out;
}
ldlinux_cluster = libfat_searchdir(fs, 0, "LDLINUX SYS", NULL);
@ -257,7 +257,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
libfat_close(fs);
break;
default:
uprintf("Unsupported Syslinux filesystem\n");
uprintf("Unsupported Syslinux filesystem");
goto out;
}
@ -269,9 +269,8 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
/* Rewrite the file */
if (SetFilePointer(f_handle, 0, NULL, FILE_BEGIN) != 0 ||
!WriteFile(f_handle, syslinux_ldlinux[0], syslinux_ldlinux_len[0],
&bytes_written, NULL)
|| bytes_written != syslinux_ldlinux_len[0]) {
!WriteFileWithRetry(f_handle, syslinux_ldlinux[0], syslinux_ldlinux_len[0],
&bytes_written, WRITE_RETRIES)) {
uprintf("Could not write '%s': %s\n", &path[3], WindowsErrorString());
goto out;
}
@ -282,9 +281,12 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
/* Read existing FAT data into boot sector */
if (SetFilePointer(d_handle, 0, NULL, FILE_BEGIN) != 0 ||
!ReadFile(d_handle, sectbuf, SECTOR_SIZE,
&bytes_read, NULL)
|| bytes_read != SECTOR_SIZE) {
uprintf("Could not read boot record: %s\n", WindowsErrorString());
&bytes_read, NULL)) {
uprintf("Could not read Syslinux boot record: %s", WindowsErrorString());
goto out;
}
if (bytes_read < SECTOR_SIZE) {
uprintf("Partial read of Syslinux boot record: read %d bytes but requested %d", bytes_read, SECTOR_SIZE);
goto out;
}
@ -293,14 +295,12 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
/* Write boot sector back */
if (SetFilePointer(d_handle, 0, NULL, FILE_BEGIN) != 0 ||
!WriteFile(d_handle, sectbuf, SECTOR_SIZE,
&bytes_written, NULL)
|| bytes_written != SECTOR_SIZE) {
uprintf("Could not write Syslinux boot record: %s\n", WindowsErrorString());
!WriteFileWithRetry(d_handle, sectbuf, SECTOR_SIZE,
&bytes_written, WRITE_RETRIES)) {
uprintf("Could not write Syslinux boot record: %s", WindowsErrorString());
goto out;
}
uprintf("Successfully wrote Syslinux boot record\n");
uprintf("Successfully wrote Syslinux boot record");
if (bt == BT_SYSLINUX_V6) {
IGNORE_RETVAL(_chdirU(app_dir));
@ -309,17 +309,17 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
static_sprintf(path, "%C:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[2]);
fd = fopen(&path[3], "rb");
if (fd == NULL) {
uprintf("Caution: No '%s' was provided. The target will be missing a required Syslinux file!\n", &path[3]);
uprintf("Caution: No '%s' was provided. The target will be missing a required Syslinux file!", &path[3]);
} else {
fclose(fd);
if (CopyFileA(&path[3], path, TRUE)) {
uprintf("Created '%s' (from '%s/%s-%s/%s')", path, FILES_DIR, syslinux, embedded_sl_version_str[1], &path[3]);
} else {
uprintf("Failed to create '%s': %s\n", path, WindowsErrorString());
uprintf("Failed to create '%s': %s", path, WindowsErrorString());
}
}
} else if (IS_REACTOS(img_report)) {
uprintf("Setting up ReactOS...\n");
uprintf("Setting up ReactOS...");
syslinux_mboot = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_SL_MBOOT_C32),
_RT_RCDATA, "mboot.c32", &syslinux_mboot_len, FALSE);
if (syslinux_mboot == NULL) {
@ -334,21 +334,20 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type)
uprintf("Unable to create '%s'\n", path);
goto out;
}
if (!WriteFile(f_handle, syslinux_mboot, syslinux_mboot_len,
&bytes_written, NULL) ||
bytes_written != syslinux_mboot_len) {
uprintf("Could not write '%s'\n", path);
if (!WriteFileWithRetry(f_handle, syslinux_mboot, syslinux_mboot_len,
&bytes_written, WRITE_RETRIES)) {
uprintf("Could not write '%s'", path);
goto out;
}
safe_closehandle(f_handle);
static_sprintf(path, "%C:\\syslinux.cfg", drive_letter);
fd = fopen(path, "w");
if (fd == NULL) {
uprintf("Could not create ReactOS 'syslinux.cfg'\n");
uprintf("Could not create ReactOS 'syslinux.cfg'");
goto out;
}
/* Write the syslinux.cfg for ReactOS */
fprintf(fd, "DEFAULT ReactOS\nLABEL ReactOS\n KERNEL %s\n APPEND %s\n",
fprintf(fd, "DEFAULT ReactOS\nLABEL ReactOS\n KERNEL %s\n APPEND %s",
mboot_c32, img_report.reactos_path);
fclose(fd);
}

View file

@ -104,6 +104,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4018;4244</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -124,6 +125,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4018;4244</DisableSpecificWarnings>
</ClCompile>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
@ -139,6 +141,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4018;4244</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -159,6 +162,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4018;4244</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View file

@ -5,7 +5,7 @@ INCLUDES=$(DDK_INC_PATH);..\..\msvc-missing
C_DEFINES=$(C_DEFINES) /Dinline=__inline /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED
!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
MSC_WARNING_LEVEL=/W2
!ENDIF
USE_MSVCRT=1

View file

@ -66,7 +66,7 @@ libfat_sector_t libfat_nextsector(struct libfat_filesystem * fs,
if (~rs & clustmask)
return s + 1; /* Next sector in cluster */
cluster = (int32_t) (2 + (rs >> fs->clustshift));
cluster = 2 + (rs >> fs->clustshift);
if (cluster >= fs->endcluster)
return -1;

View file

@ -77,7 +77,7 @@ libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t),
goto barf;
/* Figure out how many clusters */
nclusters = (uint32_t) ((fs->end - fs->data) >> fs->clustshift);
nclusters = (fs->end - fs->data) >> fs->clustshift;
fs->endcluster = nclusters + 2;
if (nclusters <= 0xff4) {
@ -92,15 +92,10 @@ libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t),
} else
goto barf; /* Impossibly many clusters */
/* This check doesn't hold for Large FAT32 => remove it */
#if 0
minfatsize = (minfatsize + LIBFAT_SECTOR_SIZE - 1) >> LIBFAT_SECTOR_SHIFT;
minfatsize = (minfatsize + LIBFAT_SECTOR_SIZE - 1) >> LIBFAT_SECTOR_SHIFT;
if (minfatsize > fatsize)
goto barf; /* The FATs don't fit */
#else
(void)(minfatsize); /* silence an unused warning in MinGW */
#endif
if (fs->fat_type == FAT28)
fs->rootcluster = read32(&bs->u.fat32.bpb_rootclus);

View file

@ -25,7 +25,7 @@ int32_t libfat_searchdir(struct libfat_filesystem *fs, int32_t dirclust,
const void *name, struct libfat_direntry *direntry)
{
struct fat_dirent *dep;
unsigned int nent;
int nent;
libfat_sector_t s = libfat_clustertosector(fs, dirclust);
while (1) {

View file

@ -20,7 +20,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\advconst.h" />
<ClInclude Include="..\ntfssect.h" />
<ClInclude Include="..\syslinux.h" />
<ClInclude Include="..\syslxcom.h" />
<ClInclude Include="..\syslxfs.h" />
@ -28,7 +27,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\fs.c" />
<ClCompile Include="..\ntfssect.c" />
<ClCompile Include="..\setadv.c" />
<ClCompile Include="..\syslxmod.c" />
</ItemGroup>
@ -106,6 +104,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -126,6 +125,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
</ClCompile>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
@ -141,6 +141,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -161,6 +162,7 @@
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View file

@ -26,9 +26,6 @@
<ClInclude Include="..\syslxcom.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ntfssect.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\fs.c">
@ -40,8 +37,5 @@
<ClCompile Include="..\syslxmod.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ntfssect.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -5,7 +5,7 @@ INCLUDES=$(DDK_INC_PATH);..\..\msvc-missing
C_DEFINES=$(C_DEFINES) /Dinline=__inline /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED
!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W3
MSC_WARNING_LEVEL=/W2
!ENDIF
USE_MSVCRT=1
@ -13,6 +13,5 @@ TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib
SOURCES=fs.c \
ntfssect.c \
setadv.c \
syslxmod.c

View file

@ -1,4 +1,4 @@
noinst_LIBRARIES = libinstaller.a
libinstaller_a_SOURCES = fs.c ntfssect.c setadv.c syslxmod.c
libinstaller_a_SOURCES = fs.c setadv.c syslxmod.c
libinstaller_a_CFLAGS = $(AM_CFLAGS)

View file

@ -94,7 +94,6 @@ am__v_AR_1 =
libinstaller_a_AR = $(AR) $(ARFLAGS)
libinstaller_a_LIBADD =
am_libinstaller_a_OBJECTS = libinstaller_a-fs.$(OBJEXT) \
libinstaller_a-ntfssect.$(OBJEXT) \
libinstaller_a-setadv.$(OBJEXT) \
libinstaller_a-syslxmod.$(OBJEXT)
libinstaller_a_OBJECTS = $(am_libinstaller_a_OBJECTS)
@ -244,7 +243,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LIBRARIES = libinstaller.a
libinstaller_a_SOURCES = fs.c ntfssect.c setadv.c syslxmod.c
libinstaller_a_SOURCES = fs.c setadv.c syslxmod.c
libinstaller_a_CFLAGS = $(AM_CFLAGS)
all: all-am
@ -307,12 +306,6 @@ libinstaller_a-fs.o: fs.c
libinstaller_a-fs.obj: fs.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libinstaller_a_CFLAGS) $(CFLAGS) -c -o libinstaller_a-fs.obj `if test -f 'fs.c'; then $(CYGPATH_W) 'fs.c'; else $(CYGPATH_W) '$(srcdir)/fs.c'; fi`
libinstaller_a-ntfssect.o: ntfssect.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libinstaller_a_CFLAGS) $(CFLAGS) -c -o libinstaller_a-ntfssect.o `test -f 'ntfssect.c' || echo '$(srcdir)/'`ntfssect.c
libinstaller_a-ntfssect.obj: ntfssect.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libinstaller_a_CFLAGS) $(CFLAGS) -c -o libinstaller_a-ntfssect.obj `if test -f 'ntfssect.c'; then $(CYGPATH_W) 'ntfssect.c'; else $(CYGPATH_W) '$(srcdir)/ntfssect.c'; fi`
libinstaller_a-setadv.o: setadv.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libinstaller_a_CFLAGS) $(CFLAGS) -c -o libinstaller_a-setadv.o `test -f 'setadv.c' || echo '$(srcdir)/'`setadv.c

View file

@ -20,7 +20,6 @@
* Return 0 on success, -1 on error, and set errno.
*
*/
//#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
@ -110,8 +109,8 @@ int syslinux_setadv(int tag, size_t size, const void *data)
return -1;
}
*p++ = (uint8_t) tag;
*p++ = (uint8_t) size;
*p++ = tag;
*p++ = size;
memcpy(p, data, size);
p += size;
left -= size + 2;

View file

@ -13,7 +13,6 @@
#ifndef SYSLINUX_H
#define SYSLINUX_H
#include <windows.h>
#include <inttypes.h>
#include "advconst.h"
#include "setadv.h"
@ -28,7 +27,7 @@
/* The standard boot sector and ldlinux image */
extern unsigned char* syslinux_ldlinux[2];
extern DWORD syslinux_ldlinux_len[2];
extern unsigned long syslinux_ldlinux_len[2];
extern const int syslinux_ldlinux_mtime[2];
#define boot_sector syslinux_ldlinux[1]
@ -40,12 +39,9 @@ extern unsigned char syslinux_mbr[];
extern const unsigned int syslinux_mbr_len;
extern const int syslinux_mbr_mtime;
/* Sector size assumptions... */
// Workaround for 4K support
/* Sector size variables are defined externally for 4K support */
extern uint32_t SECTOR_SHIFT;
extern uint32_t SECTOR_SIZE;
//#define SECTOR_SHIFT 9
//#define SECTOR_SIZE (1 << SECTOR_SHIFT)
/* This takes a boot sector and merges in the syslinux fields */
void syslinux_make_bootsect(void *bs, int fs_type);

View file

@ -92,8 +92,8 @@ static inline void set_16(uint16_t *p, uint16_t v)
*p = v;
#else
uint8_t *pp = (uint8_t *) p;
pp[0] = (v & 0xff);
pp[1] = ((v >> 8) & 0xff);
pp[0] = v;
pp[1] = v >> 8;
#endif
}

View file

@ -60,7 +60,7 @@ static void generate_extents(struct syslinux_extent _slimg *ex, int nptrs,
}
set_64_sl(&ex->lba, lba);
set_16_sl(&ex->len, (uint16_t) len);
set_16_sl(&ex->len, len);
ex++;
}
@ -75,7 +75,7 @@ static void generate_extents(struct syslinux_extent _slimg *ex, int nptrs,
if (len) {
set_64_sl(&ex->lba, lba);
set_16_sl(&ex->len, (uint16_t) len);
set_16_sl(&ex->len, len);
ex++;
}
}
@ -122,18 +122,18 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
return -1; /* The actual file is too small for content */
/* Search for LDLINUX_MAGIC to find the patch area */
for (wp = (const uint32_t _slimg *)boot_image;
(get_32_sl(wp) != LDLINUX_MAGIC) && (((uintptr_t)wp) < ((uintptr_t)boot_image + boot_image_len));
wp++)
;
if (((uintptr_t)wp) >= ((uintptr_t)boot_image + boot_image_len))
dw = (boot_image_len - sizeof(struct patch_area)) >> 2;
for (i = 0, wp = (const uint32_t _slimg *)boot_image;
(i <= dw) && ((get_32_sl(wp) != LDLINUX_MAGIC));
i++, wp++)
if (i > dw) /* Not found */
return -1;
patcharea = (struct patch_area _slimg *)wp;
epa = slptr(boot_image, &patcharea->epaoffset);
/* First sector need pointer in boot sector */
set_32(ptr(sbs, &epa->sect1ptr0), (uint32_t) sectp[0]);
set_32(ptr(sbs, &epa->sect1ptr1), (uint32_t) (sectp[0] >> 32));
set_32(ptr(sbs, &epa->sect1ptr0), sectp[0]);
set_32(ptr(sbs, &epa->sect1ptr1), sectp[0] >> 32);
sectp++;
/* Handle RAID mode */
@ -176,7 +176,7 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
/* Poke in the base directory path */
if (subdir) {
int sublen = (int) (strlen(subdir) + 1);
int sublen = strlen(subdir) + 1;
if (get_16_sl(&epa->dirlen) < sublen) {
fprintf(stderr, "Subdirectory path too long... aborting install!\n");
exit(1);
@ -186,7 +186,7 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
/* Poke in the subvolume information */
if (subvol) {
int sublen = (int) (strlen(subvol) + 1);
int sublen = strlen(subvol) + 1;
if (get_16_sl(&epa->subvollen) < sublen) {
fprintf(stderr, "Subvol name too long... aborting install!\n");
exit(1);

View file

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ntfssect.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\ntfssect.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7D2E9784-DDF7-4988-A887-CF099BC3B340}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>win</RootNamespace>
<ProjectName>syslinux-win</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)x86_32\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)x86_32\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)x86_32\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)x86_64\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)x86_64\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)x86_64\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>inline=__inline;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267;4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267;4996</DisableSpecificWarnings>
</ClCompile>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>inline=__inline;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267;4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<TargetMachine>MachineX64</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;..\..\..\msvc-missing;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4244;4267;4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<TargetMachine>MachineX64</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ntfssect.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\ntfssect.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -0,0 +1,15 @@
TARGETNAME=win
TARGETTYPE=LIBRARY
INCLUDES=$(DDK_INC_PATH);..\..\msvc-missing
C_DEFINES=$(C_DEFINES) /Dinline=__inline /DDDKBUILD /DUNICODE /D_UNICODE /DISOLATION_AWARE_ENABLED
!IFNDEF MSC_WARNING_LEVEL
MSC_WARNING_LEVEL=/W2
!ENDIF
USE_MSVCRT=1
TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib
SOURCES=ntfssect.c

View file

@ -0,0 +1,4 @@
noinst_LIBRARIES = libwin.a
libwin_a_SOURCES = ntfssect.c
libwin_a_CFLAGS = $(AM_CFLAGS)

View file

@ -0,0 +1,477 @@
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = src/syslinux/win
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LIBRARIES = $(noinst_LIBRARIES)
ARFLAGS = cru
AM_V_AR = $(am__v_AR_@AM_V@)
am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
libwin_a_AR = $(AR) $(ARFLAGS)
libwin_a_LIBADD =
am_libwin_a_OBJECTS = libwin_a-ntfssect.$(OBJEXT)
libwin_a_OBJECTS = $(am_libwin_a_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp =
am__depfiles_maybe =
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libwin_a_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EXEEXT = @EXEEXT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
RM = @RM@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SUFFIX = @SUFFIX@
VERSION = @VERSION@
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@
WINDRES = @WINDRES@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__leading_dot = @am__leading_dot@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LIBRARIES = libwin.a
libwin_a_SOURCES = ntfssect.c
libwin_a_CFLAGS = $(AM_CFLAGS)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps src/syslinux/win/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign --ignore-deps src/syslinux/win/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libwin.a: $(libwin_a_OBJECTS) $(libwin_a_DEPENDENCIES) $(EXTRA_libwin_a_DEPENDENCIES)
$(AM_V_at)-rm -f libwin.a
$(AM_V_AR)$(libwin_a_AR) libwin.a $(libwin_a_OBJECTS) $(libwin_a_LIBADD)
$(AM_V_at)$(RANLIB) libwin.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(AM_V_CC)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
libwin_a-ntfssect.o: ntfssect.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libwin_a_CFLAGS) $(CFLAGS) -c -o libwin_a-ntfssect.o `test -f 'ntfssect.c' || echo '$(srcdir)/'`ntfssect.c
libwin_a-ntfssect.obj: ntfssect.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libwin_a_CFLAGS) $(CFLAGS) -c -o libwin_a-ntfssect.obj `if test -f 'ntfssect.c'; then $(CYGPATH_W) 'ntfssect.c'; else $(CYGPATH_W) '$(srcdir)/ntfssect.c'; fi`
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-noinstLIBRARIES cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-tags dvi dvi-am \
html html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -18,9 +18,6 @@
* With special thanks to Mark Roddy for his article:
* http://www.wd-3.com/archive/luserland.htm
*/
#if defined(_MSC_VER)
#pragma warning(disable:4996)
#endif
#include <windows.h>
#include <winioctl.h>
@ -33,6 +30,10 @@
#define M_ERR(msg) (NtfsSectLastErrorMessage = (msg))
/*** Function declarations */
static DWORD NtfsSectGetVolumeHandle(
CHAR * VolumeName,
S_NTFSSECT_VOLINFO * VolumeInfo
);
static DWORD NtfsSectGetVolumePartitionLba(S_NTFSSECT_VOLINFO * VolumeInfo);
/*** Objects */
@ -44,7 +45,7 @@ DWORD M_NTFSSECT_API NtfsSectGetFileVcnExtent(
LARGE_INTEGER * Vcn,
S_NTFSSECT_EXTENT * Extent
) {
BOOL bad, ok;
BOOL bad;
DWORD output_size, rc;
STARTING_VCN_INPUT_BUFFER input;
RETRIEVAL_POINTERS_BUFFER output;
@ -59,7 +60,7 @@ DWORD M_NTFSSECT_API NtfsSectGetFileVcnExtent(
return ERROR_INVALID_PARAMETER;
input.StartingVcn = *Vcn;
ok = DeviceIoControl(
DeviceIoControl(
File,
FSCTL_GET_RETRIEVAL_POINTERS,
&input,
@ -69,7 +70,6 @@ DWORD M_NTFSSECT_API NtfsSectGetFileVcnExtent(
&output_size,
NULL
);
ok = ok;
rc = GetLastError();
switch (rc) {
case NO_ERROR:
@ -89,6 +89,52 @@ DWORD M_NTFSSECT_API NtfsSectGetFileVcnExtent(
return rc;
}
/* Internal use only */
static DWORD NtfsSectGetVolumeHandle(
CHAR * VolumeName,
S_NTFSSECT_VOLINFO * VolumeInfo
) {
#define M_VOL_PREFIX "\\\\.\\"
CHAR volname[sizeof M_VOL_PREFIX - 1 + MAX_PATH + 1] = M_VOL_PREFIX;
CHAR * const volname_short = volname + sizeof M_VOL_PREFIX - 1;
CHAR * c;
DWORD rc;
/* Prefix "\\.\" onto the passed volume name */
strcpy(volname + sizeof M_VOL_PREFIX - 1, VolumeName);
/* Find the last non-null character */
for (c = volname_short; *c; ++c)
;
/* Remove trailing back-slash */
if (c[-1] == '\\')
c[-1] = 0;
/* Open the volume */
VolumeInfo->Handle = CreateFileA(
volname,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL
);
rc = GetLastError();
if (VolumeInfo->Handle == INVALID_HANDLE_VALUE) {
M_ERR("Unable to open volume handle!");
goto err_handle;
}
return ERROR_SUCCESS;
CloseHandle(VolumeInfo->Handle);
err_handle:
return rc;
}
DWORD M_NTFSSECT_API NtfsSectGetVolumeInfo(
CHAR * VolumeName,
S_NTFSSECT_VOLINFO * VolumeInfo
@ -100,6 +146,10 @@ DWORD M_NTFSSECT_API NtfsSectGetVolumeInfo(
if (!VolumeName || !VolumeInfo)
return ERROR_INVALID_PARAMETER;
rc = NtfsSectGetVolumeHandle(VolumeName, VolumeInfo);
if (rc != ERROR_SUCCESS)
goto err_handle;
rc = NtfsSectLoadXpFuncs(&xp_funcs);
if (rc != ERROR_SUCCESS)
goto err_xp_funcs;
@ -135,6 +185,7 @@ DWORD M_NTFSSECT_API NtfsSectGetVolumeInfo(
CloseHandle(VolumeInfo->Handle);
VolumeInfo->Handle = INVALID_HANDLE_VALUE;
}
err_handle:
return rc;
}

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Virtual Disk Handling functions
* Copyright © 2013-2015 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,22 +24,14 @@
#include <time.h>
#include "rufus.h"
#include "missing.h"
#include "resource.h"
#include "msapi_utf8.h"
#include "drive.h"
#include "registry.h"
#include "bled/bled.h"
#if defined(_MSC_VER)
#define bswap_uint64 _byteswap_uint64
#define bswap_uint32 _byteswap_ulong
#define bswap_uint16 _byteswap_ushort
#else
#define bswap_uint64 __builtin_bswap64
#define bswap_uint32 __builtin_bswap32
#define bswap_uint16 __builtin_bswap16
#endif
#define VHD_FOOTER_COOKIE { 'c', 'o', 'n', 'e', 'c', 't', 'i', 'x' }
#define VHD_FOOTER_FEATURES_NONE 0x00000000
@ -111,7 +103,7 @@ static char sevenzip_path[MAX_PATH];
static const char conectix_str[] = VHD_FOOTER_COOKIE;
static uint32_t wim_nb_files, wim_proc_files;
static BOOL count_files;
static DWORD LastRefresh;
static uint64_t LastRefresh;
static BOOL Get7ZipPath(void)
{
@ -178,7 +170,7 @@ BOOL AppendVHDFooter(const char* vhd_path)
heads = 16;
cylinderTimesHeads = (uint32_t)(totalSectors / sectorsPerTrack);
} else {
sectorsPerTrack = 17;
sectorsPerTrack = 17;
cylinderTimesHeads = (uint32_t)(totalSectors / sectorsPerTrack);
heads = (cylinderTimesHeads + 1023) / 1024;
@ -207,12 +199,12 @@ BOOL AppendVHDFooter(const char* vhd_path)
checksum += ((uint8_t*)footer)[i];
footer->checksum = bswap_uint32(~checksum);
if (!WriteFile(handle, footer, sizeof(vhd_footer), &size, NULL) || (size != sizeof(vhd_footer))) {
if (!WriteFileWithRetry(handle, footer, sizeof(vhd_footer), &size, WRITE_RETRIES)) {
uprintf("Could not write VHD footer: %s", WindowsErrorString());
goto out;
}
r = TRUE;
out:
safe_free(footer);
safe_closehandle(handle);
@ -439,42 +431,54 @@ out:
// Extract a file from a WIM image using 7-Zip
static BOOL WimExtractFile_7z(const char* image, int index, const char* src, const char* dst)
{
int n;
size_t i;
STARTUPINFOA si = {0};
PROCESS_INFORMATION pi = {0};
char cmdline[MAX_PATH];
char tmpdst[MAX_PATH];
char index_prefix[] = "#\\";
uprintf("Opening: %s:[%d] (7-Zip)", image, index);
if ((image == NULL) || (src == NULL) || (dst == NULL))
return FALSE;
safe_strcpy(tmpdst, sizeof(tmpdst), dst);
for (i=strlen(tmpdst)-1; i>0; i--) {
if (tmpdst[i] == '\\')
// If you shove more than 9 images in a WIM, don't come complaining
// that this breaks!
index_prefix[0] = '0' + index;
uprintf("Extracting: %s (From %s)", dst, src);
// 7z has a quirk where the image index MUST be specified if a
// WIM has multiple indexes, but it MUST be removed if there is
// only one image. Because of this (and because 7z will not
// return an error code if it can't extract the file), we need
// to issue 2 passes. See github issue #680.
for (n = 0; n < 2; n++) {
safe_strcpy(tmpdst, sizeof(tmpdst), dst);
for (i = strlen(tmpdst) - 1; i > 0; i--) {
if (tmpdst[i] == '\\')
break;
}
tmpdst[i] = 0;
safe_sprintf(cmdline, sizeof(cmdline), "\"%s\" -y e \"%s\" %s%s", sevenzip_path,
image, (n == 0) ? index_prefix : "", src);
if (RunCommand(cmdline, tmpdst, FALSE) != 0) {
uprintf(" Could not launch 7z.exe: %s", WindowsErrorString());
return FALSE;
}
safe_strcat(tmpdst, sizeof(tmpdst), "\\bootmgfw.efi");
if (_access(tmpdst, 0) == 0)
// File was extracted => move on
break;
}
tmpdst[i] = 0;
// TODO: use RunCommand
si.cb = sizeof(si);
safe_sprintf(cmdline, sizeof(cmdline), "7z -y e \"%s\" %d\\%s", image, index, src);
uprintf("Extracting: %s (From %s)", dst, src);
if (!CreateProcessU(sevenzip_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, tmpdst, &si, &pi)) {
uprintf(" Could not launch 7z.exe: %s", WindowsErrorString());
return FALSE;
}
WaitForSingleObject(pi.hProcess, INFINITE);
UpdateProgress(OP_FINALIZE, -1.0f);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
safe_strcat(tmpdst, sizeof(tmpdst), "\\bootmgfw.efi");
if (_access(tmpdst, 0) == -1) {
if (n >= 2) {
uprintf(" 7z.exe did not extract %s", tmpdst);
return FALSE;
}
// coverity[toctou]
if (rename(tmpdst, dst) != 0) {
uprintf(" Could not rename %s to %s", tmpdst, dst);
@ -569,12 +573,12 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
wim_nb_files++;
} else {
wim_proc_files++;
if (GetTickCount() > LastRefresh + 100) {
if (_GetTickCount64() > LastRefresh + 100) {
// At the end of an actual apply, the WIM API re-lists a bunch of directories it
// already processed, so we end up with more entries than counted - ignore those.
if (wim_proc_files > wim_nb_files)
wim_proc_files = wim_nb_files;
LastRefresh = GetTickCount();
LastRefresh = _GetTickCount64();
// x^3 progress, so as not to give a better idea right from the onset
// as to the dismal speed with which the WIM API can actually apply files...
apply_percent = 4.636942595f * ((float)wim_proc_files) / ((float)wim_nb_files);

View file

@ -70,6 +70,21 @@ copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\libinstaller.lib . >NUL 2>&1
if EXIST Makefile.hide ren Makefile.hide Makefile
if EXIST sources del sources >NUL 2>&1
::# SysLinux win Library
cd ..\win
if EXIST Makefile ren Makefile Makefile.hide
copy .msvc\win_sources sources >NUL 2>&1
@echo on
%BUILD_CMD%
@echo off
if errorlevel 1 goto builderror
copy obj%BUILD_ALT_DIR%\%ARCH_DIR%\win.lib . >NUL 2>&1
if EXIST Makefile.hide ren Makefile.hide Makefile
if EXIST sources del sources >NUL 2>&1
::# libcdio iso9660 Library
cd ..\..\libcdio\iso9660
if EXIST Makefile ren Makefile Makefile.hide