{"id":1648,"date":"2016-04-21T08:27:22","date_gmt":"2016-04-21T06:27:22","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=1648"},"modified":"2016-04-22T07:13:32","modified_gmt":"2016-04-22T05:13:32","slug":"directshowspy-regdb_e_classnotreg-with-immdeviceactivate","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/1648","title":{"rendered":"DirectShowSpy: REGDB_E_CLASSNOTREG with IMMDevice::Activate"},"content":{"rendered":"<p>A DirectShow developer <a href=\"http:\/\/stackoverflow.com\/questions\/36664818\/immdeviceactivate-with-ibasefilter-return-regdb-e-classnotreg-class-not-regi\">complained<\/a> on sudden failure of Core Audio <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd371405\"><code>IMMDevice::Activate<\/code><\/a> call supposed to instantiate a DirectShow filter for a given device.<\/p>\n<p>The problem appeared to be related to installed DirectShowSpy and its interference with the API calls. The symptom was of the following kind: when <code>Activate<\/code> was called for different types of objects, the calls all succeeded except interoperation with DirectShow (activation for <code>IBaseFilter<\/code>), e.g. <a href=\"https:\/\/alax.info\/blog\/1279\"><code>EnumerateAudioDevices<\/code><\/a> output:<\/p>\n<pre><code>    IAudioClient            0x00000000\r\n    IAudioEndpointVolume    0x00000000\r\n    IAudioMeterInformation  0x00000000\r\n    IAudioSessionManager    0x00000000\r\n    IAudioSessionManager2   0x00000000\r\n    IBaseFilter             REGDB_E_CLASSNOTREG\r\n    IDeviceTopology         0x00000000\r\n    IMFTrustedOutput        0x00000000\r\n<\/code><\/pre>\n<p>When Core Audio is requested to do DirectShow activation, the API creates and instance of <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd407180\">System Device Enumerator<\/a>, which is forwarded the activation call to. DirectShowSpy intercepts these calls, however what it did not do was support for unknown COM interfaces, and support for undocumented <code>IMMDeviceActivator<\/code> interface which is used internally by the APIs to forward the activation call.<\/p>\n<p>So, System Device Enumerator implements documented <code>ICreateDevEnum<\/code> and then it also implements undocumented internal <code>IMMDeviceActivator<\/code>. The entire sequence call is as follows:<\/p>\n<pre><code>\/\/ Top level code:\r\n\r\nCComPtr&lt;IMMDevice&gt; pDevice = ...; \/\/ Audio endpoint interface\r\npDevice-&gt;Activate(..., __uuidof(IBaseFilter), ...)\r\n\r\n\/\/ API:\r\n\r\nSTDMETHOD(Activate)(...)\r\n{\r\n    \/\/ ...\r\n    if(requested is IBaseFilter)\r\n    {\r\n        CComPtr&lt;IMMDeviceActivator&gt; pDeviceActivator;\r\n        pDeviceActivator.CoCreateInstace(CLSID_SystemDeviceEnum);\r\n        return pDeviceActivator-&gt;Activate(pDevice, ...)\r\n    }\r\n<\/code><\/pre>\n<p>DirectShowSpy&#8217;s failure to provide <code>IMMDeviceActivator<\/code> resulted in symptom in question and is fixed with version 1.0.0.2106 and on. The failure code is not so much descriptive, but of course the APIs did not expect external hook and failure is not actually a supposed possible behavior there.<\/p>\n<p>System Device Enumerator matches the known devices to the provided Core Audio device and creates an instance of respective filter &#8211; this is how APIs work together. DirectShowSpy prints these calls out to its log.<\/p>\n<pre><code>roatlbase.h(1582): TraceModuleVersion: \"D:\\...\\DirectShowSpy-Win32.dll\" version is 1.0.0.2107, running in \"D:\\...\\EnumerateAudioDevices-Win32.exe\" at 0x63210000\r\ndllmain.h(36): CDirectShowSpyModule::CDirectShowSpyModule: this 0x633963A4\r\nSystemDeviceEnumeratorSpy.h(669): CSystemDeviceEnumeratorSpyT&lt;...&gt;::CSystemDeviceEnumeratorSpyT: this 0x02F1DA68\r\nSystemDeviceEnumeratorSpy.h(681): CSystemDeviceEnumeratorSpyT&lt;...&gt;::FinalConstruct: pszPath \"D:\\...\\EnumerateAudioDevices-Win32.exe\", this 0x02F1DA68, m_dwRef 1\r\nSystemDeviceEnumeratorSpy.h(49): CSystemDeviceEnumeratorSpyT&lt;...&gt;::InternalQueryInterface: 0x02F1DA68, Interface {3B0D0EA4-D0A9-4B0E-935B-09516746FAC0}, Result 0x00000000\r\nSystemDeviceEnumeratorSpy.h(49): CSystemDeviceEnumeratorSpyT&lt;...&gt;::InternalQueryInterface: 0x02F1DA68, Interface {3B0D0EA4-D0A9-4B0E-935B-09516746FAC0}, Result 0x00000000\r\nSystemDeviceEnumeratorSpy.h(808): CSystemDeviceEnumeratorSpyT&lt;...&gt;::Activate: this 0x02F1DA68, InterfaceIdentifier {56A86895-0AD4-11CE-B03A-0020AF0BA770}, pMmDevice 0x0054E7F8\r\nSystemDeviceEnumeratorSpy.h(815): CSystemDeviceEnumeratorSpyT&lt;...&gt;::Activate: nActivateResult 0x00000000 \r\nSystemDeviceEnumeratorSpy.h(673): CSystemDeviceEnumeratorSpyT&lt;...&gt;::~CSystemDeviceEnumeratorSpyT: this 0x02F1DA68\r\n<\/code><\/pre>\n<h3>Download links<\/h3>\n<ul>\n<li>Binaries:\n<ul>\n<li>32-bit: <a href=\"https:\/\/www.alax.info\/svn\/public\/trunk\/DirectShowSpy\/_Bin\/DirectShowSpy-Win32.dll\">DirectShowSpy-Win32.dll<\/a> (1.0.0.2107)<\/li>\n<li>64-bit: <a href=\"https:\/\/www.alax.info\/svn\/public\/trunk\/DirectShowSpy\/_Bin\/DirectShowSpy-x64.dll\">DirectShowSpy-x64.dll<\/a> (1.0.0.2106)<\/li>\n<\/ul>\n<\/li>\n<li>Shortcuts to Exported Functions: <a href=\"https:\/\/www.alax.info\/svn\/public\/trunk\/DirectShowSpy\/_Bin\/\">Helper .BAT files<\/a><\/li>\n<li>License: This software is free to use<\/li>\n<li>Installation Instructions: <a href=\"https:\/\/alax.info\/blog\/777\">Original post<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A DirectShow developer complained on sudden failure of Core Audio IMMDevice::Activate call supposed to instantiate a DirectShow filter for a given device. The problem appeared to be related to installed DirectShowSpy and its interference with the API calls. The symptom was of the following kind: when Activate was called for different types of objects, the&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/1648\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[485,63,378,446,269,520],"class_list":["post-1648","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-audio","tag-bug","tag-core-audio","tag-directshowspy","tag-fix","tag-immdeviceactivator"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=1648"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1648\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=1648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=1648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=1648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}