如何在没有管理员权限的情况下判断驱动器是否已加密 BitLocker?

c00*_*0fd 4 c++ windows encryption winapi

为了我的目的,我需要知道的是驱动器的 DOS 路径的 BitLocker 加密状态。像这样的东西:

enum DriveEncryptionStatus{
    Unprotected,
    Protected,
    Unknown
};

DriveEncryptionStatus = GetDriveBitlockerEncryptionStatus(L"C:\\");
Run Code Online (Sandbox Code Playgroud)

我能够找到Win32_EncryptableVolume类,不幸的是,这个警告伴随着:

要使用 Win32_EncryptableVolume 方法,必须满足以下条件: 您必须具有管理员权限。

知道如何在不以管理员身份运行的情况下执行此操作吗?

小智 8

在此答案的基础上...

在 Windows 10 1909 (10.0.18363.1082) 上凭经验确定的值System.Volume.BitLockerProtection

| System.Volume.      | Control Panel                    | manage-bde conversion     | manage-bde     | Get-BitlockerVolume          | Get-BitlockerVolume |
| BitLockerProtection |                                  |                           | protection     | VolumeStatus                 | ProtectionStatus    |
| ------------------- | -------------------------------- | ------------------------- | -------------- | ---------------------------- | ------------------- |
|                   1 | BitLocker on                     | Used Space Only Encrypted | Protection On  | FullyEncrypted               | On                  |
|                   1 | BitLocker on                     | Fully Encrypted           | Protection On  | FullyEncrypted               | On                  |
|                   1 | BitLocker on                     | Fully Encrypted           | Protection On  | FullyEncryptedWipeInProgress | On                  |
|                   2 | BitLocker off                    | Fully Decrypted           | Protection Off | FullyDecrypted               | Off                 |
|                   3 | BitLocker Encrypting             | Encryption In Progress    | Protection Off | EncryptionInProgress         | Off                 |
|                   3 | BitLocker Encryption Paused      | Encryption Paused         | Protection Off | EncryptionSuspended          | Off                 |
|                   4 | BitLocker Decrypting             | Decryption in progress    | Protection Off | DecyptionInProgress          | Off                 |
|                   4 | BitLocker Decryption Paused      | Decryption Paused         | Protection Off | DecryptionSuspended          | Off                 |
|                   5 | BitLocker suspended              | Used Space Only Encrypted | Protection Off | FullyEncrypted               | Off                 |
|                   5 | BitLocker suspended              | Fully Encrypted           | Protection Off | FullyEncrypted               | Off                 |
|                   6 | BitLocker on (Locked)            | Unknown                   | Unknown        | $null                        | Unknown             |
|                   7 |                                  |                           |                |                              |                     |
|                   8 | BitLocker waiting for activation | Used Space Only Encrypted | Protection Off | FullyEncrypted               | Off                 |
Run Code Online (Sandbox Code Playgroud)


sly*_*ete 7

BitLocker 状态可供 shell 中的任何普通用户使用。Windows 使用Win32 API 中的Windows 属性系统来获取状态,以检查未记录的外壳属性System.Volume.BitLockerProtection。您的程序还可以在没有提升的情况下检查此属性。

如果此属性的值为 1、3 或 5,则在驱动器上启用了 BitLocker。任何其他值都被视为关闭。

您可以使用 Win32 API 来检查此外壳属性。出于礼貌,我已将我的托管实现从我对类似问题的其他答案移植过来

#include <shlobj.h>
#pragma comment(lib, "shell32.lib")
#pragma comment(lib, "propsys.lib")

DriveEncryptionStatus getDriveEncryptionStatus(LPCWSTR parsingName)
{
    IShellItem2 *drive = NULL;
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
    hr = SHCreateItemFromParsingName(parsingName, NULL, IID_PPV_ARGS(&drive));
    if (SUCCEEDED(hr)) {
        PROPERTYKEY pKey;
        hr = PSGetPropertyKeyFromName(L"System.Volume.BitLockerProtection", &pKey);
        if (SUCCEEDED(hr)) {
            PROPVARIANT prop;
            PropVariantInit(&prop);
            hr = drive->GetProperty(pKey, &prop);
            if (SUCCEEDED(hr)) {
                int status = prop.intVal;

                drive->Release();

                if (status == 1 || status == 3 || status == 5)
                    return DriveEncryptionStatus::Protected;
                else
                    return DriveEncryptionStatus::Unprotected;
            }
        }
    }

    if (drive)
        drive->Release();

    return DriveEncryptionStatus::Unknown;
}

int main()
{
    DriveEncryptionStatus status = getDriveEncryptionStatus(L"C:");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

  • 相信我在 Bitlocker powershell 模块中的 Microsoft.BitLocker.Structures.BitLockervolumeStatus 中找到了它们:0 -fullyDecrypted、1:FullyEncrypted、2:EncryptionInProgress、3:DecryptionInProgress、4:EncryptionSuspended、5:DecryptionSuspended、6:FullyEncryptedWipeFullyEncryptedWipeSuspended (2认同)