mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Windows: Fix false positive detection of new device insertion when clear keys option is enable
When this option is enabled, we first build the list of currently inserted devices then we start listening to insertion events. When a device insertion occurs, we check if this device is on our list and if yes, we ignore its insertion. We also ignore devices whose Device ID starts with "SWD\" and "ROOT\" since these are not real devices.
This commit is contained in:
@@ -491,4 +491,9 @@ DWORD BaseCom::UpdateSetupConfigFile (BOOL bForInstall)
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD BaseCom::NotifyService(DWORD dwNotifyCode)
|
||||
{
|
||||
return SendServiceNotification(dwNotifyCode);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,8 @@ public:
|
||||
static DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
|
||||
static DWORD UpdateSetupConfigFile (BOOL bForInstall);
|
||||
static DWORD GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded);
|
||||
static DWORD NotifyService (DWORD dwNotifyCode);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -667,6 +667,18 @@ namespace VeraCrypt
|
||||
}
|
||||
}
|
||||
|
||||
static void NotifyService (DWORD dwNotifyCmd)
|
||||
{
|
||||
Elevate();
|
||||
|
||||
DWORD result = ElevatedComInstance->NotifyService (dwNotifyCmd);
|
||||
if (result != ERROR_SUCCESS)
|
||||
{
|
||||
SetLastError (result);
|
||||
throw SystemException(SRC_POS);
|
||||
}
|
||||
}
|
||||
|
||||
static void Release ()
|
||||
{
|
||||
if (--ReferenceCount == 0 && ElevatedComInstance)
|
||||
@@ -5708,6 +5720,22 @@ namespace VeraCrypt
|
||||
throw_sys_if (!WriteLocalMachineRegistryDword (keyPath, valueName, value));
|
||||
}
|
||||
|
||||
void BootEncryption::NotifyService (DWORD dwNotifyCmd)
|
||||
{
|
||||
if (!IsAdmin() && IsUacSupported())
|
||||
{
|
||||
Elevator::NotifyService (dwNotifyCmd);
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD dwRet = SendServiceNotification(dwNotifyCmd);
|
||||
if (dwRet != ERROR_SUCCESS)
|
||||
{
|
||||
SetLastError(dwRet);
|
||||
throw SystemException (SRC_POS);
|
||||
}
|
||||
}
|
||||
|
||||
void BootEncryption::StartDecryption (BOOL discardUnreadableEncryptedSectors)
|
||||
{
|
||||
BootEncryptionStatus encStatus = GetStatus();
|
||||
|
||||
@@ -314,6 +314,7 @@ namespace VeraCrypt
|
||||
static void UpdateSetupConfigFile (bool bForInstall);
|
||||
void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded);
|
||||
bool IsUsingUnsupportedAlgorithm(LONG driverVersion);
|
||||
void NotifyService (DWORD dwNotifyCmd);
|
||||
protected:
|
||||
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
|
||||
|
||||
|
||||
@@ -15711,4 +15711,36 @@ bool OneOfKBsInstalled (const wchar_t* szKBs[], int count)
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
DWORD SendServiceNotification (DWORD dwNotificationCmd)
|
||||
{
|
||||
DWORD dwRet = ERROR_INVALID_PARAMETER;
|
||||
// We only support clearing keys on new device insertion
|
||||
if (VC_DRIVER_CONFIG_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION == dwNotificationCmd)
|
||||
{
|
||||
DWORD dwServiceControlCode = VC_SERVICE_CONTROL_BUILD_DEVICE_LIST;
|
||||
// send this control code to VeraCrypt SystemFavorites service
|
||||
SC_HANDLE hSCManager = OpenSCManager (NULL, NULL, SC_MANAGER_CONNECT);
|
||||
if (hSCManager != NULL)
|
||||
{
|
||||
SC_HANDLE hService = OpenService (hSCManager, TC_SYSTEM_FAVORITES_SERVICE_NAME, SERVICE_ALL_ACCESS);
|
||||
if (hService != NULL)
|
||||
{
|
||||
SERVICE_STATUS ss;
|
||||
if (ControlService (hService, dwServiceControlCode, &ss))
|
||||
dwRet = ERROR_SUCCESS;
|
||||
else
|
||||
dwRet = GetLastError ();
|
||||
CloseServiceHandle (hService);
|
||||
}
|
||||
else
|
||||
dwRet = GetLastError ();
|
||||
CloseServiceHandle (hSCManager);
|
||||
}
|
||||
else
|
||||
dwRet = GetLastError ();
|
||||
}
|
||||
|
||||
return dwRet;
|
||||
}
|
||||
#endif // VC_COMREG
|
||||
@@ -84,6 +84,9 @@ enum
|
||||
|
||||
#define VC_FILENAME_RENAMED_SUFFIX L"_old"
|
||||
|
||||
/* customer service control code to build device list */
|
||||
#define VC_SERVICE_CONTROL_BUILD_DEVICE_LIST 128
|
||||
|
||||
#ifndef USER_DEFAULT_SCREEN_DPI
|
||||
#define USER_DEFAULT_SCREEN_DPI 96
|
||||
#endif
|
||||
@@ -585,6 +588,7 @@ BOOL EnableProcessProtection();
|
||||
void SafeOpenURL (LPCWSTR szUrl);
|
||||
BitLockerEncryptionStatus GetBitLockerEncryptionStatus(WCHAR driveLetter);
|
||||
BOOL IsTestSigningModeEnabled ();
|
||||
DWORD SendServiceNotification (DWORD dwNotificationCmd);
|
||||
#ifdef _WIN64
|
||||
void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user