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>
This commit is contained in:
Craig Schardt
2026-01-07 23:22:17 -06:00
committed by GitHub
parent de8905ee10
commit 1bedadde97
2 changed files with 47 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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 <https://www.gnu.org/licenses/>.
*/
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.
*
* <p>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.
*
* <p>In the end, it isn't worth the risk to include this dependency, so we don't do CPU
* temperature monitoring on Windows.
*
* <p>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;
}
}