<?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; registry</title>
	<atom:link href="http://alax.info/blog/tag/registry/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>Microsoft.Jet.OLEDB.4.0 ProgID is not available (Windows 7 but probably not only)</title>
		<link>http://alax.info/blog/1086</link>
		<comments>http://alax.info/blog/1086#comments</comments>
		<pubDate>Fri, 30 Oct 2009 08:56:38 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[ole]]></category>
		<category><![CDATA[oledb]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[win7]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1086</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1086" title="Microsoft.Jet.OLEDB.4.0 ProgID is not available (Windows 7 but probably not only)"></a>It was a sort of ridiculous problem: an attempt to instantiate a Microsoft.Jet.OLEDB.4.0 object failed with error. Still some applications are still running without problems connecting to Jet databases, how comes? There has been a number of posts on Internet, &#8230;<p class="read-more"><a href="http://alax.info/blog/1086">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1086" title="Microsoft.Jet.OLEDB.4.0 ProgID is not available (Windows 7 but probably not only)"></a><p>It was a sort of ridiculous problem: an attempt to instantiate a Microsoft.Jet.OLEDB.4.0 object failed with error. Still some applications are still running without problems connecting to Jet databases, how comes?</p>
<p>There has been <a href="http://www.google.com/search?q=Microsoft.Jet.OLEDB.4.0">a number of posts on Internet</a>, but none of the top ones appeared to be relevant.</p>
<p>The problem is reproduced extremely simple:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><span style="color: #800000; font-weight: bold;">int</span> _tmain<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">int</span> argc<span style="color: #808030;">,</span> _TCHAR<span style="color: #808030;">*</span> argv<span style="color: #808030;">[</span><span style="color: #808030;">]</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    ATLVERIFY<span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>CoInitialize<span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">{</span>
        <span style="color: #696969;">//CoLoadLibrary(L"C:\\Program Files (x86)\\Common Files\\System\\Ole DB\\oledb32.dll", TRUE);</span>
        CComPtr<span style="color: #800080;">&lt;</span>IDBInitialize<span style="color: #800080;">&gt;</span> pDbInitialize<span style="color: #800080;">;</span>
        <span style="color: #800000; font-weight: bold;">const</span> HRESULT nResult <span style="color: #808030;">=</span> pDbInitialize<span style="color: #808030;">.</span>CoCreateInstance<span style="color: #808030;">(</span><span style="color: #800000;">L"</span><span style="color: #0000e6;">Microsoft.Jet.OLEDB.4.0</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> <span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> CLSCTX_INPROC_SERVER<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        _tprintf<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">nResult 0x</span><span style="color: #0f69ff;">%08x</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> nResult<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    CoUninitialize<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
<p>Oops, the code gives error REGDB_E_CLASSNOTREG 0&#215;80040154 &#8220;Class not registered&#8221;. It looked like system was unable to locate one of the internally used DLLs &#8211; oledb32.dll, and if we help by uncommenting the line commented in the code snippet above, the error changes to ERROR_MOD_NOT_FOUND 0x8007007e &#8220;The specified module could not be found&#8221;.</p>
<p>The problem appears to be that one of the system components, which is involved, &#8220;Microsoft OLE DB Data Conversion Library&#8221; is registered with the system using a <a href="http://msdn.microsoft.com/en-us/library/ms724884%28VS.85%29.aspx">REG_EXPAND_SZ</a> value, to be located using path &#8220;%CommonProgramFiles(x86)%\System\Ole DB\oledb32.dll&#8221;. It is obvious that <strong>CommonProgramFiles(x86)</strong> is placeholder to be expanded, but does the expansion succeed?</p>
<p><span id="more-1086"></span></p>
<p>On my system there was no such environment string, so expansion failed. There however was <strong>CommonProgramFiles</strong>, and it pointed to correct location. So, this hot fix makes it work right:</p>
<pre><span style="color: #603000;">BOOL</span> UpdateEnvironmentVariables<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    <span style="color: #603000;">CString</span> sCommonProgramFilesX86<span style="color: #800080;">;</span>
    sCommonProgramFilesX86<span style="color: #808030;">.</span><span style="color: #400000;">GetEnvironmentVariable</span><span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">CommonProgramFiles(x86)</span><span style="color: #800000;">"</span><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>sCommonProgramFilesX86<span style="color: #808030;">.</span>IsEmpty<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> sCommonProgramFiles<span style="color: #800080;">;</span>
        sCommonProgramFiles<span style="color: #808030;">.</span><span style="color: #400000;">GetEnvironmentVariable</span><span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">CommonProgramFiles</span><span style="color: #800000;">"</span><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><span style="color: #808030;">!</span>sCommonProgramFiles<span style="color: #808030;">.</span>IsEmpty<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            ATLVERIFY<span style="color: #808030;">(</span><span style="color: #400000;">SetEnvironmentVariable</span><span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">CommonProgramFiles(x86)</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> sCommonProgramFiles<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #800000; font-weight: bold;">return</span> TRUE<span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
    <span style="color: #800080;">}</span>
    <span style="color: #800000; font-weight: bold;">return</span> FALSE<span style="color: #800080;">;</span>
<span style="color: #800080;">}</span>

