<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Bug me</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/rchiodo/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/rchiodo/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:26:40 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Can’t use DirectX 11.2 with Visual Studio 2012 Graphics Diagnostics</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/cant-use-directx-11-2-with-visual-studio-2012-graphics-diagnostics</link>
      <pubDate>Mon, 05 Aug 2013 17:50:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2013/08/05/cant-use-directx-11-2-with-visual-studio-2012-graphics-diagnostics/</guid>
      <description><![CDATA[If you’re one of the people using Graphics Diagnostics in Visual Studio 2012, please be aware that...]]></description>
      <content:encoded><![CDATA[<p>If you’re one of the people using <a href="http://msdn.microsoft.com/en-us/library/vstudio/hh873207.aspx">Graphics Diagnostics</a> in Visual Studio 2012, please be aware that the DirectX 11.2 APIs are not supported.</p>  <p>This includes:</p>  <ul>   <li>ID3D11Device2</li>    <li>ID3D11DeviceContext2</li>    <li>HLSL Shader Linking</li>    <li>Tiled resources</li> </ul>  <p>Basically anything listed here:</p>  <p><a title="http://msdn.microsoft.com/en-us/library/windows/desktop/dn312084(v=vs.85).aspx" href="http://msdn.microsoft.com/en-us/library/windows/desktop/dn312084(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/dn312084(v=vs.85).aspx</a></p>  <p>Now that doesn’t mean 11.1 and below doesn’t work. In fact we fixed a number of bugs in our second <a href="http://www.microsoft.com/en-us/download/details.aspx?id=39305">update</a> to VS 2012, and as long as you use 11.1 interfaces (or below) everything else should work on Windows 8.1</p>  <p>&#160;</p>  <h2>Why doesn’t it work?</h2>  <p>If you really care to know, I’m going to go into some detail on how we actually do graphics diagnostics. This will explain why 11.2 doesn’t work in VS 2012 and what we plan to do to address this in the future.</p>  <h3>Capturing</h3>  <p>When you hit print screen during graphics diagnostics, we “capture” a frame of your app running. You can see all the stuff your frame did in the event list here:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/1018.image_6572CB62.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/1018.image_5F00_6572CB62.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/0044.image_thumb_57345272.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/0044.image_5F00_thumb_5F00_57345272.png" width="466" height="529" /></a></p>  <p>So how do we “capture” this list of events?</p>  <h3>Detours</h3>  <p>For VS 2012 (and previous incarnations of WinPIX), we use something called <a href="http://research.microsoft.com/apps/pubs/default.aspx?id=68568">detours</a>. Detours essentially rewrites the beginning of a function so that it jmps to somewhere else. Here’s the disassembly for D3D11CreateDevice:</p> <font style="font-size: 12pt;"></font>  <p style="line-height: 13pt; margin-top: 0pt; margin-bottom: 8pt; margin-left: 0in; list-style-type: disc; unicode-bidi: embed; direction: ltr; -ms-word-break: normal; language: en-us; mso-line-break-override: none; punctuation-wrap: hanging;" align="left"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/0435.image_20E0527B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/0435.image_5F00_20E0527B.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/5734.image_thumb_71AE66E3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/5734.image_5F00_thumb_5F00_71AE66E3.png" width="579" height="140" /></a></p> <font style="font-size: 12pt;"></font>  <p>This is what D3D11CreateDevice looks like before it is detoured. </p>  <p>After detouring, this assembly changes to this (notice the new jmp):</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/1524.image_23A6076E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/1524.image_5F00_23A6076E.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/0028.image_thumb_6A8F2A6B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/0028.image_5F00_thumb_5F00_6A8F2A6B.png" width="549" height="144" /></a></p>  <p>This means calls to D3D11CreateDevice go to another create device function. </p>  <p>However, this other function still needs to call the original, so detours also creates a “trampoline” function to allow us to call the original:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/4251.image_5F65A021.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/4251.image_5F00_5F65A021.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/8484.image_thumb_636FEDF3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/8484.image_5F00_thumb_5F00_636FEDF3.png" width="547" height="285" /></a></p>  <p>Here’s an example of a new detoured CreateDevice:</p>  <div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">   <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">     <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">HRESULT CHookedD3D11Top::D3D11CreateDevice( D3D11CREATEDEVICE_TYPED_PARAMS )</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">{</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">if</span> ( D3D11CreateDevice_Trampoline == NULL )</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 0, 255);">return</span> E_NOINTERFACE;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    m_pHookMgr-&gt;LogInputParams( D3D11CREATEDEVICE_PARAMS );</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    HRESULT hr = D3D11CreateDevice_Trampoline( D3D11CREATEDEVICE_PARAMS );</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    m_pHookMgr-&gt;LogOutputParams( D3D11CREATEDEVICE_PARAMS, hr );</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">return</span> hr;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">}</pre>
<!--CRLF--></div>
</div>

<p>Essentially we:</p>

<ul>
  <li>Intercept the call</li>

  <li>Log the input parameters</li>

  <li>Make the original call</li>

  <li>Log the output parameters</li>
</ul>

<p>This allows us to log/(and more importantly) recreate all the things your app did while running. </p>

<p>Sounds simple, so why not just add logging for the new 11.2 apis?</p>

<h3>Hooked objects</h3>

<p>It’s actually a bit more complicated than that. In the example above, the ID3D11Device returned from the function is likely going to be used later, to say create textures.</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/1121.image_24644BFE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/1121.image_5F00_24644BFE.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/2548.image_thumb_565BEC88.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/2548.image_5F00_thumb_5F00_565BEC88.png" width="691" height="317" /></a></p>

<p>The workflow here is:</p>

<ol>
  <li>Game calls D3D11CreateDevice</li>

  <li>We intercept in our detoured HookedD3D11CreateDevice</li>

  <li>We call into the RealD3D11CreateDevice</li>

  <li>It returns a real device object</li>

  <li>Game calls the ID3D11Device::CreateTexture</li>

  <li>We don’t capture this. Well because CreateTexture is called on something we aren’t detouring.</li>
</ol>

<p>You can’t detour a virtual function (not with the detours api anyway, more on this later) so we need to do more than just detour the straight create functions. We also need to wrap objects as they are returned.</p>

<p>This gives us something like so:</p>

<p>&#160;</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/2438.image_4F3CB010.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/2438.image_5F00_4F3CB010.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/1452.image_thumb_441325C6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/1452.image_5F00_thumb_5F00_441325C6.png" width="571" height="376" /></a></p>

<p>Now we can log our HookedDevice::CreateTexture. It’s code would look something like so:</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">HRESULT CHookedD3D11Device::CreateTexture2D( D3D11CREATEDTEXTURE2D_TYPED_PARAMS )</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"> {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     m_pHookMgr-&gt;LogInputParams( D3D11CREATEDTEXTURE2D_PARAMS );</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">     </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     HRESULT hr = m_pRealDevice( D3D11CREATEDTEXTURE2D_PARAMS );</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">     </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     m_pHookMgr-&gt;LogOutputParams( D3D11CREATEDTEXTURE2D_PARAMS, hr );</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     <span style="color: rgb(0, 0, 255);">if</span> (hr == S_OK)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">         *ppTexture = m_pHookMgr-&gt;WrapObject(*ppTexture);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">     </pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">     <span style="color: rgb(0, 0, 255);">return</span> hr;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"> }</pre>
<!--CRLF--></div>
</div>

<p>This is the general pattern we follow throughout our hooking. </p>

<p>Things get messy in some scenarios however. </p>

<h3>QueryInterface</h3>

<p>QueryInterface is a special function. This is the way a COM object is queried for new types. </p>

<p>
  <br /> HRESULT QueryInterface( 

  <br />&#160; [in]&#160;&#160; REFIID riid, 

  <br />&#160; [out]&#160; void **ppvObject 

  <br /> );</p>

<p>In our example, our HookedDevice has its own implementation of QueryInterface. What happens when we QI for some interface we don’t know about (like say ID3D11Device2)?</p>

<p>There are really two things we can do (well that I’ve thought of)</p>

<h3>Off the farm</h3>

<p>We could just return the original m_pRealDevice object. This means if you QI for ID3D11Device2, and then start calling functions on it, we won’t hook them and capture won’t succeed. This means your app will probably run under the graphics debugger, but we’ll just miss calls.</p>

<p>Imagine this workflow:</p>

<ol>
  <li>Create device</li>

  <li>QI for ID3D11Device2</li>

  <li>GetImmediateContext2</li>

  <li>Call draw calls on ID3D11DeviceContext2</li>
</ol>

<p>In step 2, the QI for ID3D11Device2 is not understood by VS 2012 (well because ID3D11Device2 didn't exist yet). So it returns the original object. In step 3, the immediate context returned is not our hooked immediate context, and in step 4, the draw calls are not hooked. This means the QI for ID3D11Device2 goes “off the farm” and we can’t see our sheep anymore. </p>

<p>This scenario actually came up during development of VS 2012. It seems D2D actually queries a device for internal only interfaces that it knows about. This means if you use D2D in your app, you wouldn’t have been able to capture with VS 2012. Pretty crummy.</p>

<h3>VTable patching</h3>

<p>This prompted us to actually not return hooked objects, but instead to return the original m_pRealDevice (from D3D11CreateDevice) and patch its vtable to point to our Hooked API calls. This is another form of detouring that allows the QI to go “off the farm” but come back onto the farm whenever a call is made to a known API.</p>

<p>It works something like so:</p>

<p>The real device starts out something like so:</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/3817.image_4D2A55C1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/3817.image_5F00_4D2A55C1.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/1680.image_thumb_2C36E31A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/1680.image_5F00_thumb_5F00_2C36E31A.png" width="376" height="149" /></a></p>

<p>&#160;</p>

<p>Then we create a hooked device that looks like this:</p>

<p>&#160;</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/3326.image_570F472C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/3326.image_5F00_570F472C.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/3240.image_thumb_4BE5BCE2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/3240.image_5F00_thumb_5F00_4BE5BCE2.png" width="383" height="152" /></a></p>

<p>&#160;</p>

<p>Then we rewire the Original Device to point to the VTable of the HookedDevice and the hooked entries to call into the original as necessary:</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/1106.image_72B3D322.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/1106.image_5F00_72B3D322.png"><img title="image" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/2766.image_thumb_24AB73AD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/2766.image_5F00_thumb_5F00_24AB73AD.png" width="466" height="330" /></a></p>

<p>This allows us to always return the “original” object, but have its functions still detoured, and when subsequent QI’s happen for unknown interfaces, we can patch just those vtables for the IUnknown vtable.</p>

<h3>Additional difficulties</h3>

<p>This seems to fix the capture with 11.2 problem. As long as the original vtable is patched, any new interfaces would at least work (if not capture). However there’s a problem here. </p>

<p>DirectX itself is patching vtables. The device context is patched at the vtable by DirectX to swap out feature levels. This breaks our vtable patching. So we can only returned hooked objects for device contexts. </p>

<p>&#160;</p>

<h2>Supporting 11.2 = VS 2013</h2>

<p>Given all of this background, you may be able to see how much work it is to actually hook DirectX. Months of patching vtables here, making sure parameters are copied correctly, etc. Not to mention responding to changes as they come up. DirectX changed some of the 11.1 APIs 5 times during the release of VS 2012.</p>

<p>The ideal alternative would be for DirectX itself to support hooking DirectX APIs. This way DirectX could keep the hooks up to date as they made changes to their APIs and handle any private interfaces that might come up. </p>

<p>For <a href="http://www.microsoft.com/visualstudio/eng/2013-downloads">VS 2013</a>, this is what we are doing. From now on, DirectX detouring will be handled internally by DirectX itself. This eliminates the need for us to keep updating our hooking every time DirectX adds new APIs.</p>

<p>So given all of that, we’re not porting this change to VS 2012 for a couple of reasons:</p>

<ol>
  <li>It would take up months of development time we could be spending on new features. </li>

  <li>The new version will be free (for store apps, and somewhat useable for desktop apps)</li>
</ol>

<p>I’ll leave the details of the new DirectX hooking as a topic for a future post <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/7065.wlEmoticon-smile_327DB9A8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/7065.wlEmoticon_2D00_smile_5F00_327DB9A8.png" /></p>]]></content:encoded>
    </item>
    <item>
      <title>Blending Demystified</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/blending-demystified</link>
      <pubDate>Tue, 20 Nov 2012 16:21:05 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2012/11/20/blending-demystified/</guid>
      <description><![CDATA[Sorry, I'm terrible at updating my blog, but I had an interesting debugging session learning about...]]></description>
      <content:encoded><![CDATA[<p>Sorry, I'm terrible at updating my blog, but I had an interesting debugging session learning about D3D Blend states. The MSDN documentation is severely lacking in my opinion, so I'm going to try and explain it here.</p>  <p>&#160;</p>  <p>Suppose I have an image I'm about to draw to the screen. Let's say this image has the RGBA color of (1.0, 0.5, 0.0, 0.5) which looks like so:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/8233.tbqzjzqh_7F20554A.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/8233.tbqzjzqh_5F00_7F20554A.jpg"><img title="tbqzjzqh" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="tbqzjzqh" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/6170.tbqzjzqh_thumb_1ECF2F13.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/6170.tbqzjzqh_5F00_thumb_5F00_1ECF2F13.jpg" width="96" height="98" /></a></p>  <p>And suppose I want to blend this with the background (0.0, 0.0, 1.0, 1.0) which might be something like the following:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/5684.o5ofawke_7EB42255.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/5684.o5ofawke_5F00_7EB42255.jpg"><img title="o5ofawke" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="o5ofawke" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/7750.o5ofawke_thumb_17AFF29B.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/7750.o5ofawke_5F00_thumb_5F00_17AFF29B.jpg" width="96" height="98" /></a></p>  <p>&#160;</p>  <h2>How do I blend them together?</h2>  <p>D3D has this nice option in the output merger stage, that allows you to blend what your draw did with whatever was previously in your render target. You do this by calling OMSetBlendState which takes an ID3D11BlendState object.</p>  <p>You set your blend state object with a series of flags that looks like so:</p>  <pre class="code"><span style="background: white; color: black;">    </span><span style="background: white; color: rgb(43, 145, 175);">D3D11_BLEND_DESC </span><span style="background: white; color: black;">bs;
    </span><span style="background: white; color: rgb(111, 0, 138);">ZeroMemory</span><span style="background: white; color: black;">(&amp;bs, </span><span style="background: white; color: blue;">sizeof</span><span style="background: white; color: black;">(bs));
    </span><span style="background: white; color: blue;">for </span><span style="background: white; color: black;">(</span><span style="background: white; color: blue;">int </span><span style="background: white; color: black;">i=0; i&lt;8; i++)
    {
        bs.RenderTarget[i].BlendEnable = </span><span style="background: white; color: rgb(111, 0, 138);">TRUE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOp = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOpAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].RenderTargetWriteMask = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_COLOR_WRITE_ENABLE_ALL</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ZERO</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;

    }</span></pre>


<h2>What do all those flags mean?</h2>

<p>This is where I feel like the documentation is lacking. There are 2 enums you have to deal with here:</p>

<ul>
  <li>D3D11_BLEND_OP</li>

  <li>D3D11_BLEND_MODE</li>
</ul>

<p>Let’s talk about each one separately.</p>

<h3>BLEND_OP</h3>

<p>The BLEND_OP is a little bit easier to understand. Basically when you are blending, you are combining the original color (the one already in the render target) with a new color (the one you are outputting on your current draw). The BLEND_OP specifies how you combine these colors after applying the blend mode. It’s one of:</p>

<ul>
  <li>ADD</li>

  <li>SUBTRACT output from original</li>

  <li>SUBTRACT original from output</li>

  <li>MIN</li>

  <li>MAX</li>
</ul>

<h3>&#160;</h3>

<h3>BLEND_MODE</h3>

<p>BLEND_MODE is a little more complicated. This is where the confusion set in for me. BLEND_MODE has a bunch of different values, like SRC_COLOR, SRC_ALPHA etc. What these mean is where to get our multiplier from. The general formula for the blend is like so:</p>

<blockquote>
  <p>FinalColor = (SourceColor * Source BlendFactor) Blend Op (DestinationColor * Destination BlendFactor)</p>
</blockquote>

<p>BLEND_MODE just lets us decide how to compute the BlendFactor in that equation above.</p>

<p>This makes a big matrix of possibilities. So what might the results be? I created an example table using just the R value from each of my colors:</p>

<table cellspacing="0" cellpadding="2" width="534" border="1"><tbody>
    <tr>
      <td valign="top" width="133">
        <blockquote style="margin-right: 0px;" dir="ltr">
          <p align="left"><strong><font size="4">Blend Mode</font></strong></p>
        </blockquote>
      </td>

      <td valign="top" width="76">
        <p align="center"><strong><font size="4"> Blend Multiplier (factor)</font></strong></p>
      </td>

      <td valign="top" width="108">
        <p align="center">&#160;<strong><font size="4">Src Color </font></strong></p>

        <p align="center"><strong><font size="4">(</font></strong><strong><font size="4">just R)</font></strong></p>
      </td>

      <td valign="top" width="113">
        <p align="center"><strong><font size="4">Dest Color</font></strong></p>

        <p align="center"><strong><font size="4">(just R)</font></strong></p>
      </td>

      <td valign="top" width="80">
        <p align="center"><font color="#333333" size="4"><strong>Blend op</strong></font></p>
      </td>

      <td valign="top" width="22">
        <p align="center"><strong><font size="4">Final Color</font></strong></p>
      </td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_ZERO</td>

      <td valign="top" width="76">0</td>

      <td valign="top" width="108">1.0 * 0.0</td>

      <td valign="top" width="113">0.0 * 0.0</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_ONE</td>

      <td valign="top" width="76">1</td>

      <td valign="top" width="108">1.0 * 1.0</td>

      <td valign="top" width="113">0.0 * 1.0</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_SRC_COLOR</td>

      <td valign="top" width="76">1.0</td>

      <td valign="top" width="108">1.0 * 1.0</td>

      <td valign="top" width="113">0.0 * 0.0</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_INV_SRC_COLOR</td>

      <td valign="top" width="76">1.0 – 1.0</td>

      <td valign="top" width="108">1.0 * (1.0 – 1.0)</td>

      <td valign="top" width="113">0.0 * (1.0 – 1.0)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_SRC_ALPHA</td>

      <td valign="top" width="76">0.5</td>

      <td valign="top" width="108">1.0 * 0.5</td>

      <td valign="top" width="113">0.0 * 0.5</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.5</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_INV_SRC_ALPHA</td>

      <td valign="top" width="76">1.0 – 0.5</td>

      <td valign="top" width="108">1.0 * (1.0 – 0.5)</td>

      <td valign="top" width="113">0.0 * (1.0 – 0.5)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.5</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_DEST_ALPHA</td>

      <td valign="top" width="76">1.0</td>

      <td valign="top" width="108">1.0 * 1.0</td>

      <td valign="top" width="113">0.0 * 1.0</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_DEST_INV_ALPHA</td>

      <td valign="top" width="76">1.0 – 1.0</td>

      <td valign="top" width="108">1.0 * (1.0 – 1.0)</td>

      <td valign="top" width="113">0.0 * (1.0 – 1.0)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_DEST_COLOR</td>

      <td valign="top" width="76">0.0</td>

      <td valign="top" width="108">1.0 * 0.0</td>

      <td valign="top" width="113">0.0 * 0.0</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_DEST_INV_COLOR</td>

      <td valign="top" width="76">1.0 – 0.0</td>

      <td valign="top" width="108">1.0 * (1.0 – 0.0)</td>

      <td valign="top" width="113">0.0 * (1.0 – 0.0)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_SRC_ALPHA_SAT</td>

      <td valign="top" width="76">min(0.5, 1-1)</td>

      <td valign="top" width="108">1.0 * 0.0</td>

      <td valign="top" width="113">0.0 * 0.0</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">0.0</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_BLEND_FACTOR</td>

      <td valign="top" width="76">blend factor on OMSetBlendState</td>

      <td valign="top" width="108">1.0 * f</td>

      <td valign="top" width="113">0.0 * f</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">f</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_INV_BLEND_FACTOR</td>

      <td valign="top" width="76">1- blend factor set</td>

      <td valign="top" width="108">1.0 * (1.0 –f)</td>

      <td valign="top" width="113">0.0 * (1.0 –f)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1-f</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_SRC1_COLOR</td>

      <td valign="top" width="76">color data from Pixel shader</td>

      <td valign="top" width="108">1.0 * c</td>

      <td valign="top" width="113">0.0 * c</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">c</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_INV_SRC1_COLOR</td>

      <td valign="top" width="76">1- color data from pixel shader</td>

      <td valign="top" width="108">1.0 * (1-c)</td>

      <td valign="top" width="113">0.0 * (1-c)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1-c</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_SRC1_ALPHA</td>

      <td valign="top" width="76">alpha from pixel shader</td>

      <td valign="top" width="108">1.0 * (a)</td>

      <td valign="top" width="113">0.0 * (a)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">a</td>
    </tr>

    <tr>
      <td valign="top" width="133">BLEND_INV_SRC1_ALPHA</td>

      <td valign="top" width="76">1- alpha from pixel shader</td>

      <td valign="top" width="108">1.0 * (1- a)</td>

      <td valign="top" width="113">0.0 * (1- a)</td>

      <td valign="top" width="80">OP_ADD</td>

      <td valign="top" width="22">1- a</td>
    </tr>
  </tbody></table>

<p>Now this table is certainly not the limit of what the matrix might be, this table is simply specifying OP_ADD and using the same blend mode for both the source and destination, In a blend desc, this would be set like so:</p>

<pre class="code"><span style="background: white; color: rgb(43, 145, 175);">    D3D11_BLEND_DESC </span><span style="background: white; color: black;">bs;
    </span><span style="background: white; color: rgb(111, 0, 138);">ZeroMemory</span><span style="background: white; color: black;">(&amp;bs, </span><span style="background: white; color: blue;">sizeof</span><span style="background: white; color: black;">(bs));
    </span><span style="background: white; color: blue;">for </span><span style="background: white; color: black;">(</span><span style="background: white; color: blue;">int </span><span style="background: white; color: black;">i=0; i&lt;8; i++)
    {
        bs.RenderTarget[i].BlendEnable = </span><span style="background: white; color: rgb(111, 0, 138);">TRUE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOp = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOpAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].RenderTargetWriteMask = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_COLOR_WRITE_ENABLE_ALL</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;

    }</span></pre>

<p>This example is probably a silly idea, as you want to combine the destination and source in different ways. This blend mode above is just adding up all the colors together, more than likely getting something close to white each time. </p>

<p>The default (meaning no blending) would effectively be like so:</p>

<pre class="code"><span style="background: white; color: black;">    </span><span style="background: white; color: rgb(43, 145, 175);">D3D11_BLEND_DESC </span><span style="background: white; color: black;">bs;
    </span><span style="background: white; color: rgb(111, 0, 138);">ZeroMemory</span><span style="background: white; color: black;">(&amp;bs, </span><span style="background: white; color: blue;">sizeof</span><span style="background: white; color: black;">(bs));
    </span><span style="background: white; color: blue;">for </span><span style="background: white; color: black;">(</span><span style="background: white; color: blue;">int </span><span style="background: white; color: black;">i=0; i&lt;8; i++)
    {
        bs.RenderTarget[i].BlendEnable = </span><span style="background: white; color: rgb(111, 0, 138);">TRUE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOp = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOpAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].RenderTargetWriteMask = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_COLOR_WRITE_ENABLE_ALL</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ZERO</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ZERO</span><span style="background: white; color: black;">;

    }
</span></pre>

<p>&#160;</p>

<p>Although this is just the same as setting BlendEnable to false. Most of the time what people want to do is actually blend using the alpha component. This produces a nice effect where you can sort of see the stuff behind what you are drawing. A common way to do that would be to pick the following:</p>

<p>&#160;</p>

<pre class="code"><span style="background: white; color: black;">    </span><span style="background: white; color: rgb(43, 145, 175);">D3D11_BLEND_DESC </span><span style="background: white; color: black;">bs;
    </span><span style="background: white; color: rgb(111, 0, 138);">ZeroMemory</span><span style="background: white; color: black;">(&amp;bs, </span><span style="background: white; color: blue;">sizeof</span><span style="background: white; color: black;">(bs));
    </span><span style="background: white; color: blue;">for </span><span style="background: white; color: black;">(</span><span style="background: white; color: blue;">int </span><span style="background: white; color: black;">i=0; i&lt;8; i++)
    {
        bs.RenderTarget[i].BlendEnable = </span><span style="background: white; color: rgb(111, 0, 138);">TRUE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOp = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_ADD</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].BlendOpAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_OP_MAX</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].RenderTargetWriteMask = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_COLOR_WRITE_ENABLE_ALL</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_SRC_ALPHA</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlend = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_INV_SRC_ALPHA</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].SrcBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;
        bs.RenderTarget[i].DestBlendAlpha = </span><span style="background: white; color: rgb(47, 79, 79);">D3D11_BLEND_ONE</span><span style="background: white; color: black;">;

    }
</span></pre>

<p>What this does is makes the src alpha component more important in the final output, and destination color less important (the inverse applied). For our image above this would be:</p>

<blockquote>
  <p>Final Color = (Source Color * Source Alpha) + (Destination Color * Inverse Source Alpha)</p>

  <p>Final ColorR = (1.0 * 0.5) + (0.0 * (1.0 – 0.5))</p>

  <p>Final ColorG = (0.5 * 0.5) + (0.0 * (1.0 – 0.5))</p>

  <p>Final ColorB = (0.0 * 0.5) + (1.0 * (1.0 – 0.5))</p>

  <p>Final Color = (0.5, 0.25, 0.5)</p>
</blockquote>

<p>This ends up looking like so when we overlay:</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/0474.aarlqbtt_5E991598.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/0474.aarlqbtt_5F00_5E991598.jpg"><img title="aarlqbtt" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="aarlqbtt" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/5265.aarlqbtt_thumb_3E11D5E6.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/5265.aarlqbtt_5F00_thumb_5F00_3E11D5E6.jpg" width="162" height="148" />&#160;</a></p>]]></content:encoded>
    </item>
    <item>
      <title>I’m internet famous!</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/im-internet-famous</link>
      <pubDate>Wed, 11 Apr 2012 13:08:46 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2012/04/11/im-internet-famous/</guid>
      <description><![CDATA[I went to GDC in March and Bytes by MSDN interviewed me. In case you interested in what Visual...]]></description>
      <content:encoded><![CDATA[<p>I went to GDC in March and Bytes by MSDN interviewed me. In case you interested in what Visual Studio Graphics Debugger is for, here’s the interview:</p>  <p><a title="http://msdn.microsoft.com/en-us/hh965632.aspx" href="http://msdn.microsoft.com/en-us/hh965632.aspx">http://msdn.microsoft.com/en-us/hh965632.aspx</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Graphics Debugging inside of Visual Studio = new job for me!</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/graphics-debugging-inside-of-visual-studio-new-job-for-me</link>
      <pubDate>Fri, 06 Apr 2012 14:15:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2012/04/06/graphics-debugging-inside-of-visual-studio-new-job-for-me/</guid>
      <description><![CDATA[&nbsp;
Hi, welcome back. If you look at my older posts, you may notice that I don&rsquo;t publish...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>Hi, welcome back. If you look at my older posts, you may notice that I don&rsquo;t publish very much. Mostly because I&rsquo;m lazy and I hated the tools inside of blogs.msdn for writing posts.</p>
<p>Well they&rsquo;ve made it much <a href="http://windows.microsoft.com/en-US/windows-live/essentials-other-programs">easier</a> now -- and I have a new job. Basically creating this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/2867.image_583CD293.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/2867.image_5F00_583CD293.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/3022.image_thumb_1EB9C29C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/3022.image_5F00_thumb_5F00_1EB9C29C.png" width="774" height="508" /></a></p>
<p>Most people call it Visual Studio <a href="http://blogs.msdn.com/b/manders/archive/2006/12/15/a-painless-introduction-to-pix-for-windows.aspx">PIX</a>. We&rsquo;re calling it the Visual Studio Graphics Debugger.</p>
<p>I&rsquo;ve always wanted to write video games. Working on this tool has finally pushed me into this realm and I hope to share everything that I&rsquo;ve learned. That&rsquo;s my new goal for this blog. I&rsquo;d like to teach myself (and anybody that reads this blog) how to write DirectX based C++ games.</p>
<p>I know it&rsquo;s been done before, but maybe I can explain something nobody is answering. Or at least teach one person about DirectX = me.</p>
<p>But if you have questions about the screenshot above, feel free to ping me <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/82/38/metablogapi/0207.wlEmoticon-smile_0551BF62.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-82-38-metablogapi/0207.wlEmoticon_2D00_smile_5F00_0551BF62.png" /> (There are others blogging about it <a href="http://blogs.msdn.com/b/vcblog/archive/2011/11/08/10235150.aspx">too</a>)</p>]]></content:encoded>
    </item>
    <item>
      <title>Hidden feature of VSIP: Sharing a machine</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/hidden-feature-of-vsip-sharing-a-machine</link>
      <pubDate>Thu, 03 May 2007 19:58:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2007/05/03/hidden-feature-of-vsip-sharing-a-machine/</guid>
      <description><![CDATA[Okay so this really isn't a debugger feature, but I thought it was handy anyway.
Yesterday a...]]></description>
      <content:encoded><![CDATA[<P>Okay so this really isn't a debugger feature, but I thought it was handy anyway.</P>
<P>Yesterday a colleague and I were both logged onto the same machine, both using Visual Studio as two different users. Since I work at Microsoft, I naturally needed to change Visual Studio. So how to do that without having my co-worker log off (because he had the same dlls loaded I needed to change)?</P>
<P><STRONG>Registry hives</STRONG></P>
<P>VSIP&nbsp;(well actually Visual Studio) has this <A class="" title=nifty href="http://msdn2.microsoft.com/en-us/library/bb166560(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bb166560(VS.80).aspx">nifty</A> idea where you can load devenv using a different root key in the registry. The intent here is&nbsp;that when you are developing a Visual Studio <A class="" title=package href="http://msdn2.microsoft.com/en-us/library/bb166424(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bb166424(VS.80).aspx">package</A>&nbsp;you can build the package in one instance of Visual Studio and run in another. This means the package is not loaded in the same environment you are building in. Very handy when your package causes Visual Studio to crash. How would you debug it if you can't even start Visual Studio?</P>
<P>&nbsp;So most of the time (at least in my past) people use the Exp hive. If you look in your registry, you'll have a root install of HKLM\Software\Microsoft\VisualStudio\8.0. The Exp hive lives at HKLM\Software\Microsoft\VisualStudio\8.0Exp. If you install your package in just the Exp hive, you can run the Exp version and debug with the normal.</P>
<P><STRONG>Package redirect</STRONG></P>
<P>So how did I use this exp hive to my advantage? </P>
<P>Packages are loaded dynamically as devenv needs them (usually when a command or window from the package is called). The location for these packages is stored in the registry underneath the root location for Visual Studio (i.e. HKLM\Software\Microsoft\VisualStudio\8.0\Packages\{package guid}). </P>
<P>For example, the debugger package (which is what I wanted to change) is loaded from here:</P>
<P mce_keep="true"><IMG style="WIDTH: 1184px; HEIGHT: 248px" height=248 src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/02/40/22/90/DebuggerPackage.png" original-url="http://blogs.msdn.com/photos/rchiodo/images/2402290/original.aspx" width=1184 mce_src="http://blogs.msdn.com/photos/rchiodo/images/2402290/original.aspx"></P>
<P>Since my colleague was using the 9.0 hive, I could just change the package load location for my Exp hive and have my version of devenv load a different dll! </P>
<P>Something like so:</P>
<P mce_keep="true"><IMG style="WIDTH: 1184px; HEIGHT: 248px" height=248 src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/02/40/24/39/DebuggerPackage2.png" original-url="http://blogs.msdn.com/photos/rchiodo/images/2402439/original.aspx" width=1184 mce_src="http://blogs.msdn.com/photos/rchiodo/images/2402439/original.aspx"></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>The next level of DLL Hell - SxS.</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/the-next-level-of-dll-hell-sxs</link>
      <pubDate>Mon, 09 Apr 2007 16:34:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2007/04/09/the-next-level-of-dll-hell-sxs/</guid>
      <description><![CDATA[Everybody seems to be having SxS problems. I know I have them all the time.
SxS (or side by side)...]]></description>
      <content:encoded><![CDATA[<P>Everybody seems to be having SxS <A class="" title=problems href="http://search.msdn.microsoft.com/search/default.aspx?__VIEWSTATE=&amp;query=sxs+crt&amp;siteid=0&amp;tab=2" target=_blank mce_href="http://search.msdn.microsoft.com/search/default.aspx?__VIEWSTATE=&amp;query=sxs+crt&amp;siteid=0&amp;tab=2">problems</A>. I know I have them all the time.</P>
<P>SxS (or side by side) was a solution Microsoft developed for people distributing the C runtime with their application. </P>
<P>I won't comment on whether or not this was the right solution to the problem, but I'll talk about what I do to resolve it. </P>
<P><STRONG>Is it SxS?</STRONG></P>
<P>Anytime an application doesn't load a dll or refuses to start for some reason, I suspect SxS. Usually you'll get something like: </P>
<P><EM>The application has attempted to load the runtime library incorrectly.&nbsp; Contact support for more information</EM></P>
<P><EM>This application has failed to start because the application configuration is incorrect</EM></P>
<P>At this point, I do one of the following to make sure it is a side by side issue:</P>
<UL>
<LI>Open the event log in (XP/Vista) and look at the Application or System list. There should be a SxS error in there somewhere</LI>
<LI>Open the offending dll or exe&nbsp;using depends.exe (usually installed with Visual Studio under Common7\Tools\Bin). It will tell you if there is a SxS issue.</LI></UL>
<P><STRONG>Do I have that CRT installed?</STRONG></P>
<P>So one reason you might be having sxs problems is you don't even have the appropriate run time dlls installed. Usually this isn't the case, but I say it here first just&nbsp;to make sure you check.</P>
<P>To check if you do:</P>
<UL>
<LI>Open the event from the event viewer that identifies what dll it is trying to load. Vista shows something like so:</LI></UL>
<BLOCKQUOTE>
<P><EM>Component identity found in manifest does not match the identity of the component requested. Reference is Microsoft.VC80.ATL blah blah blah</EM></P></BLOCKQUOTE>
<UL>
<LI>Go to your Windows\WinSxS directory and see if you have a directory with a name containing the reference. Vista could have multiple.</LI></UL>
<P>If you find a directory containing the name of the runtime, then some version of that runtime is installed. You probably need to redirect.</P>
<P><STRONG>Redirecting - Fixing the problem </STRONG></P>
<P><EM>Obligatory warning: Mucking with system files can screw stuff up later on. Not that I've had problems after doing any of these fixes, but people say it's unsupported. I wouldn't recommend this as&nbsp;a "fix" but rather a workaround on your development machine. </EM></P>
<P>Anyway, here's what I do depending upon the platform:</P>
<BLOCKQUOTE>
<P><STRONG>XP/2003 Server</STRONG></P>
<UL>
<LI>Go to the event log. Find the error that names the dll you are having trouble with (there might be 3 or more errors for your one side by side load) </LI>
<LI>Go to the Windows\WinSxS\Policies\&lt;goofy directory containing your CRT dll name&gt;</LI>
<LI>Edit the .policy file with the <STRONG><EM>largest</EM></STRONG> number. </LI>
<LI>Change the binding redirect to be like so:</LI></UL>
<BLOCKQUOTE>
<P><SPAN style="COLOR: blue">&lt;</SPAN><SPAN style="COLOR: #a31515">bindingRedirect</SPAN><SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">oldVersion</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">9.0.0.0-9.0.65535.65535</SPAN>"<SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">newVersion</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">9.0.<STRONG>xxxxxx</STRONG>.<STRONG>xxxxx</STRONG></SPAN>"<SPAN style="COLOR: blue">/&gt;</SPAN>&nbsp;</P></BLOCKQUOTE>
<UL>
<LI>The critical part here is that the&nbsp;the <EM><STRONG>newVersion</STRONG></EM> value matches the policy file's main number. Here's one on my machine:</LI><!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Lucida Console;}}{\colortbl;??\red255\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red0\green0\blue0;}??\fs16 \cf1 name\cf3 =\cf0 "\cf3 policy.9.0.Microsoft.VC90.DebugCRT\cf0 "\cf3  \cf1 version\cf3 =\cf0 "\cf3 9.0.20223.44800\cf0 "}
-->
<DIV style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Lucida Console">
<P style="MARGIN: 0px"><SPAN style="COLOR: red"></SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: red">name</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">policy.9.0.Microsoft.VC90.DebugCRT</SPAN>"<SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">version</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">9.0.20223.44800</SPAN>"</P></DIV></UL>
<BLOCKQUOTE>
<P style="MARGIN: 0px">Make sure the number at the top of the file matches the newVersion you type in.</P></BLOCKQUOTE>
<P><STRONG>Vista</STRONG></P>
<UL>
<LI>Go to the event log. Find the error that names the dll you are having trouble with (there might be 3 or more errors for your one side by side load) </LI>
<LI>Go to the Windows\WinSxS\Manifests</LI>
<LI>Find the <STRONG><EM>newest</EM></STRONG>&nbsp;manifest file with the name like so </LI></UL>
<BLOCKQUOTE>
<P><EM>x86_policy.8.0.microsoft.vc80.atl_1fc8b3b9a1e18e3b_8.0.50727.762_none_8e053e8c6967ba9d.manifest</EM></P></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<P>The important parts being x86_policy and microsoft.vc80.atl - this name matches the runtime you are trying to redirect. The rest of the name doesn't really matter, although it should be the newest file and probably the&nbsp;highest version&nbsp;x86_policy file in that directory for your runtime.</P>
<P>My friend John discusses another alternative (at least on Vista) to find the appropriate file:&nbsp;<A class="" title=sxstrace href="http://lyon-smith.org/blogs/code-o-rama/archive/2007/03/28/side-by-side-problems.aspx" mce_href="http://lyon-smith.org/blogs/code-o-rama/archive/2007/03/28/side-by-side-problems.aspx">sxstrace</A></FONT></P></BLOCKQUOTE>
<UL>
<LI>Edit this file and change the binding redirect to be like so:</LI></UL>
<BLOCKQUOTE>
<P><SPAN style="COLOR: blue">&lt;</SPAN><SPAN style="COLOR: #a31515">bindingRedirect</SPAN><SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">oldVersion</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">8.0.0.0-8.0.65535.65535</SPAN>"<SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">newVersion</SPAN><SPAN style="COLOR: blue">=</SPAN>"8<SPAN style="COLOR: blue">.0.<STRONG>xxxxxx</STRONG>.<STRONG>xxxxx</STRONG></SPAN>"<SPAN style="COLOR: blue">/&gt;</SPAN>&nbsp;</P></BLOCKQUOTE>
<UL>
<LI>The critical part here is that the&nbsp;the <EM><STRONG>newVersion</STRONG></EM> value matches the policy file's main number. Here's one on my machine:</LI><!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Lucida Console;}}{\colortbl;??\red255\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red0\green0\blue0;}??\fs16 \cf1 name\cf3 =\cf0 "\cf3 policy.9.0.Microsoft.VC90.DebugCRT\cf0 "\cf3  \cf1 version\cf3 =\cf0 "\cf3 9.0.20223.44800\cf0 "}
-->
<DIV style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Lucida Console">
<P style="MARGIN: 0px"><SPAN style="COLOR: red"></SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: red">name</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">policy.8.0.Microsoft.VC80.ATL"</SPAN><SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">version</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">8.0.50727.44800</SPAN>"</P></DIV></UL>
<BLOCKQUOTE>
<P style="MARGIN: 0px">Make sure the number at the top of the file matches the newVersion you type in.</P></BLOCKQUOTE>
<UL>
<LI>Here's another caveat for vista = saving the file.&nbsp;You probably aren't the owner of this file. You need to remove whoever is the owner, and make yourself owner of this file before you can save it. I'll leave that step up to the user for brevity's sake. </LI></UL></BLOCKQUOTE>
<P mce_keep="true">After changing the appropriate policy file, your app should start to work. If it doesn't, hey you might have a dependency on another part of the CRT. Check the event log again :)</P>
<P mce_keep="true"><STRONG><SPAN style="COLOR: red">Update: How to tell when this isn't going to work</SPAN></STRONG></P>
<P mce_keep="true">So I finally ran into a case when this workaround failed. When the CRT is actually different and your application is using the wrong CRT! Duh. </P>
<P mce_keep="true">You'll get something like:</P>
<BLOCKQUOTE>
<P mce_keep="true"><EM>---------------------------<BR>devenv.exe - Entry Point Not Found<BR>---------------------------<BR>The procedure entry point </EM><A href="mailto:?replace@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@0ABV12@@Z"><EM>?replace@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@0ABV12@@Z</EM></A><EM> could not be located in the dynamic link library MSVCP80.dll. <BR>---------------------------<BR>OK&nbsp;&nbsp; <BR>---------------------------<BR></EM></P></BLOCKQUOTE>
<P mce_keep="true">In this case you actually need to go through the correct channels - like trying to find this version of the CRT and installing it. Should be installed under:</P>
<BLOCKQUOTE>
<P style="FONT-SIZE: 10pt; MARGIN: 0in; COLOR: black; FONT-FAMILY: Verdana">Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86</P></BLOCKQUOTE>
<P style="FONT-SIZE: 10pt; MARGIN: 0in; COLOR: black; FONT-FAMILY: Verdana" mce_keep="true">You might also try a <A class="" title=manifest href="http://msdn2.microsoft.com/en-us/library/ms229072(vs.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms229072(vs.80).aspx">manifest</A> for the appropriate dlls. Here's a blog entry about<A class="" title=it href="http://otb.manusoft.com/2007/01/my-manusoft-manifest-manifesto.htm" mce_href="http://otb.manusoft.com/2007/01/my-manusoft-manifest-manifesto.htm"> it</A>.</P>]]></content:encoded>
    </item>
    <item>
      <title>PCs still suck</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/pcs-still-suck</link>
      <pubDate>Mon, 09 Apr 2007 14:29:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2007/04/09/pcs-still-suck/</guid>
      <description><![CDATA[Okay so I probably shouldn't be writing that as a title considering who I work for, but I had a...]]></description>
      <content:encoded><![CDATA[<P>Okay so I probably shouldn't be writing that as a title considering who I work for, but I had a rather frustrating weekend IT session. Since I work at Microsoft, all of my family and friends expect me to answer any obscure computer problem they might have.&nbsp; I wonder if doctors have this same problem?</P>
<P>I had 3 separate "support" calls this weekend:</P>
<OL>
<LI>My wife informed me that Win32 was not working on our laptop. </LI>
<LI>My in-laws told me that they couldn't see themselves when talking to us through video conferencing (and hence we couldn't see them either)</LI>
<LI>Our laptop was consistently blue-screening (separate issue from the first) during video conferencing.</LI></OL>
<P>All 3 of these problems would not be&nbsp;diagnosable by say my wife. In fact one of them was only fixable because of the specific knowledge I have from working here. </P>
<P>PC's still aren't ready or usable by home consumers. At least not without a lot of hand holding and support. How come we haven't fixed this yet? Why do PCs have to be so techie? Okay I know why, but the reasons/excuses seem shortsighted to me.</P>
<P>What if we had an OS where all drivers were controlled/written by the vendor. What if the whole OS allowed but a single app to run at a time? And what if you had to control it with say, a game controller, instead of a keyboard and a mouse? </P>
<P>I think for Christmas next year I'm buying everybody an X-box with live and a camera. </P>
<P>Now if only X-box live would come&nbsp;with a browser.</P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Hidden Breakpoint Feature: Stepping in just one thread</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/hidden-breakpoint-feature-stepping-in-just-one-thread</link>
      <pubDate>Fri, 30 Mar 2007 04:00:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2007/03/30/hidden-breakpoint-feature-stepping-in-just-one-thread/</guid>
      <description><![CDATA[So I was giving this demo the other day of some of our new concurrency features in&nbsp;the Orcas...]]></description>
      <content:encoded><![CDATA[<P>So I was giving this demo the other day of some of our new concurrency features in&nbsp;the <A class="" title="Orcas CTP" href="http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx" mce_href="http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx">Orcas CTP</A>&nbsp;and&nbsp; I found this "new" feature for breakpoints. At least it was new for me. Sorry I'm a noob :)</P>
<P>The code was something like so:</P>
<DIV style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Lucida Console">
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;</P>
<DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;451</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">void</SPAN> ComputePrimes_ThreadProc(<SPAN style="COLOR: blue">object</SPAN> obj)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;452</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;453</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #2b91af">ThreadParams</SPAN> threadParams = (<SPAN style="COLOR: #2b91af">ThreadParams</SPAN>)obj;<SPAN style="COLOR: #ff0000"> &lt;- Breakpoint here</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;454</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;455</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: green">// Go through our range, determining if a number is a prime</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;456</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> number = threadParams.lower; number &lt;= threadParams.upper; number++)</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;457</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;458</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">if</SPAN> (IsAPrime(number))</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;459</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;460</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <SPAN style="COLOR: green">// Then add to our list</SPAN></P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;461</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _primes.Add(number); </P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;462</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;463</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;464</SPAN>&nbsp;</P>
<P style="MARGIN: 0px"><SPAN style="COLOR: #2b91af">&nbsp;&nbsp;465</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P style="MARGIN: 0px" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0px" mce_keep="true">&nbsp;</P></DIV>
<P style="MARGIN: 0px"><!--EndFragment--></SPAN></P></DIV>
<P>The problem I was trying to demonstrate, while stepping through some code, was a race condition&nbsp;occurring&nbsp;on a collection&nbsp;(one of our new features is supposed to help point this out). However, whenever I stepped, the other threads kept hitting the breakpoint, moving my ip indicator back to the breakpoint, and generally screwing stuff up.</P>
<P>Here's a screenshot of it in action (notice our new other thread indicators)</P>
<P mce_keep="true"><IMG src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/01/99/47/26/concurrency.png" original-url="http://blogs.msdn.com/photos/rchiodo/images/1994726/original.aspx" mce_src="http://blogs.msdn.com/photos/rchiodo/images/1994726/original.aspx"></P>
<P>Yeah this is a pain. I want to just step in this first thread. I guess I could wait until the right thread gets to the breakpoint, then freeze everybody else. This doesn't seem to work though (mostly because of the internal state of the other threads)</P>
<P>But wait, there is a way to step in just this thread!&nbsp;&nbsp;</P>
<P>Here's how:</P>
<OL>
<LI>Right click on the breakpoint and select "Filter" from the list of options</LI>
<LI>When the filter dialog appears, type in a filter condition. I used ThreadName=&lt;my thread name&gt;</LI>
<LI>Click OK</LI></OL>
<P>Now when the breakpoint gets hit, only this thread will be in stepping mode. (Something else I learned, threads are in one of 3 states - stepping, running, or suspended)</P>
<P>So as you step, the IP indicator won't jump around. </P>
<P>Of course this then made me want more, but I'll leave that for another post. </P>]]></content:encoded>
    </item>
    <item>
      <title>Hello World</title>
      <link>https://docs.microsoft.com/archive/blogs/rchiodo/hello-world</link>
      <pubDate>Thu, 29 Mar 2007 19:46:00 GMT</pubDate>
      <dc:creator><![CDATA[rchiodo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rchiodo/2007/03/29/hello-world/</guid>
      <description><![CDATA[Hi, my name is Rich Chiodo, and I work at Microsoft. 
That sounds like an admission of...]]></description>
      <content:encoded><![CDATA[<P>Hi, my name is Rich Chiodo, and I work at Microsoft. </P>
<P>That sounds like an admission of guilt.&nbsp;</P>
<P>I suppose in some ways I do feel guilty working here. I work for the&nbsp;<EM>man</EM> now. No longer am I&nbsp;one of the free spirited plebes of the&nbsp;software world. I am&nbsp;now the property of Mr. Bill. </P>
<P>I've been here for 8 months as part of the Visual Studio Diagnostics team - specifically working in the Visual Studio debugger. I'm hoping that this blog will let me discuss some of the interesting things I've found (or am trying to do) with the debugger. </P>]]></content:encoded>
    </item>
  </channel>
</rss>