コード例 #1
0
        public static bool IsVolumeEncryptionPaused(ManagementObject encryptableVolume, out Exception ex)
        {
            int num;

            BitlockerUtil.BitlockerConversionState bitlockerConversionState = BitlockerUtil.GetBitlockerConversionState(encryptableVolume, out num, out ex);
            return(bitlockerConversionState == BitlockerUtil.BitlockerConversionState.EncryptionPaused);
        }
コード例 #2
0
        public static Exception ValidateAndEncryptEmptyWin7Volume(ManagementObject encryptableVolume, bool fipsCompliant, out int returnValueEncrypt)
        {
            int returnValue = -1;

            returnValueEncrypt = -1;
            if (encryptableVolume == null)
            {
                return(new EncryptableVolumeArgNullException("ValidateAndEncryptEmptyWin7Volume"));
            }
            string deviceID = encryptableVolume.GetPropertyValue("DeviceId").ToString();

            if (Util.IsOperatingSystemWin8OrHigher())
            {
                return(new FullVolumeEncryptionOnWin8ServerException(deviceID));
            }
            Exception ex = Util.HandleExceptions(delegate
            {
                Exception ex = null;
                if (!BitlockerUtil.IsVolumeEmpty(deviceID, out ex))
                {
                    Util.ThrowIfNotNull(ex);
                    throw new FullVolumeEncryptionAttemptOnANonEmptyVolumeException(deviceID);
                }
                string mountPoint;
                string eventXML;
                bool flag = BitlockerUtil.DoesVolumeHaveBadBlocks(deviceID, out mountPoint, out ex, out eventXML);
                if (flag)
                {
                    throw new Win7EmptyVolumeNotStartedDueToPreviousFailureBadBlocksException(deviceID, mountPoint, eventXML);
                }
                if (!fipsCompliant)
                {
                    ex = BitlockerUtil.AddNumericalPassword(encryptableVolume, "563563-218372-416746-433752-541937-608069-594110-446754", out returnValue);
                    Util.ThrowIfNotNull(ex);
                }
                ex = BitlockerUtil.AddCertificateBasedKeyProtectors(encryptableVolume, out returnValue);
                Util.ThrowIfNotNull(ex);
                ex = BitlockerUtil.Encrypt(encryptableVolume, false, out returnValue);
                Util.ThrowIfNotNull(ex);
                BitlockerUtil.BitlockerConversionState bitlockerConversionState = BitlockerUtil.GetBitlockerConversionState(encryptableVolume, out returnValue, out ex);
                Util.ThrowIfNotNull(ex);
                if (bitlockerConversionState != BitlockerUtil.BitlockerConversionState.EncryptionInProgress)
                {
                    throw new Win7EmptyVolumeNotEncryptingAfterStartingEncryptionException(deviceID, bitlockerConversionState.ToString());
                }
            });

            returnValueEncrypt = returnValue;
            return(Util.ReturnWMIErrorExceptionOnExceptionOrError(returnValueEncrypt, "ValidateAndEncryptEmptyWin7Volume", ex));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public static BitlockerUtil.BitlockerConversionState GetBitlockerConversionState(ManagementObject encryptableVolume, out int returnValueConversionState, out Exception ex)
        {
            BitlockerUtil.BitlockerConversionState bitlockerConversionState = BitlockerUtil.BitlockerConversionState.Unknown;
            ManagementBaseObject outParams = null;

            ex = null;
            int returnValue = -1;

            ex = Util.HandleExceptions(delegate
            {
                returnValue = WMIUtil.CallWMIMethod(encryptableVolume, "GetConversionStatus", null, null, out outParams);
                if (returnValue == 0)
                {
                    int num = Convert.ToInt32(outParams["ConversionStatus"]);
                    if (Enum.IsDefined(typeof(BitlockerUtil.BitlockerConversionState), num))
                    {
                        bitlockerConversionState = (BitlockerUtil.BitlockerConversionState)num;
                    }
                }
            });
            returnValueConversionState = returnValue;
            return(bitlockerConversionState);
        }