1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

Windows: correctly handle SEH exceptions during self-tests in order to disable CPU extended features in such case.

This commit is contained in:
Mounir IDRASSI
2017-07-04 11:19:53 +02:00
parent 0358eb6c71
commit 88cc8a00f4
6 changed files with 91 additions and 54 deletions

View File

@@ -1355,18 +1355,45 @@ BOOL AutoTestAlgorithms (void)
{
BOOL result = TRUE;
BOOL hwEncryptionEnabled = IsHwEncryptionEnabled();
#if defined (_MSC_VER) && !defined (_UEFI)
BOOL exceptionCatched = FALSE;
__try
{
#endif
EnableHwEncryption (FALSE);
EnableHwEncryption (FALSE);
if (!DoAutoTestAlgorithms())
result = FALSE;
if (!DoAutoTestAlgorithms())
result = FALSE;
EnableHwEncryption (TRUE);
EnableHwEncryption (TRUE);
if (!DoAutoTestAlgorithms())
result = FALSE;
if (!DoAutoTestAlgorithms())
result = FALSE;
EnableHwEncryption (hwEncryptionEnabled);
#if defined (_MSC_VER) && !defined (_UEFI)
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
exceptionCatched = TRUE;
}
EnableHwEncryption (hwEncryptionEnabled);
if (exceptionCatched)
{
/* unexepected exception raised. Disable all CPU extended feature and try again */
EnableHwEncryption (hwEncryptionEnabled);
DisableCPUExtendedFeatures ();
__try
{
result = DoAutoTestAlgorithms();
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
/* exception still occuring. Report failure. */
result = FALSE;
}
}
#endif
return result;
}