Enhancement idea: cancel-safe IRP queueing
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 592
- PR merge metrics
- No merged PRs in 30d
Description
Npcap currently allows all IRPs to be handled concurrently, necessitating a lot of individual spinlocks and interlocked operations. Additionally, IRPs that result in sending packets (IRP_MJ_WRITE as well as IRP_MJ_DEVICE_CONTROL with code BIOCSENDPACKETSNOSYNC) are limited to sequential processing with the WriteInProgress flag which causes writes that come in while another is processing to be rejected with STATUS_DEVICE_BUSY. Read IRPs, on the other hand, could conceivably be issued by threads on 2 separate processors which would result in captured packets being dealt to each semi-randomly, where neither one gets a sequential set of packets.
I believe we could resolve these issues by using IRP queuing so that IRPs that contend for resources are processed sequentially, and others can be processed immediately. The IoCsq* functions provide an easy-to-use cancel-safe IRP queue which would give us further benefit of allowing user code to cancel IRPs when needed. I haven't tested to confirm, but this might resolve most of the "can't stop the driver because someone is using it" issues we run into in installation.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the driver's current IRP handling, including IRP_MJ_WRITE, IRP_MJ_DEVICE_CONTROL, and the WriteInProgress path. Evaluate how the IoCsq* functions could provide cancel-safe queues for contending IRPs. Done means sequential processing where required, safe cancellation, and validation of the driver-shutdown behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- networking, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100