Exemple #1
0
 public static string GetReturnValueExceptionInconsistencyErrorMessage(string methodName, Exception ex)
 {
     if (ex != null)
     {
         return(DiskManagementStrings.ReturnValueExceptionInconsistency(methodName, ex.Message));
     }
     return(DiskManagementStrings.ReturnValueExceptionInconsistency(methodName, "Exception is null"));
 }
        public static Exception IsVolumeEncryptedOrEncrypting(string deviceId, out bool isVolumeEncrypting, out bool isVolumeEncrypted)
        {
            isVolumeEncrypting = false;
            isVolumeEncrypted  = false;
            Exception ex  = null;
            Exception ex2 = null;
            Exception ex3 = null;

            if (!BitlockerUtil.IsSystemVolume(deviceId, out ex) && !BitlockerUtil.IsBootVolume(deviceId, out ex2))
            {
                if (ex != null)
                {
                    return(ex);
                }
                if (ex2 != null)
                {
                    return(ex2);
                }
                ManagementObject encryptableVolume = BitlockerUtil.GetEncryptableVolume(deviceId, out ex3);
                if (encryptableVolume == null)
                {
                    return(ex3);
                }
                int num;
                BitlockerUtil.BitlockerConversionState bitlockerConversionState = BitlockerUtil.GetBitlockerConversionState(encryptableVolume, out num, out ex3);
                if (ex3 != null)
                {
                    return(ex3);
                }
                if (bitlockerConversionState != BitlockerUtil.BitlockerConversionState.FullyDecrypted && bitlockerConversionState != BitlockerUtil.BitlockerConversionState.FullyEncrypted && bitlockerConversionState != BitlockerUtil.BitlockerConversionState.EncryptionPaused && bitlockerConversionState != BitlockerUtil.BitlockerConversionState.Unknown)
                {
                    isVolumeEncrypting = true;
                }
                if (bitlockerConversionState == BitlockerUtil.BitlockerConversionState.FullyEncrypted)
                {
                    isVolumeEncrypted = true;
                }
                ExAssert.RetailAssert(!isVolumeEncrypting || !isVolumeEncrypted, DiskManagementStrings.VolumeCannotBeBothEncryptingAndEncrypted(deviceId));
            }
            return(ex3);
        }