{"componentChunkName":"component---src-templates-post-template-js","path":"/magical-windbg-vol1-07-en","result":{"data":{"markdownRemark":{"id":"187b0ad8-7bb9-581c-8669-0b8fd94185c8","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/magical-windbg-vol1-07\">original page</a>.</p>\n</blockquote>\n<p>In Chapter 7, the final chapter of this book, we will analyze the same user-mode memory leak issue covered in Chapter 6, this time from a full system memory dump.</p>\n<p>Since the method of investigating the memory leak itself is the same as in Chapter 6, Chapter 7 focuses more on introducing techniques for extracting various kinds of information from a full memory dump.</p>\n<p>However, when analyzing a full memory dump that includes kernel-mode memory information, the available commands and their output differ from those used in user-mode process dump analysis, so I think you will be able to enjoy a different style of analysis here as well.</p>\n<!-- omit in toc -->\n<h2 id=\"table-of-contents\" style=\"position:relative;\"><a href=\"#table-of-contents\" aria-label=\"table of contents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Table of contents</h2>\n<ul>\n<li><a href=\"#obtaining-a-full-system-memory-dump\">Obtaining a full system memory dump</a></li>\n<li><a href=\"#loading-the-full-memory-dump-into-windbg\">Loading the full memory dump into WinDbg</a></li>\n<li><a href=\"#collecting-hardware-information-about-the-machine\">Collecting hardware information about the machine</a></li>\n<li><a href=\"#collecting-system-information\">Collecting system information</a></li>\n<li><a href=\"#exploring-the-system-registry\">Exploring the system registry</a></li>\n<li><a href=\"#investigating-memory-resource-usage\">Investigating memory resource usage</a></li>\n<li><a href=\"#investigating-information-about-running-processes\">Investigating information about running processes</a></li>\n<li><a href=\"#investigating-the-stack-backtrace-of-a-specific-process\">Investigating the stack backtrace of a specific process</a></li>\n<li><a href=\"#investigating-heap-information-for-a-user-mode-process\">Investigating heap information for a user-mode process</a></li>\n<li><a href=\"#summary-of-chapter-7\">Summary of Chapter 7</a></li>\n<li><a href=\"#links-to-each-chapter\">Links to each chapter</a></li>\n</ul>\n<h2 id=\"obtaining-a-full-system-memory-dump\" style=\"position:relative;\"><a href=\"#obtaining-a-full-system-memory-dump\" aria-label=\"obtaining a full system memory dump permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Obtaining a full system memory dump</h2>\n<p>To obtain the full memory dump for analysis, just as in Chapter 6, start D4C.exe, choose menu item 2, and reproduce the application’s memory leak issue.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/c9686e0bd856e304ccbd48f263c244c5/0b533/mem-leak-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 76.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACNklEQVQ4y42TS2/TQBSFDUpC4lect+147PEj8atpRSR+E2wRC1YsCGxb/gYgiEARXVAoISqs+UeHO5OkhLaBLo6uc618PufeGWX++Rvmi094+2Eh9Wb+Ea9J7xenOPt+gS+rH7Jun7+ufu6I3i0vcHq2xPlyhXfnv6D0XQ+9ThtqowFdU2HquqxN04CmUk+lnqFLqY06atXKddVqqNxR8OjpSyjBKEORZzg4mKAoSlKBsiwxnU7lc5pmyKn2+31YlgXDMG6QCa1ew+Pnr6DYjMNzXQQBx3A4BPMZHMdBFEXyt+d5Us1mEyq51UWCazKg3quugXFWggcBAQMkSUKgGGEYYjweYzAYoNvtoiHGsfmzpml7gJU1MDu8j/EoQZbnmEwmyKmKmL7vy5hb6M2gK8DZCZQwzRGRI89jEuJSXOGW0wjsgY1WqwXTNG8BFJFPxFJSxDQvRkAxR2/oSbD4iIi+G1lA90feAPkG6DMfnHO5AOFQ9MQH2u32JWS/y12HycYhYxIkNivA256IfOulzGgpUVZQPH4JFA5deYzIZRzDtm3pUpy3fzsk4AsCjsoJQr4GCajj2LIKpxa5E+dPQP8PrK637FPkhJyIRYglSKcUWZ5J6nd7PdTr9T+Rr0j2je0Mj2mG8QhJGMAnh5ygzHVkTaIQAfPQtprQ6A7r8l7vEd19tXoXT2YE5EcPEJdHcJMMLC3gxCnYuEBYHMIb5bBcH2rHhtZ1SPbf6mxE71SzhYfPjvEbvIqsR9VDrFUAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/c9686e0bd856e304ccbd48f263c244c5/8ac56/mem-leak-001.webp 240w,\n/static/c9686e0bd856e304ccbd48f263c244c5/d3be9/mem-leak-001.webp 480w,\n/static/c9686e0bd856e304ccbd48f263c244c5/b0a15/mem-leak-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/c9686e0bd856e304ccbd48f263c244c5/8ff5a/mem-leak-001.png 240w,\n/static/c9686e0bd856e304ccbd48f263c244c5/e85cb/mem-leak-001.png 480w,\n/static/c9686e0bd856e304ccbd48f263c244c5/0b533/mem-leak-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/c9686e0bd856e304ccbd48f263c244c5/0b533/mem-leak-001.png\"\n            alt=\"Reproducing the user-mode memory leak with D4C.exe\"\n            title=\"Reproducing the user-mode memory leak with D4C.exe\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Once you have confirmed with a tool such as Process Explorer that the virtual memory region used by the D4C.exe process has ballooned, obtain a full memory dump by causing a system crash with a keyboard operation.</p>\n<p>A keyboard-triggered system crash can be caused using the same steps as in Chapter 1: while holding down the right Ctrl key, tap the Space key twice in quick succession.</p>\n<p>If the keyboard-crash settings configured in Chapter 1 are in effect, performing the above key sequence will crash the system and display a blue screen.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/aed56d2ac06acaecdc7941c14636d092/0b533/fulldump-003.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 49.16666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABZUlEQVQoz41S2U4CQRBcXxARF8EDwXjFC2OIiQ/GaHzwm4AlgiKigOAVj+iXufeun1J2zyywIQZ5qO2Z7p6artpRlPI3FC2EIqE0BC2If9V69bIuo1IykL6xBRbrNvKPHnIdF/tdT+wzDZnfbLs4eHax0rSw0bax9+BgrWVjt+sgUTMlMZMqmo7MrYV1Kp5++Dh+83Hy7mO742Dr3kGODuzQ+vzrB4cvHo5ePZx9+sg/uaKuElmkog+mZMnxSwMzVwaydxY1GEhem4hRbqpqIFqVtVTdFHuuzdGac5MVY2BVXzJ9eMLVpo15ahQ+FYY8KoZQCFAc8lQLEfKEfHOCblUJyZqcIFqR0/FEKvXEA0yzIo5VuY9R7JMyIZOx3GXCUsOiH2SKOFuTh1k++8Ty+TBL71nCkfNSuvBQR4oIF4gkS9LTDSY1hfzIhY4J9qYUelajnk05kDyysd/8D8ITjtU8Th/hFw2O1/mgLvuiAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/aed56d2ac06acaecdc7941c14636d092/8ac56/fulldump-003.webp 240w,\n/static/aed56d2ac06acaecdc7941c14636d092/d3be9/fulldump-003.webp 480w,\n/static/aed56d2ac06acaecdc7941c14636d092/b0a15/fulldump-003.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/aed56d2ac06acaecdc7941c14636d092/8ff5a/fulldump-003.png 240w,\n/static/aed56d2ac06acaecdc7941c14636d092/e85cb/fulldump-003.png 480w,\n/static/aed56d2ac06acaecdc7941c14636d092/0b533/fulldump-003.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/aed56d2ac06acaecdc7941c14636d092/0b533/fulldump-003.png\"\n            alt=\"Blue screen (BSOD)\"\n            title=\"Blue screen (BSOD)\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>After the system reboots, a <code class=\"language-text\">FULL_MEMORY.DMP</code> file roughly the same size as the virtual machine’s physical memory will be created directly under the <code class=\"language-text\">C:\\Windows</code> folder.</p>\n<p>In this chapter, we will use this full memory dump to investigate the application’s memory leak issue.</p>\n<p>Incidentally, as mentioned in Chapter 1, the keyboard-crash configuration described in this book does not work when you are connected over RDP.</p>\n<p>If you can use a physical keyboard, you need to sign in directly to the local machine and cause the system crash by pressing the right Ctrl key while tapping the Space key twice.</p>\n<p>If you are using a Hyper-V virtual machine, you can also trigger the keyboard crash by signing in with Enhanced Session Mode disabled and then pressing the right Ctrl key while tapping the Space key twice.</p>\n<p>If you are using another kind of virtual machine, try using a software keyboard.</p>\n<p>If your environment does not allow you to perform a keyboard crash, you can also intentionally reproduce a system crash by using notmyfault.exe included in the SysinternalsSuite downloaded in <a href=\"/magical-windbg-vol1-01-en#installing-the-sysinternals-utilities\">Installing the Sysinternals utilities</a>.</p>\n<h2 id=\"loading-the-full-memory-dump-into-windbg\" style=\"position:relative;\"><a href=\"#loading-the-full-memory-dump-into-windbg\" aria-label=\"loading the full memory dump into windbg permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Loading the full memory dump into WinDbg</h2>\n<p>Once you have obtained the dump file for analysis, let’s load it right away into WinDbg running with administrator privileges.</p>\n<p>As in the previous chapters, when we run the <code class=\"language-text\">!analyze -v</code> command and inspect the Bug Check information contained in the dump file, it is displayed as <code class=\"language-text\">MANUALLY_INITIATED_CRASH (e2)</code><sup id=\"fnref-1\"><a href=\"#fn-1\" class=\"footnote-ref\">1</a></sup>, as shown below.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !analyze -v\n\nMANUALLY_INITIATED_CRASH (e2)\nThe user manually initiated this crash dump.\nArguments:\nArg1: 0000000000000000\nArg2: 0000000000000000\nArg3: 0000000000000000\nArg4: 0000000000000000</code></pre></div>\n<p>This is the value recorded when a user intentionally causes a system crash through a kernel debugger or a keyboard operation.</p>\n<p>In other words, just like the process dump that was generated manually in Chapter 6, the exception context stored in this full memory dump is not useful for analyzing the memory leak issue.</p>\n<p>Therefore, when investigating problems other than crashes from a full memory dump, you first need to narrow down the appropriate analysis target and set the debugger context accordingly.</p>\n<p>So, in the following sections, we will comprehensively collect information from the full memory dump to identify the proper analysis target.</p>\n<p>A full memory dump contains information about every page currently held in the system’s physical memory, and by fully using the capabilities of WinDbg as a powerful debugger, you can retrieve virtually any information in the system from that full memory dump.</p>\n<p>Depending on the command you run, the output can be enormous, so it is a good idea to use the <code class=\"language-text\">.logopen</code> command to write the results to a file as needed.</p>\n<h2 id=\"collecting-hardware-information-about-the-machine\" style=\"position:relative;\"><a href=\"#collecting-hardware-information-about-the-machine\" aria-label=\"collecting hardware information about the machine permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Collecting hardware information about the machine</h2>\n<p>To begin with, let’s use the <code class=\"language-text\">!sysinfo</code> extension command<sup id=\"fnref-2\"><a href=\"#fn-2\" class=\"footnote-ref\">2</a></sup> to collect hardware information recorded in the dump file.</p>\n<p>The <code class=\"language-text\">!sysinfo</code> extension command has several options, but in this book we use <code class=\"language-text\">!sysinfo cpuinfo</code> to display CPU information and <code class=\"language-text\">!sysinfo machineid</code> to display machine information.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Display CPU information\n0: kd> !sysinfo cpuinfo\n[CPU Information]\n~MHz = REG_DWORD 1992\nComponent Information = REG_BINARY 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\nConfiguration Data = REG_FULL_RESOURCE_DESCRIPTOR ff,ff,ff,ff,ff,ff,ff,ff,0,0,0,0,0,0,0,0\nIdentifier = REG_SZ Intel64 Family 6 Model 142 Stepping 10\nProcessorNameString = REG_SZ Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz\nUpdate Status = REG_DWORD 7\nVendorIdentifier = REG_SZ GenuineIntel\nMSR8B = REG_QWORD ea00000000\n\n# Display machine information\n0: kd> !sysinfo machineid\nMachine ID Information [From Smbios 3.0, DMIVersion 0, Size=3046]\nBiosMajorRelease = 1\nBiosMinorRelease = 43\nFirmwareMajorRelease = 1\nFirmwareMinorRelease = 10\nBiosVendor = LENOVO\nBiosVersion = N20ET58W (1.43 )\nBiosReleaseDate = 07/26/2021\nSystemManufacturer = LENOVO\nSystemProductName = 20KES0KB00\nSystemFamily = ThinkPad X280\nSystemVersion = ThinkPad X280\nSystemSKU = LENOVO_MT_20KE_BU_Think_FM_ThinkPad X280\nBaseBoardManufacturer = LENOVO\nBaseBoardProduct = 20KES0KB00\nBaseBoardVersion = Not Defined</code></pre></div>\n<p>By running these commands, we were able to confirm, as shown above, that the machine on which the system crash occurred was a ThinkPad X280 equipped with an Intel i7-8550U.</p>\n<p>If you want to display even more detailed CPU information, you can use the <code class=\"language-text\">!cpuinfo</code> extension command<sup id=\"fnref-3\"><a href=\"#fn-3\" class=\"footnote-ref\">3</a></sup>.</p>\n<p>When you run <code class=\"language-text\">!cpuinfo</code> without any options, information for all processors is displayed.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/e2b34eda87dc1bf2f29cbe237be8f562/0b533/system-windbg-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 22.499999999999996%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8ElEQVQY002QWauDQAyF/f8/qSjog/pQxbq2uCAVUcEFq6B1PZcELHcghDk5+ZIZ4f1+w7ZthGGItm3R9z3KskSWZZyLomCtrmt0XYemafhO3qqqWL80ygKBXNeFYRiQZRn3+x2O40DXddxuNw5JknjAtm2YpgnrumIYBvZblsVQ0uZ5hpCmKZ7PJ4Ig4CLlOI4ZqqoqgxVF4ab/hwA0/PV6YRzHny4kScLAx+MBTdNgmiY8z2MzbUYhiiLyPMd5nliWBfu+4/v9sp+8n8+HYVQXjuNgA2UK+lOaSsYoin7/6/s+v4AGU402vHoIdAH/AOdKbH6gd91XAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/e2b34eda87dc1bf2f29cbe237be8f562/8ac56/system-windbg-001.webp 240w,\n/static/e2b34eda87dc1bf2f29cbe237be8f562/d3be9/system-windbg-001.webp 480w,\n/static/e2b34eda87dc1bf2f29cbe237be8f562/b0a15/system-windbg-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/e2b34eda87dc1bf2f29cbe237be8f562/8ff5a/system-windbg-001.png 240w,\n/static/e2b34eda87dc1bf2f29cbe237be8f562/e85cb/system-windbg-001.png 480w,\n/static/e2b34eda87dc1bf2f29cbe237be8f562/0b533/system-windbg-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/e2b34eda87dc1bf2f29cbe237be8f562/0b533/system-windbg-001.png\"\n            alt=\"Output of the !cpuinfo extension command\"\n            title=\"Output of the !cpuinfo extension command\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Because the Intel i7-8550U is a 4-core, 8-thread CPU, the output of <code class=\"language-text\">!cpuinfo</code> also has 8 lines.</p>\n<p>The values from 0 to 7 in the CP column represent each processor, and the MHz column represents the clock frequency.</p>\n<h2 id=\"collecting-system-information\" style=\"position:relative;\"><a href=\"#collecting-system-information\" aria-label=\"collecting system information permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Collecting system information</h2>\n<p>Next, we will collect OS system information from the full memory dump.</p>\n<p>Regarding OS system information, if you set the context to a process the user is running and execute the <code class=\"language-text\">!peb</code> command, you can refer to it through the user’s environment variable information contained in the PEB.</p>\n<p>In fact, from the full memory dump analyzed this time as well, we were able to retrieve information such as the computer name, the number of CPUs, the PATH environment variable, and the username, as shown below.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !peb\n{{ omitted }}\nEnvironment:  000001d5a58027f0\n  ...\n  COMPUTERNAME=THINKPAD-X280\n  ...\n  NUMBER_OF_PROCESSORS=8\n  OS=Windows_NT\n  Path=C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\WINDOWS\\ServiceProfiles\\NetworkService\\AppData\\Local\\Microsoft\\WindowsApps\n  ...\n  PROCESSOR_ARCHITECTURE=AMD64\n  PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 10, GenuineIntel\n  ...\n  USERDOMAIN=THINKPAD-X280\n  USERDOMAIN_ROAMINGPROFILE=THINKPAD-X280\n  USERNAME=Win10\n  USERPROFILE=C:\\Users\\Win10</code></pre></div>\n<p>In addition, you can also collect OS information and the computer name by using the <code class=\"language-text\">!mex.ver</code> and <code class=\"language-text\">!mex.computername</code> commands provided by the MEX extension<sup id=\"fnref-4\"><a href=\"#fn-4\" class=\"footnote-ref\">4</a></sup>, which is introduced in “Appendix A: WinDbg Tips” in this book.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Check OS version information with the MEX extension\n0: kd> !mex.ver\nPlatform ID: 2\nMajor Version: 10\nMinor Version: 0\nWinXP: False\nWin2K3: False\nWin2k3SP1OrNewer: True\nVista: False\nVistaOrNewer: True\nWin7: False\nWin8: False\nBlue: False\n19041.1.amd64fre.vb_release.191206-1406\nBuild Number: 19041\nKernel Start Address: ffff800000000000\nSystem Version Build String: 19041.1.amd64fre.vb_release.191206-1406\n\n# Check the computer name with the MEX extension\n0: kd> !mex.computername\nComputer Name: THINKPAD-X280</code></pre></div>\n<h2 id=\"exploring-the-system-registry\" style=\"position:relative;\"><a href=\"#exploring-the-system-registry\" aria-label=\"exploring the system registry permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Exploring the system registry</h2>\n<p>On Windows systems, OS settings, application settings, and various other kinds of information are stored in the registry.</p>\n<p>Therefore, by analyzing a full memory dump and exploring the registry hives, you can access most information related to the system and its configuration.</p>\n<p>To search the registry from a full memory dump in WinDbg, use the <code class=\"language-text\">!reg</code> extension command<sup id=\"fnref-4a\"><a href=\"#fn-4a\" class=\"footnote-ref\">4a</a></sup>.</p>\n<p>For example, by executing commands in the following steps, you can use the <code class=\"language-text\">!reg</code> extension command to search a specified registry value in a full memory dump.</p>\n<ol>\n<li>Use the <code class=\"language-text\">!reg hivelist</code> command to obtain the addresses of the registry hives in the system.</li>\n<li>Use the <code class=\"language-text\">!reg openkeys &lt;hive address></code> command to obtain the exact hive name and the address of the key control block (KCB).</li>\n<li>Use the <code class=\"language-text\">!reg querykey &lt;hive name></code> command to obtain address information for the subkeys.</li>\n<li>Use the <code class=\"language-text\">!reg keyinfo &lt;hive address> &lt;subkey address></code> command to obtain the keys and registry values inside the subkey.</li>\n</ol>\n<p>Using these commands, let’s actually retrieve some registry information from the full memory dump that is the target of this analysis.</p>\n<p>First, enumerate the registry hive information in the system with the <code class=\"language-text\">!reg hivelist</code> command.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ceef47beab3b33b70571ad495ffb9d6d/0b533/system-reg-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 53.333333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABj0lEQVQoz3WS2YrCQBRE8/+f5W5co8Z9J7hmcVf0oYZzh4RBGEE6dBdV51a3s91uFcexTqeT7ve7rterbreb/b/3LpeL7Z3PZ1tfr5ftsaJ5Pp9yXNfVYrHQfr/XbDaT53lqNptKkkRBEGiz2aher8v3fU2nU1UqFQ2HQ9MBgw4gQt7vt5xSqWSGHGDYbrfN4PF4KAxDHY9HVatV9Xo9LZdLoZ9MJpkpQcVi0XT8nHw+b0YkzOdz1Wo1o8CQPxSFQsGC0OVyOY3HY/X7fdNhyDdAZsgmhHSwWq1s3EajYX3QG1WggZBACBkdSkL4Xq/XFm6GpCOkXA4xo1cM6QRCpmA8CNFD2O12rQpMmYp6MkK6gRDS9FK4uc/no91uZ1QYcI6e4MFgYDrIOctGplAIGQ8CCEnEMCWEKiVEDyHdQYieS4yi6NewXC5bMu+NlREQ/UeInv4wRYeesIyQfv52SNo34XeHo9Eo67DVatnovEUzxIAHzLPhlumk0+lkhIfDwQLojNtEDwDvEB37rOnIP0kTGOJKKiOPAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ceef47beab3b33b70571ad495ffb9d6d/8ac56/system-reg-001.webp 240w,\n/static/ceef47beab3b33b70571ad495ffb9d6d/d3be9/system-reg-001.webp 480w,\n/static/ceef47beab3b33b70571ad495ffb9d6d/b0a15/system-reg-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ceef47beab3b33b70571ad495ffb9d6d/8ff5a/system-reg-001.png 240w,\n/static/ceef47beab3b33b70571ad495ffb9d6d/e85cb/system-reg-001.png 480w,\n/static/ceef47beab3b33b70571ad495ffb9d6d/0b533/system-reg-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ceef47beab3b33b70571ad495ffb9d6d/0b533/system-reg-001.png\"\n            alt=\"Enumerating registry hives\"\n            title=\"Enumerating registry hives\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Although it may be difficult to read at this image scale, the seventh line of the output shows information for a hive whose FileName is <code class=\"language-text\">emRoot\\System32\\Config\\SOFTWARE</code>. (Because of the character limit, the FileName column shows only the last 32 characters of the path.)</p>\n<p>This matches the default path of the SOFTWARE hive, <code class=\"language-text\">%SystemRoot%\\System32\\Config\\SOFTWARE</code>.<sup id=\"fnref-5\"><a href=\"#fn-5\" class=\"footnote-ref\">5</a></sup></p>\n<p>In other words, when exploring the registry corresponding to <code class=\"language-text\">HKEY_LOCAL_MACHINE\\SOFTWARE</code>, we can see that we should use the address <code class=\"language-text\">0xffffa58428b62000</code> shown in the HiveAddr column on the seventh line.</p>\n<p>Next, use the SOFTWARE hive address we obtained and run the <code class=\"language-text\">!reg openkeys ffffa58428b62000</code> command.</p>\n<p>The <code class=\"language-text\">!reg openkeys</code> command can also be run without arguments, but because the output becomes very large, we specify the address of the hive we want to analyze.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !reg openkeys ffffa58428b62000\n\nHive: \\REGISTRY\\MACHINE\\SOFTWARE\n===========================================================================================\nIndex 0:  00000000 kcb=ffffa5842b2d1d50 cell=00000020 f=002c0000 \\REGISTRY\\MACHINE\\SOFTWARE\nIndex 1:  f386608f kcb=ffffa584316e1d00 cell=017c4288 f=00200000 \\REGISTRY\\MACHINE\\SOFTWARE\\SYNAPTICS\\SYNTPENH\\ZONECONFIG\\DEFAULTS\\PALMCHECK GROUP\\2FVSCROLL ZONE\n 8a10ced9 kcb=ffffa5842d346350 cell=80008f90 f=00200000 \\REGISTRY\\MACHINE\\SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERSION\\APPMODEL\\STATEREPOSITORY\\CACHE\\PACKAGEEXTERNALLOCATION\nIndex 2:  5c8055db kcb=ffffa58433820390 cell=002a8cf8 f=00200000 \\REGISTRY\\MACHINE\\SOFTWARE\\CLASSES\\CLSID\\{896664F7-12E1-490F-8782-C0835AFD98FC}\\INSTANCE\n{{ omitted }}</code></pre></div>\n<p>When you actually run this command, you can confirm, as shown above, that the first line of the output displays <code class=\"language-text\">Hive: \\REGISTRY\\MACHINE\\SOFTWARE</code>.</p>\n<p>Therefore, use this result to run the <code class=\"language-text\">!reg querykey \\REGISTRY\\MACHINE\\SOFTWARE</code> command. (If you are already comfortable with this kind of analysis, there is no problem running this command from the start.)</p>\n<p>The output of this command was as follows.</p>\n<p>At this point, you can see that the hive address <code class=\"language-text\">0xffffa58428b62000</code> identified so far, the key control block (KCB) address, and a list of subkeys together with their SubKeyAddr values are all displayed.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !reg querykey \\REGISTRY\\MACHINE\\SOFTWARE\n\nFound KCB = ffffa5842b2d1d50 :: \\REGISTRY\\MACHINE\\SOFTWARE\n\nHive         ffffa58428b62000\nKeyNode      0000022eaab61024\n\n[SubKeyAddr]         [SubKeyName]\n22eaab61174          Classes\n22eab25daec          Clients\n22eab5b2184          CVSM\n22eab5b244c          DefaultUserEnvironment\n22eab5b2624          Dolby\n22eab5b297c          Fortemedia\n22eab5b2b0c          Google\n22eab5b2dec          InstalledOptions\n22eab5b2e4c          Intel\n22eab5b7af4          JavaSoft\n22eab5b7b4c          Lenovo\n22eab5b8524          Microsoft\n22eac3103ac          Mozilla\n22eac310614          Nuance\n22eac31066c          ODBC\n22eac3106c4          OEM\n22eac310894          OpenSSH\n22eac31097c          Oracle\n22eac3109d4          Partner\n22eac310a2c          Policies\n22eac313854          Realtek\n22eac313d34          RegisteredApplications\n22eac3144bc          SRS Labs\n22eac31467c          Synaptics\n22eac32d2c4          Windows\n22eac32d31c          WOW6432Node\n\n Use '!reg keyinfo ffffa58428b62000 &lt;SubKeyAddr>' to dump the subkey details\n\n[ValueType]         [ValueName]                   [ValueData]\n Key has no Values</code></pre></div>\n<p>Now that we have the necessary information, use the <code class=\"language-text\">!reg keyinfo &lt;hive address> &lt;subkey address></code> command to retrieve the keys and registry values inside a subkey.</p>\n<p>For example, to explore the Microsoft subkey whose SubKeyAddr is <code class=\"language-text\">0x22eab5b8524</code> inside the SOFTWARE hive, the command is <code class=\"language-text\">!reg keyinfo ffffa58428b62000 22eab5b8524</code>.</p>\n<p>When you actually run this command, the list of subkeys under <code class=\"language-text\">HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft</code> and their SubKeyAddr values are displayed as follows.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !reg keyinfo ffffa58428b62000 22eab5b8524\n\nKeyPath \\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\n\n[SubKeyAddr]         [SubKeyName]\n22eab5b8694          .NETFramework\n22eab5fc13c          AccountsControl\n22eab5fc19c          Active Setup\n22eab5ff7dc          ActiveSync\n22eab6009ac          ADs\n22eab600a04          Advanced INF Setup\n22eab600a6c          ALG\n22eab600ce4          AllUserInstallAgent\n22eab600e94          AMSI\n\n22eab79a0ec          Windows\n22eac107024          Windows Advanced Threat Protection\n22eac1073ac          Windows Defender\n22eac10bcf4          Windows Defender Security Center</code></pre></div>\n<p>If you want to explore registry information at a deeper level, specify one of the SubKeyAddr values obtained above and issue the <code class=\"language-text\">!reg keyinfo</code> command again.</p>\n<p>For example, to retrieve information for the <code class=\"language-text\">Windows Defender</code> subkey whose SubKeyAddr is <code class=\"language-text\">0x22eac1073ac</code>, run <code class=\"language-text\">!reg keyinfo ffffa58428b62000 22eac1073ac</code>.</p>\n<p>When you actually run this command, the upper part of the output shows the list of subkeys under <code class=\"language-text\">HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Defender</code>, and the lower part shows the list of values present in this registry key.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/cb7580691f56033fb5dc0071dfc780ed/0b533/system-reg-002.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 62.916666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABbUlEQVQ4y42Sh6rCUBBE8/+/paCI0djQqMResCXBXvdxBiJifQtLbsLeszObdZbLpfX7fWWn07Fer6fzYDCw1Wplm83G4ji20+lkxO12s2/h+L6vYi6Xy2ULgkDvXDyfzzofj0e7Xq//AxYKBR1QmsvlbDqd6jKw58u/YAIWi0UVzmYzAefzuW232xebCeynwkqloiIUlkolKTwcDi8WE+gv8N0yCj3P0yxR+GjzUz6rFxAIAajRaMhyFEWaIT/jXXyDO4vFQqsBhFUZj8dSyzMMQ81yvV7f83K5fG2iGQJkdplMxlqtlkAETbLZrGbLd1aq2+1au93WmQbUJPOWZdd1ZQ9FqVTKms2mVFFEcb1eVwJiHDQejUZyQ2PEMBoYqHfoRAyHQ0un01atVgXa7/dSwHcAgNgExpGMhDpg/ERq2Q6nVqsJyCUUYhtLFE8mE6l4tyIf1+ZZYT6f1xnbJJbovNvtpIR38nFPH/MPK5vlIdst9hYAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/cb7580691f56033fb5dc0071dfc780ed/8ac56/system-reg-002.webp 240w,\n/static/cb7580691f56033fb5dc0071dfc780ed/d3be9/system-reg-002.webp 480w,\n/static/cb7580691f56033fb5dc0071dfc780ed/b0a15/system-reg-002.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/cb7580691f56033fb5dc0071dfc780ed/8ff5a/system-reg-002.png 240w,\n/static/cb7580691f56033fb5dc0071dfc780ed/e85cb/system-reg-002.png 480w,\n/static/cb7580691f56033fb5dc0071dfc780ed/0b533/system-reg-002.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/cb7580691f56033fb5dc0071dfc780ed/0b533/system-reg-002.png\"\n            alt=\"Registry information for HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Defender\"\n            title=\"Registry information for HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Defender\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>With that, we have finished exploring registry information inside the system from the full memory dump.</p>\n<h2 id=\"investigating-memory-resource-usage\" style=\"position:relative;\"><a href=\"#investigating-memory-resource-usage\" aria-label=\"investigating memory resource usage permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Investigating memory resource usage</h2>\n<p>In the sections so far, we have collected hardware information and OS configuration information.</p>\n<p>Next, we will investigate memory resource usage at the time the full memory dump was captured (that is, when the system crash occurred).</p>\n<p>This kind of information is especially useful when investigating performance-related problems such as the memory leak issue in this chapter.</p>\n<p>First, use the <code class=\"language-text\">!vm</code> extension command<sup id=\"fnref-6\"><a href=\"#fn-6\" class=\"footnote-ref\">6</a></sup>, which can investigate virtual memory usage in the system.</p>\n<p>When you run <code class=\"language-text\">!vm</code> without any option arguments, you can obtain system-wide statistical information about virtual memory usage as well as information about the commit size of each process.</p>\n<p>By loading the full memory dump that is the target of this analysis and running the <code class=\"language-text\">!vm</code> command, we can identify that the D4C.exe process is consuming the largest amount of virtual memory in the system and is therefore highly likely to be experiencing a user-mode memory leak.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/19f2114e7884b2430ee1551475271988/0b533/system-resource-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 20.833333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA7klEQVQY01WM2W6CUBRF+f/fafrQIWn6YGpji8AFvJdRBoEqt1KNHbSySvCpO1kP65zsbUQrjZeU2EGGiEqa/e9IvTsOnC58/BBXGifMyTZ7ZNniJvXoadOxPvRE9ZYwrzAmTsTNxOTq4ZnbJ4uJmxJvvli+H0n1N1l3YrHquH6ccTe1sZM36k94DSvuB5+pgnLfIzLN1F5gpHGIJ2xcx8IXDsp3gTP/cj5hmS8ju60eT8UyQVgm66Ya/bDrkL6HkecFruthzufMB6RUKBUQBAFtqzn3Pf1QkFIOf4tWXwbzosARgqqqR++6YVAp/gBjfyQeUKCFCQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/19f2114e7884b2430ee1551475271988/8ac56/system-resource-001.webp 240w,\n/static/19f2114e7884b2430ee1551475271988/d3be9/system-resource-001.webp 480w,\n/static/19f2114e7884b2430ee1551475271988/b0a15/system-resource-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/19f2114e7884b2430ee1551475271988/8ff5a/system-resource-001.png 240w,\n/static/19f2114e7884b2430ee1551475271988/e85cb/system-resource-001.png 480w,\n/static/19f2114e7884b2430ee1551475271988/0b533/system-resource-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/19f2114e7884b2430ee1551475271988/0b533/system-resource-001.png\"\n            alt=\"Virtual memory usage by process\"\n            title=\"Virtual memory usage by process\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Now that we have confirmed virtual memory resource consumption, let’s next investigate physical memory resource consumption.</p>\n<p>To investigate physical memory resource consumption, you can use the <code class=\"language-text\">!memusage</code> extension command<sup id=\"fnref-7\"><a href=\"#fn-7\" class=\"footnote-ref\">7</a></sup>.</p>\n<p>The <code class=\"language-text\">!memusage</code> extension command outputs physical memory statistics by using information from the page frame number (PFN) database that Windows uses to manage physical memory.</p>\n<p>Because the output of the <code class=\"language-text\">!memusage</code> command is extremely large, this time we run <code class=\"language-text\">!memusage 0x08</code>, which displays only summary information.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !memusage 0x08\nloading PFN database\nloading (100% complete)\nCompiling memory usage data (99% Complete).\n          Zeroed:   319761 ( 1279044 kb)\n            Free:      460 (    1840 kb)\n         Standby:  1669387 ( 6677548 kb)\n        Modified:    50530 (  202120 kb)\n ModifiedNoWrite:        7 (      28 kb)\n    Active/Valid:  1118305 ( 4473220 kb)\n      Transition:  1002519 ( 4010076 kb)\n      SLIST/Temp:     6687 (   26748 kb)\n             Bad:        0 (       0 kb)\n         Unknown:        0 (       0 kb)\n           TOTAL:  4167656 (16670624 kb)\n\nDangling Yes Commit:      169 (     676 kb)\n Dangling No Commit:    50768 (  203072 kb)</code></pre></div>\n<p>By running this command, you can obtain statistical information about the system’s physical memory usage as shown above.</p>\n<p>Each item in the output corresponds to information about the state of physical pages contained in the PFN database.</p>\n<p>A summary of some frequently referenced items is given below.<sup id=\"fnref-8\"><a href=\"#fn-8\" class=\"footnote-ref\">8</a></sup></p>\n<ul>\n<li>Zeroed: free pages that are initialized to zero, or pages that are already known to be zero</li>\n<li>Free: free pages that have not been initialized to zero</li>\n<li>Standby: pages that were previously registered in a working set but are now on the standby page list</li>\n<li>Active or Valid: pages that are part of a working set, or nonpaged kernel pages</li>\n<li>Transition: temporary pages that are not in a working set or any other page list (for example, when I/O is being performed on that page)</li>\n<li>Bad: pages that cannot be read because of a hardware error</li>\n</ul>\n<p>If you want to learn more about the PFN database, I recommend <em>Windows Internals, 7th Edition, Part 1</em>, which is listed in the references.</p>\n<h2 id=\"investigating-information-about-running-processes\" style=\"position:relative;\"><a href=\"#investigating-information-about-running-processes\" aria-label=\"investigating information about running processes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Investigating information about running processes</h2>\n<p>Next, we will collect information about processes running in the system.</p>\n<p>Information about running processes is used in a variety of situations, such as setting the appropriate process context and investigating problems like spikes in CPU usage.</p>\n<p>There are multiple ways to collect process information, but in this book I will introduce only some of them.</p>\n<p>First, let’s use the <code class=\"language-text\">!process</code> extension command<sup id=\"fnref-9\"><a href=\"#fn-9\" class=\"footnote-ref\">9</a></sup>.</p>\n<p>When memory information from kernel space that includes EPROCESS structure data—such as a full system memory dump—is loaded into WinDbg, you can enumerate summary information for all processes in the system by running <code class=\"language-text\">!process 0 0</code>.</p>\n<p>The output of this command includes the addresses of EPROCESS structures and the process names, as shown below.</p>\n<p>Therefore, by using the EPROCESS structure address obtained from this command, you can change the process context or retrieve more detailed information about the target process.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !process 0 0\n\n**** NT ACTIVE PROCESS DUMP ****\nPROCESS ffffcb0c8a6bf080\n    SessionId: none  Cid: 0004    Peb: 00000000  ParentCid: 0000\n    DirBase: 001ad002  ObjectTable: ffffa58427e2e600  HandleCount: 3952.\n    Image: System\n\nPROCESS ffffcb0c8a71f080\n    SessionId: none  Cid: 007c    Peb: 00000000  ParentCid: 0004\n    DirBase: 007dc002  ObjectTable: ffffa58427e5c5c0  HandleCount:   0.\n    Image: Registry\n\n{{ omitted }}</code></pre></div>\n<p>Also, if you have already identified the name of the process to investigate, you can search for the address of a specific process object (EPROCESS) by using <code class=\"language-text\">!process 0 0 &lt;process name></code>.</p>\n<p>When we actually specify D4C.exe and run the <code class=\"language-text\">!process 0 0 D4C.exe</code> command, we can identify that the process object for D4C.exe exists at address <code class=\"language-text\">0xffffcb0c950ea0c0</code>. (We will use this address later.)</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !process 0 0 D4C.exe\n\nPROCESS ffffcb0c950ea0c0\n    SessionId: 3  Cid: 0d40    Peb: 13c75e4000  ParentCid: 3758\n    DirBase: 27cd1f002  ObjectTable: ffffa5843cdd8c00  HandleCount:  51.\n    Image: D4C.exe</code></pre></div>\n<p>Incidentally, you can also output information about a specific process by giving the address of its process object as the first argument to the <code class=\"language-text\">!process</code> command. (If <code class=\"language-text\">0</code> is specified, information about all active processes is displayed.)</p>\n<p>The second argument, meanwhile, is a flag that controls how much information is displayed, and when <code class=\"language-text\">0</code> is specified only minimal information is output.</p>\n<p>If you specify <code class=\"language-text\">7</code> for the second argument, on the other hand, you can display detailed information including threads associated with the process and their stack backtraces.</p>\n<p>Therefore, if you have already identified the name of the target process, you can collect more detailed information by running a command such as <code class=\"language-text\">!process 0 7 D4C.exe</code>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/789b4acf2e17814c210e3b87e85cb67b/0b533/system-process-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 53.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABoElEQVQoz41SiY6CQAz1//9LE090dUEFVFROFRgORQ7ftpOVxGQ3OslLO9drX9vOYrHAt6pht7MQC4GLyBHFMcIwRCRSVFWFpmnweDzA62n/Wx1lOsPBj+CcYkRRjK19wnJzRHAOIUSC6/WK2+2Guq4/I5xMJnAcG57r4n6/Y0OZ2m6AsqpldmVZSjDRO0jCbreL9XqNNEkkoU5+cc3R1BXtCyK7ky3xyWLSzmq1gkgzNHTAsnZHF96FyElhTUGb5iFryHecMdu/0GZ4OBwwXxpUx5DqFmHv+PDO1JS0QJiVEEmGJBGyllmWScvI87wF71tCVVWxmM+RpYI+pzAsB8FFwKW6ngIft9+mfCJXStY0DSrBMAywfGUyhkZBgiCgLgsURfG2sy+Euq5LIp5HJnccF5ZlwTRN2LYN3/dJavrScfYZHIzLwGft2DDZ12yGGUFRFEmUUMfZHw4GmE6nGI1GGI/HGA6H4DHr9/vynlX1ej2554T4X2e/32O73cHcbOmBKbPjC5381VqXZ4auy888Xk/LgV2aXfZZJavzPA8/vvNCve/bD58AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/789b4acf2e17814c210e3b87e85cb67b/8ac56/system-process-001.webp 240w,\n/static/789b4acf2e17814c210e3b87e85cb67b/d3be9/system-process-001.webp 480w,\n/static/789b4acf2e17814c210e3b87e85cb67b/b0a15/system-process-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/789b4acf2e17814c210e3b87e85cb67b/8ff5a/system-process-001.png 240w,\n/static/789b4acf2e17814c210e3b87e85cb67b/e85cb/system-process-001.png 480w,\n/static/789b4acf2e17814c210e3b87e85cb67b/0b533/system-process-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/789b4acf2e17814c210e3b87e85cb67b/0b533/system-process-001.png\"\n            alt=\"Detailed output for the D4C.exe process\"\n            title=\"Detailed output for the D4C.exe process\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>The <code class=\"language-text\">!for_each_process</code> extension command<sup id=\"fnref-10\"><a href=\"#fn-10\" class=\"footnote-ref\">10</a></sup>, when run with no option arguments, also outputs information equivalent to <code class=\"language-text\">!process 0 0</code>.</p>\n<p>However, unlike the <code class=\"language-text\">!process</code> extension command, it can issue arbitrary debugger commands to all active processes in the system.</p>\n<p>For example, if you run the <code class=\"language-text\">!for_each_process \".echo @#Process\"</code> command, you can print the addresses of all process objects. (Inside the command string for <code class=\"language-text\">!for_each_process</code>, <code class=\"language-text\">@#Process</code> is automatically replaced with the process object address.)</p>\n<p>Therefore, a command such as <code class=\"language-text\">!for_each_process \".process /r /p @#Process; lm\"</code> lets you change the process context to each active process and then execute the <code class=\"language-text\">lm</code> command.</p>\n<p>As a more advanced application, you can use a command such as <code class=\"language-text\">!for_each_process \".process @#Process; dt ntdll!_EPROCESS @#Process Peb->ProcessParameters->CommandLine\"</code>.</p>\n<p>This retrieves the PEB information from the EPROCESS structure of every process obtained by <code class=\"language-text\">!for_each_process</code> and enumerates the command-line information.</p>\n<p>In this way, <code class=\"language-text\">!for_each_process</code> can issue very flexible commands when enumerating processes.</p>\n<p>Also, when enumerating processes in the system, <code class=\"language-text\">!mex.tlist</code>, which is included in the MEX extension, is very convenient as well.</p>\n<p>When you run the <code class=\"language-text\">!mex.tlist</code> command, it can format and output the PID, the address of the process object, and the process name as shown below.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/5488e9f872ac4cbd0e1da97b6fc5ec51/0b533/system-process-002.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 106.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAYAAABG1c6oAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADPUlEQVQ4y4VUaVPaABDN//8t7Wg9avvBqRyCnDm4CYIiIAJCCCAox+u+xaRa7dSZHZiJebxr17DdHsbjMYbDIUbDAUrNe9R6M8wXT8Buje1mDbe/gP/0jPXLM56f/z3r9RpGqVLDYrFAs9nCbrtBtesjWhrgqjaSGaLY9lAoVXF/38dqtcJ8Ptf//2yWyyWMbCYD3/eRzeXkcwq7s8Sx7eHQnODInuJXxUM6nYZj2/rC//6MWCyOdruNnAD2el0Uuyt8dyY4tiY4kUm4UxSKRQVsNpvYbDb64m63+3SMeDyOTqeDTDaL4eABBQE8tSc6B/kJYrUpHMdBsVBAUYBHo9E7wL+/G5FIRBkmr64U0O6scGSOcSTsvonseN1HIplELBZDQUBd11UfA6APgGTY7XbVw9ubFoq9veQTYXjmeEg1Z0ilM8iI12SYz+dDwLegoYdkeHd3B8uy4NbrKpmAZwVPQROuj5yAmKaJUqmkTLNiz+3trSR//7lkAublhXqtqoAEOhXQn0UPyYYv/uaQFwUEvLy8BFXZElK/3/8Q0DtAt157rc1ERxkKYFokk1XAMBqN4ko8r4uiIPVQMh8wZf4iAa07AbTGCvglO0aEKUsY9C4rTAmcSqXQaDQwnU7VT/aT8/LyAoMPGQoBKdlsLyXdsc5XAYxJypY8o8dkSOCbmxv1j+v68PCgw+/8ASMplSBD07TQal6jJCn/lEB+yLA6THkPaGrKTJsBMZRPN+Xi4kI9ZJLX1w044uGfYu8ZBpLJkpKphiw9z/vQR4MmayjyAj1kymeSMKtzJMUmYCaThcUWSAiJRCKUTx8pl5YxcfoZbgoB6SFT5g6fvKYcq0+VPXedm8J95rkjOx6V7Xar7PgZMiQgd7laKevqMWUNRiRfur4+y/DiOAWV3Gq1FJB7HdxS3sPQQ1Img0Dy6Su7g9xYe8i1ZBC8Oiw2JQ8GA61KcAuDPiqgXhvxqVat6C5zSzgMJf5m9crlcrgpvED07+2fSj4/P99LljqQocNrw2Jb+2LTQ16ioC48tpVKRVN+fHzUs//2RipDdopbQIaszfFrKIdyD6OyKWm9NmmtS3DGKJke8nM2m4WAvwHGffI5oWAX+gAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/5488e9f872ac4cbd0e1da97b6fc5ec51/8ac56/system-process-002.webp 240w,\n/static/5488e9f872ac4cbd0e1da97b6fc5ec51/d3be9/system-process-002.webp 480w,\n/static/5488e9f872ac4cbd0e1da97b6fc5ec51/b0a15/system-process-002.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/5488e9f872ac4cbd0e1da97b6fc5ec51/8ff5a/system-process-002.png 240w,\n/static/5488e9f872ac4cbd0e1da97b6fc5ec51/e85cb/system-process-002.png 480w,\n/static/5488e9f872ac4cbd0e1da97b6fc5ec51/0b533/system-process-002.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/5488e9f872ac4cbd0e1da97b6fc5ec51/0b533/system-process-002.png\"\n            alt=\"Getting the process list with !mex.tlist\"\n            title=\"Getting the process list with !mex.tlist\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Another very convenient command included in the MEX extension is <code class=\"language-text\">!mex.commandline -a</code>.</p>\n<p>This command can enumerate the command lines of all active processes in the system.</p>\n<p>By running this command, you can output the addresses of all processes and their command-line information, as shown below.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b14eef29ffe42faae6ef5a8618c9d7f7/0b533/system-process-004.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 47.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABmklEQVQoz32SWWvCUBCF8///SB8LpbVQ2roXrEtioiZxS8zimhpNBEGUU89UQ+1DLxzu3IT57pmZqxR6K3zYEUzLhqap8H0fk8kEnudhsVhgu90iTVMRYyqOYzknSXIj/lPu1Rgv5g6O66FSLkM3DDiOA9d1Bbjf77Hb7XA4HMB1Op3+lfJsxCj2U3h+gGq1gmaziW63C+MCNk1TYsJns1nmjvtvp4w3mw2U3AU48QKUSyU0Go1z6RparRYGg4HAa7WagBmrqpq1goC/S3nSYxTsW2C73RYR2Ov1BNLpdGSn2yAIsFqtMB6PsVwupR1XKQ9ajFczEWCpVMwcMtm2bQHQLUWnhLD06XSK4XAovQ7DUC5hr8Xhu5XC9XwUiwXU6/UbIJ0SRqe8bDQaiTs6I4Rls4fcBfh4Br5ZCbwgRKVSzkomsN/vC4AwxuwhzxzAer3OXgLPhB6Px5+hFDiU85Tz+bwACbu6upbNoViWJeJ3iuUTfB0Qocrd5xdyxhbhdCYwXdclmQl0wMHQMR3yGc3nc4FEUSSgv+sbWF3VbSTE66MAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/b14eef29ffe42faae6ef5a8618c9d7f7/8ac56/system-process-004.webp 240w,\n/static/b14eef29ffe42faae6ef5a8618c9d7f7/d3be9/system-process-004.webp 480w,\n/static/b14eef29ffe42faae6ef5a8618c9d7f7/b0a15/system-process-004.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/b14eef29ffe42faae6ef5a8618c9d7f7/8ff5a/system-process-004.png 240w,\n/static/b14eef29ffe42faae6ef5a8618c9d7f7/e85cb/system-process-004.png 480w,\n/static/b14eef29ffe42faae6ef5a8618c9d7f7/0b533/system-process-004.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/b14eef29ffe42faae6ef5a8618c9d7f7/0b533/system-process-004.png\"\n            alt=\"Enumerating command-line information for processes\"\n            title=\"Enumerating command-line information for processes\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>There are other ways to obtain a list of processes in WinDbg, but in practice, using any of the above should be sufficient.</p>\n<p>Next, after changing the process context to a specific process, we will refer to more detailed information.</p>\n<p>You can change the process context with <code class=\"language-text\">.process /r /p &lt;process object address></code>.</p>\n<p>To change the context to the D4C.exe process identified earlier, run the <code class=\"language-text\">.process /r /p 0xffffcb0c950ea0c0</code> command.</p>\n<p>To check whether the process context change succeeded, you can try running commands such as <code class=\"language-text\">!peb</code> and <code class=\"language-text\">lm</code>.</p>\n<p>Because these commands output information based on the debugger’s process context, if information about D4C.exe is displayed, you can determine that the process context was changed successfully.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/a612bd29deed41ea810d1127fa46debb/0b533/system-process-003.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 44.99999999999999%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABdElEQVQoz11S226CQBTk/z+nP9C3RoLFekFRQEQRJCB38RacMqeBtN1ksrtnz23mrGKaJlzXxeFwwGw2w2KxwPF4FDiOg81mA/pst1tMp1O53+93cL1erz/gUvb7PaIoQhzHA06nEy6Xizi0bSvoz7+D/y/aFSbI81xQFAXqukaWZbKnaYqyLAewCP2appE3gr7McbvdfjocjUZCdTweY7lcShBBWpZlwTAMJEkiBcgkCAJJyjNl4Z2JB8q+7wtFoj/33fT0aafN87zu/iMPk/EtDEMp2Mco7IJYr9dSjcPhAKgtnRlEGzuiT9j5cIj9IEmZOwfHeIVTZWVWqKpK9CGl3W6H6/Uq2pAu3zkUJ3nCz56IqhZB/kBzqSVm0JDa8Tswqa7rUFVVOqF9Pp9Lt5qmdXcN53MK1W3wbhYwggZWWMN2XEwmuuSgFMpqtYJt20KN/47JqBn/G2mRNs+UhQw+vQZvXxk+nApx+ei09MEcfCezbxu4nb1zkQDPAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/a612bd29deed41ea810d1127fa46debb/8ac56/system-process-003.webp 240w,\n/static/a612bd29deed41ea810d1127fa46debb/d3be9/system-process-003.webp 480w,\n/static/a612bd29deed41ea810d1127fa46debb/b0a15/system-process-003.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/a612bd29deed41ea810d1127fa46debb/8ff5a/system-process-003.png 240w,\n/static/a612bd29deed41ea810d1127fa46debb/e85cb/system-process-003.png 480w,\n/static/a612bd29deed41ea810d1127fa46debb/0b533/system-process-003.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/a612bd29deed41ea810d1127fa46debb/0b533/system-process-003.png\"\n            alt=\"Changing the process context\"\n            title=\"Changing the process context\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>As mentioned above, by changing the process context, you can investigate detailed information about the process with commands such as <code class=\"language-text\">!peb</code> and <code class=\"language-text\">lm</code>, just as when analyzing a user-mode process dump.</p>\n<h2 id=\"investigating-the-stack-backtrace-of-a-specific-process\" style=\"position:relative;\"><a href=\"#investigating-the-stack-backtrace-of-a-specific-process\" aria-label=\"investigating the stack backtrace of a specific process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Investigating the stack backtrace of a specific process</h2>\n<p>Now that we can enumerate system process information and change the debugger’s process context, next we will obtain stack backtrace information for a specific process.</p>\n<p>We already confirmed in the previous section that the <code class=\"language-text\">!process 0 7 D4C.exe</code> command can output stack backtraces for all threads in the process, but here we intentionally obtain the information using the <code class=\"language-text\">k</code> command.</p>\n<p>However, even if you set the debugger’s process context to D4C.exe by following the steps in the previous section, the <code class=\"language-text\">k</code> command, which outputs the stack backtrace for the current thread, does not output information about D4C.exe.</p>\n<p>This is because the <code class=\"language-text\">k</code> command depends on the debugger’s register context.<sup id=\"fnref-11\"><a href=\"#fn-11\" class=\"footnote-ref\">11</a></sup></p>\n<p>Therefore, we first change the debugger’s register context by using the <code class=\"language-text\">.thread</code> command<sup id=\"fnref-12\"><a href=\"#fn-12\" class=\"footnote-ref\">12</a></sup>.</p>\n<p>To change the register context with the <code class=\"language-text\">.thread</code> command, you need to specify the address of the thread to switch to.</p>\n<p>There are several ways to find the threads of a process from a full system memory dump, but the method using the <code class=\"language-text\">!process</code> extension command introduced in the previous section is simple.</p>\n<p>To display thread information with the <code class=\"language-text\">!process</code> extension command, specify <code class=\"language-text\">2</code> for the optional Flag argument. (You can also use <code class=\"language-text\">7</code>, which outputs all available information.)</p>\n<p>To retrieve thread information for the D4C.exe process with the <code class=\"language-text\">!process</code> extension command, run the <code class=\"language-text\">!process 0 2 D4C.exe</code> command.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4a2d1adf33347305d7035d5c8967341c/0b533/system-thread-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 28.750000000000004%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABR0lEQVQY0z2R2W7jMAxF/f8/lqdBkXRcJ95XeZPX2BmvOZVddAQcEKSIS15JM00TwzD4q+vYts3t9kkQhOz7zrquTOvOOO8qvn/yaWLdNpXD/ob3yfs/2uVy4Xq94vs+D+MLkUQkcUhZZHiei6gGPizB3c+xLAvXsc/7uycoZc22TGxqwO/R+r5XTQ6OF2BGFaF84eWqlj1pmlYJ5zS1pGsb2oNhxpf/SKoRvxjJ2om6qpBSUjcN2qEqZYmrBK0gQ7djdCfGETVBGJGmGcfQYRx5KZ6vhbxfqceN8rmpuNJ1nRrWMgwD2uE7FQLT8XjENTev5CuosESPEKmyF/8Iqua+a5GdciBnonrGLSdEM1Op7YqiODk3zNIU03b5tBM+7iF/jADdy4miGEt92kPhuu4peFiOmoWsW0jahbJf1JPUSGW7UZa/AU05wdFI6wRkAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/4a2d1adf33347305d7035d5c8967341c/8ac56/system-thread-001.webp 240w,\n/static/4a2d1adf33347305d7035d5c8967341c/d3be9/system-thread-001.webp 480w,\n/static/4a2d1adf33347305d7035d5c8967341c/b0a15/system-thread-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/4a2d1adf33347305d7035d5c8967341c/8ff5a/system-thread-001.png 240w,\n/static/4a2d1adf33347305d7035d5c8967341c/e85cb/system-thread-001.png 480w,\n/static/4a2d1adf33347305d7035d5c8967341c/0b533/system-thread-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/4a2d1adf33347305d7035d5c8967341c/0b533/system-thread-001.png\"\n            alt=\"Displaying thread information for D4C.exe\"\n            title=\"Displaying thread information for D4C.exe\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>This lets us identify that the three thread addresses associated with the D4C.exe process are <code class=\"language-text\">0xffffcb0c93f24080</code>, <code class=\"language-text\">0xffffcb0c93d17080</code>, and <code class=\"language-text\">0xffffcb0c95645080</code>.</p>\n<p>Now, by setting the thread context with these three addresses, we can use the <code class=\"language-text\">k</code> command to inspect stack backtrace information for D4C.exe’s threads.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Set the first thread context and print the stack backtrace\n0: kd> .thread 0xffffcb0c93f24080; k\nImplicit thread is now ffffcb0c`93f24080\n  *** Stack trace for last set context - .thread/.cxr resets it\n # Child-SP          RetAddr               Call Site\n00 ffffef81`2c6ef5e0 fffff806`72e1bca0     nt!KiSwapContext+0x76\n01 ffffef81`2c6ef720 fffff806`72e1b1cf     nt!KiSwapThread+0x500\n02 ffffef81`2c6ef7d0 fffff806`72e1aa73     nt!KiCommitThreadWait+0x14f\n03 ffffef81`2c6ef870 fffff806`73201b11     nt!KeWaitForSingleObject+0x233\n04 ffffef81`2c6ef960 fffff806`73201a6a     nt!ObWaitForSingleObject+0x91\n{{ omitted }}\n\n# Set the second thread context and print the stack backtrace\n0: kd> .thread 0xffffcb0c93d17080; k\nImplicit thread is now ffffcb0c`93d17080\n  *** Stack trace for last set context - .thread/.cxr resets it\n # Child-SP          RetAddr               Call Site\n00 ffffef81`2c7476e0 fffff806`72e1bca0     nt!KiSwapContext+0x76\n01 ffffef81`2c747820 fffff806`72e1b1cf     nt!KiSwapThread+0x500\n02 ffffef81`2c7478d0 fffff806`72ef51a4     nt!KiCommitThreadWait+0x14f\n03 ffffef81`2c747970 fffff806`732b1d20     nt!KeWaitForAlertByThreadId+0xc4\n04 ffffef81`2c7479d0 fffff806`730105f5     nt!NtWaitForAlertByThreadId+0x30\n{{ omitted }}\n\n# Set the third thread context and print the stack backtrace\n0: kd> .thread 0xffffcb0c95645080; k\nImplicit thread is now ffffcb0c`95645080\n  *** Stack trace for last set context - .thread/.cxr resets it\n # Child-SP          RetAddr               Call Site\n00 ffffef81`2c847310 fffff806`72e1bca0     nt!KiSwapContext+0x76\n01 ffffef81`2c847450 fffff806`72e1b1cf     nt!KiSwapThread+0x500\n02 ffffef81`2c847500 fffff806`72e1aa73     nt!KiCommitThreadWait+0x14f\n03 ffffef81`2c8475a0 fffff806`72ff1494     nt!KeWaitForSingleObject+0x233\n04 ffffef81`2c847690 fffff806`732011ab     nt!IopWaitForSynchronousIoEvent+0x50\n{{ omitted }}</code></pre></div>\n<p>Furthermore, by passing a thread object’s address as an argument to the <code class=\"language-text\">!thread</code> extension command<sup id=\"fnref-13\"><a href=\"#fn-13\" class=\"footnote-ref\">13</a></sup>, you can display the target thread’s execution time and stack backtrace together without changing the thread context.</p>\n<p>Below is the output of running the <code class=\"language-text\">!thread 0xffffcb0c93d17080</code> command.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/2351d31a38a34156ad37b3381da4e24e/0b533/system-thread-002.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 31.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABAUlEQVQY04WRWWuEQBCE/f9/zBfvA13HNSibXR0luh54W7EbhIQ8ZKD4XrqrqxjFclxESYqXrJA9Xvh6d3j3I+p2QNd1mKYJ4zhinmfmTy3LAnrHcbDoKZZl4fn5QNM0CMQHnrlEVUpM58K6rvjvXWaXFMdxcLvd4HkeRBThfo8hRIwsy1CWJfq+/6VhGFDXNaff9/3PAcU8E7quC0oqhEBVVdA0DbquMw3DYJqmyaTjNKuqKjPPc65O2rYNCi3ats0LYRiiKAo2uQyItEgzxDiOQa2uQ0EQcAhK3rbtmdC04Ps+D0dnZapJJtcRIolMiNSCGiVJgjRNIaXkD6N0lPIbF1m6aOApsOgAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/2351d31a38a34156ad37b3381da4e24e/8ac56/system-thread-002.webp 240w,\n/static/2351d31a38a34156ad37b3381da4e24e/d3be9/system-thread-002.webp 480w,\n/static/2351d31a38a34156ad37b3381da4e24e/b0a15/system-thread-002.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/2351d31a38a34156ad37b3381da4e24e/8ff5a/system-thread-002.png 240w,\n/static/2351d31a38a34156ad37b3381da4e24e/e85cb/system-thread-002.png 480w,\n/static/2351d31a38a34156ad37b3381da4e24e/0b533/system-thread-002.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/2351d31a38a34156ad37b3381da4e24e/0b533/system-thread-002.png\"\n            alt=\"Output of the !thread extension command\"\n            title=\"Output of the !thread extension command\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Incidentally, as mentioned in Chapter 3, Windows threads are represented by the ETHREAD structure, and the TEB (Thread Environment Block) is contained within the KTHREAD structure, which is its first member.</p>\n<p>In other words, by using the thread object address obtained here and running the <code class=\"language-text\">dt ntdll!_ETHREAD &lt;thread object address> Tcb->Teb</code> command, you can easily refer to the TEB address of a specific thread object.</p>\n<p>By passing the TEB address you obtained as an argument to the <code class=\"language-text\">!teb</code> extension command, you can display information about the target TEB in the debugger.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> dt ntdll!_ETHREAD 0xffffcb0c93f24080 Tcb->Teb\n   +0x000 Tcb      : \n      +0x0f0 Teb      : 0x00000013`c75e5000 Void\n\n0: kd> !teb 0x00000013c75e5000\nTEB at 00000013c75e5000\n  ExceptionList:        0000000000000000\n  StackBase:            00000013c7360000\n  StackLimit:           00000013c735c000\n  SubSystemTib:         0000000000000000\n  FiberData:            0000000000001e00\n  ArbitraryUserPointer: 0000000000000000\n  Self:                 00000013c75e5000\n  EnvironmentPointer:   0000000000000000\n  ClientId:             0000000000000d40 . 00000000000029c8\n  RpcHandle:            0000000000000000\n  Tls Storage:          000001244e6d33c0\n  PEB Address:          00000013c75e4000\n  LastErrorValue:       0\n  LastStatusValue:      c0000034\n  Count Owned Locks:    0\n  HardErrorMode:        0</code></pre></div>\n<h2 id=\"investigating-heap-information-for-a-user-mode-process\" style=\"position:relative;\"><a href=\"#investigating-heap-information-for-a-user-mode-process\" aria-label=\"investigating heap information for a user mode process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Investigating heap information for a user-mode process</h2>\n<p>Even when the analysis target is a full system memory dump, once the debugger’s process context is set appropriately, you can also inspect process heap information with the <code class=\"language-text\">!heap</code> extension command.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> .process /r /p 0xffffcb0c950ea0c0\n\n0: kd> !heap\nHeap Address      NT/Segment Heap\n 1244e6d0000       NT Heap\n 1244e500000       NT Heap\n 1244e950000       NT Heap\n\n0: kd> !heap -a\nHEAPEXT: Unable to get address of ntdll!RtlpHeapInvalidBadAddress.\nIndex   Address  Name      Debugging options enabled\n  1:   1244e6d0000 \n    Segment at 000001244e6d0000 to 000001244e7cf000 (000ef000 bytes committed)\n    Segment at 000001244e810000 to 000001244e90f000 (000f8000 bytes committed)\n    Segment at 000001244e960000 to 000001244eb5f000 (001f8000 bytes committed)\n    Segment at 000001244eb60000 to 000001244ef5f000 (003f7000 bytes committed)\n{{ omitted }}</code></pre></div>\n<p>The method for investigating user-mode heaps with the <code class=\"language-text\">!heap</code> command is the same as in Chapter 6, so I will omit it here.</p>\n<p>If, as in Chapter 6, you dump a few heap entries in an arbitrary heap segment, you can confirm that strings beginning with <code class=\"language-text\">==> Allocated addr:</code> have been written there, as shown below.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/82cba68fddce35c0dcfacfa398ca1593/0b533/system-heap-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABwklEQVQ4y12Tx44DMQxD5/9/Kv2Q3nvvvSE9SMDFE6Bsdg+GxrJNUaQmSKVSqtVqyufzyuVy6nQ6KpfLajabarVaGgwG6vf7Flnj8VjT6dS+9/u9Xq+XHo+HVquVzuezglAoZGAAZ7NZjUajDyCLYoVCwXKlUkmVSkWNRkPFYlGz2czAD4eDlsulrtergng8bpdh54CAOENitVo1EM/RRb1e12Kx0PF41OVyMbbEIBKJWDUYZjIZAwQAUECIsCIHCGCAsofVZrPR6XQytsQgFov9YcgBD3nkDL11CnieIvP5XO/323REv+fzqSAajRrDdDptC9F53G63P4/ZUwRAbx2Gk8nEGHKX/Ha7VQAIh7TLNwewhQFAFEAGIgCYQBfkdrudMbzdbqYhMUgkEuaet8yIAOYMvTqsiN1u1+6wX6/XZgSLQjY24XDYWoZhMpk0JmjqILRKQbpwczgjB1Pmj7HBkPv9/js2zCIMXUM3wPX6NgqnOWdsaJX5w3FG6DM2zhDqMPl2F0BfXoQ7w+HQAGGGIfwxH5fR8L/LDurz6E47a1oGBGboaRrCzCu6LrTU6/VMfKLvWf5PU5CWcZp77NHyBy1MoiteW1+BAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/82cba68fddce35c0dcfacfa398ca1593/8ac56/system-heap-001.webp 240w,\n/static/82cba68fddce35c0dcfacfa398ca1593/d3be9/system-heap-001.webp 480w,\n/static/82cba68fddce35c0dcfacfa398ca1593/b0a15/system-heap-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/82cba68fddce35c0dcfacfa398ca1593/8ff5a/system-heap-001.png 240w,\n/static/82cba68fddce35c0dcfacfa398ca1593/e85cb/system-heap-001.png 480w,\n/static/82cba68fddce35c0dcfacfa398ca1593/0b533/system-heap-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/82cba68fddce35c0dcfacfa398ca1593/0b533/system-heap-001.png\"\n            alt=\"Dumping memory information from the heap region\"\n            title=\"Dumping memory information from the heap region\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>From here, by using the Ghidra decompiler just as in Chapter 6 to investigate the code that writes to the heap, you can identify the location that caused the user-mode memory leak.</p>\n<p>Incidentally, although this book does not use them, when you investigate kernel-mode memory leak issues rather than user-mode ones, you inspect paged pool and nonpaged pool information with commands such as the <code class=\"language-text\">!pool</code> extension command<sup id=\"fnref-14\"><a href=\"#fn-14\" class=\"footnote-ref\">14</a></sup> and the <code class=\"language-text\">!poolused</code> extension command<sup id=\"fnref-15\"><a href=\"#fn-15\" class=\"footnote-ref\">15</a></sup>.</p>\n<h2 id=\"summary-of-chapter-7\" style=\"position:relative;\"><a href=\"#summary-of-chapter-7\" aria-label=\"summary of chapter 7 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary of Chapter 7</h2>\n<p>In Chapters 6 and 7, we analyzed memory leak issues in user-mode applications as examples of investigating the causes of problems that do not involve a crash from dump files.</p>\n<p>Unlike process dump analysis, when troubleshooting a specific process from a full system memory dump, you need to set the appropriate process context and register context in the debugger.</p>\n<p>I think this point can easily become a hurdle for people who are analyzing dump files for the first time, so I hope you will read this chapter while comparing it with the analysis in Chapter 6.</p>\n<p>Although this book dealt with memory leaks in user applications as a non-crash problem, there are many other kinds of problems like this.</p>\n<p>For example, spikes in CPU usage, process hangs, application deadlocks, handle leaks, and even depletion of the system’s memory pools can all be investigated by analyzing dump files.</p>\n<p>When you investigate these problems, you can enjoy dump file analysis with approaches that differ yet again from those used for crashes and memory leaks.</p>\n<p>Unfortunately, Vol.1 cannot cover these analysis methods, but if you want to learn Windows dump file analysis more deeply, I recommend reproducing various troubles with tools such as Crash Me from “Welcome to WinDbg.info” and NotMyFault, then obtaining and analyzing dump files.</p>\n<br>\n<p>Crash Me:</p>\n<p><a href=\"http://windbg.info/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://windbg.info/</a></p>\n<br>\n<h2 id=\"links-to-each-chapter\" style=\"position:relative;\"><a href=\"#links-to-each-chapter\" aria-label=\"links to each chapter permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Links to each chapter</h2>\n<ul>\n<li><a href=\"/magical-windbg-vol1-00-en\">Preface</a></li>\n<li><a href=\"/magical-windbg-vol1-01-en\">Chapter 1: Environment Setup</a></li>\n<li><a href=\"/magical-windbg-vol1-02-en\">Chapter 2: Basic WinDbg Operations</a></li>\n<li><a href=\"/magical-windbg-vol1-03-en\">Chapter 3: Prerequisites for Analysis</a></li>\n<li><a href=\"/magical-windbg-vol1-04-en\">Chapter 4: Analyzing an Application Crash Dump</a></li>\n<li><a href=\"/magical-windbg-vol1-05-en\">Chapter 5: Analyzing a Full Memory Dump from a System Crash</a></li>\n<li><a href=\"/magical-windbg-vol1-06-en\">Chapter 6: Investigating a User-Mode Application Memory Leak from a Process Dump</a></li>\n<li><a href=\"/magical-windbg-vol1-07-en\">Chapter 7: Investigating a User-Mode Memory Leak from a Full Memory Dump</a></li>\n<li><a href=\"/magical-windbg-vol1-50-en\">Appendix A: WinDbg Tips</a></li>\n<li><a href=\"/magical-windbg-vol1-51-en\">Appendix B: Analyzing Crash Dumps with Volatility 3</a></li>\n</ul>\n<div class=\"footnotes\">\n<hr>\n<ol>\n<li id=\"fn-1\">\n<p>Bug Check <code class=\"language-text\">0xE2:MANUALLY_INITIATED_CRASH</code> <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/bug-check-0xe2--manually-initiated-crash\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/bug-check-0xe2—manually-initiated-crash</a></p>\n<a href=\"#fnref-1\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-2\">\n<p><code class=\"language-text\">!sysinfo</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-sysinfo\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-sysinfo</a></p>\n<a href=\"#fnref-2\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-3\">\n<p><code class=\"language-text\">!cpuinfo</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-cpuinfo\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-cpuinfo</a></p>\n<a href=\"#fnref-3\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-4\">\n<p>MEX extension <a href=\"https://www.microsoft.com/en-us/download/details.aspx?id=53304\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://www.microsoft.com/en-us/download/details.aspx?id=53304</a></p>\n<a href=\"#fnref-4\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-4a\">\n<p><code class=\"language-text\">!reg</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-reg\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-reg</a></p>\n<a href=\"#fnref-4a\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-5\">\n<p>Advanced Windows registry information for power users <a href=\"https://learn.microsoft.com/ja-jp/troubleshoot/windows-server/performance/windows-registry-advanced-users\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/troubleshoot/windows-server/performance/windows-registry-advanced-users</a></p>\n<a href=\"#fnref-5\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-6\">\n<p><code class=\"language-text\">!vm</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-vm\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-vm</a></p>\n<a href=\"#fnref-6\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-7\">\n<p><code class=\"language-text\">!memusage</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-memusage\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-memusage</a></p>\n<a href=\"#fnref-7\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-8\">\n<p><em>Windows Internals, 7th Edition, Part 1</em>, p.471 (by Pavel Yosifovich, Alex Ionescu, Mark E. Russinovich, David A. Solomon / translated by 山内 和朗 / 日系 BP 社 / 2018)</p>\n<a href=\"#fnref-8\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-9\">\n<p><code class=\"language-text\">!process</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-process\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-process</a></p>\n<a href=\"#fnref-9\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-10\">\n<p><code class=\"language-text\">!for_each_process</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-for-each-process\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-for-each-process</a></p>\n<a href=\"#fnref-10\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-11\">\n<p>Displaying a stack backtrace with k, kb, kc, kd, kp, kP, and kv <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/k--kb--kc--kd--kp--kp--kv--display-stack-backtrace-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/k—kb—kc—kd—kp—kp—kv—display-stack-backtrace-</a></p>\n<a href=\"#fnref-11\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-12\">\n<p>Setting register context with <code class=\"language-text\">.thread</code> <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-thread--set-register-context-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-thread—set-register-context-</a></p>\n<a href=\"#fnref-12\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-13\">\n<p><code class=\"language-text\">!thread</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-thread\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-thread</a></p>\n<a href=\"#fnref-13\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-14\">\n<p><code class=\"language-text\">!pool</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-pool\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-pool</a></p>\n<a href=\"#fnref-14\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-15\">\n<p><code class=\"language-text\">!poolused</code> extension command <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-poolused\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-poolused</a></p>\n<a href=\"#fnref-15\" class=\"footnote-backref\">↩</a>\n</li>\n</ol>\n</div>","fields":{"slug":"/magical-windbg-vol1-07-en","tagSlugs":["/tag/magical-win-dbg/","/tag/windows/","/tag/win-dbg/","/tag/english/"]},"frontmatter":{"date":"2023-11-15","description":"This is the web edition of Magical WinDbg - Enjoying Windows Dump Analysis and Troubleshooting by Feel - VOL.1, distributed at Tech Book Fest 15.","tags":["Magical WinDbg","Windows","WinDbg","English"],"title":"Magical WinDbg VOL.1 [Chapter 7: Investigating a User-Mode Memory Leak from a Full Memory Dump]","socialImage":{"publicURL":"/static/2dbf3e09d59db889dc9dc41adcc8e827/magical-windbg-vol1.png"}}}},"pageContext":{"slug":"/magical-windbg-vol1-07-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}