<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fooling Around &#187; spy</title>
	<atom:link href="http://alax.info/blog/tag/spy/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Wed, 02 May 2012 15:42:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>DirectShow Spy: Intelligent Connect Trace, Selective Process Black Listing</title>
		<link>http://alax.info/blog/1253</link>
		<comments>http://alax.info/blog/1253#comments</comments>
		<pubDate>Sun, 24 Jul 2011 18:55:47 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[intelligent connect]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[spy]]></category>
		<category><![CDATA[trace]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1253</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1253" title="DirectShow Spy: Intelligent Connect Trace, Selective Process Black Listing"></a>DirectShow Spy is updated with a few new features: retroactive Intelligent Connect trace log output for IAMGraphBuilderCallback-related activity process name based black list to selectively exclude processes from spying Intelligent Connect Trace The utility received a capability to read back &#8230;<p class="read-more"><a href="http://alax.info/blog/1253">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1253" title="DirectShow Spy: Intelligent Connect Trace, Selective Process Black Listing"></a><p>DirectShow Spy is updated with a few new features:</p>
<ul>
<li>retroactive Intelligent Connect trace</li>
<li>log output for IAMGraphBuilderCallback-related activity</li>
<li>process name based black list to selectively exclude processes from spying</li>
</ul>
<h4>Intelligent Connect Trace</h4>
<p>The utility received a capability to read back from its own log file (DirectShowSpy.log, located typically in C:\ProgramData directory) and reconstruct graph building sequence, including steps taken by DirectShow <a href="http://msdn.microsoft.com/en-us/library/dd390342%28VS.85%29.aspx">Intelligent Connect</a>.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0012.png"><img class="alignnone size-large wp-image-1254" title="Intelligent Connect Trace" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0012-582x600.png" alt="" width="582" height="600" /></a></p>
<p>In order to activate the Intelligent Connect Trace property sheet, one needs to call exported function &#8220;<em>DoGraphBuilderCallbackPropertySheetModal</em>&#8220;, such as using <em>runndll32</em> tool:</p>
<p style="text-align: left; padding-left: 30px;">C:\DirectShowSpy&gt;rundll32 DirectShowSpy.dll,DoGraphBuilderCallbackPropertySheetModal</p>
<p style="text-align: left;">The upper part of the property page displays recently created DirectShow fitler graphs, newest to older. For a selected graph, the lower part displays events in chronological order. The events include:</p>
<ul>
<li>Adding a filter, at <a href="http://msdn.microsoft.com/en-us/library/dd390016%28VS.85%29.aspx">IFilterGraph2::AddFilter</a> method</li>
<li>Removing a filter, at <a href="http://msdn.microsoft.com/en-us/library/dd390022%28VS.85%29.aspx">IFilterGraph2::RemoveFilter</a> method</li>
<li>Selecting a filter, at Intelligent Connect&#8217;s callback at <a href="http://msdn.microsoft.com/en-us/library/dd389378%28VS.85%29.aspx">IAMGraphBuilderCallback::SelectedFilter</a></li>
<li>Creating a filter, at <a href="http://msdn.microsoft.com/en-us/library/dd389377%28VS.85%29.aspx">IAMGraphBuilderCallback::CreatedFilter</a></li>
</ul>
<p>The latter two methods also show &#8220;Application Result&#8221; column and values, which are HRESULT values returned by IAMGraphBuilderCallback callback provided by the application. Typically, a failure HRESULT code indicates that the application rejected the filter.</p>
<p>The trace log is good to expose all DirectShow junk installed in the system. For example,</p>
<p><span id="more-1253"></span><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0022.png"><img class="alignnone size-large wp-image-1255" title="Junk: ffdshowBC.ax" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0022-800x496.png" alt="" width="620" height="384" /></a></p>
<p>In an attempt to build graph to decode FourCC &#8216;LXH4&#8242; video (which is a private alias for H.264 media type), Filter Graph Manager tried to apply &#8216;ffdshow Video Decoder&#8217; filter, which is unable to process the feed, but is registered at an extremely high merit and violating the guidelines.</p>
<p>The tool shows that the file hosting the filter is &#8220;<em>ffdshowBC.ax</em>&#8221; and shows its location. The application however appears to be aware of this piece of trash, and returned E_FAIL (0&#215;80004005) rejecting the filter.</p>
<p>How comes the garbage is hooking into place where it is not supposed to be, yet is sophisticated enough to reach such internals of operating system? This module is a clone/branch of well-known <a href="http://www.google.com/search?q=ffdshow">ffdshow</a> software, which by default registers itself with abnormally high merit &#8220;with good intentions in mind&#8221;. A short-sighted manufacturer of cheap stuff IP camera duplicated the project, changed the GUIDs, packaged the pathetic crap into ActiveX control cabinet and started distributing it over clean and virgin workstations around the globe.</p>
<p>Going further with the the trace being checked, there are more things to enjoy:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0033.png"><img class="alignnone size-large wp-image-1256" title="Junk: MainConcept Showcase" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0033-800x553.png" alt="" width="620" height="428" /></a></p>
<p>Trying to decode the same H.264 video feed, the Filter Graph Manager mounting three demultiplexers madeĀ  by MainConcept in a row, for MP4, MPEG and MXF containers. The utility immediately indicates that this trash contribution was brought by <a href="http://www.mainconcept.com/products/sdks/others/showcase.html">MainConcept Showcase</a> 8.7.0.28412. One might wanted to install it for a purpose, and it started killing other DirectShow software it shares workstation with.</p>
<p>The good news is that the method is friendly for production environment and only requires to register spy and collect log file. You don&#8217;t eve need to check the UI at the same computer, it is possible to transfer the log file into development environment and have spy read the log there.</p>
<p>The &#8220;Copy to Clipboard&#8221; link is a convenient option to transfer the findings into tab-separated values format, such as to paste into Microsoft Excel:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0042.png"><img class="alignnone size-large wp-image-1257" title="Data Transfered to Microsoft Excel" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0042-800x394.png" alt="" width="620" height="305" /></a></p>
<h4>Process Black Listing</h4>
<p>The utility received a capability to selectively not load into specific processes. DirectShowSpy is a developer tool and is not intended for production environment, nor it is guaranteed to be issue-free. So in case of specific conflict it is possible to exclude specific process from applying a spy using registry:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0051.png"><img class="alignnone size-large wp-image-1258" title="Black List Registry" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0051-800x424.png" alt="" width="620" height="328" /></a></p>
<p>The values are under <em>HKLM, SOFTWARE\[Wow6432Node\]Alax.Info\Utilities\DirectShowSpy</em> key, and there are three values defined:</p>
<ul>
<li>CFilterMapperSpy Black List &#8211; defines exclusion for filter mapper spying</li>
<li>CSpy Black List &#8211; defines exclusion for filter graph spy (effective for most applications)</li>
<li>CNoThreadSpy Black List &#8211; defines exclusion for filter graphs created with <a href="http://msdn.microsoft.com/en-us/library/dd375786%28VS.85%29.aspx">CLSID_FilterGraphNoThread</a></li>
</ul>
<p>The exclusion value is a comma-separated list of process names, exact case-insensitive match for executable file names without directory and extension.</p>
<p>It is recommended that filter mapper spy has at least as rich exclusion list as the filter graph spy entires (otherwise, it is possible that spy might raise unexpected exceptions).</p>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary included (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>, <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>); installation instructions are in <a href="../777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1253/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow Spy: Memory Allocator Properties</title>
		<link>http://alax.info/blog/1168</link>
		<comments>http://alax.info/blog/1168#comments</comments>
		<pubDate>Sat, 05 Mar 2011 10:15:42 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[allocator]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1168</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1168" title="DirectShow Spy: Memory Allocator Properties"></a>A small update to the DirectShow Spy today: DirectShow Filter Graph Spy prints memory allocator properties as a part of graph topology trace on transition to running state. Why is that and what it is for? Filters normally agree on &#8230;<p class="read-more"><a href="http://alax.info/blog/1168">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1168" title="DirectShow Spy: Memory Allocator Properties"></a><p>A small update to the DirectShow Spy today: <a href="http://alax.info/blog/777">DirectShow Filter Graph Spy</a> prints memory allocator properties as a part of graph topology trace on transition to running state. Why is that and what it is for? Filters normally agree on allocator properties (<a href="http://msdn.microsoft.com/en-us/library/dd373419%28VS.85%29.aspx">ALLOCATOR_PROPERTIES</a>, obtained from <a href="http://msdn.microsoft.com/en-us/library/dd407061%28VS.85%29.aspx">IMemAllocator</a>, obtained from <a href="http://msdn.microsoft.com/en-us/library/dd407073%28VS.85%29.aspx">IMemInputPin</a>) themselves without interference from controlling application. Sometimes an undesired choice of buffers can cause sick runtime behavior, including but not limited to the following:</p>
<ol>
<li>live audio capture buffers are too long, and introduce significant latency, including from live video capture stream taking place in parallel; controlling application might need to take advantage of <a href="http://msdn.microsoft.com/en-us/library/dd389144%28VS.85%29.aspx">IAMBufferNegotiation::SuggestAllocatorProperties</a> and request shorter buffers.</li>
<li>a filter, such as for example DMO Wrapper Filter, may default to 1 buffer on allocator, which means that if a buffer reference is for some reason held for future reference (e.g. a video filter might be holding a reference to be able to re-push a video sample if an application is requesting video update), the entire streaming might lock.</li>
<li>some filters are requesting unreasonably many/large buffers and consume vast spaces of RAM, such as MainConcept MXF Demultiplexer requesting 200 buffers x 640 kilobytes each (128 MB in total out of sudden)</li>
<li>some filters are requesting unreasonably few/small buffers resulting in inability to pre-buffer data</li>
</ol>
<p>In a chase for answers to questions &#8220;Where is my memory?&#8221;, &#8220;Why is it so choppy?&#8221;, &#8220;I would really appreciate a nice lipsync&#8221; and to troubleshoot the mentioned scenarios it is helpful to understand buffering configuration. DirectShow Filter Spy is here to deliver this information. Once the graph is put into running state, spy prints out topology data into log file (which is in most cases C:\ProgramData\DirectShowSpy.log):</p>
<pre>Pin 2: Name "Input 01", Direction "Input", Peer "Tee 0x087A5AF0.Output2"
 Connection media type:
 majortype {73646976-0000-0010-8000-00AA00389B71}, subtype {31435641-0000-0010-8000-00AA00389B71}, pUnk 0x00000000
 bFixedSizeSamples 0, bTemporalCompression 0, lSampleSize 1
 formattype {E06D80E3-DB46-11CF-B4D1-00805F6CBBEA}, cbFormat 170, pbFormat 0x07c46fc0
pbFormat as MPEG2VIDEOINFO:
 rcSource { 0, 0, 0, 0 ), rcTarget { 0, 0, 0, 0 }
 dwBitRate 0, dwBitErrorRate 0, AvgTimePerFrame 0
 dwInterlaceFlags 0x0, dwCopyProtectFlags 0x0, dwPictAspectRatioX 16, dwPictAspectRatioY 9, dwControlFlags 0x0
 bmiHeader.biSize 40, bmiHeader.biWidth 1280, bmiHeader.biHeight 720, bmiHeader.biPlanes 1, bmiHeader.biBitCount 24, bmiHeader.biCompression avc1
 bmiHeader.biSizeImage 0, bmiHeader.biXPelsPerMeter 1, bmiHeader.biYPelsPerMeter 1, bmiHeader.biClrUsed 0, bmiHeader.biClrImportant 0
 dwStartTimeCode 0x00000000, cbSequenceHeader 38, dwProfile 100, dwLevel 31, dwFlags 0x4
 [0x0000] 00 1D 67 64 00 1F AC 24 88 05 00 5B BF F0 00 10
 [0x0010] 00 11 00 00 03 03 E8 00 00 E9 BA 0F 18 32 A0 00
 [0x0020] 05 68 EE 32 C8 B0
<strong><span style="text-decoration: underline;"> Memory Allocator: 1 buffers, 1,024 bytes each (1,024 bytes total), align 1, prefix 0</span></strong></pre>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available  from SVN</a>, release binary included (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>,  <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>);  installation instructions are in <a href="http://alax.info/blog/777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1168/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DirectShow Spy: IAMFilterData interface</title>
		<link>http://alax.info/blog/1111</link>
		<comments>http://alax.info/blog/1111#comments</comments>
		<pubDate>Mon, 08 Feb 2010 18:47:28 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[mapper]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1111</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1111" title="DirectShow Spy: IAMFilterData interface"></a>This quick update for DirectShow Filter Graph Spy adds tracing for (deprecated) IAMFilterData interface, and also fixes problem with Media Player Classic &#8211; Home Cinema, when the player crashes in External Filters windows. Partial Visual C++ .NET 2008 source code &#8230;<p class="read-more"><a href="http://alax.info/blog/1111">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1111" title="DirectShow Spy: IAMFilterData interface"></a><p>This quick update for <a href="http://alax.info/blog/777">DirectShow Filter Graph Spy</a> adds tracing for (deprecated) <a href="http://msdn.microsoft.com/en-us/library/dd389369%28VS.85%29.aspx" rel="nofollow">IAMFilterData</a> interface, and also fixes problem with <a href="http://www.xvidvideo.ru/media-player-classic-home-cinema-x86-x64/">Media Player Classic &#8211; Home Cinema</a>, when the player <a href="http://alax.info/blog/1100/comment-page-1#comment-5738">crashes in External Filters windows</a>.</p>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary included (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>, <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>); installation instructions are in <a href="http://alax.info/blog/777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1111/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>DirectShow Spy: Filter Mapper Spy</title>
		<link>http://alax.info/blog/1100</link>
		<comments>http://alax.info/blog/1100#comments</comments>
		<pubDate>Thu, 24 Dec 2009 13:07:50 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[mapper]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1100</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1100" title="DirectShow Spy: Filter Mapper Spy"></a>DirectShow Filter Graph Spy was updated to add new functionality: spying over another DirectShow object &#8211; Filter Mapper. Filter Mapper object is used for filter registration purposes and also internally by DirectShow&#8217;s Intelligent Connect. IFilterMapper2 interface traces provide detailed description &#8230;<p class="read-more"><a href="http://alax.info/blog/1100">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1100" title="DirectShow Spy: Filter Mapper Spy"></a><p><a href="http://alax.info/blog/777">DirectShow Filter Graph Spy</a> was updated to add new functionality: spying over another DirectShow object &#8211; <a href="http://msdn.microsoft.com/en-us/library/dd375788%28VS.85%29.aspx">Filter Mapper</a>. Filter Mapper object is used for filter registration purposes and also internally by DirectShow&#8217;s <a href="http://msdn.microsoft.com/en-us/library/ms940065.aspx">Intelligent Connect</a>. <a href="http://msdn.microsoft.com/en-us/library/dd390033%28VS.85%29.aspx">IFilterMapper2</a> interface traces provide detailed description on steps DirectShow takes in order to connect and/or render filter pins. For example when trying to render <em>MEDIATYPE_Audio</em> pin, Filter Mapper suggested &#8220;RDP DShow Redirection Filter&#8221; and, then, &#8220;Default DirectSound Device&#8221;:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">186</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> nFlags 0x0<span style="color: #808030;">,</span> bExactMatch <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nMinimalMerit 0x00200001<span style="color: #808030;">,</span> bInputNeeded <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> nInputTypeCount <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> pInputPinCategory NULL<span style="color: #808030;">,</span> bRender <span style="color: #008c00;">1</span><span style="color: #808030;">,</span> bOutputNeeded <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nOutputTypeCount <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> pOutputPinCategory NULL
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">191</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> nInputTypeIndex <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> MajorType <span style="color: #808030;">{</span><span style="color: #008c00;">73647561</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0010</span><span style="color: #808030;">-</span><span style="color: #008c00;">8000</span><span style="color: #808030;">-</span>00AA00389B71<span style="color: #808030;">}</span><span style="color: #808030;">,</span> Subtype <span style="color: #808030;">{</span><span style="color: #008c00;">00000000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">0000</span><span style="color: #808030;">-</span><span style="color: #008c00;">000000000000</span><span style="color: #808030;">}</span>
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">212</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> pMoniker @device<span style="color: #808030;">:</span>sw<span style="color: #808030;">:</span><span style="color: #808030;">{</span>083863F1<span style="color: #808030;">-</span>70DE<span style="color: #808030;">-</span>11D0<span style="color: #808030;">-</span>BD40<span style="color: #808030;">-</span>00A0C911CE86<span style="color: #808030;">}</span><span style="color: #808030;">\</span><span style="color: #808030;">{</span>AB9D6472<span style="color: #808030;">-</span>752F<span style="color: #808030;">-</span>43F6<span style="color: #808030;">-</span>B29E<span style="color: #808030;">-</span>61207BDA8E06<span style="color: #808030;">}</span>
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">220</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> sFriendlyName <span style="color: #800000;">"</span><span style="color: #0000e6;">RDP DShow Redirection Filter</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDescription <span style="color: #800000;">"</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDevicePath <span style="color: #800000;">"</span><span style="color: #800000;">"</span>
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">212</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> pMoniker @device<span style="color: #808030;">:</span>cm<span style="color: #808030;">:</span><span style="color: #808030;">{</span>E0F158E1<span style="color: #808030;">-</span>CB04<span style="color: #808030;">-</span>11D0<span style="color: #808030;">-</span>BD4E<span style="color: #808030;">-</span>00A0C911CE86<span style="color: #808030;">}</span><span style="color: #808030;">\</span>Default DirectSound Device
FilterMapperSpy<span style="color: #008c00;">.</span>h<span style="color: #808030;">(</span><span style="color: #008c00;">220</span><span style="color: #808030;">)</span><span style="color: #808030;">:</span> CFilterMapperSpy<span style="color: #808030;">:</span><span style="color: #808030;">:</span>EnumMatchingFilters<span style="color: #808030;">:</span> sFriendlyName <span style="color: #800000;">"</span><span style="color: #0000e6;">Default DirectSound Device</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDescription <span style="color: #800000;">"</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> sDevicePath <span style="color: #800000;">"</span><span style="color: #800000;">"</span></pre>
<p>Important is that DirectShow&#8217;s internals are using the mapper through COM instantiation and this provides a safe method to override default behavior process wide in order to, for example, extend <a href="http://msdn.microsoft.com/en-us/library/ms940065.aspx">Intelligent Connect</a> functionality onto custom, unregistered globally, private filters.</p>
<p>Also, the binary is renamed from FilterGraphSpy.dll to DirectShowSpy.dll.</p>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary included (<a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>, <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>); installation instructions are in <a href="./777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1100/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>DirectShow Filter Graph Spy: 64-bit version and hook API</title>
		<link>http://alax.info/blog/1094</link>
		<comments>http://alax.info/blog/1094#comments</comments>
		<pubDate>Sun, 01 Nov 2009 19:30:19 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[spy]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1094</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1094" title="DirectShow Filter Graph Spy: 64-bit version and hook API"></a>Today&#8217;s update for DirectShow Filter Graph Spy introduces 64-bit version (mind the beta state) and a mini-API for an external module to be involved into graph building process. Filter Graph Spy is offering three new interfaces that provide extensibility of &#8230;<p class="read-more"><a href="http://alax.info/blog/1094">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1094" title="DirectShow Filter Graph Spy: 64-bit version and hook API"></a><p>Today&#8217;s update for DirectShow Filter Graph Spy introduces 64-bit version (mind the beta state) and a mini-API for an external module to be involved into graph building process.</p>
<p>Filter Graph Spy is offering three new interfaces that provide extensibility of the spy:</p>
<ul>
<li>IFilterGraphAddRemoveHook</li>
<li>IFilterGraphConnectHook</li>
<li>IFilterGraphStateControlHook</li>
</ul>
<p>The interfaces are contained in the type library and can be imported using <a href="http://msdn.microsoft.com/en-us/library/8etzzkb6%28VS.71%29.aspx">#import</a> directive. An implementation of one or more of these interfaces will receive hook style calls corresponding to respective <a href="http://msdn.microsoft.com/en-us/library/dd375786%28VS.85%29.aspx">Filter Graph Manager</a> calls, system wide including in context of other applications.</p>
<p>A COM object may be registered as a hook object with <em>Spy</em> and <em>NoThreadSpy</em> COM classes under predefined registry keys:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/11/02-Image001.png"><img class="alignnone size-medium wp-image-1095" title="Registering a DirectShow Filter Graph Spy Hook" src="http://alax.info/blog/wp-content/uploads/2009/11/02-Image001-320x136.png" alt="Registering a DirectShow Filter Graph Spy Hook" width="320" height="136" /></a></p>
<p>Spy will instantiate the registered hook objects and forward them the calls it receive, before passing them to system Filter Graph Manager object. A hook object has an option to override default processing, including, for example, inserting its own filter in between. For example, <a href="http://msdn.microsoft.com/en-us/library/dd390021%28VS.85%29.aspx">IFilterGraph::Reconnect</a> call is implemented the following way:</p>
<pre>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">STDMETHOD<span style="color: #808030;">(</span>Reconnect<span style="color: #808030;">)</span><span style="color: #808030;">(</span>IPin<span style="color: #808030;">*</span> pPin<span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    _Z4<span style="color: #808030;">(</span>atlTraceCOM<span style="color: #808030;">,</span> <span style="color: #008c00;">4</span><span style="color: #808030;">,</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">...</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    HOOK_PROLOG<span style="color: #808030;">(</span>CFilterGraphConnectHookHost<span style="color: #808030;">)</span>
        OnReconnect<span style="color: #808030;">(</span>pT<span style="color: #808030;">,</span> pPin<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>bDefault<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    HOOK_EPILOG<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    <span style="color: #800000; font-weight: bold;">return</span> m_pInnerFilterGraph2<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Reconnect<span style="color: #808030;">(</span>pPin<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
</pre>
<p>Before passing the call to original Reconnect method, spy is iterating through associated hooks, passing them <em>IFilterGraphConnectHook::OnReconnect</em> call. Setting <em>bDefault</em> parameter to <em>FALSE</em> will prevent spy from passing the call to original method.</p>
<p>Included <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/BdaHooks">BdaHooks</a> project shows a sample implementation of the hooking COM classes (note <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/BdaHooks/ConnectHook.rgs">.rgs registration</a>).</p>
<p>Filter Graph Spy is compatible with all current Windows operating systems, 32-bit and 64-bit (<a href="http://en.wikipedia.org/wiki/X86-64">x64</a>), in particular including:</p>
<ul>
<li><a href="http://www.microsoft.com/windows/windows-7/">Windows 7</a></li>
<li>Windows Server 2008</li>
<li>Windows Vista</li>
<li>Windows Server 2003</li>
<li>Windows XP</li>
<li>Windows 2000</li>
</ul>
<p>NOTE: DirectShow Filter Graph Spy is <span style="text-decoration: underline;">NOT</span> suitable for production environment, it is <span style="text-decoration: underline;">NOT</span> licensed to be redistributed to be a part of production state software item.</p>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary included (<a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/Win32/DirectShowSpy.dll?format=raw">Win32</a>, <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/x64/DirectShowSpy.dll?format=raw">x64</a>); installation instructions are in <a href="http://alax.info/blog/777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1094/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DirectShow Filter Graph Spy: Log Filters and Connection Media Types</title>
		<link>http://alax.info/blog/1078</link>
		<comments>http://alax.info/blog/1078#comments</comments>
		<pubDate>Tue, 06 Oct 2009 19:26:23 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1078</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1078" title="DirectShow Filter Graph Spy: Log Filters and Connection Media Types"></a>Having hard time to connect to remote filter graph on Windows 7 machine, I suspected that some of the filters do not like being connected through marshaling and freeze. Or, actually more likely, it is SDK&#8217;s proppage.dll which hosts proxy &#8230;<p class="read-more"><a href="http://alax.info/blog/1078">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1078" title="DirectShow Filter Graph Spy: Log Filters and Connection Media Types"></a><p>Having hard time to connect to remote filter graph on Windows 7 machine, I suspected that some of the filters do not like being connected through marshaling and freeze. Or, actually more likely, it is SDK&#8217;s proppage.dll which hosts proxy stub pairs behaves itself in a not quite expected way and freezes remote application (Graph Edit or similar) during attempt to connect to remote graph.</p>
<p>As the goal was to find out details about connection media types between the filters being spied over, the spy received a new feature of logging graph details each time the graph is going to running state:</p>
<blockquote>
<pre>Filter 7: Name "[1BDADev]", Class {17CCA71B-ECD7-11D0-B908-00A0C9223196}, State 2
 Pin 1: Name "MPEG2 Transport", Direction "Input", Peer "[0BDATnr].MPEG2 Transport"
 Connection media type:
 majortype {E436EB83-524F-11CE-9F53-0020AF0BA770}, subtype {E06D8023-DB46-11CF-B4D1-00805F6CBBEA}, pUnk 0x00000000
 bFixedSizeSamples 0, bTemporalCompression 0, lSampleSize 1
 formattype {8DEDA6FD-AC5F-4334-8ECF-A4BA8FA7D0F0}, cbFormat 24, pbFormat 0x00350868
 [0x0000] BC 00 00 00 38 9A 00 00 00 00 00 00 00 00 00 00
 [0x0010] 00 00 00 00 00 00 00 00
 Pin 2: Name "MPEG2 Transport", Direction "Output", Peer "Infinite Pin Tee Filter[BDATsIft].Input"
 Connection media type:
 majortype {E436EB83-524F-11CE-9F53-0020AF0BA770}, subtype {F4AEB342-0329-4FDD-A8FD-4AFF4926C978}, pUnk 0x00000000
 bFixedSizeSamples 1, bTemporalCompression 0, lSampleSize 39480
 formattype {0F6417D6-C318-11D0-A43F-00A0C9223196}, cbFormat 0, pbFormat 0x00000000
Filter 8: Name "[0BDATnr]", Class {17CCA71B-ECD7-11D0-B908-00A0C9223196}, State 2
 Pin 1: Name "Input0", Direction "Input", Peer "Microsoft Network Provider[NwPvd].Antenna Out"
 Connection media type:
 majortype {71985F41-1CA1-11D3-9CC8-00C04F7971E0}, subtype {E436EB8E-524F-11CE-9F53-0020AF0BA770}, pUnk 0x00000000
 bFixedSizeSamples 0, bTemporalCompression 0, lSampleSize 1
 formattype {0F6417D6-C318-11D0-A43F-00A0C9223196}, cbFormat 0, pbFormat 0x00000000
 Pin 2: Name "MPEG2 Transport", Direction "Output", Peer "[1BDADev].MPEG2 Transport"
 Connection media type:
 majortype {E436EB83-524F-11CE-9F53-0020AF0BA770}, subtype {E06D8023-DB46-11CF-B4D1-00805F6CBBEA}, pUnk 0x00000000
 bFixedSizeSamples 0, bTemporalCompression 0, lSampleSize 1
 formattype {8DEDA6FD-AC5F-4334-8ECF-A4BA8FA7D0F0}, cbFormat 24, pbFormat 0x00350868
 [0x0000] BC 00 00 00 38 9A 00 00 00 00 00 00 00 00 00 00
 [0x0010] 00 00 00 00 00 00 00 00</pre>
</blockquote>
<p>Partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/FilterGraphSpy.dll?format=raw">included</a>; installation instructions are in <a href="http://alax.info/blog/777">another post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1078/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow Filter Graph Spy on Vista</title>
		<link>http://alax.info/blog/944</link>
		<comments>http://alax.info/blog/944#comments</comments>
		<pubDate>Mon, 22 Jun 2009 08:36:15 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[ATL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[spy]]></category>
		<category><![CDATA[Vista]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=944</guid>
		<description><![CDATA[<a href="http://alax.info/blog/944" title="DirectShow Filter Graph Spy on Vista"></a>I have been receiving comments that Filter Graph Spy tool does not work with Microsoft Vista operating system. I never had a moment to check until recently, and this time I realized that it really does not work. I am &#8230;<p class="read-more"><a href="http://alax.info/blog/944">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/944" title="DirectShow Filter Graph Spy on Vista"></a><p>I have been receiving comments that <a href="http://alax.info/blog/777">Filter Graph Spy</a> tool does not work with Microsoft Vista operating system. I never had a moment to check until recently, and this time I realized that it really does not work. I am definitely aware of dramatic changes introduced with this operating system, and in particular UAC feature, virtualization and changes in security. No wonder this was the first guess that security was the cause, however the investigation showed there was a trail of issues underneath&#8230;</p>
<p>Investigation details deserve a separate post, while this one briefly outlines the issues and also accompany the repository update with a version compatible with Vista OS.</p>
<p>First of all, COM registration of the DLL (which definitely requires privilege elevation) succeeded on Vista. This means the registration procedure did not encounter any errors on the way, or poorly written code ignored the problem. It appeared that the source of the problem was <a href="http://msdn.microsoft.com/en-us/library/ms693452(VS.85).aspx">CoTreatAsClass</a> API, which failed to do the requested action, however returned status code indicating successful operation. This definitely looks like a bug and further comments on this particular behavior are expected to appear on <a href="http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/threads/">Windows Applications Security MSDN forum</a>, where I opened <a href="http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/583793b8-a73c-4cb5-ae8c-a3620203aed9">a topic on the matter</a>.</p>
<p>With a COM TreatAs feature activated, the class&#8217;s behavior to instantiate instead of DirectShow&#8217;s CLSID_FilterGraph is restored, and in particular the DLL generates <em>FilterGraphSpy.log</em> log file on filter graph activity. Note that log file location is OS dependent (due to Vista&#8217;s permissions and file system virtualization):</p>
<ul>
<li>pre-Vista OS: root of syste drive, typically <em>C:\</em></li>
<li>starting Vista, administrator with elevated privileges: <em>CSIDL_COMMON_APPDATA</em>, typically <em>C:\ProgramData</em> (note this directory is hidden by deafult)</li>
<li>starting Vista, without elevated administrator privileges: <em>CSIDL_LOCAL_APPDATA</em>, typically <em>C:\Users\$(UserName)\AppData\Local</em> (note that <em>AppData</em> directory is hidden by deafult)</li>
</ul>
<p>Still even with the log file generated and indicating activation of the spy, it was unable to connect to remote graph through the running object table (ROT). It appeared that the ROT entires are there where expected, it was OK to get an object from ROT and the problem came from QueryInterface code:</p>
<pre>CComPtr<span style="color: #800080;">&lt;</span>IUnknown<span style="color: #800080;">&gt;</span> pFilterGraphUnknown<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pRunningObjectTable<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span><span style="color: #400000;">GetObject</span><span style="color: #808030;">(</span>pMoniker<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>pFilterGraphUnknown<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
CComQIPtr<span style="color: #800080;">&lt;</span>IMyFilterGraph<span style="color: #800080;">&gt;</span> pFilterGraph <span style="color: #808030;">=</span> pFilterGraphUnknown<span style="color: #800080;">;</span> <span style="color: #696969;">// <span style="color: #ff0000;">E_NOINTERFACE</span></span></pre>
<p>The call reached the original object but COM subsystem was unable to marshal the interface through apartments to enable interprocess communication on it. The reason for this is absence of <em>PSFactoryBuffer</em> class (CLSID {92A3A302-DA7C-4A1F-BA7E-1802BB5D2D02}), which provides proxy/stub pairs for marshaling well known DirectShow interfaces in the Vista&#8217;s version of <em>quartz.dll</em>. <a href="http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/5079f1c5-1275-4449-a11c-3cbb820e33eb">As mentioned by Microsoft&#8217;s Mike Wasson</a>, this class was moved from <em>quartz.dll</em> into Vista SDK&#8217;s <em>proppage.dll</em>, so in order to obtain connectivity to remote DirectShow graphs starting Vista, one needs to install this DLL with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en">Windows SDK</a>, or otherwise have it registered with the operating system.</p>
<p>Also note that DirectShow-enabled applications that have their filter graphs published on ROT will need an utility application such as <a href="http://msdn.microsoft.com/en-us/library/ms787460(VS.85).aspx">GraphEdit</a> started with the same permissions (elevated or not) in order to be able to access ROT entires.</p>
<div style="background-color: #efa; border: 1px solid #ffc; padding: 2px; ">To sum everything up, to install Alax.Info DirectShow Filter Graph Spy on Vista:<br/></p>
<ul>
<li>get the latest <em>FilterGraphSpy.dll</em></li>
<li>regsvr32 <em>FilterGraphSpy.dll</em> on target system from administrative command prompt, with elevated privileges (note you should have a log file <em>FilterGraphSpy.log</em> generated in CSIDL_COMMON_APPDATA directory, with a few lines indicating registration success)</li>
<li>get <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en">Windows SDK</a> and make <em>$(WindowsSDK)\Bin\proppage.dll</em> file registered on target system (also administrative regsvr32), note that it is necessary to restart DirectShow-enabled applications and GraphEdit after DLL registration to get graphs visible through ROT</li>
<li>mind the log file directories with <em>FilterGraphSpy.log</em> file</li>
</ul>
</div>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/FilterGraphSpy.dll?format=raw">included</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/944/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hint on how to easily find your filter graph on running object table (ROT)</title>
		<link>http://alax.info/blog/930</link>
		<comments>http://alax.info/blog/930#comments</comments>
		<pubDate>Thu, 11 Jun 2009 13:14:21 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[graphedit]]></category>
		<category><![CDATA[graphstudio]]></category>
		<category><![CDATA[moniker]]></category>
		<category><![CDATA[rot]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=930</guid>
		<description><![CDATA[<a href="http://alax.info/blog/930" title="Hint on how to easily find your filter graph on running object table (ROT)"></a>With a lot of DirectShow Filter Graphs published on Running Object Table, especially those automatically published by Filter Graph Spy utility, it might be a bit tricky to locate your graph of interest in the list. Filter graphs are published &#8230;<p class="read-more"><a href="http://alax.info/blog/930">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/930" title="Hint on how to easily find your filter graph on running object table (ROT)"></a><p>With a lot of <a href="http://msdn.microsoft.com/en-us/library/dd407188(VS.85).aspx">DirectShow Filter Graphs</a> published on <a href="http://msdn.microsoft.com/en-us/library/ms684004(VS.85).aspx">Running Object Table</a>, especially those automatically published by <a href="http://alax.info/blog/793">Filter Graph Spy utility</a>, it might be a bit tricky to locate your graph of interest in the list.</p>
<p>Filter graphs are published with a textual <a href="http://msdn.microsoft.com/en-us/library/ms680140(VS.85).aspx">moniker item name</a> of predefined format, which is recognized by <a href="http://msdn.microsoft.com/en-us/library/ms787460(VS.85).aspx">GraphEdit</a> or <a href="http://blog.monogram.sk/janos/tools/monogram-graphstudio/">GraphStudio</a>, or similar utilities as an item corresponding to a filter graph. A template for such a string is &#8220;<em>FilterGraph %08x pid %08x</em>&#8220;, which obviously only contains raw pointer address and process identifier, which only help a bit in looking up for proper graph interactively. However, it is important how exactly applications are recognizing filter graph related names. For example, GraphStudio <a href="http://dev.monogram.sk/websvn/listing.php?repname=graphstudio">does it</a> the following way:</p>
<pre>rot<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>EnumRunning<span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>emon<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
emon<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Reset<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800000; font-weight: bold;">while</span> <span style="color: #808030;">(</span>emon<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Next<span style="color: #808030;">(</span><span style="color: #008c00;">1</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>moniker<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>f<span style="color: #808030;">)</span> <span style="color: #808030;">=</span><span style="color: #808030;">=</span> NOERROR<span style="color: #808030;">)</span> <span style="color: #800080;">{</span>

    <span style="color: #696969;">// is this a graph object ?</span>
    LPOLESTR    displayname<span style="color: #800080;">;</span>
    moniker<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>GetDisplayName<span style="color: #808030;">(</span>bindctx<span style="color: #808030;">,</span> <span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>displayname<span style="color: #808030;">)</span><span style="color: #800080;">;</span>

    <span style="color: #603000;">CString</span>        name<span style="color: #808030;">(</span>displayname<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">if</span> <span style="color: #808030;">(</span>name<span style="color: #808030;">.</span>Find<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">!FilterGraph</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span> <span style="color: #808030;">=</span><span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">)</span> <span style="color: #800080;">{</span></pre>
<p>The items that match are then listed in GUI with an original string, which means that it is possible to provide an informational suffix to be able to locate the graph in a more convenient way, e.g. with a process image name, not only identifier (&#8220;; process: &#8230;&#8221; was appended to the item name):</p>
<p><img class="alignnone size-full wp-image-932" title="GraphStudio's ROT Items" src="http://alax.info/blog/wp-content/uploads/2009/06/11-image001.png" alt="GraphStudio's ROT Items" width="400" height="249" /></p>
<p>GraphEdit is using another method and is more strict in selecting among available items. AFAIR earlier versions did not allow custom suffixes in item names, however the latest version still picks the items up from the global list. However, GraphEdit does not show graph&#8217;s original item name, so suffixes are merely useless with GraphEdit.</p>
<p><img class="alignnone size-full wp-image-933" title="GraphEdit ROT Items" src="http://alax.info/blog/wp-content/uploads/2009/06/11-image002.png" alt="GraphEdit ROT Items" width="314" height="215" /></p>
<p><a href="http://alax.info/blog/793">Filter Graph Spy utility</a> was updated to automatically append process name suffix, which should be OK for both GrapEdit and GraphStudio. Still, the feature can be disabled through registry DWORD value named &#8220;<em>Enable ROT Moniker Item Name Suffix</em>&#8221; under <em>HKEY_LOCAL_MACHINE\SOFTWARE\Alax.Info\Utilities</em>. The value of zero, or missing, is the default behavior to enable suffixes. The value of 1 disables the feature, the value of 2 makes sure it is enabled.</p>
<pre><span style="color: #800000; font-weight: bold;">static</span> CConstIntegerRegistryValue g_nEnableRotMonikerItemNameSuffix<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Enable ROT Moniker Item Name Suffix</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span> <span style="color: #696969;">// 0 Default, 1 Disable, 2 Enable</span>
<span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>g_nEnableRotMonikerItemNameSuffix <span style="color: #808030;">!</span><span style="color: #808030;">=</span> <span style="color: #008c00;">1</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    <span style="color: #603000;">TCHAR</span> pszPath<span style="color: #808030;">[</span>MAX_PATH<span style="color: #808030;">]</span> <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> <span style="color: #008c00;">0</span> <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
    _W<span style="color: #808030;">(</span><span style="color: #400000;">GetModuleFileName</span><span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> pszPath<span style="color: #808030;">,</span> DIM<span style="color: #808030;">(</span>pszPath<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #603000;">CString</span> sItemName <span style="color: #808030;">=</span> AtlFormatString<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0f69ff;">%s</span><span style="color: #0000e6;">; process: </span><span style="color: #0f69ff;">%s</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> m_RunningFilterGraph<span style="color: #808030;">.</span>GetDefaultMonikerItemName<span style="color: #808030;">(</span>GetControllingUnknown<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> FindFileName<span style="color: #808030;">(</span>pszPath<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    m_RunningFilterGraph<span style="color: #808030;">.</span>SetFilterGraph<span style="color: #808030;">(</span>GetControllingUnknown<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> CStringW<span style="color: #808030;">(</span>sItemName<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span> <span style="color: #800000; font-weight: bold;">else</span>
    m_RunningFilterGraph<span style="color: #808030;">.</span>SetFilterGraph<span style="color: #808030;">(</span>GetControllingUnknown<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span></pre>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/FilterGraphSpy.dll?format=raw">included</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/930/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More on DirectShow Filter Graph Spy</title>
		<link>http://alax.info/blog/793</link>
		<comments>http://alax.info/blog/793#comments</comments>
		<pubDate>Sat, 07 Feb 2009 09:55:30 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=793</guid>
		<description><![CDATA[<a href="http://alax.info/blog/793" title="More on DirectShow Filter Graph Spy"></a>Having DirectShow Filter Graph Spy installed in the system, I noticed a new and weird effect that when Media Player Classic plays a list of files and each MP3 file being currently decoded shows decoder&#8217;s system tray icon, a switch &#8230;<p class="read-more"><a href="http://alax.info/blog/793">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/793" title="More on DirectShow Filter Graph Spy"></a><p>Having <a href="http://alax.info/blog/784">DirectShow Filter Graph Spy</a> installed in the system, I noticed a new and weird effect that when <a href="http://sourceforge.net/projects/guliverkli/">Media Player Classic</a> plays a list of files and each MP3 file being currently decoded shows decoder&#8217;s system tray icon, a switch to a new file leaves an old icon in place and adds a new icon for a new decoder.  I thought this might be also a decoder&#8217;s problem which I also recently updated to a new version, but then I noticed other artifacts, with other software and again with <a href="http://sourceforge.net/projects/guliverkli/">Media Player Classic</a>, that if I drop a new file onto the player and it starts playing it, old file is still being played as if player just releases all referenced to the graph and never calls <a href="http://msdn.microsoft.com/en-us/library/dd390178(VS.85).aspx">IMediaControl::Stop</a> to force stop of playback.</p>
<p>It was clear at that point that it is related to filter graph spy and the problem needs a fix. The problem definitely looked like the spy leave outstanding references to the filter graph and when the application releases graph and it is supposed to be automatically destroyed, it is still being alive and possibly, such as in case of <a href="http://sourceforge.net/projects/guliverkli/">Media Player Classic</a>, even running.</p>
<p>The first clue was that being published to running object table (ROT), the object gets more than one additional reference on it and as such it never gets removed from ROT until application terminates as ROT keeps a reference to the graph and there is noone to remove it. By original design spy published filter graph on ROT and removed one reference immediately after that to compensate the ROT&#8217;s reference (one only) making it a weak reference. So when all references are released from the filter graph but ROT reference, the graph gets destroyed and in <a href="http://msdn.microsoft.com/en-us/library/ea0ca499.aspx">FinalRelease</a> class on the COM object we re-add the reference back and automatically remove the object from ROT as well. The whole scheme works in assumption that ROT adds one reference only, if there are more then the object is referenced by the ROT forever.</p>
<p>Debugging however showed that ROT adds a single reference and there is no problem from this side. However I immediately noticed  another weird behavior in the same method <a href="http://msdn.microsoft.com/en-us/library/afkt56xx.aspx">FinalConstruct</a>. An underlying (real) filter graph object, i.e. CFilterGraph from quartz.dll, is adding a reference on the outer COM object when being queried for a private interface from <a href="http://msdn.microsoft.com/en-us/library/ms810016.aspx">implicit</a> (also known as main, raw) IUnknown when created as aggregated object. And it is not exactly the behavior one would expect from aggregated object because it basically break proper reference counting. I realize that aggregating is a rather rare technique and DirectShow COM base is one of the very first COM bases at all which then stopped being developed, so perhaps this problem was not identified on time and later left unfixed at all, so in present situation there should rather be a workaround.</p>
<p>It is also worth mentioning that there are two scenarios involved. My <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Spy.h">CSpy</a> object creates DirectShow <a href="http://msdn.microsoft.com/en-us/library/dd375786(VS.85).aspx">CFilterGraph</a> as an aggregated object. And CSpy in its turn may be created as aggregated too. For example, <a href="http://www.microsoft.com/windows/windowsmedia/players.aspx">Windows Media Player</a> creates (as most applications in this universe do) filter graph object the regular way, as a standalone COM object. However it appears that <a href="http://sourceforge.net/projects/guliverkli/">Media Player Classic</a> creates filter graph as aggregated, for whatever it needs it for. Because of the discovered problem inner CFilterGraph adds an outstanding reference on the top level &#8220;controlling IUnknown&#8221;, which is either CSpy&#8217;s private IUnkown in case of <a href="http://www.microsoft.com/windows/windowsmedia/players.aspx">Windows Media Player</a>, or higher level IUnknown in case of <a href="http://sourceforge.net/projects/guliverkli/">Media Player Classic</a>.</p>
<p>So the proper workaround is to release unwanted references from controlling unknown rather than self:</p>
<pre>CComPtr<span style="color: #800080;">&lt;</span>IUnknown<span style="color: #800080;">&gt;</span> pUnknown<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>pClassFactory<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>CreateInstance<span style="color: #808030;">(</span>pControllingUnknown<span style="color: #808030;">,</span> <span style="color: #800000; font-weight: bold;">__uuidof</span><span style="color: #808030;">(</span>IUnknown<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #808030;">(</span><span style="color: #603000;">VOID</span><span style="color: #808030;">*</span><span style="color: #808030;">*</span><span style="color: #808030;">)</span> <span style="color: #808030;">&amp;</span>pUnknown<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #696969;">// NOTE: DirectShow FilterGraph is incorrectly implementing COM aggregation adding outer reference to interfaces queried from private IUnknown</span>
CComQIPtr<span style="color: #800080;">&lt;</span>IFilterGraph2<span style="color: #800080;">&gt;</span> pFilterGraph2 <span style="color: #808030;">=</span> pUnknown<span style="color: #800080;">;</span>
ATLENSURE_THROW<span style="color: #808030;">(</span>pFilterGraph2<span style="color: #808030;">,</span> E_NOINTERFACE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
pFilterGraph2<span style="color: #808030;">.</span>p<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Release<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span> <span style="color: #696969;">// &lt;&lt;--------------------------</span></pre>
<p>It looked like the problem is finally worked around but in aggregated creation scenario it brought another problem up. Since instantiation of inner CFilterGraph takes place in FinalConstruct and CSpy is also being instantiated as aggregated, it appears that outer COM object is sensible to manipulation with its reference counter. CFilterGraph added a reference it should not, CSpy released it in compensation but on this early stage the compensating Release might zero reference counter and might initiate unexpected object destruction. It is not necessarily this way as it depends on outer COM object base, but it seems that Media Player Classic does not do <a href="http://msdn.microsoft.com/en-us/library/97c868sh.aspx">DECLARE_PROTECT_FINAL_CONSTRUCT</a> or its equavalent and things go the worst scenario.</p>
<p>CSpy is an inner object and we don&#8217;t have any external instance to hold a temporary reference for us while outer COM object is being created, so a workround for this is to temporarily hold a circular reference to an outer object to let it complete its instanatiation and pass another reference higher up to the controlling application. At which point we are going to be safe to release the temporary reference and normalize reference counters.</p>
<pre><span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>m_bIsAggregated<span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    pControllingUnknown<span style="color: #808030;">.</span>p<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>AddRef<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">ULONG</span> nReferenceCount <span style="color: #808030;">=</span> pControllingUnknown<span style="color: #808030;">.</span>p<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>Release<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>nReferenceCount <span style="color: #808030;">=</span><span style="color: #808030;">=</span> <span style="color: #008c00;">1</span><span style="color: #808030;">)</span>
        m_pTemporaryUnknown <span style="color: #808030;">=</span> pControllingUnknown<span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
<p>The only thing is left is to release the temporary reference early enough, but we have a filter graph, don&#8217;t we? What is typically done with a filter graph, adding a filter right? And it is a controlling application which has its own reference, who adds filters so we are safe to release temporary reference in <a href="http://msdn.microsoft.com/en-us/library/dd390016(VS.85).aspx">IFilterGraph::AddFilter</a> or <a href="http://msdn.microsoft.com/en-us/library/dd390087(VS.85).aspx">IGraphBuilder::AddSourceFilter</a> (actually it would not hurt to add this in other methods as well):</p>
<pre>STDMETHOD<span style="color: #808030;">(</span>AddFilter<span style="color: #808030;">)</span><span style="color: #808030;">(</span>IBaseFilter<span style="color: #808030;">*</span> pFilter<span style="color: #808030;">,</span> <span style="color: #603000;">LPCWSTR</span> pszName<span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    _Z4<span style="color: #808030;">(</span>atlTraceCOM<span style="color: #808030;">,</span> <span style="color: #008c00;">4</span><span style="color: #808030;">,</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">pszName </span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">%s</span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>pszName<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    ReleaseTemporaryUnknown<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span> <span style="color: #696969;">// &lt;&lt;--------------------------</span>
    <span style="color: #800000; font-weight: bold;">return</span> m_pInnerFilterGraph2<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>AddFilter<span style="color: #808030;">(</span>pFilter<span style="color: #808030;">,</span> pszName<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
<p>Additionally, the spy also implements now <a href="http://msdn.microsoft.com/en-us/library/dd390170(VS.85).aspx">IMediaControl</a> interface and traces calls to log file, it is convenient.</p>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/FilterGraphSpy.dll?format=raw">included</a>.</p>
<p>reg-FilterGraphSpy.dll.bat and unreg-FilterGraphSpy.dll.bat files <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace">in SVN</a> are convenient batch files to register and unregister the spy with the operating system.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/793/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow Filter Graph Spy &#8211; CLSID_FilterGraphNoThread</title>
		<link>http://alax.info/blog/784</link>
		<comments>http://alax.info/blog/784#comments</comments>
		<pubDate>Thu, 29 Jan 2009 21:11:45 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=784</guid>
		<description><![CDATA[<a href="http://alax.info/blog/784" title="DirectShow Filter Graph Spy - CLSID_FilterGraphNoThread"></a>At the time of original implementation I intentionally left off a variation of Filter Graph Manager that runs on application thread, CLSID_FilterGraphNoThread. MSDN says: CLSID_FilterGraphNoThread creates the Filter Graph Manager on the application&#8217;s thread. If you use this CLSID, the &#8230;<p class="read-more"><a href="http://alax.info/blog/784">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/784" title="DirectShow Filter Graph Spy - CLSID_FilterGraphNoThread"></a><p>At the time of <a href="http://alax.info/blog/777">original implementation</a> I intentionally left off a variation of <a href="http://msdn.microsoft.com/en-us/library/dd375786(VS.85).aspx">Filter Graph Manager</a> that runs on application thread, CLSID_FilterGraphNoThread. MSDN says:</p>
<p style="padding-left: 30px;">CLSID_FilterGraphNoThread creates the Filter Graph Manager on the application&#8217;s thread. If you use this CLSID, the thread that calls CoCreateInstance must have a message loop that dispatches messages; otherwise, deadlocks can occur. Also, before the application thread exits, it must release the Filter Graph Manager and all graph objects (such as filters, pins, reference clocks, and so forth).</p>
<p>I have never needed to use this CLSID (by the way Windows SDK has one more CLSID &#8211; CLSID_FilterGraphPrivateThread &#8211; but it does not seem to be documented) and for this reason I left it for the time a need in it comes up. However it appeared that this CLSID was not created just for fun, there was a need in it. Filter graphs of Windows Media Player playing well known Windows&#8217; clock.avi appeared to be not published on <a href="http://msdn.microsoft.com/en-us/library/ms684004%28VS.85%29.aspx">Running Object Table</a>. Why?</p>
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx">Process Monitor</a> showed clearly that Windows Media Player created filter graph through CLSID_FilterGraphNoThread and quite obviously it was not intercepted by <a href="http://alax.info/blog/777">Filter Graph Spy</a> (still I wonder what made it different previous time when I could see WMP&#8217;s graph).</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/01/29-image001.png"><img class="alignnone size-medium wp-image-785" title="Another Windows Media Player Filter Graph" src="http://alax.info/blog/wp-content/uploads/2009/01/29-image001-300x119.png" alt="" width="300" height="119" /></a></p>
<p><span id="more-784"></span></p>
<p>In order to extend spy&#8217;s support to CLSID_FilterGraphNoThread I moved most of the code from CSpy COM class into CSpyT template class and derived two COM classes from it, CSpy and CNoThreadSpy, in order to cover and &#8220;COM Treat As&#8221; both DirectShow/Quartz COM classes.</p>
<pre><span style="color: #3f5fbf;">////////////////////////////////////////////////////////////</span>
<span style="color: #696969;">// CSpy</span>

<span style="color: #800000; font-weight: bold;">class</span> ATL_NO_VTABLE CSpy <span style="color: #800080;">:</span>
    <span style="color: #800000; font-weight: bold;">public</span> CSpyT<span style="color: #800080;">&lt;</span>CSpy<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>CLSID_FilterGraph<span style="color: #800080;">&gt;</span><span style="color: #808030;">,</span>
    <span style="color: #800000; font-weight: bold;">public</span> CComCoClass<span style="color: #800080;">&lt;</span>CSpy<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>CLSID_Spy<span style="color: #800080;">&gt;</span>
<span style="color: #800080;">{</span>
<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>
    <span style="color: #800000; font-weight: bold;">enum</span> <span style="color: #800080;">{</span> IDR <span style="color: #808030;">=</span> IDR_SPY <span style="color: #800080;">}</span><span style="color: #800080;">;</span>

<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>
<span style="color: #696969;">// CSpy</span>
<span style="color: #800080;">}</span><span style="color: #800080;">;</span>

OBJECT_ENTRY_AUTO<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">__uuidof</span><span style="color: #808030;">(</span>Spy<span style="color: #808030;">)</span><span style="color: #808030;">,</span> CSpy<span style="color: #808030;">)</span>

<span style="color: #3f5fbf;">////////////////////////////////////////////////////////////</span>
<span style="color: #696969;">// CNoThreadSpy</span>

<span style="color: #800000; font-weight: bold;">class</span> ATL_NO_VTABLE CNoThreadSpy <span style="color: #800080;">:</span>
    <span style="color: #800000; font-weight: bold;">public</span> CSpyT<span style="color: #800080;">&lt;</span>CNoThreadSpy<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>CLSID_FilterGraphNoThread<span style="color: #800080;">&gt;</span><span style="color: #808030;">,</span>
    <span style="color: #800000; font-weight: bold;">public</span> CComCoClass<span style="color: #800080;">&lt;</span>CNoThreadSpy<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>CLSID_NoThreadSpy<span style="color: #800080;">&gt;</span>
<span style="color: #800080;">{</span>
<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>
    <span style="color: #800000; font-weight: bold;">enum</span> <span style="color: #800080;">{</span> IDR <span style="color: #808030;">=</span> IDR_NOTHREADSPY <span style="color: #800080;">}</span><span style="color: #800080;">;</span>

<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>
<span style="color: #696969;">// CNoThreadSpy</span>
<span style="color: #800080;">}</span><span style="color: #800080;">;</span>

OBJECT_ENTRY_AUTO<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">__uuidof</span><span style="color: #808030;">(</span>NoThreadSpy<span style="color: #808030;">)</span><span style="color: #808030;">,</span> CNoThreadSpy<span style="color: #808030;">)</span></pre>
<p>A partial Visual C++ .NET 2008 source code is <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy">available from SVN</a>, release binary <a href="http://code.assembla.com/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/Release%20Trace/FilterGraphSpy.dll?format=raw">included</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/784/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

