diff --git a/CMakeLists.txt b/CMakeLists.txt index e60ff1e40..30d071f29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c new file mode 100644 index 000000000..68e51a904 --- /dev/null +++ b/src/detection/bios/bios_windows.c @@ -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); +} diff --git a/src/detection/bios/bios_windows.cpp b/src/detection/bios/bios_windows.cpp deleted file mode 100644 index a48d5d538..000000000 --- a/src/detection/bios/bios_windows.cpp +++ /dev/null @@ -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"); -}