Changeset 285


Ignore:
Timestamp:
May 8, 2014, 9:04:30 AM (10 years ago)
Author:
roman
Message:

Added local in-process COM server identification through virtual method table lookup

Location:
trunk/DirectShowSpy
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/DirectShowSpy/DirectShowSpy.idl

    r280 r285  
    5555[
    5656        object,
     57        uuid(A7490000-3A5D-455D-9B81-2025B74CD4CD),
     58        nonextensible,
     59        helpstring("ISpyEx Interface"),
     60        pointer_default(unique)
     61]
     62interface ISpyEx : IUnknown
     63{
     64};
     65[
     66        object,
    5767        uuid(34B280D7-A144-4a64-BCB9-3616896F6877),
    5868        dual,
     
    153163        {
    154164                [default] interface ISpy;
     165                //interface ISpyEx;
    155166                interface IModuleVersionInformation;
    156167        };
     
    162173        {
    163174                [default] interface ISpy;
     175                //interface ISpyEx;
    164176                interface IModuleVersionInformation;
    165177        };
  • trunk/DirectShowSpy/DirectShowSpy.rc

    r280 r285  
    6060
    6161VS_VERSION_INFO VERSIONINFO
    62  FILEVERSION  1, 0, 0, 1466
     62 FILEVERSION  1, 0, 0, 1483
    6363 PRODUCTVERSION 1,0,0,1
    6464 FILEFLAGSMASK 0x3fL
     
    7979            VALUE "CompanyName", "Roman Ryltsov"
    8080            VALUE "FileDescription", "Alax.Info DirectShow Spy Module"
    81             VALUE "FileVersion",  "1, 0, 0, 1466\0"
     81            VALUE "FileVersion",  "1, 0, 0, 1483\0"
    8282            VALUE "InternalName", "DirectShowSpy.dll"
    8383            VALUE "LegalCopyright", "Copyright © Alax.Info, Roman Ryltsov, 2008-2014"
  • trunk/DirectShowSpy/DirectShowSpy_i.c

    r280 r285  
    77
    88 /* File created by MIDL compiler version 7.00.0555 */
    9 /* at Thu Mar 13 20:08:29 2014
     9/* at Wed May 07 14:27:04 2014
    1010 */
    1111/* Compiler settings for DirectShowSpy.idl:
     
    7474
    7575
     76MIDL_DEFINE_GUID(IID, IID_ISpyEx,0xA7490000,0x3A5D,0x455D,0x9B,0x81,0x20,0x25,0xB7,0x4C,0xD4,0xCD);
     77
     78
    7679MIDL_DEFINE_GUID(IID, IID_IFilterMapperSpy,0x34B280D7,0xA144,0x4a64,0xBC,0xB9,0x36,0x16,0x89,0x6F,0x68,0x77);
    7780
  • trunk/DirectShowSpy/DirectShowSpy_i.h

    r280 r285  
    55
    66 /* File created by MIDL compiler version 7.00.0555 */
    7 /* at Thu Mar 13 20:08:29 2014
     7/* at Wed May 07 14:27:04 2014
    88 */
    99/* Compiler settings for DirectShowSpy.idl:
     
    5858
    5959
     60#ifndef __ISpyEx_FWD_DEFINED__
     61#define __ISpyEx_FWD_DEFINED__
     62typedef interface ISpyEx ISpyEx;
     63#endif  /* __ISpyEx_FWD_DEFINED__ */
     64
     65
    6066#ifndef __IFilterMapperSpy_FWD_DEFINED__
    6167#define __IFilterMapperSpy_FWD_DEFINED__
     
    531537
    532538
     539#ifndef __ISpyEx_INTERFACE_DEFINED__
     540#define __ISpyEx_INTERFACE_DEFINED__
     541
     542/* interface ISpyEx */
     543/* [unique][helpstring][nonextensible][uuid][object] */
     544
     545
     546EXTERN_C const IID IID_ISpyEx;
     547
     548#if defined(__cplusplus) && !defined(CINTERFACE)
     549   
     550    MIDL_INTERFACE("A7490000-3A5D-455D-9B81-2025B74CD4CD")
     551    ISpyEx : public IUnknown
     552    {
     553    public:
     554    };
     555   
     556#else   /* C style interface */
     557
     558    typedef struct ISpyExVtbl
     559    {
     560        BEGIN_INTERFACE
     561       
     562        HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
     563            ISpyEx * This,
     564            /* [in] */ REFIID riid,
     565            /* [annotation][iid_is][out] */
     566            __RPC__deref_out  void **ppvObject);
     567       
     568        ULONG ( STDMETHODCALLTYPE *AddRef )(
     569            ISpyEx * This);
     570       
     571        ULONG ( STDMETHODCALLTYPE *Release )(
     572            ISpyEx * This);
     573       
     574        END_INTERFACE
     575    } ISpyExVtbl;
     576
     577    interface ISpyEx
     578    {
     579        CONST_VTBL struct ISpyExVtbl *lpVtbl;
     580    };
     581
     582   
     583
     584#ifdef COBJMACROS
     585
     586
     587#define ISpyEx_QueryInterface(This,riid,ppvObject)      \
     588    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
     589
     590#define ISpyEx_AddRef(This)     \
     591    ( (This)->lpVtbl -> AddRef(This) )
     592
     593#define ISpyEx_Release(This)    \
     594    ( (This)->lpVtbl -> Release(This) )
     595
     596
     597#endif /* COBJMACROS */
     598
     599
     600#endif  /* C style interface */
     601
     602
     603
     604
     605#endif  /* __ISpyEx_INTERFACE_DEFINED__ */
     606
     607
    533608#ifndef __IFilterMapperSpy_INTERFACE_DEFINED__
    534609#define __IFilterMapperSpy_INTERFACE_DEFINED__
  • trunk/DirectShowSpy/DirectShowSpy_p.c

    r280 r285  
    55
    66 /* File created by MIDL compiler version 7.00.0555 */
    7 /* at Thu Mar 13 20:08:29 2014
     7/* at Wed May 07 14:27:04 2014
    88 */
    99/* Compiler settings for DirectShowSpy.idl:
     
    9696extern const MIDL_SERVER_INFO ISpy_ServerInfo;
    9797extern const MIDL_STUBLESS_PROXY_INFO ISpy_ProxyInfo;
     98
     99
     100extern const MIDL_STUB_DESC Object_StubDesc;
     101
     102
     103extern const MIDL_SERVER_INFO ISpyEx_ServerInfo;
     104extern const MIDL_STUBLESS_PROXY_INFO ISpyEx_ProxyInfo;
    98105
    99106
     
    16261633
    16271634
     1635/* Object interface: ISpyEx, ver. 0.0,
     1636   GUID={0xA7490000,0x3A5D,0x455D,{0x9B,0x81,0x20,0x25,0xB7,0x4C,0xD4,0xCD}} */
     1637
     1638#pragma code_seg(".orpc")
     1639static const unsigned short ISpyEx_FormatStringOffsetTable[] =
     1640    {
     1641    0
     1642    };
     1643
     1644static const MIDL_STUBLESS_PROXY_INFO ISpyEx_ProxyInfo =
     1645    {
     1646    &Object_StubDesc,
     1647    DirectShowSpy__MIDL_ProcFormatString.Format,
     1648    &ISpyEx_FormatStringOffsetTable[-3],
     1649    0,
     1650    0,
     1651    0
     1652    };
     1653
     1654
     1655static const MIDL_SERVER_INFO ISpyEx_ServerInfo =
     1656    {
     1657    &Object_StubDesc,
     1658    0,
     1659    DirectShowSpy__MIDL_ProcFormatString.Format,
     1660    &ISpyEx_FormatStringOffsetTable[-3],
     1661    0,
     1662    0,
     1663    0,
     1664    0};
     1665CINTERFACE_PROXY_VTABLE(3) _ISpyExProxyVtbl =
     1666{
     1667    0,
     1668    &IID_ISpyEx,
     1669    IUnknown_QueryInterface_Proxy,
     1670    IUnknown_AddRef_Proxy,
     1671    IUnknown_Release_Proxy
     1672};
     1673
     1674const CInterfaceStubVtbl _ISpyExStubVtbl =
     1675{
     1676    &IID_ISpyEx,
     1677    &ISpyEx_ServerInfo,
     1678    3,
     1679    0, /* pure interpreted */
     1680    CStdStubBuffer_METHODS
     1681};
     1682
     1683
    16281684/* Object interface: IFilterMapperSpy, ver. 0.0,
    16291685   GUID={0x34B280D7,0xA144,0x4a64,{0xBC,0xB9,0x36,0x16,0x89,0x6F,0x68,0x77}} */
     
    18691925const CInterfaceProxyVtbl * const _DirectShowSpy_ProxyVtblList[] =
    18701926{
     1927    ( CInterfaceProxyVtbl *) &_ISpyExProxyVtbl,
    18711928    ( CInterfaceProxyVtbl *) &_ISpyProxyVtbl,
    18721929    ( CInterfaceProxyVtbl *) &_IFilterGraphHelperProxyVtbl,
     
    18791936const CInterfaceStubVtbl * const _DirectShowSpy_StubVtblList[] =
    18801937{
     1938    ( CInterfaceStubVtbl *) &_ISpyExStubVtbl,
    18811939    ( CInterfaceStubVtbl *) &_ISpyStubVtbl,
    18821940    ( CInterfaceStubVtbl *) &_IFilterGraphHelperStubVtbl,
     
    18891947PCInterfaceName const _DirectShowSpy_InterfaceNamesList[] =
    18901948{
     1949    "ISpyEx",
    18911950    "ISpy",
    18921951    "IFilterGraphHelper",
     
    18991958const IID *  const _DirectShowSpy_BaseIIDList[] =
    19001959{
     1960    0,
    19011961    &IID_IDispatch,
    19021962    &IID_IDispatch,
     
    19141974    IID_BS_LOOKUP_SETUP
    19151975
    1916     IID_BS_LOOKUP_INITIAL_TEST( _DirectShowSpy, 5, 4 )
     1976    IID_BS_LOOKUP_INITIAL_TEST( _DirectShowSpy, 6, 4 )
    19171977    IID_BS_LOOKUP_NEXT_TEST( _DirectShowSpy, 2 )
    19181978    IID_BS_LOOKUP_NEXT_TEST( _DirectShowSpy, 1 )
    1919     IID_BS_LOOKUP_RETURN_RESULT( _DirectShowSpy, 5, *pIndex )
     1979    IID_BS_LOOKUP_RETURN_RESULT( _DirectShowSpy, 6, *pIndex )
    19201980   
    19211981}
     
    19281988    (const IID ** ) & _DirectShowSpy_BaseIIDList,
    19291989    & _DirectShowSpy_IID_Lookup,
    1930     5,
     1990    6,
    19311991    2,
    19321992    0, /* table of [async_uuid] interfaces */
  • trunk/DirectShowSpy/FilterGraphHelper.h

    r280 r285  
    202202                DWORD m_nIdentifier;
    203203                CPath m_sImagePath;
     204
     205        public:
     206        // CProcessData
     207                CProcessData() :
     208                        m_nIdentifier(0)
     209                {
     210                }
    204211        };
    205212
     
    18881895private:
    18891896        mutable CRoCriticalSection m_DataCriticalSection;
     1897        CProcessData m_ProcessData;
    18901898        CComPtr<IFilterGraph> m_pFilterGraph;
    18911899
     
    20252033                return _StringHelper::Join(Array, _T(", "));
    20262034        }
    2027         static CString GetFilterText(IBaseFilter* pBaseFilter, IReferenceClock* pFilterGraphReferenceClock = NULL)
     2035        static CString GetFilterText(IBaseFilter* pBaseFilter, const CProcessData* pProcessData, IReferenceClock* pFilterGraphReferenceClock = NULL)
    20282036        {
    20292037                CString sText;
    20302038                #pragma region COM
     2039                CString sPath;
    20312040                const CStringW sClassIdentifierString = _FilterGraphHelper::GetFilterClassIdentifierString(pBaseFilter);
    20322041                if(!sClassIdentifierString.IsEmpty())
     
    20392048                                _ATLTRY
    20402049                                {
    2041                                         const CString sPath = _RegKeyHelper::QueryStringValue(HKEY_CLASSES_ROOT, AtlFormatString(_T("CLSID\\%ls\\InprocServer32"), sClassIdentifierString));
     2050                                        sPath = _RegKeyHelper::QueryStringValue(HKEY_CLASSES_ROOT, AtlFormatString(_T("CLSID\\%ls\\InprocServer32"), sClassIdentifierString));
    20422051                                        if(!sPath.IsEmpty())
    20432052                                        {
     
    20572066                        }
    20582067                }
     2068                if(_tcslen(sPath) == 0 && pProcessData && pProcessData->m_nIdentifier == GetCurrentProcessId())
     2069                        _ATLTRY
     2070                        {
     2071                                const VOID* pvVirtualTable = *((const VOID**) pBaseFilter);
     2072                                MEMORY_BASIC_INFORMATION Information;
     2073                                if(VirtualQueryEx(GetCurrentProcess(), pvVirtualTable, &Information, sizeof Information))
     2074                                {
     2075                                        TCHAR pszPath[MAX_PATH] = { 0 };
     2076                                        if(GetModuleFileName((HMODULE) Information.AllocationBase, pszPath, DIM(pszPath)))
     2077                                        {
     2078                                                sPath = pszPath;
     2079                                                sText += AtlFormatString(_T(" * ") _T("Virtual Table Location: %s") _T("\r\n"), I(sPath));
     2080                                                const ULONGLONG nProductVersion = _VersionInfoHelper::GetProductVersion(sPath);
     2081                                                if(nProductVersion && (nProductVersion + 1))
     2082                                                        sText += AtlFormatString(_T(" * ") _T("Product Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(nProductVersion)));
     2083                                                const ULONGLONG nFileVersion = _VersionInfoHelper::GetFileVersion(sPath);
     2084                                                if(nFileVersion && (nFileVersion + 1))
     2085                                                        sText += AtlFormatString(_T(" * ") _T("File Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(nFileVersion)));
     2086                                        }
     2087                                }
     2088                        }
     2089                        _ATLCATCHALL()
     2090                        {
     2091                                _Z_EXCEPTION();
     2092                        }
    20592093                #pragma endregion
     2094                #pragma region Pin
    20602095                _FilterGraphHelper::CPinArray InputPinArray;
    20612096                if(_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_INPUT, InputPinArray))
     
    20642099                if(_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_OUTPUT, OutputPinArray))
    20652100                        sText += AtlFormatString(_T(" * ") _T("Output Pins: %s") _T("\r\n"), FormatPins(OutputPinArray));
     2101                #pragma endregion
    20662102                #pragma region IReferenceClock
    20672103                const CComQIPtr<IReferenceClock> pReferenceClock = pBaseFilter;
     
    24542490                if(!pFilterGraph)
    24552491                        return (LPCTSTR) NULL;
     2492                const CComQIPtr<ISpy> pSpy = pFilterGraph;
    24562493                CString sText;
    24572494                sText += AtlFormatString(_T("# ") _T("Filter Graph") _T("\r\n") _T("\r\n"));
     
    25022539                        if(!pProcessData->m_sDisplayName.IsEmpty())
    25032540                                sText += AtlFormatString(_T("* ") _T("Display Name: %s") _T("\r\n"), I(pProcessData->m_sDisplayName));
    2504                         const CString sDirectory = (LPCTSTR) GetPathDirectory(pProcessData->m_sImagePath);
    2505                         if(!sDirectory.IsEmpty())
    2506                                 sText += AtlFormatString(_T("* ") _T("Process Directory: %s") _T("\r\n"), I(sDirectory));
     2541                        if(_tcslen(pProcessData->m_sImagePath))
     2542                        {
     2543                                const CString sDirectory = (LPCTSTR) GetPathDirectory(pProcessData->m_sImagePath);
     2544                                if(!sDirectory.IsEmpty())
     2545                                        sText += AtlFormatString(_T("* ") _T("Process Directory: %s") _T("\r\n"), I(sDirectory));
     2546                        }
    25072547                }
    25082548                const CComQIPtr<IMediaFilter> pMediaFilter = pFilterGraph;
     
    25232563                                        const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nIndex];
    25242564                                        sText += AtlFormatString(_T("%d. ") _T("%ls") _T("\r\n"), nIndex + 1, _FilterGraphHelper::GetFilterName(pBaseFilter));
    2525                                         sText += GetFilterText(pBaseFilter, pFilterGraphReferenceClock);
     2565                                        sText += GetFilterText(pBaseFilter, pProcessData, pFilterGraphReferenceClock);
    25262566                                }
    25272567                                _ATLCATCHALL()
     
    26452685                                        const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nIndex];
    26462686                                        //_Z4(atlTraceGeneral, 4, _T("pBaseFilter 0x%p \"%ls\"\n"), pBaseFilter, _FilterGraphHelper::GetFilterName(pBaseFilter));
    2647                                         const CString sPropertyBagText = CPropertyBagHelper::GetPropertyBagText(pBaseFilter, CComQIPtr<ISpy>(pFilterGraph));
     2687                                        const CString sPropertyBagText = CPropertyBagHelper::GetPropertyBagText(pBaseFilter, pSpy);
    26482688                                        if(sPropertyBagText.IsEmpty())
    26492689                                                continue;
     
    26722712                return m_pFilterGraph;
    26732713        }
    2674         VOID SetFilterGraph(IFilterGraph* pFilterGraph)
     2714        VOID SetFilterGraph(IFilterGraph* pFilterGraph, CProcessData* pProcessData = NULL)
    26752715        {
    26762716                CRoCriticalSectionLock DataLock(m_DataCriticalSection);
     2717                if(!pProcessData)
     2718                {
     2719                        m_ProcessData = CProcessData();
     2720                        const CComQIPtr<ISpyEx> pSpyEx = pFilterGraph;
     2721                        if(pSpyEx)
     2722                                m_ProcessData.m_nIdentifier = GetCurrentProcessId();
     2723                } else
     2724                        m_ProcessData = *pProcessData;
    26772725                m_pFilterGraph = pFilterGraph;
    26782726        }
    2679         BOOL SetFilterGraph(IUnknown* pFilterGraphUnknown)
     2727        BOOL SetFilterGraph(IUnknown* pFilterGraphUnknown, CProcessData* pProcessData = NULL)
    26802728        {
    26812729                CComQIPtr<IFilterGraph> pFilterGraph;
     
    26952743                        }
    26962744                }
     2745                SetFilterGraph(pFilterGraph, pProcessData);
     2746                return pFilterGraph != NULL;
     2747        }
     2748        CString GetFilterText(IBaseFilter* pBaseFilter) const
     2749        {
     2750                return GetFilterText(pBaseFilter, m_ProcessData.m_nIdentifier ? &m_ProcessData : NULL);
     2751        }
     2752        CString GetText() const
     2753        {
    26972754                CRoCriticalSectionLock DataLock(m_DataCriticalSection);
    2698                 m_pFilterGraph = pFilterGraph;
    2699                 return m_pFilterGraph != NULL;
    2700         }
    2701         CString GetText() const
    2702         {
    2703                 CRoCriticalSectionLock DataLock(m_DataCriticalSection);
    2704                 return GetText(m_pFilterGraph);
     2755                return GetText(m_pFilterGraph, m_ProcessData.m_nIdentifier ? &m_ProcessData : NULL);
    27052756        }
    27062757        static LPCTSTR GetPlatformName()
  • trunk/DirectShowSpy/FilterGraphList.h

    r276 r285  
    148148                                return m_pFilterGraph;
    149149                        }
     150                        CFilterGraphHelper::CProcessData GetProcessData() const
     151                        {
     152                                CFilterGraphHelper::CProcessData ProcessData;
     153                                ProcessData.m_sDisplayName = m_sDisplayName;
     154                                ProcessData.m_nIdentifier = m_nProcessIdentifier;
     155                                ProcessData.m_sImagePath = m_sProcessImagePath;
     156                                return ProcessData;
     157                        }
    150158                        BOOL Check()
    151159                        {
     
    342350                                                Item.Check();
    343351                                                m_GraphListView.RedrawItems(nItem, nItem);
    344                                                 CFilterGraphHelper::CProcessData ProcessData;
    345                                                 ProcessData.m_sDisplayName = Item.m_sDisplayName;
    346                                                 ProcessData.m_nIdentifier = Item.m_nProcessIdentifier;
    347                                                 ProcessData.m_sImagePath = Item.m_sProcessImagePath;
    348                                                 GraphArray.Add(CFilterGraphHelper::GetText(Item.m_pFilterGraph, &ProcessData));
     352                                                GraphArray.Add(CFilterGraphHelper::GetText(Item.m_pFilterGraph, &Item.GetProcessData()));
    349353                                        }
    350354                                }
     
    568572                        Item.Check();
    569573                        CLocalObjectPtr<CFilterGraphHelper> pFilterGraphHelper;
    570                         pFilterGraphHelper->SetFilterGraph(Item.m_pFilterGraph);
     574                        pFilterGraphHelper->SetFilterGraph(Item.m_pFilterGraph, &Item.GetProcessData());
    571575                        _V(pFilterGraphHelper->DoPropertyFrameModal((LONG) (LONG_PTR) m_hWnd));
    572576                        return 0;
  • trunk/DirectShowSpy/FilterGraphSpy.h

    r280 r285  
    9292        public CTransparentCoClassT<T, t_pFilterGraphClassIdentifier>,
    9393        public IDispatchImpl<ISpy>,
     94        public ISpyEx,
    9495        public IFilterGraph2,
    9596        public IDispatchImpl<IMediaControl, &__uuidof(IMediaControl), &__uuidof(Quartz::__QuartzTypeLib)>,
     
    125126        COM_INTERFACE_ENTRY(ISpy)
    126127        COM_INTERFACE_ENTRY_FUNC(__uuidof(IFilterGraph3), 0, QueryFilterGraph3Interface)
     128        COM_INTERFACE_ENTRY(ISpyEx)
    127129        COM_INTERFACE_ENTRY(IFilterGraph2)
    128130        COM_INTERFACE_ENTRY(IGraphBuilder)
     
    797799        }
    798800
     801// ISpyEx
     802
    799803// IFilterGraph
    800804        STDMETHOD(AddFilter)(IBaseFilter* pBaseFilter, LPCWSTR pszName)
Note: See TracChangeset for help on using the changeset viewer.