Why do many device drivers have an IoCompleteRequest(irp,IO_NO_INCREMENT);
at the end of the dispatch routines? I read the corresponding Microsoft docs for the IoCompleteRequest
function, but I didn't understand very well those concepts.
First, you need to understand the lifecycle of an IRP. How the IRP is created (IoAllocateIrp), delivered (IoCallDriver), and released (IoFreeIrp) after work is done. Second, if necessary, when post-processing is required at the end of the operation, the processing of the I/O completion routine is also handled in the driver hierarchical manner. IoCompleteRequest does the job of ensuring these two things.