mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Windows: Remove VeraCrypt from EFI boot partition after decrypting the system
This commit is contained in:
@@ -2351,7 +2351,7 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EfiBoot::SaveFile(wchar_t* name, byte* data, DWORD size) {
|
void EfiBoot::SaveFile(const wchar_t* name, byte* data, DWORD size) {
|
||||||
wstring path = EfiBootPartPath;
|
wstring path = EfiBootPartPath;
|
||||||
path += name;
|
path += name;
|
||||||
File f(path, false, true);
|
File f(path, false, true);
|
||||||
@@ -2389,7 +2389,7 @@ namespace VeraCrypt
|
|||||||
throw_sys_if (!::CopyFileW (path.c_str(), targetPath.c_str(), FALSE));
|
throw_sys_if (!::CopyFileW (path.c_str(), targetPath.c_str(), FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EfiBoot::RenameFile(wchar_t* name, wchar_t* nameNew, BOOL bForce) {
|
BOOL EfiBoot::RenameFile(const wchar_t* name, wchar_t* nameNew, BOOL bForce) {
|
||||||
wstring path = EfiBootPartPath;
|
wstring path = EfiBootPartPath;
|
||||||
path += name;
|
path += name;
|
||||||
wstring pathNew = EfiBootPartPath;
|
wstring pathNew = EfiBootPartPath;
|
||||||
@@ -2397,13 +2397,13 @@ namespace VeraCrypt
|
|||||||
return MoveFileExW(path.c_str(), pathNew.c_str(), bForce? MOVEFILE_REPLACE_EXISTING : 0);
|
return MoveFileExW(path.c_str(), pathNew.c_str(), bForce? MOVEFILE_REPLACE_EXISTING : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EfiBoot::DelFile(wchar_t* name) {
|
BOOL EfiBoot::DelFile(const wchar_t* name) {
|
||||||
wstring path = EfiBootPartPath;
|
wstring path = EfiBootPartPath;
|
||||||
path += name;
|
path += name;
|
||||||
return DeleteFile(path.c_str());
|
return DeleteFile(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EfiBoot::MkDir(wchar_t* name, bool& bAlreadyExists) {
|
BOOL EfiBoot::MkDir(const wchar_t* name, bool& bAlreadyExists) {
|
||||||
wstring path = EfiBootPartPath;
|
wstring path = EfiBootPartPath;
|
||||||
path += name;
|
path += name;
|
||||||
bAlreadyExists = false;
|
bAlreadyExists = false;
|
||||||
@@ -2416,7 +2416,13 @@ namespace VeraCrypt
|
|||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EfiBoot::ReadConfig (wchar_t* name, EfiBootConf& conf)
|
BOOL EfiBoot::DelDir(const wchar_t* name) {
|
||||||
|
wstring path = EfiBootPartPath;
|
||||||
|
path += name;
|
||||||
|
return DeleteDirectory (path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL EfiBoot::ReadConfig (const wchar_t* name, EfiBootConf& conf)
|
||||||
{
|
{
|
||||||
wstring path = EfiBootPartPath;
|
wstring path = EfiBootPartPath;
|
||||||
path += name;
|
path += name;
|
||||||
@@ -2424,7 +2430,7 @@ namespace VeraCrypt
|
|||||||
return conf.Load (path.c_str());
|
return conf.Load (path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EfiBoot::UpdateConfig (wchar_t* name, int pim, int hashAlgo, HWND hwndDlg)
|
BOOL EfiBoot::UpdateConfig (const wchar_t* name, int pim, int hashAlgo, HWND hwndDlg)
|
||||||
{
|
{
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
EfiBootConf conf;
|
EfiBootConf conf;
|
||||||
@@ -2461,7 +2467,7 @@ namespace VeraCrypt
|
|||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL EfiBoot::WriteConfig (wchar_t* name, bool preserveUserConfig, int pim, int hashAlgo, const char* passPromptMsg, HWND hwndDlg)
|
BOOL EfiBoot::WriteConfig (const wchar_t* name, bool preserveUserConfig, int pim, int hashAlgo, const char* passPromptMsg, HWND hwndDlg)
|
||||||
{
|
{
|
||||||
EfiBootConf conf;
|
EfiBootConf conf;
|
||||||
wstring path = EfiBootPartPath;
|
wstring path = EfiBootPartPath;
|
||||||
@@ -3483,6 +3489,7 @@ namespace VeraCrypt
|
|||||||
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBml.dcs");
|
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBml.dcs");
|
||||||
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBoot");
|
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBoot");
|
||||||
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsProp");
|
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsProp");
|
||||||
|
EfiBootInst.DelDir (L"\\EFI\\VeraCrypt");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -196,17 +196,18 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
void DeleteStartExec(uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL);
|
void DeleteStartExec(uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL);
|
||||||
void SetStartExec(wstring description, wstring execPath, uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL, uint32 attr = 1);
|
void SetStartExec(wstring description, wstring execPath, uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL, uint32 attr = 1);
|
||||||
void SaveFile(wchar_t* name, byte* data, DWORD size);
|
void SaveFile(const wchar_t* name, byte* data, DWORD size);
|
||||||
void GetFileSize(const wchar_t* name, unsigned __int64& size);
|
void GetFileSize(const wchar_t* name, unsigned __int64& size);
|
||||||
void ReadFile(const wchar_t* name, byte* data, DWORD size);
|
void ReadFile(const wchar_t* name, byte* data, DWORD size);
|
||||||
void CopyFile(const wchar_t* name, const wchar_t* targetName);
|
void CopyFile(const wchar_t* name, const wchar_t* targetName);
|
||||||
|
|
||||||
BOOL RenameFile(wchar_t* name, wchar_t* nameNew, BOOL bForce);
|
BOOL RenameFile(const wchar_t* name, wchar_t* nameNew, BOOL bForce);
|
||||||
BOOL DelFile(wchar_t* name);
|
BOOL DelFile(const wchar_t* name);
|
||||||
BOOL MkDir(wchar_t* name, bool& bAlreadyExists);
|
BOOL MkDir(const wchar_t* name, bool& bAlreadyExists);
|
||||||
BOOL ReadConfig (wchar_t* name, EfiBootConf& conf);
|
BOOL ReadConfig (const wchar_t* name, EfiBootConf& conf);
|
||||||
BOOL UpdateConfig (wchar_t* name, int pim, int hashAlgo, HWND hwndDlg);
|
BOOL UpdateConfig (const wchar_t* name, int pim, int hashAlgo, HWND hwndDlg);
|
||||||
BOOL WriteConfig (wchar_t* name, bool preserveUserConfig, int pim, int hashAlgo, const char* passPromptMsg, 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);
|
||||||
|
|
||||||
PSTORAGE_DEVICE_NUMBER GetStorageDeviceNumber () { return &sdn;}
|
PSTORAGE_DEVICE_NUMBER GetStorageDeviceNumber () { return &sdn;}
|
||||||
|
|
||||||
|
|||||||
@@ -12204,3 +12204,24 @@ BOOL RaisePrivileges(void)
|
|||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL DeleteDirectory (const wchar_t* szDirName)
|
||||||
|
{
|
||||||
|
BOOL bStatus = RemoveDirectory (szDirName);
|
||||||
|
if (!bStatus)
|
||||||
|
{
|
||||||
|
/* force removal of the non empty directory */
|
||||||
|
wchar_t szOpPath[TC_MAX_PATH + 1] = {0};
|
||||||
|
SHFILEOPSTRUCTW op;
|
||||||
|
|
||||||
|
StringCchCopyW(szOpPath, ARRAYSIZE(szOpPath)-1, szDirName);
|
||||||
|
ZeroMemory(&op, sizeof(op));
|
||||||
|
op.wFunc = FO_DELETE;
|
||||||
|
op.pFrom = szOpPath;
|
||||||
|
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
|
||||||
|
|
||||||
|
if ((0 == SHFileOperation(&op)) && (!op.fAnyOperationsAborted))
|
||||||
|
bStatus = TRUE;
|
||||||
|
}
|
||||||
|
return bStatus;
|
||||||
|
}
|
||||||
|
|||||||
@@ -513,6 +513,7 @@ BOOL CopyTextToClipboard (const wchar_t* txtValue);
|
|||||||
BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args);
|
BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args);
|
||||||
BOOL GetFreeDriveLetter(WCHAR* pCh);
|
BOOL GetFreeDriveLetter(WCHAR* pCh);
|
||||||
BOOL RaisePrivileges(void);
|
BOOL RaisePrivileges(void);
|
||||||
|
BOOL DeleteDirectory (const wchar_t* szDirName);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,23 +128,7 @@ BOOL StatRemoveDirectory (wchar_t *lpszDir)
|
|||||||
|
|
||||||
if (_wstat64 (lpszDir, &st) == 0)
|
if (_wstat64 (lpszDir, &st) == 0)
|
||||||
{
|
{
|
||||||
BOOL bStatus = RemoveDirectory (lpszDir);
|
return DeleteDirectory (lpszDir);
|
||||||
if (!bStatus)
|
|
||||||
{
|
|
||||||
/* force removal of the non empty directory */
|
|
||||||
wchar_t szOpPath[TC_MAX_PATH + 1] = {0};
|
|
||||||
SHFILEOPSTRUCTW op;
|
|
||||||
|
|
||||||
StringCchCopyW(szOpPath, ARRAYSIZE(szOpPath)-1, lpszDir);
|
|
||||||
ZeroMemory(&op, sizeof(op));
|
|
||||||
op.wFunc = FO_DELETE;
|
|
||||||
op.pFrom = szOpPath;
|
|
||||||
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
|
|
||||||
|
|
||||||
if ((0 == SHFileOperation(&op)) && (!op.fAnyOperationsAborted))
|
|
||||||
bStatus = TRUE;
|
|
||||||
}
|
|
||||||
return bStatus;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user