mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-05-21 21:30:48 -05:00
Normalize all line terminators
This commit is contained in:
+503
-503
File diff suppressed because it is too large
Load Diff
@@ -1,264 +1,264 @@
|
|||||||
This archive contains the source code of VeraCrypt.
|
This archive contains the source code of VeraCrypt.
|
||||||
It is based on original TrueCrypt 7.1a with security enhancements and modifications.
|
It is based on original TrueCrypt 7.1a with security enhancements and modifications.
|
||||||
|
|
||||||
|
|
||||||
Important
|
Important
|
||||||
=========
|
=========
|
||||||
|
|
||||||
You may use the source code contained in this archive only if you accept and
|
You may use the source code contained in this archive only if you accept and
|
||||||
agree to the license terms contained in the file 'License.txt', which is
|
agree to the license terms contained in the file 'License.txt', which is
|
||||||
included in this archive.
|
included in this archive.
|
||||||
|
|
||||||
Note that the license specifies, for example, that a derived work must not be
|
Note that the license specifies, for example, that a derived work must not be
|
||||||
called 'TrueCrypt' or 'VeraCrypt'
|
called 'TrueCrypt' or 'VeraCrypt'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Contents
|
Contents
|
||||||
========
|
========
|
||||||
|
|
||||||
I. Windows
|
I. Windows
|
||||||
Requirements for Building VeraCrypt for Windows
|
Requirements for Building VeraCrypt for Windows
|
||||||
Instructions for Building VeraCrypt for Windows
|
Instructions for Building VeraCrypt for Windows
|
||||||
Instructions for Signing and Packaging VeraCrypt for Windows
|
Instructions for Signing and Packaging VeraCrypt for Windows
|
||||||
|
|
||||||
II. Linux and Mac OS X
|
II. Linux and Mac OS X
|
||||||
Requirements for Building VeraCrypt for Linux and Mac OS X
|
Requirements for Building VeraCrypt for Linux and Mac OS X
|
||||||
Instructions for Building VeraCrypt for Linux and Mac OS X
|
Instructions for Building VeraCrypt for Linux and Mac OS X
|
||||||
Mac OS X specifics
|
Mac OS X specifics
|
||||||
|
|
||||||
III. FreeBSD and OpenSolaris
|
III. FreeBSD and OpenSolaris
|
||||||
|
|
||||||
IV. Third-Party Developers (Contributors)
|
IV. Third-Party Developers (Contributors)
|
||||||
|
|
||||||
V. Legal Information
|
V. Legal Information
|
||||||
|
|
||||||
VI. Further Information
|
VI. Further Information
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
I. Windows
|
I. Windows
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Requirements for Building VeraCrypt for Windows:
|
Requirements for Building VeraCrypt for Windows:
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
- Microsoft Visual C++ 2008 SP1 (Professional Edition or compatible)
|
- Microsoft Visual C++ 2008 SP1 (Professional Edition or compatible)
|
||||||
- Microsoft Visual C++ 1.52 (available from MSDN Subscriber Downloads)
|
- Microsoft Visual C++ 1.52 (available from MSDN Subscriber Downloads)
|
||||||
- Microsoft Windows SDK for Windows 7 (configured for Visual C++)
|
- Microsoft Windows SDK for Windows 7 (configured for Visual C++)
|
||||||
- Microsoft Windows SDK for Windows 8.1 (needed for SHA-256 code signing)
|
- Microsoft Windows SDK for Windows 8.1 (needed for SHA-256 code signing)
|
||||||
- Microsoft Windows Driver Kit 7.1.0 (build 7600.16385.1)
|
- Microsoft Windows Driver Kit 7.1.0 (build 7600.16385.1)
|
||||||
- RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) 2.20
|
- RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) 2.20
|
||||||
header files (available at ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20)
|
header files (available at ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20)
|
||||||
- NASM assembler 2.08 or compatible
|
- NASM assembler 2.08 or compatible
|
||||||
- gzip compressor
|
- gzip compressor
|
||||||
- upx packer (available at http://upx.sourceforge.net/)
|
- upx packer (available at http://upx.sourceforge.net/)
|
||||||
|
|
||||||
IMPORTANT:
|
IMPORTANT:
|
||||||
|
|
||||||
The 64-bit editions of Windows Vista and later versions of Windows, and in
|
The 64-bit editions of Windows Vista and later versions of Windows, and in
|
||||||
some cases (e.g. playback of HD DVD content) also the 32-bit editions, do not
|
some cases (e.g. playback of HD DVD content) also the 32-bit editions, do not
|
||||||
allow the VeraCrypt driver to run without an appropriate digital signature.
|
allow the VeraCrypt driver to run without an appropriate digital signature.
|
||||||
Therefore, all .sys files in official VeraCrypt binary packages are digitally
|
Therefore, all .sys files in official VeraCrypt binary packages are digitally
|
||||||
signed with the digital certificate of the IDRIX, which was
|
signed with the digital certificate of the IDRIX, which was
|
||||||
issued by Thawte certification authority. At the end of each official .exe and
|
issued by Thawte certification authority. At the end of each official .exe and
|
||||||
.sys file, there are embedded digital signatures and all related certificates
|
.sys file, there are embedded digital signatures and all related certificates
|
||||||
(i.e. all certificates in the relevant certification chain, such as the
|
(i.e. all certificates in the relevant certification chain, such as the
|
||||||
certification authority certificates, CA-MS cross-certificate, and the
|
certification authority certificates, CA-MS cross-certificate, and the
|
||||||
IDRIX certificate).
|
IDRIX certificate).
|
||||||
Keep this in mind if you compile VeraCrypt
|
Keep this in mind if you compile VeraCrypt
|
||||||
and compare your binaries with the official binaries. If your binaries are
|
and compare your binaries with the official binaries. If your binaries are
|
||||||
unsigned, the sizes of the official binaries will usually be approximately
|
unsigned, the sizes of the official binaries will usually be approximately
|
||||||
10 KB greater than sizes of your binaries (there may be further differences
|
10 KB greater than sizes of your binaries (there may be further differences
|
||||||
if you use a different version of the compiler, or if you install a different
|
if you use a different version of the compiler, or if you install a different
|
||||||
or no service pack for Visual Studio, or different hotfixes for it, or if you
|
or no service pack for Visual Studio, or different hotfixes for it, or if you
|
||||||
use different versions of the required SDKs).
|
use different versions of the required SDKs).
|
||||||
|
|
||||||
|
|
||||||
Instructions for Building VeraCrypt for Windows:
|
Instructions for Building VeraCrypt for Windows:
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
1) Create an environment variable 'MSVC16_ROOT' pointing to the folder 'MSVC15'
|
1) Create an environment variable 'MSVC16_ROOT' pointing to the folder 'MSVC15'
|
||||||
extracted from the Visual C++ 1.52 self-extracting package.
|
extracted from the Visual C++ 1.52 self-extracting package.
|
||||||
|
|
||||||
Note: The 16-bit installer MSVC15\SETUP.EXE cannot be run on 64-bit Windows,
|
Note: The 16-bit installer MSVC15\SETUP.EXE cannot be run on 64-bit Windows,
|
||||||
but it is actually not necessary to run it. You only need to extract the
|
but it is actually not necessary to run it. You only need to extract the
|
||||||
folder 'MSVC15', which contains the 32-bit binaries required to build the
|
folder 'MSVC15', which contains the 32-bit binaries required to build the
|
||||||
VeraCrypt Boot Loader.
|
VeraCrypt Boot Loader.
|
||||||
|
|
||||||
2) If you have installed the Windows Driver Development Kit in another
|
2) If you have installed the Windows Driver Development Kit in another
|
||||||
directory than '%SYSTEMDRIVE%\WinDDK', create an environment variable
|
directory than '%SYSTEMDRIVE%\WinDDK', create an environment variable
|
||||||
'WINDDK_ROOT' pointing to the DDK installation directory.
|
'WINDDK_ROOT' pointing to the DDK installation directory.
|
||||||
|
|
||||||
3) Copy the PKCS #11 header files to a standard include path or create an
|
3) Copy the PKCS #11 header files to a standard include path or create an
|
||||||
environment variable 'PKCS11_INC' pointing to the directory where
|
environment variable 'PKCS11_INC' pointing to the directory where
|
||||||
the PKCS #11 header files are installed.
|
the PKCS #11 header files are installed.
|
||||||
|
|
||||||
4) Open the solution file 'VeraCrypt.sln' in Microsoft Visual Studio 2008.
|
4) Open the solution file 'VeraCrypt.sln' in Microsoft Visual Studio 2008.
|
||||||
|
|
||||||
5) Select 'All' as the active solution configuration.
|
5) Select 'All' as the active solution configuration.
|
||||||
|
|
||||||
6) Build the solution.
|
6) Build the solution.
|
||||||
|
|
||||||
7) If successful, there should be newly built VeraCrypt binaries in the
|
7) If successful, there should be newly built VeraCrypt binaries in the
|
||||||
'Release' folder.
|
'Release' folder.
|
||||||
|
|
||||||
Instructions for Signing and Packaging VeraCrypt for Windows:
|
Instructions for Signing and Packaging VeraCrypt for Windows:
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
|
|
||||||
First, create an environment variable 'WSDK81' pointing to the Windows SDK
|
First, create an environment variable 'WSDK81' pointing to the Windows SDK
|
||||||
for Windows 8.1 installation directory.
|
for Windows 8.1 installation directory.
|
||||||
The folder "Signing" contains a batch file (sign.bat) that will sign all
|
The folder "Signing" contains a batch file (sign.bat) that will sign all
|
||||||
VeraCrypt components using a code signing certificate present on the
|
VeraCrypt components using a code signing certificate present on the
|
||||||
certificate store and also build the final installation setup.
|
certificate store and also build the final installation setup.
|
||||||
The batch file suppose that the code signing certificate is issued by Thawt.
|
The batch file suppose that the code signing certificate is issued by Thawt.
|
||||||
This is the case for IDRIX's certificate. If yours is issued by another CA,
|
This is the case for IDRIX's certificate. If yours is issued by another CA,
|
||||||
then you should put the Root and Intermediate certificates in the "Signing"
|
then you should put the Root and Intermediate certificates in the "Signing"
|
||||||
folder and then modify sign.bat accordingly.
|
folder and then modify sign.bat accordingly.
|
||||||
|
|
||||||
|
|
||||||
II. Linux and Mac OS X
|
II. Linux and Mac OS X
|
||||||
======================
|
======================
|
||||||
|
|
||||||
Requirements for Building VeraCrypt for Linux and Mac OS X:
|
Requirements for Building VeraCrypt for Linux and Mac OS X:
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
|
||||||
- GNU Make
|
- GNU Make
|
||||||
- GNU C++ Compiler 4.0 or compatible
|
- GNU C++ Compiler 4.0 or compatible
|
||||||
- Apple Xcode (Mac OS X only)
|
- Apple Xcode (Mac OS X only)
|
||||||
- NASM assembler 2.08 or compatible (x86/x64 architecture only)
|
- NASM assembler 2.08 or compatible (x86/x64 architecture only)
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- makeself (Linux only)
|
- makeself (Linux only)
|
||||||
- wxWidgets 3.0 shared library and header files installed or
|
- wxWidgets 3.0 shared library and header files installed or
|
||||||
wxWidgets 3.0 library source code (available at http://www.wxwidgets.org)
|
wxWidgets 3.0 library source code (available at http://www.wxwidgets.org)
|
||||||
- FUSE library and header files (available at https://github.com/libfuse/libfuse
|
- FUSE library and header files (available at https://github.com/libfuse/libfuse
|
||||||
and https://osxfuse.github.io/)
|
and https://osxfuse.github.io/)
|
||||||
- RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) 2.20
|
- RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) 2.20
|
||||||
header files (available at ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20).
|
header files (available at ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20).
|
||||||
They are already included in the source tree under the directory PKCS11 but
|
They are already included in the source tree under the directory PKCS11 but
|
||||||
it is possible to override it using the environment variable 'PKCS11_INC'.
|
it is possible to override it using the environment variable 'PKCS11_INC'.
|
||||||
|
|
||||||
|
|
||||||
Instructions for Building VeraCrypt for Linux and Mac OS X:
|
Instructions for Building VeraCrypt for Linux and Mac OS X:
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
|
||||||
1) Change the current directory to the root of the VeraCrypt source code.
|
1) Change the current directory to the root of the VeraCrypt source code.
|
||||||
|
|
||||||
2) If you have no wxWidgets shared library installed, run the following
|
2) If you have no wxWidgets shared library installed, run the following
|
||||||
command to configure the wxWidgets static library for VeraCrypt and to
|
command to configure the wxWidgets static library for VeraCrypt and to
|
||||||
build it:
|
build it:
|
||||||
|
|
||||||
$ make WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild
|
$ make WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild
|
||||||
|
|
||||||
The variable WX_ROOT must point to the location of the source code of the
|
The variable WX_ROOT must point to the location of the source code of the
|
||||||
wxWidgets library. Output files will be placed in the './wxrelease/'
|
wxWidgets library. Output files will be placed in the './wxrelease/'
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
3) To build VeraCrypt, run the following command:
|
3) To build VeraCrypt, run the following command:
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
or if you have no wxWidgets shared library installed:
|
or if you have no wxWidgets shared library installed:
|
||||||
|
|
||||||
$ make WXSTATIC=1
|
$ make WXSTATIC=1
|
||||||
|
|
||||||
4) If successful, the VeraCrypt executable should be located in the directory
|
4) If successful, the VeraCrypt executable should be located in the directory
|
||||||
'Main'.
|
'Main'.
|
||||||
|
|
||||||
By default, a universal executable supporting both graphical and text user
|
By default, a universal executable supporting both graphical and text user
|
||||||
interface (through the switch --text) is built.
|
interface (through the switch --text) is built.
|
||||||
On Linux, a console-only executable, which requires no GUI library, can be
|
On Linux, a console-only executable, which requires no GUI library, can be
|
||||||
built using the 'NOGUI' parameter:
|
built using the 'NOGUI' parameter:
|
||||||
|
|
||||||
$ make NOGUI=1 WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild
|
$ make NOGUI=1 WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild
|
||||||
$ make NOGUI=1 WXSTATIC=1
|
$ make NOGUI=1 WXSTATIC=1
|
||||||
|
|
||||||
On MacOSX, building a console-only executable is not supported.
|
On MacOSX, building a console-only executable is not supported.
|
||||||
|
|
||||||
Mac OS X specifics:
|
Mac OS X specifics:
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
|
||||||
Under MacOSX, the SDK for OSX 10.7 is used by default. To use another version
|
Under MacOSX, the SDK for OSX 10.7 is used by default. To use another version
|
||||||
of the SDK (i.e. 10.6), you can export the environment variable VC_OSX_TARGET:
|
of the SDK (i.e. 10.6), you can export the environment variable VC_OSX_TARGET:
|
||||||
|
|
||||||
$ export VC_OSX_TARGET=10.6
|
$ export VC_OSX_TARGET=10.6
|
||||||
|
|
||||||
|
|
||||||
Before building under MacOSX, pkg-config must be installed if not yet available.
|
Before building under MacOSX, pkg-config must be installed if not yet available.
|
||||||
Get it from http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz and
|
Get it from http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz and
|
||||||
compile using the following commands :
|
compile using the following commands :
|
||||||
|
|
||||||
$ ./configure --with-internal-glib
|
$ ./configure --with-internal-glib
|
||||||
$ make
|
$ make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
|
|
||||||
After making sure pkg-config is available, download and install OSXFuse from
|
After making sure pkg-config is available, download and install OSXFuse from
|
||||||
https://osxfuse.github.io/ (MacFUSE compatibility layer must selected)
|
https://osxfuse.github.io/ (MacFUSE compatibility layer must selected)
|
||||||
|
|
||||||
The script build_veracrypt_macosx.sh available under "src/Build" performs the
|
The script build_veracrypt_macosx.sh available under "src/Build" performs the
|
||||||
full build of VeraCrypt including the creation of the installer pkg. It expects
|
full build of VeraCrypt including the creation of the installer pkg. It expects
|
||||||
to find the wxWidgets 3.0.2 sources at the same level as where you put
|
to find the wxWidgets 3.0.2 sources at the same level as where you put
|
||||||
VeraCrypt sources (i.e. if "src" path is "/Users/joe/Projects/VeraCrypt/src"
|
VeraCrypt sources (i.e. if "src" path is "/Users/joe/Projects/VeraCrypt/src"
|
||||||
then wxWidgets should be at "/Users/joe/Projects/wxWidgets-wxWidgets-3.0.2")
|
then wxWidgets should be at "/Users/joe/Projects/wxWidgets-wxWidgets-3.0.2")
|
||||||
|
|
||||||
The build process uses Code Signing certificates whose ID is specified in
|
The build process uses Code Signing certificates whose ID is specified in
|
||||||
src/Main/Main.make (lines 167 & 169). You'll have to modify these lines to put
|
src/Main/Main.make (lines 167 & 169). You'll have to modify these lines to put
|
||||||
the ID of your Code Signing certificates or comment them if you don't have one.
|
the ID of your Code Signing certificates or comment them if you don't have one.
|
||||||
|
|
||||||
Because of incompatibility issues with OSXFUSE, the SDK 10.9 generates a
|
Because of incompatibility issues with OSXFUSE, the SDK 10.9 generates a
|
||||||
VeraCrypt binary that has issues communicating with the OSXFUSE kernel extension.
|
VeraCrypt binary that has issues communicating with the OSXFUSE kernel extension.
|
||||||
Thus, we recommend to use the SDK 10.8 or earlier for building VeraCrypt.
|
Thus, we recommend to use the SDK 10.8 or earlier for building VeraCrypt.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
III. FreeBSD and OpenSolaris
|
III. FreeBSD and OpenSolaris
|
||||||
============================
|
============================
|
||||||
|
|
||||||
FreeBSD and OpenSolaris are not yet supported.
|
FreeBSD and OpenSolaris are not yet supported.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IV. Third-Party Developers (Contributors)
|
IV. Third-Party Developers (Contributors)
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
If you intend to implement a feature, please contact us first to make sure:
|
If you intend to implement a feature, please contact us first to make sure:
|
||||||
|
|
||||||
1) That the feature has not been implemented (we may have already implemented
|
1) That the feature has not been implemented (we may have already implemented
|
||||||
it, but haven't released the code yet).
|
it, but haven't released the code yet).
|
||||||
2) That the feature is acceptable.
|
2) That the feature is acceptable.
|
||||||
3) Whether we need help of third-party developers with implementing the feature.
|
3) Whether we need help of third-party developers with implementing the feature.
|
||||||
|
|
||||||
Information on how to contact us can be found at:
|
Information on how to contact us can be found at:
|
||||||
https://veracrypt.codeplex.com/
|
https://veracrypt.codeplex.com/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
V. Legal Information
|
V. Legal Information
|
||||||
====================
|
====================
|
||||||
|
|
||||||
Copyright Information
|
Copyright Information
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
This software as a whole:
|
This software as a whole:
|
||||||
Copyright (c) 2013-2015 IDRIX. All rights reserved.
|
Copyright (c) 2013-2015 IDRIX. All rights reserved.
|
||||||
|
|
||||||
Portions of this software:
|
Portions of this software:
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association. All rights reserved.
|
Copyright (c) 2003-2012 TrueCrypt Developers Association. All rights reserved.
|
||||||
Copyright (c) 1998-2000 Paul Le Roux. All rights reserved.
|
Copyright (c) 1998-2000 Paul Le Roux. All rights reserved.
|
||||||
Copyright (c) 1998-2008 Brian Gladman, Worcester, UK. All rights reserved.
|
Copyright (c) 1998-2008 Brian Gladman, Worcester, UK. All rights reserved.
|
||||||
Copyright (c) 2002-2004 Mark Adler. All rights reserved.
|
Copyright (c) 2002-2004 Mark Adler. All rights reserved.
|
||||||
For more information, please see the legal notices attached to parts of the
|
For more information, please see the legal notices attached to parts of the
|
||||||
source code.
|
source code.
|
||||||
|
|
||||||
Trademark Information
|
Trademark Information
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Any trademarks contained in the source code, binaries, and/or in the
|
Any trademarks contained in the source code, binaries, and/or in the
|
||||||
documentation, are the sole property of their respective owners.
|
documentation, are the sole property of their respective owners.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VI. Further Information
|
VI. Further Information
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
http://www.veracrypt.fr
|
http://www.veracrypt.fr
|
||||||
|
|||||||
+321
-321
@@ -1,321 +1,321 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
call :freedrive mydriveletter && goto :cont
|
call :freedrive mydriveletter && goto :cont
|
||||||
echo ERROR: No free drive letter found.
|
echo ERROR: No free drive letter found.
|
||||||
goto :exit
|
goto :exit
|
||||||
:cont
|
:cont
|
||||||
|
|
||||||
echo Using drive letter %mydriveletter%: for our tests
|
echo Using drive letter %mydriveletter%: for our tests
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
IF NOT EXIST test.sha512.hc GOTO :whirlpool
|
IF NOT EXIST test.sha512.hc GOTO :whirlpool
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount SHA-512 container (Normal)
|
rem Mount SHA-512 container (Normal)
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha512.hc /hash sha512 /l %mydriveletter% /password test /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha512.hc /hash sha512 /l %mydriveletter% /password test /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo SHA-512 (Normal) = %hh%:%mm%:%ss%,%cc%
|
echo SHA-512 (Normal) = %hh%:%mm%:%ss%,%cc%
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount SHA-512 container (Hidden)
|
rem Mount SHA-512 container (Hidden)
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha512.hc /hash sha512 /l %mydriveletter% /password testhidden /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha512.hc /hash sha512 /l %mydriveletter% /password testhidden /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo SHA-512 (Hidden) = %hh%:%mm%:%ss%,%cc%
|
echo SHA-512 (Hidden) = %hh%:%mm%:%ss%,%cc%
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
:whirlpool
|
:whirlpool
|
||||||
|
|
||||||
IF NOT EXIST test.whirlpool.hc GOTO :sha256
|
IF NOT EXIST test.whirlpool.hc GOTO :sha256
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount Whirlpool container (Normal).
|
rem Mount Whirlpool container (Normal).
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.whirlpool.hc /hash whirlpool /l %mydriveletter% /password test /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.whirlpool.hc /hash whirlpool /l %mydriveletter% /password test /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo Whirlpool (Normal) = %hh%:%mm%:%ss%,%cc%
|
echo Whirlpool (Normal) = %hh%:%mm%:%ss%,%cc%
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount Whirlpool container (Hidden).
|
rem Mount Whirlpool container (Hidden).
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.whirlpool.hc /hash whirlpool /l %mydriveletter% /password testhidden /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.whirlpool.hc /hash whirlpool /l %mydriveletter% /password testhidden /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo Whirlpool (Hidden) = %hh%:%mm%:%ss%,%cc%
|
echo Whirlpool (Hidden) = %hh%:%mm%:%ss%,%cc%
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
:sha256
|
:sha256
|
||||||
|
|
||||||
IF NOT EXIST test.sha256.hc GOTO :ripemd160
|
IF NOT EXIST test.sha256.hc GOTO :ripemd160
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount SHA-256 container (Normal)
|
rem Mount SHA-256 container (Normal)
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha256.hc /hash sha256 /l %mydriveletter% /password test /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha256.hc /hash sha256 /l %mydriveletter% /password test /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo SHA-256 (Normal) = %hh%:%mm%:%ss%,%cc%
|
echo SHA-256 (Normal) = %hh%:%mm%:%ss%,%cc%
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount SHA-256 container (Hidden)
|
rem Mount SHA-256 container (Hidden)
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha256.hc /hash sha256 /l %mydriveletter% /password testhidden /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.sha256.hc /hash sha256 /l %mydriveletter% /password testhidden /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo SHA-256 (Hidden) = %hh%:%mm%:%ss%,%cc%
|
echo SHA-256 (Hidden) = %hh%:%mm%:%ss%,%cc%
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
:ripemd160
|
:ripemd160
|
||||||
|
|
||||||
IF NOT EXIST test.ripemd160.hc GOTO :autodetect
|
IF NOT EXIST test.ripemd160.hc GOTO :autodetect
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount RIPEMD-160 container (Normal)
|
rem Mount RIPEMD-160 container (Normal)
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.ripemd160.hc /hash ripemd160 /l %mydriveletter% /password test /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.ripemd160.hc /hash ripemd160 /l %mydriveletter% /password test /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo RIPEMD-160 (Normal) = %hh%:%mm%:%ss%,%cc%
|
echo RIPEMD-160 (Normal) = %hh%:%mm%:%ss%,%cc%
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Mount RIPEMD-160 container (Hidden)
|
rem Mount RIPEMD-160 container (Hidden)
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.ripemd160.hc /hash ripemd160 /l %mydriveletter% /password testhidden /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume test.ripemd160.hc /hash ripemd160 /l %mydriveletter% /password testhidden /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo RIPEMD-160 (Hidden) = %hh%:%mm%:%ss%,%cc%
|
echo RIPEMD-160 (Hidden) = %hh%:%mm%:%ss%,%cc%
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /dismount %mydriveletter% /silent /q
|
||||||
|
|
||||||
:autodetect
|
:autodetect
|
||||||
|
|
||||||
call :availablevolume testvolume && goto :contautodetect
|
call :availablevolume testvolume && goto :contautodetect
|
||||||
goto :exit
|
goto :exit
|
||||||
:contautodetect
|
:contautodetect
|
||||||
|
|
||||||
rem Get start time:
|
rem Get start time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Try to mount with a wrong password and PRF autodetection
|
rem Try to mount with a wrong password and PRF autodetection
|
||||||
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume %testvolume% /l %mydriveletter% /password wrongpassword /q /silent /m ro
|
"c:\Program Files\VeraCrypt\veracrypt.exe" /volume %testvolume% /l %mydriveletter% /password wrongpassword /q /silent /m ro
|
||||||
|
|
||||||
rem Get end time:
|
rem Get end time:
|
||||||
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
for /F "tokens=1-4 delims=:.," %%a in ("%time%") do (
|
||||||
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
||||||
)
|
)
|
||||||
|
|
||||||
rem Get elapsed time:
|
rem Get elapsed time:
|
||||||
set /A elapsed=end-start
|
set /A elapsed=end-start
|
||||||
|
|
||||||
rem Show elapsed time:
|
rem Show elapsed time:
|
||||||
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100
|
||||||
if %hh% lss 10 set hh=0%hh%
|
if %hh% lss 10 set hh=0%hh%
|
||||||
if %mm% lss 10 set mm=0%mm%
|
if %mm% lss 10 set mm=0%mm%
|
||||||
if %ss% lss 10 set ss=0%ss%
|
if %ss% lss 10 set ss=0%ss%
|
||||||
if %cc% lss 10 set cc=0%cc%
|
if %cc% lss 10 set cc=0%cc%
|
||||||
echo Wrong Password (PRF Auto-detection)= %hh%:%mm%:%ss%,%cc%
|
echo Wrong Password (PRF Auto-detection)= %hh%:%mm%:%ss%,%cc%
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
|
|
||||||
goto :exit
|
goto :exit
|
||||||
|
|
||||||
rem Finds a free drive letter.
|
rem Finds a free drive letter.
|
||||||
rem
|
rem
|
||||||
rem Parameters:
|
rem Parameters:
|
||||||
rem %1 = Output variable name.
|
rem %1 = Output variable name.
|
||||||
rem
|
rem
|
||||||
rem Example:
|
rem Example:
|
||||||
rem call :freedrive mydriveletter && goto :cont
|
rem call :freedrive mydriveletter && goto :cont
|
||||||
rem echo ERROR: No free drive letter found.
|
rem echo ERROR: No free drive letter found.
|
||||||
rem goto :EOF
|
rem goto :EOF
|
||||||
rem :cont
|
rem :cont
|
||||||
rem echo Found drive letter: %mydriveletter%
|
rem echo Found drive letter: %mydriveletter%
|
||||||
:freedrive
|
:freedrive
|
||||||
setlocal EnableDelayedExpansion
|
setlocal EnableDelayedExpansion
|
||||||
set exitcode=0
|
set exitcode=0
|
||||||
set "output_var=%~1"
|
set "output_var=%~1"
|
||||||
for %%i in (C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (
|
for %%i in (C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (
|
||||||
set "drive=%%i:"
|
set "drive=%%i:"
|
||||||
rem If 'subst' fails, the drive letter is already in use.
|
rem If 'subst' fails, the drive letter is already in use.
|
||||||
rem This way we can even detect optical drives that have a drive
|
rem This way we can even detect optical drives that have a drive
|
||||||
rem letter but no media in them, a case that goes undetected when
|
rem letter but no media in them, a case that goes undetected when
|
||||||
rem using 'if exist'.
|
rem using 'if exist'.
|
||||||
subst !drive! %SystemDrive%\ >nul
|
subst !drive! %SystemDrive%\ >nul
|
||||||
if !errorlevel! == 0 (
|
if !errorlevel! == 0 (
|
||||||
subst !drive! /d >nul
|
subst !drive! /d >nul
|
||||||
set "drive=%%i"
|
set "drive=%%i"
|
||||||
goto :freedrive0
|
goto :freedrive0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
set exitcode=1
|
set exitcode=1
|
||||||
set drive=
|
set drive=
|
||||||
:freedrive0
|
:freedrive0
|
||||||
endlocal & set "%output_var%=%drive%" & exit /b %exitcode%
|
endlocal & set "%output_var%=%drive%" & exit /b %exitcode%
|
||||||
|
|
||||||
:availablevolume
|
:availablevolume
|
||||||
setlocal EnableDelayedExpansion
|
setlocal EnableDelayedExpansion
|
||||||
set exitcode=0
|
set exitcode=0
|
||||||
set "output_var=%~1"
|
set "output_var=%~1"
|
||||||
for %%i in (test.sha512.hc,test.sha256.hc,test.whirlpool.hc,test.ripemd160.hc) do (
|
for %%i in (test.sha512.hc,test.sha256.hc,test.whirlpool.hc,test.ripemd160.hc) do (
|
||||||
if exist %%i (
|
if exist %%i (
|
||||||
set "volume=%%i"
|
set "volume=%%i"
|
||||||
goto :availablevolume0
|
goto :availablevolume0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
set exitcode=1
|
set exitcode=1
|
||||||
set volume=
|
set volume=
|
||||||
:availablevolume0
|
:availablevolume0
|
||||||
endlocal & set "%output_var%=%volume%" & exit /b %exitcode%
|
endlocal & set "%output_var%=%volume%" & exit /b %exitcode%
|
||||||
|
|
||||||
:exit
|
:exit
|
||||||
|
|||||||
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1458
-1458
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1458
-1458
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1458
-1458
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1457
-1457
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1451
-1451
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1454
-1454
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1456
-1456
File diff suppressed because it is too large
Load Diff
+1455
-1455
File diff suppressed because it is too large
Load Diff
+1453
-1453
File diff suppressed because it is too large
Load Diff
+32
-32
@@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_Bios
|
#ifndef TC_HEADER_Boot_Bios
|
||||||
#define TC_HEADER_Boot_Bios
|
#define TC_HEADER_Boot_Bios
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
#define TC_LB_SIZE_BIT_SHIFT_DIVISOR 9
|
#define TC_LB_SIZE_BIT_SHIFT_DIVISOR 9
|
||||||
|
|
||||||
#define TC_FIRST_BIOS_DRIVE 0x80
|
#define TC_FIRST_BIOS_DRIVE 0x80
|
||||||
#define TC_LAST_BIOS_DRIVE 0x8f
|
#define TC_LAST_BIOS_DRIVE 0x8f
|
||||||
#define TC_INVALID_BIOS_DRIVE (TC_FIRST_BIOS_DRIVE - 1)
|
#define TC_INVALID_BIOS_DRIVE (TC_FIRST_BIOS_DRIVE - 1)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BiosResultSuccess = 0x00,
|
BiosResultSuccess = 0x00,
|
||||||
BiosResultInvalidFunction = 0x01
|
BiosResultInvalidFunction = 0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef byte BiosResult;
|
typedef byte BiosResult;
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_Bios
|
#endif // TC_HEADER_Boot_Bios
|
||||||
|
|||||||
+246
-246
@@ -1,246 +1,246 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="Boot"
|
Name="Boot"
|
||||||
ProjectGUID="{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}"
|
ProjectGUID="{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}"
|
||||||
RootNamespace="Boot"
|
RootNamespace="Boot"
|
||||||
Keyword="MakeFileProj"
|
Keyword="MakeFileProj"
|
||||||
TargetFrameworkVersion="131072"
|
TargetFrameworkVersion="131072"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(ConfigurationName)"
|
OutputDirectory="$(ConfigurationName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
ConfigurationType="0"
|
ConfigurationType="0"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCNMakeTool"
|
Name="VCNMakeTool"
|
||||||
BuildCommandLine="md Release 2>NUL:
nmake.exe /nologo RELEASE=1

md Release_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_PRF=SHA2

md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

md Release_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES SINGLE_PRF=SHA2

md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

md Release_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT SINGLE_PRF=SHA2

md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH

md Release_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH SINGLE_PRF=SHA2

md Rescue 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1

md Rescue_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1

md Rescue_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1

md Rescue_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1

md Rescue_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1 SINGLE_PRF=SHA2"
|
BuildCommandLine="md Release 2>NUL:
nmake.exe /nologo RELEASE=1

md Release_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_PRF=SHA2

md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

md Release_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES SINGLE_PRF=SHA2

md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

md Release_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT SINGLE_PRF=SHA2

md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH

md Release_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH SINGLE_PRF=SHA2

md Rescue 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1

md Rescue_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1

md Rescue_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1

md Rescue_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1

md Rescue_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1 SINGLE_PRF=SHA2"
|
||||||
ReBuildCommandLine="del /q /s Release >NUL:
md Release 2>NUL:
nmake.exe /nologo RELEASE=1

del /q /s Release_SHA2 >NUL:
md Release_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_PRF=SHA2

del /q /s Release_AES >NUL:
md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

del /q /s Release_AES_SHA2 >NUL:
md Release_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES SINGLE_PRF=SHA2

del /q /s Release_Serpent >NUL:
md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

del /q /s Release_Serpent_SHA2 >NUL:
md Release_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT SINGLE_PRF=SHA2

del /q /s Release_Twofish >NUL:
md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH

del /q /s Release_Twofish_SHA2 >NUL:
md Release_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH SINGLE_PRF=SHA2

del /q /s Rescue >NUL:
md Rescue 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1

del /q /s Rescue_SHA2 >NUL:
md Rescue_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_AES >NUL:
md Rescue_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1

del /q /s Rescue_AES_SHA2 >NUL:
md Rescue_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Serpent >NUL:
md Rescue_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1

del /q /s Rescue_Serpent_SHA2 >NUL:
md Rescue_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Twofish >NUL:
md Rescue_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1

del /q /s Rescue_Twofish_SHA2 >NUL:
md Rescue_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1 SINGLE_PRF=SHA2"
|
ReBuildCommandLine="del /q /s Release >NUL:
md Release 2>NUL:
nmake.exe /nologo RELEASE=1

del /q /s Release_SHA2 >NUL:
md Release_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_PRF=SHA2

del /q /s Release_AES >NUL:
md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

del /q /s Release_AES_SHA2 >NUL:
md Release_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES SINGLE_PRF=SHA2

del /q /s Release_Serpent >NUL:
md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

del /q /s Release_Serpent_SHA2 >NUL:
md Release_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT SINGLE_PRF=SHA2

del /q /s Release_Twofish >NUL:
md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH

del /q /s Release_Twofish_SHA2 >NUL:
md Release_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH SINGLE_PRF=SHA2

del /q /s Rescue >NUL:
md Rescue 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1

del /q /s Rescue_SHA2 >NUL:
md Rescue_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_AES >NUL:
md Rescue_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1

del /q /s Rescue_AES_SHA2 >NUL:
md Rescue_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Serpent >NUL:
md Rescue_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1

del /q /s Rescue_Serpent_SHA2 >NUL:
md Rescue_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Twofish >NUL:
md Rescue_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1

del /q /s Rescue_Twofish_SHA2 >NUL:
md Rescue_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1 SINGLE_PRF=SHA2"
|
||||||
CleanCommandLine="del /q /s Release Release_AES Release_Serpent Release_Twofish Rescue Rescue_AES Rescue_Serpent Rescue_Twofish >NUL:
del /q /s Release_SHA2 Release_AES_SHA2 Release_Serpent_SHA2 Release_Twofish_SHA2 Rescue_SHA2 Rescue_AES_SHA2 Rescue_Serpent_SHA2 Rescue_Twofish_SHA2 >NUL:
"
|
CleanCommandLine="del /q /s Release Release_AES Release_Serpent Release_Twofish Rescue Rescue_AES Rescue_Serpent Rescue_Twofish >NUL:
del /q /s Release_SHA2 Release_AES_SHA2 Release_Serpent_SHA2 Release_Twofish_SHA2 Rescue_SHA2 Rescue_AES_SHA2 Rescue_Serpent_SHA2 Rescue_Twofish_SHA2 >NUL:
"
|
||||||
Output="Release\BootLoader.com"
|
Output="Release\BootLoader.com"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||||
IncludeSearchPath=""$(SolutionDir)";"$(SolutionDir)\Common";"$(SolutionDir)\Crypto";"$(MSVC16_ROOT)\Include""
|
IncludeSearchPath=""$(SolutionDir)";"$(SolutionDir)\Common";"$(SolutionDir)\Crypto";"$(MSVC16_ROOT)\Include""
|
||||||
ForcedIncludes=""
|
ForcedIncludes=""
|
||||||
AssemblySearchPath=""
|
AssemblySearchPath=""
|
||||||
ForcedUsingAssemblies=""
|
ForcedUsingAssemblies=""
|
||||||
CompileAsManaged=""
|
CompileAsManaged=""
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release Loader|Win32"
|
Name="Release Loader|Win32"
|
||||||
OutputDirectory="$(ConfigurationName)"
|
OutputDirectory="$(ConfigurationName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
ConfigurationType="0"
|
ConfigurationType="0"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCNMakeTool"
|
Name="VCNMakeTool"
|
||||||
BuildCommandLine="md Release 2>NUL:
nmake.exe /nologo RELEASE=1

md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH"
|
BuildCommandLine="md Release 2>NUL:
nmake.exe /nologo RELEASE=1

md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH"
|
||||||
ReBuildCommandLine="del /q /s Release >NUL:
md Release 2>NUL:
nmake.exe /nologo RELEASE=1

del /q /s Release_AES >NUL:
md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

del /q /s Release_Serpent >NUL:
md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

del /q /s Release_Twofish >NUL:
md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH"
|
ReBuildCommandLine="del /q /s Release >NUL:
md Release 2>NUL:
nmake.exe /nologo RELEASE=1

del /q /s Release_AES >NUL:
md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

del /q /s Release_Serpent >NUL:
md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

del /q /s Release_Twofish >NUL:
md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH"
|
||||||
CleanCommandLine="del /q /s Release Release_AES Release_Serpent Release_Twofish >NUL:"
|
CleanCommandLine="del /q /s Release Release_AES Release_Serpent Release_Twofish >NUL:"
|
||||||
Output="Release\BootLoader.com"
|
Output="Release\BootLoader.com"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||||
IncludeSearchPath=""$(SolutionDir)";"$(SolutionDir)\Common";"$(SolutionDir)\Crypto";"$(MSVC16_ROOT)\Include""
|
IncludeSearchPath=""$(SolutionDir)";"$(SolutionDir)\Common";"$(SolutionDir)\Crypto";"$(MSVC16_ROOT)\Include""
|
||||||
ForcedIncludes=""
|
ForcedIncludes=""
|
||||||
AssemblySearchPath=""
|
AssemblySearchPath=""
|
||||||
ForcedUsingAssemblies=""
|
ForcedUsingAssemblies=""
|
||||||
CompileAsManaged=""
|
CompileAsManaged=""
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootConfig.cpp"
|
RelativePath=".\BootConfig.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootConsoleIo.cpp"
|
RelativePath=".\BootConsoleIo.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootCrt.asm"
|
RelativePath=".\BootCrt.asm"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootDebug.cpp"
|
RelativePath=".\BootDebug.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootDiskIo.cpp"
|
RelativePath=".\BootDiskIo.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootEncryptedIo.cpp"
|
RelativePath=".\BootEncryptedIo.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootMain.cpp"
|
RelativePath=".\BootMain.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootMemory.cpp"
|
RelativePath=".\BootMemory.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootSector.asm"
|
RelativePath=".\BootSector.asm"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Decompressor.c"
|
RelativePath=".\Decompressor.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\IntFilter.cpp"
|
RelativePath=".\IntFilter.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Platform.cpp"
|
RelativePath=".\Platform.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Common"
|
Name="Common"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Common\Crc.c"
|
RelativePath="..\..\Common\Crc.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Common\Crypto.c"
|
RelativePath="..\..\Common\Crypto.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Common\Endian.c"
|
RelativePath="..\..\Common\Endian.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Common\Pkcs5.c"
|
RelativePath="..\..\Common\Pkcs5.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Common\Volumes.c"
|
RelativePath="..\..\Common\Volumes.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Common\Xts.c"
|
RelativePath="..\..\Common\Xts.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Crypto"
|
Name="Crypto"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\Aes_hw_cpu.asm"
|
RelativePath="..\..\Crypto\Aes_hw_cpu.asm"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\AesSmall.c"
|
RelativePath="..\..\Crypto\AesSmall.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\AesSmall_x86.asm"
|
RelativePath="..\..\Crypto\AesSmall_x86.asm"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\Rmd160.c"
|
RelativePath="..\..\Crypto\Rmd160.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\Serpent.c"
|
RelativePath="..\..\Crypto\Serpent.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\Sha2Small.c"
|
RelativePath="..\..\Crypto\Sha2Small.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Crypto\Twofish.c"
|
RelativePath="..\..\Crypto\Twofish.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Bios.h"
|
RelativePath=".\Bios.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootCommon.h"
|
RelativePath=".\BootCommon.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootConfig.h"
|
RelativePath=".\BootConfig.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootConsoleIo.h"
|
RelativePath=".\BootConsoleIo.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootDebug.h"
|
RelativePath=".\BootDebug.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootDefs.h"
|
RelativePath=".\BootDefs.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootDiskIo.h"
|
RelativePath=".\BootDiskIo.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootEncryptedIo.h"
|
RelativePath=".\BootEncryptedIo.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootMain.h"
|
RelativePath=".\BootMain.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootMemory.h"
|
RelativePath=".\BootMemory.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BootStrings.h"
|
RelativePath=".\BootStrings.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\IntFilter.h"
|
RelativePath=".\IntFilter.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Platform.h"
|
RelativePath=".\Platform.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Build Files"
|
Name="Build Files"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Makefile"
|
RelativePath=".\Makefile"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
@@ -1,82 +1,82 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootCommon
|
#ifndef TC_HEADER_Boot_BootCommon
|
||||||
#define TC_HEADER_Boot_BootCommon
|
#define TC_HEADER_Boot_BootCommon
|
||||||
|
|
||||||
#include "Common/Password.h"
|
#include "Common/Password.h"
|
||||||
#include "BootDefs.h"
|
#include "BootDefs.h"
|
||||||
|
|
||||||
// The user will be advised to upgrade the rescue disk if upgrading from the following or any previous version
|
// The user will be advised to upgrade the rescue disk if upgrading from the following or any previous version
|
||||||
#define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0117
|
#define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0117
|
||||||
|
|
||||||
#define TC_BOOT_LOADER_AREA_SIZE (TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
|
#define TC_BOOT_LOADER_AREA_SIZE (TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
|
||||||
|
|
||||||
#define TC_BOOT_VOLUME_HEADER_SECTOR (TC_BOOT_LOADER_AREA_SECTOR_COUNT - 1)
|
#define TC_BOOT_VOLUME_HEADER_SECTOR (TC_BOOT_LOADER_AREA_SECTOR_COUNT - 1)
|
||||||
#define TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET (TC_BOOT_VOLUME_HEADER_SECTOR * TC_SECTOR_SIZE_BIOS)
|
#define TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET (TC_BOOT_VOLUME_HEADER_SECTOR * TC_SECTOR_SIZE_BIOS)
|
||||||
|
|
||||||
#define TC_CD_BOOTSECTOR_OFFSET 0xd000
|
#define TC_CD_BOOTSECTOR_OFFSET 0xd000
|
||||||
#define TC_CD_BOOT_LOADER_SECTOR 26
|
#define TC_CD_BOOT_LOADER_SECTOR 26
|
||||||
|
|
||||||
#define TC_ORIG_BOOT_LOADER_BACKUP_SECTOR TC_BOOT_LOADER_AREA_SECTOR_COUNT
|
#define TC_ORIG_BOOT_LOADER_BACKUP_SECTOR TC_BOOT_LOADER_AREA_SECTOR_COUNT
|
||||||
#define TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET (TC_ORIG_BOOT_LOADER_BACKUP_SECTOR * TC_SECTOR_SIZE_BIOS)
|
#define TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET (TC_ORIG_BOOT_LOADER_BACKUP_SECTOR * TC_SECTOR_SIZE_BIOS)
|
||||||
|
|
||||||
#define TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR (TC_ORIG_BOOT_LOADER_BACKUP_SECTOR + TC_BOOT_LOADER_AREA_SECTOR_COUNT)
|
#define TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR (TC_ORIG_BOOT_LOADER_BACKUP_SECTOR + TC_BOOT_LOADER_AREA_SECTOR_COUNT)
|
||||||
#define TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET (TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR * TC_SECTOR_SIZE_BIOS)
|
#define TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET (TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR * TC_SECTOR_SIZE_BIOS)
|
||||||
|
|
||||||
#define TC_MBR_SECTOR 0
|
#define TC_MBR_SECTOR 0
|
||||||
#define TC_MAX_MBR_BOOT_CODE_SIZE 440
|
#define TC_MAX_MBR_BOOT_CODE_SIZE 440
|
||||||
|
|
||||||
#define TC_MAX_EXTRA_BOOT_PARTITION_SIZE (512UL * 1024UL * 1024UL)
|
#define TC_MAX_EXTRA_BOOT_PARTITION_SIZE (512UL * 1024UL * 1024UL)
|
||||||
|
|
||||||
|
|
||||||
#pragma pack (1)
|
#pragma pack (1)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
byte Flags;
|
byte Flags;
|
||||||
} BootSectorConfiguration;
|
} BootSectorConfiguration;
|
||||||
|
|
||||||
|
|
||||||
// Modifying this value can introduce incompatibility with previous versions
|
// Modifying this value can introduce incompatibility with previous versions
|
||||||
#define TC_BOOT_LOADER_ARGS_OFFSET 0x10
|
#define TC_BOOT_LOADER_ARGS_OFFSET 0x10
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// Modifying this structure can introduce incompatibility with previous versions
|
// Modifying this structure can introduce incompatibility with previous versions
|
||||||
char Signature[8];
|
char Signature[8];
|
||||||
uint16 BootLoaderVersion;
|
uint16 BootLoaderVersion;
|
||||||
uint16 CryptoInfoOffset;
|
uint16 CryptoInfoOffset;
|
||||||
uint16 CryptoInfoLength;
|
uint16 CryptoInfoLength;
|
||||||
uint32 HeaderSaltCrc32;
|
uint32 HeaderSaltCrc32;
|
||||||
Password BootPassword;
|
Password BootPassword;
|
||||||
uint64 HiddenSystemPartitionStart;
|
uint64 HiddenSystemPartitionStart;
|
||||||
uint64 DecoySystemPartitionStart;
|
uint64 DecoySystemPartitionStart;
|
||||||
uint32 Flags;
|
uint32 Flags;
|
||||||
uint32 BootDriveSignature;
|
uint32 BootDriveSignature;
|
||||||
|
|
||||||
uint32 BootArgumentsCrc32;
|
uint32 BootArgumentsCrc32;
|
||||||
|
|
||||||
} BootArguments;
|
} BootArguments;
|
||||||
|
|
||||||
// Modifying these values can introduce incompatibility with previous versions
|
// Modifying these values can introduce incompatibility with previous versions
|
||||||
#define TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION 0x1
|
#define TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION 0x1
|
||||||
|
|
||||||
#pragma pack ()
|
#pragma pack ()
|
||||||
|
|
||||||
// Boot arguments signature should not be defined as a static string
|
// Boot arguments signature should not be defined as a static string
|
||||||
// Modifying these values can introduce incompatibility with previous versions
|
// Modifying these values can introduce incompatibility with previous versions
|
||||||
#define TC_SET_BOOT_ARGUMENTS_SIGNATURE(SG) do { SG[0] = 'T'; SG[1] = 'R'; SG[2] = 'U'; SG[3] = 'E'; SG[4] = 0x11; SG[5] = 0x23; SG[6] = 0x45; SG[7] = 0x66; } while (FALSE)
|
#define TC_SET_BOOT_ARGUMENTS_SIGNATURE(SG) do { SG[0] = 'T'; SG[1] = 'R'; SG[2] = 'U'; SG[3] = 'E'; SG[4] = 0x11; SG[5] = 0x23; SG[6] = 0x45; SG[7] = 0x66; } while (FALSE)
|
||||||
#define TC_IS_BOOT_ARGUMENTS_SIGNATURE(SG) (SG[0] == 'T' && SG[1] == 'R' && SG[2] == 'U' && SG[3] == 'E' && SG[4] == 0x11 && SG[5] == 0x23 && SG[6] == 0x45 && SG[7] == 0x66)
|
#define TC_IS_BOOT_ARGUMENTS_SIGNATURE(SG) (SG[0] == 'T' && SG[1] == 'R' && SG[2] == 'U' && SG[3] == 'E' && SG[4] == 0x11 && SG[5] == 0x23 && SG[6] == 0x45 && SG[7] == 0x66)
|
||||||
|
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootCommon
|
#endif // TC_HEADER_Boot_BootCommon
|
||||||
|
|||||||
+102
-102
@@ -1,102 +1,102 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BootConfig.h"
|
#include "BootConfig.h"
|
||||||
|
|
||||||
byte BootSectorFlags;
|
byte BootSectorFlags;
|
||||||
|
|
||||||
byte BootLoaderDrive;
|
byte BootLoaderDrive;
|
||||||
byte BootDrive;
|
byte BootDrive;
|
||||||
bool BootDriveGeometryValid = false;
|
bool BootDriveGeometryValid = false;
|
||||||
bool PreventNormalSystemBoot = false;
|
bool PreventNormalSystemBoot = false;
|
||||||
bool PreventBootMenu = false;
|
bool PreventBootMenu = false;
|
||||||
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
|
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
|
||||||
uint32 OuterVolumeBackupHeaderCrc;
|
uint32 OuterVolumeBackupHeaderCrc;
|
||||||
|
|
||||||
bool BootStarted = false;
|
bool BootStarted = false;
|
||||||
|
|
||||||
DriveGeometry BootDriveGeometry;
|
DriveGeometry BootDriveGeometry;
|
||||||
|
|
||||||
CRYPTO_INFO *BootCryptoInfo;
|
CRYPTO_INFO *BootCryptoInfo;
|
||||||
Partition EncryptedVirtualPartition;
|
Partition EncryptedVirtualPartition;
|
||||||
|
|
||||||
Partition ActivePartition;
|
Partition ActivePartition;
|
||||||
Partition PartitionFollowingActive;
|
Partition PartitionFollowingActive;
|
||||||
bool ExtraBootPartitionPresent = false;
|
bool ExtraBootPartitionPresent = false;
|
||||||
uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage
|
uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage
|
||||||
uint64 HiddenVolumeStartSector;
|
uint64 HiddenVolumeStartSector;
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
||||||
|
|
||||||
void ReadBootSectorUserConfiguration ()
|
void ReadBootSectorUserConfiguration ()
|
||||||
{
|
{
|
||||||
byte userConfig;
|
byte userConfig;
|
||||||
|
|
||||||
AcquireSectorBuffer();
|
AcquireSectorBuffer();
|
||||||
|
|
||||||
if (ReadWriteMBR (false, BootLoaderDrive, true) != BiosResultSuccess)
|
if (ReadWriteMBR (false, BootLoaderDrive, true) != BiosResultSuccess)
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
userConfig = SectorBuffer[TC_BOOT_SECTOR_USER_CONFIG_OFFSET];
|
userConfig = SectorBuffer[TC_BOOT_SECTOR_USER_CONFIG_OFFSET];
|
||||||
|
|
||||||
#ifdef TC_WINDOWS_BOOT_AES
|
#ifdef TC_WINDOWS_BOOT_AES
|
||||||
EnableHwEncryption (!(userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION));
|
EnableHwEncryption (!(userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PreventBootMenu = (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_ESC);
|
PreventBootMenu = (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_ESC);
|
||||||
|
|
||||||
memcpy (CustomUserMessage, SectorBuffer + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH);
|
memcpy (CustomUserMessage, SectorBuffer + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH);
|
||||||
CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH] = 0;
|
CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH] = 0;
|
||||||
|
|
||||||
if (userConfig & TC_BOOT_USER_CFG_FLAG_SILENT_MODE)
|
if (userConfig & TC_BOOT_USER_CFG_FLAG_SILENT_MODE)
|
||||||
{
|
{
|
||||||
if (CustomUserMessage[0])
|
if (CustomUserMessage[0])
|
||||||
{
|
{
|
||||||
InitVideoMode();
|
InitVideoMode();
|
||||||
Print (CustomUserMessage);
|
Print (CustomUserMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableScreenOutput();
|
DisableScreenOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)
|
if (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)
|
||||||
{
|
{
|
||||||
PimValueOrHiddenVolumeStartUnitNo.LowPart = 0;
|
PimValueOrHiddenVolumeStartUnitNo.LowPart = 0;
|
||||||
memcpy (&PimValueOrHiddenVolumeStartUnitNo.LowPart, SectorBuffer + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, TC_BOOT_SECTOR_PIM_VALUE_SIZE);
|
memcpy (&PimValueOrHiddenVolumeStartUnitNo.LowPart, SectorBuffer + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, TC_BOOT_SECTOR_PIM_VALUE_SIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PimValueOrHiddenVolumeStartUnitNo.LowPart = -1;
|
PimValueOrHiddenVolumeStartUnitNo.LowPart = -1;
|
||||||
|
|
||||||
OuterVolumeBackupHeaderCrc = *(uint32 *) (SectorBuffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET);
|
OuterVolumeBackupHeaderCrc = *(uint32 *) (SectorBuffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET);
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
ReleaseSectorBuffer();
|
ReleaseSectorBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult UpdateBootSectorConfiguration (byte drive)
|
BiosResult UpdateBootSectorConfiguration (byte drive)
|
||||||
{
|
{
|
||||||
AcquireSectorBuffer();
|
AcquireSectorBuffer();
|
||||||
|
|
||||||
BiosResult result = ReadWriteMBR (false, drive);
|
BiosResult result = ReadWriteMBR (false, drive);
|
||||||
if (result != BiosResultSuccess)
|
if (result != BiosResultSuccess)
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags;
|
SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags;
|
||||||
result = ReadWriteMBR (true, drive);
|
result = ReadWriteMBR (true, drive);
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
ReleaseSectorBuffer();
|
ReleaseSectorBuffer();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
#endif // !TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootConfig
|
#ifndef TC_HEADER_Boot_BootConfig
|
||||||
#define TC_HEADER_Boot_BootConfig
|
#define TC_HEADER_Boot_BootConfig
|
||||||
|
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "BootDiskIo.h"
|
#include "BootDiskIo.h"
|
||||||
|
|
||||||
extern byte BootSectorFlags;
|
extern byte BootSectorFlags;
|
||||||
|
|
||||||
extern byte BootLoaderDrive;
|
extern byte BootLoaderDrive;
|
||||||
extern byte BootDrive;
|
extern byte BootDrive;
|
||||||
extern bool BootDriveGeometryValid;
|
extern bool BootDriveGeometryValid;
|
||||||
extern DriveGeometry BootDriveGeometry;
|
extern DriveGeometry BootDriveGeometry;
|
||||||
extern bool PreventNormalSystemBoot;
|
extern bool PreventNormalSystemBoot;
|
||||||
extern bool PreventBootMenu;
|
extern bool PreventBootMenu;
|
||||||
extern char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
|
extern char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
|
||||||
extern uint32 OuterVolumeBackupHeaderCrc;
|
extern uint32 OuterVolumeBackupHeaderCrc;
|
||||||
|
|
||||||
extern bool BootStarted;
|
extern bool BootStarted;
|
||||||
|
|
||||||
extern CRYPTO_INFO *BootCryptoInfo;
|
extern CRYPTO_INFO *BootCryptoInfo;
|
||||||
extern Partition EncryptedVirtualPartition;
|
extern Partition EncryptedVirtualPartition;
|
||||||
|
|
||||||
extern Partition ActivePartition;
|
extern Partition ActivePartition;
|
||||||
extern Partition PartitionFollowingActive;
|
extern Partition PartitionFollowingActive;
|
||||||
extern bool ExtraBootPartitionPresent;
|
extern bool ExtraBootPartitionPresent;
|
||||||
extern uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage
|
extern uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage
|
||||||
extern uint64 HiddenVolumeStartSector;
|
extern uint64 HiddenVolumeStartSector;
|
||||||
|
|
||||||
|
|
||||||
void ReadBootSectorUserConfiguration ();
|
void ReadBootSectorUserConfiguration ();
|
||||||
BiosResult UpdateBootSectorConfiguration (byte drive);
|
BiosResult UpdateBootSectorConfiguration (byte drive);
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootConfig
|
#endif // TC_HEADER_Boot_BootConfig
|
||||||
|
|||||||
+339
-339
@@ -1,339 +1,339 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "BootConsoleIo.h"
|
#include "BootConsoleIo.h"
|
||||||
#include "BootDebug.h"
|
#include "BootDebug.h"
|
||||||
#include "BootStrings.h"
|
#include "BootStrings.h"
|
||||||
|
|
||||||
|
|
||||||
static int ScreenOutputDisabled = 0;
|
static int ScreenOutputDisabled = 0;
|
||||||
|
|
||||||
void DisableScreenOutput ()
|
void DisableScreenOutput ()
|
||||||
{
|
{
|
||||||
++ScreenOutputDisabled;
|
++ScreenOutputDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EnableScreenOutput ()
|
void EnableScreenOutput ()
|
||||||
{
|
{
|
||||||
--ScreenOutputDisabled;
|
--ScreenOutputDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintChar (char c)
|
void PrintChar (char c)
|
||||||
{
|
{
|
||||||
#ifdef TC_BOOT_TRACING_ENABLED
|
#ifdef TC_BOOT_TRACING_ENABLED
|
||||||
WriteDebugPort (c);
|
WriteDebugPort (c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ScreenOutputDisabled)
|
if (ScreenOutputDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov bx, 7
|
mov bx, 7
|
||||||
mov al, c
|
mov al, c
|
||||||
mov ah, 0xe
|
mov ah, 0xe
|
||||||
int 0x10
|
int 0x10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintCharAtCursor (char c)
|
void PrintCharAtCursor (char c)
|
||||||
{
|
{
|
||||||
if (ScreenOutputDisabled)
|
if (ScreenOutputDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov bx, 7
|
mov bx, 7
|
||||||
mov al, c
|
mov al, c
|
||||||
mov cx, 1
|
mov cx, 1
|
||||||
mov ah, 0xa
|
mov ah, 0xa
|
||||||
int 0x10
|
int 0x10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Print (const char *str)
|
void Print (const char *str)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
while (c = *str++)
|
while (c = *str++)
|
||||||
PrintChar (c);
|
PrintChar (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Print (uint32 number)
|
void Print (uint32 number)
|
||||||
{
|
{
|
||||||
char str[12];
|
char str[12];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (number >= 10)
|
while (number >= 10)
|
||||||
{
|
{
|
||||||
str[pos++] = (char) (number % 10) + '0';
|
str[pos++] = (char) (number % 10) + '0';
|
||||||
number /= 10;
|
number /= 10;
|
||||||
}
|
}
|
||||||
str[pos] = (char) (number % 10) + '0';
|
str[pos] = (char) (number % 10) + '0';
|
||||||
|
|
||||||
while (pos >= 0)
|
while (pos >= 0)
|
||||||
PrintChar (str[pos--]);
|
PrintChar (str[pos--]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Print (const uint64 &number)
|
void Print (const uint64 &number)
|
||||||
{
|
{
|
||||||
if (number.HighPart == 0)
|
if (number.HighPart == 0)
|
||||||
Print (number.LowPart);
|
Print (number.LowPart);
|
||||||
else
|
else
|
||||||
PrintHex (number);
|
PrintHex (number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintHex (byte b)
|
void PrintHex (byte b)
|
||||||
{
|
{
|
||||||
PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4));
|
PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4));
|
||||||
PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF));
|
PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintHex (uint16 data)
|
void PrintHex (uint16 data)
|
||||||
{
|
{
|
||||||
PrintHex (byte (data >> 8));
|
PrintHex (byte (data >> 8));
|
||||||
PrintHex (byte (data));
|
PrintHex (byte (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintHex (uint32 data)
|
void PrintHex (uint32 data)
|
||||||
{
|
{
|
||||||
PrintHex (uint16 (data >> 16));
|
PrintHex (uint16 (data >> 16));
|
||||||
PrintHex (uint16 (data));
|
PrintHex (uint16 (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintHex (const uint64 &data)
|
void PrintHex (const uint64 &data)
|
||||||
{
|
{
|
||||||
PrintHex (data.HighPart);
|
PrintHex (data.HighPart);
|
||||||
PrintHex (data.LowPart);
|
PrintHex (data.LowPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintRepeatedChar (char c, int n)
|
void PrintRepeatedChar (char c, int n)
|
||||||
{
|
{
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
PrintChar (c);
|
PrintChar (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintEndl ()
|
void PrintEndl ()
|
||||||
{
|
{
|
||||||
Print ("\r\n");
|
Print ("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintEndl (int cnt)
|
void PrintEndl (int cnt)
|
||||||
{
|
{
|
||||||
while (cnt-- > 0)
|
while (cnt-- > 0)
|
||||||
PrintEndl ();
|
PrintEndl ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Beep ()
|
void Beep ()
|
||||||
{
|
{
|
||||||
PrintChar (7);
|
PrintChar (7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitVideoMode ()
|
void InitVideoMode ()
|
||||||
{
|
{
|
||||||
if (ScreenOutputDisabled)
|
if (ScreenOutputDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
// Text mode 80x25
|
// Text mode 80x25
|
||||||
mov ax, 3
|
mov ax, 3
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
// Page 0
|
// Page 0
|
||||||
mov ax, 0x500
|
mov ax, 0x500
|
||||||
int 0x10
|
int 0x10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClearScreen ()
|
void ClearScreen ()
|
||||||
{
|
{
|
||||||
if (ScreenOutputDisabled)
|
if (ScreenOutputDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
// White text on black
|
// White text on black
|
||||||
mov bh, 7
|
mov bh, 7
|
||||||
xor cx, cx
|
xor cx, cx
|
||||||
mov dx, 0x184f
|
mov dx, 0x184f
|
||||||
mov ax, 0x600
|
mov ax, 0x600
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
// Cursor at 0,0
|
// Cursor at 0,0
|
||||||
xor bh, bh
|
xor bh, bh
|
||||||
xor dx, dx
|
xor dx, dx
|
||||||
mov ah, 2
|
mov ah, 2
|
||||||
int 0x10
|
int 0x10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintBackspace ()
|
void PrintBackspace ()
|
||||||
{
|
{
|
||||||
PrintChar (TC_BIOS_CHAR_BACKSPACE);
|
PrintChar (TC_BIOS_CHAR_BACKSPACE);
|
||||||
PrintCharAtCursor (' ');
|
PrintCharAtCursor (' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintError (const char *message)
|
void PrintError (const char *message)
|
||||||
{
|
{
|
||||||
Print (TC_BOOT_STR_ERROR);
|
Print (TC_BOOT_STR_ERROR);
|
||||||
Print (message);
|
Print (message);
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
Beep();
|
Beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintErrorNoEndl (const char *message)
|
void PrintErrorNoEndl (const char *message)
|
||||||
{
|
{
|
||||||
Print (TC_BOOT_STR_ERROR);
|
Print (TC_BOOT_STR_ERROR);
|
||||||
Print (message);
|
Print (message);
|
||||||
Beep();
|
Beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
byte GetShiftFlags ()
|
byte GetShiftFlags ()
|
||||||
{
|
{
|
||||||
byte flags;
|
byte flags;
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov ah, 2
|
mov ah, 2
|
||||||
int 0x16
|
int 0x16
|
||||||
mov flags, al
|
mov flags, al
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
byte GetKeyboardChar ()
|
byte GetKeyboardChar ()
|
||||||
{
|
{
|
||||||
return GetKeyboardChar (nullptr);
|
return GetKeyboardChar (nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
byte GetKeyboardChar (byte *scanCode)
|
byte GetKeyboardChar (byte *scanCode)
|
||||||
{
|
{
|
||||||
// Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer)
|
// Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer)
|
||||||
while (!IsKeyboardCharAvailable());
|
while (!IsKeyboardCharAvailable());
|
||||||
|
|
||||||
byte asciiCode;
|
byte asciiCode;
|
||||||
byte scan;
|
byte scan;
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov ah, 0
|
mov ah, 0
|
||||||
int 0x16
|
int 0x16
|
||||||
mov asciiCode, al
|
mov asciiCode, al
|
||||||
mov scan, ah
|
mov scan, ah
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanCode)
|
if (scanCode)
|
||||||
*scanCode = scan;
|
*scanCode = scan;
|
||||||
|
|
||||||
return asciiCode;
|
return asciiCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IsKeyboardCharAvailable ()
|
bool IsKeyboardCharAvailable ()
|
||||||
{
|
{
|
||||||
bool available = false;
|
bool available = false;
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov ah, 1
|
mov ah, 1
|
||||||
int 0x16
|
int 0x16
|
||||||
jz not_avail
|
jz not_avail
|
||||||
mov available, true
|
mov available, true
|
||||||
not_avail:
|
not_avail:
|
||||||
}
|
}
|
||||||
|
|
||||||
return available;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EscKeyPressed ()
|
bool EscKeyPressed ()
|
||||||
{
|
{
|
||||||
if (IsKeyboardCharAvailable ())
|
if (IsKeyboardCharAvailable ())
|
||||||
{
|
{
|
||||||
byte keyScanCode;
|
byte keyScanCode;
|
||||||
GetKeyboardChar (&keyScanCode);
|
GetKeyboardChar (&keyScanCode);
|
||||||
return keyScanCode == TC_BIOS_KEY_ESC;
|
return keyScanCode == TC_BIOS_KEY_ESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClearBiosKeystrokeBuffer ()
|
void ClearBiosKeystrokeBuffer ()
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push es
|
push es
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov di, 0x41e
|
mov di, 0x41e
|
||||||
mov cx, 32
|
mov cx, 32
|
||||||
cld
|
cld
|
||||||
rep stosb
|
rep stosb
|
||||||
pop es
|
pop es
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IsPrintable (char c)
|
bool IsPrintable (char c)
|
||||||
{
|
{
|
||||||
return c >= ' ' && c <= '~';
|
return c >= ' ' && c <= '~';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDigit (char c)
|
bool IsDigit (char c)
|
||||||
{
|
{
|
||||||
return c >= '0' && c <= '9';
|
return c >= '0' && c <= '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GetString (char *buffer, size_t bufferSize)
|
int GetString (char *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
byte c;
|
byte c;
|
||||||
byte scanCode;
|
byte scanCode;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
while (pos < bufferSize)
|
while (pos < bufferSize)
|
||||||
{
|
{
|
||||||
c = GetKeyboardChar (&scanCode);
|
c = GetKeyboardChar (&scanCode);
|
||||||
|
|
||||||
if (scanCode == TC_BIOS_KEY_ENTER)
|
if (scanCode == TC_BIOS_KEY_ENTER)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (scanCode == TC_BIOS_KEY_ESC)
|
if (scanCode == TC_BIOS_KEY_ESC)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer[pos++] = c;
|
buffer[pos++] = c;
|
||||||
PrintChar (IsPrintable (c) ? c : ' ');
|
PrintChar (IsPrintable (c) ? c : ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +1,72 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootConsoleIo
|
#ifndef TC_HEADER_Boot_BootConsoleIo
|
||||||
#define TC_HEADER_Boot_BootConsoleIo
|
#define TC_HEADER_Boot_BootConsoleIo
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
#define TC_DEBUG_PORT 0
|
#define TC_DEBUG_PORT 0
|
||||||
|
|
||||||
#define TC_BIOS_KEY_ESC 1
|
#define TC_BIOS_KEY_ESC 1
|
||||||
#define TC_BIOS_KEY_BACKSPACE 14
|
#define TC_BIOS_KEY_BACKSPACE 14
|
||||||
#define TC_BIOS_KEY_ENTER 28
|
#define TC_BIOS_KEY_ENTER 28
|
||||||
#define TC_BIOS_KEY_F1 0x3b
|
#define TC_BIOS_KEY_F1 0x3b
|
||||||
#define TC_BIOS_KEY_F2 0x3c
|
#define TC_BIOS_KEY_F2 0x3c
|
||||||
#define TC_BIOS_KEY_F3 0x3d
|
#define TC_BIOS_KEY_F3 0x3d
|
||||||
#define TC_BIOS_KEY_F4 0x3e
|
#define TC_BIOS_KEY_F4 0x3e
|
||||||
#define TC_BIOS_KEY_F5 0x3f
|
#define TC_BIOS_KEY_F5 0x3f
|
||||||
#define TC_BIOS_KEY_F6 0x40
|
#define TC_BIOS_KEY_F6 0x40
|
||||||
#define TC_BIOS_KEY_F7 0x41
|
#define TC_BIOS_KEY_F7 0x41
|
||||||
#define TC_BIOS_KEY_F8 0x42
|
#define TC_BIOS_KEY_F8 0x42
|
||||||
#define TC_BIOS_KEY_F9 0x43
|
#define TC_BIOS_KEY_F9 0x43
|
||||||
#define TC_BIOS_KEY_F10 0x44
|
#define TC_BIOS_KEY_F10 0x44
|
||||||
|
|
||||||
#define TC_BIOS_SHIFTMASK_CAPSLOCK (1 << 6)
|
#define TC_BIOS_SHIFTMASK_CAPSLOCK (1 << 6)
|
||||||
#define TC_BIOS_SHIFTMASK_LSHIFT (1 << 1)
|
#define TC_BIOS_SHIFTMASK_LSHIFT (1 << 1)
|
||||||
#define TC_BIOS_SHIFTMASK_RSHIFT (1 << 0)
|
#define TC_BIOS_SHIFTMASK_RSHIFT (1 << 0)
|
||||||
|
|
||||||
#define TC_BIOS_CHAR_BACKSPACE 8
|
#define TC_BIOS_CHAR_BACKSPACE 8
|
||||||
|
|
||||||
#define TC_BIOS_MAX_CHARS_PER_LINE 80
|
#define TC_BIOS_MAX_CHARS_PER_LINE 80
|
||||||
|
|
||||||
void Beep ();
|
void Beep ();
|
||||||
void ClearBiosKeystrokeBuffer ();
|
void ClearBiosKeystrokeBuffer ();
|
||||||
void ClearScreen ();
|
void ClearScreen ();
|
||||||
void DisableScreenOutput ();
|
void DisableScreenOutput ();
|
||||||
void EnableScreenOutput ();
|
void EnableScreenOutput ();
|
||||||
bool EscKeyPressed ();
|
bool EscKeyPressed ();
|
||||||
byte GetKeyboardChar ();
|
byte GetKeyboardChar ();
|
||||||
byte GetKeyboardChar (byte *scanCode);
|
byte GetKeyboardChar (byte *scanCode);
|
||||||
byte GetShiftFlags ();
|
byte GetShiftFlags ();
|
||||||
int GetString (char *buffer, size_t bufferSize);
|
int GetString (char *buffer, size_t bufferSize);
|
||||||
void InitVideoMode ();
|
void InitVideoMode ();
|
||||||
bool IsKeyboardCharAvailable ();
|
bool IsKeyboardCharAvailable ();
|
||||||
bool IsPrintable (char c);
|
bool IsPrintable (char c);
|
||||||
bool IsDigit (char c);
|
bool IsDigit (char c);
|
||||||
void Print (const char *str);
|
void Print (const char *str);
|
||||||
void Print (uint32 number);
|
void Print (uint32 number);
|
||||||
void Print (const uint64 &number);
|
void Print (const uint64 &number);
|
||||||
void PrintBackspace ();
|
void PrintBackspace ();
|
||||||
void PrintChar (char c);
|
void PrintChar (char c);
|
||||||
void PrintCharAtCursor (char c);
|
void PrintCharAtCursor (char c);
|
||||||
void PrintEndl ();
|
void PrintEndl ();
|
||||||
void PrintEndl (int cnt);
|
void PrintEndl (int cnt);
|
||||||
void PrintRepeatedChar (char c, int n);
|
void PrintRepeatedChar (char c, int n);
|
||||||
void PrintError (const char *message);
|
void PrintError (const char *message);
|
||||||
void PrintErrorNoEndl (const char *message);
|
void PrintErrorNoEndl (const char *message);
|
||||||
void PrintHex (byte b);
|
void PrintHex (byte b);
|
||||||
void PrintHex (uint16 data);
|
void PrintHex (uint16 data);
|
||||||
void PrintHex (uint32 data);
|
void PrintHex (uint32 data);
|
||||||
void PrintHex (const uint64 &data);
|
void PrintHex (const uint64 &data);
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootConsoleIo
|
#endif // TC_HEADER_Boot_BootConsoleIo
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
;
|
;
|
||||||
; Derived from source code of TrueCrypt 7.1a, which is
|
; Derived from source code of TrueCrypt 7.1a, which is
|
||||||
; Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
; Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
; by the TrueCrypt License 3.0.
|
; by the TrueCrypt License 3.0.
|
||||||
;
|
;
|
||||||
; Modifications and additions to the original source code (contained in this file)
|
; Modifications and additions to the original source code (contained in this file)
|
||||||
; and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
; and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
; and are governed by the Apache License 2.0 the full text of which is
|
; and are governed by the Apache License 2.0 the full text of which is
|
||||||
; contained in the file License.txt included in VeraCrypt binary and source
|
; contained in the file License.txt included in VeraCrypt binary and source
|
||||||
; code distribution packages.
|
; code distribution packages.
|
||||||
;
|
;
|
||||||
|
|
||||||
.MODEL tiny, C
|
.MODEL tiny, C
|
||||||
.386
|
.386
|
||||||
|
|
||||||
INCLUDE BootDefs.i
|
INCLUDE BootDefs.i
|
||||||
|
|
||||||
EXTERNDEF main:NEAR
|
EXTERNDEF main:NEAR
|
||||||
|
|
||||||
_TEXT SEGMENT
|
_TEXT SEGMENT
|
||||||
ORG TC_COM_EXECUTABLE_OFFSET
|
ORG TC_COM_EXECUTABLE_OFFSET
|
||||||
|
|
||||||
start:
|
start:
|
||||||
jmp main
|
jmp main
|
||||||
|
|
||||||
_TEXT ENDS
|
_TEXT ENDS
|
||||||
END start
|
END start
|
||||||
|
|||||||
+181
-181
@@ -1,181 +1,181 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "BootConsoleIo.h"
|
#include "BootConsoleIo.h"
|
||||||
#include "BootDefs.h"
|
#include "BootDefs.h"
|
||||||
#include "BootDiskIo.h"
|
#include "BootDiskIo.h"
|
||||||
#include "BootDebug.h"
|
#include "BootDebug.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef TC_BOOT_TRACING_ENABLED
|
#ifdef TC_BOOT_TRACING_ENABLED
|
||||||
|
|
||||||
void InitDebugPort ()
|
void InitDebugPort ()
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov dx, TC_DEBUG_PORT
|
mov dx, TC_DEBUG_PORT
|
||||||
mov ah, 1
|
mov ah, 1
|
||||||
int 0x17
|
int 0x17
|
||||||
mov dx, TC_DEBUG_PORT
|
mov dx, TC_DEBUG_PORT
|
||||||
mov ah, 0xe2
|
mov ah, 0xe2
|
||||||
int 0x17
|
int 0x17
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WriteDebugPort (byte dataByte)
|
void WriteDebugPort (byte dataByte)
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov al, dataByte
|
mov al, dataByte
|
||||||
mov dx, TC_DEBUG_PORT
|
mov dx, TC_DEBUG_PORT
|
||||||
mov ah, 0
|
mov ah, 0
|
||||||
int 0x17
|
int 0x17
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TC_BOOT_TRACING_ENABLED
|
#endif // TC_BOOT_TRACING_ENABLED
|
||||||
|
|
||||||
|
|
||||||
#ifdef TC_BOOT_DEBUG_ENABLED
|
#ifdef TC_BOOT_DEBUG_ENABLED
|
||||||
|
|
||||||
extern "C" void PrintDebug (uint32 debugVal)
|
extern "C" void PrintDebug (uint32 debugVal)
|
||||||
{
|
{
|
||||||
Print (debugVal);
|
Print (debugVal);
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintVal (const char *message, const uint32 value, bool newLine, bool hex)
|
void PrintVal (const char *message, const uint32 value, bool newLine, bool hex)
|
||||||
{
|
{
|
||||||
Print (message);
|
Print (message);
|
||||||
Print (": ");
|
Print (": ");
|
||||||
|
|
||||||
if (hex)
|
if (hex)
|
||||||
PrintHex (value);
|
PrintHex (value);
|
||||||
else
|
else
|
||||||
Print (value);
|
Print (value);
|
||||||
|
|
||||||
if (newLine)
|
if (newLine)
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintVal (const char *message, const uint64 &value, bool newLine, bool hex)
|
void PrintVal (const char *message, const uint64 &value, bool newLine, bool hex)
|
||||||
{
|
{
|
||||||
Print (message);
|
Print (message);
|
||||||
Print (": ");
|
Print (": ");
|
||||||
PrintHex (value);
|
PrintHex (value);
|
||||||
if (newLine)
|
if (newLine)
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintHexDump (byte *mem, size_t size, uint16 *memSegment)
|
void PrintHexDump (byte *mem, size_t size, uint16 *memSegment)
|
||||||
{
|
{
|
||||||
const size_t width = 16;
|
const size_t width = 16;
|
||||||
for (size_t pos = 0; pos < size; )
|
for (size_t pos = 0; pos < size; )
|
||||||
{
|
{
|
||||||
for (int pass = 1; pass <= 2; ++pass)
|
for (int pass = 1; pass <= 2; ++pass)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < width && pos < size; ++i)
|
for (i = 0; i < width && pos < size; ++i)
|
||||||
{
|
{
|
||||||
byte dataByte;
|
byte dataByte;
|
||||||
if (memSegment)
|
if (memSegment)
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push es
|
push es
|
||||||
mov si, ss:memSegment
|
mov si, ss:memSegment
|
||||||
mov es, ss:[si]
|
mov es, ss:[si]
|
||||||
mov si, ss:mem
|
mov si, ss:mem
|
||||||
add si, pos
|
add si, pos
|
||||||
mov al, es:[si]
|
mov al, es:[si]
|
||||||
mov dataByte, al
|
mov dataByte, al
|
||||||
pop es
|
pop es
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dataByte = mem[pos++];
|
dataByte = mem[pos++];
|
||||||
|
|
||||||
if (pass == 1)
|
if (pass == 1)
|
||||||
{
|
{
|
||||||
PrintHex (dataByte);
|
PrintHex (dataByte);
|
||||||
PrintChar (' ');
|
PrintChar (' ');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PrintChar (IsPrintable (dataByte) ? dataByte : '.');
|
PrintChar (IsPrintable (dataByte) ? dataByte : '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pass == 1)
|
if (pass == 1)
|
||||||
{
|
{
|
||||||
pos -= i;
|
pos -= i;
|
||||||
PrintChar (' ');
|
PrintChar (' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintEndl ();
|
PrintEndl ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size)
|
void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size)
|
||||||
{
|
{
|
||||||
PrintHexDump ((byte *) memOffset, size, &memSegment);
|
PrintHexDump ((byte *) memOffset, size, &memSegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TC_BOOT_DEBUG_ENABLED
|
#endif // TC_BOOT_DEBUG_ENABLED
|
||||||
|
|
||||||
|
|
||||||
#ifdef TC_BOOT_STACK_CHECKING_ENABLED
|
#ifdef TC_BOOT_STACK_CHECKING_ENABLED
|
||||||
|
|
||||||
extern "C" char end[];
|
extern "C" char end[];
|
||||||
|
|
||||||
static void PrintStackInfo ()
|
static void PrintStackInfo ()
|
||||||
{
|
{
|
||||||
uint16 spReg;
|
uint16 spReg;
|
||||||
__asm mov spReg, sp
|
__asm mov spReg, sp
|
||||||
|
|
||||||
Print ("Stack: "); Print (TC_BOOT_LOADER_STACK_TOP - spReg);
|
Print ("Stack: "); Print (TC_BOOT_LOADER_STACK_TOP - spReg);
|
||||||
Print ("/"); Print (TC_BOOT_LOADER_STACK_TOP - (uint16) end);
|
Print ("/"); Print (TC_BOOT_LOADER_STACK_TOP - (uint16) end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CheckStack ()
|
void CheckStack ()
|
||||||
{
|
{
|
||||||
uint16 spReg;
|
uint16 spReg;
|
||||||
__asm mov spReg, sp
|
__asm mov spReg, sp
|
||||||
|
|
||||||
if (*(uint32 *) end != 0x12345678UL || spReg < (uint16) end)
|
if (*(uint32 *) end != 0x12345678UL || spReg < (uint16) end)
|
||||||
{
|
{
|
||||||
__asm cli
|
__asm cli
|
||||||
__asm mov sp, TC_BOOT_LOADER_STACK_TOP
|
__asm mov sp, TC_BOOT_LOADER_STACK_TOP
|
||||||
|
|
||||||
PrintError ("Stack overflow");
|
PrintError ("Stack overflow");
|
||||||
TC_THROW_FATAL_EXCEPTION;
|
TC_THROW_FATAL_EXCEPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitStackChecker ()
|
void InitStackChecker ()
|
||||||
{
|
{
|
||||||
*(uint32 *) end = 0x12345678UL;
|
*(uint32 *) end = 0x12345678UL;
|
||||||
|
|
||||||
PrintStackInfo();
|
PrintStackInfo();
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TC_BOOT_STACK_CHECKING_ENABLED
|
#endif // TC_BOOT_STACK_CHECKING_ENABLED
|
||||||
|
|||||||
@@ -1,60 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootDebug
|
#ifndef TC_HEADER_Boot_BootDebug
|
||||||
#define TC_HEADER_Boot_BootDebug
|
#define TC_HEADER_Boot_BootDebug
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "BootConsoleIo.h"
|
#include "BootConsoleIo.h"
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
# define TC_BOOT_DEBUG_ENABLED
|
# define TC_BOOT_DEBUG_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 || defined (TC_BOOT_DEBUG_ENABLED)
|
#if 0 || defined (TC_BOOT_DEBUG_ENABLED)
|
||||||
# define TC_BOOT_STACK_CHECKING_ENABLED
|
# define TC_BOOT_STACK_CHECKING_ENABLED
|
||||||
extern "C" void CheckStack ();
|
extern "C" void CheckStack ();
|
||||||
#else
|
#else
|
||||||
# define CheckStack()
|
# define CheckStack()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
# define TC_BOOT_TRACING_ENABLED
|
# define TC_BOOT_TRACING_ENABLED
|
||||||
# if 1
|
# if 1
|
||||||
# define TC_TRACE_INT13
|
# define TC_TRACE_INT13
|
||||||
# endif
|
# endif
|
||||||
# if 0
|
# if 0
|
||||||
# define TC_TRACE_INT15
|
# define TC_TRACE_INT15
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TC_BOOT_DEBUG_ENABLED
|
#ifdef TC_BOOT_DEBUG_ENABLED
|
||||||
# define trace_point do { Print(__FILE__); PrintChar (':'); Print (TC_TO_STRING (__LINE__)); PrintEndl(); } while (false)
|
# define trace_point do { Print(__FILE__); PrintChar (':'); Print (TC_TO_STRING (__LINE__)); PrintEndl(); } while (false)
|
||||||
# define trace_val(VAL) PrintVal (#VAL, VAL);
|
# define trace_val(VAL) PrintVal (#VAL, VAL);
|
||||||
# define trace_hex(VAL) do { Print (#VAL), PrintChar (':'); PrintHex (VAL); PrintEndl(); } while (false)
|
# define trace_hex(VAL) do { Print (#VAL), PrintChar (':'); PrintHex (VAL); PrintEndl(); } while (false)
|
||||||
# define assert(COND) do { if (!(COND)) { trace_point; __asm jmp $ } } while (false)
|
# define assert(COND) do { if (!(COND)) { trace_point; __asm jmp $ } } while (false)
|
||||||
#else
|
#else
|
||||||
# define trace_point
|
# define trace_point
|
||||||
# define trace_val(VAL)
|
# define trace_val(VAL)
|
||||||
# define trace_hex(VAL)
|
# define trace_hex(VAL)
|
||||||
# define assert(COND)
|
# define assert(COND)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void InitDebugPort ();
|
void InitDebugPort ();
|
||||||
void InitStackChecker ();
|
void InitStackChecker ();
|
||||||
void WriteDebugPort (byte dataByte);
|
void WriteDebugPort (byte dataByte);
|
||||||
void PrintHexDump (byte *mem, size_t size, uint16 *memSegment = nullptr);
|
void PrintHexDump (byte *mem, size_t size, uint16 *memSegment = nullptr);
|
||||||
void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size);
|
void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size);
|
||||||
void PrintVal (const char *message, const uint32 value, bool newLine = true, bool hex = false);
|
void PrintVal (const char *message, const uint32 value, bool newLine = true, bool hex = false);
|
||||||
void PrintVal (const char *message, const uint64 &value, bool newLine = true, bool hex = false);
|
void PrintVal (const char *message, const uint64 &value, bool newLine = true, bool hex = false);
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootDebug
|
#endif // TC_HEADER_Boot_BootDebug
|
||||||
|
|||||||
+199
-199
@@ -1,199 +1,199 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootDefs
|
#ifndef TC_HEADER_Boot_BootDefs
|
||||||
#define TC_HEADER_Boot_BootDefs
|
#define TC_HEADER_Boot_BootDefs
|
||||||
|
|
||||||
// Total memory required (CODE + DATA + BSS + STACK + 0x100) in KBytes - determined from linker map.
|
// Total memory required (CODE + DATA + BSS + STACK + 0x100) in KBytes - determined from linker map.
|
||||||
#define TC__BOOT_MEMORY_REQUIRED 43
|
#define TC__BOOT_MEMORY_REQUIRED 43
|
||||||
|
|
||||||
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
|
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
|
||||||
# undef TC__BOOT_MEMORY_REQUIRED
|
# undef TC__BOOT_MEMORY_REQUIRED
|
||||||
|
|
||||||
# ifdef TC_WINDOWS_BOOT_AES
|
# ifdef TC_WINDOWS_BOOT_AES
|
||||||
# ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
# ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
||||||
# define TC__BOOT_MEMORY_REQUIRED 31
|
# define TC__BOOT_MEMORY_REQUIRED 31
|
||||||
# else
|
# else
|
||||||
# define TC__BOOT_MEMORY_REQUIRED 29
|
# define TC__BOOT_MEMORY_REQUIRED 29
|
||||||
# endif
|
# endif
|
||||||
# elif defined (TC_WINDOWS_BOOT_SERPENT)
|
# elif defined (TC_WINDOWS_BOOT_SERPENT)
|
||||||
# define TC__BOOT_MEMORY_REQUIRED 33
|
# define TC__BOOT_MEMORY_REQUIRED 33
|
||||||
# elif defined (TC_WINDOWS_BOOT_TWOFISH)
|
# elif defined (TC_WINDOWS_BOOT_TWOFISH)
|
||||||
# define TC__BOOT_MEMORY_REQUIRED 41
|
# define TC__BOOT_MEMORY_REQUIRED 41
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
# undef TC__BOOT_MEMORY_REQUIRED
|
# undef TC__BOOT_MEMORY_REQUIRED
|
||||||
# define TC__BOOT_MEMORY_REQUIRED 60
|
# define TC__BOOT_MEMORY_REQUIRED 60
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Modifying this value can introduce incompatibility with previous versions
|
// Modifying this value can introduce incompatibility with previous versions
|
||||||
#define TC__BOOT_LOADER_SEGMENT TC_HEX (9000) // Some buggy BIOS routines fail if CS bits 0-10 are not zero
|
#define TC__BOOT_LOADER_SEGMENT TC_HEX (9000) // Some buggy BIOS routines fail if CS bits 0-10 are not zero
|
||||||
|
|
||||||
#if TC__BOOT_MEMORY_REQUIRED <= 32
|
#if TC__BOOT_MEMORY_REQUIRED <= 32
|
||||||
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 32 * 1024 / 16)
|
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 32 * 1024 / 16)
|
||||||
#else
|
#else
|
||||||
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 64 * 1024 / 16)
|
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 64 * 1024 / 16)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TC__COM_EXECUTABLE_OFFSET TC_HEX (100)
|
#define TC__COM_EXECUTABLE_OFFSET TC_HEX (100)
|
||||||
|
|
||||||
#define TC__BOOT_LOADER_LOWMEM_SEGMENT TC_HEX (2000)
|
#define TC__BOOT_LOADER_LOWMEM_SEGMENT TC_HEX (2000)
|
||||||
#define TC__BOOT_LOADER_BUFFER_SEGMENT TC_HEX (4000)
|
#define TC__BOOT_LOADER_BUFFER_SEGMENT TC_HEX (4000)
|
||||||
#define TC__BOOT_LOADER_ALT_SEGMENT TC_HEX (6000)
|
#define TC__BOOT_LOADER_ALT_SEGMENT TC_HEX (6000)
|
||||||
|
|
||||||
#define TC__BOOT_LOADER_STACK_TOP (TC_BOOT_MEMORY_REQUIRED * TC_UNSIGNED (1024) - 4)
|
#define TC__BOOT_LOADER_STACK_TOP (TC_BOOT_MEMORY_REQUIRED * TC_UNSIGNED (1024) - 4)
|
||||||
|
|
||||||
#define TC__LB_SIZE 512
|
#define TC__LB_SIZE 512
|
||||||
#define TC__BOOT_LOADER_AREA_SECTOR_COUNT 63
|
#define TC__BOOT_LOADER_AREA_SECTOR_COUNT 63
|
||||||
|
|
||||||
#define TC__BOOT_SECTOR_VERSION_OFFSET 430
|
#define TC__BOOT_SECTOR_VERSION_OFFSET 430
|
||||||
#define TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET 432
|
#define TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET 432
|
||||||
#define TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET 434
|
#define TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET 434
|
||||||
#define TC__BOOT_SECTOR_USER_CONFIG_OFFSET 438
|
#define TC__BOOT_SECTOR_USER_CONFIG_OFFSET 438
|
||||||
#define TC__BOOT_SECTOR_CONFIG_OFFSET 439 // The last byte that is reserved for the boot loader
|
#define TC__BOOT_SECTOR_CONFIG_OFFSET 439 // The last byte that is reserved for the boot loader
|
||||||
|
|
||||||
#define TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH 24
|
#define TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH 24
|
||||||
#define TC__BOOT_SECTOR_USER_MESSAGE_OFFSET (TC__BOOT_SECTOR_VERSION_OFFSET - TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)
|
#define TC__BOOT_SECTOR_USER_MESSAGE_OFFSET (TC__BOOT_SECTOR_VERSION_OFFSET - TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)
|
||||||
|
|
||||||
#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE 4
|
#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE 4
|
||||||
#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET (TC__BOOT_SECTOR_USER_MESSAGE_OFFSET - TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE)
|
#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET (TC__BOOT_SECTOR_USER_MESSAGE_OFFSET - TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE)
|
||||||
|
|
||||||
#define TC__BOOT_SECTOR_PIM_VALUE_SIZE 2
|
#define TC__BOOT_SECTOR_PIM_VALUE_SIZE 2
|
||||||
#define TC__BOOT_SECTOR_PIM_VALUE_OFFSET (TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET - TC__BOOT_SECTOR_PIM_VALUE_SIZE)
|
#define TC__BOOT_SECTOR_PIM_VALUE_OFFSET (TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET - TC__BOOT_SECTOR_PIM_VALUE_SIZE)
|
||||||
|
|
||||||
#define TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR 2
|
#define TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR 2
|
||||||
#define TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT 4
|
#define TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT 4
|
||||||
#define TC__BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE 32768
|
#define TC__BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE 32768
|
||||||
#define TC__BOOT_LOADER_COMPRESSED_BUFFER_OFFSET (TC_COM_EXECUTABLE_OFFSET + 3072)
|
#define TC__BOOT_LOADER_COMPRESSED_BUFFER_OFFSET (TC_COM_EXECUTABLE_OFFSET + 3072)
|
||||||
|
|
||||||
#define TC__BOOT_LOADER_START_SECTOR (TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR + TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT)
|
#define TC__BOOT_LOADER_START_SECTOR (TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR + TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT)
|
||||||
#define TC__MAX_BOOT_LOADER_SECTOR_COUNT (TC_BOOT_LOADER_AREA_SECTOR_COUNT - TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT - 2)
|
#define TC__MAX_BOOT_LOADER_SECTOR_COUNT (TC_BOOT_LOADER_AREA_SECTOR_COUNT - TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT - 2)
|
||||||
#define TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE ((TC_BOOT_LOADER_AREA_SECTOR_COUNT - 2) * TC_LB_SIZE)
|
#define TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE ((TC_BOOT_LOADER_AREA_SECTOR_COUNT - 2) * TC_LB_SIZE)
|
||||||
|
|
||||||
#define TC__BOOT_LOADER_BACKUP_SECTOR_COUNT 30
|
#define TC__BOOT_LOADER_BACKUP_SECTOR_COUNT 30
|
||||||
|
|
||||||
#define TC__GZIP_HEADER_SIZE 10
|
#define TC__GZIP_HEADER_SIZE 10
|
||||||
|
|
||||||
#define TC__BOOT_CFG_FLAG_AREA_SIZE 1 // In bytes
|
#define TC__BOOT_CFG_FLAG_AREA_SIZE 1 // In bytes
|
||||||
|
|
||||||
// If you add more flags, revise TC__BOOT_CFG_FLAG_AREA_SIZE
|
// If you add more flags, revise TC__BOOT_CFG_FLAG_AREA_SIZE
|
||||||
#define TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE TC_HEX (02)
|
#define TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE TC_HEX (02)
|
||||||
#define TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER TC_HEX (04)
|
#define TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER TC_HEX (04)
|
||||||
#define TC__BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION TC_HEX (10)
|
#define TC__BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION TC_HEX (10)
|
||||||
#define TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER TC_HEX (20)
|
#define TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER TC_HEX (20)
|
||||||
#define TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE (TC_HEX (40) + TC_HEX (80))
|
#define TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE (TC_HEX (40) + TC_HEX (80))
|
||||||
|
|
||||||
// Modifying the following values can introduce incompatibility with previous versions
|
// Modifying the following values can introduce incompatibility with previous versions
|
||||||
#define TC__BOOT_USER_CFG_FLAG_SILENT_MODE TC_HEX (01)
|
#define TC__BOOT_USER_CFG_FLAG_SILENT_MODE TC_HEX (01)
|
||||||
#define TC__BOOT_USER_CFG_FLAG_DISABLE_ESC TC_HEX (02)
|
#define TC__BOOT_USER_CFG_FLAG_DISABLE_ESC TC_HEX (02)
|
||||||
#define TC__BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION TC_HEX (04)
|
#define TC__BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION TC_HEX (04)
|
||||||
#define TC__BOOT_USER_CFG_FLAG_DISABLE_PIM TC_HEX (08)
|
#define TC__BOOT_USER_CFG_FLAG_DISABLE_PIM TC_HEX (08)
|
||||||
|
|
||||||
// The following items are treated as a 2-bit value (apply TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE to obtain the value)
|
// The following items are treated as a 2-bit value (apply TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE to obtain the value)
|
||||||
#define TC__HIDDEN_OS_CREATION_PHASE_NONE 0
|
#define TC__HIDDEN_OS_CREATION_PHASE_NONE 0
|
||||||
#define TC__HIDDEN_OS_CREATION_PHASE_CLONING TC_HEX (40) // The boot loader is to copy the content of the system partition to the hidden volume
|
#define TC__HIDDEN_OS_CREATION_PHASE_CLONING TC_HEX (40) // The boot loader is to copy the content of the system partition to the hidden volume
|
||||||
#define TC__HIDDEN_OS_CREATION_PHASE_WIPING TC_HEX (80) // The boot loader has successfully copied the content of the system partition to the hidden volume. The original OS is to be wiped now.
|
#define TC__HIDDEN_OS_CREATION_PHASE_WIPING TC_HEX (80) // The boot loader has successfully copied the content of the system partition to the hidden volume. The original OS is to be wiped now.
|
||||||
#define TC__HIDDEN_OS_CREATION_PHASE_WIPED (TC_HEX (40) + TC_HEX (80)) // The original OS has been wiped. The user is required to install a new OS (decoy OS) on the system partition now.
|
#define TC__HIDDEN_OS_CREATION_PHASE_WIPED (TC_HEX (40) + TC_HEX (80)) // The original OS has been wiped. The user is required to install a new OS (decoy OS) on the system partition now.
|
||||||
|
|
||||||
|
|
||||||
#ifdef TC_ASM_PREPROCESS
|
#ifdef TC_ASM_PREPROCESS
|
||||||
|
|
||||||
#define TC_HEX(N) 0##N##h
|
#define TC_HEX(N) 0##N##h
|
||||||
#define TC_UNSIGNED(N) N
|
#define TC_UNSIGNED(N) N
|
||||||
|
|
||||||
TC_BOOT_MEMORY_REQUIRED = TC__BOOT_MEMORY_REQUIRED
|
TC_BOOT_MEMORY_REQUIRED = TC__BOOT_MEMORY_REQUIRED
|
||||||
TC_BOOT_LOADER_SEGMENT = TC__BOOT_LOADER_SEGMENT
|
TC_BOOT_LOADER_SEGMENT = TC__BOOT_LOADER_SEGMENT
|
||||||
TC_BOOT_LOADER_SEGMENT_LOW = TC__BOOT_LOADER_SEGMENT_LOW
|
TC_BOOT_LOADER_SEGMENT_LOW = TC__BOOT_LOADER_SEGMENT_LOW
|
||||||
TC_COM_EXECUTABLE_OFFSET = TC__COM_EXECUTABLE_OFFSET
|
TC_COM_EXECUTABLE_OFFSET = TC__COM_EXECUTABLE_OFFSET
|
||||||
TC_BOOT_LOADER_LOWMEM_SEGMENT = TC__BOOT_LOADER_LOWMEM_SEGMENT
|
TC_BOOT_LOADER_LOWMEM_SEGMENT = TC__BOOT_LOADER_LOWMEM_SEGMENT
|
||||||
TC_BOOT_LOADER_BUFFER_SEGMENT = TC__BOOT_LOADER_BUFFER_SEGMENT
|
TC_BOOT_LOADER_BUFFER_SEGMENT = TC__BOOT_LOADER_BUFFER_SEGMENT
|
||||||
TC_BOOT_LOADER_ALT_SEGMENT = TC__BOOT_LOADER_ALT_SEGMENT
|
TC_BOOT_LOADER_ALT_SEGMENT = TC__BOOT_LOADER_ALT_SEGMENT
|
||||||
TC_BOOT_LOADER_STACK_TOP = TC__BOOT_LOADER_STACK_TOP
|
TC_BOOT_LOADER_STACK_TOP = TC__BOOT_LOADER_STACK_TOP
|
||||||
TC_LB_SIZE = TC__LB_SIZE
|
TC_LB_SIZE = TC__LB_SIZE
|
||||||
TC_BOOT_LOADER_AREA_SECTOR_COUNT = TC__BOOT_LOADER_AREA_SECTOR_COUNT
|
TC_BOOT_LOADER_AREA_SECTOR_COUNT = TC__BOOT_LOADER_AREA_SECTOR_COUNT
|
||||||
TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET = TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET
|
TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET = TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET
|
||||||
TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET = TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET
|
TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET = TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET
|
||||||
TC_BOOT_SECTOR_CONFIG_OFFSET = TC__BOOT_SECTOR_CONFIG_OFFSET
|
TC_BOOT_SECTOR_CONFIG_OFFSET = TC__BOOT_SECTOR_CONFIG_OFFSET
|
||||||
TC_BOOT_SECTOR_USER_CONFIG_OFFSET = TC__BOOT_SECTOR_USER_CONFIG_OFFSET
|
TC_BOOT_SECTOR_USER_CONFIG_OFFSET = TC__BOOT_SECTOR_USER_CONFIG_OFFSET
|
||||||
TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR = TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR
|
TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR = TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR
|
||||||
TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT = TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT = TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
||||||
TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE = TC__BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE
|
TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE = TC__BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE
|
||||||
TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET = TC__BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
|
TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET = TC__BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
|
||||||
TC_BOOT_LOADER_START_SECTOR = TC__BOOT_LOADER_START_SECTOR
|
TC_BOOT_LOADER_START_SECTOR = TC__BOOT_LOADER_START_SECTOR
|
||||||
TC_MAX_BOOT_LOADER_SECTOR_COUNT = TC__MAX_BOOT_LOADER_SECTOR_COUNT
|
TC_MAX_BOOT_LOADER_SECTOR_COUNT = TC__MAX_BOOT_LOADER_SECTOR_COUNT
|
||||||
TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE = TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE
|
TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE = TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE
|
||||||
TC_BOOT_LOADER_BACKUP_SECTOR_COUNT = TC__BOOT_LOADER_BACKUP_SECTOR_COUNT
|
TC_BOOT_LOADER_BACKUP_SECTOR_COUNT = TC__BOOT_LOADER_BACKUP_SECTOR_COUNT
|
||||||
TC_GZIP_HEADER_SIZE = TC__GZIP_HEADER_SIZE
|
TC_GZIP_HEADER_SIZE = TC__GZIP_HEADER_SIZE
|
||||||
TC_BOOT_CFG_FLAG_AREA_SIZE = TC__BOOT_CFG_FLAG_AREA_SIZE
|
TC_BOOT_CFG_FLAG_AREA_SIZE = TC__BOOT_CFG_FLAG_AREA_SIZE
|
||||||
TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE = TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE
|
TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE = TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE
|
||||||
TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER = TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER
|
TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER = TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER
|
||||||
TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER = TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER
|
TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER = TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER
|
||||||
TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE = TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE
|
TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE = TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE
|
||||||
TC_BOOT_USER_CFG_FLAG_SILENT_MODE = TC__BOOT_USER_CFG_FLAG_SILENT_MODE
|
TC_BOOT_USER_CFG_FLAG_SILENT_MODE = TC__BOOT_USER_CFG_FLAG_SILENT_MODE
|
||||||
TC_HIDDEN_OS_CREATION_PHASE_NONE = TC__HIDDEN_OS_CREATION_PHASE_NONE
|
TC_HIDDEN_OS_CREATION_PHASE_NONE = TC__HIDDEN_OS_CREATION_PHASE_NONE
|
||||||
TC_HIDDEN_OS_CREATION_PHASE_CLONING = TC__HIDDEN_OS_CREATION_PHASE_CLONING
|
TC_HIDDEN_OS_CREATION_PHASE_CLONING = TC__HIDDEN_OS_CREATION_PHASE_CLONING
|
||||||
TC_HIDDEN_OS_CREATION_PHASE_WIPING = TC__HIDDEN_OS_CREATION_PHASE_WIPING
|
TC_HIDDEN_OS_CREATION_PHASE_WIPING = TC__HIDDEN_OS_CREATION_PHASE_WIPING
|
||||||
TC_HIDDEN_OS_CREATION_PHASE_WIPED = TC__HIDDEN_OS_CREATION_PHASE_WIPED
|
TC_HIDDEN_OS_CREATION_PHASE_WIPED = TC__HIDDEN_OS_CREATION_PHASE_WIPED
|
||||||
|
|
||||||
#else // TC_ASM_PREPROCESS
|
#else // TC_ASM_PREPROCESS
|
||||||
|
|
||||||
#define TC_HEX(N) 0x##N
|
#define TC_HEX(N) 0x##N
|
||||||
#define TC_UNSIGNED(N) N##U
|
#define TC_UNSIGNED(N) N##U
|
||||||
|
|
||||||
#define TC_BOOT_MEMORY_REQUIRED TC__BOOT_MEMORY_REQUIRED
|
#define TC_BOOT_MEMORY_REQUIRED TC__BOOT_MEMORY_REQUIRED
|
||||||
#define TC_BOOT_LOADER_SEGMENT TC__BOOT_LOADER_SEGMENT
|
#define TC_BOOT_LOADER_SEGMENT TC__BOOT_LOADER_SEGMENT
|
||||||
#define TC_COM_EXECUTABLE_OFFSET TC__COM_EXECUTABLE_OFFSET
|
#define TC_COM_EXECUTABLE_OFFSET TC__COM_EXECUTABLE_OFFSET
|
||||||
#define TC_BOOT_LOADER_LOWMEM_SEGMENT TC__BOOT_LOADER_LOWMEM_SEGMENT
|
#define TC_BOOT_LOADER_LOWMEM_SEGMENT TC__BOOT_LOADER_LOWMEM_SEGMENT
|
||||||
#define TC_BOOT_LOADER_BUFFER_SEGMENT TC__BOOT_LOADER_BUFFER_SEGMENT
|
#define TC_BOOT_LOADER_BUFFER_SEGMENT TC__BOOT_LOADER_BUFFER_SEGMENT
|
||||||
#define TC_BOOT_LOADER_ALT_SEGMENT TC__BOOT_LOADER_ALT_SEGMENT
|
#define TC_BOOT_LOADER_ALT_SEGMENT TC__BOOT_LOADER_ALT_SEGMENT
|
||||||
#define TC_BOOT_LOADER_STACK_TOP (TC__BOOT_LOADER_STACK_TOP)
|
#define TC_BOOT_LOADER_STACK_TOP (TC__BOOT_LOADER_STACK_TOP)
|
||||||
#define TC_BOOT_LOADER_AREA_SECTOR_COUNT TC__BOOT_LOADER_AREA_SECTOR_COUNT
|
#define TC_BOOT_LOADER_AREA_SECTOR_COUNT TC__BOOT_LOADER_AREA_SECTOR_COUNT
|
||||||
#define TC_BOOT_SECTOR_USER_MESSAGE_OFFSET TC__BOOT_SECTOR_USER_MESSAGE_OFFSET
|
#define TC_BOOT_SECTOR_USER_MESSAGE_OFFSET TC__BOOT_SECTOR_USER_MESSAGE_OFFSET
|
||||||
#define TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE
|
#define TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE
|
||||||
#define TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET
|
#define TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET
|
||||||
#define TC_BOOT_SECTOR_PIM_VALUE_SIZE TC__BOOT_SECTOR_PIM_VALUE_SIZE
|
#define TC_BOOT_SECTOR_PIM_VALUE_SIZE TC__BOOT_SECTOR_PIM_VALUE_SIZE
|
||||||
#define TC_BOOT_SECTOR_PIM_VALUE_OFFSET TC__BOOT_SECTOR_PIM_VALUE_OFFSET
|
#define TC_BOOT_SECTOR_PIM_VALUE_OFFSET TC__BOOT_SECTOR_PIM_VALUE_OFFSET
|
||||||
#define TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH
|
#define TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH
|
||||||
#define TC_BOOT_SECTOR_VERSION_OFFSET TC__BOOT_SECTOR_VERSION_OFFSET
|
#define TC_BOOT_SECTOR_VERSION_OFFSET TC__BOOT_SECTOR_VERSION_OFFSET
|
||||||
#define TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET
|
#define TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET
|
||||||
#define TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET
|
#define TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET
|
||||||
#define TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR
|
#define TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR
|
||||||
#define TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
#define TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
||||||
#define TC_BOOT_SECTOR_CONFIG_OFFSET TC__BOOT_SECTOR_CONFIG_OFFSET
|
#define TC_BOOT_SECTOR_CONFIG_OFFSET TC__BOOT_SECTOR_CONFIG_OFFSET
|
||||||
#define TC_BOOT_SECTOR_USER_CONFIG_OFFSET TC__BOOT_SECTOR_USER_CONFIG_OFFSET
|
#define TC_BOOT_SECTOR_USER_CONFIG_OFFSET TC__BOOT_SECTOR_USER_CONFIG_OFFSET
|
||||||
#define TC_BOOT_LOADER_START_SECTOR TC__BOOT_LOADER_START_SECTOR
|
#define TC_BOOT_LOADER_START_SECTOR TC__BOOT_LOADER_START_SECTOR
|
||||||
#define TC_LB_SIZE TC__LB_SIZE
|
#define TC_LB_SIZE TC__LB_SIZE
|
||||||
#define TC_MAX_BOOT_LOADER_SECTOR_COUNT TC__MAX_BOOT_LOADER_SECTOR_COUNT
|
#define TC_MAX_BOOT_LOADER_SECTOR_COUNT TC__MAX_BOOT_LOADER_SECTOR_COUNT
|
||||||
#define TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE
|
#define TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE
|
||||||
#define TC_BOOT_LOADER_BACKUP_SECTOR_COUNT TC__BOOT_LOADER_BACKUP_SECTOR_COUNT
|
#define TC_BOOT_LOADER_BACKUP_SECTOR_COUNT TC__BOOT_LOADER_BACKUP_SECTOR_COUNT
|
||||||
#define TC_GZIP_HEADER_SIZE TC__GZIP_HEADER_SIZE
|
#define TC_GZIP_HEADER_SIZE TC__GZIP_HEADER_SIZE
|
||||||
#define TC_BOOT_CFG_FLAG_AREA_SIZE TC__BOOT_CFG_FLAG_AREA_SIZE
|
#define TC_BOOT_CFG_FLAG_AREA_SIZE TC__BOOT_CFG_FLAG_AREA_SIZE
|
||||||
#define TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE
|
#define TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE
|
||||||
#define TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER
|
#define TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER
|
||||||
#define TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER
|
#define TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER
|
||||||
#define TC_BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION TC__BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION
|
#define TC_BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION TC__BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION
|
||||||
#define TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE
|
#define TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE
|
||||||
#define TC_BOOT_USER_CFG_FLAG_SILENT_MODE TC__BOOT_USER_CFG_FLAG_SILENT_MODE
|
#define TC_BOOT_USER_CFG_FLAG_SILENT_MODE TC__BOOT_USER_CFG_FLAG_SILENT_MODE
|
||||||
#define TC_BOOT_USER_CFG_FLAG_DISABLE_ESC TC__BOOT_USER_CFG_FLAG_DISABLE_ESC
|
#define TC_BOOT_USER_CFG_FLAG_DISABLE_ESC TC__BOOT_USER_CFG_FLAG_DISABLE_ESC
|
||||||
#define TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION TC__BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION
|
#define TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION TC__BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION
|
||||||
#define TC_BOOT_USER_CFG_FLAG_DISABLE_PIM TC__BOOT_USER_CFG_FLAG_DISABLE_PIM
|
#define TC_BOOT_USER_CFG_FLAG_DISABLE_PIM TC__BOOT_USER_CFG_FLAG_DISABLE_PIM
|
||||||
#define TC_HIDDEN_OS_CREATION_PHASE_NONE TC__HIDDEN_OS_CREATION_PHASE_NONE
|
#define TC_HIDDEN_OS_CREATION_PHASE_NONE TC__HIDDEN_OS_CREATION_PHASE_NONE
|
||||||
#define TC_HIDDEN_OS_CREATION_PHASE_CLONING TC__HIDDEN_OS_CREATION_PHASE_CLONING
|
#define TC_HIDDEN_OS_CREATION_PHASE_CLONING TC__HIDDEN_OS_CREATION_PHASE_CLONING
|
||||||
#define TC_HIDDEN_OS_CREATION_PHASE_WIPING TC__HIDDEN_OS_CREATION_PHASE_WIPING
|
#define TC_HIDDEN_OS_CREATION_PHASE_WIPING TC__HIDDEN_OS_CREATION_PHASE_WIPING
|
||||||
#define TC_HIDDEN_OS_CREATION_PHASE_WIPED TC__HIDDEN_OS_CREATION_PHASE_WIPED
|
#define TC_HIDDEN_OS_CREATION_PHASE_WIPED TC__HIDDEN_OS_CREATION_PHASE_WIPED
|
||||||
|
|
||||||
#endif // TC_ASM_PREPROCESS
|
#endif // TC_ASM_PREPROCESS
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootDefs
|
#endif // TC_HEADER_Boot_BootDefs
|
||||||
|
|||||||
+491
-491
@@ -1,491 +1,491 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "BootConsoleIo.h"
|
#include "BootConsoleIo.h"
|
||||||
#include "BootConfig.h"
|
#include "BootConfig.h"
|
||||||
#include "BootDebug.h"
|
#include "BootDebug.h"
|
||||||
#include "BootDefs.h"
|
#include "BootDefs.h"
|
||||||
#include "BootDiskIo.h"
|
#include "BootDiskIo.h"
|
||||||
#include "BootStrings.h"
|
#include "BootStrings.h"
|
||||||
|
|
||||||
|
|
||||||
byte SectorBuffer[TC_LB_SIZE];
|
byte SectorBuffer[TC_LB_SIZE];
|
||||||
|
|
||||||
#ifdef TC_BOOT_DEBUG_ENABLED
|
#ifdef TC_BOOT_DEBUG_ENABLED
|
||||||
static bool SectorBufferInUse = false;
|
static bool SectorBufferInUse = false;
|
||||||
|
|
||||||
void AcquireSectorBuffer ()
|
void AcquireSectorBuffer ()
|
||||||
{
|
{
|
||||||
if (SectorBufferInUse)
|
if (SectorBufferInUse)
|
||||||
TC_THROW_FATAL_EXCEPTION;
|
TC_THROW_FATAL_EXCEPTION;
|
||||||
|
|
||||||
SectorBufferInUse = true;
|
SectorBufferInUse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ReleaseSectorBuffer ()
|
void ReleaseSectorBuffer ()
|
||||||
{
|
{
|
||||||
SectorBufferInUse = false;
|
SectorBufferInUse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool IsLbaSupported (byte drive)
|
bool IsLbaSupported (byte drive)
|
||||||
{
|
{
|
||||||
static byte CachedDrive = TC_INVALID_BIOS_DRIVE;
|
static byte CachedDrive = TC_INVALID_BIOS_DRIVE;
|
||||||
static bool CachedStatus;
|
static bool CachedStatus;
|
||||||
uint16 result = 0;
|
uint16 result = 0;
|
||||||
|
|
||||||
if (CachedDrive == drive)
|
if (CachedDrive == drive)
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov bx, 0x55aa
|
mov bx, 0x55aa
|
||||||
mov dl, drive
|
mov dl, drive
|
||||||
mov ah, 0x41
|
mov ah, 0x41
|
||||||
int 0x13
|
int 0x13
|
||||||
jc err
|
jc err
|
||||||
mov result, bx
|
mov result, bx
|
||||||
err:
|
err:
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedDrive = drive;
|
CachedDrive = drive;
|
||||||
CachedStatus = (result == 0xaa55);
|
CachedStatus = (result == 0xaa55);
|
||||||
ret:
|
ret:
|
||||||
return CachedStatus;
|
return CachedStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs)
|
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs)
|
||||||
{
|
{
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
Print (write ? "Write" : "Read"); Print (" error:");
|
Print (write ? "Write" : "Read"); Print (" error:");
|
||||||
Print (error);
|
Print (error);
|
||||||
Print (" Drive:");
|
Print (" Drive:");
|
||||||
Print (drive ^ 0x80);
|
Print (drive ^ 0x80);
|
||||||
|
|
||||||
if (sector)
|
if (sector)
|
||||||
{
|
{
|
||||||
Print (" Sector:");
|
Print (" Sector:");
|
||||||
Print (*sector);
|
Print (*sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chs)
|
if (chs)
|
||||||
{
|
{
|
||||||
Print (" CHS:");
|
Print (" CHS:");
|
||||||
Print (*chs);
|
Print (*chs);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
Beep();
|
Beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Print (const ChsAddress &chs)
|
void Print (const ChsAddress &chs)
|
||||||
{
|
{
|
||||||
Print (chs.Cylinder);
|
Print (chs.Cylinder);
|
||||||
PrintChar ('/');
|
PrintChar ('/');
|
||||||
Print (chs.Head);
|
Print (chs.Head);
|
||||||
PrintChar ('/');
|
PrintChar ('/');
|
||||||
Print (chs.Sector);
|
Print (chs.Sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintSectorCountInMB (const uint64 §orCount)
|
void PrintSectorCountInMB (const uint64 §orCount)
|
||||||
{
|
{
|
||||||
Print (sectorCount >> (TC_LB_SIZE_BIT_SHIFT_DIVISOR + 2)); Print (" MB ");
|
Print (sectorCount >> (TC_LB_SIZE_BIT_SHIFT_DIVISOR + 2)); Print (" MB ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
CheckStack();
|
CheckStack();
|
||||||
|
|
||||||
byte cylinderLow = (byte) chs.Cylinder;
|
byte cylinderLow = (byte) chs.Cylinder;
|
||||||
byte sector = chs.Sector;
|
byte sector = chs.Sector;
|
||||||
sector |= byte (chs.Cylinder >> 2) & 0xc0;
|
sector |= byte (chs.Cylinder >> 2) & 0xc0;
|
||||||
byte function = write ? 0x03 : 0x02;
|
byte function = write ? 0x03 : 0x02;
|
||||||
|
|
||||||
BiosResult result;
|
BiosResult result;
|
||||||
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
|
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = BiosResultSuccess;
|
result = BiosResultSuccess;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push es
|
push es
|
||||||
mov ax, bufferSegment
|
mov ax, bufferSegment
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov bx, bufferOffset
|
mov bx, bufferOffset
|
||||||
mov dl, drive
|
mov dl, drive
|
||||||
mov ch, cylinderLow
|
mov ch, cylinderLow
|
||||||
mov si, chs
|
mov si, chs
|
||||||
mov dh, [si].Head
|
mov dh, [si].Head
|
||||||
mov cl, sector
|
mov cl, sector
|
||||||
mov al, sectorCount
|
mov al, sectorCount
|
||||||
mov ah, function
|
mov ah, function
|
||||||
int 0x13
|
int 0x13
|
||||||
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
|
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
|
||||||
mov result, ah
|
mov result, ah
|
||||||
ok:
|
ok:
|
||||||
pop es
|
pop es
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == BiosResultEccCorrected)
|
if (result == BiosResultEccCorrected)
|
||||||
result = BiosResultSuccess;
|
result = BiosResultSuccess;
|
||||||
|
|
||||||
// Some BIOSes report I/O errors prematurely in some cases
|
// Some BIOSes report I/O errors prematurely in some cases
|
||||||
} while (result != BiosResultSuccess && --tryCount != 0);
|
} while (result != BiosResultSuccess && --tryCount != 0);
|
||||||
|
|
||||||
if (!silent && result != BiosResultSuccess)
|
if (!silent && result != BiosResultSuccess)
|
||||||
PrintDiskError (result, write, drive, nullptr, &chs);
|
PrintDiskError (result, write, drive, nullptr, &chs);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
uint16 codeSeg;
|
uint16 codeSeg;
|
||||||
__asm mov codeSeg, cs
|
__asm mov codeSeg, cs
|
||||||
return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent);
|
return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
|
return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
|
return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
CheckStack();
|
CheckStack();
|
||||||
|
|
||||||
if (!IsLbaSupported (drive))
|
if (!IsLbaSupported (drive))
|
||||||
{
|
{
|
||||||
DriveGeometry geometry;
|
DriveGeometry geometry;
|
||||||
|
|
||||||
BiosResult result = GetDriveGeometry (drive, geometry, silent);
|
BiosResult result = GetDriveGeometry (drive, geometry, silent);
|
||||||
if (result != BiosResultSuccess)
|
if (result != BiosResultSuccess)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
ChsAddress chs;
|
ChsAddress chs;
|
||||||
LbaToChs (geometry, sector, chs);
|
LbaToChs (geometry, sector, chs);
|
||||||
return ReadWriteSectors (write, (uint16) (dapPacket.Buffer >> 16), (uint16) dapPacket.Buffer, drive, chs, sectorCount, silent);
|
return ReadWriteSectors (write, (uint16) (dapPacket.Buffer >> 16), (uint16) dapPacket.Buffer, drive, chs, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
dapPacket.Size = sizeof (dapPacket);
|
dapPacket.Size = sizeof (dapPacket);
|
||||||
dapPacket.Reserved = 0;
|
dapPacket.Reserved = 0;
|
||||||
dapPacket.SectorCount = sectorCount;
|
dapPacket.SectorCount = sectorCount;
|
||||||
dapPacket.Sector = sector;
|
dapPacket.Sector = sector;
|
||||||
|
|
||||||
byte function = write ? 0x43 : 0x42;
|
byte function = write ? 0x43 : 0x42;
|
||||||
|
|
||||||
BiosResult result;
|
BiosResult result;
|
||||||
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
|
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = BiosResultSuccess;
|
result = BiosResultSuccess;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov bx, 0x55aa
|
mov bx, 0x55aa
|
||||||
mov dl, drive
|
mov dl, drive
|
||||||
mov si, [dapPacket]
|
mov si, [dapPacket]
|
||||||
mov ah, function
|
mov ah, function
|
||||||
xor al, al
|
xor al, al
|
||||||
int 0x13
|
int 0x13
|
||||||
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
|
jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes
|
||||||
mov result, ah
|
mov result, ah
|
||||||
ok:
|
ok:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == BiosResultEccCorrected)
|
if (result == BiosResultEccCorrected)
|
||||||
result = BiosResultSuccess;
|
result = BiosResultSuccess;
|
||||||
|
|
||||||
// Some BIOSes report I/O errors prematurely in some cases
|
// Some BIOSes report I/O errors prematurely in some cases
|
||||||
} while (result != BiosResultSuccess && --tryCount != 0);
|
} while (result != BiosResultSuccess && --tryCount != 0);
|
||||||
|
|
||||||
if (!silent && result != BiosResultSuccess)
|
if (!silent && result != BiosResultSuccess)
|
||||||
PrintDiskError (result, write, drive, §or);
|
PrintDiskError (result, write, drive, §or);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
static BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
BiosLbaPacket dapPacket;
|
BiosLbaPacket dapPacket;
|
||||||
dapPacket.Buffer = (uint32) buffer;
|
dapPacket.Buffer = (uint32) buffer;
|
||||||
return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
|
return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
BiosLbaPacket dapPacket;
|
BiosLbaPacket dapPacket;
|
||||||
dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset;
|
dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset;
|
||||||
return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
|
return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent);
|
return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
BiosResult result;
|
BiosResult result;
|
||||||
uint16 codeSeg;
|
uint16 codeSeg;
|
||||||
__asm mov codeSeg, cs
|
__asm mov codeSeg, cs
|
||||||
|
|
||||||
result = ReadSectors (BootStarted ? codeSeg : TC_BOOT_LOADER_ALT_SEGMENT, (uint16) buffer, drive, sector, sectorCount, silent);
|
result = ReadSectors (BootStarted ? codeSeg : TC_BOOT_LOADER_ALT_SEGMENT, (uint16) buffer, drive, sector, sectorCount, silent);
|
||||||
|
|
||||||
// Alternative segment is used to prevent memory corruption caused by buggy BIOSes
|
// Alternative segment is used to prevent memory corruption caused by buggy BIOSes
|
||||||
if (!BootStarted)
|
if (!BootStarted)
|
||||||
CopyMemory (TC_BOOT_LOADER_ALT_SEGMENT, (uint16) buffer, buffer, sectorCount * TC_LB_SIZE);
|
CopyMemory (TC_BOOT_LOADER_ALT_SEGMENT, (uint16) buffer, buffer, sectorCount * TC_LB_SIZE);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent);
|
return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent)
|
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent)
|
||||||
{
|
{
|
||||||
CheckStack();
|
CheckStack();
|
||||||
|
|
||||||
byte maxCylinderLow, maxHead, maxSector;
|
byte maxCylinderLow, maxHead, maxSector;
|
||||||
BiosResult result;
|
BiosResult result;
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push es
|
push es
|
||||||
mov dl, drive
|
mov dl, drive
|
||||||
mov ah, 0x08
|
mov ah, 0x08
|
||||||
int 0x13
|
int 0x13
|
||||||
|
|
||||||
mov result, ah
|
mov result, ah
|
||||||
mov maxCylinderLow, ch
|
mov maxCylinderLow, ch
|
||||||
mov maxSector, cl
|
mov maxSector, cl
|
||||||
mov maxHead, dh
|
mov maxHead, dh
|
||||||
pop es
|
pop es
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == BiosResultSuccess)
|
if (result == BiosResultSuccess)
|
||||||
{
|
{
|
||||||
geometry.Cylinders = (maxCylinderLow | (uint16 (maxSector & 0xc0) << 2)) + 1;
|
geometry.Cylinders = (maxCylinderLow | (uint16 (maxSector & 0xc0) << 2)) + 1;
|
||||||
geometry.Heads = maxHead + 1;
|
geometry.Heads = maxHead + 1;
|
||||||
geometry.Sectors = maxSector & ~0xc0;
|
geometry.Sectors = maxSector & ~0xc0;
|
||||||
}
|
}
|
||||||
else if (!silent)
|
else if (!silent)
|
||||||
{
|
{
|
||||||
Print ("Drive ");
|
Print ("Drive ");
|
||||||
Print (drive ^ 0x80);
|
Print (drive ^ 0x80);
|
||||||
Print (" not found: ");
|
Print (" not found: ");
|
||||||
PrintErrorNoEndl ("");
|
PrintErrorNoEndl ("");
|
||||||
Print (result);
|
Print (result);
|
||||||
PrintEndl();
|
PrintEndl();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba)
|
void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba)
|
||||||
{
|
{
|
||||||
lba.HighPart = 0;
|
lba.HighPart = 0;
|
||||||
lba.LowPart = (uint32 (chs.Cylinder) * geometry.Heads + chs.Head) * geometry.Sectors + chs.Sector - 1;
|
lba.LowPart = (uint32 (chs.Cylinder) * geometry.Heads + chs.Head) * geometry.Sectors + chs.Sector - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs)
|
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs)
|
||||||
{
|
{
|
||||||
chs.Sector = (byte) ((lba.LowPart % geometry.Sectors) + 1);
|
chs.Sector = (byte) ((lba.LowPart % geometry.Sectors) + 1);
|
||||||
uint32 ch = lba.LowPart / geometry.Sectors;
|
uint32 ch = lba.LowPart / geometry.Sectors;
|
||||||
chs.Head = (byte) (ch % geometry.Heads);
|
chs.Head = (byte) (ch % geometry.Heads);
|
||||||
chs.Cylinder = (uint16) (ch / geometry.Heads);
|
chs.Cylinder = (uint16) (ch / geometry.Heads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition &partition)
|
void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition &partition)
|
||||||
{
|
{
|
||||||
partition.Active = partEntry.BootIndicator == 0x80;
|
partition.Active = partEntry.BootIndicator == 0x80;
|
||||||
partition.EndSector.HighPart = 0;
|
partition.EndSector.HighPart = 0;
|
||||||
partition.EndSector.LowPart = partEntry.StartLBA + partEntry.SectorCountLBA - 1;
|
partition.EndSector.LowPart = partEntry.StartLBA + partEntry.SectorCountLBA - 1;
|
||||||
partition.SectorCount.HighPart = 0;
|
partition.SectorCount.HighPart = 0;
|
||||||
partition.SectorCount.LowPart = partEntry.SectorCountLBA;
|
partition.SectorCount.LowPart = partEntry.SectorCountLBA;
|
||||||
partition.StartSector.HighPart = 0;
|
partition.StartSector.HighPart = 0;
|
||||||
partition.StartSector.LowPart = partEntry.StartLBA;
|
partition.StartSector.LowPart = partEntry.StartLBA;
|
||||||
partition.Type = partEntry.Type;
|
partition.Type = partEntry.Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadWriteMBR (bool write, byte drive, bool silent)
|
BiosResult ReadWriteMBR (bool write, byte drive, bool silent)
|
||||||
{
|
{
|
||||||
uint64 mbrSector;
|
uint64 mbrSector;
|
||||||
mbrSector.HighPart = 0;
|
mbrSector.HighPart = 0;
|
||||||
mbrSector.LowPart = 0;
|
mbrSector.LowPart = 0;
|
||||||
|
|
||||||
if (write)
|
if (write)
|
||||||
return WriteSectors (SectorBuffer, drive, mbrSector, 1, silent);
|
return WriteSectors (SectorBuffer, drive, mbrSector, 1, silent);
|
||||||
|
|
||||||
return ReadSectors (SectorBuffer, drive, mbrSector, 1, silent); // Uses alternative segment
|
return ReadSectors (SectorBuffer, drive, mbrSector, 1, silent); // Uses alternative segment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent)
|
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent)
|
||||||
{
|
{
|
||||||
Partition *followingPartition;
|
Partition *followingPartition;
|
||||||
Partition tmpPartition;
|
Partition tmpPartition;
|
||||||
|
|
||||||
if (findPartitionFollowingThis)
|
if (findPartitionFollowingThis)
|
||||||
{
|
{
|
||||||
assert (partitionArrayCapacity == 1);
|
assert (partitionArrayCapacity == 1);
|
||||||
partitionArrayCapacity = 0xff;
|
partitionArrayCapacity = 0xff;
|
||||||
followingPartition = partitionArray;
|
followingPartition = partitionArray;
|
||||||
partitionArray = &tmpPartition;
|
partitionArray = &tmpPartition;
|
||||||
|
|
||||||
followingPartition->Drive = TC_INVALID_BIOS_DRIVE;
|
followingPartition->Drive = TC_INVALID_BIOS_DRIVE;
|
||||||
followingPartition->StartSector.LowPart = 0xFFFFffffUL;
|
followingPartition->StartSector.LowPart = 0xFFFFffffUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AcquireSectorBuffer();
|
AcquireSectorBuffer();
|
||||||
BiosResult result = ReadWriteMBR (false, drive, silent);
|
BiosResult result = ReadWriteMBR (false, drive, silent);
|
||||||
ReleaseSectorBuffer();
|
ReleaseSectorBuffer();
|
||||||
|
|
||||||
partitionCount = 0;
|
partitionCount = 0;
|
||||||
|
|
||||||
MBR *mbr = (MBR *) SectorBuffer;
|
MBR *mbr = (MBR *) SectorBuffer;
|
||||||
if (result != BiosResultSuccess || mbr->Signature != 0xaa55)
|
if (result != BiosResultSuccess || mbr->Signature != 0xaa55)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
PartitionEntryMBR mbrPartitions[4];
|
PartitionEntryMBR mbrPartitions[4];
|
||||||
memcpy (mbrPartitions, mbr->Partitions, sizeof (mbrPartitions));
|
memcpy (mbrPartitions, mbr->Partitions, sizeof (mbrPartitions));
|
||||||
size_t partitionArrayPos = 0, partitionNumber;
|
size_t partitionArrayPos = 0, partitionNumber;
|
||||||
|
|
||||||
for (partitionNumber = 0;
|
for (partitionNumber = 0;
|
||||||
partitionNumber < array_capacity (mbrPartitions) && partitionArrayPos < partitionArrayCapacity;
|
partitionNumber < array_capacity (mbrPartitions) && partitionArrayPos < partitionArrayCapacity;
|
||||||
++partitionNumber)
|
++partitionNumber)
|
||||||
{
|
{
|
||||||
const PartitionEntryMBR &partEntry = mbrPartitions[partitionNumber];
|
const PartitionEntryMBR &partEntry = mbrPartitions[partitionNumber];
|
||||||
|
|
||||||
if (partEntry.SectorCountLBA > 0)
|
if (partEntry.SectorCountLBA > 0)
|
||||||
{
|
{
|
||||||
Partition &partition = partitionArray[partitionArrayPos];
|
Partition &partition = partitionArray[partitionArrayPos];
|
||||||
PartitionEntryMBRToPartition (partEntry, partition);
|
PartitionEntryMBRToPartition (partEntry, partition);
|
||||||
|
|
||||||
if (activeOnly && !partition.Active)
|
if (activeOnly && !partition.Active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
partition.Drive = drive;
|
partition.Drive = drive;
|
||||||
partition.Number = partitionArrayPos;
|
partition.Number = partitionArrayPos;
|
||||||
|
|
||||||
if (partEntry.Type == 0x5 || partEntry.Type == 0xf) // Extended partition
|
if (partEntry.Type == 0x5 || partEntry.Type == 0xf) // Extended partition
|
||||||
{
|
{
|
||||||
if (IsLbaSupported (drive))
|
if (IsLbaSupported (drive))
|
||||||
{
|
{
|
||||||
// Find all extended partitions
|
// Find all extended partitions
|
||||||
uint64 firstExtStartLBA = partition.StartSector;
|
uint64 firstExtStartLBA = partition.StartSector;
|
||||||
uint64 extStartLBA = partition.StartSector;
|
uint64 extStartLBA = partition.StartSector;
|
||||||
MBR *extMbr = (MBR *) SectorBuffer;
|
MBR *extMbr = (MBR *) SectorBuffer;
|
||||||
|
|
||||||
while (partitionArrayPos < partitionArrayCapacity &&
|
while (partitionArrayPos < partitionArrayCapacity &&
|
||||||
(result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess
|
(result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess
|
||||||
&& extMbr->Signature == 0xaa55)
|
&& extMbr->Signature == 0xaa55)
|
||||||
{
|
{
|
||||||
if (extMbr->Partitions[0].SectorCountLBA > 0)
|
if (extMbr->Partitions[0].SectorCountLBA > 0)
|
||||||
{
|
{
|
||||||
Partition &logPart = partitionArray[partitionArrayPos];
|
Partition &logPart = partitionArray[partitionArrayPos];
|
||||||
PartitionEntryMBRToPartition (extMbr->Partitions[0], logPart);
|
PartitionEntryMBRToPartition (extMbr->Partitions[0], logPart);
|
||||||
logPart.Drive = drive;
|
logPart.Drive = drive;
|
||||||
|
|
||||||
logPart.Number = partitionArrayPos;
|
logPart.Number = partitionArrayPos;
|
||||||
logPart.Primary = false;
|
logPart.Primary = false;
|
||||||
|
|
||||||
logPart.StartSector.LowPart += extStartLBA.LowPart;
|
logPart.StartSector.LowPart += extStartLBA.LowPart;
|
||||||
logPart.EndSector.LowPart += extStartLBA.LowPart;
|
logPart.EndSector.LowPart += extStartLBA.LowPart;
|
||||||
|
|
||||||
if (findPartitionFollowingThis)
|
if (findPartitionFollowingThis)
|
||||||
{
|
{
|
||||||
if (logPart.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart
|
if (logPart.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart
|
||||||
&& logPart.StartSector.LowPart < followingPartition->StartSector.LowPart)
|
&& logPart.StartSector.LowPart < followingPartition->StartSector.LowPart)
|
||||||
{
|
{
|
||||||
*followingPartition = logPart;
|
*followingPartition = logPart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++partitionArrayPos;
|
++partitionArrayPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Secondary extended
|
// Secondary extended
|
||||||
if (extMbr->Partitions[1].Type != 0x5 && extMbr->Partitions[1].Type == 0xf
|
if (extMbr->Partitions[1].Type != 0x5 && extMbr->Partitions[1].Type == 0xf
|
||||||
|| extMbr->Partitions[1].SectorCountLBA == 0)
|
|| extMbr->Partitions[1].SectorCountLBA == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
extStartLBA.LowPart = extMbr->Partitions[1].StartLBA + firstExtStartLBA.LowPart;
|
extStartLBA.LowPart = extMbr->Partitions[1].StartLBA + firstExtStartLBA.LowPart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partition.Primary = true;
|
partition.Primary = true;
|
||||||
|
|
||||||
if (findPartitionFollowingThis)
|
if (findPartitionFollowingThis)
|
||||||
{
|
{
|
||||||
if (partition.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart
|
if (partition.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart
|
||||||
&& partition.StartSector.LowPart < followingPartition->StartSector.LowPart)
|
&& partition.StartSector.LowPart < followingPartition->StartSector.LowPart)
|
||||||
{
|
{
|
||||||
*followingPartition = partition;
|
*followingPartition = partition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++partitionArrayPos;
|
++partitionArrayPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partitionCount = partitionArrayPos;
|
partitionCount = partitionArrayPos;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GetActivePartition (byte drive)
|
bool GetActivePartition (byte drive)
|
||||||
{
|
{
|
||||||
size_t partCount;
|
size_t partCount;
|
||||||
|
|
||||||
if (GetDrivePartitions (drive, &ActivePartition, 1, partCount, true) != BiosResultSuccess || partCount < 1)
|
if (GetDrivePartitions (drive, &ActivePartition, 1, partCount, true) != BiosResultSuccess || partCount < 1)
|
||||||
{
|
{
|
||||||
ActivePartition.Drive = TC_INVALID_BIOS_DRIVE;
|
ActivePartition.Drive = TC_INVALID_BIOS_DRIVE;
|
||||||
PrintError (TC_BOOT_STR_NO_BOOT_PARTITION);
|
PrintError (TC_BOOT_STR_NO_BOOT_PARTITION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+120
-120
@@ -1,120 +1,120 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootDiskIo
|
#ifndef TC_HEADER_Boot_BootDiskIo
|
||||||
#define TC_HEADER_Boot_BootDiskIo
|
#define TC_HEADER_Boot_BootDiskIo
|
||||||
|
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "BootDebug.h"
|
#include "BootDebug.h"
|
||||||
#include "BootDefs.h"
|
#include "BootDefs.h"
|
||||||
|
|
||||||
#define TC_MAX_BIOS_DISK_IO_RETRIES 5
|
#define TC_MAX_BIOS_DISK_IO_RETRIES 5
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BiosResultEccCorrected = 0x11
|
BiosResultEccCorrected = 0x11
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
struct PartitionEntryMBR
|
struct PartitionEntryMBR
|
||||||
{
|
{
|
||||||
byte BootIndicator;
|
byte BootIndicator;
|
||||||
|
|
||||||
byte StartHead;
|
byte StartHead;
|
||||||
byte StartCylSector;
|
byte StartCylSector;
|
||||||
byte StartCylinder;
|
byte StartCylinder;
|
||||||
|
|
||||||
byte Type;
|
byte Type;
|
||||||
|
|
||||||
byte EndHead;
|
byte EndHead;
|
||||||
byte EndSector;
|
byte EndSector;
|
||||||
byte EndCylinder;
|
byte EndCylinder;
|
||||||
|
|
||||||
uint32 StartLBA;
|
uint32 StartLBA;
|
||||||
uint32 SectorCountLBA;
|
uint32 SectorCountLBA;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MBR
|
struct MBR
|
||||||
{
|
{
|
||||||
byte Code[446];
|
byte Code[446];
|
||||||
PartitionEntryMBR Partitions[4];
|
PartitionEntryMBR Partitions[4];
|
||||||
uint16 Signature;
|
uint16 Signature;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BiosLbaPacket
|
struct BiosLbaPacket
|
||||||
{
|
{
|
||||||
byte Size;
|
byte Size;
|
||||||
byte Reserved;
|
byte Reserved;
|
||||||
uint16 SectorCount;
|
uint16 SectorCount;
|
||||||
uint32 Buffer;
|
uint32 Buffer;
|
||||||
uint64 Sector;
|
uint64 Sector;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
struct ChsAddress
|
struct ChsAddress
|
||||||
{
|
{
|
||||||
uint16 Cylinder;
|
uint16 Cylinder;
|
||||||
byte Head;
|
byte Head;
|
||||||
byte Sector;
|
byte Sector;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Partition
|
struct Partition
|
||||||
{
|
{
|
||||||
byte Number;
|
byte Number;
|
||||||
byte Drive;
|
byte Drive;
|
||||||
bool Active;
|
bool Active;
|
||||||
uint64 EndSector;
|
uint64 EndSector;
|
||||||
bool Primary;
|
bool Primary;
|
||||||
uint64 SectorCount;
|
uint64 SectorCount;
|
||||||
uint64 StartSector;
|
uint64 StartSector;
|
||||||
byte Type;
|
byte Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DriveGeometry
|
struct DriveGeometry
|
||||||
{
|
{
|
||||||
uint16 Cylinders;
|
uint16 Cylinders;
|
||||||
byte Heads;
|
byte Heads;
|
||||||
byte Sectors;
|
byte Sectors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef TC_BOOT_DEBUG_ENABLED
|
#ifdef TC_BOOT_DEBUG_ENABLED
|
||||||
void AcquireSectorBuffer ();
|
void AcquireSectorBuffer ();
|
||||||
void ReleaseSectorBuffer ();
|
void ReleaseSectorBuffer ();
|
||||||
#else
|
#else
|
||||||
# define AcquireSectorBuffer()
|
# define AcquireSectorBuffer()
|
||||||
# define ReleaseSectorBuffer()
|
# define ReleaseSectorBuffer()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba);
|
void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba);
|
||||||
bool GetActivePartition (byte drive);
|
bool GetActivePartition (byte drive);
|
||||||
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false);
|
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false);
|
||||||
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false);
|
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false);
|
||||||
bool IsLbaSupported (byte drive);
|
bool IsLbaSupported (byte drive);
|
||||||
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs);
|
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs);
|
||||||
void Print (const ChsAddress &chs);
|
void Print (const ChsAddress &chs);
|
||||||
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr);
|
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr);
|
||||||
void PrintSectorCountInMB (const uint64 §orCount);
|
void PrintSectorCountInMB (const uint64 §orCount);
|
||||||
BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false);
|
BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false);
|
||||||
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
|
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
|
||||||
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
|
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
|
||||||
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false);
|
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false);
|
||||||
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent);
|
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent);
|
||||||
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
|
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false);
|
||||||
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false);
|
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false);
|
||||||
|
|
||||||
extern byte SectorBuffer[TC_LB_SIZE];
|
extern byte SectorBuffer[TC_LB_SIZE];
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootDiskIo
|
#endif // TC_HEADER_Boot_BootDiskIo
|
||||||
|
|||||||
@@ -1,132 +1,132 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "BootConfig.h"
|
#include "BootConfig.h"
|
||||||
#include "BootDebug.h"
|
#include "BootDebug.h"
|
||||||
#include "BootDefs.h"
|
#include "BootDefs.h"
|
||||||
#include "BootDiskIo.h"
|
#include "BootDiskIo.h"
|
||||||
#include "BootEncryptedIo.h"
|
#include "BootEncryptedIo.h"
|
||||||
|
|
||||||
|
|
||||||
BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount)
|
BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount)
|
||||||
{
|
{
|
||||||
BiosResult result;
|
BiosResult result;
|
||||||
bool decrypt = true;
|
bool decrypt = true;
|
||||||
|
|
||||||
if (BootCryptoInfo->hiddenVolume)
|
if (BootCryptoInfo->hiddenVolume)
|
||||||
{
|
{
|
||||||
if (ReadWritePartiallyCoversEncryptedArea (sector, sectorCount))
|
if (ReadWritePartiallyCoversEncryptedArea (sector, sectorCount))
|
||||||
return BiosResultInvalidFunction;
|
return BiosResultInvalidFunction;
|
||||||
|
|
||||||
if (sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector)
|
if (sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector)
|
||||||
{
|
{
|
||||||
// Remap the request to the hidden volume
|
// Remap the request to the hidden volume
|
||||||
sector -= EncryptedVirtualPartition.StartSector;
|
sector -= EncryptedVirtualPartition.StartSector;
|
||||||
sector += HiddenVolumeStartSector;
|
sector += HiddenVolumeStartSector;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
decrypt = false;
|
decrypt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ReadSectors (destSegment, destOffset, drive, sector, sectorCount);
|
result = ReadSectors (destSegment, destOffset, drive, sector, sectorCount);
|
||||||
|
|
||||||
if (result != BiosResultSuccess || !decrypt)
|
if (result != BiosResultSuccess || !decrypt)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (BootCryptoInfo->hiddenVolume)
|
if (BootCryptoInfo->hiddenVolume)
|
||||||
{
|
{
|
||||||
// Convert sector number to data unit number of the hidden volume
|
// Convert sector number to data unit number of the hidden volume
|
||||||
sector -= HiddenVolumeStartSector;
|
sector -= HiddenVolumeStartSector;
|
||||||
sector += PimValueOrHiddenVolumeStartUnitNo;
|
sector += PimValueOrHiddenVolumeStartUnitNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drive == EncryptedVirtualPartition.Drive)
|
if (drive == EncryptedVirtualPartition.Drive)
|
||||||
{
|
{
|
||||||
while (sectorCount-- > 0)
|
while (sectorCount-- > 0)
|
||||||
{
|
{
|
||||||
if (BootCryptoInfo->hiddenVolume
|
if (BootCryptoInfo->hiddenVolume
|
||||||
|| (sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector))
|
|| (sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector))
|
||||||
{
|
{
|
||||||
AcquireSectorBuffer();
|
AcquireSectorBuffer();
|
||||||
CopyMemory (destSegment, destOffset, SectorBuffer, TC_LB_SIZE);
|
CopyMemory (destSegment, destOffset, SectorBuffer, TC_LB_SIZE);
|
||||||
|
|
||||||
DecryptDataUnits (SectorBuffer, §or, 1, BootCryptoInfo);
|
DecryptDataUnits (SectorBuffer, §or, 1, BootCryptoInfo);
|
||||||
|
|
||||||
CopyMemory (SectorBuffer, destSegment, destOffset, TC_LB_SIZE);
|
CopyMemory (SectorBuffer, destSegment, destOffset, TC_LB_SIZE);
|
||||||
ReleaseSectorBuffer();
|
ReleaseSectorBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
++sector;
|
++sector;
|
||||||
destOffset += TC_LB_SIZE;
|
destOffset += TC_LB_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount)
|
BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount)
|
||||||
{
|
{
|
||||||
BiosResult result = BiosResultSuccess;
|
BiosResult result = BiosResultSuccess;
|
||||||
AcquireSectorBuffer();
|
AcquireSectorBuffer();
|
||||||
uint64 dataUnitNo;
|
uint64 dataUnitNo;
|
||||||
uint64 writeOffset;
|
uint64 writeOffset;
|
||||||
|
|
||||||
dataUnitNo = sector;
|
dataUnitNo = sector;
|
||||||
writeOffset.HighPart = 0;
|
writeOffset.HighPart = 0;
|
||||||
writeOffset.LowPart = 0;
|
writeOffset.LowPart = 0;
|
||||||
|
|
||||||
if (BootCryptoInfo->hiddenVolume)
|
if (BootCryptoInfo->hiddenVolume)
|
||||||
{
|
{
|
||||||
if (ReadWritePartiallyCoversEncryptedArea (sector, sectorCount))
|
if (ReadWritePartiallyCoversEncryptedArea (sector, sectorCount))
|
||||||
return BiosResultInvalidFunction;
|
return BiosResultInvalidFunction;
|
||||||
|
|
||||||
// Remap the request to the hidden volume
|
// Remap the request to the hidden volume
|
||||||
writeOffset = HiddenVolumeStartSector;
|
writeOffset = HiddenVolumeStartSector;
|
||||||
writeOffset -= EncryptedVirtualPartition.StartSector;
|
writeOffset -= EncryptedVirtualPartition.StartSector;
|
||||||
dataUnitNo -= EncryptedVirtualPartition.StartSector;
|
dataUnitNo -= EncryptedVirtualPartition.StartSector;
|
||||||
dataUnitNo += PimValueOrHiddenVolumeStartUnitNo;
|
dataUnitNo += PimValueOrHiddenVolumeStartUnitNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (sectorCount-- > 0)
|
while (sectorCount-- > 0)
|
||||||
{
|
{
|
||||||
CopyMemory (sourceSegment, sourceOffset, SectorBuffer, TC_LB_SIZE);
|
CopyMemory (sourceSegment, sourceOffset, SectorBuffer, TC_LB_SIZE);
|
||||||
|
|
||||||
if (drive == EncryptedVirtualPartition.Drive && sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector)
|
if (drive == EncryptedVirtualPartition.Drive && sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector)
|
||||||
{
|
{
|
||||||
EncryptDataUnits (SectorBuffer, &dataUnitNo, 1, BootCryptoInfo);
|
EncryptDataUnits (SectorBuffer, &dataUnitNo, 1, BootCryptoInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = WriteSectors (SectorBuffer, drive, sector + writeOffset, 1);
|
result = WriteSectors (SectorBuffer, drive, sector + writeOffset, 1);
|
||||||
|
|
||||||
if (result != BiosResultSuccess)
|
if (result != BiosResultSuccess)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
++sector;
|
++sector;
|
||||||
++dataUnitNo;
|
++dataUnitNo;
|
||||||
sourceOffset += TC_LB_SIZE;
|
sourceOffset += TC_LB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseSectorBuffer();
|
ReleaseSectorBuffer();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool ReadWritePartiallyCoversEncryptedArea (const uint64 §or, uint16 sectorCount)
|
static bool ReadWritePartiallyCoversEncryptedArea (const uint64 §or, uint16 sectorCount)
|
||||||
{
|
{
|
||||||
uint64 readWriteEnd = sector + --sectorCount;
|
uint64 readWriteEnd = sector + --sectorCount;
|
||||||
|
|
||||||
return ((sector < EncryptedVirtualPartition.StartSector && readWriteEnd >= EncryptedVirtualPartition.StartSector)
|
return ((sector < EncryptedVirtualPartition.StartSector && readWriteEnd >= EncryptedVirtualPartition.StartSector)
|
||||||
|| (sector >= EncryptedVirtualPartition.StartSector && readWriteEnd > EncryptedVirtualPartition.EndSector));
|
|| (sector >= EncryptedVirtualPartition.StartSector && readWriteEnd > EncryptedVirtualPartition.EndSector));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootEncryptionIo
|
#ifndef TC_HEADER_Boot_BootEncryptionIo
|
||||||
#define TC_HEADER_Boot_BootEncryptionIo
|
#define TC_HEADER_Boot_BootEncryptionIo
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount);
|
BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount);
|
||||||
BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount);
|
BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount);
|
||||||
static bool ReadWritePartiallyCoversEncryptedArea (const uint64 §or, uint16 sectorCount);
|
static bool ReadWritePartiallyCoversEncryptedArea (const uint64 §or, uint16 sectorCount);
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootEncryptionIo
|
#endif // TC_HEADER_Boot_BootEncryptionIo
|
||||||
|
|||||||
+1269
-1269
File diff suppressed because it is too large
Load Diff
+34
-34
@@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootMain
|
#ifndef TC_HEADER_Boot_BootMain
|
||||||
#define TC_HEADER_Boot_BootMain
|
#define TC_HEADER_Boot_BootMain
|
||||||
|
|
||||||
#include "TCdefs.h"
|
#include "TCdefs.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
static byte AskPassword (Password &password, int& pim);
|
static byte AskPassword (Password &password, int& pim);
|
||||||
static int AskSelection (const char *options[], size_t optionCount);
|
static int AskSelection (const char *options[], size_t optionCount);
|
||||||
static bool AskYesNo (const char *message);
|
static bool AskYesNo (const char *message);
|
||||||
static byte BootEncryptedDrive ();
|
static byte BootEncryptedDrive ();
|
||||||
static void BootMenu ();
|
static void BootMenu ();
|
||||||
static void ExecuteBootSector (byte drive, byte *sectorBuffer);
|
static void ExecuteBootSector (byte drive, byte *sectorBuffer);
|
||||||
static void InitScreen ();
|
static void InitScreen ();
|
||||||
static bool IsMenuKey (byte scanCode);
|
static bool IsMenuKey (byte scanCode);
|
||||||
static bool MountVolume (byte drive, byte &exitKey);
|
static bool MountVolume (byte drive, byte &exitKey);
|
||||||
static bool OpenVolume (byte drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false);
|
static bool OpenVolume (byte drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false);
|
||||||
static void PrintMainMenu ();
|
static void PrintMainMenu ();
|
||||||
static void RepairMenu ();
|
static void RepairMenu ();
|
||||||
|
|
||||||
#define TC_MENU_KEY_REPAIR TC_BIOS_KEY_F8
|
#define TC_MENU_KEY_REPAIR TC_BIOS_KEY_F8
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootMain
|
#endif // TC_HEADER_Boot_BootMain
|
||||||
|
|||||||
@@ -1,86 +1,86 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BootDefs.h"
|
#include "BootDefs.h"
|
||||||
#include "BootMemory.h"
|
#include "BootMemory.h"
|
||||||
|
|
||||||
static uint32 MemoryMapContValue;
|
static uint32 MemoryMapContValue;
|
||||||
|
|
||||||
static bool GetMemoryMapEntry (BiosMemoryMapEntry &entry)
|
static bool GetMemoryMapEntry (BiosMemoryMapEntry &entry)
|
||||||
{
|
{
|
||||||
static const uint32 function = 0x0000E820UL;
|
static const uint32 function = 0x0000E820UL;
|
||||||
static const uint32 magic = 0x534D4150UL;
|
static const uint32 magic = 0x534D4150UL;
|
||||||
static const uint32 bufferSize = sizeof (BiosMemoryMapEntry);
|
static const uint32 bufferSize = sizeof (BiosMemoryMapEntry);
|
||||||
|
|
||||||
bool carry = false;
|
bool carry = false;
|
||||||
uint32 resultMagic;
|
uint32 resultMagic;
|
||||||
uint32 resultSize;
|
uint32 resultSize;
|
||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push es
|
push es
|
||||||
|
|
||||||
lea di, function
|
lea di, function
|
||||||
TC_ASM_MOV_EAX_DI
|
TC_ASM_MOV_EAX_DI
|
||||||
lea di, MemoryMapContValue
|
lea di, MemoryMapContValue
|
||||||
TC_ASM_MOV_EBX_DI
|
TC_ASM_MOV_EBX_DI
|
||||||
lea di, bufferSize
|
lea di, bufferSize
|
||||||
TC_ASM_MOV_ECX_DI
|
TC_ASM_MOV_ECX_DI
|
||||||
lea di, magic
|
lea di, magic
|
||||||
TC_ASM_MOV_EDX_DI
|
TC_ASM_MOV_EDX_DI
|
||||||
lea di, MemoryMapContValue
|
lea di, MemoryMapContValue
|
||||||
TC_ASM_MOV_DI_ECX
|
TC_ASM_MOV_DI_ECX
|
||||||
|
|
||||||
// Use alternative segment to prevent memory corruption caused by buggy BIOSes
|
// Use alternative segment to prevent memory corruption caused by buggy BIOSes
|
||||||
push TC_BOOT_LOADER_ALT_SEGMENT
|
push TC_BOOT_LOADER_ALT_SEGMENT
|
||||||
pop es
|
pop es
|
||||||
mov di, 0
|
mov di, 0
|
||||||
|
|
||||||
int 0x15
|
int 0x15
|
||||||
jnc no_carry
|
jnc no_carry
|
||||||
mov carry, true
|
mov carry, true
|
||||||
no_carry:
|
no_carry:
|
||||||
|
|
||||||
lea di, resultMagic
|
lea di, resultMagic
|
||||||
TC_ASM_MOV_DI_EAX
|
TC_ASM_MOV_DI_EAX
|
||||||
lea di, MemoryMapContValue
|
lea di, MemoryMapContValue
|
||||||
TC_ASM_MOV_DI_EBX
|
TC_ASM_MOV_DI_EBX
|
||||||
lea di, resultSize
|
lea di, resultSize
|
||||||
TC_ASM_MOV_DI_ECX
|
TC_ASM_MOV_DI_ECX
|
||||||
|
|
||||||
pop es
|
pop es
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMemory (TC_BOOT_LOADER_ALT_SEGMENT, 0, &entry, sizeof (entry));
|
CopyMemory (TC_BOOT_LOADER_ALT_SEGMENT, 0, &entry, sizeof (entry));
|
||||||
|
|
||||||
// BIOS may set CF at the end of the list
|
// BIOS may set CF at the end of the list
|
||||||
if (carry)
|
if (carry)
|
||||||
MemoryMapContValue = 0;
|
MemoryMapContValue = 0;
|
||||||
|
|
||||||
return resultMagic == magic && resultSize == bufferSize;
|
return resultMagic == magic && resultSize == bufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GetFirstBiosMemoryMapEntry (BiosMemoryMapEntry &entry)
|
bool GetFirstBiosMemoryMapEntry (BiosMemoryMapEntry &entry)
|
||||||
{
|
{
|
||||||
MemoryMapContValue = 0;
|
MemoryMapContValue = 0;
|
||||||
return GetMemoryMapEntry (entry);
|
return GetMemoryMapEntry (entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GetNextBiosMemoryMapEntry (BiosMemoryMapEntry &entry)
|
bool GetNextBiosMemoryMapEntry (BiosMemoryMapEntry &entry)
|
||||||
{
|
{
|
||||||
if (MemoryMapContValue == 0)
|
if (MemoryMapContValue == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return GetMemoryMapEntry (entry);
|
return GetMemoryMapEntry (entry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
struct BiosMemoryMapEntry
|
struct BiosMemoryMapEntry
|
||||||
{
|
{
|
||||||
uint64 BaseAddress;
|
uint64 BaseAddress;
|
||||||
uint64 Length;
|
uint64 Length;
|
||||||
uint32 Type;
|
uint32 Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
bool GetFirstBiosMemoryMapEntry (BiosMemoryMapEntry &entry);
|
bool GetFirstBiosMemoryMapEntry (BiosMemoryMapEntry &entry);
|
||||||
bool GetNextBiosMemoryMapEntry (BiosMemoryMapEntry &entry);
|
bool GetNextBiosMemoryMapEntry (BiosMemoryMapEntry &entry);
|
||||||
|
|||||||
+244
-244
@@ -1,244 +1,244 @@
|
|||||||
;
|
;
|
||||||
; Derived from source code of TrueCrypt 7.1a, which is
|
; Derived from source code of TrueCrypt 7.1a, which is
|
||||||
; Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
; Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
; by the TrueCrypt License 3.0.
|
; by the TrueCrypt License 3.0.
|
||||||
;
|
;
|
||||||
; Modifications and additions to the original source code (contained in this file)
|
; Modifications and additions to the original source code (contained in this file)
|
||||||
; and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
; and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
; and are governed by the Apache License 2.0 the full text of which is
|
; and are governed by the Apache License 2.0 the full text of which is
|
||||||
; contained in the file License.txt included in VeraCrypt binary and source
|
; contained in the file License.txt included in VeraCrypt binary and source
|
||||||
; code distribution packages.
|
; code distribution packages.
|
||||||
;
|
;
|
||||||
|
|
||||||
.MODEL tiny
|
.MODEL tiny
|
||||||
.386
|
.386
|
||||||
_TEXT SEGMENT USE16
|
_TEXT SEGMENT USE16
|
||||||
|
|
||||||
INCLUDE BootDefs.i
|
INCLUDE BootDefs.i
|
||||||
|
|
||||||
ORG 7C00h ; Standard boot sector offset
|
ORG 7C00h ; Standard boot sector offset
|
||||||
|
|
||||||
start:
|
start:
|
||||||
; BIOS executes boot sector from 0:7C00 or 7C0:0000 (default CD boot loader address).
|
; BIOS executes boot sector from 0:7C00 or 7C0:0000 (default CD boot loader address).
|
||||||
; Far jump to the next instruction sets IP to the standard offset 7C00.
|
; Far jump to the next instruction sets IP to the standard offset 7C00.
|
||||||
db 0EAh ; jmp 0:main
|
db 0EAh ; jmp 0:main
|
||||||
dw main, 0
|
dw main, 0
|
||||||
|
|
||||||
loader_name_msg:
|
loader_name_msg:
|
||||||
db ' VeraCrypt Boot Loader', 13, 10, 0
|
db ' VeraCrypt Boot Loader', 13, 10, 0
|
||||||
|
|
||||||
main:
|
main:
|
||||||
cli
|
cli
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
mov ss, ax
|
mov ss, ax
|
||||||
mov sp, 7C00h
|
mov sp, 7C00h
|
||||||
sti
|
sti
|
||||||
|
|
||||||
; Display boot loader name
|
; Display boot loader name
|
||||||
test byte ptr [start + TC_BOOT_SECTOR_USER_CONFIG_OFFSET], TC_BOOT_USER_CFG_FLAG_SILENT_MODE
|
test byte ptr [start + TC_BOOT_SECTOR_USER_CONFIG_OFFSET], TC_BOOT_USER_CFG_FLAG_SILENT_MODE
|
||||||
jnz skip_loader_name_msg
|
jnz skip_loader_name_msg
|
||||||
|
|
||||||
lea si, loader_name_msg
|
lea si, loader_name_msg
|
||||||
call print
|
call print
|
||||||
skip_loader_name_msg:
|
skip_loader_name_msg:
|
||||||
|
|
||||||
; Determine boot loader segment
|
; Determine boot loader segment
|
||||||
mov ax, TC_BOOT_LOADER_SEGMENT
|
mov ax, TC_BOOT_LOADER_SEGMENT
|
||||||
|
|
||||||
; Check available memory
|
; Check available memory
|
||||||
cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
|
cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
|
||||||
jge memory_ok
|
jge memory_ok
|
||||||
|
|
||||||
mov ax, TC_BOOT_LOADER_SEGMENT_LOW
|
mov ax, TC_BOOT_LOADER_SEGMENT_LOW
|
||||||
|
|
||||||
cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT_LOW / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
|
cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT_LOW / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
|
||||||
jge memory_ok
|
jge memory_ok
|
||||||
|
|
||||||
; Insufficient memory
|
; Insufficient memory
|
||||||
mov ax, TC_BOOT_LOADER_LOWMEM_SEGMENT
|
mov ax, TC_BOOT_LOADER_LOWMEM_SEGMENT
|
||||||
|
|
||||||
memory_ok:
|
memory_ok:
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
; Clear BSS section
|
; Clear BSS section
|
||||||
xor al, al
|
xor al, al
|
||||||
mov di, TC_COM_EXECUTABLE_OFFSET
|
mov di, TC_COM_EXECUTABLE_OFFSET
|
||||||
mov cx, TC_BOOT_MEMORY_REQUIRED * 1024 - TC_COM_EXECUTABLE_OFFSET - 1
|
mov cx, TC_BOOT_MEMORY_REQUIRED * 1024 - TC_COM_EXECUTABLE_OFFSET - 1
|
||||||
cld
|
cld
|
||||||
rep stosb
|
rep stosb
|
||||||
|
|
||||||
mov ax, es
|
mov ax, es
|
||||||
sub ax, TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE / 16 ; Decompressor segment
|
sub ax, TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE / 16 ; Decompressor segment
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
; Load decompressor
|
; Load decompressor
|
||||||
mov cl, TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR
|
mov cl, TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR
|
||||||
retry_backup:
|
retry_backup:
|
||||||
mov al, TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
mov al, TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
||||||
mov bx, TC_COM_EXECUTABLE_OFFSET
|
mov bx, TC_COM_EXECUTABLE_OFFSET
|
||||||
call read_sectors
|
call read_sectors
|
||||||
|
|
||||||
; Decompressor checksum
|
; Decompressor checksum
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov si, TC_COM_EXECUTABLE_OFFSET
|
mov si, TC_COM_EXECUTABLE_OFFSET
|
||||||
mov cx, TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_LB_SIZE
|
mov cx, TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_LB_SIZE
|
||||||
call checksum
|
call checksum
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
; Load compressed boot loader
|
; Load compressed boot loader
|
||||||
mov bx, TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
|
mov bx, TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
|
||||||
mov cl, TC_BOOT_LOADER_START_SECTOR
|
mov cl, TC_BOOT_LOADER_START_SECTOR
|
||||||
mov al, TC_MAX_BOOT_LOADER_SECTOR_COUNT
|
mov al, TC_MAX_BOOT_LOADER_SECTOR_COUNT
|
||||||
|
|
||||||
test backup_loader_used, 1
|
test backup_loader_used, 1
|
||||||
jz non_backup
|
jz non_backup
|
||||||
mov al, TC_BOOT_LOADER_BACKUP_SECTOR_COUNT - TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
mov al, TC_BOOT_LOADER_BACKUP_SECTOR_COUNT - TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
|
||||||
mov cl, TC_BOOT_LOADER_START_SECTOR + TC_BOOT_LOADER_BACKUP_SECTOR_COUNT
|
mov cl, TC_BOOT_LOADER_START_SECTOR + TC_BOOT_LOADER_BACKUP_SECTOR_COUNT
|
||||||
|
|
||||||
non_backup:
|
non_backup:
|
||||||
call read_sectors
|
call read_sectors
|
||||||
|
|
||||||
; Boot loader checksum
|
; Boot loader checksum
|
||||||
pop ebx
|
pop ebx
|
||||||
mov si, TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
|
mov si, TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
|
||||||
mov cx, word ptr [start + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET]
|
mov cx, word ptr [start + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET]
|
||||||
call checksum
|
call checksum
|
||||||
|
|
||||||
; Verify checksum
|
; Verify checksum
|
||||||
cmp ebx, dword ptr [start + TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET]
|
cmp ebx, dword ptr [start + TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET]
|
||||||
je checksum_ok
|
je checksum_ok
|
||||||
|
|
||||||
; Checksum incorrect - try using backup if available
|
; Checksum incorrect - try using backup if available
|
||||||
test backup_loader_used, 1
|
test backup_loader_used, 1
|
||||||
jnz loader_damaged
|
jnz loader_damaged
|
||||||
|
|
||||||
mov backup_loader_used, 1
|
mov backup_loader_used, 1
|
||||||
mov cl, TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR + TC_BOOT_LOADER_BACKUP_SECTOR_COUNT
|
mov cl, TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR + TC_BOOT_LOADER_BACKUP_SECTOR_COUNT
|
||||||
|
|
||||||
test TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE, byte ptr [start + TC_BOOT_SECTOR_CONFIG_OFFSET]
|
test TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE, byte ptr [start + TC_BOOT_SECTOR_CONFIG_OFFSET]
|
||||||
jnz retry_backup
|
jnz retry_backup
|
||||||
|
|
||||||
loader_damaged:
|
loader_damaged:
|
||||||
lea si, loader_damaged_msg
|
lea si, loader_damaged_msg
|
||||||
call print
|
call print
|
||||||
lea si, loader_name_msg
|
lea si, loader_name_msg
|
||||||
call print
|
call print
|
||||||
jmp $
|
jmp $
|
||||||
checksum_ok:
|
checksum_ok:
|
||||||
|
|
||||||
; Set up decompressor segment
|
; Set up decompressor segment
|
||||||
mov ax, es
|
mov ax, es
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
cli
|
cli
|
||||||
mov ss, ax
|
mov ss, ax
|
||||||
mov sp, TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE
|
mov sp, TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE
|
||||||
sti
|
sti
|
||||||
|
|
||||||
push dx
|
push dx
|
||||||
|
|
||||||
; Decompress boot loader
|
; Decompress boot loader
|
||||||
mov cx, word ptr [start + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET]
|
mov cx, word ptr [start + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET]
|
||||||
sub cx, TC_GZIP_HEADER_SIZE
|
sub cx, TC_GZIP_HEADER_SIZE
|
||||||
push cx ; Compressed data size
|
push cx ; Compressed data size
|
||||||
push TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET + TC_GZIP_HEADER_SIZE ; Compressed data
|
push TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET + TC_GZIP_HEADER_SIZE ; Compressed data
|
||||||
push TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE ; Output buffer size
|
push TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE ; Output buffer size
|
||||||
push TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE + TC_COM_EXECUTABLE_OFFSET ; Output buffer
|
push TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE + TC_COM_EXECUTABLE_OFFSET ; Output buffer
|
||||||
|
|
||||||
push cs
|
push cs
|
||||||
push decompressor_ret
|
push decompressor_ret
|
||||||
push es
|
push es
|
||||||
push TC_COM_EXECUTABLE_OFFSET
|
push TC_COM_EXECUTABLE_OFFSET
|
||||||
retf
|
retf
|
||||||
decompressor_ret:
|
decompressor_ret:
|
||||||
|
|
||||||
add sp, 8
|
add sp, 8
|
||||||
pop dx
|
pop dx
|
||||||
|
|
||||||
; Restore boot sector segment
|
; Restore boot sector segment
|
||||||
push cs
|
push cs
|
||||||
pop ds
|
pop ds
|
||||||
|
|
||||||
; Check decompression result
|
; Check decompression result
|
||||||
test ax, ax
|
test ax, ax
|
||||||
jz decompression_ok
|
jz decompression_ok
|
||||||
|
|
||||||
lea si, loader_damaged_msg
|
lea si, loader_damaged_msg
|
||||||
call print
|
call print
|
||||||
jmp $
|
jmp $
|
||||||
decompression_ok:
|
decompression_ok:
|
||||||
|
|
||||||
; DH = boot sector flags
|
; DH = boot sector flags
|
||||||
mov dh, byte ptr [start + TC_BOOT_SECTOR_CONFIG_OFFSET]
|
mov dh, byte ptr [start + TC_BOOT_SECTOR_CONFIG_OFFSET]
|
||||||
|
|
||||||
; Set up boot loader segment
|
; Set up boot loader segment
|
||||||
mov ax, es
|
mov ax, es
|
||||||
add ax, TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE / 16
|
add ax, TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE / 16
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
cli
|
cli
|
||||||
mov ss, ax
|
mov ss, ax
|
||||||
mov sp, TC_BOOT_LOADER_STACK_TOP
|
mov sp, TC_BOOT_LOADER_STACK_TOP
|
||||||
sti
|
sti
|
||||||
|
|
||||||
; Execute boot loader
|
; Execute boot loader
|
||||||
push es
|
push es
|
||||||
push TC_COM_EXECUTABLE_OFFSET
|
push TC_COM_EXECUTABLE_OFFSET
|
||||||
retf
|
retf
|
||||||
|
|
||||||
; Print string
|
; Print string
|
||||||
print:
|
print:
|
||||||
xor bx, bx
|
xor bx, bx
|
||||||
mov ah, 0eh
|
mov ah, 0eh
|
||||||
cld
|
cld
|
||||||
|
|
||||||
@@: lodsb
|
@@: lodsb
|
||||||
test al, al
|
test al, al
|
||||||
jz print_end
|
jz print_end
|
||||||
|
|
||||||
int 10h
|
int 10h
|
||||||
jmp @B
|
jmp @B
|
||||||
|
|
||||||
print_end:
|
print_end:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Read sectors of the first cylinder
|
; Read sectors of the first cylinder
|
||||||
read_sectors:
|
read_sectors:
|
||||||
mov ch, 0 ; Cylinder
|
mov ch, 0 ; Cylinder
|
||||||
mov dh, 0 ; Head
|
mov dh, 0 ; Head
|
||||||
; DL = drive number passed from BIOS
|
; DL = drive number passed from BIOS
|
||||||
mov ah, 2
|
mov ah, 2
|
||||||
int 13h
|
int 13h
|
||||||
jnc read_ok
|
jnc read_ok
|
||||||
|
|
||||||
lea si, disk_error_msg
|
lea si, disk_error_msg
|
||||||
call print
|
call print
|
||||||
read_ok:
|
read_ok:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Calculate checksum
|
; Calculate checksum
|
||||||
checksum:
|
checksum:
|
||||||
push ds
|
push ds
|
||||||
push es
|
push es
|
||||||
pop ds
|
pop ds
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
cld
|
cld
|
||||||
|
|
||||||
@@: lodsb
|
@@: lodsb
|
||||||
add ebx, eax
|
add ebx, eax
|
||||||
rol ebx, 1
|
rol ebx, 1
|
||||||
loop @B
|
loop @B
|
||||||
|
|
||||||
pop ds
|
pop ds
|
||||||
ret
|
ret
|
||||||
|
|
||||||
backup_loader_used db 0
|
backup_loader_used db 0
|
||||||
|
|
||||||
disk_error_msg db 'Disk error', 13, 10, 7, 0
|
disk_error_msg db 'Disk error', 13, 10, 7, 0
|
||||||
loader_damaged_msg db 7, 'Loader damaged! Repair with Rescue Disk', 0
|
loader_damaged_msg db 7, 'Loader damaged! Repair with Rescue Disk', 0
|
||||||
|
|
||||||
ORG 7C00h + 510
|
ORG 7C00h + 510
|
||||||
dw 0AA55h ; Boot sector signature
|
dw 0AA55h ; Boot sector signature
|
||||||
|
|
||||||
_TEXT ENDS
|
_TEXT ENDS
|
||||||
END start
|
END start
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_BootStrings
|
#ifndef TC_HEADER_Boot_BootStrings
|
||||||
#define TC_HEADER_Boot_BootStrings
|
#define TC_HEADER_Boot_BootStrings
|
||||||
|
|
||||||
#define TC_BOOT_STR_ERROR "Error: "
|
#define TC_BOOT_STR_ERROR "Error: "
|
||||||
#define TC_BOOT_STR_NO_BOOT_PARTITION "No bootable partition found"
|
#define TC_BOOT_STR_NO_BOOT_PARTITION "No bootable partition found"
|
||||||
#define TC_BOOT_STR_UPGRADE_BIOS "- Upgrade BIOS\r\n- Use a different motherboard model/brand\r\n"
|
#define TC_BOOT_STR_UPGRADE_BIOS "- Upgrade BIOS\r\n- Use a different motherboard model/brand\r\n"
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_BootStrings
|
#endif // TC_HEADER_Boot_BootStrings
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ local int stored(struct state *s)
|
|||||||
s->bitbuf = 0;
|
s->bitbuf = 0;
|
||||||
s->bitcnt = 0;
|
s->bitcnt = 0;
|
||||||
|
|
||||||
if (s->incnt + 4 > s->inlen)
|
if (s->incnt + 4 > s->inlen)
|
||||||
return 2; /* not enough input */
|
return 2; /* not enough input */
|
||||||
|
|
||||||
/* get length and check against its one's complement */
|
/* get length and check against its one's complement */
|
||||||
@@ -93,7 +93,7 @@ local int stored(struct state *s)
|
|||||||
s->in[s->incnt++] != ((~len >> 8) & 0xff))
|
s->in[s->incnt++] != ((~len >> 8) & 0xff))
|
||||||
return -2; /* didn't match complement! */
|
return -2; /* didn't match complement! */
|
||||||
|
|
||||||
if (s->incnt + len > s->inlen)
|
if (s->incnt + len > s->inlen)
|
||||||
return 2; /* not enough input */
|
return 2; /* not enough input */
|
||||||
|
|
||||||
/* copy len bytes from in to out */
|
/* copy len bytes from in to out */
|
||||||
@@ -379,21 +379,21 @@ local int dynamic(struct state *s)
|
|||||||
lengths[index++] = symbol;
|
lengths[index++] = symbol;
|
||||||
else { /* repeat instruction */
|
else { /* repeat instruction */
|
||||||
len = 0; /* assume repeating zeros */
|
len = 0; /* assume repeating zeros */
|
||||||
switch(symbol)
|
switch(symbol)
|
||||||
{
|
{
|
||||||
case 16: { /* repeat last length 3..6 times */
|
case 16: { /* repeat last length 3..6 times */
|
||||||
if (index == 0) return -5; /* no last length! */
|
if (index == 0) return -5; /* no last length! */
|
||||||
len = lengths[index - 1]; /* last length */
|
len = lengths[index - 1]; /* last length */
|
||||||
symbol = 3 + bits(s, 2);
|
symbol = 3 + bits(s, 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 17: /* repeat zero 3..10 times */
|
case 17: /* repeat zero 3..10 times */
|
||||||
symbol = 3 + bits(s, 3);
|
symbol = 3 + bits(s, 3);
|
||||||
break;
|
break;
|
||||||
default: /* == 18, repeat zero 11..138 times */
|
default: /* == 18, repeat zero 11..138 times */
|
||||||
symbol = 11 + bits(s, 7);
|
symbol = 11 + bits(s, 7);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((index + symbol > nlen + ndist))
|
if ((index + symbol > nlen + ndist))
|
||||||
return -6; /* too many lengths! */
|
return -6; /* too many lengths! */
|
||||||
while (symbol--) /* repeat last or zero symbol times */
|
while (symbol--) /* repeat last or zero symbol times */
|
||||||
@@ -401,8 +401,8 @@ local int dynamic(struct state *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for end-of-block code -- there better be one! */
|
/* check for end-of-block code -- there better be one! */
|
||||||
if (lengths[256] == 0)
|
if (lengths[256] == 0)
|
||||||
return -9;
|
return -9;
|
||||||
|
|
||||||
/* build huffman table for literal/length codes */
|
/* build huffman table for literal/length codes */
|
||||||
@@ -423,50 +423,50 @@ local int dynamic(struct state *s)
|
|||||||
void _acrtused () { }
|
void _acrtused () { }
|
||||||
|
|
||||||
// Decompress deflated data
|
// Decompress deflated data
|
||||||
int far main (
|
int far main (
|
||||||
unsigned char *dest, /* pointer to destination pointer */
|
unsigned char *dest, /* pointer to destination pointer */
|
||||||
unsigned int destlen, /* amount of output space */
|
unsigned int destlen, /* amount of output space */
|
||||||
unsigned char *source, /* pointer to source data pointer */
|
unsigned char *source, /* pointer to source data pointer */
|
||||||
unsigned int sourcelen)
|
unsigned int sourcelen)
|
||||||
{
|
{
|
||||||
struct state s; /* input/output state */
|
struct state s; /* input/output state */
|
||||||
int last, type; /* block information */
|
int last, type; /* block information */
|
||||||
int err; /* return value */
|
int err; /* return value */
|
||||||
|
|
||||||
/* initialize output state */
|
/* initialize output state */
|
||||||
s.out = dest;
|
s.out = dest;
|
||||||
s.outlen = destlen; /* ignored if dest is NIL */
|
s.outlen = destlen; /* ignored if dest is NIL */
|
||||||
s.outcnt = 0;
|
s.outcnt = 0;
|
||||||
|
|
||||||
/* initialize input state */
|
/* initialize input state */
|
||||||
s.in = source;
|
s.in = source;
|
||||||
s.inlen = sourcelen;
|
s.inlen = sourcelen;
|
||||||
s.incnt = 0;
|
s.incnt = 0;
|
||||||
s.bitbuf = 0;
|
s.bitbuf = 0;
|
||||||
s.bitcnt = 0;
|
s.bitcnt = 0;
|
||||||
|
|
||||||
/* process blocks until last block or error */
|
/* process blocks until last block or error */
|
||||||
do {
|
do {
|
||||||
last = bits(&s, 1); /* one if last block */
|
last = bits(&s, 1); /* one if last block */
|
||||||
type = bits(&s, 2); /* block type 0..3 */
|
type = bits(&s, 2); /* block type 0..3 */
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
err = stored(&s);
|
err = stored(&s);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
err = fixed(&s);
|
err = fixed(&s);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
err = dynamic(&s);
|
err = dynamic(&s);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err = -1; /* type == 3, invalid */
|
err = -1; /* type == 3, invalid */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != 0) break; /* return with error */
|
if (err != 0) break; /* return with error */
|
||||||
} while (!last);
|
} while (!last);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
+645
-645
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_IntFilter
|
#ifndef TC_HEADER_Boot_IntFilter
|
||||||
#define TC_HEADER_Boot_IntFilter
|
#define TC_HEADER_Boot_IntFilter
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
bool InstallInterruptFilters ();
|
bool InstallInterruptFilters ();
|
||||||
|
|
||||||
#endif TC_HEADER_Boot_IntFilter
|
#endif TC_HEADER_Boot_IntFilter
|
||||||
|
|||||||
+202
-202
@@ -1,202 +1,202 @@
|
|||||||
#
|
#
|
||||||
# Derived from source code of TrueCrypt 7.1a, which is
|
# Derived from source code of TrueCrypt 7.1a, which is
|
||||||
# Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
# Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
# by the TrueCrypt License 3.0.
|
# by the TrueCrypt License 3.0.
|
||||||
#
|
#
|
||||||
# Modifications and additions to the original source code (contained in this file)
|
# Modifications and additions to the original source code (contained in this file)
|
||||||
# and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
# and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
# and are governed by the Apache License 2.0 the full text of which is
|
# and are governed by the Apache License 2.0 the full text of which is
|
||||||
# contained in the file License.txt included in VeraCrypt binary and source
|
# contained in the file License.txt included in VeraCrypt binary and source
|
||||||
# code distribution packages.
|
# code distribution packages.
|
||||||
|
|
||||||
PROJ = BootLoader
|
PROJ = BootLoader
|
||||||
.SILENT:
|
.SILENT:
|
||||||
|
|
||||||
!ifndef MSVC16_ROOT
|
!ifndef MSVC16_ROOT
|
||||||
!error Environment variable MSVC16_ROOT must point to the installation directory of MS Visual C++ 1.5
|
!error Environment variable MSVC16_ROOT must point to the installation directory of MS Visual C++ 1.5
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
ENVPATH = $(PATH)
|
ENVPATH = $(PATH)
|
||||||
|
|
||||||
CC = $(MSVC16_ROOT)\bin\cl.exe
|
CC = $(MSVC16_ROOT)\bin\cl.exe
|
||||||
LD = $(MSVC16_ROOT)\bin\link.exe
|
LD = $(MSVC16_ROOT)\bin\link.exe
|
||||||
|
|
||||||
AFLAGS = /nologo /omf
|
AFLAGS = /nologo /omf
|
||||||
|
|
||||||
CFLAGS = /nologo /W3 /Fc /I "$(MSVC16_ROOT)\Include" /I"..\..\.." /I"..\..\..\Common" /I"..\..\..\Crypto"
|
CFLAGS = /nologo /W3 /Fc /I "$(MSVC16_ROOT)\Include" /I"..\..\.." /I"..\..\..\Common" /I"..\..\..\Crypto"
|
||||||
CFLAGS = $(CFLAGS) /D __int8=char /D __int16=int /D __int32=long /D BOOL=char /D FALSE=0 /D TRUE=1
|
CFLAGS = $(CFLAGS) /D __int8=char /D __int16=int /D __int32=long /D BOOL=char /D FALSE=0 /D TRUE=1
|
||||||
CFLAGS = $(CFLAGS) /D LITTLE_ENDIAN=1234 /D BYTE_ORDER=1234 /D TC_WINDOWS_BOOT /D TC_MINIMIZE_CODE_SIZE /D TC_NO_COMPILER_INT64
|
CFLAGS = $(CFLAGS) /D LITTLE_ENDIAN=1234 /D BYTE_ORDER=1234 /D TC_WINDOWS_BOOT /D TC_MINIMIZE_CODE_SIZE /D TC_NO_COMPILER_INT64
|
||||||
CFLAGS = $(CFLAGS) /D malloc=malloc_NA
|
CFLAGS = $(CFLAGS) /D malloc=malloc_NA
|
||||||
|
|
||||||
LFLAGS = /NOLOGO /ONERROR:NOEXE /NOI /BATCH
|
LFLAGS = /NOLOGO /ONERROR:NOEXE /NOI /BATCH
|
||||||
|
|
||||||
OBJDIR = Release
|
OBJDIR = Release
|
||||||
|
|
||||||
!ifdef RESCUE_DISK
|
!ifdef RESCUE_DISK
|
||||||
OBJDIR = Rescue
|
OBJDIR = Rescue
|
||||||
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
!ifdef SINGLE_CIPHER
|
!ifdef SINGLE_CIPHER
|
||||||
OBJDIR = $(OBJDIR)_$(SINGLE_CIPHER)
|
OBJDIR = $(OBJDIR)_$(SINGLE_CIPHER)
|
||||||
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE /D TC_WINDOWS_BOOT_$(SINGLE_CIPHER)
|
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE /D TC_WINDOWS_BOOT_$(SINGLE_CIPHER)
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
!ifdef SINGLE_PRF
|
!ifdef SINGLE_PRF
|
||||||
OBJDIR = $(OBJDIR)_$(SINGLE_PRF)
|
OBJDIR = $(OBJDIR)_$(SINGLE_PRF)
|
||||||
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_$(SINGLE_PRF)
|
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_$(SINGLE_PRF)
|
||||||
!else
|
!else
|
||||||
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_RIPEMD160
|
CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_RIPEMD160
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
OUTDIR = $(OBJDIR)
|
OUTDIR = $(OBJDIR)
|
||||||
TARGETEXT = com
|
TARGETEXT = com
|
||||||
TARGETS = $(OUTDIR)\BootDefs.i $(OUTDIR)\BootSector.bin $(OUTDIR)\Decompressor.com
|
TARGETS = $(OUTDIR)\BootDefs.i $(OUTDIR)\BootSector.bin $(OUTDIR)\Decompressor.com
|
||||||
CFLAGS = $(CFLAGS) /AT /Zl /f- /G3 /Oe /Os /Ob1 /OV0 /Gs /Gf /Gy /D NDEBUG
|
CFLAGS = $(CFLAGS) /AT /Zl /f- /G3 /Oe /Os /Ob1 /OV0 /Gs /Gf /Gy /D NDEBUG
|
||||||
LFLAGS = $(LFLAGS) /NOD /NOE /TINY
|
LFLAGS = $(LFLAGS) /NOD /NOE /TINY
|
||||||
OBJS = $(OUTDIR)\BootCrt.obj
|
OBJS = $(OUTDIR)\BootCrt.obj
|
||||||
LIBS = slibce
|
LIBS = slibce
|
||||||
|
|
||||||
!if 1
|
!if 1
|
||||||
SRCDIR = ..
|
SRCDIR = ..
|
||||||
!else
|
!else
|
||||||
SRCDIR = $(MAKEDIR)
|
SRCDIR = $(MAKEDIR)
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
TARGETS = $(TARGETS) $(OUTDIR)\$(PROJ).$(TARGETEXT)
|
TARGETS = $(TARGETS) $(OUTDIR)\$(PROJ).$(TARGETEXT)
|
||||||
|
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootConfig.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootConfig.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootConsoleIo.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootConsoleIo.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootDebug.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootDebug.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootDiskIo.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootDiskIo.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootEncryptedIo.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootEncryptedIo.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootMain.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootMain.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\BootMemory.obj
|
OBJS = $(OBJS) $(OUTDIR)\BootMemory.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\IntFilter.obj
|
OBJS = $(OBJS) $(OUTDIR)\IntFilter.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Platform.obj
|
OBJS = $(OBJS) $(OUTDIR)\Platform.obj
|
||||||
|
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Crc.obj
|
OBJS = $(OBJS) $(OUTDIR)\Crc.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Crypto.obj
|
OBJS = $(OBJS) $(OUTDIR)\Crypto.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Endian.obj
|
OBJS = $(OBJS) $(OUTDIR)\Endian.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Pkcs5.obj
|
OBJS = $(OBJS) $(OUTDIR)\Pkcs5.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Volumes.obj
|
OBJS = $(OBJS) $(OUTDIR)\Volumes.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Xts.obj
|
OBJS = $(OBJS) $(OUTDIR)\Xts.obj
|
||||||
|
|
||||||
!if "$(SINGLE_PRF)" == "SHA2"
|
!if "$(SINGLE_PRF)" == "SHA2"
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Sha2Small.obj
|
OBJS = $(OBJS) $(OUTDIR)\Sha2Small.obj
|
||||||
!else
|
!else
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Rmd160.obj
|
OBJS = $(OBJS) $(OUTDIR)\Rmd160.obj
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
!if !DEFINED (SINGLE_CIPHER)
|
!if !DEFINED (SINGLE_CIPHER)
|
||||||
OBJS = $(OBJS) $(OUTDIR)\AesSmall.obj
|
OBJS = $(OBJS) $(OUTDIR)\AesSmall.obj
|
||||||
!else if "$(SINGLE_CIPHER)" == "AES"
|
!else if "$(SINGLE_CIPHER)" == "AES"
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Aes_hw_cpu.obj
|
OBJS = $(OBJS) $(OUTDIR)\Aes_hw_cpu.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\AesSmall_x86.obj
|
OBJS = $(OBJS) $(OUTDIR)\AesSmall_x86.obj
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Aestab.obj
|
OBJS = $(OBJS) $(OUTDIR)\Aestab.obj
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
!if !DEFINED (SINGLE_CIPHER) || "$(SINGLE_CIPHER)" == "SERPENT"
|
!if !DEFINED (SINGLE_CIPHER) || "$(SINGLE_CIPHER)" == "SERPENT"
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Serpent.obj
|
OBJS = $(OBJS) $(OUTDIR)\Serpent.obj
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
!if !DEFINED (SINGLE_CIPHER) || "$(SINGLE_CIPHER)" == "TWOFISH"
|
!if !DEFINED (SINGLE_CIPHER) || "$(SINGLE_CIPHER)" == "TWOFISH"
|
||||||
OBJS = $(OBJS) $(OUTDIR)\Twofish.obj
|
OBJS = $(OBJS) $(OUTDIR)\Twofish.obj
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
|
||||||
all: env $(TARGETS)
|
all: env $(TARGETS)
|
||||||
|
|
||||||
env:
|
env:
|
||||||
set INCLUDE=.
|
set INCLUDE=.
|
||||||
set LIB=.
|
set LIB=.
|
||||||
set LIBPATH=.
|
set LIBPATH=.
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-del /q /s $(OBJDIR) >NUL:
|
-del /q /s $(OBJDIR) >NUL:
|
||||||
|
|
||||||
|
|
||||||
.asm{$(OUTDIR)}.obj:
|
.asm{$(OUTDIR)}.obj:
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
$(AS) $(AFLAGS) /c "$(SRCDIR)\$<"
|
$(AS) $(AFLAGS) /c "$(SRCDIR)\$<"
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
{..\..\Crypto}.asm{$(OUTDIR)}.obj:
|
{..\..\Crypto}.asm{$(OUTDIR)}.obj:
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
echo $(<F)
|
echo $(<F)
|
||||||
nasm.exe -Xvc -f obj -Ox -o "$(<B).obj" -l "$(<B).lst" "$(SRCDIR)\$<"
|
nasm.exe -Xvc -f obj -Ox -o "$(<B).obj" -l "$(<B).lst" "$(SRCDIR)\$<"
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
{..\..\Crypto}.c{$(OUTDIR)}.obj:
|
{..\..\Crypto}.c{$(OUTDIR)}.obj:
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
set PATH=.
|
set PATH=.
|
||||||
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
||||||
set PATH=$(ENVPATH)
|
set PATH=$(ENVPATH)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
{..\..\Common}.c{$(OUTDIR)}.obj:
|
{..\..\Common}.c{$(OUTDIR)}.obj:
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
set PATH=.
|
set PATH=.
|
||||||
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
||||||
set PATH=$(ENVPATH)
|
set PATH=$(ENVPATH)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
.c{$(OUTDIR)}.obj:
|
.c{$(OUTDIR)}.obj:
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
set PATH=.
|
set PATH=.
|
||||||
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
||||||
set PATH=$(ENVPATH)
|
set PATH=$(ENVPATH)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
.cpp{$(OUTDIR)}.obj:
|
.cpp{$(OUTDIR)}.obj:
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
set PATH=.
|
set PATH=.
|
||||||
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
$(CC) $(CFLAGS) /c "$(SRCDIR)\$<"
|
||||||
set PATH=$(ENVPATH)
|
set PATH=$(ENVPATH)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
$(OUTDIR)\BootDefs.i: BootDefs.h
|
$(OUTDIR)\BootDefs.i: BootDefs.h
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
set PATH=.
|
set PATH=.
|
||||||
$(CC) $(CFLAGS) /D TC_ASM_PREPROCESS /P /EP "$(SRCDIR)\BootDefs.h"
|
$(CC) $(CFLAGS) /D TC_ASM_PREPROCESS /P /EP "$(SRCDIR)\BootDefs.h"
|
||||||
set PATH=$(ENVPATH)
|
set PATH=$(ENVPATH)
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
$(OUTDIR)\BootSector.bin: $(OUTDIR)\BootSector.obj
|
$(OUTDIR)\BootSector.bin: $(OUTDIR)\BootSector.obj
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
$(LD) $(LFLAGS) BootSector.obj,BootSector.bin,,,, >NUL:
|
$(LD) $(LFLAGS) BootSector.obj,BootSector.bin,,,, >NUL:
|
||||||
-dd.exe conv=notrunc bs=512 if=BootSector.bin of=$(PROJ).flp 2>NUL:
|
-dd.exe conv=notrunc bs=512 if=BootSector.bin of=$(PROJ).flp 2>NUL:
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
$(OUTDIR)\Decompressor.com: $(OUTDIR)\BootCrt.obj $(OUTDIR)\Decompressor.obj
|
$(OUTDIR)\Decompressor.com: $(OUTDIR)\BootCrt.obj $(OUTDIR)\Decompressor.obj
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
$(LD) $(LFLAGS) BootCrt.obj Decompressor.obj,Decompressor.com,Decompressor.map,$(MSVC16_ROOT)\lib\+slibce,,
|
$(LD) $(LFLAGS) BootCrt.obj Decompressor.obj,Decompressor.com,Decompressor.map,$(MSVC16_ROOT)\lib\+slibce,,
|
||||||
-dd.exe conv=notrunc,sync bs=512 seek=1 if=Decompressor.com of=$(PROJ).flp 2>NUL:
|
-dd.exe conv=notrunc,sync bs=512 seek=1 if=Decompressor.com of=$(PROJ).flp 2>NUL:
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
$(OUTDIR)\$(PROJ).$(TARGETEXT): $(OBJS)
|
$(OUTDIR)\$(PROJ).$(TARGETEXT): $(OBJS)
|
||||||
@echo Linking...
|
@echo Linking...
|
||||||
cd $(OBJDIR)
|
cd $(OBJDIR)
|
||||||
|
|
||||||
echo >NUL: @<<$(PROJ).crf2
|
echo >NUL: @<<$(PROJ).crf2
|
||||||
|
|
||||||
$(PROJ).$(TARGETEXT)
|
$(PROJ).$(TARGETEXT)
|
||||||
$(PROJ).map
|
$(PROJ).map
|
||||||
$(MSVC16_ROOT)\lib\+
|
$(MSVC16_ROOT)\lib\+
|
||||||
$(LIBS)
|
$(LIBS)
|
||||||
;
|
;
|
||||||
<<
|
<<
|
||||||
del $(PROJ).crf >NUL: 2>NUL:
|
del $(PROJ).crf >NUL: 2>NUL:
|
||||||
for %F in ($(**F)) do @echo %F + >>$(PROJ).crf
|
for %F in ($(**F)) do @echo %F + >>$(PROJ).crf
|
||||||
type $(PROJ).crf2 >>$(PROJ).crf
|
type $(PROJ).crf2 >>$(PROJ).crf
|
||||||
|
|
||||||
$(LD) $(LFLAGS) @$(PROJ).crf
|
$(LD) $(LFLAGS) @$(PROJ).crf
|
||||||
del $(PROJ).crf $(PROJ).crf2
|
del $(PROJ).crf $(PROJ).crf2
|
||||||
|
|
||||||
# Compress the Rescue Disk botloader for Cascades and Serpent since it is too big (size > 31232 bytes)
|
# Compress the Rescue Disk botloader for Cascades and Serpent since it is too big (size > 31232 bytes)
|
||||||
!if DEFINED(RESCUE_DISK) && (!DEFINED (SINGLE_CIPHER) || ("$(SINGLE_CIPHER)" == "SERPENT"))
|
!if DEFINED(RESCUE_DISK) && (!DEFINED (SINGLE_CIPHER) || ("$(SINGLE_CIPHER)" == "SERPENT"))
|
||||||
upx $(PROJ).$(TARGETEXT)
|
upx $(PROJ).$(TARGETEXT)
|
||||||
!endif
|
!endif
|
||||||
gzip.exe -c -n --best $(PROJ).$(TARGETEXT) >$(PROJ).$(TARGETEXT).gz
|
gzip.exe -c -n --best $(PROJ).$(TARGETEXT) >$(PROJ).$(TARGETEXT).gz
|
||||||
-dd.exe conv=notrunc,sync bs=512 seek=5 if=$(PROJ).$(TARGETEXT).gz of=$(PROJ).flp 2>NUL:
|
-dd.exe conv=notrunc,sync bs=512 seek=5 if=$(PROJ).$(TARGETEXT).gz of=$(PROJ).flp 2>NUL:
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
+230
-230
@@ -1,230 +1,230 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "BootConsoleIo.h"
|
#include "BootConsoleIo.h"
|
||||||
|
|
||||||
|
|
||||||
uint64 operator+ (const uint64 &a, const uint64 &b)
|
uint64 operator+ (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
int carry = 0;
|
int carry = 0;
|
||||||
uint64 r;
|
uint64 r;
|
||||||
|
|
||||||
r.LowPart = a.LowPart + b.LowPart;
|
r.LowPart = a.LowPart + b.LowPart;
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
jnc nocarry
|
jnc nocarry
|
||||||
mov carry, 1
|
mov carry, 1
|
||||||
nocarry:
|
nocarry:
|
||||||
}
|
}
|
||||||
|
|
||||||
r.HighPart = a.HighPart + b.HighPart + carry;
|
r.HighPart = a.HighPart + b.HighPart + carry;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 operator+ (const uint64 &a, uint32 b)
|
uint64 operator+ (const uint64 &a, uint32 b)
|
||||||
{
|
{
|
||||||
uint64 b64;
|
uint64 b64;
|
||||||
b64.HighPart = 0;
|
b64.HighPart = 0;
|
||||||
b64.LowPart = b;
|
b64.LowPart = b;
|
||||||
return a + b64;
|
return a + b64;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 &operator+= (uint64 &a, const uint64 &b)
|
uint64 &operator+= (uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return a = a + b;
|
return a = a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 operator- (const uint64 &a, const uint64 &b)
|
uint64 operator- (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
int carry = 0;
|
int carry = 0;
|
||||||
uint64 r;
|
uint64 r;
|
||||||
|
|
||||||
r.LowPart = a.LowPart - b.LowPart;
|
r.LowPart = a.LowPart - b.LowPart;
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
jnc nocarry
|
jnc nocarry
|
||||||
mov carry, 1
|
mov carry, 1
|
||||||
nocarry:
|
nocarry:
|
||||||
}
|
}
|
||||||
|
|
||||||
r.HighPart = a.HighPart - b.HighPart - carry;
|
r.HighPart = a.HighPart - b.HighPart - carry;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 operator- (const uint64 &a, uint32 b)
|
uint64 operator- (const uint64 &a, uint32 b)
|
||||||
{
|
{
|
||||||
uint64 b64;
|
uint64 b64;
|
||||||
b64.HighPart = 0;
|
b64.HighPart = 0;
|
||||||
b64.LowPart = b;
|
b64.LowPart = b;
|
||||||
return a - b64;
|
return a - b64;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 &operator-= (uint64 &a, const uint64 &b)
|
uint64 &operator-= (uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return a = a - b;
|
return a = a - b;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 operator>> (const uint64 &a, int shiftCount)
|
uint64 operator>> (const uint64 &a, int shiftCount)
|
||||||
{
|
{
|
||||||
uint64 r = a;
|
uint64 r = a;
|
||||||
|
|
||||||
while (shiftCount--)
|
while (shiftCount--)
|
||||||
{
|
{
|
||||||
r.LowPart >>= 1;
|
r.LowPart >>= 1;
|
||||||
|
|
||||||
if ((byte) r.HighPart & 1)
|
if ((byte) r.HighPart & 1)
|
||||||
r.LowPart |= 0x80000000UL;
|
r.LowPart |= 0x80000000UL;
|
||||||
|
|
||||||
r.HighPart >>= 1;
|
r.HighPart >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 operator<< (const uint64 &a, int shiftCount)
|
uint64 operator<< (const uint64 &a, int shiftCount)
|
||||||
{
|
{
|
||||||
uint64 r = a;
|
uint64 r = a;
|
||||||
|
|
||||||
while (shiftCount--)
|
while (shiftCount--)
|
||||||
r += r;
|
r += r;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 &operator++ (uint64 &a)
|
uint64 &operator++ (uint64 &a)
|
||||||
{
|
{
|
||||||
uint64 b;
|
uint64 b;
|
||||||
b.HighPart = 0;
|
b.HighPart = 0;
|
||||||
b.LowPart = 1;
|
b.LowPart = 1;
|
||||||
|
|
||||||
return a += b;
|
return a += b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (const uint64 &a, const uint64 &b)
|
bool operator== (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return a.HighPart == b.HighPart && a.LowPart == b.LowPart;
|
return a.HighPart == b.HighPart && a.LowPart == b.LowPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator> (const uint64 &a, const uint64 &b)
|
bool operator> (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return (a.HighPart > b.HighPart) || (a.HighPart == b.HighPart && a.LowPart > b.LowPart);
|
return (a.HighPart > b.HighPart) || (a.HighPart == b.HighPart && a.LowPart > b.LowPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator< (const uint64 &a, const uint64 &b)
|
bool operator< (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return (a.HighPart < b.HighPart) || (a.HighPart == b.HighPart && a.LowPart < b.LowPart);
|
return (a.HighPart < b.HighPart) || (a.HighPart == b.HighPart && a.LowPart < b.LowPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator>= (const uint64 &a, const uint64 &b)
|
bool operator>= (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return a > b || a == b;
|
return a > b || a == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<= (const uint64 &a, const uint64 &b)
|
bool operator<= (const uint64 &a, const uint64 &b)
|
||||||
{
|
{
|
||||||
return a < b || a == b;
|
return a < b || a == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestInt64 ()
|
bool TestInt64 ()
|
||||||
{
|
{
|
||||||
uint64 a, b, c;
|
uint64 a, b, c;
|
||||||
a.HighPart = 0x00112233UL;
|
a.HighPart = 0x00112233UL;
|
||||||
a.LowPart = 0xabcd1234UL;
|
a.LowPart = 0xabcd1234UL;
|
||||||
|
|
||||||
b.HighPart = 0x00ffeeddUL;
|
b.HighPart = 0x00ffeeddUL;
|
||||||
b.LowPart = 0xffffFFFFUL;
|
b.LowPart = 0xffffFFFFUL;
|
||||||
|
|
||||||
a += b;
|
a += b;
|
||||||
a -= b;
|
a -= b;
|
||||||
|
|
||||||
++a;
|
++a;
|
||||||
|
|
||||||
b = b + (uint32) 1UL;
|
b = b + (uint32) 1UL;
|
||||||
|
|
||||||
c = (a - ((a + b) >> 32) - (uint32) 1UL);
|
c = (a - ((a + b) >> 32) - (uint32) 1UL);
|
||||||
if (c.HighPart != 0x112233UL || c.LowPart != 0xAABC0123UL)
|
if (c.HighPart != 0x112233UL || c.LowPart != 0xAABC0123UL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
c = c << 9;
|
c = c << 9;
|
||||||
return c.HighPart == 0x22446755UL && c.LowPart == 0x78024600UL;
|
return c.HighPart == 0x22446755UL && c.LowPart == 0x78024600UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CopyMemory (void *source, uint16 destSegment, uint16 destOffset, uint16 blockSize)
|
void CopyMemory (void *source, uint16 destSegment, uint16 destOffset, uint16 blockSize)
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push es
|
push es
|
||||||
mov si, ss:source
|
mov si, ss:source
|
||||||
mov es, ss:destSegment
|
mov es, ss:destSegment
|
||||||
mov di, ss:destOffset
|
mov di, ss:destOffset
|
||||||
mov cx, ss:blockSize
|
mov cx, ss:blockSize
|
||||||
cld
|
cld
|
||||||
rep movsb
|
rep movsb
|
||||||
pop es
|
pop es
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CopyMemory (uint16 sourceSegment, uint16 sourceOffset, void *destination, uint16 blockSize)
|
void CopyMemory (uint16 sourceSegment, uint16 sourceOffset, void *destination, uint16 blockSize)
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
push ds
|
push ds
|
||||||
push es
|
push es
|
||||||
mov ax, ds
|
mov ax, ds
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov di, ss:destination
|
mov di, ss:destination
|
||||||
mov si, ss:sourceOffset
|
mov si, ss:sourceOffset
|
||||||
mov cx, ss:blockSize
|
mov cx, ss:blockSize
|
||||||
mov ds, ss:sourceSegment
|
mov ds, ss:sourceSegment
|
||||||
cld
|
cld
|
||||||
rep movsb
|
rep movsb
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EraseMemory (void *memory, int size)
|
void EraseMemory (void *memory, int size)
|
||||||
{
|
{
|
||||||
memset (memory, 0, size);
|
memset (memory, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32 GetLinearAddress (uint16 segment, uint16 offset)
|
uint32 GetLinearAddress (uint16 segment, uint16 offset)
|
||||||
{
|
{
|
||||||
return (uint32 (segment) << 4) + offset;
|
return (uint32 (segment) << 4) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RegionsIntersect (const uint64 &start1, uint32 length1, const uint64 &start2, const uint64 &end2)
|
bool RegionsIntersect (const uint64 &start1, uint32 length1, const uint64 &start2, const uint64 &end2)
|
||||||
{
|
{
|
||||||
uint64 end1 = start1 + length1 - 1UL;
|
uint64 end1 = start1 + length1 - 1UL;
|
||||||
uint64 intersectEnd = (end1 <= end2) ? end1 : end2;
|
uint64 intersectEnd = (end1 <= end2) ? end1 : end2;
|
||||||
|
|
||||||
uint64 intersectStart = (start1 >= start2) ? start1 : start2;
|
uint64 intersectStart = (start1 >= start2) ? start1 : start2;
|
||||||
if (intersectStart > intersectEnd)
|
if (intersectStart > intersectEnd)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (intersectEnd + 1UL - intersectStart).LowPart != 0;
|
return (intersectEnd + 1UL - intersectStart).LowPart != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ThrowFatalException (int line)
|
void ThrowFatalException (int line)
|
||||||
{
|
{
|
||||||
PrintChar ('#'); Print (line);
|
PrintChar ('#'); Print (line);
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|||||||
+116
-116
@@ -1,116 +1,116 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Boot_Platform
|
#ifndef TC_HEADER_Boot_Platform
|
||||||
#define TC_HEADER_Boot_Platform
|
#define TC_HEADER_Boot_Platform
|
||||||
|
|
||||||
#pragma warning (disable: 4018 4102 4704 4769)
|
#pragma warning (disable: 4018 4102 4704 4769)
|
||||||
|
|
||||||
#include "TCdefs.h"
|
#include "TCdefs.h"
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
typedef char bool;
|
typedef char bool;
|
||||||
#define false 0
|
#define false 0
|
||||||
#define true 1
|
#define true 1
|
||||||
|
|
||||||
#define nullptr 0
|
#define nullptr 0
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
|
|
||||||
typedef UINT64_STRUCT uint64;
|
typedef UINT64_STRUCT uint64;
|
||||||
|
|
||||||
#define array_capacity(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
#define array_capacity(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
||||||
|
|
||||||
#define TC_TO_STRING2(n) #n
|
#define TC_TO_STRING2(n) #n
|
||||||
#define TC_TO_STRING(n) TC_TO_STRING2(n)
|
#define TC_TO_STRING(n) TC_TO_STRING2(n)
|
||||||
|
|
||||||
|
|
||||||
#define TC_X86_CARRY_FLAG 0x1
|
#define TC_X86_CARRY_FLAG 0x1
|
||||||
|
|
||||||
#define TC_ASM_EMIT(A,B) __asm _emit 0x##A __asm _emit 0x##B
|
#define TC_ASM_EMIT(A,B) __asm _emit 0x##A __asm _emit 0x##B
|
||||||
#define TC_ASM_EMIT3(A,B,C) __asm _emit 0x##A __asm _emit 0x##B __asm _emit 0x##C
|
#define TC_ASM_EMIT3(A,B,C) __asm _emit 0x##A __asm _emit 0x##B __asm _emit 0x##C
|
||||||
#define TC_ASM_EMIT4(A,B,C,D) __asm _emit 0x##A __asm _emit 0x##B __asm _emit 0x##C __asm _emit 0x##D
|
#define TC_ASM_EMIT4(A,B,C,D) __asm _emit 0x##A __asm _emit 0x##B __asm _emit 0x##C __asm _emit 0x##D
|
||||||
|
|
||||||
#define TC_ASM_MOV_EAX_DI TC_ASM_EMIT3 (66, 8B, 05)
|
#define TC_ASM_MOV_EAX_DI TC_ASM_EMIT3 (66, 8B, 05)
|
||||||
#define TC_ASM_MOV_EBX_DI TC_ASM_EMIT3 (66, 8B, 1D)
|
#define TC_ASM_MOV_EBX_DI TC_ASM_EMIT3 (66, 8B, 1D)
|
||||||
#define TC_ASM_MOV_ECX_DI TC_ASM_EMIT3 (66, 8B, 0D)
|
#define TC_ASM_MOV_ECX_DI TC_ASM_EMIT3 (66, 8B, 0D)
|
||||||
#define TC_ASM_MOV_EDX_DI TC_ASM_EMIT3 (66, 8B, 15)
|
#define TC_ASM_MOV_EDX_DI TC_ASM_EMIT3 (66, 8B, 15)
|
||||||
|
|
||||||
#define TC_ASM_MOV_DI_EAX TC_ASM_EMIT3 (66, 89, 05)
|
#define TC_ASM_MOV_DI_EAX TC_ASM_EMIT3 (66, 89, 05)
|
||||||
#define TC_ASM_MOV_DI_EBX TC_ASM_EMIT3 (66, 89, 1D)
|
#define TC_ASM_MOV_DI_EBX TC_ASM_EMIT3 (66, 89, 1D)
|
||||||
#define TC_ASM_MOV_DI_ECX TC_ASM_EMIT3 (66, 89, 0D)
|
#define TC_ASM_MOV_DI_ECX TC_ASM_EMIT3 (66, 89, 0D)
|
||||||
#define TC_ASM_MOV_DI_EDX TC_ASM_EMIT3 (66, 89, 15)
|
#define TC_ASM_MOV_DI_EDX TC_ASM_EMIT3 (66, 89, 15)
|
||||||
|
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
struct Registers
|
struct Registers
|
||||||
{
|
{
|
||||||
uint16 Flags;
|
uint16 Flags;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint32 EAX;
|
uint32 EAX;
|
||||||
struct { uint16 AX; uint16 EAXH; };
|
struct { uint16 AX; uint16 EAXH; };
|
||||||
};
|
};
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint32 EBX;
|
uint32 EBX;
|
||||||
struct { uint16 BX; uint16 EBXH; };
|
struct { uint16 BX; uint16 EBXH; };
|
||||||
};
|
};
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint32 ECX;
|
uint32 ECX;
|
||||||
struct { uint16 CX; uint16 ECXH; };
|
struct { uint16 CX; uint16 ECXH; };
|
||||||
};
|
};
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint32 EDX;
|
uint32 EDX;
|
||||||
struct { uint16 DX; uint16 EDXH; };
|
struct { uint16 DX; uint16 EDXH; };
|
||||||
};
|
};
|
||||||
|
|
||||||
uint16 DI;
|
uint16 DI;
|
||||||
uint16 SI;
|
uint16 SI;
|
||||||
uint16 DS;
|
uint16 DS;
|
||||||
uint16 ES;
|
uint16 ES;
|
||||||
uint16 SS;
|
uint16 SS;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
uint64 operator+ (const uint64 &a, const uint64 &b);
|
uint64 operator+ (const uint64 &a, const uint64 &b);
|
||||||
uint64 operator+ (const uint64 &a, uint32 b);
|
uint64 operator+ (const uint64 &a, uint32 b);
|
||||||
uint64 &operator+= (uint64 &a, const uint64 &b);
|
uint64 &operator+= (uint64 &a, const uint64 &b);
|
||||||
uint64 operator- (const uint64 &a, const uint64 &b);
|
uint64 operator- (const uint64 &a, const uint64 &b);
|
||||||
uint64 operator- (const uint64 &a, uint32 b);
|
uint64 operator- (const uint64 &a, uint32 b);
|
||||||
uint64 &operator-= (uint64 &a, const uint64 &b);
|
uint64 &operator-= (uint64 &a, const uint64 &b);
|
||||||
uint64 operator>> (const uint64 &a, int shiftCount);
|
uint64 operator>> (const uint64 &a, int shiftCount);
|
||||||
uint64 operator<< (const uint64 &a, int shiftCount);
|
uint64 operator<< (const uint64 &a, int shiftCount);
|
||||||
uint64 &operator++ (uint64 &a);
|
uint64 &operator++ (uint64 &a);
|
||||||
bool operator== (const uint64 &a, const uint64 &b);
|
bool operator== (const uint64 &a, const uint64 &b);
|
||||||
bool operator> (const uint64 &a, const uint64 &b);
|
bool operator> (const uint64 &a, const uint64 &b);
|
||||||
bool operator< (const uint64 &a, const uint64 &b);
|
bool operator< (const uint64 &a, const uint64 &b);
|
||||||
bool operator>= (const uint64 &a, const uint64 &b);
|
bool operator>= (const uint64 &a, const uint64 &b);
|
||||||
bool operator<= (const uint64 &a, const uint64 &b);
|
bool operator<= (const uint64 &a, const uint64 &b);
|
||||||
|
|
||||||
void CopyMemory (void *source, uint16 destSegment, uint16 destOffset, uint16 blockSize);
|
void CopyMemory (void *source, uint16 destSegment, uint16 destOffset, uint16 blockSize);
|
||||||
void CopyMemory (uint16 sourceSegment, uint16 sourceOffset, void *destination, uint16 blockSize);
|
void CopyMemory (uint16 sourceSegment, uint16 sourceOffset, void *destination, uint16 blockSize);
|
||||||
extern "C" void EraseMemory (void *memory, int size);
|
extern "C" void EraseMemory (void *memory, int size);
|
||||||
uint32 GetLinearAddress (uint16 segment, uint16 offset);
|
uint32 GetLinearAddress (uint16 segment, uint16 offset);
|
||||||
bool RegionsIntersect (const uint64 &start1, uint32 length1, const uint64 &start2, const uint64 &end2);
|
bool RegionsIntersect (const uint64 &start1, uint32 length1, const uint64 &start2, const uint64 &end2);
|
||||||
bool TestInt64 ();
|
bool TestInt64 ();
|
||||||
extern "C" void ThrowFatalException (int line);
|
extern "C" void ThrowFatalException (int line);
|
||||||
|
|
||||||
#endif // TC_HEADER_Boot_Platform
|
#endif // TC_HEADER_Boot_Platform
|
||||||
|
|||||||
Binary file not shown.
+344
-344
@@ -1,344 +1,344 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Boot/Windows/BootDefs.h"
|
#include "Boot/Windows/BootDefs.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Volumes.h"
|
#include "Volumes.h"
|
||||||
#include "Wipe.h"
|
#include "Wipe.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
/* WARNING: Modifying the following values or their meanings can introduce incompatibility with previous versions. */
|
/* WARNING: Modifying the following values or their meanings can introduce incompatibility with previous versions. */
|
||||||
|
|
||||||
#define TC_IOCTL(CODE) (CTL_CODE (FILE_DEVICE_UNKNOWN, 0x800 + (CODE), METHOD_BUFFERED, FILE_ANY_ACCESS))
|
#define TC_IOCTL(CODE) (CTL_CODE (FILE_DEVICE_UNKNOWN, 0x800 + (CODE), METHOD_BUFFERED, FILE_ANY_ACCESS))
|
||||||
|
|
||||||
#define TC_IOCTL_GET_DRIVER_VERSION TC_IOCTL (1)
|
#define TC_IOCTL_GET_DRIVER_VERSION TC_IOCTL (1)
|
||||||
#define TC_IOCTL_GET_BOOT_LOADER_VERSION TC_IOCTL (2)
|
#define TC_IOCTL_GET_BOOT_LOADER_VERSION TC_IOCTL (2)
|
||||||
#define TC_IOCTL_MOUNT_VOLUME TC_IOCTL (3)
|
#define TC_IOCTL_MOUNT_VOLUME TC_IOCTL (3)
|
||||||
#define TC_IOCTL_DISMOUNT_VOLUME TC_IOCTL (4)
|
#define TC_IOCTL_DISMOUNT_VOLUME TC_IOCTL (4)
|
||||||
#define TC_IOCTL_DISMOUNT_ALL_VOLUMES TC_IOCTL (5)
|
#define TC_IOCTL_DISMOUNT_ALL_VOLUMES TC_IOCTL (5)
|
||||||
#define TC_IOCTL_GET_MOUNTED_VOLUMES TC_IOCTL (6)
|
#define TC_IOCTL_GET_MOUNTED_VOLUMES TC_IOCTL (6)
|
||||||
#define TC_IOCTL_GET_VOLUME_PROPERTIES TC_IOCTL (7)
|
#define TC_IOCTL_GET_VOLUME_PROPERTIES TC_IOCTL (7)
|
||||||
#define TC_IOCTL_GET_DEVICE_REFCOUNT TC_IOCTL (8)
|
#define TC_IOCTL_GET_DEVICE_REFCOUNT TC_IOCTL (8)
|
||||||
#define TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED TC_IOCTL (9)
|
#define TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED TC_IOCTL (9)
|
||||||
#define TC_IOCTL_IS_ANY_VOLUME_MOUNTED TC_IOCTL (10)
|
#define TC_IOCTL_IS_ANY_VOLUME_MOUNTED TC_IOCTL (10)
|
||||||
#define TC_IOCTL_GET_PASSWORD_CACHE_STATUS TC_IOCTL (11)
|
#define TC_IOCTL_GET_PASSWORD_CACHE_STATUS TC_IOCTL (11)
|
||||||
#define TC_IOCTL_WIPE_PASSWORD_CACHE TC_IOCTL (12)
|
#define TC_IOCTL_WIPE_PASSWORD_CACHE TC_IOCTL (12)
|
||||||
#define TC_IOCTL_OPEN_TEST TC_IOCTL (13)
|
#define TC_IOCTL_OPEN_TEST TC_IOCTL (13)
|
||||||
#define TC_IOCTL_GET_DRIVE_PARTITION_INFO TC_IOCTL (14)
|
#define TC_IOCTL_GET_DRIVE_PARTITION_INFO TC_IOCTL (14)
|
||||||
#define TC_IOCTL_GET_DRIVE_GEOMETRY TC_IOCTL (15)
|
#define TC_IOCTL_GET_DRIVE_GEOMETRY TC_IOCTL (15)
|
||||||
#define TC_IOCTL_PROBE_REAL_DRIVE_SIZE TC_IOCTL (16)
|
#define TC_IOCTL_PROBE_REAL_DRIVE_SIZE TC_IOCTL (16)
|
||||||
#define TC_IOCTL_GET_RESOLVED_SYMLINK TC_IOCTL (17)
|
#define TC_IOCTL_GET_RESOLVED_SYMLINK TC_IOCTL (17)
|
||||||
#define TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS TC_IOCTL (18)
|
#define TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS TC_IOCTL (18)
|
||||||
#define TC_IOCTL_BOOT_ENCRYPTION_SETUP TC_IOCTL (19)
|
#define TC_IOCTL_BOOT_ENCRYPTION_SETUP TC_IOCTL (19)
|
||||||
#define TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP TC_IOCTL (20)
|
#define TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP TC_IOCTL (20)
|
||||||
#define TC_IOCTL_GET_BOOT_ENCRYPTION_SETUP_RESULT TC_IOCTL (21)
|
#define TC_IOCTL_GET_BOOT_ENCRYPTION_SETUP_RESULT TC_IOCTL (21)
|
||||||
#define TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES TC_IOCTL (22)
|
#define TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES TC_IOCTL (22)
|
||||||
#define TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER TC_IOCTL (23)
|
#define TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER TC_IOCTL (23)
|
||||||
#define TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME TC_IOCTL (24)
|
#define TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME TC_IOCTL (24)
|
||||||
#define TC_IOCTL_GET_PORTABLE_MODE_STATUS TC_IOCTL (25)
|
#define TC_IOCTL_GET_PORTABLE_MODE_STATUS TC_IOCTL (25)
|
||||||
#define TC_IOCTL_SET_PORTABLE_MODE_STATUS TC_IOCTL (26)
|
#define TC_IOCTL_SET_PORTABLE_MODE_STATUS TC_IOCTL (26)
|
||||||
#define TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING TC_IOCTL (27)
|
#define TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING TC_IOCTL (27)
|
||||||
#define TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG TC_IOCTL (28)
|
#define TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG TC_IOCTL (28)
|
||||||
#define TC_IOCTL_DISK_IS_WRITABLE TC_IOCTL (29)
|
#define TC_IOCTL_DISK_IS_WRITABLE TC_IOCTL (29)
|
||||||
#define TC_IOCTL_START_DECOY_SYSTEM_WIPE TC_IOCTL (30)
|
#define TC_IOCTL_START_DECOY_SYSTEM_WIPE TC_IOCTL (30)
|
||||||
#define TC_IOCTL_ABORT_DECOY_SYSTEM_WIPE TC_IOCTL (31)
|
#define TC_IOCTL_ABORT_DECOY_SYSTEM_WIPE TC_IOCTL (31)
|
||||||
#define TC_IOCTL_GET_DECOY_SYSTEM_WIPE_STATUS TC_IOCTL (32)
|
#define TC_IOCTL_GET_DECOY_SYSTEM_WIPE_STATUS TC_IOCTL (32)
|
||||||
#define TC_IOCTL_GET_DECOY_SYSTEM_WIPE_RESULT TC_IOCTL (33)
|
#define TC_IOCTL_GET_DECOY_SYSTEM_WIPE_RESULT TC_IOCTL (33)
|
||||||
#define TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR TC_IOCTL (34)
|
#define TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR TC_IOCTL (34)
|
||||||
#define TC_IOCTL_GET_WARNING_FLAGS TC_IOCTL (35)
|
#define TC_IOCTL_GET_WARNING_FLAGS TC_IOCTL (35)
|
||||||
#define TC_IOCTL_SET_SYSTEM_FAVORITE_VOLUME_DIRTY TC_IOCTL (36)
|
#define TC_IOCTL_SET_SYSTEM_FAVORITE_VOLUME_DIRTY TC_IOCTL (36)
|
||||||
#define TC_IOCTL_REREAD_DRIVER_CONFIG TC_IOCTL (37)
|
#define TC_IOCTL_REREAD_DRIVER_CONFIG TC_IOCTL (37)
|
||||||
#define TC_IOCTL_GET_SYSTEM_DRIVE_DUMP_CONFIG TC_IOCTL (38)
|
#define TC_IOCTL_GET_SYSTEM_DRIVE_DUMP_CONFIG TC_IOCTL (38)
|
||||||
#define VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT TC_IOCTL (39)
|
#define VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT TC_IOCTL (39)
|
||||||
|
|
||||||
// Legacy IOCTLs used before version 5.0
|
// Legacy IOCTLs used before version 5.0
|
||||||
#define TC_IOCTL_LEGACY_GET_DRIVER_VERSION 466968
|
#define TC_IOCTL_LEGACY_GET_DRIVER_VERSION 466968
|
||||||
#define TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES 466948
|
#define TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES 466948
|
||||||
|
|
||||||
|
|
||||||
/* Start of driver interface structures, the size of these structures may
|
/* Start of driver interface structures, the size of these structures may
|
||||||
change between versions; so make sure you first send DRIVER_VERSION to
|
change between versions; so make sure you first send DRIVER_VERSION to
|
||||||
check that it's the correct device driver */
|
check that it's the correct device driver */
|
||||||
|
|
||||||
#pragma pack (push)
|
#pragma pack (push)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nReturnCode; /* Return code back from driver */
|
int nReturnCode; /* Return code back from driver */
|
||||||
BOOL FilesystemDirty;
|
BOOL FilesystemDirty;
|
||||||
BOOL VolumeMountedReadOnlyAfterAccessDenied;
|
BOOL VolumeMountedReadOnlyAfterAccessDenied;
|
||||||
BOOL VolumeMountedReadOnlyAfterDeviceWriteProtected;
|
BOOL VolumeMountedReadOnlyAfterDeviceWriteProtected;
|
||||||
|
|
||||||
wchar_t wszVolume[TC_MAX_PATH]; /* Volume to be mounted */
|
wchar_t wszVolume[TC_MAX_PATH]; /* Volume to be mounted */
|
||||||
Password VolumePassword; /* User password */
|
Password VolumePassword; /* User password */
|
||||||
BOOL bCache; /* Cache passwords in driver */
|
BOOL bCache; /* Cache passwords in driver */
|
||||||
int nDosDriveNo; /* Drive number to mount */
|
int nDosDriveNo; /* Drive number to mount */
|
||||||
uint32 BytesPerSector;
|
uint32 BytesPerSector;
|
||||||
BOOL bMountReadOnly; /* Mount volume in read-only mode */
|
BOOL bMountReadOnly; /* Mount volume in read-only mode */
|
||||||
BOOL bMountRemovable; /* Mount volume as removable media */
|
BOOL bMountRemovable; /* Mount volume as removable media */
|
||||||
BOOL bExclusiveAccess; /* Open host file/device in exclusive access mode */
|
BOOL bExclusiveAccess; /* Open host file/device in exclusive access mode */
|
||||||
BOOL bMountManager; /* Announce volume to mount manager */
|
BOOL bMountManager; /* Announce volume to mount manager */
|
||||||
BOOL bPreserveTimestamp; /* Preserve file container timestamp */
|
BOOL bPreserveTimestamp; /* Preserve file container timestamp */
|
||||||
BOOL bPartitionInInactiveSysEncScope; /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
|
BOOL bPartitionInInactiveSysEncScope; /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
|
||||||
int nPartitionInInactiveSysEncScopeDriveNo; /* If bPartitionInInactiveSysEncScope is TRUE, this contains the drive number of the system drive on which the partition is located. */
|
int nPartitionInInactiveSysEncScopeDriveNo; /* If bPartitionInInactiveSysEncScope is TRUE, this contains the drive number of the system drive on which the partition is located. */
|
||||||
BOOL SystemFavorite;
|
BOOL SystemFavorite;
|
||||||
// Hidden volume protection
|
// Hidden volume protection
|
||||||
BOOL bProtectHiddenVolume; /* TRUE if the user wants the hidden volume within this volume to be protected against being overwritten (damaged) */
|
BOOL bProtectHiddenVolume; /* TRUE if the user wants the hidden volume within this volume to be protected against being overwritten (damaged) */
|
||||||
Password ProtectedHidVolPassword; /* Password to the hidden volume to be protected against overwriting */
|
Password ProtectedHidVolPassword; /* Password to the hidden volume to be protected against overwriting */
|
||||||
BOOL UseBackupHeader;
|
BOOL UseBackupHeader;
|
||||||
BOOL RecoveryMode;
|
BOOL RecoveryMode;
|
||||||
int pkcs5_prf;
|
int pkcs5_prf;
|
||||||
int ProtectedHidVolPkcs5Prf;
|
int ProtectedHidVolPkcs5Prf;
|
||||||
BOOL bTrueCryptMode;
|
BOOL bTrueCryptMode;
|
||||||
uint32 BytesPerPhysicalSector;
|
uint32 BytesPerPhysicalSector;
|
||||||
int VolumePim;
|
int VolumePim;
|
||||||
int ProtectedHidVolPim;
|
int ProtectedHidVolPim;
|
||||||
wchar_t wszLabel[33]; // maximum label length is 32 for NTFS and 11 for FAT32
|
wchar_t wszLabel[33]; // maximum label length is 32 for NTFS and 11 for FAT32
|
||||||
BOOL bIsNTFS; // output only
|
BOOL bIsNTFS; // output only
|
||||||
BOOL bDriverSetLabel;
|
BOOL bDriverSetLabel;
|
||||||
BOOL bCachePim;
|
BOOL bCachePim;
|
||||||
} MOUNT_STRUCT;
|
} MOUNT_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nDosDriveNo; /* Drive letter to unmount */
|
int nDosDriveNo; /* Drive letter to unmount */
|
||||||
BOOL ignoreOpenFiles;
|
BOOL ignoreOpenFiles;
|
||||||
BOOL HiddenVolumeProtectionTriggered;
|
BOOL HiddenVolumeProtectionTriggered;
|
||||||
int nReturnCode; /* Return code back from driver */
|
int nReturnCode; /* Return code back from driver */
|
||||||
} UNMOUNT_STRUCT;
|
} UNMOUNT_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */
|
unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */
|
||||||
wchar_t wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */
|
wchar_t wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */
|
||||||
wchar_t wszLabel[26][33]; /* Labels of mounted volumes */
|
wchar_t wszLabel[26][33]; /* Labels of mounted volumes */
|
||||||
wchar_t volumeID[26][VOLUME_ID_SIZE]; /* IDs of mounted volumes */
|
wchar_t volumeID[26][VOLUME_ID_SIZE]; /* IDs of mounted volumes */
|
||||||
unsigned __int64 diskLength[26];
|
unsigned __int64 diskLength[26];
|
||||||
int ea[26];
|
int ea[26];
|
||||||
int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
|
int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
|
||||||
BOOL truecryptMode[26];
|
BOOL truecryptMode[26];
|
||||||
} MOUNT_LIST_STRUCT;
|
} MOUNT_LIST_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int driveNo;
|
int driveNo;
|
||||||
int uniqueId;
|
int uniqueId;
|
||||||
wchar_t wszVolume[TC_MAX_PATH];
|
wchar_t wszVolume[TC_MAX_PATH];
|
||||||
unsigned __int64 diskLength;
|
unsigned __int64 diskLength;
|
||||||
int ea;
|
int ea;
|
||||||
int mode;
|
int mode;
|
||||||
int pkcs5;
|
int pkcs5;
|
||||||
int pkcs5Iterations;
|
int pkcs5Iterations;
|
||||||
BOOL hiddenVolume;
|
BOOL hiddenVolume;
|
||||||
BOOL readOnly;
|
BOOL readOnly;
|
||||||
BOOL removable;
|
BOOL removable;
|
||||||
BOOL partitionInInactiveSysEncScope;
|
BOOL partitionInInactiveSysEncScope;
|
||||||
uint32 volumeHeaderFlags;
|
uint32 volumeHeaderFlags;
|
||||||
unsigned __int64 totalBytesRead;
|
unsigned __int64 totalBytesRead;
|
||||||
unsigned __int64 totalBytesWritten;
|
unsigned __int64 totalBytesWritten;
|
||||||
int hiddenVolProtection; /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */
|
int hiddenVolProtection; /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */
|
||||||
int volFormatVersion;
|
int volFormatVersion;
|
||||||
int volumePim;
|
int volumePim;
|
||||||
wchar_t wszLabel[33];
|
wchar_t wszLabel[33];
|
||||||
BOOL bDriverSetLabel;
|
BOOL bDriverSetLabel;
|
||||||
unsigned char volumeID[VOLUME_ID_SIZE];
|
unsigned char volumeID[VOLUME_ID_SIZE];
|
||||||
} VOLUME_PROPERTIES_STRUCT;
|
} VOLUME_PROPERTIES_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WCHAR symLinkName[TC_MAX_PATH];
|
WCHAR symLinkName[TC_MAX_PATH];
|
||||||
WCHAR targetName[TC_MAX_PATH];
|
WCHAR targetName[TC_MAX_PATH];
|
||||||
} RESOLVE_SYMLINK_STRUCT;
|
} RESOLVE_SYMLINK_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WCHAR deviceName[TC_MAX_PATH];
|
WCHAR deviceName[TC_MAX_PATH];
|
||||||
PARTITION_INFORMATION partInfo;
|
PARTITION_INFORMATION partInfo;
|
||||||
BOOL IsGPT;
|
BOOL IsGPT;
|
||||||
BOOL IsDynamic;
|
BOOL IsDynamic;
|
||||||
}
|
}
|
||||||
DISK_PARTITION_INFO_STRUCT;
|
DISK_PARTITION_INFO_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WCHAR deviceName[TC_MAX_PATH];
|
WCHAR deviceName[TC_MAX_PATH];
|
||||||
DISK_GEOMETRY diskGeometry;
|
DISK_GEOMETRY diskGeometry;
|
||||||
}
|
}
|
||||||
DISK_GEOMETRY_STRUCT;
|
DISK_GEOMETRY_STRUCT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WCHAR DeviceName[TC_MAX_PATH];
|
WCHAR DeviceName[TC_MAX_PATH];
|
||||||
LARGE_INTEGER RealDriveSize;
|
LARGE_INTEGER RealDriveSize;
|
||||||
BOOL TimeOut;
|
BOOL TimeOut;
|
||||||
} ProbeRealDriveSizeRequest;
|
} ProbeRealDriveSizeRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
wchar_t wszFileName[TC_MAX_PATH]; // Volume to be "open tested"
|
wchar_t wszFileName[TC_MAX_PATH]; // Volume to be "open tested"
|
||||||
BOOL bDetectTCBootLoader; // Whether the driver is to determine if the first sector contains a portion of the TrueCrypt Boot Loader
|
BOOL bDetectTCBootLoader; // Whether the driver is to determine if the first sector contains a portion of the TrueCrypt Boot Loader
|
||||||
BOOL TCBootLoaderDetected;
|
BOOL TCBootLoaderDetected;
|
||||||
BOOL DetectFilesystem;
|
BOOL DetectFilesystem;
|
||||||
BOOL FilesystemDetected;
|
BOOL FilesystemDetected;
|
||||||
BOOL bMatchVolumeID;
|
BOOL bMatchVolumeID;
|
||||||
unsigned char volumeID[VOLUME_ID_SIZE];
|
unsigned char volumeID[VOLUME_ID_SIZE];
|
||||||
BOOL VolumeIDMatched;
|
BOOL VolumeIDMatched;
|
||||||
} OPEN_TEST_STRUCT;
|
} OPEN_TEST_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SetupNone = 0,
|
SetupNone = 0,
|
||||||
SetupEncryption,
|
SetupEncryption,
|
||||||
SetupDecryption
|
SetupDecryption
|
||||||
} BootEncryptionSetupMode;
|
} BootEncryptionSetupMode;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// New fields must be added at the end of the structure to maintain compatibility with previous versions
|
// New fields must be added at the end of the structure to maintain compatibility with previous versions
|
||||||
BOOL DeviceFilterActive;
|
BOOL DeviceFilterActive;
|
||||||
|
|
||||||
uint16 BootLoaderVersion;
|
uint16 BootLoaderVersion;
|
||||||
|
|
||||||
BOOL DriveMounted;
|
BOOL DriveMounted;
|
||||||
BOOL VolumeHeaderPresent;
|
BOOL VolumeHeaderPresent;
|
||||||
BOOL DriveEncrypted;
|
BOOL DriveEncrypted;
|
||||||
|
|
||||||
LARGE_INTEGER BootDriveLength;
|
LARGE_INTEGER BootDriveLength;
|
||||||
|
|
||||||
int64 ConfiguredEncryptedAreaStart;
|
int64 ConfiguredEncryptedAreaStart;
|
||||||
int64 ConfiguredEncryptedAreaEnd;
|
int64 ConfiguredEncryptedAreaEnd;
|
||||||
int64 EncryptedAreaStart;
|
int64 EncryptedAreaStart;
|
||||||
int64 EncryptedAreaEnd;
|
int64 EncryptedAreaEnd;
|
||||||
|
|
||||||
uint32 VolumeHeaderSaltCrc32;
|
uint32 VolumeHeaderSaltCrc32;
|
||||||
|
|
||||||
BOOL SetupInProgress;
|
BOOL SetupInProgress;
|
||||||
BootEncryptionSetupMode SetupMode;
|
BootEncryptionSetupMode SetupMode;
|
||||||
BOOL TransformWaitingForIdle;
|
BOOL TransformWaitingForIdle;
|
||||||
|
|
||||||
uint32 HibernationPreventionCount;
|
uint32 HibernationPreventionCount;
|
||||||
|
|
||||||
BOOL HiddenSystem;
|
BOOL HiddenSystem;
|
||||||
int64 HiddenSystemPartitionStart;
|
int64 HiddenSystemPartitionStart;
|
||||||
|
|
||||||
// Number of times the filter driver answered that an unencrypted volume
|
// Number of times the filter driver answered that an unencrypted volume
|
||||||
// is read-only (or mounted an outer/normal TrueCrypt volume as read only)
|
// is read-only (or mounted an outer/normal TrueCrypt volume as read only)
|
||||||
uint32 HiddenSysLeakProtectionCount;
|
uint32 HiddenSysLeakProtectionCount;
|
||||||
|
|
||||||
} BootEncryptionStatus;
|
} BootEncryptionStatus;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BootEncryptionSetupMode SetupMode;
|
BootEncryptionSetupMode SetupMode;
|
||||||
WipeAlgorithmId WipeAlgorithm;
|
WipeAlgorithmId WipeAlgorithm;
|
||||||
BOOL ZeroUnreadableSectors;
|
BOOL ZeroUnreadableSectors;
|
||||||
BOOL DiscardUnreadableEncryptedSectors;
|
BOOL DiscardUnreadableEncryptedSectors;
|
||||||
} BootEncryptionSetupRequest;
|
} BootEncryptionSetupRequest;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Password VolumePassword;
|
Password VolumePassword;
|
||||||
int pkcs5_prf;
|
int pkcs5_prf;
|
||||||
int pim;
|
int pim;
|
||||||
} ReopenBootVolumeHeaderRequest;
|
} ReopenBootVolumeHeaderRequest;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char BootEncryptionAlgorithmName[256];
|
char BootEncryptionAlgorithmName[256];
|
||||||
char BootPrfAlgorithmName[256];
|
char BootPrfAlgorithmName[256];
|
||||||
} GetBootEncryptionAlgorithmNameRequest;
|
} GetBootEncryptionAlgorithmNameRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
byte Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
|
byte Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
|
||||||
} BootLoaderFingerprintRequest;
|
} BootLoaderFingerprintRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
wchar_t DevicePath[TC_MAX_PATH];
|
wchar_t DevicePath[TC_MAX_PATH];
|
||||||
byte Configuration;
|
byte Configuration;
|
||||||
BOOL DriveIsDynamic;
|
BOOL DriveIsDynamic;
|
||||||
uint16 BootLoaderVersion;
|
uint16 BootLoaderVersion;
|
||||||
byte UserConfiguration;
|
byte UserConfiguration;
|
||||||
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
|
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
|
||||||
} GetSystemDriveConfigurationRequest;
|
} GetSystemDriveConfigurationRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WipeAlgorithmId WipeAlgorithm;
|
WipeAlgorithmId WipeAlgorithm;
|
||||||
byte WipeKey[MASTER_KEYDATA_SIZE];
|
byte WipeKey[MASTER_KEYDATA_SIZE];
|
||||||
} WipeDecoySystemRequest;
|
} WipeDecoySystemRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BOOL WipeInProgress;
|
BOOL WipeInProgress;
|
||||||
WipeAlgorithmId WipeAlgorithm;
|
WipeAlgorithmId WipeAlgorithm;
|
||||||
int64 WipedAreaEnd;
|
int64 WipedAreaEnd;
|
||||||
} DecoySystemWipeStatus;
|
} DecoySystemWipeStatus;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
byte Data[TC_SECTOR_SIZE_BIOS];
|
byte Data[TC_SECTOR_SIZE_BIOS];
|
||||||
} WriteBootDriveSectorRequest;
|
} WriteBootDriveSectorRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BOOL PagingFileCreationPrevented;
|
BOOL PagingFileCreationPrevented;
|
||||||
BOOL SystemFavoriteVolumeDirty;
|
BOOL SystemFavoriteVolumeDirty;
|
||||||
} GetWarningFlagsRequest;
|
} GetWarningFlagsRequest;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
struct _DriveFilterExtension *BootDriveFilterExtension;
|
struct _DriveFilterExtension *BootDriveFilterExtension;
|
||||||
BOOL HwEncryptionEnabled;
|
BOOL HwEncryptionEnabled;
|
||||||
} GetSystemDriveDumpConfigRequest;
|
} GetSystemDriveDumpConfigRequest;
|
||||||
|
|
||||||
#pragma pack (pop)
|
#pragma pack (pop)
|
||||||
|
|
||||||
#define DRIVER_STR WIDE
|
#define DRIVER_STR WIDE
|
||||||
|
|
||||||
#define TC_UNIQUE_ID_PREFIX "VeraCryptVolume"
|
#define TC_UNIQUE_ID_PREFIX "VeraCryptVolume"
|
||||||
#define TC_MOUNT_PREFIX L"\\Device\\VeraCryptVolume"
|
#define TC_MOUNT_PREFIX L"\\Device\\VeraCryptVolume"
|
||||||
|
|
||||||
#define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\VeraCryptVolume")
|
#define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\VeraCryptVolume")
|
||||||
#define NT_ROOT_PREFIX DRIVER_STR("\\Device\\VeraCrypt")
|
#define NT_ROOT_PREFIX DRIVER_STR("\\Device\\VeraCrypt")
|
||||||
#define DOS_MOUNT_PREFIX_DEFAULT DRIVER_STR("\\DosDevices\\")
|
#define DOS_MOUNT_PREFIX_DEFAULT DRIVER_STR("\\DosDevices\\")
|
||||||
#define DOS_MOUNT_PREFIX_GLOBAL DRIVER_STR("\\GLOBAL??\\") // Use Global MS-DOS device names for sanity checks on drive letters
|
#define DOS_MOUNT_PREFIX_GLOBAL DRIVER_STR("\\GLOBAL??\\") // Use Global MS-DOS device names for sanity checks on drive letters
|
||||||
#define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\VeraCrypt")
|
#define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\VeraCrypt")
|
||||||
#define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\VeraCrypt")
|
#define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\VeraCrypt")
|
||||||
|
|
||||||
#define TC_DRIVER_CONFIG_REG_VALUE_NAME DRIVER_STR("VeraCryptConfig")
|
#define TC_DRIVER_CONFIG_REG_VALUE_NAME DRIVER_STR("VeraCryptConfig")
|
||||||
#define TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME DRIVER_STR("VeraCryptEncryptionFreeCpuCount")
|
#define TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME DRIVER_STR("VeraCryptEncryptionFreeCpuCount")
|
||||||
|
|
||||||
// WARNING: Modifying the following values can introduce incompatibility with previous versions.
|
// WARNING: Modifying the following values can introduce incompatibility with previous versions.
|
||||||
#define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD 0x1
|
#define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD 0x1
|
||||||
#define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES 0x2
|
#define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES 0x2
|
||||||
#define TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS 0x4
|
#define TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS 0x4
|
||||||
#define TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION 0x8
|
#define TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION 0x8
|
||||||
#define TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL 0x10
|
#define TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL 0x10
|
||||||
#define TC_DRIVER_CONFIG_DISABLE_EVIL_MAID_ATTACK_DETECTION 0x20
|
#define TC_DRIVER_CONFIG_DISABLE_EVIL_MAID_ATTACK_DETECTION 0x20
|
||||||
#define TC_DRIVER_CONFIG_CACHE_BOOT_PIM 0x40
|
#define TC_DRIVER_CONFIG_CACHE_BOOT_PIM 0x40
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|||||||
+246
-246
@@ -1,246 +1,246 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <atlcomcli.h>
|
#include <atlcomcli.h>
|
||||||
#include <atlconv.h>
|
#include <atlconv.h>
|
||||||
#include <comutil.h>
|
#include <comutil.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "BaseCom.h"
|
#include "BaseCom.h"
|
||||||
#include "BootEncryption.h"
|
#include "BootEncryption.h"
|
||||||
#include "Dlgcode.h"
|
#include "Dlgcode.h"
|
||||||
#include "Registry.h"
|
#include "Registry.h"
|
||||||
|
|
||||||
using namespace VeraCrypt;
|
using namespace VeraCrypt;
|
||||||
|
|
||||||
HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv)
|
HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv)
|
||||||
{
|
{
|
||||||
WCHAR monikerName[1024];
|
WCHAR monikerName[1024];
|
||||||
WCHAR clsid[1024];
|
WCHAR clsid[1024];
|
||||||
BIND_OPTS3 bo;
|
BIND_OPTS3 bo;
|
||||||
|
|
||||||
StringFromGUID2 (guid, clsid, sizeof (clsid) / 2);
|
StringFromGUID2 (guid, clsid, sizeof (clsid) / 2);
|
||||||
swprintf_s (monikerName, sizeof (monikerName) / 2, L"Elevation:Administrator!new:%s", clsid);
|
swprintf_s (monikerName, sizeof (monikerName) / 2, L"Elevation:Administrator!new:%s", clsid);
|
||||||
|
|
||||||
memset (&bo, 0, sizeof (bo));
|
memset (&bo, 0, sizeof (bo));
|
||||||
bo.cbStruct = sizeof (bo);
|
bo.cbStruct = sizeof (bo);
|
||||||
bo.hwnd = hwnd;
|
bo.hwnd = hwnd;
|
||||||
bo.dwClassContext = CLSCTX_LOCAL_SERVER;
|
bo.dwClassContext = CLSCTX_LOCAL_SERVER;
|
||||||
|
|
||||||
// Prevent the GUI from being half-rendered when the UAC prompt "freezes" it
|
// Prevent the GUI from being half-rendered when the UAC prompt "freezes" it
|
||||||
ProcessPaintMessages (hwnd, 5000);
|
ProcessPaintMessages (hwnd, 5000);
|
||||||
|
|
||||||
return CoGetObject (monikerName, &bo, iid, ppv);
|
return CoGetObject (monikerName, &bo, iid, ppv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer)
|
BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer)
|
||||||
{
|
{
|
||||||
BOOL r;
|
BOOL r;
|
||||||
|
|
||||||
if (IsUacSupported ())
|
if (IsUacSupported ())
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
r = CreateElevatedComObject (hWnd, clsid, iid, tcServer) == S_OK;
|
r = CreateElevatedComObject (hWnd, clsid, iid, tcServer) == S_OK;
|
||||||
if (r)
|
if (r)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IDRETRY == ErrorRetryCancel ("UAC_INIT_ERROR", hWnd))
|
if (IDRETRY == ErrorRetryCancel ("UAC_INIT_ERROR", hWnd))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK;
|
r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK;
|
||||||
if (!r)
|
if (!r)
|
||||||
Error ("UAC_INIT_ERROR", hWnd);
|
Error ("UAC_INIT_ERROR", hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::CallDriver (DWORD ioctl, BSTR input, BSTR *output)
|
DWORD BaseCom::CallDriver (DWORD ioctl, BSTR input, BSTR *output)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BootEncryption bootEnc (NULL);
|
BootEncryption bootEnc (NULL);
|
||||||
bootEnc.CallDriver (ioctl,
|
bootEnc.CallDriver (ioctl,
|
||||||
(BYTE *) input, !(BYTE *) input ? 0 : ((DWORD *) ((BYTE *) input))[-1],
|
(BYTE *) input, !(BYTE *) input ? 0 : ((DWORD *) ((BYTE *) input))[-1],
|
||||||
(BYTE *) *output, !(BYTE *) *output ? 0 : ((DWORD *) ((BYTE *) *output))[-1]);
|
(BYTE *) *output, !(BYTE *) *output ? 0 : ((DWORD *) ((BYTE *) *output))[-1]);
|
||||||
}
|
}
|
||||||
catch (SystemException &)
|
catch (SystemException &)
|
||||||
{
|
{
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
}
|
}
|
||||||
catch (Exception &e)
|
catch (Exception &e)
|
||||||
{
|
{
|
||||||
e.Show (NULL);
|
e.Show (NULL);
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::CopyFile (BSTR sourceFile, BSTR destinationFile)
|
DWORD BaseCom::CopyFile (BSTR sourceFile, BSTR destinationFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!::CopyFileW (sourceFile, destinationFile, FALSE))
|
if (!::CopyFileW (sourceFile, destinationFile, FALSE))
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::DeleteFile (BSTR file)
|
DWORD BaseCom::DeleteFile (BSTR file)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!::DeleteFileW (file))
|
if (!::DeleteFileW (file))
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL BaseCom::IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
|
BOOL BaseCom::IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
|
||||||
{
|
{
|
||||||
return ::IsPagingFileActive (checkNonWindowsPartitionsOnly);
|
return ::IsPagingFileActive (checkNonWindowsPartitionsOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone)
|
DWORD BaseCom::ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto_ptr <File> file (device ? new Device (filePath, !write) : new File (filePath, !write));
|
auto_ptr <File> file (device ? new Device (filePath, !write) : new File (filePath, !write));
|
||||||
file->CheckOpened (SRC_POS);
|
file->CheckOpened (SRC_POS);
|
||||||
file->SeekAt (offset);
|
file->SeekAt (offset);
|
||||||
|
|
||||||
if (write)
|
if (write)
|
||||||
{
|
{
|
||||||
file->Write ((BYTE *) *bufferBstr, size);
|
file->Write ((BYTE *) *bufferBstr, size);
|
||||||
*sizeDone = size;
|
*sizeDone = size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*sizeDone = file->Read ((BYTE *) *bufferBstr, size);
|
*sizeDone = file->Read ((BYTE *) *bufferBstr, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SystemException &)
|
catch (SystemException &)
|
||||||
{
|
{
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
}
|
}
|
||||||
catch (Exception &e)
|
catch (Exception &e)
|
||||||
{
|
{
|
||||||
e.Show (NULL);
|
e.Show (NULL);
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::RegisterFilterDriver (BOOL registerDriver, int filterType)
|
DWORD BaseCom::RegisterFilterDriver (BOOL registerDriver, int filterType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BootEncryption bootEnc (NULL);
|
BootEncryption bootEnc (NULL);
|
||||||
bootEnc.RegisterFilterDriver (registerDriver ? true : false, (BootEncryption::FilterType) filterType);
|
bootEnc.RegisterFilterDriver (registerDriver ? true : false, (BootEncryption::FilterType) filterType);
|
||||||
}
|
}
|
||||||
catch (SystemException &)
|
catch (SystemException &)
|
||||||
{
|
{
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
}
|
}
|
||||||
catch (Exception &e)
|
catch (Exception &e)
|
||||||
{
|
{
|
||||||
e.Show (NULL);
|
e.Show (NULL);
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::RegisterSystemFavoritesService (BOOL registerService)
|
DWORD BaseCom::RegisterSystemFavoritesService (BOOL registerService)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BootEncryption bootEnc (NULL);
|
BootEncryption bootEnc (NULL);
|
||||||
bootEnc.RegisterSystemFavoritesService (registerService);
|
bootEnc.RegisterSystemFavoritesService (registerService);
|
||||||
}
|
}
|
||||||
catch (SystemException &)
|
catch (SystemException &)
|
||||||
{
|
{
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
}
|
}
|
||||||
catch (Exception &e)
|
catch (Exception &e)
|
||||||
{
|
{
|
||||||
e.Show (NULL);
|
e.Show (NULL);
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::SetDriverServiceStartType (DWORD startType)
|
DWORD BaseCom::SetDriverServiceStartType (DWORD startType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BootEncryption bootEnc (NULL);
|
BootEncryption bootEnc (NULL);
|
||||||
bootEnc.SetDriverServiceStartType (startType);
|
bootEnc.SetDriverServiceStartType (startType);
|
||||||
}
|
}
|
||||||
catch (SystemException &)
|
catch (SystemException &)
|
||||||
{
|
{
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
}
|
}
|
||||||
catch (Exception &e)
|
catch (Exception &e)
|
||||||
{
|
{
|
||||||
e.Show (NULL);
|
e.Show (NULL);
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
return ERROR_EXCEPTION_IN_SERVICE;
|
return ERROR_EXCEPTION_IN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD BaseCom::WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value)
|
DWORD BaseCom::WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value)
|
||||||
{
|
{
|
||||||
if (!::WriteLocalMachineRegistryDword (keyPath, valueName, value))
|
if (!::WriteLocalMachineRegistryDword (keyPath, valueName, value))
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+119
-119
@@ -1,119 +1,119 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_BASE_COM
|
#ifndef TC_HEADER_BASE_COM
|
||||||
#define TC_HEADER_BASE_COM
|
#define TC_HEADER_BASE_COM
|
||||||
|
|
||||||
#include <guiddef.h>
|
#include <guiddef.h>
|
||||||
|
|
||||||
template <class TClass>
|
template <class TClass>
|
||||||
class TrueCryptFactory : public IClassFactory
|
class TrueCryptFactory : public IClassFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrueCryptFactory (DWORD messageThreadId) :
|
TrueCryptFactory (DWORD messageThreadId) :
|
||||||
RefCount (1), ServerLockCount (0), MessageThreadId (messageThreadId) { }
|
RefCount (1), ServerLockCount (0), MessageThreadId (messageThreadId) { }
|
||||||
|
|
||||||
~TrueCryptFactory () { }
|
~TrueCryptFactory () { }
|
||||||
|
|
||||||
virtual ULONG STDMETHODCALLTYPE AddRef ()
|
virtual ULONG STDMETHODCALLTYPE AddRef ()
|
||||||
{
|
{
|
||||||
return InterlockedIncrement (&RefCount) - 1;
|
return InterlockedIncrement (&RefCount) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ULONG STDMETHODCALLTYPE Release ()
|
virtual ULONG STDMETHODCALLTYPE Release ()
|
||||||
{
|
{
|
||||||
ULONG r = InterlockedDecrement (&RefCount) + 1;
|
ULONG r = InterlockedDecrement (&RefCount) + 1;
|
||||||
|
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
delete this;
|
delete this;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppvObject)
|
virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppvObject)
|
||||||
{
|
{
|
||||||
if (riid == IID_IUnknown || riid == IID_IClassFactory)
|
if (riid == IID_IUnknown || riid == IID_IClassFactory)
|
||||||
*ppvObject = this;
|
*ppvObject = this;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*ppvObject = NULL;
|
*ppvObject = NULL;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddRef ();
|
AddRef ();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE CreateInstance (IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
|
virtual HRESULT STDMETHODCALLTYPE CreateInstance (IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
|
||||||
{
|
{
|
||||||
if (pUnkOuter != NULL)
|
if (pUnkOuter != NULL)
|
||||||
return CLASS_E_NOAGGREGATION;
|
return CLASS_E_NOAGGREGATION;
|
||||||
|
|
||||||
TClass *tc = new TClass (MessageThreadId);
|
TClass *tc = new TClass (MessageThreadId);
|
||||||
if (tc == NULL)
|
if (tc == NULL)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
HRESULT hr = tc->QueryInterface (riid, ppvObject);
|
HRESULT hr = tc->QueryInterface (riid, ppvObject);
|
||||||
|
|
||||||
if (hr)
|
if (hr)
|
||||||
delete tc;
|
delete tc;
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE LockServer (BOOL fLock)
|
virtual HRESULT STDMETHODCALLTYPE LockServer (BOOL fLock)
|
||||||
{
|
{
|
||||||
if (fLock)
|
if (fLock)
|
||||||
{
|
{
|
||||||
InterlockedIncrement (&ServerLockCount);
|
InterlockedIncrement (&ServerLockCount);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!InterlockedDecrement (&ServerLockCount))
|
if (!InterlockedDecrement (&ServerLockCount))
|
||||||
PostThreadMessage (MessageThreadId, WM_APP, 0, 0);
|
PostThreadMessage (MessageThreadId, WM_APP, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsServerLocked ()
|
virtual bool IsServerLocked ()
|
||||||
{
|
{
|
||||||
return ServerLockCount > 0;
|
return ServerLockCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DWORD MessageThreadId;
|
DWORD MessageThreadId;
|
||||||
LONG RefCount;
|
LONG RefCount;
|
||||||
LONG ServerLockCount;
|
LONG ServerLockCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BaseCom
|
class BaseCom
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output);
|
static DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output);
|
||||||
static DWORD CopyFile (BSTR sourceFile, BSTR destinationFile);
|
static DWORD CopyFile (BSTR sourceFile, BSTR destinationFile);
|
||||||
static DWORD DeleteFile (BSTR file);
|
static DWORD DeleteFile (BSTR file);
|
||||||
static BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
|
static BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
|
||||||
static DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone);
|
static DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone);
|
||||||
static DWORD RegisterFilterDriver (BOOL registerDriver, int filterType);
|
static DWORD RegisterFilterDriver (BOOL registerDriver, int filterType);
|
||||||
static DWORD RegisterSystemFavoritesService (BOOL registerService);
|
static DWORD RegisterSystemFavoritesService (BOOL registerService);
|
||||||
static DWORD SetDriverServiceStartType (DWORD startType);
|
static DWORD SetDriverServiceStartType (DWORD startType);
|
||||||
static DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value);
|
static DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer);
|
BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer);
|
||||||
HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv);
|
HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv);
|
||||||
|
|
||||||
#endif // TC_HEADER_BASE_COM
|
#endif // TC_HEADER_BASE_COM
|
||||||
|
|||||||
+2813
-2813
File diff suppressed because it is too large
Load Diff
+255
-255
@@ -1,255 +1,255 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Common_BootEncryption
|
#ifndef TC_HEADER_Common_BootEncryption
|
||||||
#define TC_HEADER_Common_BootEncryption
|
#define TC_HEADER_Common_BootEncryption
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Dlgcode.h"
|
#include "Dlgcode.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Platform/PlatformBase.h"
|
#include "Platform/PlatformBase.h"
|
||||||
#include "Volumes.h"
|
#include "Volumes.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace VeraCrypt
|
namespace VeraCrypt
|
||||||
{
|
{
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
File () : Elevated (false), FileOpen (false), FilePointerPosition(0), Handle(INVALID_HANDLE_VALUE), IsDevice(false), LastError(0) { }
|
File () : Elevated (false), FileOpen (false), FilePointerPosition(0), Handle(INVALID_HANDLE_VALUE), IsDevice(false), LastError(0) { }
|
||||||
File (wstring path,bool readOnly = false, bool create = false);
|
File (wstring path,bool readOnly = false, bool create = false);
|
||||||
virtual ~File () { Close(); }
|
virtual ~File () { Close(); }
|
||||||
|
|
||||||
void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
|
void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
|
||||||
void Close ();
|
void Close ();
|
||||||
DWORD Read (byte *buffer, DWORD size);
|
DWORD Read (byte *buffer, DWORD size);
|
||||||
void Write (byte *buffer, DWORD size);
|
void Write (byte *buffer, DWORD size);
|
||||||
void SeekAt (int64 position);
|
void SeekAt (int64 position);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Elevated;
|
bool Elevated;
|
||||||
bool FileOpen;
|
bool FileOpen;
|
||||||
uint64 FilePointerPosition;
|
uint64 FilePointerPosition;
|
||||||
HANDLE Handle;
|
HANDLE Handle;
|
||||||
bool IsDevice;
|
bool IsDevice;
|
||||||
wstring Path;
|
wstring Path;
|
||||||
DWORD LastError;
|
DWORD LastError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Device : public File
|
class Device : public File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Device (wstring path,bool readOnly = false);
|
Device (wstring path,bool readOnly = false);
|
||||||
virtual ~Device () {}
|
virtual ~Device () {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Buffer
|
class Buffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Buffer (size_t size) : DataSize (size)
|
Buffer (size_t size) : DataSize (size)
|
||||||
{
|
{
|
||||||
DataPtr = new byte[size];
|
DataPtr = new byte[size];
|
||||||
if (!DataPtr)
|
if (!DataPtr)
|
||||||
throw bad_alloc();
|
throw bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
~Buffer () { delete[] DataPtr; }
|
~Buffer () { delete[] DataPtr; }
|
||||||
byte *Ptr () const { return DataPtr; }
|
byte *Ptr () const { return DataPtr; }
|
||||||
size_t Size () const { return DataSize; }
|
size_t Size () const { return DataSize; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
byte *DataPtr;
|
byte *DataPtr;
|
||||||
size_t DataSize;
|
size_t DataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Partition
|
struct Partition
|
||||||
{
|
{
|
||||||
wstring DevicePath;
|
wstring DevicePath;
|
||||||
PARTITION_INFORMATION Info;
|
PARTITION_INFORMATION Info;
|
||||||
wstring MountPoint;
|
wstring MountPoint;
|
||||||
size_t Number;
|
size_t Number;
|
||||||
BOOL IsGPT;
|
BOOL IsGPT;
|
||||||
wstring VolumeNameId;
|
wstring VolumeNameId;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef list <Partition> PartitionList;
|
typedef list <Partition> PartitionList;
|
||||||
|
|
||||||
#pragma pack (push)
|
#pragma pack (push)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
struct PartitionEntryMBR
|
struct PartitionEntryMBR
|
||||||
{
|
{
|
||||||
byte BootIndicator;
|
byte BootIndicator;
|
||||||
|
|
||||||
byte StartHead;
|
byte StartHead;
|
||||||
byte StartCylSector;
|
byte StartCylSector;
|
||||||
byte StartCylinder;
|
byte StartCylinder;
|
||||||
|
|
||||||
byte Type;
|
byte Type;
|
||||||
|
|
||||||
byte EndHead;
|
byte EndHead;
|
||||||
byte EndSector;
|
byte EndSector;
|
||||||
byte EndCylinder;
|
byte EndCylinder;
|
||||||
|
|
||||||
uint32 StartLBA;
|
uint32 StartLBA;
|
||||||
uint32 SectorCountLBA;
|
uint32 SectorCountLBA;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MBR
|
struct MBR
|
||||||
{
|
{
|
||||||
byte Code[446];
|
byte Code[446];
|
||||||
PartitionEntryMBR Partitions[4];
|
PartitionEntryMBR Partitions[4];
|
||||||
uint16 Signature;
|
uint16 Signature;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack (pop)
|
#pragma pack (pop)
|
||||||
|
|
||||||
struct SystemDriveConfiguration
|
struct SystemDriveConfiguration
|
||||||
{
|
{
|
||||||
wstring DeviceKernelPath;
|
wstring DeviceKernelPath;
|
||||||
wstring DevicePath;
|
wstring DevicePath;
|
||||||
int DriveNumber;
|
int DriveNumber;
|
||||||
Partition DrivePartition;
|
Partition DrivePartition;
|
||||||
bool ExtraBootPartitionPresent;
|
bool ExtraBootPartitionPresent;
|
||||||
int64 InitialUnallocatedSpace;
|
int64 InitialUnallocatedSpace;
|
||||||
PartitionList Partitions;
|
PartitionList Partitions;
|
||||||
Partition SystemPartition;
|
Partition SystemPartition;
|
||||||
int64 TotalUnallocatedSpace;
|
int64 TotalUnallocatedSpace;
|
||||||
bool SystemLoaderPresent;
|
bool SystemLoaderPresent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BootEncryption
|
class BootEncryption
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BootEncryption (HWND parent);
|
BootEncryption (HWND parent);
|
||||||
~BootEncryption ();
|
~BootEncryption ();
|
||||||
|
|
||||||
enum FilterType
|
enum FilterType
|
||||||
{
|
{
|
||||||
DriveFilter,
|
DriveFilter,
|
||||||
VolumeFilter,
|
VolumeFilter,
|
||||||
DumpFilter
|
DumpFilter
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetParentWindow (HWND parent) { ParentWindow = parent; }
|
void SetParentWindow (HWND parent) { ParentWindow = parent; }
|
||||||
void AbortDecoyOSWipe ();
|
void AbortDecoyOSWipe ();
|
||||||
void AbortSetup ();
|
void AbortSetup ();
|
||||||
void AbortSetupWait ();
|
void AbortSetupWait ();
|
||||||
void CallDriver (DWORD ioctl, void *input = nullptr, DWORD inputSize = 0, void *output = nullptr, DWORD outputSize = 0);
|
void CallDriver (DWORD ioctl, void *input = nullptr, DWORD inputSize = 0, void *output = nullptr, DWORD outputSize = 0);
|
||||||
int ChangePassword (Password *oldPassword, int old_pkcs5, int old_pim, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
|
int ChangePassword (Password *oldPassword, int old_pkcs5, int old_pim, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
|
||||||
void CheckDecoyOSWipeResult ();
|
void CheckDecoyOSWipeResult ();
|
||||||
void CheckEncryptionSetupResult ();
|
void CheckEncryptionSetupResult ();
|
||||||
void CheckRequirements ();
|
void CheckRequirements ();
|
||||||
void CheckRequirementsHiddenOS ();
|
void CheckRequirementsHiddenOS ();
|
||||||
void CopyFileAdmin (const wstring &sourceFile, const wstring &destinationFile);
|
void CopyFileAdmin (const wstring &sourceFile, const wstring &destinationFile);
|
||||||
void CreateRescueIsoImage (bool initialSetup, const wstring &isoImagePath);
|
void CreateRescueIsoImage (bool initialSetup, const wstring &isoImagePath);
|
||||||
void Deinstall (bool displayWaitDialog = false);
|
void Deinstall (bool displayWaitDialog = false);
|
||||||
void DeleteFileAdmin (const wstring &file);
|
void DeleteFileAdmin (const wstring &file);
|
||||||
DecoySystemWipeStatus GetDecoyOSWipeStatus ();
|
DecoySystemWipeStatus GetDecoyOSWipeStatus ();
|
||||||
DWORD GetDriverServiceStartType ();
|
DWORD GetDriverServiceStartType ();
|
||||||
unsigned int GetHiddenOSCreationPhase ();
|
unsigned int GetHiddenOSCreationPhase ();
|
||||||
uint16 GetInstalledBootLoaderVersion ();
|
uint16 GetInstalledBootLoaderVersion ();
|
||||||
void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
|
void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
|
||||||
Partition GetPartitionForHiddenOS ();
|
Partition GetPartitionForHiddenOS ();
|
||||||
bool IsBootLoaderOnDrive (wchar_t *devicePath);
|
bool IsBootLoaderOnDrive (wchar_t *devicePath);
|
||||||
BootEncryptionStatus GetStatus ();
|
BootEncryptionStatus GetStatus ();
|
||||||
void GetVolumeProperties (VOLUME_PROPERTIES_STRUCT *properties);
|
void GetVolumeProperties (VOLUME_PROPERTIES_STRUCT *properties);
|
||||||
SystemDriveConfiguration GetSystemDriveConfiguration ();
|
SystemDriveConfiguration GetSystemDriveConfiguration ();
|
||||||
void Install (bool hiddenSystem);
|
void Install (bool hiddenSystem);
|
||||||
void InstallBootLoader (Device& device, bool preserveUserConfig = false, bool hiddenOSCreation = false, int pim = -1);
|
void InstallBootLoader (Device& device, bool preserveUserConfig = false, bool hiddenOSCreation = false, int pim = -1);
|
||||||
void InstallBootLoader (bool preserveUserConfig = false, bool hiddenOSCreation = false);
|
void InstallBootLoader (bool preserveUserConfig = false, bool hiddenOSCreation = false);
|
||||||
bool CheckBootloaderFingerprint (bool bSilent = false);
|
bool CheckBootloaderFingerprint (bool bSilent = false);
|
||||||
void InvalidateCachedSysDriveProperties ();
|
void InvalidateCachedSysDriveProperties ();
|
||||||
bool IsCDRecorderPresent ();
|
bool IsCDRecorderPresent ();
|
||||||
bool IsHiddenSystemRunning ();
|
bool IsHiddenSystemRunning ();
|
||||||
bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
|
bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
|
||||||
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5);
|
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5);
|
||||||
void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath);
|
void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath);
|
||||||
void ProbeRealSystemDriveSize ();
|
void ProbeRealSystemDriveSize ();
|
||||||
void ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
|
void ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
|
||||||
uint32 ReadDriverConfigurationFlags ();
|
uint32 ReadDriverConfigurationFlags ();
|
||||||
void RegisterBootDriver (bool hiddenSystem);
|
void RegisterBootDriver (bool hiddenSystem);
|
||||||
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
|
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
|
||||||
void RegisterSystemFavoritesService (BOOL registerService);
|
void RegisterSystemFavoritesService (BOOL registerService);
|
||||||
void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling);
|
void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling);
|
||||||
void UpdateSystemFavoritesService ();
|
void UpdateSystemFavoritesService ();
|
||||||
void RenameDeprecatedSystemLoaderBackup ();
|
void RenameDeprecatedSystemLoaderBackup ();
|
||||||
bool RestartComputer (void);
|
bool RestartComputer (void);
|
||||||
void InitialSecurityChecksForHiddenOS ();
|
void InitialSecurityChecksForHiddenOS ();
|
||||||
void RestrictPagingFilesToSystemPartition ();
|
void RestrictPagingFilesToSystemPartition ();
|
||||||
void SetDriverConfigurationFlag (uint32 flag, bool state);
|
void SetDriverConfigurationFlag (uint32 flag, bool state);
|
||||||
void SetDriverServiceStartType (DWORD startType);
|
void SetDriverServiceStartType (DWORD startType);
|
||||||
void SetHiddenOSCreationPhase (unsigned int newPhase);
|
void SetHiddenOSCreationPhase (unsigned int newPhase);
|
||||||
void StartDecryption (BOOL discardUnreadableEncryptedSectors);
|
void StartDecryption (BOOL discardUnreadableEncryptedSectors);
|
||||||
void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm);
|
void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm);
|
||||||
void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors);
|
void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors);
|
||||||
bool SystemDriveContainsPartitionType (byte type);
|
bool SystemDriveContainsPartitionType (byte type);
|
||||||
bool SystemDriveContainsExtendedPartition ();
|
bool SystemDriveContainsExtendedPartition ();
|
||||||
bool SystemDriveContainsNonStandardPartitions ();
|
bool SystemDriveContainsNonStandardPartitions ();
|
||||||
bool SystemPartitionCoversWholeDrive ();
|
bool SystemPartitionCoversWholeDrive ();
|
||||||
bool SystemDriveIsDynamic ();
|
bool SystemDriveIsDynamic ();
|
||||||
bool VerifyRescueDisk ();
|
bool VerifyRescueDisk ();
|
||||||
bool VerifyRescueDiskIsoImage (const wchar_t* imageFile);
|
bool VerifyRescueDiskIsoImage (const wchar_t* imageFile);
|
||||||
void WipeHiddenOSCreationConfig ();
|
void WipeHiddenOSCreationConfig ();
|
||||||
void WriteBootDriveSector (uint64 offset, byte *data);
|
void WriteBootDriveSector (uint64 offset, byte *data);
|
||||||
void WriteBootSectorConfig (const byte newConfig[]);
|
void WriteBootSectorConfig (const byte newConfig[]);
|
||||||
void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim);
|
void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim);
|
||||||
void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value);
|
void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
|
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
|
||||||
|
|
||||||
void BackupSystemLoader ();
|
void BackupSystemLoader ();
|
||||||
void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
|
void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
|
||||||
void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim);
|
void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim);
|
||||||
wstring GetSystemLoaderBackupPath ();
|
wstring GetSystemLoaderBackupPath ();
|
||||||
uint32 GetChecksum (byte *data, size_t size);
|
uint32 GetChecksum (byte *data, size_t size);
|
||||||
DISK_GEOMETRY GetDriveGeometry (int driveNumber);
|
DISK_GEOMETRY GetDriveGeometry (int driveNumber);
|
||||||
PartitionList GetDrivePartitions (int driveNumber);
|
PartitionList GetDrivePartitions (int driveNumber);
|
||||||
wstring GetRemarksOnHiddenOS ();
|
wstring GetRemarksOnHiddenOS ();
|
||||||
wstring GetWindowsDirectory ();
|
wstring GetWindowsDirectory ();
|
||||||
void RegisterFilter (bool registerFilter, FilterType filterType, const GUID *deviceClassGuid = nullptr);
|
void RegisterFilter (bool registerFilter, FilterType filterType, const GUID *deviceClassGuid = nullptr);
|
||||||
void RestoreSystemLoader ();
|
void RestoreSystemLoader ();
|
||||||
void InstallVolumeHeader ();
|
void InstallVolumeHeader ();
|
||||||
|
|
||||||
HWND ParentWindow;
|
HWND ParentWindow;
|
||||||
SystemDriveConfiguration DriveConfig;
|
SystemDriveConfiguration DriveConfig;
|
||||||
int SelectedEncryptionAlgorithmId;
|
int SelectedEncryptionAlgorithmId;
|
||||||
int SelectedPrfAlgorithmId;
|
int SelectedPrfAlgorithmId;
|
||||||
Partition HiddenOSCandidatePartition;
|
Partition HiddenOSCandidatePartition;
|
||||||
byte *RescueIsoImage;
|
byte *RescueIsoImage;
|
||||||
byte RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
|
byte RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
|
||||||
byte VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
|
byte VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
|
||||||
bool DriveConfigValid;
|
bool DriveConfigValid;
|
||||||
bool RealSystemDriveSizeValid;
|
bool RealSystemDriveSizeValid;
|
||||||
bool RescueVolumeHeaderValid;
|
bool RescueVolumeHeaderValid;
|
||||||
bool VolumeHeaderValid;
|
bool VolumeHeaderValid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TC_ABORT_TRANSFORM_WAIT_INTERVAL 10
|
#define TC_ABORT_TRANSFORM_WAIT_INTERVAL 10
|
||||||
|
|
||||||
#define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_NTFS 2.1
|
#define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_NTFS 2.1
|
||||||
#define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_FAT 1.05
|
#define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_FAT 1.05
|
||||||
|
|
||||||
#define TC_SYS_BOOT_LOADER_BACKUP_NAME L"Original System Loader"
|
#define TC_SYS_BOOT_LOADER_BACKUP_NAME L"Original System Loader"
|
||||||
#define TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY L"Original System Loader.bak" // Deprecated to prevent removal by some "cleaners"
|
#define TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY L"Original System Loader.bak" // Deprecated to prevent removal by some "cleaners"
|
||||||
|
|
||||||
#define TC_SYSTEM_FAVORITES_SERVICE_NAME _T(TC_APP_NAME) L"SystemFavorites"
|
#define TC_SYSTEM_FAVORITES_SERVICE_NAME _T(TC_APP_NAME) L"SystemFavorites"
|
||||||
#define TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP L"Event Log"
|
#define TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP L"Event Log"
|
||||||
#define TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION L"/systemFavoritesService"
|
#define TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION L"/systemFavoritesService"
|
||||||
|
|
||||||
#endif // TC_HEADER_Common_BootEncryption
|
#endif // TC_HEADER_Common_BootEncryption
|
||||||
|
|||||||
+115
-115
@@ -1,115 +1,115 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Fat.h"
|
#include "Fat.h"
|
||||||
#include "Volumes.h"
|
#include "Volumes.h"
|
||||||
#include "Apidrvr.h"
|
#include "Apidrvr.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
|
|
||||||
Password CachedPasswords[CACHE_SIZE];
|
Password CachedPasswords[CACHE_SIZE];
|
||||||
int CachedPim[CACHE_SIZE];
|
int CachedPim[CACHE_SIZE];
|
||||||
int cacheEmpty = 1;
|
int cacheEmpty = 1;
|
||||||
static int nPasswordIdx = 0;
|
static int nPasswordIdx = 0;
|
||||||
|
|
||||||
int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *header, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, PCRYPTO_INFO *retInfo)
|
int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *header, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, PCRYPTO_INFO *retInfo)
|
||||||
{
|
{
|
||||||
int nReturnCode = ERR_PASSWORD_WRONG;
|
int nReturnCode = ERR_PASSWORD_WRONG;
|
||||||
int i, effectivePim;
|
int i, effectivePim;
|
||||||
|
|
||||||
/* Attempt to recognize volume using mount password */
|
/* Attempt to recognize volume using mount password */
|
||||||
if (password->Length > 0)
|
if (password->Length > 0)
|
||||||
{
|
{
|
||||||
nReturnCode = ReadVolumeHeader (bBoot, header, password, pkcs5_prf, pim, truecryptMode, retInfo, NULL);
|
nReturnCode = ReadVolumeHeader (bBoot, header, password, pkcs5_prf, pim, truecryptMode, retInfo, NULL);
|
||||||
|
|
||||||
/* Save mount passwords back into cache if asked to do so */
|
/* Save mount passwords back into cache if asked to do so */
|
||||||
if (bCache && (nReturnCode == 0 || nReturnCode == ERR_CIPHER_INIT_WEAK_KEY))
|
if (bCache && (nReturnCode == 0 || nReturnCode == ERR_CIPHER_INIT_WEAK_KEY))
|
||||||
{
|
{
|
||||||
for (i = 0; i < CACHE_SIZE; i++)
|
for (i = 0; i < CACHE_SIZE; i++)
|
||||||
{
|
{
|
||||||
if (memcmp (&CachedPasswords[i], password, sizeof (Password)) == 0)
|
if (memcmp (&CachedPasswords[i], password, sizeof (Password)) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == CACHE_SIZE)
|
if (i == CACHE_SIZE)
|
||||||
{
|
{
|
||||||
/* Store the password */
|
/* Store the password */
|
||||||
CachedPasswords[nPasswordIdx] = *password;
|
CachedPasswords[nPasswordIdx] = *password;
|
||||||
|
|
||||||
/* Store also PIM if requested, otherwise set to default */
|
/* Store also PIM if requested, otherwise set to default */
|
||||||
if (bCachePim && (pim > 0))
|
if (bCachePim && (pim > 0))
|
||||||
CachedPim[nPasswordIdx] = pim;
|
CachedPim[nPasswordIdx] = pim;
|
||||||
else
|
else
|
||||||
CachedPim[nPasswordIdx] = 0;
|
CachedPim[nPasswordIdx] = 0;
|
||||||
|
|
||||||
/* Try another slot */
|
/* Try another slot */
|
||||||
nPasswordIdx = (nPasswordIdx + 1) % CACHE_SIZE;
|
nPasswordIdx = (nPasswordIdx + 1) % CACHE_SIZE;
|
||||||
|
|
||||||
cacheEmpty = 0;
|
cacheEmpty = 0;
|
||||||
}
|
}
|
||||||
else if (bCachePim)
|
else if (bCachePim)
|
||||||
{
|
{
|
||||||
CachedPim[i] = pim > 0? pim : 0;
|
CachedPim[i] = pim > 0? pim : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!cacheEmpty)
|
else if (!cacheEmpty)
|
||||||
{
|
{
|
||||||
/* Attempt to recognize volume using cached passwords */
|
/* Attempt to recognize volume using cached passwords */
|
||||||
for (i = 0; i < CACHE_SIZE; i++)
|
for (i = 0; i < CACHE_SIZE; i++)
|
||||||
{
|
{
|
||||||
if (CachedPasswords[i].Length > 0)
|
if (CachedPasswords[i].Length > 0)
|
||||||
{
|
{
|
||||||
if (truecryptMode)
|
if (truecryptMode)
|
||||||
effectivePim = 0;
|
effectivePim = 0;
|
||||||
else if (pim == -1)
|
else if (pim == -1)
|
||||||
effectivePim = CachedPim[i];
|
effectivePim = CachedPim[i];
|
||||||
else
|
else
|
||||||
effectivePim = pim;
|
effectivePim = pim;
|
||||||
nReturnCode = ReadVolumeHeader (bBoot, header, &CachedPasswords[i], pkcs5_prf, effectivePim, truecryptMode, retInfo, NULL);
|
nReturnCode = ReadVolumeHeader (bBoot, header, &CachedPasswords[i], pkcs5_prf, effectivePim, truecryptMode, retInfo, NULL);
|
||||||
|
|
||||||
if (nReturnCode != ERR_PASSWORD_WRONG)
|
if (nReturnCode != ERR_PASSWORD_WRONG)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nReturnCode;
|
return nReturnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AddPasswordToCache (Password *password, int pim)
|
void AddPasswordToCache (Password *password, int pim)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < CACHE_SIZE; i++)
|
for (i = 0; i < CACHE_SIZE; i++)
|
||||||
{
|
{
|
||||||
if (memcmp (&CachedPasswords[i], password, sizeof (Password)) == 0)
|
if (memcmp (&CachedPasswords[i], password, sizeof (Password)) == 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedPasswords[nPasswordIdx] = *password;
|
CachedPasswords[nPasswordIdx] = *password;
|
||||||
CachedPim[nPasswordIdx] = pim > 0? pim : 0;
|
CachedPim[nPasswordIdx] = pim > 0? pim : 0;
|
||||||
nPasswordIdx = (nPasswordIdx + 1) % CACHE_SIZE;
|
nPasswordIdx = (nPasswordIdx + 1) % CACHE_SIZE;
|
||||||
cacheEmpty = 0;
|
cacheEmpty = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WipeCache ()
|
void WipeCache ()
|
||||||
{
|
{
|
||||||
burn (CachedPasswords, sizeof (CachedPasswords));
|
burn (CachedPasswords, sizeof (CachedPasswords));
|
||||||
burn (CachedPim, sizeof (CachedPim));
|
burn (CachedPim, sizeof (CachedPim));
|
||||||
nPasswordIdx = 0;
|
nPasswordIdx = 0;
|
||||||
cacheEmpty = 1;
|
cacheEmpty = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-25
@@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#ifndef CACHE_SIZE
|
#ifndef CACHE_SIZE
|
||||||
/* WARNING: Changing this value might not be safe (some items may be hard coded for 4)! Inspection necessary. */
|
/* WARNING: Changing this value might not be safe (some items may be hard coded for 4)! Inspection necessary. */
|
||||||
#define CACHE_SIZE 4
|
#define CACHE_SIZE 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int cacheEmpty;
|
extern int cacheEmpty;
|
||||||
|
|
||||||
void AddPasswordToCache (Password *password, int pim);
|
void AddPasswordToCache (Password *password, int pim);
|
||||||
int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim,char *header, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, PCRYPTO_INFO *retInfo);
|
int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim,char *header, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, PCRYPTO_INFO *retInfo);
|
||||||
void WipeCache (void);
|
void WipeCache (void);
|
||||||
|
|||||||
+184
-184
@@ -1,184 +1,184 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "Cmdline.h"
|
#include "Cmdline.h"
|
||||||
|
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Apidrvr.h"
|
#include "Apidrvr.h"
|
||||||
#include "Dlgcode.h"
|
#include "Dlgcode.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include <Strsafe.h>
|
#include <Strsafe.h>
|
||||||
|
|
||||||
#ifndef SRC_POS
|
#ifndef SRC_POS
|
||||||
#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
|
#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Except in response to the WM_INITDIALOG message, the dialog box procedure
|
/* Except in response to the WM_INITDIALOG message, the dialog box procedure
|
||||||
should return nonzero if it processes the message, and zero if it does
|
should return nonzero if it processes the message, and zero if it does
|
||||||
not. - see DialogProc */
|
not. - see DialogProc */
|
||||||
BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER (lParam); /* remove warning */
|
UNREFERENCED_PARAMETER (lParam); /* remove warning */
|
||||||
UNREFERENCED_PARAMETER (wParam); /* remove warning */
|
UNREFERENCED_PARAMETER (wParam); /* remove warning */
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
wchar_t * tmp = err_malloc(8192 * sizeof (wchar_t));
|
wchar_t * tmp = err_malloc(8192 * sizeof (wchar_t));
|
||||||
wchar_t tmp2[MAX_PATH * 2];
|
wchar_t tmp2[MAX_PATH * 2];
|
||||||
argumentspec *as;
|
argumentspec *as;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LocalizeDialog (hwndDlg, "IDD_COMMANDHELP_DLG");
|
LocalizeDialog (hwndDlg, "IDD_COMMANDHELP_DLG");
|
||||||
|
|
||||||
as = (argumentspec*) lParam;
|
as = (argumentspec*) lParam;
|
||||||
|
|
||||||
*tmp = 0;
|
*tmp = 0;
|
||||||
|
|
||||||
StringCchCopyW (tmp, 8192, L"VeraCrypt " _T(VERSION_STRING));
|
StringCchCopyW (tmp, 8192, L"VeraCrypt " _T(VERSION_STRING));
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
StringCchCatW (tmp, 8192, L" (64-bit)");
|
StringCchCatW (tmp, 8192, L" (64-bit)");
|
||||||
#else
|
#else
|
||||||
StringCchCatW (tmp, 8192, L" (32-bit)");
|
StringCchCatW (tmp, 8192, L" (32-bit)");
|
||||||
#endif
|
#endif
|
||||||
#if (defined(_DEBUG) || defined(DEBUG))
|
#if (defined(_DEBUG) || defined(DEBUG))
|
||||||
StringCchCatW (tmp, 8192, L" (debug)");
|
StringCchCatW (tmp, 8192, L" (debug)");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StringCchCatW (tmp, 8192, L"\n\nCommand line options:\n\n");
|
StringCchCatW (tmp, 8192, L"\n\nCommand line options:\n\n");
|
||||||
for (i = 0; i < as->arg_cnt; i ++)
|
for (i = 0; i < as->arg_cnt; i ++)
|
||||||
{
|
{
|
||||||
if (!as->args[i].Internal)
|
if (!as->args[i].Internal)
|
||||||
{
|
{
|
||||||
StringCchPrintfW(tmp2, MAX_PATH * 2, L"%s\t%s\n", as->args[i].short_name, as->args[i].long_name);
|
StringCchPrintfW(tmp2, MAX_PATH * 2, L"%s\t%s\n", as->args[i].short_name, as->args[i].long_name);
|
||||||
StringCchCatW(tmp, 8192, tmp2);
|
StringCchCatW(tmp, 8192, tmp2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringCchCatW (tmp, 8192, L"\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nDismount a volume X:\tveracrypt.exe /q /d X");
|
StringCchCatW (tmp, 8192, L"\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nDismount a volume X:\tveracrypt.exe /q /d X");
|
||||||
|
|
||||||
SetWindowTextW (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), tmp);
|
SetWindowTextW (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), tmp);
|
||||||
|
|
||||||
TCfree(tmp);
|
TCfree(tmp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
EndDialog (hwndDlg, IDOK);
|
EndDialog (hwndDlg, IDOK);
|
||||||
return 1;
|
return 1;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
EndDialog (hwndDlg, 0);
|
EndDialog (hwndDlg, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Win32CommandLine (wchar_t ***lpszArgs)
|
int Win32CommandLine (wchar_t ***lpszArgs)
|
||||||
{
|
{
|
||||||
int argumentCount;
|
int argumentCount;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LPWSTR *arguments = CommandLineToArgvW (GetCommandLineW(), &argumentCount);
|
LPWSTR *arguments = CommandLineToArgvW (GetCommandLineW(), &argumentCount);
|
||||||
if (!arguments)
|
if (!arguments)
|
||||||
{
|
{
|
||||||
handleWin32Error (NULL, SRC_POS);
|
handleWin32Error (NULL, SRC_POS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
--argumentCount;
|
--argumentCount;
|
||||||
if (argumentCount < 1)
|
if (argumentCount < 1)
|
||||||
{
|
{
|
||||||
LocalFree (arguments);
|
LocalFree (arguments);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*lpszArgs = malloc (sizeof (wchar_t *) * argumentCount);
|
*lpszArgs = malloc (sizeof (wchar_t *) * argumentCount);
|
||||||
if (!*lpszArgs)
|
if (!*lpszArgs)
|
||||||
AbortProcess ("OUTOFMEMORY");
|
AbortProcess ("OUTOFMEMORY");
|
||||||
|
|
||||||
for (i = 0; i < argumentCount; ++i)
|
for (i = 0; i < argumentCount; ++i)
|
||||||
{
|
{
|
||||||
wchar_t *arg = _wcsdup (arguments[i + 1]);
|
wchar_t *arg = _wcsdup (arguments[i + 1]);
|
||||||
if (!arg)
|
if (!arg)
|
||||||
AbortProcess ("OUTOFMEMORY");
|
AbortProcess ("OUTOFMEMORY");
|
||||||
|
|
||||||
(*lpszArgs)[i] = arg;
|
(*lpszArgs)[i] = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFree (arguments);
|
LocalFree (arguments);
|
||||||
return argumentCount;
|
return argumentCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetArgSepPosOffset (wchar_t *lpszArgument)
|
int GetArgSepPosOffset (wchar_t *lpszArgument)
|
||||||
{
|
{
|
||||||
if (lpszArgument[0] == L'/')
|
if (lpszArgument[0] == L'/')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetArgumentID (argumentspec *as, wchar_t *lpszArgument)
|
int GetArgumentID (argumentspec *as, wchar_t *lpszArgument)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < as->arg_cnt; i++)
|
for (i = 0; i < as->arg_cnt; i++)
|
||||||
{
|
{
|
||||||
if (_wcsicmp (as->args[i].long_name, lpszArgument) == 0)
|
if (_wcsicmp (as->args[i].long_name, lpszArgument) == 0)
|
||||||
{
|
{
|
||||||
return as->args[i].Id;
|
return as->args[i].Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < as->arg_cnt; i++)
|
for (i = 0; i < as->arg_cnt; i++)
|
||||||
{
|
{
|
||||||
if (as->args[i].short_name[0] == 0)
|
if (as->args[i].short_name[0] == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_wcsicmp (as->args[i].short_name, lpszArgument) == 0)
|
if (_wcsicmp (as->args[i].short_name, lpszArgument) == 0)
|
||||||
{
|
{
|
||||||
return as->args[i].Id;
|
return as->args[i].Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetArgumentValue (wchar_t **lpszCommandLineArgs, int *nArgIdx,
|
int GetArgumentValue (wchar_t **lpszCommandLineArgs, int *nArgIdx,
|
||||||
int nNoCommandLineArgs, wchar_t *lpszValue, int nValueSize)
|
int nNoCommandLineArgs, wchar_t *lpszValue, int nValueSize)
|
||||||
{
|
{
|
||||||
*lpszValue = 0;
|
*lpszValue = 0;
|
||||||
|
|
||||||
if (*nArgIdx + 1 < nNoCommandLineArgs)
|
if (*nArgIdx + 1 < nNoCommandLineArgs)
|
||||||
{
|
{
|
||||||
int x = GetArgSepPosOffset (lpszCommandLineArgs[*nArgIdx + 1]);
|
int x = GetArgSepPosOffset (lpszCommandLineArgs[*nArgIdx + 1]);
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
{
|
{
|
||||||
/* Handles the case of space between parameter code
|
/* Handles the case of space between parameter code
|
||||||
and value */
|
and value */
|
||||||
StringCchCopyW (lpszValue, nValueSize, lpszCommandLineArgs[*nArgIdx + 1]);
|
StringCchCopyW (lpszValue, nValueSize, lpszCommandLineArgs[*nArgIdx + 1]);
|
||||||
lpszValue[nValueSize - 1] = 0;
|
lpszValue[nValueSize - 1] = 0;
|
||||||
(*nArgIdx)++;
|
(*nArgIdx)++;
|
||||||
return HAS_ARGUMENT;
|
return HAS_ARGUMENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HAS_NO_ARGUMENT;
|
return HAS_NO_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-43
@@ -1,43 +1,43 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAS_ARGUMENT 1
|
#define HAS_ARGUMENT 1
|
||||||
#define HAS_NO_ARGUMENT !HAS_ARGUMENT
|
#define HAS_NO_ARGUMENT !HAS_ARGUMENT
|
||||||
|
|
||||||
typedef struct argument_t
|
typedef struct argument_t
|
||||||
{
|
{
|
||||||
int Id;
|
int Id;
|
||||||
wchar_t long_name[32];
|
wchar_t long_name[32];
|
||||||
wchar_t short_name[8];
|
wchar_t short_name[8];
|
||||||
BOOL Internal;
|
BOOL Internal;
|
||||||
} argument;
|
} argument;
|
||||||
|
|
||||||
typedef struct argumentspec_t
|
typedef struct argumentspec_t
|
||||||
{
|
{
|
||||||
argument *args;
|
argument *args;
|
||||||
int arg_cnt;
|
int arg_cnt;
|
||||||
} argumentspec;
|
} argumentspec;
|
||||||
|
|
||||||
BOOL CALLBACK CommandHelpDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
|
BOOL CALLBACK CommandHelpDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
|
||||||
int Win32CommandLine ( wchar_t ***lpszArgs );
|
int Win32CommandLine ( wchar_t ***lpszArgs );
|
||||||
int GetArgSepPosOffset ( wchar_t *lpszArgument );
|
int GetArgSepPosOffset ( wchar_t *lpszArgument );
|
||||||
int GetArgumentID ( argumentspec *as , wchar_t *lpszArgument );
|
int GetArgumentID ( argumentspec *as , wchar_t *lpszArgument );
|
||||||
int GetArgumentValue ( wchar_t **lpszCommandLineArgs , int *nArgIdx , int nNoCommandLineArgs , wchar_t *lpszValue , int nValueSize );
|
int GetArgumentValue ( wchar_t **lpszCommandLineArgs , int *nArgIdx , int nNoCommandLineArgs , wchar_t *lpszValue , int nValueSize );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+258
-258
@@ -1,258 +1,258 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Combo.h"
|
#include "Combo.h"
|
||||||
#include "Dlgcode.h"
|
#include "Dlgcode.h"
|
||||||
#include "Xml.h"
|
#include "Xml.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define SIZEOF_MRU_LIST 20
|
#define SIZEOF_MRU_LIST 20
|
||||||
|
|
||||||
void AddComboItem (HWND hComboBox, const wchar_t *lpszFileName, BOOL saveHistory)
|
void AddComboItem (HWND hComboBox, const wchar_t *lpszFileName, BOOL saveHistory)
|
||||||
{
|
{
|
||||||
LPARAM nIndex;
|
LPARAM nIndex;
|
||||||
|
|
||||||
if (!saveHistory)
|
if (!saveHistory)
|
||||||
{
|
{
|
||||||
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
|
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
|
||||||
SetWindowText (hComboBox, lpszFileName);
|
SetWindowText (hComboBox, lpszFileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nIndex = SendMessage (hComboBox, CB_FINDSTRINGEXACT, (WPARAM) - 1, (LPARAM) & lpszFileName[0]);
|
nIndex = SendMessage (hComboBox, CB_FINDSTRINGEXACT, (WPARAM) - 1, (LPARAM) & lpszFileName[0]);
|
||||||
|
|
||||||
if (nIndex == CB_ERR && *lpszFileName)
|
if (nIndex == CB_ERR && *lpszFileName)
|
||||||
{
|
{
|
||||||
time_t lTime = time (NULL);
|
time_t lTime = time (NULL);
|
||||||
nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) & lpszFileName[0]);
|
nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) & lpszFileName[0]);
|
||||||
if (nIndex != CB_ERR)
|
if (nIndex != CB_ERR)
|
||||||
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) lTime);
|
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) lTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nIndex != CB_ERR && *lpszFileName)
|
if (nIndex != CB_ERR && *lpszFileName)
|
||||||
nIndex = SendMessage (hComboBox, CB_SETCURSEL, nIndex, 0);
|
nIndex = SendMessage (hComboBox, CB_SETCURSEL, nIndex, 0);
|
||||||
|
|
||||||
if (*lpszFileName == 0)
|
if (*lpszFileName == 0)
|
||||||
{
|
{
|
||||||
SendMessage (hComboBox, CB_SETCURSEL, (WPARAM) - 1, 0);
|
SendMessage (hComboBox, CB_SETCURSEL, (WPARAM) - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory)
|
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory)
|
||||||
{
|
{
|
||||||
wchar_t szTmp[TC_MAX_PATH] = {0};
|
wchar_t szTmp[TC_MAX_PATH] = {0};
|
||||||
|
|
||||||
if (!saveHistory)
|
if (!saveHistory)
|
||||||
{
|
{
|
||||||
GetWindowText (hComboBox, szTmp, ARRAYSIZE (szTmp));
|
GetWindowText (hComboBox, szTmp, ARRAYSIZE (szTmp));
|
||||||
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
|
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
|
||||||
SetWindowText (hComboBox, szTmp);
|
SetWindowText (hComboBox, szTmp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetWindowText (hComboBox, szTmp, ARRAYSIZE (szTmp));
|
GetWindowText (hComboBox, szTmp, ARRAYSIZE (szTmp));
|
||||||
|
|
||||||
if (wcslen (szTmp) > 0)
|
if (wcslen (szTmp) > 0)
|
||||||
{
|
{
|
||||||
LPARAM nIndex = SendMessage (hComboBox, CB_FINDSTRINGEXACT, (WPARAM) - 1,
|
LPARAM nIndex = SendMessage (hComboBox, CB_FINDSTRINGEXACT, (WPARAM) - 1,
|
||||||
(LPARAM) & szTmp[0]);
|
(LPARAM) & szTmp[0]);
|
||||||
if (nIndex == CB_ERR)
|
if (nIndex == CB_ERR)
|
||||||
{
|
{
|
||||||
time_t lTime = time (NULL);
|
time_t lTime = time (NULL);
|
||||||
nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) & szTmp[0]);
|
nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) & szTmp[0]);
|
||||||
if (nIndex != CB_ERR)
|
if (nIndex != CB_ERR)
|
||||||
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (DWORD) lTime);
|
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (DWORD) lTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
time_t lTime = time (NULL);
|
time_t lTime = time (NULL);
|
||||||
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (DWORD) lTime);
|
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (DWORD) lTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nIndex;
|
return nIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SendMessage (hComboBox, CB_GETCURSEL, 0, 0);
|
return SendMessage (hComboBox, CB_GETCURSEL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetOrderComboIdx (HWND hComboBox, int *nIdxList, int nElems)
|
int GetOrderComboIdx (HWND hComboBox, int *nIdxList, int nElems)
|
||||||
{
|
{
|
||||||
int x = (int) SendMessage (hComboBox, CB_GETCOUNT, 0, 0);
|
int x = (int) SendMessage (hComboBox, CB_GETCOUNT, 0, 0);
|
||||||
if (x != CB_ERR)
|
if (x != CB_ERR)
|
||||||
{
|
{
|
||||||
int i, nHighIdx = CB_ERR;
|
int i, nHighIdx = CB_ERR;
|
||||||
time_t lHighTime = -1;
|
time_t lHighTime = -1;
|
||||||
|
|
||||||
for (i = 0; i < x; i++)
|
for (i = 0; i < x; i++)
|
||||||
{
|
{
|
||||||
time_t lTime = SendMessage (hComboBox, CB_GETITEMDATA, (WPARAM) i, 0);
|
time_t lTime = SendMessage (hComboBox, CB_GETITEMDATA, (WPARAM) i, 0);
|
||||||
if (lTime > lHighTime)
|
if (lTime > lHighTime)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
for (n = 0; n < nElems; n++)
|
for (n = 0; n < nElems; n++)
|
||||||
if (nIdxList[n] == i)
|
if (nIdxList[n] == i)
|
||||||
break;
|
break;
|
||||||
if (n == nElems)
|
if (n == nElems)
|
||||||
{
|
{
|
||||||
lHighTime = lTime;
|
lHighTime = lTime;
|
||||||
nHighIdx = i;
|
nHighIdx = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nHighIdx;
|
return nHighIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CB_ERR;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPARAM UpdateComboOrder (HWND hComboBox)
|
LPARAM UpdateComboOrder (HWND hComboBox)
|
||||||
{
|
{
|
||||||
LPARAM nIndex;
|
LPARAM nIndex;
|
||||||
|
|
||||||
nIndex = SendMessage (hComboBox, CB_GETCURSEL, 0, 0);
|
nIndex = SendMessage (hComboBox, CB_GETCURSEL, 0, 0);
|
||||||
|
|
||||||
if (nIndex != CB_ERR)
|
if (nIndex != CB_ERR)
|
||||||
{
|
{
|
||||||
time_t lTime = time (NULL);
|
time_t lTime = time (NULL);
|
||||||
nIndex = SendMessage (hComboBox, CB_SETITEMDATA, (WPARAM) nIndex,
|
nIndex = SendMessage (hComboBox, CB_SETITEMDATA, (WPARAM) nIndex,
|
||||||
(LPARAM) lTime);
|
(LPARAM) lTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nIndex;
|
return nIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pbModified)
|
void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pbModified)
|
||||||
{
|
{
|
||||||
DWORD size;
|
DWORD size;
|
||||||
char *history = LoadFile (GetConfigPath (TC_APPD_FILENAME_HISTORY), &size);
|
char *history = LoadFile (GetConfigPath (TC_APPD_FILENAME_HISTORY), &size);
|
||||||
char *xml = history;
|
char *xml = history;
|
||||||
char volume[MAX_PATH];
|
char volume[MAX_PATH];
|
||||||
int i, nComboIdx[SIZEOF_MRU_LIST] = {0};
|
int i, nComboIdx[SIZEOF_MRU_LIST] = {0};
|
||||||
int count = SendMessage (hComboBox, CB_GETCOUNT, 0, 0);
|
int count = SendMessage (hComboBox, CB_GETCOUNT, 0, 0);
|
||||||
|
|
||||||
if (xml == NULL)
|
if (xml == NULL)
|
||||||
{
|
{
|
||||||
// No history XML file but history is enabled
|
// No history XML file but history is enabled
|
||||||
if (bEnabled && pbModified)
|
if (bEnabled && pbModified)
|
||||||
*pbModified = TRUE;
|
*pbModified = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bEnabled && bOnlyCheckModified)
|
if (!bEnabled && bOnlyCheckModified)
|
||||||
{
|
{
|
||||||
// History is disable but there is a history XML file
|
// History is disable but there is a history XML file
|
||||||
if (pbModified)
|
if (pbModified)
|
||||||
*pbModified = TRUE;
|
*pbModified = TRUE;
|
||||||
free (history);
|
free (history);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* combo list part:- get mru items */
|
/* combo list part:- get mru items */
|
||||||
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
||||||
nComboIdx[i] = GetOrderComboIdx (hComboBox, &nComboIdx[0], i);
|
nComboIdx[i] = GetOrderComboIdx (hComboBox, &nComboIdx[0], i);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (xml = XmlFindElement (xml, "volume"))
|
while (xml = XmlFindElement (xml, "volume"))
|
||||||
{
|
{
|
||||||
wchar_t szTmp[MAX_PATH] = { 0 };
|
wchar_t szTmp[MAX_PATH] = { 0 };
|
||||||
wchar_t wszVolume[MAX_PATH] = {0};
|
wchar_t wszVolume[MAX_PATH] = {0};
|
||||||
|
|
||||||
if (i < count)
|
if (i < count)
|
||||||
{
|
{
|
||||||
if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp))
|
if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp))
|
||||||
SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
|
SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlGetNodeText (xml, volume, sizeof (volume));
|
XmlGetNodeText (xml, volume, sizeof (volume));
|
||||||
if (0 == MultiByteToWideChar (CP_UTF8, 0, volume, -1, wszVolume, MAX_PATH))
|
if (0 == MultiByteToWideChar (CP_UTF8, 0, volume, -1, wszVolume, MAX_PATH))
|
||||||
wszVolume [0] = 0;
|
wszVolume [0] = 0;
|
||||||
if (!bOnlyCheckModified)
|
if (!bOnlyCheckModified)
|
||||||
AddComboItem (hComboBox, wszVolume, TRUE);
|
AddComboItem (hComboBox, wszVolume, TRUE);
|
||||||
|
|
||||||
if (pbModified && wcscmp (wszVolume, szTmp))
|
if (pbModified && wcscmp (wszVolume, szTmp))
|
||||||
*pbModified = TRUE;
|
*pbModified = TRUE;
|
||||||
|
|
||||||
xml++;
|
xml++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pbModified && (i != count))
|
if (pbModified && (i != count))
|
||||||
*pbModified = TRUE;
|
*pbModified = TRUE;
|
||||||
|
|
||||||
if (!bOnlyCheckModified)
|
if (!bOnlyCheckModified)
|
||||||
SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
|
SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
|
||||||
|
|
||||||
free (history);
|
free (history);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpCombo (HWND hComboBox, int bClear)
|
void DumpCombo (HWND hComboBox, int bClear)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int i, nComboIdx[SIZEOF_MRU_LIST] = {0};
|
int i, nComboIdx[SIZEOF_MRU_LIST] = {0};
|
||||||
|
|
||||||
if (bClear)
|
if (bClear)
|
||||||
{
|
{
|
||||||
DeleteFile (GetConfigPath (TC_APPD_FILENAME_HISTORY));
|
DeleteFile (GetConfigPath (TC_APPD_FILENAME_HISTORY));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = _wfopen (GetConfigPath (TC_APPD_FILENAME_HISTORY), L"w,ccs=UTF-8");
|
f = _wfopen (GetConfigPath (TC_APPD_FILENAME_HISTORY), L"w,ccs=UTF-8");
|
||||||
if (f == NULL) return;
|
if (f == NULL) return;
|
||||||
|
|
||||||
XmlWriteHeader (f);
|
XmlWriteHeader (f);
|
||||||
fputws (L"\n\t<history>", f);
|
fputws (L"\n\t<history>", f);
|
||||||
|
|
||||||
/* combo list part:- get mru items */
|
/* combo list part:- get mru items */
|
||||||
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
||||||
nComboIdx[i] = GetOrderComboIdx (hComboBox, &nComboIdx[0], i);
|
nComboIdx[i] = GetOrderComboIdx (hComboBox, &nComboIdx[0], i);
|
||||||
|
|
||||||
/* combo list part:- write out mru items */
|
/* combo list part:- write out mru items */
|
||||||
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
||||||
{
|
{
|
||||||
wchar_t szTmp[MAX_PATH] = { 0 };
|
wchar_t szTmp[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp))
|
if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp))
|
||||||
SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
|
SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
|
||||||
|
|
||||||
if (szTmp[0] != 0)
|
if (szTmp[0] != 0)
|
||||||
{
|
{
|
||||||
wchar_t q[MAX_PATH * 2] = { 0 };
|
wchar_t q[MAX_PATH * 2] = { 0 };
|
||||||
XmlQuoteTextW (szTmp, q, ARRAYSIZE (q));
|
XmlQuoteTextW (szTmp, q, ARRAYSIZE (q));
|
||||||
|
|
||||||
fwprintf (f, L"\n\t\t<volume>%s</volume>", q);
|
fwprintf (f, L"\n\t\t<volume>%s</volume>", q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fputws (L"\n\t</history>", f);
|
fputws (L"\n\t</history>", f);
|
||||||
XmlWriteFooter (f);
|
XmlWriteFooter (f);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearCombo (HWND hComboBox)
|
void ClearCombo (HWND hComboBox)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
for (i = 0; i < SIZEOF_MRU_LIST; i++)
|
||||||
{
|
{
|
||||||
SendMessage (hComboBox, CB_DELETESTRING, 0, 0);
|
SendMessage (hComboBox, CB_DELETESTRING, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int IsComboEmpty (HWND hComboBox)
|
int IsComboEmpty (HWND hComboBox)
|
||||||
{
|
{
|
||||||
return SendMessage (hComboBox, CB_GETCOUNT, 0, 0) < 1;
|
return SendMessage (hComboBox, CB_GETCOUNT, 0, 0) < 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-29
@@ -1,29 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AddComboItem (HWND hComboBox, const wchar_t *lpszFileName, BOOL saveHistory);
|
void AddComboItem (HWND hComboBox, const wchar_t *lpszFileName, BOOL saveHistory);
|
||||||
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory);
|
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory);
|
||||||
int GetOrderComboIdx ( HWND hComboBox , int *nIdxList , int nElems );
|
int GetOrderComboIdx ( HWND hComboBox , int *nIdxList , int nElems );
|
||||||
LPARAM UpdateComboOrder ( HWND hComboBox );
|
LPARAM UpdateComboOrder ( HWND hComboBox );
|
||||||
void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pbModified);
|
void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pbModified);
|
||||||
void DumpCombo ( HWND hComboBox , int bClear );
|
void DumpCombo ( HWND hComboBox , int bClear );
|
||||||
void ClearCombo (HWND hComboBox);
|
void ClearCombo (HWND hComboBox);
|
||||||
int IsComboEmpty (HWND hComboBox);
|
int IsComboEmpty (HWND hComboBox);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+95
-95
@@ -1,95 +1,95 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMMON_H
|
#ifndef COMMON_H
|
||||||
#define COMMON_H
|
#define COMMON_H
|
||||||
|
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
|
|
||||||
#define MIN_MOUNTED_VOLUME_DRIVE_NUMBER ('A' - 'A')
|
#define MIN_MOUNTED_VOLUME_DRIVE_NUMBER ('A' - 'A')
|
||||||
#define MAX_MOUNTED_VOLUME_DRIVE_NUMBER ('Z' - 'A')
|
#define MAX_MOUNTED_VOLUME_DRIVE_NUMBER ('Z' - 'A')
|
||||||
|
|
||||||
#define MAX_HOST_DRIVE_NUMBER 64
|
#define MAX_HOST_DRIVE_NUMBER 64
|
||||||
#define MAX_HOST_PARTITION_NUMBER 32
|
#define MAX_HOST_PARTITION_NUMBER 32
|
||||||
|
|
||||||
#define VOLUME_ID_SIZE SHA256_DIGESTSIZE
|
#define VOLUME_ID_SIZE SHA256_DIGESTSIZE
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
// IMPORTANT: If you add a new item here, update IsOSVersionAtLeast().
|
// IMPORTANT: If you add a new item here, update IsOSVersionAtLeast().
|
||||||
|
|
||||||
WIN_UNKNOWN = 0,
|
WIN_UNKNOWN = 0,
|
||||||
WIN_31,
|
WIN_31,
|
||||||
WIN_95,
|
WIN_95,
|
||||||
WIN_98,
|
WIN_98,
|
||||||
WIN_ME,
|
WIN_ME,
|
||||||
WIN_NT3,
|
WIN_NT3,
|
||||||
WIN_NT4,
|
WIN_NT4,
|
||||||
WIN_2000,
|
WIN_2000,
|
||||||
WIN_XP,
|
WIN_XP,
|
||||||
WIN_XP64,
|
WIN_XP64,
|
||||||
WIN_SERVER_2003,
|
WIN_SERVER_2003,
|
||||||
WIN_VISTA,
|
WIN_VISTA,
|
||||||
WIN_SERVER_2008,
|
WIN_SERVER_2008,
|
||||||
WIN_7,
|
WIN_7,
|
||||||
WIN_SERVER_2008_R2,
|
WIN_SERVER_2008_R2,
|
||||||
WIN_8,
|
WIN_8,
|
||||||
WIN_SERVER_2012,
|
WIN_SERVER_2012,
|
||||||
WIN_8_1,
|
WIN_8_1,
|
||||||
WIN_SERVER_2012_R2,
|
WIN_SERVER_2012_R2,
|
||||||
WIN_10,
|
WIN_10,
|
||||||
WIN_SERVER_2016
|
WIN_SERVER_2016
|
||||||
} OSVersionEnum;
|
} OSVersionEnum;
|
||||||
|
|
||||||
/* Volume types */
|
/* Volume types */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TC_VOLUME_TYPE_NORMAL = 0,
|
TC_VOLUME_TYPE_NORMAL = 0,
|
||||||
TC_VOLUME_TYPE_HIDDEN,
|
TC_VOLUME_TYPE_HIDDEN,
|
||||||
TC_VOLUME_TYPE_COUNT
|
TC_VOLUME_TYPE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Prop volume types */
|
/* Prop volume types */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_VOL_TYPE_NORMAL = 0,
|
PROP_VOL_TYPE_NORMAL = 0,
|
||||||
PROP_VOL_TYPE_HIDDEN,
|
PROP_VOL_TYPE_HIDDEN,
|
||||||
PROP_VOL_TYPE_OUTER, /* Outer/normal (hidden volume protected) */
|
PROP_VOL_TYPE_OUTER, /* Outer/normal (hidden volume protected) */
|
||||||
PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, /* Outer/normal (hidden volume protected AND write already prevented) */
|
PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, /* Outer/normal (hidden volume protected AND write already prevented) */
|
||||||
PROP_VOL_TYPE_SYSTEM,
|
PROP_VOL_TYPE_SYSTEM,
|
||||||
PROP_NBR_VOLUME_TYPES
|
PROP_NBR_VOLUME_TYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Hidden volume protection status */
|
/* Hidden volume protection status */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HIDVOL_PROT_STATUS_NONE = 0,
|
HIDVOL_PROT_STATUS_NONE = 0,
|
||||||
HIDVOL_PROT_STATUS_ACTIVE,
|
HIDVOL_PROT_STATUS_ACTIVE,
|
||||||
HIDVOL_PROT_STATUS_ACTION_TAKEN /* Active + action taken (write operation has already been denied) */
|
HIDVOL_PROT_STATUS_ACTION_TAKEN /* Active + action taken (write operation has already been denied) */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BOOL ReadOnly;
|
BOOL ReadOnly;
|
||||||
BOOL Removable;
|
BOOL Removable;
|
||||||
BOOL ProtectHiddenVolume;
|
BOOL ProtectHiddenVolume;
|
||||||
BOOL PreserveTimestamp;
|
BOOL PreserveTimestamp;
|
||||||
BOOL PartitionInInactiveSysEncScope; /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
|
BOOL PartitionInInactiveSysEncScope; /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
|
||||||
Password ProtectedHidVolPassword; /* Password of hidden volume to protect against overwriting */
|
Password ProtectedHidVolPassword; /* Password of hidden volume to protect against overwriting */
|
||||||
BOOL UseBackupHeader;
|
BOOL UseBackupHeader;
|
||||||
BOOL RecoveryMode;
|
BOOL RecoveryMode;
|
||||||
int ProtectedHidVolPkcs5Prf;
|
int ProtectedHidVolPkcs5Prf;
|
||||||
int ProtectedHidVolPim;
|
int ProtectedHidVolPim;
|
||||||
wchar_t Label[33]; /* maximum label length is 32 for NTFS and 11 for FAT32 */
|
wchar_t Label[33]; /* maximum label length is 32 for NTFS and 11 for FAT32 */
|
||||||
} MountOptions;
|
} MountOptions;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+603
-603
File diff suppressed because it is too large
Load Diff
+135
-135
@@ -1,135 +1,135 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Crc.h"
|
#include "Crc.h"
|
||||||
#include "Common/Endian.h"
|
#include "Common/Endian.h"
|
||||||
|
|
||||||
#ifndef TC_MINIMIZE_CODE_SIZE
|
#ifndef TC_MINIMIZE_CODE_SIZE
|
||||||
|
|
||||||
/* CRC polynomial 0x04c11db7 */
|
/* CRC polynomial 0x04c11db7 */
|
||||||
unsigned __int32 crc_32_tab[]=
|
unsigned __int32 crc_32_tab[]=
|
||||||
{
|
{
|
||||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
||||||
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
||||||
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
||||||
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
||||||
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
||||||
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
||||||
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
||||||
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
||||||
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
||||||
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
||||||
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
||||||
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
||||||
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
||||||
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
||||||
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
||||||
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
||||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned __int32 GetCrc32 (unsigned char *data, int length)
|
unsigned __int32 GetCrc32 (unsigned char *data, int length)
|
||||||
{
|
{
|
||||||
unsigned __int32 CRC = 0xffffffff;
|
unsigned __int32 CRC = 0xffffffff;
|
||||||
|
|
||||||
while (length--)
|
while (length--)
|
||||||
{
|
{
|
||||||
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *data++) & 0xFF ];
|
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *data++) & 0xFF ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CRC ^ 0xffffffff;
|
return CRC ^ 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned __int32 crc32int (unsigned __int32 *data)
|
unsigned __int32 crc32int (unsigned __int32 *data)
|
||||||
{
|
{
|
||||||
unsigned char *d = (unsigned char *) data;
|
unsigned char *d = (unsigned char *) data;
|
||||||
unsigned __int32 CRC = 0xffffffff;
|
unsigned __int32 CRC = 0xffffffff;
|
||||||
|
|
||||||
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d++) & 0xFF ];
|
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d++) & 0xFF ];
|
||||||
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d++) & 0xFF ];
|
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d++) & 0xFF ];
|
||||||
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d++) & 0xFF ];
|
CRC = (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d++) & 0xFF ];
|
||||||
return (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d) & 0xFF ] ^ 0xffffffff;
|
return (CRC >> 8) ^ crc_32_tab[ (CRC ^ *d) & 0xFF ] ^ 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||||
# define CRC_SELFTEST 0x6fcf9e13
|
# define CRC_SELFTEST 0x6fcf9e13
|
||||||
#else
|
#else
|
||||||
# define CRC_SELFTEST 0xca87914d
|
# define CRC_SELFTEST 0xca87914d
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOL crc32_selftests (void)
|
BOOL crc32_selftests (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned __int32 crc = 0xffffffff;
|
unsigned __int32 crc = 0xffffffff;
|
||||||
BOOL bSuccess = FALSE;
|
BOOL bSuccess = FALSE;
|
||||||
|
|
||||||
for (i = 0; i < (int)sizeof(crc_32_tab); i++)
|
for (i = 0; i < (int)sizeof(crc_32_tab); i++)
|
||||||
crc = UPDC32 (((unsigned char *) crc_32_tab)[i], crc);
|
crc = UPDC32 (((unsigned char *) crc_32_tab)[i], crc);
|
||||||
|
|
||||||
bSuccess = CRC_SELFTEST == (crc ^ 0xffffffff);
|
bSuccess = CRC_SELFTEST == (crc ^ 0xffffffff);
|
||||||
|
|
||||||
bSuccess &= GetCrc32 ((unsigned char *)crc_32_tab, sizeof crc_32_tab) == CRC_SELFTEST;
|
bSuccess &= GetCrc32 ((unsigned char *)crc_32_tab, sizeof crc_32_tab) == CRC_SELFTEST;
|
||||||
|
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // TC_MINIMIZE_CODE_SIZE
|
#else // TC_MINIMIZE_CODE_SIZE
|
||||||
|
|
||||||
unsigned __int32 GetCrc32 (unsigned char *data, int length)
|
unsigned __int32 GetCrc32 (unsigned char *data, int length)
|
||||||
{
|
{
|
||||||
unsigned __int32 r = 0xFFFFFFFFUL;
|
unsigned __int32 r = 0xFFFFFFFFUL;
|
||||||
int i, b;
|
int i, b;
|
||||||
|
|
||||||
for (i = 0; i < length; ++i)
|
for (i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
r ^= data[i];
|
r ^= data[i];
|
||||||
for (b = 0; b < 8; ++b)
|
for (b = 0; b < 8; ++b)
|
||||||
{
|
{
|
||||||
if ((unsigned __int8) r & 1)
|
if ((unsigned __int8) r & 1)
|
||||||
r = (r >> 1) ^ 0xEDB88320UL;
|
r = (r >> 1) ^ 0xEDB88320UL;
|
||||||
else
|
else
|
||||||
r >>= 1;
|
r >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r ^ 0xFFFFFFFFUL;
|
return r ^ 0xFFFFFFFFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL crc32_selftests ()
|
BOOL crc32_selftests ()
|
||||||
{
|
{
|
||||||
unsigned __int8 testData[32];
|
unsigned __int8 testData[32];
|
||||||
unsigned __int8 i;
|
unsigned __int8 i;
|
||||||
|
|
||||||
for (i = 0; i < sizeof (testData); ++i)
|
for (i = 0; i < sizeof (testData); ++i)
|
||||||
testData[i] = i;
|
testData[i] = i;
|
||||||
|
|
||||||
return GetCrc32 (testData, sizeof (testData)) == 0x91267E8AUL;
|
return GetCrc32 (testData, sizeof (testData)) == 0x91267E8AUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TC_MINIMIZE_CODE_SIZE
|
#endif // TC_MINIMIZE_CODE_SIZE
|
||||||
|
|||||||
+37
-37
@@ -1,37 +1,37 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#ifndef TC_HEADER_CRC
|
#ifndef TC_HEADER_CRC
|
||||||
#define TC_HEADER_CRC
|
#define TC_HEADER_CRC
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UPDC32(octet, crc)\
|
#define UPDC32(octet, crc)\
|
||||||
(unsigned __int32)((crc_32_tab[(((unsigned __int32)(crc)) ^ ((unsigned char)(octet))) & 0xff] ^ (((unsigned __int32)(crc)) >> 8)))
|
(unsigned __int32)((crc_32_tab[(((unsigned __int32)(crc)) ^ ((unsigned char)(octet))) & 0xff] ^ (((unsigned __int32)(crc)) >> 8)))
|
||||||
|
|
||||||
unsigned __int32 GetCrc32 (unsigned char *data, int length);
|
unsigned __int32 GetCrc32 (unsigned char *data, int length);
|
||||||
unsigned __int32 crc32int (unsigned __int32 *data);
|
unsigned __int32 crc32int (unsigned __int32 *data);
|
||||||
BOOL crc32_selftests (void);
|
BOOL crc32_selftests (void);
|
||||||
|
|
||||||
extern unsigned __int32 crc_32_tab[];
|
extern unsigned __int32 crc_32_tab[];
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TC_HEADER_CRC
|
#endif // TC_HEADER_CRC
|
||||||
|
|||||||
+1058
-1058
File diff suppressed because it is too large
Load Diff
+363
-363
@@ -1,363 +1,363 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
/* Update the following when adding a new cipher or EA:
|
/* Update the following when adding a new cipher or EA:
|
||||||
|
|
||||||
Crypto.h:
|
Crypto.h:
|
||||||
ID #define
|
ID #define
|
||||||
MAX_EXPANDED_KEY #define
|
MAX_EXPANDED_KEY #define
|
||||||
|
|
||||||
Crypto.c:
|
Crypto.c:
|
||||||
Ciphers[]
|
Ciphers[]
|
||||||
EncryptionAlgorithms[]
|
EncryptionAlgorithms[]
|
||||||
CipherInit()
|
CipherInit()
|
||||||
EncipherBlock()
|
EncipherBlock()
|
||||||
DecipherBlock()
|
DecipherBlock()
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CRYPTO_H
|
#ifndef CRYPTO_H
|
||||||
#define CRYPTO_H
|
#define CRYPTO_H
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Encryption data unit size, which may differ from the sector size and must always be 512
|
// Encryption data unit size, which may differ from the sector size and must always be 512
|
||||||
#define ENCRYPTION_DATA_UNIT_SIZE 512
|
#define ENCRYPTION_DATA_UNIT_SIZE 512
|
||||||
|
|
||||||
// Size of the salt (in bytes)
|
// Size of the salt (in bytes)
|
||||||
#define PKCS5_SALT_SIZE 64
|
#define PKCS5_SALT_SIZE 64
|
||||||
|
|
||||||
// Size of the volume header area containing concatenated master key(s) and secondary key(s) (XTS mode)
|
// Size of the volume header area containing concatenated master key(s) and secondary key(s) (XTS mode)
|
||||||
#define MASTER_KEYDATA_SIZE 256
|
#define MASTER_KEYDATA_SIZE 256
|
||||||
|
|
||||||
// The first PRF to try when mounting
|
// The first PRF to try when mounting
|
||||||
#define FIRST_PRF_ID 1
|
#define FIRST_PRF_ID 1
|
||||||
|
|
||||||
// Hash algorithms (pseudorandom functions).
|
// Hash algorithms (pseudorandom functions).
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SHA512 = FIRST_PRF_ID,
|
SHA512 = FIRST_PRF_ID,
|
||||||
WHIRLPOOL,
|
WHIRLPOOL,
|
||||||
SHA256,
|
SHA256,
|
||||||
RIPEMD160,
|
RIPEMD160,
|
||||||
HASH_ENUM_END_ID
|
HASH_ENUM_END_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
// The last PRF to try when mounting and also the number of implemented PRFs
|
// The last PRF to try when mounting and also the number of implemented PRFs
|
||||||
#define LAST_PRF_ID (HASH_ENUM_END_ID - 1)
|
#define LAST_PRF_ID (HASH_ENUM_END_ID - 1)
|
||||||
|
|
||||||
#define RIPEMD160_BLOCKSIZE 64
|
#define RIPEMD160_BLOCKSIZE 64
|
||||||
#define RIPEMD160_DIGESTSIZE 20
|
#define RIPEMD160_DIGESTSIZE 20
|
||||||
|
|
||||||
#define SHA256_BLOCKSIZE 64
|
#define SHA256_BLOCKSIZE 64
|
||||||
#define SHA256_DIGESTSIZE 32
|
#define SHA256_DIGESTSIZE 32
|
||||||
|
|
||||||
#define SHA512_BLOCKSIZE 128
|
#define SHA512_BLOCKSIZE 128
|
||||||
#define SHA512_DIGESTSIZE 64
|
#define SHA512_DIGESTSIZE 64
|
||||||
|
|
||||||
#define WHIRLPOOL_BLOCKSIZE 64
|
#define WHIRLPOOL_BLOCKSIZE 64
|
||||||
#define WHIRLPOOL_DIGESTSIZE 64
|
#define WHIRLPOOL_DIGESTSIZE 64
|
||||||
|
|
||||||
#define MAX_DIGESTSIZE WHIRLPOOL_DIGESTSIZE
|
#define MAX_DIGESTSIZE WHIRLPOOL_DIGESTSIZE
|
||||||
|
|
||||||
#define DEFAULT_HASH_ALGORITHM FIRST_PRF_ID
|
#define DEFAULT_HASH_ALGORITHM FIRST_PRF_ID
|
||||||
#define DEFAULT_HASH_ALGORITHM_BOOT SHA256
|
#define DEFAULT_HASH_ALGORITHM_BOOT SHA256
|
||||||
|
|
||||||
// The mode of operation used for newly created volumes and first to try when mounting
|
// The mode of operation used for newly created volumes and first to try when mounting
|
||||||
#define FIRST_MODE_OF_OPERATION_ID 1
|
#define FIRST_MODE_OF_OPERATION_ID 1
|
||||||
|
|
||||||
// Modes of operation
|
// Modes of operation
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
/* If you add/remove a mode, update the following: GetMaxPkcs5OutSize(), EAInitMode() */
|
/* If you add/remove a mode, update the following: GetMaxPkcs5OutSize(), EAInitMode() */
|
||||||
|
|
||||||
XTS = FIRST_MODE_OF_OPERATION_ID,
|
XTS = FIRST_MODE_OF_OPERATION_ID,
|
||||||
MODE_ENUM_END_ID
|
MODE_ENUM_END_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// The last mode of operation to try when mounting and also the number of implemented modes
|
// The last mode of operation to try when mounting and also the number of implemented modes
|
||||||
#define LAST_MODE_OF_OPERATION (MODE_ENUM_END_ID - 1)
|
#define LAST_MODE_OF_OPERATION (MODE_ENUM_END_ID - 1)
|
||||||
|
|
||||||
// Ciphertext/plaintext block size for XTS mode (in bytes)
|
// Ciphertext/plaintext block size for XTS mode (in bytes)
|
||||||
#define BYTES_PER_XTS_BLOCK 16
|
#define BYTES_PER_XTS_BLOCK 16
|
||||||
|
|
||||||
// Number of ciphertext/plaintext blocks per XTS data unit
|
// Number of ciphertext/plaintext blocks per XTS data unit
|
||||||
#define BLOCKS_PER_XTS_DATA_UNIT (ENCRYPTION_DATA_UNIT_SIZE / BYTES_PER_XTS_BLOCK)
|
#define BLOCKS_PER_XTS_DATA_UNIT (ENCRYPTION_DATA_UNIT_SIZE / BYTES_PER_XTS_BLOCK)
|
||||||
|
|
||||||
|
|
||||||
// Cipher IDs
|
// Cipher IDs
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
AES,
|
AES,
|
||||||
SERPENT,
|
SERPENT,
|
||||||
TWOFISH
|
TWOFISH
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int Id; // Cipher ID
|
int Id; // Cipher ID
|
||||||
#ifdef TC_WINDOWS_BOOT
|
#ifdef TC_WINDOWS_BOOT
|
||||||
char *Name; // Name
|
char *Name; // Name
|
||||||
#else
|
#else
|
||||||
wchar_t *Name; // Name
|
wchar_t *Name; // Name
|
||||||
#endif
|
#endif
|
||||||
int BlockSize; // Block size (bytes)
|
int BlockSize; // Block size (bytes)
|
||||||
int KeySize; // Key size (bytes)
|
int KeySize; // Key size (bytes)
|
||||||
int KeyScheduleSize; // Scheduled key size (bytes)
|
int KeyScheduleSize; // Scheduled key size (bytes)
|
||||||
} Cipher;
|
} Cipher;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int Ciphers[4]; // Null terminated array of ciphers used by encryption algorithm
|
int Ciphers[4]; // Null terminated array of ciphers used by encryption algorithm
|
||||||
int Modes[LAST_MODE_OF_OPERATION + 1]; // Null terminated array of modes of operation
|
int Modes[LAST_MODE_OF_OPERATION + 1]; // Null terminated array of modes of operation
|
||||||
int FormatEnabled;
|
int FormatEnabled;
|
||||||
} EncryptionAlgorithm;
|
} EncryptionAlgorithm;
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int Id; // Hash ID
|
int Id; // Hash ID
|
||||||
wchar_t *Name; // Name
|
wchar_t *Name; // Name
|
||||||
BOOL Deprecated;
|
BOOL Deprecated;
|
||||||
BOOL SystemEncryption; // Available for system encryption
|
BOOL SystemEncryption; // Available for system encryption
|
||||||
} Hash;
|
} Hash;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Maxium length of scheduled key
|
// Maxium length of scheduled key
|
||||||
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_AES)
|
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_AES)
|
||||||
# define AES_KS (sizeof(aes_encrypt_ctx) + sizeof(aes_decrypt_ctx))
|
# define AES_KS (sizeof(aes_encrypt_ctx) + sizeof(aes_decrypt_ctx))
|
||||||
#else
|
#else
|
||||||
# define AES_KS (sizeof(aes_context))
|
# define AES_KS (sizeof(aes_context))
|
||||||
#endif
|
#endif
|
||||||
#define SERPENT_KS (140 * 4)
|
#define SERPENT_KS (140 * 4)
|
||||||
|
|
||||||
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
|
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
|
||||||
|
|
||||||
# ifdef TC_WINDOWS_BOOT_AES
|
# ifdef TC_WINDOWS_BOOT_AES
|
||||||
# define MAX_EXPANDED_KEY AES_KS
|
# define MAX_EXPANDED_KEY AES_KS
|
||||||
# elif defined (TC_WINDOWS_BOOT_SERPENT)
|
# elif defined (TC_WINDOWS_BOOT_SERPENT)
|
||||||
# define MAX_EXPANDED_KEY SERPENT_KS
|
# define MAX_EXPANDED_KEY SERPENT_KS
|
||||||
# elif defined (TC_WINDOWS_BOOT_TWOFISH)
|
# elif defined (TC_WINDOWS_BOOT_TWOFISH)
|
||||||
# define MAX_EXPANDED_KEY TWOFISH_KS
|
# define MAX_EXPANDED_KEY TWOFISH_KS
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define MAX_EXPANDED_KEY (AES_KS + SERPENT_KS + TWOFISH_KS)
|
#define MAX_EXPANDED_KEY (AES_KS + SERPENT_KS + TWOFISH_KS)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define PRAND_DISK_WIPE_PASSES 3
|
# define PRAND_DISK_WIPE_PASSES 3
|
||||||
#else
|
#else
|
||||||
# define PRAND_DISK_WIPE_PASSES 256
|
# define PRAND_DISK_WIPE_PASSES 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* specific value for volume header wipe used only when drive is fully wiped. */
|
/* specific value for volume header wipe used only when drive is fully wiped. */
|
||||||
#define PRAND_HEADER_WIPE_PASSES 3
|
#define PRAND_HEADER_WIPE_PASSES 3
|
||||||
|
|
||||||
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_AES)
|
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_AES)
|
||||||
# include "Aes.h"
|
# include "Aes.h"
|
||||||
#else
|
#else
|
||||||
# include "AesSmall.h"
|
# include "AesSmall.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Aes_hw_cpu.h"
|
#include "Aes_hw_cpu.h"
|
||||||
#include "Serpent.h"
|
#include "Serpent.h"
|
||||||
#include "Twofish.h"
|
#include "Twofish.h"
|
||||||
|
|
||||||
#include "Rmd160.h"
|
#include "Rmd160.h"
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
# include "Sha2.h"
|
# include "Sha2.h"
|
||||||
# include "Whirlpool.h"
|
# include "Whirlpool.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "GfMul.h"
|
#include "GfMul.h"
|
||||||
#include "Password.h"
|
#include "Password.h"
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
typedef struct keyInfo_t
|
typedef struct keyInfo_t
|
||||||
{
|
{
|
||||||
int noIterations; /* Number of times to iterate (PKCS-5) */
|
int noIterations; /* Number of times to iterate (PKCS-5) */
|
||||||
int keyLength; /* Length of the key */
|
int keyLength; /* Length of the key */
|
||||||
uint64 dummy; /* Dummy field to ensure 16-byte alignment of this structure */
|
uint64 dummy; /* Dummy field to ensure 16-byte alignment of this structure */
|
||||||
__int8 salt[PKCS5_SALT_SIZE]; /* PKCS-5 salt */
|
__int8 salt[PKCS5_SALT_SIZE]; /* PKCS-5 salt */
|
||||||
__int8 master_keydata[MASTER_KEYDATA_SIZE]; /* Concatenated master primary and secondary key(s) (XTS mode). For LRW (deprecated/legacy), it contains the tweak key before the master key(s). For CBC (deprecated/legacy), it contains the IV seed before the master key(s). */
|
__int8 master_keydata[MASTER_KEYDATA_SIZE]; /* Concatenated master primary and secondary key(s) (XTS mode). For LRW (deprecated/legacy), it contains the tweak key before the master key(s). For CBC (deprecated/legacy), it contains the IV seed before the master key(s). */
|
||||||
CRYPTOPP_ALIGN_DATA(16) __int8 userKey[MAX_PASSWORD]; /* Password (to which keyfiles may have been applied). WITHOUT +1 for the null terminator. */
|
CRYPTOPP_ALIGN_DATA(16) __int8 userKey[MAX_PASSWORD]; /* Password (to which keyfiles may have been applied). WITHOUT +1 for the null terminator. */
|
||||||
} KEY_INFO, *PKEY_INFO;
|
} KEY_INFO, *PKEY_INFO;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct CRYPTO_INFO_t
|
typedef struct CRYPTO_INFO_t
|
||||||
{
|
{
|
||||||
int ea; /* Encryption algorithm ID */
|
int ea; /* Encryption algorithm ID */
|
||||||
int mode; /* Mode of operation (e.g., XTS) */
|
int mode; /* Mode of operation (e.g., XTS) */
|
||||||
int pkcs5; /* PRF algorithm */
|
int pkcs5; /* PRF algorithm */
|
||||||
|
|
||||||
unsigned __int8 ks[MAX_EXPANDED_KEY]; /* Primary key schedule (if it is a cascade, it conatins multiple concatenated keys) */
|
unsigned __int8 ks[MAX_EXPANDED_KEY]; /* Primary key schedule (if it is a cascade, it conatins multiple concatenated keys) */
|
||||||
unsigned __int8 ks2[MAX_EXPANDED_KEY]; /* Secondary key schedule (if cascade, multiple concatenated) for XTS mode. */
|
unsigned __int8 ks2[MAX_EXPANDED_KEY]; /* Secondary key schedule (if cascade, multiple concatenated) for XTS mode. */
|
||||||
|
|
||||||
BOOL hiddenVolume; // Indicates whether the volume is mounted/mountable as hidden volume
|
BOOL hiddenVolume; // Indicates whether the volume is mounted/mountable as hidden volume
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
uint16 HeaderVersion;
|
uint16 HeaderVersion;
|
||||||
|
|
||||||
GfCtx gf_ctx;
|
GfCtx gf_ctx;
|
||||||
|
|
||||||
unsigned __int8 master_keydata[MASTER_KEYDATA_SIZE]; /* This holds the volume header area containing concatenated master key(s) and secondary key(s) (XTS mode). For LRW (deprecated/legacy), it contains the tweak key before the master key(s). For CBC (deprecated/legacy), it contains the IV seed before the master key(s). */
|
unsigned __int8 master_keydata[MASTER_KEYDATA_SIZE]; /* This holds the volume header area containing concatenated master key(s) and secondary key(s) (XTS mode). For LRW (deprecated/legacy), it contains the tweak key before the master key(s). For CBC (deprecated/legacy), it contains the IV seed before the master key(s). */
|
||||||
unsigned __int8 k2[MASTER_KEYDATA_SIZE]; /* For XTS, this contains the secondary key (if cascade, multiple concatenated). For LRW (deprecated/legacy), it contains the tweak key. For CBC (deprecated/legacy), it contains the IV seed. */
|
unsigned __int8 k2[MASTER_KEYDATA_SIZE]; /* For XTS, this contains the secondary key (if cascade, multiple concatenated). For LRW (deprecated/legacy), it contains the tweak key. For CBC (deprecated/legacy), it contains the IV seed. */
|
||||||
unsigned __int8 salt[PKCS5_SALT_SIZE];
|
unsigned __int8 salt[PKCS5_SALT_SIZE];
|
||||||
int noIterations;
|
int noIterations;
|
||||||
BOOL bTrueCryptMode;
|
BOOL bTrueCryptMode;
|
||||||
int volumePim;
|
int volumePim;
|
||||||
|
|
||||||
uint64 volume_creation_time; // Legacy
|
uint64 volume_creation_time; // Legacy
|
||||||
uint64 header_creation_time; // Legacy
|
uint64 header_creation_time; // Legacy
|
||||||
|
|
||||||
BOOL bProtectHiddenVolume; // Indicates whether the volume contains a hidden volume to be protected against overwriting
|
BOOL bProtectHiddenVolume; // Indicates whether the volume contains a hidden volume to be protected against overwriting
|
||||||
BOOL bHiddenVolProtectionAction; // TRUE if a write operation has been denied by the driver in order to prevent the hidden volume from being overwritten (set to FALSE upon volume mount).
|
BOOL bHiddenVolProtectionAction; // TRUE if a write operation has been denied by the driver in order to prevent the hidden volume from being overwritten (set to FALSE upon volume mount).
|
||||||
|
|
||||||
uint64 volDataAreaOffset; // Absolute position, in bytes, of the first data sector of the volume.
|
uint64 volDataAreaOffset; // Absolute position, in bytes, of the first data sector of the volume.
|
||||||
|
|
||||||
uint64 hiddenVolumeSize; // Size of the hidden volume excluding the header (in bytes). Set to 0 for standard volumes.
|
uint64 hiddenVolumeSize; // Size of the hidden volume excluding the header (in bytes). Set to 0 for standard volumes.
|
||||||
uint64 hiddenVolumeOffset; // Absolute position, in bytes, of the first hidden volume data sector within the host volume (provided that there is a hidden volume within). This must be set for all hidden volumes; in case of a normal volume, this variable is only used when protecting a hidden volume within it.
|
uint64 hiddenVolumeOffset; // Absolute position, in bytes, of the first hidden volume data sector within the host volume (provided that there is a hidden volume within). This must be set for all hidden volumes; in case of a normal volume, this variable is only used when protecting a hidden volume within it.
|
||||||
uint64 hiddenVolumeProtectedSize;
|
uint64 hiddenVolumeProtectedSize;
|
||||||
|
|
||||||
BOOL bPartitionInInactiveSysEncScope; // If TRUE, the volume is a partition located on an encrypted system drive and mounted without pre-boot authentication.
|
BOOL bPartitionInInactiveSysEncScope; // If TRUE, the volume is a partition located on an encrypted system drive and mounted without pre-boot authentication.
|
||||||
|
|
||||||
UINT64_STRUCT FirstDataUnitNo; // First data unit number of the volume. This is 0 for file-hosted and non-system partition-hosted volumes. For partitions within key scope of system encryption this reflects real physical offset within the device (this is used e.g. when such a partition is mounted as a regular volume without pre-boot authentication).
|
UINT64_STRUCT FirstDataUnitNo; // First data unit number of the volume. This is 0 for file-hosted and non-system partition-hosted volumes. For partitions within key scope of system encryption this reflects real physical offset within the device (this is used e.g. when such a partition is mounted as a regular volume without pre-boot authentication).
|
||||||
|
|
||||||
uint16 RequiredProgramVersion;
|
uint16 RequiredProgramVersion;
|
||||||
BOOL LegacyVolume;
|
BOOL LegacyVolume;
|
||||||
|
|
||||||
uint32 SectorSize;
|
uint32 SectorSize;
|
||||||
|
|
||||||
#endif // !TC_WINDOWS_BOOT
|
#endif // !TC_WINDOWS_BOOT
|
||||||
|
|
||||||
UINT64_STRUCT VolumeSize;
|
UINT64_STRUCT VolumeSize;
|
||||||
|
|
||||||
UINT64_STRUCT EncryptedAreaStart;
|
UINT64_STRUCT EncryptedAreaStart;
|
||||||
UINT64_STRUCT EncryptedAreaLength;
|
UINT64_STRUCT EncryptedAreaLength;
|
||||||
|
|
||||||
uint32 HeaderFlags;
|
uint32 HeaderFlags;
|
||||||
|
|
||||||
} CRYPTO_INFO, *PCRYPTO_INFO;
|
} CRYPTO_INFO, *PCRYPTO_INFO;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#pragma pack (push)
|
#pragma pack (push)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef struct BOOT_CRYPTO_HEADER_t
|
typedef struct BOOT_CRYPTO_HEADER_t
|
||||||
{
|
{
|
||||||
__int16 ea; /* Encryption algorithm ID */
|
__int16 ea; /* Encryption algorithm ID */
|
||||||
__int16 mode; /* Mode of operation (e.g., XTS) */
|
__int16 mode; /* Mode of operation (e.g., XTS) */
|
||||||
__int16 pkcs5; /* PRF algorithm */
|
__int16 pkcs5; /* PRF algorithm */
|
||||||
|
|
||||||
} BOOT_CRYPTO_HEADER, *PBOOT_CRYPTO_HEADER;
|
} BOOT_CRYPTO_HEADER, *PBOOT_CRYPTO_HEADER;
|
||||||
|
|
||||||
#pragma pack (pop)
|
#pragma pack (pop)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PCRYPTO_INFO crypto_open (void);
|
PCRYPTO_INFO crypto_open (void);
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen);
|
void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen);
|
||||||
#endif
|
#endif
|
||||||
void crypto_close (PCRYPTO_INFO cryptoInfo);
|
void crypto_close (PCRYPTO_INFO cryptoInfo);
|
||||||
|
|
||||||
int CipherGetBlockSize (int cipher);
|
int CipherGetBlockSize (int cipher);
|
||||||
int CipherGetKeySize (int cipher);
|
int CipherGetKeySize (int cipher);
|
||||||
int CipherGetKeyScheduleSize (int cipher);
|
int CipherGetKeyScheduleSize (int cipher);
|
||||||
BOOL CipherSupportsIntraDataUnitParallelization (int cipher);
|
BOOL CipherSupportsIntraDataUnitParallelization (int cipher);
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
const wchar_t * CipherGetName (int cipher);
|
const wchar_t * CipherGetName (int cipher);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int CipherInit (int cipher, unsigned char *key, unsigned char *ks);
|
int CipherInit (int cipher, unsigned char *key, unsigned char *ks);
|
||||||
#ifndef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
|
#ifndef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
|
||||||
int EAInit (int ea, unsigned char *key, unsigned char *ks);
|
int EAInit (int ea, unsigned char *key, unsigned char *ks);
|
||||||
#else
|
#else
|
||||||
int EAInit (unsigned char *key, unsigned char *ks);
|
int EAInit (unsigned char *key, unsigned char *ks);
|
||||||
#endif
|
#endif
|
||||||
BOOL EAInitMode (PCRYPTO_INFO ci);
|
BOOL EAInitMode (PCRYPTO_INFO ci);
|
||||||
void EncipherBlock(int cipher, void *data, void *ks);
|
void EncipherBlock(int cipher, void *data, void *ks);
|
||||||
void DecipherBlock(int cipher, void *data, void *ks);
|
void DecipherBlock(int cipher, void *data, void *ks);
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount);
|
void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount);
|
||||||
void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount);
|
void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int EAGetFirst ();
|
int EAGetFirst ();
|
||||||
int EAGetCount (void);
|
int EAGetCount (void);
|
||||||
int EAGetNext (int previousEA);
|
int EAGetNext (int previousEA);
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
wchar_t * EAGetName (wchar_t *buf, int ea, int guiDisplay);
|
wchar_t * EAGetName (wchar_t *buf, int ea, int guiDisplay);
|
||||||
int EAGetByName (wchar_t *name);
|
int EAGetByName (wchar_t *name);
|
||||||
#endif
|
#endif
|
||||||
int EAGetKeySize (int ea);
|
int EAGetKeySize (int ea);
|
||||||
int EAGetFirstMode (int ea);
|
int EAGetFirstMode (int ea);
|
||||||
int EAGetNextMode (int ea, int previousModeId);
|
int EAGetNextMode (int ea, int previousModeId);
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
wchar_t * EAGetModeName (int ea, int mode, BOOL capitalLetters);
|
wchar_t * EAGetModeName (int ea, int mode, BOOL capitalLetters);
|
||||||
#endif
|
#endif
|
||||||
int EAGetKeyScheduleSize (int ea);
|
int EAGetKeyScheduleSize (int ea);
|
||||||
int EAGetLargestKey ();
|
int EAGetLargestKey ();
|
||||||
int EAGetLargestKeyForMode (int mode);
|
int EAGetLargestKeyForMode (int mode);
|
||||||
|
|
||||||
int EAGetCipherCount (int ea);
|
int EAGetCipherCount (int ea);
|
||||||
int EAGetFirstCipher (int ea);
|
int EAGetFirstCipher (int ea);
|
||||||
int EAGetLastCipher (int ea);
|
int EAGetLastCipher (int ea);
|
||||||
int EAGetNextCipher (int ea, int previousCipherId);
|
int EAGetNextCipher (int ea, int previousCipherId);
|
||||||
int EAGetPreviousCipher (int ea, int previousCipherId);
|
int EAGetPreviousCipher (int ea, int previousCipherId);
|
||||||
int EAIsFormatEnabled (int ea);
|
int EAIsFormatEnabled (int ea);
|
||||||
BOOL EAIsModeSupported (int ea, int testedMode);
|
BOOL EAIsModeSupported (int ea, int testedMode);
|
||||||
|
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
const wchar_t *HashGetName (int hash_algo_id);
|
const wchar_t *HashGetName (int hash_algo_id);
|
||||||
|
|
||||||
Hash *HashGet (int id);
|
Hash *HashGet (int id);
|
||||||
void HashGetName2 (wchar_t *buf, int hashId);
|
void HashGetName2 (wchar_t *buf, int hashId);
|
||||||
BOOL HashIsDeprecated (int hashId);
|
BOOL HashIsDeprecated (int hashId);
|
||||||
BOOL HashForSystemEncryption (int hashId);
|
BOOL HashForSystemEncryption (int hashId);
|
||||||
int GetMaxPkcs5OutSize (void);
|
int GetMaxPkcs5OutSize (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void EncryptDataUnits (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, uint32 nbrUnits, PCRYPTO_INFO ci);
|
void EncryptDataUnits (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, uint32 nbrUnits, PCRYPTO_INFO ci);
|
||||||
void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci);
|
void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci);
|
||||||
void DecryptDataUnits (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, uint32 nbrUnits, PCRYPTO_INFO ci);
|
void DecryptDataUnits (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, uint32 nbrUnits, PCRYPTO_INFO ci);
|
||||||
void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci);
|
void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci);
|
||||||
void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo);
|
void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo);
|
||||||
void DecryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo);
|
void DecryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo);
|
||||||
|
|
||||||
BOOL IsAesHwCpuSupported ();
|
BOOL IsAesHwCpuSupported ();
|
||||||
void EnableHwEncryption (BOOL enable);
|
void EnableHwEncryption (BOOL enable);
|
||||||
BOOL IsHwEncryptionEnabled ();
|
BOOL IsHwEncryptionEnabled ();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CRYPTO_H */
|
#endif /* CRYPTO_H */
|
||||||
|
|||||||
+87
-87
@@ -1,88 +1,88 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../Common/Dictionary.h"
|
#include "../Common/Dictionary.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static map <string, void *> StringKeyMap;
|
static map <string, void *> StringKeyMap;
|
||||||
static map <int, void *> IntKeyMap;
|
static map <int, void *> IntKeyMap;
|
||||||
|
|
||||||
static void *DataPool = NULL;
|
static void *DataPool = NULL;
|
||||||
static size_t DataPoolSize = 0;
|
static size_t DataPoolSize = 0;
|
||||||
|
|
||||||
|
|
||||||
void AddDictionaryEntry (char *key, int intKey, void *value)
|
void AddDictionaryEntry (char *key, int intKey, void *value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (key)
|
if (key)
|
||||||
StringKeyMap[key] = value;
|
StringKeyMap[key] = value;
|
||||||
|
|
||||||
if (intKey != 0)
|
if (intKey != 0)
|
||||||
IntKeyMap[intKey] = value;
|
IntKeyMap[intKey] = value;
|
||||||
}
|
}
|
||||||
catch (exception&) {}
|
catch (exception&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *GetDictionaryValue (const char *key)
|
void *GetDictionaryValue (const char *key)
|
||||||
{
|
{
|
||||||
map <string, void *>::const_iterator i = StringKeyMap.find (key);
|
map <string, void *>::const_iterator i = StringKeyMap.find (key);
|
||||||
|
|
||||||
if (i == StringKeyMap.end())
|
if (i == StringKeyMap.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *GetDictionaryValueByInt (int intKey)
|
void *GetDictionaryValueByInt (int intKey)
|
||||||
{
|
{
|
||||||
map <int, void *>::const_iterator i = IntKeyMap.find (intKey);
|
map <int, void *>::const_iterator i = IntKeyMap.find (intKey);
|
||||||
|
|
||||||
if (i == IntKeyMap.end())
|
if (i == IntKeyMap.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *AddPoolData (void *data, size_t dataSize)
|
void *AddPoolData (void *data, size_t dataSize)
|
||||||
{
|
{
|
||||||
if (DataPoolSize + dataSize > DATA_POOL_CAPACITY) return NULL;
|
if (DataPoolSize + dataSize > DATA_POOL_CAPACITY) return NULL;
|
||||||
|
|
||||||
if (DataPool == NULL)
|
if (DataPool == NULL)
|
||||||
{
|
{
|
||||||
DataPool = malloc (DATA_POOL_CAPACITY);
|
DataPool = malloc (DATA_POOL_CAPACITY);
|
||||||
if (DataPool == NULL) return NULL;
|
if (DataPool == NULL) return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy ((BYTE *)DataPool + DataPoolSize, data, dataSize);
|
memcpy ((BYTE *)DataPool + DataPoolSize, data, dataSize);
|
||||||
|
|
||||||
// Ensure 32-bit alignment for next entries
|
// Ensure 32-bit alignment for next entries
|
||||||
dataSize = (dataSize + 3) & (~(size_t)3);
|
dataSize = (dataSize + 3) & (~(size_t)3);
|
||||||
|
|
||||||
DataPoolSize += dataSize;
|
DataPoolSize += dataSize;
|
||||||
return (BYTE *)DataPool + DataPoolSize - dataSize;
|
return (BYTE *)DataPool + DataPoolSize - dataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClearDictionaryPool ()
|
void ClearDictionaryPool ()
|
||||||
{
|
{
|
||||||
DataPoolSize = 0;
|
DataPoolSize = 0;
|
||||||
StringKeyMap.clear();
|
StringKeyMap.clear();
|
||||||
IntKeyMap.clear();
|
IntKeyMap.clear();
|
||||||
}
|
}
|
||||||
+34
-34
@@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DICTIONARY_H
|
#ifndef DICTIONARY_H
|
||||||
#define DICTIONARY_H
|
#define DICTIONARY_H
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DATA_POOL_CAPACITY 1000000
|
#define DATA_POOL_CAPACITY 1000000
|
||||||
|
|
||||||
void AddDictionaryEntry (char *key, int intKey, void *value);
|
void AddDictionaryEntry (char *key, int intKey, void *value);
|
||||||
void *GetDictionaryValue (const char *key);
|
void *GetDictionaryValue (const char *key);
|
||||||
void *GetDictionaryValueByInt (int intKey);
|
void *GetDictionaryValueByInt (int intKey);
|
||||||
void *AddPoolData (void *data, size_t dataSize);
|
void *AddPoolData (void *data, size_t dataSize);
|
||||||
void ClearDictionaryPool ();
|
void ClearDictionaryPool ();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+11890
-11890
File diff suppressed because it is too large
Load Diff
+593
-593
File diff suppressed because it is too large
Load Diff
+511
-511
File diff suppressed because it is too large
Load Diff
@@ -1,42 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_ENCRYPTION_THREAD_POOL
|
#ifndef TC_HEADER_ENCRYPTION_THREAD_POOL
|
||||||
#define TC_HEADER_ENCRYPTION_THREAD_POOL
|
#define TC_HEADER_ENCRYPTION_THREAD_POOL
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
EncryptDataUnitsWork,
|
EncryptDataUnitsWork,
|
||||||
DecryptDataUnitsWork,
|
DecryptDataUnitsWork,
|
||||||
DeriveKeyWork
|
DeriveKeyWork
|
||||||
} EncryptionThreadPoolWorkType;
|
} EncryptionThreadPoolWorkType;
|
||||||
|
|
||||||
void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, char *derivedKey);
|
void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, char *derivedKey);
|
||||||
void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo);
|
void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo);
|
||||||
BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount);
|
BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount);
|
||||||
void EncryptionThreadPoolStop ();
|
void EncryptionThreadPoolStop ();
|
||||||
size_t GetEncryptionThreadCount ();
|
size_t GetEncryptionThreadCount ();
|
||||||
size_t GetMaxEncryptionThreadCount ();
|
size_t GetMaxEncryptionThreadCount ();
|
||||||
BOOL IsEncryptionThreadPoolRunning ();
|
BOOL IsEncryptionThreadPoolRunning ();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TC_HEADER_ENCRYPTION_THREAD_POOL
|
#endif // TC_HEADER_ENCRYPTION_THREAD_POOL
|
||||||
|
|||||||
+59
-59
@@ -1,59 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
#include "Common/Endian.h"
|
#include "Common/Endian.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned __int16 MirrorBytes16 (unsigned __int16 x)
|
unsigned __int16 MirrorBytes16 (unsigned __int16 x)
|
||||||
{
|
{
|
||||||
return (x << 8) | (x >> 8);
|
return (x << 8) | (x >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned __int32 MirrorBytes32 (unsigned __int32 x)
|
unsigned __int32 MirrorBytes32 (unsigned __int32 x)
|
||||||
{
|
{
|
||||||
unsigned __int32 n = (unsigned __int8) x;
|
unsigned __int32 n = (unsigned __int8) x;
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 8);
|
n <<= 8; n |= (unsigned __int8) (x >> 8);
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 16);
|
n <<= 8; n |= (unsigned __int8) (x >> 16);
|
||||||
return (n << 8) | (unsigned __int8) (x >> 24);
|
return (n << 8) | (unsigned __int8) (x >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TC_NO_COMPILER_INT64
|
#ifndef TC_NO_COMPILER_INT64
|
||||||
uint64 MirrorBytes64 (uint64 x)
|
uint64 MirrorBytes64 (uint64 x)
|
||||||
{
|
{
|
||||||
uint64 n = (unsigned __int8) x;
|
uint64 n = (unsigned __int8) x;
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 8);
|
n <<= 8; n |= (unsigned __int8) (x >> 8);
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 16);
|
n <<= 8; n |= (unsigned __int8) (x >> 16);
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 24);
|
n <<= 8; n |= (unsigned __int8) (x >> 24);
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 32);
|
n <<= 8; n |= (unsigned __int8) (x >> 32);
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 40);
|
n <<= 8; n |= (unsigned __int8) (x >> 40);
|
||||||
n <<= 8; n |= (unsigned __int8) (x >> 48);
|
n <<= 8; n |= (unsigned __int8) (x >> 48);
|
||||||
return (n << 8) | (unsigned __int8) (x >> 56);
|
return (n << 8) | (unsigned __int8) (x >> 56);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
LongReverse (unsigned __int32 *buffer, unsigned byteCount)
|
LongReverse (unsigned __int32 *buffer, unsigned byteCount)
|
||||||
{
|
{
|
||||||
unsigned __int32 value;
|
unsigned __int32 value;
|
||||||
|
|
||||||
byteCount /= sizeof (unsigned __int32);
|
byteCount /= sizeof (unsigned __int32);
|
||||||
while (byteCount--)
|
while (byteCount--)
|
||||||
{
|
{
|
||||||
value = *buffer;
|
value = *buffer;
|
||||||
value = ((value & 0xFF00FF00L) >> 8) | \
|
value = ((value & 0xFF00FF00L) >> 8) | \
|
||||||
((value & 0x00FF00FFL) << 8);
|
((value & 0x00FF00FFL) << 8);
|
||||||
*buffer++ = (value << 16) | (value >> 16);
|
*buffer++ = (value << 16) | (value >> 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+149
-149
@@ -1,149 +1,149 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#ifndef TC_ENDIAN_H
|
#ifndef TC_ENDIAN_H
|
||||||
#define TC_ENDIAN_H
|
#define TC_ENDIAN_H
|
||||||
|
|
||||||
#include "Common/Tcdefs.h"
|
#include "Common/Tcdefs.h"
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
# ifndef LITTLE_ENDIAN
|
# ifndef LITTLE_ENDIAN
|
||||||
# define LITTLE_ENDIAN 1234
|
# define LITTLE_ENDIAN 1234
|
||||||
# endif
|
# endif
|
||||||
# ifndef BYTE_ORDER
|
# ifndef BYTE_ORDER
|
||||||
# define BYTE_ORDER LITTLE_ENDIAN
|
# define BYTE_ORDER LITTLE_ENDIAN
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#elif !defined(BYTE_ORDER)
|
#elif !defined(BYTE_ORDER)
|
||||||
|
|
||||||
# ifdef TC_MACOSX
|
# ifdef TC_MACOSX
|
||||||
# include <machine/endian.h>
|
# include <machine/endian.h>
|
||||||
# elif defined (TC_BSD)
|
# elif defined (TC_BSD)
|
||||||
# include <sys/endian.h>
|
# include <sys/endian.h>
|
||||||
# elif defined (TC_SOLARIS)
|
# elif defined (TC_SOLARIS)
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# define LITTLE_ENDIAN 1234
|
# define LITTLE_ENDIAN 1234
|
||||||
# define BIG_ENDIAN 4321
|
# define BIG_ENDIAN 4321
|
||||||
# ifdef _BIG_ENDIAN
|
# ifdef _BIG_ENDIAN
|
||||||
# define BYTE_ORDER BIG_ENDIAN
|
# define BYTE_ORDER BIG_ENDIAN
|
||||||
# else
|
# else
|
||||||
# define BYTE_ORDER LITTLE_ENDIAN
|
# define BYTE_ORDER LITTLE_ENDIAN
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# include <endian.h>
|
# include <endian.h>
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef BYTE_ORDER
|
# ifndef BYTE_ORDER
|
||||||
# ifndef __BYTE_ORDER
|
# ifndef __BYTE_ORDER
|
||||||
# error Byte order cannot be determined (BYTE_ORDER undefined)
|
# error Byte order cannot be determined (BYTE_ORDER undefined)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define BYTE_ORDER __BYTE_ORDER
|
# define BYTE_ORDER __BYTE_ORDER
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef LITTLE_ENDIAN
|
# ifndef LITTLE_ENDIAN
|
||||||
# define LITTLE_ENDIAN __LITTLE_ENDIAN
|
# define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef BIG_ENDIAN
|
# ifndef BIG_ENDIAN
|
||||||
# define BIG_ENDIAN __BIG_ENDIAN
|
# define BIG_ENDIAN __BIG_ENDIAN
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif // !BYTE_ORDER
|
#endif // !BYTE_ORDER
|
||||||
|
|
||||||
/* Macros to read and write 16, 32, and 64-bit quantities in a portable manner.
|
/* Macros to read and write 16, 32, and 64-bit quantities in a portable manner.
|
||||||
These functions are implemented as macros rather than true functions as
|
These functions are implemented as macros rather than true functions as
|
||||||
the need to adjust the memory pointers makes them somewhat painful to call
|
the need to adjust the memory pointers makes them somewhat painful to call
|
||||||
in user code */
|
in user code */
|
||||||
|
|
||||||
#define mputInt64(memPtr,data) \
|
#define mputInt64(memPtr,data) \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 56 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 56 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 48 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 48 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 40 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 40 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 32 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 32 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 24 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 24 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 16 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 16 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
|
*memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
|
||||||
|
|
||||||
#define mputLong(memPtr,data) \
|
#define mputLong(memPtr,data) \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 24 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 24 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 16 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 16 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
|
*memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
|
||||||
|
|
||||||
#define mputWord(memPtr,data) \
|
#define mputWord(memPtr,data) \
|
||||||
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
|
*memPtr++ = ( unsigned char ) ( ( ( data ) >> 8 ) & 0xFF ), \
|
||||||
*memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
|
*memPtr++ = ( unsigned char ) ( ( data ) & 0xFF )
|
||||||
|
|
||||||
#define mputByte(memPtr,data) \
|
#define mputByte(memPtr,data) \
|
||||||
*memPtr++ = ( unsigned char ) data
|
*memPtr++ = ( unsigned char ) data
|
||||||
|
|
||||||
#define mputBytes(memPtr,data,len) \
|
#define mputBytes(memPtr,data,len) \
|
||||||
memcpy (memPtr,data,len); \
|
memcpy (memPtr,data,len); \
|
||||||
memPtr += len;
|
memPtr += len;
|
||||||
|
|
||||||
#define mgetInt64(memPtr) \
|
#define mgetInt64(memPtr) \
|
||||||
( memPtr += 8, ( ( unsigned __int64 ) memPtr[ -8 ] << 56 ) | ( ( unsigned __int64 ) memPtr[ -7 ] << 48 ) | \
|
( memPtr += 8, ( ( unsigned __int64 ) memPtr[ -8 ] << 56 ) | ( ( unsigned __int64 ) memPtr[ -7 ] << 48 ) | \
|
||||||
( ( unsigned __int64 ) memPtr[ -6 ] << 40 ) | ( ( unsigned __int64 ) memPtr[ -5 ] << 32 ) | \
|
( ( unsigned __int64 ) memPtr[ -6 ] << 40 ) | ( ( unsigned __int64 ) memPtr[ -5 ] << 32 ) | \
|
||||||
( ( unsigned __int64 ) memPtr[ -4 ] << 24 ) | ( ( unsigned __int64 ) memPtr[ -3 ] << 16 ) | \
|
( ( unsigned __int64 ) memPtr[ -4 ] << 24 ) | ( ( unsigned __int64 ) memPtr[ -3 ] << 16 ) | \
|
||||||
( ( unsigned __int64 ) memPtr[ -2 ] << 8 ) | ( unsigned __int64 ) memPtr[ -1 ] )
|
( ( unsigned __int64 ) memPtr[ -2 ] << 8 ) | ( unsigned __int64 ) memPtr[ -1 ] )
|
||||||
|
|
||||||
#define mgetLong(memPtr) \
|
#define mgetLong(memPtr) \
|
||||||
( memPtr += 4, ( ( unsigned __int32 ) memPtr[ -4 ] << 24 ) | ( ( unsigned __int32 ) memPtr[ -3 ] << 16 ) | \
|
( memPtr += 4, ( ( unsigned __int32 ) memPtr[ -4 ] << 24 ) | ( ( unsigned __int32 ) memPtr[ -3 ] << 16 ) | \
|
||||||
( ( unsigned __int32 ) memPtr[ -2 ] << 8 ) | ( unsigned __int32 ) memPtr[ -1 ] )
|
( ( unsigned __int32 ) memPtr[ -2 ] << 8 ) | ( unsigned __int32 ) memPtr[ -1 ] )
|
||||||
|
|
||||||
#define mgetWord(memPtr) \
|
#define mgetWord(memPtr) \
|
||||||
( memPtr += 2, ((( unsigned short ) memPtr[ -2 ] << 8 ) | ( ( unsigned short ) memPtr[ -1 ] )) )
|
( memPtr += 2, ((( unsigned short ) memPtr[ -2 ] << 8 ) | ( ( unsigned short ) memPtr[ -1 ] )) )
|
||||||
|
|
||||||
#define mgetByte(memPtr) \
|
#define mgetByte(memPtr) \
|
||||||
( ( unsigned char ) *memPtr++ )
|
( ( unsigned char ) *memPtr++ )
|
||||||
|
|
||||||
#if BYTE_ORDER == BIG_ENDIAN
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
# define LE16(x) MirrorBytes16(x)
|
# define LE16(x) MirrorBytes16(x)
|
||||||
# define LE32(x) MirrorBytes32(x)
|
# define LE32(x) MirrorBytes32(x)
|
||||||
# define LE64(x) MirrorBytes64(x)
|
# define LE64(x) MirrorBytes64(x)
|
||||||
#else
|
#else
|
||||||
# define LE16(x) (x)
|
# define LE16(x) (x)
|
||||||
# define LE32(x) (x)
|
# define LE32(x) (x)
|
||||||
# define LE64(x) (x)
|
# define LE64(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||||
# define BE16(x) MirrorBytes16(x)
|
# define BE16(x) MirrorBytes16(x)
|
||||||
# define BE32(x) MirrorBytes32(x)
|
# define BE32(x) MirrorBytes32(x)
|
||||||
# define BE64(x) MirrorBytes64(x)
|
# define BE64(x) MirrorBytes64(x)
|
||||||
#else
|
#else
|
||||||
# define BE16(x) (x)
|
# define BE16(x) (x)
|
||||||
# define BE32(x) (x)
|
# define BE32(x) (x)
|
||||||
# define BE64(x) (x)
|
# define BE64(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned __int16 MirrorBytes16 (unsigned __int16 x);
|
unsigned __int16 MirrorBytes16 (unsigned __int16 x);
|
||||||
unsigned __int32 MirrorBytes32 (unsigned __int32 x);
|
unsigned __int32 MirrorBytes32 (unsigned __int32 x);
|
||||||
#ifndef TC_NO_COMPILER_INT64
|
#ifndef TC_NO_COMPILER_INT64
|
||||||
uint64 MirrorBytes64 (uint64 x);
|
uint64 MirrorBytes64 (uint64 x);
|
||||||
#endif
|
#endif
|
||||||
void LongReverse ( unsigned __int32 *buffer , unsigned byteCount );
|
void LongReverse ( unsigned __int32 *buffer , unsigned byteCount );
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* TC_ENDIAN_H */
|
#endif /* TC_ENDIAN_H */
|
||||||
|
|||||||
+123
-123
@@ -1,123 +1,123 @@
|
|||||||
/*
|
/*
|
||||||
Derived from source code of TrueCrypt 7.1a, which is
|
Derived from source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
||||||
by the TrueCrypt License 3.0.
|
by the TrueCrypt License 3.0.
|
||||||
|
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages.
|
code distribution packages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TC_HEADER_Common_Exception
|
#ifndef TC_HEADER_Common_Exception
|
||||||
#define TC_HEADER_Common_Exception
|
#define TC_HEADER_Common_Exception
|
||||||
|
|
||||||
#include "Platform/PlatformBase.h"
|
#include "Platform/PlatformBase.h"
|
||||||
#include "Dlgcode.h"
|
#include "Dlgcode.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
|
||||||
namespace VeraCrypt
|
namespace VeraCrypt
|
||||||
{
|
{
|
||||||
struct Exception
|
struct Exception
|
||||||
{
|
{
|
||||||
virtual void Show (HWND parent) const = 0;
|
virtual void Show (HWND parent) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SystemException : public Exception
|
struct SystemException : public Exception
|
||||||
{
|
{
|
||||||
SystemException (const char *srcPos) : ErrorCode (GetLastError()), SrcPos (srcPos) { }
|
SystemException (const char *srcPos) : ErrorCode (GetLastError()), SrcPos (srcPos) { }
|
||||||
|
|
||||||
void Show (HWND parent) const
|
void Show (HWND parent) const
|
||||||
{
|
{
|
||||||
SetLastError (ErrorCode);
|
SetLastError (ErrorCode);
|
||||||
handleWin32Error (parent, SrcPos);
|
handleWin32Error (parent, SrcPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ErrorCode;
|
DWORD ErrorCode;
|
||||||
const char *SrcPos;
|
const char *SrcPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ErrorException : public Exception
|
struct ErrorException : public Exception
|
||||||
{
|
{
|
||||||
ErrorException (char *langId, const char *srcPos) : SrcPos (srcPos), ErrLangId (langId) { }
|
ErrorException (char *langId, const char *srcPos) : SrcPos (srcPos), ErrLangId (langId) { }
|
||||||
ErrorException (const wstring &errMsg, const char *srcPos) : SrcPos (srcPos), ErrLangId(NULL), ErrMsg (errMsg) { }
|
ErrorException (const wstring &errMsg, const char *srcPos) : SrcPos (srcPos), ErrLangId(NULL), ErrMsg (errMsg) { }
|
||||||
|
|
||||||
void Show (HWND parent) const
|
void Show (HWND parent) const
|
||||||
{
|
{
|
||||||
if (ErrMsg.empty())
|
if (ErrMsg.empty())
|
||||||
::ErrorDirect (AppendSrcPos (GetString (ErrLangId? ErrLangId : ""), SrcPos).c_str (), parent);
|
::ErrorDirect (AppendSrcPos (GetString (ErrLangId? ErrLangId : ""), SrcPos).c_str (), parent);
|
||||||
else
|
else
|
||||||
::ErrorDirect (AppendSrcPos (ErrMsg.c_str(), SrcPos).c_str (), parent);
|
::ErrorDirect (AppendSrcPos (ErrMsg.c_str(), SrcPos).c_str (), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SrcPos;
|
const char *SrcPos;
|
||||||
char *ErrLangId;
|
char *ErrLangId;
|
||||||
wstring ErrMsg;
|
wstring ErrMsg;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParameterIncorrect : public Exception
|
struct ParameterIncorrect : public Exception
|
||||||
{
|
{
|
||||||
ParameterIncorrect (const char *srcPos) : SrcPos (srcPos) { }
|
ParameterIncorrect (const char *srcPos) : SrcPos (srcPos) { }
|
||||||
|
|
||||||
void Show (HWND parent) const
|
void Show (HWND parent) const
|
||||||
{
|
{
|
||||||
string msgBody = "Parameter incorrect.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + ")";
|
string msgBody = "Parameter incorrect.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + ")";
|
||||||
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SrcPos;
|
const char *SrcPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RandInitFailed : public Exception
|
struct RandInitFailed : public Exception
|
||||||
{
|
{
|
||||||
RandInitFailed (const char *srcPos, DWORD dwLastError) : SrcPos (srcPos), LastError (dwLastError) { }
|
RandInitFailed (const char *srcPos, DWORD dwLastError) : SrcPos (srcPos), LastError (dwLastError) { }
|
||||||
|
|
||||||
void Show (HWND parent) const
|
void Show (HWND parent) const
|
||||||
{
|
{
|
||||||
char szErrCode[16];
|
char szErrCode[16];
|
||||||
StringCchPrintfA (szErrCode, ARRAYSIZE(szErrCode), "0x%.8X", LastError);
|
StringCchPrintfA (szErrCode, ARRAYSIZE(szErrCode), "0x%.8X", LastError);
|
||||||
string msgBody = "The Random Generator initialization failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
string msgBody = "The Random Generator initialization failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
||||||
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SrcPos;
|
const char *SrcPos;
|
||||||
DWORD LastError;
|
DWORD LastError;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CryptoApiFailed : public Exception
|
struct CryptoApiFailed : public Exception
|
||||||
{
|
{
|
||||||
CryptoApiFailed (const char *srcPos, DWORD dwLastError) : SrcPos (srcPos), LastError (dwLastError) { }
|
CryptoApiFailed (const char *srcPos, DWORD dwLastError) : SrcPos (srcPos), LastError (dwLastError) { }
|
||||||
|
|
||||||
void Show (HWND parent) const
|
void Show (HWND parent) const
|
||||||
{
|
{
|
||||||
char szErrCode[16];
|
char szErrCode[16];
|
||||||
StringCchPrintfA (szErrCode, ARRAYSIZE(szErrCode), "0x%.8X", LastError);
|
StringCchPrintfA (szErrCode, ARRAYSIZE(szErrCode), "0x%.8X", LastError);
|
||||||
string msgBody = "Windows Crypto API failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
string msgBody = "Windows Crypto API failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
||||||
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SrcPos;
|
const char *SrcPos;
|
||||||
DWORD LastError;
|
DWORD LastError;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TimeOut : public Exception
|
struct TimeOut : public Exception
|
||||||
{
|
{
|
||||||
TimeOut (const char *srcPos) : SrcPos (srcPos) { }
|
TimeOut (const char *srcPos) : SrcPos (srcPos) { }
|
||||||
void Show (HWND parent) const { ErrorDirect (AppendSrcPos (L"Timeout", SrcPos).c_str (), parent); }
|
void Show (HWND parent) const { ErrorDirect (AppendSrcPos (L"Timeout", SrcPos).c_str (), parent); }
|
||||||
|
|
||||||
const char *SrcPos;
|
const char *SrcPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UserAbort : public Exception
|
struct UserAbort : public Exception
|
||||||
{
|
{
|
||||||
UserAbort (const char *srcPos) { }
|
UserAbort (const char *srcPos) { }
|
||||||
void Show (HWND parent) const { }
|
void Show (HWND parent) const { }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define throw_sys_if(condition) do { if (condition) throw SystemException( SRC_POS ); } while (false)
|
#define throw_sys_if(condition) do { if (condition) throw SystemException( SRC_POS ); } while (false)
|
||||||
|
|
||||||
|
|
||||||
#endif // TC_HEADER_Common_Exception
|
#endif // TC_HEADER_Common_Exception
|
||||||
|
|||||||
+449
-449
@@ -1,449 +1,449 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
|
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "Common/Endian.h"
|
#include "Common/Endian.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "Fat.h"
|
#include "Fat.h"
|
||||||
#include "Progress.h"
|
#include "Progress.h"
|
||||||
#include "Random.h"
|
#include "Random.h"
|
||||||
#include "Volumes.h"
|
#include "Volumes.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
GetFatParams (fatparams * ft)
|
GetFatParams (fatparams * ft)
|
||||||
{
|
{
|
||||||
uint64 volumeSize = (uint64) ft->num_sectors * ft->sector_size;
|
uint64 volumeSize = (uint64) ft->num_sectors * ft->sector_size;
|
||||||
unsigned int fatsecs;
|
unsigned int fatsecs;
|
||||||
|
|
||||||
if(ft->cluster_size == 0) // 'Default' cluster size
|
if(ft->cluster_size == 0) // 'Default' cluster size
|
||||||
{
|
{
|
||||||
uint32 clusterSize;
|
uint32 clusterSize;
|
||||||
|
|
||||||
// Determine optimal cluster size to minimize FAT size (mounting delay), maximize number of files, keep 4 KB alignment, etc.
|
// Determine optimal cluster size to minimize FAT size (mounting delay), maximize number of files, keep 4 KB alignment, etc.
|
||||||
if (volumeSize >= 2 * BYTES_PER_TB)
|
if (volumeSize >= 2 * BYTES_PER_TB)
|
||||||
clusterSize = 256 * BYTES_PER_KB;
|
clusterSize = 256 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 512 * BYTES_PER_GB)
|
else if (volumeSize >= 512 * BYTES_PER_GB)
|
||||||
clusterSize = 128 * BYTES_PER_KB;
|
clusterSize = 128 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 128 * BYTES_PER_GB)
|
else if (volumeSize >= 128 * BYTES_PER_GB)
|
||||||
clusterSize = 64 * BYTES_PER_KB;
|
clusterSize = 64 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 64 * BYTES_PER_GB)
|
else if (volumeSize >= 64 * BYTES_PER_GB)
|
||||||
clusterSize = 32 * BYTES_PER_KB;
|
clusterSize = 32 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 32 * BYTES_PER_GB)
|
else if (volumeSize >= 32 * BYTES_PER_GB)
|
||||||
clusterSize = 16 * BYTES_PER_KB;
|
clusterSize = 16 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 16 * BYTES_PER_GB)
|
else if (volumeSize >= 16 * BYTES_PER_GB)
|
||||||
clusterSize = 8 * BYTES_PER_KB;
|
clusterSize = 8 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 512 * BYTES_PER_MB)
|
else if (volumeSize >= 512 * BYTES_PER_MB)
|
||||||
clusterSize = 4 * BYTES_PER_KB;
|
clusterSize = 4 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 256 * BYTES_PER_MB)
|
else if (volumeSize >= 256 * BYTES_PER_MB)
|
||||||
clusterSize = 2 * BYTES_PER_KB;
|
clusterSize = 2 * BYTES_PER_KB;
|
||||||
else if (volumeSize >= 1 * BYTES_PER_MB)
|
else if (volumeSize >= 1 * BYTES_PER_MB)
|
||||||
clusterSize = 1 * BYTES_PER_KB;
|
clusterSize = 1 * BYTES_PER_KB;
|
||||||
else
|
else
|
||||||
clusterSize = 512;
|
clusterSize = 512;
|
||||||
|
|
||||||
ft->cluster_size = clusterSize / ft->sector_size;
|
ft->cluster_size = clusterSize / ft->sector_size;
|
||||||
|
|
||||||
if (ft->cluster_size == 0)
|
if (ft->cluster_size == 0)
|
||||||
ft->cluster_size = 1;
|
ft->cluster_size = 1;
|
||||||
|
|
||||||
if (((unsigned __int64) ft->cluster_size * ft->sector_size) > TC_MAX_FAT_CLUSTER_SIZE)
|
if (((unsigned __int64) ft->cluster_size * ft->sector_size) > TC_MAX_FAT_CLUSTER_SIZE)
|
||||||
ft->cluster_size = TC_MAX_FAT_CLUSTER_SIZE / ft->sector_size;
|
ft->cluster_size = TC_MAX_FAT_CLUSTER_SIZE / ft->sector_size;
|
||||||
|
|
||||||
if (ft->cluster_size > 128)
|
if (ft->cluster_size > 128)
|
||||||
ft->cluster_size = 128;
|
ft->cluster_size = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (volumeSize <= TC_MAX_FAT_CLUSTER_SIZE * 4)
|
if (volumeSize <= TC_MAX_FAT_CLUSTER_SIZE * 4)
|
||||||
ft->cluster_size = 1;
|
ft->cluster_size = 1;
|
||||||
|
|
||||||
// Geometry always set to SECTORS/1/1
|
// Geometry always set to SECTORS/1/1
|
||||||
ft->secs_track = 1;
|
ft->secs_track = 1;
|
||||||
ft->heads = 1;
|
ft->heads = 1;
|
||||||
|
|
||||||
ft->dir_entries = 512;
|
ft->dir_entries = 512;
|
||||||
ft->fats = 2;
|
ft->fats = 2;
|
||||||
ft->media = 0xf8;
|
ft->media = 0xf8;
|
||||||
ft->hidden = 0;
|
ft->hidden = 0;
|
||||||
|
|
||||||
ft->size_root_dir = ft->dir_entries * 32;
|
ft->size_root_dir = ft->dir_entries * 32;
|
||||||
|
|
||||||
// FAT12
|
// FAT12
|
||||||
ft->size_fat = 12;
|
ft->size_fat = 12;
|
||||||
ft->reserved = 2;
|
ft->reserved = 2;
|
||||||
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
|
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
|
||||||
ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / ((unsigned __int64) ft->cluster_size * ft->sector_size));
|
ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / ((unsigned __int64) ft->cluster_size * ft->sector_size));
|
||||||
ft->fat_length = (((ft->cluster_count * 3 + 1) >> 1) + ft->sector_size - 1) / ft->sector_size;
|
ft->fat_length = (((ft->cluster_count * 3 + 1) >> 1) + ft->sector_size - 1) / ft->sector_size;
|
||||||
|
|
||||||
if (ft->cluster_count >= 4085) // FAT16
|
if (ft->cluster_count >= 4085) // FAT16
|
||||||
{
|
{
|
||||||
ft->size_fat = 16;
|
ft->size_fat = 16;
|
||||||
ft->reserved = 2;
|
ft->reserved = 2;
|
||||||
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
|
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
|
||||||
ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
||||||
ft->fat_length = (ft->cluster_count * 2 + ft->sector_size - 1) / ft->sector_size;
|
ft->fat_length = (ft->cluster_count * 2 + ft->sector_size - 1) / ft->sector_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ft->cluster_count >= 65525) // FAT32
|
if(ft->cluster_count >= 65525) // FAT32
|
||||||
{
|
{
|
||||||
ft->size_fat = 32;
|
ft->size_fat = 32;
|
||||||
ft->reserved = 32 - 1;
|
ft->reserved = 32 - 1;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ft->reserved++;
|
ft->reserved++;
|
||||||
|
|
||||||
fatsecs = ft->num_sectors - ft->reserved;
|
fatsecs = ft->num_sectors - ft->reserved;
|
||||||
ft->size_root_dir = ft->cluster_size * ft->sector_size;
|
ft->size_root_dir = ft->cluster_size * ft->sector_size;
|
||||||
ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
||||||
ft->fat_length = (ft->cluster_count * 4 + ft->sector_size - 1) / ft->sector_size;
|
ft->fat_length = (ft->cluster_count * 4 + ft->sector_size - 1) / ft->sector_size;
|
||||||
|
|
||||||
// Align data area on TC_MAX_VOLUME_SECTOR_SIZE
|
// Align data area on TC_MAX_VOLUME_SECTOR_SIZE
|
||||||
|
|
||||||
} while (ft->sector_size == TC_SECTOR_SIZE_LEGACY
|
} while (ft->sector_size == TC_SECTOR_SIZE_LEGACY
|
||||||
&& (ft->reserved * ft->sector_size + ft->fat_length * ft->fats * ft->sector_size) % TC_MAX_VOLUME_SECTOR_SIZE != 0);
|
&& (ft->reserved * ft->sector_size + ft->fat_length * ft->fats * ft->sector_size) % TC_MAX_VOLUME_SECTOR_SIZE != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ft->cluster_count -= ft->fat_length * ft->fats / ft->cluster_size;
|
ft->cluster_count -= ft->fat_length * ft->fats / ft->cluster_size;
|
||||||
|
|
||||||
if (ft->num_sectors >= 65536 || ft->size_fat == 32)
|
if (ft->num_sectors >= 65536 || ft->size_fat == 32)
|
||||||
{
|
{
|
||||||
ft->sectors = 0;
|
ft->sectors = 0;
|
||||||
ft->total_sect = ft->num_sectors;
|
ft->total_sect = ft->num_sectors;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ft->sectors = (uint16) ft->num_sectors;
|
ft->sectors = (uint16) ft->num_sectors;
|
||||||
ft->total_sect = 0;
|
ft->total_sect = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PutBoot (fatparams * ft, unsigned char *boot)
|
PutBoot (fatparams * ft, unsigned char *boot)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
boot[cnt++] = 0xeb; /* boot jump */
|
boot[cnt++] = 0xeb; /* boot jump */
|
||||||
boot[cnt++] = 0x3c;
|
boot[cnt++] = 0x3c;
|
||||||
boot[cnt++] = 0x90;
|
boot[cnt++] = 0x90;
|
||||||
memcpy (boot + cnt, "MSDOS5.0", 8); /* system id */
|
memcpy (boot + cnt, "MSDOS5.0", 8); /* system id */
|
||||||
cnt += 8;
|
cnt += 8;
|
||||||
*(__int16 *)(boot + cnt) = LE16(ft->sector_size); /* bytes per sector */
|
*(__int16 *)(boot + cnt) = LE16(ft->sector_size); /* bytes per sector */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
boot[cnt++] = (__int8) ft->cluster_size; /* sectors per cluster */
|
boot[cnt++] = (__int8) ft->cluster_size; /* sectors per cluster */
|
||||||
*(__int16 *)(boot + cnt) = LE16(ft->reserved); /* reserved sectors */
|
*(__int16 *)(boot + cnt) = LE16(ft->reserved); /* reserved sectors */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
boot[cnt++] = (__int8) ft->fats; /* 2 fats */
|
boot[cnt++] = (__int8) ft->fats; /* 2 fats */
|
||||||
|
|
||||||
if(ft->size_fat == 32)
|
if(ft->size_fat == 32)
|
||||||
{
|
{
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*(__int16 *)(boot + cnt) = LE16(ft->dir_entries); /* 512 root entries */
|
*(__int16 *)(boot + cnt) = LE16(ft->dir_entries); /* 512 root entries */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(__int16 *)(boot + cnt) = LE16(ft->sectors); /* # sectors */
|
*(__int16 *)(boot + cnt) = LE16(ft->sectors); /* # sectors */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
boot[cnt++] = (__int8) ft->media; /* media byte */
|
boot[cnt++] = (__int8) ft->media; /* media byte */
|
||||||
|
|
||||||
if(ft->size_fat == 32)
|
if(ft->size_fat == 32)
|
||||||
{
|
{
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*(__int16 *)(boot + cnt) = LE16((uint16) ft->fat_length); /* fat size */
|
*(__int16 *)(boot + cnt) = LE16((uint16) ft->fat_length); /* fat size */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(__int16 *)(boot + cnt) = LE16(ft->secs_track); /* # sectors per track */
|
*(__int16 *)(boot + cnt) = LE16(ft->secs_track); /* # sectors per track */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
*(__int16 *)(boot + cnt) = LE16(ft->heads); /* # heads */
|
*(__int16 *)(boot + cnt) = LE16(ft->heads); /* # heads */
|
||||||
cnt += 2;
|
cnt += 2;
|
||||||
*(__int32 *)(boot + cnt) = LE32(ft->hidden); /* # hidden sectors */
|
*(__int32 *)(boot + cnt) = LE32(ft->hidden); /* # hidden sectors */
|
||||||
cnt += 4;
|
cnt += 4;
|
||||||
*(__int32 *)(boot + cnt) = LE32(ft->total_sect); /* # huge sectors */
|
*(__int32 *)(boot + cnt) = LE32(ft->total_sect); /* # huge sectors */
|
||||||
cnt += 4;
|
cnt += 4;
|
||||||
|
|
||||||
if(ft->size_fat == 32)
|
if(ft->size_fat == 32)
|
||||||
{
|
{
|
||||||
*(__int32 *)(boot + cnt) = LE32(ft->fat_length); cnt += 4; /* fat size 32 */
|
*(__int32 *)(boot + cnt) = LE32(ft->fat_length); cnt += 4; /* fat size 32 */
|
||||||
boot[cnt++] = 0x00; /* ExtFlags */
|
boot[cnt++] = 0x00; /* ExtFlags */
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x00; /* FSVer */
|
boot[cnt++] = 0x00; /* FSVer */
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x02; /* RootClus */
|
boot[cnt++] = 0x02; /* RootClus */
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x01; /* FSInfo */
|
boot[cnt++] = 0x01; /* FSInfo */
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
boot[cnt++] = 0x06; /* BkBootSec */
|
boot[cnt++] = 0x06; /* BkBootSec */
|
||||||
boot[cnt++] = 0x00;
|
boot[cnt++] = 0x00;
|
||||||
memset(boot+cnt, 0, 12); cnt+=12; /* Reserved */
|
memset(boot+cnt, 0, 12); cnt+=12; /* Reserved */
|
||||||
}
|
}
|
||||||
|
|
||||||
boot[cnt++] = 0x00; /* drive number */ // FIXED 80 > 00
|
boot[cnt++] = 0x00; /* drive number */ // FIXED 80 > 00
|
||||||
boot[cnt++] = 0x00; /* reserved */
|
boot[cnt++] = 0x00; /* reserved */
|
||||||
boot[cnt++] = 0x29; /* boot sig */
|
boot[cnt++] = 0x29; /* boot sig */
|
||||||
|
|
||||||
memcpy (boot + cnt, ft->volume_id, 4); /* vol id */
|
memcpy (boot + cnt, ft->volume_id, 4); /* vol id */
|
||||||
cnt += 4;
|
cnt += 4;
|
||||||
|
|
||||||
memcpy (boot + cnt, ft->volume_name, 11); /* vol title */
|
memcpy (boot + cnt, ft->volume_name, 11); /* vol title */
|
||||||
cnt += 11;
|
cnt += 11;
|
||||||
|
|
||||||
switch(ft->size_fat) /* filesystem type */
|
switch(ft->size_fat) /* filesystem type */
|
||||||
{
|
{
|
||||||
case 12: memcpy (boot + cnt, "FAT12 ", 8); break;
|
case 12: memcpy (boot + cnt, "FAT12 ", 8); break;
|
||||||
case 16: memcpy (boot + cnt, "FAT16 ", 8); break;
|
case 16: memcpy (boot + cnt, "FAT16 ", 8); break;
|
||||||
case 32: memcpy (boot + cnt, "FAT32 ", 8); break;
|
case 32: memcpy (boot + cnt, "FAT32 ", 8); break;
|
||||||
}
|
}
|
||||||
cnt += 8;
|
cnt += 8;
|
||||||
|
|
||||||
memset (boot + cnt, 0, ft->size_fat==32 ? 420:448); /* boot code */
|
memset (boot + cnt, 0, ft->size_fat==32 ? 420:448); /* boot code */
|
||||||
cnt += ft->size_fat==32 ? 420:448;
|
cnt += ft->size_fat==32 ? 420:448;
|
||||||
boot[cnt++] = 0x55;
|
boot[cnt++] = 0x55;
|
||||||
boot[cnt++] = 0xaa; /* boot sig */
|
boot[cnt++] = 0xaa; /* boot sig */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FAT32 FSInfo */
|
/* FAT32 FSInfo */
|
||||||
static void PutFSInfo (unsigned char *sector, fatparams *ft)
|
static void PutFSInfo (unsigned char *sector, fatparams *ft)
|
||||||
{
|
{
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
sector[3]=0x41; /* LeadSig */
|
sector[3]=0x41; /* LeadSig */
|
||||||
sector[2]=0x61;
|
sector[2]=0x61;
|
||||||
sector[1]=0x52;
|
sector[1]=0x52;
|
||||||
sector[0]=0x52;
|
sector[0]=0x52;
|
||||||
sector[484+3]=0x61; /* StrucSig */
|
sector[484+3]=0x61; /* StrucSig */
|
||||||
sector[484+2]=0x41;
|
sector[484+2]=0x41;
|
||||||
sector[484+1]=0x72;
|
sector[484+1]=0x72;
|
||||||
sector[484+0]=0x72;
|
sector[484+0]=0x72;
|
||||||
|
|
||||||
// Free cluster count
|
// Free cluster count
|
||||||
*(uint32 *)(sector + 488) = LE32 (ft->cluster_count - ft->size_root_dir / ft->sector_size / ft->cluster_size);
|
*(uint32 *)(sector + 488) = LE32 (ft->cluster_count - ft->size_root_dir / ft->sector_size / ft->cluster_size);
|
||||||
|
|
||||||
// Next free cluster
|
// Next free cluster
|
||||||
*(uint32 *)(sector + 492) = LE32 (2);
|
*(uint32 *)(sector + 492) = LE32 (2);
|
||||||
|
|
||||||
sector[508+3]=0xaa; /* TrailSig */
|
sector[508+3]=0xaa; /* TrailSig */
|
||||||
sector[508+2]=0x55;
|
sector[508+2]=0x55;
|
||||||
sector[508+1]=0x00;
|
sector[508+1]=0x00;
|
||||||
sector[508+0]=0x00;
|
sector[508+0]=0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
|
FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
|
||||||
{
|
{
|
||||||
int write_buf_cnt = 0;
|
int write_buf_cnt = 0;
|
||||||
char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf;
|
char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf;
|
||||||
unsigned __int64 nSecNo = startSector;
|
unsigned __int64 nSecNo = startSector;
|
||||||
int x, n;
|
int x, n;
|
||||||
int retVal;
|
int retVal;
|
||||||
char temporaryKey[MASTER_KEYDATA_SIZE];
|
char temporaryKey[MASTER_KEYDATA_SIZE];
|
||||||
HWND hwndDlg = (HWND) hwndDlgPtr;
|
HWND hwndDlg = (HWND) hwndDlgPtr;
|
||||||
|
|
||||||
LARGE_INTEGER startOffset;
|
LARGE_INTEGER startOffset;
|
||||||
LARGE_INTEGER newOffset;
|
LARGE_INTEGER newOffset;
|
||||||
|
|
||||||
// Seek to start sector
|
// Seek to start sector
|
||||||
startOffset.QuadPart = startSector * ft->sector_size;
|
startOffset.QuadPart = startSector * ft->sector_size;
|
||||||
if (!SetFilePointerEx ((HANDLE) dev, startOffset, &newOffset, FILE_BEGIN)
|
if (!SetFilePointerEx ((HANDLE) dev, startOffset, &newOffset, FILE_BEGIN)
|
||||||
|| newOffset.QuadPart != startOffset.QuadPart)
|
|| newOffset.QuadPart != startOffset.QuadPart)
|
||||||
{
|
{
|
||||||
return ERR_VOL_SEEKING;
|
return ERR_VOL_SEEKING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the data area */
|
/* Write the data area */
|
||||||
|
|
||||||
write_buf = (char *)TCalloc (FormatWriteBufferSize);
|
write_buf = (char *)TCalloc (FormatWriteBufferSize);
|
||||||
if (!write_buf)
|
if (!write_buf)
|
||||||
return ERR_OUTOFMEMORY;
|
return ERR_OUTOFMEMORY;
|
||||||
|
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
|
|
||||||
if (!RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE))
|
if (!RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
PutBoot (ft, (unsigned char *) sector);
|
PutBoot (ft, (unsigned char *) sector);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* fat32 boot area */
|
/* fat32 boot area */
|
||||||
if (ft->size_fat == 32)
|
if (ft->size_fat == 32)
|
||||||
{
|
{
|
||||||
/* fsinfo */
|
/* fsinfo */
|
||||||
PutFSInfo((unsigned char *) sector, ft);
|
PutFSInfo((unsigned char *) sector, ft);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* reserved */
|
/* reserved */
|
||||||
while (nSecNo - startSector < 6)
|
while (nSecNo - startSector < 6)
|
||||||
{
|
{
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
sector[508+3]=0xaa; /* TrailSig */
|
sector[508+3]=0xaa; /* TrailSig */
|
||||||
sector[508+2]=0x55;
|
sector[508+2]=0x55;
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bootsector backup */
|
/* bootsector backup */
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
PutBoot (ft, (unsigned char *) sector);
|
PutBoot (ft, (unsigned char *) sector);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
PutFSInfo((unsigned char *) sector, ft);
|
PutFSInfo((unsigned char *) sector, ft);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reserved */
|
/* reserved */
|
||||||
while (nSecNo - startSector < (unsigned int)ft->reserved)
|
while (nSecNo - startSector < (unsigned int)ft->reserved)
|
||||||
{
|
{
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write fat */
|
/* write fat */
|
||||||
for (x = 1; x <= ft->fats; x++)
|
for (x = 1; x <= ft->fats; x++)
|
||||||
{
|
{
|
||||||
for (n = 0; n < ft->fat_length; n++)
|
for (n = 0; n < ft->fat_length; n++)
|
||||||
{
|
{
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
unsigned char fat_sig[12];
|
unsigned char fat_sig[12];
|
||||||
if (ft->size_fat == 32)
|
if (ft->size_fat == 32)
|
||||||
{
|
{
|
||||||
fat_sig[0] = (unsigned char) ft->media;
|
fat_sig[0] = (unsigned char) ft->media;
|
||||||
fat_sig[1] = fat_sig[2] = 0xff;
|
fat_sig[1] = fat_sig[2] = 0xff;
|
||||||
fat_sig[3] = 0x0f;
|
fat_sig[3] = 0x0f;
|
||||||
fat_sig[4] = fat_sig[5] = fat_sig[6] = 0xff;
|
fat_sig[4] = fat_sig[5] = fat_sig[6] = 0xff;
|
||||||
fat_sig[7] = 0x0f;
|
fat_sig[7] = 0x0f;
|
||||||
fat_sig[8] = fat_sig[9] = fat_sig[10] = 0xff;
|
fat_sig[8] = fat_sig[9] = fat_sig[10] = 0xff;
|
||||||
fat_sig[11] = 0x0f;
|
fat_sig[11] = 0x0f;
|
||||||
memcpy (sector, fat_sig, 12);
|
memcpy (sector, fat_sig, 12);
|
||||||
}
|
}
|
||||||
else if (ft->size_fat == 16)
|
else if (ft->size_fat == 16)
|
||||||
{
|
{
|
||||||
fat_sig[0] = (unsigned char) ft->media;
|
fat_sig[0] = (unsigned char) ft->media;
|
||||||
fat_sig[1] = 0xff;
|
fat_sig[1] = 0xff;
|
||||||
fat_sig[2] = 0xff;
|
fat_sig[2] = 0xff;
|
||||||
fat_sig[3] = 0xff;
|
fat_sig[3] = 0xff;
|
||||||
memcpy (sector, fat_sig, 4);
|
memcpy (sector, fat_sig, 4);
|
||||||
}
|
}
|
||||||
else if (ft->size_fat == 12)
|
else if (ft->size_fat == 12)
|
||||||
{
|
{
|
||||||
fat_sig[0] = (unsigned char) ft->media;
|
fat_sig[0] = (unsigned char) ft->media;
|
||||||
fat_sig[1] = 0xff;
|
fat_sig[1] = 0xff;
|
||||||
fat_sig[2] = 0xff;
|
fat_sig[2] = 0xff;
|
||||||
fat_sig[3] = 0x00;
|
fat_sig[3] = 0x00;
|
||||||
memcpy (sector, fat_sig, 4);
|
memcpy (sector, fat_sig, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* write rootdir */
|
/* write rootdir */
|
||||||
for (x = 0; x < ft->size_root_dir / ft->sector_size; x++)
|
for (x = 0; x < ft->size_root_dir / ft->sector_size; x++)
|
||||||
{
|
{
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill the rest of the data area with random data */
|
/* Fill the rest of the data area with random data */
|
||||||
|
|
||||||
if(!quickFormat)
|
if(!quickFormat)
|
||||||
{
|
{
|
||||||
if (!FlushFormatWriteBuffer (dev, write_buf, &write_buf_cnt, &nSecNo, cryptoInfo))
|
if (!FlushFormatWriteBuffer (dev, write_buf, &write_buf_cnt, &nSecNo, cryptoInfo))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Generate a random temporary key set to be used for "dummy" encryption that will fill
|
/* Generate a random temporary key set to be used for "dummy" encryption that will fill
|
||||||
the free disk space (data area) with random data. This is necessary for plausible
|
the free disk space (data area) with random data. This is necessary for plausible
|
||||||
deniability of hidden volumes (and also reduces the amount of predictable plaintext
|
deniability of hidden volumes (and also reduces the amount of predictable plaintext
|
||||||
within the volume). */
|
within the volume). */
|
||||||
|
|
||||||
// Temporary master key
|
// Temporary master key
|
||||||
if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
|
if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
// Temporary secondary key (XTS mode)
|
// Temporary secondary key (XTS mode)
|
||||||
if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
|
if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);
|
retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);
|
||||||
if (retVal != ERR_SUCCESS)
|
if (retVal != ERR_SUCCESS)
|
||||||
{
|
{
|
||||||
burn (temporaryKey, sizeof(temporaryKey));
|
burn (temporaryKey, sizeof(temporaryKey));
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
if (!EAInitMode (cryptoInfo))
|
if (!EAInitMode (cryptoInfo))
|
||||||
{
|
{
|
||||||
burn (temporaryKey, sizeof(temporaryKey));
|
burn (temporaryKey, sizeof(temporaryKey));
|
||||||
return ERR_MODE_INIT_FAILED;
|
return ERR_MODE_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = ft->num_sectors - ft->reserved - ft->size_root_dir / ft->sector_size - ft->fat_length * 2;
|
x = ft->num_sectors - ft->reserved - ft->size_root_dir / ft->sector_size - ft->fat_length * 2;
|
||||||
while (x--)
|
while (x--)
|
||||||
{
|
{
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
cryptoInfo) == FALSE)
|
cryptoInfo) == FALSE)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
UpdateProgressBar (nSecNo * ft->sector_size);
|
UpdateProgressBar (nSecNo * ft->sector_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UpdateProgressBar ((uint64) ft->num_sectors * ft->sector_size);
|
UpdateProgressBar ((uint64) ft->num_sectors * ft->sector_size);
|
||||||
|
|
||||||
if (!FlushFormatWriteBuffer (dev, write_buf, &write_buf_cnt, &nSecNo, cryptoInfo))
|
if (!FlushFormatWriteBuffer (dev, write_buf, &write_buf_cnt, &nSecNo, cryptoInfo))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
TCfree (write_buf);
|
TCfree (write_buf);
|
||||||
burn (temporaryKey, sizeof(temporaryKey));
|
burn (temporaryKey, sizeof(temporaryKey));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
TCfree (write_buf);
|
TCfree (write_buf);
|
||||||
burn (temporaryKey, sizeof(temporaryKey));
|
burn (temporaryKey, sizeof(temporaryKey));
|
||||||
return ERR_OS_ERROR;
|
return ERR_OS_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
+69
-69
@@ -1,69 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
typedef struct fatparams_t
|
typedef struct fatparams_t
|
||||||
{
|
{
|
||||||
char volume_name[11];
|
char volume_name[11];
|
||||||
byte volume_id[4];
|
byte volume_id[4];
|
||||||
unsigned int num_sectors; /* total number of sectors */
|
unsigned int num_sectors; /* total number of sectors */
|
||||||
int cluster_count; /* number of clusters */
|
int cluster_count; /* number of clusters */
|
||||||
int size_root_dir; /* size of the root directory in bytes */
|
int size_root_dir; /* size of the root directory in bytes */
|
||||||
int size_fat; /* size of FAT */
|
int size_fat; /* size of FAT */
|
||||||
int fats;
|
int fats;
|
||||||
int media;
|
int media;
|
||||||
unsigned int cluster_size;
|
unsigned int cluster_size;
|
||||||
int fat_length;
|
int fat_length;
|
||||||
uint16 dir_entries;
|
uint16 dir_entries;
|
||||||
uint16 sector_size;
|
uint16 sector_size;
|
||||||
int hidden;
|
int hidden;
|
||||||
__int16 reserved;
|
__int16 reserved;
|
||||||
uint16 sectors;
|
uint16 sectors;
|
||||||
unsigned int total_sect;
|
unsigned int total_sect;
|
||||||
|
|
||||||
uint16 heads;
|
uint16 heads;
|
||||||
uint16 secs_track;
|
uint16 secs_track;
|
||||||
|
|
||||||
} fatparams;
|
} fatparams;
|
||||||
|
|
||||||
|
|
||||||
struct msdos_boot_sector
|
struct msdos_boot_sector
|
||||||
{
|
{
|
||||||
unsigned char boot_jump[3]; /* Boot strap short or near jump */
|
unsigned char boot_jump[3]; /* Boot strap short or near jump */
|
||||||
char system_id[8]; /* Name - can be used to special case
|
char system_id[8]; /* Name - can be used to special case
|
||||||
partition manager volumes */
|
partition manager volumes */
|
||||||
unsigned char sector_size[2]; /* bytes per logical sector */
|
unsigned char sector_size[2]; /* bytes per logical sector */
|
||||||
unsigned char cluster_size; /* sectors/cluster */
|
unsigned char cluster_size; /* sectors/cluster */
|
||||||
unsigned short reserved;/* reserved sectors */
|
unsigned short reserved;/* reserved sectors */
|
||||||
unsigned char fats; /* number of FATs */
|
unsigned char fats; /* number of FATs */
|
||||||
unsigned char dir_entries[2]; /* root directory entries */
|
unsigned char dir_entries[2]; /* root directory entries */
|
||||||
unsigned char sectors[2]; /* number of sectors */
|
unsigned char sectors[2]; /* number of sectors */
|
||||||
unsigned char media; /* media code */
|
unsigned char media; /* media code */
|
||||||
unsigned short fat_length; /* sectors/FAT */
|
unsigned short fat_length; /* sectors/FAT */
|
||||||
unsigned short secs_track; /* sectors per track */
|
unsigned short secs_track; /* sectors per track */
|
||||||
unsigned short heads; /* number of heads */
|
unsigned short heads; /* number of heads */
|
||||||
unsigned __int32 hidden; /* hidden sectors */
|
unsigned __int32 hidden; /* hidden sectors */
|
||||||
unsigned __int32 total_sect; /* number of sectors (if sectors == 0) */
|
unsigned __int32 total_sect; /* number of sectors (if sectors == 0) */
|
||||||
unsigned char drive_number; /* BIOS drive number */
|
unsigned char drive_number; /* BIOS drive number */
|
||||||
unsigned char RESERVED; /* Unused */
|
unsigned char RESERVED; /* Unused */
|
||||||
unsigned char ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
|
unsigned char ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */
|
||||||
unsigned char volume_id[4]; /* Volume ID number */
|
unsigned char volume_id[4]; /* Volume ID number */
|
||||||
char volume_label[11]; /* Volume label */
|
char volume_label[11]; /* Volume label */
|
||||||
char fs_type[8]; /* Typically FAT12, FAT16, or FAT32 */
|
char fs_type[8]; /* Typically FAT12, FAT16, or FAT32 */
|
||||||
unsigned char boot_code[448]; /* Boot code (or message) */
|
unsigned char boot_code[448]; /* Boot code (or message) */
|
||||||
unsigned short boot_sign; /* 0xAA55 */
|
unsigned short boot_sign; /* 0xAA55 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void GetFatParams ( fatparams *ft );
|
void GetFatParams ( fatparams *ft );
|
||||||
void PutBoot ( fatparams *ft , unsigned char *boot );
|
void PutBoot ( fatparams *ft , unsigned char *boot );
|
||||||
int FormatFat (void* hwndDlg, unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
|
int FormatFat (void* hwndDlg, unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
|
||||||
|
|||||||
+1054
-1054
File diff suppressed because it is too large
Load Diff
+76
-76
@@ -1,53 +1,53 @@
|
|||||||
/*
|
/*
|
||||||
Legal Notice: Some portions of the source code contained in this file were
|
Legal Notice: Some portions of the source code contained in this file were
|
||||||
derived from the source code of TrueCrypt 7.1a, which is
|
derived from the source code of TrueCrypt 7.1a, which is
|
||||||
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
|
||||||
governed by the TrueCrypt License 3.0, also from the source code of
|
governed by the TrueCrypt License 3.0, also from the source code of
|
||||||
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
|
||||||
and which is governed by the 'License Agreement for Encryption for the Masses'
|
and which is governed by the 'License Agreement for Encryption for the Masses'
|
||||||
Modifications and additions to the original source code (contained in this file)
|
Modifications and additions to the original source code (contained in this file)
|
||||||
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
and all other portions of this file are Copyright (c) 2013-2016 IDRIX
|
||||||
and are governed by the Apache License 2.0 the full text of which is
|
and are governed by the Apache License 2.0 the full text of which is
|
||||||
contained in the file License.txt included in VeraCrypt binary and source
|
contained in the file License.txt included in VeraCrypt binary and source
|
||||||
code distribution packages. */
|
code distribution packages. */
|
||||||
|
|
||||||
#ifndef TC_HEADER_Format
|
#ifndef TC_HEADER_Format
|
||||||
#define TC_HEADER_Format
|
#define TC_HEADER_Format
|
||||||
|
|
||||||
#include "Password.h"
|
#include "Password.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FMIFS
|
// FMIFS
|
||||||
typedef BOOLEAN (__stdcall *PFMIFSCALLBACK)( int command, DWORD subCommand, PVOID parameter );
|
typedef BOOLEAN (__stdcall *PFMIFSCALLBACK)( int command, DWORD subCommand, PVOID parameter );
|
||||||
typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot, DWORD MediaFlag, PWCHAR Format, PWCHAR Label, BOOL QuickFormat, DWORD ClusterSize, PFMIFSCALLBACK Callback );
|
typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot, DWORD MediaFlag, PWCHAR Format, PWCHAR Label, BOOL QuickFormat, DWORD ClusterSize, PFMIFSCALLBACK Callback );
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BOOL bDevice;
|
BOOL bDevice;
|
||||||
BOOL hiddenVol;
|
BOOL hiddenVol;
|
||||||
wchar_t *volumePath;
|
wchar_t *volumePath;
|
||||||
unsigned __int64 size;
|
unsigned __int64 size;
|
||||||
unsigned __int64 hiddenVolHostSize;
|
unsigned __int64 hiddenVolHostSize;
|
||||||
int ea;
|
int ea;
|
||||||
int pkcs5;
|
int pkcs5;
|
||||||
uint32 headerFlags;
|
uint32 headerFlags;
|
||||||
int fileSystem;
|
int fileSystem;
|
||||||
unsigned int clusterSize;
|
unsigned int clusterSize;
|
||||||
BOOL sparseFileSwitch;
|
BOOL sparseFileSwitch;
|
||||||
BOOL quickFormat;
|
BOOL quickFormat;
|
||||||
DWORD sectorSize;
|
DWORD sectorSize;
|
||||||
int *realClusterSize;
|
int *realClusterSize;
|
||||||
Password *password;
|
Password *password;
|
||||||
int pim;
|
int pim;
|
||||||
HWND hwndDlg;
|
HWND hwndDlg;
|
||||||
BOOL bForceOperation;
|
BOOL bForceOperation;
|
||||||
BOOL bGuiMode;
|
BOOL bGuiMode;
|
||||||
}
|
}
|
||||||
FORMAT_VOL_PARAMETERS;
|
FORMAT_VOL_PARAMETERS;
|
||||||
|
|
||||||
#define FMIFS_PROGRESS 0x00
|
#define FMIFS_PROGRESS 0x00
|
||||||
#define FMIFS_DONE_WITH_STRUCTURE 0x01
|
#define FMIFS_DONE_WITH_STRUCTURE 0x01
|
||||||
#define FMIFS_INCOMPATIBLE_FILE_SYSTEM 0x03
|
#define FMIFS_INCOMPATIBLE_FILE_SYSTEM 0x03
|
||||||
@@ -66,29 +66,29 @@ FORMAT_VOL_PARAMETERS;
|
|||||||
#define FMIFS_NO_MEDIA_IN_DRIVE 0x14
|
#define FMIFS_NO_MEDIA_IN_DRIVE 0x14
|
||||||
#define FMIFS_DEVICE_NOT_READY 0x18
|
#define FMIFS_DEVICE_NOT_READY 0x18
|
||||||
#define FMIFS_CHECKDISK_PROGRESS 0x19
|
#define FMIFS_CHECKDISK_PROGRESS 0x19
|
||||||
#define FMIFS_READ_ONLY_MODE 0x20
|
#define FMIFS_READ_ONLY_MODE 0x20
|
||||||
|
|
||||||
#define FMIFS_HARDDISK 0xC
|
#define FMIFS_HARDDISK 0xC
|
||||||
|
|
||||||
extern int FormatWriteBufferSize;
|
extern int FormatWriteBufferSize;
|
||||||
|
|
||||||
int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams);
|
int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams);
|
||||||
BOOL FormatNtfs (int driveNo, int clusterSize);
|
BOOL FormatNtfs (int driveNo, int clusterSize);
|
||||||
BOOL FormatFs (int driveNo, int clusterSize, int fsType);
|
BOOL FormatFs (int driveNo, int clusterSize, int fsType);
|
||||||
uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize);
|
uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize);
|
||||||
int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
|
int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
|
||||||
BOOL WriteSector ( void *dev , char *sector , char *write_buf , int *write_buf_cnt , __int64 *nSecNo , PCRYPTO_INFO cryptoInfo );
|
BOOL WriteSector ( void *dev , char *sector , char *write_buf , int *write_buf_cnt , __int64 *nSecNo , PCRYPTO_INFO cryptoInfo );
|
||||||
BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo);
|
BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo);
|
||||||
static BOOL StartFormatWriteThread ();
|
static BOOL StartFormatWriteThread ();
|
||||||
static void StopFormatWriteThread ();
|
static void StopFormatWriteThread ();
|
||||||
|
|
||||||
#define FILESYS_NONE 0
|
#define FILESYS_NONE 0
|
||||||
#define FILESYS_FAT 1
|
#define FILESYS_FAT 1
|
||||||
#define FILESYS_NTFS 2
|
#define FILESYS_NTFS 2
|
||||||
#define FILESYS_EXFAT 3
|
#define FILESYS_EXFAT 3
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TC_HEADER_Format
|
#endif // TC_HEADER_Format
|
||||||
|
|||||||
+768
-768
File diff suppressed because it is too large
Load Diff
+74
-74
@@ -1,74 +1,74 @@
|
|||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
|
Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
|
||||||
|
|
||||||
LICENSE TERMS
|
LICENSE TERMS
|
||||||
|
|
||||||
The free distribution and use of this software is allowed (with or without
|
The free distribution and use of this software is allowed (with or without
|
||||||
changes) provided that:
|
changes) provided that:
|
||||||
|
|
||||||
1. source code distributions include the above copyright notice, this
|
1. source code distributions include the above copyright notice, this
|
||||||
list of conditions and the following disclaimer;
|
list of conditions and the following disclaimer;
|
||||||
|
|
||||||
2. binary distributions include the above copyright notice, this list
|
2. binary distributions include the above copyright notice, this list
|
||||||
of conditions and the following disclaimer in their documentation;
|
of conditions and the following disclaimer in their documentation;
|
||||||
|
|
||||||
3. the name of the copyright holder is not used to endorse products
|
3. the name of the copyright holder is not used to endorse products
|
||||||
built using this software without specific written permission.
|
built using this software without specific written permission.
|
||||||
|
|
||||||
DISCLAIMER
|
DISCLAIMER
|
||||||
|
|
||||||
This software is provided 'as is' with no explicit or implied warranties
|
This software is provided 'as is' with no explicit or implied warranties
|
||||||
in respect of its properties, including, but not limited to, correctness
|
in respect of its properties, including, but not limited to, correctness
|
||||||
and/or fitness for purpose.
|
and/or fitness for purpose.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Issue Date: 31/01/2004
|
Issue Date: 31/01/2004
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Adapted for TrueCrypt */
|
/* Adapted for TrueCrypt */
|
||||||
|
|
||||||
#ifndef _GCM_H
|
#ifndef _GCM_H
|
||||||
#define _GCM_H
|
#define _GCM_H
|
||||||
|
|
||||||
#include "Tcdefs.h"
|
#include "Tcdefs.h"
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CBLK_LEN 16 /* encryption block length */
|
#define CBLK_LEN 16 /* encryption block length */
|
||||||
#define CBLK_LEN8 8
|
#define CBLK_LEN8 8
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned __int32 gf_t8k[CBLK_LEN * 2][16][CBLK_LEN / 4];
|
unsigned __int32 gf_t8k[CBLK_LEN * 2][16][CBLK_LEN / 4];
|
||||||
} GfCtx8k;
|
} GfCtx8k;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned __int32 gf_t4k[CBLK_LEN8 * 2][16][CBLK_LEN / 4];
|
unsigned __int32 gf_t4k[CBLK_LEN8 * 2][16][CBLK_LEN / 4];
|
||||||
} GfCtx4k64;
|
} GfCtx4k64;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* union not used to support faster mounting */
|
/* union not used to support faster mounting */
|
||||||
unsigned __int32 gf_t128[CBLK_LEN * 2 / 2][16][CBLK_LEN / 4];
|
unsigned __int32 gf_t128[CBLK_LEN * 2 / 2][16][CBLK_LEN / 4];
|
||||||
unsigned __int32 gf_t64[CBLK_LEN8 * 2][16][CBLK_LEN8 / 4];
|
unsigned __int32 gf_t64[CBLK_LEN8 * 2][16][CBLK_LEN8 / 4];
|
||||||
} GfCtx;
|
} GfCtx;
|
||||||
|
|
||||||
typedef int ret_type;
|
typedef int ret_type;
|
||||||
|
|
||||||
void GfMul128 (void *a, const void* b);
|
void GfMul128 (void *a, const void* b);
|
||||||
void GfMul128Tab(unsigned char a[16], GfCtx8k *ctx);
|
void GfMul128Tab(unsigned char a[16], GfCtx8k *ctx);
|
||||||
int Gf128Tab64Init (unsigned __int8 *a, GfCtx *ctx);
|
int Gf128Tab64Init (unsigned __int8 *a, GfCtx *ctx);
|
||||||
void Gf128MulBy64Tab (unsigned __int8 a[8], unsigned __int8 p[16], GfCtx *ctx);
|
void Gf128MulBy64Tab (unsigned __int8 a[8], unsigned __int8 p[16], GfCtx *ctx);
|
||||||
void MirrorBits128 (unsigned __int8 *a);
|
void MirrorBits128 (unsigned __int8 *a);
|
||||||
void MirrorBits64 (unsigned __int8 *a);
|
void MirrorBits64 (unsigned __int8 *a);
|
||||||
BOOL GfMulSelfTest ();
|
BOOL GfMulSelfTest ();
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user