Skip to content

fix: harden WMI/event-log error handling in health score, memory check, and known folders#930

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/p2-wmi-hardening
Jun 18, 2026
Merged

fix: harden WMI/event-log error handling in health score, memory check, and known folders#930
laurentiu021 merged 1 commit into
mainfrom
fix/p2-wmi-hardening

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

WMI/event-log correctness hardening across three services.

Changes

  • HealthScoreService.ComputeAsync — each of the three data sources (system info, disk health, battery) caught ManagementException/InvalidOperationException but not COMException, which WMI Get() throws on repository/RPC faults. A transient fault crashed the whole score instead of degrading. Added a COMException arm to all three.
  • MemoryTestService.CheckErrorLogsAsync — counted EVERY Microsoft-Windows-MemoryDiagnostics-Results event as a memory error, including event 1101 ("no errors found"), turning a clean test into a false warning. Now counts only event 1201 (errors detected), mirroring the WHEA ID guard, and only advances lastError for records that actually count. Also reordered the loop to check cancellation before the read.
  • KnownFolders.GetPathSHGetKnownFolderPath was imported with a void return, so its HRESULT was discarded and the catch (COMException) was dead code (a plain LibraryImport doesn't translate HRESULT to an exception). A failed lookup returned a null/empty path instead of falling back. Now returns/checks the int HRESULT (and guards against an empty path) and applies the SpecialFolder fallback on failure.

Tests

  • These are WMI/event-log/native-call paths that need a live system to exercise; covered by runtime use. The MemoryDiagnostics 1101-vs-1201 logic and KnownFolders fallback are pure branches verified by reading the providers' documented event IDs.

Build: 0 warnings / 0 errors. Version 1.20.40. (Stacks on #929; will rebase before merge.)

@laurentiu021 laurentiu021 force-pushed the fix/p2-wmi-hardening branch from 1678407 to dafe02f Compare June 17, 2026 16:41
@laurentiu021 laurentiu021 merged commit 2adf608 into main Jun 18, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the fix/p2-wmi-hardening branch June 18, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant