IOCTL驱动程序SystemBuffer始终为NULL [英] IOCTL Driver SystemBuffer always NULL
本文介绍了IOCTL驱动程序SystemBuffer始终为NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的结构,想传递给驱动程序。以下是该结构:
I have a simple struct which I would like to pass to my driver. Here is the struct:
typedef struct readStruct
{
...
} ReadStruct, *pRreadStruct;
这是我的用户模式应用程序:
Here is my usermode application:
DWORD dwReturn;
readStruct reader{ ... };
WriteFile(hDriver, (LPCVOID)&reader, sizeof(ReadStruct), &dwReturn, NULL);
这是我的驱动程序代码,它始终将NULL返回给readStruct。我在做什么错?
Here is my driver code, it always returns NULL to the readStruct. What am I doing wrong?
PIO_STACK_LOCATION pIoStackIrp = NULL;
pRreadStruct readStruct;
pIoStackIrp = IoGetCurrentIrpStackLocation(Irp);
DbgPrintEx(0, 0, "WriteBufferedIO\n");
if (pIoStackIrp)
{
readStruct = (pRreadStruct)Irp->AssociatedIrp.SystemBuffer;
if (readStruct)
{
// this is the place I never get into
if (readStruct->ReadSize)
{
ReadMemOutputClient(readStruct);
}
}
}
推荐答案
DO_BUFFERED_IO 标志应在 DeviceObject-> Flags 的DriverEntry中设置。
DO_BUFFERED_IO flag should be set in DriverEntry in DeviceObject->Flags.
感谢用户@ RbMm指出了这一点。
Thanks to user @RbMm for pointing this out.
这篇关于IOCTL驱动程序SystemBuffer始终为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文