I saw these two functions while reading the book today, but I didn't care about them yet. I thought they were the same and they should have the same functions. Later, I thought about the same thing. I got two more functions, so I checked them and found that the differences between the two functions are quite big.
First, let's look at the prototype of the two functions:
Ntstatus <br/> iocalldriver (<br/> In pdevice_object deviceobject, <br/> In out pirp <br/> ); <br/> ntstatus <br/> pocalldriver (<br/> In pdevice_object deviceobject, <br/> In out pirp <br/> );
All functions except function names are the same. The parameters are two. One is the pointer of the device object, and the other is the pointer of the IRP request object. The same is true for returned values. So what is the difference?
Let's take a look at the explanation on wdk documentation:
TheIocalldriver
Routine sends an IRP to the driver associated with
Specified device object.
ThePocalldriver
Routine passes a power IRP
To
Next-lower driver in the device stack. (Windows Server 2003, Windows XP, and
Windows 2000 only .)
From the above two sentences, we can see that the iocalldriver function sends an IRP request to the driver object of the deviceobject device object; the pocalldriver function transmits a request with the main function number irp_mj_power to the underlying device in the device stack, and is limited to a specific OS.
Moreover, before calling iocalldriver, the main driver must create an I/O stack location in the IRP for the target driver, the iocalldriver function also helps the driver to assign the deviceobject value of the input parameter to the deviceobject member in the io_stack_location structure.