VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/BootEncryption.cpp
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2017-02-26 10:48:24 +0300
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-06-05 17:45:45 +0200
commitcf5729d4e184831d8d1a9bb3a83db9b645f96c24 (patch)
tree20bc6797f36b1ac27b827435e83d956175adcd50 /src/Common/BootEncryption.cpp
parent46cd09ef50bb63fa2b30b9c4f9fd284e130a46d4 (diff)
downloadVeraCrypt-cf5729d4e184831d8d1a9bb3a83db9b645f96c24.tar.gz
VeraCrypt-cf5729d4e184831d8d1a9bb3a83db9b645f96c24.zip
Beta2 patch 1
Edit DcsProp and PlatformInfo from System->Settings EFI loader updated
Diffstat (limited to 'src/Common/BootEncryption.cpp')
-rw-r--r--src/Common/BootEncryption.cpp64
1 files changed, 56 insertions, 8 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);