VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Format/FormatCom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Format/FormatCom.cpp')
-rw-r--r--src/Format/FormatCom.cpp104
1 files changed, 92 insertions, 12 deletions
diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp
index 2aa5cea9..90333f23 100644
--- a/src/Format/FormatCom.cpp
+++ b/src/Format/FormatCom.cpp
@@ -3,9 +3,9 @@
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 all other portions of this file are Copyright (c) 2013-2017 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.
*/
@@ -91,13 +91,13 @@ public:
}
virtual BOOL STDMETHODCALLTYPE FormatNtfs (int driveNo, int clusterSize)
{
- return ::FormatNtfs (driveNo, clusterSize);
+ return ::FormatNtfs (driveNo, clusterSize, TRUE);
}
virtual int STDMETHODCALLTYPE AnalyzeHiddenVolumeHost (
- LONG_PTR hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters)
+ __int64 hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters)
{
return ::AnalyzeHiddenVolumeHost (
(HWND) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
}
@@ -133,9 +133,9 @@ public:
}
virtual BOOL STDMETHODCALLTYPE FormatFs (int driveNo, int clusterSize, int fsType)
{
- return ::FormatFs (driveNo, clusterSize, fsType);
+ return ::FormatFs (driveNo, clusterSize, fsType, TRUE);
}
virtual DWORD STDMETHODCALLTYPE GetFileSize (BSTR filePath, unsigned __int64 *pSize)
{
@@ -166,18 +166,33 @@ public:
{
return BaseCom::GetEfiBootDeviceNumber (pSdn);
}
- virtual DWORD STDMETHODCALLTYPE ReadEfiConfig (BSTR* pContent, DWORD *pcbRead)
+ virtual DWORD STDMETHODCALLTYPE GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded)
{
- return BaseCom::ReadEfiConfig (pContent, pcbRead);
+ return BaseCom::GetSecureBootConfig (pSecureBootEnabled, pVeraCryptKeysLoaded);
}
virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg)
{
return BaseCom::WriteEfiBootSectorUserConfig (userConfig, customUserMessage,pim, hashAlg);
}
+ virtual DWORD STDMETHODCALLTYPE UpdateSetupConfigFile (BOOL bForInstall)
+ {
+ return BaseCom::UpdateSetupConfigFile (bForInstall);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE NotifyService (DWORD dwNotifyCode)
+ {
+ return BaseCom::NotifyService (dwNotifyCode);
+ }
+
+ virtual DWORD STDMETHODCALLTYPE FastFileResize (BSTR filePath, __int64 fileSize)
+ {
+ return BaseCom::FastFileResize (filePath, fileSize);
+ }
+
protected:
DWORD MessageThreadId;
LONG RefCount;
ITrueCryptFormatCom *CallBack;
@@ -239,14 +254,14 @@ extern "C" int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize)
{
CComPtr<ITrueCryptFormatCom> tc;
int r;
- CoInitialize (NULL);
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (ComGetInstance (hWnd, &tc))
r = tc->FormatNtfs (driveNo, clusterSize);
else
- r = 0;
+ r = (int) GetLastError();
CoUninitialize ();
return r;
@@ -256,14 +271,14 @@ extern "C" int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType)
{
CComPtr<ITrueCryptFormatCom> tc;
int r;
- CoInitialize (NULL);
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (ComGetInstance (hWnd, &tc))
r = tc->FormatFs (driveNo, clusterSize, fsType);
else
- r = 0;
+ r = (int) GetLastError();
CoUninitialize ();
return r;
@@ -274,15 +289,80 @@ extern "C" int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 h
{
CComPtr<ITrueCryptFormatCom> tc;
int r;
- CoInitialize (NULL);
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (ComGetInstance (hwndDlg, &tc))
- r = tc->AnalyzeHiddenVolumeHost ((LONG_PTR) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
+ r = tc->AnalyzeHiddenVolumeHost ((__int64) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters);
else
r = 0;
CoUninitialize ();
return r;
}
+
+extern "C" BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPath, wchar_t *valueName, DWORD value)
+{
+ CComPtr<ITrueCryptFormatCom> tc;
+ int r = 0;
+
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+
+ if (ComGetInstance (hwndDlg, &tc))
+ {
+ CComBSTR keyPathBstr, valueNameBstr;
+ BSTR bstr = W2BSTR(keyPath);
+ if (bstr)
+ {
+ keyPathBstr.Attach (bstr);
+ bstr = W2BSTR(valueName);
+ if (bstr)
+ {
+ valueNameBstr.Attach (bstr);
+ r = tc->WriteLocalMachineRegistryDwordValue (keyPathBstr, valueNameBstr, value);
+ }
+ else
+ r = ERROR_OUTOFMEMORY;
+ }
+ else
+ r = ERROR_OUTOFMEMORY;
+ }
+
+ CoUninitialize ();
+
+ if (r == ERROR_SUCCESS)
+ return TRUE;
+ else
+ {
+ SetLastError (r);
+ return FALSE;
+ }
+}
+
+extern "C" DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize)
+{
+ CComPtr<ITrueCryptFormatCom> tc;
+ DWORD r;
+
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+
+ if (ComGetInstance (hWnd, &tc))
+ {
+ CComBSTR filePathBstr;
+ BSTR bstr = W2BSTR(filePath);
+ if (bstr)
+ {
+ filePathBstr.Attach (bstr);
+ r = tc->FastFileResize (filePathBstr, fileSize);
+ }
+ else
+ r = ERROR_OUTOFMEMORY;
+ }
+ else
+ r = GetLastError();
+
+ CoUninitialize ();
+
+ return r;
+}