diff options
Diffstat (limited to 'src/Format')
-rw-r--r-- | src/Format/Format.manifest | 8 | ||||
-rw-r--r-- | src/Format/Format.rc | 12 | ||||
-rw-r--r-- | src/Format/Format.vcxproj | 80 | ||||
-rw-r--r-- | src/Format/Format.vcxproj.filters | 66 | ||||
-rw-r--r-- | src/Format/FormatCom.cpp | 52 | ||||
-rw-r--r-- | src/Format/FormatCom.h | 1 | ||||
-rw-r--r-- | src/Format/FormatCom.idl | 4 | ||||
-rw-r--r-- | src/Format/Format_vs2019.vcxproj | 61 | ||||
-rw-r--r-- | src/Format/InPlace.c | 79 | ||||
-rw-r--r-- | src/Format/Resource.h | 3 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 251 |
11 files changed, 426 insertions, 191 deletions
diff --git a/src/Format/Format.manifest b/src/Format/Format.manifest index 5d4cb896..79d86799 100644 --- a/src/Format/Format.manifest +++ b/src/Format/Format.manifest @@ -14,7 +14,13 @@ </asmv3:application> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 10 and Windows 11 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> diff --git a/src/Format/Format.rc b/src/Format/Format.rc index 0114bacd..46e811b7 100644 --- a/src/Format/Format.rc +++ b/src/Format/Format.rc @@ -28,8 +28,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,25,7,0 - PRODUCTVERSION 1,25,7,0 + FILEVERSION 1,26,10,0 + PRODUCTVERSION 1,26,10,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -46,11 +46,11 @@ BEGIN BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt Format" - VALUE "FileVersion", "1.25" + VALUE "FileVersion", "1.26.10" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCrypt Format.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.25" + VALUE "ProductVersion", "1.26.10" END END BLOCK "VarFileInfo" @@ -154,7 +154,8 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN COMBOBOX IDC_FILESYS,50,13,36,90,CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX IDC_CLUSTERSIZE,135,13,42,90,CBS_DROPDOWNLIST | WS_TABSTOP - CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,181,9,92,8 + COMBOBOX IDC_FORMAT_TYPE,181,8,93,131,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Dynamic",SPARSE_FILE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,181,22,92,8 CONTROL "",IDC_SHOW_KEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,265,38,9,8 PUSHBUTTON "Abort",IDC_ABORT_BUTTON,200,75,64,14 RTEXT "Header Key: ",IDT_HEADER_KEY,2,47,76,8 @@ -178,7 +179,6 @@ BEGIN CONTROL "",IDC_RANDOM_BYTES,"Static",SS_SIMPLE | WS_GROUP,83,38,177,8,WS_EX_TRANSPARENT GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,0,175,276,18 CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",WS_BORDER,20,184,235,6 - CONTROL "Dynamic",SPARSE_FILE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,181,21,92,8 END IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 276, 193 diff --git a/src/Format/Format.vcxproj b/src/Format/Format.vcxproj index d80f4618..1ae26d43 100644 --- a/src/Format/Format.vcxproj +++ b/src/Format/Format.vcxproj @@ -165,7 +165,7 @@ </Midl> <ClCompile> <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> @@ -178,10 +178,10 @@ <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;..\Common\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> @@ -205,7 +205,7 @@ copy Debug\VeraCryptFormat.exe "..\Debug\Setup Files\VeraCrypt Format.exe" >N </Midl> <ClCompile> <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> @@ -218,10 +218,10 @@ copy Debug\VeraCryptFormat.exe "..\Debug\Setup Files\VeraCrypt Format.exe" >N <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;..\Common\x64\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> @@ -248,7 +248,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -261,10 +261,10 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -288,7 +288,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -301,10 +301,10 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -328,7 +328,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -341,10 +341,10 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -372,7 +372,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -385,10 +385,10 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -416,7 +416,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -429,10 +429,10 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -460,7 +460,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -473,10 +473,10 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> - <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -497,6 +497,17 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="..\Common\CommandAPDU.cpp" /> + <ClCompile Include="..\Common\EMVCard.cpp" /> + <ClCompile Include="..\Common\EMVToken.cpp" /> + <ClCompile Include="..\Common\PCSCException.cpp" /> + <ClCompile Include="..\Common\ResponseAPDU.cpp" /> + <ClCompile Include="..\Common\SCard.cpp" /> + <ClCompile Include="..\Common\SCardLoader.cpp" /> + <ClCompile Include="..\Common\SCardManager.cpp" /> + <ClCompile Include="..\Common\SCardReader.cpp" /> + <ClCompile Include="..\Common\TLVParser.cpp" /> + <ClCompile Include="..\Common\Token.cpp" /> <ClCompile Include="FormatCom.cpp" /> <ClCompile Include="InPlace.c"> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> @@ -577,16 +588,27 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: </ItemGroup> <ItemGroup> <ClInclude Include="..\Common\BaseCom.h" /> + <ClInclude Include="..\Common\CommandAPDU.h" /> <ClInclude Include="..\Common\Common.h" /> <ClInclude Include="..\Common\Crc.h" /> <ClInclude Include="..\Common\Crypto.h" /> <ClInclude Include="..\Common\Dictionary.h" /> <ClInclude Include="..\Common\Dlgcode.h" /> + <ClInclude Include="..\Common\EMVCard.h" /> + <ClInclude Include="..\Common\EMVToken.h" /> <ClInclude Include="..\Common\EncryptionThreadPool.h" /> <ClInclude Include="..\Common\Endian.h" /> <ClInclude Include="..\Common\Exception.h" /> <ClInclude Include="..\Common\Fat.h" /> <ClInclude Include="..\Common\Format.h" /> + <ClInclude Include="..\Common\PCSCException.h" /> + <ClInclude Include="..\Common\ResponseAPDU.h" /> + <ClInclude Include="..\Common\SCard.h" /> + <ClInclude Include="..\Common\SCardLoader.h" /> + <ClInclude Include="..\Common\SCardManager.h" /> + <ClInclude Include="..\Common\SCardReader.h" /> + <ClInclude Include="..\Common\TLVParser.h" /> + <ClInclude Include="..\Common\Token.h" /> <ClInclude Include="FormatCom.h" /> <ClInclude Include="..\Common\GfMul.h" /> <ClInclude Include="InPlace.h" /> @@ -644,7 +666,9 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <None Include="..\Boot\Windows\Release_Twofish\BootSector.bin" /> <None Include="..\Boot\Windows\Release_AES\BootSector.bin" /> <None Include="..\Boot\Windows\Release\Decompressor.com" /> - <None Include="..\Common\Language.xml" /> + <None Include="..\Common\Language.xml"> + <SubType>Designer</SubType> + </None> <None Include="..\Resources\Texts\License.rtf" /> <None Include="..\Common\Textual_logo_288dpi.bmp" /> <None Include="..\Common\Textual_logo_96dpi.bmp" /> @@ -672,6 +696,12 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <Project>{8b7f059f-e4c7-4e11-88f5-ee8b8433072e}</Project> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> </ProjectReference> + <ProjectReference Include="..\Common\Lzma.vcxproj"> + <Project>{b896fe1f-6bf3-4f75-9148-f841829073d9}</Project> + </ProjectReference> + <ProjectReference Include="..\Common\Zip.vcxproj"> + <Project>{6316ee71-0210-4ca4-bcc7-cfb7a3c090fc}</Project> + </ProjectReference> <ProjectReference Include="..\Crypto\Crypto.vcxproj"> <Project>{993245cf-6b70-47ee-91bb-39f8fc6dc0e7}</Project> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> diff --git a/src/Format/Format.vcxproj.filters b/src/Format/Format.vcxproj.filters index 4f0e81eb..dbba0b57 100644 --- a/src/Format/Format.vcxproj.filters +++ b/src/Format/Format.vcxproj.filters @@ -108,6 +108,39 @@ <ClCompile Include="..\Common\Xts.c"> <Filter>Source Files\Common</Filter> </ClCompile> + <ClCompile Include="..\Common\EMVToken.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Token.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\TLVParser.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\CommandAPDU.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\PCSCException.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\ResponseAPDU.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\SCardLoader.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\SCardManager.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\SCardReader.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\EMVCard.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\SCard.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <Midl Include="FormatCom.idl"> @@ -208,6 +241,39 @@ <ClInclude Include="..\Common\Xts.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\Common\EMVToken.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Token.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\TLVParser.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\CommandAPDU.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\PCSCException.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\ResponseAPDU.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\SCardLoader.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\SCardManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\SCardReader.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\EMVCard.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\SCard.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="..\Boot\Windows\Release_Serpent_SHA2\BootSector.bin"> diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp index 7c155600..90333f23 100644 --- a/src/Format/FormatCom.cpp +++ b/src/Format/FormatCom.cpp @@ -92,7 +92,7 @@ public: virtual BOOL STDMETHODCALLTYPE FormatNtfs (int driveNo, int clusterSize) { - return ::FormatNtfs (driveNo, clusterSize); + return ::FormatNtfs (driveNo, clusterSize, TRUE); } virtual int STDMETHODCALLTYPE AnalyzeHiddenVolumeHost ( @@ -134,7 +134,7 @@ public: virtual BOOL STDMETHODCALLTYPE FormatFs (int driveNo, int clusterSize, int fsType) { - return ::FormatFs (driveNo, clusterSize, fsType); + return ::FormatFs (driveNo, clusterSize, fsType, TRUE); } virtual DWORD STDMETHODCALLTYPE GetFileSize (BSTR filePath, unsigned __int64 *pSize) @@ -182,6 +182,16 @@ public: return BaseCom::UpdateSetupConfigFile (bForInstall); } + virtual DWORD STDMETHODCALLTYPE NotifyService (DWORD dwNotifyCode) + { + return BaseCom::NotifyService (dwNotifyCode); + } + + virtual DWORD STDMETHODCALLTYPE FastFileResize (BSTR filePath, __int64 fileSize) + { + return BaseCom::FastFileResize (filePath, fileSize); + } + protected: DWORD MessageThreadId; LONG RefCount; @@ -245,12 +255,12 @@ extern "C" int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize) CComPtr<ITrueCryptFormatCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hWnd, &tc)) r = tc->FormatNtfs (driveNo, clusterSize); else - r = 0; + r = (int) GetLastError(); CoUninitialize (); @@ -262,12 +272,12 @@ extern "C" int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType) CComPtr<ITrueCryptFormatCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hWnd, &tc)) r = tc->FormatFs (driveNo, clusterSize, fsType); else - r = 0; + r = (int) GetLastError(); CoUninitialize (); @@ -280,7 +290,7 @@ extern "C" int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 h CComPtr<ITrueCryptFormatCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) r = tc->AnalyzeHiddenVolumeHost ((__int64) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters); @@ -297,7 +307,7 @@ extern "C" BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPat CComPtr<ITrueCryptFormatCom> tc; int r = 0; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) { @@ -330,3 +340,29 @@ extern "C" BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPat } } +extern "C" DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize) +{ + CComPtr<ITrueCryptFormatCom> tc; + DWORD r; + + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + + if (ComGetInstance (hWnd, &tc)) + { + CComBSTR filePathBstr; + BSTR bstr = W2BSTR(filePath); + if (bstr) + { + filePathBstr.Attach (bstr); + r = tc->FastFileResize (filePathBstr, fileSize); + } + else + r = ERROR_OUTOFMEMORY; + } + else + r = GetLastError(); + + CoUninitialize (); + + return r; +} diff --git a/src/Format/FormatCom.h b/src/Format/FormatCom.h index 5ab6bd52..e474608d 100644 --- a/src/Format/FormatCom.h +++ b/src/Format/FormatCom.h @@ -30,6 +30,7 @@ int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHos int UacFormatVolume (char *cvolumePath , BOOL bDevice , unsigned __int64 size , unsigned __int64 hiddenVolHostSize , Password *password , int cipher , int pkcs5 , BOOL quickFormat, BOOL sparseFileSwitch, int fileSystem , int clusterSize, HWND hwndDlg , BOOL hiddenVol , int *realClusterSize); BOOL UacUpdateProgressBar (__int64 nSecNo, BOOL *bVolTransformThreadCancel); BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPath, wchar_t *valueName, DWORD value); +DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize); #ifdef __cplusplus } diff --git a/src/Format/FormatCom.idl b/src/Format/FormatCom.idl index 9df43f6e..7276de81 100644 --- a/src/Format/FormatCom.idl +++ b/src/Format/FormatCom.idl @@ -16,7 +16,7 @@ import "..\Common\Password.h"; [ uuid(56327DDA-F1A7-4e13-B128-520D129BDEF6), helpstring("VeraCrypt Format UAC Support Library"), - version(2.9) // Update ComSetup.cpp when changing version number + version(2.10) // Update ComSetup.cpp when changing version number ] library TrueCryptFormatCom { @@ -49,6 +49,8 @@ library TrueCryptFormatCom DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); DWORD UpdateSetupConfigFile (BOOL bForInstall); DWORD GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded); + DWORD NotifyService (DWORD dwNotifyCode); + DWORD FastFileResize (BSTR filePath, __int64 fileSize); }; [ diff --git a/src/Format/Format_vs2019.vcxproj b/src/Format/Format_vs2019.vcxproj index 8b56b8d0..95f61615 100644 --- a/src/Format/Format_vs2019.vcxproj +++ b/src/Format/Format_vs2019.vcxproj @@ -185,7 +185,7 @@ </Midl> <ClCompile> <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> @@ -201,7 +201,7 @@ <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> @@ -225,7 +225,7 @@ copy Debug\VeraCryptFormat.exe "..\Debug\Setup Files\VeraCrypt Format.exe" >N </Midl> <ClCompile> <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> @@ -241,7 +241,7 @@ copy Debug\VeraCryptFormat.exe "..\Debug\Setup Files\VeraCrypt Format.exe" >N <AdditionalDependencies>..\Crypto\ARM64\Debug\crypto.lib;..\Common\ARM64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> @@ -267,7 +267,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: </Midl> <ClCompile> <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> @@ -283,7 +283,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: <AdditionalDependencies>..\Crypto\ARM64\Debug\crypto.lib;..\Common\ARM64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> @@ -308,7 +308,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -324,7 +324,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -348,7 +348,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -364,7 +364,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -392,7 +392,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -408,7 +408,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -435,7 +435,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -451,7 +451,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <AdditionalDependencies>..\Crypto\ARM64\Release\crypto.lib;..\Common\ARM64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -478,7 +478,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -494,7 +494,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -521,7 +521,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> - <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> @@ -537,7 +537,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> @@ -557,6 +557,17 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="..\Common\CommandAPDU.cpp" /> + <ClCompile Include="..\Common\EMVCard.cpp" /> + <ClCompile Include="..\Common\EMVToken.cpp" /> + <ClCompile Include="..\Common\PCSCException.cpp" /> + <ClCompile Include="..\Common\ResponseAPDU.cpp" /> + <ClCompile Include="..\Common\SCard.cpp" /> + <ClCompile Include="..\Common\SCardLoader.cpp" /> + <ClCompile Include="..\Common\SCardManager.cpp" /> + <ClCompile Include="..\Common\SCardReader.cpp" /> + <ClCompile Include="..\Common\TLVParser.cpp" /> + <ClCompile Include="..\Common\Token.cpp" /> <ClCompile Include="FormatCom.cpp" /> <ClCompile Include="InPlace.c"> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> @@ -642,16 +653,27 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: </ItemGroup> <ItemGroup> <ClInclude Include="..\Common\BaseCom.h" /> + <ClInclude Include="..\Common\CommandAPDU.h" /> <ClInclude Include="..\Common\Common.h" /> <ClInclude Include="..\Common\Crc.h" /> <ClInclude Include="..\Common\Crypto.h" /> <ClInclude Include="..\Common\Dictionary.h" /> <ClInclude Include="..\Common\Dlgcode.h" /> + <ClInclude Include="..\Common\EMVCard.h" /> + <ClInclude Include="..\Common\EMVToken.h" /> <ClInclude Include="..\Common\EncryptionThreadPool.h" /> <ClInclude Include="..\Common\Endian.h" /> <ClInclude Include="..\Common\Exception.h" /> <ClInclude Include="..\Common\Fat.h" /> <ClInclude Include="..\Common\Format.h" /> + <ClInclude Include="..\Common\PCSCException.h" /> + <ClInclude Include="..\Common\ResponseAPDU.h" /> + <ClInclude Include="..\Common\SCard.h" /> + <ClInclude Include="..\Common\SCardLoader.h" /> + <ClInclude Include="..\Common\SCardManager.h" /> + <ClInclude Include="..\Common\SCardReader.h" /> + <ClInclude Include="..\Common\TLVParser.h" /> + <ClInclude Include="..\Common\Token.h" /> <ClInclude Include="FormatCom.h" /> <ClInclude Include="..\Common\GfMul.h" /> <ClInclude Include="InPlace.h" /> @@ -734,6 +756,9 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: </ResourceCompile> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\Common\Lzma_vs2019.vcxproj"> + <Project>{b896fe1f-6bf3-4f75-9148-f841829073d9}</Project> + </ProjectReference> <ProjectReference Include="..\Crypto\Crypto_vs2019.vcxproj"> <Project>{993245cf-6b70-47ee-91bb-39f8fc6dc0e7}</Project> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c index 4a16fd4f..b1483631 100644 --- a/src/Format/InPlace.c +++ b/src/Format/InPlace.c @@ -89,6 +89,8 @@ static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const wchar_t *devicePath, } if ( (ntfsVolData.NumberSectors.QuadPart <= 0) + || (ntfsVolData.BytesPerSector == 0) + || (ntfsVolData.BytesPerSector >= (DWORD) UINT_MAX) || (ntfsVolData.NumberSectors.QuadPart > (INT64_MAX / (__int64) ntfsVolData.BytesPerSector)) // overflow test ) { @@ -591,7 +593,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol offset.QuadPart = TC_VOLUME_DATA_OFFSET + dataAreaSize; - if (!SetFilePointerEx (dev, offset, NULL, FILE_BEGIN)) + if (!MoveFilePointer (dev, offset)) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -637,7 +639,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; - if (!SetFilePointerEx (dev, offset, NULL, FILE_BEGIN)) + if (!MoveFilePointer (dev, offset)) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -914,7 +916,7 @@ inplace_enc_read: offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize - TC_VOLUME_DATA_OFFSET; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1005,14 +1007,14 @@ inplace_enc_read: memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate)); } - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + if (MoveFilePointer (dev, offset) == 0 || WriteFile (dev, wipeBuffer, workChunkSize, &n, NULL) == 0) { // Write error dwError = GetLastError(); // Undo failed write operation - if (workChunkSize > TC_VOLUME_DATA_OFFSET && SetFilePointerEx (dev, offset, NULL, FILE_BEGIN)) + if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset)) { DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL); @@ -1032,7 +1034,7 @@ inplace_enc_read: offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1044,7 +1046,7 @@ inplace_enc_read: dwError = GetLastError(); // Undo failed write operation - if (workChunkSize > TC_VOLUME_DATA_OFFSET && SetFilePointerEx (dev, offset, NULL, FILE_BEGIN)) + if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset)) { DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL); @@ -1146,7 +1148,7 @@ inplace_enc_read: offset.QuadPart = TC_VOLUME_HEADER_OFFSET; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + if (MoveFilePointer (dev, offset) == 0 || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) { nStatus = ERR_OS_ERROR; @@ -1205,7 +1207,7 @@ inplace_enc_read: offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + if (MoveFilePointer (dev, offset) == 0 || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) { nStatus = ERR_OS_ERROR; @@ -1542,7 +1544,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile offset.QuadPart = workChunkStartByteOffset; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1576,7 +1578,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile for (tmpSectorCount = workChunkSize / sectorSize; tmpSectorCount > 0; --tmpSectorCount) { - if (SetFilePointerEx (dev, tmpSectorOffset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, tmpSectorOffset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1638,7 +1640,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile offset.QuadPart = workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1722,7 +1724,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile offset.QuadPart <= deviceSize - sectorSize; offset.QuadPart += sectorSize) { - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1862,7 +1864,7 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + if (MoveFilePointer (dev, offset) == 0 || !ReadEffectiveVolumeHeader (TRUE, dev, header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE) { nStatus = ERR_OS_ERROR; @@ -1911,7 +1913,7 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo); - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + if (MoveFilePointer (dev, offset) == 0 || !WriteEffectiveVolumeHeader (TRUE, dev, header)) { nStatus = ERR_OS_ERROR; @@ -2090,7 +2092,7 @@ static int ConcealNTFS (HANDLE dev) offset.QuadPart = 0; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) return ERR_OS_ERROR; if (ReadFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed, NULL) == 0) @@ -2101,7 +2103,7 @@ static int ConcealNTFS (HANDLE dev) offset.QuadPart = 0; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0) + if (MoveFilePointer (dev, offset) == 0) return ERR_OS_ERROR; if (WriteFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed, NULL) == 0) @@ -2120,7 +2122,7 @@ static int ConcealNTFS (HANDLE dev) { Sleep (1); } - while (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + while (MoveFilePointer (dev, offset) == 0 || WriteFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed2, NULL) == 0); SetLastError (dwError); @@ -2196,6 +2198,38 @@ BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId newWipeAlgorithm, return SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC), (DWORD) strlen(str), FALSE, FALSE); } +// This function moves the file pointer to the given offset. It first retrieves the current +// file position using SetFilePointerEx() with FILE_CURRENT as the reference point, and then +// calculates the difference between the current position and the desired position. Subsequently, +// it moves the file pointer by the difference calculated using SetFilePointerEx() again. +// +// This approach of moving the file pointer relatively (instead of absolutely) was implemented +// as a workaround to address the performance issues related to in-place encryption. When using +// SetFilePointerEx() with FILE_BEGIN as the reference point, reaching the end of large drives +// during in-place encryption can cause significant slowdowns. By moving the file pointer +// relatively, these performance issues are mitigated. +// +// We fall back to absolute positioning if the relative positioning fails. +BOOL MoveFilePointer (HANDLE dev, LARGE_INTEGER offset) +{ + LARGE_INTEGER currOffset; + LARGE_INTEGER diffOffset; + + currOffset.QuadPart = 0; + if (SetFilePointerEx (dev, currOffset, &currOffset, FILE_CURRENT)) + { + diffOffset.QuadPart = offset.QuadPart - currOffset.QuadPart; + if (diffOffset.QuadPart == 0) + return TRUE; + + // Moves the file pointer by the difference between current and desired positions + if (SetFilePointerEx (dev, diffOffset, NULL, FILE_CURRENT)) + return TRUE; + } + + // An error occurred, fallback to absolute positioning + return SetFilePointerEx (dev, offset, NULL, FILE_BEGIN); +} // Repairs damaged sectors (i.e. those with read errors) by zeroing them. // Note that this operating fails if there are any write errors. @@ -2215,7 +2249,7 @@ int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, in if (!sectorBuffer) return ERR_OUTOFMEMORY; - if (SetFilePointerEx (dev, startOffset, NULL, FILE_BEGIN) == 0) + if (!MoveFilePointer(dev, workOffset)) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -2228,7 +2262,8 @@ int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, in { memset (sectorBuffer, 0, sectorSize); - if (SetFilePointerEx (dev, workOffset, NULL, FILE_BEGIN) == 0) + // If ReadFile failed, move back to start of the unreadable sector + if (MoveFilePointer (dev, workOffset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; @@ -2279,7 +2314,7 @@ static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *pa offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE; - if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0 + if (MoveFilePointer (dev, offset) == 0 || !ReadEffectiveVolumeHeader (TRUE, dev, (byte *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE) { nStatus = ERR_OS_ERROR; @@ -2287,7 +2322,7 @@ static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *pa } - nStatus = ReadVolumeHeader (FALSE, header, password, pkcs5, pim, FALSE, retMasterCryptoInfo, headerCryptoInfo); + nStatus = ReadVolumeHeader (FALSE, header, password, pkcs5, pim, retMasterCryptoInfo, headerCryptoInfo); if (nStatus != ERR_SUCCESS) goto closing_seq; diff --git a/src/Format/Resource.h b/src/Format/Resource.h index c37a6f4a..d8fb8dc4 100644 --- a/src/Format/Resource.h +++ b/src/Format/Resource.h @@ -146,6 +146,7 @@ #define IDC_TB 1107 #define IDC_SKIP_RESCUE_VERIFICATION 1108 #define SPARSE_FILE 1109 +#define IDC_FORMAT_TYPE 1110 // Next default values for new objects // @@ -154,7 +155,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 134 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1110 +#define _APS_NEXT_CONTROL_VALUE 1111 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 9143e8c5..658d3797 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -290,6 +290,7 @@ volatile BOOL quickFormat = FALSE; volatile BOOL fastCreateFile = FALSE; volatile BOOL dynamicFormat = FALSE; /* this variable represents the sparse file flag. */ volatile int fileSystem = FILESYS_NONE; +volatile int formatType = FORMAT_TYPE_FULL; volatile int clusterSize = 0; SYSENC_MULTIBOOT_CFG SysEncMultiBootCfg; @@ -324,7 +325,7 @@ void CALLBACK ResumeInPlaceEncWaitThreadProc(void* pArg, HWND hwndDlg) if (device.Path == szDevicePath) { OpenVolumeContext volume; - int status = OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE); + int status = OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, volumePim, FALSE, FALSE, TRUE); if ( status == ERR_SUCCESS) { @@ -370,7 +371,7 @@ void CALLBACK ResumeInPlaceEncWaitThreadProc(void* pArg, HWND hwndDlg) OpenVolumeContext volume; - if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE) == ERR_SUCCESS) + if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, volumePim, FALSE, FALSE, TRUE) == ERR_SUCCESS) { if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0 && volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value) @@ -801,6 +802,8 @@ static void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, ConfigReadCompareInt ("UseLegacyMaxPasswordLength", FALSE, &bUseLegacyMaxPasswordLength, bOnlyCheckModified, pbSettingsModified); + ConfigReadCompareInt ("EMVSupportEnabled", 0, &EMVSupportEnabled, bOnlyCheckModified, pbSettingsModified); + { char szTmp[MAX_PATH] = {0}; WideCharToMultiByte (CP_UTF8, 0, SecurityTokenLibraryPath, -1, szTmp, MAX_PATH, NULL, NULL); @@ -1103,24 +1106,6 @@ BOOL SwitchWizardToSysEncMode (void) if (AskWarnYesNoString ((wstring (GetString ("SYSDRIVE_NON_STANDARD_PARTITIONS")) + L"\n\n" + GetString ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE")).c_str(), MainDlg) == IDYES) bWholeSysDrive = FALSE; } - - if (!IsOSAtLeast (WIN_VISTA) && bWholeSysDrive) - { - if (BootEncObj->SystemDriveContainsExtendedPartition()) - { - bWholeSysDrive = FALSE; - - Error ("WDE_UNSUPPORTED_FOR_EXTENDED_PARTITIONS", MainDlg); - - if (AskYesNo ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE", MainDlg) == IDNO) - { - ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE); - return FALSE; - } - } - else - Warning ("WDE_EXTENDED_PARTITIONS_WARNING", MainDlg); - } } else if (BootEncObj->SystemPartitionCoversWholeDrive() && !bWholeSysDrive) @@ -3459,6 +3444,13 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFr else { LARGE_INTEGER lDiskFree; + // if the file pointed by szFileName already exists, we must add its size to the free space since it will be overwritten durig the volume creation + __int64 lFileSize = GetFileSize64(szFileName); + if (lFileSize != -1) + { + free.QuadPart += lFileSize; + } + lDiskFree.QuadPart = free.QuadPart; if (pFreeSpaceValue) @@ -3702,24 +3694,44 @@ static void UpdateClusterSizeList (HWND hwndDlg, int fsType) SendMessage (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), CB_RESETCONTENT, 0, 0); AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), GetString ("DEFAULT"), 0); - for (int i = 1; i <= 128; i *= 2) + for (int i = 1; i <= 65536; i *= 2) { wstringstream s; DWORD size = GetFormatSectorSize() * i; - if (size > TC_MAX_FAT_CLUSTER_SIZE) + /* cluster size makes sense only when there is a filesystem */ + if (fsType == FILESYS_NONE) + break; + + /* FAT supports at maximum 64K when sector size is 512, and at maximum 256K when sector size is larger than 512 */ + /* For now we set maximum cluster size to 64K in all cases for compatibility with exiting FAT code in VeraCrypt */ + if ((fsType == FILESYS_FAT) && (size > 64*BYTES_PER_KB)) break; /* ReFS supports only 4KiB and 64KiB clusters */ if ((fsType == FILESYS_REFS) && (size != 4*BYTES_PER_KB) && (size != 64*BYTES_PER_KB)) continue; + /* NTFS supports at maximum 2M cluster */ + if ((fsType == FILESYS_NTFS) && (size > 2*BYTES_PER_MB)) + break; + + /* exFAT supports at maximum 32M cluster */ + if ((fsType == FILESYS_EXFAT) && (size > 32*BYTES_PER_MB)) + break; + if (size == 512) - s << L"0.5"; - else + s << L"0.5 " << GetString ("KB"); + else if (size < BYTES_PER_MB) + { s << size / BYTES_PER_KB; - - s << L" " << GetString ("KB"); + s << L" " << GetString ("KB"); + } + else + { + s << size / BYTES_PER_MB; + s << L" " << GetString ("MB"); + } AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), s.str().c_str(), i); } @@ -4183,8 +4195,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) { - // For now, we keep RIPEMD160 for system encryption - if (((hid == RIPEMD160) || !HashIsDeprecated (hid)) && (bSystemIsGPT || HashForSystemEncryption (hid))) + if ((!HashIsDeprecated (hid)) && (bSystemIsGPT || HashForSystemEncryption (hid))) AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); } } @@ -4464,9 +4475,11 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } SetFocus (GetDlgItem (hwndDlg, IDC_PIM)); - + #ifndef WOLFCRYPT_BACKEND SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (SysEncInEffect () && hash_algo != SHA512 && hash_algo != WHIRLPOOL? "PIM_SYSENC_HELP" : "PIM_HELP")); - + #else + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (SysEncInEffect () && hash_algo != SHA512? "PIM_SYSENC_HELP" : "PIM_HELP")); + #endif ToHyperlink (hwndDlg, IDC_LINK_PIM_INFO); if (CreatingHiddenSysVol()) @@ -4962,6 +4975,18 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa else SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("FORMAT_TITLE")); + /* Fill the format type combobox */ + SendMessage (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), CB_RESETCONTENT, 0, 0); + EnableWindow (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), TRUE); + + AddComboPair (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), GetString("FULL_FORMAT"), FORMAT_TYPE_FULL); + AddComboPair (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), GetString("IDC_QUICKFORMAT"), FORMAT_TYPE_QUICK); + if (!bDevice) // Fast Create only makes sens for file containers + AddComboPair (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), GetString("FAST_CREATE"), FORMAT_TYPE_FAST); + SendMessage (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), CB_SETCURSEL, 0, 0); + + formatType = FORMAT_TYPE_FULL; + /* Quick/Dynamic */ if (bHiddenVol) @@ -4973,8 +4998,18 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), FALSE); - SetCheckBox (hwndDlg, IDC_QUICKFORMAT, quickFormat); - EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), bHiddenVolHost); + if (quickFormat) + { + formatType = FORMAT_TYPE_QUICK; + SelectAlgo (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), (int *) &formatType); + } + else if (!bDevice && fastCreateFile) + { + formatType = FORMAT_TYPE_FAST; + quickFormat = TRUE; + SelectAlgo (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), (int *) &formatType); + } + EnableWindow (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), bHiddenVolHost); } else { @@ -4984,7 +5019,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa bSparseFileSwitch = FALSE; SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), FALSE); - EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); + EnableWindow (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), TRUE); } else { @@ -5005,8 +5040,15 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa dynamicFormat = FALSE; SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); } + + if (fastCreateFile) + { + formatType = FORMAT_TYPE_FAST; + quickFormat = TRUE; + SelectAlgo (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), (int *) &formatType); + } EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), bSparseFileSwitch); - EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); + EnableWindow (GetDlgItem (hwndDlg, IDC_FORMAT_TYPE), TRUE); } } @@ -5044,7 +5086,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } //exFAT support added starting from Vista SP1 - if (IsOSVersionAtLeast (WIN_VISTA, 1) && dataAreaSize >= TC_MIN_EXFAT_FS_SIZE && dataAreaSize <= TC_MAX_EXFAT_FS_SIZE) + if (dataAreaSize >= TC_MIN_EXFAT_FS_SIZE && dataAreaSize <= TC_MAX_EXFAT_FS_SIZE) { AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"exFAT", FILESYS_EXFAT); bEXFATallowed = TRUE; @@ -5605,8 +5647,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa Applink ("serpent"); else if (wcscmp (name, L"Twofish") == 0) Applink ("twofish"); - else if (wcscmp (name, L"GOST89") == 0) - Applink ("gost89"); else if (wcscmp (name, L"Kuznyechik") == 0) Applink ("kuznyechik"); else if (wcscmp (name, L"Camellia") == 0) @@ -5865,7 +5905,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { // Select file - if (BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, !bHiddenVolDirect, NULL) == FALSE) + if (BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, !bHiddenVolDirect) == FALSE) return 1; AddComboItem (GetDlgItem (hwndDlg, IDC_COMBO_BOX), szFileName, bHistory); @@ -5962,29 +6002,50 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } - if (lw == IDC_QUICKFORMAT) + if (lw == IDC_FORMAT_TYPE && hw == CBN_SELCHANGE) { - if (IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) + formatType = (int) SendMessage (GetDlgItem (hCurPage, IDC_FORMAT_TYPE), CB_GETITEMDATA, + SendMessage (GetDlgItem (hCurPage, IDC_FORMAT_TYPE), CB_GETCURSEL, 0, 0) , 0); + + if (formatType == FORMAT_TYPE_QUICK) { if (AskWarnYesNo("WARN_QUICK_FORMAT", MainDlg) == IDNO) - SetCheckBox (hwndDlg, IDC_QUICKFORMAT, FALSE); + { + formatType = FORMAT_TYPE_FULL; + SelectAlgo(GetDlgItem (hCurPage, IDC_FORMAT_TYPE), (int *) &formatType); + } } - else if (IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) + else if (formatType == FORMAT_TYPE_FAST) { - /* sparse file require quick format */ - SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + if (AskWarnYesNo("WARN_FAST_CREATE", MainDlg) == IDNO) + { + formatType = FORMAT_TYPE_FULL; + SelectAlgo(GetDlgItem (hCurPage, IDC_FORMAT_TYPE), (int *) &formatType); + } } + return 1; } - if (lw == SPARSE_FILE && IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) + if (lw == SPARSE_FILE) { - if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO) - SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); - else if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT)) && IsWindowEnabled (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) + if (IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) + { + if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO) + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + else + { + /* sparse file require quick format */ + formatType = FORMAT_TYPE_QUICK; + SelectAlgo(GetDlgItem (hCurPage, IDC_FORMAT_TYPE), (int *) &formatType); + EnableWindow(GetDlgItem (hCurPage, IDC_FORMAT_TYPE), FALSE); + } + } + else { - /* sparse file require quick format */ - SetCheckBox (hwndDlg, IDC_QUICKFORMAT, TRUE); + EnableWindow(GetDlgItem (hCurPage, IDC_FORMAT_TYPE), TRUE); + formatType = FORMAT_TYPE_FULL; + SelectAlgo(GetDlgItem (hCurPage, IDC_FORMAT_TYPE), (int *) &formatType); } return 1; } @@ -6035,7 +6096,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { wchar_t tmpszRescueDiskISO [TC_MAX_PATH+1]; - if (!BrowseFiles (hwndDlg, "OPEN_TITLE", tmpszRescueDiskISO, FALSE, TRUE, NULL)) + if (!BrowseFiles (hwndDlg, "OPEN_TITLE", tmpszRescueDiskISO, FALSE, TRUE)) return 1; StringCbCopyW (szRescueDiskISO, sizeof(szRescueDiskISO), tmpszRescueDiskISO); @@ -6180,7 +6241,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (EnableMemoryProtection) { /* Protect this process memory from being accessed by non-admin users */ - EnableProcessProtection (); + ActivateMemoryProtection (); } if (ComServerMode) @@ -6347,13 +6408,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - /* Verify that the volume would not be too large for the operating system */ - if (!IsOSAtLeast (WIN_VISTA) - && nVolumeSize > 2 * BYTES_PER_TB) - { - AbortProcess ("VOLUME_TOO_LARGE_FOR_WINXP"); - } - if (volumePassword.Length > 0) { // Check password length (check also done for outer volume which is not the case in TrueCrypt). @@ -6379,12 +6433,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa else StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.iso"); - if (IsOSAtLeast (WIN_VISTA)) - { - // Availability of in-place encryption (which is pre-selected by default whenever - // possible) makes partition-hosted volume creation safer. - bWarnDeviceFormatAdvanced = FALSE; - } + // Availability of in-place encryption (which is pre-selected by default whenever + // possible) makes partition-hosted volume creation safer. + bWarnDeviceFormatAdvanced = FALSE; #ifdef _DEBUG // For faster testing @@ -6899,7 +6950,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { // Format has been aborted (did not finish) - EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), !(bHiddenVol && !bHiddenVolHost)); + EnableWindow (GetDlgItem (hCurPage, IDC_FORMAT_TYPE), !(bHiddenVol && !bHiddenVolHost)); EnableWindow (GetDlgItem (hCurPage, SPARSE_FILE), (bSparseFileSwitch) && !(bHiddenVol && !bHiddenVolHost)); EnableWindow (GetDlgItem (hCurPage, IDC_FILESYS), TRUE); EnableWindow (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), TRUE); @@ -7161,21 +7212,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (AskWarnYesNoString ((wstring (GetString ("SYSDRIVE_NON_STANDARD_PARTITIONS")) + L"\n\n" + GetString ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE")).c_str(), MainDlg) == IDYES) bWholeSysDrive = FALSE; } - - if (!IsOSAtLeast (WIN_VISTA) && bWholeSysDrive) - { - if (BootEncObj->SystemDriveContainsExtendedPartition()) - { - Error ("WDE_UNSUPPORTED_FOR_EXTENDED_PARTITIONS", MainDlg); - - if (AskYesNo ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE", MainDlg) == IDNO) - return 1; - - bWholeSysDrive = FALSE; - } - else - Warning ("WDE_EXTENDED_PARTITIONS_WARNING", hwndDlg); - } } if (!bWholeSysDrive && BootEncObj->SystemPartitionCoversWholeDrive()) @@ -7233,8 +7269,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (bHiddenOS) { - if (IsOSAtLeast (WIN_7) - && BootEncObj->GetSystemDriveConfiguration().ExtraBootPartitionPresent + if (BootEncObj->GetSystemDriveConfiguration().ExtraBootPartitionPresent && AskWarnYesNo ("CONFIRM_HIDDEN_OS_EXTRA_BOOT_PARTITION", hwndDlg) == IDNO) { TextInfoDialogBox (TC_TBXID_EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS); @@ -7603,13 +7638,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - /* Verify that the volume would not be too large for the operating system */ - - if (!IsOSAtLeast (WIN_VISTA) - && nUIVolumeSize * nMultiplier > 2 * BYTES_PER_TB) - { - Warning ("VOLUME_TOO_LARGE_FOR_WINXP", hwndDlg); - } } if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume @@ -8010,7 +8038,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // Check that it is not a hidden or legacy volume - if (MountVolume (hwndDlg, driveNo, szFileName, &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) + if (MountVolume (hwndDlg, driveNo, szFileName, &volumePassword, hash_algo, volumePim, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) { NormalCursor(); return 1; @@ -8052,7 +8080,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa mountOptions.UseBackupHeader = TRUE; // This must be TRUE at this point (we won't be using the regular header, which will be lost soon after the decryption process starts) - if (MountVolume (hwndDlg, driveNo, szFileName, &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) + if (MountVolume (hwndDlg, driveNo, szFileName, &volumePassword, hash_algo, volumePim, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) { NormalCursor(); return 1; @@ -8499,7 +8527,10 @@ retryCDDriveCheck: clusterSize = (int) SendMessage (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), CB_GETITEMDATA, SendMessage (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), CB_GETCURSEL, 0, 0) , 0); - quickFormat = IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT)); + formatType = (int) SendMessage (GetDlgItem (hCurPage, IDC_FORMAT_TYPE), CB_GETITEMDATA, + SendMessage (GetDlgItem (hCurPage, IDC_FORMAT_TYPE), CB_GETCURSEL, 0, 0) , 0); + quickFormat = (formatType == FORMAT_TYPE_QUICK) || (formatType == FORMAT_TYPE_FAST); + fastCreateFile = (formatType == FORMAT_TYPE_FAST); dynamicFormat = IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE)); if (!dynamicFormat && !bDevice && !(bHiddenVol && !bHiddenVolHost) && (nVolumeSize > (ULONGLONG) nAvailableFreeSpace)) @@ -8598,7 +8629,7 @@ retryCDDriveCheck: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE); - EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), FALSE); + EnableWindow (GetDlgItem (hCurPage, IDC_FORMAT_TYPE), FALSE); EnableWindow (GetDlgItem (hCurPage, SPARSE_FILE), FALSE); EnableWindow (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), FALSE); EnableWindow (GetDlgItem (hCurPage, IDC_FILESYS), FALSE); @@ -9209,7 +9240,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) CmdVolumeFilesystem = FILESYS_FAT; else if (_wcsicmp(szTmp, L"NTFS") == 0) CmdVolumeFilesystem = FILESYS_NTFS; - else if (IsOSVersionAtLeast (WIN_VISTA, 1) && _wcsicmp(szTmp, L"EXFAT") == 0) + else if (_wcsicmp(szTmp, L"EXFAT") == 0) CmdVolumeFilesystem = FILESYS_EXFAT; else if (IsOSVersionAtLeast (WIN_10, 0) && _wcsicmp(szTmp, L"ReFS") == 0) CmdVolumeFilesystem = FILESYS_REFS; @@ -9250,8 +9281,8 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) CmdVolumePkcs5 = SHA512; else if (_wcsicmp(szTmp, L"sha256") == 0) CmdVolumePkcs5 = SHA256; - else if (_wcsicmp(szTmp, L"ripemd160") == 0) - CmdVolumePkcs5 = RIPEMD160; + else if ((_wcsicmp(szTmp, L"blake2s") == 0) || (_wcsicmp(szTmp, L"blake2s-256") == 0)) + CmdVolumePkcs5 = BLAKE2S; else { /* match using internal hash names */ @@ -9538,7 +9569,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) case OptionTokenPin: { - wchar_t szTmp[SecurityToken::MaxPasswordLength + 1] = {0}; + wchar_t szTmp[SecurityToken::MaxPasswordLength + 1] = {0}; // TODO Use Token if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)) == HAS_ARGUMENT) { if (0 == WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, CmdTokenPin, TC_MAX_PATH, nullptr, nullptr)) @@ -9759,11 +9790,18 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi // The map will be scanned to determine the size of the uninterrupted block of free // space (provided there is any) whose end is aligned with the end of the volume. // The value will then be used to determine the maximum possible size of the hidden volume. - - return ScanVolClusterBitmap (hwndDlg, - driveNo, - hiddenVolHostSize / *realClusterSize, - pnbrFreeClusters); + if (*realClusterSize > 0) + { + return ScanVolClusterBitmap (hwndDlg, + driveNo, + hiddenVolHostSize / *realClusterSize, + pnbrFreeClusters); + } + else + { + // should never happen + return -1; + } } else if (!wcsncmp (szFileSystemNameBuffer, L"NTFS", 4) || !_wcsnicmp (szFileSystemNameBuffer, L"exFAT", 5)) { @@ -9835,7 +9873,7 @@ int MountHiddenVolHost (HWND hwndDlg, wchar_t *volumePath, int *driveNo, Passwor mountOptions.PartitionInInactiveSysEncScope = FALSE; mountOptions.UseBackupHeader = FALSE; - if (MountVolume (hwndDlg, *driveNo, volumePath, password, pkcs5_prf, pim, FALSE, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) + if (MountVolume (hwndDlg, *driveNo, volumePath, password, pkcs5_prf, pim, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) { *driveNo = -3; return ERR_VOL_MOUNT_FAILED; @@ -10563,10 +10601,6 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz InitApp (hInstance, lpszCommandLine); - // Write block size greater than 64 KB causes a performance drop when writing to files on XP/Vista - if (!IsOSAtLeast (WIN_7)) - FormatWriteBufferSize = 64 * 1024; - #if TC_MAX_VOLUME_SECTOR_SIZE > 64 * 1024 #error TC_MAX_VOLUME_SECTOR_SIZE > 64 * 1024 #endif @@ -10607,7 +10641,6 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_VOL_CREATION_WIZARD_DLG), NULL, (DLGPROC) MainDialogProc, (LPARAM)lpszCommandLine); - FinalizeApp (); return 0; } |