public static bool IsBootVolume(ManagementObject encryptableVolume, out Exception ex) { ex = null; if (encryptableVolume == null) { return(false); } string deviceID = encryptableVolume.GetPropertyValue("DeviceID").ToString(); return(BitlockerUtil.IsBootVolume(deviceID, out ex)); }
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); }