From 9376bc8f5147c892769bddfc738563b9790d4f07 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 22 Aug 2018 17:52:28 +0200 Subject: Windows: Add check on size of file container to ensure it's smaller than available free space on disk when this is required. --- Translations/Language.ar.xml | 1 + Translations/Language.be.xml | 1 + Translations/Language.bg.xml | 1 + Translations/Language.ca.xml | 1 + Translations/Language.cs.xml | 1 + Translations/Language.da.xml | 1 + Translations/Language.de.xml | 1 + Translations/Language.el.xml | 1 + Translations/Language.es.xml | 1 + Translations/Language.et.xml | 1 + Translations/Language.eu.xml | 1 + Translations/Language.fa.xml | 1 + Translations/Language.fi.xml | 1 + Translations/Language.fr.xml | 3 ++- Translations/Language.hu.xml | 1 + Translations/Language.id.xml | 1 + Translations/Language.it.xml | 1 + Translations/Language.ja.xml | 1 + Translations/Language.ka.xml | 1 + Translations/Language.ko.xml | 1 + Translations/Language.lv.xml | 1 + Translations/Language.my.xml | 1 + Translations/Language.nl.xml | 1 + Translations/Language.nn.xml | 1 + Translations/Language.pl.xml | 1 + Translations/Language.pt-br.xml | 1 + Translations/Language.ro.xml | 1 + Translations/Language.ru.xml | 1 + Translations/Language.sk.xml | 1 + Translations/Language.sl.xml | 1 + Translations/Language.sv.xml | 1 + Translations/Language.th.xml | 1 + Translations/Language.tr.xml | 1 + Translations/Language.uk.xml | 1 + Translations/Language.uz.xml | 1 + Translations/Language.vi.xml | 1 + Translations/Language.zh-cn.xml | 1 + Translations/Language.zh-hk.xml | 1 + Translations/Language.zh-tw.xml | 1 + src/Common/Language.xml | 1 + src/Format/Tcformat.c | 45 ++++++++++++++++++++++++++++++++++++++--- src/Format/Tcformat.h | 2 +- 42 files changed, 84 insertions(+), 5 deletions(-) diff --git a/Translations/Language.ar.xml b/Translations/Language.ar.xml index 3597f109..6534b03f 100644 --- a/Translations/Language.ar.xml +++ b/Translations/Language.ar.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.be.xml b/Translations/Language.be.xml index 7cad3919..bdd0e439 100644 --- a/Translations/Language.be.xml +++ b/Translations/Language.be.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.bg.xml b/Translations/Language.bg.xml index 93dd0a45..15f176fb 100644 --- a/Translations/Language.bg.xml +++ b/Translations/Language.bg.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.ca.xml b/Translations/Language.ca.xml index edebb4f2..4da3657f 100644 --- a/Translations/Language.ca.xml +++ b/Translations/Language.ca.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Trieu idioma a emprar durant la instal·lació: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.cs.xml b/Translations/Language.cs.xml index 63bdced1..f5be9ecd 100644 --- a/Translations/Language.cs.xml +++ b/Translations/Language.cs.xml @@ -1425,6 +1425,7 @@ Vložený text byl zkrácen, neboť maximální délka hesla je 64 znaků. Heslo je již dlouhé 64 znaků.\nDalší znaky nejsou již umožněny. Vyberte si jazyk instalace: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.da.xml b/Translations/Language.da.xml index 998cba0a..d6f45768 100644 --- a/Translations/Language.da.xml +++ b/Translations/Language.da.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Vælg det sprog der skal vises under installationen: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.de.xml b/Translations/Language.de.xml index f48a8c28..2d2d69ae 100644 --- a/Translations/Language.de.xml +++ b/Translations/Language.de.xml @@ -1427,6 +1427,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Wählen Sie die Sprache aus, die während der Installation benutzt werden soll: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.el.xml b/Translations/Language.el.xml index e686e1c8..d2009c72 100644 --- a/Translations/Language.el.xml +++ b/Translations/Language.el.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Επιλέξτε τη γλώσσα που θα χρησιμοποιηθεί κατά τη διάρκεια της εγκατάστασης: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.es.xml b/Translations/Language.es.xml index c0ae171e..00d0f071 100644 --- a/Translations/Language.es.xml +++ b/Translations/Language.es.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Seleccione el idioma a utilizar durante la instalación: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.et.xml b/Translations/Language.et.xml index 449f88c1..93250280 100644 --- a/Translations/Language.et.xml +++ b/Translations/Language.et.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.eu.xml b/Translations/Language.eu.xml index 1c02b4b0..181b8389 100644 --- a/Translations/Language.eu.xml +++ b/Translations/Language.eu.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.fa.xml b/Translations/Language.fa.xml index 3dbbe6c0..e0f89f0a 100644 --- a/Translations/Language.fa.xml +++ b/Translations/Language.fa.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.fi.xml b/Translations/Language.fi.xml index 9eb090eb..08ba5b65 100644 --- a/Translations/Language.fi.xml +++ b/Translations/Language.fi.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Valitse asentamisen aikana käytettävä kieli: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.fr.xml b/Translations/Language.fr.xml index 4406fbf7..6c39153c 100644 --- a/Translations/Language.fr.xml +++ b/Translations/Language.fr.xml @@ -1419,11 +1419,12 @@ Il est fortement recommandé de créer un nouveau disque de secours VeraCrypt (qui contiendra la nouvelle version du chargeur d'amorçage de VeraCrypt) en sélectionnant 'Système' > 'Créer un disque de secours'.\nVoulez-vous le faire maintenant? Autoriser la commande TRIM sur les disques SSD non système Bloquer la commande TRIM sur la partition/disque système - ERREUR: Le chargeur de démarrage système EFI de Windows n'a pas pu être trouvé sur le disque. L'opération va être interrompue. + ERREUR : Le chargeur de démarrage système EFI de Windows n'a pas pu être trouvé sur le disque. L'opération va être interrompue. Il n'est actuellement pas possible de chiffrer un système si SecureBoot est activé et si les clefs personnalisées de VeraCrypt ne sont pas chargées dans le firmware de la machine. SecureBoot doit être désactivé dans la configuration du BIOS afin de permettre d'effectuer le chiffrement du système. Le texte collé a été tronqué car la taille maximale du mot de passe est 64 caractères Le mot de passe a déjà atteint sa taille maximale de 64 caractères.\nAucun caractère supplémentaire n'est autorisé. Veuillez sélectionner la langue qui sera utilisée par l'assistant d'installation : + ERREUR : La taille du fichier conteneur est plus grande que l'espace libre sur le disque. diff --git a/Translations/Language.hu.xml b/Translations/Language.hu.xml index 5d3b66c3..31a0e15c 100644 --- a/Translations/Language.hu.xml +++ b/Translations/Language.hu.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Válassza ki a telepítés során használandó nyelvet: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.id.xml b/Translations/Language.id.xml index 977c6550..5d6db3a4 100644 --- a/Translations/Language.id.xml +++ b/Translations/Language.id.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.it.xml b/Translations/Language.it.xml index 3588b1f4..5bead74e 100644 --- a/Translations/Language.it.xml +++ b/Translations/Language.it.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Selezionare la lingua da utilizzare durante l'installazione: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.ja.xml b/Translations/Language.ja.xml index 4a99f148..78906cde 100644 --- a/Translations/Language.ja.xml +++ b/Translations/Language.ja.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. インストール中に利用する言語を選んでください: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.ka.xml b/Translations/Language.ka.xml index 91b9570e..e170f522 100644 --- a/Translations/Language.ka.xml +++ b/Translations/Language.ka.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.ko.xml b/Translations/Language.ko.xml index 4ac72238..4dea57b1 100644 --- a/Translations/Language.ko.xml +++ b/Translations/Language.ko.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.lv.xml b/Translations/Language.lv.xml index 10d2f74d..f2f8eee5 100644 --- a/Translations/Language.lv.xml +++ b/Translations/Language.lv.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.my.xml b/Translations/Language.my.xml index bce31682..8ceac641 100644 --- a/Translations/Language.my.xml +++ b/Translations/Language.my.xml @@ -1426,6 +1426,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.nl.xml b/Translations/Language.nl.xml index 2bf3c0c3..53bf42e4 100644 --- a/Translations/Language.nl.xml +++ b/Translations/Language.nl.xml @@ -1425,6 +1425,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Selecteer de taal welke Setup gebruikt tijdens de installatie: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.nn.xml b/Translations/Language.nn.xml index 1e471d6b..896a341a 100644 --- a/Translations/Language.nn.xml +++ b/Translations/Language.nn.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Velg språket som skal brukes under installasjonen: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.pl.xml b/Translations/Language.pl.xml index 0319505e..94075d74 100644 --- a/Translations/Language.pl.xml +++ b/Translations/Language.pl.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Wybierz jêzyk u¿ywany podczas instalacji: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.pt-br.xml b/Translations/Language.pt-br.xml index 5c158c7d..afd6eab3 100644 --- a/Translations/Language.pt-br.xml +++ b/Translations/Language.pt-br.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Selecione o idioma a ser utilizado durante a instalação: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.ro.xml b/Translations/Language.ro.xml index 04b039f6..e5b8d44b 100644 --- a/Translations/Language.ro.xml +++ b/Translations/Language.ro.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.ru.xml b/Translations/Language.ru.xml index c603b701..91551291 100644 --- a/Translations/Language.ru.xml +++ b/Translations/Language.ru.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Выберите язык, который будет использован в процессе установки: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.sk.xml b/Translations/Language.sk.xml index bf1f5b17..77c3c722 100644 --- a/Translations/Language.sk.xml +++ b/Translations/Language.sk.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.sl.xml b/Translations/Language.sl.xml index 6c3a57c9..6435d0db 100644 --- a/Translations/Language.sl.xml +++ b/Translations/Language.sl.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Izberite jezik, ki ga želite uporabljati med namestitvijo: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.sv.xml b/Translations/Language.sv.xml index 8b93120e..4398ca22 100644 --- a/Translations/Language.sv.xml +++ b/Translations/Language.sv.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.th.xml b/Translations/Language.th.xml index 811b3275..9d5f897a 100644 --- a/Translations/Language.th.xml +++ b/Translations/Language.th.xml @@ -1425,6 +1425,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.tr.xml b/Translations/Language.tr.xml index 76553376..7892ae5f 100644 --- a/Translations/Language.tr.xml +++ b/Translations/Language.tr.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Kurulum süresince kullanýlacak dili seçin: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.uk.xml b/Translations/Language.uk.xml index 07d5a613..e6254b7d 100644 --- a/Translations/Language.uk.xml +++ b/Translations/Language.uk.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Виберіть мову, яка буде використовуватися під час встановлення: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.uz.xml b/Translations/Language.uz.xml index e1b53ee1..038ce378 100644 --- a/Translations/Language.uz.xml +++ b/Translations/Language.uz.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.vi.xml b/Translations/Language.vi.xml index 469e436f..0b5d0c7a 100644 --- a/Translations/Language.vi.xml +++ b/Translations/Language.vi.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.zh-cn.xml b/Translations/Language.zh-cn.xml index bc1f9b1f..9b866210 100644 --- a/Translations/Language.zh-cn.xml +++ b/Translations/Language.zh-cn.xml @@ -1424,6 +1424,7 @@ 粘贴的文本被截断, 因为密码最大长度为64个字符 密码已达到其最大长度64个字符。\n不允许附加字符。 选择安装期间要使用的语言: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.zh-hk.xml b/Translations/Language.zh-hk.xml index 9848dbf0..48c9a6bd 100644 --- a/Translations/Language.zh-hk.xml +++ b/Translations/Language.zh-hk.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/Translations/Language.zh-tw.xml b/Translations/Language.zh-tw.xml index d74cddbe..a44583b1 100644 --- a/Translations/Language.zh-tw.xml +++ b/Translations/Language.zh-tw.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/src/Common/Language.xml b/src/Common/Language.xml index 9073dc1e..9c0e4fae 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1424,6 +1424,7 @@ Pasted text truncated because the password maximum length is 64 characters Password already reached its maximum length of 64 characters.\nNo additional character is allowed. Select the language to use during the installation: + ERROR: The size of the file container is larger than the available free space on disk. diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 2f8b9b2f..f2493b08 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -287,6 +287,9 @@ SYSENC_MULTIBOOT_CFG SysEncMultiBootCfg; wchar_t SysEncMultiBootCfgOutcome [4096] = {L'N',L'/',L'A',0}; volatile int NonSysInplaceEncStatus = NONSYS_INPLACE_ENC_STATUS_NONE; +LONGLONG nAvailableFreeSpace = -1; +BOOL bIsSparseFilesSupportedByHost = FALSE; + vector DeferredNonSysInPlaceEncDevices; // specific definitions and implementation for support of resume operation @@ -1538,6 +1541,12 @@ static void VerifySizeAndUpdate (HWND hwndDlg, BOOL bUpdate) { if (lTmp * i > (bHiddenVolHost ? TC_MAX_HIDDEN_VOLUME_HOST_SIZE : TC_MAX_VOLUME_SIZE)) bEnable = FALSE; + else if (!bDevice && (lTmp * i > nAvailableFreeSpace) && (!bIsSparseFilesSupportedByHost || bHiddenVolHost)) + { + // we check container size against available free space only when creating dynamic volume is not possible + // which is the case if filesystem doesn't allow sparce file or if we are creating outer volume of a hidden volume + bEnable = FALSE; + } } } @@ -3366,14 +3375,23 @@ BOOL GetFileVolSize (HWND hwndDlg, unsigned __int64 *size) } -BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) +BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFreeSpaceValue, BOOL* pbIsSparceFilesSupported) { + if (pFreeSpaceValue) + *pFreeSpaceValue = 0; + + if (pbIsSparceFilesSupported) + *pbIsSparceFilesSupported = FALSE; + if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume { LARGE_INTEGER lDiskFree; lDiskFree.QuadPart = nMaximumHiddenVolSize; + if (pFreeSpaceValue) + *pFreeSpaceValue = nMaximumHiddenVolSize; + if (display) PrintFreeSpace (hwndTextBox, NULL, &lDiskFree); @@ -3382,6 +3400,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) else if (bDevice == FALSE) { wchar_t root[TC_MAX_PATH]; + DWORD fileSystemFlags = 0; ULARGE_INTEGER free; if (!GetVolumePathName (szFileName, root, ARRAYSIZE (root))) @@ -3390,6 +3409,14 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) return FALSE; } + if ( pbIsSparceFilesSupported + && GetVolumeInformation (root, NULL, 0, NULL, NULL, &fileSystemFlags, NULL, 0) + && (fileSystemFlags & FILE_SUPPORTS_SPARSE_FILES) + ) + { + *pbIsSparceFilesSupported = TRUE; + } + if (!GetDiskFreeSpaceEx (root, &free, 0, 0)) { if (display) @@ -3402,6 +3429,9 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) LARGE_INTEGER lDiskFree; lDiskFree.QuadPart = free.QuadPart; + if (pFreeSpaceValue) + *pFreeSpaceValue = free.QuadPart; + if (display) PrintFreeSpace (hwndTextBox, root, &lDiskFree); @@ -3463,6 +3493,9 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) nVolumeSize = lDiskFree.QuadPart; + if (pFreeSpaceValue) + *pFreeSpaceValue = lDiskFree.QuadPart; + if (display) nMultiplier = PrintFreeSpace (hwndTextBox, szDiskFile, &lDiskFree); @@ -4169,7 +4202,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SendMessage (GetDlgItem (hwndDlg, IDC_SPACE_LEFT), WM_SETFONT, (WPARAM) hBoldFont, (LPARAM) TRUE); SendMessage (GetDlgItem (hwndDlg, IDC_SIZEBOX), EM_LIMITTEXT, 12, 0); - if(!QueryFreeSpace (hwndDlg, GetDlgItem (hwndDlg, IDC_SPACE_LEFT), TRUE)) + if(!QueryFreeSpace (hwndDlg, GetDlgItem (hwndDlg, IDC_SPACE_LEFT), TRUE, &nAvailableFreeSpace, &bIsSparseFilesSupportedByHost)) { nUIVolumeSize=0; nVolumeSize=0; @@ -7348,7 +7381,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (bDevice) { - if(!QueryFreeSpace (hwndDlg, GetDlgItem (hwndDlg, IDC_SPACE_LEFT), FALSE)) + if(!QueryFreeSpace (hwndDlg, GetDlgItem (hwndDlg, IDC_SPACE_LEFT), FALSE, NULL, NULL)) { MessageBoxW (hwndDlg, GetString ("CANT_GET_VOLSIZE"), lpszTitle, ICON_HAND); NormalCursor (); @@ -8315,6 +8348,12 @@ retryCDDriveCheck: quickFormat = IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT)); + if (!quickFormat && !bDevice && !(bHiddenVol && !bHiddenVolHost) && (nVolumeSize > (ULONGLONG) nAvailableFreeSpace)) + { + Error("VOLUME_TOO_LARGE_FOR_HOST", hwndDlg); + bVolTransformThreadToRun = FALSE; + return 1; + } if (!bHiddenVol && IsHiddenOSRunning()) { diff --git a/src/Format/Tcformat.h b/src/Format/Tcformat.h index 183f17f6..caaf2c28 100644 --- a/src/Format/Tcformat.h +++ b/src/Format/Tcformat.h @@ -42,7 +42,7 @@ static void LoadPage ( HWND hwndDlg , int nPageNo ); __int64 PrintFreeSpace ( HWND hwndTextBox , wchar_t *lpszDrive , PLARGE_INTEGER lDiskFree ); void DisplaySizingErrorText ( HWND hwndTextBox ); void EnableDisableFileNext ( HWND hComboBox , HWND hMainButton ); -BOOL QueryFreeSpace ( HWND hwndDlg , HWND hwndTextBox , BOOL display ); +BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFreeSpaceValue, BOOL* pbIsSparseFilesSupported); static BOOL FinalPreTransformPrompts (void); void UpdateLastDialogId (void); void HandleOldAssignedDriveLetter (void); -- cgit v1.2.3