Repository navigation
Dropped requirement for elevation on input report wait event - #431
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRefactors HID input-report wait handling from driver-duplicated handles to per-device named auto-reset events; SDK now opens per-slot named events directly and caches them, driver creates deterministic per-slot event names and exposes no handle-duplication IPC path. Changes
Sequence Diagram(s)sequenceDiagram
participant SDK as SDK Process
participant Shared as Shared Memory
participant Driver as Kernel Driver
SDK->>Driver: Open device / discover slot index
Driver-->>SDK: Slot available + HID buffer name (shared memory)
Driver->>Driver: Create named auto-reset event "PREFIX<slot>"
SDK->>Driver: (no longer requests duplicated handle)
SDK->>Driver: OpenExisting("PREFIX<slot>") -> EventWaitHandle cached
SDK->>Shared: Read initial HID buffer pointer
SDK->>SDK: WaitOne(timeout) on per-slot EventWaitHandle
Driver->>Shared: Write new HID report into shared memory
Driver->>Driver: SetEvent("PREFIX<slot>")
SDK->>SDK: WaitOne returns -> read report from Shared Memory
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
SDK/Nefarius.DsHidMini.IPC/DsHidMiniInterop.cs (1)
233-249: Consider documenting the exception behavior.
EventWaitHandle.OpenExistingthrowsWaitHandleCannotBeOpenedExceptionif the named event doesn't exist (e.g., device slot is empty). While the caller inDsHidMiniInterop.Commands.cshandles this, the XML doc comment should mention this for maintainability.📝 Suggested documentation update
/// <summary> /// Opens the driver's named auto-reset event for the given one-based device slot (created with DACL allowing /// authenticated users). /// </summary> + /// <exception cref="WaitHandleCannotBeOpenedException"> + /// The named event does not exist (device slot may be empty or driver unavailable). + /// </exception> private EventWaitHandle GetOrOpenHidReportWaitEvent(int deviceIndex)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@SDK/Nefarius.DsHidMini.IPC/DsHidMiniInterop.cs` around lines 233 - 249, Update the XML documentation for GetOrOpenHidReportWaitEvent to explicitly state that EventWaitHandle.OpenExisting may throw WaitHandleCannotBeOpenedException when the named event does not exist (for example when a device slot is empty), and note that callers are expected to handle this exception (as done in DsHidMiniInterop.Commands.cs); reference the method name GetOrOpenHidReportWaitEvent and the exception type WaitHandleCannotBeOpenedException in the summary/remarks to improve maintainability.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@SDK/Nefarius.DsHidMini.IPC/DsHidMiniInterop.cs`:
- Line 45: The _inputReportWaitEvents dictionary is accessed concurrently by
device notification handlers (DsHidMiniDeviceRemoved, DsHidMiniDeviceArrived →
RefreshDevices() → DisposeInputReportWaitEvents()) and client code
(GetOrOpenHidReportWaitEvent()), causing a race and possible
InvalidOperationException; fix by replacing the Dictionary<int, EventWaitHandle>
_inputReportWaitEvents with a ConcurrentDictionary<int, EventWaitHandle> or
protect all accesses (reads, writes, iteration/clear) to _inputReportWaitEvents
with a single lock object so DisposeInputReportWaitEvents and
GetOrOpenHidReportWaitEvent use the same synchronization mechanism to avoid
concurrent enumeration/modification.
---
Nitpick comments:
In `@SDK/Nefarius.DsHidMini.IPC/DsHidMiniInterop.cs`:
- Around line 233-249: Update the XML documentation for
GetOrOpenHidReportWaitEvent to explicitly state that
EventWaitHandle.OpenExisting may throw WaitHandleCannotBeOpenedException when
the named event does not exist (for example when a device slot is empty), and
note that callers are expected to handle this exception (as done in
DsHidMiniInterop.Commands.cs); reference the method name
GetOrOpenHidReportWaitEvent and the exception type
WaitHandleCannotBeOpenedException in the summary/remarks to improve
maintainability.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 100f64e7-cd73-40de-895d-77c8916e9133
📒 Files selected for processing (14)
SDK/Nefarius.DsHidMini.IPC/DsHidMiniInterop.Commands.csSDK/Nefarius.DsHidMini.IPC/DsHidMiniInterop.csSDK/Nefarius.DsHidMini.IPC/Exceptions/Exceptions.csSDK/Nefarius.DsHidMini.IPC/Models/CmdStructs.csSDK/Nefarius.DsHidMini.IPC/Models/Enums.csSDK/Nefarius.DsHidMini.IPC/NativeMethods.txtSDK/Nefarius.DsHidMini.IPC/README.mdSDK/Nefarius.DsHidMini.IPC/docs/nefarius.dshidmini.ipc.dshidminiinterop.mddriver/Device.cdriver/Device.hdriver/Driver.hdriver/IPC.Device.cdriver/IPC.hdriver/Util.c
💤 Files with no reviewable changes (4)
- driver/Driver.h
- driver/IPC.Device.c
- driver/Device.h
- SDK/Nefarius.DsHidMini.IPC/NativeMethods.txt
Summary by CodeRabbit
Documentation
Refactor