TL;DR: Access CPU/GPU temperatures and other hardware data on Windows without needing to run your app as 🔐 Administrator.
The LibreHardwareMonitorService (LHM) project allows you to access hardware information, such as CPU and GPU temperatures, on Windows from user-land code using Rust. Typically, user-land programs cannot directly access hardware information due to operating system restrictions, which require administrator privileges for such actions.
This library overcomes this limitation by installing a service that handles hardware information requests. Instead of requiring the program to access hardware directly, it sends requests to this service, which allows the program to run without administrator permissions. The only time administrator privileges are needed is during the installation of the service.
- Installation: The user installs the
lhm-service
, which requires administrator permissions to set up. - Service Communication: The
lhm-service
runs in the background, waiting for requests from user-land applications. - Client Requests: Your program (using
lhm-client
) sends requests to the service through the named pipe. These requests are passed to the Libre Hardware Monitor library to retrieve hardware data. - Response: The service responds to the request with the requested hardware data in MsgPack format, allowing your program to access hardware metrics like temperatures without requiring elevated privileges.
flowchart TD
App["🦀 Rust App<br/>(User Mode - No Admin)"]
Client["🔌 lhm-client<br/>(Sends MsgPack Request)"]
Pipe["📡 Named Pipe<br/>\\\\.\\pipe\\LHMLibreHardwareMonitorService"]
Service["🛎️ lhm-service<br/>(Windows Service)"]
FFI["🧩 lhm-sys<br/>(Rust ↔ C# Bridge)"]
Monitor["📈 LibreHardwareMonitorLib<br/>(Reads Hardware Data)"]
App --> Client
Client --> Pipe
Pipe --> Service
Service --> FFI
FFI --> Monitor
Monitor --> FFI
FFI --> Service
Service --> Pipe
Pipe --> Client
Client --> App
To build lhm-sys
or lhm-service
, you need to have the .NET SDK 8.0 installed. You can install it using winget with the following command:
winget install Microsoft.DotNet.SDK.8
The lhm-sys
crate serves as a bridge that connects the Rust code to AOT-compiled C# through either static linking or a dynamic link library (DLL). This crate builds C# code that interacts with the LibreHardwareMonitorLib project and sets up the FFI layer for communication between Rust and C#.
The lhm-service
is a small Windows service that runs in the background. It runs the lhm-server
as a windows service.
- Pre-built installer: The lhm-service is provided as a pre-built installer through GitHub releases (automatically built by GitHub Actions).
- As a consumer of the lhm-client library, you will likely want to bundle this installer with your application or direct users to install it manually.
You can download the prebuilt installer from Releases
The lhm-server
is a small server. It creates a named pipe (\\.\pipe\LHMLibreHardwareMonitorService
) for communication with user-land applications. The server interacts with Libre Hardware Monitor, providing hardware details to the client over this pipe via MsgPack.
The lhm-client
is the client library that interacts with the named pipe created by lhm-service
. It allows user-land applications to request hardware details (e.g., CPU/GPU temperatures) via the service using MsgPack over the named pipe.