描述:
初接触driverstudio ,就遇到了这样的一个问题 !(呵呵,也可能是因为初接触的原因才有这样的问题了。)
大家都知道,driverstudio 用Kirp类封装了irp 结构。我的vc 里面装了visual assist ,每次遇到 (Kirp)I. ****() 的时候,visual assist都会自动把其转化为I->****() .看了一下 driverstudio 带的帮助文件,
Instances of class KIrp can usually be used whenever a pointer to an IRP (PIRP) can be used, and vice versa. This is possible because:
The constructor for KIrp takes a single parameter, which is a PIRP. The compiler can therefore automatically convert from PIRP to KIrp.
The class provides an overloaded cast to PIRP, which simply returns the underlying PIRP data member. The compiler can therefore automatically convert from KIrp to PIRP.
The class provides an overloaded pointer to member operator ( -> ) which returns type PIRP. This means that an instance of a KIrp followed by ' -> ' behaves exactly like the underlying PIRP would.
Because KIrp has no virtual functions and a single data member (a PIRP), it can be passed efficiently as a parameter, i.e., there is rarely a need to pass a pointer to a KIrp.
No single member of KIrp is more than a few lines of code, but taken as a group, the members offer a means to significantly reduce lines of source code, and to make the driver more readable and maintainable
。。。。。
Note that the data size of KIrp is only 32 bits 。
我的英文很烂了,看的不是很明白。说的好象是 Kirp只是一个32位的数据,编译器会自动转换成 PIRP 。于是visual assist 就自动把 (Kirp)I 认为成了一个指针 。所以调用所有的 Kirp 成员都变成了 I->**** .
显然,这是错误的! (原因我不知道了,至少编译不通过.)从帮助文件得知驱动程序在传递irp的时候,出于效率的原因传递的应该是个指针,但编写代码的时候,正确的做法却把 I 作为一个类的对象, 调用 Kirp 的成员要用 I.****() .
于是,我迷惑了~~~~~~~~~~~~~ 望同辈们探讨,请前辈们指点!!!