<span style="color: #800000; font-weight: bold;">int</span> _tmain<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">int</span> argc<span style="color: #808030;">,</span> _TCHAR<span style="color: #808030;">*</span> argv<span style="color: #808030;">[</span><span style="color: #808030;">]</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    ATLVERIFY<span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>CoInitialize<span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">{</span>
        UpdateEnvironmentVariables<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        CComPtr<span style="color: #800080;">&lt;</span>IDBInitialize<span style="color: #800080;">&gt;</span> pDbInitialize<span style="color: #800080;">;</span>
        <span style="color: #800000; font-weight: bold;">const</span> HRESULT nResult <span style="color: #808030;">=</span> pDbInitialize<span style="color: #808030;">.</span>CoCreateInstance<span style="color: #808030;">(</span><span style="color: #800000;">L"</span><span style="color: #0000e6;">Microsoft.Jet.OLEDB.4.0</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> <span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> CLSCTX_INPROC_SERVER<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        _tprintf<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">nResult 0x</span><span style="color: #0f69ff;">%08x</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> nResult<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    CoUninitialize<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
<span style="color: #800080;">} </span></pre>
<p>I am under impression that the problem is not specific to Windows 7. I remember similar symptoms on Windows XP system, but they were not critical and not investigated to solution. It rather seems that OLE DB component is registering itself using a reference to environment variable which is not present on a number of systems.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 81px; width: 1px; height: 1px;">
<h3 class="r"><a class="l" onmousedown="return rwt(this,'','','res','1','AFQjCNEiQBNPN2MLUciPFN3dRVUU-1FyJA','&amp;sig2=GPxd_FHW5MyBRM2Op0Da1A','0CAoQFjAA')" href="http://support.software602.com/kb/view.aspx?articleID=987">Error code 80040154. <em>Class not registered</em></a></h3>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1086/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RegSetKeySecurity, CRegKey::SetKeySecurity and CSecurityDesc</title>
		<link>http://alax.info/blog/950</link>
		<comments>http://alax.info/blog/950#comments</comments>
		<pubDate>Mon, 22 Jun 2009 18:10:43 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CRegKey]]></category>
		<category><![CDATA[CSecurityDesc]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[RegSetKeySecurity]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SetKeySecurity]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=950</guid>
		<description><![CDATA[<a href="http://alax.info/blog/950" title="RegSetKeySecurity, CRegKey::SetKeySecurity and CSecurityDesc"></a>One thing is worth special mentioning in connection with previous post on DirectShow Filter Graph Spy on Microsoft Vista system: ATL&#8217;s CSecurityDesc class caused to waste some time. CRegKey Key; ATLENSURE_SUCCEEDED(HRESULT_FROM_WIN32(Key.Open(HKEY_CLASSES_ROOT, pszKeyName, READ_CONTROL &#124; WRITE_OWNER))); CSecurityDesc AdministratorsOwnerSecurityDescriptor; AdministratorsOwnerSecurityDescriptor.SetOwner(Sids::Admins()); ATLENSURE_SUCCEEDED(HRESULT_FROM_WIN32(Key.SetKeySecurity(OWNER_SECURITY_INFORMATION, &#38;AdministratorsOwnerSecurityDescriptor))); &#8230;<p class="read-more"><a href="http://alax.info/blog/950">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/950" title="RegSetKeySecurity, CRegKey::SetKeySecurity and CSecurityDesc"></a><p>One thing is worth special mentioning in connection with previous post on <a href="http://alax.info/blog/944">DirectShow Filter Graph Spy</a> on <a href="http://www.microsoft.com/windows/windows-vista/default.aspx">Microsoft Vista</a> system: ATL&#8217;s CSecurityDesc class caused to waste some time.</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">CRegKey Key<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>Open<span style="color: #808030;">(</span>HKEY_CLASSES_ROOT<span style="color: #808030;">,</span> pszKeyName<span style="color: #808030;">,</span> READ_CONTROL <span style="color: #808030;">|</span> WRITE_OWNER<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
CSecurityDesc AdministratorsOwnerSecurityDescriptor<span style="color: #800080;">;</span>
AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">.</span>SetOwner<span style="color: #808030;">(</span>Sids<span style="color: #800080;">::</span>Admins<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>SetKeySecurity<span style="color: #808030;">(</span>OWNER_SECURITY_INFORMATION<span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>The code compiles fine, but on runtime it gives error <em>87</em> (<em>ERROR_INVALID_PARAMETER</em>, <em>E_INVALIDARG</em>) in the last line, returned from <a href="http://msdn.microsoft.com/en-us/library/aa379314(VS.85).aspx">RegSetKeySecurity</a> API call. My first guess was that ATL&#8217;s <a href="http://msdn.microsoft.com/en-us/library/k0c0e5w6.aspx">CSecurityDesc</a> class for some reason prepared wrong descriptor which resulted in rejecting it as an argument. From the first glance it looks (not sure) that this class deals, to some extent, with structures itself rather than using API functions, so it could be that it results in something looking differently from expected by API calls.</p>
<p>Still the problem is in class itself and its cast from <em>CSecurityDesc&amp;</em> to required <em>SECURITY_DESCRIPTOR*</em> type. The class only implements operator to automatically cast to <em><span style="color: #ff0000;">const</span> SECURITY_DESCRIPTOR*</em> type, so the following line would not be passed by compiler:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">Key<span style="color: #808030;">.</span>SetKeySecurity<span style="color: #808030;">(</span>OWNER_SECURITY_INFORMATION<span style="color: #808030;">,</span> AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">)</span></pre>
<p>However <em><span style="color: #ff0000;">&amp;</span>AdministratorsOwnerSecurityDescriptor</em> is another level of indirection and hence <em>SECURITY_DESCRIPTOR*</em><span style="color: #ff0000;">*</span> type, which is passed by compiler, but results in indeed invalid argument.</p>
<p>So in order to correctly convert <em>CSecurityDesc&amp;</em> to <em>SECURITY_DESCRIPTOR*</em> it can be done this way:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000;">CRegKey Key<span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>Open<span style="color: #808030;">(</span>HKEY_CLASSES_ROOT<span style="color: #808030;">,</span> pszKeyName<span style="color: #808030;">,</span> READ_CONTROL <span style="color: #808030;">|</span> WRITE_OWNER<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
CSecurityDesc AdministratorsOwnerSecurityDescriptor<span style="color: #800080;">;</span>
AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">.</span>SetOwner<span style="color: #808030;">(</span>Sids<span style="color: #800080;">::</span>Admins<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
ATLENSURE_SUCCEEDED<span style="color: #808030;">(</span>HRESULT_FROM_WIN32<span style="color: #808030;">(</span>Key<span style="color: #808030;">.</span>SetKeySecurity<span style="color: #808030;">(</span>OWNER_SECURITY_INFORMATION<span style="color: #808030;">,</span> const_cast<span style="color: #808030;">&lt;</span><span style="color: #603000;">SECURITY_DESCRIPTOR</span><span style="color: #808030;">*</span><span style="color: #808030;">&gt;</span><span style="color: #808030;">(</span><span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">SECURITY_DESCRIPTOR</span><span style="color: #808030;">*</span><span style="color: #808030;">)</span> AdministratorsOwnerSecurityDescriptor<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/950/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>ATL Registration Script</title>
		<link>http://alax.info/blog/630</link>
		<comments>http://alax.info/blog/630#comments</comments>
		<pubDate>Sat, 06 Sep 2008 16:05:27 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[rgs]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=630</guid>
		<description><![CDATA[<a href="http://alax.info/blog/630" title="ATL Registration Script"></a>Since ATL version 3, and actually it probably existed even since even earlier time, I have seen Microsoft Visual Studio (and its predecessor Visual C++) generating .RGS registration script with hardcoded CLSID value, ProgID values and other strings entered through &#8230;<p class="read-more"><a href="http://alax.info/blog/630">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/630" title="ATL Registration Script"></a><p>Since ATL version 3, and actually it probably existed even since even earlier time, I have seen Microsoft Visual Studio (and its predecessor Visual C++) generating .RGS registration script with hardcoded CLSID value, ProgID values and other strings entered through IDE wizard. While it seems to work nice at the moment of generation, it still gives the problem to lose sync between identifiers if code is copied between projects or a different way. It might be an oversight originally, but was not it the obvious thing to do later to avoid possible typos of inaccurate user? Microsoft Visua Studio 2008 still generates the same code.</p>
<p>Previous versions of development environment offered attributed code option which in fact took care of this problem very well. Although there has been a lot of negative feedback written about C++ attributes, this was a kind of problem attributes left no chances to break: CLSID was specified once only in C++ COM class attribute and the rest of the deal was generated automatically, including IDL and registration sequence.</p>
<p>It is especially unclear why it was left this way because internal ATL classes already have all necessary capabilities to process wildcards. For example, default .RGS script contains an entry for COM class type library, HKCR\CLSID\{&#8230;} key, &#8220;TypeLib&#8221; value. Why would hardcode it if it can be specified through a replacement:</p>
<pre>HKCR
{
	NoRemove CLSID
	{
		ForceRemove %CLSID% = s '...'
		{
<strong><span style="color: #3366ff;">			'TypeLib' = s '%LIBID%'
</span></strong></pre>
<p>And the replacement is so easily added overriding CAtlModule&#8217;s virtual AddCommonRGSReplacements:</p>
<pre>class CFooModule :
	public CAtlDllModuleT&lt;CFooModule&gt;
{
...
// CAtlModule
	HRESULT AddCommonRGSReplacements(IRegistrarBase* pRegistrar) throw()
	{
		_ATLTRY
		{
			ATLENSURE_SUCCEEDED(__super::AddCommonRGSReplacements(pRegistrar));
			ATLASSERT(!IsEqualGUID(m_libid, GUID_NULL));
			ATLENSURE_SUCCEEDED(pRegistrar-&gt;AddReplacement(L"LIBID", StringFromIdentifier(m_libid)));
		}
		_ATLCATCH(Exception)
		{
			return Exception;
		}
		return S_OK;
	}</pre>
<p>I thought it would be implemented natively in ATL long ago, along with per-coclass replacements like %CLSID%.</p>
<p>This is how I like my registration script:</p>
<pre>HKCR
{
	%PROGID% = s '%DESCRIPTION%'
	{
		CLSID = s '%CLSID%'
	}
	%VIPROGID% = s '%DESCRIPTION%'
	{
		CLSID = s '%CLSID%'
		CurVer = s '%PROGID%'
	}
	NoRemove CLSID
	{
		ForceRemove %CLSID% = s '%DESCRIPTION%'
		{
			ProgID = s '%PROGID%'
			VersionIndependentProgID = s '%VIPROGID%'
			ForceRemove 'Programmable'
			InprocServer32 = s '%MODULE%'
			{
				val ThreadingModel = s 'Both'
			}
			TypeLib = s '%LIBID%'
		}
	}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/630/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

