VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Format
diff options
context:
space:
mode:
Diffstat (limited to 'src/Format')
-rw-r--r--src/Format/Format.manifest64
-rw-r--r--src/Format/Format.rc1494
-rw-r--r--src/Format/Format.vcproj2056
-rw-r--r--src/Format/FormatCom.cpp496
-rw-r--r--src/Format/FormatCom.h72
-rw-r--r--src/Format/FormatCom.idl106
-rw-r--r--src/Format/InPlace.c4586
-rw-r--r--src/Format/InPlace.h104
-rw-r--r--src/Format/Resource.h318
-rw-r--r--src/Format/Tcformat.c20466
-rw-r--r--src/Format/Tcformat.h218
11 files changed, 14990 insertions, 14990 deletions
diff --git a/src/Format/Format.manifest b/src/Format/Format.manifest
index 255a867e..5d4cb896 100644
--- a/src/Format/Format.manifest
+++ b/src/Format/Format.manifest
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
- <security>
- <requestedPrivileges>
- <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
- <asmv3:application>
- <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
- <dpiAware>true</dpiAware>
- </asmv3:windowsSettings>
- </asmv3:application>
- <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
- <application>
- <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
- <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
- </application>
- </compatibility>
- <dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="*"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
- </dependency>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <asmv3:application>
+ <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+ <dpiAware>true</dpiAware>
+ </asmv3:windowsSettings>
+ </asmv3:application>
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
+ <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+ </application>
+ </compatibility>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="*"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>
</assembly> \ No newline at end of file
diff --git a/src/Format/Format.rc b/src/Format/Format.rc
index 9e13a29b..eb2fcfa0 100644
--- a/src/Format/Format.rc
+++ b/src/Format/Format.rc
@@ -1,747 +1,747 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-#include "..\\common\\resource.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,17,22,0
- PRODUCTVERSION 1,17,22,0
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "CompanyName", "IDRIX"
- VALUE "FileDescription", "VeraCrypt Format"
- VALUE "FileVersion", "1.17"
- VALUE "LegalTrademarks", "VeraCrypt"
- VALUE "OriginalFilename", "VeraCrypt Format.exe"
- VALUE "ProductName", "VeraCrypt"
- VALUE "ProductVersion", "1.17"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// HEADER
-//
-
-IDR_FORMAT_RSRC_HEADER HEADER "resource.h"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// TYPELIB
-//
-
-IDR_FORMAT_TLB TYPELIB "Format.tlb"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_VOL_CREATION_WIZARD_DLG DIALOGEX 0, 0, 400, 229
-STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "VeraCrypt Volume Creation Wizard"
-CLASS "VeraCryptCustomDlg"
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- PUSHBUTTON "&Help",IDHELP,176,209,50,14
- PUSHBUTTON "",IDC_PREV,235,209,50,14
- DEFPUSHBUTTON "",IDC_NEXT,285,209,50,14
- PUSHBUTTON "Cancel",IDCANCEL,343,209,50,14
- LTEXT "",IDC_BOX_TITLE,160,8,233,17
- GROUPBOX "",IDC_STATIC,4,0,392,203
- CONTROL 116,IDC_BITMAP_WIZARD,"Static",SS_BITMAP | SS_SUNKEN,10,9,137,169
- LTEXT "",IDC_POS_BOX,160,24,231,172
-END
-
-IDD_CIPHER_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- COMBOBOX IDC_COMBO_BOX,7,23,137,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "&Test",IDC_CIPHER_TEST,149,22,59,14
- PUSHBUTTON "&Benchmark",IDC_BENCHMARK,149,100,59,14
- COMBOBOX IDC_COMBO_BOX_HASH_ALGO,7,137,83,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "",IDC_BOX_HELP,7,40,205,58
- GROUPBOX "Encryption Algorithm",IDT_ENCRYPTION_ALGO,0,10,217,111
- GROUPBOX "Hash Algorithm",IDT_HASH_ALGO,0,124,217,35
- LTEXT "More information",IDC_LINK_MORE_INFO_ABOUT_CIPHER,7,102,135,10,SS_NOTIFY
- LTEXT "Information on hash algorithms",IDC_LINK_HASH_INFO,97,139,115,8,SS_NOTIFY
-END
-
-IDD_PASSWORD_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- EDITTEXT IDC_PASSWORD,53,3,170,14,ES_PASSWORD | ES_AUTOHSCROLL
- EDITTEXT IDC_VERIFY,53,19,170,14,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,35,95,10
- PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,152,36,71,14,WS_DISABLED
- CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,45,95,11,WS_EX_TRANSPARENT
- CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,56,97,10
- RTEXT "Password:",IDT_PASSWORD,1,6,50,8
- RTEXT "&Confirm:",IDT_CONFIRM,1,23,50,8
- LTEXT "",IDC_BOX_HELP,0,71,225,97
-END
-
-IDD_SIZE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- EDITTEXT IDC_SIZEBOX,0,22,71,14,ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "&KB",IDC_KB,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,80,25,27,10
- CONTROL "&MB",IDC_MB,"Button",BS_AUTORADIOBUTTON,115,25,27,10
- CONTROL "&GB",IDC_GB,"Button",BS_AUTORADIOBUTTON,150,25,27,10
- LTEXT "",IDC_BOX_HELP,0,84,214,75
- LTEXT "",IDC_SPACE_LEFT,0,44,214,33
- CONTROL "&TB",IDC_TB,"Button",BS_AUTORADIOBUTTON,185,25,27,10
-END
-
-IDD_VOLUME_LOCATION_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- COMBOBOX IDC_COMBO_BOX,0,9,148,80,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- CONTROL "&Never save history",IDC_NO_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,28,213,10
- PUSHBUTTON "",IDC_SELECT_VOLUME_LOCATION,155,9,62,14
- LTEXT "",IDC_BOX_HELP,0,42,219,125
-END
-
-IDD_FORMAT_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- COMBOBOX IDC_FILESYS,43,13,36,90,CBS_DROPDOWNLIST | WS_TABSTOP
- COMBOBOX IDC_CLUSTERSIZE,112,13,42,90,CBS_DROPDOWNLIST | WS_TABSTOP
- CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,163,11,60,18
- CONTROL "",IDC_SHOW_KEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,214,38,9,8
- PUSHBUTTON "Abort",IDC_ABORT_BUTTON,169,75,50,14
- RTEXT "Header Key: ",IDT_HEADER_KEY,2,47,54,8
- CONTROL "",IDC_HEADER_KEY,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,57,46,163,8,WS_EX_TRANSPARENT
- RTEXT "Master Key: ",IDT_MASTER_KEY,2,55,54,8
- LTEXT "",IDC_DISK_KEY,57,54,163,8,0,WS_EX_TRANSPARENT
- RTEXT "Cluster ",IDT_CLUSTER,80,15,32,8
- LTEXT "",IDC_BOX_HELP,1,112,224,40
- GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,3,225,29
- CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,76,158,12
- RTEXT "",IDC_TIMEREMAIN,177,93,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "",IDC_WRITESPEED,106,93,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- LTEXT "",IDC_BYTESWRITTEN,29,93,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "Done",IDT_DONE,5,94,22,8
- RTEXT "Speed",IDT_SPEED,70,94,34,8
- RTEXT "Left",IDT_LEFT,150,94,25,8
- GROUPBOX "",IDC_STATIC,0,67,225,41
- RTEXT "Filesystem ",IDT_FILESYSTEM,1,15,41,8,0,WS_EX_RIGHT
- RTEXT "Random Pool: ",IDT_RANDOM_POOL,2,39,54,8
- GROUPBOX "",IDC_STATIC,0,32,225,35
- CONTROL "",IDC_RANDOM_BYTES,"Static",SS_SIMPLE | WS_GROUP,57,38,155,8,WS_EX_TRANSPARENT
- GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,0,153,224,18
- CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",WS_BORDER,11,162,202,6
-END
-
-IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Create an encrypted file container",IDC_FILE_CONTAINER,
- "Button",BS_AUTORADIOBUTTON,0,7,217,10
- LTEXT "More information",IDC_MORE_INFO_ON_CONTAINERS,16,40,165,10,SS_NOTIFY
- CONTROL "Encrypt a non-system partition/drive",IDC_NONSYS_DEVICE,
- "Button",BS_AUTORADIOBUTTON,0,53,217,10
- CONTROL "Encrypt the system partition or entire system drive",IDC_SYS_DEVICE,
- "Button",BS_AUTORADIOBUTTON,0,89,217,10
- LTEXT "More information about system encryption",IDC_MORE_INFO_ON_SYS_ENCRYPTION,16,153,190,10,SS_NOTIFY
- LTEXT "Creates a virtual encrypted disk within a file. Recommended for inexperienced users.",IDT_FILE_CONTAINER,16,20,205,16
- LTEXT "Encrypts a non-system partition on any internal or external drive (e.g. a flash drive). Optionally, creates a hidden volume.",IDT_NON_SYS_DEVICE,16,66,205,20
- LTEXT "Encrypts the partition/drive where Windows is installed. Anyone who wants to gain access and use the system, read and write files, etc., will need to enter the correct password each time before Windows boots. Optionally, creates a hidden system.",IDT_SYS_DEVICE,16,102,205,47
-END
-
-IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "",IDC_BOX_HELP,0,10,225,155
-END
-
-IDD_HIDVOL_HOST_FILL_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "",IDC_BOX_HELP,0,6,226,138
- PUSHBUTTON "Open Outer Volume",IDC_OPEN_OUTER_VOLUME,0,146,85,14
-END
-
-IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Normal mode",IDC_HIDVOL_WIZ_MODE_FULL,"Button",BS_AUTORADIOBUTTON,0,7,217,10
- CONTROL "Direct mode",IDC_HIDVOL_WIZ_MODE_DIRECT,"Button",BS_AUTORADIOBUTTON,0,87,217,10
- LTEXT "",IDC_BOX_HELP,16,20,205,63
- LTEXT "",IDC_BOX_HELP2,16,101,205,59
-END
-
-IDD_PASSWORD_ENTRY_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- EDITTEXT IDC_PASSWORD_DIRECT,50,2,173,14,ES_PASSWORD | ES_AUTOHSCROLL
- COMBOBOX IDC_PKCS5_PRF_ID,50,17,104,90,CBS_DROPDOWNLIST | WS_TABSTOP
- EDITTEXT IDC_PIM,50,32,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
- LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,96,34,127,8,NOT WS_VISIBLE
- CONTROL "&Display password",IDC_SHOW_PASSWORD_SINGLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,46,84,11,WS_EX_TRANSPARENT
- CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,57,94,11
- PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,149,54,74,14
- LTEXT "",IDC_BOX_HELP,0,74,225,94
- RTEXT "Password:",IDT_PASSWORD,0,6,48,8
- RTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,0,19,48,8
- RTEXT "Volume PIM:",IDT_PIM,0,35,48,8,NOT WS_VISIBLE
- CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,35,97,10
-END
-
-IDD_VOLUME_TYPE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Standard VeraCrypt volume",IDC_STD_VOL,"Button",BS_AUTORADIOBUTTON,0,7,212,10
- CONTROL "Hi&dden VeraCrypt volume ",IDC_HIDDEN_VOL,"Button",BS_AUTORADIOBUTTON,0,68,212,10
- LTEXT "More information about hidden volumes",IDC_HIDDEN_VOL_HELP,16,151,205,10,SS_NOTIFY
- LTEXT "",IDC_BOX_HELP_NORMAL_VOL,16,20,205,41
- LTEXT "",IDC_BOX_HELP,16,83,205,62
-END
-
-IDD_SYSENC_SPAN_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Encrypt the Windows system partition",IDC_SYS_PARTITION,
- "Button",BS_AUTORADIOBUTTON,0,7,212,10
- CONTROL "Encrypt the whole drive",IDC_WHOLE_SYS_DRIVE,"Button",BS_AUTORADIOBUTTON,0,53,212,10
- LTEXT "Select this option to encrypt the partition where the currently running Windows operating system is installed.",IDT_SYS_PARTITION,16,20,205,32
- LTEXT "",IDT_WHOLE_SYS_DRIVE,16,70,205,95
-END
-
-IDD_SYSENC_RESCUE_DISK_CREATION_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- EDITTEXT IDC_RESCUE_DISK_ISO_PATH,0,159,163,13,ES_AUTOHSCROLL
- PUSHBUTTON "Bro&wse...",IDC_BROWSE,166,158,59,14
- LTEXT "",IDT_RESCUE_DISK_INFO,0,1,225,137
- CONTROL "Skip Rescue Disk verification",IDC_SKIP_RESCUE_VERIFICATION,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,145,106,10
-END
-
-IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- CONTROL "Display pool content",IDC_DISPLAY_POOL_CONTENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,1,98,122,10
- CONTROL "",IDC_SYS_POOL_CONTENTS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,8,14,205,72,WS_EX_TRANSPARENT
- LTEXT "IMPORTANT: Move your mouse as randomly as possible within this window. The longer you move it, the better. This significantly increases the cryptographic strength of the encryption keys. Then click Next to continue.",IDT_COLLECTING_RANDOM_DATA_NOTE,1,112,224,40
- GROUPBOX "Current pool content (partial)",IDT_PARTIAL_POOL_CONTENTS,0,5,222,88
- GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,0,154,224,18
- CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",WS_BORDER,11,163,202,6
-END
-
-IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Single-boot",IDC_SINGLE_BOOT,"Button",BS_AUTORADIOBUTTON,0,7,212,10
- CONTROL "Multi-boot",IDC_MULTI_BOOT,"Button",BS_AUTORADIOBUTTON,0,53,217,10
- LTEXT "Select this option if there is only one operating system installed on this computer (even if it has multiple users).",IDT_SINGLE_BOOT,16,20,205,32
- LTEXT "Select this option if there are two or more operating systems installed on this computer.\n\nFor example:\n- Windows XP and Windows XP\n- Windows XP and Windows Vista\n- Windows and Mac OS X\n- Windows and Linux\n- Windows, Linux and Mac OS X",IDT_MULTI_BOOT,16,66,205,72
-END
-
-IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- LTEXT "Download CD/DVD recording software",IDC_DOWNLOAD_CD_BURN_SOFTWARE,0,136,217,10,SS_NOTIFY
- LTEXT "",IDT_RESCUE_DISK_BURN_INFO,0,4,225,128
-END
-
-IDD_SYSENC_WIPE_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- COMBOBOX IDC_WIPE_MODE,61,0,127,90,CBS_DROPDOWNLIST | WS_TABSTOP
- RTEXT "Wipe mode:",IDT_WIPE_MODE,0,2,59,8,0,WS_EX_RIGHT
- LTEXT "",IDT_WIPE_MODE_INFO,0,19,225,128
-END
-
-IDD_INPLACE_ENCRYPTION_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- COMBOBOX IDC_WIPE_MODE,67,13,125,90,CBS_DROPDOWNLIST | WS_TABSTOP
- PUSHBUTTON "&Pause",IDC_PAUSE,169,40,50,14
- LTEXT "More information",IDC_MORE_INFO_SYS_ENCRYPTION,1,150,202,10,SS_NOTIFY
- LTEXT "",IDC_BYTESWRITTEN,29,58,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "",IDC_WRITESPEED,103,58,46,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "",IDC_TIMEREMAIN,177,58,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "Wipe mode:",IDT_WIPE_MODE,6,15,59,8,0,WS_EX_RIGHT
- CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,41,158,12
- RTEXT "Done",IDT_DONE,5,59,22,8
- RTEXT "Status",IDT_STATUS,72,59,29,8
- RTEXT "Left",IDT_LEFT,151,59,24,8
- LTEXT "",IDC_BOX_HELP,1,77,224,70
- GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,3,225,29
- GROUPBOX "",IDC_STATIC,0,32,225,41
-END
-
-IDD_SYSENC_KEYS_GEN_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- CONTROL "Display generated keys (their portions)",IDC_DISPLAY_KEYS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,1,94,216,10
- CONTROL "",IDC_HEADER_KEY,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,57,71,163,8,WS_EX_TRANSPARENT
- LTEXT "",IDC_DISK_KEY,57,79,163,8,0,WS_EX_TRANSPARENT
- LTEXT "The keys, salt, and other data have been successfully generated. If you want to generate new keys, click Back and then Next. Otherwise, click Next to continue.",IDT_SYSENC_KEYS_GEN_INFO,1,23,224,41
- RTEXT "Header Key: ",IDT_HEADER_KEY,2,72,54,8
- RTEXT "Master Key: ",IDT_MASTER_KEY,2,80,54,8
- GROUPBOX "",-1,0,65,225,26
-END
-
-IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "",IDC_CHOICE1,"Button",BS_AUTORADIOBUTTON,0,7,212,10
- CONTROL "",IDC_CHOICE2,"Button",BS_AUTORADIOBUTTON,0,17,217,10
- LTEXT "",IDC_BOX_HELP,1,34,220,112
-END
-
-IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- LTEXT "",IDT_SYSENC_DRIVE_ANALYSIS_INFO,2,10,215,88
- CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,1,115,216,12
- LTEXT "Progress:",IDT_PROGRESS,2,104,57,8
-END
-
-IDD_SYSENC_TYPE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Normal",IDC_SYSENC_NORMAL,"Button",BS_AUTORADIOBUTTON,0,7,212,10
- CONTROL "Hi&dden",IDC_SYSENC_HIDDEN,"Button",BS_AUTORADIOBUTTON,0,53,212,10
- LTEXT "More information",IDC_HIDDEN_SYSENC_INFO_LINK,16,148,205,10,SS_NOTIFY
- LTEXT "",IDC_BOX_HELP_SYSENC_NORMAL,16,20,205,25
- LTEXT "",IDC_BOX_HELP,16,67,205,72
-END
-
-IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- LTEXT "More information",IDC_HIDDEN_SYSENC_INFO_LINK,0,150,217,10,SS_NOTIFY
- LTEXT "",IDC_BOX_HELP,0,2,225,142
-END
-
-IDD_DEVICE_WIPE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- PUSHBUTTON "Abort",IDC_ABORT_BUTTON,169,48,50,14
- LTEXT "",IDC_BYTESWRITTEN,29,66,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "",IDC_WRITESPEED,103,66,46,11,SS_CENTERIMAGE | NOT WS_VISIBLE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "",IDC_TIMEREMAIN,177,66,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
- RTEXT "Wipe mode:",IDT_WIPE_MODE,6,22,59,8,0,WS_EX_RIGHT
- CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,49,158,12
- RTEXT "Done",IDT_DONE,5,67,22,8
- RTEXT "Pass",IDT_PASS,72,67,29,8,NOT WS_VISIBLE
- RTEXT "Left",IDT_LEFT,151,67,24,8
- LTEXT "",IDC_BOX_HELP,1,86,224,80
- GROUPBOX "",IDT_FORMAT_OPTIONS,0,10,225,29
- GROUPBOX "",IDC_STATIC,0,40,225,42
- LTEXT "",IDC_WIPE_MODE,67,21,125,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_STATICEDGE
-END
-
-IDD_DEVICE_WIPE_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- COMBOBOX IDC_WIPE_MODE,61,9,127,90,CBS_DROPDOWNLIST | WS_TABSTOP
- RTEXT "Wipe mode:",IDT_WIPE_MODE,0,11,59,8,0,WS_EX_RIGHT
- LTEXT "",IDT_WIPE_MODE_INFO,0,29,225,122
-END
-
-IDD_DEVICE_TRANSFORM_MODE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Create encrypted volume and format it",IDC_DEVICE_TRANSFORM_MODE_FORMAT,
- "Button",BS_AUTORADIOBUTTON,0,8,217,10
- CONTROL "Encrypt partition in place",IDC_DEVICE_TRANSFORM_MODE_INPLACE,
- "Button",BS_AUTORADIOBUTTON,0,98,217,10
- LTEXT "",IDC_BOX_HELP,16,21,205,74
- LTEXT "",IDC_BOX_HELP2,16,112,205,53
-END
-
-IDD_EXPANDED_LIST_SELECT_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "",IDC_BOX_HELP,0,107,225,58
- LISTBOX IDC_LIST_BOX,0,3,222,100,LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL
-END
-
-IDD_DRIVE_LETTER_SELECTION_PAGE DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "",IDC_BOX_HELP,0,40,225,118
- COMBOBOX IDC_DRIVE_LETTER_LIST,94,15,38,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- RTEXT "Drive letter:",IDT_DRIVE_LETTER,5,17,86,8
-END
-
-IDD_PIM_PAGE_DLG DIALOGEX 0, 0, 226, 172
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- EDITTEXT IDC_PIM,53,0,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
- LTEXT "",IDC_BOX_HELP,0,32,225,126
- RTEXT "Volume PIM:",IDT_PIM,1,3,50,8
- LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,97,3,126,8
- LTEXT "Information on PIM",IDC_LINK_PIM_INFO,0,161,213,8,SS_NOTIFY
- CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,17,150,10
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "#include ""..\\\\common\\\\resource.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "#include ""..\\\\common\\\\common.rc""\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_VOL_CREATION_WIZARD_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 393
- TOPMARGIN, 1
- BOTTOMMARGIN, 227
- HORZGUIDE, 216
- END
-
- IDD_CIPHER_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 161
- END
-
- IDD_PASSWORD_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 143
- END
-
- IDD_SIZE_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 165
- END
-
- IDD_VOLUME_LOCATION_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 167
- END
-
- IDD_FORMAT_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 217
- BOTTOMMARGIN, 153
- HORZGUIDE, 80
- HORZGUIDE, 96
- END
-
- IDD_INTRO_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_INFO_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_HIDVOL_HOST_FILL_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_PASSWORD_ENTRY_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 143
- END
-
- IDD_VOLUME_TYPE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_SYSENC_SPAN_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_SYSENC_RESCUE_DISK_CREATION_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 167
- END
-
- IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 217
- BOTTOMMARGIN, 153
- HORZGUIDE, 80
- HORZGUIDE, 96
- END
-
- IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 167
- END
-
- IDD_SYSENC_WIPE_MODE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_INPLACE_ENCRYPTION_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 217
- BOTTOMMARGIN, 166
- HORZGUIDE, 80
- HORZGUIDE, 96
- END
-
- IDD_SYSENC_KEYS_GEN_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 217
- BOTTOMMARGIN, 153
- HORZGUIDE, 80
- HORZGUIDE, 96
- END
-
- IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 217
- BOTTOMMARGIN, 153
- HORZGUIDE, 80
- HORZGUIDE, 96
- END
-
- IDD_SYSENC_TYPE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 167
- END
-
- IDD_DEVICE_WIPE_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 217
- BOTTOMMARGIN, 166
- HORZGUIDE, 80
- HORZGUIDE, 96
- END
-
- IDD_DEVICE_WIPE_MODE_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_DEVICE_TRANSFORM_MODE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_EXPANDED_LIST_SELECT_PAGE_DLG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_DRIVE_LETTER_SELECTION_PAGE, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 165
- END
-
- IDD_PIM_PAGE_DLG, DIALOG
- BEGIN
- RIGHTMARGIN, 223
- BOTTOMMARGIN, 171
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDB_WIZARD BITMAP "VeraCrypt_wizard.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
- IDS_UACSTRING_FMT "VeraCrypt"
-END
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-#include "..\\common\\common.rc"
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+#include "..\\common\\resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,17,22,0
+ PRODUCTVERSION 1,17,22,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "IDRIX"
+ VALUE "FileDescription", "VeraCrypt Format"
+ VALUE "FileVersion", "1.17"
+ VALUE "LegalTrademarks", "VeraCrypt"
+ VALUE "OriginalFilename", "VeraCrypt Format.exe"
+ VALUE "ProductName", "VeraCrypt"
+ VALUE "ProductVersion", "1.17"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// HEADER
+//
+
+IDR_FORMAT_RSRC_HEADER HEADER "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// TYPELIB
+//
+
+IDR_FORMAT_TLB TYPELIB "Format.tlb"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_VOL_CREATION_WIZARD_DLG DIALOGEX 0, 0, 400, 229
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Volume Creation Wizard"
+CLASS "VeraCryptCustomDlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "&Help",IDHELP,176,209,50,14
+ PUSHBUTTON "",IDC_PREV,235,209,50,14
+ DEFPUSHBUTTON "",IDC_NEXT,285,209,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,343,209,50,14
+ LTEXT "",IDC_BOX_TITLE,160,8,233,17
+ GROUPBOX "",IDC_STATIC,4,0,392,203
+ CONTROL 116,IDC_BITMAP_WIZARD,"Static",SS_BITMAP | SS_SUNKEN,10,9,137,169
+ LTEXT "",IDC_POS_BOX,160,24,231,172
+END
+
+IDD_CIPHER_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_COMBO_BOX,7,23,137,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "&Test",IDC_CIPHER_TEST,149,22,59,14
+ PUSHBUTTON "&Benchmark",IDC_BENCHMARK,149,100,59,14
+ COMBOBOX IDC_COMBO_BOX_HASH_ALGO,7,137,83,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "",IDC_BOX_HELP,7,40,205,58
+ GROUPBOX "Encryption Algorithm",IDT_ENCRYPTION_ALGO,0,10,217,111
+ GROUPBOX "Hash Algorithm",IDT_HASH_ALGO,0,124,217,35
+ LTEXT "More information",IDC_LINK_MORE_INFO_ABOUT_CIPHER,7,102,135,10,SS_NOTIFY
+ LTEXT "Information on hash algorithms",IDC_LINK_HASH_INFO,97,139,115,8,SS_NOTIFY
+END
+
+IDD_PASSWORD_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_PASSWORD,53,3,170,14,ES_PASSWORD | ES_AUTOHSCROLL
+ EDITTEXT IDC_VERIFY,53,19,170,14,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,35,95,10
+ PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,152,36,71,14,WS_DISABLED
+ CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,45,95,11,WS_EX_TRANSPARENT
+ CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,56,97,10
+ RTEXT "Password:",IDT_PASSWORD,1,6,50,8
+ RTEXT "&Confirm:",IDT_CONFIRM,1,23,50,8
+ LTEXT "",IDC_BOX_HELP,0,71,225,97
+END
+
+IDD_SIZE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_SIZEBOX,0,22,71,14,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "&KB",IDC_KB,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,80,25,27,10
+ CONTROL "&MB",IDC_MB,"Button",BS_AUTORADIOBUTTON,115,25,27,10
+ CONTROL "&GB",IDC_GB,"Button",BS_AUTORADIOBUTTON,150,25,27,10
+ LTEXT "",IDC_BOX_HELP,0,84,214,75
+ LTEXT "",IDC_SPACE_LEFT,0,44,214,33
+ CONTROL "&TB",IDC_TB,"Button",BS_AUTORADIOBUTTON,185,25,27,10
+END
+
+IDD_VOLUME_LOCATION_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_COMBO_BOX,0,9,148,80,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ CONTROL "&Never save history",IDC_NO_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,28,213,10
+ PUSHBUTTON "",IDC_SELECT_VOLUME_LOCATION,155,9,62,14
+ LTEXT "",IDC_BOX_HELP,0,42,219,125
+END
+
+IDD_FORMAT_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_FILESYS,43,13,36,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ COMBOBOX IDC_CLUSTERSIZE,112,13,42,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,163,11,60,18
+ CONTROL "",IDC_SHOW_KEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,214,38,9,8
+ PUSHBUTTON "Abort",IDC_ABORT_BUTTON,169,75,50,14
+ RTEXT "Header Key: ",IDT_HEADER_KEY,2,47,54,8
+ CONTROL "",IDC_HEADER_KEY,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,57,46,163,8,WS_EX_TRANSPARENT
+ RTEXT "Master Key: ",IDT_MASTER_KEY,2,55,54,8
+ LTEXT "",IDC_DISK_KEY,57,54,163,8,0,WS_EX_TRANSPARENT
+ RTEXT "Cluster ",IDT_CLUSTER,80,15,32,8
+ LTEXT "",IDC_BOX_HELP,1,112,224,40
+ GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,3,225,29
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,76,158,12
+ RTEXT "",IDC_TIMEREMAIN,177,93,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "",IDC_WRITESPEED,106,93,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ LTEXT "",IDC_BYTESWRITTEN,29,93,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "Done",IDT_DONE,5,94,22,8
+ RTEXT "Speed",IDT_SPEED,70,94,34,8
+ RTEXT "Left",IDT_LEFT,150,94,25,8
+ GROUPBOX "",IDC_STATIC,0,67,225,41
+ RTEXT "Filesystem ",IDT_FILESYSTEM,1,15,41,8,0,WS_EX_RIGHT
+ RTEXT "Random Pool: ",IDT_RANDOM_POOL,2,39,54,8
+ GROUPBOX "",IDC_STATIC,0,32,225,35
+ CONTROL "",IDC_RANDOM_BYTES,"Static",SS_SIMPLE | WS_GROUP,57,38,155,8,WS_EX_TRANSPARENT
+ GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,0,153,224,18
+ CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",WS_BORDER,11,162,202,6
+END
+
+IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Create an encrypted file container",IDC_FILE_CONTAINER,
+ "Button",BS_AUTORADIOBUTTON,0,7,217,10
+ LTEXT "More information",IDC_MORE_INFO_ON_CONTAINERS,16,40,165,10,SS_NOTIFY
+ CONTROL "Encrypt a non-system partition/drive",IDC_NONSYS_DEVICE,
+ "Button",BS_AUTORADIOBUTTON,0,53,217,10
+ CONTROL "Encrypt the system partition or entire system drive",IDC_SYS_DEVICE,
+ "Button",BS_AUTORADIOBUTTON,0,89,217,10
+ LTEXT "More information about system encryption",IDC_MORE_INFO_ON_SYS_ENCRYPTION,16,153,190,10,SS_NOTIFY
+ LTEXT "Creates a virtual encrypted disk within a file. Recommended for inexperienced users.",IDT_FILE_CONTAINER,16,20,205,16
+ LTEXT "Encrypts a non-system partition on any internal or external drive (e.g. a flash drive). Optionally, creates a hidden volume.",IDT_NON_SYS_DEVICE,16,66,205,20
+ LTEXT "Encrypts the partition/drive where Windows is installed. Anyone who wants to gain access and use the system, read and write files, etc., will need to enter the correct password each time before Windows boots. Optionally, creates a hidden system.",IDT_SYS_DEVICE,16,102,205,47
+END
+
+IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "",IDC_BOX_HELP,0,10,225,155
+END
+
+IDD_HIDVOL_HOST_FILL_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "",IDC_BOX_HELP,0,6,226,138
+ PUSHBUTTON "Open Outer Volume",IDC_OPEN_OUTER_VOLUME,0,146,85,14
+END
+
+IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Normal mode",IDC_HIDVOL_WIZ_MODE_FULL,"Button",BS_AUTORADIOBUTTON,0,7,217,10
+ CONTROL "Direct mode",IDC_HIDVOL_WIZ_MODE_DIRECT,"Button",BS_AUTORADIOBUTTON,0,87,217,10
+ LTEXT "",IDC_BOX_HELP,16,20,205,63
+ LTEXT "",IDC_BOX_HELP2,16,101,205,59
+END
+
+IDD_PASSWORD_ENTRY_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_PASSWORD_DIRECT,50,2,173,14,ES_PASSWORD | ES_AUTOHSCROLL
+ COMBOBOX IDC_PKCS5_PRF_ID,50,17,104,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ EDITTEXT IDC_PIM,50,32,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE
+ LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,96,34,127,8,NOT WS_VISIBLE
+ CONTROL "&Display password",IDC_SHOW_PASSWORD_SINGLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,46,84,11,WS_EX_TRANSPARENT
+ CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,57,94,11
+ PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,149,54,74,14
+ LTEXT "",IDC_BOX_HELP,0,74,225,94
+ RTEXT "Password:",IDT_PASSWORD,0,6,48,8
+ RTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,0,19,48,8
+ RTEXT "Volume PIM:",IDT_PIM,0,35,48,8,NOT WS_VISIBLE
+ CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,35,97,10
+END
+
+IDD_VOLUME_TYPE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Standard VeraCrypt volume",IDC_STD_VOL,"Button",BS_AUTORADIOBUTTON,0,7,212,10
+ CONTROL "Hi&dden VeraCrypt volume ",IDC_HIDDEN_VOL,"Button",BS_AUTORADIOBUTTON,0,68,212,10
+ LTEXT "More information about hidden volumes",IDC_HIDDEN_VOL_HELP,16,151,205,10,SS_NOTIFY
+ LTEXT "",IDC_BOX_HELP_NORMAL_VOL,16,20,205,41
+ LTEXT "",IDC_BOX_HELP,16,83,205,62
+END
+
+IDD_SYSENC_SPAN_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Encrypt the Windows system partition",IDC_SYS_PARTITION,
+ "Button",BS_AUTORADIOBUTTON,0,7,212,10
+ CONTROL "Encrypt the whole drive",IDC_WHOLE_SYS_DRIVE,"Button",BS_AUTORADIOBUTTON,0,53,212,10
+ LTEXT "Select this option to encrypt the partition where the currently running Windows operating system is installed.",IDT_SYS_PARTITION,16,20,205,32
+ LTEXT "",IDT_WHOLE_SYS_DRIVE,16,70,205,95
+END
+
+IDD_SYSENC_RESCUE_DISK_CREATION_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_RESCUE_DISK_ISO_PATH,0,159,163,13,ES_AUTOHSCROLL
+ PUSHBUTTON "Bro&wse...",IDC_BROWSE,166,158,59,14
+ LTEXT "",IDT_RESCUE_DISK_INFO,0,1,225,137
+ CONTROL "Skip Rescue Disk verification",IDC_SKIP_RESCUE_VERIFICATION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,145,106,10
+END
+
+IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ CONTROL "Display pool content",IDC_DISPLAY_POOL_CONTENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,1,98,122,10
+ CONTROL "",IDC_SYS_POOL_CONTENTS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,8,14,205,72,WS_EX_TRANSPARENT
+ LTEXT "IMPORTANT: Move your mouse as randomly as possible within this window. The longer you move it, the better. This significantly increases the cryptographic strength of the encryption keys. Then click Next to continue.",IDT_COLLECTING_RANDOM_DATA_NOTE,1,112,224,40
+ GROUPBOX "Current pool content (partial)",IDT_PARTIAL_POOL_CONTENTS,0,5,222,88
+ GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,0,154,224,18
+ CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",WS_BORDER,11,163,202,6
+END
+
+IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Single-boot",IDC_SINGLE_BOOT,"Button",BS_AUTORADIOBUTTON,0,7,212,10
+ CONTROL "Multi-boot",IDC_MULTI_BOOT,"Button",BS_AUTORADIOBUTTON,0,53,217,10
+ LTEXT "Select this option if there is only one operating system installed on this computer (even if it has multiple users).",IDT_SINGLE_BOOT,16,20,205,32
+ LTEXT "Select this option if there are two or more operating systems installed on this computer.\n\nFor example:\n- Windows XP and Windows XP\n- Windows XP and Windows Vista\n- Windows and Mac OS X\n- Windows and Linux\n- Windows, Linux and Mac OS X",IDT_MULTI_BOOT,16,66,205,72
+END
+
+IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Download CD/DVD recording software",IDC_DOWNLOAD_CD_BURN_SOFTWARE,0,136,217,10,SS_NOTIFY
+ LTEXT "",IDT_RESCUE_DISK_BURN_INFO,0,4,225,128
+END
+
+IDD_SYSENC_WIPE_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ COMBOBOX IDC_WIPE_MODE,61,0,127,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ RTEXT "Wipe mode:",IDT_WIPE_MODE,0,2,59,8,0,WS_EX_RIGHT
+ LTEXT "",IDT_WIPE_MODE_INFO,0,19,225,128
+END
+
+IDD_INPLACE_ENCRYPTION_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_WIPE_MODE,67,13,125,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ PUSHBUTTON "&Pause",IDC_PAUSE,169,40,50,14
+ LTEXT "More information",IDC_MORE_INFO_SYS_ENCRYPTION,1,150,202,10,SS_NOTIFY
+ LTEXT "",IDC_BYTESWRITTEN,29,58,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "",IDC_WRITESPEED,103,58,46,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "",IDC_TIMEREMAIN,177,58,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "Wipe mode:",IDT_WIPE_MODE,6,15,59,8,0,WS_EX_RIGHT
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,41,158,12
+ RTEXT "Done",IDT_DONE,5,59,22,8
+ RTEXT "Status",IDT_STATUS,72,59,29,8
+ RTEXT "Left",IDT_LEFT,151,59,24,8
+ LTEXT "",IDC_BOX_HELP,1,77,224,70
+ GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,3,225,29
+ GROUPBOX "",IDC_STATIC,0,32,225,41
+END
+
+IDD_SYSENC_KEYS_GEN_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ CONTROL "Display generated keys (their portions)",IDC_DISPLAY_KEYS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,1,94,216,10
+ CONTROL "",IDC_HEADER_KEY,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,57,71,163,8,WS_EX_TRANSPARENT
+ LTEXT "",IDC_DISK_KEY,57,79,163,8,0,WS_EX_TRANSPARENT
+ LTEXT "The keys, salt, and other data have been successfully generated. If you want to generate new keys, click Back and then Next. Otherwise, click Next to continue.",IDT_SYSENC_KEYS_GEN_INFO,1,23,224,41
+ RTEXT "Header Key: ",IDT_HEADER_KEY,2,72,54,8
+ RTEXT "Master Key: ",IDT_MASTER_KEY,2,80,54,8
+ GROUPBOX "",-1,0,65,225,26
+END
+
+IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_CHOICE1,"Button",BS_AUTORADIOBUTTON,0,7,212,10
+ CONTROL "",IDC_CHOICE2,"Button",BS_AUTORADIOBUTTON,0,17,217,10
+ LTEXT "",IDC_BOX_HELP,1,34,220,112
+END
+
+IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "",IDT_SYSENC_DRIVE_ANALYSIS_INFO,2,10,215,88
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,1,115,216,12
+ LTEXT "Progress:",IDT_PROGRESS,2,104,57,8
+END
+
+IDD_SYSENC_TYPE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Normal",IDC_SYSENC_NORMAL,"Button",BS_AUTORADIOBUTTON,0,7,212,10
+ CONTROL "Hi&dden",IDC_SYSENC_HIDDEN,"Button",BS_AUTORADIOBUTTON,0,53,212,10
+ LTEXT "More information",IDC_HIDDEN_SYSENC_INFO_LINK,16,148,205,10,SS_NOTIFY
+ LTEXT "",IDC_BOX_HELP_SYSENC_NORMAL,16,20,205,25
+ LTEXT "",IDC_BOX_HELP,16,67,205,72
+END
+
+IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "More information",IDC_HIDDEN_SYSENC_INFO_LINK,0,150,217,10,SS_NOTIFY
+ LTEXT "",IDC_BOX_HELP,0,2,225,142
+END
+
+IDD_DEVICE_WIPE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "Abort",IDC_ABORT_BUTTON,169,48,50,14
+ LTEXT "",IDC_BYTESWRITTEN,29,66,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "",IDC_WRITESPEED,103,66,46,11,SS_CENTERIMAGE | NOT WS_VISIBLE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "",IDC_TIMEREMAIN,177,66,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "Wipe mode:",IDT_WIPE_MODE,6,22,59,8,0,WS_EX_RIGHT
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,49,158,12
+ RTEXT "Done",IDT_DONE,5,67,22,8
+ RTEXT "Pass",IDT_PASS,72,67,29,8,NOT WS_VISIBLE
+ RTEXT "Left",IDT_LEFT,151,67,24,8
+ LTEXT "",IDC_BOX_HELP,1,86,224,80
+ GROUPBOX "",IDT_FORMAT_OPTIONS,0,10,225,29
+ GROUPBOX "",IDC_STATIC,0,40,225,42
+ LTEXT "",IDC_WIPE_MODE,67,21,125,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_STATICEDGE
+END
+
+IDD_DEVICE_WIPE_MODE_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ COMBOBOX IDC_WIPE_MODE,61,9,127,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ RTEXT "Wipe mode:",IDT_WIPE_MODE,0,11,59,8,0,WS_EX_RIGHT
+ LTEXT "",IDT_WIPE_MODE_INFO,0,29,225,122
+END
+
+IDD_DEVICE_TRANSFORM_MODE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Create encrypted volume and format it",IDC_DEVICE_TRANSFORM_MODE_FORMAT,
+ "Button",BS_AUTORADIOBUTTON,0,8,217,10
+ CONTROL "Encrypt partition in place",IDC_DEVICE_TRANSFORM_MODE_INPLACE,
+ "Button",BS_AUTORADIOBUTTON,0,98,217,10
+ LTEXT "",IDC_BOX_HELP,16,21,205,74
+ LTEXT "",IDC_BOX_HELP2,16,112,205,53
+END
+
+IDD_EXPANDED_LIST_SELECT_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "",IDC_BOX_HELP,0,107,225,58
+ LISTBOX IDC_LIST_BOX,0,3,222,100,LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL
+END
+
+IDD_DRIVE_LETTER_SELECTION_PAGE DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "",IDC_BOX_HELP,0,40,225,118
+ COMBOBOX IDC_DRIVE_LETTER_LIST,94,15,38,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Drive letter:",IDT_DRIVE_LETTER,5,17,86,8
+END
+
+IDD_PIM_PAGE_DLG DIALOGEX 0, 0, 226, 172
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_PIM,53,0,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "",IDC_BOX_HELP,0,32,225,126
+ RTEXT "Volume PIM:",IDT_PIM,1,3,50,8
+ LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,97,3,126,8
+ LTEXT "Information on PIM",IDC_LINK_PIM_INFO,0,161,213,8,SS_NOTIFY
+ CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,53,17,150,10
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "#include ""..\\\\common\\\\resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "#include ""..\\\\common\\\\common.rc""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_VOL_CREATION_WIZARD_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 393
+ TOPMARGIN, 1
+ BOTTOMMARGIN, 227
+ HORZGUIDE, 216
+ END
+
+ IDD_CIPHER_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 161
+ END
+
+ IDD_PASSWORD_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 143
+ END
+
+ IDD_SIZE_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_VOLUME_LOCATION_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 167
+ END
+
+ IDD_FORMAT_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 217
+ BOTTOMMARGIN, 153
+ HORZGUIDE, 80
+ HORZGUIDE, 96
+ END
+
+ IDD_INTRO_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_INFO_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_HIDVOL_HOST_FILL_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_PASSWORD_ENTRY_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 143
+ END
+
+ IDD_VOLUME_TYPE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_SYSENC_SPAN_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_SYSENC_RESCUE_DISK_CREATION_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 167
+ END
+
+ IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 217
+ BOTTOMMARGIN, 153
+ HORZGUIDE, 80
+ HORZGUIDE, 96
+ END
+
+ IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 167
+ END
+
+ IDD_SYSENC_WIPE_MODE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_INPLACE_ENCRYPTION_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 217
+ BOTTOMMARGIN, 166
+ HORZGUIDE, 80
+ HORZGUIDE, 96
+ END
+
+ IDD_SYSENC_KEYS_GEN_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 217
+ BOTTOMMARGIN, 153
+ HORZGUIDE, 80
+ HORZGUIDE, 96
+ END
+
+ IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 217
+ BOTTOMMARGIN, 153
+ HORZGUIDE, 80
+ HORZGUIDE, 96
+ END
+
+ IDD_SYSENC_TYPE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 167
+ END
+
+ IDD_DEVICE_WIPE_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 217
+ BOTTOMMARGIN, 166
+ HORZGUIDE, 80
+ HORZGUIDE, 96
+ END
+
+ IDD_DEVICE_WIPE_MODE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_DEVICE_TRANSFORM_MODE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_EXPANDED_LIST_SELECT_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_DRIVE_LETTER_SELECTION_PAGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 165
+ END
+
+ IDD_PIM_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 223
+ BOTTOMMARGIN, 171
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_WIZARD BITMAP "VeraCrypt_wizard.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_UACSTRING_FMT "VeraCrypt"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "..\\common\\common.rc"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/Format/Format.vcproj b/src/Format/Format.vcproj
index b8747baf..9fa108bc 100644
--- a/src/Format/Format.vcproj
+++ b/src/Format/Format.vcproj
@@ -1,1028 +1,1028 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="Format"
- ProjectGUID="{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}"
- RootNamespace="Format"
- Keyword="Win32Proj"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="VOLFORMAT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- BufferSecurityCheck="true"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- DebugInformationFormat="4"
- DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\Crypto\Debug\crypto.lib mpr.lib"
- OutputFile="$(OutDir)/VeraCryptFormat.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- DelayLoadDLLs="mpr.dll"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/Format.pdb"
- SubSystem="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- AdditionalManifestFiles="Format.manifest"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy Debug\VeraCryptFormat.exe &quot;..\Debug\Setup Files\VeraCrypt Format.exe&quot; &gt;NUL:&#x0D;&#x0A;"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="VOLFORMAT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- BufferSecurityCheck="true"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\Crypto\x64\Debug\crypto.lib mpr.lib"
- OutputFile="$(OutDir)/VeraCryptFormat.exe"
- LinkIncremental="2"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- DelayLoadDLLs="mpr.dll"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/Format.pdb"
- SubSystem="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- AdditionalManifestFiles="Format.manifest"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCrypt Format-x64.exe&quot; &gt;NUL:&#x0D;&#x0A;"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/w34189"
- Optimization="2"
- AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="VOLFORMAT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- RuntimeLibrary="0"
- BufferSecurityCheck="true"
- UsePrecompiledHeader="0"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)/"
- WarningLevel="4"
- DebugInformationFormat="0"
- DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\Crypto\Release\crypto.lib mpr.lib"
- OutputFile="$(OutDir)/VeraCryptFormat.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- DelayLoadDLLs="mpr.dll"
- GenerateDebugInformation="false"
- GenerateMapFile="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- AdditionalManifestFiles="Format.manifest"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- CommandLine="copy Release\VeraCryptFormat.exe &quot;..\Release\Setup Files\VeraCrypt Format.exe&quot;"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/w34189"
- Optimization="2"
- AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="VOLFORMAT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- RuntimeLibrary="0"
- BufferSecurityCheck="true"
- UsePrecompiledHeader="0"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)/"
- WarningLevel="4"
- DebugInformationFormat="0"
- DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="..\Crypto\x64\Release\crypto.lib mpr.lib"
- OutputFile="$(OutDir)/VeraCryptFormat.exe"
- LinkIncremental="1"
- GenerateManifest="false"
- IgnoreAllDefaultLibraries="false"
- DelayLoadDLLs="mpr.dll"
- GenerateDebugInformation="false"
- GenerateMapFile="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- AdditionalManifestFiles="Format.manifest"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- CommandLine="copy $(TargetPath) &quot;..\Release\Setup Files\VeraCrypt Format-x64.exe&quot;"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\FormatCom.cpp"
- >
- </File>
- <File
- RelativePath=".\FormatCom.idl"
- >
- </File>
- <File
- RelativePath=".\InPlace.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\Tcformat.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- </File>
- <Filter
- Name="Common"
- >
- <File
- RelativePath="..\Common\BaseCom.cpp"
- >
- </File>
- <File
- RelativePath="..\Common\BootEncryption.cpp"
- >
- </File>
- <File
- RelativePath="..\Common\Cmdline.c"
- >
- </File>
- <File
- RelativePath="..\Common\Combo.c"
- >
- </File>
- <File
- RelativePath="..\Common\Crc.c"
- >
- </File>
- <File
- RelativePath="..\Common\Crypto.c"
- >
- </File>
- <File
- RelativePath="..\Common\Dictionary.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Common\Dlgcode.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Common\EncryptionThreadPool.c"
- >
- </File>
- <File
- RelativePath="..\Common\Endian.c"
- >
- </File>
- <File
- RelativePath="..\Common\Fat.c"
- >
- </File>
- <File
- RelativePath="..\Common\Format.c"
- >
- </File>
- <File
- RelativePath="..\Common\GfMul.c"
- >
- </File>
- <File
- RelativePath="..\Common\Keyfiles.c"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- CompileAs="2"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Common\Language.c"
- >
- </File>
- <File
- RelativePath="..\Common\Password.c"
- >
- </File>
- <File
- RelativePath="..\Common\Pkcs5.c"
- >
- </File>
- <File
- RelativePath="..\Common\Progress.c"
- >
- </File>
- <File
- RelativePath="..\Common\Random.c"
- >
- </File>
- <File
- RelativePath="..\Common\Registry.c"
- >
- </File>
- <File
- RelativePath="..\Common\SecurityToken.cpp"
- >
- </File>
- <File
- RelativePath="..\Common\Tests.c"
- >
- </File>
- <File
- RelativePath="..\Common\Volumes.c"
- >
- </File>
- <File
- RelativePath="..\Common\Wipe.c"
- >
- </File>
- <File
- RelativePath="..\Common\Xml.c"
- >
- </File>
- <File
- RelativePath="..\Common\Xts.c"
- >
- </File>
- </Filter>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\Common\BaseCom.h"
- >
- </File>
- <File
- RelativePath="..\Common\Common.h"
- >
- </File>
- <File
- RelativePath="..\Common\Crc.h"
- >
- </File>
- <File
- RelativePath="..\Common\Crypto.h"
- >
- </File>
- <File
- RelativePath="..\Common\Dictionary.h"
- >
- </File>
- <File
- RelativePath="..\Common\Dlgcode.h"
- >
- </File>
- <File
- RelativePath="..\Common\EncryptionThreadPool.h"
- >
- </File>
- <File
- RelativePath="..\Common\Endian.h"
- >
- </File>
- <File
- RelativePath="..\Common\Exception.h"
- >
- </File>
- <File
- RelativePath="..\Common\Fat.h"
- >
- </File>
- <File
- RelativePath="..\Common\Format.h"
- >
- </File>
- <File
- RelativePath=".\FormatCom.h"
- >
- </File>
- <File
- RelativePath="..\Common\GfMul.h"
- >
- </File>
- <File
- RelativePath=".\InPlace.h"
- >
- </File>
- <File
- RelativePath="..\Common\Keyfiles.h"
- >
- </File>
- <File
- RelativePath="..\Common\Language.h"
- >
- </File>
- <File
- RelativePath="..\Mount\Mount.h"
- >
- </File>
- <File
- RelativePath="..\Common\Pkcs5.h"
- >
- </File>
- <File
- RelativePath="..\Common\Progress.h"
- >
- </File>
- <File
- RelativePath="..\Common\Random.h"
- >
- </File>
- <File
- RelativePath="..\Common\Registry.h"
- >
- </File>
- <File
- RelativePath=".\resource.h"
- >
- </File>
- <File
- RelativePath="..\Common\Resource.h"
- >
- </File>
- <File
- RelativePath="..\Common\SecurityToken.h"
- >
- </File>
- <File
- RelativePath="..\Common\Tcdefs.h"
- >
- </File>
- <File
- RelativePath=".\Tcformat.h"
- >
- </File>
- <File
- RelativePath="..\Common\Tests.h"
- >
- </File>
- <File
- RelativePath="..\Common\Volumes.h"
- >
- </File>
- <File
- RelativePath="..\Common\Wipe.h"
- >
- </File>
- <File
- RelativePath="..\Common\Xml.h"
- >
- </File>
- <File
- RelativePath="..\Common\Xts.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- <File
- RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_AES_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootSector.bin"
- >
- </File>
- <File
- RelativePath=".\Format.manifest"
- >
- </File>
- <File
- RelativePath=".\Format.rc"
- >
- </File>
- <File
- RelativePath=".\Format.tlb"
- SubType="Designer"
- >
- </File>
- <File
- RelativePath="..\Common\VeraCrypt_mounted.ico"
- >
- </File>
- <File
- RelativePath="..\Common\VeraCrypt_Volume.ico"
- >
- </File>
- <File
- RelativePath=".\VeraCrypt_wizard.bmp"
- >
- </File>
- <Filter
- Name="Common"
- >
- <File
- RelativePath="..\Boot\Windows\Release_AES\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_Twofish\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Serpent\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_AES\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Twofish\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_Serpent\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_AES\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_Serpent\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Serpent\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Twofish\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_Twofish\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_AES\BootSector.bin"
- >
- </File>
- <File
- RelativePath="..\Common\Common.rc"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCResourceCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCResourceCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCResourceCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCResourceCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\Boot\Windows\Release\Decompressor.com"
- >
- </File>
- <File
- RelativePath="..\Common\Language.xml"
- >
- </File>
- <File
- RelativePath="..\Resources\Texts\License.rtf"
- >
- </File>
- <File
- RelativePath="..\Common\Textual_logo_288dpi.bmp"
- >
- </File>
- <File
- RelativePath="..\Common\Textual_logo_96dpi.bmp"
- >
- </File>
- <File
- RelativePath="..\Common\Textual_logo_background.bmp"
- >
- </File>
- <File
- RelativePath="..\Common\VeraCrypt.ico"
- >
- </File>
- </Filter>
- </Filter>
- <File
- RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_SHA2\BootLoader.com.gz"
- >
- </File>
- <File
- RelativePath="..\Boot\Windows\Release_AES_SHA2\BootLoader.com.gz"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="Format"
+ ProjectGUID="{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}"
+ RootNamespace="Format"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
+ PreprocessorDefinitions="VOLFORMAT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ BufferSecurityCheck="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ DebugInformationFormat="4"
+ DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="..\Crypto\Debug\crypto.lib mpr.lib"
+ OutputFile="$(OutDir)/VeraCryptFormat.exe"
+ LinkIncremental="2"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ DelayLoadDLLs="mpr.dll"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/Format.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="Format.manifest"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy Debug\VeraCryptFormat.exe &quot;..\Debug\Setup Files\VeraCrypt Format.exe&quot; &gt;NUL:&#x0D;&#x0A;"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
+ PreprocessorDefinitions="VOLFORMAT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ BufferSecurityCheck="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="..\Crypto\x64\Debug\crypto.lib mpr.lib"
+ OutputFile="$(OutDir)/VeraCryptFormat.exe"
+ LinkIncremental="2"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ DelayLoadDLLs="mpr.dll"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/Format.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="Format.manifest"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCrypt Format-x64.exe&quot; &gt;NUL:&#x0D;&#x0A;"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/w34189"
+ Optimization="2"
+ AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
+ PreprocessorDefinitions="VOLFORMAT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="true"
+ UsePrecompiledHeader="0"
+ AssemblerOutput="2"
+ AssemblerListingLocation="$(IntDir)/"
+ WarningLevel="4"
+ DebugInformationFormat="0"
+ DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="..\Crypto\Release\crypto.lib mpr.lib"
+ OutputFile="$(OutDir)/VeraCryptFormat.exe"
+ LinkIncremental="1"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ DelayLoadDLLs="mpr.dll"
+ GenerateDebugInformation="false"
+ GenerateMapFile="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="Format.manifest"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy Release\VeraCryptFormat.exe &quot;..\Release\Setup Files\VeraCrypt Format.exe&quot;"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/w34189"
+ Optimization="2"
+ AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
+ PreprocessorDefinitions="VOLFORMAT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="true"
+ UsePrecompiledHeader="0"
+ AssemblerOutput="2"
+ AssemblerListingLocation="$(IntDir)/"
+ WarningLevel="4"
+ DebugInformationFormat="0"
+ DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="..\Crypto\x64\Release\crypto.lib mpr.lib"
+ OutputFile="$(OutDir)/VeraCryptFormat.exe"
+ LinkIncremental="1"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ DelayLoadDLLs="mpr.dll"
+ GenerateDebugInformation="false"
+ GenerateMapFile="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="Format.manifest"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy $(TargetPath) &quot;..\Release\Setup Files\VeraCrypt Format-x64.exe&quot;"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\FormatCom.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\FormatCom.idl"
+ >
+ </File>
+ <File
+ RelativePath=".\InPlace.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Tcformat.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <Filter
+ Name="Common"
+ >
+ <File
+ RelativePath="..\Common\BaseCom.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\BootEncryption.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Cmdline.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Combo.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crypto.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Dictionary.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\Dlgcode.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\EncryptionThreadPool.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Endian.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Fat.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Format.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\GfMul.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Keyfiles.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\Language.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Password.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Pkcs5.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Progress.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Random.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Registry.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\SecurityToken.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Tests.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Volumes.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Wipe.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xml.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xts.c"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\Common\BaseCom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Common.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crypto.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Dictionary.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Dlgcode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\EncryptionThreadPool.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Endian.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Exception.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Fat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Format.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FormatCom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\GfMul.h"
+ >
+ </File>
+ <File
+ RelativePath=".\InPlace.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Keyfiles.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Language.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Mount\Mount.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Pkcs5.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Progress.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Random.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Registry.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\SecurityToken.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Tcdefs.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Tcformat.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Tests.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Volumes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Wipe.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xml.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xts.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath=".\Format.manifest"
+ >
+ </File>
+ <File
+ RelativePath=".\Format.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\Format.tlb"
+ SubType="Designer"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\VeraCrypt_mounted.ico"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\VeraCrypt_Volume.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\VeraCrypt_wizard.bmp"
+ >
+ </File>
+ <Filter
+ Name="Common"
+ >
+ <File
+ RelativePath="..\Boot\Windows\Release_AES\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Common.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release\Decompressor.com"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Language.xml"
+ >
+ </File>
+ <File
+ RelativePath="..\Resources\Texts\License.rtf"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Textual_logo_288dpi.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Textual_logo_96dpi.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Textual_logo_background.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\VeraCrypt.ico"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp
index 2dd5fa79..96e3e3cd 100644
--- a/src/Format/FormatCom.cpp
+++ b/src/Format/FormatCom.cpp
@@ -1,248 +1,248 @@
-/*
- Derived from source code of TrueCrypt 7.1a, which is
- Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
- by the TrueCrypt License 3.0.
-
- 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 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
- code distribution packages.
-*/
-
-#include <atlcomcli.h>
-#include <atlconv.h>
-#include <comutil.h>
-#include <windows.h>
-#include "BaseCom.h"
-#include "BootEncryption.h"
-#include "Dlgcode.h"
-#include "Format.h"
-#include "Progress.h"
-#include "TcFormat.h"
-#include "FormatCom.h"
-#include "FormatCom_h.h"
-#include "FormatCom_i.c"
-
-using namespace VeraCrypt;
-
-static volatile LONG ObjectCount = 0;
-
-class TrueCryptFormatCom : public ITrueCryptFormatCom
-{
-
-public:
- TrueCryptFormatCom (DWORD messageThreadId) : RefCount (0),
- MessageThreadId (messageThreadId),
- CallBack (NULL)
- {
- InterlockedIncrement (&ObjectCount);
- }
-
- virtual ~TrueCryptFormatCom ()
- {
- if (InterlockedDecrement (&ObjectCount) == 0)
- PostThreadMessage (MessageThreadId, WM_APP, 0, 0);
- }
-
- virtual ULONG STDMETHODCALLTYPE AddRef ()
- {
- return InterlockedIncrement (&RefCount);
- }
-
- virtual ULONG STDMETHODCALLTYPE Release ()
- {
- if (!InterlockedDecrement (&RefCount))
- {
- delete this;
- return 0;
- }
-
- return RefCount;
- }
-
- virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppvObject)
- {
- if (riid == IID_IUnknown || riid == IID_ITrueCryptFormatCom)
- *ppvObject = this;
- else
- {
- *ppvObject = NULL;
- return E_NOINTERFACE;
- }
-
- AddRef ();
- return S_OK;
- }
-
- virtual DWORD STDMETHODCALLTYPE CallDriver (DWORD ioctl, BSTR input, BSTR *output)
- {
- return BaseCom::CallDriver (ioctl, input, output);
- }
-
- virtual DWORD STDMETHODCALLTYPE CopyFile (BSTR sourceFile, BSTR destinationFile)
- {
- return BaseCom::CopyFile (sourceFile, destinationFile);
- }
-
- virtual DWORD STDMETHODCALLTYPE DeleteFile (BSTR file)
- {
- return BaseCom::DeleteFile (file);
- }
-
- virtual BOOL STDMETHODCALLTYPE FormatNtfs (int driveNo, int clusterSize)
- {
- return ::FormatNtfs (driveNo, clusterSize);
- }
-
- virtual int STDMETHODCALLTYPE AnalyzeHiddenVolumeHost (
- LONG_PTR hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters)
- {
- return ::AnalyzeHiddenVolumeHost (
- (HWND) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
- }
-
- virtual DWORD STDMETHODCALLTYPE ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone)
- {
- return BaseCom::ReadWriteFile (write, device, filePath, bufferBstr, offset, size, sizeDone);
- }
-
- virtual DWORD STDMETHODCALLTYPE RegisterFilterDriver (BOOL registerDriver, int filterType)
- {
- return BaseCom::RegisterFilterDriver (registerDriver, filterType);
- }
-
- virtual DWORD STDMETHODCALLTYPE RegisterSystemFavoritesService (BOOL registerService)
- {
- return BaseCom::RegisterSystemFavoritesService (registerService);
- }
-
- virtual DWORD STDMETHODCALLTYPE SetDriverServiceStartType (DWORD startType)
- {
- return BaseCom::SetDriverServiceStartType (startType);
- }
-
- virtual BOOL STDMETHODCALLTYPE IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
- {
- return BaseCom::IsPagingFileActive (checkNonWindowsPartitionsOnly);
- }
-
- virtual DWORD STDMETHODCALLTYPE WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value)
- {
- return BaseCom::WriteLocalMachineRegistryDwordValue (keyPath, valueName, value);
- }
-
- virtual BOOL STDMETHODCALLTYPE FormatFs (int driveNo, int clusterSize, int fsType)
- {
- return ::FormatFs (driveNo, clusterSize, fsType);
- }
-
-protected:
- DWORD MessageThreadId;
- LONG RefCount;
- ITrueCryptFormatCom *CallBack;
-};
-
-
-extern "C" BOOL ComServerFormat ()
-{
- SetProcessShutdownParameters (0x100, 0);
-
- TrueCryptFactory<TrueCryptFormatCom> factory (GetCurrentThreadId ());
- DWORD cookie;
-
- if (IsUacSupported ())
- UacElevated = TRUE;
-
- if (CoRegisterClassObject (CLSID_TrueCryptFormatCom, (LPUNKNOWN) &factory,
- CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &cookie) != S_OK)
- return FALSE;
-
- MSG msg;
- while (int r = GetMessageW (&msg, NULL, 0, 0))
- {
- if (r == -1)
- return FALSE;
-
- TranslateMessage (&msg);
- DispatchMessageW (&msg);
-
- if (msg.message == WM_APP
- && ObjectCount < 1
- && !factory.IsServerLocked ())
- break;
- }
- CoRevokeClassObject (cookie);
-
- return TRUE;
-}
-
-
-static BOOL ComGetInstance (HWND hWnd, ITrueCryptFormatCom **tcServer)
-{
- return ComGetInstanceBase (hWnd, CLSID_TrueCryptFormatCom, IID_ITrueCryptFormatCom, (void **) tcServer);
-}
-
-
-ITrueCryptFormatCom *GetElevatedInstance (HWND parent)
-{
- ITrueCryptFormatCom *instance;
-
- if (!ComGetInstance (parent, &instance))
- throw UserAbort (SRC_POS);
-
- return instance;
-}
-
-
-extern "C" int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize)
-{
- CComPtr<ITrueCryptFormatCom> tc;
- int r;
-
- CoInitialize (NULL);
-
- if (ComGetInstance (hWnd, &tc))
- r = tc->FormatNtfs (driveNo, clusterSize);
- else
- r = 0;
-
- CoUninitialize ();
-
- return r;
-}
-
-extern "C" int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType)
-{
- CComPtr<ITrueCryptFormatCom> tc;
- int r;
-
- CoInitialize (NULL);
-
- if (ComGetInstance (hWnd, &tc))
- r = tc->FormatFs (driveNo, clusterSize, fsType);
- else
- r = 0;
-
- CoUninitialize ();
-
- return r;
-}
-
-
-extern "C" int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters)
-{
- CComPtr<ITrueCryptFormatCom> tc;
- int r;
-
- CoInitialize (NULL);
-
- if (ComGetInstance (hwndDlg, &tc))
- r = tc->AnalyzeHiddenVolumeHost ((LONG_PTR) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
- else
- r = 0;
-
- CoUninitialize ();
-
- return r;
-}
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ 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 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
+ code distribution packages.
+*/
+
+#include <atlcomcli.h>
+#include <atlconv.h>
+#include <comutil.h>
+#include <windows.h>
+#include "BaseCom.h"
+#include "BootEncryption.h"
+#include "Dlgcode.h"
+#include "Format.h"
+#include "Progress.h"
+#include "TcFormat.h"
+#include "FormatCom.h"
+#include "FormatCom_h.h"
+#include "FormatCom_i.c"
+
+using namespace VeraCrypt;
+
+static volatile LONG ObjectCount = 0;
+
+class TrueCryptFormatCom : public ITrueCryptFormatCom
+{
+
+public:
+ TrueCryptFormatCom (DWORD messageThreadId) : RefCount (0),
+ MessageThreadId (messageThreadId),
+ CallBack (NULL)
+ {
+ InterlockedIncrement (&ObjectCount);
+ }
+
+ virtual ~TrueCryptFormatCom ()
+ {
+ if (InterlockedDecrement (&ObjectCount) == 0)
+ PostThreadMessage (MessageThreadId, WM_APP, 0, 0);
+ }
+
+ virtual ULONG STDMETHODCALLTYPE AddRef ()
+ {
+ return InterlockedIncrement (&RefCount);
+ }
+
+ virtual ULONG STDMETHODCALLTYPE Release ()
+ {
+ if (!InterlockedDecrement (&RefCount))
+ {
+ delete this;
+ return 0;
+ }
+
+ return RefCount;
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppvObject)
+ {
+ if (riid == IID_IUnknown || riid == IID_ITrueCryptFormatCom)
+ *ppvObject = this;
+ else
+ {
+ *ppvObject = NULL;
+ return E_NOINTERFACE;
+ }
+
+ AddRef ();
+ return S_OK;
+ }
+
+ virtual DWORD STDMETHODCALLTYPE CallDriver (DWORD ioctl, BSTR input, BSTR *output)
+ {
+ return BaseCom::CallDriver (ioctl, input, output);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE CopyFile (BSTR sourceFile, BSTR destinationFile)
+ {
+ return BaseCom::CopyFile (sourceFile, destinationFile);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE DeleteFile (BSTR file)
+ {
+ return BaseCom::DeleteFile (file);
+ }
+
+ virtual BOOL STDMETHODCALLTYPE FormatNtfs (int driveNo, int clusterSize)
+ {
+ return ::FormatNtfs (driveNo, clusterSize);
+ }
+
+ virtual int STDMETHODCALLTYPE AnalyzeHiddenVolumeHost (
+ LONG_PTR hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters)
+ {
+ return ::AnalyzeHiddenVolumeHost (
+ (HWND) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone)
+ {
+ return BaseCom::ReadWriteFile (write, device, filePath, bufferBstr, offset, size, sizeDone);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE RegisterFilterDriver (BOOL registerDriver, int filterType)
+ {
+ return BaseCom::RegisterFilterDriver (registerDriver, filterType);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE RegisterSystemFavoritesService (BOOL registerService)
+ {
+ return BaseCom::RegisterSystemFavoritesService (registerService);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE SetDriverServiceStartType (DWORD startType)
+ {
+ return BaseCom::SetDriverServiceStartType (startType);
+ }
+
+ virtual BOOL STDMETHODCALLTYPE IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
+ {
+ return BaseCom::IsPagingFileActive (checkNonWindowsPartitionsOnly);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value)
+ {
+ return BaseCom::WriteLocalMachineRegistryDwordValue (keyPath, valueName, value);
+ }
+
+ virtual BOOL STDMETHODCALLTYPE FormatFs (int driveNo, int clusterSize, int fsType)
+ {
+ return ::FormatFs (driveNo, clusterSize, fsType);
+ }
+
+protected:
+ DWORD MessageThreadId;
+ LONG RefCount;
+ ITrueCryptFormatCom *CallBack;
+};
+
+
+extern "C" BOOL ComServerFormat ()
+{
+ SetProcessShutdownParameters (0x100, 0);
+
+ TrueCryptFactory<TrueCryptFormatCom> factory (GetCurrentThreadId ());
+ DWORD cookie;
+
+ if (IsUacSupported ())
+ UacElevated = TRUE;
+
+ if (CoRegisterClassObject (CLSID_TrueCryptFormatCom, (LPUNKNOWN) &factory,
+ CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &cookie) != S_OK)
+ return FALSE;
+
+ MSG msg;
+ while (int r = GetMessageW (&msg, NULL, 0, 0))
+ {
+ if (r == -1)
+ return FALSE;
+
+ TranslateMessage (&msg);
+ DispatchMessageW (&msg);
+
+ if (msg.message == WM_APP
+ && ObjectCount < 1
+ && !factory.IsServerLocked ())
+ break;
+ }
+ CoRevokeClassObject (cookie);
+
+ return TRUE;
+}
+
+
+static BOOL ComGetInstance (HWND hWnd, ITrueCryptFormatCom **tcServer)
+{
+ return ComGetInstanceBase (hWnd, CLSID_TrueCryptFormatCom, IID_ITrueCryptFormatCom, (void **) tcServer);
+}
+
+
+ITrueCryptFormatCom *GetElevatedInstance (HWND parent)
+{
+ ITrueCryptFormatCom *instance;
+
+ if (!ComGetInstance (parent, &instance))
+ throw UserAbort (SRC_POS);
+
+ return instance;
+}
+
+
+extern "C" int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize)
+{
+ CComPtr<ITrueCryptFormatCom> tc;
+ int r;
+
+ CoInitialize (NULL);
+
+ if (ComGetInstance (hWnd, &tc))
+ r = tc->FormatNtfs (driveNo, clusterSize);
+ else
+ r = 0;
+
+ CoUninitialize ();
+
+ return r;
+}
+
+extern "C" int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType)
+{
+ CComPtr<ITrueCryptFormatCom> tc;
+ int r;
+
+ CoInitialize (NULL);
+
+ if (ComGetInstance (hWnd, &tc))
+ r = tc->FormatFs (driveNo, clusterSize, fsType);
+ else
+ r = 0;
+
+ CoUninitialize ();
+
+ return r;
+}
+
+
+extern "C" int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters)
+{
+ CComPtr<ITrueCryptFormatCom> tc;
+ int r;
+
+ CoInitialize (NULL);
+
+ if (ComGetInstance (hwndDlg, &tc))
+ r = tc->AnalyzeHiddenVolumeHost ((LONG_PTR) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
+ else
+ r = 0;
+
+ CoUninitialize ();
+
+ return r;
+}
diff --git a/src/Format/FormatCom.h b/src/Format/FormatCom.h
index e79cd9cc..65fadbe9 100644
--- a/src/Format/FormatCom.h
+++ b/src/Format/FormatCom.h
@@ -1,37 +1,37 @@
-/*
- Derived from source code of TrueCrypt 7.1a, which is
- Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
- by the TrueCrypt License 3.0.
-
- 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 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
- code distribution packages.
-*/
-
-#ifndef TC_HEADER_FORMAT_COM
-#define TC_HEADER_FORMAT_COM
-
-#include <windows.h>
-
-#ifdef __cplusplus
-
-#include "FormatCom_h.h"
-ITrueCryptFormatCom *GetElevatedInstance (HWND parent);
-
-extern "C" {
-#endif
-
-BOOL ComServerFormat ();
-int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize);
-int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType);
-int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters);
-int UacFormatVolume (char *cvolumePath , BOOL bDevice , unsigned __int64 size , unsigned __int64 hiddenVolHostSize , Password *password , int cipher , int pkcs5 , BOOL quickFormat, BOOL sparseFileSwitch, int fileSystem , int clusterSize, HWND hwndDlg , BOOL hiddenVol , int *realClusterSize);
-BOOL UacUpdateProgressBar (__int64 nSecNo, BOOL *bVolTransformThreadCancel);
-
-#ifdef __cplusplus
-}
-#endif
-
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ 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 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
+ code distribution packages.
+*/
+
+#ifndef TC_HEADER_FORMAT_COM
+#define TC_HEADER_FORMAT_COM
+
+#include <windows.h>
+
+#ifdef __cplusplus
+
+#include "FormatCom_h.h"
+ITrueCryptFormatCom *GetElevatedInstance (HWND parent);
+
+extern "C" {
+#endif
+
+BOOL ComServerFormat ();
+int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize);
+int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType);
+int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters);
+int UacFormatVolume (char *cvolumePath , BOOL bDevice , unsigned __int64 size , unsigned __int64 hiddenVolHostSize , Password *password , int cipher , int pkcs5 , BOOL quickFormat, BOOL sparseFileSwitch, int fileSystem , int clusterSize, HWND hwndDlg , BOOL hiddenVol , int *realClusterSize);
+BOOL UacUpdateProgressBar (__int64 nSecNo, BOOL *bVolTransformThreadCancel);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // TC_HEADER_FORMAT_COM \ No newline at end of file
diff --git a/src/Format/FormatCom.idl b/src/Format/FormatCom.idl
index 5579d28d..23d987a7 100644
--- a/src/Format/FormatCom.idl
+++ b/src/Format/FormatCom.idl
@@ -1,53 +1,53 @@
-/*
- Derived from source code of TrueCrypt 7.1a, which is
- Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
- by the TrueCrypt License 3.0.
-
- 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 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
- code distribution packages.
-*/
-
-import "wtypes.idl";
-import "..\Common\Password.h";
-
-[
- uuid(56327DDA-F1A7-4e13-B128-520D129BDEF6),
- helpstring("VeraCrypt Format UAC Support Library"),
- version(2.5) // Update ComSetup.cpp when changing version number
-]
-library TrueCryptFormatCom
-{
- [
- uuid(7AB357D9-A17F-466e-BCD6-F49E97C218D8),
- object,
- oleautomation,
- helpstring("VeraCrypt Format UAC Support Interface")
- ]
- interface ITrueCryptFormatCom : IUnknown
- {
- int AnalyzeHiddenVolumeHost (LONG_PTR hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters);
- DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output);
- DWORD CopyFile (BSTR sourceFile, BSTR destinationFile);
- DWORD DeleteFile (BSTR file);
- BOOL FormatNtfs (int driveNo, int clusterSize);
- BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
- DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone);
- DWORD RegisterFilterDriver (BOOL registerDriver, int filterType);
- DWORD RegisterSystemFavoritesService (BOOL registerService);
- DWORD SetDriverServiceStartType (DWORD startType);
- DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value);
- BOOL FormatFs (int driveNo, int clusterSize, int fsType);
- };
-
- [
- uuid(A96D3797-9F31-49f4-A0CE-9657392CF789),
- helpstring("VeraCrypt Format UAC Support Coclass")
- ]
- coclass TrueCryptFormatCom
- {
- [default] interface ITrueCryptFormatCom;
- }
-}
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ 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 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
+ code distribution packages.
+*/
+
+import "wtypes.idl";
+import "..\Common\Password.h";
+
+[
+ uuid(56327DDA-F1A7-4e13-B128-520D129BDEF6),
+ helpstring("VeraCrypt Format UAC Support Library"),
+ version(2.5) // Update ComSetup.cpp when changing version number
+]
+library TrueCryptFormatCom
+{
+ [
+ uuid(7AB357D9-A17F-466e-BCD6-F49E97C218D8),
+ object,
+ oleautomation,
+ helpstring("VeraCrypt Format UAC Support Interface")
+ ]
+ interface ITrueCryptFormatCom : IUnknown
+ {
+ int AnalyzeHiddenVolumeHost (LONG_PTR hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters);
+ DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output);
+ DWORD CopyFile (BSTR sourceFile, BSTR destinationFile);
+ DWORD DeleteFile (BSTR file);
+ BOOL FormatNtfs (int driveNo, int clusterSize);
+ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
+ DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone);
+ DWORD RegisterFilterDriver (BOOL registerDriver, int filterType);
+ DWORD RegisterSystemFavoritesService (BOOL registerService);
+ DWORD SetDriverServiceStartType (DWORD startType);
+ DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value);
+ BOOL FormatFs (int driveNo, int clusterSize, int fsType);
+ };
+
+ [
+ uuid(A96D3797-9F31-49f4-A0CE-9657392CF789),
+ helpstring("VeraCrypt Format UAC Support Coclass")
+ ]
+ coclass TrueCryptFormatCom
+ {
+ [default] interface ITrueCryptFormatCom;
+ }
+}
diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c
index 720b9466..d3b3212b 100644
--- a/src/Format/InPlace.c
+++ b/src/Format/InPlace.c
@@ -1,2293 +1,2293 @@
-/*
- Derived from source code of TrueCrypt 7.1a, which is
- Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
- by the TrueCrypt License 3.0.
-
- 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 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
- code distribution packages.
-*/
-
-
-/* In this file, _WIN32_WINNT is defined as 0x0600 to make filesystem shrink available (Vista
-or later). _WIN32_WINNT cannot be defined as 0x0600 for the entire user-space projects
-because it breaks the main font app when the app is running on XP (likely an MS bug).
-IMPORTANT: Due to this issue, functions in this file must not directly interact with GUI. */
-#define TC_LOCAL_WIN32_WINNT_OVERRIDE 1
-#if (_WIN32_WINNT < 0x0600)
-# undef _WIN32_WINNT
-# define _WIN32_WINNT 0x0600
-#endif
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <string>
-#include <intsafe.h>
-
-#include "Tcdefs.h"
-#include "Platform/Finally.h"
-
-#include "Common.h"
-#include "Crc.h"
-#include "Dlgcode.h"
-#include "Language.h"
-#include "Tcformat.h"
-#include "Volumes.h"
-
-#include "InPlace.h"
-
-#include <Strsafe.h>
-
-using namespace std;
-using namespace VeraCrypt;
-
-#if TC_VOLUME_DATA_OFFSET != 131072
-# error TC_VOLUME_DATA_OFFSET != 131072
-#endif
-
-#if TC_VOLUME_HEADER_EFFECTIVE_SIZE != 512
-# error TC_VOLUME_HEADER_EFFECTIVE_SIZE != 512
-#endif
-
-#if TC_TOTAL_VOLUME_HEADERS_SIZE != 262144
-# error TC_TOTAL_VOLUME_HEADERS_SIZE != 262144
-#endif
-
-#define TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE (2048 * BYTES_PER_KB)
-#define TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE (2 * TC_MAX_VOLUME_SECTOR_SIZE)
-#define TC_NTFS_CONCEAL_CONSTANT 0xFF
-#define TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL (64 * BYTES_PER_MB)
-#define TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE (TC_TOTAL_VOLUME_HEADERS_SIZE + TC_MIN_NTFS_FS_SIZE * 2)
-
-
-// If the returned value is greater than 0, it is the desired volume size in NTFS sectors (not in bytes)
-// after shrinking has been performed. If there's any error, returns -1.
-static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const wchar_t *devicePath, int64 *totalClusterCount, DWORD *bytesPerCluster, BOOL silent)
-{
- NTFS_VOLUME_DATA_BUFFER ntfsVolData;
- DWORD nBytesReturned;
- __int64 fileSysSize, desiredNbrSectors;
-
- // Filesystem size and sector size
-
- if (!DeviceIoControl (dev,
- FSCTL_GET_NTFS_VOLUME_DATA,
- NULL,
- 0,
- (LPVOID) &ntfsVolData,
- sizeof (ntfsVolData),
- &nBytesReturned,
- NULL))
- {
- if (!silent)
- handleWin32Error (MainDlg, SRC_POS);
-
- return -1;
- }
-
- if ( (ntfsVolData.NumberSectors.QuadPart <= 0)
- || (ntfsVolData.NumberSectors.QuadPart > (INT64_MAX / (__int64) ntfsVolData.BytesPerSector)) // overflow test
- )
- {
- SetLastError (ERROR_INTERNAL_ERROR);
- if (!silent)
- handleWin32Error (MainDlg, SRC_POS);
-
- return -1;
- }
-
- fileSysSize = ntfsVolData.NumberSectors.QuadPart * ntfsVolData.BytesPerSector;
-
- desiredNbrSectors = (fileSysSize - TC_TOTAL_VOLUME_HEADERS_SIZE) / ntfsVolData.BytesPerSector;
-
- if (desiredNbrSectors <= 0)
- return -1;
-
- if (totalClusterCount)
- *totalClusterCount = ntfsVolData.TotalClusters.QuadPart;
- if (bytesPerCluster)
- *bytesPerCluster = ntfsVolData.BytesPerCluster;
-
- return desiredNbrSectors;
-}
-
-
-BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const wchar_t *devicePath, BOOL silent)
-{
- NTFS_VOLUME_DATA_BUFFER ntfsVolData;
- DWORD nBytesReturned;
- HANDLE dev;
- WCHAR szFileSysName [256];
- WCHAR devPath [MAX_PATH];
- WCHAR dosDev [TC_MAX_PATH] = {0};
- WCHAR devName [MAX_PATH] = {0};
- int driveLetterNo = -1;
- WCHAR szRootPath[4] = {0, L':', L'\\', 0};
- __int64 deviceSize;
- int partitionNumber = -1, driveNumber = -1;
-
-
- /* ---------- Checks that do not require admin rights ----------- */
-
-
- /* Operating system */
-
- if (CurrentOSMajor < 6)
- {
- if (!silent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "OS_NOT_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE);
-
- return FALSE;
- }
-
-
- /* Volume type (must be a partition or a dynamic volume) */
-
- if (swscanf (devicePath, L"\\Device\\HarddiskVolume%d", &partitionNumber) != 1
- && swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
- {
- if (!silent)
- Error ("INPLACE_ENC_INVALID_PATH", hwndDlg);
-
- return FALSE;
- }
-
- if (partitionNumber == 0)
- {
- if (!silent)
- Warning ("RAW_DEV_NOT_SUPPORTED_FOR_INPLACE_ENC", hwndDlg);
-
- return FALSE;
- }
-
-
- /* Admin rights */
-
- if (!IsAdmin())
- {
- // We rely on the wizard process to call us only when the whole wizard process has been elevated (so UAC
- // status can be ignored). In case the IsAdmin() detection somehow fails, we allow the user to continue.
-
- if (!silent)
- Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", hwndDlg);
- }
-
-
- /* ---------- Checks that may require admin rights ----------- */
-
-
- /* Access to the partition */
-
- StringCbCopyW (devPath, sizeof(devPath), devicePath);
-
- driveLetterNo = GetDiskDeviceDriveLetter (devPath);
-
- if (driveLetterNo >= 0)
- szRootPath[0] = (wchar_t) driveLetterNo + L'A';
-
- if (FakeDosNameForDevice (devicePath, dosDev, sizeof(dosDev), devName, sizeof(devName),FALSE) != 0)
- {
- if (!silent)
- {
- handleWin32Error (hwndDlg, SRC_POS);
- Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
- }
- return FALSE;
- }
-
- dev = OpenPartitionVolume (hwndDlg, devName,
- FALSE, // Do not require exclusive access
- TRUE, // Require shared access (must be TRUE; otherwise, volume properties will not be possible to obtain)
- FALSE, // Do not ask the user to confirm shared access (if exclusive fails)
- FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
- silent); // Silent mode
-
- if (dev == INVALID_HANDLE_VALUE)
- return FALSE;
-
-
- /* File system type */
-
- GetVolumeInformation (szRootPath, NULL, 0, NULL, NULL, NULL, szFileSysName, ARRAYSIZE (szFileSysName));
-
- if (wcsncmp (szFileSysName, L"NTFS", 4))
- {
- // The previous filesystem type detection method failed (or it's not NTFS) -- try an alternative method
-
- if (!DeviceIoControl (dev,
- FSCTL_GET_NTFS_VOLUME_DATA,
- NULL,
- 0,
- (LPVOID) &ntfsVolData,
- sizeof (ntfsVolData),
- &nBytesReturned,
- NULL))
- {
- if (!silent)
- {
- // The filesystem is not NTFS or the filesystem type could not be determined (or the NTFS filesystem
- // is dismounted).
-
- if (IsDeviceMounted (devName))
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "ONLY_NTFS_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE);
- else
- Warning ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC", hwndDlg);
- }
-
- CloseHandle (dev);
- return FALSE;
- }
- }
-
-
- /* Attempt to determine whether the filesystem can be safely shrunk */
-
- if (NewFileSysSizeAfterShrink (dev, devicePath, NULL, NULL, silent) == -1)
- {
- // Cannot determine whether shrinking is required
- if (!silent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
-
- CloseHandle (dev);
- return FALSE;
- }
-
-
- /* Partition size */
-
- deviceSize = GetDeviceSize (devicePath);
- if (deviceSize < 0)
- {
- // Cannot determine the size of the partition
- if (!silent)
- Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
-
- CloseHandle (dev);
- return FALSE;
- }
-
- if (deviceSize < TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE)
- {
- // The partition is too small
- if (!silent)
- {
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", FALSE);
- }
-
- CloseHandle (dev);
- return FALSE;
- }
-
-
- /* Free space on the filesystem */
-
- if (!DeviceIoControl (dev,
- FSCTL_GET_NTFS_VOLUME_DATA,
- NULL,
- 0,
- (LPVOID) &ntfsVolData,
- sizeof (ntfsVolData),
- &nBytesReturned,
- NULL))
- {
- if (!silent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", TRUE);
-
- CloseHandle (dev);
- return FALSE;
- }
-
- if (ntfsVolData.FreeClusters.QuadPart * ntfsVolData.BytesPerCluster < TC_TOTAL_VOLUME_HEADERS_SIZE)
- {
- if (!silent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "NOT_ENOUGH_FREE_FILESYS_SPACE_FOR_SHRINK", TRUE);
-
- CloseHandle (dev);
- return FALSE;
- }
-
-
- /* Filesystem sector size */
-
- if (ntfsVolData.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE
- || ntfsVolData.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0)
- {
- if (!silent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "SECTOR_SIZE_UNSUPPORTED", TRUE);
-
- CloseHandle (dev);
- return FALSE;
- }
-
-
- CloseHandle (dev);
- return TRUE;
-}
-
-BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const wchar_t *devicePath, BOOL silent)
-{
- int partitionNumber = -1, driveNumber = -1;
-
- /* ---------- Checks that do not require admin rights ----------- */
-
- /* Volume type (must be a partition or a dynamic volume) */
- if ((swscanf (devicePath, L"\\Device\\HarddiskVolume%d", &partitionNumber) != 1
- && swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
- || partitionNumber == 0)
- {
- if (!silent)
- Error ("INPLACE_ENC_INVALID_PATH", hwndDlg);
-
- return FALSE;
- }
-
-
- /* Admin rights */
- if (!IsAdmin())
- {
- // We rely on the wizard process to call us only when the whole wizard process has been elevated (so UAC
- // status can be ignored). In case the IsAdmin() detection somehow fails, we allow the user to continue.
-
- if (!silent)
- Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", hwndDlg);
- }
-
-
- /* ---------- Checks that may require admin rights ----------- */
-
- // [Currently none]
-
- return TRUE;
-}
-
-
-int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm)
-{
- SHRINK_VOLUME_INFORMATION shrinkVolInfo;
- signed __int64 sizeToShrinkTo;
- int nStatus = ERR_SUCCESS;
- PCRYPTO_INFO cryptoInfo = NULL;
- PCRYPTO_INFO cryptoInfo2 = NULL;
- HANDLE dev = INVALID_HANDLE_VALUE;
- DWORD dwError;
- char *header;
- WCHAR dosDev[TC_MAX_PATH] = {0};
- WCHAR devName[MAX_PATH] = {0};
- int driveLetter = -1;
- WCHAR deviceName[MAX_PATH];
- uint64 dataAreaSize;
- __int64 deviceSize;
- LARGE_INTEGER offset;
- DWORD dwResult;
- HWND hwndDlg = volParams->hwndDlg;
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING);
-
-
- if (!CheckRequirementsForNonSysInPlaceEnc (hwndDlg, volParams->volumePath, FALSE))
- return ERR_DONT_REPORT;
-
-
- header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- if (!header)
- return ERR_OUTOFMEMORY;
-
- VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
-
- deviceSize = GetDeviceSize (volParams->volumePath);
- if (deviceSize < 0)
- {
- // Cannot determine the size of the partition
- nStatus = ERR_PARAMETER_INCORRECT;
- goto closing_seq;
- }
-
- if (deviceSize < TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE)
- {
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", TRUE);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- dataAreaSize = GetVolumeDataAreaSize (volParams->hiddenVol, deviceSize);
-
- StringCchCopyW (deviceName, ARRAYSIZE(deviceName), volParams->volumePath);
-
- driveLetter = GetDiskDeviceDriveLetter (deviceName);
-
-
- if (FakeDosNameForDevice (volParams->volumePath, dosDev, sizeof(dosDev),devName, sizeof(devName),FALSE) != 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (IsDeviceMounted (devName))
- {
- dev = OpenPartitionVolume (hwndDlg, devName,
- FALSE, // Do not require exclusive access (must be FALSE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too)
- TRUE, // Require shared access (must be TRUE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too)
- FALSE, // Do not ask the user to confirm shared access (if exclusive fails)
- FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
- FALSE); // Non-silent mode
-
- if (dev == INVALID_HANDLE_VALUE)
- {
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
- }
- else
- {
- // The volume is not mounted so we can't work with the filesystem.
- Error ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC", hwndDlg);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
-
- /* Gain "raw" access to the partition (the NTFS driver guards hidden sectors). */
-
- if (!DeviceIoControl (dev,
- FSCTL_ALLOW_EXTENDED_DASD_IO,
- NULL,
- 0,
- NULL,
- 0,
- &dwResult,
- NULL))
- {
- handleWin32Error (MainDlg, SRC_POS);
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
-
-
- /* Shrink the filesystem */
-
- int64 totalClusterCount;
- DWORD bytesPerCluster;
-
- sizeToShrinkTo = NewFileSysSizeAfterShrink (dev, volParams->volumePath, &totalClusterCount, &bytesPerCluster, FALSE);
-
- if (sizeToShrinkTo == -1)
- {
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_RESIZING);
-
- memset (&shrinkVolInfo, 0, sizeof (shrinkVolInfo));
-
- shrinkVolInfo.ShrinkRequestType = ShrinkPrepare;
- shrinkVolInfo.NewNumberOfSectors = sizeToShrinkTo;
-
- if (!DeviceIoControl (dev,
- FSCTL_SHRINK_VOLUME,
- (LPVOID) &shrinkVolInfo,
- sizeof (shrinkVolInfo),
- NULL,
- 0,
- &dwResult,
- NULL))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- BOOL clustersMovedBeforeVolumeEnd = FALSE;
-
- while (true)
- {
- shrinkVolInfo.ShrinkRequestType = ShrinkCommit;
- shrinkVolInfo.NewNumberOfSectors = 0;
-
- if (!DeviceIoControl (dev, FSCTL_SHRINK_VOLUME, &shrinkVolInfo, sizeof (shrinkVolInfo), NULL, 0, &dwResult, NULL))
- {
- // If there are any occupied clusters beyond the new desired end of the volume, the call fails with
- // ERROR_ACCESS_DENIED (STATUS_ALREADY_COMMITTED).
- if (GetLastError () == ERROR_ACCESS_DENIED)
- {
- if (!clustersMovedBeforeVolumeEnd)
- {
- if (MoveClustersBeforeThreshold (dev, deviceName, totalClusterCount - (bytesPerCluster > TC_TOTAL_VOLUME_HEADERS_SIZE ? 1 : TC_TOTAL_VOLUME_HEADERS_SIZE / bytesPerCluster)))
- {
- clustersMovedBeforeVolumeEnd = TRUE;
- continue;
- }
-
- handleWin32Error (hwndDlg, SRC_POS);
- }
- }
- else
- handleWin32Error (hwndDlg, SRC_POS);
-
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- break;
- }
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING);
-
-
- /* Gain exclusive access to the volume */
-
- nStatus = DismountFileSystem (hwndDlg, dev,
- driveLetter,
- TRUE,
- TRUE,
- FALSE);
-
- if (nStatus != ERR_SUCCESS)
- {
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
-
-
- /* Create header backup on the partition. Until the volume is fully encrypted, the backup header will provide
- us with the master key, encrypted range, and other data for pause/resume operations. We cannot create the
- primary header until the entire partition is encrypted (because we encrypt backwards and the primary header
- area is occuppied by data until the very end of the process). */
-
- // Prepare the backup header
- for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++)
- {
- nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
- header,
- volParams->ea,
- FIRST_MODE_OF_OPERATION_ID,
- volParams->password,
- volParams->pkcs5,
- volParams->pim,
- wipePass == 0 ? NULL : (char *) cryptoInfo->master_keydata,
- &cryptoInfo,
- dataAreaSize,
- 0,
- TC_VOLUME_DATA_OFFSET + dataAreaSize, // Start of the encrypted area = the first byte of the backup heeader (encrypting from the end)
- 0, // No data is encrypted yet
- 0,
- volParams->headerFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC,
- volParams->sectorSize,
- wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1));
-
- if (nStatus != 0)
- goto closing_seq;
-
- offset.QuadPart = TC_VOLUME_DATA_OFFSET + dataAreaSize;
-
- if (!SetFilePointerEx (dev, offset, NULL, FILE_BEGIN))
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- // Write the backup header to the partition
- if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header))
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- // Fill the reserved sectors of the backup header area with random data
- nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, TRUE);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
- }
-
-
- /* Now we will try to decrypt the backup header to verify it has been correctly written. */
-
- nStatus = OpenBackupHeader (dev, volParams->volumePath, volParams->password, volParams->pkcs5, volParams->pim, &cryptoInfo2, NULL, deviceSize);
-
- if (nStatus != ERR_SUCCESS
- || cryptoInfo->EncryptedAreaStart.Value != cryptoInfo2->EncryptedAreaStart.Value
- || cryptoInfo2->EncryptedAreaStart.Value == 0)
- {
- if (nStatus == ERR_SUCCESS)
- nStatus = ERR_PARAMETER_INCORRECT;
-
- goto closing_seq;
- }
-
- // The backup header is valid so we know we should be able to safely resume in-place encryption
- // of this partition even if the system/app crashes.
-
-
-
- /* Conceal the NTFS filesystem (by performing an easy-to-undo modification). This will prevent Windows
- and apps from interfering with the volume until it has been fully encrypted. */
-
- nStatus = ConcealNTFS (dev);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
-
- // /* If a drive letter is assigned to the device, remove it (so that users do not try to open it, which
- //would cause Windows to ask them if they want to format the volume and other dangerous things). */
-
- //if (driveLetter >= 0)
- //{
- // char rootPath[] = { driveLetter + 'A', ':', '\\', 0 };
-
- // // Try to remove the assigned drive letter
- // if (DeleteVolumeMountPoint (rootPath))
- // driveLetter = -1;
- //}
-
-
-
- /* Update config files and app data */
-
- // In the config file, increase the number of partitions where in-place encryption is in progress
-
- SaveNonSysInPlaceEncSettings (1, wipeAlgorithm, FALSE);
-
-
- // Add the wizard to the system startup sequence if appropriate
-
- if (!IsNonInstallMode ())
- ManageStartupSeqWiz (FALSE, L"/prinplace");
-
-
- nStatus = ERR_SUCCESS;
-
-
-closing_seq:
-
- dwError = GetLastError();
-
- if (cryptoInfo != NULL)
- {
- crypto_close (cryptoInfo);
- cryptoInfo = NULL;
- }
-
- if (cryptoInfo2 != NULL)
- {
- crypto_close (cryptoInfo2);
- cryptoInfo2 = NULL;
- }
-
- burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- TCfree (header);
-
- if (dosDev[0])
- RemoveFakeDosName (volParams->volumePath, dosDev);
-
- *outHandle = dev;
-
- if (nStatus != ERR_SUCCESS)
- SetLastError (dwError);
-
- return nStatus;
-}
-
-
-int EncryptPartitionInPlaceResume (HANDLE dev,
- volatile FORMAT_VOL_PARAMETERS *volParams,
- WipeAlgorithmId wipeAlgorithm,
- volatile BOOL *bTryToCorrectReadErrors)
-{
- PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL, tmpCryptoInfo = NULL;
- UINT64_STRUCT unitNo;
- char *buf = NULL, *header = NULL;
- byte *wipeBuffer = NULL;
- byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT];
- byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT];
- WCHAR dosDev[TC_MAX_PATH] = {0};
- WCHAR devName[MAX_PATH] = {0};
- WCHAR deviceName[MAX_PATH];
- int nStatus = ERR_SUCCESS;
- __int64 deviceSize;
- uint64 remainingBytes, lastHeaderUpdateDistance = 0, zeroedSectorCount = 0;
- uint32 workChunkSize;
- DWORD dwError, dwResult;
- BOOL bPause = FALSE, bEncryptedAreaSizeChanged = FALSE;
- LARGE_INTEGER offset;
- int sectorSize;
- int i;
- DWORD n;
- WCHAR *devicePath = volParams->volumePath;
- Password *password = volParams->password;
- int pkcs5_prf = volParams->pkcs5;
- int pim = volParams->pim;
- DISK_GEOMETRY driveGeometry;
- HWND hwndDlg = volParams->hwndDlg;
-
-
- bInPlaceEncNonSysResumed = TRUE;
-
- buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
- if (!buf)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
-
- header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- if (!header)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
-
- VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
-
- if (wipeAlgorithm != TC_WIPE_NONE)
- {
- wipeBuffer = (byte *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
- if (!wipeBuffer)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
- }
-
- headerCryptoInfo = crypto_open();
-
- if (headerCryptoInfo == NULL)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
-
- deviceSize = GetDeviceSize (devicePath);
- if (deviceSize < 0)
- {
- // Cannot determine the size of the partition
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (dev == INVALID_HANDLE_VALUE)
- {
- StringCchCopyW (deviceName, ARRAYSIZE(deviceName), devicePath);
-
- if (FakeDosNameForDevice (deviceName, dosDev, sizeof(dosDev),devName, sizeof(devName),FALSE) != 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- dev = OpenPartitionVolume (hwndDlg, devName,
- FALSE, // Do not require exclusive access
- FALSE, // Do not require shared access
- TRUE, // Ask the user to confirm shared access (if exclusive fails)
- FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
- FALSE); // Non-silent mode
-
- if (dev == INVALID_HANDLE_VALUE)
- {
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
- }
-
- // This should never be needed, but is still performed for extra safety (without checking the result)
- DeviceIoControl (dev,
- FSCTL_ALLOW_EXTENDED_DASD_IO,
- NULL,
- 0,
- NULL,
- 0,
- &dwResult,
- NULL);
-
-
- if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL))
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- sectorSize = driveGeometry.BytesPerSector;
-
-
- nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
-
- remainingBytes = masterCryptoInfo->VolumeSize.Value - masterCryptoInfo->EncryptedAreaLength.Value;
-
- lastHeaderUpdateDistance = 0;
-
-
- ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_ENCRYPTING);
-
- bFirstNonSysInPlaceEncResumeDone = TRUE;
-
-
- /* The in-place encryption core */
-
- while (remainingBytes > 0)
- {
- workChunkSize = (uint32) min (remainingBytes, TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
-
- if (workChunkSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
- {
- nStatus = ERR_PARAMETER_INCORRECT;
- goto closing_seq;
- }
-
- unitNo.Value = (remainingBytes - workChunkSize + TC_VOLUME_DATA_OFFSET) / ENCRYPTION_DATA_UNIT_SIZE;
-
-
- // Read the plaintext into RAM
-
-inplace_enc_read:
-
- offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize - TC_VOLUME_DATA_OFFSET;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (ReadFile (dev, buf, workChunkSize, &n, NULL) == 0)
- {
- // Read error
-
- DWORD dwTmpErr = GetLastError ();
-
- if (IsDiskReadError (dwTmpErr) && !bVolTransformThreadCancel)
- {
- // Physical defect or data corruption
-
- if (!*bTryToCorrectReadErrors)
- {
- *bTryToCorrectReadErrors = (AskWarnYesNo ("ENABLE_BAD_SECTOR_ZEROING", hwndDlg) == IDYES);
- }
-
- if (*bTryToCorrectReadErrors)
- {
- // Try to correct the read errors physically
-
- offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize - TC_VOLUME_DATA_OFFSET;
-
- nStatus = ZeroUnreadableSectors (dev, offset, workChunkSize, sectorSize, &zeroedSectorCount);
-
- if (nStatus != ERR_SUCCESS)
- {
- // Due to write errors, we can't correct the read errors
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- goto inplace_enc_read;
- }
- }
-
- SetLastError (dwTmpErr); // Preserve the original error code
-
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (remainingBytes - workChunkSize < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE)
- {
- // We reached the inital portion of the filesystem, which we had concealed (in order to prevent
- // Windows from interfering with the volume). Now we need to undo that modification.
-
- for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE - (remainingBytes - workChunkSize); i++)
- buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
- }
-
-
- // Encrypt the plaintext in RAM
-
- EncryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
-
-
- // If enabled, wipe the area to which we will write the ciphertext
-
- if (wipeAlgorithm != TC_WIPE_NONE)
- {
- byte wipePass;
- int wipePassCount = GetWipePassCount (wipeAlgorithm);
-
- if (wipePassCount <= 0)
- {
- SetLastError (ERROR_INVALID_PARAMETER);
- nStatus = ERR_PARAMETER_INCORRECT;
- goto closing_seq;
- }
-
- offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize;
-
- for (wipePass = 1; wipePass <= wipePassCount; ++wipePass)
- {
- if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize))
- {
- ULONG i;
- for (i = 0; i < workChunkSize; ++i)
- {
- wipeBuffer[i] = buf[i] + wipePass;
- }
-
- EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
- memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate));
- }
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
- || WriteFile (dev, wipeBuffer, workChunkSize, &n, NULL) == 0)
- {
- // Write error
- dwError = GetLastError();
-
- // Undo failed write operation
- if (workChunkSize > TC_VOLUME_DATA_OFFSET && SetFilePointerEx (dev, offset, NULL, FILE_BEGIN))
- {
- DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
- WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL);
- }
-
- SetLastError (dwError);
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
- }
-
- memcpy (wipeRandChars, wipeRandCharsUpdate, sizeof (wipeRandCharsUpdate));
- }
-
-
- // Write the ciphertext
-
- offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (WriteFile (dev, buf, workChunkSize, &n, NULL) == 0)
- {
- // Write error
- dwError = GetLastError();
-
- // Undo failed write operation
- if (workChunkSize > TC_VOLUME_DATA_OFFSET && SetFilePointerEx (dev, offset, NULL, FILE_BEGIN))
- {
- DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
- WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL);
- }
-
- SetLastError (dwError);
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
- masterCryptoInfo->EncryptedAreaStart.Value -= workChunkSize;
- masterCryptoInfo->EncryptedAreaLength.Value += workChunkSize;
-
- remainingBytes -= workChunkSize;
- lastHeaderUpdateDistance += workChunkSize;
-
- bEncryptedAreaSizeChanged = TRUE;
-
- if (lastHeaderUpdateDistance >= TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL)
- {
- nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
- lastHeaderUpdateDistance = 0;
- }
-
- ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
-
- if (bVolTransformThreadCancel)
- {
- bPause = TRUE;
- break;
- }
- }
-
- nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
-
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
- if (!bPause)
- {
- /* The data area has been fully encrypted; create and write the primary volume header */
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINALIZING);
-
- for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++)
- {
- nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
- header,
- headerCryptoInfo->ea,
- headerCryptoInfo->mode,
- password,
- masterCryptoInfo->pkcs5,
- pim,
- (char *) masterCryptoInfo->master_keydata,
- &tmpCryptoInfo,
- masterCryptoInfo->VolumeSize.Value,
- 0,
- masterCryptoInfo->EncryptedAreaStart.Value,
- masterCryptoInfo->EncryptedAreaLength.Value,
- masterCryptoInfo->RequiredProgramVersion,
- masterCryptoInfo->HeaderFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC,
- masterCryptoInfo->SectorSize,
- wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1));
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
- offset.QuadPart = TC_VOLUME_HEADER_OFFSET;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
- || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header))
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- // Fill the reserved sectors of the header area with random data
- nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
- }
-
- // Update the configuration files
-
- SaveNonSysInPlaceEncSettings (-1, wipeAlgorithm, FALSE);
-
-
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINISHED);
-
- nStatus = ERR_SUCCESS;
- }
- else
- {
- // The process has been paused by the user or aborted by the wizard (e.g. on app exit)
-
- nStatus = ERR_USER_ABORT;
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED);
- }
-
-
-closing_seq:
-
- dwError = GetLastError();
-
- if (bEncryptedAreaSizeChanged
- && dev != INVALID_HANDLE_VALUE
- && masterCryptoInfo != NULL
- && headerCryptoInfo != NULL
- && deviceSize > 0)
- {
- // Execution of the core loop may have been interrupted due to an error or user action without updating the header
- FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
- }
-
- if (masterCryptoInfo != NULL)
- {
- crypto_close (masterCryptoInfo);
- masterCryptoInfo = NULL;
- }
-
- if (headerCryptoInfo != NULL)
- {
- crypto_close (headerCryptoInfo);
- headerCryptoInfo = NULL;
- }
-
- if (tmpCryptoInfo != NULL)
- {
- crypto_close (tmpCryptoInfo);
- tmpCryptoInfo = NULL;
- }
-
- if (dosDev[0])
- RemoveFakeDosName (devicePath, dosDev);
-
- if (dev != INVALID_HANDLE_VALUE)
- {
- CloseHandle (dev);
- dev = INVALID_HANDLE_VALUE;
- }
-
- if (buf != NULL)
- TCfree (buf);
-
- if (header != NULL)
- {
- burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- TCfree (header);
- }
-
- if (wipeBuffer != NULL)
- TCfree (wipeBuffer);
-
- if (zeroedSectorCount > 0)
- {
- wchar_t msg[30000] = {0};
- wchar_t sizeStr[500] = {0};
-
- GetSizeString (zeroedSectorCount * sectorSize, sizeStr, sizeof(sizeStr));
-
- StringCbPrintfW (msg, sizeof(msg),
- GetString ("ZEROED_BAD_SECTOR_COUNT"),
- zeroedSectorCount,
- sizeStr);
-
- WarningDirect (msg, hwndDlg);
- }
-
- if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT)
- SetLastError (dwError);
-
- return nStatus;
-}
-
-int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile BOOL *DiscardUnreadableEncryptedSectors)
-{
- HANDLE dev = INVALID_HANDLE_VALUE;
- PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL;
- UINT64_STRUCT unitNo;
- char *buf = NULL;
- byte *tmpSectorBuf = NULL;
- WCHAR dosDev[TC_MAX_PATH] = {0};
- WCHAR devName[MAX_PATH] = {0};
- WCHAR deviceName[MAX_PATH];
- int nStatus = ERR_SUCCESS;
- __int64 deviceSize;
- uint64 remainingBytes, workChunkStartByteOffset, lastHeaderUpdateDistance = 0, skippedBadSectorCount = 0;
- uint32 workChunkSize;
- DWORD dwError, dwResult;
- BOOL bPause = FALSE, bEncryptedAreaSizeChanged = FALSE;
- LARGE_INTEGER offset;
- int sectorSize;
- int i;
- DWORD n;
- WCHAR *devicePath = volParams->volumePath;
- Password *password = volParams->password;
- HWND hwndDlg = volParams->hwndDlg;
- int pkcs5_prf = volParams->pkcs5;
- int pim = volParams->pim;
- DISK_GEOMETRY driveGeometry;
-
-
- buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
- if (!buf)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
-
- headerCryptoInfo = crypto_open();
-
- if (headerCryptoInfo == NULL)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
-
- deviceSize = GetDeviceSize (devicePath);
- if (deviceSize < 0)
- {
- // Cannot determine the size of the partition
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
- // The wizard should have dismounted the TC volume if it was mounted, but for extra safety we will check this again.
- if (IsMountedVolume (devicePath))
- {
- int driveLetter = GetMountedVolumeDriveNo (devicePath);
-
- if (driveLetter == -1
- || !UnmountVolume (hwndDlg, driveLetter, TRUE))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- AbortProcess ("CANT_DISMOUNT_VOLUME");
- }
- }
-
-
- StringCchCopyW (deviceName, ARRAYSIZE(deviceName), devicePath);
-
- if (FakeDosNameForDevice (deviceName, dosDev, sizeof(dosDev), devName, sizeof(devName), FALSE) != 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- dev = OpenPartitionVolume (hwndDlg, devName,
- TRUE, // Require exclusive access
- FALSE, // Do not require shared access
- TRUE, // Ask the user to confirm shared access (if exclusive fails)
- FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
- FALSE); // Non-silent mode
-
- if (dev == INVALID_HANDLE_VALUE)
- {
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
-
-
- // This should never be needed, but is still performed for extra safety (without checking the result)
- DeviceIoControl (dev,
- FSCTL_ALLOW_EXTENDED_DASD_IO,
- NULL,
- 0,
- NULL,
- 0,
- &dwResult,
- NULL);
-
-
- if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL))
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if ( (driveGeometry.BytesPerSector == 0)
- || (driveGeometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE)
- || (driveGeometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0)
- )
- {
- Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- sectorSize = driveGeometry.BytesPerSector;
-
-
- tmpSectorBuf = (byte *) TCalloc (sectorSize);
- if (!tmpSectorBuf)
- {
- nStatus = ERR_OUTOFMEMORY;
- goto closing_seq;
- }
-
-
- nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
- if (masterCryptoInfo->LegacyVolume)
- {
- Error ("NONSYS_INPLACE_DECRYPTION_BAD_VOL_FORMAT", hwndDlg);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- if (masterCryptoInfo->hiddenVolume)
- {
- Error ("NONSYS_INPLACE_DECRYPTION_CANT_DECRYPT_HID_VOL", hwndDlg);
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
-
- if (!bInPlaceEncNonSysResumed
- && masterCryptoInfo->VolumeSize.Value == masterCryptoInfo->EncryptedAreaLength.Value)
- {
- /* Decryption started (not resumed) */
-
- if ((masterCryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) == 0)
- {
- // The volume has not been encrypted in-place so it may contain a hidden volume.
- // Ask the user to confirm it does not.
-
- char *tmpStr[] = {0,
- "CONFIRM_VOL_CONTAINS_NO_HIDDEN_VOL",
- "VOL_CONTAINS_NO_HIDDEN_VOL",
- "VOL_CONTAINS_A_HIDDEN_VOL",
- 0};
-
- switch (AskMultiChoice ((void **) tmpStr, FALSE, hwndDlg))
- {
- case 1:
- // NOP
- break;
- case 2:
- default:
- // Cancel
- nStatus = ERR_DONT_REPORT;
- goto closing_seq;
- }
- }
-
- // Update config files and app data
-
- // In the config file, increase the number of partitions where in-place decryption is in progress
- SaveNonSysInPlaceEncSettings (1, TC_WIPE_NONE, TRUE);
-
- // Add the wizard to the system startup sequence if appropriate
- if (!IsNonInstallMode ())
- ManageStartupSeqWiz (FALSE, L"/prinplace");
- }
-
-
-
- bInPlaceEncNonSysResumed = TRUE;
- bFirstNonSysInPlaceEncResumeDone = TRUE;
-
-
- remainingBytes = masterCryptoInfo->EncryptedAreaLength.Value;
-
- lastHeaderUpdateDistance = 0;
-
-
- ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_DECRYPTING);
-
-
-
- /* The in-place decryption core */
-
- while (remainingBytes > 0)
- {
- workChunkSize = (uint32) min (remainingBytes, TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
-
- if (workChunkSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
- {
- nStatus = ERR_PARAMETER_INCORRECT;
- goto closing_seq;
- }
-
- workChunkStartByteOffset = masterCryptoInfo->EncryptedAreaStart.Value;
-
- unitNo.Value = workChunkStartByteOffset / ENCRYPTION_DATA_UNIT_SIZE;
-
-
- // Read the ciphertext into RAM
-
- offset.QuadPart = workChunkStartByteOffset;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (ReadFile (dev, buf, workChunkSize, &n, NULL) == 0)
- {
- // Read error
-
- DWORD dwTmpErr = GetLastError ();
-
- if (IsDiskReadError (dwTmpErr) && !bVolTransformThreadCancel)
- {
- // Physical defect or data corruption
-
- if (!*DiscardUnreadableEncryptedSectors)
- {
- *DiscardUnreadableEncryptedSectors = (AskWarnYesNo ("DISCARD_UNREADABLE_ENCRYPTED_SECTORS", hwndDlg) == IDYES);
- }
-
- if (*DiscardUnreadableEncryptedSectors)
- {
- // Read the work chunk again, but this time each sector individually and skiping each bad sector
-
- LARGE_INTEGER tmpSectorOffset;
- uint64 tmpSectorCount;
- uint64 tmpBufOffset = 0;
- DWORD tmpNbrReadBytes = 0;
-
- tmpSectorOffset.QuadPart = offset.QuadPart;
-
- for (tmpSectorCount = workChunkSize / sectorSize; tmpSectorCount > 0; --tmpSectorCount)
- {
- if (SetFilePointerEx (dev, tmpSectorOffset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (ReadFile (dev, tmpSectorBuf, sectorSize, &tmpNbrReadBytes, NULL) == 0
- || tmpNbrReadBytes != (DWORD) sectorSize)
- {
- // Read error
-
- // Clear the buffer so the content of each unreadable sector is replaced with decrypted all-zero blocks (producing pseudorandom data)
- memset (tmpSectorBuf, 0, sectorSize);
-
- skippedBadSectorCount++;
- }
-
- memcpy (buf + tmpBufOffset, tmpSectorBuf, sectorSize);
-
- tmpSectorOffset.QuadPart += sectorSize;
- tmpBufOffset += sectorSize;
- }
- }
- else
- {
- SetLastError (dwTmpErr); // Preserve the original error code
-
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
- }
- else
- {
- SetLastError (dwTmpErr); // Preserve the original error code
-
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
- }
-
- // Decrypt the ciphertext in RAM
-
- DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
-
-
-
- // Conceal initial portion of the filesystem
-
- if (workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE)
- {
- // We are decrypting the initial TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE bytes of the filesystem. We will
- // conceal this portion to prevent Windows and applications from interfering with the volume.
-
- for (i = 0; i < min (TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET + workChunkSize); i++)
- buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
- }
-
-
- // Write the plaintext
-
- offset.QuadPart = workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (WriteFile (dev, buf, workChunkSize, &n, NULL) == 0)
- {
- // Write error
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
- masterCryptoInfo->EncryptedAreaStart.Value += workChunkSize;
- masterCryptoInfo->EncryptedAreaLength.Value -= workChunkSize;
-
- remainingBytes -= workChunkSize;
- lastHeaderUpdateDistance += workChunkSize;
-
- bEncryptedAreaSizeChanged = TRUE;
-
- if (lastHeaderUpdateDistance >= TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL)
- {
- nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
-
- if (nStatus != ERR_SUCCESS)
- {
- // Possible write error
- goto closing_seq;
- }
-
- lastHeaderUpdateDistance = 0;
- }
-
- ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
-
- if (bVolTransformThreadCancel)
- {
- bPause = TRUE;
- break;
- }
- }
-
- nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
-
-
- if (nStatus != ERR_SUCCESS)
- {
- // Possible write error
- goto closing_seq;
- }
-
-
- if (!bPause)
- {
- /* Volume has been fully decrypted. */
-
-
- // Prevent attempts to update volume header during the closing sequence
- bEncryptedAreaSizeChanged = FALSE;
-
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINALIZING);
-
-
-
- /* Undo concealing of the filesystem */
-
- nStatus = ConcealNTFS (dev);
-
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
-
- /* Ovewrite the backup header and the remaining ciphertext with all-zero blocks (the primary header was overwritten with the decrypted data). */
-
- memset (tmpSectorBuf, 0, sectorSize);
-
- for (offset.QuadPart = masterCryptoInfo->VolumeSize.Value;
- offset.QuadPart <= deviceSize - sectorSize;
- offset.QuadPart += sectorSize)
- {
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (WriteFile (dev, tmpSectorBuf, sectorSize, &n, NULL) == 0)
- {
- // Write error
- dwError = GetLastError();
-
- SetLastError (dwError);
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
- }
-
-
-
- /* Update the configuration files */
-
- SaveNonSysInPlaceEncSettings (-1, TC_WIPE_NONE, TRUE);
-
-
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINISHED);
-
- nStatus = ERR_SUCCESS;
-
- }
- else
- {
- // The process has been paused by the user or aborted by the wizard (e.g. on app exit)
-
- nStatus = ERR_USER_ABORT;
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED);
- }
-
- if (dev != INVALID_HANDLE_VALUE)
- {
- CloseHandle (dev);
- dev = INVALID_HANDLE_VALUE;
- }
-
-
-closing_seq:
-
- dwError = GetLastError();
-
- if (bEncryptedAreaSizeChanged
- && dev != INVALID_HANDLE_VALUE
- && masterCryptoInfo != NULL
- && headerCryptoInfo != NULL
- && deviceSize > 0)
- {
- // Execution of the core loop may have been interrupted due to an error or user action without updating the header
- FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
- }
-
- if (dev != INVALID_HANDLE_VALUE)
- {
- CloseHandle (dev);
- dev = INVALID_HANDLE_VALUE;
- }
-
- if (masterCryptoInfo != NULL)
- {
- crypto_close (masterCryptoInfo);
- masterCryptoInfo = NULL;
- }
-
- if (headerCryptoInfo != NULL)
- {
- crypto_close (headerCryptoInfo);
- headerCryptoInfo = NULL;
- }
-
- if (dosDev[0])
- RemoveFakeDosName (devicePath, dosDev);
-
- if (buf != NULL)
- {
- TCfree (buf);
- buf = NULL;
- }
-
- if (tmpSectorBuf != NULL)
- {
- TCfree (tmpSectorBuf);
- tmpSectorBuf = NULL;
- }
-
- if (skippedBadSectorCount > 0)
- {
- wchar_t msg[30000] = {0};
- wchar_t sizeStr[500] = {0};
-
- GetSizeString (skippedBadSectorCount * sectorSize, sizeStr, sizeof(sizeStr));
-
- StringCbPrintfW (msg, sizeof(msg),
- GetString ("SKIPPED_BAD_SECTOR_COUNT"),
- skippedBadSectorCount,
- sizeStr);
-
- WarningDirect (msg, hwndDlg);
- }
-
- if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT)
- SetLastError (dwError);
-
- return nStatus;
-}
-
-int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize)
-{
- LARGE_INTEGER offset;
- DWORD n;
- int nStatus = ERR_SUCCESS;
- byte *header;
- DWORD dwError;
- uint32 headerCrc32;
- byte *fieldPos;
-
- header = (byte *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
-
- if (!header)
- return ERR_OUTOFMEMORY;
-
- VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
-
-
- fieldPos = (byte *) header + TC_HEADER_OFFSET_ENCRYPTED_AREA_START;
-
- offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
- || !ReadEffectiveVolumeHeader (TRUE, dev, header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
- DecryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo);
-
- if (GetHeaderField32 (header, TC_HEADER_OFFSET_MAGIC) != 0x56455241)
- {
- nStatus = ERR_PARAMETER_INCORRECT;
- goto closing_seq;
- }
-
- mputInt64 (fieldPos, (masterCryptoInfo->EncryptedAreaStart.Value));
- mputInt64 (fieldPos, (masterCryptoInfo->EncryptedAreaLength.Value));
-
- // We need to ensure the TC_HEADER_FLAG_NONSYS_INPLACE_ENC flag bit is set, because if volumes created by TC-format
- // were decrypted in place, it would be possible to mount them partially encrypted and it wouldn't be possible
- // to resume interrupted decryption after the wizard exits.
- masterCryptoInfo->HeaderFlags |= TC_HEADER_FLAG_NONSYS_INPLACE_ENC;
- fieldPos = (byte *) header + TC_HEADER_OFFSET_FLAGS;
- mputLong (fieldPos, (masterCryptoInfo->HeaderFlags));
-
-
- headerCrc32 = GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC);
- fieldPos = (byte *) header + TC_HEADER_OFFSET_HEADER_CRC;
- mputLong (fieldPos, headerCrc32);
-
- EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo);
-
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
- || !WriteEffectiveVolumeHeader (TRUE, dev, header))
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
-closing_seq:
-
- dwError = GetLastError();
-
- burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- TCfree (header);
-
- if (nStatus != ERR_SUCCESS)
- SetLastError (dwError);
-
- return nStatus;
-}
-
-
-static HANDLE OpenPartitionVolume (HWND hwndDlg, const wchar_t *devName,
- BOOL bExclusiveRequired,
- BOOL bSharedRequired,
- BOOL bSharedRequiresConfirmation,
- BOOL bShowAlternativeSteps,
- BOOL bSilent)
-{
- HANDLE dev = INVALID_HANDLE_VALUE;
- int retryCount = 0;
-
- if (bExclusiveRequired)
- bSharedRequired = FALSE;
-
- if (bExclusiveRequired || !bSharedRequired)
- {
- // Exclusive access
- // Note that when exclusive access is denied, it is worth retrying (usually succeeds after a few tries).
- while (dev == INVALID_HANDLE_VALUE && retryCount++ < EXCL_ACCESS_MAX_AUTO_RETRIES)
- {
- dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL);
-
- if (retryCount > 1)
- Sleep (EXCL_ACCESS_AUTO_RETRY_DELAY);
- }
- }
-
- if (dev == INVALID_HANDLE_VALUE)
- {
- if (bExclusiveRequired)
- {
- if (!bSilent)
- {
- handleWin32Error (hwndDlg, SRC_POS);
-
- if (bShowAlternativeSteps)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
- else
- Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
- }
- return INVALID_HANDLE_VALUE;
- }
-
- // Shared mode
- dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL);
- if (dev != INVALID_HANDLE_VALUE)
- {
- if (bSharedRequiresConfirmation
- && !bSilent
- && AskWarnNoYes ("DEVICE_IN_USE_INPLACE_ENC", hwndDlg) == IDNO)
- {
- CloseHandle (dev);
- return INVALID_HANDLE_VALUE;
- }
- }
- else
- {
- if (!bSilent)
- {
- handleWin32Error (MainDlg, SRC_POS);
-
- if (bShowAlternativeSteps)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
- else
- Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
- }
- return INVALID_HANDLE_VALUE;
- }
- }
-
- return dev;
-}
-
-
-static int DismountFileSystem (HWND hwndDlg, HANDLE dev,
- int driveLetter,
- BOOL bForcedAllowed,
- BOOL bForcedRequiresConfirmation,
- BOOL bSilent)
-{
- int attempt;
- BOOL bResult;
- DWORD dwResult;
-
- CloseVolumeExplorerWindows (MainDlg, driveLetter);
-
- attempt = UNMOUNT_MAX_AUTO_RETRIES * 10;
-
- while (!(bResult = DeviceIoControl (dev, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL))
- && attempt > 0)
- {
- Sleep (UNMOUNT_AUTO_RETRY_DELAY);
- attempt--;
- }
-
- if (!bResult)
- {
- if (!bForcedAllowed)
- {
- if (!bSilent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE);
-
- return ERR_DONT_REPORT;
- }
-
- if (bForcedRequiresConfirmation
- && !bSilent
- && AskWarnYesNo ("VOL_LOCK_FAILED_OFFER_FORCED_DISMOUNT", hwndDlg) == IDNO)
- {
- return ERR_DONT_REPORT;
- }
- }
-
- // Dismount the volume
-
- attempt = UNMOUNT_MAX_AUTO_RETRIES * 10;
-
- while (!(bResult = DeviceIoControl (dev, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL))
- && attempt > 0)
- {
- Sleep (UNMOUNT_AUTO_RETRY_DELAY);
- attempt--;
- }
-
- if (!bResult)
- {
- if (!bSilent)
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE);
-
- return ERR_DONT_REPORT;
- }
-
- return ERR_SUCCESS;
-}
-
-
-// Easy-to-undo modification applied to conceal the NTFS filesystem (to prevent Windows and apps from
-// interfering with it until the volume has been fully encrypted). Note that this function will precisely
-// undo any modifications it made to the filesystem automatically if an error occurs when writing (including
-// physical drive defects).
-static int ConcealNTFS (HANDLE dev)
-{
- char buf [TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE];
- DWORD nbrBytesProcessed, nbrBytesProcessed2;
- int i;
- LARGE_INTEGER offset;
- DWORD dwError;
-
- offset.QuadPart = 0;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- return ERR_OS_ERROR;
-
- if (ReadFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed, NULL) == 0)
- return ERR_OS_ERROR;
-
- for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE; i++)
- buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
-
- offset.QuadPart = 0;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
- return ERR_OS_ERROR;
-
- if (WriteFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed, NULL) == 0)
- {
- // One or more of the sectors is/are probably damaged and cause write errors.
- // We must undo the modifications we made.
-
- dwError = GetLastError();
-
- for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE; i++)
- buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
-
- offset.QuadPart = 0;
-
- do
- {
- Sleep (1);
- }
- while (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
- || WriteFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed2, NULL) == 0);
-
- SetLastError (dwError);
-
- return ERR_OS_ERROR;
- }
-
- return ERR_SUCCESS;
-}
-
-
-void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr)
-{
- wchar_t msg[30000];
-
- StringCbCopyW (msg, sizeof(msg), GetString (iniStrId));
-
- StringCbCatW (msg, sizeof(msg), L"\n\n\n");
- StringCbCatW (msg, sizeof(msg), GetString ("INPLACE_ENC_ALTERNATIVE_STEPS"));
-
- if (bErr)
- ErrorDirect (msg, hwndDlg);
- else
- WarningDirect (msg, hwndDlg);
-}
-
-
-static void ExportProgressStats (__int64 bytesDone, __int64 totalSize)
-{
- NonSysInplaceEncBytesDone = bytesDone;
- NonSysInplaceEncTotalSize = totalSize;
-}
-
-
-void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus)
-{
- NonSysInplaceEncStatus = nonSysInplaceEncStatus;
-}
-
-
-BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId newWipeAlgorithm, BOOL bDecrypt)
-{
- int count;
- char str[32];
- WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
-
- if (delta == 0)
- return TRUE;
-
- count = LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) + delta;
-
- if (count < 1)
- {
- RemoveNonSysInPlaceEncNotifications();
- return TRUE;
- }
- else if (!bDecrypt)
- {
- if (newWipeAlgorithm != TC_WIPE_NONE)
- {
- StringCbPrintfA (str, sizeof(str), "%d", (int) newWipeAlgorithm);
-
- SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE), (DWORD) strlen(str), FALSE, FALSE);
- }
- else if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE)))
- {
- _wremove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE));
- }
- }
-
- StringCbPrintfA (str, sizeof(str), "%d", count);
-
- return SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC), (DWORD) strlen(str), FALSE, FALSE);
-}
-
-
-// Repairs damaged sectors (i.e. those with read errors) by zeroing them.
-// Note that this operating fails if there are any write errors.
-int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount)
-{
- int nStatus;
- DWORD n;
- int64 sectorCount;
- LARGE_INTEGER workOffset;
- byte *sectorBuffer = NULL;
- DWORD dwError;
-
- workOffset.QuadPart = startOffset.QuadPart;
-
- sectorBuffer = (byte *) TCalloc (sectorSize);
-
- if (!sectorBuffer)
- return ERR_OUTOFMEMORY;
-
- if (SetFilePointerEx (dev, startOffset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
- for (sectorCount = size / sectorSize; sectorCount > 0; --sectorCount)
- {
- if (ReadFile (dev, sectorBuffer, sectorSize, &n, NULL) == 0)
- {
- memset (sectorBuffer, 0, sectorSize);
-
- if (SetFilePointerEx (dev, workOffset, NULL, FILE_BEGIN) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
- if (WriteFile (dev, sectorBuffer, sectorSize, &n, NULL) == 0)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
- ++(*zeroedSectorCount);
- }
-
- workOffset.QuadPart += n;
- }
-
- nStatus = ERR_SUCCESS;
-
-closing_seq:
-
- dwError = GetLastError();
-
- if (sectorBuffer != NULL)
- TCfree (sectorBuffer);
-
- if (nStatus != ERR_SUCCESS)
- SetLastError (dwError);
-
- return nStatus;
-}
-
-
-static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize)
-{
- LARGE_INTEGER offset;
- DWORD n;
- int nStatus = ERR_SUCCESS;
- char *header;
- DWORD dwError;
-
- header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- if (!header)
- return ERR_OUTOFMEMORY;
-
- VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
-
-
-
- offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE;
-
- if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
- || !ReadEffectiveVolumeHeader (TRUE, dev, (byte *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE)
- {
- nStatus = ERR_OS_ERROR;
- goto closing_seq;
- }
-
-
- nStatus = ReadVolumeHeader (FALSE, header, password, pkcs5, pim, FALSE, retMasterCryptoInfo, headerCryptoInfo);
- if (nStatus != ERR_SUCCESS)
- goto closing_seq;
-
-
-closing_seq:
-
- dwError = GetLastError();
-
- burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
- TCfree (header);
-
- dwError = GetLastError();
-
- if (nStatus != ERR_SUCCESS)
- SetLastError (dwError);
-
- return nStatus;
-}
-
-
-static BOOL GetFreeClusterBeforeThreshold (HANDLE volumeHandle, int64 *freeCluster, int64 clusterThreshold)
-{
- const int bitmapSize = 65536;
- byte bitmapBuffer[bitmapSize + sizeof (VOLUME_BITMAP_BUFFER)];
- VOLUME_BITMAP_BUFFER *bitmap = (VOLUME_BITMAP_BUFFER *) bitmapBuffer;
- STARTING_LCN_INPUT_BUFFER startLcn;
- startLcn.StartingLcn.QuadPart = 0;
-
- DWORD bytesReturned;
- while (DeviceIoControl (volumeHandle, FSCTL_GET_VOLUME_BITMAP, &startLcn, sizeof (startLcn), &bitmapBuffer, sizeof (bitmapBuffer), &bytesReturned, NULL)
- || GetLastError() == ERROR_MORE_DATA)
- {
- for (int64 bitmapIndex = 0; bitmapIndex < min (bitmapSize, (bitmap->BitmapSize.QuadPart / 8)); ++bitmapIndex)
- {
- if (bitmap->StartingLcn.QuadPart + bitmapIndex * 8 >= clusterThreshold)
- goto err;
-
- if (bitmap->Buffer[bitmapIndex] != 0xff)
- {
- for (int bit = 0; bit < 8; ++bit)
- {
- if ((bitmap->Buffer[bitmapIndex] & (1 << bit)) == 0)
- {
- *freeCluster = bitmap->StartingLcn.QuadPart + bitmapIndex * 8 + bit;
-
- if (*freeCluster >= clusterThreshold)
- goto err;
-
- return TRUE;
- }
- }
- }
- }
-
- startLcn.StartingLcn.QuadPart += min (bitmapSize * 8, bitmap->BitmapSize.QuadPart);
- }
-
-err:
- SetLastError (ERROR_DISK_FULL);
- return FALSE;
-}
-
-
-static BOOL MoveClustersBeforeThresholdInDir (HANDLE volumeHandle, const wstring &directory, int64 clusterThreshold)
-{
- WIN32_FIND_DATAW findData;
-
- HANDLE findHandle = FindFirstFileW (((directory.size() <= 3 ? L"" : L"\\\\?\\") + directory + L"\\*").c_str(), &findData);
- if (findHandle == INVALID_HANDLE_VALUE)
- return TRUE; // Error ignored
-
- finally_do_arg (HANDLE, findHandle, { FindClose (finally_arg); });
-
- // Find all files and directories
- do
- {
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- wstring subDir = findData.cFileName;
-
- if (subDir == L"." || subDir == L"..")
- continue;
-
- if (!MoveClustersBeforeThresholdInDir (volumeHandle, directory + L"\\" + subDir, clusterThreshold))
- return FALSE;
- }
-
- DWORD access = FILE_READ_ATTRIBUTES;
-
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED)
- access = FILE_READ_DATA;
-
- HANDLE fsObject = CreateFileW ((directory + L"\\" + findData.cFileName).c_str(), access, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- if (fsObject == INVALID_HANDLE_VALUE)
- continue;
-
- finally_do_arg (HANDLE, fsObject, { CloseHandle (finally_arg); });
-
- STARTING_VCN_INPUT_BUFFER startVcn;
- startVcn.StartingVcn.QuadPart = 0;
- RETRIEVAL_POINTERS_BUFFER retPointers;
- DWORD bytesReturned;
-
- // Find clusters allocated beyond the threshold
- while (DeviceIoControl (fsObject, FSCTL_GET_RETRIEVAL_POINTERS, &startVcn, sizeof (startVcn), &retPointers, sizeof (retPointers), &bytesReturned, NULL)
- || GetLastError() == ERROR_MORE_DATA)
- {
- if (retPointers.ExtentCount == 0)
- break;
-
- if (retPointers.Extents[0].Lcn.QuadPart != -1)
- {
- int64 extentStartCluster = retPointers.Extents[0].Lcn.QuadPart;
- int64 extentLen = retPointers.Extents[0].NextVcn.QuadPart - retPointers.StartingVcn.QuadPart;
- int64 extentEndCluster = extentStartCluster + extentLen - 1;
-
- if (extentEndCluster >= clusterThreshold)
- {
- // Move clusters before the threshold
- for (int64 movedCluster = max (extentStartCluster, clusterThreshold); movedCluster <= extentEndCluster; ++movedCluster)
- {
- for (int retry = 0; ; ++retry)
- {
- MOVE_FILE_DATA moveData;
-
- if (GetFreeClusterBeforeThreshold (volumeHandle, &moveData.StartingLcn.QuadPart, clusterThreshold))
- {
- moveData.FileHandle = fsObject;
- moveData.StartingVcn.QuadPart = movedCluster - extentStartCluster + retPointers.StartingVcn.QuadPart;
- moveData.ClusterCount = 1;
-
- if (DeviceIoControl (volumeHandle, FSCTL_MOVE_FILE, &moveData, sizeof (moveData), NULL, 0, &bytesReturned, NULL))
- break;
- }
-
- if (retry > 600)
- return FALSE;
-
- // There are possible race conditions as we work on a live filesystem
- Sleep (100);
- }
- }
- }
- }
-
- startVcn.StartingVcn = retPointers.Extents[0].NextVcn;
- }
-
- } while (FindNextFileW (findHandle, &findData));
-
- return TRUE;
-}
-
-
-BOOL MoveClustersBeforeThreshold (HANDLE volumeHandle, PWSTR volumeDevicePath, int64 clusterThreshold)
-{
- int drive = GetDiskDeviceDriveLetter (volumeDevicePath);
- if (drive == -1)
- {
- SetLastError (ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- wstring volumeRoot = L"X:";
- volumeRoot[0] = L'A' + (wchar_t) drive;
-
- return MoveClustersBeforeThresholdInDir (volumeHandle, volumeRoot, clusterThreshold);
-}
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ 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 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
+ code distribution packages.
+*/
+
+
+/* In this file, _WIN32_WINNT is defined as 0x0600 to make filesystem shrink available (Vista
+or later). _WIN32_WINNT cannot be defined as 0x0600 for the entire user-space projects
+because it breaks the main font app when the app is running on XP (likely an MS bug).
+IMPORTANT: Due to this issue, functions in this file must not directly interact with GUI. */
+#define TC_LOCAL_WIN32_WINNT_OVERRIDE 1
+#if (_WIN32_WINNT < 0x0600)
+# undef _WIN32_WINNT
+# define _WIN32_WINNT 0x0600
+#endif
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+#include <intsafe.h>
+
+#include "Tcdefs.h"
+#include "Platform/Finally.h"
+
+#include "Common.h"
+#include "Crc.h"
+#include "Dlgcode.h"
+#include "Language.h"
+#include "Tcformat.h"
+#include "Volumes.h"
+
+#include "InPlace.h"
+
+#include <Strsafe.h>
+
+using namespace std;
+using namespace VeraCrypt;
+
+#if TC_VOLUME_DATA_OFFSET != 131072
+# error TC_VOLUME_DATA_OFFSET != 131072
+#endif
+
+#if TC_VOLUME_HEADER_EFFECTIVE_SIZE != 512
+# error TC_VOLUME_HEADER_EFFECTIVE_SIZE != 512
+#endif
+
+#if TC_TOTAL_VOLUME_HEADERS_SIZE != 262144
+# error TC_TOTAL_VOLUME_HEADERS_SIZE != 262144
+#endif
+
+#define TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE (2048 * BYTES_PER_KB)
+#define TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE (2 * TC_MAX_VOLUME_SECTOR_SIZE)
+#define TC_NTFS_CONCEAL_CONSTANT 0xFF
+#define TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL (64 * BYTES_PER_MB)
+#define TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE (TC_TOTAL_VOLUME_HEADERS_SIZE + TC_MIN_NTFS_FS_SIZE * 2)
+
+
+// If the returned value is greater than 0, it is the desired volume size in NTFS sectors (not in bytes)
+// after shrinking has been performed. If there's any error, returns -1.
+static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const wchar_t *devicePath, int64 *totalClusterCount, DWORD *bytesPerCluster, BOOL silent)
+{
+ NTFS_VOLUME_DATA_BUFFER ntfsVolData;
+ DWORD nBytesReturned;
+ __int64 fileSysSize, desiredNbrSectors;
+
+ // Filesystem size and sector size
+
+ if (!DeviceIoControl (dev,
+ FSCTL_GET_NTFS_VOLUME_DATA,
+ NULL,
+ 0,
+ (LPVOID) &ntfsVolData,
+ sizeof (ntfsVolData),
+ &nBytesReturned,
+ NULL))
+ {
+ if (!silent)
+ handleWin32Error (MainDlg, SRC_POS);
+
+ return -1;
+ }
+
+ if ( (ntfsVolData.NumberSectors.QuadPart <= 0)
+ || (ntfsVolData.NumberSectors.QuadPart > (INT64_MAX / (__int64) ntfsVolData.BytesPerSector)) // overflow test
+ )
+ {
+ SetLastError (ERROR_INTERNAL_ERROR);
+ if (!silent)
+ handleWin32Error (MainDlg, SRC_POS);
+
+ return -1;
+ }
+
+ fileSysSize = ntfsVolData.NumberSectors.QuadPart * ntfsVolData.BytesPerSector;
+
+ desiredNbrSectors = (fileSysSize - TC_TOTAL_VOLUME_HEADERS_SIZE) / ntfsVolData.BytesPerSector;
+
+ if (desiredNbrSectors <= 0)
+ return -1;
+
+ if (totalClusterCount)
+ *totalClusterCount = ntfsVolData.TotalClusters.QuadPart;
+ if (bytesPerCluster)
+ *bytesPerCluster = ntfsVolData.BytesPerCluster;
+
+ return desiredNbrSectors;
+}
+
+
+BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const wchar_t *devicePath, BOOL silent)
+{
+ NTFS_VOLUME_DATA_BUFFER ntfsVolData;
+ DWORD nBytesReturned;
+ HANDLE dev;
+ WCHAR szFileSysName [256];
+ WCHAR devPath [MAX_PATH];
+ WCHAR dosDev [TC_MAX_PATH] = {0};
+ WCHAR devName [MAX_PATH] = {0};
+ int driveLetterNo = -1;
+ WCHAR szRootPath[4] = {0, L':', L'\\', 0};
+ __int64 deviceSize;
+ int partitionNumber = -1, driveNumber = -1;
+
+
+ /* ---------- Checks that do not require admin rights ----------- */
+
+
+ /* Operating system */
+
+ if (CurrentOSMajor < 6)
+ {
+ if (!silent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "OS_NOT_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE);
+
+ return FALSE;
+ }
+
+
+ /* Volume type (must be a partition or a dynamic volume) */
+
+ if (swscanf (devicePath, L"\\Device\\HarddiskVolume%d", &partitionNumber) != 1
+ && swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
+ {
+ if (!silent)
+ Error ("INPLACE_ENC_INVALID_PATH", hwndDlg);
+
+ return FALSE;
+ }
+
+ if (partitionNumber == 0)
+ {
+ if (!silent)
+ Warning ("RAW_DEV_NOT_SUPPORTED_FOR_INPLACE_ENC", hwndDlg);
+
+ return FALSE;
+ }
+
+
+ /* Admin rights */
+
+ if (!IsAdmin())
+ {
+ // We rely on the wizard process to call us only when the whole wizard process has been elevated (so UAC
+ // status can be ignored). In case the IsAdmin() detection somehow fails, we allow the user to continue.
+
+ if (!silent)
+ Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", hwndDlg);
+ }
+
+
+ /* ---------- Checks that may require admin rights ----------- */
+
+
+ /* Access to the partition */
+
+ StringCbCopyW (devPath, sizeof(devPath), devicePath);
+
+ driveLetterNo = GetDiskDeviceDriveLetter (devPath);
+
+ if (driveLetterNo >= 0)
+ szRootPath[0] = (wchar_t) driveLetterNo + L'A';
+
+ if (FakeDosNameForDevice (devicePath, dosDev, sizeof(dosDev), devName, sizeof(devName),FALSE) != 0)
+ {
+ if (!silent)
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
+ }
+ return FALSE;
+ }
+
+ dev = OpenPartitionVolume (hwndDlg, devName,
+ FALSE, // Do not require exclusive access
+ TRUE, // Require shared access (must be TRUE; otherwise, volume properties will not be possible to obtain)
+ FALSE, // Do not ask the user to confirm shared access (if exclusive fails)
+ FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
+ silent); // Silent mode
+
+ if (dev == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+
+ /* File system type */
+
+ GetVolumeInformation (szRootPath, NULL, 0, NULL, NULL, NULL, szFileSysName, ARRAYSIZE (szFileSysName));
+
+ if (wcsncmp (szFileSysName, L"NTFS", 4))
+ {
+ // The previous filesystem type detection method failed (or it's not NTFS) -- try an alternative method
+
+ if (!DeviceIoControl (dev,
+ FSCTL_GET_NTFS_VOLUME_DATA,
+ NULL,
+ 0,
+ (LPVOID) &ntfsVolData,
+ sizeof (ntfsVolData),
+ &nBytesReturned,
+ NULL))
+ {
+ if (!silent)
+ {
+ // The filesystem is not NTFS or the filesystem type could not be determined (or the NTFS filesystem
+ // is dismounted).
+
+ if (IsDeviceMounted (devName))
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "ONLY_NTFS_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE);
+ else
+ Warning ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC", hwndDlg);
+ }
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+ }
+
+
+ /* Attempt to determine whether the filesystem can be safely shrunk */
+
+ if (NewFileSysSizeAfterShrink (dev, devicePath, NULL, NULL, silent) == -1)
+ {
+ // Cannot determine whether shrinking is required
+ if (!silent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+
+
+ /* Partition size */
+
+ deviceSize = GetDeviceSize (devicePath);
+ if (deviceSize < 0)
+ {
+ // Cannot determine the size of the partition
+ if (!silent)
+ Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+
+ if (deviceSize < TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE)
+ {
+ // The partition is too small
+ if (!silent)
+ {
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", FALSE);
+ }
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+
+
+ /* Free space on the filesystem */
+
+ if (!DeviceIoControl (dev,
+ FSCTL_GET_NTFS_VOLUME_DATA,
+ NULL,
+ 0,
+ (LPVOID) &ntfsVolData,
+ sizeof (ntfsVolData),
+ &nBytesReturned,
+ NULL))
+ {
+ if (!silent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", TRUE);
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+
+ if (ntfsVolData.FreeClusters.QuadPart * ntfsVolData.BytesPerCluster < TC_TOTAL_VOLUME_HEADERS_SIZE)
+ {
+ if (!silent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "NOT_ENOUGH_FREE_FILESYS_SPACE_FOR_SHRINK", TRUE);
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+
+
+ /* Filesystem sector size */
+
+ if (ntfsVolData.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE
+ || ntfsVolData.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0)
+ {
+ if (!silent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "SECTOR_SIZE_UNSUPPORTED", TRUE);
+
+ CloseHandle (dev);
+ return FALSE;
+ }
+
+
+ CloseHandle (dev);
+ return TRUE;
+}
+
+BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const wchar_t *devicePath, BOOL silent)
+{
+ int partitionNumber = -1, driveNumber = -1;
+
+ /* ---------- Checks that do not require admin rights ----------- */
+
+ /* Volume type (must be a partition or a dynamic volume) */
+ if ((swscanf (devicePath, L"\\Device\\HarddiskVolume%d", &partitionNumber) != 1
+ && swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
+ || partitionNumber == 0)
+ {
+ if (!silent)
+ Error ("INPLACE_ENC_INVALID_PATH", hwndDlg);
+
+ return FALSE;
+ }
+
+
+ /* Admin rights */
+ if (!IsAdmin())
+ {
+ // We rely on the wizard process to call us only when the whole wizard process has been elevated (so UAC
+ // status can be ignored). In case the IsAdmin() detection somehow fails, we allow the user to continue.
+
+ if (!silent)
+ Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", hwndDlg);
+ }
+
+
+ /* ---------- Checks that may require admin rights ----------- */
+
+ // [Currently none]
+
+ return TRUE;
+}
+
+
+int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm)
+{
+ SHRINK_VOLUME_INFORMATION shrinkVolInfo;
+ signed __int64 sizeToShrinkTo;
+ int nStatus = ERR_SUCCESS;
+ PCRYPTO_INFO cryptoInfo = NULL;
+ PCRYPTO_INFO cryptoInfo2 = NULL;
+ HANDLE dev = INVALID_HANDLE_VALUE;
+ DWORD dwError;
+ char *header;
+ WCHAR dosDev[TC_MAX_PATH] = {0};
+ WCHAR devName[MAX_PATH] = {0};
+ int driveLetter = -1;
+ WCHAR deviceName[MAX_PATH];
+ uint64 dataAreaSize;
+ __int64 deviceSize;
+ LARGE_INTEGER offset;
+ DWORD dwResult;
+ HWND hwndDlg = volParams->hwndDlg;
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING);
+
+
+ if (!CheckRequirementsForNonSysInPlaceEnc (hwndDlg, volParams->volumePath, FALSE))
+ return ERR_DONT_REPORT;
+
+
+ header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ if (!header)
+ return ERR_OUTOFMEMORY;
+
+ VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+
+ deviceSize = GetDeviceSize (volParams->volumePath);
+ if (deviceSize < 0)
+ {
+ // Cannot determine the size of the partition
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto closing_seq;
+ }
+
+ if (deviceSize < TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE)
+ {
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", TRUE);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ dataAreaSize = GetVolumeDataAreaSize (volParams->hiddenVol, deviceSize);
+
+ StringCchCopyW (deviceName, ARRAYSIZE(deviceName), volParams->volumePath);
+
+ driveLetter = GetDiskDeviceDriveLetter (deviceName);
+
+
+ if (FakeDosNameForDevice (volParams->volumePath, dosDev, sizeof(dosDev),devName, sizeof(devName),FALSE) != 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (IsDeviceMounted (devName))
+ {
+ dev = OpenPartitionVolume (hwndDlg, devName,
+ FALSE, // Do not require exclusive access (must be FALSE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too)
+ TRUE, // Require shared access (must be TRUE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too)
+ FALSE, // Do not ask the user to confirm shared access (if exclusive fails)
+ FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
+ FALSE); // Non-silent mode
+
+ if (dev == INVALID_HANDLE_VALUE)
+ {
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+ }
+ else
+ {
+ // The volume is not mounted so we can't work with the filesystem.
+ Error ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC", hwndDlg);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+
+ /* Gain "raw" access to the partition (the NTFS driver guards hidden sectors). */
+
+ if (!DeviceIoControl (dev,
+ FSCTL_ALLOW_EXTENDED_DASD_IO,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ &dwResult,
+ NULL))
+ {
+ handleWin32Error (MainDlg, SRC_POS);
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+
+
+ /* Shrink the filesystem */
+
+ int64 totalClusterCount;
+ DWORD bytesPerCluster;
+
+ sizeToShrinkTo = NewFileSysSizeAfterShrink (dev, volParams->volumePath, &totalClusterCount, &bytesPerCluster, FALSE);
+
+ if (sizeToShrinkTo == -1)
+ {
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_RESIZING);
+
+ memset (&shrinkVolInfo, 0, sizeof (shrinkVolInfo));
+
+ shrinkVolInfo.ShrinkRequestType = ShrinkPrepare;
+ shrinkVolInfo.NewNumberOfSectors = sizeToShrinkTo;
+
+ if (!DeviceIoControl (dev,
+ FSCTL_SHRINK_VOLUME,
+ (LPVOID) &shrinkVolInfo,
+ sizeof (shrinkVolInfo),
+ NULL,
+ 0,
+ &dwResult,
+ NULL))
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ BOOL clustersMovedBeforeVolumeEnd = FALSE;
+
+ while (true)
+ {
+ shrinkVolInfo.ShrinkRequestType = ShrinkCommit;
+ shrinkVolInfo.NewNumberOfSectors = 0;
+
+ if (!DeviceIoControl (dev, FSCTL_SHRINK_VOLUME, &shrinkVolInfo, sizeof (shrinkVolInfo), NULL, 0, &dwResult, NULL))
+ {
+ // If there are any occupied clusters beyond the new desired end of the volume, the call fails with
+ // ERROR_ACCESS_DENIED (STATUS_ALREADY_COMMITTED).
+ if (GetLastError () == ERROR_ACCESS_DENIED)
+ {
+ if (!clustersMovedBeforeVolumeEnd)
+ {
+ if (MoveClustersBeforeThreshold (dev, deviceName, totalClusterCount - (bytesPerCluster > TC_TOTAL_VOLUME_HEADERS_SIZE ? 1 : TC_TOTAL_VOLUME_HEADERS_SIZE / bytesPerCluster)))
+ {
+ clustersMovedBeforeVolumeEnd = TRUE;
+ continue;
+ }
+
+ handleWin32Error (hwndDlg, SRC_POS);
+ }
+ }
+ else
+ handleWin32Error (hwndDlg, SRC_POS);
+
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ break;
+ }
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING);
+
+
+ /* Gain exclusive access to the volume */
+
+ nStatus = DismountFileSystem (hwndDlg, dev,
+ driveLetter,
+ TRUE,
+ TRUE,
+ FALSE);
+
+ if (nStatus != ERR_SUCCESS)
+ {
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+
+
+ /* Create header backup on the partition. Until the volume is fully encrypted, the backup header will provide
+ us with the master key, encrypted range, and other data for pause/resume operations. We cannot create the
+ primary header until the entire partition is encrypted (because we encrypt backwards and the primary header
+ area is occuppied by data until the very end of the process). */
+
+ // Prepare the backup header
+ for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++)
+ {
+ nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
+ header,
+ volParams->ea,
+ FIRST_MODE_OF_OPERATION_ID,
+ volParams->password,
+ volParams->pkcs5,
+ volParams->pim,
+ wipePass == 0 ? NULL : (char *) cryptoInfo->master_keydata,
+ &cryptoInfo,
+ dataAreaSize,
+ 0,
+ TC_VOLUME_DATA_OFFSET + dataAreaSize, // Start of the encrypted area = the first byte of the backup heeader (encrypting from the end)
+ 0, // No data is encrypted yet
+ 0,
+ volParams->headerFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC,
+ volParams->sectorSize,
+ wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1));
+
+ if (nStatus != 0)
+ goto closing_seq;
+
+ offset.QuadPart = TC_VOLUME_DATA_OFFSET + dataAreaSize;
+
+ if (!SetFilePointerEx (dev, offset, NULL, FILE_BEGIN))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ // Write the backup header to the partition
+ if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ // Fill the reserved sectors of the backup header area with random data
+ nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, TRUE);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+ }
+
+
+ /* Now we will try to decrypt the backup header to verify it has been correctly written. */
+
+ nStatus = OpenBackupHeader (dev, volParams->volumePath, volParams->password, volParams->pkcs5, volParams->pim, &cryptoInfo2, NULL, deviceSize);
+
+ if (nStatus != ERR_SUCCESS
+ || cryptoInfo->EncryptedAreaStart.Value != cryptoInfo2->EncryptedAreaStart.Value
+ || cryptoInfo2->EncryptedAreaStart.Value == 0)
+ {
+ if (nStatus == ERR_SUCCESS)
+ nStatus = ERR_PARAMETER_INCORRECT;
+
+ goto closing_seq;
+ }
+
+ // The backup header is valid so we know we should be able to safely resume in-place encryption
+ // of this partition even if the system/app crashes.
+
+
+
+ /* Conceal the NTFS filesystem (by performing an easy-to-undo modification). This will prevent Windows
+ and apps from interfering with the volume until it has been fully encrypted. */
+
+ nStatus = ConcealNTFS (dev);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+
+ // /* If a drive letter is assigned to the device, remove it (so that users do not try to open it, which
+ //would cause Windows to ask them if they want to format the volume and other dangerous things). */
+
+ //if (driveLetter >= 0)
+ //{
+ // char rootPath[] = { driveLetter + 'A', ':', '\\', 0 };
+
+ // // Try to remove the assigned drive letter
+ // if (DeleteVolumeMountPoint (rootPath))
+ // driveLetter = -1;
+ //}
+
+
+
+ /* Update config files and app data */
+
+ // In the config file, increase the number of partitions where in-place encryption is in progress
+
+ SaveNonSysInPlaceEncSettings (1, wipeAlgorithm, FALSE);
+
+
+ // Add the wizard to the system startup sequence if appropriate
+
+ if (!IsNonInstallMode ())
+ ManageStartupSeqWiz (FALSE, L"/prinplace");
+
+
+ nStatus = ERR_SUCCESS;
+
+
+closing_seq:
+
+ dwError = GetLastError();
+
+ if (cryptoInfo != NULL)
+ {
+ crypto_close (cryptoInfo);
+ cryptoInfo = NULL;
+ }
+
+ if (cryptoInfo2 != NULL)
+ {
+ crypto_close (cryptoInfo2);
+ cryptoInfo2 = NULL;
+ }
+
+ burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ TCfree (header);
+
+ if (dosDev[0])
+ RemoveFakeDosName (volParams->volumePath, dosDev);
+
+ *outHandle = dev;
+
+ if (nStatus != ERR_SUCCESS)
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+
+int EncryptPartitionInPlaceResume (HANDLE dev,
+ volatile FORMAT_VOL_PARAMETERS *volParams,
+ WipeAlgorithmId wipeAlgorithm,
+ volatile BOOL *bTryToCorrectReadErrors)
+{
+ PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL, tmpCryptoInfo = NULL;
+ UINT64_STRUCT unitNo;
+ char *buf = NULL, *header = NULL;
+ byte *wipeBuffer = NULL;
+ byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT];
+ byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT];
+ WCHAR dosDev[TC_MAX_PATH] = {0};
+ WCHAR devName[MAX_PATH] = {0};
+ WCHAR deviceName[MAX_PATH];
+ int nStatus = ERR_SUCCESS;
+ __int64 deviceSize;
+ uint64 remainingBytes, lastHeaderUpdateDistance = 0, zeroedSectorCount = 0;
+ uint32 workChunkSize;
+ DWORD dwError, dwResult;
+ BOOL bPause = FALSE, bEncryptedAreaSizeChanged = FALSE;
+ LARGE_INTEGER offset;
+ int sectorSize;
+ int i;
+ DWORD n;
+ WCHAR *devicePath = volParams->volumePath;
+ Password *password = volParams->password;
+ int pkcs5_prf = volParams->pkcs5;
+ int pim = volParams->pim;
+ DISK_GEOMETRY driveGeometry;
+ HWND hwndDlg = volParams->hwndDlg;
+
+
+ bInPlaceEncNonSysResumed = TRUE;
+
+ buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
+ if (!buf)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+
+ header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ if (!header)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+
+ VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+
+ if (wipeAlgorithm != TC_WIPE_NONE)
+ {
+ wipeBuffer = (byte *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
+ if (!wipeBuffer)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+ }
+
+ headerCryptoInfo = crypto_open();
+
+ if (headerCryptoInfo == NULL)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+
+ deviceSize = GetDeviceSize (devicePath);
+ if (deviceSize < 0)
+ {
+ // Cannot determine the size of the partition
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (dev == INVALID_HANDLE_VALUE)
+ {
+ StringCchCopyW (deviceName, ARRAYSIZE(deviceName), devicePath);
+
+ if (FakeDosNameForDevice (deviceName, dosDev, sizeof(dosDev),devName, sizeof(devName),FALSE) != 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ dev = OpenPartitionVolume (hwndDlg, devName,
+ FALSE, // Do not require exclusive access
+ FALSE, // Do not require shared access
+ TRUE, // Ask the user to confirm shared access (if exclusive fails)
+ FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
+ FALSE); // Non-silent mode
+
+ if (dev == INVALID_HANDLE_VALUE)
+ {
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+ }
+
+ // This should never be needed, but is still performed for extra safety (without checking the result)
+ DeviceIoControl (dev,
+ FSCTL_ALLOW_EXTENDED_DASD_IO,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ &dwResult,
+ NULL);
+
+
+ if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ sectorSize = driveGeometry.BytesPerSector;
+
+
+ nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+
+ remainingBytes = masterCryptoInfo->VolumeSize.Value - masterCryptoInfo->EncryptedAreaLength.Value;
+
+ lastHeaderUpdateDistance = 0;
+
+
+ ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_ENCRYPTING);
+
+ bFirstNonSysInPlaceEncResumeDone = TRUE;
+
+
+ /* The in-place encryption core */
+
+ while (remainingBytes > 0)
+ {
+ workChunkSize = (uint32) min (remainingBytes, TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
+
+ if (workChunkSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
+ {
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto closing_seq;
+ }
+
+ unitNo.Value = (remainingBytes - workChunkSize + TC_VOLUME_DATA_OFFSET) / ENCRYPTION_DATA_UNIT_SIZE;
+
+
+ // Read the plaintext into RAM
+
+inplace_enc_read:
+
+ offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize - TC_VOLUME_DATA_OFFSET;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (ReadFile (dev, buf, workChunkSize, &n, NULL) == 0)
+ {
+ // Read error
+
+ DWORD dwTmpErr = GetLastError ();
+
+ if (IsDiskReadError (dwTmpErr) && !bVolTransformThreadCancel)
+ {
+ // Physical defect or data corruption
+
+ if (!*bTryToCorrectReadErrors)
+ {
+ *bTryToCorrectReadErrors = (AskWarnYesNo ("ENABLE_BAD_SECTOR_ZEROING", hwndDlg) == IDYES);
+ }
+
+ if (*bTryToCorrectReadErrors)
+ {
+ // Try to correct the read errors physically
+
+ offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize - TC_VOLUME_DATA_OFFSET;
+
+ nStatus = ZeroUnreadableSectors (dev, offset, workChunkSize, sectorSize, &zeroedSectorCount);
+
+ if (nStatus != ERR_SUCCESS)
+ {
+ // Due to write errors, we can't correct the read errors
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ goto inplace_enc_read;
+ }
+ }
+
+ SetLastError (dwTmpErr); // Preserve the original error code
+
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (remainingBytes - workChunkSize < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE)
+ {
+ // We reached the inital portion of the filesystem, which we had concealed (in order to prevent
+ // Windows from interfering with the volume). Now we need to undo that modification.
+
+ for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE - (remainingBytes - workChunkSize); i++)
+ buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
+ }
+
+
+ // Encrypt the plaintext in RAM
+
+ EncryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
+
+
+ // If enabled, wipe the area to which we will write the ciphertext
+
+ if (wipeAlgorithm != TC_WIPE_NONE)
+ {
+ byte wipePass;
+ int wipePassCount = GetWipePassCount (wipeAlgorithm);
+
+ if (wipePassCount <= 0)
+ {
+ SetLastError (ERROR_INVALID_PARAMETER);
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto closing_seq;
+ }
+
+ offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize;
+
+ for (wipePass = 1; wipePass <= wipePassCount; ++wipePass)
+ {
+ if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize))
+ {
+ ULONG i;
+ for (i = 0; i < workChunkSize; ++i)
+ {
+ wipeBuffer[i] = buf[i] + wipePass;
+ }
+
+ EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
+ memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate));
+ }
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
+ || WriteFile (dev, wipeBuffer, workChunkSize, &n, NULL) == 0)
+ {
+ // Write error
+ dwError = GetLastError();
+
+ // Undo failed write operation
+ if (workChunkSize > TC_VOLUME_DATA_OFFSET && SetFilePointerEx (dev, offset, NULL, FILE_BEGIN))
+ {
+ DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
+ WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL);
+ }
+
+ SetLastError (dwError);
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+ }
+
+ memcpy (wipeRandChars, wipeRandCharsUpdate, sizeof (wipeRandCharsUpdate));
+ }
+
+
+ // Write the ciphertext
+
+ offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (WriteFile (dev, buf, workChunkSize, &n, NULL) == 0)
+ {
+ // Write error
+ dwError = GetLastError();
+
+ // Undo failed write operation
+ if (workChunkSize > TC_VOLUME_DATA_OFFSET && SetFilePointerEx (dev, offset, NULL, FILE_BEGIN))
+ {
+ DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
+ WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL);
+ }
+
+ SetLastError (dwError);
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+ masterCryptoInfo->EncryptedAreaStart.Value -= workChunkSize;
+ masterCryptoInfo->EncryptedAreaLength.Value += workChunkSize;
+
+ remainingBytes -= workChunkSize;
+ lastHeaderUpdateDistance += workChunkSize;
+
+ bEncryptedAreaSizeChanged = TRUE;
+
+ if (lastHeaderUpdateDistance >= TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL)
+ {
+ nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+ lastHeaderUpdateDistance = 0;
+ }
+
+ ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
+
+ if (bVolTransformThreadCancel)
+ {
+ bPause = TRUE;
+ break;
+ }
+ }
+
+ nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
+
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+ if (!bPause)
+ {
+ /* The data area has been fully encrypted; create and write the primary volume header */
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINALIZING);
+
+ for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++)
+ {
+ nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
+ header,
+ headerCryptoInfo->ea,
+ headerCryptoInfo->mode,
+ password,
+ masterCryptoInfo->pkcs5,
+ pim,
+ (char *) masterCryptoInfo->master_keydata,
+ &tmpCryptoInfo,
+ masterCryptoInfo->VolumeSize.Value,
+ 0,
+ masterCryptoInfo->EncryptedAreaStart.Value,
+ masterCryptoInfo->EncryptedAreaLength.Value,
+ masterCryptoInfo->RequiredProgramVersion,
+ masterCryptoInfo->HeaderFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC,
+ masterCryptoInfo->SectorSize,
+ wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1));
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+ offset.QuadPart = TC_VOLUME_HEADER_OFFSET;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
+ || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ // Fill the reserved sectors of the header area with random data
+ nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+ }
+
+ // Update the configuration files
+
+ SaveNonSysInPlaceEncSettings (-1, wipeAlgorithm, FALSE);
+
+
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINISHED);
+
+ nStatus = ERR_SUCCESS;
+ }
+ else
+ {
+ // The process has been paused by the user or aborted by the wizard (e.g. on app exit)
+
+ nStatus = ERR_USER_ABORT;
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED);
+ }
+
+
+closing_seq:
+
+ dwError = GetLastError();
+
+ if (bEncryptedAreaSizeChanged
+ && dev != INVALID_HANDLE_VALUE
+ && masterCryptoInfo != NULL
+ && headerCryptoInfo != NULL
+ && deviceSize > 0)
+ {
+ // Execution of the core loop may have been interrupted due to an error or user action without updating the header
+ FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
+ }
+
+ if (masterCryptoInfo != NULL)
+ {
+ crypto_close (masterCryptoInfo);
+ masterCryptoInfo = NULL;
+ }
+
+ if (headerCryptoInfo != NULL)
+ {
+ crypto_close (headerCryptoInfo);
+ headerCryptoInfo = NULL;
+ }
+
+ if (tmpCryptoInfo != NULL)
+ {
+ crypto_close (tmpCryptoInfo);
+ tmpCryptoInfo = NULL;
+ }
+
+ if (dosDev[0])
+ RemoveFakeDosName (devicePath, dosDev);
+
+ if (dev != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle (dev);
+ dev = INVALID_HANDLE_VALUE;
+ }
+
+ if (buf != NULL)
+ TCfree (buf);
+
+ if (header != NULL)
+ {
+ burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ TCfree (header);
+ }
+
+ if (wipeBuffer != NULL)
+ TCfree (wipeBuffer);
+
+ if (zeroedSectorCount > 0)
+ {
+ wchar_t msg[30000] = {0};
+ wchar_t sizeStr[500] = {0};
+
+ GetSizeString (zeroedSectorCount * sectorSize, sizeStr, sizeof(sizeStr));
+
+ StringCbPrintfW (msg, sizeof(msg),
+ GetString ("ZEROED_BAD_SECTOR_COUNT"),
+ zeroedSectorCount,
+ sizeStr);
+
+ WarningDirect (msg, hwndDlg);
+ }
+
+ if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT)
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile BOOL *DiscardUnreadableEncryptedSectors)
+{
+ HANDLE dev = INVALID_HANDLE_VALUE;
+ PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL;
+ UINT64_STRUCT unitNo;
+ char *buf = NULL;
+ byte *tmpSectorBuf = NULL;
+ WCHAR dosDev[TC_MAX_PATH] = {0};
+ WCHAR devName[MAX_PATH] = {0};
+ WCHAR deviceName[MAX_PATH];
+ int nStatus = ERR_SUCCESS;
+ __int64 deviceSize;
+ uint64 remainingBytes, workChunkStartByteOffset, lastHeaderUpdateDistance = 0, skippedBadSectorCount = 0;
+ uint32 workChunkSize;
+ DWORD dwError, dwResult;
+ BOOL bPause = FALSE, bEncryptedAreaSizeChanged = FALSE;
+ LARGE_INTEGER offset;
+ int sectorSize;
+ int i;
+ DWORD n;
+ WCHAR *devicePath = volParams->volumePath;
+ Password *password = volParams->password;
+ HWND hwndDlg = volParams->hwndDlg;
+ int pkcs5_prf = volParams->pkcs5;
+ int pim = volParams->pim;
+ DISK_GEOMETRY driveGeometry;
+
+
+ buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
+ if (!buf)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+
+ headerCryptoInfo = crypto_open();
+
+ if (headerCryptoInfo == NULL)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+
+ deviceSize = GetDeviceSize (devicePath);
+ if (deviceSize < 0)
+ {
+ // Cannot determine the size of the partition
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+ // The wizard should have dismounted the TC volume if it was mounted, but for extra safety we will check this again.
+ if (IsMountedVolume (devicePath))
+ {
+ int driveLetter = GetMountedVolumeDriveNo (devicePath);
+
+ if (driveLetter == -1
+ || !UnmountVolume (hwndDlg, driveLetter, TRUE))
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ AbortProcess ("CANT_DISMOUNT_VOLUME");
+ }
+ }
+
+
+ StringCchCopyW (deviceName, ARRAYSIZE(deviceName), devicePath);
+
+ if (FakeDosNameForDevice (deviceName, dosDev, sizeof(dosDev), devName, sizeof(devName), FALSE) != 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ dev = OpenPartitionVolume (hwndDlg, devName,
+ TRUE, // Require exclusive access
+ FALSE, // Do not require shared access
+ TRUE, // Ask the user to confirm shared access (if exclusive fails)
+ FALSE, // Do not append alternative instructions how to encrypt the data (to applicable error messages)
+ FALSE); // Non-silent mode
+
+ if (dev == INVALID_HANDLE_VALUE)
+ {
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+
+
+ // This should never be needed, but is still performed for extra safety (without checking the result)
+ DeviceIoControl (dev,
+ FSCTL_ALLOW_EXTENDED_DASD_IO,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ &dwResult,
+ NULL);
+
+
+ if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if ( (driveGeometry.BytesPerSector == 0)
+ || (driveGeometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE)
+ || (driveGeometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0)
+ )
+ {
+ Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ sectorSize = driveGeometry.BytesPerSector;
+
+
+ tmpSectorBuf = (byte *) TCalloc (sectorSize);
+ if (!tmpSectorBuf)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto closing_seq;
+ }
+
+
+ nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+ if (masterCryptoInfo->LegacyVolume)
+ {
+ Error ("NONSYS_INPLACE_DECRYPTION_BAD_VOL_FORMAT", hwndDlg);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ if (masterCryptoInfo->hiddenVolume)
+ {
+ Error ("NONSYS_INPLACE_DECRYPTION_CANT_DECRYPT_HID_VOL", hwndDlg);
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+
+ if (!bInPlaceEncNonSysResumed
+ && masterCryptoInfo->VolumeSize.Value == masterCryptoInfo->EncryptedAreaLength.Value)
+ {
+ /* Decryption started (not resumed) */
+
+ if ((masterCryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) == 0)
+ {
+ // The volume has not been encrypted in-place so it may contain a hidden volume.
+ // Ask the user to confirm it does not.
+
+ char *tmpStr[] = {0,
+ "CONFIRM_VOL_CONTAINS_NO_HIDDEN_VOL",
+ "VOL_CONTAINS_NO_HIDDEN_VOL",
+ "VOL_CONTAINS_A_HIDDEN_VOL",
+ 0};
+
+ switch (AskMultiChoice ((void **) tmpStr, FALSE, hwndDlg))
+ {
+ case 1:
+ // NOP
+ break;
+ case 2:
+ default:
+ // Cancel
+ nStatus = ERR_DONT_REPORT;
+ goto closing_seq;
+ }
+ }
+
+ // Update config files and app data
+
+ // In the config file, increase the number of partitions where in-place decryption is in progress
+ SaveNonSysInPlaceEncSettings (1, TC_WIPE_NONE, TRUE);
+
+ // Add the wizard to the system startup sequence if appropriate
+ if (!IsNonInstallMode ())
+ ManageStartupSeqWiz (FALSE, L"/prinplace");
+ }
+
+
+
+ bInPlaceEncNonSysResumed = TRUE;
+ bFirstNonSysInPlaceEncResumeDone = TRUE;
+
+
+ remainingBytes = masterCryptoInfo->EncryptedAreaLength.Value;
+
+ lastHeaderUpdateDistance = 0;
+
+
+ ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_DECRYPTING);
+
+
+
+ /* The in-place decryption core */
+
+ while (remainingBytes > 0)
+ {
+ workChunkSize = (uint32) min (remainingBytes, TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
+
+ if (workChunkSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
+ {
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto closing_seq;
+ }
+
+ workChunkStartByteOffset = masterCryptoInfo->EncryptedAreaStart.Value;
+
+ unitNo.Value = workChunkStartByteOffset / ENCRYPTION_DATA_UNIT_SIZE;
+
+
+ // Read the ciphertext into RAM
+
+ offset.QuadPart = workChunkStartByteOffset;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (ReadFile (dev, buf, workChunkSize, &n, NULL) == 0)
+ {
+ // Read error
+
+ DWORD dwTmpErr = GetLastError ();
+
+ if (IsDiskReadError (dwTmpErr) && !bVolTransformThreadCancel)
+ {
+ // Physical defect or data corruption
+
+ if (!*DiscardUnreadableEncryptedSectors)
+ {
+ *DiscardUnreadableEncryptedSectors = (AskWarnYesNo ("DISCARD_UNREADABLE_ENCRYPTED_SECTORS", hwndDlg) == IDYES);
+ }
+
+ if (*DiscardUnreadableEncryptedSectors)
+ {
+ // Read the work chunk again, but this time each sector individually and skiping each bad sector
+
+ LARGE_INTEGER tmpSectorOffset;
+ uint64 tmpSectorCount;
+ uint64 tmpBufOffset = 0;
+ DWORD tmpNbrReadBytes = 0;
+
+ tmpSectorOffset.QuadPart = offset.QuadPart;
+
+ for (tmpSectorCount = workChunkSize / sectorSize; tmpSectorCount > 0; --tmpSectorCount)
+ {
+ if (SetFilePointerEx (dev, tmpSectorOffset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (ReadFile (dev, tmpSectorBuf, sectorSize, &tmpNbrReadBytes, NULL) == 0
+ || tmpNbrReadBytes != (DWORD) sectorSize)
+ {
+ // Read error
+
+ // Clear the buffer so the content of each unreadable sector is replaced with decrypted all-zero blocks (producing pseudorandom data)
+ memset (tmpSectorBuf, 0, sectorSize);
+
+ skippedBadSectorCount++;
+ }
+
+ memcpy (buf + tmpBufOffset, tmpSectorBuf, sectorSize);
+
+ tmpSectorOffset.QuadPart += sectorSize;
+ tmpBufOffset += sectorSize;
+ }
+ }
+ else
+ {
+ SetLastError (dwTmpErr); // Preserve the original error code
+
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+ }
+ else
+ {
+ SetLastError (dwTmpErr); // Preserve the original error code
+
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+ }
+
+ // Decrypt the ciphertext in RAM
+
+ DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
+
+
+
+ // Conceal initial portion of the filesystem
+
+ if (workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE)
+ {
+ // We are decrypting the initial TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE bytes of the filesystem. We will
+ // conceal this portion to prevent Windows and applications from interfering with the volume.
+
+ for (i = 0; i < min (TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET + workChunkSize); i++)
+ buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
+ }
+
+
+ // Write the plaintext
+
+ offset.QuadPart = workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (WriteFile (dev, buf, workChunkSize, &n, NULL) == 0)
+ {
+ // Write error
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+ masterCryptoInfo->EncryptedAreaStart.Value += workChunkSize;
+ masterCryptoInfo->EncryptedAreaLength.Value -= workChunkSize;
+
+ remainingBytes -= workChunkSize;
+ lastHeaderUpdateDistance += workChunkSize;
+
+ bEncryptedAreaSizeChanged = TRUE;
+
+ if (lastHeaderUpdateDistance >= TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL)
+ {
+ nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
+
+ if (nStatus != ERR_SUCCESS)
+ {
+ // Possible write error
+ goto closing_seq;
+ }
+
+ lastHeaderUpdateDistance = 0;
+ }
+
+ ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value);
+
+ if (bVolTransformThreadCancel)
+ {
+ bPause = TRUE;
+ break;
+ }
+ }
+
+ nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
+
+
+ if (nStatus != ERR_SUCCESS)
+ {
+ // Possible write error
+ goto closing_seq;
+ }
+
+
+ if (!bPause)
+ {
+ /* Volume has been fully decrypted. */
+
+
+ // Prevent attempts to update volume header during the closing sequence
+ bEncryptedAreaSizeChanged = FALSE;
+
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINALIZING);
+
+
+
+ /* Undo concealing of the filesystem */
+
+ nStatus = ConcealNTFS (dev);
+
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+
+ /* Ovewrite the backup header and the remaining ciphertext with all-zero blocks (the primary header was overwritten with the decrypted data). */
+
+ memset (tmpSectorBuf, 0, sectorSize);
+
+ for (offset.QuadPart = masterCryptoInfo->VolumeSize.Value;
+ offset.QuadPart <= deviceSize - sectorSize;
+ offset.QuadPart += sectorSize)
+ {
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (WriteFile (dev, tmpSectorBuf, sectorSize, &n, NULL) == 0)
+ {
+ // Write error
+ dwError = GetLastError();
+
+ SetLastError (dwError);
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+ }
+
+
+
+ /* Update the configuration files */
+
+ SaveNonSysInPlaceEncSettings (-1, TC_WIPE_NONE, TRUE);
+
+
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINISHED);
+
+ nStatus = ERR_SUCCESS;
+
+ }
+ else
+ {
+ // The process has been paused by the user or aborted by the wizard (e.g. on app exit)
+
+ nStatus = ERR_USER_ABORT;
+
+ SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED);
+ }
+
+ if (dev != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle (dev);
+ dev = INVALID_HANDLE_VALUE;
+ }
+
+
+closing_seq:
+
+ dwError = GetLastError();
+
+ if (bEncryptedAreaSizeChanged
+ && dev != INVALID_HANDLE_VALUE
+ && masterCryptoInfo != NULL
+ && headerCryptoInfo != NULL
+ && deviceSize > 0)
+ {
+ // Execution of the core loop may have been interrupted due to an error or user action without updating the header
+ FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize);
+ }
+
+ if (dev != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle (dev);
+ dev = INVALID_HANDLE_VALUE;
+ }
+
+ if (masterCryptoInfo != NULL)
+ {
+ crypto_close (masterCryptoInfo);
+ masterCryptoInfo = NULL;
+ }
+
+ if (headerCryptoInfo != NULL)
+ {
+ crypto_close (headerCryptoInfo);
+ headerCryptoInfo = NULL;
+ }
+
+ if (dosDev[0])
+ RemoveFakeDosName (devicePath, dosDev);
+
+ if (buf != NULL)
+ {
+ TCfree (buf);
+ buf = NULL;
+ }
+
+ if (tmpSectorBuf != NULL)
+ {
+ TCfree (tmpSectorBuf);
+ tmpSectorBuf = NULL;
+ }
+
+ if (skippedBadSectorCount > 0)
+ {
+ wchar_t msg[30000] = {0};
+ wchar_t sizeStr[500] = {0};
+
+ GetSizeString (skippedBadSectorCount * sectorSize, sizeStr, sizeof(sizeStr));
+
+ StringCbPrintfW (msg, sizeof(msg),
+ GetString ("SKIPPED_BAD_SECTOR_COUNT"),
+ skippedBadSectorCount,
+ sizeStr);
+
+ WarningDirect (msg, hwndDlg);
+ }
+
+ if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT)
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize)
+{
+ LARGE_INTEGER offset;
+ DWORD n;
+ int nStatus = ERR_SUCCESS;
+ byte *header;
+ DWORD dwError;
+ uint32 headerCrc32;
+ byte *fieldPos;
+
+ header = (byte *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+
+ if (!header)
+ return ERR_OUTOFMEMORY;
+
+ VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+
+
+ fieldPos = (byte *) header + TC_HEADER_OFFSET_ENCRYPTED_AREA_START;
+
+ offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
+ || !ReadEffectiveVolumeHeader (TRUE, dev, header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+ DecryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo);
+
+ if (GetHeaderField32 (header, TC_HEADER_OFFSET_MAGIC) != 0x56455241)
+ {
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto closing_seq;
+ }
+
+ mputInt64 (fieldPos, (masterCryptoInfo->EncryptedAreaStart.Value));
+ mputInt64 (fieldPos, (masterCryptoInfo->EncryptedAreaLength.Value));
+
+ // We need to ensure the TC_HEADER_FLAG_NONSYS_INPLACE_ENC flag bit is set, because if volumes created by TC-format
+ // were decrypted in place, it would be possible to mount them partially encrypted and it wouldn't be possible
+ // to resume interrupted decryption after the wizard exits.
+ masterCryptoInfo->HeaderFlags |= TC_HEADER_FLAG_NONSYS_INPLACE_ENC;
+ fieldPos = (byte *) header + TC_HEADER_OFFSET_FLAGS;
+ mputLong (fieldPos, (masterCryptoInfo->HeaderFlags));
+
+
+ headerCrc32 = GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC);
+ fieldPos = (byte *) header + TC_HEADER_OFFSET_HEADER_CRC;
+ mputLong (fieldPos, headerCrc32);
+
+ EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo);
+
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
+ || !WriteEffectiveVolumeHeader (TRUE, dev, header))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+closing_seq:
+
+ dwError = GetLastError();
+
+ burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ TCfree (header);
+
+ if (nStatus != ERR_SUCCESS)
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+
+static HANDLE OpenPartitionVolume (HWND hwndDlg, const wchar_t *devName,
+ BOOL bExclusiveRequired,
+ BOOL bSharedRequired,
+ BOOL bSharedRequiresConfirmation,
+ BOOL bShowAlternativeSteps,
+ BOOL bSilent)
+{
+ HANDLE dev = INVALID_HANDLE_VALUE;
+ int retryCount = 0;
+
+ if (bExclusiveRequired)
+ bSharedRequired = FALSE;
+
+ if (bExclusiveRequired || !bSharedRequired)
+ {
+ // Exclusive access
+ // Note that when exclusive access is denied, it is worth retrying (usually succeeds after a few tries).
+ while (dev == INVALID_HANDLE_VALUE && retryCount++ < EXCL_ACCESS_MAX_AUTO_RETRIES)
+ {
+ dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL);
+
+ if (retryCount > 1)
+ Sleep (EXCL_ACCESS_AUTO_RETRY_DELAY);
+ }
+ }
+
+ if (dev == INVALID_HANDLE_VALUE)
+ {
+ if (bExclusiveRequired)
+ {
+ if (!bSilent)
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+
+ if (bShowAlternativeSteps)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
+ else
+ Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
+ }
+ return INVALID_HANDLE_VALUE;
+ }
+
+ // Shared mode
+ dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, NULL);
+ if (dev != INVALID_HANDLE_VALUE)
+ {
+ if (bSharedRequiresConfirmation
+ && !bSilent
+ && AskWarnNoYes ("DEVICE_IN_USE_INPLACE_ENC", hwndDlg) == IDNO)
+ {
+ CloseHandle (dev);
+ return INVALID_HANDLE_VALUE;
+ }
+ }
+ else
+ {
+ if (!bSilent)
+ {
+ handleWin32Error (MainDlg, SRC_POS);
+
+ if (bShowAlternativeSteps)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
+ else
+ Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
+ }
+ return INVALID_HANDLE_VALUE;
+ }
+ }
+
+ return dev;
+}
+
+
+static int DismountFileSystem (HWND hwndDlg, HANDLE dev,
+ int driveLetter,
+ BOOL bForcedAllowed,
+ BOOL bForcedRequiresConfirmation,
+ BOOL bSilent)
+{
+ int attempt;
+ BOOL bResult;
+ DWORD dwResult;
+
+ CloseVolumeExplorerWindows (MainDlg, driveLetter);
+
+ attempt = UNMOUNT_MAX_AUTO_RETRIES * 10;
+
+ while (!(bResult = DeviceIoControl (dev, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL))
+ && attempt > 0)
+ {
+ Sleep (UNMOUNT_AUTO_RETRY_DELAY);
+ attempt--;
+ }
+
+ if (!bResult)
+ {
+ if (!bForcedAllowed)
+ {
+ if (!bSilent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE);
+
+ return ERR_DONT_REPORT;
+ }
+
+ if (bForcedRequiresConfirmation
+ && !bSilent
+ && AskWarnYesNo ("VOL_LOCK_FAILED_OFFER_FORCED_DISMOUNT", hwndDlg) == IDNO)
+ {
+ return ERR_DONT_REPORT;
+ }
+ }
+
+ // Dismount the volume
+
+ attempt = UNMOUNT_MAX_AUTO_RETRIES * 10;
+
+ while (!(bResult = DeviceIoControl (dev, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL))
+ && attempt > 0)
+ {
+ Sleep (UNMOUNT_AUTO_RETRY_DELAY);
+ attempt--;
+ }
+
+ if (!bResult)
+ {
+ if (!bSilent)
+ ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE);
+
+ return ERR_DONT_REPORT;
+ }
+
+ return ERR_SUCCESS;
+}
+
+
+// Easy-to-undo modification applied to conceal the NTFS filesystem (to prevent Windows and apps from
+// interfering with it until the volume has been fully encrypted). Note that this function will precisely
+// undo any modifications it made to the filesystem automatically if an error occurs when writing (including
+// physical drive defects).
+static int ConcealNTFS (HANDLE dev)
+{
+ char buf [TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE];
+ DWORD nbrBytesProcessed, nbrBytesProcessed2;
+ int i;
+ LARGE_INTEGER offset;
+ DWORD dwError;
+
+ offset.QuadPart = 0;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ return ERR_OS_ERROR;
+
+ if (ReadFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed, NULL) == 0)
+ return ERR_OS_ERROR;
+
+ for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE; i++)
+ buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
+
+ offset.QuadPart = 0;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0)
+ return ERR_OS_ERROR;
+
+ if (WriteFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed, NULL) == 0)
+ {
+ // One or more of the sectors is/are probably damaged and cause write errors.
+ // We must undo the modifications we made.
+
+ dwError = GetLastError();
+
+ for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE; i++)
+ buf[i] ^= TC_NTFS_CONCEAL_CONSTANT;
+
+ offset.QuadPart = 0;
+
+ do
+ {
+ Sleep (1);
+ }
+ while (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
+ || WriteFile (dev, buf, TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, &nbrBytesProcessed2, NULL) == 0);
+
+ SetLastError (dwError);
+
+ return ERR_OS_ERROR;
+ }
+
+ return ERR_SUCCESS;
+}
+
+
+void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr)
+{
+ wchar_t msg[30000];
+
+ StringCbCopyW (msg, sizeof(msg), GetString (iniStrId));
+
+ StringCbCatW (msg, sizeof(msg), L"\n\n\n");
+ StringCbCatW (msg, sizeof(msg), GetString ("INPLACE_ENC_ALTERNATIVE_STEPS"));
+
+ if (bErr)
+ ErrorDirect (msg, hwndDlg);
+ else
+ WarningDirect (msg, hwndDlg);
+}
+
+
+static void ExportProgressStats (__int64 bytesDone, __int64 totalSize)
+{
+ NonSysInplaceEncBytesDone = bytesDone;
+ NonSysInplaceEncTotalSize = totalSize;
+}
+
+
+void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus)
+{
+ NonSysInplaceEncStatus = nonSysInplaceEncStatus;
+}
+
+
+BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId newWipeAlgorithm, BOOL bDecrypt)
+{
+ int count;
+ char str[32];
+ WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
+
+ if (delta == 0)
+ return TRUE;
+
+ count = LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) + delta;
+
+ if (count < 1)
+ {
+ RemoveNonSysInPlaceEncNotifications();
+ return TRUE;
+ }
+ else if (!bDecrypt)
+ {
+ if (newWipeAlgorithm != TC_WIPE_NONE)
+ {
+ StringCbPrintfA (str, sizeof(str), "%d", (int) newWipeAlgorithm);
+
+ SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE), (DWORD) strlen(str), FALSE, FALSE);
+ }
+ else if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE)))
+ {
+ _wremove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE));
+ }
+ }
+
+ StringCbPrintfA (str, sizeof(str), "%d", count);
+
+ return SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC), (DWORD) strlen(str), FALSE, FALSE);
+}
+
+
+// Repairs damaged sectors (i.e. those with read errors) by zeroing them.
+// Note that this operating fails if there are any write errors.
+int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount)
+{
+ int nStatus;
+ DWORD n;
+ int64 sectorCount;
+ LARGE_INTEGER workOffset;
+ byte *sectorBuffer = NULL;
+ DWORD dwError;
+
+ workOffset.QuadPart = startOffset.QuadPart;
+
+ sectorBuffer = (byte *) TCalloc (sectorSize);
+
+ if (!sectorBuffer)
+ return ERR_OUTOFMEMORY;
+
+ if (SetFilePointerEx (dev, startOffset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+ for (sectorCount = size / sectorSize; sectorCount > 0; --sectorCount)
+ {
+ if (ReadFile (dev, sectorBuffer, sectorSize, &n, NULL) == 0)
+ {
+ memset (sectorBuffer, 0, sectorSize);
+
+ if (SetFilePointerEx (dev, workOffset, NULL, FILE_BEGIN) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+ if (WriteFile (dev, sectorBuffer, sectorSize, &n, NULL) == 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+ ++(*zeroedSectorCount);
+ }
+
+ workOffset.QuadPart += n;
+ }
+
+ nStatus = ERR_SUCCESS;
+
+closing_seq:
+
+ dwError = GetLastError();
+
+ if (sectorBuffer != NULL)
+ TCfree (sectorBuffer);
+
+ if (nStatus != ERR_SUCCESS)
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+
+static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize)
+{
+ LARGE_INTEGER offset;
+ DWORD n;
+ int nStatus = ERR_SUCCESS;
+ char *header;
+ DWORD dwError;
+
+ header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ if (!header)
+ return ERR_OUTOFMEMORY;
+
+ VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+
+
+
+ offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE;
+
+ if (SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) == 0
+ || !ReadEffectiveVolumeHeader (TRUE, dev, (byte *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto closing_seq;
+ }
+
+
+ nStatus = ReadVolumeHeader (FALSE, header, password, pkcs5, pim, FALSE, retMasterCryptoInfo, headerCryptoInfo);
+ if (nStatus != ERR_SUCCESS)
+ goto closing_seq;
+
+
+closing_seq:
+
+ dwError = GetLastError();
+
+ burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ TCfree (header);
+
+ dwError = GetLastError();
+
+ if (nStatus != ERR_SUCCESS)
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+
+static BOOL GetFreeClusterBeforeThreshold (HANDLE volumeHandle, int64 *freeCluster, int64 clusterThreshold)
+{
+ const int bitmapSize = 65536;
+ byte bitmapBuffer[bitmapSize + sizeof (VOLUME_BITMAP_BUFFER)];
+ VOLUME_BITMAP_BUFFER *bitmap = (VOLUME_BITMAP_BUFFER *) bitmapBuffer;
+ STARTING_LCN_INPUT_BUFFER startLcn;
+ startLcn.StartingLcn.QuadPart = 0;
+
+ DWORD bytesReturned;
+ while (DeviceIoControl (volumeHandle, FSCTL_GET_VOLUME_BITMAP, &startLcn, sizeof (startLcn), &bitmapBuffer, sizeof (bitmapBuffer), &bytesReturned, NULL)
+ || GetLastError() == ERROR_MORE_DATA)
+ {
+ for (int64 bitmapIndex = 0; bitmapIndex < min (bitmapSize, (bitmap->BitmapSize.QuadPart / 8)); ++bitmapIndex)
+ {
+ if (bitmap->StartingLcn.QuadPart + bitmapIndex * 8 >= clusterThreshold)
+ goto err;
+
+ if (bitmap->Buffer[bitmapIndex] != 0xff)
+ {
+ for (int bit = 0; bit < 8; ++bit)
+ {
+ if ((bitmap->Buffer[bitmapIndex] & (1 << bit)) == 0)
+ {
+ *freeCluster = bitmap->StartingLcn.QuadPart + bitmapIndex * 8 + bit;
+
+ if (*freeCluster >= clusterThreshold)
+ goto err;
+
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ startLcn.StartingLcn.QuadPart += min (bitmapSize * 8, bitmap->BitmapSize.QuadPart);
+ }
+
+err:
+ SetLastError (ERROR_DISK_FULL);
+ return FALSE;
+}
+
+
+static BOOL MoveClustersBeforeThresholdInDir (HANDLE volumeHandle, const wstring &directory, int64 clusterThreshold)
+{
+ WIN32_FIND_DATAW findData;
+
+ HANDLE findHandle = FindFirstFileW (((directory.size() <= 3 ? L"" : L"\\\\?\\") + directory + L"\\*").c_str(), &findData);
+ if (findHandle == INVALID_HANDLE_VALUE)
+ return TRUE; // Error ignored
+
+ finally_do_arg (HANDLE, findHandle, { FindClose (finally_arg); });
+
+ // Find all files and directories
+ do
+ {
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ wstring subDir = findData.cFileName;
+
+ if (subDir == L"." || subDir == L"..")
+ continue;
+
+ if (!MoveClustersBeforeThresholdInDir (volumeHandle, directory + L"\\" + subDir, clusterThreshold))
+ return FALSE;
+ }
+
+ DWORD access = FILE_READ_ATTRIBUTES;
+
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED)
+ access = FILE_READ_DATA;
+
+ HANDLE fsObject = CreateFileW ((directory + L"\\" + findData.cFileName).c_str(), access, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (fsObject == INVALID_HANDLE_VALUE)
+ continue;
+
+ finally_do_arg (HANDLE, fsObject, { CloseHandle (finally_arg); });
+
+ STARTING_VCN_INPUT_BUFFER startVcn;
+ startVcn.StartingVcn.QuadPart = 0;
+ RETRIEVAL_POINTERS_BUFFER retPointers;
+ DWORD bytesReturned;
+
+ // Find clusters allocated beyond the threshold
+ while (DeviceIoControl (fsObject, FSCTL_GET_RETRIEVAL_POINTERS, &startVcn, sizeof (startVcn), &retPointers, sizeof (retPointers), &bytesReturned, NULL)
+ || GetLastError() == ERROR_MORE_DATA)
+ {
+ if (retPointers.ExtentCount == 0)
+ break;
+
+ if (retPointers.Extents[0].Lcn.QuadPart != -1)
+ {
+ int64 extentStartCluster = retPointers.Extents[0].Lcn.QuadPart;
+ int64 extentLen = retPointers.Extents[0].NextVcn.QuadPart - retPointers.StartingVcn.QuadPart;
+ int64 extentEndCluster = extentStartCluster + extentLen - 1;
+
+ if (extentEndCluster >= clusterThreshold)
+ {
+ // Move clusters before the threshold
+ for (int64 movedCluster = max (extentStartCluster, clusterThreshold); movedCluster <= extentEndCluster; ++movedCluster)
+ {
+ for (int retry = 0; ; ++retry)
+ {
+ MOVE_FILE_DATA moveData;
+
+ if (GetFreeClusterBeforeThreshold (volumeHandle, &moveData.StartingLcn.QuadPart, clusterThreshold))
+ {
+ moveData.FileHandle = fsObject;
+ moveData.StartingVcn.QuadPart = movedCluster - extentStartCluster + retPointers.StartingVcn.QuadPart;
+ moveData.ClusterCount = 1;
+
+ if (DeviceIoControl (volumeHandle, FSCTL_MOVE_FILE, &moveData, sizeof (moveData), NULL, 0, &bytesReturned, NULL))
+ break;
+ }
+
+ if (retry > 600)
+ return FALSE;
+
+ // There are possible race conditions as we work on a live filesystem
+ Sleep (100);
+ }
+ }
+ }
+ }
+
+ startVcn.StartingVcn = retPointers.Extents[0].NextVcn;
+ }
+
+ } while (FindNextFileW (findHandle, &findData));
+
+ return TRUE;
+}
+
+
+BOOL MoveClustersBeforeThreshold (HANDLE volumeHandle, PWSTR volumeDevicePath, int64 clusterThreshold)
+{
+ int drive = GetDiskDeviceDriveLetter (volumeDevicePath);
+ if (drive == -1)
+ {
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ wstring volumeRoot = L"X:";
+ volumeRoot[0] = L'A' + (wchar_t) drive;
+
+ return MoveClustersBeforeThresholdInDir (volumeHandle, volumeRoot, clusterThreshold);
+}
diff --git a/src/Format/InPlace.h b/src/Format/InPlace.h
index 63673d9d..ed24cb89 100644
--- a/src/Format/InPlace.h
+++ b/src/Format/InPlace.h
@@ -1,52 +1,52 @@
-/*
- Derived from source code of TrueCrypt 7.1a, which is
- Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
- by the TrueCrypt License 3.0.
-
- 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 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
- code distribution packages.
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "Format.h"
-
-enum nonsys_inplace_enc_status
-{
- NONSYS_INPLACE_ENC_STATUS_NONE = 0,
- NONSYS_INPLACE_ENC_STATUS_PREPARING,
- NONSYS_INPLACE_ENC_STATUS_RESIZING,
- NONSYS_INPLACE_ENC_STATUS_ENCRYPTING,
- NONSYS_INPLACE_ENC_STATUS_DECRYPTING,
- NONSYS_INPLACE_ENC_STATUS_FINALIZING,
- NONSYS_INPLACE_ENC_STATUS_PAUSED,
- NONSYS_INPLACE_ENC_STATUS_FINISHED,
- NONSYS_INPLACE_ENC_STATUS_ERROR
-};
-
-BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const wchar_t *devicePath, BOOL silent);
-BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const wchar_t *devicePath, BOOL silent);
-int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm);
-int EncryptPartitionInPlaceResume (HANDLE dev, volatile FORMAT_VOL_PARAMETERS *volParams, WipeAlgorithmId wipeAlgorithm, volatile BOOL *bTryToCorrectReadErrors);
-int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile BOOL *DiscardUnreadableEncryptedSectors);
-void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr);
-void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus);
-int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize);
-
-static HANDLE OpenPartitionVolume (HWND hwndDlg, const wchar_t *devName, BOOL bExclusiveRequired, BOOL bSharedRequired, BOOL bSharedRequiresConfirmation, BOOL bShowAlternativeSteps, BOOL bSilent);
-static int DismountFileSystem (HWND hwndDlg, HANDLE dev, int driveLetter, BOOL bForcedAllowed, BOOL bForcedRequiresConfirmation, BOOL bSilent);
-static int ConcealNTFS (HANDLE dev);
-BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId wipeAlgorithm, BOOL bDecrypting);
-static void ExportProgressStats (__int64 bytesDone, __int64 totalSize);
-int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount);
-static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize);
-BOOL MoveClustersBeforeThreshold (HANDLE volumeHandle, PWSTR volumeDevicePath, int64 clusterThreshold);
-
-#ifdef __cplusplus
-}
-#endif
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ 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 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
+ code distribution packages.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "Format.h"
+
+enum nonsys_inplace_enc_status
+{
+ NONSYS_INPLACE_ENC_STATUS_NONE = 0,
+ NONSYS_INPLACE_ENC_STATUS_PREPARING,
+ NONSYS_INPLACE_ENC_STATUS_RESIZING,
+ NONSYS_INPLACE_ENC_STATUS_ENCRYPTING,
+ NONSYS_INPLACE_ENC_STATUS_DECRYPTING,
+ NONSYS_INPLACE_ENC_STATUS_FINALIZING,
+ NONSYS_INPLACE_ENC_STATUS_PAUSED,
+ NONSYS_INPLACE_ENC_STATUS_FINISHED,
+ NONSYS_INPLACE_ENC_STATUS_ERROR
+};
+
+BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const wchar_t *devicePath, BOOL silent);
+BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const wchar_t *devicePath, BOOL silent);
+int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm);
+int EncryptPartitionInPlaceResume (HANDLE dev, volatile FORMAT_VOL_PARAMETERS *volParams, WipeAlgorithmId wipeAlgorithm, volatile BOOL *bTryToCorrectReadErrors);
+int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile BOOL *DiscardUnreadableEncryptedSectors);
+void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr);
+void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus);
+int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize);
+
+static HANDLE OpenPartitionVolume (HWND hwndDlg, const wchar_t *devName, BOOL bExclusiveRequired, BOOL bSharedRequired, BOOL bSharedRequiresConfirmation, BOOL bShowAlternativeSteps, BOOL bSilent);
+static int DismountFileSystem (HWND hwndDlg, HANDLE dev, int driveLetter, BOOL bForcedAllowed, BOOL bForcedRequiresConfirmation, BOOL bSilent);
+static int ConcealNTFS (HANDLE dev);
+BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId wipeAlgorithm, BOOL bDecrypting);
+static void ExportProgressStats (__int64 bytesDone, __int64 totalSize);
+int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount);
+static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize);
+BOOL MoveClustersBeforeThreshold (HANDLE volumeHandle, PWSTR volumeDevicePath, int64 clusterThreshold);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/Format/Resource.h b/src/Format/Resource.h
index 6f0fdb1b..1bdc2f5c 100644
--- a/src/Format/Resource.h
+++ b/src/Format/Resource.h
@@ -1,159 +1,159 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by Format.rc
-//
-#define IDR_FORMAT_TLB 1
-#define IDD_VOL_CREATION_WIZARD_DLG 101
-#define IDD_CIPHER_PAGE_DLG 102
-#define IDD_SIZE_PAGE_DLG 103
-#define IDD_PASSWORD_PAGE_DLG 104
-#define IDD_VOLUME_LOCATION_PAGE_DLG 105
-#define IDD_FORMAT_PAGE_DLG 106
-#define IDD_INTRO_PAGE_DLG 107
-#define IDD_INFO_PAGE_DLG 108
-#define IDD_HIDVOL_HOST_FILL_PAGE_DLG 109
-#define IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG 110
-#define IDD_PASSWORD_ENTRY_PAGE_DLG 111
-#define IDS_UACSTRING_FMT 112
-#define IDD_VOLUME_TYPE_PAGE_DLG 113
-#define IDR_FORMAT_RSRC_HEADER 114
-#define IDD_SYSENC_SPAN_PAGE_DLG 115
-#define IDB_WIZARD 116
-#define IDD_SYSENC_RESCUE_DISK_CREATION_DLG 117
-#define IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG 118
-#define IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG 119
-#define IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG 120
-#define IDD_SYSENC_WIPE_MODE_PAGE_DLG 121
-#define IDD_INPLACE_ENCRYPTION_PAGE_DLG 122
-#define IDD_SYSENC_KEYS_GEN_PAGE_DLG 123
-#define IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG 124
-#define IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG 125
-#define IDD_SYSENC_TYPE_PAGE_DLG 126
-#define IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG 127
-#define IDD_DEVICE_WIPE_PAGE_DLG 128
-#define IDD_DEVICE_WIPE_MODE_PAGE_DLG 129
-#define IDD_DEVICE_TRANSFORM_MODE_DLG 130
-#define IDD_EXPANDED_LIST_SELECT_PAGE_DLG 131
-#define IDD_DRIVE_LETTER_SELECTION_PAGE 132
-#define IDD_PIM_PAGE_DLG 133
-#define IDC_BOX_TITLE 1000
-#define IDC_RESCUE_DISK_ISO_PATH 1001
-#define IDC_COMBO_BOX 1002
-#define IDC_BOX_HELP 1003
-#define IDC_PASSWORD 1004
-#define IDC_BROWSE 1005
-#define IDC_BOX_HELP2 1006
-#define IDC_COMBO_BOX_HASH 1007
-#define IDC_COMBO_BOX_HASH_ALGO 1008
-#define IDC_SPACE_LEFT 1009
-#define IDC_VERIFY 1010
-#define IDC_KB 1011
-#define IDC_NO_HISTORY 1012
-#define IDC_MB 1013
-#define IDC_PROGRESS_BAR 1014
-#define IDC_GB 1015
-#define IDC_ABORT_BUTTON 1016
-#define IDC_HEADER_KEY 1017
-#define IDC_LIST_BOX 1018
-#define IDC_DISK_KEY 1019
-#define IDC_RANDOM_BYTES 1020
-#define IDC_CIPHER_TEST 1021
-#define IDC_BENCHMARK 1022
-#define IDC_QUICKFORMAT 1023
-#define IDC_BYTESWRITTEN 1024
-#define IDC_WRITESPEED 1025
-#define IDC_KEY_FILES 1026
-#define IDC_TIMEREMAIN 1027
-#define IDC_CLUSTERSIZE 1028
-#define IDC_FILESYS 1029
-#define IDC_SHOW_KEYS 1030
-#define IDC_STD_VOL 1031
-#define IDC_HIDDEN_VOL 1032
-#define IDC_HIDDEN_VOL_HELP 1033
-#define IDC_OPEN_OUTER_VOLUME 1034
-#define IDC_HIDVOL_WIZ_MODE_FULL 1035
-#define IDC_HIDVOL_WIZ_MODE_DIRECT 1036
-#define IDC_PASSWORD_DIRECT 1037
-#define IDC_SIZEBOX 1038
-#define IDC_SELECT_VOLUME_LOCATION 1039
-#define IDC_NEXT 1040
-#define IDC_PREV 1041
-#define IDT_ENCRYPTION_ALGO 1042
-#define IDT_HASH_ALGO 1043
-#define IDT_FORMAT_OPTIONS 1044
-#define IDT_FILESYSTEM 1045
-#define IDT_CLUSTER 1046
-#define IDT_RANDOM_POOL 1047
-#define IDT_HEADER_KEY 1048
-#define IDT_MASTER_KEY 1049
-#define IDT_DONE 1050
-#define IDT_SPEED 1051
-#define IDT_LEFT 1052
-#define IDT_CONFIRM 1053
-#define IDT_PASSWORD 1054
-#define IDC_SHOW_PASSWORD_SINGLE 1055
-#define IDC_SHOW_PASSWORD 1056
-#define IDC_LINK_MORE_INFO_ABOUT_CIPHER 1057
-#define IDC_LINK_HASH_INFO 1058
-#define IDC_POS_BOX 1059
-#define IDC_BITMAP_WIZARD 1060
-#define IDC_FILE_CONTAINER 1061
-#define IDC_NONSYS_DEVICE 1062
-#define IDC_SYS_DEVICE 1063
-#define IDT_FILE_CONTAINER 1064
-#define IDT_NON_SYS_DEVICE 1065
-#define IDT_SYS_DEVICE 1066
-#define IDC_WHOLE_SYS_DRIVE 1067
-#define IDC_SYS_PARTITION 1068
-#define IDT_WHOLE_SYS_DRIVE 1069
-#define IDT_SYS_PARTITION 1070
-#define IDT_RESCUE_DISK_INFO 1071
-#define IDC_MORE_INFO 1072
-#define IDC_MORE_INFO_ON_SYS_ENCRYPTION 1073
-#define IDT_COLLECTING_RANDOM_DATA_NOTE 1074
-#define IDC_MORE_INFO_ON_CONTAINERS 1075
-#define IDC_SINGLE_BOOT 1076
-#define IDC_MULTI_BOOT 1077
-#define IDT_MULTI_BOOT 1078
-#define IDT_SINGLE_BOOT 1079
-#define IDC_SYS_POOL_CONTENTS 1080
-#define IDT_PARTIAL_POOL_CONTENTS 1081
-#define IDC_DOWNLOAD_CD_BURN_SOFTWARE 1082
-#define IDT_RESCUE_DISK_BURN_INFO 1083
-#define IDT_WIPE_MODE_INFO 1084
-#define IDC_WIPE_MODE 1085
-#define IDC_SELECT 1086
-#define IDT_SYSENC_KEYS_GEN_INFO 1087
-#define IDC_DISPLAY_KEYS 1088
-#define IDC_PAUSE 1089
-#define IDT_WIPE_MODE 1090
-#define IDC_MORE_INFO_SYS_ENCRYPTION 1091
-#define IDC_BOX_HELP_NORMAL_VOL 1092
-#define IDT_STATUS 1093
-#define IDT_PROGRESS 1094
-#define IDT_SYSENC_DRIVE_ANALYSIS_INFO 1095
-#define IDC_SYSENC_NORMAL 1096
-#define IDC_SYSENC_HIDDEN 1097
-#define IDC_BOX_HELP_SYSENC_NORMAL 1098
-#define IDC_HIDDEN_SYSENC_INFO_LINK 1099
-#define IDT_PASS 1100
-#define IDC_DEVICE_TRANSFORM_MODE_FORMAT 1101
-#define IDC_DEVICE_TRANSFORM_MODE_INPLACE 1102
-#define IDC_DRIVE_LETTER_LIST 1103
-#define IDT_DRIVE_LETTER 1104
-#define IDC_LINK_PIM_INFO 1105
-#define IDC_SHOW_PIM 1106
-#define IDC_TB 1107
-#define IDC_SKIP_RESCUE_VERIFICATION 1108
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 134
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1109
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Format.rc
+//
+#define IDR_FORMAT_TLB 1
+#define IDD_VOL_CREATION_WIZARD_DLG 101
+#define IDD_CIPHER_PAGE_DLG 102
+#define IDD_SIZE_PAGE_DLG 103
+#define IDD_PASSWORD_PAGE_DLG 104
+#define IDD_VOLUME_LOCATION_PAGE_DLG 105
+#define IDD_FORMAT_PAGE_DLG 106
+#define IDD_INTRO_PAGE_DLG 107
+#define IDD_INFO_PAGE_DLG 108
+#define IDD_HIDVOL_HOST_FILL_PAGE_DLG 109
+#define IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG 110
+#define IDD_PASSWORD_ENTRY_PAGE_DLG 111
+#define IDS_UACSTRING_FMT 112
+#define IDD_VOLUME_TYPE_PAGE_DLG 113
+#define IDR_FORMAT_RSRC_HEADER 114
+#define IDD_SYSENC_SPAN_PAGE_DLG 115
+#define IDB_WIZARD 116
+#define IDD_SYSENC_RESCUE_DISK_CREATION_DLG 117
+#define IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG 118
+#define IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG 119
+#define IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG 120
+#define IDD_SYSENC_WIPE_MODE_PAGE_DLG 121
+#define IDD_INPLACE_ENCRYPTION_PAGE_DLG 122
+#define IDD_SYSENC_KEYS_GEN_PAGE_DLG 123
+#define IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG 124
+#define IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG 125
+#define IDD_SYSENC_TYPE_PAGE_DLG 126
+#define IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG 127
+#define IDD_DEVICE_WIPE_PAGE_DLG 128
+#define IDD_DEVICE_WIPE_MODE_PAGE_DLG 129
+#define IDD_DEVICE_TRANSFORM_MODE_DLG 130
+#define IDD_EXPANDED_LIST_SELECT_PAGE_DLG 131
+#define IDD_DRIVE_LETTER_SELECTION_PAGE 132
+#define IDD_PIM_PAGE_DLG 133
+#define IDC_BOX_TITLE 1000
+#define IDC_RESCUE_DISK_ISO_PATH 1001
+#define IDC_COMBO_BOX 1002
+#define IDC_BOX_HELP 1003
+#define IDC_PASSWORD 1004
+#define IDC_BROWSE 1005
+#define IDC_BOX_HELP2 1006
+#define IDC_COMBO_BOX_HASH 1007
+#define IDC_COMBO_BOX_HASH_ALGO 1008
+#define IDC_SPACE_LEFT 1009
+#define IDC_VERIFY 1010
+#define IDC_KB 1011
+#define IDC_NO_HISTORY 1012
+#define IDC_MB 1013
+#define IDC_PROGRESS_BAR 1014
+#define IDC_GB 1015
+#define IDC_ABORT_BUTTON 1016
+#define IDC_HEADER_KEY 1017
+#define IDC_LIST_BOX 1018
+#define IDC_DISK_KEY 1019
+#define IDC_RANDOM_BYTES 1020
+#define IDC_CIPHER_TEST 1021
+#define IDC_BENCHMARK 1022
+#define IDC_QUICKFORMAT 1023
+#define IDC_BYTESWRITTEN 1024
+#define IDC_WRITESPEED 1025
+#define IDC_KEY_FILES 1026
+#define IDC_TIMEREMAIN 1027
+#define IDC_CLUSTERSIZE 1028
+#define IDC_FILESYS 1029
+#define IDC_SHOW_KEYS 1030
+#define IDC_STD_VOL 1031
+#define IDC_HIDDEN_VOL 1032
+#define IDC_HIDDEN_VOL_HELP 1033
+#define IDC_OPEN_OUTER_VOLUME 1034
+#define IDC_HIDVOL_WIZ_MODE_FULL 1035
+#define IDC_HIDVOL_WIZ_MODE_DIRECT 1036
+#define IDC_PASSWORD_DIRECT 1037
+#define IDC_SIZEBOX 1038
+#define IDC_SELECT_VOLUME_LOCATION 1039
+#define IDC_NEXT 1040
+#define IDC_PREV 1041
+#define IDT_ENCRYPTION_ALGO 1042
+#define IDT_HASH_ALGO 1043
+#define IDT_FORMAT_OPTIONS 1044
+#define IDT_FILESYSTEM 1045
+#define IDT_CLUSTER 1046
+#define IDT_RANDOM_POOL 1047
+#define IDT_HEADER_KEY 1048
+#define IDT_MASTER_KEY 1049
+#define IDT_DONE 1050
+#define IDT_SPEED 1051
+#define IDT_LEFT 1052
+#define IDT_CONFIRM 1053
+#define IDT_PASSWORD 1054
+#define IDC_SHOW_PASSWORD_SINGLE 1055
+#define IDC_SHOW_PASSWORD 1056
+#define IDC_LINK_MORE_INFO_ABOUT_CIPHER 1057
+#define IDC_LINK_HASH_INFO 1058
+#define IDC_POS_BOX 1059
+#define IDC_BITMAP_WIZARD 1060
+#define IDC_FILE_CONTAINER 1061
+#define IDC_NONSYS_DEVICE 1062
+#define IDC_SYS_DEVICE 1063
+#define IDT_FILE_CONTAINER 1064
+#define IDT_NON_SYS_DEVICE 1065
+#define IDT_SYS_DEVICE 1066
+#define IDC_WHOLE_SYS_DRIVE 1067
+#define IDC_SYS_PARTITION 1068
+#define IDT_WHOLE_SYS_DRIVE 1069
+#define IDT_SYS_PARTITION 1070
+#define IDT_RESCUE_DISK_INFO 1071
+#define IDC_MORE_INFO 1072
+#define IDC_MORE_INFO_ON_SYS_ENCRYPTION 1073
+#define IDT_COLLECTING_RANDOM_DATA_NOTE 1074
+#define IDC_MORE_INFO_ON_CONTAINERS 1075
+#define IDC_SINGLE_BOOT 1076
+#define IDC_MULTI_BOOT 1077
+#define IDT_MULTI_BOOT 1078
+#define IDT_SINGLE_BOOT 1079
+#define IDC_SYS_POOL_CONTENTS 1080
+#define IDT_PARTIAL_POOL_CONTENTS 1081
+#define IDC_DOWNLOAD_CD_BURN_SOFTWARE 1082
+#define IDT_RESCUE_DISK_BURN_INFO 1083
+#define IDT_WIPE_MODE_INFO 1084
+#define IDC_WIPE_MODE 1085
+#define IDC_SELECT 1086
+#define IDT_SYSENC_KEYS_GEN_INFO 1087
+#define IDC_DISPLAY_KEYS 1088
+#define IDC_PAUSE 1089
+#define IDT_WIPE_MODE 1090
+#define IDC_MORE_INFO_SYS_ENCRYPTION 1091
+#define IDC_BOX_HELP_NORMAL_VOL 1092
+#define IDT_STATUS 1093
+#define IDT_PROGRESS 1094
+#define IDT_SYSENC_DRIVE_ANALYSIS_INFO 1095
+#define IDC_SYSENC_NORMAL 1096
+#define IDC_SYSENC_HIDDEN 1097
+#define IDC_BOX_HELP_SYSENC_NORMAL 1098
+#define IDC_HIDDEN_SYSENC_INFO_LINK 1099
+#define IDT_PASS 1100
+#define IDC_DEVICE_TRANSFORM_MODE_FORMAT 1101
+#define IDC_DEVICE_TRANSFORM_MODE_INPLACE 1102
+#define IDC_DRIVE_LETTER_LIST 1103
+#define IDT_DRIVE_LETTER 1104
+#define IDC_LINK_PIM_INFO 1105
+#define IDC_SHOW_PIM 1106
+#define IDC_TB 1107
+#define IDC_SKIP_RESCUE_VERIFICATION 1108
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 134
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1109
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index a4372533..40c17d66 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -1,10233 +1,10233 @@
-/*
- Legal Notice: Some portions of the source code contained in this file were
- derived from the source code of TrueCrypt 7.1a, 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
- 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'
- 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 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
- code distribution packages. */
-
-#include "Tcdefs.h"
-
-#include <stdlib.h>
-#include <limits.h>
-#include <time.h>
-#include <errno.h>
-#include <io.h>
-#include <sys/stat.h>
-#include <shlobj.h>
-
-#include "Crypto.h"
-#include "cpu.h"
-#include "Apidrvr.h"
-#include "Dlgcode.h"
-#include "Language.h"
-#include "Combo.h"
-#include "Registry.h"
-#include "Boot/Windows/BootDefs.h"
-#include "Common/Common.h"
-#include "Common/BootEncryption.h"
-#include "Common/Dictionary.h"
-#include "Common/Endian.h"
-#include "Common/resource.h"
-#include "Common/Pkcs5.h"
-#include "Platform/Finally.h"
-#include "Platform/ForEach.h"
-#include "Random.h"
-#include "Fat.h"
-#include "InPlace.h"
-#include "Resource.h"
-#include "TcFormat.h"
-#include "Format.h"
-#include "FormatCom.h"
-#include "Password.h"
-#include "Progress.h"
-#include "Tests.h"
-#include "Cmdline.h"
-#include "Volumes.h"
-#include "Wipe.h"
-#include "Xml.h"
-
-#include <Strsafe.h>
-
-using namespace VeraCrypt;
-
-enum wizard_pages
-{
- /* IMPORTANT: IF YOU ADD/REMOVE/MOVE ANY PAGES THAT ARE RELATED TO SYSTEM ENCRYPTION,
- REVISE THE 'DECOY_OS_INSTRUCTIONS_PORTION_??' STRINGS! */
-
- INTRO_PAGE,
- SYSENC_TYPE_PAGE,
- SYSENC_HIDDEN_OS_REQ_CHECK_PAGE,
- SYSENC_SPAN_PAGE,
- SYSENC_PRE_DRIVE_ANALYSIS_PAGE,
- SYSENC_DRIVE_ANALYSIS_PAGE,
- SYSENC_MULTI_BOOT_MODE_PAGE,
- SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE,
- SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_PAGE,
- SYSENC_MULTI_BOOT_ADJACENT_SYS_PAGE,
- SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE,
- SYSENC_MULTI_BOOT_OUTCOME_PAGE,
- VOLUME_TYPE_PAGE,
- HIDDEN_VOL_WIZARD_MODE_PAGE,
- VOLUME_LOCATION_PAGE,
- DEVICE_TRANSFORM_MODE_PAGE,
- HIDDEN_VOL_HOST_PRE_CIPHER_PAGE,
- HIDDEN_VOL_PRE_CIPHER_PAGE,
- CIPHER_PAGE,
- SIZE_PAGE,
- HIDDEN_VOL_HOST_PASSWORD_PAGE,
- PASSWORD_PAGE,
- PIM_PAGE,
- FILESYS_PAGE,
- SYSENC_COLLECTING_RANDOM_DATA_PAGE,
- SYSENC_KEYS_GEN_PAGE,
- SYSENC_RESCUE_DISK_CREATION_PAGE,
- SYSENC_RESCUE_DISK_BURN_PAGE,
- SYSENC_RESCUE_DISK_VERIFIED_PAGE,
- SYSENC_WIPE_MODE_PAGE,
- SYSENC_PRETEST_INFO_PAGE,
- SYSENC_PRETEST_RESULT_PAGE,
- SYSENC_ENCRYPTION_PAGE,
- NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE,
- NONSYS_INPLACE_ENC_RESUME_PARTITION_SEL_PAGE,
- NONSYS_INPLACE_ENC_RAND_DATA_PAGE,
- NONSYS_INPLACE_ENC_WIPE_MODE_PAGE,
- NONSYS_INPLACE_ENC_TRANSFORM_PAGE,
- NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE,
- NONSYS_INPLACE_DEC_TRANSFORM_FINISHED_DRIVE_LETTER_PAGE,
- FORMAT_PAGE,
- FORMAT_FINISHED_PAGE,
- SYSENC_HIDDEN_OS_INITIAL_INFO_PAGE,
- SYSENC_HIDDEN_OS_WIPE_INFO_PAGE,
- DEVICE_WIPE_MODE_PAGE,
- DEVICE_WIPE_PAGE
-};
-
-#define TIMER_INTERVAL_RANDVIEW 30
-#define TIMER_INTERVAL_SYSENC_PROGRESS 30
-#define TIMER_INTERVAL_NONSYS_INPLACE_ENC_PROGRESS 30
-#define TIMER_INTERVAL_SYSENC_DRIVE_ANALYSIS_PROGRESS 100
-#define TIMER_INTERVAL_WIPE_PROGRESS 30
-#define TIMER_INTERVAL_KEYB_LAYOUT_GUARD 10
-
-enum sys_encryption_cmd_line_switches
-{
- SYSENC_COMMAND_NONE = 0,
- SYSENC_COMMAND_RESUME,
- SYSENC_COMMAND_STARTUP_SEQ_RESUME,
- SYSENC_COMMAND_ENCRYPT,
- SYSENC_COMMAND_DECRYPT,
- SYSENC_COMMAND_CREATE_HIDDEN_OS,
- SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV
-};
-
-typedef struct
-{
- int NumberOfSysDrives; // Number of drives that contain an operating system. -1: unknown, 1: one, 2: two or more
- int MultipleSystemsOnDrive; // Multiple systems are installed on the drive where the currently running system resides. -1: unknown, 0: no, 1: yes
- int BootLoaderLocation; // Boot loader (boot manager) installed in: 1: MBR/1st cylinder, 0: partition/bootsector: -1: unknown
- int BootLoaderBrand; // -1: unknown, 0: Microsoft Windows, 1: any non-Windows boot manager/loader
- int SystemOnBootDrive; // If the currently running operating system is installed on the boot drive. -1: unknown, 0: no, 1: yes
-} SYSENC_MULTIBOOT_CFG;
-
-#define SYSENC_PAUSE_RETRY_INTERVAL 100
-#define SYSENC_PAUSE_RETRIES 200
-
-// Expected duration of system drive analysis, in ms
-#define SYSENC_DRIVE_ANALYSIS_ETA (4*60000)
-
-BootEncryption *BootEncObj = NULL;
-BootEncryptionStatus BootEncStatus;
-
-HWND hCurPage = NULL; /* Handle to current wizard page */
-int nCurPageNo = -1; /* The current wizard page */
-int nLastPageNo = -1;
-volatile int WizardMode = DEFAULT_VOL_CREATION_WIZARD_MODE; /* IMPORTANT: Never change this value directly -- always use ChangeWizardMode() instead. */
-volatile BOOL bHiddenOS = FALSE; /* If TRUE, we are performing or (or supposed to perform) actions relating to an operating system installed in a hidden volume (i.e., encrypting a decoy OS partition or creating the outer/hidden volume for the hidden OS). To determine or set the phase of the process, call ChangeHiddenOSCreationPhase() and DetermineHiddenOSCreationPhase()) */
-BOOL bDirectSysEncMode = FALSE;
-BOOL bDirectSysEncModeCommand = SYSENC_COMMAND_NONE;
-BOOL DirectDeviceEncMode = FALSE;
-BOOL DirectNonSysInplaceDecStartMode = FALSE;
-BOOL DirectNonSysInplaceEncResumeMode = FALSE;
-BOOL DirectNonSysInplaceDecResumeMode = FALSE;
-BOOL DirectPromptNonSysInplaceEncResumeMode = FALSE;
-BOOL DirectCreationMode = FALSE;
-
-volatile BOOL bInPlaceEncNonSys = FALSE; /* If TRUE, existing data on a non-system partition/volume are to be encrypted (or decrypted if bInPlaceDecNonSys is TRUE) in place (for system encryption, this flag is ignored) */
-volatile BOOL bInPlaceDecNonSys = FALSE; /* If TRUE, existing data on a non-system partition/volume are to be decrypted in place (for system encryption, this flag is ignored) */
-volatile BOOL bInPlaceEncNonSysResumed = FALSE; /* If TRUE, the wizard is supposed to resume (or has resumed) process of non-system in-place encryption/decryption. */
-volatile BOOL bFirstNonSysInPlaceEncResumeDone = FALSE;
-__int64 NonSysInplaceEncBytesDone = 0;
-__int64 NonSysInplaceEncTotalSize = 0;
-BOOL bDeviceTransformModeChoiceMade = FALSE; /* TRUE if the user has at least once manually selected the 'in-place' or 'format' option (on the 'device transform mode' page). */
-int nNeedToStoreFilesOver4GB = 0; /* Whether the user wants to be able to store files larger than 4GB on the volume: -1 = Undecided or error, 0 = No, 1 = Yes */
-int nVolumeEA = 1; /* Default encryption algorithm */
-BOOL bSystemEncryptionInProgress = FALSE; /* TRUE when encrypting/decrypting the system partition/drive (FALSE when paused). */
-BOOL bWholeSysDrive = FALSE; /* Whether to encrypt the entire system drive or just the system partition. */
-static BOOL bSystemEncryptionStatusChanged = FALSE; /* TRUE if this instance changed the value of SystemEncryptionStatus (it's set to FALSE each time the system encryption settings are saved to the config file). This value is to be treated as protected -- only the wizard can change this value (others may only read it). */
-volatile BOOL bSysEncDriveAnalysisInProgress = FALSE;
-volatile BOOL bSysEncDriveAnalysisTimeOutOccurred = FALSE;
-int SysEncDetectHiddenSectors = -1; /* Whether the user wants us to detect and encrypt the Host Protect Area (if any): -1 = Undecided or error, 0 = No, 1 = Yes */
-int SysEncDriveAnalysisStart;
-BOOL bDontVerifyRescueDisk = FALSE;
-BOOL bFirstSysEncResumeDone = FALSE;
-int nMultiBoot = 0; /* The number of operating systems installed on the computer, according to the user. 0: undetermined, 1: one, 2: two or more */
-volatile BOOL bHiddenVol = FALSE; /* If true, we are (or will be) creating a hidden volume. */
-volatile BOOL bHiddenVolHost = FALSE; /* If true, we are (or will be) creating the host volume (called "outer") for a hidden volume. */
-volatile BOOL bHiddenVolDirect = FALSE; /* If true, the wizard omits creating a host volume in the course of the process of hidden volume creation. */
-volatile BOOL bHiddenVolFinished = FALSE;
-int hiddenVolHostDriveNo = -1; /* Drive letter for the volume intended to host a hidden volume. */
-BOOL bRemovableHostDevice = FALSE; /* TRUE when creating a device/partition-hosted volume on a removable device. State undefined when creating file-hosted volumes. */
-int realClusterSize; /* Parameter used when determining the maximum possible size of a hidden volume. */
-int hash_algo = DEFAULT_HASH_ALGORITHM; /* Which PRF to use in header key derivation (PKCS #5) and in the RNG. */
-unsigned __int64 nUIVolumeSize = 0; /* The volume size. Important: This value is not in bytes. It has to be multiplied by nMultiplier. Do not use this value when actually creating the volume (it may chop off sector size, if it is not a multiple of 1024 bytes). */
-unsigned __int64 nVolumeSize = 0; /* The volume size, in bytes. */
-unsigned __int64 nHiddenVolHostSize = 0; /* Size of the hidden volume host, in bytes */
-__int64 nMaximumHiddenVolSize = 0; /* Maximum possible size of the hidden volume, in bytes */
-__int64 nbrFreeClusters = 0;
-__int64 nMultiplier = BYTES_PER_MB; /* Size selection multiplier. */
-wchar_t szFileName[TC_MAX_PATH+1]; /* The file selected by the user */
-wchar_t szDiskFile[TC_MAX_PATH+1]; /* Fully qualified name derived from szFileName */
-wchar_t szRescueDiskISO[TC_MAX_PATH+1]; /* The filename and path to the Rescue Disk ISO file to be burned (for boot encryption) */
-BOOL bDeviceWipeInProgress = FALSE;
-volatile BOOL bTryToCorrectReadErrors = FALSE;
-volatile BOOL DiscardUnreadableEncryptedSectors = FALSE;
-
-volatile BOOL bVolTransformThreadCancel = FALSE; /* TRUE if the user cancels/pauses volume encryption/format */
-volatile BOOL bVolTransformThreadRunning = FALSE; /* Is the volume encryption/format thread running */
-volatile BOOL bVolTransformThreadToRun = FALSE; /* TRUE if the Format/Encrypt button has been clicked and we are proceeding towards launching the thread. */
-
-volatile BOOL bConfirmQuit = FALSE; /* If TRUE, the user is asked to confirm exit when he clicks the X icon, Exit, etc. */
-volatile BOOL bConfirmQuitSysEncPretest = FALSE;
-
-BOOL bDevice = FALSE; /* Is this a partition volume ? */
-
-BOOL showKeys = FALSE;
-volatile HWND hMasterKey = NULL; /* Text box showing hex dump of the master key */
-volatile HWND hHeaderKey = NULL; /* Text box showing hex dump of the header key */
-volatile HWND hRandPool = NULL; /* Text box showing hex dump of the random pool */
-volatile HWND hRandPoolSys = NULL; /* Text box showing hex dump of the random pool for system encryption */
-volatile HWND hPasswordInputField = NULL; /* Password input field */
-volatile HWND hVerifyPasswordInputField = NULL; /* Verify-password input field */
-
-HBITMAP hbmWizardBitmapRescaled = NULL;
-
-wchar_t OrigKeyboardLayout [8+1] = L"00000409";
-BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */
-BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */
-
-#ifndef _DEBUG
- BOOL bWarnDeviceFormatAdvanced = TRUE;
-#else
- BOOL bWarnDeviceFormatAdvanced = FALSE;
-#endif
-
-BOOL bWarnOuterVolSuitableFileSys = TRUE;
-
-Password volumePassword; /* User password */
-char szVerify[MAX_PASSWORD + 1]; /* Tmp password buffer */
-char szRawPassword[MAX_PASSWORD + 1]; /* Password before keyfile was applied to it */
-
-int volumePim = 0;
-
-BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
-BOOL ComServerMode = FALSE;
-
-
-Password CmdVolumePassword = {0}; /* Password passed from command line */
-int CmdVolumeEA = 0;
-int CmdVolumePkcs5 = 0;
-int CmdVolumePim = 0;
-int CmdVolumeFilesystem = FILESYS_NONE;
-unsigned __int64 CmdVolumeFileSize = 0;
-BOOL CmdSparseFileSwitch = FALSE;
-
-BOOL bForceOperation = FALSE;
-
-BOOL bOperationSuccess = FALSE;
-
-BOOL bGuiMode = TRUE;
-
-int nPbar = 0; /* Control ID of progress bar:- for format code */
-
-wchar_t HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
-wchar_t MasterKeyGUIView [KEY_GUI_VIEW_SIZE];
-
-#define RANDPOOL_DISPLAY_COLUMNS 15
-#define RANDPOOL_DISPLAY_ROWS 8
-#define RANDPOOL_DISPLAY_BYTE_PORTION (RANDPOOL_DISPLAY_COLUMNS * RANDPOOL_DISPLAY_ROWS)
-#define RANDPOOL_DISPLAY_SIZE (RANDPOOL_DISPLAY_BYTE_PORTION * 3 + RANDPOOL_DISPLAY_ROWS + 2)
-unsigned char randPool [RANDPOOL_DISPLAY_BYTE_PORTION];
-unsigned char lastRandPool [RANDPOOL_DISPLAY_BYTE_PORTION];
-static unsigned char maskRandPool [RANDPOOL_DISPLAY_BYTE_PORTION];
-static BOOL bUseMask = FALSE;
-static DWORD mouseEntropyGathered = 0xFFFFFFFF;
-static DWORD mouseEventsInitialCount = 0;
-/* max value of entropy needed to fill all random pool = 8 * RNG_POOL_SIZE = 2560 bits */
-static const DWORD maxEntropyLevel = RNG_POOL_SIZE * 8;
-static HWND hEntropyBar = NULL;
-wchar_t outRandPoolDispBuffer [RANDPOOL_DISPLAY_SIZE];
-BOOL bDisplayPoolContents = TRUE;
-
-volatile BOOL bSparseFileSwitch = FALSE;
-volatile BOOL quickFormat = FALSE; /* WARNING: Meaning of this variable depends on bSparseFileSwitch. If bSparseFileSwitch is TRUE, this variable represents the sparse file flag. */
-volatile int fileSystem = FILESYS_NONE;
-volatile int clusterSize = 0;
-
-SYSENC_MULTIBOOT_CFG SysEncMultiBootCfg;
-wchar_t SysEncMultiBootCfgOutcome [4096] = {L'N',L'/',L'A',0};
-volatile int NonSysInplaceEncStatus = NONSYS_INPLACE_ENC_STATUS_NONE;
-
-vector <HostDevice> DeferredNonSysInPlaceEncDevices;
-
-// specific definitions and implementation for support of resume operation
-// in wait dialog mechanism
-
-void CALLBACK ResumeInPlaceEncWaitThreadProc(void* pArg, HWND hwndDlg)
-{
- wchar_t szDevicePath[MAX_PATH] = {0};
- RawDevicesDlgParam param;
- param.devices = GetAvailableHostDevices (false, true, false);
- param.pszFileName = szDevicePath;
-
- DeferredNonSysInPlaceEncDevices.clear();
-
- if ((IDOK == DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
- (DLGPROC) RawDevicesDlgProc, (LPARAM) &param)) && wcslen(szDevicePath))
- {
- foreach (const HostDevice &device, param.devices)
- {
- if (device.Path == szDevicePath)
- {
- OpenVolumeContext volume;
- int status = OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE);
-
- if ( status == ERR_SUCCESS)
- {
- if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
- && volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value)
- {
- DeferredNonSysInPlaceEncDevices.push_back (device);
- }
- else if (volume.CryptoInfo->EncryptedAreaLength.Value == volume.CryptoInfo->VolumeSize.Value)
- {
- WCHAR szMsg[1024];
- StringCbPrintfW(szMsg, sizeof(szMsg), GetString ("SELECTED_PARTITION_ALREADY_INPLACE_ENC"),
- volume.CryptoInfo->HeaderFlags);
- ErrorDirect(szMsg, hwndDlg);
- }
- else
- {
- WCHAR szMsg[1024];
- StringCbPrintfW(szMsg, sizeof(szMsg), GetString ("SELECTED_PARTITION_NOT_INPLACE_ENC"),
- volume.CryptoInfo->HeaderFlags);
- ErrorDirect(szMsg, hwndDlg);
- }
-
- CloseVolume (&volume);
- }
- else
- {
- handleError(hwndDlg, status, SRC_POS);
- }
-
- break;
- }
- }
- }
- else
- {
- foreach (const HostDevice &device, param.devices)
- {
- if ( !device.ContainsSystem
- && (device.IsPartition || device.DynamicVolume || device.IsVirtualPartition || device.Partitions.empty())
- )
- {
-
- OpenVolumeContext volume;
-
- if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE) == ERR_SUCCESS)
- {
- if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
- && volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value)
- {
- DeferredNonSysInPlaceEncDevices.push_back (device);
- }
-
- CloseVolume (&volume);
- }
- }
- }
- }
-}
-
-
-static BOOL ElevateWholeWizardProcess (wstring arguments)
-{
- wchar_t modPath[MAX_PATH];
-
- if (IsAdmin())
- return TRUE;
-
- if (!IsUacSupported())
- return IsAdmin();
-
- GetModuleFileName (NULL, modPath, ARRAYSIZE (modPath));
-
- while (true)
- {
- if ((int)ShellExecute (MainDlg, L"runas", modPath, (wstring(L"/q UAC ") + arguments).c_str(), NULL, SW_SHOWNORMAL) > 32)
- {
- exit (0);
- }
- else
- {
- if (IDRETRY == ErrorRetryCancel ("UAC_INIT_ERROR", MainDlg))
- continue;
- return FALSE;
- }
- }
-}
-
-static void WipePasswordsAndKeyfiles (void)
-{
- wchar_t tmp[MAX_PASSWORD+1];
-
- // Attempt to wipe passwords stored in the input field buffers
- wmemset (tmp, L'X', MAX_PASSWORD);
- tmp [MAX_PASSWORD] = 0;
- SetWindowText (hPasswordInputField, tmp);
- SetWindowText (hVerifyPasswordInputField, tmp);
-
- burn (&szVerify[0], sizeof (szVerify));
- burn (&volumePassword, sizeof (volumePassword));
- burn (&szRawPassword[0], sizeof (szRawPassword));
- burn (&volumePim, sizeof (volumePim));
- burn (&CmdVolumePassword, sizeof (CmdVolumePassword));
- burn (&CmdVolumePim, sizeof (CmdVolumePim));
-
- SetWindowText (hPasswordInputField, L"");
- SetWindowText (hVerifyPasswordInputField, L"");
-
- KeyFileRemoveAll (&FirstKeyFile);
- KeyFileRemoveAll (&defaultKeyFilesParam.FirstKeyFile);
-}
-
-static void localcleanup (void)
-{
- wchar_t tmp[RANDPOOL_DISPLAY_SIZE+1];
-
- // System encryption
-
- if (WizardMode == WIZARD_MODE_SYS_DEVICE
- && InstanceHasSysEncMutex ())
- {
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
-
- if (BootEncStatus.SetupInProgress)
- {
- BootEncObj->AbortSetup ();
- }
- }
- catch (...)
- {
- // NOP
- }
- }
-
- // Mon-system in-place encryption
-
- if (bInPlaceEncNonSys && (bVolTransformThreadRunning || bVolTransformThreadToRun))
- {
- NonSysInplaceEncPause ();
- }
-
- CloseNonSysInplaceEncMutex ();
-
-
- // Device wipe
-
- if (bDeviceWipeInProgress)
- WipeAbort();
-
-
- WipePasswordsAndKeyfiles ();
-
- RandStop (TRUE);
-
- burn (HeaderKeyGUIView, sizeof(HeaderKeyGUIView));
- burn (MasterKeyGUIView, sizeof(MasterKeyGUIView));
- burn (randPool, sizeof(randPool));
- burn (lastRandPool, sizeof(lastRandPool));
- burn (outRandPoolDispBuffer, sizeof(outRandPoolDispBuffer));
- burn (&mouseEntropyGathered, sizeof(mouseEntropyGathered));
- burn (&mouseEventsInitialCount, sizeof(mouseEventsInitialCount));
- burn (maskRandPool, sizeof(maskRandPool));
- burn (szFileName, sizeof(szFileName));
- burn (szDiskFile, sizeof(szDiskFile));
-
- // Attempt to wipe the GUI fields showing portions of randpool, of the master and header keys
- wmemset (tmp, L'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hRandPool, tmp);
- SetWindowText (hRandPoolSys, tmp);
- SetWindowText (hMasterKey, tmp);
- SetWindowText (hHeaderKey, tmp);
-
- UnregisterRedTick (hInst);
-
- // Delete buffered bitmaps (if any)
- if (hbmWizardBitmapRescaled != NULL)
- {
- DeleteObject ((HGDIOBJ) hbmWizardBitmapRescaled);
- hbmWizardBitmapRescaled = NULL;
- }
-
- // Cleanup common code resources
- cleanup ();
-
- if (BootEncObj != NULL)
- {
- delete BootEncObj;
- BootEncObj = NULL;
- }
-}
-
-static BOOL CALLBACK BroadcastSysEncCfgUpdateCallb (HWND hwnd, LPARAM lParam)
-{
- LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA);
- if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs
- {
- wchar_t name[1024] = { 0 };
- GetWindowText (hwnd, name, ARRAYSIZE (name) - 1);
- if (hwnd != MainDlg && wcsstr (name, L"VeraCrypt"))
- {
- PostMessage (hwnd, TC_APPMSG_SYSENC_CONFIG_UPDATE, 0, 0);
- }
- }
- return TRUE;
-}
-
-static BOOL BroadcastSysEncCfgUpdate (void)
-{
- BOOL bSuccess = FALSE;
- EnumWindows (BroadcastSysEncCfgUpdateCallb, (LPARAM) &bSuccess);
- return bSuccess;
-}
-
-// IMPORTANT: This function may be called only by Format (other modules can only _read_ the system encryption config).
-// Returns TRUE if successful (otherwise FALSE)
-static BOOL SaveSysEncSettings (HWND hwndDlg)
-{
- FILE *f;
-
- if (!bSystemEncryptionStatusChanged)
- return TRUE;
-
- if (hwndDlg == NULL && MainDlg != NULL)
- hwndDlg = MainDlg;
-
- if (!CreateSysEncMutex ())
- return FALSE; // Only one instance that has the mutex can modify the system encryption settings
-
- if (SystemEncryptionStatus == SYSENC_STATUS_NONE)
- {
- if (_wremove (GetConfigPath (TC_APPD_FILENAME_SYSTEM_ENCRYPTION)) != 0)
- {
- Error ("CANNOT_SAVE_SYS_ENCRYPTION_SETTINGS", hwndDlg);
- return FALSE;
- }
-
- bSystemEncryptionStatusChanged = FALSE;
- BroadcastSysEncCfgUpdate ();
- return TRUE;
- }
-
- f = _wfopen (GetConfigPath (TC_APPD_FILENAME_SYSTEM_ENCRYPTION), L"w,ccs=UTF-8");
- if (f == NULL)
- {
- Error ("CANNOT_SAVE_SYS_ENCRYPTION_SETTINGS", hwndDlg);
- handleWin32Error (hwndDlg, SRC_POS);
- return FALSE;
- }
-
- if (XmlWriteHeader (f) < 0
-
- || fputws (L"\n\t<sysencryption>", f) < 0
-
- || fwprintf (f, L"\n\t\t<config key=\"SystemEncryptionStatus\">%d</config>", SystemEncryptionStatus) < 0
-
- || fwprintf (f, L"\n\t\t<config key=\"WipeMode\">%d</config>", (int) nWipeMode) < 0
-
- || fputws (L"\n\t</sysencryption>", f) < 0
-
- || XmlWriteFooter (f) < 0)
- {
- handleWin32Error (hwndDlg, SRC_POS);
- fclose (f);
- Error ("CANNOT_SAVE_SYS_ENCRYPTION_SETTINGS", hwndDlg);
- return FALSE;
- }
-
- TCFlushFile (f);
-
- fclose (f);
-
- bSystemEncryptionStatusChanged = FALSE;
- BroadcastSysEncCfgUpdate ();
-
- return TRUE;
-}
-
-// WARNING: This function may take a long time to finish
-static unsigned int DetermineHiddenOSCreationPhase (void)
-{
- unsigned int phase = TC_HIDDEN_OS_CREATION_PHASE_NONE;
-
- try
- {
- phase = BootEncObj->GetHiddenOSCreationPhase();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- AbortProcess("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS");
- }
-
- return phase;
-}
-
-// IMPORTANT: This function may be called only by Format (other modules can only _read_ the status).
-// Returns TRUE if successful (otherwise FALSE)
-static BOOL ChangeHiddenOSCreationPhase (int newPhase)
-{
- if (!CreateSysEncMutex ())
- {
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
- return FALSE;
- }
-
- try
- {
- BootEncObj->SetHiddenOSCreationPhase (newPhase);
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
-
- //// The contents of the following items might be inappropriate after a change of the phase
- //szFileName[0] = 0;
- //szDiskFile[0] = 0;
- //nUIVolumeSize = 0;
- //nVolumeSize = 0;
-
- return TRUE;
-}
-
-// IMPORTANT: This function may be called only by Format (other modules can only _read_ the system encryption status).
-// Returns TRUE if successful (otherwise FALSE)
-static BOOL ChangeSystemEncryptionStatus (int newStatus)
-{
- if (!CreateSysEncMutex ())
- {
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
- return FALSE; // Only one instance that has the mutex can modify the system encryption settings
- }
-
- SystemEncryptionStatus = newStatus;
- bSystemEncryptionStatusChanged = TRUE;
-
- if (newStatus == SYSENC_STATUS_ENCRYPTING)
- {
- // If the user has created a hidden OS and now is creating a decoy OS, we must wipe the hidden OS
- // config area in the MBR.
- WipeHiddenOSCreationConfig();
- }
-
- if (newStatus == SYSENC_STATUS_NONE && !IsHiddenOSRunning())
- {
- if (DetermineHiddenOSCreationPhase() != TC_HIDDEN_OS_CREATION_PHASE_NONE
- && !ChangeHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_NONE))
- return FALSE;
-
- WipeHiddenOSCreationConfig();
- }
-
- if (!SaveSysEncSettings (MainDlg))
- {
- return FALSE;
- }
-
- return TRUE;
-}
-
-// If the return code of this function is ignored and newWizardMode == WIZARD_MODE_SYS_DEVICE, then this function
-// may be called only after CreateSysEncMutex() returns TRUE. It returns TRUE if successful (otherwise FALSE).
-static BOOL ChangeWizardMode (int newWizardMode)
-{
- if (WizardMode != newWizardMode)
- {
- if (WizardMode == WIZARD_MODE_SYS_DEVICE || newWizardMode == WIZARD_MODE_SYS_DEVICE)
- {
- if (newWizardMode == WIZARD_MODE_SYS_DEVICE)
- {
- if (!CreateSysEncMutex ())
- {
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
- return FALSE;
- }
- }
-
- // If the previous mode was different, the password may have been typed using a different
- // keyboard layout (which might confuse the user and cause other problems if system encryption
- // was or will be involved).
- WipePasswordsAndKeyfiles();
- }
-
- if (newWizardMode != WIZARD_MODE_NONSYS_DEVICE)
- {
- bInPlaceEncNonSys = FALSE;
- bInPlaceDecNonSys = FALSE;
- }
-
- if (newWizardMode == WIZARD_MODE_NONSYS_DEVICE && !IsAdmin() && IsUacSupported())
- {
- if (!ElevateWholeWizardProcess (L"/e"))
- return FALSE;
- }
-
- // The contents of the following items may be inappropriate after a change of mode
- if (! (bInPlaceDecNonSys && !bInPlaceEncNonSysResumed)) // If we are starting (but not resuming) decryption of non-system volume, we actually need szFileName as it contains the command line param.
- szFileName[0] = 0;
- szDiskFile[0] = 0;
- nUIVolumeSize = 0;
- nVolumeSize = 0;
-
- WizardMode = newWizardMode;
- }
-
- bDevice = (WizardMode != WIZARD_MODE_FILE_CONTAINER);
-
- if (newWizardMode != WIZARD_MODE_SYS_DEVICE
- && !bHiddenOS)
- {
- CloseSysEncMutex ();
- }
-
- return TRUE;
-}
-
-// Determines whether the wizard directly affects system encryption in any way.
-// Note, for example, that when the user enters a password for a hidden volume that is to host a hidden OS,
-// WizardMode is NOT set to WIZARD_MODE_SYS_DEVICE. The keyboard layout, however, has to be US. That's why
-// this function has to be called instead of checking the value of WizardMode.
-static BOOL SysEncInEffect (void)
-{
- return (WizardMode == WIZARD_MODE_SYS_DEVICE
- || CreatingHiddenSysVol());
-}
-
-static BOOL CreatingHiddenSysVol (void)
-{
- return (bHiddenOS
- && bHiddenVol && !bHiddenVolHost);
-}
-
-static void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* pbSettingsModified, BOOL* pbHistoryModified)
-{
- if (!bOnlyCheckModified)
- EnableHwEncryption ((ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? FALSE : TRUE);
-
- WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
-
- if (!bOnlyCheckModified)
- LoadSysEncSettings ();
-
- if (!bOnlyCheckModified && LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
- bInPlaceEncNonSysPending = TRUE;
-
- if (!bOnlyCheckModified)
- defaultKeyFilesParam.EnableKeyFiles = FALSE;
-
- ConfigReadCompareInt ("StartOnLogon", FALSE, &bStartOnLogon, bOnlyCheckModified, pbSettingsModified);
-
- ConfigReadCompareInt ("HiddenSectorDetectionStatus", 0, &HiddenSectorDetectionStatus, bOnlyCheckModified, pbSettingsModified);
-
- ConfigReadCompareInt ("ShowDisconnectedNetworkDrives", FALSE, &bShowDisconnectedNetworkDrives, bOnlyCheckModified, pbSettingsModified);
-
- ConfigReadCompareInt ("HideWaitingDialog", FALSE, &bHideWaitingDialog, bOnlyCheckModified, pbSettingsModified);
-
- ConfigReadCompareInt ("SaveVolumeHistory", FALSE, &bHistory, bOnlyCheckModified, pbSettingsModified);
-
- {
- char szTmp[MAX_PATH] = {0};
- WideCharToMultiByte (CP_UTF8, 0, SecurityTokenLibraryPath, -1, szTmp, MAX_PATH, NULL, NULL);
- ConfigReadCompareString ("SecurityTokenLibrary", "", szTmp, sizeof (szTmp) - 1, bOnlyCheckModified, pbSettingsModified);
- MultiByteToWideChar (CP_UTF8, 0, szTmp, -1, SecurityTokenLibraryPath, ARRAYSIZE (SecurityTokenLibraryPath));
-
- if (!bOnlyCheckModified && SecurityTokenLibraryPath[0])
- InitSecurityTokenLibrary(hwndDlg);
- }
-
- if (bOnlyCheckModified)
- {
- char langid[6] = {0};
- if (!IsNonInstallMode ())
- {
- ConfigReadString ("Language", "", langid, sizeof (langid));
- // when installed, if no preferred language set by user, English is selected default
- if (langid [0] == 0)
- StringCbCopyA (langid, sizeof(langid), "en");
-
- if (pbSettingsModified && strcmp (langid, GetPreferredLangId ()))
- *pbSettingsModified = TRUE;
- }
- else
- {
- StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
- ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
- }
- }
-
- if (hwndDlg != NULL)
- {
- LoadCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), bHistory, bOnlyCheckModified, pbHistoryModified);
- return;
- }
-
- if (bHistoryCmdLine)
- return;
-}
-
-static void LoadSettings (HWND hwndDlg)
-{
- LoadSettingsAndCheckModified (hwndDlg, FALSE, NULL, NULL);
-}
-
-static void SaveSettings (HWND hwndDlg)
-{
- WaitCursor ();
-
- // Check first if modifications ocurred before writing to the settings and history files
- // This avoids leaking information about VeraCrypt usage when user only mount volumes without changing setttings or history
- BOOL bSettingsChanged = FALSE;
- BOOL bHistoryChanged = FALSE;
-
- LoadSettingsAndCheckModified (hwndDlg, TRUE, &bSettingsChanged, &bHistoryChanged);
-
- if (bHistoryChanged && hwndDlg != NULL)
- DumpCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), !bHistory);
-
- if (bSettingsChanged)
- {
- ConfigWriteBegin ();
-
- ConfigWriteInt ("StartOnLogon", bStartOnLogon);
- ConfigWriteInt ("HiddenSectorDetectionStatus", HiddenSectorDetectionStatus);
- ConfigWriteInt ("SaveVolumeHistory", bHistory);
- ConfigWriteStringW ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : L"");
-
- ConfigWriteString ("Language", GetPreferredLangId ());
-
- ConfigWriteEnd (hwndDlg);
- }
-
- NormalCursor ();
-}
-
-// WARNING: This function does NOT cause immediate application exit (use e.g. return 1 after calling it
-// from a DialogProc function).
-static void EndMainDlg (HWND hwndDlg)
-{
- if (nCurPageNo == VOLUME_LOCATION_PAGE)
- {
- if (IsWindow(GetDlgItem(hCurPage, IDC_NO_HISTORY)))
- bHistory = !IsButtonChecked (GetDlgItem (hCurPage, IDC_NO_HISTORY));
-
- MoveEditToCombo (GetDlgItem (hCurPage, IDC_COMBO_BOX), bHistory);
- SaveSettings (hCurPage);
- }
- else
- {
- SaveSettings (NULL);
- }
-
- SaveSysEncSettings (hwndDlg);
-
- if (!bHistory)
- CleanLastVisitedMRU ();
-
- EndDialog (hwndDlg, 0);
-}
-
-// Returns TRUE if system encryption or decryption had been or is in progress and has not been completed
-static BOOL SysEncryptionOrDecryptionRequired (void)
-{
- /* If you update this function, revise SysEncryptionOrDecryptionRequired() in Mount.c as well. */
-
- static BootEncryptionStatus locBootEncStatus;
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
-
- return (SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING
- || SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING
- ||
- (
- locBootEncStatus.DriveMounted
- &&
- (
- locBootEncStatus.ConfiguredEncryptedAreaStart != locBootEncStatus.EncryptedAreaStart
- || locBootEncStatus.ConfiguredEncryptedAreaEnd != locBootEncStatus.EncryptedAreaEnd
- )
- )
- );
-}
-
-// Returns TRUE if the system partition/drive is completely encrypted
-static BOOL SysDriveOrPartitionFullyEncrypted (BOOL bSilent)
-{
- /* If you update this function, revise SysDriveOrPartitionFullyEncrypted() in Mount.c as well. */
-
- static BootEncryptionStatus locBootEncStatus;
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- if (!bSilent)
- e.Show (MainDlg);
- }
-
- return (!locBootEncStatus.SetupInProgress
- && locBootEncStatus.ConfiguredEncryptedAreaEnd != 0
- && locBootEncStatus.ConfiguredEncryptedAreaEnd != -1
- && locBootEncStatus.ConfiguredEncryptedAreaStart == locBootEncStatus.EncryptedAreaStart
- && locBootEncStatus.ConfiguredEncryptedAreaEnd == locBootEncStatus.EncryptedAreaEnd);
-}
-
-// This functions is to be used when the wizard mode needs to be changed to WIZARD_MODE_SYS_DEVICE.
-// If the function fails to switch the mode, it returns FALSE (otherwise TRUE).
-BOOL SwitchWizardToSysEncMode (void)
-{
- WaitCursor ();
-
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
- bWholeSysDrive = BootEncObj->SystemPartitionCoversWholeDrive();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- NormalCursor ();
- return FALSE;
- }
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (!CreateSysEncMutex ())
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
- NormalCursor ();
- return FALSE;
- }
-
- // User-mode app may have crashed and its mutex may have gotten lost, so we need to check the driver status too
- if (BootEncStatus.SetupInProgress)
- {
- if (AskWarnYesNo ("SYSTEM_ENCRYPTION_RESUME_PROMPT", MainDlg) == IDYES)
- {
- if (SystemEncryptionStatus != SYSENC_STATUS_ENCRYPTING
- && SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING)
- {
- // The config file with status was lost or not written correctly
- if (!ResolveUnknownSysEncDirection ())
- {
- CloseSysEncMutex ();
- NormalCursor ();
- return FALSE;
- }
- }
-
- bDirectSysEncMode = TRUE;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- LoadPage (MainDlg, SYSENC_ENCRYPTION_PAGE);
- NormalCursor ();
- return TRUE;
- }
- else
- {
- CloseSysEncMutex ();
- Error ("SYS_ENCRYPTION_OR_DECRYPTION_IN_PROGRESS", MainDlg);
- NormalCursor ();
- return FALSE;
- }
- }
-
- if (BootEncStatus.DriveMounted
- || BootEncStatus.DriveEncrypted
- || SysEncryptionOrDecryptionRequired ())
- {
-
- if (!SysDriveOrPartitionFullyEncrypted (FALSE)
- && AskWarnYesNo ("SYSTEM_ENCRYPTION_RESUME_PROMPT", MainDlg) == IDYES)
- {
- if (SystemEncryptionStatus == SYSENC_STATUS_NONE)
- {
- // If the config file with status was lost or not written correctly, we
- // don't know whether to encrypt or decrypt (but we know that encryption or
- // decryption is required). Ask the user to select encryption, decryption,
- // or cancel
- if (!ResolveUnknownSysEncDirection ())
- {
- CloseSysEncMutex ();
- NormalCursor ();
- return FALSE;
- }
- }
-
- bDirectSysEncMode = TRUE;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- LoadPage (MainDlg, SYSENC_ENCRYPTION_PAGE);
- NormalCursor ();
- return TRUE;
- }
- else
- {
- CloseSysEncMutex ();
- Error ("SETUP_FAILED_BOOT_DRIVE_ENCRYPTED", MainDlg);
- NormalCursor ();
- return FALSE;
- }
- }
- else
- {
- // Check compliance with requirements for boot encryption
-
- if (!IsAdmin())
- {
- if (!IsUacSupported())
- {
- Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", MainDlg);
- }
- }
-
- try
- {
- BootEncObj->CheckRequirements ();
- }
- catch (Exception &e)
- {
- CloseSysEncMutex ();
- e.Show (MainDlg);
- NormalCursor ();
- return FALSE;
- }
-
- if (!ChangeWizardMode (WIZARD_MODE_SYS_DEVICE))
- {
- NormalCursor ();
- return FALSE;
- }
-
- if (bSysDriveSelected || bSysPartitionSelected)
- {
- // The user selected the non-sys-device wizard mode but then selected a system device
-
- bWholeSysDrive = (bSysDriveSelected && !bSysPartitionSelected);
-
- bSysDriveSelected = FALSE;
- bSysPartitionSelected = FALSE;
-
- try
- {
- if (!bHiddenVol)
- {
- if (bWholeSysDrive && !BootEncObj->SystemPartitionCoversWholeDrive())
- {
- if (BootEncObj->SystemDriveContainsNonStandardPartitions())
- {
- if (AskWarnYesNoString ((wstring (GetString ("SYSDRIVE_NON_STANDARD_PARTITIONS")) + L"\n\n" + GetString ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE")).c_str(), MainDlg) == IDYES)
- bWholeSysDrive = FALSE;
- }
-
- if (!IsOSAtLeast (WIN_VISTA) && bWholeSysDrive)
- {
- if (BootEncObj->SystemDriveContainsExtendedPartition())
- {
- bWholeSysDrive = FALSE;
-
- Error ("WDE_UNSUPPORTED_FOR_EXTENDED_PARTITIONS", MainDlg);
-
- if (AskYesNo ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE", MainDlg) == IDNO)
- {
- ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE);
- return FALSE;
- }
- }
- else
- Warning ("WDE_EXTENDED_PARTITIONS_WARNING", MainDlg);
- }
- }
- else if (BootEncObj->SystemPartitionCoversWholeDrive()
- && !bWholeSysDrive)
- bWholeSysDrive = (AskYesNo ("WHOLE_SYC_DEVICE_RECOM", MainDlg) == IDYES);
- }
-
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
-
- if (!bHiddenVol)
- {
- // Skip SYSENC_SPAN_PAGE and SYSENC_TYPE_PAGE as the user already made the choice
- LoadPage (MainDlg, bWholeSysDrive ? SYSENC_PRE_DRIVE_ANALYSIS_PAGE : SYSENC_MULTI_BOOT_MODE_PAGE);
- }
- else
- {
- // The user selected the non-sys-device wizard mode but then selected a system device.
- // In addition, he selected the hidden volume mode.
-
- if (bWholeSysDrive)
- Warning ("HIDDEN_OS_PRECLUDES_SINGLE_KEY_WDE", MainDlg);
-
- bWholeSysDrive = FALSE;
-
- LoadPage (MainDlg, SYSENC_TYPE_PAGE);
- }
- }
- else
- LoadPage (MainDlg, SYSENC_TYPE_PAGE);
-
- NormalCursor ();
- return TRUE;
- }
-}
-
-void SwitchWizardToFileContainerMode (void)
-{
- ChangeWizardMode (WIZARD_MODE_FILE_CONTAINER);
-
- LoadPage (MainDlg, VOLUME_LOCATION_PAGE);
-
- NormalCursor ();
-}
-
-void SwitchWizardToNonSysDeviceMode (void)
-{
- ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE);
-
- LoadPage (MainDlg, VOLUME_TYPE_PAGE);
-
- NormalCursor ();
-}
-
-BOOL SwitchWizardToHiddenOSMode (void)
-{
- if (SwitchWizardToSysEncMode())
- {
- if (nCurPageNo != SYSENC_ENCRYPTION_PAGE) // If the user did not manually choose to resume encryption or decryption of the system partition/drive
- {
- bHiddenOS = TRUE;
- bHiddenVol = TRUE;
- bHiddenVolHost = TRUE;
- bHiddenVolDirect = FALSE;
- bWholeSysDrive = FALSE;
- bInPlaceEncNonSys = FALSE;
- bInPlaceDecNonSys = FALSE;
-
- if (bDirectSysEncModeCommand == SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV)
- {
- // Some of the requirements for hidden OS should have already been checked by the wizard process
- // that launched us (in order to elevate), but we must recheck them. Otherwise, an advanced user
- // could bypass the checks by using the undocumented CLI switch. Moreover, some requirements
- // can be checked only at this point (when we are elevated).
- try
- {
- BootEncObj->CheckRequirementsHiddenOS ();
-
- BootEncObj->InitialSecurityChecksForHiddenOS ();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
-
- LoadPage (MainDlg, SYSENC_MULTI_BOOT_MODE_PAGE);
- }
- else
- LoadPage (MainDlg, SYSENC_HIDDEN_OS_REQ_CHECK_PAGE);
-
- NormalCursor ();
- }
- else
- return TRUE;
- }
- else
- return FALSE;
-
- return TRUE;
-}
-
-void SwitchWizardToNonSysInplaceEncResumeMode (BOOL bDecrypt)
-{
- if (!IsAdmin() && IsUacSupported())
- {
- if (!ElevateWholeWizardProcess (bDecrypt ? L"/resumeinplacedec" : L"/zinplace"))
- AbortProcessSilent ();
- }
-
- if (!IsAdmin())
- AbortProcess("ADMIN_PRIVILEGES_WARN_DEVICES");
-
- CreateNonSysInplaceEncMutex ();
-
- bInPlaceEncNonSys = TRUE;
- bInPlaceDecNonSys = bDecrypt;
- bInPlaceEncNonSysResumed = TRUE;
-
- ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE);
-
- LoadPage (MainDlg, NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE);
-}
-
-void SwitchWizardToNonSysInplaceDecStartMode (wchar_t *volPath)
-{
- if (!IsAdmin() && IsUacSupported())
- {
- if (!ElevateWholeWizardProcess ((wstring (L"/inplacedec \"") + volPath + L"\"").c_str()))
- AbortProcessSilent ();
- }
-
- if (!IsAdmin())
- AbortProcess("ADMIN_PRIVILEGES_WARN_DEVICES");
-
- if (!CheckRequirementsForNonSysInPlaceDec (MainDlg, volPath, FALSE))
- AbortProcessSilent ();
-
- CreateNonSysInplaceEncMutex ();
-
- bInPlaceEncNonSys = TRUE;
- bInPlaceDecNonSys = TRUE;
- bInPlaceEncNonSysResumed = FALSE;
-
- ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE);
-
- LoadPage (MainDlg, NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE);
-}
-
-// Use this function e.g. if the config file with the system encryption settings was lost or not written
-// correctly, and we don't know whether to encrypt or decrypt (but we know that encryption or decryption
-// is required). Returns FALSE if failed or cancelled.
-static BOOL ResolveUnknownSysEncDirection (void)
-{
- if (CreateSysEncMutex ())
- {
- if (SystemEncryptionStatus != SYSENC_STATUS_ENCRYPTING
- && SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING)
- {
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- return FALSE;
- }
-
- if (BootEncStatus.SetupInProgress)
- {
- return ChangeSystemEncryptionStatus (
- (BootEncStatus.SetupMode != SetupDecryption) ? SYSENC_STATUS_ENCRYPTING : SYSENC_STATUS_DECRYPTING);
- }
- else
- {
- // Ask the user to select encryption, decryption, or cancel
-
- char *tmpStr[] = {0,
- !BootEncStatus.DriveEncrypted ? "CHOOSE_ENCRYPT_OR_DECRYPT_FINALIZE_DECRYPT_NOTE" : "CHOOSE_ENCRYPT_OR_DECRYPT",
- "ENCRYPT",
- "DECRYPT",
- "IDCANCEL",
- 0};
-
- switch (AskMultiChoice ((void **) tmpStr, FALSE, MainDlg))
- {
- case 1:
- return ChangeSystemEncryptionStatus (SYSENC_STATUS_ENCRYPTING);
- case 2:
- return ChangeSystemEncryptionStatus (SYSENC_STATUS_DECRYPTING);
- default:
- return FALSE;
- }
- }
- }
- else
- return TRUE;
- }
- else
- {
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
- return FALSE;
- }
-}
-
-// This function should be used to resolve inconsistencies that might lead to a deadlock (inability to encrypt or
-// decrypt the system partition/drive and to uninstall TrueCrypt). The function removes the system encryption key
-// data ("volume header"), the TrueCrypt boot loader, restores the original system loader (if available),
-// unregisters the boot driver, etc. Note that if the system partition/drive is encrypted, it will start decrypting
-// it in the background (therefore, it should be used when the system partition/drive is not encrypted, ideally).
-// Exceptions are handled and errors are reported within the function. Returns TRUE if successful.
-static BOOL ForceRemoveSysEnc (void)
-{
- if (CreateSysEncMutex ()) // If no other instance is currently taking care of system encryption
- {
- BootEncryptionStatus locBootEncStatus;
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
-
- if (locBootEncStatus.SetupInProgress)
- BootEncObj->AbortSetupWait ();
-
- locBootEncStatus = BootEncObj->GetStatus();
-
- if (locBootEncStatus.DriveMounted)
- {
- // Remove the header
- BootEncObj->StartDecryption (DiscardUnreadableEncryptedSectors);
- locBootEncStatus = BootEncObj->GetStatus();
-
- while (locBootEncStatus.SetupInProgress)
- {
- Sleep (100);
- locBootEncStatus = BootEncObj->GetStatus();
- }
-
- BootEncObj->CheckEncryptionSetupResult ();
- }
-
- Sleep (50);
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
-
- if (!locBootEncStatus.DriveMounted)
- BootEncObj->Deinstall (true);
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
-
- return TRUE;
- }
- else
- return FALSE;
-}
-
-// Returns 0 if there's an error.
-__int64 GetSystemPartitionSize (void)
-{
- try
- {
- return BootEncObj->GetSystemDriveConfiguration().SystemPartition.Info.PartitionLength.QuadPart;
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return 0;
- }
-}
-
-void ComboSelChangeEA (HWND hwndDlg)
-{
- int nIndex = (int) SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0);
-
- if (nIndex == CB_ERR)
- {
- SetWindowText (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"");
- }
- else
- {
- wchar_t name[100];
- wchar_t auxLine[4096];
- wchar_t hyperLink[256] = { 0 };
- int cipherIDs[5];
- int i, cnt = 0;
-
- nIndex = (int) SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0);
- EAGetName (name, nIndex, 0);
-
- if (wcscmp (name, L"AES") == 0)
- {
- StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AES_HELP"));
- }
- else if (wcscmp (name, L"Serpent") == 0)
- {
- StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SERPENT_HELP"));
- }
- else if (wcscmp (name, L"Twofish") == 0)
- {
- StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("TWOFISH_HELP"));
- }
- else if (EAGetCipherCount (nIndex) > 1)
- {
- // Cascade
- cipherIDs[cnt++] = i = EAGetLastCipher(nIndex);
- while (i = EAGetPreviousCipher(nIndex, i))
- {
- cipherIDs[cnt] = i;
- cnt++;
- }
-
- switch (cnt) // Number of ciphers in the cascade
- {
- case 2:
- StringCbPrintfW (auxLine, sizeof(auxLine), GetString ("TWO_LAYER_CASCADE_HELP"),
- CipherGetName (cipherIDs[1]),
- CipherGetKeySize (cipherIDs[1])*8,
- CipherGetName (cipherIDs[0]),
- CipherGetKeySize (cipherIDs[0])*8);
- break;
-
- case 3:
- StringCbPrintfW (auxLine, sizeof(auxLine), GetString ("THREE_LAYER_CASCADE_HELP"),
- CipherGetName (cipherIDs[2]),
- CipherGetKeySize (cipherIDs[2])*8,
- CipherGetName (cipherIDs[1]),
- CipherGetKeySize (cipherIDs[1])*8,
- CipherGetName (cipherIDs[0]),
- CipherGetKeySize (cipherIDs[0])*8);
- break;
- }
-
- StringCbCopyW (hyperLink, sizeof(hyperLink), GetString ("IDC_LINK_MORE_INFO_ABOUT_CIPHER"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), auxLine);
- }
- else
- {
- // No info available for this encryption algorithm
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"");
- }
-
-
- // Update hyperlink
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER), hyperLink);
- AccommodateTextField (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER, FALSE, hUserUnderlineFont);
- }
-}
-
-static void VerifySizeAndUpdate (HWND hwndDlg, BOOL bUpdate)
-{
- BOOL bEnable = TRUE;
- wchar_t szTmp[50];
- __int64 lTmp;
- __int64 i;
- static unsigned __int64 nLastVolumeSize = 0;
-
- GetWindowText (GetDlgItem (hwndDlg, IDC_SIZEBOX), szTmp, ARRAYSIZE (szTmp));
-
- for (i = 0; i < (__int64) wcslen (szTmp); i++)
- {
- if (szTmp[i] >= L'0' && szTmp[i] <= L'9')
- continue;
- else
- {
- bEnable = FALSE;
- break;
- }
- }
-
- if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_KB)))
- nMultiplier = BYTES_PER_KB;
- else if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_MB)))
- nMultiplier = BYTES_PER_MB;
- else if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_GB)))
- nMultiplier = BYTES_PER_GB;
- else
- nMultiplier = BYTES_PER_TB;
-
- if (bDevice && !(bHiddenVol && !bHiddenVolHost)) // If raw device but not a hidden volume
- {
- lTmp = nVolumeSize;
- i = 1;
- }
- else
- {
- i = nMultiplier;
- lTmp = _wtoi64 (szTmp);
-
- DWORD sectorSize = GetFormatSectorSize();
- uint32 sectorSizeRem = (lTmp * nMultiplier) % sectorSize;
-
- if (sectorSizeRem != 0)
- lTmp = (lTmp * nMultiplier + (sectorSize - sectorSizeRem)) / nMultiplier;
- }
-
- if (bEnable)
- {
- if (lTmp * i < (bHiddenVolHost ? TC_MIN_HIDDEN_VOLUME_HOST_SIZE : (bHiddenVol ? TC_MIN_HIDDEN_VOLUME_SIZE : TC_MIN_VOLUME_SIZE)))
- bEnable = FALSE;
-
- if (!bHiddenVolHost && bHiddenVol)
- {
- if (lTmp * i > nMaximumHiddenVolSize)
- bEnable = FALSE;
- }
- else
- {
- if (lTmp * i > (bHiddenVolHost ? TC_MAX_HIDDEN_VOLUME_HOST_SIZE : TC_MAX_VOLUME_SIZE))
- bEnable = FALSE;
- }
- }
-
- if (bUpdate)
- {
- nUIVolumeSize = lTmp;
-
- if (!bDevice || (bHiddenVol && !bHiddenVolHost)) // Update only if it's not a raw device or if it's a hidden volume
- nVolumeSize = i * lTmp;
- }
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bEnable);
-
- if (nVolumeSize != nLastVolumeSize)
- {
- // Change of volume size may make some file systems allowed or disallowed, so the default filesystem must
- // be reselected.
- fileSystem = FILESYS_NONE;
- nLastVolumeSize = nVolumeSize;
- }
-}
-
-static void UpdateWizardModeControls (HWND hwndDlg, int setWizardMode)
-{
- SendMessage (GetDlgItem (hwndDlg, IDC_FILE_CONTAINER),
- BM_SETCHECK,
- setWizardMode == WIZARD_MODE_FILE_CONTAINER ? BST_CHECKED : BST_UNCHECKED,
- 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_NONSYS_DEVICE),
- BM_SETCHECK,
- setWizardMode == WIZARD_MODE_NONSYS_DEVICE ? BST_CHECKED : BST_UNCHECKED,
- 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SYS_DEVICE),
- BM_SETCHECK,
- setWizardMode == WIZARD_MODE_SYS_DEVICE ? BST_CHECKED : BST_UNCHECKED,
- 0);
-}
-
-static int GetSelectedWizardMode (HWND hwndDlg)
-{
- if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_FILE_CONTAINER)))
- return WIZARD_MODE_FILE_CONTAINER;
-
- if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_NONSYS_DEVICE)))
- return WIZARD_MODE_NONSYS_DEVICE;
-
- if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_SYS_DEVICE)))
- return WIZARD_MODE_SYS_DEVICE;
-
- return DEFAULT_VOL_CREATION_WIZARD_MODE;
-}
-
-static void RefreshMultiBootControls (HWND hwndDlg)
-{
-#ifdef DEBUG
- if (nMultiBoot == 0)
- nMultiBoot = 1;
-#endif
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SINGLE_BOOT),
- BM_SETCHECK,
- nMultiBoot == 1 ? BST_CHECKED : BST_UNCHECKED,
- 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_MULTI_BOOT),
- BM_SETCHECK,
- nMultiBoot > 1 ? BST_CHECKED : BST_UNCHECKED,
- 0);
-}
-
-// -1 = Undecided or error, 0 = No, 1 = Yes
-static int Get2RadButtonPageAnswer (void)
-{
- if (IsButtonChecked (GetDlgItem (hCurPage, IDC_CHOICE1)))
- return 1;
-
- if (IsButtonChecked (GetDlgItem (hCurPage, IDC_CHOICE2)))
- return 0;
-
- return -1;
-}
-
-// 0 = No, 1 = Yes
-static void Update2RadButtonPage (int answer)
-{
- SendMessage (GetDlgItem (hCurPage, IDC_CHOICE1),
- BM_SETCHECK,
- answer == 1 ? BST_CHECKED : BST_UNCHECKED,
- 0);
-
- SendMessage (GetDlgItem (hCurPage, IDC_CHOICE2),
- BM_SETCHECK,
- answer == 0 ? BST_CHECKED : BST_UNCHECKED,
- 0);
-}
-
-// -1 = Undecided, 0 = No, 1 = Yes
-static void Init2RadButtonPageYesNo (int answer)
-{
- SetWindowTextW (GetDlgItem (hCurPage, IDC_CHOICE1), GetString ("UISTR_YES"));
- SetWindowTextW (GetDlgItem (hCurPage, IDC_CHOICE2), GetString ("UISTR_NO"));
-
- SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), answer >= 0);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), TRUE);
-
- Update2RadButtonPage (answer);
-}
-
-static void UpdateSysEncProgressBar (void)
-{
- BootEncryptionStatus locBootEncStatus;
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (...)
- {
- return;
- }
-
- if (locBootEncStatus.EncryptedAreaEnd == -1
- || locBootEncStatus.EncryptedAreaStart == -1)
- {
- UpdateProgressBarProc (0);
- }
- else
- {
- UpdateProgressBarProc (locBootEncStatus.EncryptedAreaEnd - locBootEncStatus.EncryptedAreaStart + 1);
-
- if (locBootEncStatus.SetupInProgress)
- {
- wchar_t tmpStr[100];
-
- // Status
-
- if (locBootEncStatus.TransformWaitingForIdle)
- StringCbCopyW (tmpStr, sizeof(tmpStr), GetString ("PROGRESS_STATUS_WAITING"));
- else
- StringCbCopyW (tmpStr, sizeof(tmpStr), GetString (SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING ? "PROGRESS_STATUS_DECRYPTING" : "PROGRESS_STATUS_ENCRYPTING"));
-
- StringCbCatW (tmpStr, sizeof(tmpStr), L" ");
-
- SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), tmpStr);
- }
- }
-}
-
-static void InitSysEncProgressBar (void)
-{
- BootEncryptionStatus locBootEncStatus;
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (...)
- {
- return;
- }
-
- if (locBootEncStatus.ConfiguredEncryptedAreaEnd == -1
- || locBootEncStatus.ConfiguredEncryptedAreaStart == -1)
- return;
-
- InitProgressBar (locBootEncStatus.ConfiguredEncryptedAreaEnd
- - locBootEncStatus.ConfiguredEncryptedAreaStart + 1,
- (locBootEncStatus.EncryptedAreaEnd == locBootEncStatus.EncryptedAreaStart || locBootEncStatus.EncryptedAreaEnd == -1) ?
- 0 : locBootEncStatus.EncryptedAreaEnd - locBootEncStatus.EncryptedAreaStart + 1,
- SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING,
- TRUE,
- TRUE,
- TRUE);
-}
-
-static void UpdateSysEncControls (void)
-{
- BootEncryptionStatus locBootEncStatus;
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (...)
- {
- return;
- }
-
- EnableWindow (GetDlgItem (hCurPage, IDC_WIPE_MODE),
- !locBootEncStatus.SetupInProgress
- && SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING);
-
- SetWindowTextW (GetDlgItem (hCurPage, IDC_PAUSE),
- GetString (locBootEncStatus.SetupInProgress ? "IDC_PAUSE" : "RESUME"));
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), !locBootEncStatus.SetupInProgress && !bFirstSysEncResumeDone);
-
- if (!locBootEncStatus.SetupInProgress)
- {
- wchar_t tmpStr[100];
-
- StringCbCopyW (tmpStr, sizeof(tmpStr), GetString ((SysDriveOrPartitionFullyEncrypted (TRUE) || !locBootEncStatus.DriveMounted) ?
- "PROGRESS_STATUS_FINISHED" : "PROGRESS_STATUS_PAUSED"));
- StringCbCatW (tmpStr, sizeof(tmpStr), L" ");
-
- // Status
- SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), tmpStr);
-
- if (SysDriveOrPartitionFullyEncrypted (TRUE) || SystemEncryptionStatus == SYSENC_STATUS_NONE)
- {
- StringCbCopyW (tmpStr, sizeof(tmpStr), GetString ("PROCESSED_PORTION_100_PERCENT"));
- StringCbCatW (tmpStr, sizeof(tmpStr), L" ");
-
- SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), tmpStr);
- }
-
- SetWindowText (GetDlgItem (hCurPage, IDC_TIMEREMAIN), L" ");
- }
-}
-
-static void SysEncPause (void)
-{
- BootEncryptionStatus locBootEncStatus;
-
- if (CreateSysEncMutex ())
- {
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), FALSE);
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- return;
- }
-
- if (!locBootEncStatus.SetupInProgress)
- {
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- return;
- }
-
- WaitCursor ();
-
- try
- {
- int attempts = SYSENC_PAUSE_RETRIES;
-
- BootEncObj->AbortSetup ();
-
- locBootEncStatus = BootEncObj->GetStatus();
-
- while (locBootEncStatus.SetupInProgress && attempts > 0)
- {
- Sleep (SYSENC_PAUSE_RETRY_INTERVAL);
- attempts--;
- locBootEncStatus = BootEncObj->GetStatus();
- }
-
- if (!locBootEncStatus.SetupInProgress)
- BootEncObj->CheckEncryptionSetupResult ();
-
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
-
- NormalCursor ();
-
- if (locBootEncStatus.SetupInProgress)
- {
- SetTimer (MainDlg, TIMER_ID_SYSENC_PROGRESS, TIMER_INTERVAL_SYSENC_PROGRESS, NULL);
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- Error ("FAILED_TO_INTERRUPT_SYSTEM_ENCRYPTION", MainDlg);
- return;
- }
-
- UpdateSysEncControls ();
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- }
- else
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
-}
-
-
-static void SysEncResume (void)
-{
- BootEncryptionStatus locBootEncStatus;
-
- if (CreateSysEncMutex ())
- {
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), FALSE);
-
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- return;
- }
-
- if (locBootEncStatus.SetupInProgress)
- {
- // Prevent the OS from entering Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
-
- bSystemEncryptionInProgress = TRUE;
- UpdateSysEncControls ();
- SetTimer (MainDlg, TIMER_ID_SYSENC_PROGRESS, TIMER_INTERVAL_SYSENC_PROGRESS, NULL);
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- return;
- }
-
- bVolTransformThreadCancel = FALSE;
- bSystemEncryptionInProgress = FALSE;
- WaitCursor ();
-
- try
- {
- switch (SystemEncryptionStatus)
- {
- case SYSENC_STATUS_ENCRYPTING:
-
- BootEncObj->StartEncryption (nWipeMode, bTryToCorrectReadErrors ? true : false);
- break;
-
- case SYSENC_STATUS_DECRYPTING:
-
- if (locBootEncStatus.DriveMounted) // If the drive is not encrypted we will just deinstall
- BootEncObj->StartDecryption (DiscardUnreadableEncryptedSectors);
-
- break;
- }
-
- bSystemEncryptionInProgress = TRUE;
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
-
- NormalCursor ();
-
- if (!bSystemEncryptionInProgress)
- {
- // Allow the OS to enter Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS);
-
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- Error ("FAILED_TO_RESUME_SYSTEM_ENCRYPTION", MainDlg);
- return;
- }
-
- // Prevent the OS from entering Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
-
- bFirstSysEncResumeDone = TRUE;
- InitSysEncProgressBar ();
- UpdateSysEncProgressBar ();
- UpdateSysEncControls ();
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), TRUE);
- SetTimer (MainDlg, TIMER_ID_SYSENC_PROGRESS, TIMER_INTERVAL_SYSENC_PROGRESS, NULL);
- }
- else
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
-}
-
-
-static BOOL GetDevicePathForHiddenOS (void)
-{
- BOOL tmpbDevice = FALSE;
-
- try
- {
- StringCbCopyW (szFileName, sizeof(szFileName), BootEncObj->GetPartitionForHiddenOS().DevicePath.c_str());
-
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &tmpbDevice);
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
-
- return (szFileName[0] != 0
- && szDiskFile[0] != 0
- && tmpbDevice);
-}
-
-
-// Returns TRUE if there is unallocated space greater than 64 MB (max possible slack space size) between the
-// boot partition and the first partition behind it. If there's none or if an error occurs, returns FALSE.
-static BOOL CheckGapBetweenSysAndHiddenOS (void)
-{
- try
- {
- SystemDriveConfiguration sysDriveCfg = BootEncObj->GetSystemDriveConfiguration();
-
- return (sysDriveCfg.SystemPartition.Info.StartingOffset.QuadPart
- + sysDriveCfg.SystemPartition.Info.PartitionLength.QuadPart
- + 64 * BYTES_PER_MB
- + 128 * BYTES_PER_KB
- <= BootEncObj->GetPartitionForHiddenOS().Info.StartingOffset.QuadPart);
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
-
- return FALSE;
-}
-
-
-static void NonSysInplaceEncPause (void)
-{
- bVolTransformThreadCancel = TRUE;
-
- WaitCursor ();
-
- int waitThreshold = 100; // Do not block GUI events for more than 10 seconds. IMPORTANT: This prevents deadlocks when the thread calls us back e.g. to update GUI!
-
- while (bVolTransformThreadRunning || bVolTransformThreadToRun)
- {
- MSG guiMsg;
-
- bVolTransformThreadCancel = TRUE;
-
- if (waitThreshold <= 0)
- {
- while (PeekMessageW (&guiMsg, NULL, 0, 0, PM_REMOVE) != 0)
- {
- DispatchMessageW (&guiMsg);
- }
- }
- else
- waitThreshold--;
-
- Sleep (100);
- }
-}
-
-
-static void NonSysInplaceEncResume (void)
-{
- if (bVolTransformThreadRunning || bVolTransformThreadToRun || bVolTransformThreadCancel)
- return;
-
- if (!bInPlaceEncNonSysResumed
- && !FinalPreTransformPrompts ())
- {
- return;
- }
-
- CreateNonSysInplaceEncMutex ();
-
- bFirstNonSysInPlaceEncResumeDone = TRUE;
-
- SetTimer (MainDlg, TIMER_ID_NONSYS_INPLACE_ENC_PROGRESS, TIMER_INTERVAL_NONSYS_INPLACE_ENC_PROGRESS, NULL);
-
- bVolTransformThreadCancel = FALSE;
- bVolTransformThreadToRun = TRUE;
-
- UpdateNonSysInPlaceEncControls ();
-
- LastDialogId = "NONSYS_INPLACE_ENC_IN_PROGRESS";
-
- _beginthread (volTransformThreadFunction, 0, MainDlg);
-
- return;
-}
-
-
-void ShowNonSysInPlaceEncUIStatus (void)
-{
- wchar_t nonSysInplaceEncUIStatus [300] = {0};
-
- switch (NonSysInplaceEncStatus)
- {
- case NONSYS_INPLACE_ENC_STATUS_PAUSED:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_PAUSED"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_PREPARING:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_PREPARING"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_RESIZING:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_RESIZING"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_ENCRYPTING:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_ENCRYPTING"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_DECRYPTING:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_DECRYPTING"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_FINALIZING:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_FINALIZING"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_FINISHED:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_FINISHED"));
- break;
- case NONSYS_INPLACE_ENC_STATUS_ERROR:
- StringCbCopyW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), GetString ("PROGRESS_STATUS_ERROR"));
- break;
- }
-
- StringCbCatW (nonSysInplaceEncUIStatus, sizeof(nonSysInplaceEncUIStatus), L" ");
-
- SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), nonSysInplaceEncUIStatus);
-}
-
-
-void UpdateNonSysInPlaceEncControls (void)
-{
- // Reduce flickering by updating a GUI element only when a relevant change affects it
- static BOOL lastbVolTransformThreadRunning = !bVolTransformThreadRunning;
- static BOOL lastbVolTransformThreadToRun = !bVolTransformThreadToRun;
- static BOOL lastbInPlaceEncNonSysResumed = !bInPlaceEncNonSysResumed;
-
- EnableWindow (GetDlgItem (hCurPage, IDC_WIPE_MODE), !(bVolTransformThreadRunning || bVolTransformThreadToRun) && !bInPlaceDecNonSys);
-
- if (lastbVolTransformThreadRunning != bVolTransformThreadRunning
- || lastbVolTransformThreadToRun != bVolTransformThreadToRun)
- {
- SetWindowTextW (GetDlgItem (hCurPage, IDC_PAUSE),
- GetString ((bVolTransformThreadRunning || bVolTransformThreadToRun) ? "IDC_PAUSE" : "RESUME"));
-
- lastbVolTransformThreadRunning = bVolTransformThreadRunning;
- lastbVolTransformThreadToRun = bVolTransformThreadToRun;
- }
-
- if (lastbInPlaceEncNonSysResumed != bInPlaceEncNonSysResumed)
- {
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString (bInPlaceEncNonSysResumed ? "DEFER" : "CANCEL"));
- lastbInPlaceEncNonSysResumed = bInPlaceEncNonSysResumed;
- }
-
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), bFirstNonSysInPlaceEncResumeDone
- && NonSysInplaceEncStatus != NONSYS_INPLACE_ENC_STATUS_FINALIZING
- && NonSysInplaceEncStatus != NONSYS_INPLACE_ENC_STATUS_FINISHED);
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), !(bVolTransformThreadRunning || bVolTransformThreadToRun) && !bFirstNonSysInPlaceEncResumeDone);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), !(bVolTransformThreadRunning || bVolTransformThreadToRun) && !bInPlaceEncNonSysResumed);
- EnableWindow (GetDlgItem (MainDlg, IDCANCEL),
- !(bVolTransformThreadToRun
- || NonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_PREPARING
- || NonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_RESIZING
- || NonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_FINALIZING
- || NonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_FINISHED));
-
- if (bVolTransformThreadRunning || bVolTransformThreadToRun)
- {
- switch (NonSysInplaceEncStatus)
- {
- case NONSYS_INPLACE_ENC_STATUS_PREPARING:
- case NONSYS_INPLACE_ENC_STATUS_RESIZING:
- case NONSYS_INPLACE_ENC_STATUS_FINALIZING:
- ArrowWaitCursor ();
- break;
-
- case NONSYS_INPLACE_ENC_STATUS_ENCRYPTING:
- NormalCursor ();
- break;
-
- default:
- NormalCursor ();
- break;
- }
-
- if (bVolTransformThreadCancel)
- WaitCursor ();
- }
- else
- {
- NormalCursor ();
-
- if (bInPlaceEncNonSysResumed)
- {
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED);
- }
- else
- SetWindowText (GetDlgItem (hCurPage, IDC_WRITESPEED), L" ");
-
- SetWindowText (GetDlgItem (hCurPage, IDC_TIMEREMAIN), L" ");
- }
-
- ShowNonSysInPlaceEncUIStatus ();
-
- UpdateNonSysInplaceEncProgressBar ();
-}
-
-
-static void UpdateNonSysInplaceEncProgressBar (void)
-{
- static int lastNonSysInplaceEncStatus = NONSYS_INPLACE_ENC_STATUS_NONE;
- int nonSysInplaceEncStatus = NonSysInplaceEncStatus;
- __int64 totalSize = NonSysInplaceEncTotalSize;
-
- if (bVolTransformThreadRunning
- && (nonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_ENCRYPTING
- || nonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_DECRYPTING
- || nonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_FINALIZING
- || nonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_FINISHED))
- {
- if (lastNonSysInplaceEncStatus != nonSysInplaceEncStatus
- && (nonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_ENCRYPTING || nonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_DECRYPTING))
- {
- InitNonSysInplaceEncProgressBar ();
- }
- else
- {
- if (totalSize <= 0 && nVolumeSize > 0)
- totalSize = nVolumeSize;
-
- if (totalSize > 0)
- UpdateProgressBarProc (NonSysInplaceEncBytesDone);
- }
- }
-
- ShowNonSysInPlaceEncUIStatus ();
-
- lastNonSysInplaceEncStatus = nonSysInplaceEncStatus;
-}
-
-
-static void InitNonSysInplaceEncProgressBar (void)
-{
- __int64 totalSize = NonSysInplaceEncTotalSize;
-
- if (totalSize <= 0)
- {
- if (nVolumeSize <= 0)
- return;
-
- totalSize = nVolumeSize;
- }
-
- InitProgressBar (totalSize,
- NonSysInplaceEncBytesDone,
- bInPlaceDecNonSys,
- TRUE,
- TRUE,
- TRUE);
-}
-
-
-void DisplayRandPool (HWND hwndDlg, HWND hPoolDisplay, BOOL bShow)
-{
- wchar_t tmp[4];
- unsigned char tmpByte;
- int col, row;
- static BOOL bRandPoolDispAscii = FALSE;
- DWORD mouseEventsCounter;
-
- RandpeekBytes (hwndDlg, randPool, sizeof (randPool), &mouseEventsCounter);
-
- ProcessEntropyEstimate (hEntropyBar, &mouseEventsInitialCount, mouseEventsCounter, maxEntropyLevel, &mouseEntropyGathered);
-
- if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0)
- {
- outRandPoolDispBuffer[0] = 0;
-
- for (row = 0; row < RANDPOOL_DISPLAY_ROWS; row++)
- {
- for (col = 0; col < RANDPOOL_DISPLAY_COLUMNS; col++)
- {
- if (bShow)
- {
- tmpByte = randPool[row * RANDPOOL_DISPLAY_COLUMNS + col];
-
- StringCbPrintfW (tmp, sizeof(tmp), bRandPoolDispAscii ? ((tmpByte >= 32 && tmpByte < 255 && tmpByte != L'&') ? L" %c " : L" . ") : L"%02X ", tmpByte);
- }
- else if (bUseMask)
- {
- /* use mask to compute a randomized ASCII representation */
- tmpByte = (randPool[row * RANDPOOL_DISPLAY_COLUMNS + col] -
- lastRandPool[row * RANDPOOL_DISPLAY_COLUMNS + col]) ^ maskRandPool [row * RANDPOOL_DISPLAY_COLUMNS + col];
- tmp[0] = (wchar_t) (((tmpByte >> 4) % 6) + L'*');
- tmp[1] = (wchar_t) (((tmpByte & 0x0F) % 6) + L'*');
- tmp[2] = L' ';
- tmp[3] = 0;
- }
- else
- {
- StringCbCopyW (tmp, sizeof(tmp), L"** ");
- }
-
-
- StringCbCatW (outRandPoolDispBuffer, sizeof(outRandPoolDispBuffer), tmp);
- }
- StringCbCatW (outRandPoolDispBuffer, sizeof(outRandPoolDispBuffer), L"\n");
- }
- SetWindowText (hPoolDisplay, outRandPoolDispBuffer);
-
- memcpy (lastRandPool, randPool, sizeof(lastRandPool));
- }
-}
-
-
-void DisplayPortionsOfKeys (HWND headerKeyHandle, HWND masterKeyHandle, wchar_t *headerKeyStr, wchar_t *masterKeyStr, BOOL hideKeys)
-{
- const wchar_t *hiddenKey = L"******************************** ";
-
- SetWindowTextW (headerKeyHandle, hideKeys ? hiddenKey : (std::wstring (headerKeyStr) + GetString ("TRIPLE_DOT_GLYPH_ELLIPSIS")).c_str());
- SetWindowTextW (masterKeyHandle, hideKeys ? hiddenKey : (std::wstring (masterKeyStr) + GetString ("TRIPLE_DOT_GLYPH_ELLIPSIS")).c_str());
-}
-
-
-static void WipeAbort (void)
-{
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), FALSE);
-
- if (bHiddenOS && IsHiddenOSRunning())
- {
- /* Decoy system partition wipe */
-
- DecoySystemWipeStatus decoySysPartitionWipeStatus;
-
- try
- {
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
- return;
- }
-
- if (!decoySysPartitionWipeStatus.WipeInProgress)
- {
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
- return;
- }
-
- WaitCursor ();
-
- try
- {
- int attempts = SYSENC_PAUSE_RETRIES;
-
- BootEncObj->AbortDecoyOSWipe ();
-
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
-
- while (decoySysPartitionWipeStatus.WipeInProgress && attempts > 0)
- {
- Sleep (SYSENC_PAUSE_RETRY_INTERVAL);
- attempts--;
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
- }
-
- if (!decoySysPartitionWipeStatus.WipeInProgress)
- BootEncObj->CheckDecoyOSWipeResult ();
-
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
-
- NormalCursor ();
-
- if (decoySysPartitionWipeStatus.WipeInProgress)
- {
- SetTimer (MainDlg, TIMER_ID_WIPE_PROGRESS, TIMER_INTERVAL_WIPE_PROGRESS, NULL);
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
- Error ("FAILED_TO_INTERRUPT_WIPING", MainDlg);
- return;
- }
- }
- else
- {
- /* Regular device wipe (not decoy system partition wipe) */
- }
-
- UpdateWipeControls ();
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
-}
-
-
-static void WipeStart (void)
-{
- if (bHiddenOS && IsHiddenOSRunning())
- {
- /* Decoy system partition wipe */
-
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), FALSE);
-
- bDeviceWipeInProgress = FALSE;
- WaitCursor ();
-
- try
- {
- BootEncObj->StartDecoyOSWipe (nWipeMode);
-
- bDeviceWipeInProgress = TRUE;
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
-
- NormalCursor ();
-
- if (!bDeviceWipeInProgress)
- {
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
- Error ("FAILED_TO_START_WIPING", MainDlg);
- return;
- }
- }
- else
- {
- /* Regular device wipe (not decoy system partition wipe) */
- }
-
- InitWipeProgressBar ();
- UpdateWipeProgressBar ();
- UpdateWipeControls ();
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
- SetTimer (MainDlg, TIMER_ID_WIPE_PROGRESS, TIMER_INTERVAL_WIPE_PROGRESS, NULL);
-}
-
-
-static void UpdateWipeProgressBar (void)
-{
- if (bHiddenOS && IsHiddenOSRunning())
- {
- /* Decoy system partition wipe */
-
- DecoySystemWipeStatus decoySysPartitionWipeStatus;
-
- try
- {
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (...)
- {
- return;
- }
-
- if (decoySysPartitionWipeStatus.WipedAreaEnd == -1)
- UpdateProgressBarProc (0);
- else
- UpdateProgressBarProc (decoySysPartitionWipeStatus.WipedAreaEnd - BootEncStatus.ConfiguredEncryptedAreaStart + 1);
- }
- else
- {
- /* Regular device wipe (not decoy system partition wipe) */
- }
-}
-
-
-static void InitWipeProgressBar (void)
-{
- if (bHiddenOS && IsHiddenOSRunning())
- {
- /* Decoy system partition wipe */
-
- DecoySystemWipeStatus decoySysPartitionWipeStatus;
-
- try
- {
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (...)
- {
- return;
- }
-
- if (BootEncStatus.ConfiguredEncryptedAreaEnd == -1
- || BootEncStatus.ConfiguredEncryptedAreaStart == -1)
- return;
-
- InitProgressBar (BootEncStatus.ConfiguredEncryptedAreaEnd - BootEncStatus.ConfiguredEncryptedAreaStart + 1,
- (decoySysPartitionWipeStatus.WipedAreaEnd == BootEncStatus.ConfiguredEncryptedAreaStart || decoySysPartitionWipeStatus.WipedAreaEnd == -1) ?
- 0 : decoySysPartitionWipeStatus.WipedAreaEnd - BootEncStatus.ConfiguredEncryptedAreaStart + 1,
- FALSE,
- TRUE,
- FALSE,
- TRUE);
- }
- else
- {
- /* Regular device wipe (not decoy system partition wipe) */
- }
-}
-
-
-static void UpdateWipeControls (void)
-{
- if (bHiddenOS && IsHiddenOSRunning())
- {
- /* Decoy system partition wipe */
-
- DecoySystemWipeStatus decoySysPartitionWipeStatus;
-
- try
- {
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (...)
- {
- return;
- }
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), !decoySysPartitionWipeStatus.WipeInProgress);
- }
- else
- {
- /* Regular device wipe (not decoy system partition wipe) */
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), bDeviceWipeInProgress);
-
- if (!bDeviceWipeInProgress)
- {
- SetWindowText (GetDlgItem (hCurPage, IDC_TIMEREMAIN), L" ");
- }
- }
-
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), bDeviceWipeInProgress);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), !bDeviceWipeInProgress);
-
- bConfirmQuit = bDeviceWipeInProgress;
-}
-
-
-
-static void __cdecl sysEncDriveAnalysisThread (void *hwndDlgArg)
-{
- // Mark the detection process as 'in progress'
- HiddenSectorDetectionStatus = 1;
- SaveSettings (NULL);
- BroadcastSysEncCfgUpdate ();
-
- try
- {
- BootEncObj->ProbeRealSystemDriveSize ();
- bSysEncDriveAnalysisTimeOutOccurred = FALSE;
- }
- catch (TimeOut &)
- {
- bSysEncDriveAnalysisTimeOutOccurred = TRUE;
- }
- catch (Exception &e)
- {
- // There was a problem but the system did not freeze. Mark the detection process as completed.
- HiddenSectorDetectionStatus = 0;
- SaveSettings (NULL);
- BroadcastSysEncCfgUpdate ();
-
- e.Show (NULL);
- EndMainDlg (MainDlg);
- exit(0);
- }
-
- // Mark the detection process as completed
- HiddenSectorDetectionStatus = 0;
- SaveSettings (NULL);
- BroadcastSysEncCfgUpdate ();
-
- // This artificial delay prevents user confusion on systems where the analysis ends almost instantly
- Sleep (3000);
-
- bSysEncDriveAnalysisInProgress = FALSE;
-}
-
-static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
-{
- int nStatus;
- DWORD dwWin32FormatError;
- BOOL bHidden;
- HWND hwndDlg = (HWND) hwndDlgArg;
- volatile FORMAT_VOL_PARAMETERS *volParams = (FORMAT_VOL_PARAMETERS *) malloc (sizeof(FORMAT_VOL_PARAMETERS));
-
- if (volParams == NULL)
- AbortProcess ("ERR_MEM_ALLOC");
-
- VirtualLock ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
-
- bOperationSuccess = FALSE;
-
- if (bGuiMode)
- {
- bVolTransformThreadRunning = TRUE;
- bVolTransformThreadToRun = FALSE;
- }
-
- // Check administrator privileges
- if (!IsAdmin () && !IsUacSupported ())
- {
- if (fileSystem == FILESYS_NTFS || fileSystem == FILESYS_EXFAT)
- {
- if (Silent || (MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_NTFS"), lpszTitle, MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2) == IDCANCEL))
- goto cancel;
- }
- if (bDevice)
- {
- if (Silent || (MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_DEVICES"), lpszTitle, MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2) == IDCANCEL))
- goto cancel;
- }
- }
-
- if (!bInPlaceEncNonSys)
- {
- if (!bDevice)
- {
- int x = _waccess (szDiskFile, 06);
- if (x == 0 || errno != ENOENT)
- {
- wchar_t szTmp[512];
-
- if (!bForceOperation && !((bHiddenVol && !bHiddenVolHost) && errno != EACCES)) // Only ask ask for permission to overwrite an existing volume if we're not creating a hidden volume
- {
- StringCbPrintfW (szTmp, sizeof szTmp,
- GetString (errno == EACCES ? "READONLYPROMPT" : "OVERWRITEPROMPT"),
- szDiskFile);
-
- x = Silent? IDNO : MessageBoxW (hwndDlg, szTmp, lpszTitle, YES_NO|MB_ICONWARNING|MB_DEFBUTTON2);
-
- if (x != IDYES)
- goto cancel;
- }
- }
-
- if (_waccess (szDiskFile, 06) != 0)
- {
- if (errno == EACCES)
- {
- if (_wchmod (szDiskFile, _S_IREAD | _S_IWRITE) != 0)
- {
- if (!Silent) MessageBoxW (hwndDlg, GetString ("ACCESSMODEFAIL"), lpszTitle, ICON_HAND);
- goto cancel;
- }
- }
- }
-
- }
- else
- {
- // Partition / device / dynamic volume
-
- if (!FinalPreTransformPrompts ())
- goto cancel;
- }
- }
-
- // Prevent the OS from entering Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
-
- bHidden = bHiddenVol && !bHiddenVolHost;
-
- volParams->bDevice = bDevice;
- volParams->hiddenVol = bHidden;
- volParams->volumePath = szDiskFile;
- volParams->size = nVolumeSize;
- volParams->hiddenVolHostSize = nHiddenVolHostSize;
- volParams->ea = nVolumeEA;
- volParams->pkcs5 = hash_algo;
- volParams->headerFlags = (CreatingHiddenSysVol() ? TC_HEADER_FLAG_ENCRYPTED_SYSTEM : 0);
- volParams->fileSystem = fileSystem;
- volParams->clusterSize = clusterSize;
- volParams->sparseFileSwitch = bSparseFileSwitch;
- volParams->quickFormat = quickFormat;
- volParams->sectorSize = GetFormatSectorSize();
- volParams->realClusterSize = &realClusterSize;
- volParams->password = &volumePassword;
- volParams->pim = volumePim;
- volParams->hwndDlg = hwndDlg;
- volParams->bForceOperation = bForceOperation;
- volParams->bGuiMode = bGuiMode;
-
- if (bInPlaceDecNonSys)
- {
- // In-place decryption of non-system volume
-
- if (!bInPlaceEncNonSysResumed)
- DiscardUnreadableEncryptedSectors = FALSE;
-
- nStatus = DecryptPartitionInPlace (volParams, &DiscardUnreadableEncryptedSectors);
- }
- else if (bInPlaceEncNonSys)
- {
- // In-place encryption of non-system volume
-
- HANDLE hPartition = INVALID_HANDLE_VALUE;
-
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING);
-
- if (!bInPlaceEncNonSysResumed)
- {
- bTryToCorrectReadErrors = FALSE;
-
- nStatus = EncryptPartitionInPlaceBegin (volParams, &hPartition, nWipeMode);
-
- if (nStatus == ERR_SUCCESS)
- {
- nStatus = EncryptPartitionInPlaceResume (hPartition, volParams, nWipeMode, &bTryToCorrectReadErrors);
- }
- else if (hPartition != INVALID_HANDLE_VALUE)
- {
- CloseHandle (hPartition);
- hPartition = INVALID_HANDLE_VALUE;
- }
- }
- else
- {
- nStatus = EncryptPartitionInPlaceResume (INVALID_HANDLE_VALUE, volParams, nWipeMode, &bTryToCorrectReadErrors);
- }
- }
- else
- {
- // Format-encryption
-
- if (hwndDlg && bGuiMode) InitProgressBar (GetVolumeDataAreaSize (bHidden, nVolumeSize), 0, FALSE, FALSE, FALSE, TRUE);
-
- nStatus = TCFormatVolume (volParams);
- }
-
- // Allow the OS to enter Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS);
-
- if (nStatus == ERR_OUTOFMEMORY)
- {
- AbortProcess ("OUTOFMEMORY");
- }
-
- if (bInPlaceEncNonSys
- && nStatus == ERR_USER_ABORT
- && NonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_FINISHED)
- {
- // Ignore user abort if non-system in-place encryption/decryption successfully finished
- nStatus = ERR_SUCCESS;
- }
-
-
- dwWin32FormatError = GetLastError ();
-
- if (bHiddenVolHost && (!bGuiMode || !bVolTransformThreadCancel) && nStatus == 0)
- {
- /* Auto mount the newly created hidden volume host */
- switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, volumePim, FALSE))
- {
- case ERR_NO_FREE_DRIVES:
- if (!Silent) MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
- if (bGuiMode) bVolTransformThreadCancel = TRUE;
- break;
- case ERR_VOL_MOUNT_FAILED:
- case ERR_PASSWORD_WRONG:
- if (!Silent) MessageBoxW (hwndDlg, GetString ("CANT_MOUNT_OUTER_VOL"), lpszTitle, ICON_HAND);
- if (bGuiMode) bVolTransformThreadCancel = TRUE;
- break;
- }
- }
-
- SetLastError (dwWin32FormatError);
-
- if ((bVolTransformThreadCancel || nStatus == ERR_USER_ABORT)
- && !(bInPlaceEncNonSys && NonSysInplaceEncStatus == NONSYS_INPLACE_ENC_STATUS_FINISHED)) // Ignore user abort if non-system in-place encryption/decryption successfully finished.
- {
- if (!bDevice && !(bHiddenVol && !bHiddenVolHost)) // If we're not creating a hidden volume and if it's a file container
- {
- _wremove (szDiskFile); // Delete the container
- }
-
- goto cancel;
- }
-
- if (nStatus != ERR_USER_ABORT)
- {
- if (nStatus != 0)
- {
- /* An error occurred */
-
- wchar_t szMsg[8192];
-
- handleError (hwndDlg, nStatus, SRC_POS);
-
- if (bInPlaceEncNonSys)
- {
- if (bInPlaceEncNonSysResumed)
- {
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED);
- Error ("INPLACE_ENC_GENERIC_ERR_RESUME", hwndDlg);
- }
- else
- {
- SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_ERROR);
-
- if (bInPlaceDecNonSys)
- Error ("INPLACE_DEC_GENERIC_ERR", hwndDlg);
- else
- ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_GENERIC_ERR_ALT_STEPS", TRUE);
- }
- }
- else if (!Silent && !(bHiddenVolHost && hiddenVolHostDriveNo < 0)) // If the error was not that the hidden volume host could not be mounted (this error has already been reported to the user)
- {
- StringCbPrintfW (szMsg, sizeof(szMsg), GetString ("CREATE_FAILED"), szDiskFile);
- MessageBoxW (hwndDlg, szMsg, lpszTitle, ICON_HAND);
- }
-
- if (!bDevice && !(bHiddenVol && !bHiddenVolHost)) // If we're not creating a hidden volume and if it's a file container
- {
- _wremove (szDiskFile); // Delete the container
- }
-
- goto cancel;
- }
- else
- {
- /* Volume successfully created */
-
- RestoreDefaultKeyFilesParam ();
-
- PimEnable = FALSE;
-
- bOperationSuccess = TRUE;
-
- if (bDevice && !bInPlaceEncNonSys)
- {
- // Handle assigned drive letter (if any)
-
- HandleOldAssignedDriveLetter ();
- }
-
- if (!bHiddenVolHost)
- {
- if (bHiddenVol)
- {
- bHiddenVolFinished = TRUE;
-
- if (!bHiddenOS)
- Warning ("HIDVOL_FORMAT_FINISHED_HELP", hwndDlg);
- }
- else if (bInPlaceEncNonSys)
- {
- if (!bInPlaceDecNonSys)
- {
- Warning ("NONSYS_INPLACE_ENC_FINISHED_INFO", hwndDlg);
-
- HandleOldAssignedDriveLetter ();
- }
- else
- {
- // NOP - Final steps for in-place decryption are handled with the TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED message.
- }
- }
- else
- {
- Info("FORMAT_FINISHED_INFO", hwndDlg);
-
- if (bSparseFileSwitch && quickFormat)
- Warning("SPARSE_FILE_SIZE_NOTE", hwndDlg);
- }
- }
- else
- {
- /* We've just created an outer volume (to host a hidden volume within) */
-
- bHiddenVolHost = FALSE;
- bHiddenVolFinished = FALSE;
- nHiddenVolHostSize = nVolumeSize;
-
- // Clear the outer volume password
- burn(&szVerify[0], sizeof (szVerify));
- burn(&szRawPassword[0], sizeof (szRawPassword));
-
- if (!Silent) MessageBeep (MB_OK);
- }
-
- if (!bInPlaceEncNonSys && hwndDlg && bGuiMode)
- SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
-
-
- // volParams is ensured to be non NULL at this stage
- burn ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
- VirtualUnlock ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
- free ((LPVOID) volParams);
- volParams = NULL;
-
- if (bGuiMode)
- {
- bVolTransformThreadRunning = FALSE;
- bVolTransformThreadCancel = FALSE;
- }
-
- if (hwndDlg && bGuiMode) PostMessage (hwndDlg, bInPlaceEncNonSys ? TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED : TC_APPMSG_FORMAT_FINISHED, 0, 0);
-
- LastDialogId = "FORMAT_FINISHED";
- if (bGuiMode) _endthread ();
- }
- }
-
-cancel:
-
- LastDialogId = (bInPlaceEncNonSys ? "NONSYS_INPLACE_ENC_CANCELED" : "FORMAT_CANCELED");
-
- if (!bInPlaceEncNonSys && hwndDlg && bGuiMode)
- SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
-
- if (volParams != NULL)
- {
- burn ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
- VirtualUnlock ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
- free ((LPVOID) volParams);
- volParams = NULL;
- }
-
- if (bGuiMode)
- {
- bVolTransformThreadRunning = FALSE;
- bVolTransformThreadCancel = FALSE;
- }
-
- // Allow the OS to enter Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS);
-
- if (hwndDlg) PostMessage (hwndDlg, TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED, 0, 0);
-
- if (bHiddenVolHost && hiddenVolHostDriveNo < -1 && !bVolTransformThreadCancel) // If hidden volume host could not be mounted
- AbortProcessSilent ();
-
- if (bGuiMode) _endthread ();
-}
-
-static void LoadPage (HWND hwndDlg, int nPageNo)
-{
- RECT rD, rW;
-
- nLastPageNo = nCurPageNo;
-
- if (hCurPage != NULL)
- {
- // WARNING: nCurPageNo must be set to a non-existent ID here before wiping the password fields below in
- // this function, etc. Otherwise, such actions (SetWindowText) would invoke the EN_CHANGE handlers, which
- // would, if keyfiles were applied, e.g. use strlen() on a buffer full of random data, in most cases
- // not null-terminated.
- nCurPageNo = -1;
-
-
- // Place here any actions that need to be performed at the latest possible time when leaving a wizard page
- // (i.e. right before "destroying" the page). Also, code that needs to be executed both on IDC_NEXT and
- // on IDC_PREV can be placed here so as to avoid code doubling.
-
- switch (nLastPageNo)
- {
- case PASSWORD_PAGE:
- {
- wchar_t tmp[MAX_PASSWORD+1];
-
- // Attempt to wipe passwords stored in the input field buffers. This is performed here (and
- // not in the IDC_PREV or IDC_NEXT sections) in order to prevent certain race conditions
- // when keyfiles are used.
- wmemset (tmp, 'X', MAX_PASSWORD);
- tmp [MAX_PASSWORD] = 0;
- SetWindowText (hPasswordInputField, tmp);
- SetWindowText (hVerifyPasswordInputField, tmp);
- }
- break;
- }
-
- DestroyWindow (hCurPage);
- hCurPage = NULL;
- }
-
- // This prevents the mouse pointer from remaining as the "hand" cursor when the user presses Enter
- // while hovering over a hyperlink.
- bHyperLinkBeingTracked = FALSE;
- NormalCursor();
-
- GetWindowRect (GetDlgItem (hwndDlg, IDC_POS_BOX), &rW);
-
-
- nCurPageNo = nPageNo;
-
-
- switch (nPageNo)
- {
- case INTRO_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INTRO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_TYPE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_TYPE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_HIDDEN_OS_REQ_CHECK_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_SPAN_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_SPAN_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_PRE_DRIVE_ANALYSIS_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_DRIVE_ANALYSIS_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_DRIVE_ANALYSIS_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_MULTI_BOOT_MODE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_MULTI_BOOT_MODE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE:
- case SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_PAGE:
- case SYSENC_MULTI_BOOT_ADJACENT_SYS_PAGE:
- case SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_MULTI_BOOT_OUTCOME_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case VOLUME_TYPE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_VOLUME_TYPE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case HIDDEN_VOL_WIZARD_MODE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_HIDDEN_VOL_WIZARD_MODE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case VOLUME_LOCATION_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_VOLUME_LOCATION_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
-
- EnableWindow (GetDlgItem(hCurPage, IDC_NO_HISTORY), !bHistoryCmdLine);
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT),
- GetWindowTextLength (GetDlgItem (hCurPage, IDC_COMBO_BOX)) > 0);
-
- break;
-
- case DEVICE_TRANSFORM_MODE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_DEVICE_TRANSFORM_MODE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case HIDDEN_VOL_HOST_PRE_CIPHER_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case HIDDEN_VOL_PRE_CIPHER_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case CIPHER_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_CIPHER_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SIZE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SIZE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case HIDDEN_VOL_HOST_PASSWORD_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PASSWORD_ENTRY_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case PASSWORD_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PASSWORD_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case PIM_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PIM_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case FILESYS_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_UNIVERSAL_DUAL_CHOICE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_COLLECTING_RANDOM_DATA_PAGE:
- case NONSYS_INPLACE_ENC_RAND_DATA_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_KEYS_GEN_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_KEYS_GEN_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_RESCUE_DISK_CREATION_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_RESCUE_DISK_CREATION_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_RESCUE_DISK_BURN_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_RESCUE_DISK_VERIFIED_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_WIPE_MODE_PAGE:
- case NONSYS_INPLACE_ENC_WIPE_MODE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_SYSENC_WIPE_MODE_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_PRETEST_INFO_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_PRETEST_RESULT_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case SYSENC_ENCRYPTION_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INPLACE_ENCRYPTION_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PASSWORD_ENTRY_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case NONSYS_INPLACE_ENC_RESUME_PARTITION_SEL_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_EXPANDED_LIST_SELECT_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case NONSYS_INPLACE_ENC_TRANSFORM_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INPLACE_ENCRYPTION_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case NONSYS_INPLACE_DEC_TRANSFORM_FINISHED_DRIVE_LETTER_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_DRIVE_LETTER_SELECTION_PAGE), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case FORMAT_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_FORMAT_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
- case FORMAT_FINISHED_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW ((bHiddenVol && !bHiddenVolHost && !bHiddenVolFinished) ? IDD_HIDVOL_HOST_FILL_PAGE_DLG : IDD_INFO_PAGE_DLG), hwndDlg,
- (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_HIDDEN_OS_INITIAL_INFO_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg, (DLGPROC) PageDialogProc);
- break;
-
- case SYSENC_HIDDEN_OS_WIPE_INFO_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INFO_PAGE_DLG), hwndDlg, (DLGPROC) PageDialogProc);
- break;
-
- case DEVICE_WIPE_MODE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_DEVICE_WIPE_MODE_PAGE_DLG), hwndDlg, (DLGPROC) PageDialogProc);
- break;
-
- case DEVICE_WIPE_PAGE:
- hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_DEVICE_WIPE_PAGE_DLG), hwndDlg, (DLGPROC) PageDialogProc);
- break;
- }
-
- rD.left = 162;
- rD.top = 25;
- rD.right = 0;
- rD.bottom = 0;
- MapDialogRect (hwndDlg, &rD);
-
- if (hCurPage != NULL)
- {
- MoveWindow (hCurPage, rD.left, rD.top, rW.right - rW.left, rW.bottom - rW.top, TRUE);
- ShowWindow (hCurPage, SW_SHOWNORMAL);
-
- // Place here any message boxes that need to be displayed as soon as a new page is displayed. This
- // ensures that the page is fully rendered (otherwise it would remain blank, until the message box
- // is closed).
- switch (nPageNo)
- {
- case PASSWORD_PAGE:
-
- CheckCapsLock (hwndDlg, FALSE);
-
- if (CreatingHiddenSysVol())
- Warning ("PASSWORD_HIDDEN_OS_NOTE", MainDlg);
-
- break;
-
- case CIPHER_PAGE:
-
- if (CreatingHiddenSysVol())
- Warning ("HIDDEN_OS_PRE_CIPHER_WARNING", MainDlg);
-
- break;
- }
- }
-}
-
-
-__int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDiskFree)
-{
- char *nResourceString;
- __int64 nMultiplier;
- wchar_t szTmp2[256];
-
- if (lDiskFree->QuadPart < BYTES_PER_KB)
- nMultiplier = 1;
- else if (lDiskFree->QuadPart < BYTES_PER_MB)
- nMultiplier = BYTES_PER_KB;
- else if (lDiskFree->QuadPart < BYTES_PER_GB)
- nMultiplier = BYTES_PER_MB;
- else if (lDiskFree->QuadPart < BYTES_PER_TB)
- nMultiplier = BYTES_PER_GB;
- else
- nMultiplier = BYTES_PER_TB;
-
- if (nMultiplier == 1)
- {
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- nResourceString = "MAX_HIDVOL_SIZE_BYTES";
- else if (bDevice)
- nResourceString = "DEVICE_FREE_BYTES";
- else
- nResourceString = "DISK_FREE_BYTES";
- }
- else if (nMultiplier == BYTES_PER_KB)
- {
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- nResourceString = "MAX_HIDVOL_SIZE_KB";
- else if (bDevice)
- nResourceString = "DEVICE_FREE_KB";
- else
- nResourceString = "DISK_FREE_KB";
- }
- else if (nMultiplier == BYTES_PER_MB)
- {
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- nResourceString = "MAX_HIDVOL_SIZE_MB";
- else if (bDevice)
- nResourceString = "DEVICE_FREE_MB";
- else
- nResourceString = "DISK_FREE_MB";
- }
- else if (nMultiplier == BYTES_PER_GB)
- {
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- nResourceString = "MAX_HIDVOL_SIZE_GB";
- else if (bDevice)
- nResourceString = "DEVICE_FREE_GB";
- else
- nResourceString = "DISK_FREE_GB";
- }
- else
- {
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- nResourceString = "MAX_HIDVOL_SIZE_TB";
- else if (bDevice)
- nResourceString = "DEVICE_FREE_TB";
- else
- nResourceString = "DISK_FREE_TB";
- }
-
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- {
- StringCbPrintfW (szTmp2, sizeof szTmp2, GetString (nResourceString), ((double) lDiskFree->QuadPart) / nMultiplier);
- SetWindowTextW (GetDlgItem (hwndTextBox, IDC_SIZEBOX), szTmp2);
- }
- else if (lpszDrive)
- StringCbPrintfW (szTmp2, sizeof szTmp2, GetString (nResourceString), lpszDrive, ((double) lDiskFree->QuadPart) / nMultiplier);
- else
- szTmp2 [0] = 0;
-
- SetWindowTextW (hwndTextBox, szTmp2);
-
- if (lDiskFree->QuadPart % (__int64) BYTES_PER_MB != 0)
- nMultiplier = BYTES_PER_KB;
-
- return nMultiplier;
-}
-
-void DisplaySizingErrorText (HWND hwndTextBox)
-{
- wchar_t szTmp[1024];
-
- if (translateWin32Error (szTmp, sizeof (szTmp) / sizeof(szTmp[0])))
- {
- wchar_t szTmp2[1024];
- StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s\n%s", GetString ("CANNOT_CALC_SPACE"), szTmp);
- SetWindowTextW (hwndTextBox, szTmp2);
- }
- else
- {
- SetWindowText (hwndTextBox, L"");
- }
-}
-
-void EnableDisableFileNext (HWND hComboBox, HWND hMainButton)
-{
- int nIndex = (int) SendMessage (hComboBox, CB_GETCURSEL, 0, 0);
- if (bHistory && nIndex == CB_ERR)
- {
- EnableWindow (hMainButton, FALSE);
- SetFocus (hComboBox);
- }
- else
- {
- EnableWindow (hMainButton, TRUE);
- SetFocus (hMainButton);
- }
-}
-
-// Returns TRUE if the file is a sparse file. If it's not a sparse file or in case of any error, returns FALSE.
-BOOL IsSparseFile (HWND hwndDlg)
-{
- HANDLE hFile;
- BY_HANDLE_FILE_INFORMATION bhFileInfo;
-
- FILETIME ftLastAccessTime;
- BOOL bTimeStampValid = FALSE;
-
- BOOL retCode = FALSE;
-
- hFile = CreateFile (szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
-
- if (hFile == INVALID_HANDLE_VALUE)
- {
- MessageBoxW (hwndDlg, GetString ("CANT_ACCESS_VOL"), lpszTitle, ICON_HAND);
- return FALSE;
- }
-
- if (bPreserveTimestamp)
- {
- if (GetFileTime (hFile, NULL, &ftLastAccessTime, NULL) == 0)
- bTimeStampValid = FALSE;
- else
- bTimeStampValid = TRUE;
- }
-
- bhFileInfo.dwFileAttributes = 0;
-
- GetFileInformationByHandle(hFile, &bhFileInfo);
-
- retCode = bhFileInfo.dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE;
-
- if (bTimeStampValid)
- SetFileTime (hFile, NULL, &ftLastAccessTime, NULL);
-
- CloseHandle (hFile);
- return retCode;
-}
-
-
-// Note: GetFileVolSize is not to be used for devices (only for file-hosted volumes)
-BOOL GetFileVolSize (HWND hwndDlg, unsigned __int64 *size)
-{
- LARGE_INTEGER fileSize;
- HANDLE hFile;
-
- FILETIME ftLastAccessTime;
- BOOL bTimeStampValid = FALSE;
-
- hFile = CreateFile (szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
-
- if (hFile == INVALID_HANDLE_VALUE)
- {
- MessageBoxW (hwndDlg, GetString ("CANT_ACCESS_VOL"), lpszTitle, ICON_HAND);
- return FALSE;
- }
-
- if (bPreserveTimestamp)
- {
- if (GetFileTime (hFile, NULL, &ftLastAccessTime, NULL) == 0)
- bTimeStampValid = FALSE;
- else
- bTimeStampValid = TRUE;
- }
-
- if (GetFileSizeEx(hFile, &fileSize) == 0)
- {
- MessageBoxW (hwndDlg, GetString ("CANT_GET_VOLSIZE"), lpszTitle, ICON_HAND);
-
- if (bTimeStampValid)
- SetFileTime (hFile, NULL, &ftLastAccessTime, NULL);
-
- CloseHandle (hFile);
- return FALSE;
- }
-
- if (bTimeStampValid)
- SetFileTime (hFile, NULL, &ftLastAccessTime, NULL);
-
- CloseHandle (hFile);
- *size = fileSize.QuadPart;
- return TRUE;
-}
-
-
-BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display)
-{
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- {
- LARGE_INTEGER lDiskFree;
-
- lDiskFree.QuadPart = nMaximumHiddenVolSize;
-
- if (display)
- PrintFreeSpace (hwndTextBox, NULL, &lDiskFree);
-
- return TRUE;
- }
- else if (bDevice == FALSE)
- {
- wchar_t root[TC_MAX_PATH];
- ULARGE_INTEGER free;
-
- if (!GetVolumePathName (szFileName, root, ARRAYSIZE (root)))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- return FALSE;
- }
-
- if (!GetDiskFreeSpaceEx (root, &free, 0, 0))
- {
- if (display)
- DisplaySizingErrorText (hwndTextBox);
-
- return FALSE;
- }
- else
- {
- LARGE_INTEGER lDiskFree;
- lDiskFree.QuadPart = free.QuadPart;
-
- if (display)
- PrintFreeSpace (hwndTextBox, root, &lDiskFree);
-
- return TRUE;
- }
- }
- else
- {
- DISK_GEOMETRY driveInfo;
- PARTITION_INFORMATION diskInfo;
- BOOL piValid = FALSE;
- BOOL gValid = FALSE;
-
- // Query partition size
- piValid = GetPartitionInfo (szDiskFile, &diskInfo);
- gValid = GetDriveGeometry (szDiskFile, &driveInfo);
-
- if (!piValid && !gValid)
- {
- if (display)
- DisplaySizingErrorText (hwndTextBox);
-
- return FALSE;
- }
-
- DWORD sectorSize = GetFormatSectorSize();
-
- if (sectorSize < TC_MIN_VOLUME_SECTOR_SIZE
- || sectorSize > TC_MAX_VOLUME_SECTOR_SIZE
- || sectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
- {
- Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg);
- return FALSE;
- }
-
- if (piValid)
- {
- nVolumeSize = diskInfo.PartitionLength.QuadPart;
-
- if(display)
- nMultiplier = PrintFreeSpace (hwndTextBox, szDiskFile, &diskInfo.PartitionLength);
-
- nUIVolumeSize = diskInfo.PartitionLength.QuadPart / nMultiplier;
-
- if (nVolumeSize == 0)
- {
- if (display)
- SetWindowTextW (hwndTextBox, GetString ("EXT_PARTITION"));
-
- return FALSE;
- }
- }
- else
- {
- LARGE_INTEGER lDiskFree;
-
- // Drive geometry info is used only when GetPartitionInfo() fails
- lDiskFree.QuadPart = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector *
- driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder;
-
- nVolumeSize = lDiskFree.QuadPart;
-
- if (display)
- nMultiplier = PrintFreeSpace (hwndTextBox, szDiskFile, &lDiskFree);
-
- nUIVolumeSize = lDiskFree.QuadPart / nMultiplier;
- }
-
- return TRUE;
- }
-}
-
-
-static BOOL FinalPreTransformPrompts (void)
-{
- int x;
- wchar_t szTmp[4096];
- int driveNo;
- WCHAR deviceName[MAX_PATH];
-
- StringCbCopyW (deviceName, sizeof(deviceName), szFileName);
-
- driveNo = GetDiskDeviceDriveLetter (deviceName);
-
- if (!bForceOperation && !(bHiddenVol && !bHiddenVolHost)) // Do not ask for permission to overwrite an existing volume if we're creating a hidden volume within it
- {
- wchar_t drive[128];
- wchar_t volumeLabel[128];
- wchar_t *type;
- BOOL bTmpIsPartition = FALSE;
-
- type = GetPathType (szFileName, !bInPlaceEncNonSys, &bTmpIsPartition);
-
- if (driveNo != -1)
- {
- if (!GetDriveLabel (driveNo, volumeLabel, sizeof (volumeLabel)))
- volumeLabel[0] = 0;
-
- StringCbPrintfW (drive, sizeof (drive), volumeLabel[0] ? L" (%hc: '%s')" : L" (%hc:%s)", 'A' + driveNo, volumeLabel[0] ? volumeLabel : L"");
- }
- else
- {
- drive[0] = 0;
- volumeLabel[0] = 0;
- }
-
- if (bHiddenOS && bHiddenVolHost)
- StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("OVERWRITEPROMPT_DEVICE_HIDDEN_OS_PARTITION"), szFileName, drive);
- else
- StringCbPrintfW (szTmp, sizeof(szTmp), GetString (bInPlaceEncNonSys ? (bInPlaceDecNonSys ? "NONSYS_INPLACE_DEC_CONFIRM" : "NONSYS_INPLACE_ENC_CONFIRM") : "OVERWRITEPROMPT_DEVICE"), type, szFileName, drive);
-
- if (bInPlaceEncNonSys)
- x = AskWarnYesNoString (szTmp, MainDlg);
- else
- x = AskWarnNoYesString (szTmp, MainDlg);
-
- if (x != IDYES)
- return FALSE;
-
-
- if (driveNo != -1 && bTmpIsPartition && !bInPlaceEncNonSys)
- {
- float percentFreeSpace = 100.0;
- __int64 occupiedBytes = 0;
-
- // Do a second check. If we find that the partition contains more than 1GB of data or more than 12%
- // of its space is occupied, we will display an extra warning, however, this time it won't be a Yes/No
- // dialog box (because users often ignore such dialog boxes).
-
- if (GetStatsFreeSpaceOnPartition (szFileName, &percentFreeSpace, &occupiedBytes, TRUE) != -1)
- {
- if (occupiedBytes > BYTES_PER_GB && percentFreeSpace < 99.99 // "percentFreeSpace < 99.99" is needed because an NTFS filesystem larger than several terabytes can have more than 1GB of data in use, even if there are no files stored on it.
- || percentFreeSpace < 88) // A 24-MB NTFS filesystem has 11.5% of space in use even if there are no files stored on it.
- {
- wchar_t tmpMcMsg [8000];
- wchar_t tmpMcOption1 [500];
- wchar_t tmpMcOptionCancel [50];
-
- StringCbCopyW (tmpMcMsg, sizeof(tmpMcMsg), GetString("OVERWRITEPROMPT_DEVICE_SECOND_WARNING_LOTS_OF_DATA"));
- StringCbCopyW (tmpMcOption1, sizeof(tmpMcOption1), GetString("ERASE_FILES_BY_CREATING_VOLUME"));
- StringCbCopyW (tmpMcOptionCancel, sizeof(tmpMcOptionCancel), GetString("CANCEL"));
-
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), L"\n\n");
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), GetString("DRIVE_LETTER_ITEM"));
- StringCbPrintfW (szTmp, sizeof (szTmp), L"%hc:", 'A' + driveNo);
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), szTmp);
-
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), L"\n");
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), GetString("LABEL_ITEM"));
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), volumeLabel[0] != 0 ? volumeLabel : GetString("NOT_APPLICABLE_OR_NOT_AVAILABLE"));
-
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), L"\n");
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), GetString("SIZE_ITEM"));
- GetSizeString (nVolumeSize, szTmp, sizeof(szTmp));
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), szTmp);
-
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), L"\n");
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), GetString("PATH_ITEM"));
- StringCbCatW (tmpMcMsg, sizeof(tmpMcMsg), deviceName);
-
- wchar_t *tmpStr[] = {L"", tmpMcMsg, tmpMcOption1, tmpMcOptionCancel, 0};
- switch (AskMultiChoice ((void **) tmpStr, TRUE, MainDlg))
- {
- case 1:
- // Proceed
-
- // NOP
- break;
-
- default:
- return FALSE;
- }
- }
- }
- }
- }
- return TRUE;
-}
-
-void UpdateLastDialogId (void)
-{
- static char PageDebugId[128];
-
- StringCbPrintfA (PageDebugId, sizeof(PageDebugId), "FORMAT_PAGE_%d", nCurPageNo);
- LastDialogId = PageDebugId;
-}
-
-
-void HandleOldAssignedDriveLetter (void)
-{
- if (bDevice)
- {
- // Handle assigned drive letter (if any)
-
- WCHAR deviceName[MAX_PATH];
- int driveLetter = -1;
-
- StringCbCopyW (deviceName, sizeof(deviceName), szDiskFile);
- driveLetter = GetDiskDeviceDriveLetter (deviceName);
-
- if (!Silent && !bHiddenVolHost
- && !bHiddenOS
- && driveLetter >= 0)
- {
- wchar_t rootPath[] = { (wchar_t) driveLetter + L'A', L':', L'\\', 0 };
- wchar_t szTmp[8192];
-
- StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("AFTER_FORMAT_DRIVE_LETTER_WARN"), rootPath[0], rootPath[0], rootPath[0], rootPath[0]);
- MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING);
- }
- }
-}
-
-
-// Returns TRUE if it makes sense to ask the user whether he wants to store files larger than 4GB in the volume.
-static BOOL FileSize4GBLimitQuestionNeeded (void)
-{
- uint64 dataAreaSize = GetVolumeDataAreaSize (bHiddenVol && !bHiddenVolHost, nVolumeSize);
-
- return (dataAreaSize > 4 * BYTES_PER_GB + TC_MIN_FAT_FS_SIZE
- && dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize());
-}
-
-
-/* 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
- not. - see DialogProc */
-BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- WORD lw = LOWORD (wParam);
- WORD hw = HIWORD (wParam);
- static BOOL PimValueChangedWarning = FALSE;
-
- hCurPage = hwndDlg;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- PimValueChangedWarning = FALSE;
- LocalizeDialog (hwndDlg, "IDD_VOL_CREATION_WIZARD_DLG");
-
- burn (randPool, sizeof(randPool));
- burn (lastRandPool, sizeof(lastRandPool));
- burn (maskRandPool, sizeof (maskRandPool));
-
- UpdateLastDialogId ();
-
- switch (nCurPageNo)
- {
- case INTRO_PAGE:
-
- SendMessage (GetDlgItem (hwndDlg, IDC_FILE_CONTAINER), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_NONSYS_DEVICE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_SYS_DEVICE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("INTRO_TITLE"));
-
- ToHyperlink (hwndDlg, IDC_MORE_INFO_ON_CONTAINERS);
- ToHyperlink (hwndDlg, IDC_MORE_INFO_ON_SYS_ENCRYPTION);
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_STD_VOL), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_HIDDEN_VOL), TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
-
- UpdateWizardModeControls (hwndDlg, WizardMode);
- break;
-
- case SYSENC_TYPE_PAGE:
-
- bHiddenVolHost = bHiddenVol = bHiddenOS;
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_TYPE_PAGE_TITLE"));
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_HIDDEN), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_NORMAL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- CheckButton (GetDlgItem (hwndDlg, bHiddenOS ? IDC_SYSENC_HIDDEN : IDC_SYSENC_NORMAL));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_HIDDEN_TYPE_HELP"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP_SYSENC_NORMAL), GetString ("SYSENC_NORMAL_TYPE_HELP"));
-
- ToHyperlink (hwndDlg, IDC_HIDDEN_SYSENC_INFO_LINK);
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bDirectSysEncMode);
-
- SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
- break;
-
- case SYSENC_HIDDEN_OS_REQ_CHECK_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_HELP"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), bDirectSysEncModeCommand != SYSENC_COMMAND_CREATE_HIDDEN_OS && bDirectSysEncModeCommand != SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV);
-
- ToHyperlink (hwndDlg, IDC_HIDDEN_SYSENC_INFO_LINK);
- break;
-
- case SYSENC_SPAN_PAGE:
-
- SendMessage (GetDlgItem (hwndDlg, IDC_WHOLE_SYS_DRIVE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_SYS_PARTITION), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYS_ENCRYPTION_SPAN_TITLE"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDT_WHOLE_SYS_DRIVE), GetString ("SYS_ENCRYPTION_SPAN_WHOLE_SYS_DRIVE_HELP"));
-
- CheckButton (GetDlgItem (hwndDlg, bWholeSysDrive ? IDC_WHOLE_SYS_DRIVE : IDC_SYS_PARTITION));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- break;
-
-
- case SYSENC_PRE_DRIVE_ANALYSIS_PAGE:
-
- Init2RadButtonPageYesNo (SysEncDetectHiddenSectors);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_PRE_DRIVE_ANALYSIS_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_PRE_DRIVE_ANALYSIS_HELP"));
- break;
-
-
- case SYSENC_DRIVE_ANALYSIS_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_DRIVE_ANALYSIS_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDT_SYSENC_DRIVE_ANALYSIS_INFO), GetString ("SYSENC_DRIVE_ANALYSIS_INFO"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), FALSE);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (MainDlg, IDCANCEL), FALSE);
-
- LoadSettings (hwndDlg);
-
- if (HiddenSectorDetectionStatus == 1)
- {
- // Detection of hidden sectors was already in progress but it did not finish successfully.
- // Ask the user if he wants to try again (to prevent repeated system freezing, etc.)
-
- char *tmpStr[] = {0, "HIDDEN_SECTOR_DETECTION_FAILED_PREVIOUSLY", "SKIP_HIDDEN_SECTOR_DETECTION", "RETRY_HIDDEN_SECTOR_DETECTION", "IDC_EXIT", 0};
- switch (AskMultiChoice ((void **) tmpStr, FALSE, MainDlg))
- {
- case 1:
- // Do not try again
- LoadPage (MainDlg, SYSENC_DRIVE_ANALYSIS_PAGE + 1);
- return 0;
-
- case 2:
- // Try again
- break;
-
- default:
- EndMainDlg (MainDlg);
- return 0;
- }
- }
-
- SetTimer (MainDlg, TIMER_ID_SYSENC_DRIVE_ANALYSIS_PROGRESS, TIMER_INTERVAL_SYSENC_DRIVE_ANALYSIS_PROGRESS, NULL);
- bSysEncDriveAnalysisInProgress = TRUE;
- ArrowWaitCursor ();
- SysEncDriveAnalysisStart = GetTickCount ();
- InitProgressBar (SYSENC_DRIVE_ANALYSIS_ETA, 0, FALSE, FALSE, FALSE, TRUE);
-
- _beginthread (sysEncDriveAnalysisThread, 0, hwndDlg);
-
- break;
-
-
- case SYSENC_MULTI_BOOT_MODE_PAGE:
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SINGLE_BOOT), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_MULTI_BOOT), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYS_MULTI_BOOT_MODE_TITLE"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
-
- RefreshMultiBootControls (hwndDlg);
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), nMultiBoot > 0);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
- break;
-
-
- case SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE:
-
- Init2RadButtonPageYesNo (SysEncMultiBootCfg.SystemOnBootDrive);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_MULTI_BOOT_SYS_EQ_BOOT_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_MULTI_BOOT_SYS_EQ_BOOT_HELP"));
- break;
-
-
- case SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_PAGE:
-
- SetWindowTextW (GetDlgItem (hCurPage, IDC_CHOICE1), GetString ("DIGIT_ONE"));
- SetWindowTextW (GetDlgItem (hCurPage, IDC_CHOICE2), GetString ("TWO_OR_MORE"));
-
- SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), SysEncMultiBootCfg.NumberOfSysDrives > 0);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), TRUE);
-
- if (SysEncMultiBootCfg.NumberOfSysDrives == 2)
- Update2RadButtonPage (0); // 2 or more drives contain an OS
- else if (SysEncMultiBootCfg.NumberOfSysDrives == 1)
- Update2RadButtonPage (1); // Only 1 drive contains an OS
- else
- Update2RadButtonPage (-1);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_HELP"));
- break;
-
-
- case SYSENC_MULTI_BOOT_ADJACENT_SYS_PAGE:
-
- Init2RadButtonPageYesNo (SysEncMultiBootCfg.MultipleSystemsOnDrive);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_MULTI_BOOT_ADJACENT_SYS_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_MULTI_BOOT_ADJACENT_SYS_HELP"));
- break;
-
-
- case SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE:
-
- Init2RadButtonPageYesNo (SysEncMultiBootCfg.BootLoaderBrand);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_HELP"));
- break;
-
-
- case SYSENC_MULTI_BOOT_OUTCOME_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_MULTI_BOOT_OUTCOME_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), SysEncMultiBootCfgOutcome);
- SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), TRUE);
- break;
-
-
- case VOLUME_TYPE_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("VOLUME_TYPE_TITLE"));
-
- SendMessage (GetDlgItem (hwndDlg, IDC_HIDDEN_VOL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_STD_VOL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- CheckButton (GetDlgItem (hwndDlg, bHiddenVol ? IDC_HIDDEN_VOL : IDC_STD_VOL));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("HIDDEN_VOLUME_TYPE_HELP"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP_NORMAL_VOL), GetString ("NORMAL_VOLUME_TYPE_HELP"));
-
- ToHyperlink (hwndDlg, IDC_HIDDEN_VOL_HELP);
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
- break;
-
- case HIDDEN_VOL_WIZARD_MODE_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("HIDDEN_VOL_WIZARD_MODE_TITLE"));
-
- SendMessage (GetDlgItem (hwndDlg, IDC_HIDVOL_WIZ_MODE_DIRECT), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_HIDVOL_WIZ_MODE_FULL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- CheckButton (GetDlgItem (hwndDlg, bHiddenVolDirect ? IDC_HIDVOL_WIZ_MODE_DIRECT : IDC_HIDVOL_WIZ_MODE_FULL));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("HIDDEN_VOL_WIZARD_MODE_NORMAL_HELP"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString ("HIDDEN_VOL_WIZARD_MODE_DIRECT_HELP"));
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_HIDVOL_WIZ_MODE_DIRECT), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_HIDVOL_WIZ_MODE_FULL), TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- break;
-
- case VOLUME_LOCATION_PAGE:
- {
- char *nID;
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_SELECT_VOLUME_LOCATION),
- GetString (bDevice ? "IDC_SELECT_DEVICE" : "IDC_SELECT_FILE"));
-
- if (bHiddenVolDirect && bHiddenVolHost)
- {
- nID = "FILE_HELP_HIDDEN_HOST_VOL_DIRECT";
- }
- else
- {
- if (bDevice)
- nID = bHiddenVolHost ? "DEVICE_HELP_HIDDEN_HOST_VOL" : "DEVICE_HELP";
- else
- nID = bHiddenVolHost ? "FILE_HELP_HIDDEN_HOST_VOL" : "FILE_HELP";
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_LIMITTEXT, TC_MAX_PATH, 0);
-
- LoadCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), bHistory, FALSE, NULL);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_NO_HISTORY), BM_SETCHECK, bHistory ? BST_UNCHECKED : BST_CHECKED, 0);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("FILE_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (nID));
-
- SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- AddComboItem (GetDlgItem (hwndDlg, IDC_COMBO_BOX), szFileName, bHistory);
-
- EnableDisableFileNext (GetDlgItem (hwndDlg, IDC_COMBO_BOX),
- GetDlgItem (GetParent (hwndDlg), IDC_NEXT));
-
- }
- break;
-
- case DEVICE_TRANSFORM_MODE_PAGE:
-
- if (!bDeviceTransformModeChoiceMade && !bInPlaceEncNonSys)
- {
- // The user has not chosen whether to perform in-place encryption or format yet.
- // We will preselect in-place encryption if the requirements are met and if the
- // filesystem does not appear empty.
-
- WaitCursor();
-
- if (CheckRequirementsForNonSysInPlaceEnc (hwndDlg, szDiskFile, TRUE))
- {
- bInPlaceEncNonSys = (FileSystemAppearsEmpty (szDiskFile) == 0);
- }
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("DEVICE_TRANSFORM_MODE_PAGE_TITLE"));
-
- SendMessage (GetDlgItem (hwndDlg, IDC_DEVICE_TRANSFORM_MODE_INPLACE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_DEVICE_TRANSFORM_MODE_FORMAT), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("DEVICE_TRANSFORM_MODE_PAGE_FORMAT_HELP"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString ("DEVICE_TRANSFORM_MODE_PAGE_INPLACE_HELP"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- CheckButton (GetDlgItem (hwndDlg, bInPlaceEncNonSys ? IDC_DEVICE_TRANSFORM_MODE_INPLACE : IDC_DEVICE_TRANSFORM_MODE_FORMAT));
-
- NormalCursor();
-
- break;
-
- case HIDDEN_VOL_HOST_PRE_CIPHER_PAGE:
- {
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("HIDVOL_HOST_PRE_CIPHER_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bHiddenOS ? "HIDVOL_HOST_PRE_CIPHER_HELP_SYSENC" : "HIDVOL_HOST_PRE_CIPHER_HELP"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- if (bHiddenOS)
- {
- if (!GetDevicePathForHiddenOS())
- AbortProcess ("INVALID_PATH");
- }
- }
- break;
-
- case HIDDEN_VOL_PRE_CIPHER_PAGE:
- {
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("HIDVOL_PRE_CIPHER_TITLE"));
-
- if (bHiddenOS)
- {
- // Verify whether the clone of the OS fits in the hidden volume (the hidden
- // volume is to host a hidden OS).
- if (nMaximumHiddenVolSize - TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE_HIGH < GetSystemPartitionSize())
- {
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("HIDDEN_VOLUME_TOO_SMALL_FOR_OS_CLONE"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("EXIT"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
-
- bConfirmQuit = FALSE;
- bConfirmQuitSysEncPretest = FALSE;
- }
- else
- {
- // The hidden volume must be as large as the system partition
- nVolumeSize = GetSystemPartitionSize() + TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE_HIGH;
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("HIDDEN_OS_PRE_CIPHER_HELP"));
- }
- }
- else
- {
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("HIDVOL_PRE_CIPHER_HELP"));
- }
- }
- break;
-
- case CIPHER_PAGE:
- {
- int ea, hid;
- wchar_t buf[100];
-
- // Encryption algorithms
-
- SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0);
-
- if (bHiddenVol)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "CIPHER_HIDVOL_HOST_TITLE" : "CIPHER_HIDVOL_TITLE"));
- else
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CIPHER_TITLE"));
-
- for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea))
- {
- if (EAIsFormatEnabled (ea))
- AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX), EAGetName (buf, ea, 1), ea);
- }
-
- SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), &nVolumeEA);
- ComboSelChangeEA (hwndDlg);
- SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX));
-
- ToHyperlink (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER);
-
- // Hash algorithms
-
- if (SysEncInEffect ())
- {
- hash_algo = DEFAULT_HASH_ALGORITHM_BOOT;
- RandSetHashFunction (hash_algo);
-
- for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
- {
- // For now, we keep RIPEMD160 for system encryption
- if (((hid == RIPEMD160) || !HashIsDeprecated (hid)) && HashForSystemEncryption (hid))
- AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid);
- }
- }
- else
- {
- hash_algo = RandGetHashFunction();
- for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
- {
- if (!HashIsDeprecated (hid))
- AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid);
- }
- }
-
- SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo);
-
- ToHyperlink (hwndDlg, IDC_LINK_HASH_INFO);
-
- // Wizard buttons
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- }
- break;
-
- case SIZE_PAGE:
- {
- wchar_t str[1000];
-
- if (bHiddenVolHost)
- {
- StringCbCopyW (str, sizeof(str), GetString ("SIZE_HELP_HIDDEN_HOST_VOL"));
- }
- else
- {
- StringCbCopyW (str, sizeof(str), GetString (bHiddenVol ? "SIZE_HELP_HIDDEN_VOL" : "SIZE_HELP"));
- }
-
- if (bDevice && !(bHiddenVol && !bHiddenVolHost)) // If raw device but not a hidden volume
- {
- StringCbPrintfW (str, sizeof str, L"%s%s",
- GetString ((bHiddenOS && bHiddenVol) ? "SIZE_PARTITION_HIDDEN_SYSENC_HELP" : "SIZE_PARTITION_HELP"),
- (bHiddenVolHost && !bHiddenOS) ? GetString ("SIZE_PARTITION_HIDDEN_VOL_HELP") : L"");
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SPACE_LEFT), WM_SETFONT, (WPARAM) hBoldFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_SIZEBOX), EM_LIMITTEXT, 12, 0);
-
- if(!QueryFreeSpace (hwndDlg, GetDlgItem (hwndDlg, IDC_SPACE_LEFT), TRUE))
- {
- nUIVolumeSize=0;
- nVolumeSize=0;
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_SIZEBOX), GetString ("UNKNOWN"));
- EnableWindow (GetDlgItem (hwndDlg, IDC_SIZEBOX), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_KB), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_MB), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_GB), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_TB), FALSE);
- }
- else if (bDevice && !(bHiddenVol && !bHiddenVolHost)) // If raw device but not a hidden volume
- {
- EnableWindow (GetDlgItem (hwndDlg, IDC_SIZEBOX), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_KB), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_MB), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_GB), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_TB), FALSE);
- }
- else
- {
- EnableWindow (GetDlgItem (hwndDlg, IDC_SIZEBOX), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_KB), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_MB), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_GB), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_TB), TRUE);
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_KB), BM_SETCHECK, BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_MB), BM_SETCHECK, BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_GB), BM_SETCHECK, BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_TB), BM_SETCHECK, BST_UNCHECKED, 0);
-
- switch (nMultiplier)
- {
- case BYTES_PER_KB:
- SendMessage (GetDlgItem (hwndDlg, IDC_KB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- case BYTES_PER_MB:
- SendMessage (GetDlgItem (hwndDlg, IDC_MB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- case BYTES_PER_GB:
- SendMessage (GetDlgItem (hwndDlg, IDC_GB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- case BYTES_PER_TB:
- SendMessage (GetDlgItem (hwndDlg, IDC_TB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- }
-
- if (nUIVolumeSize != 0)
- {
- wchar_t szTmp[32];
- StringCbPrintfW (szTmp, sizeof(szTmp), L"%I64u", nUIVolumeSize);
- SetWindowText (GetDlgItem (hwndDlg, IDC_SIZEBOX), szTmp);
- }
-
- SetFocus (GetDlgItem (hwndDlg, IDC_SIZEBOX));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), str);
-
- if (bHiddenVol)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "SIZE_HIDVOL_HOST_TITLE" : "SIZE_HIDVOL_TITLE"));
- else
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SIZE_TITLE"));
-
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- VerifySizeAndUpdate (hwndDlg, FALSE);
- }
- break;
-
- case HIDDEN_VOL_HOST_PASSWORD_PAGE:
- case NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE:
- {
- /* Populate the PRF algorithms list */
- int nIndex, i;
- HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
- SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
-
- nIndex = (int) SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
- SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
-
- for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
- {
- nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
- SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
- }
-
- /* make autodetection the default */
- SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), EM_LIMITTEXT, MAX_PASSWORD, 0);
-
- SetPassword (hwndDlg, IDC_PASSWORD_DIRECT, szRawPassword);
-
- SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT));
-
- SendMessage (GetDlgItem (hwndDlg, IDC_PIM), EM_LIMITTEXT, MAX_PIM, 0);
- SetPim (hwndDlg, IDC_PIM, volumePim);
-
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_ENABLE), PimEnable? SW_HIDE : SW_SHOW);
- ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), PimEnable? SW_SHOW : SW_HIDE);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), PimEnable? SW_SHOW : SW_HIDE);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), PimEnable? SW_SHOW : SW_HIDE);
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bInPlaceEncNonSys ? (bInPlaceEncNonSysResumed ? "NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE_HELP" : "NONSYS_INPLACE_DEC_PASSWORD_PAGE_HELP") : "PASSWORD_HIDDENVOL_HOST_DIRECT_HELP"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bInPlaceEncNonSys ? "PASSWORD" : "PASSWORD_HIDVOL_HOST_TITLE"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bInPlaceEncNonSys);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- }
-
- break;
-
- case PASSWORD_PAGE:
- {
- wchar_t str[1000];
-
- hPasswordInputField = GetDlgItem (hwndDlg, IDC_PASSWORD);
- hVerifyPasswordInputField = GetDlgItem (hwndDlg, IDC_VERIFY);
-
- if (SysEncInEffect ())
- {
- ToBootPwdField (hwndDlg, IDC_PASSWORD);
- ToBootPwdField (hwndDlg, IDC_VERIFY);
-
- StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
-
- if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409)
- {
- DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
-
- if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
- {
- Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", MainDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
- bKeyboardLayoutChanged = TRUE;
- }
-
-
- if (SetTimer (MainDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0)
- {
- Error ("CANNOT_SET_TIMER", MainDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
- }
-
- if (bHiddenVolHost)
- {
- StringCbCopyW (str, sizeof(str), GetString (bHiddenOS ? "PASSWORD_SYSENC_OUTERVOL_HELP" : "PASSWORD_HIDDENVOL_HOST_HELP"));
- }
- else if (bHiddenVol)
- {
- StringCbPrintfW (str, sizeof str, L"%s%s",
- GetString (bHiddenOS ? "PASSWORD_HIDDEN_OS_HELP" : "PASSWORD_HIDDENVOL_HELP"),
- GetString ("PASSWORD_HELP"));
- }
- else
- {
- StringCbCopyW (str, sizeof(str), GetString ("PASSWORD_HELP"));
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_LIMITTEXT, MAX_PASSWORD, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_VERIFY), EM_LIMITTEXT, MAX_PASSWORD, 0);
-
- SetPassword (hwndDlg, IDC_PASSWORD, szRawPassword);
- SetPassword (hwndDlg, IDC_VERIFY, szVerify);
-
- SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD));
-
- SetCheckBox (hwndDlg, IDC_PIM_ENABLE, PimEnable);
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable && !SysEncInEffect());
- EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), KeyFilesEnable);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), str);
-
- if (CreatingHiddenSysVol())
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_HIDDEN_OS_TITLE"));
- else if (bHiddenVol)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "PASSWORD_HIDVOL_HOST_TITLE" : "PASSWORD_HIDVOL_TITLE"));
- else if (WizardMode == WIZARD_MODE_SYS_DEVICE)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD"));
- else
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_TITLE"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetDlgItem (hwndDlg, IDC_PASSWORD),
- GetDlgItem (hwndDlg, IDC_VERIFY),
- NULL,
- NULL,
- KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect());
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
-
- }
- break;
-
- case PIM_PAGE:
- {
- SendMessage (GetDlgItem (hwndDlg, IDC_PIM), EM_LIMITTEXT, SysEncInEffect()? MAX_BOOT_PIM: MAX_PIM, 0);
- if (volumePim > 0)
- {
- SetPim (hwndDlg, IDC_PIM, volumePim);
-
- PimValueChangedWarning = TRUE;
- SetDlgItemTextW (hwndDlg, IDC_PIM_HELP, GetString (SysEncInEffect ()? "PIM_SYSENC_CHANGE_WARNING" : "PIM_CHANGE_WARNING"));
- }
-
- SetFocus (GetDlgItem (hwndDlg, IDC_PIM));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (SysEncInEffect ()? "PIM_SYSENC_HELP" : "PIM_HELP"));
-
- ToHyperlink (hwndDlg, IDC_LINK_PIM_INFO);
-
- if (CreatingHiddenSysVol())
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PIM_HIDDEN_OS_TITLE"));
- else if (bHiddenVol)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "PIM_HIDVOL_HOST_TITLE" : "PIM_HIDVOL_TITLE"));
- else if (WizardMode == WIZARD_MODE_SYS_DEVICE)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PIM"));
- else
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PIM_TITLE"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- }
- break;
-
- case FILESYS_PAGE:
- {
- wchar_t szTmp[8192];
-
- Init2RadButtonPageYesNo (nNeedToStoreFilesOver4GB);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("FILESYS_PAGE_TITLE"));
-
- StringCbCopyW (szTmp, sizeof(szTmp), GetString ("FILESYS_PAGE_HELP_QUESTION"));
-
- if (bHiddenVolHost)
- StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
- else
- {
- StringCbCatW (szTmp, sizeof(szTmp), L"\n\n\n");
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("NOTE_BEGINNING"));
- }
-
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("FILESYS_PAGE_HELP_EXPLANATION"));
-
- if (bHiddenVolHost)
- {
- StringCbCatW (szTmp, sizeof(szTmp), L" ");
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("FILESYS_PAGE_HELP_EXPLANATION_HIDVOL"));
- }
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), szTmp);
- }
- break;
-
- case SYSENC_COLLECTING_RANDOM_DATA_PAGE:
- case NONSYS_INPLACE_ENC_RAND_DATA_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("COLLECTING_RANDOM_DATA_TITLE"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- mouseEntropyGathered = 0xFFFFFFFF;
- mouseEventsInitialCount = 0;
- bUseMask = FALSE;
- {
- HCRYPTPROV hRngProv;
- if (CryptAcquireContext (&hRngProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
- {
- if (CryptGenRandom (hRngProv, sizeof (maskRandPool), maskRandPool))
- bUseMask = TRUE;
- CryptReleaseContext (hRngProv, 0);
- }
- }
-
- SetTimer (GetParent (hwndDlg), TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
-
- hRandPoolSys = GetDlgItem (hwndDlg, IDC_SYS_POOL_CONTENTS);
- hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR);
- SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel);
- SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SYS_POOL_CONTENTS), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS), BM_SETCHECK, showKeys ? BST_CHECKED : BST_UNCHECKED, 0);
-
- DisplayRandPool (hwndDlg, hRandPoolSys, showKeys);
-
- break;
-
- case SYSENC_KEYS_GEN_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("KEYS_GEN_TITLE"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- hMasterKey = GetDlgItem (hwndDlg, IDC_DISK_KEY);
- hHeaderKey = GetDlgItem (hwndDlg, IDC_HEADER_KEY);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_DISK_KEY), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_HEADER_KEY), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_DISPLAY_KEYS), BM_SETCHECK, showKeys ? BST_CHECKED : BST_UNCHECKED, 0);
-
- DisplayPortionsOfKeys (hHeaderKey, hMasterKey, HeaderKeyGUIView, MasterKeyGUIView, !showKeys);
-
- break;
-
- case SYSENC_RESCUE_DISK_CREATION_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("RESCUE_DISK"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDT_RESCUE_DISK_INFO), GetString ("RESCUE_DISK_INFO"));
- SetDlgItemText (hwndDlg, IDC_RESCUE_DISK_ISO_PATH, szRescueDiskISO);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH)) > 1));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- SetCheckBox (hCurPage, IDC_SKIP_RESCUE_VERIFICATION, bDontVerifyRescueDisk);
-
- break;
-
- case SYSENC_RESCUE_DISK_BURN_PAGE:
- {
- wchar_t szTmp[8192];
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bDontVerifyRescueDisk ? "RESCUE_DISK_CREATED_TITLE" : "RESCUE_DISK_RECORDING_TITLE"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- StringCbPrintfW (szTmp, sizeof szTmp,
- GetString (bDontVerifyRescueDisk ? "RESCUE_DISK_BURN_INFO_NO_CHECK" : "RESCUE_DISK_BURN_INFO"),
- szRescueDiskISO, IsWindowsIsoBurnerAvailable() ? L"" : GetString ("RESCUE_DISK_BURN_INFO_NONWIN_ISO_BURNER"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDT_RESCUE_DISK_BURN_INFO), szTmp);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- /* The 'Back' button must be disabled now because the user could burn a Rescue Disk, then go back, and
- generate a different master key, which would cause the Rescue Disk verification to fail (the result
- would be confusion and bug reports). */
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
-
- if (IsWindowsIsoBurnerAvailable())
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE), GetString ("LAUNCH_WIN_ISOBURN"));
-
- ToHyperlink (hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE);
-
- if (IsWindowsIsoBurnerAvailable() && !bDontVerifyRescueDisk)
- LaunchWindowsIsoBurner (hwndDlg, szRescueDiskISO);
- }
- break;
-
- case SYSENC_RESCUE_DISK_VERIFIED_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("RESCUE_DISK_DISK_VERIFIED_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("RESCUE_DISK_VERIFIED_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- // Rescue Disk has been verified, no need to go back
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
-
- // Prevent losing the burned rescue disk by inadvertent exit
- bConfirmQuit = TRUE;
-
- break;
-
- case SYSENC_WIPE_MODE_PAGE:
- case NONSYS_INPLACE_ENC_WIPE_MODE_PAGE:
- {
- if (nWipeMode == TC_WIPE_1_RAND)
- nWipeMode = TC_WIPE_NONE;
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("WIPE_MODE_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDT_WIPE_MODE_INFO), GetString ("INPLACE_ENC_WIPE_MODE_INFO"));
-
- PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE),
- SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING && !bInPlaceEncNonSys,
- TRUE,
- FALSE);
-
- SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- }
- break;
-
- case SYSENC_PRETEST_INFO_PAGE:
-
- if (bHiddenOS)
- {
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("HIDDEN_OS_CREATION_PREINFO_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("HIDDEN_OS_CREATION_PREINFO_HELP"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("START"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- }
- else
- {
- wchar_t finalMsg[8024] = {0};
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYS_ENCRYPTION_PRETEST_TITLE"));
-
- try
- {
- StringCbPrintfW (finalMsg, sizeof(finalMsg),
- GetString ("SYS_ENCRYPTION_PRETEST_INFO"),
- BootEncObj->GetSystemDriveConfiguration().DriveNumber);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- EndMainDlg (MainDlg);
- return 0;
- }
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), finalMsg);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("TEST"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- break;
-
- case SYSENC_PRETEST_RESULT_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYS_ENCRYPTION_PRETEST_RESULT_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYS_ENCRYPTION_PRETEST_RESULT_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("ENCRYPT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("DEFER"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
-
- break;
-
- case SYSENC_ENCRYPTION_PAGE:
-
- if (CreateSysEncMutex ())
- {
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
- bSystemEncryptionInProgress = BootEncStatus.SetupInProgress;
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- EndMainDlg (MainDlg);
- return 0;
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE),
- GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "ENCRYPTION" : "DECRYPTION"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_ENCRYPTION_PAGE_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("DEFER"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "ENCRYPT" : "DECRYPT"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_PAUSE),
- GetString (bSystemEncryptionInProgress ? "IDC_PAUSE" : "RESUME"));
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_PAUSE), BootEncStatus.DriveEncrypted);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), !BootEncStatus.SetupInProgress);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
-
- ToHyperlink (hwndDlg, IDC_MORE_INFO_SYS_ENCRYPTION);
-
- if (SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING)
- {
- nWipeMode = TC_WIPE_NONE;
- EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDT_WIPE_MODE), FALSE);
- PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), TRUE, TRUE, FALSE);
- SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode);
- }
- else
- {
- EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), !bSystemEncryptionInProgress);
- PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, TRUE, FALSE);
- SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode);
- }
-
- PostMessage (hwndDlg, TC_APPMSG_PERFORM_POST_SYSENC_WMINIT_TASKS, 0, 0);
- }
- else
- {
- Error ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", MainDlg);
- EndMainDlg (MainDlg);
- return 0;
- }
- return 0;
-
- case NONSYS_INPLACE_ENC_RESUME_PARTITION_SEL_PAGE:
-
- {
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("FILE_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("NONSYS_INPLACE_ENC_RESUME_VOL_SELECT_HELP"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
-
- foreach (const HostDevice &device, DeferredNonSysInPlaceEncDevices)
- {
- SendMessage (GetDlgItem (hwndDlg, IDC_LIST_BOX), LB_ADDSTRING, 0, (LPARAM) device.Path.c_str());
- }
-
- // Deselect all
- SendMessage (GetDlgItem (hwndDlg, IDC_LIST_BOX), LB_SETCURSEL, (WPARAM) -1, 0);
- }
-
- break;
-
- case NONSYS_INPLACE_ENC_TRANSFORM_PAGE:
-
- if (bInPlaceEncNonSysResumed)
- {
- WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
-
- if (LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
- nWipeMode = savedWipeAlgorithm;
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bInPlaceDecNonSys ? "DECRYPTION" : "ENCRYPTION"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bInPlaceDecNonSys ? "NONSYS_INPLACE_DEC_DECRYPTION_PAGE_INFO" : "NONSYS_INPLACE_ENC_ENCRYPTION_PAGE_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString (bInPlaceEncNonSysResumed ? "DEFER" : "CANCEL"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString (bInPlaceEncNonSysResumed ? "RESUME" : (bInPlaceDecNonSys ? "DECRYPT" : "ENCRYPT")));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_PAUSE), GetString ("IDC_PAUSE"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bInPlaceEncNonSysResumed && !bInPlaceDecNonSys);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_PAUSE), FALSE);
-
- ShowWindow (GetDlgItem (hwndDlg, IDC_MORE_INFO_SYS_ENCRYPTION), SW_HIDE);
-
- if (bInPlaceDecNonSys)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDT_WIPE_MODE), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_WIPE_MODE), SW_HIDE);
- }
- else
- {
- EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), TRUE);
- PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, TRUE, FALSE);
- SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode);
- }
-
- break;
-
- case NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE:
-
- bConfirmQuit = FALSE;
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bInPlaceDecNonSys ? "NONSYS_INPLACE_DEC_FINISHED_TITLE" : "NONSYS_INPLACE_ENC_FINISHED_TITLE"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bInPlaceDecNonSys ? "NONSYS_INPLACE_DEC_FINISHED_INFO" : "NONSYS_INPLACE_ENC_FINISHED_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("FINALIZE"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("EXIT"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
-
- break;
-
- case NONSYS_INPLACE_DEC_TRANSFORM_FINISHED_DRIVE_LETTER_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("NONSYS_INPLACE_DEC_FINISHED_TITLE"));
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("NONSYS_INPLACE_DEC_FINISHED_DRIVE_LETTER_SEL_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("FINALIZE"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
-
- // The Cancel button and the X button must be disabled to prevent the user from forgetting to assign a drive letter to the partition by closing
- // the window accidentally or clicking Cancel. The user is forced to click Finish to assign at least the pre-selected free drive letter.
- // This is critical because inexperienced users would not know how to access data on the decrypted volume without a drive letter.
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
- DisableCloseButton (MainDlg);
- bConfirmQuit = TRUE; // Alt-F4 will still work but the user will be prompted to confirm the action.
-
- // Decryption of non-system volume finished, no drive letter is assigned to the decrypted volume, and free drive letters are available.
- // This is critical because inexperienced users would not know how to access data on the decrypted volume. We cannot allow exit
- // until a drive letter is freed up and assigned to the decrypted volume.
-
- while (GetFirstAvailableDrive () == -1)
- {
- Error ("NONSYS_INPLACE_DEC_FINISHED_NO_DRIVE_LETTER_AVAILABLE", hwndDlg);
- }
-
- // Populate the combobox with free drive letters
- {
- DWORD dwUsedDrives = GetUsedLogicalDrives();
- wchar_t szDriveLetter[] = {L' ', L':', 0 };
- int i;
-
- for (i = 0; i < 26; i++)
- {
- if (!(dwUsedDrives & 1 << i))
- {
- // Add
- szDriveLetter [0] = (wchar_t) (i + L'A');
- AddComboPair (GetDlgItem (hCurPage, IDC_DRIVE_LETTER_LIST), szDriveLetter, i);
- }
- }
- }
- SendMessage (GetDlgItem (hwndDlg, IDC_DRIVE_LETTER_LIST), CB_SETCURSEL, 0, 0);
- break;
-
- case FORMAT_PAGE:
- {
- BOOL bNTFSallowed = FALSE;
- BOOL bFATallowed = FALSE;
- BOOL bEXFATallowed = FALSE;
- BOOL bNoFSallowed = FALSE;
- HCRYPTPROV hRngProv;
-
- mouseEntropyGathered = 0xFFFFFFFF;
- mouseEventsInitialCount = 0;
- bUseMask = FALSE;
- if (CryptAcquireContext (&hRngProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
- {
- if (CryptGenRandom (hRngProv, sizeof (maskRandPool), maskRandPool))
- bUseMask = TRUE;
- CryptReleaseContext (hRngProv, 0);
- }
-
- SetTimer (GetParent (hwndDlg), TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
-
- hMasterKey = GetDlgItem (hwndDlg, IDC_DISK_KEY);
- hHeaderKey = GetDlgItem (hwndDlg, IDC_HEADER_KEY);
- hRandPool = GetDlgItem (hwndDlg, IDC_RANDOM_BYTES);
- hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR);
- SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel);
- SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0);
-
- SendMessage (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_DISK_KEY), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
- SendMessage (GetDlgItem (hwndDlg, IDC_HEADER_KEY), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP),
- GetString (bHiddenVolHost ? "FORMAT_HIDVOL_HOST_HELP" : "FORMAT_HELP"));
-
- if (bHiddenVol)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "FORMAT_HIDVOL_HOST_TITLE" : "FORMAT_HIDVOL_TITLE"));
- else
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("FORMAT_TITLE"));
-
- /* Quick/Dynamic */
-
- if (bHiddenVol)
- {
- quickFormat = !bHiddenVolHost;
- bSparseFileSwitch = FALSE;
-
- SetCheckBox (hwndDlg, IDC_QUICKFORMAT, quickFormat);
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), GetString ((bDevice || !bHiddenVolHost) ? "IDC_QUICKFORMAT" : "SPARSE_FILE"));
- EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), bDevice && bHiddenVolHost);
- }
- else
- {
- if (bDevice)
- {
- bSparseFileSwitch = FALSE;
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), GetString("IDC_QUICKFORMAT"));
- EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE);
- }
- else
- {
- wchar_t root[TC_MAX_PATH];
- DWORD fileSystemFlags = 0;
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), GetString("SPARSE_FILE"));
-
- /* Check if the host file system supports sparse files */
-
- if (GetVolumePathName (szFileName, root, array_capacity (root)))
- {
- GetVolumeInformation (root, NULL, 0, NULL, NULL, &fileSystemFlags, NULL, 0);
- bSparseFileSwitch = fileSystemFlags & FILE_SUPPORTS_SPARSE_FILES;
- }
- else
- bSparseFileSwitch = FALSE;
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), bSparseFileSwitch);
- }
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_SHOW_KEYS), BM_SETCHECK, showKeys ? BST_CHECKED : BST_UNCHECKED, 0);
- SetWindowText (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), showKeys ? L"" : L"******************************** ");
- SetWindowText (GetDlgItem (hwndDlg, IDC_HEADER_KEY), showKeys ? L"" : L"******************************** ");
- SetWindowText (GetDlgItem (hwndDlg, IDC_DISK_KEY), showKeys ? L"" : L"******************************** ");
-
- SendMessage (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), CB_RESETCONTENT, 0, 0);
- AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), GetString ("DEFAULT"), 0);
-
- for (int i = 1; i <= 128; i *= 2)
- {
- wstringstream s;
- DWORD size = GetFormatSectorSize() * i;
-
- if (size > TC_MAX_FAT_CLUSTER_SIZE)
- break;
-
- if (size == 512)
- s << L"0.5";
- else
- s << size / BYTES_PER_KB;
-
- s << L" " << GetString ("KB");
-
- AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), s.str().c_str(), i);
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), CB_SETCURSEL, 0, 0);
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), TRUE);
-
- /* Filesystems */
-
- bNTFSallowed = FALSE;
- bFATallowed = FALSE;
- bNoFSallowed = FALSE;
-
- SendMessage (GetDlgItem (hwndDlg, IDC_FILESYS), CB_RESETCONTENT, 0, 0);
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_FILESYS), TRUE);
-
- uint64 dataAreaSize = GetVolumeDataAreaSize (bHiddenVol && !bHiddenVolHost, nVolumeSize);
-
- if (!CreatingHiddenSysVol())
- {
- if (dataAreaSize >= TC_MIN_NTFS_FS_SIZE && dataAreaSize <= TC_MAX_NTFS_FS_SIZE)
- {
- AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"NTFS", FILESYS_NTFS);
- bNTFSallowed = TRUE;
- }
-
- if (dataAreaSize >= TC_MIN_FAT_FS_SIZE && dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize())
- {
- AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"FAT", FILESYS_FAT);
- bFATallowed = TRUE;
- }
-
- //exFAT support added starting from Vista SP1
- if (IsOSVersionAtLeast (WIN_VISTA, 1) && dataAreaSize >= TC_MIN_EXFAT_FS_SIZE && dataAreaSize <= TC_MAX_EXFAT_FS_SIZE)
- {
- AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"exFAT", FILESYS_EXFAT);
- bEXFATallowed = TRUE;
- }
- }
- else
- {
- // We're creating a hidden volume for a hidden OS, so we don't need to format it with
- // any filesystem (the entire OS will be copied to the hidden volume sector by sector).
- EnableWindow (GetDlgItem (hwndDlg, IDC_FILESYS), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), FALSE);
- }
-
- if (!bHiddenVolHost)
- {
- AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), GetString ("NONE"), FILESYS_NONE);
- bNoFSallowed = TRUE;
- }
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- if (fileSystem == FILESYS_NONE) // If no file system has been previously selected
- {
- // Set default file system
-
- if (bFATallowed && !(nNeedToStoreFilesOver4GB == 1 && (bNTFSallowed || bEXFATallowed)))
- fileSystem = FILESYS_FAT;
- else if (bEXFATallowed)
- fileSystem = FILESYS_EXFAT;
- else if (bNTFSallowed)
- fileSystem = FILESYS_NTFS;
- else if (bNoFSallowed)
- fileSystem = FILESYS_NONE;
- else
- {
- AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"---", 0);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
- }
- }
-
- SendMessage (GetDlgItem (hwndDlg, IDC_FILESYS), CB_SETCURSEL, 0, 0);
- SelectAlgo (GetDlgItem (hwndDlg, IDC_FILESYS), (int *) &fileSystem);
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_ABORT_BUTTON), FALSE);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("FORMAT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- SetFocus (GetDlgItem (GetParent (hwndDlg), IDC_NEXT));
- }
- break;
-
- case FORMAT_FINISHED_PAGE:
- {
- if (!bHiddenVolHost && bHiddenVol && !bHiddenVolFinished)
- {
- wchar_t msg[4096];
-
- nNeedToStoreFilesOver4GB = -1;
-
- if (bHiddenOS)
- {
- wchar_t szMaxRecomOuterVolFillSize[100];
-
- __int64 maxRecomOuterVolFillSize = 0;
-
- // Determine the maximum recommended total size of files that can be copied to the outer volume
- // while leaving enough space for the hidden volume, which must contain a clone of the OS
-
- maxRecomOuterVolFillSize = nVolumeSize - GetSystemPartitionSize();
-
- // -50% reserve for filesystem "peculiarities"
- maxRecomOuterVolFillSize /= 2;
-
- StringCbPrintfW (szMaxRecomOuterVolFillSize, sizeof(szMaxRecomOuterVolFillSize), L"%I64d %s", maxRecomOuterVolFillSize / BYTES_PER_MB, GetString ("MB"));
-
- StringCbPrintfW (msg, sizeof(msg), GetString ("HIDVOL_HOST_FILLING_HELP_SYSENC"), hiddenVolHostDriveNo + 'A', szMaxRecomOuterVolFillSize);
- }
- else
- StringCbPrintfW (msg, sizeof(msg), GetString ("HIDVOL_HOST_FILLING_HELP"), hiddenVolHostDriveNo + 'A');
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), msg);
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("HIDVOL_HOST_FILLING_TITLE"));
- }
- else
- {
- if (bHiddenOS)
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_HIDDEN_VOL_FORMAT_FINISHED_HELP"));
- else
- {
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bInPlaceEncNonSys ? "NONSYS_INPLACE_ENC_FINISHED_INFO" : "FORMAT_FINISHED_HELP"));
- bConfirmQuit = FALSE;
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVol ? "HIDVOL_FORMAT_FINISHED_TITLE" : "FORMAT_FINISHED_TITLE"));
- }
-
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), (!bHiddenVol || bHiddenVolFinished) && !bHiddenOS && !bInPlaceEncNonSys);
-
- if ((!bHiddenVol || bHiddenVolFinished) && !bHiddenOS)
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("EXIT"));
- }
- break;
-
- case SYSENC_HIDDEN_OS_INITIAL_INFO_PAGE:
-
- if (!IsHiddenOSRunning() || !bHiddenOS)
- {
- ReportUnexpectedState (SRC_POS);
- EndMainDlg (MainDlg);
- return 0;
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_HIDDEN_OS_INITIAL_INFO_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("FIRST_HIDDEN_OS_BOOT_INFO"));
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("DEFER"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
- break;
-
- case SYSENC_HIDDEN_OS_WIPE_INFO_PAGE:
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_HIDDEN_OS_WIPE_INFO_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_HIDDEN_OS_WIPE_INFO"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- break;
-
- case DEVICE_WIPE_MODE_PAGE:
-
- if (nWipeMode == TC_WIPE_NONE)
- nWipeMode = TC_WIPE_1_RAND;
-
- if (bHiddenOS && IsHiddenOSRunning())
- {
- // Decoy system partition wipe
-
- WipeAbort(); // In case the GUI previously crashed and the driver is still wiping
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
- }
- else
- {
- // Regular device wipe (not decoy system partition wipe)
-
- // Title bar
- SetWindowText (MainDlg, _T(TC_APP_NAME));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("WIPE_MODE_TITLE"));
- SetWindowTextW (GetDlgItem (hwndDlg, IDT_WIPE_MODE_INFO), GetString ("WIPE_MODE_INFO"));
-
- PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, FALSE, TRUE);
-
- SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode);
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
-
- break;
-
- case DEVICE_WIPE_PAGE:
-
- if (bHiddenOS && IsHiddenOSRunning())
- {
- // Decoy system partition wipe
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("DEVICE_WIPE_PAGE_INFO_HIDDEN_OS"));
- }
- else
- {
- // Regular device wipe (not decoy system partition wipe)
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("DEVICE_WIPE_PAGE_INFO"));
- }
-
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("DEVICE_WIPE_PAGE_TITLE"));
- SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("WIPE"));
- SetWindowTextW (GetDlgItem (hCurPage, IDC_WIPE_MODE), (wstring (L" ") + GetWipeModeName (nWipeMode)).c_str());
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_ABORT_BUTTON), FALSE);
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
-
- break;
- }
- return 0;
-
- case WM_HELP:
- OpenPageHelp (GetParent (hwndDlg), nCurPageNo);
- return 1;
-
- case TC_APPMSG_PERFORM_POST_SYSENC_WMINIT_TASKS:
- AfterSysEncProgressWMInitTasks (hwndDlg);
- return 1;
-
- case WM_CTLCOLORSTATIC:
- {
- if (PimValueChangedWarning && ((HWND)lParam == GetDlgItem(hwndDlg, IDC_PIM_HELP)) )
- {
- // we're about to draw the static
- // set the text colour in (HDC)lParam
- SetBkMode((HDC)wParam,TRANSPARENT);
- SetTextColor((HDC)wParam, RGB(255,0,0));
- // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle.
- return (BOOL)GetSysColorBrush(COLOR_MENU);
- }
- }
- return 0;
-
- case WM_COMMAND:
-
- if (nCurPageNo == INTRO_PAGE)
- {
- switch (lw)
- {
- case IDC_FILE_CONTAINER:
- UpdateWizardModeControls (hwndDlg, WIZARD_MODE_FILE_CONTAINER);
- return 1;
-
- case IDC_NONSYS_DEVICE:
- UpdateWizardModeControls (hwndDlg, WIZARD_MODE_NONSYS_DEVICE);
- return 1;
-
- case IDC_SYS_DEVICE:
- UpdateWizardModeControls (hwndDlg, WIZARD_MODE_SYS_DEVICE);
- return 1;
-
- case IDC_MORE_INFO_ON_CONTAINERS:
- Applink ("introcontainer", TRUE, "");
- return 1;
-
- case IDC_MORE_INFO_ON_SYS_ENCRYPTION:
- Applink ("introsysenc", TRUE, "");
- return 1;
- }
- }
-
- if (nCurPageNo == SYSENC_TYPE_PAGE)
- {
- switch (lw)
- {
- case IDC_SYSENC_HIDDEN:
- bHiddenOS = TRUE;
- bHiddenVol = TRUE;
- bHiddenVolHost = TRUE;
- return 1;
-
- case IDC_SYSENC_NORMAL:
- bHiddenOS = FALSE;
- bHiddenVol = FALSE;
- bHiddenVolHost = FALSE;
- return 1;
-
- case IDC_HIDDEN_SYSENC_INFO_LINK:
- Applink ("hiddensysenc", TRUE, "");
- return 1;
- }
- }
-
- if (nCurPageNo == SYSENC_HIDDEN_OS_REQ_CHECK_PAGE && lw == IDC_HIDDEN_SYSENC_INFO_LINK)
- {
- Applink ("hiddensysenc", TRUE, "");
- return 1;
- }
-
- if (nCurPageNo == SYSENC_SPAN_PAGE)
- {
- switch (lw)
- {
- case IDC_WHOLE_SYS_DRIVE:
- bWholeSysDrive = TRUE;
- return 1;
- case IDC_SYS_PARTITION:
- bWholeSysDrive = FALSE;
- return 1;
- }
-
- }
-
- if (nCurPageNo == SYSENC_MULTI_BOOT_MODE_PAGE)
- {
- switch (lw)
- {
- case IDC_SINGLE_BOOT:
- nMultiBoot = 1;
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- return 1;
- case IDC_MULTI_BOOT:
- nMultiBoot = 2;
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- return 1;
- }
- }
-
- // Dual choice pages
- switch (nCurPageNo)
- {
- case SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE:
- case SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_PAGE:
- case SYSENC_MULTI_BOOT_ADJACENT_SYS_PAGE:
- case SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE:
- case SYSENC_PRE_DRIVE_ANALYSIS_PAGE:
-
- if (lw == IDC_CHOICE1 || lw == IDC_CHOICE2)
- {
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- return 1;
- }
- break;
- }
-
- if (nCurPageNo == FILESYS_PAGE && (lw == IDC_CHOICE1 || lw == IDC_CHOICE2))
- {
- if (bWarnOuterVolSuitableFileSys && lw == IDC_CHOICE1 && bHiddenVolHost)
- {
- wchar_t szTmp [4096];
-
- bWarnOuterVolSuitableFileSys = FALSE; // Do not show this warning anymore (this also prevents potential endless repetition due to some race conditions)
-
- StringCbCopyW (szTmp, sizeof(szTmp), GetString ("FILESYS_PAGE_HELP_EXPLANATION_HIDVOL"));
- StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("FILESYS_PAGE_HELP_EXPLANATION_HIDVOL_CONFIRM"));
-
- if (MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDNO)
- {
- nNeedToStoreFilesOver4GB = 0;
- Init2RadButtonPageYesNo (nNeedToStoreFilesOver4GB);
- }
- }
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- return 1;
- }
-
- if (lw == IDC_HIDDEN_VOL && nCurPageNo == VOLUME_TYPE_PAGE)
- {
- bHiddenVol = TRUE;
- bHiddenVolHost = TRUE;
- bInPlaceEncNonSys = FALSE;
- return 1;
- }
-
- if (lw == IDC_STD_VOL && nCurPageNo == VOLUME_TYPE_PAGE)
- {
- bHiddenVol = FALSE;
- bHiddenVolHost = FALSE;
- return 1;
- }
-
- if (nCurPageNo == SYSENC_ENCRYPTION_PAGE)
- {
- BootEncryptionStatus locBootEncStatus;
-
- switch (lw)
- {
- case IDC_PAUSE:
- try
- {
- locBootEncStatus = BootEncObj->GetStatus();
-
- if (locBootEncStatus.SetupInProgress)
- SysEncPause ();
- else
- SysEncResume ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
- return 1;
-
- case IDC_WIPE_MODE:
- if (hw == CBN_SELCHANGE)
- {
- nWipeMode = (WipeAlgorithmId) SendMessage (GetDlgItem (hCurPage, IDC_WIPE_MODE),
- CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_WIPE_MODE), CB_GETCURSEL, 0, 0),
- 0);
-
- return 1;
- }
- break;
-
- case IDC_MORE_INFO_SYS_ENCRYPTION:
- Applink ("sysencprogressinfo", TRUE, "");
- return 1;
- }
- }
-
- if (bInPlaceEncNonSys)
- {
- switch (nCurPageNo)
- {
- case NONSYS_INPLACE_ENC_RESUME_PARTITION_SEL_PAGE:
-
- if (lw == IDC_LIST_BOX
- && (hw == LBN_SELCHANGE || hw == LBN_DBLCLK))
- {
- BOOL tmpbDevice = FALSE;
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
-
- int selPartitionItemId = (int) SendMessage (GetDlgItem (hwndDlg, IDC_LIST_BOX), LB_GETCURSEL, 0, 0);
-
- if (selPartitionItemId == LB_ERR)
- {
- // Deselect all
- SendMessage (GetDlgItem (hwndDlg, IDC_LIST_BOX), LB_SETCURSEL, (WPARAM) -1, 0);
-
- SetFocus (GetDlgItem (MainDlg, IDC_NEXT));
- return 1;
- }
-
- SetFocus (GetDlgItem (MainDlg, IDC_NEXT));
-
- StringCbCopyW (szFileName, sizeof(szFileName), DeferredNonSysInPlaceEncDevices [selPartitionItemId].Path.c_str());
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &tmpbDevice);
-
- nVolumeSize = GetDeviceSize (szDiskFile);
- if (nVolumeSize == -1)
- {
- handleWin32Error (MainDlg, SRC_POS);
- return 1;
- }
-
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
-
- return 1;
- }
- break;
-
- case NONSYS_INPLACE_ENC_TRANSFORM_PAGE:
- {
- switch (lw)
- {
- case IDC_PAUSE:
-
- // Pause/resume non-system in-place encryption
-
- if (bVolTransformThreadRunning || bVolTransformThreadToRun)
- {
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), FALSE);
- NonSysInplaceEncPause ();
- }
- else
- NonSysInplaceEncResume ();
-
- return 1;
-
- case IDC_WIPE_MODE:
- if (hw == CBN_SELCHANGE)
- {
- nWipeMode = (WipeAlgorithmId) SendMessage (GetDlgItem (hCurPage, IDC_WIPE_MODE),
- CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_WIPE_MODE), CB_GETCURSEL, 0, 0),
- 0);
-
- return 1;
- }
- break;
- }
- }
- break;
- }
- }
-
-
- if (lw == IDC_OPEN_OUTER_VOLUME && nCurPageNo == FORMAT_FINISHED_PAGE)
- {
- OpenVolumeExplorerWindow (hiddenVolHostDriveNo);
- return 1;
- }
-
- if (lw == IDC_HIDDEN_VOL_HELP && nCurPageNo == VOLUME_TYPE_PAGE)
- {
- Applink ("hiddenvolume", TRUE, "");
- return 1;
- }
-
- if (lw == IDC_ABORT_BUTTON && nCurPageNo == FORMAT_PAGE)
- {
- if (MessageBoxW (hwndDlg, GetString ("FORMAT_ABORT"), lpszTitle, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) == IDYES)
- bVolTransformThreadCancel = TRUE;
- return 1;
- }
-
- if (lw == IDC_CIPHER_TEST && nCurPageNo == CIPHER_PAGE)
- {
- LPARAM nIndex;
- int c;
-
- nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0);
- nVolumeEA = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0);
-
- for (c = EAGetLastCipher (nVolumeEA); c != 0; c = EAGetPreviousCipher (nVolumeEA, c))
- {
- DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_CIPHER_TEST_DLG),
- GetParent (hwndDlg), (DLGPROC) CipherTestDialogProc, (LPARAM) c);
- }
- return 1;
- }
-
- if (lw == IDC_BENCHMARK && nCurPageNo == CIPHER_PAGE)
- {
- // Reduce CPU load
- bFastPollEnabled = FALSE;
- bRandmixEnabled = FALSE;
-
- DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_BENCHMARK_DLG), hwndDlg,
- (DLGPROC) BenchmarkDlgProc, (LPARAM) NULL);
-
- bFastPollEnabled = TRUE;
- bRandmixEnabled = TRUE;
-
- return 1;
- }
-
- if (lw == IDC_LINK_MORE_INFO_ABOUT_CIPHER && nCurPageNo == CIPHER_PAGE)
- {
- wchar_t name[100];
-
- int nIndex = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0);
- nIndex = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0);
- EAGetName (name, nIndex, 0);
-
- if (wcscmp (name, L"AES") == 0)
- Applink ("aes", FALSE, "");
- else if (wcscmp (name, L"Serpent") == 0)
- Applink ("serpent", FALSE, "");
- else if (wcscmp (name, L"Twofish") == 0)
- Applink ("twofish", FALSE, "");
- else if (EAGetCipherCount (nIndex) > 1)
- Applink ("cascades", TRUE, "");
-
- return 1;
- }
-
- if (lw == IDC_LINK_HASH_INFO && nCurPageNo == CIPHER_PAGE)
- {
- Applink ("hashalgorithms", TRUE, "");
- return 1;
- }
-
- if (lw == IDC_LINK_PIM_INFO && nCurPageNo == PIM_PAGE)
- {
- Applink ("pim", TRUE, "");
- return 1;
- }
-
- if (hw == CBN_EDITCHANGE && nCurPageNo == VOLUME_LOCATION_PAGE)
- {
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetWindowTextLength (GetDlgItem (hCurPage, IDC_COMBO_BOX)) > 0);
-
- bDeviceTransformModeChoiceMade = FALSE;
- bInPlaceEncNonSys = FALSE;
-
- return 1;
- }
-
- if (hw == CBN_SELCHANGE && nCurPageNo == VOLUME_LOCATION_PAGE)
- {
- LPARAM nIndex;
-
- nIndex = MoveEditToCombo ((HWND) lParam, bHistory);
- nIndex = UpdateComboOrder (GetDlgItem (hwndDlg, IDC_COMBO_BOX));
-
- if (nIndex != CB_ERR)
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
- else
- EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
-
- bDeviceTransformModeChoiceMade = FALSE;
- bInPlaceEncNonSys = FALSE;
-
- return 1;
- }
-
- if (hw == EN_CHANGE && nCurPageNo == SIZE_PAGE)
- {
- VerifySizeAndUpdate (hwndDlg, FALSE);
- return 1;
- }
-
- if (hw == EN_CHANGE && nCurPageNo == PASSWORD_PAGE)
- {
- VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetDlgItem (hwndDlg, IDC_PASSWORD),
- GetDlgItem (hwndDlg, IDC_VERIFY),
- NULL,
- NULL,
- KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect());
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
-
- return 1;
- }
-
- if (hw == EN_CHANGE && nCurPageNo == PIM_PAGE)
- {
- if (lw == IDC_PIM)
- {
- if(GetPim (hwndDlg, IDC_PIM) != 0)
- {
- PimValueChangedWarning = TRUE;
- SetDlgItemTextW (hwndDlg, IDC_PIM_HELP, GetString (SysEncInEffect ()? "PIM_SYSENC_CHANGE_WARNING" : "PIM_CHANGE_WARNING"));
- }
- else
- {
- PimValueChangedWarning = FALSE;
- SetDlgItemTextW (hwndDlg, IDC_PIM_HELP, (wchar_t *) GetDictionaryValueByInt (IDC_PIM_HELP));
- }
- }
-
- return 1;
- }
-
- if (lw == IDC_SHOW_PASSWORD && nCurPageNo == PASSWORD_PAGE)
- {
- HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_VERIFY);
- return 1;
- }
-
- if (lw == IDC_SHOW_PIM && nCurPageNo == PIM_PAGE)
- {
- HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PIM, IDC_PIM, 0);
- return 1;
- }
-
- if (lw == IDC_PIM_ENABLE)
- {
- PimEnable = GetCheckBox (hwndDlg, IDC_PIM_ENABLE);
- if (!PimEnable)
- volumePim = 0;
- if (nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE
- )
- {
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_ENABLE), PimEnable? SW_HIDE : SW_SHOW);
- ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), PimEnable? SW_SHOW : SW_HIDE);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), PimEnable? SW_SHOW : SW_HIDE);
- ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), PimEnable? SW_SHOW : SW_HIDE);
- if (PimEnable)
- {
- SetFocus (GetDlgItem (hwndDlg, IDC_PIM));
- }
- }
- return 1;
- }
-
- if (nCurPageNo == PASSWORD_PAGE
- || nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- {
- if (lw == IDC_KEY_FILES)
- {
- if (SysEncInEffect())
- {
- Warning ("KEYFILES_NOT_SUPPORTED_FOR_SYS_ENCRYPTION", MainDlg);
- return 1;
- }
-
- KeyFilesDlgParam param;
- param.EnableKeyFiles = KeyFilesEnable;
- param.FirstKeyFile = FirstKeyFile;
-
- if (IDOK == DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_KEYFILES), hwndDlg,
- (DLGPROC) KeyFilesDlgProc, (LPARAM) &param))
- {
- KeyFilesEnable = param.EnableKeyFiles;
- FirstKeyFile = param.FirstKeyFile;
-
- SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
-
- if (nCurPageNo != HIDDEN_VOL_HOST_PASSWORD_PAGE && nCurPageNo != NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), KeyFilesEnable);
-
- if (nCurPageNo != HIDDEN_VOL_HOST_PASSWORD_PAGE && nCurPageNo != NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- {
- VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetDlgItem (hCurPage, IDC_PASSWORD),
- GetDlgItem (hCurPage, IDC_VERIFY),
- volumePassword.Text, szVerify, KeyFilesEnable && FirstKeyFile!=NULL);
- }
- }
-
- return 1;
- }
-
- if (lw == IDC_KEYFILES_ENABLE)
- {
- KeyFilesEnable = GetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE);
-
- if (nCurPageNo != HIDDEN_VOL_HOST_PASSWORD_PAGE && nCurPageNo != NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- {
- EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), KeyFilesEnable);
-
- VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetDlgItem (hCurPage, IDC_PASSWORD),
- GetDlgItem (hCurPage, IDC_VERIFY),
- volumePassword.Text, szVerify, KeyFilesEnable && FirstKeyFile!=NULL);
- }
-
- return 1;
- }
- }
-
- if (nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- {
- if (hw == EN_CHANGE)
- {
- GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, MAX_PASSWORD + 1, FALSE);
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
- return 1;
- }
-
- if (lw == IDC_SHOW_PASSWORD_SINGLE)
- {
- HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_SINGLE, IDC_PASSWORD_DIRECT, IDC_PIM);
- return 1;
- }
- }
-
- if ((lw == IDC_KB || lw == IDC_MB || lw == IDC_GB || lw == IDC_TB) && nCurPageNo == SIZE_PAGE)
- {
- SendMessage (GetDlgItem (hwndDlg, IDC_KB), BM_SETCHECK, BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_MB), BM_SETCHECK, BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_GB), BM_SETCHECK, BST_UNCHECKED, 0);
- SendMessage (GetDlgItem (hwndDlg, IDC_TB), BM_SETCHECK, BST_UNCHECKED, 0);
-
- switch (lw)
- {
- case IDC_KB:
- SendMessage (GetDlgItem (hwndDlg, IDC_KB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- case IDC_MB:
- SendMessage (GetDlgItem (hwndDlg, IDC_MB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- case IDC_GB:
- SendMessage (GetDlgItem (hwndDlg, IDC_GB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- case IDC_TB:
- SendMessage (GetDlgItem (hwndDlg, IDC_TB), BM_SETCHECK, BST_CHECKED, 0);
- break;
- }
-
- VerifySizeAndUpdate (hwndDlg, FALSE);
- return 1;
- }
-
- if (lw == IDC_HIDVOL_WIZ_MODE_DIRECT && nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE)
- {
- bHiddenVolDirect = TRUE;
- return 1;
- }
-
- if (lw == IDC_HIDVOL_WIZ_MODE_FULL && nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE)
- {
- bHiddenVolDirect = FALSE;
- return 1;
- }
-
- if (lw == IDC_SELECT_VOLUME_LOCATION && nCurPageNo == VOLUME_LOCATION_PAGE)
- {
- if (!bDevice)
- {
- // Select file
-
- if (BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, !bHiddenVolDirect, NULL) == FALSE)
- return 1;
-
- AddComboItem (GetDlgItem (hwndDlg, IDC_COMBO_BOX), szFileName, bHistory);
-
- EnableDisableFileNext (GetDlgItem (hwndDlg, IDC_COMBO_BOX),
- GetDlgItem (GetParent (hwndDlg), IDC_NEXT));
-
- return 1;
- }
- else
- {
- // Select device
- RawDevicesDlgParam param;
- param.pszFileName = szFileName;
- INT_PTR nResult = DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), GetParent (hwndDlg),
- (DLGPROC) RawDevicesDlgProc, (LPARAM) & param);
-
- // Check administrator privileges
- if (!wcsstr (szFileName, L"Floppy") && !IsAdmin() && !IsUacSupported ())
- MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_DEVICES"), lpszTitle, MB_OK|MB_ICONWARNING);
-
- if (nResult == IDOK && wcslen (szFileName) > 0)
- {
- AddComboItem (GetDlgItem (hwndDlg, IDC_COMBO_BOX), szFileName, bHistory);
-
- EnableDisableFileNext (GetDlgItem (hwndDlg, IDC_COMBO_BOX),
- GetDlgItem (GetParent (hwndDlg), IDC_NEXT));
-
- bDeviceTransformModeChoiceMade = FALSE;
- bInPlaceEncNonSys = FALSE;
- }
- return 1;
- }
- }
-
- if (nCurPageNo == DEVICE_TRANSFORM_MODE_PAGE)
- {
- switch (lw)
- {
- case IDC_DEVICE_TRANSFORM_MODE_FORMAT:
-
- bInPlaceEncNonSys = FALSE;
- bDeviceTransformModeChoiceMade = TRUE;
-
- return 1;
-
- case IDC_DEVICE_TRANSFORM_MODE_INPLACE:
-
- bInPlaceEncNonSys = TRUE;
- bDeviceTransformModeChoiceMade = TRUE;
-
- bHiddenVol = FALSE;
- bHiddenVolDirect = FALSE;
- bHiddenVolHost = FALSE;
- bSparseFileSwitch = FALSE;
- quickFormat = FALSE;
-
- return 1;
- }
- }
-
- if (lw == IDC_HIDVOL_WIZ_MODE_FULL && nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE)
- {
- bHiddenVolDirect = FALSE;
- return 1;
- }
-
- if (hw == CBN_SELCHANGE && nCurPageNo == CIPHER_PAGE)
- {
- switch (lw)
- {
- case IDC_COMBO_BOX:
- ComboSelChangeEA (hwndDlg);
- break;
-
- case IDC_COMBO_BOX_HASH_ALGO:
- if (SysEncInEffect ())
- {
- HWND hHashAlgoItem = GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO);
- int selectedAlgo = (int) SendMessage (hHashAlgoItem, CB_GETITEMDATA, SendMessage (hHashAlgoItem, CB_GETCURSEL, 0, 0), 0);
- if (!HashForSystemEncryption(selectedAlgo))
- {
- hash_algo = DEFAULT_HASH_ALGORITHM_BOOT;
- RandSetHashFunction (DEFAULT_HASH_ALGORITHM_BOOT);
- Info ("ALGO_NOT_SUPPORTED_FOR_SYS_ENCRYPTION", MainDlg);
- SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo);
- }
- }
- break;
- }
- return 1;
-
- }
-
- if (lw == IDC_QUICKFORMAT && IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT)))
- {
- if (bSparseFileSwitch)
- {
- if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO)
- SetCheckBox (hwndDlg, IDC_QUICKFORMAT, FALSE);
- }
- else
- {
- if (AskWarnYesNo("WARN_QUICK_FORMAT", MainDlg) == IDNO)
- SetCheckBox (hwndDlg, IDC_QUICKFORMAT, FALSE);
- }
- return 1;
- }
-
- if (lw == IDC_FILESYS && hw == CBN_SELCHANGE)
- {
- fileSystem = (int) SendMessage (GetDlgItem (hCurPage, IDC_FILESYS), CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_FILESYS), CB_GETCURSEL, 0, 0) , 0);
-
- return 1;
- }
-
- if (lw == IDC_SHOW_KEYS && nCurPageNo == FORMAT_PAGE)
- {
- showKeys = IsButtonChecked (GetDlgItem (hCurPage, IDC_SHOW_KEYS));
-
- SetWindowText (GetDlgItem (hCurPage, IDC_RANDOM_BYTES), showKeys ? L" " : L"******************************** ");
- SetWindowText (GetDlgItem (hCurPage, IDC_HEADER_KEY), showKeys ? L"" : L"******************************** ");
- SetWindowText (GetDlgItem (hCurPage, IDC_DISK_KEY), showKeys ? L"" : L"******************************** ");
- return 1;
- }
-
- if (lw == IDC_DISPLAY_POOL_CONTENTS
- && (nCurPageNo == SYSENC_COLLECTING_RANDOM_DATA_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_RAND_DATA_PAGE))
- {
- showKeys = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISPLAY_POOL_CONTENTS));
- DisplayRandPool (hwndDlg, hRandPoolSys, showKeys);
-
- return 1;
- }
-
- if (lw == IDC_DISPLAY_KEYS && nCurPageNo == SYSENC_KEYS_GEN_PAGE)
- {
- showKeys = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISPLAY_KEYS));
-
- DisplayPortionsOfKeys (GetDlgItem (hwndDlg, IDC_HEADER_KEY), GetDlgItem (hwndDlg, IDC_DISK_KEY), HeaderKeyGUIView, MasterKeyGUIView, !showKeys);
- return 1;
- }
-
- if (nCurPageNo == SYSENC_RESCUE_DISK_CREATION_PAGE)
- {
- if (lw == IDC_BROWSE)
- {
- wchar_t tmpszRescueDiskISO [TC_MAX_PATH+1];
-
- if (!BrowseFiles (hwndDlg, "OPEN_TITLE", tmpszRescueDiskISO, FALSE, TRUE, NULL))
- return 1;
-
- StringCbCopyW (szRescueDiskISO, sizeof(szRescueDiskISO), tmpszRescueDiskISO);
-
- SetDlgItemText (hwndDlg, IDC_RESCUE_DISK_ISO_PATH, szRescueDiskISO);
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH)) > 1));
- return 1;
- }
-
- if ( hw == EN_CHANGE )
- {
- GetDlgItemText (hwndDlg, IDC_RESCUE_DISK_ISO_PATH, szRescueDiskISO, sizeof(szRescueDiskISO));
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH)) > 1));
- return 1;
- }
- }
-
- if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE && lw == IDC_DOWNLOAD_CD_BURN_SOFTWARE)
- {
- if (IsWindowsIsoBurnerAvailable())
- LaunchWindowsIsoBurner (hwndDlg, szRescueDiskISO);
- else
- Applink ("isoburning", TRUE, "");
-
- return 1;
- }
-
- if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE
- || nCurPageNo == DEVICE_WIPE_MODE_PAGE)
- && hw == CBN_SELCHANGE)
- {
- nWipeMode = (WipeAlgorithmId) SendMessage (GetDlgItem (hCurPage, IDC_WIPE_MODE),
- CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_WIPE_MODE), CB_GETCURSEL, 0, 0),
- 0);
-
- return 1;
- }
-
- if (nCurPageNo == DEVICE_WIPE_PAGE)
- {
- switch (lw)
- {
- case IDC_ABORT_BUTTON:
-
- if (AskWarnNoYes ("CONFIRM_WIPE_ABORT", MainDlg) == IDYES)
- WipeAbort();
-
- return 1;
- }
- }
-
- if (lw == IDC_NO_HISTORY)
- {
- if (!(bHistory = !IsButtonChecked (GetDlgItem (hCurPage, IDC_NO_HISTORY))))
- ClearHistory (GetDlgItem (hCurPage, IDC_COMBO_BOX));
-
- return 1;
- }
-
- return 0;
- }
-
- return 0;
-}
-
-/* Except in response to the WM_INITDIALOG and WM_ENDSESSION messages, the dialog box procedure
- should return nonzero if it processes the message, and zero if it does not. - see DialogProc */
-BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- WORD lw = LOWORD (wParam);
-
- int nNewPageNo = nCurPageNo;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- MainDlg = hwndDlg;
- InitDialog (hwndDlg);
- LocalizeDialog (hwndDlg, "IDD_VOL_CREATION_WIZARD_DLG");
-
- if (IsTrueCryptInstallerRunning())
- AbortProcess ("TC_INSTALLER_IS_RUNNING");
-
- // Resize the bitmap if the user has a non-default DPI
- if (ScreenDPI != USER_DEFAULT_SCREEN_DPI)
- {
- hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_WIZARD),
- GetDlgItem (hwndDlg, IDC_BITMAP_WIZARD),
- 0, 0, 0, 0, FALSE, FALSE);
- }
-
- LoadSettings (hwndDlg);
-
- LoadDefaultKeyFilesParam ();
- RestoreDefaultKeyFilesParam ();
-
- SysEncMultiBootCfg.NumberOfSysDrives = -1;
- SysEncMultiBootCfg.MultipleSystemsOnDrive = -1;
- SysEncMultiBootCfg.BootLoaderLocation = -1;
- SysEncMultiBootCfg.BootLoaderBrand = -1;
- SysEncMultiBootCfg.SystemOnBootDrive = -1;
-
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- EndMainDlg (MainDlg);
- return 0;
- }
-
- SendMessageW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hTitleFont, (LPARAM) TRUE);
- SetWindowTextW (hwndDlg, lpszTitle);
-
- ExtractCommandLine (hwndDlg, (wchar_t *) lParam);
-
- if (ComServerMode)
- {
- InitDialog (hwndDlg);
-
- if (!ComServerFormat ())
- {
- handleWin32Error (hwndDlg, SRC_POS);
- exit (1);
- }
- exit (0);
- }
-
- if (DirectCreationMode)
- {
- wchar_t root[TC_MAX_PATH];
- DWORD fileSystemFlags = 0;
- uint64 dataAreaSize;
- wchar_t szFileSystemNameBuffer[256];
- ULARGE_INTEGER free;
-
- showKeys = FALSE;
- bGuiMode = FALSE;
-
- if (CmdVolumePassword.Length == 0)
- AbortProcess ("ERR_PASSWORD_MISSING");
-
- if (CmdVolumeFileSize == 0)
- AbortProcess ("ERR_SIZE_MISSING");
-
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &bDevice);
-
- if (bDevice)
- AbortProcess ("ERR_DEVICE_CLI_CREATE_NOT_SUPPORTED");
-
- volumePassword = CmdVolumePassword;
- volumePim = CmdVolumePim;
-
- if (CmdVolumeEA > 0)
- nVolumeEA = CmdVolumeEA;
-
- if (CmdVolumePkcs5 > 0)
- hash_algo = CmdVolumePkcs5;
-
- if (CmdVolumeFilesystem > 0)
- fileSystem = CmdVolumeFilesystem;
- else
- fileSystem = FILESYS_NTFS;
-
- nVolumeSize = CmdVolumeFileSize;
-
- // correct volume size to be multiple of sector size
- if (bDevice && !(bHiddenVol && !bHiddenVolHost)) // If raw device but not a hidden volume
- {
- // do nothing. no correction is needed
- }
- else
- {
- unsigned __int64 sectorSize = (unsigned __int64) GetFormatSectorSize();
- unsigned __int64 sectorSizeRem = nVolumeSize % sectorSize;
-
- if (sectorSizeRem != 0)
- nVolumeSize = nVolumeSize + (sectorSize - sectorSizeRem);
- }
-
- if (nVolumeSize < (bHiddenVolHost ? TC_MIN_HIDDEN_VOLUME_HOST_SIZE : (bHiddenVol ? TC_MIN_HIDDEN_VOLUME_SIZE : TC_MIN_VOLUME_SIZE)))
- AbortProcess ("ERR_VOLUME_SIZE_TOO_SMALL");
-
- if ( ((!bHiddenVolHost && bHiddenVol) && (nVolumeSize > nMaximumHiddenVolSize))
- || (nVolumeSize > (bHiddenVolHost ? TC_MAX_HIDDEN_VOLUME_HOST_SIZE : TC_MAX_VOLUME_SIZE))
- )
- {
- AbortProcess ("ERR_VOLUME_SIZE_TOO_BIG");
- }
-
- if (!GetVolumePathName (szFileName, root, array_capacity (root)))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- exit (1);
- }
-
- if (CmdSparseFileSwitch)
- {
- /* Check if the host file system supports sparse files */
- GetVolumeInformation (root, NULL, 0, NULL, NULL, &fileSystemFlags, NULL, 0);
- bSparseFileSwitch = fileSystemFlags & FILE_SUPPORTS_SPARSE_FILES;
-
- if (!bSparseFileSwitch)
- {
- AbortProcess ("ERR_DYNAMIC_NOT_SUPPORTED");
- }
- }
-
- quickFormat = TRUE;
-
- if (!GetDiskFreeSpaceEx (root, &free, 0, 0))
- {
- wchar_t szTmp[1024];
-
- if (translateWin32Error (szTmp, sizeof (szTmp) / sizeof(szTmp[0])))
- {
- wchar_t szTmp2[1024];
- StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s\n%s", GetString ("CANNOT_CALC_SPACE"), szTmp);
- AbortProcessDirect (szTmp2);
- }
- else
- {
- handleWin32Error (hwndDlg, SRC_POS);
- }
-
- exit (1);
- }
- else
- {
- if (!bSparseFileSwitch && (nVolumeSize > free.QuadPart))
- {
- AbortProcess ("ERR_CONTAINER_SIZE_TOO_BIG");
- }
- }
-
- dataAreaSize = GetVolumeDataAreaSize (bHiddenVol && !bHiddenVolHost, nVolumeSize);
-
- if ( (fileSystem == FILESYS_NTFS) &&
- (dataAreaSize < TC_MIN_NTFS_FS_SIZE || dataAreaSize > TC_MAX_NTFS_FS_SIZE)
- )
- {
- AbortProcess ("ERR_NTFS_INVALID_VOLUME_SIZE");
- }
-
- if ( (fileSystem == FILESYS_EXFAT) &&
- (dataAreaSize < TC_MIN_EXFAT_FS_SIZE || dataAreaSize > TC_MAX_EXFAT_FS_SIZE)
- )
- {
- AbortProcess ("ERR_EXFAT_INVALID_VOLUME_SIZE");
- }
-
- if ( (fileSystem == FILESYS_FAT) &&
- (dataAreaSize < TC_MIN_FAT_FS_SIZE || dataAreaSize > (TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize()))
- )
- {
- AbortProcess ("ERR_FAT_INVALID_VOLUME_SIZE");
- }
-
- /* Verify that the volume would not be too large for the host file system */
- if (GetVolumePathName (szDiskFile, root, ARRAYSIZE (root))
- && GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFileSystemNameBuffer, ARRAYSIZE(szFileSystemNameBuffer))
- && !wcsncmp (szFileSystemNameBuffer, L"FAT32", 5))
- {
- // The host file system is FAT32
- if (nVolumeSize >= 4 * BYTES_PER_GB)
- {
- AbortProcess ("VOLUME_TOO_LARGE_FOR_FAT32");
- }
- }
-
- /* Verify that the volume would not be too large for the operating system */
- if (!IsOSAtLeast (WIN_VISTA)
- && nVolumeSize > 2 * BYTES_PER_TB)
- {
- AbortProcess ("VOLUME_TOO_LARGE_FOR_WINXP");
- }
-
- if (volumePassword.Length > 0)
- {
- // Check password length (check also done for outer volume which is not the case in TrueCrypt).
- if (!CheckPasswordLength (NULL, volumePassword.Length, volumePim, FALSE, Silent, Silent))
- {
- exit (1);
- }
- }
-
- volTransformThreadFunction (hwndDlg);
-
- exit (bOperationSuccess? 0 : 1);
- }
-
- SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, szRescueDiskISO);
- StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.iso");
-
- if (IsOSAtLeast (WIN_VISTA))
- {
- // Availability of in-place encryption (which is pre-selected by default whenever
- // possible) makes partition-hosted volume creation safer.
- bWarnDeviceFormatAdvanced = FALSE;
- }
-
-#ifdef _DEBUG
- // For faster testing
- strcpy (szVerify, "q");
- strcpy (szRawPassword, "q");
-#endif
-
- PostMessage (hwndDlg, TC_APPMSG_PERFORM_POST_WMINIT_TASKS, 0, 0);
- }
- return 0;
-
- case WM_SYSCOMMAND:
- if (lw == IDC_ABOUT)
- {
- DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
- return 1;
- }
- return 0;
-
- case WM_TIMER:
-
- switch (wParam)
- {
- case TIMER_ID_RANDVIEW:
-
- if (WizardMode == WIZARD_MODE_SYS_DEVICE
- || bInPlaceEncNonSys)
- {
- DisplayRandPool (hwndDlg, hRandPoolSys, showKeys);
- }
- else
- {
- int partialLen = 16;
- wchar_t tmp2[43];
- int i;
- DWORD mouseEventsCounter;
-
- RandpeekBytes (hwndDlg, randPool, partialLen, &mouseEventsCounter);
-
- ProcessEntropyEstimate (hEntropyBar, &mouseEventsInitialCount, mouseEventsCounter, maxEntropyLevel, &mouseEntropyGathered);
-
- tmp2[0] = 0;
-
- for (i = 0; i < partialLen; i++)
- {
- wchar_t tmp3[3];
- if (showKeys)
- {
- StringCbPrintfW (tmp3, sizeof(tmp3), L"%02X", (int) randPool[i]);
- }
- else if (bUseMask)
- {
- unsigned char tmpByte = randPool[i] ^ maskRandPool[i];
- tmp3[0] = (wchar_t) (((tmpByte >> 4) % 6) + L'*');
- tmp3[1] = (wchar_t) (((tmpByte & 0x0F) % 6) + L'*');
- tmp3[2] = 0;
- }
- else
- StringCbCopyW (tmp3, sizeof (tmp3), L"**");
- StringCbCatW (tmp2, sizeof(tmp2), tmp3);
- }
-
- tmp2[32] = 0;
-
- SetWindowTextW (GetDlgItem (hCurPage, IDC_RANDOM_BYTES), (wstring (tmp2) + GetString ("TRIPLE_DOT_GLYPH_ELLIPSIS")).c_str());
-
- burn (randPool, partialLen);
- burn (tmp2, sizeof(tmp2));
- }
- return 1;
-
- case TIMER_ID_SYSENC_PROGRESS:
- {
- // Manage system encryption/decryption and update related GUI
-
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- KillTimer (MainDlg, TIMER_ID_SYSENC_PROGRESS);
-
- try
- {
- BootEncObj->AbortSetup ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
-
- e.Show (hwndDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
-
- if (BootEncStatus.SetupInProgress)
- UpdateSysEncProgressBar ();
-
- if (bSystemEncryptionInProgress != BootEncStatus.SetupInProgress)
- {
- bSystemEncryptionInProgress = BootEncStatus.SetupInProgress;
-
- UpdateSysEncProgressBar ();
- UpdateSysEncControls ();
-
- if (!bSystemEncryptionInProgress)
- {
- // The driver stopped encrypting/decrypting
-
- // Allow the OS to enter Sleep mode when idle
- SetThreadExecutionState (ES_CONTINUOUS);
-
- KillTimer (hwndDlg, TIMER_ID_SYSENC_PROGRESS);
-
- UpdateLastDialogId ();
-
- try
- {
- if (BootEncStatus.DriveMounted) // If we had been really encrypting/decrypting (not just proceeding to deinstall)
- BootEncObj->CheckEncryptionSetupResult();
- }
- catch (SystemException &e)
- {
- if (!bTryToCorrectReadErrors
- && SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING
- && (IsDiskReadError (e.ErrorCode)))
- {
- bTryToCorrectReadErrors = (AskWarnYesNo ("ENABLE_BAD_SECTOR_ZEROING", MainDlg) == IDYES);
-
- if (bTryToCorrectReadErrors)
- {
- SysEncResume();
- return 1;
- }
- }
- else if (!DiscardUnreadableEncryptedSectors
- && SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING
- && (IsDiskReadError (e.ErrorCode)))
- {
- DiscardUnreadableEncryptedSectors = (AskWarnYesNo ("DISCARD_UNREADABLE_ENCRYPTED_SECTORS", MainDlg) == IDYES);
-
- if (DiscardUnreadableEncryptedSectors)
- {
- SysEncResume();
- return 1;
- }
- }
-
- e.Show (hwndDlg);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
-
- switch (SystemEncryptionStatus)
- {
- case SYSENC_STATUS_ENCRYPTING:
-
- if (BootEncStatus.ConfiguredEncryptedAreaStart == BootEncStatus.EncryptedAreaStart
- && BootEncStatus.ConfiguredEncryptedAreaEnd == BootEncStatus.EncryptedAreaEnd)
- {
- // The partition/drive has been fully encrypted
-
- ManageStartupSeqWiz (TRUE, L"");
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
- EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_WIPE_MODE), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), FALSE);
-
- WipeHiddenOSCreationConfig(); // For extra conservative security
-
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
-
- Info ("SYSTEM_ENCRYPTION_FINISHED", MainDlg);
- return 1;
- }
- break;
-
- case SYSENC_STATUS_DECRYPTING:
-
- if (!BootEncStatus.DriveEncrypted)
- {
- // The partition/drive has been fully decrypted
-
- try
- {
- // Finalize the process
- BootEncObj->Deinstall ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
-
- ManageStartupSeqWiz (TRUE, L"");
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
-
- SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
- EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_PAUSE), FALSE);
-
- Info ("SYSTEM_DECRYPTION_FINISHED", MainDlg);
-
- // Reboot is required to enable uninstallation and hibernation
- if (AskWarnYesNo ("CONFIRM_RESTART", MainDlg) == IDYES)
- {
- EndMainDlg (MainDlg);
-
- try
- {
- BootEncObj->RestartComputer();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
- }
-
- return 1;
- }
- break;
- }
- }
- }
- }
- return 1;
-
- case TIMER_ID_NONSYS_INPLACE_ENC_PROGRESS:
-
- if (bInPlaceEncNonSys)
- {
- // Non-system in-place encryption
-
- if (!bVolTransformThreadRunning && !bVolTransformThreadToRun)
- {
- KillTimer (hwndDlg, TIMER_ID_NONSYS_INPLACE_ENC_PROGRESS);
-
- UpdateLastDialogId ();
- }
-
- UpdateNonSysInPlaceEncControls ();
- }
- return 1;
-
- case TIMER_ID_KEYB_LAYOUT_GUARD:
- if (SysEncInEffect ())
- {
- DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL);
-
- /* Watch the keyboard layout */
-
- if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
- {
- // Keyboard layout is not standard US
-
- WipePasswordsAndKeyfiles ();
-
- SetPassword (hCurPage, IDC_PASSWORD, szRawPassword);
- SetPassword (hCurPage, IDC_VERIFY, szVerify);
-
- keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
-
- if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
- {
- KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
- Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", MainDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
-
- bKeyboardLayoutChanged = TRUE;
-
- wchar_t szTmp [4096];
- StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED"));
- StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
- MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
- }
-
- /* Watch the right Alt key (which is used to enter various characters on non-US keyboards) */
-
- if (bKeyboardLayoutChanged && !bKeybLayoutAltKeyWarningShown)
- {
- if (GetAsyncKeyState (VK_RMENU) < 0)
- {
- bKeybLayoutAltKeyWarningShown = TRUE;
-
- wchar_t szTmp [4096];
- StringCbCopyW (szTmp, sizeof(szTmp), GetString ("ALT_KEY_CHARS_NOT_FOR_SYS_ENCRYPTION"));
- StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
- StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
- MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST);
- }
- }
- }
- return 1;
-
- case TIMER_ID_SYSENC_DRIVE_ANALYSIS_PROGRESS:
-
- if (bSysEncDriveAnalysisInProgress)
- {
- UpdateProgressBarProc (GetTickCount() - SysEncDriveAnalysisStart);
-
- if (GetTickCount() - SysEncDriveAnalysisStart > SYSENC_DRIVE_ANALYSIS_ETA)
- {
- // It's taking longer than expected -- reinit the progress bar
- SysEncDriveAnalysisStart = GetTickCount ();
- InitProgressBar (SYSENC_DRIVE_ANALYSIS_ETA, 0, FALSE, FALSE, FALSE, TRUE);
- }
-
- ArrowWaitCursor ();
- }
- else
- {
- KillTimer (hwndDlg, TIMER_ID_SYSENC_DRIVE_ANALYSIS_PROGRESS);
- UpdateProgressBarProc (SYSENC_DRIVE_ANALYSIS_ETA);
- Sleep (1500); // User-friendly GUI
-
- if (bSysEncDriveAnalysisTimeOutOccurred)
- Warning ("SYS_DRIVE_SIZE_PROBE_TIMEOUT", MainDlg);
-
- LoadPage (hwndDlg, SYSENC_DRIVE_ANALYSIS_PAGE + 1);
- }
- return 1;
-
- case TIMER_ID_WIPE_PROGRESS:
-
- // Manage device wipe and update related GUI
-
- if (bHiddenOS && IsHiddenOSRunning())
- {
- // Decoy system partition wipe
-
- DecoySystemWipeStatus decoySysPartitionWipeStatus;
-
- try
- {
- decoySysPartitionWipeStatus = BootEncObj->GetDecoyOSWipeStatus();
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- KillTimer (MainDlg, TIMER_ID_WIPE_PROGRESS);
-
- try
- {
- BootEncObj->AbortDecoyOSWipe ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
-
- e.Show (hwndDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
-
- if (decoySysPartitionWipeStatus.WipeInProgress)
- {
- ArrowWaitCursor ();
-
- UpdateWipeProgressBar ();
- }
-
- if (bDeviceWipeInProgress != decoySysPartitionWipeStatus.WipeInProgress)
- {
- bDeviceWipeInProgress = decoySysPartitionWipeStatus.WipeInProgress;
-
- UpdateWipeProgressBar ();
- UpdateWipeControls ();
-
- if (!bDeviceWipeInProgress)
- {
- // The driver stopped wiping
-
- KillTimer (hwndDlg, TIMER_ID_WIPE_PROGRESS);
- UpdateLastDialogId ();
-
- try
- {
- BootEncObj->CheckDecoyOSWipeResult();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- AbortProcessSilent();
- }
-
- if (BootEncStatus.ConfiguredEncryptedAreaEnd == decoySysPartitionWipeStatus.WipedAreaEnd)
- {
- // Decoy system partition has been fully wiped
-
- ChangeHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_WIPED);
-
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("EXIT"));
- EnableWindow (GetDlgItem (MainDlg, IDCANCEL), TRUE);
- EnableWindow (GetDlgItem (MainDlg, IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), FALSE);
-
- Info ("WIPE_FINISHED_DECOY_SYSTEM_PARTITION", MainDlg);
-
- TextInfoDialogBox (TC_TBXID_DECOY_OS_INSTRUCTIONS);
-
- if (BootEncObj->GetSystemDriveConfiguration().ExtraBootPartitionPresent)
- Warning ("DECOY_OS_VERSION_WARNING", MainDlg);
-
- return 1;
- }
- }
- }
- }
- else
- {
- // Regular device wipe (not decoy system partition wipe)
-
- //Info ("WIPE_FINISHED");
- }
- return 1;
- }
-
- return 0;
-
-
- case TC_APPMSG_PERFORM_POST_WMINIT_TASKS:
-
- AfterWMInitTasks (hwndDlg);
- return 1;
-
- case TC_APPMSG_FORMAT_FINISHED:
- {
- wchar_t tmp[RNG_POOL_SIZE*2+1];
-
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
- SetFocus (GetDlgItem (hwndDlg, IDC_NEXT));
-
- if (nCurPageNo == FORMAT_PAGE)
- KillTimer (hwndDlg, TIMER_ID_RANDVIEW);
-
- // Attempt to wipe the GUI fields showing portions of randpool, of the master and header keys
- wmemset (tmp, 'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hRandPool, tmp);
- SetWindowText (hMasterKey, tmp);
- SetWindowText (hHeaderKey, tmp);
-
- LoadPage (hwndDlg, FORMAT_FINISHED_PAGE);
- }
- return 1;
-
- case TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED:
-
- // A partition has just been fully encrypted in place
-
- KillTimer (hwndDlg, TIMER_ID_NONSYS_INPLACE_ENC_PROGRESS);
-
- if (bInPlaceDecNonSys)
- {
- // Decryption of non-system volume finished and free drive letters are available. Check if a drive letter is assigned to the decrypted volume.
-
- WCHAR deviceName[MAX_PATH + 1];
-
- StringCbCopyW (deviceName, sizeof(deviceName), szDiskFile);
-
- if (GetDiskDeviceDriveLetter (deviceName) < 0)
- {
- // No drive letter is assigned to the device
- MessageBeep (MB_OK);
- LoadPage (hwndDlg, NONSYS_INPLACE_DEC_TRANSFORM_FINISHED_DRIVE_LETTER_PAGE);
- return 1;
- }
- else
- {
- Info ("NONSYS_INPLACE_DEC_FINISHED_INFO", hwndDlg);
- }
- }
-
- LoadPage (hwndDlg, NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE);
- return 1;
-
- case TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED:
-
- if (bInPlaceEncNonSys)
- {
- // In-place encryption was interrupted/paused (did not finish)
-
- KillTimer (hwndDlg, TIMER_ID_NONSYS_INPLACE_ENC_PROGRESS);
-
- UpdateNonSysInPlaceEncControls ();
- }
- else
- {
- // Format has been aborted (did not finish)
-
- EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), (bDevice || bSparseFileSwitch) && !(bHiddenVol && !bHiddenVolHost));
- EnableWindow (GetDlgItem (hCurPage, IDC_FILESYS), TRUE);
- EnableWindow (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
- EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), TRUE);
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
- SendMessage (GetDlgItem (hCurPage, IDC_PROGRESS_BAR), PBM_SETPOS, 0, 0L);
- SetFocus (GetDlgItem (hwndDlg, IDC_NEXT));
- }
-
- NormalCursor ();
- return 1;
-
- case WM_HELP:
-
- OpenPageHelp (hwndDlg, nCurPageNo);
- return 1;
-
- case TC_APPMSG_FORMAT_USER_QUIT:
-
- if (nCurPageNo == NONSYS_INPLACE_ENC_TRANSFORM_PAGE
- && (bVolTransformThreadRunning || bVolTransformThreadToRun || bInPlaceEncNonSysResumed))
- {
- // Non-system encryption in progress
- if (AskNoYes ("NONSYS_INPLACE_ENC_DEFER_CONFIRM", hwndDlg) == IDYES)
- {
- NonSysInplaceEncPause ();
-
- EndMainDlg (hwndDlg);
- return 1;
- }
- else
- return 1; // Disallow close
- }
- else if (bVolTransformThreadRunning || bVolTransformThreadToRun)
- {
- // Format (non-in-place encryption) in progress
- if (AskNoYes ("FORMAT_ABORT", hwndDlg) == IDYES)
- {
- bVolTransformThreadCancel = TRUE;
-
- EndMainDlg (hwndDlg);
- return 1;
- }
- else
- return 1; // Disallow close
- }
- else if ((nCurPageNo == SYSENC_ENCRYPTION_PAGE || nCurPageNo == SYSENC_PRETEST_RESULT_PAGE)
- && SystemEncryptionStatus != SYSENC_STATUS_NONE
- && InstanceHasSysEncMutex ())
- {
- // System encryption/decryption in progress
-
- if (AskYesNo (SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING ?
- "SYSTEM_DECRYPTION_DEFER_CONFIRM" : "SYSTEM_ENCRYPTION_DEFER_CONFIRM", MainDlg) == IDYES)
- {
- if (nCurPageNo == SYSENC_PRETEST_RESULT_PAGE)
- TextInfoDialogBox (TC_TBXID_SYS_ENC_RESCUE_DISK);
-
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
-
- if (BootEncStatus.SetupInProgress)
- {
- BootEncObj->AbortSetupWait ();
- Sleep (200);
- BootEncStatus = BootEncObj->GetStatus();
- }
-
- if (!BootEncStatus.SetupInProgress)
- {
- EndMainDlg (MainDlg);
- return 1;
- }
- else
- {
- Error ("FAILED_TO_INTERRUPT_SYSTEM_ENCRYPTION", MainDlg);
- return 1; // Disallow close
- }
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
- return 1; // Disallow close
- }
- else
- return 1; // Disallow close
- }
- else if (bConfirmQuitSysEncPretest)
- {
- if (AskWarnNoYes (bHiddenOS ? "CONFIRM_CANCEL_HIDDEN_OS_CREATION" : "CONFIRM_CANCEL_SYS_ENC_PRETEST", MainDlg) == IDNO)
- return 1; // Disallow close
- }
- else if (bConfirmQuit)
- {
- if (AskWarnNoYes ("CONFIRM_EXIT_UNIVERSAL", MainDlg) == IDNO)
- return 1; // Disallow close
- }
-
- if (hiddenVolHostDriveNo > -1)
- {
- CloseVolumeExplorerWindows (hwndDlg, hiddenVolHostDriveNo);
- UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE);
- }
-
- EndMainDlg (hwndDlg);
- return 1;
-
-
- case WM_COMMAND:
-
- if (lw == IDHELP)
- {
- OpenPageHelp (hwndDlg, nCurPageNo);
- return 1;
- }
- else if (lw == IDCANCEL)
- {
- PostMessage (hwndDlg, TC_APPMSG_FORMAT_USER_QUIT, 0, 0);
- return 1;
- }
- else if (lw == IDC_NEXT)
- {
- if (nCurPageNo == INTRO_PAGE)
- {
- switch (GetSelectedWizardMode (hCurPage))
- {
- case WIZARD_MODE_FILE_CONTAINER:
-
- if (CurrentOSMajor >= 6 && IsUacSupported() && IsAdmin() && !IsBuiltInAdmin() && !IsNonInstallMode())
- {
- static bool warningConfirmed = false;
- if (!warningConfirmed)
- {
- if (AskWarnYesNo ("CONTAINER_ADMIN_WARNING", MainDlg) == IDYES)
- exit (0);
-
- warningConfirmed = true;
- }
- }
-
- WaitCursor ();
- CloseSysEncMutex ();
- ChangeWizardMode (WIZARD_MODE_FILE_CONTAINER);
- bHiddenOS = FALSE;
- bInPlaceEncNonSys = FALSE;
- nNewPageNo = VOLUME_TYPE_PAGE - 1; // Skip irrelevant pages
- break;
-
- case WIZARD_MODE_NONSYS_DEVICE:
-
- WaitCursor ();
- CloseSysEncMutex ();
-
- if (!ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE))
- {
- NormalCursor ();
- return 1;
- }
-
- bHiddenOS = FALSE;
- nNewPageNo = VOLUME_TYPE_PAGE - 1; // Skip irrelevant pages
- break;
-
- case WIZARD_MODE_SYS_DEVICE:
-
- WaitCursor ();
- bHiddenVol = FALSE;
- bInPlaceEncNonSys = FALSE;
- SwitchWizardToSysEncMode ();
- return 1;
- }
- }
- else if (nCurPageNo == SYSENC_TYPE_PAGE)
- {
- if (bHiddenOS)
- {
- bWholeSysDrive = FALSE;
- bHiddenVolDirect = FALSE;
- }
-
- if (!bHiddenOS)
- nNewPageNo = SYSENC_SPAN_PAGE - 1; // Skip irrelevant pages
- }
- else if (nCurPageNo == SYSENC_HIDDEN_OS_REQ_CHECK_PAGE)
- {
- WaitCursor ();
- try
- {
- BootEncObj->CheckRequirementsHiddenOS ();
-
- if (CheckGapBetweenSysAndHiddenOS ())
- Warning ("GAP_BETWEEN_SYS_AND_HIDDEN_OS_PARTITION", MainDlg);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- NormalCursor ();
- return 1;
- }
-
- if (AskWarnYesNo ("DECOY_OS_REINSTALL_WARNING", MainDlg) == IDNO)
- {
- NormalCursor ();
- return 1;
- }
-
- WarningDirect ((wstring (GetString ("HIDDEN_OS_WRITE_PROTECTION_BRIEF_INFO"))
- + L"\n\n"
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_EXPLANATION")).c_str(), MainDlg);
-
- if (!IsAdmin() && IsUacSupported())
- {
- // If UAC elevation is needed, we need to elevate the complete wizard process here, because
- // we will need to switch to the non-sys-device mode, which requires the whole wizard process
- // to have admin rights.
-
- CloseSysEncMutex ();
-
- if (!ElevateWholeWizardProcess (L"/r"))
- {
- // Failed to obtain admin rights
-
- NormalCursor ();
-
- if (!CreateSysEncMutex ())
- AbortProcess ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE");
-
- return 1;
- }
- }
-
- // This check requires admin rights
- try
- {
- BootEncObj->InitialSecurityChecksForHiddenOS ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- EndMainDlg (MainDlg); // Some of the checks need the wizard to be restarted (results are cached until exit and the checks would fail even if the issues were rectified).
- return 1;
- }
-
- nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE - 1; // Skip irrelevant pages
- }
- else if (nCurPageNo == SYSENC_SPAN_PAGE)
- {
- try
- {
- if (bWholeSysDrive && !BootEncObj->SystemPartitionCoversWholeDrive())
- {
- if (BootEncObj->SystemDriveContainsNonStandardPartitions())
- {
- if (AskWarnYesNoString ((wstring (GetString ("SYSDRIVE_NON_STANDARD_PARTITIONS")) + L"\n\n" + GetString ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE")).c_str(), MainDlg) == IDYES)
- bWholeSysDrive = FALSE;
- }
-
- if (!IsOSAtLeast (WIN_VISTA) && bWholeSysDrive)
- {
- if (BootEncObj->SystemDriveContainsExtendedPartition())
- {
- Error ("WDE_UNSUPPORTED_FOR_EXTENDED_PARTITIONS", MainDlg);
-
- if (AskYesNo ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE", MainDlg) == IDNO)
- return 1;
-
- bWholeSysDrive = FALSE;
- }
- else
- Warning ("WDE_EXTENDED_PARTITIONS_WARNING", hwndDlg);
- }
- }
-
- if (!bWholeSysDrive && BootEncObj->SystemPartitionCoversWholeDrive())
- bWholeSysDrive = (AskYesNo ("WHOLE_SYC_DEVICE_RECOM", hwndDlg) == IDYES);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- NormalCursor ();
- return 1;
- }
-
- if (!bWholeSysDrive)
- nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE - 1; // Skip irrelevant pages
- }
- else if (nCurPageNo == SYSENC_PRE_DRIVE_ANALYSIS_PAGE)
- {
- if ((SysEncDetectHiddenSectors = Get2RadButtonPageAnswer()) != 1)
- {
- // Skip drive analysis
- nNewPageNo = SYSENC_DRIVE_ANALYSIS_PAGE;
-
- // If the user had already searched for hidden sectors, we must clear (invalidate) the
- // result because now he changed his mind and no longer wishes to encrypt the hidden sectors.
- try
- {
- BootEncObj->InvalidateCachedSysDriveProperties ();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- EndMainDlg (MainDlg);
- exit(0);
- }
- }
- }
- else if (nCurPageNo == SYSENC_MULTI_BOOT_MODE_PAGE)
- {
- if (nMultiBoot > 1)
- {
- // Multi-boot
-
- if (AskWarnNoYes ("MULTI_BOOT_FOR_ADVANCED_ONLY", hwndDlg) == IDNO)
- return 1;
-
- if (bHiddenOS)
- {
- if (AskWarnNoYes ("HIDDEN_OS_MULTI_BOOT", hwndDlg) == IDNO)
- {
- Error ("UNSUPPORTED_HIDDEN_OS_MULTI_BOOT_CFG", hwndDlg);
- return 1;
- }
- }
- }
-
- if (bHiddenOS)
- {
- if (IsOSAtLeast (WIN_7)
- && BootEncObj->GetSystemDriveConfiguration().ExtraBootPartitionPresent
- && AskWarnYesNo ("CONFIRM_HIDDEN_OS_EXTRA_BOOT_PARTITION", hwndDlg) == IDNO)
- {
- TextInfoDialogBox (TC_TBXID_EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS);
- NormalCursor ();
- return 1;
- }
-
- if (AskWarnYesNo ("DECOY_OS_REQUIREMENTS", hwndDlg) == IDNO)
- {
- NormalCursor ();
- return 1;
- }
-
- if (!ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE))
- {
- NormalCursor ();
- return 1;
- }
-
- // Skip irrelevant pages
- nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE - 1;
- }
- else if (nMultiBoot <= 1)
- {
- // Single-boot (not creating a hidden OS)
-
- // Skip irrelevant pages
- nNewPageNo = CIPHER_PAGE - 1;
- }
- }
- else if (nCurPageNo == SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE)
- {
- SysEncMultiBootCfg.SystemOnBootDrive = Get2RadButtonPageAnswer ();
-
- if (!SysEncMultiBootCfg.SystemOnBootDrive)
- {
- Error ("SYS_PARTITION_MUST_BE_ON_BOOT_DRIVE", hwndDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
- }
- else if (nCurPageNo == SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_PAGE)
- {
- if (Get2RadButtonPageAnswer () == 0)
- {
- // 2 or more drives contain an OS
-
- SysEncMultiBootCfg.NumberOfSysDrives = 2;
- }
- else if (Get2RadButtonPageAnswer () == 1)
- {
- // Only 1 drive contains an OS
-
- SysEncMultiBootCfg.NumberOfSysDrives = 1;
-
- if (bWholeSysDrive)
- {
- // Whole-system-drive encryption is currently not supported if the drive contains
- // more than one system
- Error ("WDE_UNSUPPORTED_FOR_MULTIPLE_SYSTEMS_ON_ONE_DRIVE", hwndDlg);
- return 1;
- }
-
- // Ask whether there is a non-Windows boot loader in the MBR
- nNewPageNo = SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE - 1;
- }
- }
- else if (nCurPageNo == SYSENC_MULTI_BOOT_ADJACENT_SYS_PAGE)
- {
- SysEncMultiBootCfg.MultipleSystemsOnDrive = Get2RadButtonPageAnswer ();
-
- if (SysEncMultiBootCfg.MultipleSystemsOnDrive && bWholeSysDrive)
- {
- // Whole-system-drive encryption is currently not supported if the drive contains
- // more than one system
- Error ("WDE_UNSUPPORTED_FOR_MULTIPLE_SYSTEMS_ON_ONE_DRIVE", hwndDlg);
- return 1;
- }
- }
-
- else if (nCurPageNo == SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE)
- {
- SysEncMultiBootCfg.BootLoaderBrand = Get2RadButtonPageAnswer ();
-
- if (SysEncMultiBootCfg.BootLoaderBrand)
- {
- // A non-Windows boot manager in the MBR
- Error ("CUSTOM_BOOT_MANAGERS_IN_MBR_UNSUPPORTED", hwndDlg);
- EndMainDlg (MainDlg);
- return 1;
- }
- else
- {
- // Either a standard Windows boot manager or no boot manager
- wcscpy_s (SysEncMultiBootCfgOutcome, sizeof(SysEncMultiBootCfgOutcome) / 2, GetString ("WINDOWS_BOOT_LOADER_HINTS"));
- }
- }
-
- else if (nCurPageNo == SYSENC_MULTI_BOOT_OUTCOME_PAGE)
- {
- if (bHiddenOS)
- {
- if (!ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE))
- {
- NormalCursor ();
- return 1;
- }
-
- nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE - 1; // Skip irrelevant pages
- }
- else
- nNewPageNo = CIPHER_PAGE - 1; // Skip irrelevant pages
- }
-
- else if (nCurPageNo == VOLUME_TYPE_PAGE)
- {
- if (IsButtonChecked (GetDlgItem (hCurPage, IDC_HIDDEN_VOL)))
- {
- if (!IsAdmin() && !IsUacSupported ()
- && IDNO == MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_HIDVOL"),
- lpszTitle, MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2))
- {
- return 1;
- }
- else
- {
- bHiddenVol = TRUE;
- bHiddenVolHost = TRUE;
- bInPlaceEncNonSys = FALSE;
- }
- }
- else
- {
- bHiddenVol = FALSE;
- bHiddenVolHost = FALSE;
- bHiddenVolDirect = FALSE;
- nNewPageNo = VOLUME_LOCATION_PAGE - 1; // Skip the hidden volume creation wizard mode selection
- }
- }
-
- else if (nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE)
- {
- if (IsButtonChecked (GetDlgItem (hCurPage, IDC_HIDVOL_WIZ_MODE_DIRECT)))
- bHiddenVolDirect = TRUE;
- else
- {
- if (IsHiddenOSRunning())
- {
- WarningDirect ((wstring (GetString ("HIDDEN_VOL_CREATION_UNDER_HIDDEN_OS_HOWTO"))
- + L"\n\n"
- + GetString ("NOTE_BEGINNING")
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_BRIEF_INFO")
- + L" "
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_EXPLANATION")).c_str(), hwndDlg);
- NormalCursor ();
- return 1;
- }
-
- bHiddenVolDirect = FALSE;
- }
- }
-
- else if (nCurPageNo == VOLUME_LOCATION_PAGE)
- {
- BOOL tmpbDevice;
-
- WaitCursor();
-
- GetWindowTextW (GetDlgItem (hCurPage, IDC_COMBO_BOX), szFileName, ARRAYSIZE (szFileName));
- RelativePath2Absolute (szFileName);
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &tmpbDevice);
-
- if (tmpbDevice != bDevice)
- {
- if (bDevice)
- {
- // Not a valid device path
- Error ("CANNOT_CALC_SPACE", hwndDlg);
- NormalCursor ();
- return 1;
- }
- else
- {
- if (AskWarnYesNo ("DEVICE_SELECTED_IN_NON_DEVICE_MODE", hwndDlg) == IDNO)
- {
- NormalCursor ();
- return 1;
- }
-
- SwitchWizardToNonSysDeviceMode ();
- NormalCursor ();
- return 1;
- }
- }
-
- MoveEditToCombo (GetDlgItem (hCurPage, IDC_COMBO_BOX), bHistory);
-
- if (IsMountedVolume (szDiskFile))
- {
- Error ("ALREADY_MOUNTED", hwndDlg);
- NormalCursor ();
- return 1;
- }
-
- if (bDevice)
- {
- switch (IsSystemDevicePath (szDiskFile, hCurPage, TRUE))
- {
- case 1:
- case 2:
- case 3:
- if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
- {
- NormalCursor ();
- return 1;
- }
- szFileName[0] = 0;
- szDiskFile[0] = 0;
- SwitchWizardToSysEncMode ();
- NormalCursor ();
- return 1;
-
- case -1:
- // In some environments (such as PE), the system volume is not located on a hard drive.
- // Therefore, we must interpret this return code as "Not a system device path" (otherwise,
- // non-system devices could not be TC-formatted in such environments). Note that this is
- // rather safe, because bReliableRequired is set to TRUE.
-
- // NOP
- break;
- }
- }
- else
- {
- if (CheckFileExtension(szFileName)
- && AskWarnNoYes ("EXE_FILE_EXTENSION_CONFIRM", hwndDlg) == IDNO)
- {
- NormalCursor ();
- return 1;
- }
- }
-
- bHistory = !IsButtonChecked (GetDlgItem (hCurPage, IDC_NO_HISTORY));
-
- SaveSettings (hCurPage);
-
- if (bHiddenVolDirect && bHiddenVolHost)
- {
- nNewPageNo = HIDDEN_VOL_HOST_PASSWORD_PAGE - 1;
-
- if (bDevice)
- {
- if(!QueryFreeSpace (hwndDlg, GetDlgItem (hwndDlg, IDC_SPACE_LEFT), FALSE))
- {
- MessageBoxW (hwndDlg, GetString ("CANT_GET_VOLSIZE"), lpszTitle, ICON_HAND);
- NormalCursor ();
- return 1;
- }
- else
- nHiddenVolHostSize = nVolumeSize;
- }
- else
- {
- if (!GetFileVolSize (hwndDlg, &nHiddenVolHostSize))
- {
- NormalCursor ();
- return 1;
- }
- else if (IsSparseFile (hwndDlg))
- {
- // Hidden volumes must not be created within sparse file containers
- Warning ("HIDDEN_VOL_HOST_SPARSE", hwndDlg);
- NormalCursor ();
- return 1;
- }
- }
- }
- else
- {
- if (!bHiddenVol && !bDevice)
- nNewPageNo = CIPHER_PAGE - 1;
- else if (bHiddenVol)
- nNewPageNo = (bHiddenVolHost ? HIDDEN_VOL_HOST_PRE_CIPHER_PAGE : HIDDEN_VOL_PRE_CIPHER_PAGE) - 1;
- }
- }
-
- else if (nCurPageNo == DEVICE_TRANSFORM_MODE_PAGE)
- {
- if (bInPlaceEncNonSys)
- {
- // Check requirements for non-system in-place encryption
-
- if (!CheckRequirementsForNonSysInPlaceEnc (hwndDlg, szDiskFile, FALSE))
- {
- return 1;
- }
-
- // We are going to skip the Size page so we must get the size here
- nVolumeSize = GetDeviceSize (szDiskFile);
-
- if (nVolumeSize == -1)
- {
- handleWin32Error (MainDlg, SRC_POS);
- return 1;
- }
-
- if (AskWarnYesNo ("NONSYS_INPLACE_ENC_CONFIRM_BACKUP", hwndDlg) == IDNO)
- return 1;
- }
- nNewPageNo = CIPHER_PAGE - 1;
- }
-
- else if (nCurPageNo == HIDDEN_VOL_HOST_PRE_CIPHER_PAGE)
- {
- if (bHiddenVolHost)
- nNewPageNo = CIPHER_PAGE - 1; // Skip the info on the hiddem volume
- }
-
- else if (nCurPageNo == CIPHER_PAGE)
- {
- LPARAM nIndex;
- nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0);
- nVolumeEA = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0);
-
- if (SysEncInEffect ()
- && EAGetCipherCount (nVolumeEA) > 1) // Cascade?
- {
- if (AskWarnNoYes ("CONFIRM_CASCADE_FOR_SYS_ENCRYPTION", hwndDlg) == IDNO)
- return 1;
-
- if (!bHiddenOS)
- Info ("NOTE_CASCADE_FOR_SYS_ENCRYPTION", hwndDlg);
- }
-
- nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), CB_GETCURSEL, 0, 0);
- hash_algo = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), CB_GETITEMDATA, nIndex, 0);
-
- RandSetHashFunction (hash_algo);
-
- if (SysEncInEffect () || bInPlaceEncNonSys)
- nNewPageNo = PASSWORD_PAGE - 1; // Skip irrelevant pages
- }
-
- else if (nCurPageNo == SIZE_PAGE)
- {
- wchar_t szFileSystemNameBuffer[256];
-
- VerifySizeAndUpdate (hCurPage, TRUE);
-
- if (!bDevice)
- {
- /* Verify that the volume would not be too large for the host file system */
-
- wchar_t root[TC_MAX_PATH];
-
- if (GetVolumePathName (szDiskFile, root, ARRAYSIZE (root))
- && GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFileSystemNameBuffer, ARRAYSIZE(szFileSystemNameBuffer))
- && !wcsncmp (szFileSystemNameBuffer, L"FAT32", 5))
- {
- // The host file system is FAT32
- if (nUIVolumeSize * nMultiplier >= 4 * BYTES_PER_GB)
- {
- Error ("VOLUME_TOO_LARGE_FOR_FAT32", hwndDlg);
- return 1;
- }
- }
-
- /* Verify that the volume would not be too large for the operating system */
-
- if (!IsOSAtLeast (WIN_VISTA)
- && nUIVolumeSize * nMultiplier > 2 * BYTES_PER_TB)
- {
- Warning ("VOLUME_TOO_LARGE_FOR_WINXP", hwndDlg);
- }
- }
-
- if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
- {
- /* Ask for confirmation if the hidden volume is too large for the user to be
- able to write much more data to the outer volume. */
-
- if (((double) nUIVolumeSize / (nMaximumHiddenVolSize / nMultiplier)) > 0.85) // 85%
- {
- if (AskWarnNoYes ("FREE_SPACE_FOR_WRITING_TO_OUTER_VOLUME", hwndDlg) == IDNO)
- return 1;
- }
- }
-
- if (!(bHiddenVolDirect && bHiddenVolHost))
- nNewPageNo = PASSWORD_PAGE - 1;
- }
-
- else if (nCurPageNo == PASSWORD_PAGE)
- {
- VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (MainDlg, IDC_NEXT),
- GetDlgItem (hCurPage, IDC_PASSWORD),
- GetDlgItem (hCurPage, IDC_VERIFY),
- volumePassword.Text,
- szVerify,
- KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect());
-
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
-
- if (volumePassword.Length > 0)
- {
- // Password character encoding
- if (SysEncInEffect () && !CheckPasswordCharEncoding (GetDlgItem (hCurPage, IDC_PASSWORD), NULL))
- {
- Error ("UNSUPPORTED_CHARS_IN_PWD", hwndDlg);
- return 1;
- }
- // Check password length (check also done for outer volume which is not the case in TrueCrypt).
- else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, 0, SysEncInEffect(), FALSE, FALSE))
- {
- return 1;
- }
- }
-
- // Store the password in case we need to restore it after keyfile is applied to it
- if (!GetPassword (hCurPage, IDC_PASSWORD, szRawPassword, sizeof (szRawPassword), TRUE))
- return 1;
-
- if (!SysEncInEffect ())
- {
- if (KeyFilesEnable)
- {
- WaitCursor ();
-
- if (!KeyFilesApply (hwndDlg, &volumePassword, FirstKeyFile, NULL))
- {
- NormalCursor ();
- return 1;
- }
-
- NormalCursor ();
- }
-
- }
- else
- {
- KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
-
- if (bKeyboardLayoutChanged)
- {
- // Restore the original keyboard layout
- if (LoadKeyboardLayout (OrigKeyboardLayout, KLF_ACTIVATE | KLF_SUBSTITUTE_OK) == NULL)
- Warning ("CANNOT_RESTORE_KEYBOARD_LAYOUT", hwndDlg);
- else
- bKeyboardLayoutChanged = FALSE;
- }
-
- }
-
- if (!PimEnable)
- {
- // PIM not activated. Skip PIM page
- nNewPageNo = PIM_PAGE;
- volumePim = 0;
-
- if (SysEncInEffect ())
- {
- nNewPageNo = SYSENC_COLLECTING_RANDOM_DATA_PAGE - 1; // Skip irrelevant pages
- }
-
- if (bInPlaceEncNonSys)
- {
- nNewPageNo = NONSYS_INPLACE_ENC_RAND_DATA_PAGE - 1; // Skip irrelevant pages
- }
- else if (WizardMode != WIZARD_MODE_SYS_DEVICE
- && !FileSize4GBLimitQuestionNeeded ()
- || CreatingHiddenSysVol()) // If we're creating a hidden volume for a hidden OS, we don't need to format it with any filesystem (the entire OS will be copied to the hidden volume sector by sector).
- {
- nNewPageNo = FORMAT_PAGE - 1; // Skip irrelevant pages
- }
-
- }
- }
-
- else if (nCurPageNo == PIM_PAGE)
- {
- volumePim = GetPim (hCurPage, IDC_PIM);
-
- if (!SysEncInEffect() && (volumePim > MAX_PIM_VALUE))
- {
- SetFocus (GetDlgItem(hCurPage, IDC_PIM));
- Error ("PIM_TOO_BIG", hwndDlg);
- return 1;
- }
-
- if (volumePassword.Length > 0)
- {
- // Password character encoding
- if (SysEncInEffect() && (volumePim > MAX_BOOT_PIM_VALUE))
- {
- SetFocus (GetDlgItem(hCurPage, IDC_PIM));
- Error ("PIM_SYSENC_TOO_BIG", hwndDlg);
- return 1;
- }
- // Check password length (check also done for outer volume which is not the case in TrueCrypt).
- else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, volumePim, SysEncInEffect(), TRUE, FALSE))
- {
- return 1;
- }
- }
-
- if (SysEncInEffect ())
- {
-
- nNewPageNo = SYSENC_COLLECTING_RANDOM_DATA_PAGE - 1; // Skip irrelevant pages
- }
-
- if (bInPlaceEncNonSys)
- {
- nNewPageNo = NONSYS_INPLACE_ENC_RAND_DATA_PAGE - 1; // Skip irrelevant pages
- }
- else if (WizardMode != WIZARD_MODE_SYS_DEVICE
- && !FileSize4GBLimitQuestionNeeded ()
- || CreatingHiddenSysVol()) // If we're creating a hidden volume for a hidden OS, we don't need to format it with any filesystem (the entire OS will be copied to the hidden volume sector by sector).
- {
- nNewPageNo = FORMAT_PAGE - 1; // Skip irrelevant pages
- }
- }
-
- else if (nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- {
- WaitCursor ();
-
- if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, MAX_PASSWORD + 1, TRUE))
- {
- NormalCursor ();
- return 1;
- }
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
-
- hash_algo = (int) SendMessage (GetDlgItem (hCurPage, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hCurPage, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
-
- volumePim = GetPim (hCurPage, IDC_PIM);
-
- // Store the password in case we need to restore it after keyfile is applied to it
- if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, sizeof (szRawPassword), TRUE))
- {
- NormalCursor ();
- return 1;
- }
-
- if (KeyFilesEnable)
- {
- KeyFilesApply (hwndDlg, &volumePassword, FirstKeyFile, NULL);
- }
-
- if (!bInPlaceEncNonSys)
- {
-
- /* Mount the volume which is to host the new hidden volume as read only */
-
- if (hiddenVolHostDriveNo >= 0) // If the hidden volume host is currently mounted (e.g. after previous unsuccessful dismount attempt)
- {
- BOOL tmp_result;
-
- // Dismount the hidden volume host (in order to remount it as read-only subsequently)
- while (!(tmp_result = UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE)))
- {
- if (MessageBoxW (hwndDlg, GetString ("CANT_DISMOUNT_OUTER_VOL"), lpszTitle, MB_RETRYCANCEL) != IDRETRY)
- {
- // Cancel
- NormalCursor();
- return 1;
- }
- }
- if (tmp_result) // If dismounted
- hiddenVolHostDriveNo = -1;
- }
-
- if (hiddenVolHostDriveNo < 0) // If the hidden volume host is not mounted
- {
- int retCode;
-
- // Mount the hidden volume host as read-only (to ensure consistent and secure
- // results of the volume bitmap scanning)
- switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, volumePim, TRUE))
- {
- case ERR_NO_FREE_DRIVES:
- NormalCursor ();
- MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
- return 1;
- case ERR_VOL_MOUNT_FAILED:
- case ERR_PASSWORD_WRONG:
- NormalCursor ();
- return 1;
- case 0:
-
- /* Hidden volume host successfully mounted as read-only */
-
- WaitCursor ();
-
- // Verify that the outer volume contains a suitable file system, retrieve cluster size, and
- // scan the volume bitmap
- if (!IsAdmin () && IsUacSupported ())
- retCode = UacAnalyzeHiddenVolumeHost (hwndDlg, &hiddenVolHostDriveNo, GetVolumeDataAreaSize (FALSE, nHiddenVolHostSize), &realClusterSize, &nbrFreeClusters);
- else
- retCode = AnalyzeHiddenVolumeHost (hwndDlg, &hiddenVolHostDriveNo, GetVolumeDataAreaSize (FALSE, nHiddenVolHostSize), &realClusterSize, &nbrFreeClusters);
-
- switch (retCode)
- {
- case -1: // Fatal error
- CloseVolumeExplorerWindows (hwndDlg, hiddenVolHostDriveNo);
-
- if (UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE))
- hiddenVolHostDriveNo = -1;
-
- AbortProcessSilent ();
- break;
-
- case 0: // Unsupported file system (or other non-fatal error which has already been reported)
- if (bHiddenVolDirect)
- {
- CloseVolumeExplorerWindows (hwndDlg, hiddenVolHostDriveNo);
-
- if (UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE))
- hiddenVolHostDriveNo = -1;
- }
- NormalCursor ();
- return 1;
-
- case 1:
-
- // Determine the maximum possible size of the hidden volume
- if (DetermineMaxHiddenVolSize (hwndDlg) < 1)
- {
- // Non-fatal error while determining maximum possible size of the hidden volume
- NormalCursor();
- return 1;
- }
- else
- {
- BOOL tmp_result;
-
- /* Maximum possible size of the hidden volume successfully determined */
-
- // Dismount the hidden volume host
- while (!(tmp_result = UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE)))
- {
- if (MessageBoxW (hwndDlg, GetString ("CANT_DISMOUNT_OUTER_VOL"), lpszTitle, MB_RETRYCANCEL) != IDRETRY)
- {
- // Cancel
- NormalCursor();
- return 1;
- }
- }
-
- if (tmp_result) // If dismounted
- {
- hiddenVolHostDriveNo = -1;
-
- bHiddenVolHost = FALSE;
- bHiddenVolFinished = FALSE;
-
- // Clear the outer volume password
- WipePasswordsAndKeyfiles ();
-
- RestoreDefaultKeyFilesParam ();
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), TRUE);
- NormalCursor ();
-
- nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE;
- }
- }
- break;
- }
- break;
- }
- }
- }
- else if (bInPlaceEncNonSysResumed)
- {
- /* Scan all available partitions to discover all partitions where non-system in-place
- encryption/decryption has been interrupted. */
-
- BOOL tmpbDevice;
-
- NormalCursor ();
-
- ShowWaitDialog (hwndDlg, TRUE, ResumeInPlaceEncWaitThreadProc, NULL);
-
- WaitCursor();
-
- if (DeferredNonSysInPlaceEncDevices.empty())
- {
- Warning ("FOUND_NO_PARTITION_W_DEFERRED_INPLACE_ENC", hwndDlg);
-
- NormalCursor();
- return 1;
- }
- else if (DeferredNonSysInPlaceEncDevices.size() == 1)
- {
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), DeferredNonSysInPlaceEncDevices.front().Path.c_str(), &tmpbDevice);
-
- nVolumeSize = GetDeviceSize (szDiskFile);
- if (nVolumeSize == -1)
- {
- handleWin32Error (MainDlg, SRC_POS);
- NormalCursor();
- return 1;
- }
-
- nNewPageNo = NONSYS_INPLACE_ENC_TRANSFORM_PAGE - 1; // Skip irrelevant pages
- }
-
- NormalCursor();
- }
- else
- {
- /* Try to mount the non-system volume to decrypt in place (the process has not started yet, we are NOT trying to resume it).
- We will try to mount it using the backup header, which we require to work (i.e. be non-damaged) before we start writing
- to the volume (the primary header will be overwritten by decrypted data soon after the decryption process begins, so the
- backup header will contain the only copy of the master key). */
-
- int driveNo = -1;
-
- // The volume may already be mounted. We need to dismount it first in order to verify the supplied password/keyfile(s) is/are correct.
- if (IsMountedVolume (szFileName))
- {
- driveNo = GetMountedVolumeDriveNo (szFileName);
-
- if (driveNo == -1
- || !UnmountVolume (hwndDlg, driveNo, TRUE))
- {
- handleWin32Error (MainDlg, SRC_POS);
- AbortProcess ("CANT_DISMOUNT_VOLUME");
- }
- }
-
- driveNo = GetLastAvailableDrive ();
-
- if (driveNo < 0)
- AbortProcess ("NO_FREE_DRIVES");
-
- MountOptions mountOptions;
- ZeroMemory (&mountOptions, sizeof (mountOptions));
-
- mountOptions.UseBackupHeader = FALSE; // This must be FALSE at this point because otherwise we wouldn't be able to detect a legacy volume
- mountOptions.ReadOnly = TRUE;
- mountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
-
- // Check that it is not a hidden or legacy volume
-
- if (MountVolume (hwndDlg, driveNo, szFileName, &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1)
- {
- NormalCursor();
- return 1;
- }
-
- {
- DWORD dwResult;
- VOLUME_PROPERTIES_STRUCT volProp;
-
- memset (&volProp, 0, sizeof(volProp));
- volProp.driveNo = driveNo;
- if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &volProp, sizeof (volProp), &volProp, sizeof (volProp), &dwResult, NULL) || dwResult == 0)
- {
- handleWin32Error (hwndDlg, SRC_POS);
- UnmountVolume (hwndDlg, driveNo, TRUE);
- AbortProcess ("CANT_GET_VOL_INFO");
- }
-
- if (volProp.volFormatVersion == TC_VOLUME_FORMAT_VERSION_PRE_6_0)
- {
- UnmountVolume (hwndDlg, driveNo, TRUE);
- AbortProcess ("NONSYS_INPLACE_DECRYPTION_BAD_VOL_FORMAT");
- }
-
- if (volProp.hiddenVolume)
- {
- UnmountVolume (hwndDlg, driveNo, TRUE);
- AbortProcess ("NONSYS_INPLACE_DECRYPTION_CANT_DECRYPT_HID_VOL");
- }
- }
-
- // Remount the volume using the backup header to verify it is working
-
- if (!UnmountVolume (hwndDlg, driveNo, TRUE))
- {
- handleWin32Error (MainDlg, SRC_POS);
- AbortProcess ("CANT_DISMOUNT_VOLUME");
- }
-
- mountOptions.UseBackupHeader = TRUE; // This must be TRUE at this point (we won't be using the regular header, which will be lost soon after the decryption process starts)
-
- if (MountVolume (hwndDlg, driveNo, szFileName, &volumePassword, hash_algo, volumePim, FALSE, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1)
- {
- NormalCursor();
- return 1;
- }
-
- if (!UnmountVolume (hwndDlg, driveNo, TRUE))
- {
- handleWin32Error (MainDlg, SRC_POS);
- AbortProcess ("CANT_DISMOUNT_VOLUME");
- }
-
- BOOL tmpbDevice;
-
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &tmpbDevice);
-
- nVolumeSize = GetDeviceSize (szDiskFile);
- if (nVolumeSize == -1)
- {
- handleWin32Error (MainDlg, SRC_POS);
- AbortProcessSilent ();
- }
-
- nNewPageNo = NONSYS_INPLACE_ENC_TRANSFORM_PAGE - 1; // Skip irrelevant pages
- NormalCursor();
- }
- }
-
- else if (nCurPageNo == FILESYS_PAGE)
- {
- if (!bHiddenVol && IsHiddenOSRunning() && Get2RadButtonPageAnswer() == 1)
- {
- // The user wants to store files larger than 4GB on the non-hidden volume about to be created and a hidden OS is running
-
- WarningDirect ((wstring (GetString ("CANNOT_SATISFY_OVER_4G_FILE_SIZE_REQ"))
- + L" "
- + GetString ("CANNOT_CREATE_NON_HIDDEN_NTFS_VOLUMES_UNDER_HIDDEN_OS")
- + L"\n\n"
- + GetString ("NOTE_BEGINNING")
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_BRIEF_INFO")
- + L" "
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_EXPLANATION")).c_str(), hwndDlg);
-
- return 1;
- }
-
- if (nNeedToStoreFilesOver4GB != Get2RadButtonPageAnswer())
- fileSystem = FILESYS_NONE; // The user may have gone back and changed the answer, so default file system must be reselected
-
- nNeedToStoreFilesOver4GB = Get2RadButtonPageAnswer();
-
- nNewPageNo = FORMAT_PAGE - 1; // Skip irrelevant pages
- }
-
- else if (nCurPageNo == SYSENC_COLLECTING_RANDOM_DATA_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RAND_DATA_PAGE)
- {
- wchar_t tmp[RANDPOOL_DISPLAY_SIZE+1];
-
- if (!bInPlaceEncNonSys)
- {
- /* Generate master key and other related data (except the rescue disk) for system encryption. */
-
- try
- {
- WaitCursor();
- BootEncObj->PrepareInstallation (!bWholeSysDrive, volumePassword, nVolumeEA, FIRST_MODE_OF_OPERATION_ID, hash_algo, volumePim, L"");
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- NormalCursor ();
- return 1;
- }
- }
-
- KillTimer (hwndDlg, TIMER_ID_RANDVIEW);
-
- // Attempt to wipe the GUI field showing portions of randpool
- wmemset (tmp, L'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hRandPoolSys, tmp);
-
- NormalCursor ();
- }
-
- else if (nCurPageNo == SYSENC_KEYS_GEN_PAGE)
- {
- wchar_t tmp[KEY_GUI_VIEW_SIZE+1];
-
- // Attempt to wipe the GUI fields showing portions of the master and header keys
- wmemset (tmp, L'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hMasterKey, tmp);
- SetWindowText (hHeaderKey, tmp);
- }
-
- else if (nCurPageNo == SYSENC_RESCUE_DISK_CREATION_PAGE)
- {
- /* Generate rescue disk for boot encryption */
-
- GetWindowText (GetDlgItem (hCurPage, IDC_RESCUE_DISK_ISO_PATH), szRescueDiskISO, ARRAYSIZE (szRescueDiskISO));
-
- bDontVerifyRescueDisk = GetCheckBox (hCurPage, IDC_SKIP_RESCUE_VERIFICATION);
-
- try
- {
- WaitCursor();
- BootEncObj->CreateRescueIsoImage (true, szRescueDiskISO);
-
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- NormalCursor ();
- return 1;
- }
-
-retryCDDriveCheck:
- if (!bDontVerifyRescueDisk && !BootEncObj->IsCDRecorderPresent())
- {
- char *multiChoiceStr[] = { 0, "CD_BURNER_NOT_PRESENT",
- "CD_BURNER_NOT_PRESENT_WILL_STORE_ISO",
- "CD_BURNER_NOT_PRESENT_WILL_CONNECT_LATER",
- "CD_BURNER_NOT_PRESENT_CONNECTED_NOW",
- 0 };
-
- switch (AskMultiChoice ((void **) multiChoiceStr, FALSE, hwndDlg))
- {
- case 1:
- wchar_t msg[8192];
- StringCchPrintfW (msg, array_capacity (msg), GetString ("CD_BURNER_NOT_PRESENT_WILL_STORE_ISO_INFO"), szRescueDiskISO);
- WarningDirect (msg, hwndDlg);
-
- Warning ("RESCUE_DISK_BURN_NO_CHECK_WARN", hwndDlg);
- bDontVerifyRescueDisk = TRUE;
- nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE;
- break;
-
- case 2:
- AbortProcessSilent();
-
- case 3:
- break;
-
- default:
- goto retryCDDriveCheck;
- }
- }
-
- if (IsWindowsIsoBurnerAvailable() && !bDontVerifyRescueDisk)
- Info ("RESCUE_DISK_WIN_ISOBURN_PRELAUNCH_NOTE", hwndDlg);
-
- NormalCursor ();
- }
-
- else if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE)
- {
- if (!bDontVerifyRescueDisk)
- {
- /* Verify that the rescue disk has been written correctly */
-
- try
- {
- WaitCursor();
- if (!BootEncObj->VerifyRescueDisk ())
- {
- wchar_t szTmp[8000];
-
- StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("RESCUE_DISK_CHECK_FAILED"),
- IsWindowsIsoBurnerAvailable () ? L"" : GetString ("RESCUE_DISK_CHECK_FAILED_SENTENCE_APPENDIX"));
-
- ErrorDirect (szTmp, hwndDlg);
-
- NormalCursor ();
-#ifndef _DEBUG
- return 1;
-#endif
- }
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- NormalCursor ();
- return 1;
- }
- NormalCursor ();
- }
- else
- {
- Warning ("RESCUE_DISK_BURN_NO_CHECK_WARN", hwndDlg);
- nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE; // Skip irrelevant pages
- }
- }
-
- else if (nCurPageNo == SYSENC_WIPE_MODE_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE)
- {
- if (nWipeMode > 0
- && AskWarnYesNo ("WIPE_MODE_WARN", hwndDlg) == IDNO)
- return 1;
- }
-
- else if (nCurPageNo == SYSENC_PRETEST_INFO_PAGE)
- {
- if (LocalizationActive
- && AskWarnYesNo ("PREBOOT_NOT_LOCALIZED", hwndDlg) == IDNO)
- return 1;
-
- bConfirmQuitSysEncPretest = TRUE;
-
- if (!bHiddenOS) // This text is not tailored to hidden OS
- TextInfoDialogBox (TC_TBXID_SYS_ENCRYPTION_PRETEST);
-
- if (AskWarnYesNo ("CONFIRM_RESTART", hwndDlg) == IDNO)
- return 1;
-
- /* Install the pre-boot authentication component and initiate the system encryption pretest.
- If we are creating a hidden OS, pretest is omitted and OS cloning will follow. */
-
- try
- {
- WaitCursor();
-
-#if 0
- // Make sure the Rescue Disk is not in the drive
- while (BootEncObj->VerifyRescueDisk ())
- {
- Error ("REMOVE_RESCUE_DISK_FROM_DRIVE");
- }
-#endif
-
- BootEncObj->Install (bHiddenOS ? true : false);
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- Error (bHiddenOS ? "CANNOT_INITIATE_HIDDEN_OS_CREATION" : "CANNOT_INITIATE_SYS_ENCRYPTION_PRETEST", hwndDlg);
- NormalCursor ();
- return 1;
- }
-
-
- /* Add the main TrueCrypt app to the system startup sequence (the TrueCrypt Background Task), which
- we need e.g. for notifications about prevented hibernation, about hidden OS leak protection, about
- inconsistent hidden OS installs (TrueCrypt upgraded in the decoy system but not in the hidden one), etc.
- Note that this must be done before calling ChangeSystemEncryptionStatus(), which broadcasts the change,
- so that the main app (if it's running with different cached settings) will not overwrite our new
- settings when it exits. */
- bStartOnLogon = TRUE;
- SaveSettings (NULL);
- ManageStartupSeq ();
-
-
- if (bHiddenOS)
- {
- /* When we are going to create a hidden OS, the system encryption status is set
- to SYSENC_STATUS_PRETEST (not to any special hidden-OS status), in case the XML
- configuration file and its properties somehow leaks somewhere outside the system
- partition (which will be wiped later on) indicating that a hidden OS has been created
- on the computer. Instead, we update our raw config flags in the master boot record
- (which is also altered when our boot loader is installed). */
-
- if (!ChangeSystemEncryptionStatus (SYSENC_STATUS_PRETEST)
- || !ChangeHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_CLONING))
- {
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
- Error ("CANNOT_INITIATE_HIDDEN_OS_CREATION", hwndDlg);
- NormalCursor ();
- return 1;
- }
- }
- else if (!ChangeSystemEncryptionStatus (SYSENC_STATUS_PRETEST))
- {
- Error ("CANNOT_INITIATE_SYS_ENCRYPTION_PRETEST", hwndDlg);
- NormalCursor ();
- return 1;
- }
-
- // Add the wizard to the system startup sequence
- ManageStartupSeqWiz (FALSE, L"/acsysenc");
-
- EndMainDlg (MainDlg);
-
- try
- {
- BootEncObj->RestartComputer ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
-
- return 1;
- }
-
- else if (nCurPageNo == SYSENC_PRETEST_RESULT_PAGE)
- {
- TextInfoDialogBox (TC_TBXID_SYS_ENC_RESCUE_DISK);
-
- // Begin the actual encryption process
-
- ChangeSystemEncryptionStatus (SYSENC_STATUS_ENCRYPTING);
- }
-
- else if (nCurPageNo == SYSENC_ENCRYPTION_PAGE
- && CreateSysEncMutex ())
- {
- // The 'Next' button functions as Finish or Resume
-
- if (SystemEncryptionStatus != SYSENC_STATUS_NONE)
- {
- try
- {
- // Resume
- SysEncResume ();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- }
- }
- else
- {
- // Finish
- PostMessage (hwndDlg, TC_APPMSG_FORMAT_USER_QUIT, 0, 0);
- }
-
- return 1;
- }
- else if (nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PARTITION_SEL_PAGE)
- {
- nNewPageNo = NONSYS_INPLACE_ENC_TRANSFORM_PAGE - 1; // Skip irrelevant pages
- }
- else if (nCurPageNo == NONSYS_INPLACE_ENC_TRANSFORM_PAGE)
- {
- /* In-place encryption start (the 'Next' button has been clicked) */
- if (bInPlaceDecNonSys
- && !bInPlaceEncNonSysResumed
- && AskWarnYesNo ("NONSYS_INPLACE_ENC_CONFIRM_BACKUP", hwndDlg) == IDNO)
- {
- // Cancel
- return 1;
- }
-
- NonSysInplaceEncResume ();
- return 1;
- }
- else if (nCurPageNo == NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE)
- {
- PostMessage (hwndDlg, TC_APPMSG_FORMAT_USER_QUIT, 0, 0);
- return 1;
- }
- else if (nCurPageNo == NONSYS_INPLACE_DEC_TRANSFORM_FINISHED_DRIVE_LETTER_PAGE)
- {
- BOOL bDrvLetterAssignResult = FALSE;
-
- int tmpDriveLetter = (int) SendMessage (GetDlgItem (hCurPage, IDC_DRIVE_LETTER_LIST),
- CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_DRIVE_LETTER_LIST), CB_GETCURSEL, 0, 0),
- 0);
-
- if (tmpDriveLetter < 0)
- tmpDriveLetter = GetFirstAvailableDrive ();
-
- do
- {
- wchar_t szDriveLetter[] = {L'A', L':', 0 };
- wchar_t rootPath[] = {L'A', L':', L'\\', 0 };
- wchar_t uniqVolName[MAX_PATH+1] = { 0 };
-
- rootPath[0] += (wchar_t) tmpDriveLetter;
- szDriveLetter[0] += (wchar_t) tmpDriveLetter;
-
- if (DefineDosDevice (DDD_RAW_TARGET_PATH, szDriveLetter, szDiskFile))
- {
- bDrvLetterAssignResult = GetVolumeNameForVolumeMountPoint (rootPath, uniqVolName, MAX_PATH);
-
- DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE,
- szDriveLetter,
- szDiskFile);
-
- if (bDrvLetterAssignResult)
- {
- if (SetVolumeMountPoint (rootPath, uniqVolName) == 0)
- bDrvLetterAssignResult = FALSE;
- }
- }
-
- if (!bDrvLetterAssignResult)
- {
- if (AskErrYesNo ("ERR_CANNOT_ASSIGN_DRIVE_LETTER_NONSYS_DEC", hwndDlg) == IDNO)
- break;
- }
-
- } while (bDrvLetterAssignResult == FALSE);
-
- bConfirmQuit = FALSE;
-
- PostMessage (hwndDlg, TC_APPMSG_FORMAT_USER_QUIT, 0, 0);
- return 1;
- }
- else if (nCurPageNo == FORMAT_PAGE)
- {
- /* Format start (the 'Next' button has been clicked on the Format page) */
-
- if (bVolTransformThreadRunning || bVolTransformThreadToRun)
- return 1;
-
- bVolTransformThreadCancel = FALSE;
-
- bVolTransformThreadToRun = TRUE;
-
- fileSystem = (int) SendMessage (GetDlgItem (hCurPage, IDC_FILESYS), CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_FILESYS), CB_GETCURSEL, 0, 0) , 0);
-
- clusterSize = (int) SendMessage (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), CB_GETITEMDATA,
- SendMessage (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), CB_GETCURSEL, 0, 0) , 0);
-
- quickFormat = IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT));
-
-
- if (!bHiddenVol && IsHiddenOSRunning())
- {
- // Creating a non-hidden volume under a hidden OS
-
- if (fileSystem == FILESYS_NTFS || fileSystem == FILESYS_EXFAT)
- {
- WarningDirect ((wstring (GetString ("CANNOT_CREATE_NON_HIDDEN_NTFS_VOLUMES_UNDER_HIDDEN_OS"))
- + L"\n\n"
- + GetString ("NOTE_BEGINNING")
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_BRIEF_INFO")
- + L" "
- + GetString ("HIDDEN_OS_WRITE_PROTECTION_EXPLANATION")).c_str(), hwndDlg);
-
- if (GetVolumeDataAreaSize (FALSE, nVolumeSize) <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize()
- && AskYesNo("OFFER_FAT_FORMAT_ALTERNATIVE", hwndDlg) == IDYES)
- {
- fileSystem = FILESYS_FAT;
- SelectAlgo (GetDlgItem (hCurPage, IDC_FILESYS), (int *) &fileSystem);
- }
- else
- {
- if (GetVolumeDataAreaSize (FALSE, nVolumeSize) > TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize())
- Info ("FAT_NOT_AVAILABLE_FOR_SO_LARGE_VOLUME", hwndDlg);
-
- bVolTransformThreadToRun = FALSE;
- return 1;
- }
- }
- }
-
- if (bHiddenVolHost)
- {
- hiddenVolHostDriveNo = -1;
- nMaximumHiddenVolSize = 0;
-
- if (fileSystem == FILESYS_NTFS || fileSystem == FILESYS_EXFAT)
- {
- if (bHiddenOS && (fileSystem == FILESYS_NTFS)
- && (double) nVolumeSize / GetSystemPartitionSize() < MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_NTFS)
- {
- Error("OUTER_VOLUME_TOO_SMALL_FOR_HIDDEN_OS_NTFS", hwndDlg);
-
- if (GetVolumeDataAreaSize (FALSE, nVolumeSize) <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize()
- && AskYesNo("OFFER_FAT_FORMAT_ALTERNATIVE", hwndDlg) == IDYES)
- {
- fileSystem = FILESYS_FAT;
- SelectAlgo (GetDlgItem (hCurPage, IDC_FILESYS), (int *) &fileSystem);
- }
- else
- {
- if (GetVolumeDataAreaSize (FALSE, nVolumeSize) > TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize())
- Info ("FAT_NOT_AVAILABLE_FOR_SO_LARGE_VOLUME", hwndDlg);
-
- bVolTransformThreadToRun = FALSE;
- return 1;
- }
- }
-
- if (fileSystem == FILESYS_NTFS || fileSystem == FILESYS_EXFAT) // The file system may have been changed in the previous block
- {
- if (nCurrentOS == WIN_2000)
- {
- Error("HIDDEN_VOL_HOST_UNSUPPORTED_FILESYS_WIN2000", hwndDlg);
- bVolTransformThreadToRun = FALSE;
- return 1;
- }
- else if ((fileSystem == FILESYS_NTFS) && (GetVolumeDataAreaSize (FALSE, nVolumeSize) <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize())
- && AskYesNo("HIDDEN_VOL_HOST_NTFS_ASK", hwndDlg) == IDNO)
- {
- bVolTransformThreadToRun = FALSE;
- return 1;
- }
- }
- }
- }
- else if (bHiddenVol)
- {
- // Hidden volume is always quick-formatted (if, however, the meaning of quickFormat is
- // whether to create a sparse file, it must be set to FALSE).
- quickFormat = !bSparseFileSwitch;
- }
-
-
- if (fileSystem == FILESYS_FAT
- && nNeedToStoreFilesOver4GB == 1
- && AskWarnNoYes("CONFIRM_FAT_FOR_FILES_OVER_4GB", hwndDlg) == IDNO)
- {
- bVolTransformThreadToRun = FALSE;
- return 1;
- }
-
- EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
- EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_FILESYS), FALSE);
- EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE);
- SetFocus (GetDlgItem (hCurPage, IDC_ABORT_BUTTON));
-
- // Increase cluster size if it's too small for this volume size (causes size of
- // free space to be 0). Note that the below constant 0x2000000 is based on
- // results of tests performed under Windows XP.
- if (fileSystem == FILESYS_FAT && clusterSize > 0)
- {
- BOOL fixed = FALSE;
- while (clusterSize < 128
- && nVolumeSize / (clusterSize * GetFormatSectorSize()) > 0x2000000)
- {
- clusterSize *= 2;
- fixed = TRUE;
- }
- if (fixed)
- MessageBoxW (hwndDlg, GetString ("CLUSTER_TOO_SMALL"), lpszTitle, MB_ICONWARNING);
- }
-
- LastDialogId = "FORMAT_IN_PROGRESS";
- ArrowWaitCursor ();
- _beginthread (volTransformThreadFunction, 0, MainDlg);
-
- return 1;
- }
-
- else if (nCurPageNo == FORMAT_FINISHED_PAGE)
- {
- if (!bHiddenVol || bHiddenVolFinished)
- {
- /* Wizard loop restart */
-
- if (bHiddenOS)
- {
- if (!ChangeWizardMode (WIZARD_MODE_SYS_DEVICE))
- return 1;
-
- // Hidden volume for hidden OS has been created. Now we will prepare our boot loader
- // that will handle the OS cloning.
- try
- {
- WaitCursor();
-
- BootEncObj->PrepareHiddenOSCreation (nVolumeEA, FIRST_MODE_OF_OPERATION_ID, hash_algo);
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- NormalCursor();
- return 1;
- }
-
- bHiddenVol = FALSE;
-
- LoadPage (hwndDlg, SYSENC_PRETEST_INFO_PAGE);
- }
- else
- LoadPage (hwndDlg, INTRO_PAGE);
-
- SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
- bHiddenVolFinished = FALSE;
- WipePasswordsAndKeyfiles ();
-
- return 1;
- }
- else
- {
- /* We're going to scan the bitmap of the hidden volume host (in the non-Direct hidden volume wizard mode) */
- int retCode;
- WaitCursor ();
-
- if (hiddenVolHostDriveNo != -1) // If the hidden volume host is mounted
- {
- BOOL tmp_result;
-
- // Dismount the hidden volume host (in order to remount it as read-only subsequently)
- CloseVolumeExplorerWindows (hwndDlg, hiddenVolHostDriveNo);
- while (!(tmp_result = UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE)))
- {
- if (MessageBoxW (hwndDlg, GetString ("CANT_DISMOUNT_OUTER_VOL"), lpszTitle, MB_RETRYCANCEL | MB_ICONERROR | MB_SETFOREGROUND) != IDRETRY)
- {
- // Cancel
- NormalCursor();
- return 1;
- }
- }
- if (tmp_result) // If dismounted
- hiddenVolHostDriveNo = -1;
- }
-
- if (hiddenVolHostDriveNo < 0) // If the hidden volume host is not mounted
- {
- // Remount the hidden volume host as read-only (to ensure consistent and secure
- // results of the volume bitmap scanning)
- switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, volumePim, TRUE))
- {
- case ERR_NO_FREE_DRIVES:
- MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
- NormalCursor ();
- return 1;
-
- case ERR_VOL_MOUNT_FAILED:
- case ERR_PASSWORD_WRONG:
- NormalCursor ();
- return 1;
-
- case 0:
-
- /* Hidden volume host successfully mounted as read-only */
-
- // Verify that the outer volume contains a suitable file system, retrieve cluster size, and
- // scan the volume bitmap
- if (!IsAdmin () && IsUacSupported ())
- retCode = UacAnalyzeHiddenVolumeHost (hwndDlg, &hiddenVolHostDriveNo, GetVolumeDataAreaSize (FALSE, nHiddenVolHostSize), &realClusterSize, &nbrFreeClusters);
- else
- retCode = AnalyzeHiddenVolumeHost (hwndDlg, &hiddenVolHostDriveNo, GetVolumeDataAreaSize (FALSE, nHiddenVolHostSize), &realClusterSize, &nbrFreeClusters);
-
- switch (retCode)
- {
- case -1: // Fatal error
- CloseVolumeExplorerWindows (hwndDlg, hiddenVolHostDriveNo);
-
- if (UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE))
- hiddenVolHostDriveNo = -1;
-
- AbortProcessSilent ();
- break;
-
- case 0: // Unsupported file system (or other non-fatal error which has already been reported)
- NormalCursor ();
- return 1;
-
- case 1: // Success
- {
- BOOL tmp_result;
-
- // Determine the maximum possible size of the hidden volume
- if (DetermineMaxHiddenVolSize (hwndDlg) < 1)
- {
- NormalCursor ();
- goto ovf_end;
- }
-
- /* Maximum possible size of the hidden volume successfully determined */
-
- // Dismount the hidden volume host
- while (!(tmp_result = UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE)))
- {
- if (MessageBoxW (hwndDlg, GetString ("CANT_DISMOUNT_OUTER_VOL"), lpszTitle, MB_RETRYCANCEL) != IDRETRY)
- {
- // Cancel
- NormalCursor ();
- goto ovf_end;
- }
- }
-
- // Prevent having to recreate the outer volume due to inadvertent exit
- bConfirmQuit = TRUE;
-
- hiddenVolHostDriveNo = -1;
-
- nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE;
-
- // Clear the outer volume password
- WipePasswordsAndKeyfiles ();
-
- EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), TRUE);
- NormalCursor ();
-
- }
- break;
- }
- break;
- }
- }
- }
- }
-
- else if (nCurPageNo == DEVICE_WIPE_PAGE)
- {
- if (AskWarnOkCancel (bHiddenOS && IsHiddenOSRunning() ? "CONFIRM_WIPE_START_DECOY_SYS_PARTITION" : "CONFIRM_WIPE_START", hwndDlg) == IDOK)
- {
- WipeStart ();
- ArrowWaitCursor();
- }
- return 1;
- }
-
- LoadPage (hwndDlg, nNewPageNo + 1);
-ovf_end:
- return 1;
- }
- else if (lw == IDC_PREV)
- {
- if (nCurPageNo == SYSENC_SPAN_PAGE)
- {
- // Skip irrelevant pages when going back
- if (!bHiddenOS)
- nNewPageNo = SYSENC_TYPE_PAGE + 1;
- }
- if (nCurPageNo == SYSENC_MULTI_BOOT_MODE_PAGE)
- {
- // Skip the drive analysis page(s) or other irrelevant pages when going back
- if (bHiddenOS)
- nNewPageNo = SYSENC_HIDDEN_OS_REQ_CHECK_PAGE + 1;
- else if (bWholeSysDrive)
- nNewPageNo = SYSENC_PRE_DRIVE_ANALYSIS_PAGE + 1;
- else
- nNewPageNo = SYSENC_SPAN_PAGE + 1;
- }
- else if (nCurPageNo == SYSENC_MULTI_BOOT_NONWIN_BOOT_LOADER_PAGE)
- {
- if (SysEncMultiBootCfg.NumberOfSysDrives == 1)
- {
- // We can skip SYSENC_MULTI_BOOT_ADJACENT_SYS_PAGE (it is implied that there are multiple systems on the drive)
- nNewPageNo = SYSENC_MULTI_BOOT_NBR_SYS_DRIVES_PAGE + 1;
- }
- }
- else if (nCurPageNo == HIDDEN_VOL_HOST_PRE_CIPHER_PAGE)
- {
- if (bHiddenOS)
- {
- if (!ChangeWizardMode (WIZARD_MODE_SYS_DEVICE))
- {
- NormalCursor ();
- return 1;
- }
-
- // Skip irrelevant pages.
- // Note that we're ignoring nMultiBoot here, as the multi-boot question pages are skipped
- // when creating a hidden OS (only a single message box is displayed with requirements).
- nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE + 1;
- }
- else
- {
- nNewPageNo = VOLUME_LOCATION_PAGE + 1;
- }
- }
- else if (nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE)
- {
- if (IsButtonChecked (GetDlgItem (hCurPage, IDC_HIDVOL_WIZ_MODE_DIRECT)))
- bHiddenVolDirect = TRUE;
- else
- bHiddenVolDirect = FALSE;
- }
- else if (nCurPageNo == VOLUME_TYPE_PAGE)
- {
- if (WizardMode != WIZARD_MODE_SYS_DEVICE)
- nNewPageNo = INTRO_PAGE + 1; // Skip irrelevant pages
- }
- else if (nCurPageNo == VOLUME_LOCATION_PAGE)
- {
- BOOL tmpbDevice;
-
- GetWindowText (GetDlgItem (hCurPage, IDC_COMBO_BOX), szFileName, ARRAYSIZE (szFileName));
- CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &tmpbDevice);
-
- if (tmpbDevice == bDevice)
- {
- MoveEditToCombo (GetDlgItem (hCurPage, IDC_COMBO_BOX), bHistory);
- SaveSettings (hCurPage);
- }
-
- if (!bHiddenVol)
- nNewPageNo = VOLUME_TYPE_PAGE + 1; // Skip the hidden volume creation wizard mode selection
- }
-
- else if (nCurPageNo == CIPHER_PAGE)
- {
- LPARAM nIndex;
- nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0);
- nVolumeEA = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0);
-
- nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), CB_GETCURSEL, 0, 0);
- hash_algo = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), CB_GETITEMDATA, nIndex, 0);
-
- RandSetHashFunction (hash_algo);
-
- if (WizardMode == WIZARD_MODE_SYS_DEVICE)
- {
- if (nMultiBoot > 1)
- nNewPageNo = SYSENC_MULTI_BOOT_OUTCOME_PAGE + 1; // Skip irrelevant pages
- else
- nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE + 1; // Skip irrelevant pages
- }
- else if (!bHiddenVol)
- nNewPageNo = (bDevice ? DEVICE_TRANSFORM_MODE_PAGE : VOLUME_LOCATION_PAGE) + 1;
- else if (bHiddenVolHost)
- nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE + 1; // Skip the info on the hidden volume
- }
-
- else if (nCurPageNo == SIZE_PAGE)
- {
- VerifySizeAndUpdate (hCurPage, TRUE);
- }
-
- else if (nCurPageNo == FILESYS_PAGE)
- {
- if (nNeedToStoreFilesOver4GB != Get2RadButtonPageAnswer())
- fileSystem = FILESYS_NONE; // The user may have gone back and changed the answer, so default file system must be reselected
-
- nNeedToStoreFilesOver4GB = Get2RadButtonPageAnswer();
-
- nNewPageNo = (PimEnable? PIM_PAGE : PASSWORD_PAGE) + 1; // Skip PIM page if it is not enabled
- }
-
- else if (nCurPageNo == PASSWORD_PAGE)
- {
- // Store the password in case we need to restore it after keyfile is applied to it
- GetPassword (hCurPage, IDC_PASSWORD, szRawPassword, sizeof (szRawPassword), FALSE);
-
- VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (MainDlg, IDC_NEXT),
- GetDlgItem (hCurPage, IDC_PASSWORD),
- GetDlgItem (hCurPage, IDC_VERIFY),
- volumePassword.Text,
- szVerify,
- KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect ());
-
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
-
-
- nNewPageNo = SIZE_PAGE + 1; // Skip the hidden volume host password page
-
- if (SysEncInEffect ())
- {
- nNewPageNo = CIPHER_PAGE + 1; // Skip irrelevant pages
-
- KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
-
- if (bKeyboardLayoutChanged)
- {
- // Restore the original keyboard layout
- if (LoadKeyboardLayout (OrigKeyboardLayout, KLF_ACTIVATE | KLF_SUBSTITUTE_OK) == NULL)
- Warning ("CANNOT_RESTORE_KEYBOARD_LAYOUT", hwndDlg);
- else
- bKeyboardLayoutChanged = FALSE;
- }
- }
- else if (bInPlaceEncNonSys)
- nNewPageNo = CIPHER_PAGE + 1;
- }
-
- else if (nCurPageNo == PIM_PAGE)
- {
- volumePim = GetPim (hCurPage, IDC_PIM);
- }
-
- else if (nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
- {
- // Store the password in case we need to restore it after keyfile is applied to it
- GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, MAX_PASSWORD + 1, FALSE);
-
- memcpy (volumePassword.Text, szRawPassword, MAX_PASSWORD + 1);
- volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
-
- if (!bInPlaceEncNonSys)
- nNewPageNo = VOLUME_LOCATION_PAGE + 1;
- }
-
- else if (nCurPageNo == SYSENC_COLLECTING_RANDOM_DATA_PAGE
- || nCurPageNo == NONSYS_INPLACE_ENC_RAND_DATA_PAGE)
- {
- wchar_t tmp[RANDPOOL_DISPLAY_SIZE+1];
-
- KillTimer (hwndDlg, TIMER_ID_RANDVIEW);
-
- // Attempt to wipe the GUI field showing portions of randpool
- wmemset (tmp, L'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hRandPoolSys, tmp);
-
- nNewPageNo = (PimEnable? PIM_PAGE : PASSWORD_PAGE) + 1; // Skip irrelevant pages
- }
-
- else if (nCurPageNo == SYSENC_KEYS_GEN_PAGE)
- {
- wchar_t tmp[KEY_GUI_VIEW_SIZE+1];
-
- // Attempt to wipe the GUI fields showing portions of the master and header keys
- wmemset (tmp, L'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hMasterKey, tmp);
- SetWindowText (hHeaderKey, tmp);
- }
-
- else if (nCurPageNo == SYSENC_WIPE_MODE_PAGE)
- {
- if (bDontVerifyRescueDisk)
- nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE; // Skip irrelevant pages
- }
-
- else if (nCurPageNo == FORMAT_PAGE)
- {
- wchar_t tmp[RNG_POOL_SIZE*2+1];
-
- KillTimer (hwndDlg, TIMER_ID_RANDVIEW);
-
- // Attempt to wipe the GUI fields showing portions of randpool, of the master and header keys
- wmemset (tmp, L'X', ARRAYSIZE(tmp));
- tmp [ARRAYSIZE(tmp)-1] = 0;
- SetWindowText (hRandPool, tmp);
- SetWindowText (hMasterKey, tmp);
- SetWindowText (hHeaderKey, tmp);
-
- if (WizardMode != WIZARD_MODE_SYS_DEVICE)
- {
- // Skip irrelevant pages
-
- if (FileSize4GBLimitQuestionNeeded ()
- && !CreatingHiddenSysVol() // If we're creating a hidden volume for a hidden OS, we don't need to format it with any filesystem (the entire OS will be copied to the hidden volume sector by sector).
- && !bInPlaceEncNonSys)
- {
- nNewPageNo = FILESYS_PAGE + 1;
- }
- else
- nNewPageNo = (PimEnable? PIM_PAGE : PASSWORD_PAGE) + 1;
- }
- }
-
- LoadPage (hwndDlg, nNewPageNo - 1);
-
- return 1;
- }
-
- return 0;
-
- case WM_ENDSESSION:
- EndMainDlg (MainDlg);
- localcleanup ();
- return 0;
-
- case WM_CLOSE:
- PostMessage (hwndDlg, TC_APPMSG_FORMAT_USER_QUIT, 0, 0);
- return 1;
- }
-
- return 0;
-}
-
-void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
-{
- wchar_t **lpszCommandLineArgs = NULL; /* Array of command line arguments */
- int nNoCommandLineArgs; /* The number of arguments in the array */
-
- if (_wcsicmp (lpszCommandLine, L"-Embedding") == 0)
- {
- ComServerMode = TRUE;
- return;
- }
-
- /* Extract command line arguments */
- nNoCommandLineArgs = Win32CommandLine (&lpszCommandLineArgs);
- if (nNoCommandLineArgs > 0)
- {
- int i;
-
- for (i = 0; i < nNoCommandLineArgs; i++)
- {
- enum
- {
- OptionHistory,
- OptionNoIsoCheck,
- OptionQuit,
- OptionTokenLib,
- CommandResumeSysEncLogOn,
- CommandResumeSysEnc,
- CommandDecryptSysEnc,
- CommandEncDev,
- CommandHiddenSys,
- CommandResumeNonSysInplaceLogOn,
- CommandResumeHiddenSys,
- CommandSysEnc,
- CommandInplaceDec,
- CommandResumeInplaceDec,
- CommandResumeInplace,
- OptionEncryption,
- OptionFilesystem,
- OptionPkcs5,
- OptionPassword,
- OptionPim,
- OptionSize,
- OptionCreate,
- OptionSilent,
- OptionDynamic,
- OptionForce,
- };
-
- argument args[]=
- {
- // Public
- { OptionHistory, L"/history", L"/h", FALSE },
- { OptionNoIsoCheck, L"/noisocheck", L"/n", FALSE },
- { OptionTokenLib, L"/tokenlib", NULL, FALSE },
- { OptionQuit, L"/quit", L"/q", FALSE },
- { OptionEncryption, L"/encryption", NULL , FALSE },
- { OptionFilesystem, L"/filesystem", NULL , FALSE },
- { OptionPkcs5, L"/hash", NULL , FALSE },
- { OptionPassword, L"/password", NULL, FALSE },
- { OptionPim, L"/pim", NULL, FALSE },
- { OptionSize, L"/size", NULL, FALSE },
- { OptionCreate, L"/create", NULL, FALSE },
- { OptionSilent, L"/silent", NULL, FALSE },
- { OptionDynamic, L"/dynamic", NULL, FALSE },
- { OptionForce, L"/force", NULL, FALSE },
-
- // Internal
- { CommandResumeSysEncLogOn, L"/acsysenc", L"/a", TRUE },
- { CommandResumeSysEnc, L"/csysenc", L"/c", TRUE },
- { CommandDecryptSysEnc, L"/dsysenc", L"/d", TRUE },
- { CommandEncDev, L"/encdev", L"/e", TRUE },
- { CommandHiddenSys, L"/isysenc", L"/i", TRUE },
- { CommandResumeNonSysInplaceLogOn, L"/prinplace", L"/p", TRUE },
- { CommandResumeHiddenSys, L"/risysenc", L"/r", TRUE },
- { CommandSysEnc, L"/sysenc", L"/s", TRUE },
- { CommandInplaceDec, L"/inplacedec", NULL, TRUE },
- { CommandResumeInplaceDec, L"/resumeinplacedec",NULL, TRUE },
- { CommandResumeInplace, L"/zinplace", L"/z", TRUE }
- };
-
- argumentspec as;
-
- int x;
-
- if (lpszCommandLineArgs[i] == NULL)
- continue;
-
- as.args = args;
- as.arg_cnt = sizeof(args)/ sizeof(args[0]);
-
- x = GetArgumentID (&as, lpszCommandLineArgs[i]);
-
- switch (x)
- {
- case OptionCreate:
- {
- DirectCreationMode = TRUE;
-
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szFileName, ARRAYSIZE (szFileName)))
- {
- RelativePath2Absolute (szFileName);
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
- case OptionEncryption:
- {
- wchar_t szTmp[64] = {0};
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
- {
- CmdVolumeEA = EAGetByName (szTmp);
- if (CmdVolumeEA == 0)
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
- case OptionFilesystem:
- {
- wchar_t szTmp[8] = {0};
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
- {
- if (_wcsicmp(szTmp, L"NONE") == 0)
- CmdVolumeFilesystem = FILESYS_NONE;
- else if (_wcsicmp(szTmp, L"FAT32") == 0 || _wcsicmp(szTmp, L"FAT") == 0)
- CmdVolumeFilesystem = FILESYS_FAT;
- else if (_wcsicmp(szTmp, L"NTFS") == 0)
- CmdVolumeFilesystem = FILESYS_NTFS;
- else if (IsOSVersionAtLeast (WIN_VISTA, 1) && _wcsicmp(szTmp, L"EXFAT") == 0)
- CmdVolumeFilesystem = FILESYS_EXFAT;
- else
- {
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
- case OptionPassword:
- {
- wchar_t szTmp[MAX_PASSWORD + 1];
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szTmp, ARRAYSIZE (szTmp)))
- {
- int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (LPSTR) CmdVolumePassword.Text, MAX_PASSWORD + 1, NULL, NULL);
- burn (szTmp, sizeof (szTmp));
- if (iLen > 0)
- CmdVolumePassword.Length = (unsigned __int32) (iLen - 1);
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
- case OptionPkcs5:
- {
- wchar_t szTmp[32] = {0};
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
- {
- if (_wcsicmp(szTmp, L"sha512") == 0 || _wcsicmp(szTmp, L"sha-512") == 0)
- CmdVolumePkcs5 = SHA512;
- else if (_wcsicmp(szTmp, L"whirlpool") == 0)
- CmdVolumePkcs5 = WHIRLPOOL;
- else if (_wcsicmp(szTmp, L"sha256") == 0 || _wcsicmp(szTmp, L"sha-256") == 0)
- CmdVolumePkcs5 = SHA256;
- else if (_wcsicmp(szTmp, L"ripemd160") == 0 || _wcsicmp(szTmp, L"ripemd-160") == 0)
- CmdVolumePkcs5 = RIPEMD160;
- else
- {
- CmdVolumePkcs5 = 0;
- AbortProcess ("COMMAND_LINE_ERROR");
- }
-
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
-
- case OptionPim:
- {
- wchar_t szTmp[32] = {0};
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
- {
- wchar_t* endPtr = NULL;
- CmdVolumePim = (int) wcstol(szTmp, &endPtr, 0);
- if (CmdVolumePim < 0 || CmdVolumePim > MAX_PIM_VALUE || endPtr == szTmp || *endPtr != L'\0')
- {
- CmdVolumePim = 0;
- AbortProcess ("COMMAND_LINE_ERROR");
- }
-
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
- case OptionSilent:
- Silent = TRUE;
- break;
- case OptionDynamic:
- CmdSparseFileSwitch = TRUE;
- break;
- case OptionForce:
- bForceOperation = TRUE;
- break;
- case OptionSize:
- {
- wchar_t szTmp[32] = {0};
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
- &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp))
- && (wcslen (szTmp) >= 2)
- )
- {
- /* size can be expressed in bytes or with suffixes K, M,G or T
- * to indicate the unit to use
- */
- unsigned __int64 multiplier;
- wchar_t* endPtr = NULL;
- wchar_t lastChar = szTmp [wcslen (szTmp) - 1];
- if (lastChar >= L'0' && lastChar <= L'9')
- multiplier = 1;
- else if (lastChar == L'K' || lastChar == L'k')
- multiplier = BYTES_PER_KB;
- else if (lastChar == L'M' || lastChar == L'm')
- multiplier = BYTES_PER_MB;
- else if (lastChar == L'G' || lastChar == L'g')
- multiplier = BYTES_PER_GB;
- else if (lastChar == L'T' || lastChar == L't')
- multiplier = BYTES_PER_TB;
- else
- AbortProcess ("COMMAND_LINE_ERROR");
-
- if (multiplier != 1)
- szTmp [wcslen (szTmp) - 1] = 0;
-
- CmdVolumeFileSize = _wcstoui64(szTmp, &endPtr, 0);
- if (CmdVolumeFileSize == 0 || CmdVolumeFileSize == _UI64_MAX
- || endPtr == szTmp || *endPtr != L'\0')
- {
- AbortProcess ("COMMAND_LINE_ERROR");
- }
-
- CmdVolumeFileSize *= multiplier;
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
- case CommandSysEnc:
- // Encrypt system partition/drive (passed by Mount if system encryption hasn't started or to reverse decryption)
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (CreateSysEncMutex ())
- {
- bDirectSysEncMode = TRUE;
- bDirectSysEncModeCommand = SYSENC_COMMAND_ENCRYPT;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- }
- else
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
- exit(0);
- }
-
- break;
-
- case CommandDecryptSysEnc:
- // Decrypt system partition/drive (passed by Mount, also to reverse encryption in progress, when paused)
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (CreateSysEncMutex ())
- {
- bDirectSysEncMode = TRUE;
- bDirectSysEncModeCommand = SYSENC_COMMAND_DECRYPT;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- }
- else
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
- exit(0);
- }
- break;
-
- case CommandHiddenSys:
- // Create a hidden operating system (passed by Mount when the user selects System -> Create Hidden Operating System)
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (CreateSysEncMutex ())
- {
- bDirectSysEncMode = TRUE;
- bDirectSysEncModeCommand = SYSENC_COMMAND_CREATE_HIDDEN_OS;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- }
- else
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
- exit(0);
- }
-
- break;
-
- case CommandResumeHiddenSys:
- // Resume process of creation of a hidden operating system (passed by Wizard when the user needs to UAC-elevate the whole wizard process)
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (CreateSysEncMutex ())
- {
- bDirectSysEncMode = TRUE;
- bDirectSysEncModeCommand = SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- }
- else
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
- exit(0);
- }
-
- break;
-
- case CommandResumeSysEnc:
- // Resume previous system-encryption operation (passed by Mount) e.g. encryption, decryption, or pretest
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (CreateSysEncMutex ())
- {
- bDirectSysEncMode = TRUE;
- bDirectSysEncModeCommand = SYSENC_COMMAND_RESUME;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- }
- else
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
- exit(0);
- }
- break;
-
- case CommandResumeSysEncLogOn:
- // Same as csysenc but passed only by the system (from the startup sequence)
-
- // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption
- if (CreateSysEncMutex ())
- {
- bDirectSysEncMode = TRUE;
- bDirectSysEncModeCommand = SYSENC_COMMAND_STARTUP_SEQ_RESUME;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- }
- else
- {
- Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
- exit(0);
- }
- break;
-
- case CommandEncDev:
- // Resume process of creation of a non-sys-device-hosted volume (passed by Wizard when the user needs to UAC-elevate)
- DirectDeviceEncMode = TRUE;
- break;
-
- case CommandInplaceDec:
- // Start (not resume) decrypting the specified non-system volume in place
- {
- wchar_t szTmp [TC_MAX_PATH + 8000] = {0};
-
- GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp));
-
- if (wcslen (szTmp) < 1)
- {
- // No valid volume path specified as command-line parameter
- AbortProcess ("ERR_PARAMETER_INCORRECT");
- }
-
- memset (szFileName, 0, sizeof (szFileName));
- StringCbCopyW (szFileName, sizeof (szFileName), szTmp);
- DirectNonSysInplaceDecStartMode = TRUE;
- }
- break;
-
- case CommandResumeInplace:
- // Resume interrupted process of non-system in-place encryption of a partition
- DirectNonSysInplaceEncResumeMode = TRUE;
- break;
-
- case CommandResumeInplaceDec:
- // Resume interrupted process of non-system in-place decryption of a partition
- DirectNonSysInplaceDecResumeMode = TRUE;
- break;
-
- case CommandResumeNonSysInplaceLogOn:
- // Ask the user whether to resume interrupted process of non-system in-place encryption of a partition
- // This switch is passed only by the system (from the startup sequence).
- DirectPromptNonSysInplaceEncResumeMode = TRUE;
- break;
-
- case OptionNoIsoCheck:
- bDontVerifyRescueDisk = TRUE;
- break;
-
- case OptionHistory:
- {
- wchar_t szTmp[8] = {0};
- bHistory = bHistoryCmdLine = TRUE;
-
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- szTmp, ARRAYSIZE (szTmp)))
- {
- if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
- {
- bHistory = TRUE;
- }
-
- else if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
- {
- bHistory = FALSE;
- }
- else
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- }
- break;
-
- case OptionTokenLib:
- if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, ARRAYSIZE (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
- InitSecurityTokenLibrary(hwndDlg);
- else
- AbortProcess ("COMMAND_LINE_ERROR");
-
- break;
-
- case OptionQuit:
- {
- // Used to indicate non-install elevation
- wchar_t szTmp[32];
- if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)) != HAS_ARGUMENT)
- AbortProcess ("COMMAND_LINE_ERROR");
- }
- break;
-
- default:
- DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_COMMANDHELP_DLG), hwndDlg, (DLGPROC)
- CommandHelpDlgProc, (LPARAM) &as);
-
- exit(0);
- }
- }
- }
-
- /* Free up the command line arguments */
- while (--nNoCommandLineArgs >= 0)
- {
- free (lpszCommandLineArgs[nNoCommandLineArgs]);
- }
-
- if (lpszCommandLineArgs)
- free (lpszCommandLineArgs);
-}
-
-
-int DetermineMaxHiddenVolSize (HWND hwndDlg)
-{
- __int64 nbrReserveBytes;
-
- if (nbrFreeClusters * realClusterSize < TC_MIN_HIDDEN_VOLUME_SIZE)
- {
- MessageBoxW (hwndDlg, GetString ("NO_SPACE_FOR_HIDDEN_VOL"), lpszTitle, ICON_HAND);
- UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE);
- AbortProcessSilent ();
- }
-
- // Add a reserve (in case the user mounts the outer volume and creates new files
- // on it by accident or OS writes some new data behind his or her back, such as
- // System Restore etc.)
- nbrReserveBytes = GetVolumeDataAreaSize (FALSE, nHiddenVolHostSize) / 200;
- if (nbrReserveBytes > BYTES_PER_MB * 10)
- nbrReserveBytes = BYTES_PER_MB * 10;
-
- // Compute the final value
-
- nMaximumHiddenVolSize = nbrFreeClusters * realClusterSize - TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE - nbrReserveBytes;
- nMaximumHiddenVolSize -= nMaximumHiddenVolSize % realClusterSize; // Must be a multiple of the sector size
-
- if (nMaximumHiddenVolSize < TC_MIN_HIDDEN_VOLUME_SIZE)
- {
- MessageBoxW (hwndDlg, GetString ("NO_SPACE_FOR_HIDDEN_VOL"), lpszTitle, ICON_HAND);
- UnmountVolume (hwndDlg, hiddenVolHostDriveNo, TRUE);
- AbortProcessSilent ();
- }
-
- // Prepare the hidden volume size parameters
- if (nMaximumHiddenVolSize < BYTES_PER_MB)
- nMultiplier = BYTES_PER_KB;
- else if (nMaximumHiddenVolSize < BYTES_PER_GB)
- nMultiplier = BYTES_PER_MB;
- else if (nMaximumHiddenVolSize < BYTES_PER_TB)
- nMultiplier = BYTES_PER_GB;
- else
- nMultiplier = BYTES_PER_TB;
-
- nUIVolumeSize = 0; // Set the initial value for the hidden volume size input field to the max
- nVolumeSize = nUIVolumeSize * nMultiplier; // Chop off possible remainder
-
- return 1;
-}
-
-
-// Tests whether the file system of the given volume is suitable to host a hidden volume,
-// retrieves the cluster size, and scans the volume cluster bitmap. In addition, checks
-// the TrueCrypt volume format version and the type of volume.
-int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *pnbrFreeClusters)
-{
- HANDLE hDevice;
- DWORD bytesReturned;
- DWORD dwSectorsPerCluster, dwBytesPerSector, dwNumberOfFreeClusters, dwTotalNumberOfClusters;
- DWORD dwResult;
- int result;
- wchar_t szFileSystemNameBuffer[256];
- wchar_t tmpPath[7] = {L'\\',L'\\',L'.',L'\\',(wchar_t) *driveNo + L'A',L':',0};
- wchar_t szRootPathName[4] = {(wchar_t) *driveNo + L'A', L':', L'\\', 0};
- BYTE readBuffer[TC_MAX_VOLUME_SECTOR_SIZE * 2];
- LARGE_INTEGER offset, offsetNew;
- VOLUME_PROPERTIES_STRUCT volProp;
-
- memset (&volProp, 0, sizeof(volProp));
- volProp.driveNo = *driveNo;
- if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &volProp, sizeof (volProp), &volProp, sizeof (volProp), &dwResult, NULL) || dwResult == 0)
- {
- handleWin32Error (hwndDlg, SRC_POS);
- Error ("CANT_ACCESS_OUTER_VOL", hwndDlg);
- goto efsf_error;
- }
-
- if (volProp.volFormatVersion < TC_VOLUME_FORMAT_VERSION)
- {
- // We do not support creating hidden volumes within volumes created by TrueCrypt 5.1a or earlier.
- Error ("ERR_VOL_FORMAT_BAD", hwndDlg);
- return 0;
- }
-
- if (volProp.hiddenVolume)
- {
- // The user entered a password for a hidden volume
- Error ("ERR_HIDDEN_NOT_NORMAL_VOLUME", hwndDlg);
- return 0;
- }
-
- if (volProp.volumeHeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC
- || volProp.volumeHeaderFlags & TC_HEADER_FLAG_ENCRYPTED_SYSTEM)
- {
- Warning ("ERR_HIDDEN_VOL_HOST_ENCRYPTED_INPLACE", hwndDlg);
- return 0;
- }
-
- hDevice = CreateFile (tmpPath, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
-
- if (hDevice == INVALID_HANDLE_VALUE)
- {
- MessageBoxW (hwndDlg, GetString ("CANT_ACCESS_OUTER_VOL"), lpszTitle, ICON_HAND);
- goto efsf_error;
- }
-
- offset.QuadPart = 0;
-
- if (SetFilePointerEx (hDevice, offset, &offsetNew, FILE_BEGIN) == 0)
- {
- handleWin32Error (hwndDlg, SRC_POS);
- goto efs_error;
- }
-
- result = ReadFile (hDevice, &readBuffer, TC_MAX_VOLUME_SECTOR_SIZE, &bytesReturned, NULL);
-
- if (result == 0)
- {
- handleWin32Error (hwndDlg, SRC_POS);
- MessageBoxW (hwndDlg, GetString ("CANT_ACCESS_OUTER_VOL"), lpszTitle, ICON_HAND);
- goto efs_error;
- }
-
- CloseHandle (hDevice);
- hDevice = INVALID_HANDLE_VALUE;
-
- // Determine file system type
-
- GetVolumeInformation(szRootPathName, NULL, 0, NULL, NULL, NULL, szFileSystemNameBuffer, ARRAYSIZE(szFileSystemNameBuffer));
-
- // The Windows API sometimes fails to indentify the file system correctly so we're using "raw" analysis too.
- if (!wcsncmp (szFileSystemNameBuffer, L"FAT", 3)
- || (readBuffer[0x36] == 'F' && readBuffer[0x37] == 'A' && readBuffer[0x38] == 'T')
- || (readBuffer[0x52] == 'F' && readBuffer[0x53] == 'A' && readBuffer[0x54] == 'T'))
- {
- // FAT12/FAT16/FAT32
-
- // Retrieve the cluster size
- *realClusterSize = ((int) readBuffer[0xb] + ((int) readBuffer[0xc] << 8)) * (int) readBuffer[0xd];
-
- // Get the map of the clusters that are free and in use on the outer volume.
- // The map will be scanned to determine the size of the uninterrupted block of free
- // space (provided there is any) whose end is aligned with the end of the volume.
- // The value will then be used to determine the maximum possible size of the hidden volume.
-
- return ScanVolClusterBitmap (hwndDlg,
- driveNo,
- hiddenVolHostSize / *realClusterSize,
- pnbrFreeClusters);
- }
- else if (!wcsncmp (szFileSystemNameBuffer, L"NTFS", 4) || !_wcsnicmp (szFileSystemNameBuffer, L"exFAT", 5))
- {
- // NTFS
- bool bIsNtfs = (0 == wcsncmp (szFileSystemNameBuffer, L"NTFS", 4));
-
- if (nCurrentOS == WIN_2000)
- {
- Error("HIDDEN_VOL_HOST_UNSUPPORTED_FILESYS_WIN2000", hwndDlg);
- return 0;
- }
-
- if (bIsNtfs && bHiddenVolDirect && GetVolumeDataAreaSize (FALSE, hiddenVolHostSize) <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize())
- Info ("HIDDEN_VOL_HOST_NTFS", hwndDlg);
-
- if (!GetDiskFreeSpace(szRootPathName,
- &dwSectorsPerCluster,
- &dwBytesPerSector,
- &dwNumberOfFreeClusters,
- &dwTotalNumberOfClusters))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- Error ("CANT_GET_OUTER_VOL_INFO", hwndDlg);
- return -1;
- };
-
- *realClusterSize = dwBytesPerSector * dwSectorsPerCluster;
-
- // Get the map of the clusters that are free and in use on the outer volume.
- // The map will be scanned to determine the size of the uninterrupted block of free
- // space (provided there is any) whose end is aligned with the end of the volume.
- // The value will then be used to determine the maximum possible size of the hidden volume.
-
- return ScanVolClusterBitmap (hwndDlg,
- driveNo,
- hiddenVolHostSize / *realClusterSize,
- pnbrFreeClusters);
- }
- else
- {
- // Unsupported file system
-
- Error ((nCurrentOS == WIN_2000) ? "HIDDEN_VOL_HOST_UNSUPPORTED_FILESYS_WIN2000" : "HIDDEN_VOL_HOST_UNSUPPORTED_FILESYS", hwndDlg);
- return 0;
- }
-
-efs_error:
- CloseHandle (hDevice);
-
-efsf_error:
- CloseVolumeExplorerWindows (hwndDlg, *driveNo);
-
- return -1;
-}
-
-
-// Mounts a volume within which the user intends to create a hidden volume
-int MountHiddenVolHost (HWND hwndDlg, wchar_t *volumePath, int *driveNo, Password *password, int pkcs5_prf, int pim, BOOL bReadOnly)
-{
- MountOptions mountOptions;
- ZeroMemory (&mountOptions, sizeof (mountOptions));
-
- *driveNo = GetLastAvailableDrive ();
-
- if (*driveNo == -1)
- {
- *driveNo = -2;
- return ERR_NO_FREE_DRIVES;
- }
-
- mountOptions.ReadOnly = bReadOnly;
- mountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
- mountOptions.ProtectHiddenVolume = FALSE;
- mountOptions.PreserveTimestamp = bPreserveTimestamp;
- mountOptions.PartitionInInactiveSysEncScope = FALSE;
- mountOptions.UseBackupHeader = FALSE;
-
- if (MountVolume (hwndDlg, *driveNo, volumePath, password, pkcs5_prf, pim, FALSE, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1)
- {
- *driveNo = -3;
- return ERR_VOL_MOUNT_FAILED;
- }
- return 0;
-}
-
-
-/* Gets the map of the clusters that are free and in use on a volume that is to host
- a hidden volume. The map is scanned to determine the size of the uninterrupted
- area of free space (provided there is any) whose end is aligned with the end
- of the volume. The value will then be used to determine the maximum possible size
- of the hidden volume. */
-int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *nbrFreeClusters)
-{
- PVOLUME_BITMAP_BUFFER lpOutBuffer;
- STARTING_LCN_INPUT_BUFFER lpInBuffer;
-
- HANDLE hDevice;
- DWORD lBytesReturned;
- BYTE rmnd;
- wchar_t tmpPath[7] = {L'\\',L'\\',L'.',L'\\', (wchar_t) *driveNo + L'A', L':', 0};
-
- DWORD bufLen;
- __int64 bitmapCnt;
-
- hDevice = CreateFile (tmpPath, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
-
- if (hDevice == INVALID_HANDLE_VALUE)
- {
- MessageBoxW (hwndDlg, GetString ("CANT_ACCESS_OUTER_VOL"), lpszTitle, ICON_HAND);
- goto vcmf_error;
- }
-
- bufLen = (DWORD) (nbrClusters / 8 + 2 * sizeof(LARGE_INTEGER));
- bufLen += 100000 + bufLen/10; // Add reserve
-
- lpOutBuffer = (PVOLUME_BITMAP_BUFFER) malloc (bufLen);
-
- if (lpOutBuffer == NULL)
- {
- MessageBoxW (hwndDlg, GetString ("ERR_MEM_ALLOC"), lpszTitle, ICON_HAND);
- goto vcm_error;
- }
-
- lpInBuffer.StartingLcn.QuadPart = 0;
-
- if ( !DeviceIoControl (hDevice,
- FSCTL_GET_VOLUME_BITMAP,
- &lpInBuffer,
- sizeof(lpInBuffer),
- lpOutBuffer,
- bufLen,
- &lBytesReturned,
- NULL))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- MessageBoxW (hwndDlg, GetString ("CANT_GET_CLUSTER_BITMAP"), lpszTitle, ICON_HAND);
-
- goto vcm_error;
- }
-
- rmnd = (BYTE) (lpOutBuffer->BitmapSize.QuadPart % 8);
-
- if ((rmnd != 0)
- && ((lpOutBuffer->Buffer[lpOutBuffer->BitmapSize.QuadPart / 8] & ((1 << rmnd)-1) ) != 0))
- {
- *nbrFreeClusters = 0;
- }
- else
- {
- *nbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart;
- bitmapCnt = lpOutBuffer->BitmapSize.QuadPart / 8;
-
- // Scan the bitmap from the end
- while (--bitmapCnt >= 0)
- {
- if (lpOutBuffer->Buffer[bitmapCnt] != 0)
- {
- // There might be up to 7 extra free clusters in this byte of the bitmap.
- // These are ignored because there is always a cluster reserve added anyway.
- *nbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart - ((bitmapCnt + 1) * 8);
- break;
- }
- }
- }
-
- CloseHandle (hDevice);
- free(lpOutBuffer);
- return 1;
-
-vcm_error:
- CloseHandle (hDevice);
- if (lpOutBuffer) free(lpOutBuffer);
-
-vcmf_error:
- return -1;
-}
-
-
-// Wipe the hidden OS config flag bits in the MBR
-static BOOL WipeHiddenOSCreationConfig (void)
-{
- if (!IsHiddenOSRunning())
- {
- try
- {
- WaitCursor();
- finally_do ({ NormalCursor(); });
-
- BootEncObj->WipeHiddenOSCreationConfig();
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-
-// Tasks that need to be performed after the WM_INITDIALOG message for the SYSENC_ENCRYPTION_PAGE dialog is
-// handled should be done here (otherwise the UAC prompt causes the GUI to be only half-rendered).
-static void AfterSysEncProgressWMInitTasks (HWND hwndDlg)
-{
- try
- {
- switch (SystemEncryptionStatus)
- {
- case SYSENC_STATUS_ENCRYPTING:
-
- if (BootEncStatus.ConfiguredEncryptedAreaStart == BootEncStatus.EncryptedAreaStart
- && BootEncStatus.ConfiguredEncryptedAreaEnd == BootEncStatus.EncryptedAreaEnd)
- {
- // The partition/drive had been fully encrypted
-
- ManageStartupSeqWiz (TRUE, L"");
- WipeHiddenOSCreationConfig(); // For extra conservative security
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
-
- Info ("SYSTEM_ENCRYPTION_FINISHED", hwndDlg);
- EndMainDlg (MainDlg);
- return;
- }
- else
- {
- SysEncResume ();
- }
-
- break;
-
- case SYSENC_STATUS_DECRYPTING:
- SysEncResume ();
- break;
-
- default:
-
- // Unexpected mode here -- fix the inconsistency
-
- ManageStartupSeqWiz (TRUE, L"");
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
- EndMainDlg (MainDlg);
- InconsistencyResolved (SRC_POS);
- return;
- }
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- EndMainDlg (MainDlg);
- return;
- }
-
- InitSysEncProgressBar ();
-
- UpdateSysEncProgressBar ();
-
- UpdateSysEncControls ();
-}
-
-
-// Tasks that need to be performed after the WM_INITDIALOG message is handled must be done here.
-// For example, any tasks that may invoke the UAC prompt (otherwise the UAC dialog box would not be on top).
-static void AfterWMInitTasks (HWND hwndDlg)
-{
- // Note that if bDirectSysEncModeCommand is not SYSENC_COMMAND_NONE, we already have the mutex.
-
- // SYSENC_COMMAND_DECRYPT has the highest priority because it also performs uninstallation (restores the
- // original contents of the first drive cylinder, etc.) so it must be attempted regardless of the phase
- // or content of configuration files.
- if (bDirectSysEncModeCommand == SYSENC_COMMAND_DECRYPT)
- {
- if (IsHiddenOSRunning())
- {
- Warning ("CANNOT_DECRYPT_HIDDEN_OS", hwndDlg);
- AbortProcessSilent();
- }
-
- // Add the wizard to the system startup sequence
- ManageStartupSeqWiz (FALSE, L"/acsysenc");
-
- ChangeSystemEncryptionStatus (SYSENC_STATUS_DECRYPTING);
- LoadPage (hwndDlg, SYSENC_ENCRYPTION_PAGE);
- return;
- }
-
-
- if (SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING
- || SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING)
- {
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
-
- if (!BootEncStatus.DriveMounted)
- {
- if (!BootEncStatus.DeviceFilterActive)
- {
- // This is an inconsistent state. SystemEncryptionStatus should never be SYSENC_STATUS_ENCRYPTING
- // or SYSENC_STATUS_DECRYPTING when the drive filter is not active. Possible causes: 1) corrupted
- // or stale config file, 2) corrupted system
-
- // Fix the inconsistency
- ManageStartupSeqWiz (TRUE, L"");
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
- EndMainDlg (MainDlg);
- InconsistencyResolved (SRC_POS);
- return;
- }
- else if (bDirectSysEncMode)
- {
- // This is an inconsistent state. We have a direct system encryption command,
- // SystemEncryptionStatus is SYSENC_STATUS_ENCRYPTING or SYSENC_STATUS_DECRYPTING, the
- // system drive is not 'mounted' and drive filter is active. Possible causes: 1) The drive had
- // been decrypted in the pre-boot environment. 2) The OS is not located on the lowest partition,
- // the drive is to be fully encrypted, but the user rebooted before encryption reached the
- // system partition and then pressed Esc in the boot loader screen. 3) Corrupted or stale config
- // file. 4) Damaged system.
-
- Warning ("SYSTEM_ENCRYPTION_SCHEDULED_BUT_PBA_FAILED", hwndDlg);
- EndMainDlg (MainDlg);
- return;
- }
- }
- }
- catch (Exception &e)
- {
- e.Show (MainDlg);
- }
- }
-
-
- if (SystemEncryptionStatus != SYSENC_STATUS_PRETEST)
- {
- // Handle system encryption command line arguments (if we're not in the Pretest phase).
- // Note that if bDirectSysEncModeCommand is not SYSENC_COMMAND_NONE, we already have the mutex.
- // Also note that SYSENC_COMMAND_DECRYPT is handled above.
-
- switch (bDirectSysEncModeCommand)
- {
- case SYSENC_COMMAND_RESUME:
- case SYSENC_COMMAND_STARTUP_SEQ_RESUME:
-
- if (bDirectSysEncModeCommand == SYSENC_COMMAND_STARTUP_SEQ_RESUME
- && AskWarnYesNo ("SYSTEM_ENCRYPTION_RESUME_PROMPT", hwndDlg) == IDNO)
- {
- EndMainDlg (MainDlg);
- return;
- }
-
- if (SysEncryptionOrDecryptionRequired ())
- {
- if (SystemEncryptionStatus != SYSENC_STATUS_ENCRYPTING
- && SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING)
- {
- // If the config file with status was lost or not written correctly, we
- // don't know whether to encrypt or decrypt (but we know that encryption or
- // decryption is required). Ask the user to select encryption, decryption,
- // or cancel
- if (!ResolveUnknownSysEncDirection ())
- {
- EndMainDlg (MainDlg);
- return;
- }
- }
-
- LoadPage (hwndDlg, SYSENC_ENCRYPTION_PAGE);
- return;
- }
- else
- {
- // Nothing to resume
- Warning ("NO_SYS_ENC_PROCESS_TO_RESUME", hwndDlg);
- EndMainDlg (MainDlg);
-
- return;
- }
- break;
-
- case SYSENC_COMMAND_ENCRYPT:
-
- if (SysDriveOrPartitionFullyEncrypted (FALSE))
- {
- Info ("SYS_PARTITION_OR_DRIVE_APPEARS_FULLY_ENCRYPTED", hwndDlg);
- EndMainDlg (MainDlg);
- return;
- }
-
- if (SysEncryptionOrDecryptionRequired ())
- {
- // System partition/drive encryption process already initiated but is incomplete.
- // If we were encrypting, resume the process directly. If we were decrypting, reverse
- // the process and start encrypting.
-
- ChangeSystemEncryptionStatus (SYSENC_STATUS_ENCRYPTING);
- LoadPage (hwndDlg, SYSENC_ENCRYPTION_PAGE);
- return;
- }
- else
- {
- // Initiate the Pretest preparation phase
- if (!SwitchWizardToSysEncMode ())
- {
- bDirectSysEncMode = FALSE;
- EndMainDlg (MainDlg);
- }
- return;
- }
-
- break;
-
- case SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV:
- case SYSENC_COMMAND_CREATE_HIDDEN_OS:
-
- if (!SwitchWizardToHiddenOSMode ())
- {
- bDirectSysEncMode = FALSE;
- EndMainDlg (MainDlg);
- }
- return;
- }
- }
-
-
- if (!bDirectSysEncMode
- || bDirectSysEncMode && SystemEncryptionStatus == SYSENC_STATUS_NONE)
- {
- // Handle system encryption cases where the wizard did not start even though it
- // was added to the startup sequence, as well as other weird cases and "leftovers"
-
- if (SystemEncryptionStatus != SYSENC_STATUS_NONE
- && SystemEncryptionStatus != SYSENC_STATUS_PRETEST
- && SysEncryptionOrDecryptionRequired ())
- {
- // System encryption/decryption had been in progress and did not finish
-
- if (CreateSysEncMutex ()) // If no other instance is currently taking care of system encryption
- {
- if (AskWarnYesNo ("SYSTEM_ENCRYPTION_RESUME_PROMPT", hwndDlg) == IDYES)
- {
- bDirectSysEncMode = TRUE;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
- LoadPage (hwndDlg, SYSENC_ENCRYPTION_PAGE);
- return;
- }
- else
- CloseSysEncMutex ();
- }
- }
-
- else if (SystemEncryptionStatus == SYSENC_STATUS_PRETEST)
- {
- // System pretest had been in progress but we were not launched during the startup seq
-
- if (CreateSysEncMutex ()) // If no other instance is currently taking care of system encryption
- {
- // The pretest has "priority handling"
- bDirectSysEncMode = TRUE;
- ChangeWizardMode (WIZARD_MODE_SYS_DEVICE);
-
- /* Do not return yet -- the principal pretest handler is below. */
- }
- }
-
- else if ((SystemEncryptionStatus == SYSENC_STATUS_NONE || SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING)
- && !BootEncStatus.DriveEncrypted
- && (BootEncStatus.DriveMounted || BootEncStatus.VolumeHeaderPresent))
- {
- // The pretest may have been in progress but we can't be sure (it is not in the config file).
- // Another possibility is that the user had finished decrypting the drive, but the config file
- // was not correctly updated. In both cases the best thing we can do is remove the header and
- // deinstall. Otherwise, the result might be some kind of deadlock.
-
- if (CreateSysEncMutex ()) // If no other instance is currently taking care of system encryption
- {
- WaitCursor ();
-
- ForceRemoveSysEnc();
-
- InconsistencyResolved (SRC_POS);
-
- NormalCursor();
- CloseSysEncMutex ();
- }
- }
- }
-
- if (bDirectSysEncMode && CreateSysEncMutex ())
- {
- // We were launched either by Mount or by the system (startup sequence). Most of such cases should have
- // been handled above already. Here we handle only the pretest phase (which can also be a hidden OS
- // creation phase actually) and possible inconsistencies.
-
- switch (SystemEncryptionStatus)
- {
- case SYSENC_STATUS_PRETEST:
- {
- unsigned int hiddenOSCreationPhase = DetermineHiddenOSCreationPhase();
-
- bHiddenOS = (hiddenOSCreationPhase != TC_HIDDEN_OS_CREATION_PHASE_NONE);
-
- // Evaluate the results of the system encryption pretest (or of the hidden OS creation process)
-
- try
- {
- BootEncStatus = BootEncObj->GetStatus();
- }
- catch (Exception &e)
- {
- e.Show (hwndDlg);
- Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", hwndDlg);
- EndMainDlg (MainDlg);
- return;
- }
-
- if (BootEncStatus.DriveMounted)
- {
- /* Pretest successful or hidden OS has been booted during the process of hidden OS creation. */
-
- switch (hiddenOSCreationPhase)
- {
- case TC_HIDDEN_OS_CREATION_PHASE_NONE:
-
- // Pretest successful (or the hidden OS has been booted for the first time since the user started installing a new decoy OS)
-
- if (IsHiddenOSRunning())
- {
- // The hidden OS has been booted for the first time since the user started installing a
- // new decoy OS (presumably, our MBR config flags have been erased).
-
- // As for things we are responsible for, the process of hidden OS creation is completed
- // (the rest is up to the user).
-
- ManageStartupSeqWiz (TRUE, L"");
- ChangeSystemEncryptionStatus (SYSENC_STATUS_NONE);
-
- EndMainDlg (MainDlg);
-
- return;
- }
-
- // Pretest successful (no hidden operating system involved)
-
- LoadPage (hwndDlg, SYSENC_PRETEST_RESULT_PAGE);
- return;
-
- case TC_HIDDEN_OS_CREATION_PHASE_WIPING:
-
- // Hidden OS has been booted when we are supposed to wipe the original OS
-
- LoadPage (hwndDlg, SYSENC_HIDDEN_OS_INITIAL_INFO_PAGE);
- return;
-
- case TC_HIDDEN_OS_CREATION_PHASE_WIPED:
-
- // Hidden OS has been booted and the original OS wiped. Now the user is required to install a new, decoy, OS.
-
- TextInfoDialogBox (TC_TBXID_DECOY_OS_INSTRUCTIONS);
-
- EndMainDlg (MainDlg);
- return;
-
- default:
-
- // Unexpected/unknown status
- ReportUnexpectedState (SRC_POS);
- EndMainDlg (MainDlg);
- return;
- }
- }
- else
- {
- BOOL bAnswerTerminate = FALSE, bAnswerRetry = FALSE;
-
- /* Pretest failed
- or hidden OS cloning has been interrupted (and non-hidden OS is running)
- or wiping of the original OS has not been started (and non-hidden OS is running) */
-
- if (hiddenOSCreationPhase == TC_HIDDEN_OS_CREATION_PHASE_NONE)
- {
- // Pretest failed (no hidden operating system involved)
-
- if (AskWarnYesNo ("BOOT_PRETEST_FAILED_RETRY", hwndDlg) == IDYES)
- {
- // User wants to retry the pretest
- bAnswerTerminate = FALSE;
- bAnswerRetry = TRUE;
- }
- else
- {
- // User doesn't want to retry the pretest
- bAnswerTerminate = TRUE;
- bAnswerRetry = FALSE;
- }
- }
- else
- {
- // Hidden OS cloning was interrupted or wiping of the original OS has not been started
-
- char *tmpStr[] = {0,
- hiddenOSCreationPhase == TC_HIDDEN_OS_CREATION_PHASE_WIPING ? "OS_WIPING_NOT_FINISHED_ASK" : "HIDDEN_OS_CREATION_NOT_FINISHED_ASK",
- "HIDDEN_OS_CREATION_NOT_FINISHED_CHOICE_RETRY",
- "HIDDEN_OS_CREATION_NOT_FINISHED_CHOICE_TERMINATE",
- "HIDDEN_OS_CREATION_NOT_FINISHED_CHOICE_ASK_LATER",
- 0};
-
- switch (AskMultiChoice ((void **) tmpStr, FALSE, hwndDlg))
- {
- case 1:
- // User wants to restart and continue/retry
- bAnswerTerminate = FALSE;
- bAnswerRetry = TRUE;
- break;
-
- case 2:
- // User doesn't want to retry but wants to terminate the entire process of hidden OS creation
- bAnswerTerminate = TRUE;
- bAnswerRetry = FALSE;
- break;
-
- default:
- // User doesn't want to do anything now
- bAnswerTerminate = FALSE;
- bAnswerRetry = FALSE;
- }
- }
-
-
- if (bAnswerRetry)
- {
- // User wants to restart and retry the pretest (or hidden OS creation)
-
- // We re-register the driver for boot because the user may have selected
- // "Last Known Good Configuration" from the Windows boot menu.
- // Note that we need to do this even when creating a hidden OS (because
- // the hidden OS needs our boot driver and it will be a clone of this OS).
- try
- {
- BootEncObj->RegisterBootDriver (bHiddenOS ? true : false);
- }
- catch (Exception &e)
- {
- e.Show (NULL);
- }
-
- if (AskWarnYesNo ("CONFIRM_RESTART", hwndDlg) == IDYES)
- {
- EndMainDlg (MainDlg);
-
- try
- {
- BootEncObj->RestartComputer ();
- }
- catch (Exception &e)
- {
- e.Show