2022-10-05 00:41:43 +08:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT Name, Version, SKUNumber, Vendor FROM Win32_ComputerSystemProduct", &host->error);
|
|
|
|
|
if(!pEnumerator)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
IWbemClassObject *pclsObj = NULL;
|
|
|
|
|
ULONG uReturn = 0;
|
|
|
|
|
|
2022-10-11 22:36:14 +08:00
|
|
|
if(FAILED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) || uReturn == 0)
|
2022-10-05 00:41:43 +08:00
|
|
|
{
|
|
|
|
|
ffStrbufInitS(&host->error, "No Wmi result returned");
|
|
|
|
|
pEnumerator->Release();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 22:56:56 +08:00
|
|
|
ffGetWmiObjString(pclsObj, L"Name", &host->productName);
|
|
|
|
|
ffGetWmiObjString(pclsObj, L"Version", &host->productVersion);
|
|
|
|
|
ffGetWmiObjString(pclsObj, L"SKUNumber", &host->productSku);
|
|
|
|
|
ffGetWmiObjString(pclsObj, L"Vendor", &host->sysVendor);
|
2022-10-05 00:41:43 +08:00
|
|
|
|
|
|
|
|
pclsObj->Release();
|
|
|
|
|
pEnumerator->Release();
|
|
|
|
|
}
|