Hi All,
I’m porting a PCI device Driver from WDM to KMDF.
The new KMDF driver can be worked well in Vista,but in XP it has problem.
It caused system crashed when run app for a period of time in XP.
[I doubt ISR rountine caused it a few days ago,later I found there are something wrong during my test,so there may be some other bug that caused it]
Our application created share event and use DeviceControl to pass the handle to driver.
[use METHOD_NEITHER method]
Then driver used ObReferenceObjectByHandle to validate the object handle.
In ISR routine,I first judge whether the interrupt is generated by our device.
If it is,set interrupt line to low,request DPC,then return TRUE.If not,return FALSE.
DPC callback for ISR called KeSetEvent to set the state of the share event object to Signaled.
If I didn’t called ObReferenceObjectByHandle in EvtIoDeviceControl,
[it caused KeSetEvent can not be implemented in EvtInterruptDpc]
App can run normally in XP.
[But this didn’t set the state of the share event,it didn’t meet our demand]
Someone encountered a similar problem with me?
Any help is appreciated.Thanks.
Best Regards
Zhou ChengJun
Related to the code below[Simplify]:
EvtIoDeviceControl:
…
WDF_REQUEST_PARAMETERS params;
WDF_REQUEST_PARAMETERS_INIT(¶ms);
WdfRequestGetParameters(Request, ¶ms );
// Access the input buffer of METHOD_NEITHER Device control IRP
hEvent = (HANDLE)params.Parameters.DeviceIoControl.Type3InputBuffer;
status = ObReferenceObjectByHandle(hEvent,GENERIC_ALL, NULL, KernelMode, &m_EventObject, m_HandleInfo);
…
EvtInterruptDpc:
…
WdfInterruptAcquireLock(Interrupt);
if(m_EventObject)
{
KeSetEvent( (KEVENT *)m_EventObject, 0, FALSE);
}
WdfInterruptReleaseLock( Interrupt );
…