Detect Firmware Type Of Local Computer

AceInfinity

Emeritus, Contributor
Joined
Feb 21, 2012
Posts
1,728
Location
Canada
There's a simple function provided within kernel32.dll which will tell you whether you've booted up through UEFI mode or whether the firmware is still using the legacy BIOS mode.

I've written an example implementation for anyone curious:

Code:
#include <Windows.h>
#include <stdio.h>

typedef BOOL (WINAPI *pGetFirmwareType)(PFIRMWARE_TYPE);

int main(void)
{
  FIRMWARE_TYPE firmware;
  pGetFirmwareType fpGetFirmwareType = GetProcAddress(GetModuleHandle("kernel32.dll"), "GetFirmwareType");
  if (fpGetFirmwareType && fpGetFirmwareType(&firmware))
  {
    switch (firmware)
    {
      case FirmwareTypeUnknown:
        puts("Firmware type unknown");
        break;

      case FirmwareTypeBios:
        puts("Legacy BIOS mode");
        break;

      case FirmwareTypeUefi:
        puts("UEFI mode");
        break;

      case FirmwareTypeMax:
        puts("Not implemented");
        break;
    }
  }

  return 0;
}

:thumbsup2:
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top