阅读:1123回复:0
求教:KeResetEvent函数调用时出现了page fault!!
大家好,我在使用共享事件实现驱动和应用通信时,参考了pjf的以下代码:
void ppppp(PVOID event) { KeWaitForSingleObject((PKEVENT)event,Executive,UserMode,0,0); //......验证处 } ...... WCHAR wEventNameBuf[]=L\"\\\\BaseNamedObjects\\\\SharedEvent\"; UNICODE_STRING uEventName; PKEVENT pEvent; HANDLE hEvent,hThread; ...... case IOCTL_******: RtlInitUnicodeString(&uEventName,wEventNameBuf); pEvent = IoCreateNotificationEvent(&uEventName,&hEvent); KeResetEvent(pEvent); RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,&hEvent,4); PsCreateSystemThread(&hThread,THREAD_ALL_ACCESS,0,0,0,ppppp,pEvent); 应用中: if(!DeviceIoControl(hDevice,IOCTL_******,0,0,&Handle,4,&Bytes,0)) MessageBox(\"DeviceIo Error!\"); esle{ wsprintf(str,\"%x,%x,%x\",hDevice,Bytes,Handle); MessageBox(str); if(!SetEvent((HANDLE)Handle)) ...... } 可是用softice调试时在KeResetEvent(pEvent)和KeWaitForSingleObject((PKEVENT)event,Executive,UserMode,0,0)里面都出现了page fault,因为一个寄存器指向了0地址。 我是刚学驱动的,也刚学softice,所以我只能给出这些信息,希望大家帮帮忙!!谢谢!! 另外L\"\\\\BaseNamedObjects\\\\SharedEvent\"; 要改为L"\\\\BaseNamedObjects\\\\SharedEvent"; 才能编译成功,请问是什么原因呢?谢谢 |
|