{"id":1094,"date":"2009-11-01T21:30:19","date_gmt":"2009-11-01T19:30:19","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=1094"},"modified":"2009-12-24T15:06:54","modified_gmt":"2009-12-24T13:06:54","slug":"directshow-filter-graph-spy-64-bit-version-and-hook-api","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/1094","title":{"rendered":"DirectShow Filter Graph Spy: 64-bit version and hook API"},"content":{"rendered":"<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>\n<p>Filter Graph Spy is offering three new interfaces that provide extensibility of the spy:<\/p>\n<ul>\n<li>IFilterGraphAddRemoveHook<\/li>\n<li>IFilterGraphConnectHook<\/li>\n<li>IFilterGraphStateControlHook<\/li>\n<\/ul>\n<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>\n<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>\n<p><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/11\/02-Image001.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1095\" title=\"Registering a DirectShow Filter Graph Spy Hook\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/11\/02-Image001-320x136.png\" alt=\"Registering a DirectShow Filter Graph Spy Hook\" width=\"320\" height=\"136\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/11\/02-Image001-320x136.png 320w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/11\/02-Image001-800x342.png 800w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2009\/11\/02-Image001.png 1087w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<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>\n<pre>\r\n<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>\r\n<span style=\"color: #800080;\">{<\/span>\r\n    _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>\r\n    HOOK_PROLOG<span style=\"color: #808030;\">(<\/span>CFilterGraphConnectHookHost<span style=\"color: #808030;\">)<\/span>\r\n        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>\r\n    HOOK_EPILOG<span style=\"color: #808030;\">(<\/span><span style=\"color: #808030;\">)<\/span>\r\n    <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>\r\n<span style=\"color: #800080;\">}<\/span><\/pre>\n<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>\n<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>\n<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>\n<ul>\n<li><a href=\"http:\/\/www.microsoft.com\/windows\/windows-7\/\">Windows 7<\/a><\/li>\n<li>Windows Server 2008<\/li>\n<li>Windows Vista<\/li>\n<li>Windows Server 2003<\/li>\n<li>Windows XP<\/li>\n<li>Windows 2000<\/li>\n<\/ul>\n<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>\n<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=\"https:\/\/alax.info\/blog\/777\">another post<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<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. Filter Graph Spy is offering three new interfaces that provide extensibility of the spy: IFilterGraphAddRemoveHook IFilterGraphConnectHook IFilterGraphStateControlHook The interfaces are contained in the type library and can&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/1094\">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":[11,12],"tags":[283,81,78,119,163,282,164,284],"class_list":["post-1094","post","type-post","status-publish","format-standard","hentry","category-atl","category-technology","tag-64-bit","tag-api","tag-directshow","tag-filter","tag-graph","tag-hook","tag-spy","tag-x64"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1094","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=1094"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1094\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=1094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=1094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=1094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}