diff --git a/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitor.java b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitor.java index 4501e0fea..3f042d470 100644 --- a/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitor.java +++ b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitor.java @@ -103,6 +103,8 @@ public class SystemMonitor { instance = new SystemMonitorRK3588(); } else if (Platform.isQCS6490()) { instance = new SystemMonitorQCS6490(); + } else if (Platform.isWindows()) { + instance = new SystemMonitorWindows(); } else { instance = new SystemMonitor(); } diff --git a/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitorWindows.java b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitorWindows.java new file mode 100644 index 000000000..6a068f7f0 --- /dev/null +++ b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitorWindows.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.photonvision.common.hardware.metrics; + +public class SystemMonitorWindows extends SystemMonitor { + /** + * Monitoring CPU Temperature on Windows is challenging because most vendors don't publish this + * data to WMI. As a work-around, OSHI tries to use LibreHardwareMonitor via + * jLibreHardwareMonitor. If the temperature isn't found in WMI and jLibreHardwareMonitor isn't + * present, OSHI issues warnings every time getCpuTemperature() is called. This clogs the console + * with useless information when running on Windows and makes testing difficult. + * + *

We could include jLibreHardwareMonitor as a dependency for our Windows jar, but + * LibreHardwareMonitor installs Winring0.sys, which is a kernel-level driver with an unfixed + * severe vulnerability. Windows defender flags Winring0 as a vulnerable driver and blocks it from + * installing. + * + *

In the end, it isn't worth the risk to include this dependency, so we don't do CPU + * temperature monitoring on Windows. + * + *

Threat Information: + * https://www.microsoft.com/en-us/wdsi/threats/threat-search?query=VulnerableDriver:WinNT/Winring0 + * Understanding Winring0 vulnerability alert: + * https://windowsforum.com/threads/understanding-microsoft-defenders-vulnerabledriver-winring0-alert-and-how-to-respond.373544/ + */ + @Override + public double getCpuTemperature() { + return -1.0; + } +}