Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Rikitav/Unified.Firmware/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through adding Unified.Firmware to a .NET project, verifying that the host system is running in UEFI mode, reading the active boot option, listing the full boot order, and locating the EFI System Partition — all in fewer than five minutes. By the end you will have a working console application that exercises the core API surface.
1

Install the packages

Add the core package and the boot-service package to your project. The core package provides FirmwareInterface and FirmwareEnvironment; the boot-service package adds FirmwareBootService and all boot entry types.dotnet CLI
dotnet add package Unified.Firmware
dotnet add package Unified.Firmware.BootService
Package Manager Console (Visual Studio)
Install-Package Unified.Firmware
Install-Package Unified.Firmware.BootService
If your boot entries reference specific hardware or media device paths, also install one or both of the protocol extension packages:
dotnet add package Unified.Firmware.DevicePathProtocols.Hardware
dotnet add package Unified.Firmware.DevicePathProtocols.Media
2

Verify UEFI availability

Before calling any firmware API, confirm that the current system was booted in UEFI mode. FirmwareInterface.Available delegates to the platform backend and returns false on Legacy BIOS systems.
using Unified.Firmware;

// Check whether UEFI firmware is available on this host.
if (!FirmwareInterface.Available)
{
    Console.Error.WriteLine("This system does not support UEFI or was booted in Legacy BIOS mode.");
    // FirmwareInterface.SystemPartition and FirmwareBootService calls will throw
    // PlatformNotSupportedException when Available is false.
    return;
}

Console.WriteLine("UEFI firmware detected.");
Console.WriteLine($"Backend: {FirmwareInterface.CurrentBackend.GetType().Name}");
On unsupported platforms (anything other than Windows or Linux) FirmwareInterface.CurrentBackend itself throws PlatformNotSupportedException, so guard that access too if you target a broad set of operating systems.
3

Read the current boot option

FirmwareBootService.CurrentLoadOptionIndex returns the BootOptionIndex that the firmware used for the current boot. Pass that index to FirmwareBootService.ReadLoadOption to deserialize the full FirmwareBootOption from NVRAM.
using Unified.Firmware;
using Unified.Firmware.BootService;
using Unified.Firmware.BootService.LoadOption;
using Unified.Firmware.BootService.Protocols;

// Retrieve the index of the boot entry used for this boot.
BootOptionIndex currentIndex = FirmwareBootService.CurrentLoadOptionIndex;
Console.WriteLine($"Current boot index: {currentIndex}");

// Deserialize the boot option from NVRAM.
FirmwareBootOption current = FirmwareBootService.ReadLoadOption(currentIndex);

Console.WriteLine($"Description : \"{current.Description}\"");
Console.WriteLine($"Attributes  : {current.Attributes}");

// Print each device path protocol attached to this option.
foreach (DevicePathProtocolBase protocol in current.Protocols)
    Console.WriteLine($"  Protocol: {protocol}");
FirmwareBootOption inherits from LoadOptionBase, which exposes Attributes (LoadOptionAttributes flags), Description (human-readable label), Protocols (device path array), and OptionalData (raw optional bytes).
4

Enumerate all boot options

FirmwareBootService.EnumerateBootOptions() reads BootOrder from NVRAM and yields a FirmwareBootOption for each index, in boot priority order.
using Unified.Firmware.BootService;
using Unified.Firmware.BootService.LoadOption;
using Unified.Firmware.BootService.Protocols;

int index = 0;
foreach (FirmwareBootOption option in FirmwareBootService.EnumerateBootOptions())
{
    Console.WriteLine($"\n===[ Boot option #{index++} ]" + new string('=', 50));
    Console.WriteLine($"Description : \"{option.Description}\"");
    Console.WriteLine($"Attributes  : {option.Attributes}");

    foreach (DevicePathProtocolBase protocol in option.Protocols)
        Console.WriteLine($"  {protocol}");
}
You can also access the raw boot order array directly through FirmwareBootService.LoadOrder, which returns a BootOptionIndex[] that you can read or replace to reorder entries.
5

Get the EFI System Partition

FirmwareInterface.SystemPartition returns a System.IO.DirectoryInfo pointing to the root of the EFI System Partition. Use it with standard System.IO APIs — no separate MountVol or partition GUID look-up required.
using Unified.Firmware;
using System.IO;

// Resolve the EFI System Partition root directory.
DirectoryInfo esp = FirmwareInterface.SystemPartition;
Console.WriteLine($"ESP path: {esp.FullName}");

// List the top-level EFI directory on the partition.
DirectoryInfo efiDir = new DirectoryInfo(Path.Combine(esp.FullName, "EFI"));
if (efiDir.Exists)
{
    Console.WriteLine("Bootloader directories on ESP:");
    foreach (DirectoryInfo dir in efiDir.GetDirectories())
        Console.WriteLine($"  {dir.Name}");
}

// Example: read a bootloader config file.
string grubCfg = Path.Combine(esp.FullName, "EFI", "ubuntu", "grub.cfg");
if (File.Exists(grubCfg))
{
    string contents = File.ReadAllText(grubCfg);
    Console.WriteLine(contents);
}
SystemPartition throws PlatformNotSupportedException when FirmwareInterface.Available is false, so always check availability first (Step 2).
On Windows, your process must run as Administrator to read or write UEFI NVRAM variables. Launch Visual Studio, your terminal, or your compiled executable with “Run as administrator”, or embed a UAC manifest that requests requireAdministrator. Without elevation, calls to FirmwareBootService and FirmwareEnvironment will throw an access-denied exception.
Ready to write your first custom boot entry? See Creating Boot Options for a step-by-step walkthrough that uses HardDriveProtocol, FilePathProtocol, and FirmwareBootService.CreateLoadOption to add a new Boot#### variable to the firmware boot order.

Build docs developers (and LLMs) love