diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ae66aa0..1811f0a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -431,7 +431,7 @@ elseif(WIN32) src/detection/displayserver/displayserver_windows.c src/detection/font/font_windows.cpp src/detection/gpu/gpu_windows.cpp - src/detection/host/host_windows.cpp + src/detection/host/host_windows.c src/detection/localip/localip_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c new file mode 100644 index 00000000..abb84a16 --- /dev/null +++ b/src/detection/host/host_windows.c @@ -0,0 +1,27 @@ +#include "host.h" +#include "util/windows/register.h" + +void ffDetectHostImpl(FFHostResult* host) +{ + ffStrbufInit(&host->error); + + ffStrbufInit(&host->productName); + ffStrbufInit(&host->productFamily); + ffStrbufInit(&host->productVersion); + ffStrbufInit(&host->productSku); + ffStrbufInit(&host->sysVendor); + ffStrbufInit(&host->chassisType); + ffStrbufInit(&host->chassisVendor); + ffStrbufInit(&host->chassisVersion); + + FF_HKEY_AUTO_DESTROY hKey = NULL; + + if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &host->error)) + return; + + ffRegReadStrbuf(hKey, "SystemProductName", &host->productName, NULL); + ffRegReadStrbuf(hKey, "SystemFamily", &host->productFamily, NULL); + ffRegReadStrbuf(hKey, "SystemVersion", &host->productVersion, NULL); + ffRegReadStrbuf(hKey, "SystemSKU", &host->productSku, NULL); + ffRegReadStrbuf(hKey, "SystemManufacturer", &host->sysVendor, NULL); +} diff --git a/src/detection/host/host_windows.cpp b/src/detection/host/host_windows.cpp deleted file mode 100644 index cbdd440a..00000000 --- a/src/detection/host/host_windows.cpp +++ /dev/null @@ -1,32 +0,0 @@ -extern "C" { -#include "host.h" -} -#include "util/windows/wmi.hpp" - -extern "C" void ffDetectHostImpl(FFHostResult* host) -{ - ffStrbufInit(&host->error); - - ffStrbufInit(&host->productName); - ffStrbufInit(&host->productFamily); - ffStrbufInit(&host->productVersion); - ffStrbufInit(&host->productSku); - ffStrbufInit(&host->sysVendor); - ffStrbufInit(&host->chassisType); - ffStrbufInit(&host->chassisVendor); - ffStrbufInit(&host->chassisVersion); - - FFWmiQuery query(L"SELECT Name, Version, SKUNumber, Vendor FROM Win32_ComputerSystemProduct", &host->error); - if(!query) - return; - - if(FFWmiRecord record = query.next()) - { - record.getString(L"Name", &host->productName); - record.getString(L"Version", &host->productVersion); - record.getString(L"SKUNumber", &host->productSku); - record.getString(L"Vendor", &host->sysVendor); - } - else - ffStrbufAppendS(&host->error, "No Wmi result returned"); -} diff --git a/src/modules/host.c b/src/modules/host.c index 8c3ec65d..cd4f5010 100644 --- a/src/modules/host.c +++ b/src/modules/host.c @@ -35,8 +35,7 @@ void ffPrintHost(FFinstance* instance) if(host->productVersion.length > 0) { - ffStrbufAppendC(&output, ' '); - ffStrbufAppend(&output, &host->productVersion); + ffStrbufAppendF(&output, " (%s)", host->productVersion.chars); } ffPrintAndWriteToCache(instance, FF_HOST_MODULE_NAME, &instance->config.host, &output, FF_HOST_NUM_FORMAT_ARGS, (FFformatarg[]) {