Home > front end >  What is the purpose of IoCompleteRequest?
What is the purpose of IoCompleteRequest?

Time:05-07

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.

CodePudding user response:

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.

  1. Application performs an I/O request.
  2. I/O Manager (create IRP, pass to driver)
  3. Driver (IRP complete after processing the job (IoCompleteRequest))
  4. I/O Manager (Release IRP, transfer result to upper application)
  5. The application receives the I/O result.
  • Related