|
这是驱动层的代码
- NTSTATUS DevIoCtrl(PDEVICE_OBJECT dev, PIRP irp )
- {
- PIO_STACK_LOCATION irpStack;
- NTSTATUS status = STATUS_SUCCESS;
- ULONG inputBufferLength;
- ULONG outputBufferLength;
- ULONG ioControlCode;
- PUCHAR buffer;
- Log log1; //我自定义的结构体
- UNREFERENCED_PARAMETER(dev);
- irpStack = IoGetCurrentIrpStackLocation(irp);
- inputBufferLength = irpStack->Parameters.DeviceIoControl.InputBufferLength;
- outputBufferLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
- buffer = irp->AssociatedIrp.SystemBuffer;
- ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
- switch(ioControlCode)
- {
- case IOCTRL_READ_DATA:
- if(outputBufferLength == sizeof(Log))
- {
- log1.a = 4;
- log1.b = 123456;
- log1.c = 456;
- log1.d = 789;
- }
- NdisMoveMemory(buffer,&log1,sizeof(Log)); //这句导致蓝屏
- break;
- }
- irp->IoStatus.Status = status;
- IoCompleteRequest(irp, IO_NO_INCREMENT);
- return status;
- }
复制代码
这是用户层的代码
- Log log;
- ULONG len,len1;
- len = sizeof(Log);
- DeviceIoControl(Handle,IOCTRL_READ_DATA,NULL,0,&log,len,&len1,NULL);
复制代码
刚开始学驱动。。找不到是什么问题 。。哪位大大帮帮我吧。。3Q了、、
|
|