From 0bfed6553d08131fd8e0bd725642ff8509a2a1d4 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 1 Jul 2023 15:16:46 +0200 Subject: Windows: Fix formatting issue during volume creation by using /Y for format.com and specifying removal parameter in FormatEx The usage of /Y parameter in format.com simplifies the logic and makes the code robust since we don't need to send \n to the format.com process. Specifying RemovableMedia parameter to FormatEx fixes its failure in Windows 10 and later to perform quick format. This is also more adequate since we are mounting the volume as removable media for the formatting process. We also add better error management in order to display adequate error message to the user in case of failure --- Translations/Language.ar.xml | 2 + Translations/Language.be.xml | 2 + Translations/Language.bg.xml | 2 + Translations/Language.ca.xml | 2 + Translations/Language.co.xml | 2 + Translations/Language.cs.xml | 2 + Translations/Language.da.xml | 2 + Translations/Language.de.xml | 2 + Translations/Language.el.xml | 2 + Translations/Language.es.xml | 2 + Translations/Language.et.xml | 2 + Translations/Language.eu.xml | 2 + Translations/Language.fa.xml | 2 + Translations/Language.fi.xml | 2 + Translations/Language.fr.xml | 2 + Translations/Language.he.xml | 2 + Translations/Language.hu.xml | 2 + Translations/Language.id.xml | 2 + Translations/Language.it.xml | 2 + Translations/Language.ja.xml | 2 + Translations/Language.ka.xml | 2 + Translations/Language.ko.xml | 2 + Translations/Language.lv.xml | 2 + Translations/Language.my.xml | 2 + Translations/Language.nl.xml | 2 + Translations/Language.nn.xml | 2 + Translations/Language.pl.xml | 2 + Translations/Language.pt-br.xml | 2 + Translations/Language.ro.xml | 2 + Translations/Language.ru.xml | 2 + Translations/Language.sk.xml | 2 + Translations/Language.sl.xml | 2 + Translations/Language.sv.xml | 2 + Translations/Language.th.xml | 2 + Translations/Language.tr.xml | 2 + Translations/Language.uk.xml | 2 + Translations/Language.uz.xml | 2 + Translations/Language.vi.xml | 2 + Translations/Language.zh-cn.xml | 2 + Translations/Language.zh-hk.xml | 2 + Translations/Language.zh-tw.xml | 2 + src/Common/Format.c | 104 +++++++++++++++++++++++++++++----------- src/Common/Format.h | 8 ++-- src/Common/Language.xml | 2 + 44 files changed, 165 insertions(+), 31 deletions(-) diff --git a/Translations/Language.ar.xml b/Translations/Language.ar.xml index b0e4a030..8561c8a8 100644 --- a/Translations/Language.ar.xml +++ b/Translations/Language.ar.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.be.xml b/Translations/Language.be.xml index 0a34c4b5..66c3e3a4 100644 --- a/Translations/Language.be.xml +++ b/Translations/Language.be.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.bg.xml b/Translations/Language.bg.xml index 715b5892..cb5c87d1 100644 --- a/Translations/Language.bg.xml +++ b/Translations/Language.bg.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.ca.xml b/Translations/Language.ca.xml index 21963c21..f957b295 100644 --- a/Translations/Language.ca.xml +++ b/Translations/Language.ca.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.co.xml b/Translations/Language.co.xml index c3c3b48a..3d7faf2f 100644 --- a/Translations/Language.co.xml +++ b/Translations/Language.co.xml @@ -1639,6 +1639,8 @@ Information about Corsican localization: U chjassu EMV hè inaccettevule. Impussibule di custruisce un schedariu chjave cù i dati di a carta EMV.\n\nUna di ste cundizione hè assente :\n- U certificatu di chjave publica ICC.\n- U certificatu di chjave publica di l’emettore.\n- I dati CPCL. Alcuna carta in u lettore.\n\nAssicuratevi chì a carta hè framessa currettamente. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.cs.xml b/Translations/Language.cs.xml index 7597e461..9c60917c 100644 --- a/Translations/Language.cs.xml +++ b/Translations/Language.cs.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.da.xml b/Translations/Language.da.xml index 2e9c4d2b..66e8621e 100644 --- a/Translations/Language.da.xml +++ b/Translations/Language.da.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.de.xml b/Translations/Language.de.xml index 0a0f22cc..4003a01c 100644 --- a/Translations/Language.de.xml +++ b/Translations/Language.de.xml @@ -1624,6 +1624,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.el.xml b/Translations/Language.el.xml index 990f6d34..e2871d4c 100644 --- a/Translations/Language.el.xml +++ b/Translations/Language.el.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.es.xml b/Translations/Language.es.xml index f75f9a1b..4054586f 100644 --- a/Translations/Language.es.xml +++ b/Translations/Language.es.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.et.xml b/Translations/Language.et.xml index b03c943d..bab16660 100644 --- a/Translations/Language.et.xml +++ b/Translations/Language.et.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.eu.xml b/Translations/Language.eu.xml index f9797267..11d479ae 100644 --- a/Translations/Language.eu.xml +++ b/Translations/Language.eu.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.fa.xml b/Translations/Language.fa.xml index da5095e4..80cd99bb 100644 --- a/Translations/Language.fa.xml +++ b/Translations/Language.fa.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.fi.xml b/Translations/Language.fi.xml index 37ba9eb6..0fba2e1a 100644 --- a/Translations/Language.fi.xml +++ b/Translations/Language.fi.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.fr.xml b/Translations/Language.fr.xml index 1d04d97e..a298fbe3 100644 --- a/Translations/Language.fr.xml +++ b/Translations/Language.fr.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.he.xml b/Translations/Language.he.xml index 0f40263c..c957d232 100644 --- a/Translations/Language.he.xml +++ b/Translations/Language.he.xml @@ -1622,6 +1622,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.hu.xml b/Translations/Language.hu.xml index 832d618a..51d3a824 100644 --- a/Translations/Language.hu.xml +++ b/Translations/Language.hu.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.id.xml b/Translations/Language.id.xml index 8258eda2..e5244017 100644 --- a/Translations/Language.id.xml +++ b/Translations/Language.id.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.it.xml b/Translations/Language.it.xml index bc2afc13..94a1617b 100644 --- a/Translations/Language.it.xml +++ b/Translations/Language.it.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.ja.xml b/Translations/Language.ja.xml index 0f8f0fae..432c37fa 100644 --- a/Translations/Language.ja.xml +++ b/Translations/Language.ja.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.ka.xml b/Translations/Language.ka.xml index 40f5a22e..655a5f42 100644 --- a/Translations/Language.ka.xml +++ b/Translations/Language.ka.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.ko.xml b/Translations/Language.ko.xml index d826294e..c64c4e9c 100644 --- a/Translations/Language.ko.xml +++ b/Translations/Language.ko.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.lv.xml b/Translations/Language.lv.xml index fdaf80f1..65ad9d47 100644 --- a/Translations/Language.lv.xml +++ b/Translations/Language.lv.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.my.xml b/Translations/Language.my.xml index 1fcbd951..76036cd5 100644 --- a/Translations/Language.my.xml +++ b/Translations/Language.my.xml @@ -1623,6 +1623,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.nl.xml b/Translations/Language.nl.xml index 05dfebfa..91dd0c52 100644 --- a/Translations/Language.nl.xml +++ b/Translations/Language.nl.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.nn.xml b/Translations/Language.nn.xml index 82af7e6e..b5ec4a71 100644 --- a/Translations/Language.nn.xml +++ b/Translations/Language.nn.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.pl.xml b/Translations/Language.pl.xml index a766b0a9..a73536be 100644 --- a/Translations/Language.pl.xml +++ b/Translations/Language.pl.xml @@ -1621,6 +1621,8 @@ Ścieżka EMV jest nieprawidłowa. Nie można utworzyć pliku klucza z danych karty EMV.\n\nBrak jednego z następujących elementów:\n- Certyfikatu klucza publicznego ICC.\n- Certyfikatu klucza publicznego wydawcy.\n- Danych CPCL. Brak karty w czytniku.\n\nUpewnij się, że karta jest prawidłowo włożona. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.pt-br.xml b/Translations/Language.pt-br.xml index 0b45ba35..76191f34 100644 --- a/Translations/Language.pt-br.xml +++ b/Translations/Language.pt-br.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.ro.xml b/Translations/Language.ro.xml index 6ad8b93b..fbf539d0 100644 --- a/Translations/Language.ro.xml +++ b/Translations/Language.ro.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.ru.xml b/Translations/Language.ru.xml index 0dedde92..03830c2a 100644 --- a/Translations/Language.ru.xml +++ b/Translations/Language.ru.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.sk.xml b/Translations/Language.sk.xml index 7b9abd60..c775a6bd 100644 --- a/Translations/Language.sk.xml +++ b/Translations/Language.sk.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.sl.xml b/Translations/Language.sl.xml index da36755f..f504c9c0 100644 --- a/Translations/Language.sl.xml +++ b/Translations/Language.sl.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.sv.xml b/Translations/Language.sv.xml index e2f1436f..55bfadbe 100644 --- a/Translations/Language.sv.xml +++ b/Translations/Language.sv.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.th.xml b/Translations/Language.th.xml index ff1b0614..4e1f1673 100644 --- a/Translations/Language.th.xml +++ b/Translations/Language.th.xml @@ -1622,6 +1622,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.tr.xml b/Translations/Language.tr.xml index 1a140f96..ecb20118 100644 --- a/Translations/Language.tr.xml +++ b/Translations/Language.tr.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.uk.xml b/Translations/Language.uk.xml index 5a4dc238..2359bfb1 100644 --- a/Translations/Language.uk.xml +++ b/Translations/Language.uk.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.uz.xml b/Translations/Language.uz.xml index ca0643e7..d4f14209 100644 --- a/Translations/Language.uz.xml +++ b/Translations/Language.uz.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.vi.xml b/Translations/Language.vi.xml index edbd4d84..7a88a903 100644 --- a/Translations/Language.vi.xml +++ b/Translations/Language.vi.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.zh-cn.xml b/Translations/Language.zh-cn.xml index 17e93372..b127eacd 100644 --- a/Translations/Language.zh-cn.xml +++ b/Translations/Language.zh-cn.xml @@ -1622,6 +1622,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.zh-hk.xml b/Translations/Language.zh-hk.xml index c62d8217..cace58ac 100644 --- a/Translations/Language.zh-hk.xml +++ b/Translations/Language.zh-hk.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/Translations/Language.zh-tw.xml b/Translations/Language.zh-tw.xml index 973eaf58..67f8f6f4 100644 --- a/Translations/Language.zh-tw.xml +++ b/Translations/Language.zh-tw.xml @@ -1621,6 +1621,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. diff --git a/src/Common/Format.c b/src/Common/Format.c index 15ca9518..d5514bf9 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -797,16 +797,26 @@ error: } retCode = ExternalFormatFs (driveNo, volParams->clusterSize, fsType); - if (retCode != TRUE) + if (retCode != 0) { + wchar_t auxLine[2048]; + StringCbPrintfW (auxLine, sizeof(auxLine), GetString ("FORMAT_EXTERNAL_FAILED"), retCode); + WarningDirect(auxLine, volParams->hwndDlg); + /* fallback to using FormatEx function from fmifs.dll */ if (!Silent && !IsAdmin () && IsUacSupported ()) retCode = UacFormatFs (volParams->hwndDlg, driveNo, volParams->clusterSize, fsType); else retCode = FormatFs (driveNo, volParams->clusterSize, fsType); + + if (retCode != 0) + { + StringCbPrintfW (auxLine, sizeof(auxLine), GetString ("FORMATEX_API_FAILED"), FormatExGetMessage(retCode)); + ErrorDirect(auxLine, volParams->hwndDlg); + } } - if (retCode != TRUE) + if (retCode != 0) { if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent) MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND); @@ -1030,6 +1040,46 @@ fail: volatile BOOLEAN FormatExError; +volatile int FormatExErrorCommand; + +LPCWSTR FormatExGetMessage (int command) +{ + static WCHAR h_szMsg[32]; + switch (command) + { + case FMIFS_DONE: + return L"FORMAT_FINISHED"; + case FMIFS_STRUCTURE_PROGRESS: + return L"FORMAT_STRUCTURE_PROGRESS"; + case FMIFS_MEDIA_WRITE_PROTECTED: + return L"FORMAT_MEDIA_WRITE_PROTECTED"; + case FMIFS_INCOMPATIBLE_FILE_SYSTEM: + return L"FORMAT_INCOMPATIBLE_FILE_SYSTEM"; + case FMIFS_ACCESS_DENIED: + return L"FORMAT_ACCESS_DENIED"; + case FMIFS_VOLUME_IN_USE: + return L"FORMAT_VOLUME_IN_USE"; + case FMIFS_CLUSTER_SIZE_TOO_SMALL: + return L"FORMAT_CLUSTER_SIZE_TOO_SMALL"; + case FMIFS_CLUSTER_SIZE_TOO_BIG: + return L"FORMAT_CLUSTER_SIZE_TOO_BIG"; + case FMIFS_VOLUME_TOO_SMALL: + return L"FORMAT_VOLUME_TOO_SMALL"; + case FMIFS_VOLUME_TOO_BIG: + return L"FORMAT_VOLUME_TOO_BIG"; + case FMIFS_NO_MEDIA_IN_DRIVE: + return L"FORMAT_NO_MEDIA_IN_DRIVE"; + case FMIFS_DEVICE_NOT_READY: + return L"FORMAT_DEVICE_NOT_READY"; + case FMIFS_BAD_LABEL: + return L"FORMAT_BAD_LABEL"; + case FMIFS_CANT_QUICK_FORMAT: + return L"FORMAT_CANT_QUICK_FORMAT"; + default: + StringCbPrintfW (h_szMsg, sizeof(h_szMsg), L"0x%.8X", command); + return h_szMsg; + } +} BOOLEAN __stdcall FormatExCallback (int command, DWORD subCommand, PVOID parameter) { @@ -1086,10 +1136,14 @@ BOOLEAN __stdcall FormatExCallback (int command, DWORD subCommand, PVOID paramet FormatExError = TRUE; break; } + if (FormatExError) + { + FormatExErrorCommand = command; + } return (FormatExError? FALSE : TRUE); } -BOOL FormatFs (int driveNo, int clusterSize, int fsType) +int FormatFs (int driveNo, int clusterSize, int fsType) { wchar_t dllPath[MAX_PATH] = {0}; WCHAR dir[8] = { (WCHAR) driveNo + L'A', 0 }; @@ -1135,29 +1189,31 @@ BOOL FormatFs (int driveNo, int clusterSize, int fsType) StringCchCatW (dir, ARRAYSIZE(dir), L":\\"); FormatExError = TRUE; + FormatExErrorCommand = 0; // Windows sometimes fails to format a volume (hosted on a removable medium) as NTFS. // It often helps to retry several times. for (i = 0; i < 50 && FormatExError; i++) { FormatExError = FALSE; - FormatEx (dir, FMIFS_HARDDISK, szFsFormat, szLabel, TRUE, clusterSize * FormatSectorSize, FormatExCallback); + FormatExErrorCommand = 0; + FormatEx (dir, FMIFS_REMOVAL, szFsFormat, szLabel, TRUE, clusterSize * FormatSectorSize, FormatExCallback); } // The device may be referenced for some time after FormatEx() returns Sleep (4000); FreeLibrary (hModule); - return FormatExError? FALSE : TRUE; + return FormatExError? FormatExErrorCommand : 0; } -BOOL FormatNtfs (int driveNo, int clusterSize) +int FormatNtfs (int driveNo, int clusterSize) { return FormatFs (driveNo, clusterSize, FILESYS_NTFS); } /* call Windows format.com program to perform formatting */ -BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType) +int ExternalFormatFs (int driveNo, int clusterSize, int fsType) { wchar_t exePath[MAX_PATH] = {0}; HANDLE hChildStd_IN_Rd = NULL; @@ -1170,6 +1226,7 @@ BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType) PROCESS_INFORMATION piProcInfo; BOOL bSuccess = FALSE; SECURITY_ATTRIBUTES saAttr; + int iRet = 0; switch (fsType) { @@ -1222,7 +1279,7 @@ BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType) else StringCchCopyW(exePath, ARRAYSIZE(exePath), L"C:\\Windows\\System32\\format.com"); - StringCbPrintf (szCmdline, sizeof(szCmdline), L"%s %c: /FS:%s /Q /X /V:\"\"", exePath, (WCHAR) driveNo + L'A', szFsFormat); + StringCbPrintf (szCmdline, sizeof(szCmdline), L"%s %c: /FS:%s /Q /X /V:\"\" /Y", exePath, (WCHAR) driveNo + L'A', szFsFormat); if (clusterSize) { @@ -1269,42 +1326,33 @@ BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType) if (bSuccess) { - /* Unblock the format process by simulating hit on ENTER key */ - DWORD dwExitCode, dwWritten; - LPCSTR newLine = "\n"; - - if (WriteFile(hChildStd_IN_Wr, (LPCVOID) newLine, 1, &dwWritten, NULL)) - { - /* wait for the format process to finish */ - WaitForSingleObject (piProcInfo.hProcess, INFINITE); - } - else - { - /* we failed to write "\n". Maybe process exited too quickly. We wait 1 second */ - WaitForSingleObject (piProcInfo.hProcess, 1000); - } + DWORD dwExitCode; + + /* wait for the format process to finish */ + WaitForSingleObject (piProcInfo.hProcess, INFINITE); /* check if it was successfull */ if (GetExitCodeProcess (piProcInfo.hProcess, &dwExitCode)) { - if (dwExitCode == 0) - bSuccess = TRUE; - else - bSuccess = FALSE; + iRet = (int) dwExitCode; /* dwExitCode will be 0 in case of success */ } else - bSuccess = FALSE; + iRet = (int) GetLastError(); CloseHandle (piProcInfo.hThread); CloseHandle (piProcInfo.hProcess); } + else + { + iRet = (int) GetLastError(); + } CloseHandle(hChildStd_OUT_Wr); CloseHandle(hChildStd_OUT_Rd); CloseHandle(hChildStd_IN_Rd); CloseHandle(hChildStd_IN_Wr); - return bSuccess; + return iRet; } BOOL WriteSector (void *dev, char *sector, diff --git a/src/Common/Format.h b/src/Common/Format.h index 826b8f6c..204feee1 100644 --- a/src/Common/Format.h +++ b/src/Common/Format.h @@ -69,14 +69,16 @@ FORMAT_VOL_PARAMETERS; #define FMIFS_CHECKDISK_PROGRESS 0x19 #define FMIFS_READ_ONLY_MODE 0x20 +#define FMIFS_REMOVAL 0xB #define FMIFS_HARDDISK 0xC extern int FormatWriteBufferSize; int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams); -BOOL FormatNtfs (int driveNo, int clusterSize); -BOOL FormatFs (int driveNo, int clusterSize, int fsType); -BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType); +int FormatNtfs (int driveNo, int clusterSize); +int FormatFs (int driveNo, int clusterSize, int fsType); +int ExternalFormatFs (int driveNo, int clusterSize, int fsType); +LPCWSTR FormatExGetMessage (int command); uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize); int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat, BOOL bDevice); BOOL WriteSector ( void *dev , char *sector , char *write_buf , int *write_buf_cnt , unsigned __int64 *nSecNo , unsigned __int64 startSector, PCRYPTO_INFO cryptoInfo ); diff --git a/src/Common/Language.xml b/src/Common/Language.xml index a34187a5..3399ccbc 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1622,6 +1622,8 @@ EMV path is invalid. Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data. No card in the reader.\n\nPlease make sure the card is correctly slotted. + Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API. + Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s. -- cgit v1.2.3