PIO_STACK_LOCATION ioStackLocation = IoGetCurrentIrpStackLocation(Irp);
ULONG code = ioStackLocation->Parameters.DeviceIoControl.IoControlCode;
ULONG inputBufferLength = ioStackLocation->Parameters.DeviceIoControl.InputBufferLength;
ULONG outputBufferLength = ioStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
PVOID inputBuffer = Irp->AssociatedIrp.SystemBuffer;
PVOID outputBuffer = Irp->AssociatedIrp.SystemBuffer;
if (Irp->MdlAddress != NULL) outputBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
// 把要传递给应用程序的数据写到outputBuffer里面,长度不可超过outputBufferLength,再把数据长度赋给Irp->IoStatus.Information。
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
|