From 1bedadde97a6a85660a1eac800c01c3e02a787bd Mon Sep 17 00:00:00 2001 From: Craig Schardt Date: Wed, 7 Jan 2026 23:22:17 -0600 Subject: [PATCH] Fix OSHI spamming failures to console on Windows (#2282) ## Description 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](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor) via [jLibreHardwareMonitor](https://github.com/pandalxb/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 vulnuratble driver and blocks it from installing. Rather than messing with it, this PR prevents Windows systems from calling the `getCpuTemperature()` method in OSHI. Fixes #2280 ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ --------- Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com> --- .../hardware/metrics/SystemMonitor.java | 2 + .../metrics/SystemMonitorWindows.java | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 photon-core/src/main/java/org/photonvision/common/hardware/metrics/SystemMonitorWindows.java 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; + } +}