Ignore:
Timestamp:
Nov 26, 2015, 3:24:03 AM (6 years ago)
Author:
roman
Message:

Added previously not included hooks; added IFilterMapper3 hook suppors; template library related updates; added FGT to replace ROT (to access services in particular) - work in progress; fixed class enumeration hook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DirectShowSpy/FilterMapperSpy.h

    r376 r545  
    1717
    1818#include "rodshow.h"
    19 #include <..\Samples\multimedia\directshow\misc\mapper\fil_data.h>
     19#include "fil_data.h" //<..\Samples\multimedia\directshow\misc\mapper\fil_data.h>
    2020#include "Module_i.h"
    2121#include "Common.h"
     
    3131        public IDispatchImpl<IFilterMapperSpy>,
    3232        public IAMFilterData,
    33         public IFilterMapper2
     33        public IFilterMapper,
     34        public IFilterMapper3
    3435{
    3536        typedef CFilterMapperSpyT<T, t_pFilterMapperClassIdentifier> CFilterMapperSpy;
     
    4445DECLARE_GET_CONTROLLING_UNKNOWN()
    4546
    46 DECLARE_QI_TRACE(CFilterMapperSpy)
    47 
    48 BEGIN_COM_MAP(CFilterMapperSpy)
     47DECLARE_QI_TRACE(CFilterMapperSpyT)
     48
     49BEGIN_COM_MAP(CFilterMapperSpyT)
    4950        COM_INTERFACE_ENTRY(IFilterMapperSpy)
    5051        COM_INTERFACE_ENTRY(IAMFilterData)
     52        COM_INTERFACE_ENTRY(IFilterMapper3)
    5153        COM_INTERFACE_ENTRY(IFilterMapper2)
     54        COM_INTERFACE_ENTRY(IFilterMapper)
    5255        COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pInnerUnknown)
    5356        //COM_INTERFACE_ENTRY(IDispatch)
     
    5861        HINSTANCE m_hQuartzModule;
    5962        CComPtr<IUnknown> m_pInnerUnknown;
    60         CComPtr<IFilterMapper2> m_pFilterMapper2;
     63        CComPtr<IFilterMapper3> m_pFilterMapper3;
     64        CComPtr<IFilterMapper> m_pFilterMapper;
    6165        CComPtr<IAMFilterData> m_pAmFilterData;
    6266
     
    6468        {
    6569                _A(pFilterInformation);
    66                 _Z4(atlTraceCOM, 4, _T("pFilterInformation { dwVersion %d, dwMerit 0x%08x, cPins2 %d }\n"), pFilterInformation->dwVersion, pFilterInformation->dwMerit, pFilterInformation->cPins2);
     70                _Z4(atlTraceCOM, 4, _T("pFilterInformation { dwVersion %d, dwMerit 0x%08X, cPins2 %d }\n"), pFilterInformation->dwVersion, pFilterInformation->dwMerit, pFilterInformation->cPins2);
    6771                if(pFilterInformation->dwVersion == 2)
    6872                        for(ULONG nPinIndex = 0; nPinIndex < pFilterInformation->cPins2; nPinIndex++)
    6973                        {
    7074                                const REGFILTERPINS2& Pin = pFilterInformation->rgPins2[nPinIndex];
    71                                 _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[%d] { dwFlags 0x%x, cInstances %d, nMediaTypes %d, nMediums %d }\n"), nPinIndex, Pin.dwFlags, Pin.cInstances, Pin.nMediaTypes, Pin.nMediums, Pin.clsPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*Pin.clsPinCategory) : L"NULL");
     75                                _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[%d] { dwFlags 0x%X, cInstances %d, nMediaTypes %d, nMediums %d }\n"), nPinIndex, Pin.dwFlags, Pin.cInstances, Pin.nMediaTypes, Pin.nMediums, Pin.clsPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*Pin.clsPinCategory) : L"NULL");
    7276                                for(UINT nIndex = 0; nIndex < Pin.nMediaTypes; nIndex++)
    7377                                {
     
    7882                                {
    7983                                        const REGPINMEDIUM& Medium = Pin.lpMedium[nIndex];
    80                                         _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[...].lpMedium[%d] { clsMedium %ls, dw1 0x%x, dw2 0x%x }\n"), nIndex, _PersistHelper::StringFromIdentifier(Medium.clsMedium), Medium.dw1, Medium.dw2);
     84                                        _Z4(atlTraceCOM, 4, _T("pFilterInformation->rgPins2[...].lpMedium[%d] { clsMedium %ls, dw1 0x%X, dw2 0x%X }\n"), nIndex, _PersistHelper::StringFromIdentifier(Medium.clsMedium), Medium.dw1, Medium.dw2);
    8185                                }
    8286                        }
    8387        }
    84         BOOL IsAggregated() const throw()
     88        BOOL IsAggregated() const
    8589        {
    8690                return (ULONG) m_dwRef >= 0x00001000;
     
    8993public:
    9094// CFilterMapperSpyT
    91         static LPCTSTR GetOriginalLibraryName() throw()
     95        static LPCTSTR GetOriginalLibraryName()
    9296        {
    9397                return _T("quartz.dll");
     
    97101                return _StringHelper::GetLine(T::IDR, 2);
    98102        }
    99         static HRESULT WINAPI UpdateRegistry(BOOL bRegister) throw()
     103        static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
    100104        {
    101105                _Z2(atlTraceRegistrar, 2, _T("bRegister %d\n"), bRegister);
     
    110114                return S_OK;
    111115        }
    112         CFilterMapperSpyT() throw() :
     116        CFilterMapperSpyT() :
    113117                m_hQuartzModule(NULL)
    114118        {
    115119                _Z4_THIS();
    116120        }
    117         ~CFilterMapperSpyT() throw()
     121        ~CFilterMapperSpyT()
    118122        {
    119123                _Z4_THIS();
    120124        }
    121         HRESULT FinalConstruct() throw()
     125        HRESULT FinalConstruct()
    122126        {
    123127                _ATLTRY
     
    126130                        TCHAR pszPath[MAX_PATH] = { 0 };
    127131                        _W(GetModuleFileName(NULL, pszPath, DIM(pszPath)));
    128                         _Z4(atlTraceRefcount, 4, _T("pszPath \"%s\", this 0x%08x, m_dwRef %d, m_bIsAggregated %d\n"), pszPath, this, m_dwRef, m_bIsAggregated);
     132                        _Z4(atlTraceRefcount, 4, _T("pszPath \"%s\", this 0x%p, m_dwRef %d, m_bIsAggregated %d\n"), pszPath, this, m_dwRef, m_bIsAggregated);
    129133                        const HINSTANCE hModule = CoLoadLibrary(const_cast<LPOLESTR>((LPCOLESTR) CT2COLE(GetOriginalLibraryName())), TRUE);
    130134                        _ATLTRY
     
    140144                                        CComPtr<IUnknown> pUnknown;
    141145                                        __C(pClassFactory->CreateInstance(pControllingUnknown, __uuidof(IUnknown), (VOID**) &pUnknown));
    142                                         const CComQIPtr<IFilterMapper2> pFilterMapper2 = pUnknown;
    143                                         __D(pFilterMapper2, E_NOINTERFACE);
    144                                         pFilterMapper2.p->Release();
     146                                        const CComQIPtr<IFilterMapper3> pFilterMapper3 = pUnknown;
     147                                        __D(pFilterMapper3, E_NOINTERFACE);
     148                                        pFilterMapper3.p->Release();
     149                                        const CComQIPtr<IFilterMapper> pFilterMapper = pUnknown;
     150                                        __D(pFilterMapper, E_NOINTERFACE);
     151                                        pFilterMapper.p->Release();
    145152                                        const CComQIPtr<IAMFilterData> pAmFilterData = pUnknown;
    146153                                        __D(pAmFilterData, E_NOINTERFACE);
    147154                                        pAmFilterData.p->Release();
    148155                                        m_pInnerUnknown = pUnknown;
    149                                         m_pFilterMapper2 = pFilterMapper2;
     156                                        m_pFilterMapper3 = pFilterMapper3;
     157                                        m_pFilterMapper = pFilterMapper;
    150158                                        m_pAmFilterData = pAmFilterData;
    151159                                }
     
    165173                return S_OK;
    166174        }
    167         VOID FinalRelease() throw()
    168         {
    169                 _Z5(atlTraceRefcount, 5, _T("m_dwRef 0x%x\n"), m_dwRef);
     175        VOID FinalRelease()
     176        {
     177                _Z5(atlTraceRefcount, 5, _T("m_dwRef 0x%X\n"), m_dwRef);
    170178                CComPtr<IUnknown> pControllingUnknown = GetControllingUnknown();
    171                 if(m_pFilterMapper2)
     179                if(m_pFilterMapper3)
    172180                {
    173181                        pControllingUnknown.p->AddRef();
    174                         m_pFilterMapper2 = NULL;
     182                        m_pFilterMapper3.Release();
     183                }
     184                if(m_pFilterMapper)
     185                {
     186                        pControllingUnknown.p->AddRef();
     187                        m_pFilterMapper.Release();
    175188                }
    176189                if(m_pAmFilterData)
    177190                {
    178191                        pControllingUnknown.p->AddRef();
    179                         m_pAmFilterData = NULL;
     192                        m_pAmFilterData.Release();
    180193                }
    181194                _ATLTRY
    182195                {
    183                         m_pInnerUnknown = NULL;
     196                        m_pInnerUnknown.Release();
    184197                }
    185198                _ATLCATCHALL()
     
    199212
    200213// IAMFilterData
    201         STDMETHOD(ParseFilterData)(BYTE* pnFilterData, ULONG nFilterDataSize, BYTE** ppFilterInformation) throw()
     214        STDMETHOD(ParseFilterData)(BYTE* pnFilterData, ULONG nFilterDataSize, BYTE** ppFilterInformation) override
    202215        {
    203216                _Z4(atlTraceCOM, 4, _T("nFilterDataSize %d\n"), nFilterDataSize);
     
    214227                return nResult;
    215228        }
    216         STDMETHOD(CreateFilterData)(REGFILTER2* pFilterInformation, BYTE** ppnFilterData, ULONG* pnFilterDataSize) throw()
     229        STDMETHOD(CreateFilterData)(REGFILTER2* pFilterInformation, BYTE** ppnFilterData, ULONG* pnFilterDataSize) override
    217230        {
    218231                _Z4(atlTraceCOM, 4, _T("...\n"));
     
    229242        }
    230243
     244// IFilterMapper3
     245        STDMETHOD(GetICreateDevEnum)(ICreateDevEnum** ppEnum) override
     246        {
     247                _Z4(atlTraceCOM, 4, _T("...\n"));
     248                return m_pFilterMapper3->GetICreateDevEnum(ppEnum);
     249        }
     250
    231251// IFilterMapper2
    232         STDMETHOD(CreateCategory)(REFCLSID CategoryIdentifier, DWORD nMerit, LPCWSTR pszDescription) throw()
    233         {
    234                 _Z4(atlTraceCOM, 4, _T("CategoryIdentifier %ls, nMerit 0x%08x, pszDescription \"%s\"\n"), _PersistHelper::StringFromIdentifier(CategoryIdentifier), nMerit, CString(pszDescription));
    235                 return m_pFilterMapper2->CreateCategory(CategoryIdentifier, nMerit, pszDescription);
    236         }
    237         STDMETHOD(UnregisterFilter)(const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, REFCLSID FilterClassIdentifier) throw()
     252        STDMETHOD(CreateCategory)(REFCLSID CategoryIdentifier, DWORD nMerit, LPCWSTR pszDescription) override
     253        {
     254                _Z4(atlTraceCOM, 4, _T("CategoryIdentifier %ls, nMerit 0x%08X, pszDescription \"%s\"\n"), _PersistHelper::StringFromIdentifier(CategoryIdentifier), nMerit, CString(pszDescription));
     255                return m_pFilterMapper3->CreateCategory(CategoryIdentifier, nMerit, pszDescription);
     256        }
     257        STDMETHOD(UnregisterFilter)(const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, REFCLSID FilterClassIdentifier) override
    238258        {
    239259                _Z4(atlTraceCOM, 4, _T("pCategoryIdentifier %ls, pszInstance %s, FilterClassIdentifier %ls\n"), pCategoryIdentifier ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pCategoryIdentifier) : L"NULL", pszInstance ? (LPCTSTR) AtlFormatString(_T("\"%s\""), CString(pszInstance)) : _T("NULL"), _PersistHelper::StringFromIdentifier(FilterClassIdentifier));
    240                 return m_pFilterMapper2->UnregisterFilter(pCategoryIdentifier, pszInstance, FilterClassIdentifier);
    241         }
    242         STDMETHOD(RegisterFilter)(REFCLSID FilterClassIdentifier, LPCWSTR pszName, IMoniker** ppMoniker, const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, const REGFILTER2* pFilterInformation) throw()
     260                return m_pFilterMapper3->UnregisterFilter(pCategoryIdentifier, pszInstance, FilterClassIdentifier);
     261        }
     262        STDMETHOD(RegisterFilter)(REFCLSID FilterClassIdentifier, LPCWSTR pszName, IMoniker** ppMoniker, const CLSID* pCategoryIdentifier, LPCOLESTR pszInstance, const REGFILTER2* pFilterInformation) override
    243263        {
    244264                _Z4(atlTraceCOM, 4, _T("FilterClassIdentifier %ls, pszName \"%s\", pCategoryIdentifier %ls, pszInstance %s\n"), _PersistHelper::StringFromIdentifier(FilterClassIdentifier), CString(pszName), pCategoryIdentifier ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pCategoryIdentifier) : L"NULL", pszInstance ? (LPCTSTR) AtlFormatString(_T("\"%s\""), CString(pszInstance)) : _T("NULL"));
     
    252272                                _Z_EXCEPTION();
    253273                        }
    254                 return m_pFilterMapper2->RegisterFilter(FilterClassIdentifier, pszName, ppMoniker, pCategoryIdentifier, pszInstance, pFilterInformation);
    255         }
    256         STDMETHOD(EnumMatchingFilters)(IEnumMoniker** ppEnumMoniker, DWORD nFlags, BOOL bExactMatch, DWORD nMinimalMerit, BOOL bInputNeeded, DWORD nInputTypeCount, const GUID* pInputTypes, const REGPINMEDIUM* pInputMedium, const CLSID* pInputPinCategory, BOOL bRender, BOOL bOutputNeeded, DWORD nOutputTypeCount, const GUID* pOutputTypes, const REGPINMEDIUM* pOutputMedium, const CLSID* pOutputPinCategory) throw()
    257         {
    258                 _Z4(atlTraceCOM, 4, _T("nFlags 0x%x, bExactMatch %d, nMinimalMerit 0x%08x, bInputNeeded %d, nInputTypeCount %d, pInputPinCategory %ls, bRender %d, bOutputNeeded %d, nOutputTypeCount %d, pOutputPinCategory %ls\n"), nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pInputPinCategory) : L"NULL", bRender, bOutputNeeded, nOutputTypeCount, pOutputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pOutputPinCategory) : L"NULL");
     274                return m_pFilterMapper3->RegisterFilter(FilterClassIdentifier, pszName, ppMoniker, pCategoryIdentifier, pszInstance, pFilterInformation);
     275        }
     276        STDMETHOD(EnumMatchingFilters)(IEnumMoniker** ppEnumMoniker, DWORD nFlags, BOOL bExactMatch, DWORD nMinimalMerit, BOOL bInputNeeded, DWORD nInputTypeCount, const GUID* pInputTypes, const REGPINMEDIUM* pInputMedium, const CLSID* pInputPinCategory, BOOL bRender, BOOL bOutputNeeded, DWORD nOutputTypeCount, const GUID* pOutputTypes, const REGPINMEDIUM* pOutputMedium, const CLSID* pOutputPinCategory) override
     277        {
     278                _Z4(atlTraceCOM, 4, _T("nFlags 0x%X, bExactMatch %d, nMinimalMerit 0x%08X, bInputNeeded %d, nInputTypeCount %d, pInputPinCategory %ls, bRender %d, bOutputNeeded %d, nOutputTypeCount %d, pOutputPinCategory %ls\n"), nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pInputPinCategory) : L"NULL", bRender, bOutputNeeded, nOutputTypeCount, pOutputPinCategory ? (LPCWSTR) _PersistHelper::StringFromIdentifier(*pOutputPinCategory) : L"NULL");
    259279                for(DWORD nInputTypeIndex = 0; nInputTypeIndex < nInputTypeCount; nInputTypeIndex++)
    260280                {
     
    264284                }
    265285                if(pInputMedium)
    266                         _Z4(atlTraceCOM, 4, _T("pInputMedium { clsMedium %ls, dw1 0x%x, dw2 0x%x }\n"), _PersistHelper::StringFromIdentifier(pInputMedium->clsMedium), pInputMedium->dw1, pInputMedium->dw2);
     286                        _Z4(atlTraceCOM, 4, _T("pInputMedium { clsMedium %ls, dw1 0x%X, dw2 0x%X }\n"), _PersistHelper::StringFromIdentifier(pInputMedium->clsMedium), pInputMedium->dw1, pInputMedium->dw2);
    267287                for(DWORD nOutputTypeIndex = 0; nOutputTypeIndex < nOutputTypeCount; nOutputTypeIndex++)
    268288                {
     
    272292                }
    273293                if(pOutputMedium)
    274                         _Z4(atlTraceCOM, 4, _T("pOutputMedium { clsMedium %ls, dw1 0x%x, dw2 0x%x }\n"), _PersistHelper::StringFromIdentifier(pOutputMedium->clsMedium), pOutputMedium->dw1, pOutputMedium->dw2);
    275                 const HRESULT nResult = m_pFilterMapper2->EnumMatchingFilters(ppEnumMoniker, nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputTypes, pInputMedium, pInputPinCategory, bRender, bOutputNeeded, nOutputTypeCount, pOutputTypes, pOutputMedium, pOutputPinCategory);
     294                        _Z4(atlTraceCOM, 4, _T("pOutputMedium { clsMedium %ls, dw1 0x%X, dw2 0x%X }\n"), _PersistHelper::StringFromIdentifier(pOutputMedium->clsMedium), pOutputMedium->dw1, pOutputMedium->dw2);
     295                const HRESULT nResult = m_pFilterMapper3->EnumMatchingFilters(ppEnumMoniker, nFlags, bExactMatch, nMinimalMerit, bInputNeeded, nInputTypeCount, pInputTypes, pInputMedium, pInputPinCategory, bRender, bOutputNeeded, nOutputTypeCount, pOutputTypes, pOutputMedium, pOutputPinCategory);
    276296                if(SUCCEEDED(nResult))
    277297                        _ATLTRY
     
    279299                                const CComPtr<IEnumMoniker>& pEnumMoniker = reinterpret_cast<const CComPtr<IEnumMoniker>&>(*ppEnumMoniker);
    280300                                __C(pEnumMoniker->Reset());
    281                                 CComPtr<IMoniker> pMoniker;
    282                                 while(pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK)
     301                                for(; ; )
    283302                                {
    284                                         _Z4(atlTraceCOM, 4, _T("pMoniker %ls\n"), _FilterGraphHelper::GetMonikerDisplayName(pMoniker));
     303                                        CComPtr<IMoniker> pMoniker;
     304                                        ULONG nElementCount;
     305                                        if(pEnumMoniker->Next(1, &pMoniker, &nElementCount) != S_OK)
     306                                                break;
     307                                        _Z4(atlTraceGeneral, 4, _T("pMoniker %ls\n"), _FilterGraphHelper::GetMonikerDisplayName(pMoniker));
    285308                                        CComPtr<IBindCtx> pBindCtx;
    286309                                        __C(CreateBindCtx(0, &pBindCtx));
     
    291314                                        const CStringW sDevicePath = _FilterGraphHelper::ReadPropertyBagString(pPropertyBag, OLESTR("DevicePath"));
    292315                                        _Z4(atlTraceCOM, 4, _T("sFriendlyName \"%ls\", sDescription \"%ls\", sDevicePath \"%ls\"\n"), sFriendlyName, sDescription, sDevicePath);
    293                                         pMoniker.Release();
    294316                                }
    295317                                __C(pEnumMoniker->Reset());
     
    300322                        }
    301323                return nResult;
     324        }
     325
     326// IFilterMapper
     327        STDMETHOD(RegisterFilter)(CLSID FilterClassIdentifier, LPCWSTR pszName, DWORD nMerit) override
     328        {
     329                _Z4(atlTraceCOM, 4, _T("...\n"));
     330                return m_pFilterMapper->RegisterFilter(FilterClassIdentifier, pszName, nMerit);
     331        }
     332        STDMETHOD(RegisterFilterInstance)(CLSID FilterClassIdentifier, LPCWSTR pszName, CLSID* pMediaResourceIdentifier) override
     333        {
     334                _Z4(atlTraceCOM, 4, _T("...\n"));
     335                return m_pFilterMapper->RegisterFilterInstance(FilterClassIdentifier, pszName, pMediaResourceIdentifier);
     336        }
     337        STDMETHOD(RegisterPin)(CLSID Filter, LPCWSTR pszName, BOOL bRendered, BOOL bOutput, BOOL bZero, BOOL bMany, CLSID ConnectsToFilter, LPCWSTR pszConnectsToPin) override
     338        {
     339                _Z4(atlTraceCOM, 4, _T("...\n"));
     340                return m_pFilterMapper->RegisterPin(Filter, pszName, bRendered, bOutput, bZero, bMany, ConnectsToFilter, pszConnectsToPin);
     341        }
     342        STDMETHOD(RegisterPinType)(CLSID FilterClassIdentifier, LPCWSTR pszName, CLSID MajorType, CLSID Subtype) override
     343        {
     344                _Z4(atlTraceCOM, 4, _T("...\n"));
     345                return m_pFilterMapper->RegisterPinType(FilterClassIdentifier, pszName, MajorType, Subtype);
     346        }
     347        STDMETHOD(UnregisterFilter)(CLSID FilterClassIdentifier) override
     348        {
     349                _Z4(atlTraceCOM, 4, _T("...\n"));
     350                return m_pFilterMapper->UnregisterFilter(FilterClassIdentifier);
     351        }
     352        STDMETHOD(UnregisterFilterInstance)(CLSID MediaResourceIdentifier) override
     353        {
     354                _Z4(atlTraceCOM, 4, _T("...\n"));
     355                return m_pFilterMapper->UnregisterFilterInstance(MediaResourceIdentifier);
     356        }
     357        STDMETHOD(UnregisterPin)(CLSID FilterClassIdentifier, LPCWSTR pszName) override
     358        {
     359                _Z4(atlTraceCOM, 4, _T("...\n"));
     360                return m_pFilterMapper->UnregisterPin(FilterClassIdentifier, pszName);
     361        }
     362        STDMETHOD(EnumMatchingFilters)(IEnumRegFilters** ppEnum, DWORD nMerit, BOOL bInputNeeded, CLSID clsInMaj, CLSID clsInSub, BOOL bRender, BOOL bOutputNeeded, CLSID clsOutMaj, CLSID clsOutSub) override
     363        {
     364                _Z4(atlTraceCOM, 4, _T("...\n"));
     365                return m_pFilterMapper->EnumMatchingFilters(ppEnum, nMerit, bInputNeeded, clsInMaj, clsInSub, bRender, bOutputNeeded, clsOutMaj, clsOutSub);
    302366        }
    303367};
Note: See TracChangeset for help on using the changeset viewer.