#define Write CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800+1, METHOD_BUFFERED, FILE_ANY_ACCESS)
应用程序
DWORD WINAPI ThreadProc(PVOID wParam)
{
for(;;)
{
WaitForSingleObject(Event,INFINITE);
MessageBox(NULL,"aaa",NULL,NULL);
}
}
Event = CreateEvent(NULL,FALSE,FALSE,NULL);
DeviceIoControl(device,
Write,
Event,
sizeof(Event),
NULL,
&dw,
NULL);
驱动
=================================
PRKEVENT Event;
HANDLE hEvent;
case Write:
hEvent = (HANDLE)Irp->AssociatedIrp.SystemBuffer;
KernelMode = Irp->RequestorMode;
status = ObReferenceObjectByHandle(hEvent,
GENERIC_ALL,
NULL,
KernelMode,
&Event,
NULL);
KeSetEvent(Event,0,FALSE);
101001101 19:35:59
#define Write CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800+1, METHOD_BUFFERED, FILE_ANY_ACCESS)
应用程序
DWORD WINAPI ThreadProc(PVOID wParam)
{
for(;;)
{
WaitForSingleObject(Event,INFINITE);
MessageBox(NULL,"aaa",NULL,NULL);
}
}
Event = CreateEvent(NULL,FALSE,FALSE,NULL);
DeviceIoControl(device,
Write,
Event,
sizeof(Event),
NULL,
&dw,
NULL);
驱动
=================================
PRKEVENT Event;
HANDLE hEvent;
case Write:
hEvent = (HANDLE)Irp->AssociatedIrp.SystemBuffer;
KernelMode = Irp->RequestorMode;
status = ObReferenceObjectByHandle(hEvent,
GENERIC_ALL,
NULL,
KernelMode,
&Event,
NULL);
KeSetEvent(Event,0,FALSE);
没有反应 不蓝 也没重起 怎么会事
DeviceIoControl中的第3参数该为&Event,
hEvent = (HANDLE)Irp->AssociatedIrp.SystemBuffer改为
hEvent = *(HANDLE*)Irp->AssociatedIrp.SystemBuffer。
这样再试试。因为DeviceIoControl是把user模式的buffer中的数据复制到kernel模式,不能传地址。