title: Iterating through !DumpHeap output to read value at memory offset
body: <p>I'm trying to come up with a WinDbg command line expression that takes the output of the <code>!DumpHeap</code> command and for each address, reads a 64-bit value from offset <code>0x08</code> after the address. I think this is possible (not sure about it) but every attempt I made so far fails with some error. </p>
  
  <p>I searched a lot but most WinDbg articles show simple examples which I can try but my attempts fail.</p>
  
  <p>I have a process dump of an ASP.NET worker process. The process has some memory growth but there's no clear offender so I'm trying to list a number of objects that appear many times in memory. I'm using sos.dll for the managed debugging WinDbg extensions.</p>
  
  <p>Here's what I'm trying to do</p>
  
  <pre><code>.foreach(myaddress {!dumpheap -short -mt 000007fe998adea8})
  {r @$t0=poi(myaddress+0x8);!do @$t0;.echo ************* myaddress}
  </code></pre>
  
  <p><em>Note, that the above command must be on a single line - I only added a line break for better readability here.</em></p>
  
  <p>For the above line, WinDbg prints this error: <code>Couldn't resolve error at 'myaddress+0x8);!do @$t0;.echo ************* 00000001003cb870'</code>.</p>
  
  <p>I'm trying to iterate through all addresses returned by <code>!DumpHeap</code> - each address should go into the <code>myaddress</code> variable. Then, for each address, I'm trying to set the <code>$t0</code> user register to the value read from <code>myaddress+0x8</code>. The <code>!do</code> (<code>!DumpObject</code>) command would then dump the object at that address.</p>
  
  <p>If I run only (<em>again, on one line in WinDbg</em>):</p>
  
  <pre><code>.foreach(myaddress {!dumpheap -short -mt 000007fe998adea8})
  {!do myaddress;.echo ************* myaddress}
  </code></pre>
  
  <p>I get a list of object dumps but this is one level higher than what I need. I want to drill down one level deeper and dump a particular member of these top-level objects that I'm iterating through.</p>
  
  <p>Is this possible or am I on the wrong track with this?</p>