阅读:1700回复:0
关于写的分发函数
下面的函数哪里错了?这个函数是写设备的,把数据写到设备,并且用KdPrint显示出来,可是在应用层调用WriteFile写数据时只显“Data : from Application”,也就是从应用层写下来的数据没有显示,是哪错了?
NTSTATUS DeviceWrite(IN PDEVICE_OBJECT pDeviceObject,IN PIRP pIrp) { NTSTATUS status=STATUS_SUCCESS; ULONG Writebyted=0; UNICODE_STRING data; PWSTR buffer; PIO_STACK_LOCATION pStack; KdPrint(("Enter WriteFunction\n")); pStack=IoGetCurrentIrpStackLocation(pIrp); Writebyted=pStack->Parameters.Write.Length; pIrp->IoStatus.Status=STATUS_SUCCESS; pIrp->IoStatus.Information=Writebyted; buffer=(PWSTR)ExAllocatePool(PagedPool,Writebyted+1); memcpy(buffer,pIrp->AssociatedIrp.SystemBuffer,Writebyted); RtlInitUnicodeString(&data,buffer); KdPrint(("Data:%wZ from Application\n",&data)); ExFreePool(buffer); IoCompleteRequest(pIrp,IO_NO_INCREMENT); return status; } |
|