UsbDk: Make CWdmList accessors safer
Accessor functions made private, corresponding list class specialization declared as friend. Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
2954a1c5a2
commit
52be87ee4c
3 changed files with 18 additions and 20 deletions
|
|
@ -64,11 +64,6 @@ public:
|
|||
bool operator==(const CUsbDkChildDevice &Dev) const;
|
||||
bool operator==(const CUsbDkRedirection &Other) const;
|
||||
|
||||
PLIST_ENTRY GetListEntry()
|
||||
{ return &m_ListEntry; }
|
||||
static CUsbDkRedirection *GetByListEntry(PLIST_ENTRY entry)
|
||||
{ return static_cast<CUsbDkRedirection*>(CONTAINING_RECORD(entry, CUsbDkRedirection, m_ListEntry)); }
|
||||
|
||||
void Dump() const;
|
||||
|
||||
void NotifyRedirectorCreated(ULONG RedirectorID);
|
||||
|
|
@ -89,7 +84,7 @@ private:
|
|||
CWdmEvent m_RedirectionCreated;
|
||||
ULONG m_RedirectorID = NO_REDIRECTOR;
|
||||
|
||||
LIST_ENTRY m_ListEntry;
|
||||
DECLARE_CWDMLIST_ENTRY(CUsbDkRedirection);
|
||||
};
|
||||
|
||||
class CUsbDkControlDevice : private CWdfControlDevice, public CAllocatable<NonPagedPool, 'DCHR'>
|
||||
|
|
|
|||
|
|
@ -57,11 +57,6 @@ public:
|
|||
|
||||
void Dump();
|
||||
|
||||
PLIST_ENTRY GetListEntry()
|
||||
{ return &m_ListEntry; }
|
||||
static CUsbDkChildDevice *GetByListEntry(PLIST_ENTRY entry)
|
||||
{ return static_cast<CUsbDkChildDevice*>(CONTAINING_RECORD(entry, CUsbDkChildDevice, m_ListEntry)); }
|
||||
|
||||
private:
|
||||
CObjHolder<CRegText> m_DeviceID;
|
||||
CObjHolder<CRegText> m_InstanceID;
|
||||
|
|
@ -70,12 +65,12 @@ private:
|
|||
PDEVICE_OBJECT m_PDO;
|
||||
const CUsbDkFilterDevice &m_ParentDevice;
|
||||
|
||||
LIST_ENTRY m_ListEntry;
|
||||
|
||||
bool CreateRedirectorDevice();
|
||||
|
||||
CUsbDkChildDevice(const CUsbDkChildDevice&) = delete;
|
||||
CUsbDkChildDevice& operator= (const CUsbDkChildDevice&) = delete;
|
||||
|
||||
DECLARE_CWDMLIST_ENTRY(CUsbDkChildDevice);
|
||||
};
|
||||
|
||||
class CDeviceRelations;
|
||||
|
|
@ -112,11 +107,6 @@ public:
|
|||
bool EnumerateChildrenIf(TPredicate Predicate, TFunctor Functor)
|
||||
{ return m_Strategy->Children().ForEachIf(Predicate, Functor); }
|
||||
|
||||
PLIST_ENTRY GetListEntry()
|
||||
{ return &m_ListEntry; }
|
||||
static CUsbDkFilterDevice *GetByListEntry(PLIST_ENTRY entry)
|
||||
{ return static_cast<CUsbDkFilterDevice*>(CONTAINING_RECORD(entry, CUsbDkFilterDevice, m_ListEntry)); }
|
||||
|
||||
ULONG GetChildrenCount()
|
||||
{ return m_Strategy->Children().GetCount(); }
|
||||
|
||||
|
|
@ -138,8 +128,6 @@ private:
|
|||
|
||||
WDFDRIVER m_Driver = WDF_NO_HANDLE;
|
||||
|
||||
LIST_ENTRY m_ListEntry;
|
||||
|
||||
class CStrategist
|
||||
{
|
||||
public:
|
||||
|
|
@ -161,4 +149,6 @@ private:
|
|||
|
||||
friend class CUsbDkFilterDeviceInit;
|
||||
friend class CUsbDkRedirectorQueue;
|
||||
|
||||
DECLARE_CWDMLIST_ENTRY(CUsbDkFilterDevice);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -86,6 +86,19 @@ protected:
|
|||
ULONG GetCount() { return 0; }
|
||||
};
|
||||
|
||||
#define DECLARE_CWDMLIST_ENTRY(type) \
|
||||
private: \
|
||||
PLIST_ENTRY GetListEntry() \
|
||||
{ return &m_ListEntry; } \
|
||||
\
|
||||
static type *GetByListEntry(PLIST_ENTRY entry) \
|
||||
{ return static_cast<type*>(CONTAINING_RECORD(entry, type, m_ListEntry)); } \
|
||||
\
|
||||
template<typename type, typename AnyAccess, typename AnyStrategy> \
|
||||
friend class CWdmList; \
|
||||
\
|
||||
LIST_ENTRY m_ListEntry
|
||||
|
||||
template <typename TEntryType, typename TAccessStrategy, typename TCountingStrategy>
|
||||
class CWdmList : private TAccessStrategy, public TCountingStrategy
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue