<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>TTL</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/ttl/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/ttl/feed.xml</link>
    <description>Random technology posts and other thoughts.</description>
    <lastBuildDate>Wed, 17 Apr 2019 04:10:46 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Browsing source from Windbg</title>
      <link>https://docs.microsoft.com/archive/blogs/ttl/browsing-source-from-windbg</link>
      <pubDate>Wed, 29 Jun 2011 00:53:00 GMT</pubDate>
      <dc:creator><![CDATA[Marktaylor2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ttl/2011/06/29/browsing-source-from-windbg/</guid>
      <description><![CDATA[This is a quick tip that I find useful for accessing source for a function. If your driver has...]]></description>
      <content:encoded><![CDATA[<p>This is a quick tip that I find useful for accessing source for a function. If your driver has multiple source files and you have setup a source server, you can save time by immediately pulling up correct version of the source you are interested in, without necessarily running the code within the debugger. The following assumes you have setup source and private symbol access correctly and that you are in an active debugger session.</p>  <p>&#160;</p>  <ol>   <li>Turn on source mode in the UI or by running the .lines command</li>    <li>Choose the function you are interested in</li>    <li>Run the following command for that function</li>    <ul>     <li>X module!function</li>   </ul>    <li>The first part of the output for this will be the memory address for the function, e.g.</li>    <ul>     <li>kd&gt; x nt!IofCallDriver</li>      <li><font style="background-color: #ffff00">82842ee0</font> nt!IofCallDriver</li>   </ul>    <li>From the Edit menu, choose “Go To Address” and enter the address highlighted above.</li> </ol>  <p>If everything is setup correctly, the source for the target function will open.</p>]]></content:encoded>
    </item>
    <item>
      <title>Server 2008 R2 transformed into Windows 7 Client</title>
      <link>https://docs.microsoft.com/archive/blogs/ttl/server-2008-r2-transformed-into-windows-7-client</link>
      <pubDate>Mon, 27 Jun 2011 14:29:00 GMT</pubDate>
      <dc:creator><![CDATA[Marktaylor2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ttl/2011/06/27/server-2008-r2-transformed-into-windows-7-client/</guid>
      <description><![CDATA[I work as a consultant so I touch a lot of technologies. I find it very handy to have a Hyper-V...]]></description>
      <content:encoded><![CDATA[<p>I work as a consultant so I touch a lot of technologies. I find it very handy to have a Hyper-V system so that I can choose from a large number of test clients across both 32 and 64 bit. The result is Server 2008 R2 installed on my laptop. The only thing I really need from the server install is the Hyper-V functionality, so after installation completes, I immediately take a long list of steps to get most of the client behavior back. I was unable to find a comprehensive list of these steps for Windows Server R2 so decided to create one&hellip;</p>
<p>From the Start Menu -&gt; Administrative Tools -&gt; Server Manager, install the following roles and features&hellip;</p>
<p>Roles:</p>
<ul>
<li>Add the Hyper-V role</li>
<li>Add the &ldquo;Windows Search Service&rdquo; role under &ldquo;File Services&rdquo; - this will enable fast search through explorer / mail items / etc.</li>
</ul>
<p>Features:</p>
<ul>
<li>Add &ldquo;Wireless LAN service&rdquo; &ndash; without this, you will not be able to connect through your wireless network adapter.</li>
<li>Add the &ldquo;Desktop Experience&rdquo;</li>
<li>Add the &ldquo;.NET Framework 3.5.1 features&rdquo;</li>
<li>Add the &ldquo;Quality Windows Audio Video Experience&rdquo;</li>
<li>Add the &ldquo;XPS Viewer&rdquo; (if needed)</li>
<li>Add &ldquo;Bitlocker Drive Encryption&rdquo; (if needed)</li>
</ul>
<p>Click on the root Server Manager node in the Server Manager tree view:</p>
<p>Disable the IE Enhanced Security Configuration (optional - do this at your own risk)</p>
<p>One of the drawbacks of having a Hyper-V server on your laptop is you lose the ability to put the machine into the &lsquo;sleep&rsquo; low power state. This is specifically due to the hypervisor, not Windows Server 2008 R2 so if you opt to boot without the hypervisor, this state becomes available to you again. You can use the BCDEdit boot utility to setup a boot option enabling you to start the machine without the hypervisor so that you can specifically choose to boot into the hypervisor when you need Hyper-V functionality:</p>
<p>BCDEdit:</p>
<ul>
<li>Start a command window as administrator</li>
<li>Clone your existing BCD boot settings so you can boot into either configuration &lt;bcdedit /copy {current} /d "Hyper-V Off"&gt;</li>
<li>You will get output similar to the following: &ldquo;The entry was successfully copied to <span style="background-color: #ffff00;">{0e448378-857f-11e0-b3b3-d8d3859a8e19}&rdquo;</span> &lt;copy the highlighted section&gt;</li>
<li>Enter the following command: &lt;BCDEdit &ndash;set <span style="background-color: #ffff00;">{0e448378-857f-11e0-b3b3-d8d3859a8e19}</span> hypervisorlaunchtype off&gt; using the GUID you copied from the last step</li>
</ul>
<p>Power Settings:</p>
<ul>
<li>Go into your laptop power settings and make sure sleep enabled in power settings. You can access power settings by right clicking the battery icon on the right side of your taskbar.</li>
</ul>
<p>Note: The sleep option may not show up on start menu, but will react to hardware power settings. So if you configure your machine to sleep when the power button is pressed in your power plan (configured in Power Options) this will work.</p>
<p>Turn on Aero Glass:</p>
<ul>
<li>From the start menu -&gt; Administrative Tools -&gt; Services, scroll down to the &lsquo;themes&rsquo; service, right click on it and choose properties. Start the service and set the startup type to &lsquo;automatic&rsquo;</li>
<li>Right click on the desktop and choose &lsquo;Personalize&rsquo;. Select an Aero Theme (probably Windows 7).</li>
<li>From the start menu, right click on &ldquo;Computer&rdquo; and choose &ldquo;Properties&rdquo;. From the &ldquo;System Properties&rdquo; dialog, choose the &ldquo;Advanced&rdquo; tab. Click &ldquo;Settings&rdquo; from the Performance section. In the &ldquo;Visual Effects&rdquo; tab, change to &ldquo;Adjust for best appearance&rdquo;.</li>
</ul>
<p>Change Performance Settings to match the client version:</p>
<ul>
<li>From the start menu, right click on &ldquo;Computer&rdquo; and choose &ldquo;Properties&rdquo;. From the &ldquo;System Properties&rdquo; dialog, choose the &ldquo;Advanced&rdquo; tab. Click &ldquo;Settings&rdquo; from the Performance section. In the &ldquo;Advanced&rdquo; tab, change &lsquo;Adjust for best performance of:&rsquo; setting to &ldquo;Programs&rdquo;</li>
</ul>
<p>Another annoying thing about running Server on a laptop is that every time you shutdown the computer, the system pops up a dialog demanding that you tell it why you are shutting it down. Take the following steps to turn this behavior off:</p>
<ul>
<li>From the Start Menu, type &ldquo;gpedit.msc&rdquo; in the search box and hit enter.</li>
<li>In the Local Group Policy Editor tree view go to Computer Configuration-&gt;Administrative Templates-&gt;System node. Scroll through the settings in the left pane to find the &ldquo;Display Shutdown Event Tracker&rdquo; setting. Double click on this and change it to &ldquo;disabled&rdquo;.</li>
</ul>
<p>I believe that at this point your Server 2008 R2 machine will be as close to a Windows 7 Client as possible. If there are any tricks that I missed, please let me know and I will add them.</p>]]></content:encoded>
    </item>
    <item>
      <title>Working with pointers and mixed syntax in Windbg kernel debugger</title>
      <link>https://docs.microsoft.com/archive/blogs/ttl/working-with-pointers-and-mixed-syntax-in-windbg-kernel-debugger</link>
      <pubDate>Mon, 27 Jun 2011 00:11:00 GMT</pubDate>
      <dc:creator><![CDATA[Marktaylor2]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ttl/2011/06/27/working-with-pointers-and-mixed-syntax-in-windbg-kernel-debugger/</guid>
      <description><![CDATA[One of the more confusing aspects of Windbg for me is the ability to compound commands. This...]]></description>
      <content:encoded><![CDATA[<p>One of the more confusing aspects of Windbg for me is the ability to compound commands. This commonly shows up in creation of conditional breakpoints, but can be generally helpful when working with complex structures and serves as the basis of debugger command programs (scripts). The Windbg help is very good and describes the syntax but is short on examples, especially complex examples.</p>  <p>There are two different syntaxes available in Windbg, MASM (assembler) and C++. Several commands allow you to choose between these, reset the debugger default, etc. For a complete treatment, see Windbg help heading ‘Evaluating Expressions’. For our purposes, there are several key things to understand. The MASM syntax is the default, but you can specify the syntax you want for your command by using either @@c++(&lt;commands&gt;), or @@masm(&lt;commands&gt;). The @@(&lt;commands&gt;) symbol has the effect of switching from the current syntax to the alternate syntax. If you want to evaluate an expression using the C++ syntax, you specify ‘??’ as the evaluation command, for MASM use ‘?’. Each syntax has its own strengths and weaknesses. We will be looking at traversing structures which is one of the major strengths of the C++ syntax so we will primarily be using it in this post. As not everyone involved in kernel debugging is intimately familiar with C++, examples of using this syntax can be helpful.</p>  <p>In order to work through the following examples, you will need to have Windbg setup on your machine with public OS symbols working correctly. You will also need a sample OS kernel crash dump. The dump must contain the full kernel memory space so a “small kernel dump” will not work. Alternatively, you can connect to, and kernel debug, a target machine. These preliminary steps are outside the scope of this post, but there are lots of articles on the web and in Windbg help explaining how to do this. I used Windows 7 X86 to create and test the examples. Once you have loaded your dump file and symbols are verified, try the following:</p>  <p>Get a thread to use: </p>  <ul>   <li>!process - (use any addresses after “THREAD” from the output)</li> </ul>  <p>Dump the Executive Thread Block pointed to by this address</p>  <ul>   <li>Dt &lt;address&gt; _ethread</li> </ul>  <p>Use the C++ evaluator (??) to evaluate one of the structures members after casting it to the correct type</p>  <ul>   <li>?? ((nt!_kthread *) 0x8add4540)-&gt;Process - (note that the 0x prefix is mandatory. Without this you will get an error)</li> </ul>  <p>Use the MASM evaluator (?) to evaluate this using MASM syntax – note the 0x150 offset is the location of the ‘Process’ member.</p>  <ul>   <li>? poi(0x8add4540 + 0x150) - (poi() dereferences a pointer. Dumps the address of the structure, but not the type as it does not map this to the symbol data)</li> </ul>  <p>You can use the dump type command (dt) or specific extensions to display similar type information to that seen in the c++ example, given the address from the MASM command</p>  <ul>   <li>!process poi(0x8add4540 + 0x150) : gives the extension output correctly</li> </ul>  <p>A big advantage of C++ syntax is the access to symbolic information, as seen in the example above. Besides being more readable and easier to work with, the symbolic names of structure members are less likely to change in future OS service packs and releases than raw offsets, making this a more reliable method of traversing structures.</p>  <p>We can now look at a more complex example using the internal list of ‘Dispatcher’ objects associated with a particular thread. For an overview of dispatcher objects, see Windows Internals 5<sup>th</sup> Edition page 178. This post is only covering how to access objects through various syntaxes in windbg. The following structures were chosen as examples for their complexity, we are not going to look at their functionality, or synchronization issues, and we will not be creating a functionally useful script (we will do that in later posts). This exercise is just designed to learn the mechanics. We don’t need to understand the functionality of the structures, but we do need to understand how they relate to one another. The below illustration shows these relationships…</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/43/metablogapi/1616.objects_531732C7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-43-metablogapi/1616.objects_5F00_531732C7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="objects" border="0" alt="objects" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/43/metablogapi/6175.objects_thumb_31B78D2B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-43-metablogapi/6175.objects_5F00_thumb_5F00_31B78D2B.png" width="851" height="533" /></a>    <br />The goal of this exercise is to start with address of a particular _DISPATCHER_HEADER structure, and try to get all the way to the name of the app that started the process containing the thread that is waiting for it (whew!).</p>  <p>The easiest way to get a _DISPATCHER_HEADER structure to play with is to look at the output of !process for the system process. Here are the commands to run in your sample dump file to get the address of a _DISPATCHER_HEADER object…</p>  <ul>   <li>!process 0 0 system – (output as below, copy the highlighted address)</li>    <li>PROCESS 83f3da40 SessionId: none Cid: 0004 Peb: 00000000 ParentCid: 0000</li>    <li>DirBase: 00185000 ObjectTable: 86c01cb8 HandleCount: 474.</li>    <li>Image: System</li>    <li>!process &lt;address&gt; </li>    <li>e.g. “!process 83f3da40”</li> </ul>  <p>&lt;Look for any thread that shows it is waiting on something – use the address of the object being waited for in the next steps (highlighted)&gt;</p>  <p>&lt;…&gt;   <br />THREAD 8af5a990 Cid 0004.0740 Teb: 00000000 Win32Thread: 00000000 WAIT: (WrQueue) KernelMode Non-Alertable    <br /><font style="background-color: #ffff00">8af59d80</font> QueueObject    <br />Not impersonating    <br />DeviceMap 86c07868    <br />Owning Process 83f3da40 Image: System    <br />Attached Process N/A Image: N/A    <br />Wait Start TickCount 2417 Ticks: 10245 (0:00:01:42.597)    <br />Context Switch Count 1 IdealProcessor: 0    <br />UserTime 00:00:00.000    <br />KernelTime 00:00:00.000    <br />Win32 Start Address srv2!SrvProcWorkerThread (0x926686cb)    <br />Stack Init 80fe4fd0 Current 80fe4c08 Base 80fe5000 Limit 80fe2000 Call 0    <br />Priority 8 BasePriority 8 UnusualBoost 0 ForegroundBoost 0 IoPriority 2 PagePriority 5    <br />ChildEBP RetAddr    <br />80fe4c20 8286fc6d nt!KiSwapContext+0x26 (FPO: [Uses EBP] [0,0,4])    <br />80fe4c58 8286ead3 nt!KiSwapThread+0x266    <br />80fe4c80 8286f7c5 nt!KiCommitThreadWait+0x1df    <br />&lt;…&gt;</p>  <p>Now that we have the address of our dispatcher object, we need to get to the first _KWAIT_BLOCK in its list of wait blocks. This is a little tricky as the _DISPATCHER_HEADER stores pointers to these in a linked list so the WaitListHead member actually contains the Flink pointing to the first _KWAIT_BLOCK (see ‘dt _DISPATCHER_HEADER and ‘dt _LIST_ENTRY’).&#160; The Flink points to the first wait block so we will cast the Flink to this type to access its members.</p>  <p>In the following examples, I am using the addresses from the thread example output above. The highlighted addresses will need to be changed to match those from your system.</p>  <ul>   <li>?? ((nt!_dispatcher_header *)<font style="background-color: #ffff00">0x8af59d80</font>)-&gt;WaitListHead.Flink - (to get the linked list)</li>    <li>?? (_kwait_block *)(((nt!_dispatcher_header *)<font style="background-color: #ffff00">0x8af59d80</font>)-&gt;WaitListHead.Flink) - (to get the _kwait_block object)</li> </ul>  <p>Looking at the _kwait_block structure, we can see that it contains a _kthread member. We can access that next…</p>  <ul>   <li>?? ((_kwait_block *)(((nt!_dispatcher_header *)<font style="background-color: #ffff00">0x8af59d80</font>)-&gt;WaitListHead.Flink))-&gt;Thread</li> </ul>  <p>Within the _kthread structure, there is a ‘Process’ member of type _kprocess. Since the correct type is contained in the structure, we can access without casting with the C++ syntax</p>  <ul>   <li>?? ((_kwait_block *)(((nt!_dispatcher_header *)<font style="background-color: #ffff00">0x8af59d80</font>)-&gt;WaitListHead.Flink))-&gt;Thread-&gt;Process</li> </ul>  <p>With heavy use of Windows Internals 5<sup>th</sup> Edition, and the ‘dt’ command, we can find that every _kprocess structure is the first member of a containing _eprocess structure. This means that we can cast the pointer to an _eprocess structure and access its ‘ImageFileName’ member, which will give us the name of the exe file associated with the process (our end goal)…</p>  <ul>   <li>?? (_eprocess *)(((_kwait_block *)(((nt!_dispatcher_header *)<font style="background-color: #ffff00">0x8af59d80</font>)-&gt;WaitListHead.Flink))-&gt;Thread-&gt;Process)</li>    <li>?? ((nt!_EPROCESS *)((nt!_KWAIT_BLOCK *)((nt!_DISPATCHER_HEADER *)<font style="background-color: #ffff00">0x8bab3250</font>)-&gt;WaitListHead.Flink)-&gt;Thread-&gt;Process)-&gt;ImageFileName</li> </ul>  <p>If we want to see the actual image file name, we can use da (dump ascii) instead of ‘??’ to dump the file name. Remember though that Windbg defaults to MASM syntax so if we are not using the ‘??’ command specific to evaluating C++ syntax, we have to place our command within the @@c++() parentheses</p>  <ul>   <li>da @@C++(((nt!_EPROCESS *)((nt!_KWAIT_BLOCK *)((nt!_DISPATCHER_HEADER *)<font style="background-color: #ffff00">0x8bab3250</font>)-&gt;WaitListHead.Flink)-&gt;Thread-&gt;Process)-&gt;ImageFileName)</li> </ul>  <p>This example is chosen to be (hopefully) as complex as most scenarios you might encounter in your own debugging. In a future series of articles, I am planning to provide an example of implementing a full scripted command (or command program) that is as easy to use as Windbg built in commands / extensions, practically useful, and available across debugging sessions. The idea is to show how you can create a library of custom commands, specific to your own drivers / troubleshooting tasks.</p>]]></content:encoded>
    </item>
  </channel>
</rss>