IOCTL Driver SystemBuffer always NULL

≯℡__Kan透↙ 提交于 2019-12-11 15:59:30

问题


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);

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);
        }
    }
}

回答1:


DO_BUFFERED_IO flag should be set in DriverEntry in DeviceObject->Flags.

Thanks to user @RbMm for pointing this out.



来源:https://stackoverflow.com/questions/45780993/ioctl-driver-systembuffer-always-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!