IRP and Io_stack_location_ Drive development

Source: Internet
Author: User

When an application invokes a function to manipulate a device, such as calling Createfile,deviceiocontrol, and so on, the I/O Manager creates an IRP data structure object and an array of irp_stack_location data structure objects for this function.

(The number of arrays equals the number of drivers on the driver stack). The data members in the IRP object are already populated, and one of the currentlocation is the index of the current irp_stack_location stack unit, Tail.Overlay.CurrentStackLocation

Is the pointer to the current irp_stack_location cell.

At first, it is of course the first element that points to the irp_stack_location array.

When this invokes the distribution function of a driver, the IRP passes it as a parameter to the distribution function, so that the function can access the Tail.Overlay.CurrentStackLocation in the IRP so that it can access the Irp_stack_location's

Members (of course we don't need to do this directly, but call iogetcurrentstacklocation to implement). Because the OS does not initialize each of the objects in the Irp_stack_location array for us, the irp_stack_location that initializes the next level of drive is completed by its upper layer drive. To initialize them, you first have to find them by calling Iogetnextstacklocation (which internally implements just currentstacklocation++) and getting the next irp_stack_location

The object pointer. It is then assigned a value. Then call IoCallDriver ().

The key points of understanding are:

An OS generates a irp,ipr_stack_location array for us, note that it is a number of groups. The currentstacklocation in the IRP points to an element in the irp_stack_location.

The two OS does not populate the Irp_stack_location array for us, and each element is populated by the upper-level driver.

Three irp_stack_location arrays, with no pointer contact between their elements.

The four OS is only responsible for the IRP package to the top-level driver, as to how to the lower level, is the driver of their own things. So the lower-level pair of those irp_stack_location, completely by the upper drive function is responsible for padding, OS regardless.

How does a driver fill a layer of irp_stack_location that needs to be driven?

can be obtained by calling the Iogetnextirpstacklocation call. In fact the function inside is to return currentstacklocation plus 1 just. The array value plus 1, of course, is to get the next value of the list.

That way, you can assign it to a value. Then call IoCallDriver (), IoCallDriver () adds the Currentstacklocation value in the IRP package to 1, and then calls that driver.

If the next level of drive requires the same irp_stack_location as the layer-driven, you can call ioskipcurrentirpstacklocation or Iocopycurrentirpstacklocationtonext directly .

Ioskipcurrentirpstacklocation will currentstacklocation minus 1. is exactly the same as the IoCallDriver plus 1 offset. So the same irp_stack_locatin element is the same as the lower drive and the layer driver.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.