阅读:1697回复:2
请问大虾,DriverUnload里如何通知线程退出,如下代码总报IRQL_NOT_LESS_OR_EQUALLARGE_INTEGER interval; HANDLE g_hThread; KEVENT gLeaveEvent; VOID ThreadProc( PVOID pPara ) { NTSTATUS status; interval.QuadPart = -(10000*1000); KeInitializeEvent(&gLeaveEvent, NotificationEvent, FALSE); while(TRUE) { status = KeWaitForSingleObject(&gLeaveEvent, Executive, KernelMode, FALSE, &interval); if( status==STATUS_SUCCESS ) { DbgPrint("gLeaveEvent is signaled\n"); break; } } } VOID DriverUnload ( IN PDRIVER_OBJECT DriverObject ) { KeSetEvent(&gLeaveEvent, IO_NO_INCREMENT, FALSE); KeWaitForSingleObject(&g_hThread, Executive, KernelMode, FALSE, NULL); } NTSTATUS DriverEntry ( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) { DriverObject->DriverUnload = DriverUnload; PsCreateSystemThread(&g_hThread, (ACCESS_MASK)0, NULL, (HANDLE)0, NULL, ThreadProc, NULL); return STATUS_SUCCESS; } |
|
沙发#
发布于:2007-04-29 21:24
KEVENT gLeaveEvent;这个变量应该放在NonPagedPool中,因为它是不允许出现PageFault的。
|
|
板凳#
发布于:2007-04-30 15:25
Re:请问大虾,DriverUnload里如何通知线程退出,如下代码总报IRQL_NOT_
放在全局就是分页内存?我是新手 |
|
|