fveapi

package
v0.32.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for windows/amd64

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

View Source
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

View Source
var ErrUnavailable = errors.New("fveapi.dll or FveGetStatusW is not available")

Functions

This section is empty.

Types

type State

type State int

State is the BitLocker state derived from Status.Flags.

const (
	StateUnknown State = iota
	StateOff
	StateOn
	StateEncrypting
	StateDecrypting
	StateSuspended
	StateLocked
	StateWaitingForActivation
)

type Status

type Status struct {
	Flags            uint32
	ConvertedPercent float64
}

Status is the BitLocker status of a volume as reported by FveGetStatusW.

func GetStatus

func GetStatus(volumeName string) (Status, error)

GetStatus returns the BitLocker status of volumeName, e.g. `\\.\C:`.

func (Status) State

func (s Status) State() 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL