In the driver, other drivers are often called.
IRP
, And then
IRP
The dispatch letter passed to the corresponding driver is a relatively simple method. The following describes how to manually create
IRP
Methods and Their features.
Create
IRP
Total
4
Method. By calling:
Iobuildsynchronousfsdrequest
,
Iobuildasynchronousfsdrequest
,
Iobuilddeviceiocontrol
And
Ioallocateirp
This
4
Kernel functions. Here,
Ioallocateirp
Is the underlying kernel function. The other three kernel functions belong to kernel functions near the upper layer.
Ioallocateirp
.
These functions are all documented functions.
DDK documentation
Here we will not talk about the differences between them:
1.
Can be created
IRP
Type
The four functions can be created
IRP
The types are different.
Iobuildsynchronousfsdrequest
Used to create Synchronization
IRP
Request, but only the following types
IRP
:
Irp_mj_pnp
, Irp_mj_read, irp_mj_write, irp_mj_flush_buffers
And irp_mj_shutdown
;
Iobuildasynchronousfsdrequest
Can be created
IRP
Type and
Iobuildsynchronousfsdrequest
The same (as can be seen from the name), but it is used to create an asynchronous
IRP
Request.
Iobuilddeviceiocontrol
Can be created
IRP
Type: irp_mj_device_control
And irp_mj_internal_device_control
. And
Iobuilddeviceiocontrol
Only synchronous
IRP
. All three functions have one
Ulong
Specify the created
IRP
Type.
Ioallocateirp
The function is flexible to use and can create any type
IRP
But it is not specified by the parameter, but is automatically filled in after the creation, requiring the user
IRP
Have a familiar understanding of the structure.
2.
After creation
IRP
Object Deletion
Iobuildsynchronousfsdrequest
,
Iobuildasynchronousfsdrequest
And
Iobuilddeviceiocontrol
The kernel function is being created.
IRP
The programmer is not required to delete
IRP
, The operating system will automatically delete it. Use
Ioallocateirp
Kernel Function Creation
IRP
Must be called by the programmer.
Iofreeirp
Delete kernel functions
IRP
Object.
3.
Associated events
Iobuildsynchronousfsdrequest
And
Iobuilddeviceiocontrol
In the create
IRP
You need to prepare an event for them.
IRP
Requests are associated when
IRP
This event is triggered when the request ends. Used in the program
Kewaitforsingleobject
Function wait.
Iobuildasynchronousfsdrequest
Function Creation
IRP
You do not need to prepare the event, but you can use
IRP
Of
Userevent
Subdomain notification
IRP
The end of the request.
When executed
Iocompleterequest
During kernel functions, the operating system checks
IRP
Of
Userevent
Whether the subdomain is empty. If this subdomain is empty, it indicates an event pointer.
Iocompleterequest
This event is set.