Skip to content

Implement COM, WMI, PDH and FileSystem in Windows FFM - #3014

Merged
dbwiddis merged 23 commits into
oshi:masterfrom
rohan-coder02:implement-file-system-in-windows-ffm
Mar 29, 2026
Merged

dbwiddis merged 23 commits into
oshi:masterfrom
rohan-coder02:implement-file-system-in-windows-ffm

Conversation

@rohan-coder02

@rohan-coder02 rohan-coder02 commented Oct 22, 2025 •

Copy link
Copy Markdown
Collaborator

Description:

  • Implemented Windows local volume using the FFM API
  • Currently, only local volume support is available, WMI dependent file store methods are not yet implemented
  • Added appropriate logging for unimplemented sections

Testing:

Tested in my local windows and local volumes reported fine.

SystemInfoFFM ffm = new SystemInfoFFM();
System.out.println(ffm.getOperatingSystem().getFileSystem().getFileStores());

Summary by CodeRabbit

  • New Features

    • Full Windows FFM-based WMI/COM stack and a Windows filesystem implementation exposing detailed file-store attributes and counts.
  • New Utilities

    • PDH-based open-handle counter and COM helpers for GUID, BSTR, VARIANT, IWbem/WMI bindings and related helpers.
  • Enhancements

    • Safer Windows volume/disk APIs with Optional-style error handling, richer filesystem metrics, and improved process/thread reporting.
  • Documentation / Chores

    • Package docs, changelog entry, checkstyle suppression, and module export updates.

@codecov

codecov Bot commented Oct 22, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.33%. Comparing base (1c083b1) to head (ae0d576).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3014      +/-   ##
==========================================
+ Coverage   68.64%   69.33%   +0.69%     
==========================================
  Files          36       36              
  Lines        1875     1875              
  Branches      305      305              
==========================================
+ Hits         1287     1300      +13     
+ Misses        492      475      -17     
- Partials       96      100       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stale

stale Bot commented Nov 28, 2025

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix label Nov 28, 2025
@dbwiddis dbwiddis removed the wontfix label Nov 28, 2025
@rohan-coder02
rohan-coder02 force-pushed the implement-file-system-in-windows-ffm branch from 4b76393 to a4528c0 Compare January 2, 2026 17:26
@dbwiddis

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds comprehensive Windows FFM support: Kernel32 volume/drive wrappers, PDH bindings and util, a COM/WMI FFM stack (OLE32, BSTR, VARIANT, GUID, IUnknown helpers, IWbem* bindings), a WMI query handler with COM lifecycle/security, and Windows filesystem/OSFileStore implementations that merge Kernel32 and WMI data.

Changes

Cohort / File(s) Summary
Kernel & low-level layouts
oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java, oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
Replaced direct ValueLayout.* references with statically imported ADDRESS/JAVA_INT in struct layouts; added INVALID_HANDLE_VALUE and isInvalidHandle; introduced Kernel32 downcalls and Optional/OptionalInt wrappers for volume/drive APIs.
PDH bindings & util
oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java, oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java
New PDH FFM bindings, formatting layouts and constants; PdhUtilFFM queries \Process(*)\Handle Count with two-pass sizing and aggregates per-process handle counts.
Windows filesystem & stores
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java, oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java, oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
New WindowsFileSystemFFM enumerates local volumes via Kernel32 and merges/enriches results with WMI; WindowsOSFileStoreFFM stores Windows-specific attributes and supports updateAttributes; WindowsOperatingSystemFFM exposes filesystem and adds process/thread helpers.
WMI query layer & driver
oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java, oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
New Win32LogicalDiskFFM maps Win32_LogicalDisk rows; WmiQueryHandlerFFM manages COM init/security, CoCreate/ConnectServer, ExecQuery, enumeration, timeouts, failed-class cache, threading-model switching, and COM lifecycle.
COM/WMI primitives
oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java, .../GuidFFM.java, .../BStrFFM.java, .../VariantFFM.java, .../ComObjectFFM.java, .../WbemcliFFM.java, .../FfmComException.java, .../package-info.java
New COM interop primitives: OLE32 wrappers and HRESULT helpers; GUID/BSTR/VARIANT layouts and utilities; ComObjectFFM vtable/downcall helpers; Wbemcli constants, FfmComException, and package docs.
IWbem bindings
oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java, .../IWbemServicesFFM.java, .../IEnumWbemClassObjectFFM.java, .../IWbemClassObjectFFM.java
New FFM bindings for IWbemLocator (create/connectServer), IWbemServices (execQuery), IEnumWbemClassObject (next/reset with NextResult), and IWbemClassObject (Get with typed getters using VariantFFM).
COM IUnknown helpers
oshi-core-java25/src/main/java/oshi/ffm/windows/com/IUnknownFFM.java
New IUnknownFFM with addRef, release, and safeRelease helpers implemented via vtable downcalls.
Module exports & config
oshi-core-java25/src/main/java/module-info.java, oshi-core-java11/src/main/java/module-info.java, config/checkstyle-suppressions.xml
Exported additional platform/utility packages in module descriptors; added ffm parameter-name checkstyle suppression.
Changelog
CHANGELOG.md
Added entry noting the Windows FFM/COM/WMI/PDH/FileSystem PR.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant WFS as WindowsFileSystemFFM
    participant Arena as Arena
    participant K32 as Kernel32FFM
    participant WMI as WmiQueryHandlerFFM
    participant IW as IWbemServicesFFM
    participant ENUM as IEnumWbemClassObjectFFM
    participant PDH as PdhUtilFFM
    participant Store as WindowsOSFileStoreFFM

    App->>WFS: getFileStores(localOnly)
    WFS->>Arena: open Arena
    WFS->>K32: FindFirstVolume(buffer)
    K32-->>WFS: volumeHandle
    loop per volume
        WFS->>K32: GetVolumeInformation(volume)
        K32-->>WFS: fsType, flags, volumeName
        WFS->>K32: GetVolumePathNamesForVolumeName(volume)
        K32-->>WFS: mountPaths
        alt need WMI enrichment
            WFS->>WMI: queryWMI("Win32_LogicalDisk", where)
            WMI->>IW: execQuery(wql)
            IW-->>WMI: pEnum
            WMI->>ENUM: next()
            ENUM-->>WMI: IWbemClassObject
            WMI->>IW: IWbemClassObject::Get(property)
            IW-->>WMI: property value
        end
        WFS->>K32: GetDiskFreeSpaceEx(volume)
        K32-->>WFS: free/total/avail
        WFS->>Store: create/update WindowsOSFileStoreFFM(...)
    end
    WFS->>K32: FindVolumeClose(handle)
    WFS->>PDH: getOpenFileDescriptors()
    PDH-->>WFS: aggregated handle counts
    WFS-->>App: List<OSFileStore>
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Poem

🐰 I hopped through GUIDs, BSTRs, and Kernel cries,

VARIANTs whispered secrets where the COM vtable lies,
WMI served the rows and PDH counted each hand,
Volumes were mounted by a careful small band,
I nibbled bugs and stitched the FFM land.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the primary change: implementing COM, WMI, PDH, and FileSystem support in Windows FFM, which aligns with the substantial additions of COM infrastructure, WMI querying, PDH bindings, and FileSystem classes throughout the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java`:
- Around line 181-195: The GetDiskFreeSpaceEx binding currently references the
ANSI symbol "GetDiskFreeSpaceExA" but callers pass UTF-16 wide strings; update
the downcall target to "GetDiskFreeSpaceExW" so the native call matches the
wide-string input and Unicode behavior. Locate the MethodHandle named
GetDiskFreeSpaceEx (the downcall(...) call) and change its symbol name from
"GetDiskFreeSpaceExA" to "GetDiskFreeSpaceExW" while keeping the existing
signature (JAVA_INT, ADDRESS, ADDRESS, ADDRESS, ADDRESS) and leave the wrapper
method GetDiskFreeSpaceEx(MemorySegment...) unchanged so wide-string callers
continue to work correctly.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 89-98: The getFileStores(boolean localOnly) method currently
ignores its localOnly parameter and always returns getLocalVolumes(null); update
the method to respect localOnly by either implementing the WMI-based fallback
for non-local volumes (invoke your existing WMI retrieval routine and
merge/return those OSFileStore entries when localOnly is false) or, if WMI
support is not available yet, explicitly throw new UnsupportedOperationException
with a clear message when localOnly is false and add a TODO comment referencing
WMI integration; ensure changes are made in getFileStores(boolean localOnly) and
mention getLocalVolumes and the WMI path in the message so callers know the
limitation.
- Around line 144-148: The code reads 64-bit ULARGE_INTEGER results from
Kernel32FFM.GetDiskFreeSpaceEx into 32-bit ints (using JAVA_INT), truncating
values; change the reads for userFreeBytesBuf, totalBytesBuf, and
systemFreeBytesBuf to use 64-bit access (e.g., get(JAVA_LONG, 0) or equivalent)
and assign to long variables (systemFreeBytes, totalBytes, usedFreeBytes) so
full 64-bit values are preserved; additionally ensure
Kernel32FFM.GetDiskFreeSpaceEx is bound to the wide-character API
(GetDiskFreeSpaceExW) to match the toWideString(...) call rather than the ANSI
variant.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java`:
- Around line 111-113: The getFileSystem() method in WindowsOperatingSystemFFM
overrides the abstract method from the OperatingSystem base but lacks the
`@Override` annotation; add the `@Override` annotation directly above the public
FileSystem getFileSystem() method (which returns new WindowsFileSystemFFM()) to
match other OS implementations and maintain consistency.

In `@oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java`:
- Around line 82-85: In PdhUtilFFM's catch block (the catch(Throwable t)
handling PDH getOpenFileDescriptors), replace the incorrect LOG.debug call that
passes t.getMessage() as a second argument with a call that passes the Throwable
itself so the stack trace is logged (e.g., pass t as the throwable parameter or
use a placeholder and include t), ensuring the exception object is logged rather
than discarding the stack trace.
🧹 Nitpick comments (4)
oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java (1)

62-72: Consider clarifying the naming in the union layout.

The field "longValue" uses JAVA_INT which correctly maps to Windows LONG (32-bit), but the naming may confuse Java developers since Java's long is 64-bit. The naming follows Windows convention, so this is acceptable if consistent with the rest of the codebase. The struct layouts and padding appear correct for proper alignment.

oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java (1)

70-76: Consider documenting why the last counter item is skipped.

The loop iterates to count - 1, which appears intentional to skip the _Total pseudo-process that PDH includes in the \\Process(*)\\Handle Count counter array. Adding a brief comment would clarify this behavior for future maintainers.

