BIOS: improve performance (Windows)

This commit is contained in:
李通洲 2022-11-21 17:27:37 +08:00
parent 04c9d16c16
commit fbd8c0237f
3 changed files with 29 additions and 29 deletions

View File

@ -422,7 +422,7 @@ elseif(WIN32)
src/common/networking_windows.c
src/common/processing_windows.c
src/detection/battery/battery_windows.cpp
src/detection/bios/bios_windows.cpp
src/detection/bios/bios_windows.c
src/detection/board/board_windows.cpp
src/detection/cpu/cpu_windows.cpp
src/detection/cpuUsage/cpuUsage_nowait_windows.cpp

View File

@ -0,0 +1,28 @@
#include "bios.h"
#include "util/windows/register.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &bios->error))
return;
if(!ffRegReadStrbuf(hKey, "BIOSVersion", &bios->biosRelease, &bios->error))
return;
ffRegReadStrbuf(hKey, "BIOSVendor", &bios->biosVendor, NULL);
ffRegReadStrbuf(hKey, "BIOSReleaseDate", &bios->biosDate, NULL);
uint32_t major, minor;
if(
ffRegReadUint(hKey, "BiosMajorRelease", &major, NULL) &&
ffRegReadUint(hKey, "BiosMinorRelease", &minor, NULL)
)
ffStrbufAppendF(&bios->biosVersion, "%u.%u", (unsigned)major, (unsigned)minor);
}

View File

@ -1,28 +0,0 @@
extern "C" {
#include "bios.h"
}
#include "util/windows/wmi.hpp"
extern "C" void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
FFWmiQuery query(L"SELECT Name, ReleaseDate, Version, Manufacturer FROM Win32_BIOS", &bios->error);
if(!query)
return;
if(FFWmiRecord record = query.next())
{
record.getString(L"Name", &bios->biosRelease);
record.getString(L"ReleaseDate", &bios->biosDate);
record.getString(L"Version", &bios->biosVersion);
record.getString(L"Manufacturer", &bios->biosVendor);
}
else
ffStrbufInitS(&bios->error, "No Wmi result returned");
}