阅读:1379回复:9
为什么不能创建消息。
应用层的设置是
HANDLE hEvent; HANDLE hDevice; int length; hDevice = CreateFile(....) hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if(!DeviceIoControl(hDevice, IOCTL_SECOND_SEND_EVENT, &hEvent, sizeof(HANDLE), //input NULL, 0, //output &length, NULL)) 运行时hDevice = 0x0070 hEvent = 0x0078 驱动层的设置: typedef struct _SECOND_DEVICE_EXTENSION { PDEVICE_OBJECT fdo; PDEVICE_OBJECT NextStackDevice; UNICODE_STRING ifSymLinkName; PKEVENT pEvent; HANDLE hEvent; } SECOND_DEVICE_EXTENSION, *PSECOND_DEVICE_EXTENSION; PSECOND_DEVICE_EXTENSION pdx = (SECOND_DEVICE_EXTENSION*)fdo->DeviceExtension; HANDLE ioBuffer; ioBuffer = Irp->AssociatedIrp.SystemBuffer; switch( ControlCode) { case IOCTL_SECOND_SEND_EVENT: status = ObReferenceObjectByHandle(ioBuffer,0x0002, NULL, UserMode, (PVOID*)(&pdx->pEvent), NULL); } 为什么status的返回值老是STATUS_INVALID_HANDLE。 |
|
|
沙发#
发布于:2002-07-05 09:02
pdx->pEvent这个值是空的,
你需要把你创建的事件句宾付给他 |
|
|
板凳#
发布于:2002-07-05 09:03
怎么做呢?
|
|
|
地板#
发布于:2002-07-05 09:09
sorry,看错了
pdx->event是个输出参数 |
|
|
地下室#
发布于:2002-07-05 09:15
看看ioBuffer的值是不是你传下来的hevent
|
|
|
5楼#
发布于:2002-07-05 10:09
不是的ioBuffer = 0x000000
怎么回事? 我是在××create()中分配1024个字节的 KIRQL irql; KeAcquireSpinLock(&BufferLock,&irql); ULONG NewBufferSize = 1024; PVOID NewBuffer = ExAllocatePool(NonPagedPool,NewBufferSize); if( NewBuffer == NULL) { DebugPrint(\"Can\'t allocate memory!\"); } else { RtlZeroMemory(NewBuffer,NewBufferSize); Buffer = (PUCHAR)NewBuffer; BufferSize = NewBufferSize; } KeReleaseSpinLock(&BufferLock,irql); 在×××DeviceControl()中 PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp); NTSTATUS status = STATUS_SUCCESS; ULONG BytesTxd = 0; /*-----------------------------------*/ PSECOND_DEVICE_EXTENSION pdx = (SECOND_DEVICE_EXTENSION*) fdo->DeviceExtension; HANDLE ioBuffer; ioBuffer = Irp->AssociatedIrp.SystemBuffer; /*-------设定消息--------------------*/ ULONG ControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode; ULONG InputLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength; ULONG OutputLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength; KIRQL irql; KeAcquireSpinLock(&BufferLock,&irql); switch( ControlCode) { ...........和前面一样了。 } 什么地方不对呢? |
|
|
6楼#
发布于:2002-07-05 20:13
祝贺你,你是用我的那种方法做好的吗?
|
|
|
7楼#
发布于:2002-07-05 20:18
把你的这个
IOCTL_SECOND_SEND_EVENT 定义贴上来看看 |
|
|
8楼#
发布于:2002-07-08 09:06
用tom的方法解决了。
多谢二位高手了。 |
|
|
9楼#
发布于:2002-10-24 14:46
用tom的方法解决了。 解决了就铁出来看看嘛,强烈建议, 不少人只发帖子问问题,搞定了就不管了,这样不好吧 :) |
|