Suggested documentation
+                // Skip the last item which is "_Total" (aggregate of all processes)
                 for (int i = 0; i < count - 1; i++) {
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (2)

106-161: Consider adding error handling for failed volume information retrieval.

The code calls GetVolumeInformation, GetVolumePathNamesForVolumeName, and GetDiskFreeSpaceEx but doesn't check their return values. If any of these calls fail, the code proceeds with uninitialized/zero buffer values, potentially adding malformed file store entries. Consider checking the OptionalInt results and skipping volumes where critical information cannot be retrieved.

Suggested approach
OptionalInt volInfoResult = Kernel32FFM.GetVolumeInformation(...);
if (volInfoResult.isEmpty() || volInfoResult.getAsInt() == 0) {
    // Log and skip this volume
    continue;
}

80-83: Consider making MAX_WINDOWS_HANDLES a simple constant.

The static initializer block for a simple arithmetic expression is unnecessary verbosity. This can be simplified to a direct constant assignment.

Proposed simplification
-    static final long MAX_WINDOWS_HANDLES;
-    static {
-        MAX_WINDOWS_HANDLES = 16_777_216L - 65_536L;
-    }
+    static final long MAX_WINDOWS_HANDLES = 16_777_216L - 65_536L;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e51b2b7 and a4528c0.

📒 Files selected for processing (7)
  • oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java
🧰 Additional context used
🧬 Code graph analysis (1)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (3)
oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java (1)
  • Kernel32FFM (24-262)
oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java (1)
  • PdhUtilFFM (29-90)
oshi-core-java25/src/main/java/oshi/ffm/windows/WindowsForeignFunctions.java (1)
  • WindowsForeignFunctions (27-129)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (9)
oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java (4)

2-2: LGTM — copyright year update.


67-69: LGTM — IP_ADDR_STRING_LAYOUT pointer field is correctly modeled as ADDRESS.


71-76: LGTM — FIXED_INFO_LAYOUT pointer field update is consistent with the C struct.


99-101: LGTM — no functional change in MIB_UDPSTATS_LAYOUT definition.

oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java (2)

12-36: LGTM - Clean class structure with proper encapsulation.

The class properly extends AbstractOSFileStore and encapsulates all necessary Windows file store attributes. The constructor delegates to the parent class and initializes local fields correctly.


78-101: Verify WMI fallback behavior.

The updateAttributes() logic looks correct: it first tries FFM-based local volumes, then falls back to WMI. However, consider whether returning false without logging is the desired behavior when no matching volume is found.

Additionally, the comparison getMount().length() < 2 with substring(0, 2) is safe, but ensure that edge cases like empty mounts or single-character mounts are handled as expected upstream.

oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java (1)

19-27: LGTM - PDH native bindings properly defined.

The PDH FFM bindings are correctly structured with appropriate downcall wrappers for the Windows Performance Data Helper API. The symbol lookup and method handle definitions follow the established pattern in this codebase.

oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java (2)

41-56: LGTM - FindFirstVolume wrapper correctly implemented.

The error handling with Optional.empty() return on failure follows the established pattern. The null check before MemorySegment.NULL comparison is defensive and appropriate.


251-261: LGTM - SetErrorMode wrapper correctly implemented.

The binding follows the established pattern with proper exception handling and OptionalInt return type.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@stale

stale Bot commented Feb 26, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix label Feb 26, 2026
@stale stale Bot closed this Mar 5, 2026
@dbwiddis dbwiddis reopened this Mar 5, 2026
@stale stale Bot removed the wontfix label Mar 5, 2026
@rohan-coder02

Copy link
Copy Markdown
Collaborator Author

Implemented FFM-based getFileStores() for Windows with full COM/WMI support.

New COM Infrastructure (oshi.ffm.windows.com):

  • OLE32 bindings, GUID, VARIANT, BSTR utilities
  • IWbemLocator, IWbemServices, IEnumWbemClassObject, IWbemClassObject interfaces
  • WmiQueryHandlerFFM with configurable timeout, threading retry, and failed class caching
  • Win32LogicalDiskFFM driver for Win32_LogicalDisk queries

JNA and FFM outputs match, also, Both Kernel32 API and WMI COM queries validated separately.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 11

🧹 Nitpick comments (1)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java (1)

83-89: Make the narrowing in the convenience overload explicit.

This overload silently truncates the 16-bit and 8-bit GUID components. A mistyped constant then turns into a different CLSID/IID and only fails later during COM activation. Consider validating the ranges or documenting that the values are intentionally masked.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java` around
lines 83 - 89, The convenience overload
create(Arena,int,int,int,int,int,int,int,int,int,int,int) currently silently
truncates data2/data3 and d4_* values; update it to perform explicit narrowing
and validation: either change the parameter types to short/byte or (if keeping
int parameters) validate that data2 and data3 are within 0..0xFFFF and each d4_*
is within 0..0xFF, throw an IllegalArgumentException with a clear message when
out of range, and then perform explicit casts like (short)(data2 & 0xFFFF) and
(byte)(d4_n & 0xFF) before calling create(arena, data1, (short) data2, (short)
data3, data4) so truncation is intentional and documented in GuidFFM.create.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java`:
- Around line 124-131: The WHERE clause construction in Win32LogicalDiskFFM
(variables localOnly, whereClause, hasWhere, nameToMatch) can produce "WHERE
DriveType = 2 OR DriveType = 3 OR DriveType = 6 AND Name=..." so the Name filter
only binds to the last OR term; fix by parenthesizing the local-drive predicate:
when appending the DriveType conditions to whereClause (the block guarded by
localOnly), wrap the entire "DriveType = 2 OR DriveType = 3 OR DriveType = 6"
expression in parentheses (e.g., "(DriveType = 2 OR DriveType = 3 OR DriveType =
6)") so subsequent appends for Name use AND against the whole group; ensure
hasWhere logic remains correct.

In
`@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java`:
- Around line 108-124: The helper methods getString, getInt, getLong and
getBoolean currently call VariantFFM.clear() only on some branches causing
native memory leaks; change each to use a try/finally around the handling of
GetResult (returned by get(pObject, propertyName, arena)) and always call
VariantFFM.clear(result.variant()) in the finally block so the VARIANT is
cleared on every exit path while preserving existing branch logic (e.g., VT_BSTR
handling in getString, numeric conversions in getInt/getLong, and boolean
handling in getBoolean).

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java`:
- Around line 93-120: The BSTR allocated into bstrNamespace must be freed in a
finally block to avoid leaks if arena.allocate(...) or mh.invokeExact(...)
throws; declare MemorySegment bstrNamespace = null before allocation, wrap the
allocate/invoke/result logic in try { ... } finally { if (bstrNamespace != null)
BStrFFM.free(bstrNamespace); } so BStrFFM.free is always executed (and only
once), preserving the existing error handling/logging and Optional returns from
the connectServer method.
- Around line 19-20: The lSecurityFlags parameter in IWbemLocatorFFM is using
JAVA_LONG which is incorrect for Windows COM (LLP64) and shifts subsequent args;
update imports to remove JAVA_LONG and use JAVA_INT instead, change the function
descriptor where lSecurityFlags is declared (in the IWbemLocatorFFM method
signature/descriptor block around lines referencing lSecurityFlags) to use
JAVA_INT, replace any literal 0L passed for lSecurityFlags with 0, and keep
toWideString usage unchanged; ensure references to the symbol lSecurityFlags and
the IWbemLocatorFFM method are the ones you modify.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java`:
- Around line 74-100: The BSTRs bstrQueryLang and bstrQuery must be initialized
to MemorySegment.NULL before the try block and their cleanup moved into a
finally block to avoid leaks if getVtable, getVtableFunction, createDowncall, or
invokeExact throws; update the method containing the allocations so that
bstrQueryLang and bstrQuery are declared/initialized to MemorySegment.NULL
outside the try, perform allocations inside the try, and call BStrFFM.free on
each (checking for non-NULL) in a finally block, leaving the existing error
handling and return logic intact.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java`:
- Around line 192-194: The getFloatVal method currently reads the 32-bit payload
using JAVA_INT causing numeric conversion instead of IEEE-754 bit
reinterpretation; fix getFloatVal to read the float bits using JAVA_FLOAT at
DATA_OFFSET (same approach as getDoubleVal uses JAVA_DOUBLE) so a stored VT_R4
value is returned as the original float bit pattern rather than converted
integer value.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java`:
- Around line 43-56: The current FindFirstVolume method incorrectly treats a
failure handle as MemorySegment.NULL; change the failure check to detect
INVALID_HANDLE_VALUE (-1) instead of 0: add a private constant
INVALID_HANDLE_VALUE = -1L and, in FindFirstVolume, detect if the returned
MemorySegment represents address -1 (use the MemorySegment's address/segment
handle check) and treat that as failure (log GetLastError and return
Optional.empty()); ensure callers (and similar handle-returning methods) use the
same constant and check so invalid handles are never propagated to
FindNextVolume/FindVolumeClose.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 151-169: The Win32 calls Kernel32FFM.GetVolumeInformation,
GetVolumePathNamesForVolumeName, GetDiskFreeSpaceEx (and similarly
GetVolumeNameForVolumeMountPoint later) return OptionalInt and may fail; modify
the code around the calls that populate nameBuf, flagsBuf, fstypeBuf, mountBuf,
userFreeBytesBuf, totalBytesBuf and systemFreeBytesBuf to capture each
OptionalInt result, check isPresent() before reading the corresponding buffers,
and skip/continue the loop when any of those OptionalInt results is empty so you
never construct the store from uninitialized buffer contents (use the existing
volumeToMatch logic to decide when to continue).

In `@oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java`:
- Around line 70-76: The loop in PdhUtilFFM that iterates (for i = 0; i < count
- 1) assumes the final array element is the `_Total` instance; instead iterate
all returned items (for i = 0; i < count; i++) and for each MemorySegment item
(using buffer.asSlice(offset, itemSize)) read the instance name field via the
layout (the InstanceName/InstanceNameLength offsets from
PDH_FMT_COUNTERVALUE_ITEM_LAYOUT/groupElement("InstanceName") or equivalent) and
perform a case-insensitive comparison to "_Total"; only skip adding the
FmtValue/Value for items whose instance name equals "_Total" and otherwise
accumulate totalHandles from the FmtValue field (using the same groupElement
references already present), updating offset by itemSize each loop.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`:
- Around line 93-95: The code currently permanently short-circuits queryWMI by
checking failedWmiClassNames and returning an empty list, so transient failures
become permanent; instead, stop using a permanent blacklist: change
failedWmiClassNames to track failures with timestamps or a retry/backoff
mechanism (e.g., Map<String,Long> lastFailureTime) and update queryWMI to only
skip classes whose lastFailureTime is still within a recent TTL, or remove
entries after a successful query; update all places that add to
failedWmiClassNames (the locations that add on namespace connection failures,
ExecQuery failures, and caught exceptions) to record timestamps or increment
retry counters rather than unconditionally adding to a permanent Set, and ensure
access to the failure store is thread-safe and cleared/updated on successful
openNamespace/execQuery in the WmiQueryHandlerFFM class.
- Around line 53-62: Shared mutable fields failedWmiClassNames, comThreading,
securityInitialized, and wmiTimeout are accessed concurrently and must be made
thread-safe: replace failedWmiClassNames (HashSet) with a concurrent set (e.g.,
Collections.newSetFromMap(new ConcurrentHashMap<>())) to avoid corruption;
change comThreading and wmiTimeout to AtomicInteger (or mark volatile and guard
mutations with synchronized) and change securityInitialized to AtomicBoolean (or
volatile + synchronized) so reads/writes are atomic; protect COM/security
initialization and any setter/getter or query code paths with a small
synchronized block or proper double-checked locking around the initialization
logic (use the same monitor) to prevent races when toggling
comThreading/securityInitialized and running WMI queries.

---

Nitpick comments:
In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java`:
- Around line 83-89: The convenience overload
create(Arena,int,int,int,int,int,int,int,int,int,int,int) currently silently
truncates data2/data3 and d4_* values; update it to perform explicit narrowing
and validation: either change the parameter types to short/byte or (if keeping
int parameters) validate that data2 and data3 are within 0..0xFFFF and each d4_*
is within 0..0xFF, throw an IllegalArgumentException with a clear message when
out of range, and then perform explicit casts like (short)(data2 & 0xFFFF) and
(byte)(d4_n & 0xFF) before calling create(arena, data1, (short) data2, (short)
data3, data4) so truncation is intentional and documented in GuidFFM.create.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c4c21eb3-6f91-48c9-84b2-e7f676d608d7

📥 Commits

Reviewing files that changed from the base of the PR and between a4528c0 and 159d45f.

📒 Files selected for processing (18)
  • oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IEnumWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/WbemcliFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/package-info.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Analyze (java)
🔇 Additional comments (8)
oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java (8)

58-70: LGTM!

The FindNextVolumeW binding is correct. Returning OptionalInt allows callers to use orElse(0) for graceful loop termination on both native API failure and exceptions.


72-82: LGTM!

The FindVolumeClose binding is correct and follows the established error-handling pattern.


181-195: LGTM!

The binding correctly uses GetDiskFreeSpaceExW (Wide variant), which aligns with the UTF-16LE strings passed by callers via toWideString().


197-207: LGTM!

Correctly uses GetDriveTypeW and follows the established error-handling pattern.


209-224: LGTM!

Correctly uses GetVolumeInformationW with proper parameter layout.


226-239: LGTM!

Correctly uses GetVolumePathNamesForVolumeNameW and follows the established pattern.


252-261: LGTM!

The SetErrorMode binding is correct. This API has no W/A variants.


263-284: LGTM!

Correctly uses GetVolumeNameForVolumeMountPointW with clear documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

61-79: Consider using an immutable map for OPTIONS_MAP.

The class is marked @ThreadSafe, but OPTIONS_MAP is a mutable HashMap. Although it's only written during class loading and read thereafter (making it functionally thread-safe), using Map.of() or Collections.unmodifiableMap() would make the immutability explicit.

♻️ Suggested refactor
-    private static final Map<Integer, String> OPTIONS_MAP = new HashMap<>();
-    static {
-        OPTIONS_MAP.put(FILE_CASE_PRESERVED_NAMES, "casepn");
-        OPTIONS_MAP.put(FILE_CASE_SENSITIVE_SEARCH, "casess");
-        OPTIONS_MAP.put(FILE_FILE_COMPRESSION, "fcomp");
-        OPTIONS_MAP.put(FILE_DAX_VOLUME, "dax");
-        OPTIONS_MAP.put(FILE_NAMED_STREAMS, "streams");
-        OPTIONS_MAP.put(FILE_PERSISTENT_ACLS, "acls");
-        OPTIONS_MAP.put(FILE_SEQUENTIAL_WRITE_ONCE, "wronce");
-        OPTIONS_MAP.put(FILE_SUPPORTS_ENCRYPTION, "efs");
-        OPTIONS_MAP.put(FILE_SUPPORTS_OBJECT_IDS, "oids");
-        OPTIONS_MAP.put(FILE_SUPPORTS_REPARSE_POINTS, "reparse");
-        OPTIONS_MAP.put(FILE_SUPPORTS_SPARSE_FILES, "sparse");
-        OPTIONS_MAP.put(FILE_SUPPORTS_TRANSACTIONS, "trans");
-        OPTIONS_MAP.put(FILE_SUPPORTS_USN_JOURNAL, "journaled");
-        OPTIONS_MAP.put(FILE_UNICODE_ON_DISK, "unicode");
-        OPTIONS_MAP.put(FILE_VOLUME_IS_COMPRESSED, "vcomp");
-        OPTIONS_MAP.put(FILE_VOLUME_QUOTAS, "quota");
-    }
+    private static final Map<Integer, String> OPTIONS_MAP = Map.ofEntries(
+            Map.entry(FILE_CASE_PRESERVED_NAMES, "casepn"),
+            Map.entry(FILE_CASE_SENSITIVE_SEARCH, "casess"),
+            Map.entry(FILE_FILE_COMPRESSION, "fcomp"),
+            Map.entry(FILE_DAX_VOLUME, "dax"),
+            Map.entry(FILE_NAMED_STREAMS, "streams"),
+            Map.entry(FILE_PERSISTENT_ACLS, "acls"),
+            Map.entry(FILE_SEQUENTIAL_WRITE_ONCE, "wronce"),
+            Map.entry(FILE_SUPPORTS_ENCRYPTION, "efs"),
+            Map.entry(FILE_SUPPORTS_OBJECT_IDS, "oids"),
+            Map.entry(FILE_SUPPORTS_REPARSE_POINTS, "reparse"),
+            Map.entry(FILE_SUPPORTS_SPARSE_FILES, "sparse"),
+            Map.entry(FILE_SUPPORTS_TRANSACTIONS, "trans"),
+            Map.entry(FILE_SUPPORTS_USN_JOURNAL, "journaled"),
+            Map.entry(FILE_UNICODE_ON_DISK, "unicode"),
+            Map.entry(FILE_VOLUME_IS_COMPRESSED, "vcomp"),
+            Map.entry(FILE_VOLUME_QUOTAS, "quota")
+    );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`
around lines 61 - 79, The static OPTIONS_MAP is currently a mutable HashMap
populated in a static block; change it to an immutable map to match the
`@ThreadSafe` intent by replacing the mutable initialization with an immutable
factory (e.g., use Map.of(...) or Map.ofEntries(...) to declare OPTIONS_MAP or
wrap the populated map with Collections.unmodifiableMap(...)) inside the class
WindowsFileSystemFFM so that OPTIONS_MAP is final and truly unmodifiable after
class loading; locate the static OPTIONS_MAP field and its static initializer
block and replace the mutable creation/population with the chosen immutable
construction.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 81-84: MAX_WINDOWS_HANDLES is computed using the 64-bit formula
but the FileSystem javadoc specifies different maxima for 32-bit vs 64-bit;
update the implementation so MAX_WINDOWS_HANDLES reflects the running
architecture by checking the JVM/OS bitness (e.g., via
System.getProperty("os.arch") or existing utility) and choose 2^24-2^15 for
32-bit or 2^24-2^16 for 64-bit, or if you prefer not to change behavior, add a
clear comment on the MAX_WINDOWS_HANDLES declaration explaining it intentionally
assumes 64-bit Windows; adjust the static initializer in WindowsFileSystemFFM
(MAX_WINDOWS_HANDLES) accordingly and reference the FileSystem interface javadoc
in the comment.

---

Nitpick comments:
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 61-79: The static OPTIONS_MAP is currently a mutable HashMap
populated in a static block; change it to an immutable map to match the
`@ThreadSafe` intent by replacing the mutable initialization with an immutable
factory (e.g., use Map.of(...) or Map.ofEntries(...) to declare OPTIONS_MAP or
wrap the populated map with Collections.unmodifiableMap(...)) inside the class
WindowsFileSystemFFM so that OPTIONS_MAP is final and truly unmodifiable after
class loading; locate the static OPTIONS_MAP field and its static initializer
block and replace the mutable creation/population with the chosen immutable
construction.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e89effea-7ace-445c-a4d8-10c3f66bec32

📥 Commits

Reviewing files that changed from the base of the PR and between 159d45f and 7b4c21f.

📒 Files selected for processing (2)
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (6)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (6)

34-40: LGTM!

The class declaration and initial constants are appropriate. The @ThreadSafe annotation is correctly applied, and the buffer size is reasonable for Windows path handling.


90-122: LGTM!

The localOnly parameter is correctly propagated to getWmiVolumes and used in the branching logic. The merging of local volumes with WMI data appropriately enriches volume names while preserving accurate local volume metrics.


151-172: Win32 call return values are not checked before reading buffers.

GetVolumeInformation, GetVolumePathNamesForVolumeName, and GetDiskFreeSpaceEx can fail (e.g., on empty optical drives or offline volumes), but their return values are discarded. On failure, the buffers may contain uninitialized or stale data, leading to incorrect volume information being reported.

Capture the return value from each call and continue the loop when any fails.

🛡️ Suggested defensive pattern
-                    Kernel32FFM.GetVolumeInformation(toWideString(arena, volume), nameBuf, BUFSIZE, NULL, NULL,
-                            flagsBuf, fstypeBuf, 16);
+                    if (Kernel32FFM.GetVolumeInformation(toWideString(arena, volume), nameBuf, BUFSIZE, NULL, NULL,
+                            flagsBuf, fstypeBuf, 16).isEmpty()) {
+                        continue;
+                    }
                     int flags = flagsBuf.get(JAVA_INT, 0);

-                    Kernel32FFM.GetVolumePathNamesForVolumeName(toWideString(arena, volume), mountBuf, BUFSIZE, NULL);
+                    if (Kernel32FFM.GetVolumePathNamesForVolumeName(toWideString(arena, volume), mountBuf, BUFSIZE, NULL).isEmpty()) {
+                        continue;
+                    }
                     String mount = readWideString(mountBuf);

194-214: LGTM!

Good defensive handling with orElse(-1) for the Optional return, and the switch expression correctly handles all standard drive types with a sensible default for unknown types.


238-243: Unchecked GetVolumeNameForVolumeMountPoint return value.

Same pattern as the local volumes method - if this call fails (e.g., for a disconnected removable drive), volumeBuf may contain uninitialized data, resulting in an incorrect or empty volume GUID path.

🛡️ Suggested fix
                 if (type != 4) {
                     // Local drive - get volume GUID path
                     MemorySegment mountPoint = toWideString(arena, name + "\\");
                     MemorySegment volumeBuf = arena.allocate(BUFSIZE * JAVA_CHAR.byteSize());
-                    Kernel32FFM.GetVolumeNameForVolumeMountPoint(mountPoint, volumeBuf, BUFSIZE);
-                    volume = readWideString(volumeBuf);
+                    if (Kernel32FFM.GetVolumeNameForVolumeMountPoint(mountPoint, volumeBuf, BUFSIZE).isPresent()) {
+                        volume = readWideString(volumeBuf);
+                    } else {
+                        volume = "";  // Or skip this drive with continue
+                    }

261-275: LGTM!

The file descriptor methods correctly implement the FileSystem interface contract. Delegating to PdhUtilFFM for open handles and returning MAX_WINDOWS_HANDLES for both max methods aligns with Windows behavior where the per-process limit equals the system limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

251-256: ⚠️ Potential issue | 🟠 Major

Check return value before reading buffer from GetVolumeNameForVolumeMountPoint.

The return value from GetVolumeNameForVolumeMountPoint is discarded. If this call fails (e.g., for offline volumes or permission issues), volumeBuf will contain uninitialized data, causing incorrect volume GUID paths to be reported.

The same return-value checking pattern used in getLocalVolumes() (lines 154, 162, 180) should be applied here.

Proposed fix
                 if (type != 4) {
                     // Local drive - get volume GUID path
                     MemorySegment mountPoint = toWideString(arena, name + "\\");
                     MemorySegment volumeBuf = arena.allocate(BUFSIZE * JAVA_CHAR.byteSize());
-                    Kernel32FFM.GetVolumeNameForVolumeMountPoint(mountPoint, volumeBuf, BUFSIZE);
-                    volume = readWideString(volumeBuf);
+                    var volumeResult = Kernel32FFM.GetVolumeNameForVolumeMountPoint(mountPoint, volumeBuf, BUFSIZE);
+                    if (volumeResult.isPresent() && volumeResult.getAsInt() != 0) {
+                        volume = readWideString(volumeBuf);
+                    } else {
+                        // Fall back to mount point name if volume GUID cannot be retrieved
+                        volume = name + "\\";
+                    }
                 } else {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`
around lines 251 - 256, The code calls
Kernel32FFM.GetVolumeNameForVolumeMountPoint and immediately reads volumeBuf via
readWideString without checking the call's boolean result; reproduce the pattern
used in getLocalVolumes() to check the return value: capture the boolean result
of GetVolumeNameForVolumeMountPoint (when building mountPoint/volumeBuf in
WindowsFileSystemFFM.java), only call readWideString(volumeBuf) and assign to
volume if the call returned true, otherwise leave volume null or skip
assigning/handle the error path appropriately; ensure you reference the same
BUFSIZE/volumeBuf/toWideString variables and avoid reading uninitialized memory.
oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java (1)

109-125: ⚠️ Potential issue | 🟠 Major

Failed Get() calls still bypass VariantClear().

The new finally blocks only run after the result.succeeded() check. If IWbemClassObject::Get returns a failing HRESULT after populating pVal, these early returns still leak the native payload.

Suggested fix
 public static String getString(MemorySegment pObject, String propertyName, Arena arena) {
     GetResult result = get(pObject, propertyName, arena);
-    if (!result.succeeded()) {
-        return "";
-    }
     try {
+        if (!result.succeeded()) {
+            return "";
+        }
         int vt = VariantFFM.getVt(result.variant());
         if (vt == VariantFFM.VT_NULL || vt == VariantFFM.VT_EMPTY) {
             return "";
         }
         if (vt == VariantFFM.VT_BSTR) {
             return VariantFFM.getBstrVal(result.variant(), arena);
         }
         LOG.debug("Expected VT_BSTR but got VT type: {}", vt);
         return "";
     } finally {
-        VariantFFM.clear(result.variant());
+        if (!result.variant().equals(NULL)) {
+            VariantFFM.clear(result.variant());
+        }
     }
 }

Apply the same pattern to getInt(), getLong(), and getBoolean().

Also applies to: 137-157, 169-198, 210-226

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java`
around lines 109 - 125, The Get() wrapper currently returns early on failed
HRESULTs or null/empty VT without clearing the native VARIANT, leaking native
memory; update the method that calls get(pObject, propertyName, arena) (and
similarly getInt(), getLong(), getBoolean()) so that
VariantFFM.clear(result.variant()) is always called before any return: obtain
the GetResult, then ensure clearing happens in a finally (or call clear
immediately before each early return) so the variant is cleared on both success
and failure, while preserving the existing logic that returns "" (or the
appropriate default) when vt is VT_NULL/VT_EMPTY or when types mismatch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java`:
- Around line 146-149: The switch handling VARTYPE widening in
IWbemClassObjectFFM incorrectly treats signed types as unsigned (masking
VT_I2/VT_I4 and not handling VT_INT/VT_UINT aliases); update the switch in the
method that reads VariantFFM variants so that VT_I2 and VT_I4 (and their
VT_INT/VT_UINT aliases) are widened with sign extension (convert
getShortVal/getIntVal to a signed long/ int without applying & 0xFFFF or
toUnsignedLong), and handle VT_INT/VT_UINT alongside VT_I4/VT_UI4 and
VT_I2/VT_UI2 branches consistently; apply the same fix to the similar block
around the later case (lines 187-193) so signedness is preserved when widening.
- Around line 81-93: The code reads pType and returns a possibly bogus cimType
even when IWbemClassObject::Get failed; change the logic around the
mh.invokeExact call so you only read pType.get(JAVA_INT, 0) when the HRESULT
indicates success and otherwise set cimType to the sentinel (CIM_ILLEGAL) before
constructing and returning new GetResult(hr, pVal, cimType). In short: after
mh.invokeExact (the call that populates pType), check hr for failure, and if
failed do not read pType but use CIM_ILLEGAL; otherwise read pType and return as
before.

---

Duplicate comments:
In
`@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java`:
- Around line 109-125: The Get() wrapper currently returns early on failed
HRESULTs or null/empty VT without clearing the native VARIANT, leaking native
memory; update the method that calls get(pObject, propertyName, arena) (and
similarly getInt(), getLong(), getBoolean()) so that
VariantFFM.clear(result.variant()) is always called before any return: obtain
the GetResult, then ensure clearing happens in a finally (or call clear
immediately before each early return) so the variant is cleared on both success
and failure, while preserving the existing logic that returns "" (or the
appropriate default) when vt is VT_NULL/VT_EMPTY or when types mismatch.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 251-256: The code calls
Kernel32FFM.GetVolumeNameForVolumeMountPoint and immediately reads volumeBuf via
readWideString without checking the call's boolean result; reproduce the pattern
used in getLocalVolumes() to check the return value: capture the boolean result
of GetVolumeNameForVolumeMountPoint (when building mountPoint/volumeBuf in
WindowsFileSystemFFM.java), only call readWideString(volumeBuf) and assign to
volume if the call returned true, otherwise leave volume null or skip
assigning/handle the error path appropriately; ensure you reference the same
BUFSIZE/volumeBuf/toWideString variables and avoid reading uninitialized memory.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba87675e-92fe-4cc8-be95-c08e43d5afe7

📥 Commits

Reviewing files that changed from the base of the PR and between 7b4c21f and 14761c2.

📒 Files selected for processing (8)
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 11, windows-latest
🔇 Additional comments (12)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java (4)

69-106: BSTR memory management is now correct.

The previous review concern about BSTR memory leaks has been properly addressed:

  • bstrQueryLang and bstrQuery are initialized to NULL before the try block (lines 69-70).
  • Cleanup is performed in the finally block with proper null checks (lines 99-106).

This ensures BSTRs are freed even if getVtable(), getVtableFunction(), createDowncall(), or invokeExact() throws an exception.


26-36: Well-structured utility class.

The class follows proper utility class patterns: final class, private constructor to prevent instantiation, and extends ComObjectFFM for shared vtable/downcall functionality. The WQL constant is appropriately documented.


38-54: FunctionDescriptor correctly models Windows LLP64 types.

The use of JAVA_INT for the lFlags parameter is correct since Windows uses the LLP64 data model where long is 32-bit. The descriptor accurately maps the COM method signature.


117-120: Clean API overload with sensible defaults.

The overload provides a convenient entry point with the common flags WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, which is the standard pattern for efficient WMI query enumeration.

oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (6)

81-84: Add a comment documenting the 64-bit assumption.

The MAX_WINDOWS_HANDLES constant uses the 64-bit formula (2^24 - 2^16), but the FileSystem interface documents different values for 32-bit (2^24 - 2^15) and 64-bit Windows. While 32-bit Windows is rare, adding a brief comment here would document this intentional assumption.


266-268: Minor note: freeSpace and usableSpace receive identical values.

Both parameters receive free (from drive.getFreeSpace()). This differs from getLocalVolumes() which distinguishes between system free bytes and user-available bytes. This appears intentional since Win32_LogicalDisk only provides a single FreeSpace value, so there's no separate usable-space figure available from WMI.


90-122: LGTM!

The localOnly parameter is now correctly used: it's passed to getWmiVolumes() and used in the conditional at line 116 to control whether network volumes are added. The merge logic between local volumes and WMI data correctly prefers local volume data while enriching with WMI names and labels.


130-199: LGTM!

The local volume enumeration correctly:

  • Checks return values from GetVolumeInformation, GetVolumePathNamesForVolumeName, and GetDiskFreeSpaceEx before reading buffers
  • Uses JAVA_LONG for 64-bit disk space values (fixing the previous truncation issue)
  • Properly cleans up with FindVolumeClose in the finally block

207-227: LGTM!

The drive type handling correctly uses orElse(-1) for failed calls and provides a sensible default in the switch expression.


274-287: LGTM!

The file descriptor methods correctly delegate to PdhUtilFFM and return the pre-computed maximum handle constant.

oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java (1)

37-97: LGTM!

The implementation correctly addresses the previous review feedback:

  • The _Total instance is now filtered by case-insensitive name comparison rather than array position
  • Logging now properly includes the placeholder and throwable for stack trace capture
  • Memory management with Arena and proper cleanup in finally block is correct
  • Two-phase buffer allocation pattern for PDH_MORE_DATA follows the Windows PDH API contract
oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java (1)

193-194: VT_R4 decoding looks correct now.

Reading the payload with JAVA_FLOAT matches the native VARIANT layout and avoids widening the raw bits as an integer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java`:
- Around line 149-160: The getInt() switch in IWbemClassObjectFFM misses
handling for VariantFFM.VT_UI1 so 8-bit unsigned WMI values fall to the default;
add a new case to the switch: handle VariantFFM.VT_UI1 by calling
VariantFFM.getByteVal(result.variant()) and zero-extend with & 0xFF (same
pattern as VT_UI2), e.g., add "case VariantFFM.VT_UI1 ->
VariantFFM.getByteVal(result.variant()) & 0xFF;" alongside the other VT_UI*
branches.
- Around line 185-192: The branch handling VT_BSTR currently always uses
Long.parseUnsignedLong and thus misparses negative signed 64-bit values; update
the IWbemClassObjectFFM code where it checks VariantFFM.VT_BSTR (using
VariantFFM.getBstrVal(result.variant(), arena)) to inspect result.cimType() and
choose parsing: if result.cimType() == 20 (CIM_SINT64) use Long.parseLong on the
string, if result.cimType() == 21 (CIM_UINT64) use Long.parseUnsignedLong, and
preserve the NumberFormatException handling to return 0L on parse failure.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 110-115: The merge logic replaces the local store name with
WMI-derived wmiVolume.getName(), losing user-friendly labels; instead preserve
the existing local name from OSFileStore (the variable volume) and only use WMI
fields to backfill missing values. Update the creation of the new
WindowsOSFileStoreFFM (in the block using volumeMap, wmiVolume and result) to
use volume.getName() (or keep volume.getLabel()-based name) as the first/name
parameter, and only substitute wmiVolume.getName() or other wmiVolume fields
when the corresponding volume getters are empty or null, leaving
volume.getLabel(), volume.getMount(), volume.getUUID(), etc. intact otherwise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 836e80b0-58a7-4220-b173-c1102fbac570

📥 Commits

Reviewing files that changed from the base of the PR and between 14761c2 and e546c80.

📒 Files selected for processing (2)
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

151-185: Nice defensive handling around the Win32 volume queries.

The early OptionalInt checks before reading nameBuf, mountBuf, and the disk-space buffers — plus the JAVA_LONG reads for space values — make this path much safer on offline, empty, or transient volumes.

@rohan-coder02

Copy link
Copy Markdown
Collaborator Author

@dbwiddis, I've added the COM implementation for this and addressed the issues raised by CodeRabbit

Let me know your views on the same, will accordingly take a look

@dbwiddis dbwiddis left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on this implementation!

A few comments inline.

In addition:

  • please run mvn spotless:apply for formatting and sort/remove some unused imports
  • after that, run mvn checkstyle:check and fix the failures (lots of missing @param or @return javadocs, and you can add more suppressions for the naming conventions)

Rohan Sarnad and others added 7 commits March 29, 2026 10:55
Add COM bindings (Ole32, WMI interfaces) and complete getFileStores() with WMI support.
Fix disk space JAVA_LONG bug and GetDiskFreeSpaceExW.
- Fix VARIANT memory leak in IWbemClassObjectFFM (try/finally for VariantClear)
- Fix BSTR leaks in IWbemLocatorFFM and IWbemServicesFFM (finally blocks)
- Fix lSecurityFlags type JAVA_LONG -> JAVA_INT (Windows LLP64)
- Fix getFloatVal to use JAVA_FLOAT for IEEE-754
- Fix FindFirstVolume to check INVALID_HANDLE_VALUE (-1) not NULL
- Check Win32 API return values before reading buffers
- Fix PdhUtilFFM to check instance name instead of assuming last is _Total
- Make WmiQueryHandlerFFM thread-safe (AtomicInteger, AtomicBoolean, ConcurrentHashMap)
- Fix signed/unsigned VARTYPE widening (VT_I2/VT_I4 sign-extend, VT_UI2/VT_UI4 zero-extend)
- Handle VT_INT/VT_UINT alongside VT_I4/VT_UI4
- Only read pType on HRESULT success, use CIM_ILLEGAL on failure
- Fix VARIANT memory leak: move early returns inside try block
- Check GetVolumeNameForVolumeMountPoint return before reading buffer
@dbwiddis
dbwiddis force-pushed the implement-file-system-in-windows-ffm branch from 24d0b15 to 00ef299 Compare March 29, 2026 17:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (3)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java (1)

46-54: Consider documenting the vtable slot limit assumption.

The vtable is reinterpreted to PTR_SIZE * 32 (256 bytes), allowing access to up to 32 vtable entries. This is sufficient for the WMI interfaces used in this PR (IWbemLocator, IWbemServices, etc. have fewer than 32 methods), but could be a limitation for other COM interfaces.

Consider adding a comment documenting this assumption, or parameterizing the slot count for future extensibility.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java` around
lines 46 - 54, The getVtable method currently reinterprets the vtable as
PTR_SIZE * 32 (allowing 32 slots) which is an implicit assumption; update the
code by either documenting this limit with a clear comment on getVtable
explaining why 32 slots was chosen and its applicability to
IWbemLocator/IWbemServices, or refactor to accept a configurable slot count
(e.g., add an int slotCount parameter or a named constant like VTABLE_SLOTS used
in the reinterpret) and use that instead of the hardcoded 32; reference
getVtable, pObject, vtablePtr, PTR_SIZE and the reinterpret calls when making
the change.
oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java (1)

81-89: Consider differentiating between downcall failure and COM initialization failure.

When CoInitializeEx throws (e.g., symbol lookup failure), the method returns OptionalInt.empty(), which callers (like WmiQueryHandlerFFM.initCOM) treat the same as RPC_E_CHANGED_MODE - returning false. This conflation could mask genuine FFM setup failures that should be logged at a higher severity or handled differently.

However, if FFM symbol lookup fails consistently, the application will fail elsewhere too, so this defensive approach may be acceptable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java` around
lines 81 - 89, The current Ole32FFM.CoInitializeEx swallows all Throwable and
returns OptionalInt.empty(), conflating FFM downcall/symbol lookup failures with
legitimate COM HRESULT failures; change CoInitializeEx to distinguish invocation
errors from HRESULT results: catch specific linkage/invocation problems (e.g.,
UnsatisfiedLinkError, NoSuchMethodError, ReflectiveOperationException or
InvocationTargetException) and either rethrow a RuntimeException or log at ERROR
and return a distinct signal (e.g., throw or use OptionalInt.empty() only for
invocation failures while returning OptionalInt.of(hr) for real COM returns),
and update callers such as WmiQueryHandlerFFM.initCOM to treat invocation
failures differently than an HRESULT like RPC_E_CHANGED_MODE so setup failures
are not mistaken for COM mode changes. Ensure you reference and handle
exceptions thrown by CoInitializeEx.invokeExact separately from the integer hr
path in Ole32FFM.CoInitializeEx.
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

61-79: Keep the option string order deterministic.

getOptions() is assembled by iterating OPTIONS_MAP. With HashMap, the comma-separated flag order is unspecified, so the same store can expose different options strings across JVMs. LinkedHashMap keeps the output stable.

♻️ Suggested change
+import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Optional;
 import java.util.stream.Collectors;
@@
-    private static final Map<Integer, String> OPTIONS_MAP = new HashMap<>();
+    private static final Map<Integer, String> OPTIONS_MAP = new LinkedHashMap<>();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`
around lines 61 - 79, The OPTIONS_MAP used by WindowsFileSystemFFM is a HashMap
so iteration order is non-deterministic and getOptions() can produce varying
flag strings; change OPTIONS_MAP to a LinkedHashMap (keep the same static
initializer and keys/values) so insertion order is preserved and options string
is stable across JVMs, updating the declaration of OPTIONS_MAP accordingly while
leaving the rest of the static block and getOptions() logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@oshi-core-java11/src/main/java/module-info.java`:
- Around line 10-17: The module-info.java currently exports packages that do not
exist in this module (oshi.util.gpu, oshi.util.platform.linux,
oshi.util.platform.mac, oshi.util.platform.unix.freebsd,
oshi.util.platform.unix.openbsd, oshi.util.platform.unix.solaris,
oshi.util.platform.windows, oshi.util.tuples); either remove those export
statements from module-info.java or create the missing package folders and add
at least one public type (class/interface) in each (e.g., a simple placeholder
public class) so the Java module system recognizes them; edit the export lines
in module-info.java (or add the corresponding package sources) to resolve the
"package is empty or does not exist" build error.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 167-168: The local-volume fast path is incorrectly comparing
volumeToMatch to the mount variable, causing GUID-based refreshes from
WindowsOSFileStoreFFM.updateAttributes() to miss and fall back to WMI; in
getLocalVolumes (WindowsFileSystemFFM) change the comparison to compare
volumeToMatch to the actual volume identifier read from the buffer (the variable
assigned by readWideString, e.g., name/volume) instead of mount so GUIDs match
and directory-mounted volumes refresh correctly.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`:
- Around line 331-333: The setter setWmiTimeout currently accepts invalid
values; add validation inside setWmiTimeout(int wmiTimeout) to reject 0 and any
value less than -1 (only allow -1 or positive integers). If an invalid value is
passed, throw an IllegalArgumentException with a clear message; otherwise set
this.wmiTimeout.set(wmiTimeout) as before. Ensure the check is implemented at
the start of setWmiTimeout so runtime behavior matches config-load validation.
- Around line 204-209: The generic Exception handler in WmiQueryHandlerFFM
currently blacklists wmiClassName for all failures; change this so
failedWmiClassNames.add(wmiClassName) is only performed for WMI-specific
failures (e.g., inside the FfmComException catch or after verifying the
exception indicates a WMI/class-not-found error), and remove it from the broad
catch(Exception) branch; keep the broad catch for logging only (using
LOG.debug/LOG.error with full exception info) so non-WMI errors don't
permanently suppress future queries.
- Around line 82-95: The current createInstance() can return null and creates a
new handler each call, losing cached state; change it so it never returns null
and preserves handler state by using a cached singleton fallback: introduce or
use a static cached instance (e.g., a private static final WmiQueryHandlerFFM
INSTANCE or a private static WmiQueryHandlerFFM cachedInstance) and, in
createInstance(), if customClass==null return that cachedInstance (or create it
once), otherwise attempt customClass.getConstructor(...).newInstance(...); on
any caught exception (NoSuchMethodException, InstantiationException,
IllegalAccessException, InvocationTargetException, etc.) LOG.error(...) and
return the cachedInstance instead of null, and optionally set customClass = null
to cache the failure and avoid repeated reflection attempts (referencing
createInstance, customClass, EMPTY_CLASS_ARRAY, EMPTY_OBJECT_ARRAY, LOG).

---

Nitpick comments:
In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java`:
- Around line 46-54: The getVtable method currently reinterprets the vtable as
PTR_SIZE * 32 (allowing 32 slots) which is an implicit assumption; update the
code by either documenting this limit with a clear comment on getVtable
explaining why 32 slots was chosen and its applicability to
IWbemLocator/IWbemServices, or refactor to accept a configurable slot count
(e.g., add an int slotCount parameter or a named constant like VTABLE_SLOTS used
in the reinterpret) and use that instead of the hardcoded 32; reference
getVtable, pObject, vtablePtr, PTR_SIZE and the reinterpret calls when making
the change.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java`:
- Around line 81-89: The current Ole32FFM.CoInitializeEx swallows all Throwable
and returns OptionalInt.empty(), conflating FFM downcall/symbol lookup failures
with legitimate COM HRESULT failures; change CoInitializeEx to distinguish
invocation errors from HRESULT results: catch specific linkage/invocation
problems (e.g., UnsatisfiedLinkError, NoSuchMethodError,
ReflectiveOperationException or InvocationTargetException) and either rethrow a
RuntimeException or log at ERROR and return a distinct signal (e.g., throw or
use OptionalInt.empty() only for invocation failures while returning
OptionalInt.of(hr) for real COM returns), and update callers such as
WmiQueryHandlerFFM.initCOM to treat invocation failures differently than an
HRESULT like RPC_E_CHANGED_MODE so setup failures are not mistaken for COM mode
changes. Ensure you reference and handle exceptions thrown by
CoInitializeEx.invokeExact separately from the integer hr path in
Ole32FFM.CoInitializeEx.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 61-79: The OPTIONS_MAP used by WindowsFileSystemFFM is a HashMap
so iteration order is non-deterministic and getOptions() can produce varying
flag strings; change OPTIONS_MAP to a LinkedHashMap (keep the same static
initializer and keys/values) so insertion order is preserved and options string
is stable across JVMs, updating the declaration of OPTIONS_MAP accordingly while
leaving the rest of the static block and getOptions() logic unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be0be5cd-1808-44cf-b787-50f26665eff7

📥 Commits

Reviewing files that changed from the base of the PR and between 14761c2 and 3b96fb2.

📒 Files selected for processing (26)
  • CHANGELOG.md
  • config/checkstyle-suppressions.xml
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/FfmComException.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IEnumWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/WbemcliFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/package-info.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
✅ Files skipped from review due to trivial changes (5)
  • config/checkstyle-suppressions.xml
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/package-info.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/WbemcliFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
🔇 Additional comments (18)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java (3)

153-155: Fix missing format placeholder in debug log statement.

The LOG.debug call uses a format string "CoCreateInstance failed with HRESULT: 0x{}" but the {} placeholder is correct. However, Integer.toHexString(hr) returns a lowercase hex string, which is fine.

Actually, looking more carefully - the format is correct. The {} will be replaced with the hex string.


197-215: LGTM!

The succeeded() and failed() HRESULT helpers correctly implement the standard Windows HRESULT classification: success codes are non-negative (>= 0), failure codes are negative (< 0).


149-162: LGTM!

The CoCreateInstance wrapper correctly:

  1. Allocates an output pointer buffer
  2. Invokes the COM function with proper parameters
  3. Returns NULL on failure with debug logging
  4. Extracts and returns the interface pointer on success
oshi-core-java25/src/main/java/module-info.java (1)

10-14: LGTM!

The new exports for platform-specific utility packages and tuples align with the PR's goal of exposing FFM-based Windows functionality. The module structure correctly exposes the necessary public APIs.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java (3)

46-54: LGTM!

The fromString method correctly converts a Java String to a wide string and allocates a BSTR via SysAllocString. Proper error handling returns MemorySegment.NULL on failure.


64-73: LGTM!

The free method correctly guards against null/NULL inputs before calling SysFreeString, preventing accidental double-frees or null pointer issues.


103-119: LGTM!

The toString method correctly reads BSTR characters using the length prefix (via SysStringLen) rather than relying on null-termination, which is the correct approach for BSTR. The buffer size calculation len * 2 + 2 properly accounts for the wide characters plus null terminator.

oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java (2)

62-72: LGTM!

The PDH layout definitions correctly model the Windows PDH_FMT_COUNTERVALUE_ITEM_W structure:

  • The union layout accommodates all possible value types (int, double, long, string pointers)
  • The 4-byte padding after CStatus correctly aligns the union to 8 bytes
  • The item layout with szName pointer followed by FmtValue matches the Windows ABI

The resulting 24-byte item size (8 + 4 + 4 + 8) is correct for 64-bit Windows.


26-60: LGTM!

The PDH function wrappers correctly expose the Windows PDH API with appropriate parameter types. The methods properly propagate Throwable to allow callers to handle native invocation errors.

oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java (1)

37-97: LGTM!

The implementation correctly:

  1. Uses the two-phase PDH query pattern to determine buffer size before allocation
  2. Filters _Total by instance name (case-insensitive) rather than array position, addressing the ordering concern
  3. Properly closes the PDH query in a finally block
  4. Returns -1 on failure with proper debug logging including the exception
oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java (2)

88-101: LGTM!

The addRef implementation correctly:

  1. Guards against null/NULL pointers
  2. Resolves the vtable and AddRef function pointer using the standard COM vtable index
  3. Creates a downcall handle and invokes it
  4. Returns 0 on failure with debug logging

113-138: LGTM!

The release and safeRelease implementations correctly handle COM reference counting cleanup with proper null guards and error handling.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/IEnumWbemClassObjectFFM.java (3)

54-62: LGTM!

The NextResult record provides clean semantics:

  • hasObject() correctly combines HRESULT success check with non-null object validation
  • isComplete() correctly identifies WBEM_S_FALSE (0x1) as the enumeration completion signal per WMI documentation

72-95: LGTM!

The next() implementation correctly:

  1. Validates the enum pointer before use
  2. Allocates output buffers for the object pointer and return count
  3. Only extracts the object when puReturned > 0, avoiding reading uninitialized memory
  4. Returns a structured result with both HRESULT and object pointer

118-132: LGTM!

The reset() implementation correctly wraps the COM method with proper null validation and returns OptionalInt to distinguish between call failure and HRESULT values.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java (1)

68-99: Exception-safe BSTR cleanup looks good.

Both query BSTRs now unwind through finally, so the native allocations are released on success, HRESULT failure, and Java-side exceptions alike.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java (1)

105-123: The VARIANT lifetime handling is in a much safer place now.

The try/finally cleanup around the typed accessors, together with the CIM-type-aware integer parsing, closes the earlier leak and signedness pitfalls in this helper.

Also applies to: 134-161, 172-208, 219-237

oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java (1)

198-200: VT_R4 decoding looks correct now.

Reading getFloatVal with JAVA_FLOAT is the right behavior for COM VT_R4.

@dbwiddis
dbwiddis force-pushed the implement-file-system-in-windows-ffm branch from 3b96fb2 to 5a82e97 Compare March 29, 2026 18:35
@dbwiddis
dbwiddis force-pushed the implement-file-system-in-windows-ffm branch from 5a82e97 to a749e90 Compare March 29, 2026 18:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java (2)

252-266: ⚠️ Potential issue | 🟠 Major

Throw on hard CoInitializeSecurity failures.

Lines 259-266 currently downgrade a real security-init failure to false, so the caller only hits the generic "Failed to initialize COM" path and loses the HRESULT. oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java throws on the equivalent branch; doing the same here would preserve the failure reason in the existing catch (FfmComException ...) flow.

🔧 Suggested fix
                     if (hrOpt.isPresent()) {
                         int hr = hrOpt.getAsInt();
                         // RPC_E_TOO_LATE is OK - security already initialized
                         if (Ole32FFM.succeeded(hr) || hr == Ole32FFM.RPC_E_TOO_LATE) {
                             securityInitialized.set(true);
                         } else {
                             Ole32FFM.CoUninitialize();
-                            return false;
+                            throw new FfmComException("Failed to initialize security.", hr);
                         }
                     }
#!/bin/bash
echo "FFM implementation:"
sed -n '252,266p' oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
echo
echo "Existing JNA implementation:"
sed -n '189,203p' oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`
around lines 252 - 266, The error branch in WmiQueryHandlerFFM that calls
Ole32FFM.CoUninitialize() and returns false on a CoInitializeSecurity failure
should instead throw an FfmComException (or the same exception type used by
WmiQueryHandler) containing the HRESULT so the caller's catch (FfmComException
...) can preserve the failure reason; locate the failure handling in the
synchronized block around securityInitialized and replace the return false path
with throwing a new FfmComException (including hr and a descriptive message)
after calling Ole32FFM.CoUninitialize(), mirroring the behavior in
WmiQueryHandler.

55-56: ⚠️ Potential issue | 🟠 Major

Narrow the failure-cache key and eviction policy.

Line 122 short-circuits by wmiClassName alone, so one failed query variant can suppress unrelated queries for the same class in a different namespace or with a different whereClause. Lines 150 and 170 also record connectServer() / execQuery() failures permanently, which makes transient failures sticky; this cache should be scoped more narrowly and only retain definitive class-not-found failures or expire entries after backoff.

Also applies to: 121-123, 147-171

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`
around lines 55 - 56, The failure cache failedWmiClassNames is too coarse and
permanent: when short-circuiting in the code paths that check
failedWmiClassNames (using only wmiClassName) you should narrow the cache key to
include namespace and whereClause (e.g., compose namespace + wmiClassName +
whereClause) so different query variants aren’t suppressed, and stop recording
transient connectServer()/execQuery() errors permanently — only record
definitive “class not found” results or add a time-based eviction/backoff (TTL)
so failures expire; update checks and writes around failedWmiClassNames, and the
places that call connectServer() and execQuery() to use the new composite key
and TTL/definitive-only logic.
🧹 Nitpick comments (1)
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

150-150: Filter volumeToMatch before the native probes.

The helper already has the volume GUID at Line 150, but the equality check waits until Line 168. Moving it up avoids two extra native calls for every non-matching volume during targeted refreshes.

♻️ Suggested change
                     String volume = readWideString(volumeNameBuf);
+                    if (volumeToMatch != null && !volume.equals(volumeToMatch)) {
+                        continue;
+                    }
 
                     // Get volume information - skip if call fails
                     var volInfoResult = Kernel32FFM.GetVolumeInformation(toWideString(arena, volume), nameBuf, BUFSIZE,
                             NULL, NULL, flagsBuf, fstypeBuf, 16);
@@
-                    if (!mount.isEmpty() && (volumeToMatch == null || volume.equals(volumeToMatch))) {
+                    if (!mount.isEmpty()) {

Also applies to: 168-168

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`
at line 150, The code currently reads the volume GUID into 'volume' via
readWideString(volumeNameBuf) but delays comparing it to 'volumeToMatch' until
later, causing unnecessary native calls; update the loop in WindowsFileSystemFFM
to compare the just-read 'volume' to 'volumeToMatch' immediately (after the
readWideString(volumeNameBuf) assignment) and continue/skip the rest of the
native probes if it does not match, so native calls invoked later in this
iteration are only executed for matching volumes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Line 145: The call in WindowsFileSystemFFM that allocates a fixed-size
mountBuf (BUFSIZE * JAVA_CHAR.byteSize()) and passes NULL for lpcchReturnLength
must be changed to handle ERROR_MORE_DATA: allocate a non-null length holder
(e.g., an IntByReference/MemorySegment for lpcchReturnLength), pass it into
GetVolumePathNamesForVolumeName, and if the call fails with ERROR_MORE_DATA read
the required character count from that holder, reallocate mountBuf to the needed
size (requiredCount * JAVA_CHAR.byteSize()), and retry the call before giving
up; update the logic around the mountBuf allocation and the
GetVolumePathNamesForVolumeName invocation in
WindowsFileSystemFFM/getLocalVolumes accordingly so volumes with multiple/long
mount paths are not skipped.

---

Duplicate comments:
In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`:
- Around line 252-266: The error branch in WmiQueryHandlerFFM that calls
Ole32FFM.CoUninitialize() and returns false on a CoInitializeSecurity failure
should instead throw an FfmComException (or the same exception type used by
WmiQueryHandler) containing the HRESULT so the caller's catch (FfmComException
...) can preserve the failure reason; locate the failure handling in the
synchronized block around securityInitialized and replace the return false path
with throwing a new FfmComException (including hr and a descriptive message)
after calling Ole32FFM.CoUninitialize(), mirroring the behavior in
WmiQueryHandler.
- Around line 55-56: The failure cache failedWmiClassNames is too coarse and
permanent: when short-circuiting in the code paths that check
failedWmiClassNames (using only wmiClassName) you should narrow the cache key to
include namespace and whereClause (e.g., compose namespace + wmiClassName +
whereClause) so different query variants aren’t suppressed, and stop recording
transient connectServer()/execQuery() errors permanently — only record
definitive “class not found” results or add a time-based eviction/backoff (TTL)
so failures expire; update checks and writes around failedWmiClassNames, and the
places that call connectServer() and execQuery() to use the new composite key
and TTL/definitive-only logic.

---

Nitpick comments:
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Line 150: The code currently reads the volume GUID into 'volume' via
readWideString(volumeNameBuf) but delays comparing it to 'volumeToMatch' until
later, causing unnecessary native calls; update the loop in WindowsFileSystemFFM
to compare the just-read 'volume' to 'volumeToMatch' immediately (after the
readWideString(volumeNameBuf) assignment) and continue/skip the rest of the
native probes if it does not match, so native calls invoked later in this
iteration are only executed for matching volumes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e382599b-baee-4ac6-a999-7e0d589340d0

📥 Commits

Reviewing files that changed from the base of the PR and between 3b96fb2 and 5a82e97.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java (1)

28-30: The AtomicInteger import is already present in the file. No action is needed.

			> Likely an incorrect or invalid review comment.
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

85-87: [Rewritten comment]
[Classification tag]

@dbwiddis dbwiddis changed the title Implement file system in windows ffm Implement COM, WMI, PDH and FileSystem in windows ffm Mar 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (6)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java (3)

118-127: Same concern applies to release error handling.

The release method swallows all exceptions the same way as addRef. For release, returning 0 on failure is particularly problematic because it may indicate "object was destroyed" when it actually wasn't, potentially masking COM reference leaks.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java` around
lines 118 - 127, The release method currently catches Throwable and returns 0,
which can be mistaken for a successful release; change the error handling in
release (the block surrounding getVtable, getVtableFunction, createDowncall,
WbemcliFFM.IUNKNOWN_RELEASE and RELEASE_DESC) to log the full exception (use
LOG.error with the throwable) and return a sentinel error value (e.g., -1)
instead of 0 so callers can distinguish failure from a real zero return; ensure
the log message includes context like "ComObjectFFM.release failed" and the
throwable.

89-102: Consider whether swallowing all Throwable is the desired behavior.

The catch block returns 0 for any failure, including Error subclasses like OutOfMemoryError. This silently masks issues that callers might need to handle differently. Since addRef returning 0 could be misinterpreted as "object was at zero refcount" rather than "call failed", callers have no way to distinguish failure from success.

If the intent is robustness, consider at minimum logging at warn level for unexpected throwables (non-RuntimeException), or re-throwing Error subclasses.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java` around
lines 89 - 102, The current addRef method swallows all Throwables which hides
serious errors; change the catch to only handle Exception (or Throwable t but
rethrow if t is instance of Error) so Errors like OutOfMemoryError propagate,
and at minimum log unexpected exceptions at warn level using LOG.warn instead of
debug; keep the existing return 0 behavior for handled exceptions but rethrow
Error instances thrown by createDowncall, getVtable/getVtableFunction or the
MethodHandle invocation to avoid masking fatal failures in addRef.

79-80: Minor: ADDREF_DESC and RELEASE_DESC are identical.

Both descriptors are FunctionDescriptor.of(JAVA_INT, ADDRESS). You could use a single shared constant to reduce duplication.

♻️ Suggested consolidation
-    // IUnknown::AddRef
-    private static final FunctionDescriptor ADDREF_DESC = FunctionDescriptor.of(JAVA_INT, ADDRESS);
+    // IUnknown::AddRef and Release share the same signature
+    private static final FunctionDescriptor IUNKNOWN_REFCOUNT_DESC = FunctionDescriptor.of(JAVA_INT, ADDRESS);
...
-    // IUnknown::Release
-    private static final FunctionDescriptor RELEASE_DESC = FunctionDescriptor.of(JAVA_INT, ADDRESS);

Also applies to: 104-105

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java` around
lines 79 - 80, The two identical FunctionDescriptor constants ADDREF_DESC and
RELEASE_DESC in ComObjectFFM should be consolidated: create a single static
final FunctionDescriptor (e.g., REFCOUNT_DESC or REFERENCE_FN_DESC) initialized
with FunctionDescriptor.of(JAVA_INT, ADDRESS) and replace both ADDREF_DESC and
RELEASE_DESC usages/declarations to reference that shared constant, keeping it
private/static/final and preserving existing names where used elsewhere (or
update code to use the new constant).
oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java (1)

82-96: Factory creates new instances, losing cached state across calls.

Each call to createInstance() returns a fresh WmiQueryHandlerFFM instance with an empty failedWmiClassNames cache. This means the "skip previously failed classes" optimization only works if callers reuse the same handler instance.

If this matches the JNA implementation's intended usage pattern (callers should cache the instance), consider adding Javadoc clarifying this. Otherwise, consider making the cache static or implementing a singleton pattern for the default case.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`
around lines 82 - 96, The factory method createInstance() repeatedly returns new
WmiQueryHandlerFFM instances so the instance field failedWmiClassNames is not
shared across calls; either make the default handler a cached singleton (create
a private static final WmiQueryHandlerFFM DEFAULT = new WmiQueryHandlerFFM() and
return DEFAULT when customClass is null) or change failedWmiClassNames to a
static field so its cache is shared among all instances; update the
createInstance() logic to return the singleton when customClass is null (or
leave creation as-is if you choose the static-cache approach) and add Javadoc on
createInstance()/WmiQueryHandlerFFM explaining the chosen lifecycle/intent.
oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (2)

106-120: Consider using index-based removal for efficiency.

result.remove(volume) performs an O(n) linear search on the ArrayList. While acceptable for typical systems with few volumes, this could be optimized if many volumes are expected.

♻️ Suggested alternative using index tracking
-        for (OSFileStore wmiVolume : getWmiVolumes(null, localOnly)) {
-            if (volumeMap.containsKey(wmiVolume.getMount())) {
-                // If the volume is already in our list, preserve local values
-                // and only backfill missing fields from WMI
-                OSFileStore volume = volumeMap.get(wmiVolume.getMount());
-                result.remove(volume);
-                result.add(new WindowsOSFileStoreFFM(volume.getName(), // preserve local name
+        // Build a map of mount -> index for efficient replacement
+        Map<String, Integer> mountToIndex = new HashMap<>();
+        for (int i = 0; i < result.size(); i++) {
+            mountToIndex.put(result.get(i).getMount(), i);
+        }
+
+        for (OSFileStore wmiVolume : getWmiVolumes(null, localOnly)) {
+            Integer idx = mountToIndex.get(wmiVolume.getMount());
+            if (idx != null) {
+                // If the volume is already in our list, preserve local values
+                // and only backfill missing fields from WMI
+                OSFileStore volume = result.get(idx);
+                result.set(idx, new WindowsOSFileStoreFFM(volume.getName(), // preserve local name
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`
around lines 106 - 120, The current removal uses result.remove(volume) which
does a linear search; instead, locate the index of the matching OSFileStore in
the result list while iterating and replace by index to avoid the extra O(n)
search. Concretely, when you detect an existing entry via
volumeMap.containsKey(wmiVolume.getMount()), find the index of that matching
OSFileStore in result (e.g., by comparing getMount() or equality with the local
variable volume), then call result.set(index, new WindowsOSFileStoreFFM(...))
(or remove at index and add at that index) rather than result.remove(volume);
keep the preserved fields logic the same and still skip adding when localOnly is
true.

219-228: Consider using named constants for drive type values.

The magic numbers (2, 3, 4, 5, 6) are Windows API constants (DRIVE_REMOVABLE, DRIVE_FIXED, etc.). Named constants would improve readability and maintainability.

♻️ Optional improvement
private static final int DRIVE_REMOVABLE = 2;
private static final int DRIVE_FIXED = 3;
private static final int DRIVE_REMOTE = 4;
private static final int DRIVE_CDROM = 5;
private static final int DRIVE_RAMDISK = 6;

private static String getDriveTypeString(int type) {
    return switch (type) {
        case DRIVE_REMOVABLE -> "Removable drive";
        case DRIVE_FIXED -> "Fixed drive";
        case DRIVE_REMOTE -> "Network drive";
        case DRIVE_CDROM -> "CD-ROM";
        case DRIVE_RAMDISK -> "RAM drive";
        default -> "Unknown drive type";
    };
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`
around lines 219 - 228, Replace the magic numbers in getDriveTypeString with
named constants: define private static final ints (e.g., DRIVE_REMOVABLE,
DRIVE_FIXED, DRIVE_REMOTE, DRIVE_CDROM, DRIVE_RAMDISK) at class scope and then
update the switch in getDriveTypeString(int type) to use those constants instead
of 2,3,4,5,6 to improve readability and maintainability; keep the returned
strings the same.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 160-165: GetVolumePathNamesForVolumeName is currently called with
NULL for the lpcchReturnLength parameter causing ERROR_MORE_DATA cases to be
skipped; modify the block around Kernel32FFM.GetVolumePathNamesForVolumeName to
allocate a MemorySegment (or equivalent) for lpcchReturnLength, pass that
pointer instead of NULL, and on failure check Kernel32FFM.GetLastError() for
ERROR_MORE_DATA; if ERROR_MORE_DATA, read the required length from your
lpcchReturnLength segment, reallocate mountBuf to the larger size and retry the
call (repeat if necessary), otherwise continue to skip only on
non-ERROR_MORE_DATA failures—update any BUFSIZE/mountBuf usage and loop logic
accordingly so volumes with multiple mount points are not silently omitted.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`:
- Around line 149-152: The code currently permanently adds wmiClassName to
failedWmiClassNames on connection/query failures (when pServicesOpt.isEmpty()
and the later query-exception block) which causes permanent blacklisting; change
this to a transient blacklist: replace the Set failedWmiClassNames with a
Map<String, FailureRecord> that stores lastFailureTimestamp and failureCount (or
similar), update the check at the top of WmiQueryHandlerFFM to skip only if
failureCount exceeds a retry threshold and lastFailureTimestamp is within a TTL
window, and on each failure (both the pServicesOpt.isEmpty() branch and the
query-failure branch) increment the count and set the timestamp; ensure
successful queries clear the entry for that wmiClassName so it can recover.

---

Nitpick comments:
In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java`:
- Around line 118-127: The release method currently catches Throwable and
returns 0, which can be mistaken for a successful release; change the error
handling in release (the block surrounding getVtable, getVtableFunction,
createDowncall, WbemcliFFM.IUNKNOWN_RELEASE and RELEASE_DESC) to log the full
exception (use LOG.error with the throwable) and return a sentinel error value
(e.g., -1) instead of 0 so callers can distinguish failure from a real zero
return; ensure the log message includes context like "ComObjectFFM.release
failed" and the throwable.
- Around line 89-102: The current addRef method swallows all Throwables which
hides serious errors; change the catch to only handle Exception (or Throwable t
but rethrow if t is instance of Error) so Errors like OutOfMemoryError
propagate, and at minimum log unexpected exceptions at warn level using LOG.warn
instead of debug; keep the existing return 0 behavior for handled exceptions but
rethrow Error instances thrown by createDowncall, getVtable/getVtableFunction or
the MethodHandle invocation to avoid masking fatal failures in addRef.
- Around line 79-80: The two identical FunctionDescriptor constants ADDREF_DESC
and RELEASE_DESC in ComObjectFFM should be consolidated: create a single static
final FunctionDescriptor (e.g., REFCOUNT_DESC or REFERENCE_FN_DESC) initialized
with FunctionDescriptor.of(JAVA_INT, ADDRESS) and replace both ADDREF_DESC and
RELEASE_DESC usages/declarations to reference that shared constant, keeping it
private/static/final and preserving existing names where used elsewhere (or
update code to use the new constant).

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 106-120: The current removal uses result.remove(volume) which does
a linear search; instead, locate the index of the matching OSFileStore in the
result list while iterating and replace by index to avoid the extra O(n) search.
Concretely, when you detect an existing entry via
volumeMap.containsKey(wmiVolume.getMount()), find the index of that matching
OSFileStore in result (e.g., by comparing getMount() or equality with the local
variable volume), then call result.set(index, new WindowsOSFileStoreFFM(...))
(or remove at index and add at that index) rather than result.remove(volume);
keep the preserved fields logic the same and still skip adding when localOnly is
true.
- Around line 219-228: Replace the magic numbers in getDriveTypeString with
named constants: define private static final ints (e.g., DRIVE_REMOVABLE,
DRIVE_FIXED, DRIVE_REMOTE, DRIVE_CDROM, DRIVE_RAMDISK) at class scope and then
update the switch in getDriveTypeString(int type) to use those constants instead
of 2,3,4,5,6 to improve readability and maintainability; keep the returned
strings the same.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`:
- Around line 82-96: The factory method createInstance() repeatedly returns new
WmiQueryHandlerFFM instances so the instance field failedWmiClassNames is not
shared across calls; either make the default handler a cached singleton (create
a private static final WmiQueryHandlerFFM DEFAULT = new WmiQueryHandlerFFM() and
return DEFAULT when customClass is null) or change failedWmiClassNames to a
static field so its cache is shared among all instances; update the
createInstance() logic to return the singleton when customClass is null (or
leave creation as-is if you choose the static-cache approach) and add Javadoc on
createInstance()/WmiQueryHandlerFFM explaining the chosen lifecycle/intent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13dba2fa-6f2d-488f-a624-77eb622048fc

📥 Commits

Reviewing files that changed from the base of the PR and between 5a82e97 and a749e90.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (9)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java (1)

46-55: LGTM: Well-structured vtable access pattern.

The COM object layout assumption (first pointer → vtable) and the 32-slot reinterpretation are correctly documented and cover all interfaces used. The null/NULL checks are proper.

oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java (4)

176-194: LGTM: Resource management in enumeration loop is correct.

The pObject returned from next() is properly released in the finally block on each iteration, and the outer pEnum, pServices, and pLocator are all released in their respective finally blocks. This correctly handles COM reference counting.


239-274: LGTM: COM initialization with threading model fallback is well-designed.

The double-checked locking for security initialization is correct with the AtomicBoolean guarding the fast path and synchronized block protecting the initialization. The threading model retry logic properly handles RPC_E_CHANGED_MODE by switching models via switchComThreadingFrom.


361-367: LGTM: Timeout validation is properly implemented.

The validation correctly rejects 0 and values less than -1, addressing the prior review feedback.


205-208: LGTM: Generic exceptions no longer trigger permanent blacklisting.

The exception handling correctly separates FfmComException (COM-specific errors) from generic Exception and does not add to failedWmiClassNames in either catch block. This addresses the prior review feedback about avoiding blacklisting from non-WMI failures.

oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (4)

1-34: LGTM!

The import structure is well-organized and all imports appear to be utilized throughout the implementation.


62-80: LGTM!

Using LinkedHashMap for OPTIONS_MAP ensures consistent ordering of filesystem options in the output string. The static initializer pattern correctly populates the map before any instance usage.


237-273: LGTM!

The WMI volume retrieval correctly handles both local and network drives. The return value check at line 257 prevents reading uninitialized buffer data, and the network path parsing at lines 261-264 safely handles edge cases.


275-289: LGTM!

The file descriptor methods are straightforward delegations. The constant MAX_WINDOWS_HANDLES is correctly documented with its 64-bit assumption.

@oshi oshi deleted a comment from coderabbitai Bot Mar 29, 2026
@dbwiddis

Copy link
Copy Markdown
Member

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java (1)

193-203: ⚠️ Potential issue | 🟡 Minor

Potential race condition on securityInitialized field access.

The securityInitialized field is read at line 193 (isSecurityInitialized()) and written at line 202 outside of synchronized blocks, while getComThreading() and switchComThreadingFrom() are synchronized. If multiple threads share the same WmiQueryHandler instance and call initCOM() concurrently, there's a race on this flag.

Consider either making isSecurityInitialized() and the write at line 202 synchronized, or marking securityInitialized as volatile.

Suggested fix
     // Track initialization of Security
-    private boolean securityInitialized = false;
+    private volatile boolean securityInitialized = false;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java`
around lines 193 - 203, The field securityInitialized is accessed without
synchronization in initCOM() via isSecurityInitialized() and later written to at
the end of that method, creating a race with synchronized methods
getComThreading() and switchComThreadingFrom(); make the access safe by
declaring the securityInitialized field as volatile (or alternatively
synchronize both the isSecurityInitialized() getter and the write at the end of
initCOM()), ensuring threads see the updated value when initCOM(),
getComThreading(), or switchComThreadingFrom() are invoked concurrently.
♻️ Duplicate comments (2)
oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java (2)

67-72: ⚠️ Potential issue | 🟠 Major

Return a cached default handler from createInstance().

Line 82 returns a fresh handler, so failed-class caching, the learned COM threading model, and any timeout set via setWmiTimeout() never survive beyond one call.

Suggested fix
+    private static final WmiQueryHandlerFFM INSTANCE = new WmiQueryHandlerFFM();
+
     private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
     private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
 
     // Factory to create this or a subclass
     private static Class<? extends WmiQueryHandlerFFM> customClass = null;
@@
     public static synchronized WmiQueryHandlerFFM createInstance() {
         if (customClass == null) {
-            return new WmiQueryHandlerFFM();
+            return INSTANCE;
         }
         try {
             return customClass.getConstructor(EMPTY_CLASS_ARRAY).newInstance(EMPTY_OBJECT_ARRAY);
         } catch (NoSuchMethodException | SecurityException e) {
             LOG.error("Failed to find or access a no-arg constructor for {}", customClass);
@@
         }
         customClass = null;
-        return new WmiQueryHandlerFFM();
+        return INSTANCE;
     }

Also applies to: 82-95

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`
around lines 67 - 72, createInstance() currently returns a new
WmiQueryHandlerFFM each call, losing learned COM threading model, failed-class
caching, and timeouts; add a private static volatile WmiQueryHandlerFFM
defaultInstance (or similar) and modify createInstance() to return that cached
instance when customClass is null (instantiate and assign it on first call). Use
simple synchronization or double-checked locking when initializing
defaultInstance to ensure thread-safety, and ensure setWmiTimeout(),
failed-class caches, and any learned state live on that shared defaultInstance
rather than on ephemeral instances.

123-124: ⚠️ Potential issue | 🟠 Major

Don't permanently blacklist classes on transient WMI failures.

Line 123 short-circuits forever once Lines 151 or 171 add the class, and there is no expiry or success-path clear. A temporary namespace or ExecQuery failure will suppress every later query on the same handler. Use a TTL/backoff record instead of a permanent Set, or clear the entry after a successful query.

Also applies to: 149-152, 169-172

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`
around lines 123 - 124, The code currently short-circuits queries by permanently
adding wmiClassName to failedWmiClassNames in WmiQueryHandlerFFM, which
suppresses all future queries after a transient ExecQuery/namespace failure;
change this to a TTL/backoff mechanism instead: replace the permanent Set
failedWmiClassNames with a Map<String,FailureInfo> (e.g., timestamp and/or retry
count), check the map entry age before short-circuiting in the place using
failedWmiClassNames, and when catching failures in the ExecQuery path (where the
code currently adds the class) record the failure timestamp/increment count;
importantly, on a successful query remove or reset the FailureInfo for that
wmiClassName so subsequent successful queries are allowed.
🧹 Nitpick comments (5)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java (1)

46-53: Avoid exception-driven flow for null input in fromString.

At Line 46, str == null currently triggers the catch path. An explicit guard is cheaper and clearer for this expected edge case.

♻️ Proposed null-guard
 public static MemorySegment fromString(Arena arena, String str) {
+    if (str == null) {
+        return MemorySegment.NULL;
+    }
     try {
         MemorySegment wideStr = toWideString(arena, str);
         return (MemorySegment) SysAllocString.invokeExact(wideStr);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java` around
lines 46 - 53, The method BStrFFM.fromString currently relies on an exception
path when str is null; add an explicit null-guard at the start of fromString
that returns MemorySegment.NULL if str == null, and only call
toWideString(arena, str) and SysAllocString.invokeExact(...) for non-null input
to avoid exception-driven flow and unnecessary overhead.
oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java (1)

48-60: Add explicit vtable slot bounds checking.

getVtableFunction currently trusts the caller index. Adding a shared slot constant and validating index will fail fast and prevent accidental out-of-range native reads as interfaces evolve.

🛡️ Proposed defensive update
 public class ComObjectFFM extends IUnknownFFM {
+    private static final int VTABLE_SLOTS = 32;
@@
-        return vtablePtr.reinterpret(PTR_SIZE * 32, arena, null);
+        return vtablePtr.reinterpret(PTR_SIZE * VTABLE_SLOTS, arena, null);
@@
     protected static MemorySegment getVtableFunction(MemorySegment vtable, int index) {
+        if (index < 0 || index >= VTABLE_SLOTS) {
+            throw new IndexOutOfBoundsException("Invalid COM vtable index: " + index);
+        }
         return vtable.get(ADDRESS, (long) index * PTR_SIZE);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java` around
lines 48 - 60, Add explicit vtable slot bounds checking in getVtableFunction:
declare a shared constant (e.g., VTABLE_SLOTS = 32) matching the reinterpret
call and validate that index is >= 0 and < VTABLE_SLOTS; if out of range, throw
an IndexOutOfBoundsException or IllegalArgumentException with a clear message,
otherwise return the existing vtable.get(ADDRESS, (long) index * PTR_SIZE). This
makes getVtableFunction defensive against accidental out-of-range native reads
as interfaces evolve.
config/checkstyle-suppressions.xml (1)

28-28: Scope the ParameterName suppression more narrowly.

Line 28 suppresses parameter naming for the entire ffm tree. This makes sense for native-mapped methods, but it can also mask accidental naming regressions in regular Java helper code under ffm. Consider narrowing the pattern to binding-heavy files/classes only.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/checkstyle-suppressions.xml` at line 28, The suppression currently
targets the whole ffm tree via the rule <suppress checks="ParameterName"
files="[\\/]ffm[\\/].*"/>, which is too broad; narrow the files pattern to only
binding/native-related sources (e.g., directories or class name patterns like
bindings, native, jni, *Binding, *Native) so ordinary helper classes still get
ParameterName checks. Update the files attribute to a more specific regex (for
example target ffm/bindings, ffm/native, or class names containing
Binding/Native) and keep the same checks="ParameterName" entry so only
binding-heavy files are exempt.
oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java (1)

71-76: Minor inconsistency: mixed usage of qualified and statically imported ValueLayout constants.

Lines 72 and 75 still use ValueLayout.JAVA_BYTE while the rest of the struct layouts now use statically imported JAVA_INT and ADDRESS. Consider importing JAVA_BYTE statically (already done at line 17) and using it consistently here for uniformity.

Suggested fix
     public static final StructLayout FIXED_INFO_LAYOUT = structLayout(
-            sequenceLayout(132, ValueLayout.JAVA_BYTE).withName("HostName"),
-            sequenceLayout(132, ValueLayout.JAVA_BYTE).withName("DomainName"), ADDRESS.withName("CurrentDnsServer"),
+            sequenceLayout(132, JAVA_BYTE).withName("HostName"),
+            sequenceLayout(132, JAVA_BYTE).withName("DomainName"), ADDRESS.withName("CurrentDnsServer"),
             IP_ADDR_STRING_LAYOUT.withName("DnsServerList"), JAVA_INT.withName("NodeType"),
-            sequenceLayout(260, ValueLayout.JAVA_BYTE).withName("ScopeId"), JAVA_INT.withName("EnableRouting"),
-            ValueLayout.JAVA_INT.withName("EnableProxy"), JAVA_INT.withName("EnableDns"));
+            sequenceLayout(260, JAVA_BYTE).withName("ScopeId"), JAVA_INT.withName("EnableRouting"),
+            JAVA_INT.withName("EnableProxy"), JAVA_INT.withName("EnableDns"));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java` around
lines 71 - 76, The FIXED_INFO_LAYOUT declaration mixes qualified
ValueLayout.JAVA_BYTE with statically imported constants; update the two
occurrences of ValueLayout.JAVA_BYTE inside the sequenceLayout calls for
"HostName" and "ScopeId" to use the statically imported JAVA_BYTE instead so the
code consistently uses statically imported layout constants (refer to
FIXED_INFO_LAYOUT, sequenceLayout("HostName"), sequenceLayout("ScopeId")).
oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java (1)

120-137: Consider escaping quotes in nameToMatch for WQL safety.

If nameToMatch contains a double-quote character, the WQL query would be malformed. While this value appears to come from internal code (drive letters like "C:"), consider escaping or validating it for robustness.

💡 Suggested defensive fix
         if (nameToMatch != null) {
             whereClause.append(hasWhere ? " AND" : " WHERE");
-            whereClause.append(" Name=\"").append(nameToMatch).append("\"");
+            whereClause.append(" Name=\"").append(nameToMatch.replace("\"", "\\\"")).append("\"");
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java`
around lines 120 - 137, The where-clause builder in queryLogicalDisk can produce
malformed WQL if nameToMatch contains a double-quote; sanitize or validate
nameToMatch before appending it. In queryLogicalDisk, before appending
Name="...", either escape double quotes in nameToMatch (e.g., replace any " with
an escaped representation appropriate for WQL) or validate/reject unexpected
input (e.g., enforce a drive-letter or expected pattern), then use the sanitized
value when calling
WmiQueryHandlerFFM.createInstance().queryWMI(WIN32_LOGICAL_DISK, ... ,
LogicalDiskInfo::new, Win32LogicalDiskFFM::populateLogicalDiskInfo).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Line 15: The changelog entry contains nonstandard capitalization: replace the
phrase "windows ffm" with "Windows FFM" in the changelog line that reads "*
[`#3014`](https://github.com/oshi/oshi/pull/3014): Implement COM, WMI, PDH and
FileSystem in windows ffm - [`@rohan-coder02`](https://github.com/rohan-coder02)."
so it reads "... in Windows FFM ..." to match project-standard product
capitalization.

In `@oshi-core-java11/src/main/java/module-info.java`:
- Around line 10-17: The module descriptor for java25 must export the same
public packages as java11 to avoid a split API; update the module-info.java in
the java25 artifact to add exports for oshi.util.platform.unix.freebsd,
oshi.util.platform.unix.openbsd, and oshi.util.platform.unix.solaris so the
module exports mirror the java11 module-info (ensure the lines exporting
oshi.util.gpu, oshi.util.platform.linux, oshi.util.platform.mac,
oshi.util.platform.windows and oshi.util.tuples remain unchanged and that the
three missing exports are added exactly as package names to the exports list).

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IUnknownFFM.java`:
- Around line 21-24: The class Javadoc for IUnknownFFM incorrectly claims it
implements QueryInterface, AddRef, and Release; update the comment to accurately
describe implemented helpers (only AddRef and Release) or explicitly note that
QueryInterface is not implemented here. Edit the class-level JavaDoc in
IUnknownFFM to remove or reword the reference to QueryInterface and state that
this utility provides helpers for AddRef and Release vtable slots (and that
QueryInterface is handled elsewhere if applicable), so the documentation matches
the actual implemented methods.

In
`@oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java`:
- Around line 91-93: The constructor in WindowsFileSystemFFM calls
Kernel32FFM.SetErrorMode(SEM_FAILCRITICALERRORS) but discards the previous mode,
permanently changing the process-wide setting; modify WindowsFileSystemFFM to
capture and store the return value of Kernel32FFM.SetErrorMode into a private
field (e.g., previousErrorMode) and provide a deterministic way to restore it
(for example a close()/shutdown() method that calls
SetErrorMode(previousErrorMode) or restore in a finalizer/try-with-resources
pattern), or alternatively add clear Javadoc on the constructor indicating the
intentional global side-effect if you choose not to restore; reference the
constructor, Kernel32FFM.SetErrorMode, and SEM_FAILCRITICALERRORS when making
the change.

In `@oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java`:
- Around line 87-89: The finally block currently calls PdhCloseQuery(query)
directly which can throw and mask any exception from the try body; change the
finally to call PdhCloseQuery(query) inside its own try-catch that catches
Throwable, and if there was an earlier primary exception (capture it from the
try block into a local Throwable primary = null) then call
primary.addSuppressed(closeThrowable), otherwise handle or rethrow/log the
closeThrowable appropriately; reference the existing PdhCloseQuery(query) call
and the local variable query when making this change.

---

Outside diff comments:
In `@oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java`:
- Around line 193-203: The field securityInitialized is accessed without
synchronization in initCOM() via isSecurityInitialized() and later written to at
the end of that method, creating a race with synchronized methods
getComThreading() and switchComThreadingFrom(); make the access safe by
declaring the securityInitialized field as volatile (or alternatively
synchronize both the isSecurityInitialized() getter and the write at the end of
initCOM()), ensuring threads see the updated value when initCOM(),
getComThreading(), or switchComThreadingFrom() are invoked concurrently.

---

Duplicate comments:
In
`@oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java`:
- Around line 67-72: createInstance() currently returns a new WmiQueryHandlerFFM
each call, losing learned COM threading model, failed-class caching, and
timeouts; add a private static volatile WmiQueryHandlerFFM defaultInstance (or
similar) and modify createInstance() to return that cached instance when
customClass is null (instantiate and assign it on first call). Use simple
synchronization or double-checked locking when initializing defaultInstance to
ensure thread-safety, and ensure setWmiTimeout(), failed-class caches, and any
learned state live on that shared defaultInstance rather than on ephemeral
instances.
- Around line 123-124: The code currently short-circuits queries by permanently
adding wmiClassName to failedWmiClassNames in WmiQueryHandlerFFM, which
suppresses all future queries after a transient ExecQuery/namespace failure;
change this to a TTL/backoff mechanism instead: replace the permanent Set
failedWmiClassNames with a Map<String,FailureInfo> (e.g., timestamp and/or retry
count), check the map entry age before short-circuiting in the place using
failedWmiClassNames, and when catching failures in the ExecQuery path (where the
code currently adds the class) record the failure timestamp/increment count;
importantly, on a successful query remove or reset the FailureInfo for that
wmiClassName so subsequent successful queries are allowed.

---

Nitpick comments:
In `@config/checkstyle-suppressions.xml`:
- Line 28: The suppression currently targets the whole ffm tree via the rule
<suppress checks="ParameterName" files="[\\/]ffm[\\/].*"/>, which is too broad;
narrow the files pattern to only binding/native-related sources (e.g.,
directories or class name patterns like bindings, native, jni, *Binding,
*Native) so ordinary helper classes still get ParameterName checks. Update the
files attribute to a more specific regex (for example target ffm/bindings,
ffm/native, or class names containing Binding/Native) and keep the same
checks="ParameterName" entry so only binding-heavy files are exempt.

In
`@oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java`:
- Around line 120-137: The where-clause builder in queryLogicalDisk can produce
malformed WQL if nameToMatch contains a double-quote; sanitize or validate
nameToMatch before appending it. In queryLogicalDisk, before appending
Name="...", either escape double quotes in nameToMatch (e.g., replace any " with
an escaped representation appropriate for WQL) or validate/reject unexpected
input (e.g., enforce a drive-letter or expected pattern), then use the sanitized
value when calling
WmiQueryHandlerFFM.createInstance().queryWMI(WIN32_LOGICAL_DISK, ... ,
LogicalDiskInfo::new, Win32LogicalDiskFFM::populateLogicalDiskInfo).

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java`:
- Around line 46-53: The method BStrFFM.fromString currently relies on an
exception path when str is null; add an explicit null-guard at the start of
fromString that returns MemorySegment.NULL if str == null, and only call
toWideString(arena, str) and SysAllocString.invokeExact(...) for non-null input
to avoid exception-driven flow and unnecessary overhead.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java`:
- Around line 48-60: Add explicit vtable slot bounds checking in
getVtableFunction: declare a shared constant (e.g., VTABLE_SLOTS = 32) matching
the reinterpret call and validate that index is >= 0 and < VTABLE_SLOTS; if out
of range, throw an IndexOutOfBoundsException or IllegalArgumentException with a
clear message, otherwise return the existing vtable.get(ADDRESS, (long) index *
PTR_SIZE). This makes getVtableFunction defensive against accidental
out-of-range native reads as interfaces evolve.

In `@oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java`:
- Around line 71-76: The FIXED_INFO_LAYOUT declaration mixes qualified
ValueLayout.JAVA_BYTE with statically imported constants; update the two
occurrences of ValueLayout.JAVA_BYTE inside the sequenceLayout calls for
"HostName" and "ScopeId" to use the statically imported JAVA_BYTE instead so the
code consistently uses statically imported layout constants (refer to
FIXED_INFO_LAYOUT, sequenceLayout("HostName"), sequenceLayout("ScopeId")).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ca988ceb-2f51-43cc-915f-1ec7ad9ce88f

📥 Commits

Reviewing files that changed from the base of the PR and between 1fc525d and 5f842a2.

📒 Files selected for processing (27)
  • CHANGELOG.md
  • config/checkstyle-suppressions.xml
  • oshi-core-java11/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/module-info.java
  • oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/ComObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/FfmComException.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IEnumWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IUnknownFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/WbemcliFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/package-info.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOSFileStoreFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java
  • oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (23)
oshi-core-java25/src/main/java/module-info.java (1)

10-14: LGTM — export additions align with the new utility surface.

The new exports are consistent with the added platform/utility APIs introduced in this PR.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/FfmComException.java (1)

10-23: Clean exception wrapper for HRESULT propagation.

Class design is clear: preserves the HRESULT and keeps call sites concise.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/package-info.java (1)

5-10: Good package-level documentation.

The Javadoc is concise and accurately describes the COM/WMI FFM scope of this package.

oshi-core-java25/src/main/java/oshi/ffm/windows/PdhFFM.java (1)

1-73: LGTM!

The PDH FFM bindings are well-structured. The struct layouts correctly account for alignment (4-byte padding before the union) and the function descriptors match the Windows PDH API signatures.

oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java (1)

263-276: LGTM - clean solution to the TOCTOU race condition.

The switchComThreadingFrom(int expected) method correctly implements compare-and-swap semantics to prevent multiple threads from toggling the threading model back and forth when they concurrently observe the same value and fail initialization.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/VariantFFM.java (1)

1-233: LGTM!

The VARIANT FFM bindings are well-implemented:

  • Correct 24-byte layout for 64-bit Windows
  • Proper use of JAVA_FLOAT for getFloatVal() (past issue addressed)
  • Defensive null handling in clear() to avoid undefined behavior with VariantClear
  • All accessor methods properly read from DATA_OFFSET
oshi-core-java25/src/main/java/oshi/ffm/windows/com/WbemcliFFM.java (1)

1-107: LGTM!

The WMI constants are well-organized and comprehensive. The vtable indices correctly follow COM convention (IUnknown methods 0-2, interface-specific methods starting at 3+).

oshi-core-java25/src/main/java/oshi/ffm/windows/com/IEnumWbemClassObjectFFM.java (1)

1-133: LGTM!

The IEnumWbemClassObject FFM bindings are well-implemented:

  • Proper null/NULL validation before vtable access
  • Safe handling of puReturned before accessing apObjects
  • NextResult record provides clean API with hasObject() and isComplete() helpers
  • Exception handling returns appropriate failure results
  • Note: The long in the native signature (line 35) refers to Windows long which is 32-bit, correctly mapped to JAVA_INT
oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemClassObjectFFM.java (1)

1-239: LGTM!

The IWbemClassObject FFM bindings are well-implemented with all past review issues addressed:

  • VariantFFM.clear() is always called in finally blocks to prevent native memory leaks
  • cimType is only read on successful HRESULT, defaulting to CIM_ILLEGAL on failure
  • Sign-extension is preserved for signed types (VT_I2, VT_I1) and zero-extension applied for unsigned (VT_UI2, VT_UI1)
  • getLong() correctly distinguishes CIM_SINT64 vs CIM_UINT64 when parsing BSTR values
  • Defensive null handling throughout
oshi-core-java25/src/main/java/oshi/ffm/windows/Kernel32FFM.java (2)

30-71: LGTM: INVALID_HANDLE_VALUE handling and FindFirstVolume implementation.

The INVALID_HANDLE_VALUE constant and isInvalidHandle() helper correctly handle the Windows API failure case where -1L is returned instead of NULL. The FindFirstVolume wrapper now properly validates the handle before returning it.


196-254: LGTM: Volume and disk space API wrappers.

The new FFM bindings for GetDiskFreeSpaceExW, GetDriveTypeW, GetVolumeInformationW, and GetVolumePathNamesForVolumeNameW are correctly implemented with proper error handling via OptionalInt returns and debug logging.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/Ole32FFM.java (2)

197-215: LGTM: HRESULT success/failure helpers.

The succeeded() and failed() methods correctly implement the standard Windows HRESULT semantics where non-negative values indicate success and negative values indicate failure.


91-103: No issue here. The downcall helper in ForeignFunctions.java (line 80) is explicitly designed to accept null for the return type and automatically converts it to FunctionDescriptor.ofVoid(argLayouts). This is the correct and intended pattern for void-returning functions in this codebase, so the CoUninitialize declaration is correct as written.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemServicesFFM.java (1)

64-100: LGTM: BSTR cleanup properly handled in finally block.

The execQuery method correctly initializes BSTR segments to NULL before the try block and frees them in the finally block, preventing memory leaks even when exceptions occur. The WMI query execution logic is well-structured with proper error handling.

oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java (2)

111-114: LGTM: FileSystem integration added with proper override.

The getFileSystem() method correctly returns the new FFM-based WindowsFileSystemFFM implementation with the @Override annotation.


131-157: LGTM: Performance info field extraction refactored cleanly.

The shared getPerformanceInfoField(String fieldName) helper reduces code duplication between getProcessCount() and getThreadCount(). The dynamic field offset calculation using MemoryLayout.PathElement.groupElement(fieldName) is correct for the PERFORMANCE_INFORMATION struct layout.

oshi-core-java25/src/main/java/oshi/driver/windows/wmi/Win32LogicalDiskFFM.java (1)

146-156: LGTM: WMI property extraction is well-structured.

The populateLogicalDiskInfo method correctly extracts all relevant properties from the WMI object using the appropriate type-specific getters (getInt, getString, getLong). The method handles the arena lifecycle correctly as the COM object is valid during the callback.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/GuidFFM.java (2)

27-61: LGTM: GUID structure layout and creation methods.

The LAYOUT correctly defines the 16-byte Windows GUID structure. The create() methods properly validate the data4 array length and write components at correct offsets. The convenience overload with all-int parameters provides a cleaner API for specifying GUIDs.


87-117: LGTM: Well-known GUID factory methods.

The CLSID_WbemLocator, IID_IWbemLocator, and IID_IUnknown factory methods correctly encode the standard Windows GUIDs needed for WMI COM operations.

oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (2)

142-224: LGTM: Local volume enumeration with proper error handling.

The getLocalVolumes method correctly:

  • Uses FindFirstVolume/FindNextVolume/FindVolumeClose pattern with proper cleanup in finally
  • Handles ERROR_MORE_DATA (0x7A) by reallocating and retrying GetVolumePathNamesForVolumeName
  • Reads disk space values using JAVA_LONG for correct 64-bit handling
  • Skips volumes when API calls fail rather than crashing

261-297: LGTM: WMI volume retrieval implementation.

The getWmiVolumes method correctly handles both local and network drives, using GetVolumeNameForVolumeMountPoint for local drives and parsing ProviderName for network drives. The drive type handling and OSFileStore construction are well-implemented.

oshi-core-java25/src/main/java/oshi/ffm/windows/com/IWbemLocatorFFM.java (2)

39-47: LGTM: IWbemLocator creation via CoCreateInstance.

The create method correctly obtains the WMI locator by calling CoCreateInstance with the proper CLSID and IID, returning Optional.empty() on failure.


60-116: LGTM: ConnectServer implementation with proper cleanup.

The connectServer method correctly:

  • Uses JAVA_INT for lSecurityFlags (matching Windows COM ABI)
  • Initializes bstrNamespace to null before the try block
  • Frees the BSTR in the finally block to prevent memory leaks
  • Handles all failure paths with proper logging

Comment thread CHANGELOG.md Resolved
@dbwiddis dbwiddis changed the title Implement COM, WMI, PDH and FileSystem in windows ffm Implement COM, WMI, PDH and FileSystem in Windows FFM Mar 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java (1)

244-276: ⚠️ Potential issue | 🟠 Major

The class is still not thread-safe.

These synchronized comThreading accessors fix the toggle race, but failedWmiClassNames is still a plain HashSet mutated from queryWMI() with no coordination. Concurrent callers can race on that cache, so @ThreadSafe remains inaccurate unless this set is also protected.

🔧 Suggested change
-import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
-    private final Set<String> failedWmiClassNames = new HashSet<>();
+    private final Set<String> failedWmiClassNames = ConcurrentHashMap.newKeySet();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java`
around lines 244 - 276, The HashSet failedWmiClassNames is mutated from
queryWMI() without synchronization, causing races; make it thread-safe by
replacing the plain HashSet with a concurrent set or by synchronizing all
accesses to it (reads/writes) using the same monitor used for comThreading
(i.e., the instance lock via synchronized methods) — update the field
failedWmiClassNames and its usages in queryWMI(), any getters, and where
elements are added/checked to use ConcurrentHashMap.newKeySet() or
Collections.synchronizedSet(...) or wrap those blocks in synchronized(this) so
modifications are atomic and the class can be correctly marked `@ThreadSafe`.
🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java (1)

52-52: Model COM security state at process scope.

CoInitializeSecurity is process-wide, but securityInitialized is still per-handler. Any new WmiQueryHandler starts at false and will re-enter the RPC_E_TOO_LATE path, so this flag is not actually tracking the lifetime it represents.

♻️ Suggested change
-    private volatile boolean securityInitialized = false;
+    private static volatile boolean securityInitialized = false;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java` at
line 52, The securityInitialized flag in WmiQueryHandler models process-wide COM
security but is declared per-instance; change securityInitialized to a
process-scoped construct (e.g., make it static or replace with a static
AtomicBoolean) so CoInitializeSecurity is only considered initialized once for
the process, and update any places that read/write securityInitialized
(references in WmiQueryHandler) to use the new static variable with proper
thread-safe checks to avoid re-entering the RPC_E_TOO_LATE path and race
conditions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@oshi-core-java25/src/main/java/oshi/ffm/windows/com/IUnknownFFM.java`:
- Around line 47-59: The addRef method must not mask interop failures by
returning 0; instead, when the MethodHandle invocation or vtable lookup fails,
rethrow a runtime exception so callers can distinguish errors from a legitimate
zero return. Modify IUnknownFFM.addRef to keep the initial null/NULL guard but
remove the catch that returns 0; catch Throwable/Exception only to wrap and
rethrow (e.g., IllegalStateException or RuntimeException with the original
throwable as cause and a clear message like "IUnknownFFM.addRef failed"). Apply
the same change pattern to the symmetric release method (IUnknownFFM.release) so
both preserve COM semantics and propagate real failures.

---

Outside diff comments:
In `@oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java`:
- Around line 244-276: The HashSet failedWmiClassNames is mutated from
queryWMI() without synchronization, causing races; make it thread-safe by
replacing the plain HashSet with a concurrent set or by synchronizing all
accesses to it (reads/writes) using the same monitor used for comThreading
(i.e., the instance lock via synchronized methods) — update the field
failedWmiClassNames and its usages in queryWMI(), any getters, and where
elements are added/checked to use ConcurrentHashMap.newKeySet() or
Collections.synchronizedSet(...) or wrap those blocks in synchronized(this) so
modifications are atomic and the class can be correctly marked `@ThreadSafe`.

---

Nitpick comments:
In `@oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java`:
- Line 52: The securityInitialized flag in WmiQueryHandler models process-wide
COM security but is declared per-instance; change securityInitialized to a
process-scoped construct (e.g., make it static or replace with a static
AtomicBoolean) so CoInitializeSecurity is only considered initialized once for
the process, and update any places that read/write securityInitialized
(references in WmiQueryHandler) to use the new static variable with proper
thread-safe checks to avoid re-entering the RPC_E_TOO_LATE path and race
conditions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40d94db9-58c3-46d8-824d-ca45f7e90395

📥 Commits

Reviewing files that changed from the base of the PR and between 5f842a2 and ae0d576.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/IUnknownFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core/src/main/java/oshi/util/platform/windows/WmiQueryHandler.java
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • oshi-core-java25/src/main/java/oshi/ffm/windows/com/BStrFFM.java
  • oshi-core-java25/src/main/java/oshi/ffm/windows/IPHlpAPIFFM.java
  • oshi-core-java25/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
oshi-core-java25/src/main/java/oshi/ffm/windows/com/IUnknownFFM.java (1)

20-25: Javadoc now correctly scopes IUnknown helpers.

Nice fix: the class docs now accurately describe AddRef/Release support and explicitly note QueryInterface is not implemented here.

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.

2 participants