VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/BootEncryption.cpp64
-rw-r--r--src/Common/BootEncryption.h8
-rw-r--r--src/Common/Common.rc17
-rw-r--r--src/Common/Dlgcode.c74
-rw-r--r--src/Common/Dlgcode.h1
-rw-r--r--src/Common/Resource.h15
-rw-r--r--src/Common/Tcdefs.h8
7 files changed, 166 insertions, 21 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index 6dc2c979..a8481f3b 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -1565,7 +1565,7 @@ namespace VeraCrypt
{
if (GetSystemDriveConfiguration().SystemPartition.IsGPT)
{
- byte confContent[4096];
+ byte confContent[4096*8];
DWORD dwSize;
// for now, we don't support any boot config flags, like hidden OS one
@@ -2032,13 +2032,17 @@ namespace VeraCrypt
BOOL EfiBootConf::Save (const wchar_t* fileName, HWND hwnd)
{
- FILE *configFile = _wfopen (fileName, L"w,ccs=UTF-8");
- if (configFile == NULL)
- return FALSE;
BOOL bRet = FALSE;
DWORD size = 0;
char* configContent = LoadFile (fileName, &size);
+
+ FILE *configFile = _wfopen (fileName, L"w,ccs=UTF-8");
+ if (configFile == NULL) {
+ burn (configContent, size);
+ free (configContent);
+ return FALSE;
+ }
XmlWriteHeader (configFile);
@@ -2088,15 +2092,43 @@ namespace VeraCrypt
static const wchar_t* EfiVarGuid = L"{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}";
+ void
+ GetVolumeESP(wstring& path)
+ {
+ ULONG len;
+ NTSTATUS res;
+ WCHAR tempBuf[1024];
+ memset(tempBuf, 0, sizeof(tempBuf));
+
+ // Load NtQuerySystemInformation function point
+ if (!NtQuerySystemInformationPtr)
+ {
+ NtQuerySystemInformationPtr = (NtQuerySystemInformationFn) GetProcAddress (GetModuleHandle (L"ntdll.dll"), "NtQuerySystemInformation");
+ if (!NtQuerySystemInformationPtr)
+ throw SystemException (SRC_POS);
+ }
+
+ res = NtQuerySystemInformationPtr((SYSTEM_INFORMATION_CLASS)SYSPARTITIONINFORMATION, tempBuf, sizeof(tempBuf), &len);
+ if (res != S_OK)
+ {
+ SetLastError (res);
+ throw SystemException (SRC_POS);
+ }
+
+ PUNICODE_STRING pStr = (PUNICODE_STRING) tempBuf;
+ path = L"\\\\?";
+ path += &pStr->Buffer[7];
+ }
+
EfiBoot::EfiBoot() {
ZeroMemory(EfiBootPartPath, sizeof(EfiBootPartPath));
- ZeroMemory (systemPartitionPath, sizeof (systemPartitionPath));
+ ZeroMemory (BootVolumePath, sizeof (BootVolumePath));
ZeroMemory (&sdn, sizeof (sdn));
ZeroMemory (&partInfo, sizeof (partInfo));
m_bMounted = false;
}
- void EfiBoot::MountBootPartition(WCHAR letter) {
+ void EfiBoot::SelectBootVolumeESP() {
NTSTATUS res;
ULONG len;
memset(tempBuf, 0, sizeof(tempBuf));
@@ -2117,7 +2149,23 @@ namespace VeraCrypt
}
PUNICODE_STRING pStr = (PUNICODE_STRING) tempBuf;
- memcpy (systemPartitionPath, pStr->Buffer, min (pStr->Length, (sizeof (systemPartitionPath) - 2)));
+ memcpy (BootVolumePath, pStr->Buffer, min (pStr->Length, (sizeof (BootVolumePath) - 2)));
+ bBootVolumePathSelected = TRUE;
+ }
+
+ void EfiBoot::SelectBootVolume(WCHAR* bootVolumePath) {
+ wstring str;
+ str = bootVolumePath;
+ memcpy (BootVolumePath, &str[0], min (str.length() * 2, (sizeof (BootVolumePath) - 2)));
+ bBootVolumePathSelected = TRUE;
+ }
+
+ void EfiBoot::MountBootPartition(WCHAR letter) {
+ NTSTATUS res;
+ ULONG len;
+ if (!bBootVolumePathSelected) {
+ SelectBootVolumeESP();
+ }
if (!letter) {
if (!GetFreeDriveLetter(&EfiBootPartPath[0])) {
@@ -2128,7 +2176,7 @@ namespace VeraCrypt
}
EfiBootPartPath[1] = ':';
EfiBootPartPath[2] = 0;
- throw_sys_if(!DefineDosDevice(DDD_RAW_TARGET_PATH, EfiBootPartPath, systemPartitionPath));
+ throw_sys_if(!DefineDosDevice(DDD_RAW_TARGET_PATH, EfiBootPartPath, BootVolumePath));
Device dev(EfiBootPartPath, TRUE);
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index c63aa80e..80ca3b52 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -186,6 +186,8 @@ namespace VeraCrypt
BOOL Save (const wchar_t* fileName, HWND hwnd);
};
+ void GetVolumeESP(wstring& path);
+
class EfiBoot {
public:
EfiBoot();
@@ -208,7 +210,8 @@ namespace VeraCrypt
BOOL UpdateConfig (const wchar_t* name, int pim, int hashAlgo, HWND hwndDlg);
BOOL WriteConfig (const wchar_t* name, bool preserveUserConfig, int pim, int hashAlgo, const char* passPromptMsg, HWND hwndDlg);
BOOL DelDir(const wchar_t* name);
-
+ void SelectBootVolumeESP();
+ void SelectBootVolume(WCHAR* bootVolumePath);
PSTORAGE_DEVICE_NUMBER GetStorageDeviceNumber () { return &sdn;}
protected:
@@ -217,7 +220,8 @@ namespace VeraCrypt
STORAGE_DEVICE_NUMBER sdn;
PARTITION_INFORMATION_EX partInfo;
WCHAR tempBuf[1024];
- WCHAR systemPartitionPath[MAX_PATH];
+ bool bBootVolumePathSelected;
+ WCHAR BootVolumePath[MAX_PATH];
};
class BootEncryption
diff --git a/src/Common/Common.rc b/src/Common/Common.rc
index 91c77a58..a9313f1a 100644
--- a/src/Common/Common.rc
+++ b/src/Common/Common.rc
@@ -335,6 +335,15 @@ BEGIN
CONTROL "",IDC_WAIT_PROGRESS_BAR,"msctls_progress32",WS_BORDER,7,49,278,14
END
+IDD_TEXT_EDIT_DLG DIALOGEX 0, 0, 372, 220
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,306,201,58,14
+ CONTROL "",IDC_INFO_BOX_TEXT,"RichEdit20W",ES_MULTILINE | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,5,6,361,188
+ DEFPUSHBUTTON "Cancel",IDCANCEL,240,201,58,14
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -478,6 +487,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 67
END
+
+ IDD_TEXT_EDIT_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 365
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 213
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index eea34b82..67e6b379 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -3360,6 +3360,80 @@ wstring GetDecoyOsInstructionsString (void)
+ GetString ("DECOY_OS_INSTRUCTIONS_PORTION_18"));
}
+struct _TEXT_EDIT_DIALOG_PARAM {
+ int Type;
+ std::string& Text;
+ const WCHAR* Title;
+ HWND Parent;
+ _TEXT_EDIT_DIALOG_PARAM(int _type, const WCHAR* title, std::string& _text) : Title(title), Text(_text), Type(_type) {}
+ _TEXT_EDIT_DIALOG_PARAM& operator=( const _TEXT_EDIT_DIALOG_PARAM& other) {
+ Type = other.Type;
+ Text = other.Text;
+ Title = other.Title;
+ return *this;
+}
+};
+typedef struct _TEXT_EDIT_DIALOG_PARAM TEXT_INFO_DIALOG_PARAM,*TEXT_INFO_DIALOG_PARAM_PTR;
+
+INT_PTR TextEditDialogBox (int type, HWND parent, const WCHAR* Title, std::string& text)
+{
+ TEXT_INFO_DIALOG_PARAM pm(type, Title, text);
+ return DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TEXT_EDIT_DLG), parent, (DLGPROC) TextEditDlgProc, (LPARAM) &pm);
+}
+
+BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WORD lw = LOWORD (wParam);
+ static int nID = 0;
+ static TEXT_INFO_DIALOG_PARAM_PTR prm;
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ prm = (TEXT_INFO_DIALOG_PARAM_PTR)lParam;
+ // increase size limit of rich edit control
+ SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1);
+
+ SetWindowTextW (hwndDlg, prm->Title);
+ // Left margin for rich edit text field
+ SendMessage (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4));
+
+ SendMessage (hwndDlg, TC_APPMSG_LOAD_TEXT_BOX_CONTENT, 0, 0);
+ }
+ return 0;
+
+ case WM_COMMAND:
+ if (lw == IDOK )
+ {
+ prm->Text.resize(GetWindowTextLengthA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT)) + 1);
+ GetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), &(prm->Text)[0], prm->Text.size());
+ NormalCursor ();
+ EndDialog (hwndDlg, IDOK);
+ return 1;
+ }
+
+ if (lw == IDCANCEL )
+ {
+ NormalCursor ();
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+ return 0;
+
+ case TC_APPMSG_LOAD_TEXT_BOX_CONTENT:
+ {
+ SetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), prm->Text.c_str());
+ }
+ return 0;
+
+ case WM_CLOSE:
+ NormalCursor ();
+ EndDialog (hwndDlg, 0);
+ return 1;
+ }
+
+ return 0;
+}
INT_PTR TextInfoDialogBox (int nID)
{
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 75196f84..1a66e102 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -313,6 +313,7 @@ int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath );
int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequired);
int IsNonSysPartitionOnSysDrive (const wchar_t *path);
BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
+BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR TextInfoDialogBox (int nID);
BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
char * GetLegalNotices ();
diff --git a/src/Common/Resource.h b/src/Common/Resource.h
index 0862a05d..7106b3b8 100644
--- a/src/Common/Resource.h
+++ b/src/Common/Resource.h
@@ -59,14 +59,14 @@
#define IDR_RESCUE_LOADER_AES_SHA2 555
#define IDR_RESCUE_LOADER_SERPENT_SHA2 556
#define IDR_RESCUE_LOADER_TWOFISH_SHA2 557
-#define IDR_BOOT_SECTOR_CAMELLIA 558
-#define IDR_BOOT_LOADER_CAMELLIA 559
-#define IDR_RESCUE_BOOT_SECTOR_CAMELLIA 560
-#define IDR_RESCUE_LOADER_CAMELLIA 561
-#define IDR_BOOT_SECTOR_CAMELLIA_SHA2 562
-#define IDR_BOOT_LOADER_CAMELLIA_SHA2 563
+#define IDR_BOOT_SECTOR_CAMELLIA 558
+#define IDR_BOOT_LOADER_CAMELLIA 559
+#define IDR_RESCUE_BOOT_SECTOR_CAMELLIA 560
+#define IDR_RESCUE_LOADER_CAMELLIA 561
+#define IDR_BOOT_SECTOR_CAMELLIA_SHA2 562
+#define IDR_BOOT_LOADER_CAMELLIA_SHA2 563
#define IDR_RESCUE_BOOT_SECTOR_CAMELLIA_SHA2 564
-#define IDR_RESCUE_LOADER_CAMELLIA_SHA2 565
+#define IDR_RESCUE_LOADER_CAMELLIA_SHA2 565
#define IDR_EFI_DCSBOOT 566
#define IDR_EFI_DCSINT 567
#define IDR_EFI_DCSCFG 568
@@ -222,6 +222,7 @@
#define IDT_BENCHMARK 5138
#define IDC_BENCHMARK_LIST 5139
#define IDC_BENCHMARK_PREBOOT 5140
+#define IDD_TEXT_EDIT_DLG 5141
// Next default values for new objects
//
diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h
index bcf2928e..149603a2 100644
--- a/src/Common/Tcdefs.h
+++ b/src/Common/Tcdefs.h
@@ -55,15 +55,15 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift);
#define TC_APP_NAME "VeraCrypt"
// Version displayed to user
-#define VERSION_STRING "1.20-BETA2"
+#define VERSION_STRING "1.20-BETA2p1"
// Version number to compare against driver
#define VERSION_NUM 0x0120
// Release date
-#define TC_STR_RELEASE_DATE L"December 30th, 2016"
-#define TC_RELEASE_DATE_YEAR 2016
-#define TC_RELEASE_DATE_MONTH 12
+#define TC_STR_RELEASE_DATE L"February 25, 2017"
+#define TC_RELEASE_DATE_YEAR 2017
+#define TC_RELEASE_DATE_MONTH 02
#define BYTES_PER_KB 1024LL
#define BYTES_PER_MB 1048576LL