From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/tpm/tpm_windows.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/detection/tpm/tpm_windows.c (limited to 'src/detection/tpm/tpm_windows.c') diff --git a/src/detection/tpm/tpm_windows.c b/src/detection/tpm/tpm_windows.c new file mode 100644 index 0000000..14f6e8a --- /dev/null +++ b/src/detection/tpm/tpm_windows.c @@ -0,0 +1,51 @@ +#include "tpm.h" +#include "common/library.h" + +#include +#include +#include + +const char* ffDetectTPM(FFTPMResult* result) { + FF_LIBRARY_LOAD_MESSAGE(tbs, "TBS" FF_LIBRARY_EXTENSION, -1) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(tbs, Tbsi_GetDeviceInfo) + + TPM_DEVICE_INFO deviceInfo = {}; + TBS_RESULT code = ffTbsi_GetDeviceInfo(sizeof(deviceInfo), &deviceInfo); + if (code != TBS_SUCCESS) { + return code == (TBS_RESULT) TBS_E_TPM_NOT_FOUND ? "TPM device is not found" : "Tbsi_GetDeviceInfo() failed"; + } + + switch (deviceInfo.tpmVersion) { + case TPM_VERSION_12: + ffStrbufSetStatic(&result->version, "1.2"); + break; + case TPM_VERSION_20: + ffStrbufSetStatic(&result->version, "2.0"); + break; + default: + ffStrbufSetStatic(&result->version, "unknown"); + break; + } + + switch (deviceInfo.tpmInterfaceType) { + case TPM_IFTYPE_1: + ffStrbufSetF(&result->description, "I/O-port or MMIO TPM %s", result->version.chars); + break; + case TPM_IFTYPE_TRUSTZONE: + ffStrbufSetF(&result->description, "Trustzone TPM %s", result->version.chars); + break; + case TPM_IFTYPE_HW: + ffStrbufSetF(&result->description, "HW TPM %s", result->version.chars); + break; + case TPM_IFTYPE_EMULATOR: + ffStrbufSetF(&result->description, "SW-emulator TPM %s", result->version.chars); + break; + case TPM_IFTYPE_SPB: + ffStrbufSetF(&result->description, "SPB attached TPM %s", result->version.chars); + break; + default: + break; + } + + return NULL; +} -- cgit v1.2.3