UsbDk: drop unused DeviceAccess logic
This patch removes CWdfDeviceAccess class, merges CDeviceAccess with CWdmDeviceAccess and removes unused CWdmDeviceAccess code. Signed-off-by: Pavel Gurvich <pavel@daynix.com> Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
d0094f66a0
commit
eb9942e5dc
2 changed files with 13 additions and 144 deletions
|
|
@ -77,7 +77,7 @@ CWdmUSBD::~CWdmUSBD()
|
|||
}
|
||||
#endif
|
||||
|
||||
ULONG CDeviceAccess::GetAddress()
|
||||
ULONG CWdmDeviceAccess::GetAddress()
|
||||
{
|
||||
DEVICE_CAPABILITIES Capabilities;
|
||||
|
||||
|
|
@ -89,39 +89,6 @@ ULONG CDeviceAccess::GetAddress()
|
|||
return Capabilities.Address;
|
||||
}
|
||||
|
||||
PWCHAR CWdfDeviceAccess::QueryBusID(BUS_QUERY_ID_TYPE idType)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(idType);
|
||||
ASSERT(!"NOT IMPLEMENTED");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NTSTATUS CWdfDeviceAccess::QueryCapabilities(DEVICE_CAPABILITIES &Capabilities)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Capabilities);
|
||||
ASSERT(!"NOT IMPLEMENTED");
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
CMemoryBuffer *CWdfDeviceAccess::GetDeviceProperty(DEVICE_REGISTRY_PROPERTY propertyId)
|
||||
{
|
||||
PAGED_CODE();
|
||||
WDFMEMORY devProperty;
|
||||
|
||||
NTSTATUS status = WdfDeviceAllocAndQueryProperty(m_DevObj,
|
||||
propertyId,
|
||||
NonPagedPool,
|
||||
WDF_NO_OBJECT_ATTRIBUTES,
|
||||
&devProperty);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
return CMemoryBuffer::GetMemoryBuffer(devProperty);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PWCHAR CWdmDeviceAccess::QueryBusID(BUS_QUERY_ID_TYPE idType)
|
||||
{
|
||||
CIrp irp;
|
||||
|
|
@ -219,58 +186,6 @@ PWCHAR CWdmDeviceAccess::MakeNonPagedDuplicate(BUS_QUERY_ID_TYPE idType, PWCHAR
|
|||
return static_cast<PWCHAR>(newIdData);
|
||||
}
|
||||
|
||||
CMemoryBuffer *CWdmDeviceAccess::GetDeviceProperty(DEVICE_REGISTRY_PROPERTY propertyId)
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVACCESS, "%!FUNC! Entry for device 0x%p, %!devprop!", m_DevObj, propertyId);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
ULONG bytesNeeded = 0;
|
||||
auto status = IoGetDeviceProperty(m_DevObj, propertyId, 0, nullptr, &bytesNeeded);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
if (status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVACCESS,
|
||||
"%!FUNC! Property %!devprop! size for device 0x%p is %lu bytes", propertyId, m_DevObj, bytesNeeded);
|
||||
|
||||
CObjHolder<CWdmMemoryBuffer> buffer(new CWdmMemoryBuffer());
|
||||
if (buffer)
|
||||
{
|
||||
status = buffer->Create(bytesNeeded, NonPagedPool);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_DEVACCESS,
|
||||
"%!FUNC! Error %!STATUS! during memory buffer creation", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
status = IoGetDeviceProperty(m_DevObj, propertyId, static_cast<ULONG>(buffer->Size()), buffer->Ptr(), &bytesNeeded);
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_DEVACCESS,
|
||||
"%!FUNC! Error %!STATUS! while reading property for device 0x%p, %!devprop!", status, m_DevObj, propertyId);
|
||||
return buffer.detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_DEVACCESS,
|
||||
"%!FUNC! Error %!STATUS! while reading property for device 0x%p, %!devprop!", status, m_DevObj, propertyId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVACCESS,
|
||||
"%!FUNC! Empty property read for device 0x%p, %!devprop!", m_DevObj, propertyId);
|
||||
return CMemoryBuffer::GetMemoryBuffer(nullptr, 0);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NTSTATUS CWdmDeviceAccess::QueryForInterface(const GUID &guid, __out INTERFACE &intf,
|
||||
USHORT intfSize, USHORT intfVer, __in_opt PVOID intfCtx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,62 +28,8 @@
|
|||
#include "MemoryBuffer.h"
|
||||
#include "Public.h"
|
||||
|
||||
class CDeviceAccess : public CAllocatable<PagedPool, 'ADHR'>
|
||||
{
|
||||
public:
|
||||
CRegText *GetHardwareIdProperty() { return new CRegText(GetDeviceProperty(DevicePropertyHardwareID)); };
|
||||
CRegText *GetDeviceID() { return QueryBusIDWrapped<CRegSz>(BusQueryDeviceID); }
|
||||
CRegText *GetInstanceID() { return QueryBusIDWrapped<CRegSz>(BusQueryInstanceID); }
|
||||
CRegText *GetHardwareIDs() { return QueryBusIDWrapped<CRegMultiSz>(BusQueryHardwareIDs); }
|
||||
|
||||
enum : ULONG
|
||||
{
|
||||
NO_ADDRESS = (ULONG) -1
|
||||
};
|
||||
|
||||
ULONG GetAddress();
|
||||
|
||||
virtual ~CDeviceAccess()
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual CMemoryBuffer *GetDeviceProperty(DEVICE_REGISTRY_PROPERTY propertyId) = 0;
|
||||
virtual PWCHAR QueryBusID(BUS_QUERY_ID_TYPE idType) = 0;
|
||||
virtual NTSTATUS QueryCapabilities(DEVICE_CAPABILITIES &Capabilities) = 0;
|
||||
|
||||
CDeviceAccess()
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
template<typename ResT>
|
||||
ResT *QueryBusIDWrapped(BUS_QUERY_ID_TYPE idType)
|
||||
{ return new ResT(QueryBusID(idType)); }
|
||||
|
||||
};
|
||||
|
||||
class CWdfDeviceAccess : public CDeviceAccess
|
||||
{
|
||||
public:
|
||||
CWdfDeviceAccess(WDFDEVICE WdfDevice)
|
||||
: m_DevObj(WdfDevice)
|
||||
{ WdfObjectReferenceWithTag(m_DevObj, (PVOID) 'DWHR'); }
|
||||
|
||||
virtual ~CWdfDeviceAccess()
|
||||
{ WdfObjectDereferenceWithTag(m_DevObj, (PVOID) 'DWHR'); }
|
||||
|
||||
CWdfDeviceAccess(const CWdfDeviceAccess&) = delete;
|
||||
CWdfDeviceAccess& operator= (const CWdfDeviceAccess&) = delete;
|
||||
|
||||
private:
|
||||
virtual CMemoryBuffer *GetDeviceProperty(DEVICE_REGISTRY_PROPERTY propertyId) override;
|
||||
virtual PWCHAR QueryBusID(BUS_QUERY_ID_TYPE idType) override;
|
||||
virtual NTSTATUS QueryCapabilities(DEVICE_CAPABILITIES &Capabilities) override;
|
||||
|
||||
WDFDEVICE m_DevObj;
|
||||
};
|
||||
|
||||
class CWdmDeviceAccess : public CDeviceAccess
|
||||
class CWdmDeviceAccess : public CAllocatable<PagedPool, 'ADHR'>
|
||||
{
|
||||
public:
|
||||
CWdmDeviceAccess(PDEVICE_OBJECT WdmDevice)
|
||||
|
|
@ -98,13 +44,21 @@ public:
|
|||
|
||||
NTSTATUS QueryForInterface(const GUID &, __out INTERFACE &, USHORT intfSize, USHORT intfVer, __in_opt PVOID intfCtx = nullptr);
|
||||
|
||||
enum : ULONG
|
||||
{
|
||||
NO_ADDRESS = (ULONG)-1
|
||||
};
|
||||
|
||||
ULONG GetAddress();
|
||||
CRegText *GetDeviceID() { return new CRegSz(QueryBusID(BusQueryDeviceID)); }
|
||||
CRegText *GetInstanceID() { return new CRegSz(QueryBusID(BusQueryInstanceID)); }
|
||||
|
||||
protected:
|
||||
PDEVICE_OBJECT m_DevObj;
|
||||
|
||||
private:
|
||||
virtual CMemoryBuffer *GetDeviceProperty(DEVICE_REGISTRY_PROPERTY propertyId) override;
|
||||
virtual PWCHAR QueryBusID(BUS_QUERY_ID_TYPE idType) override;
|
||||
virtual NTSTATUS QueryCapabilities(DEVICE_CAPABILITIES &Capabilities) override;
|
||||
PWCHAR QueryBusID(BUS_QUERY_ID_TYPE idType);
|
||||
NTSTATUS QueryCapabilities(DEVICE_CAPABILITIES &Capabilities);
|
||||
|
||||
static PWCHAR MakeNonPagedDuplicate(BUS_QUERY_ID_TYPE idType, PWCHAR idData);
|
||||
static SIZE_T GetIdBufferLength(BUS_QUERY_ID_TYPE idType, PWCHAR idData);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue