Use lower device for queries during initialization
It is more correct to use lower device in stack for queries during filter initialization. Lower device is in initialized state and can process all kinds of requests, when current one is not ready yet. Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This commit is contained in:
parent
dfd3a4a0ca
commit
d902e99a2a
3 changed files with 14 additions and 1 deletions
|
|
@ -486,7 +486,7 @@ NTSTATUS CUsbDkFilterDevice::DefineStrategy()
|
|||
return status;
|
||||
}
|
||||
|
||||
if (!m_Strategy.SelectStrategy(WdmObject()))
|
||||
if (!m_Strategy.SelectStrategy(LowerDeviceObject()))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Not attached");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
|
|
@ -525,6 +525,11 @@ NTSTATUS CUsbDkFilterDevice::Create(PWDFDEVICE_INIT DevInit)
|
|||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Failed to create device");
|
||||
return status;
|
||||
}
|
||||
if (!LowerDeviceObject())
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! No lower device, skip");
|
||||
return STATUS_INVALID_DEVICE_STATE;
|
||||
}
|
||||
|
||||
auto deviceContext = UsbDkFilterGetContext(m_Device);
|
||||
deviceContext->UsbDkFilter = this;
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ NTSTATUS CWdfDevice::Create(CPreAllocatedDeviceInit &DeviceInit, WDF_OBJECT_ATTR
|
|||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_WDFDEVICE, "%!FUNC! Device name caching failed %!STATUS!", status);
|
||||
}
|
||||
|
||||
m_LowerDeviceObj = IoGetLowerDeviceObject(WdmObject());
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +172,10 @@ void CWdfSpecificQueue::InitConfig(WDF_IO_QUEUE_CONFIG &QueueConfig)
|
|||
CWdfDevice::~CWdfDevice()
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_WDFDEVICE, "%!FUNC! Deleting device %wZ", m_CachedName);
|
||||
if (m_LowerDeviceObj)
|
||||
{
|
||||
ObDereferenceObject(m_LowerDeviceObj);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS CWdfDevice::CacheDeviceName()
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public:
|
|||
|
||||
WDFDEVICE WdfObject() const { return m_Device; }
|
||||
PDEVICE_OBJECT WdmObject() const { return WdfDeviceWdmGetDeviceObject(m_Device); };
|
||||
PDEVICE_OBJECT LowerDeviceObject() const { return m_LowerDeviceObj; }
|
||||
WDFIOTARGET IOTarget() const
|
||||
{ return WdfDeviceGetIoTarget(m_Device); }
|
||||
|
||||
|
|
@ -155,6 +156,7 @@ private:
|
|||
NTSTATUS AddQueue(WDF_IO_QUEUE_CONFIG &Config, WDF_OBJECT_ATTRIBUTES &Attributes, WDFQUEUE &Queue);
|
||||
NTSTATUS CacheDeviceName();
|
||||
CString m_CachedName;
|
||||
PDEVICE_OBJECT m_LowerDeviceObj = nullptr;
|
||||
|
||||
friend class CWdfQueue;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue