Documentation
¶
Overview ¶
Package fveapi reads the BitLocker status of a volume through fveapi.dll.
fveapi.dll is the private user-mode BitLocker (Full Volume Encryption) API. It is undocumented and Microsoft gives no ABI guarantee, so this package only uses the oldest and smallest surface: FveGetStatusW with the version 1 FVE_STATUS structure. The DLL is loaded lazily, and a missing DLL or export results in an error instead of a crash.
Why not the Shell property System.Volume.BitLockerProtection: the Shell returns VT_EMPTY for built-in service accounts (LocalSystem, virtual service accounts), so it does not work for windows_exporter running as a service (https://github.com/prometheus-community/windows_exporter/issues/2290). FveGetStatusW returns the same result for LocalSystem and for a non-elevated user.
Volume names must use the Win32 device namespace, for example `\\.\C:`, `\\.\Volume{GUID}` or `\\.\GLOBALROOT\Device\HarddiskVolume1`. A bare `C:` fails with E_ACCESSDENIED.
The flag values come from the reverse-engineered header of KNSoft.NDK (MIT): https://github.com/KNSoft/KNSoft.NDK/blob/main/Source/Include/KNSoft/NDK/Win32/FVE/FveApi.h
Verified on Windows 11 (build 26300), as LocalSystem and as a non-elevated user, against Win32_EncryptableVolume GetProtectionStatus/GetConversionStatus/GetLockStatus and manage-bde -status. Flags per state:
State Flags WMI Protection/Conversion/Lock fully decrypted 0x00000004 0/0/0 encryption paused 0x000401A1 0/4/0 encryption running 0x00042121 0/2/0 protection on 0x00041109 1/1/0 (OS volume with TPM: 0x00045309) protection suspended 0x00040509 0/1/0 locked 0x00041909 2/-/1 decryption paused 0x00040191 0/5/0 decryption running 0x00042111 0/3/0 EFI and recovery 0x00000004 - non-existent volume HRESULT 0x80070002
A suspended volume stays FULLY_ENCRYPTED; only PROTECTION_ACTIVE is cleared. A locked volume still reports FULLY_ENCRYPTED and PROTECTION_ACTIVE, so LOCKED has to be checked first. 0x80 marks a paused conversion and 0x2000 a running one; both are not needed for the state. During decryption, ConvertedPercent is the decrypted share of the volume.
Not verified: waiting for activation (clear key without key protectors).
Index ¶
Constants ¶
const ( StatusFlagInitialized uint32 = 0x00000001 StatusFlagFullyDecrypted uint32 = 0x00000004 StatusFlagFullyEncrypted uint32 = 0x00000008 StatusFlagDecryptionInProgress uint32 = 0x00000010 StatusFlagEncryptionInProgress uint32 = 0x00000020 StatusFlagConversionPausedMask uint32 = 0x000000C0 StatusFlagNonTPMProtector uint32 = 0x00000100 StatusFlagTPMProtector uint32 = 0x00000200 StatusFlagClearKey uint32 = 0x00000400 StatusFlagLocked uint32 = 0x00000800 StatusFlagProtectionActive uint32 = 0x00001000 StatusFlagOSVolume uint32 = 0x00004000 )
FVE_STATUS_FLAG_* values of the Flags field.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Status ¶
Status is the BitLocker status of a volume as reported by FveGetStatusW.
func (Status) State ¶
State maps the status flags to a BitLocker state. A fully encrypted volume is only reported as on if protection is active, because a suspended volume stays fully encrypted with protection off. Flag combinations that do not match a known state return StateUnknown instead of being reported as off.