#59 Fix Windows SMART retrieval with persistent elevated agent and Win32 device probing - #220
Open
IanReyes44 wants to merge 1 commit into
Open
#59 Fix Windows SMART retrieval with persistent elevated agent and Win32 device probing#220IanReyes44 wants to merge 1 commit into
IanReyes44 wants to merge 1 commit into
Conversation
…device probing - Enhanced getSmartDirect to probe /dev/pdN, pdN, and Win32 PhysicalDrive paths with -d nvme / -d sat hints, with fallback to error-JSON. - Replaced single-shot UAC escalation with a persistent elevated PowerShell agent running via IPC in %LOCALAPPDATA%\JDiskMark. - Fixed Start-Process argument quoting in SmartEscalation to handle paths with spaces.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Windows SMART retrieval by introducing a persistent elevated PowerShell agent (reducing repeated UAC prompts) and by expanding device probing to include Win32 PhysicalDrive paths with NVMe/SAT hints, plus a JSON fallback path when device-open fails.
Changes:
- Replaced per-query UAC elevation with a persistent elevated PowerShell agent using file-based IPC in
%LOCALAPPDATA%\JDiskMark. - Added multi-pass device candidate probing on Windows, including
\\.\PhysicalDriveNwith-d nvme/-d sathints. - Added “error-JSON” fallback handling when smartctl returns JSON but sets the “device open failed” exit-code bit.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| jdm-core/src/main/java/jdiskmark/SmartEscalation.java | Implements the persistent elevated PowerShell agent, IPC protocol, and timeouts/shutdown handling. |
| jdm-core/src/main/java/jdiskmark/Smart.java | Expands Windows probing candidates and adds error-JSON fallback behavior in the direct execution path. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+144
to
+147
| String outerCmd = "Start-Process powershell" | ||
| + " -Verb RunAs" | ||
| + " -WindowStyle Hidden" | ||
| + " -ArgumentList '-NoProfile -NonInteractive -ExecutionPolicy Bypass -File \\\"" + scriptPs + "\\\"'"; |
Comment on lines
+140
to
+142
| Path scriptFile = ipcDir.resolve("smart-agent.ps1"); | ||
| Files.writeString(scriptFile, script, StandardCharsets.UTF_8); | ||
| String scriptPs = scriptFile.toString().replace("'", "''"); |
| List<List<String>> candidates = new ArrayList<>(); | ||
| candidates.add(List.of("--json", "-a", "/dev/" + deviceName)); | ||
| candidates.add(List.of("--json", "-a", deviceName)); | ||
| if (deviceName.startsWith("pd")) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses Windows SMART data retrieval failures and improves the user experience by replacing per-query UAC prompts with a persistent elevated background agent and enhancing device path probing with NVMe/SAT hints.
Key Changes
1. Persistent Elevated Background Agent (
SmartEscalation.java)%LOCALAPPDATA%\JDiskMarkusing request (smart-req-<device>.txt), status (smart-ipc-<device>.status), and result (smart-ipc-<device>.json) files encoded in UTF-8 without BOM.smart-agent-stopper) that dropssmart-agent-stop.txtto cleanly terminate the elevated agent process upon application exit.Start-Processargument quoting in PowerShell invocation to correctly handle paths with spaces.2. Multi-Pass Device Probing & Fallback (
Smart.java&SmartEscalation.java)/dev/pdNand barepdN).\\.\PhysicalDriveN) with plain,-d nvme, and-d sathints to ensure support across NVMe controllers and SAT devices on Windows.smartctlexit code), the parser retains and returns the first available JSON output, allowing the UI to extract drive identity (model, serial number, firmware) even if SMART attribute reading is restricted.Verification
mvn clean install -pl jdm-core -am --no-transfer-progress.