{"componentChunkName":"component---src-templates-post-template-js","path":"/windbg-gflags-tutorial-en","result":{"data":{"markdownRemark":{"id":"f2aeb5f2-3a90-5538-a2f2-7600c89657de","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/windbg-gflags-tutorial\">original page</a>.</p>\n</blockquote>\n<p>This article is a follow-up to the <a href=\"/windbg-basics-001-en\">Cheat Sheet for Dump Analysis and Live Debugging with WinDbg</a> that I created the other day, and summarizes GFlags settings that are useful to remember when troubleshooting Windows.</p>\n<p>I only included the settings that I personally find useful. This is also just a memo for myself, so I would like to add more settings in the future if I find others that prove useful in different situations.</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=\"#introduction\">Introduction</a></li>\n<li><a href=\"#what-is-gflags\">What Is GFlags?</a></li>\n<li>\n<p><a href=\"#what-are-global-flags\">What Are Global Flags?</a></p>\n<ul>\n<li><a href=\"#system-global-flags\">System Global Flags</a></li>\n<li><a href=\"#per-image-file-global-flags\">Per-Image-File Global Flags</a></li>\n</ul>\n</li>\n<li><a href=\"#preventing-kernel-mode-stacks-from-being-paged-out\">Preventing Kernel-Mode Stacks from Being Paged Out</a></li>\n<li><a href=\"#viewing-image-loader-processing\">Viewing Image Loader Processing</a></li>\n<li><a href=\"#launching-a-debugger-when-a-program-starts\">Launching a Debugger When a Program Starts</a></li>\n<li><a href=\"#monitoring-program-termination\">Monitoring Program Termination</a></li>\n<li><a href=\"#summary\">Summary</a></li>\n</ul>\n<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction 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>Introduction</h2>\n<p>All of the content in this article is based only on publicly available information, published books, or results verified in a personal test environment.</p>\n<p>Related articles:</p>\n<ul>\n<li><a href=\"/windbg-basics-001-en\">Cheat Sheet for Dump Analysis and Live Debugging with WinDbg</a></li>\n<li><a href=\"/windbg-process-001-en\">Notes on Reading Windows Process Information with WinDbg</a></li>\n</ul>\n<h2 id=\"what-is-gflags\" style=\"position:relative;\"><a href=\"#what-is-gflags\" aria-label=\"what is gflags 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>What Is GFlags?</h2>\n<p>GFlags (Global Flags Editor) is a tool that can be used to enable or disable specific debugging features.</p>\n<p>Because it is included in Debugging Tools for Windows 10 (WinDbg), if you have the classic WinDbg installed, <code class=\"language-text\">gflags.exe</code> and <code class=\"language-text\">gflags.dll</code> are placed in the same folder as WinDbg (for example, <code class=\"language-text\">C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64</code>).</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GFlags - Windows drivers | Microsoft Learn</a></p>\n<p>GFlags can be used from both the CLI and the GUI, and lets you manipulate global flags for the system or for individual images (programs).</p>\n<p>The command-based way to operate GFlags is described here.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags-commands\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GFlags Commands - Windows drivers | Microsoft Learn</a></p>\n<h2 id=\"what-are-global-flags\" style=\"position:relative;\"><a href=\"#what-are-global-flags\" aria-label=\"what are global flags 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>What Are Global Flags?</h2>\n<p>Global flags are variables that support debugging and tracing of Windows systems and images.</p>\n<h3 id=\"system-global-flags\" style=\"position:relative;\"><a href=\"#system-global-flags\" aria-label=\"system global flags 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>System Global Flags</h3>\n<p>System global flags are managed by two global variables: <code class=\"language-text\">NtGlobalFlag</code> and <code class=\"language-text\">NtGlobalFlag2</code>.</p>\n<p>These system variables are defined under <code class=\"language-text\">HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager</code> and are initialized when the system starts. (The default value of both is 0, meaning no global flags are set.)</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 825px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/782d82840ff959b670976f6c36059172/d4c13/image-20230506234025475.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.08333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAABoklEQVQoz22S626bQBCF/cbpa/VHpEh9hf6o2kRVBebOAo6BZddcsrbBuMDp7IZYrpSVVrOI0Tdn5szmICU4FyhfHSRxCClrVLyiKCGFRMoYWBTjcKghhEDTNBjHEV3XmXff9zifz3Qp0nsDLJgXYFQ+yj2jRIX7Iw8d4ihDWRRo6gYJS3BURwN1XdcUvj+beZ7wdwKGNx+Rb8F1fJyOp1tCTYoDL0CSZmibFmEQIt/nGIYBHgF1AaWU+dZFbsC+deFtf1MbHaZp+g8oUoa2yvHWdmAxQ5EXGK8jjYobuB5FTy1fLpc7hZ2LjHmU+A6bl8VELls8fA3x5ZGhbhXNOUZVCVM025FqmuWnLV9UYICnU29+LCuwFB2efqT49pyCV7UBCjJLt2dZFoqyvOXrewOOKjTAXbY3zi1rRU7AHcvAs8i4z1bg9XrF1nGoSPU5cOg8MsWGbTkQ1NI8rwp5A9/PEEURzasgUwKUJTcKbdtGTu5/wFbgbIDH2sOfl+/49fPF7J9WoFcqSV4R+rFRpg2IyOWyeAdu7S1yMkjv4ceI/gHhoKd+74M3pQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/782d82840ff959b670976f6c36059172/8ac56/image-20230506234025475.webp 240w,\n/static/782d82840ff959b670976f6c36059172/d3be9/image-20230506234025475.webp 480w,\n/static/782d82840ff959b670976f6c36059172/0244e/image-20230506234025475.webp 825w\"\n              sizes=\"(max-width: 825px) 100vw, 825px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/782d82840ff959b670976f6c36059172/8ff5a/image-20230506234025475.png 240w,\n/static/782d82840ff959b670976f6c36059172/e85cb/image-20230506234025475.png 480w,\n/static/782d82840ff959b670976f6c36059172/d4c13/image-20230506234025475.png 825w\"\n            sizes=\"(max-width: 825px) 100vw, 825px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/782d82840ff959b670976f6c36059172/d4c13/image-20230506234025475.png\"\n            alt=\"image-20230506234025475\"\n            title=\"image-20230506234025475\"\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>You can inspect system-side global flags during kernel debugging by using the <code class=\"language-text\">!gflag</code> extension.</p>\n<p>However, at present this extension appears to support only the value configured in <code class=\"language-text\">NtGlobalFlag</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: 692px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b544950cd0af10cfbf57dd8c9c2f6669/91e7e/image-20230506235525826.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: 129.16666666666669%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAACXBIWXMAAAsTAAALEwEAmpwYAAACVUlEQVRIx42Va47aQBCEfQ/e2AYDNm+Mza4iJdlNpARFwC05SaJcqjNfs40Myhh+lAYbpqaqu3oIPn99l/F4JKv12q1jieNYMRgMFFmWyXA4lFarJe12+4r7Z0MAIRuWy6VMJhOJokif+/2+dDodXbvdrjSbzRv4SIMf+18ym81ktVrJYrGQNE0lz3OZTqcyGo30kHug3Kvw7f27bsbafD6XtbPOauSQ8h3v+R2H895UeiwPZOJ+xEY2sQEkSaJ1RRWH8D3vKYNX4U9nOXUbNpuNqoKwKAotAXVlhQxlANIwDP2Eu9dPzlZyYxVylLGRJgFrgsHblLzYSa/XU1tm16zxA+vq07Epdq8ydF3DDuoM1s3q5ipJPeFHDqkdq9WO+NDl/230IdiWLxK6rmEXZdgFFnSUV3PnU3ZTQ2Jg4aZ2fOYAlNOQ+zrWkQaFUzh2thZOUVmW2untdqvgIGDz7avnrWWnMI4jSZ1Nm47s47MpJVLUl6D7JsRbQ5pABm1qICGP2K+b4Sth6boMAWTYpLOshJuacgB1rE5HfQ13LzrLEGLNVlNsdlHMwQ8JsYyCNM2utw5AGYAUq41G47mmlBrsy6SYTVNm959dsNV5ro0No0eQ7WKFFHLeoZ7IcHs/ncMoCtUyKiFhRZldroBuQ/ywyxAmLhJsMmWEm7rZnxaRAVWVNV2+xAZlEJl1A892g0P48HLIi1JVoNAmg6bYLc1hENEUOm2rD8GXt2+O5PIHZdf9/dXPczVKdQh+//kr5/NZ9vu9HI9HxeFwUFSfWU+n00P8AzBB/2RTL+TAAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/b544950cd0af10cfbf57dd8c9c2f6669/8ac56/image-20230506235525826.webp 240w,\n/static/b544950cd0af10cfbf57dd8c9c2f6669/d3be9/image-20230506235525826.webp 480w,\n/static/b544950cd0af10cfbf57dd8c9c2f6669/f686e/image-20230506235525826.webp 692w\"\n              sizes=\"(max-width: 692px) 100vw, 692px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/b544950cd0af10cfbf57dd8c9c2f6669/8ff5a/image-20230506235525826.png 240w,\n/static/b544950cd0af10cfbf57dd8c9c2f6669/e85cb/image-20230506235525826.png 480w,\n/static/b544950cd0af10cfbf57dd8c9c2f6669/91e7e/image-20230506235525826.png 692w\"\n            sizes=\"(max-width: 692px) 100vw, 692px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/b544950cd0af10cfbf57dd8c9c2f6669/91e7e/image-20230506235525826.png\"\n            alt=\"image-20230506235525826\"\n            title=\"image-20230506235525826\"\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>Running the <code class=\"language-text\">!gflag -?</code> command displays help for global flags.</p>\n<h3 id=\"per-image-file-global-flags\" style=\"position:relative;\"><a href=\"#per-image-file-global-flags\" aria-label=\"per image file global flags 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>Per-Image-File Global Flags</h3>\n<p>Each image (program) also has its own global flag settings.</p>\n<p>The global flags for each image file are defined under <code class=\"language-text\">HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\&lt;Application></code>.</p>\n<p>Under this registry key you can find the <code class=\"language-text\">Debugger</code> option, which specifies the application to open when the target application starts, and <code class=\"language-text\">SilentProcessExit</code>, which can be abused to launch a process when the application exits.</p>\n<p>These Image File Execution Options (IFEO) settings are known to be abused by malware for persistence, not only for debugging purposes.</p>\n<p>Global flags for each image are processed by user-mode components such as the loader and Windows Error Reporting (WER).</p>\n<p>For example, when the loader handles global flags, it processes them while initializing the process and loading dependencies so that the program can start.</p>\n<p>At that time, the loader function <code class=\"language-text\">LdrpInitializeExecutionOptions</code> looks up the IFEO registry key based on the image file name and retrieves the global flags.</p>\n<p>The global flag information retrieved by the loader from the registry is stored in <code class=\"language-text\">NtGlobalFlag</code> and <code class=\"language-text\">NtGlobalFlag2</code> inside the PEB.</p>\n<p>When I actually inspected the PEB of a Notepad process for which global flags had been set with GFlags, I was able to confirm that a value was set in <code class=\"language-text\">NtGlobalFlag</code> as shown below.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token operator\">></span> <span class=\"token operator\">!</span>ped\nNo <span class=\"token builtin class-name\">export</span> ped found\n<span class=\"token number\">0</span>:00<span class=\"token operator\"><span class=\"token file-descriptor important\">0</span>></span> <span class=\"token operator\">!</span>peb\nPEB at 00000030dbc1e000\n    InheritedAddressSpace:    No\n    ReadImageFileExecOptions: No\n    BeingDebugged:            Yes\n    ImageBaseAddress:         00007ff689330000\n    NtGlobalFlag:             <span class=\"token number\">70</span>\n    NtGlobalFlag2:            <span class=\"token number\">0</span>\n    Ldr                       00007ffcf7f9c4c0\n    Ldr.Initialized:          Yes\n    Ldr.InInitializationOrderModuleList: 000001744bbe2a10 <span class=\"token builtin class-name\">.</span> 000001744bbe3130\n    Ldr.InLoadOrderModuleList:           000001744bbe2bc0 <span class=\"token builtin class-name\">.</span> 000001744bbf04e0\n    Ldr.InMemoryOrderModuleList:         000001744bbe2bd0 <span class=\"token builtin class-name\">.</span> 000001744bbf04f0</code></pre></div>\n<p>Reference: <a href=\"https://www.amazon.co.jp/%E3%82%A4%E3%83%B3%E3%82%B5%E3%82%A4%E3%83%89Windows-%E7%AC%AC7%E7%89%88-%E4%B8%8B-%E3%83%9E%E3%82%A4%E3%82%AF%E3%83%AD%E3%82%BD%E3%83%95%E3%83%88%E5%85%AC%E5%BC%8F%E8%A7%A3%E8%AA%AC%E6%9B%B8-Andrea-Allievi%EF%BC%88%E3%82%A2%E3%83%B3%E3%83%89%E3%83%AC%E3%82%A2%E3%83%BB%E3%82%A2%E3%83%AA%E3%82%A8%E3%83%93%EF%BC%89/dp/4296080202\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Inside Windows, 7th Edition Part 2</a></p>\n<h2 id=\"preventing-kernel-mode-stacks-from-being-paged-out\" style=\"position:relative;\"><a href=\"#preventing-kernel-mode-stacks-from-being-paged-out\" aria-label=\"preventing kernel mode stacks from being paged out 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>Preventing Kernel-Mode Stacks from Being Paged Out</h2>\n<p>By setting the <code class=\"language-text\">Disable paging of kernel stacks</code> global flag in GFlags, you can disable paging of kernel-mode stacks.</p>\n<p><code class=\"language-text\">Disable paging of kernel stacks</code> is configured with <code class=\"language-text\">FLG_DISABLE_PAGE_KERNEL_STACKS(0x80000)</code>.</p>\n<p>As described in the documentation below, kernel-mode stacks are normally not paged and are guaranteed to remain resident in memory.</p>\n<p>However, in rare cases, the kernel stacks of inactive threads may be paged out.</p>\n<p>If a kernel stack is paged out, you may no longer be able to inspect information related to the target thread during kernel debugging or full dump analysis.</p>\n<p>For that reason, setting this global flag is useful, for example, when debugging deadlocks or when you need to track every thread.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/disable-paging-of-kernel-stacks\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Disable paging of kernel stacks - Windows drivers | Microsoft Learn</a></p>\n<p>You can configure <code class=\"language-text\">Disable paging of kernel stacks</code> from the following location.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 532px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/95d0fc59be1b8d4958572b0f10afaa06/89a37/image-20230512201841302.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: 43.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsTAAALEwEAmpwYAAABjUlEQVQoz11RXXObMBDkN8dp3TznLb8nz43rac2XAQcomAQkgR1LFhIY7BLy1sWd6XS6c7q5k3Q7e3eGOPDD4U1pPX58DMPwfsX4/j/w9OsfIG3b1hBCHGFSIjmdTlo3upnQNq2e0OC+aXTXdcMVf4vhjd2uKooiSdLtdptlGSWUMUYJKVkJY5RV+FFVdV2jHuzw/TUAsYFDKY3iOIqi5+dQKX25XPrzhB4/aonSHXgIfbsGJSGkKBo1AcUK3HEcp0kaRTGI+r6fWsDpOrbffTOt5cr84TiO769c97tlbX4mr4yhOwMEnHNCKEirsgIvFE7ChkE9PpLZTXL7KZ3dvHye5/N5OpvlX+70w4O6v6/Xa0PVNSly23aCYBOGoed5GAFGhOZaxrhjp1+fsqdFvlxmi0Vprvau2yZJG8dqvze0UpiPaVq+79u27Xl+EAR5UZwh/nzmWllBYAUbNwxXa6/koh/Hdhi6cVSQjTVgO8fjsZYSXkqJRk5/gI0pJYWQguNN8APiDuNoGnhI/g0HBttQ/URI8QAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/95d0fc59be1b8d4958572b0f10afaa06/8ac56/image-20230512201841302.webp 240w,\n/static/95d0fc59be1b8d4958572b0f10afaa06/d3be9/image-20230512201841302.webp 480w,\n/static/95d0fc59be1b8d4958572b0f10afaa06/b5f85/image-20230512201841302.webp 532w\"\n              sizes=\"(max-width: 532px) 100vw, 532px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/95d0fc59be1b8d4958572b0f10afaa06/8ff5a/image-20230512201841302.png 240w,\n/static/95d0fc59be1b8d4958572b0f10afaa06/e85cb/image-20230512201841302.png 480w,\n/static/95d0fc59be1b8d4958572b0f10afaa06/89a37/image-20230512201841302.png 532w\"\n            sizes=\"(max-width: 532px) 100vw, 532px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/95d0fc59be1b8d4958572b0f10afaa06/89a37/image-20230512201841302.png\"\n            alt=\"image-20230512201841302\"\n            title=\"image-20230512201841302\"\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>In addition, the following blog mentioned that during real debugging, it is also useful to set the global flag <code class=\"language-text\">FLG_POOL_ENABLE_TAGGING(0x400)</code>, which lets you calculate statistics related to pool memory allocation, along with preventing kernel stack paging described above.</p>\n<p>Reference: <a href=\"http://winkit.blog.fc2.com/blog-entry-54.html?sp\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">How to Prevent Kernel-Mode Stacks from Being Paged Out | Mado no Kusuribako</a></p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/enable-pool-tagging\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Enable pool tagging - Windows drivers | Microsoft Learn</a></p>\n<h2 id=\"viewing-image-loader-processing\" style=\"position:relative;\"><a href=\"#viewing-image-loader-processing\" aria-label=\"viewing image loader processing 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>Viewing Image Loader Processing</h2>\n<p>By using GFlags to set the global flag that enables the <code class=\"language-text\">Show Loader Snaps</code> debugging feature, you can inspect the image loader’s debug output when the target application starts.</p>\n<p>This lets you output information about loading and unloading executables and libraries to the debugger.</p>\n<p><code class=\"language-text\">Show Loader Snaps</code> is <code class=\"language-text\">FLG_SHOW_LDR_SNAPS(0x2)</code>. If it is set system-wide, it outputs information about driver loading and unloading.</p>\n<p>If it is set only for a specific image file, it outputs information about DLL loading and unloading when the application starts.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/show-loader-snaps\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Show loader snaps - Windows drivers | Microsoft Learn</a></p>\n<p>For example, if you start <code class=\"language-text\">gflags.exe</code> and configure it from [Image File] as shown below, <code class=\"language-text\">Show Loader Snaps</code> and the <code class=\"language-text\">Debugger</code> flag are set for <code class=\"language-text\">Notepad.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: 527px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/50919acce109af02de3ce5fec63d7594/44385/image-20230506194811885.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: 110.00000000000001%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAIAAABPIytRAAAACXBIWXMAAAsTAAALEwEAmpwYAAADH0lEQVQ4y11T2U7bQBTNX/c/+lQeWqRKrYDyxAMgEQRtIBsJWZzEjvF4G+/jfQkIkNJjOwnL9Wg0M75zz73nnmm05/OlrEgGDfKcpamfZyzLsGBZufazzM9zDC9JdsOO47QofrfbDUFV4yBgrhv6fhyGAWNpHGMOmO97Hmac+4zlWfZYFJuxWq3X67PxuDERRUl8WCwWS5iwVGCqMuU47BRZUVUNW13XESEABoKGITUMZtlHt7cNQdOW/GIwGNzd3bU7XXhEUahpum1bWZZ5ridJEraEEATKKlM1zdHpQatVXjYpFQSB53ng27adpqVHmqYRwqCQAGAbi+MYh3GSrF+eS+SlrmdJUgHCN0J6G49qDraGIHXmCZzD8Lkojm5uSmRD1yaTKTebAZzjONNCwmAN9IWyLI/H49l8Pp/NOW7K80IZKIpeVqvqsq5rstz61+r3+p1Op9vtje5Huk6BAGTLskRRRAhUDioR98NlpI2WyIqi6TqcwI1BKRJMkjJtx3FwUpsiyzip03677DmOIKA1oiSRhwfJ9dw0Teqaqx6zutodFx+QIYD6tLZkazgE+UiYSBL6FG3/viHXrQJPYAu06ZQCxHXdmnaQXHWralgUbnTyHhkClEoNqEAgBGVr4lIksgJkkIS40+mUKz80ZIYUEObtcpokYRjteos5rwwLx7YNwzBNExHV6itb/r5V6DO0iX72+330CbCUGvBGhpiHw/vJZAIiUb9MZAgbdb/uaqaaNhqNkBKUAIUiynA47PV68KOUInMI2zQtxPIqsx3nKU1LeS6qn3CFjJAgoNDzGVeqDSzLhOCVqYoKzqH/SjBkwfOh5x3jPaNmcIrApgH9WKgQPONppFW38DyS7WJnYOX18bFMG/XhfcMbDGXVvLvwyXYSAGGo+Q/SnhKCMkpQvOB6OI5dDSwc17WrgYXHWLnFGWNFkvy6vm6Ytr1+enrJ89ei+DQKyMOyYtdNfR9rZhhZEDxnOSXk0Wdng0Fj7+rquN8/6HYPP46jXu/H5eW309O98/PvzYv9yybWP5rNn3+vv56c7F9cfDk8/A+glZBfZ+T5MgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/50919acce109af02de3ce5fec63d7594/8ac56/image-20230506194811885.webp 240w,\n/static/50919acce109af02de3ce5fec63d7594/d3be9/image-20230506194811885.webp 480w,\n/static/50919acce109af02de3ce5fec63d7594/042cc/image-20230506194811885.webp 527w\"\n              sizes=\"(max-width: 527px) 100vw, 527px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/50919acce109af02de3ce5fec63d7594/8ff5a/image-20230506194811885.png 240w,\n/static/50919acce109af02de3ce5fec63d7594/e85cb/image-20230506194811885.png 480w,\n/static/50919acce109af02de3ce5fec63d7594/44385/image-20230506194811885.png 527w\"\n            sizes=\"(max-width: 527px) 100vw, 527px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/50919acce109af02de3ce5fec63d7594/44385/image-20230506194811885.png\"\n            alt=\"image-20230506194811885\"\n            title=\"image-20230506194811885\"\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>Applying this setting writes the WinDbg path to <code class=\"language-text\">Debugger</code> under <code class=\"language-text\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\Notepad.exe</code>.</p>\n<p>It also sets the value <code class=\"language-text\">2</code> in <code class=\"language-text\">GlobalFlag</code>. (In this environment, no other <code class=\"language-text\">GlobalFlag</code> values were set for <code class=\"language-text\">Notepad.exe</code>, so the hexadecimal value for <code class=\"language-text\">Show Loader Snaps</code>, <code class=\"language-text\">0x2</code>, is applied as-is.)</p>\n<p>With the <code class=\"language-text\">Debugger</code> flag now set for <code class=\"language-text\">Notepad.exe</code>, trying to start Notepad automatically attaches WinDbg and records output like the following.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">ModLoad: 00007ff7<span class=\"token variable\"><span class=\"token variable\">`</span>8c3b0000 00007ff7<span class=\"token variable\">`</span></span>8c3e8000   notepad.exe\nModLoad: 00007ffd<span class=\"token variable\"><span class=\"token variable\">`</span>1f2d0000 00007ffd<span class=\"token variable\">`</span></span>1f4c8000   ntdll.dll\n22e0:0710 @ 00503718 - LdrpInitializeProcess - INFO: Beginning execution of notepad.exe <span class=\"token punctuation\">(</span>C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>system32<span class=\"token punctuation\">\\</span>notepad.exe<span class=\"token punctuation\">)</span>\nCurrent directory: C:<span class=\"token punctuation\">\\</span>Users<span class=\"token punctuation\">\\</span>Tadpole01<span class=\"token punctuation\">\\</span>\nPackage directories: <span class=\"token punctuation\">(</span>null<span class=\"token punctuation\">)</span>\n22e0:0710 @ 00503718 - LdrLoadDll - ENTER: DLL name: KERNEL32.DLL\n22e0:0710 @ 00503718 - LdrpLoadDllInternal - ENTER: DLL name: KERNEL32.DLL\n22e0:0710 @ 00503718 - LdrpFindKnownDll - ENTER: DLL name: KERNEL32.DLL\n22e0:0710 @ 00503718 - LdrpFindKnownDll - RETURN: Status: 0x00000000\n22e0:0710 @ 00503718 - LdrpMinimalMapModule - ENTER: DLL name: C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>System32<span class=\"token punctuation\">\\</span>KERNEL32.DLL\nModLoad: 00007ffd<span class=\"token variable\"><span class=\"token variable\">`</span>1d390000 00007ffd<span class=\"token variable\">`</span></span>1d44f000   C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>System32<span class=\"token punctuation\">\\</span>KERNEL32.DLL\n22e0:0710 @ 00503718 - LdrpMinimalMapModule - RETURN: Status: 0x00000000\n22e0:0710 @ 00503718 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-rtlsupport-l1-1-0.dll was redirected to C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>SYSTEM32<span class=\"token punctuation\">\\</span>ntdll.dll by API <span class=\"token builtin class-name\">set</span>\n22e0:0710 @ 00503718 - LdrpFindKnownDll - ENTER: DLL name: KERNELBASE.dll\n22e0:0710 @ 00503718 - LdrpFindKnownDll - RETURN: Status: 0x00000000\n22e0:0710 @ 00503718 - LdrpMinimalMapModule - ENTER: DLL name: C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>System32<span class=\"token punctuation\">\\</span>KERNELBASE.dll\nModLoad: 00007ffd<span class=\"token variable\"><span class=\"token variable\">`</span>1ca10000 00007ffd<span class=\"token variable\">`</span></span>1cd06000   C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>System32<span class=\"token punctuation\">\\</span>KERNELBASE.dll\n22e0:0710 @ 00503718 - LdrpMinimalMapModule - RETURN: Status: 0x00000000\n22e0:0710 @ 00503718 - LdrpPreprocessDllName - INFO: DLL api-ms-win-eventing-provider-l1-1-0.dll was redirected to C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>SYSTEM32<span class=\"token punctuation\">\\</span>kernelbase.dll by API <span class=\"token builtin class-name\">set</span>\n22e0:0710 @ 00503718 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-apiquery-l1-1-0.dll was redirected to C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>SYSTEM32<span class=\"token punctuation\">\\</span>ntdll.dll by API <span class=\"token builtin class-name\">set</span>\n22e0:0710 @ 00503718 - LdrpPreprocessDllName - INFO: DLL api-ms-win-core-apiquery-l1-1-1.dll was redirected to C:<span class=\"token punctuation\">\\</span>WINDOWS<span class=\"token punctuation\">\\</span>SYSTEM32<span class=\"token punctuation\">\\</span>ntdll.dll by API <span class=\"token builtin class-name\">set</span></code></pre></div>\n<p>The output is quite large (around 120 KB in my environment), so depending on your needs it is probably a good idea to write it to a log file.</p>\n<p>For example, if you run the <code class=\"language-text\">Debugger</code> flag with a log file path included as shown below, you can write the startup log to a file.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">C:<span class=\"token punctuation\">\\</span>Program Files <span class=\"token punctuation\">(</span>x86<span class=\"token punctuation\">)</span><span class=\"token punctuation\">\\</span>Windows Kits<span class=\"token punctuation\">\\</span><span class=\"token number\">10</span><span class=\"token punctuation\">\\</span>Debuggers<span class=\"token punctuation\">\\</span>x64<span class=\"token punctuation\">\\</span>windbg.exe -logo  C:<span class=\"token punctuation\">\\</span>Users<span class=\"token punctuation\">\\</span>Public<span class=\"token punctuation\">\\</span>debug.log</code></pre></div>\n<p>When the <code class=\"language-text\">Show Loader Snaps</code> flag is enabled, WinDbg outputs events not only when the application starts but also when a module is loaded later as the result of some operation.</p>\n<h2 id=\"launching-a-debugger-when-a-program-starts\" style=\"position:relative;\"><a href=\"#launching-a-debugger-when-a-program-starts\" aria-label=\"launching a debugger when a program starts 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>Launching a Debugger When a Program Starts</h2>\n<p>As mentioned above, setting the <code class=\"language-text\">Debugger</code> option for each image lets you attach a debugger when the program starts.</p>\n<p>Strictly speaking, these Image File Execution Options (IFEO) settings are different from global flags, but they can still be configured from GFlags.</p>\n<p>For example, by setting it up as shown below, you can start Notepad under WinDbg and begin debugging immediately.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 535px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/b5245/image-20230512203828930.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: 107.08333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAIAAADJt1n/AAAACXBIWXMAAAsTAAALEwEAmpwYAAACfUlEQVQ4y12UaVvqMBCF+f+/C6XIUgWkZWvpkjQFgS7oc/XTfSepoB4ozTLLmTMJvTRNVa7KsvwSfH65l8PXHZ/f+Gfx8fFR13Uvy7Jc5UmaMtBK82uMUUqliaxkaaa0TrP0dDo3TVNbtNfr9f3KVJw36/VqtdpsNqtwpRQRdBAE6/WGcWGhtX57eztZVFVF6M1mC+UehHEbjyej0ejhcaB1QWySs17XzfF4ZHe3i3YgivBs25Yt4uZ53sOOqDJRijnWN3qXy6Wu6raRTyOPvGSxriEOox6Pc2ZAoDxXcKtJcRGUh4PUzSqBsxx97PKFfXE2poC97/vPzy/z+YLfCHp2GyPMZ7OX19clXwcSOF7O2eyTxBt4k8nkaTgcPo0IRHlwl8xWEerdbqVopi7t3Zk6pWGWGARNaSoL7CihLI3TD+ZSkdPi5syGjb3d7/dxHFO7swAHak5TCapUhXo24q/M3+pIHvRESRG3bVk/n8/KAlOmdr25O/MkSUKTp9PnoectlwEVoBks8CS0ts5yDumlUnEs60TpMhPmcDy6M0RvSlNipLVyaVE4DMKFyB3wxedes21vafVS1kdO4ruFayYqQA1ROOvRLnKtvvXZ0GfP88bj8WP/wfOGU98nzWw2I5Apijmj+TymitMJ/VDXKSLOWKC070+hl+xpecKtGAy8fr8fhmEcc6q3URRHFkwhIizSrKNNAxcLKSpJUk4C4QpdSAG6oH7bZnpvmFNbYeSekb+jDQ3XrbMFg9bC3ZDGont9o6Pt1HZHyh3aW9urH7j8Rqc2apUdtb/QFu6Q/LRx/xDdfb5l/gOaiDZcDBJgHQYBciJ4sHydzRes/AdDZXDFT1m7AQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/8ac56/image-20230512203828930.webp 240w,\n/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/d3be9/image-20230512203828930.webp 480w,\n/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/e0c9f/image-20230512203828930.webp 535w\"\n              sizes=\"(max-width: 535px) 100vw, 535px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/8ff5a/image-20230512203828930.png 240w,\n/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/e85cb/image-20230512203828930.png 480w,\n/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/b5245/image-20230512203828930.png 535w\"\n            sizes=\"(max-width: 535px) 100vw, 535px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ee8bf6e84a0dd18ac6b9c7f726c8c9eb/b5245/image-20230512203828930.png\"\n            alt=\"image-20230512203828930\"\n            title=\"image-20230512203828930\"\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 setting is extremely useful in scenarios where you need to debug something that cannot be launched directly, must be started through some interface or job, and does not remain resident long enough to attach a debugger manually.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/en-us/previous-versions/windows/desktop/xperf/image-file-execution-options\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Image File Execution Options | Microsoft Learn</a></p>\n<p>Also, the path you specify in <code class=\"language-text\">Debugger</code> is not limited to the path of an actual debugger.</p>\n<p>For example, if you specify an editor or some other arbitrary program as shown below, then starting Notepad automatically opens Notepad with that specified program.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/809f7cfa3bc5fde355a5de8b3c3602a2/1d553/image-20230520162808075.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: 45.833333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsTAAALEwEAmpwYAAABvUlEQVQozyVRzXOiMBTn/z+3PbVana66wthZ3dPaGWcEuiruRUGQQEJCEghQ+fDkra/dmeRNJi+/9/uIFsSMUJ5KlTBJuZSq+miuH3VXXloPxRgTykTCM8IEk4W6dKqq86rlRVPWnUYZR+FZCF6WBaw8zwql2qZRuTp6Lg4OjCQYJzGKQgSFwPaD2PXj8Iy0VOYJIZTStm0vlwtjLEkSpVTTNEcfmfZf3ZiZpmVatuf5lMIoJoQUXCIUa4Rx13UPhwNcARhjHMVxURR1XfsI/5rPB8Pno3vc7raWZdrv9ma7Mc31ZrN1HEfjmQI2IQS8BnCe51VVdV0HZ+8cWbY1GA5t2zZms/Fk8vLyY774PXt91Q291+99gVPG0pSrQpVlCYMIIZxzALtBBLDJz8loNFqb5v7fHthCFEZRlLI0xrFGUxn4vh/4IBiUh+EZevLbAjD/WS7v7u90w3h8erx/eBgMB6A/ihAIvN1uGqYpYCEkwECVUoLh6/UKLoB5tVr1n/tTXR9PxvPFIgiCXClIN8uyuqk1kanm2+1/z5AzNEAC/JkboOXbW6/3NJ1O1+Z65ziQ+na3O51Ozt4BUZ/KqsV6tEOpXAAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/809f7cfa3bc5fde355a5de8b3c3602a2/8ac56/image-20230520162808075.webp 240w,\n/static/809f7cfa3bc5fde355a5de8b3c3602a2/d3be9/image-20230520162808075.webp 480w,\n/static/809f7cfa3bc5fde355a5de8b3c3602a2/e46b2/image-20230520162808075.webp 960w,\n/static/809f7cfa3bc5fde355a5de8b3c3602a2/69f9d/image-20230520162808075.webp 1159w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/809f7cfa3bc5fde355a5de8b3c3602a2/8ff5a/image-20230520162808075.png 240w,\n/static/809f7cfa3bc5fde355a5de8b3c3602a2/e85cb/image-20230520162808075.png 480w,\n/static/809f7cfa3bc5fde355a5de8b3c3602a2/d9199/image-20230520162808075.png 960w,\n/static/809f7cfa3bc5fde355a5de8b3c3602a2/1d553/image-20230520162808075.png 1159w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/809f7cfa3bc5fde355a5de8b3c3602a2/d9199/image-20230520162808075.png\"\n            alt=\"image-20230520162808075\"\n            title=\"image-20230520162808075\"\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 this behavior can be abused, it should be used with caution.</p>\n<h2 id=\"monitoring-program-termination\" style=\"position:relative;\"><a href=\"#monitoring-program-termination\" aria-label=\"monitoring program termination 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>Monitoring Program Termination</h2>\n<p>Strictly speaking, this is not a global flag either, but by enabling <code class=\"language-text\">Silent Process Exit</code> for each application, you can monitor when the application terminates.</p>\n<p>The termination events you can monitor are limited to self-termination via <code class=\"language-text\">ExitProcess</code> (for example, clicking the close button in the top right) or termination by another application via <code class=\"language-text\">TerminateProcess</code>.</p>\n<p>When <code class=\"language-text\">Silent Process Exit</code> is configured, you can output a crash dump when the application exits or send a notification to the host.</p>\n<p>You can also launch an arbitrary application as a Monitor process. (This too can be abused, so caution is required.)</p>\n<p>These settings can be configured from <code class=\"language-text\">Silent Process Exit</code> in GFlags.</p>\n<p>This makes it possible to collect dumps of programs that exited for reasons other than a crash during troubleshooting, or to identify what caused the program to terminate.</p>\n<p>For example, suppose you configure <code class=\"language-text\">Silent Process Exit</code> for the Notepad application with options like the following.</p>\n<ul>\n<li>If [Custom Dump] is selected as the dump type, the dump type that can be collected is determined by the values of <a href=\"https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidump_type\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">MINIDUMP_TYPE (minidumpapiset.h)</a>. In this example, <code class=\"language-text\">0x2</code>, which is the value of <code class=\"language-text\">MiniDumpWithFullMemory</code>, is set.</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 535px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b9d33122cce4ce71ab960b0456fc5be9/b5245/image-20230520165705480.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: 99.58333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAACgElEQVQ4y32U63KbMBCFef/HaqfttJmYAMGAuUncBOZi4zp2ks6k/SRIx+2P7Mh4kXT2nN2VsIJYlmXVqO755ZVxNWPxX15/LeP6/HK5Pv83gFhRIgopRS66rquqSjVN17Z1XfMqpSyLoizLw+FwvT5dLuvALpdLP4xWnJdZltr2g+d5vr91HCcMQgBKqaquqrKq6rohYtftb4xwsigtWXdt0yRJmuV5mmZJnDSNytJUSDnPMwzn8/mnsdM8n4wxfzwecyGtvFR9v0cdFIRnFuXw27YdBoHredFut4t2YRhC2A9927bjOIJfwfuuy/NcCJ02gXl6rrvZbOyN7boer2Thucx5j48+24hy+gvu97o2RVGQG9LYLYTMsjzLMiZbpQBnxuBgD+SrbFG1dVWic7vdog3xrMVxjI9aNiFymiYcioTaydg7uFTEDsOIwOw7Hmf6BDJOUupHI9ApTFbDMJyNUbxb5spxdEJRFBEbMH0iPLv7vh+M3TpLXdecmSErkgGDNnb8/tA08+GgwVnRnOajbqMxQgJ+e3v7AIxyKrCCTS1WW8AfM8NxWJjzopmmcRjGxUiJNlIUyqKH9s5P/9qkWSYNllVbSPFg0yyXYxDHSRRG2vM4Fa7v+8zra3djps/vsiFOkoR9tJoGcbcacxmU0iWkkQZCT7RRWtZuqt3vOTxBENAkNOuLqdRyQ/N8Obj85HKxeJLaCoZ5HAcWwyiCvzPLmrBt9U3o1wbzZ8o5v9d1znJhpaIc+q6ujaCyaPRnAFi3DHxmWEQ2Hwl8grYmF/isjZ+KSsGPfk4bT/xU1gwascuK7/fOp693965vPwafv915QWx72y8/NnfO9g9Fwj6OVqzj9gAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/b9d33122cce4ce71ab960b0456fc5be9/8ac56/image-20230520165705480.webp 240w,\n/static/b9d33122cce4ce71ab960b0456fc5be9/d3be9/image-20230520165705480.webp 480w,\n/static/b9d33122cce4ce71ab960b0456fc5be9/e0c9f/image-20230520165705480.webp 535w\"\n              sizes=\"(max-width: 535px) 100vw, 535px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/b9d33122cce4ce71ab960b0456fc5be9/8ff5a/image-20230520165705480.png 240w,\n/static/b9d33122cce4ce71ab960b0456fc5be9/e85cb/image-20230520165705480.png 480w,\n/static/b9d33122cce4ce71ab960b0456fc5be9/b5245/image-20230520165705480.png 535w\"\n            sizes=\"(max-width: 535px) 100vw, 535px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/b9d33122cce4ce71ab960b0456fc5be9/b5245/image-20230520165705480.png\"\n            alt=\"image-20230520165705480\"\n            title=\"image-20230520165705480\"\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>If you forcibly terminate Notepad from Task Manager in this state, a dump of the Task Manager process that performed the termination is also collected, 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: 715px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/d708c23db7844ca9d2ce1a02eacb94a1/d0c0e/image-20230520164926209.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: 19.166666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAn0lEQVQI1z2Paw6DIBCEOYdpCsr7oSAmgKl6/2N1irHfDzI7OwsLmYOTUmmtY4xCCKWUtbafBgL+3EE3pYTAMAyvB+K9Z4zBlVKOHc450tu2eedRpjWhhYw2RkrBKKOUvjtk/1y1lNbacZw5Z84nDJdSj/PcW8Oltda8ruM0QS/LAs0eSAghxYRHQpjDbwsK1xjjgHW3xvJ3Gh9B+R/+Ato8JWoBHapkAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/d708c23db7844ca9d2ce1a02eacb94a1/8ac56/image-20230520164926209.webp 240w,\n/static/d708c23db7844ca9d2ce1a02eacb94a1/d3be9/image-20230520164926209.webp 480w,\n/static/d708c23db7844ca9d2ce1a02eacb94a1/cb533/image-20230520164926209.webp 715w\"\n              sizes=\"(max-width: 715px) 100vw, 715px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/d708c23db7844ca9d2ce1a02eacb94a1/8ff5a/image-20230520164926209.png 240w,\n/static/d708c23db7844ca9d2ce1a02eacb94a1/e85cb/image-20230520164926209.png 480w,\n/static/d708c23db7844ca9d2ce1a02eacb94a1/d0c0e/image-20230520164926209.png 715w\"\n            sizes=\"(max-width: 715px) 100vw, 715px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/d708c23db7844ca9d2ce1a02eacb94a1/d0c0e/image-20230520164926209.png\"\n            alt=\"image-20230520164926209\"\n            title=\"image-20230520164926209\"\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>Also, if you terminate it from PowerShell with <code class=\"language-text\">Stop-Process -Name notepad</code>, a PowerShell dump is collected like this.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 678px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/1122ec328514bb95fca8bc74f9d6f6a8/38cea/image-20230520165942146.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: 19.583333333333332%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAqUlEQVQI1yVORw6DMBD0Q8A2uBvihgtEivL/X2Ugc1jtatqS7yfu+6613rbtOA4s3nvrHKYxJqWklMIMIeScIai1rusyTdM8z8Q7AwO25QGllHPOGIMZBuRSRq213rs/hVx+g+Ek/pXG9e6ttdrGeSIYDKUMzvM6Rx93ttZjDCkFDMbY3rtzDgVEaRNjKqXEEPFezkUIAQJt4QHeFlKClUJQxqSUECERmh9eXSZoXIs2TwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/1122ec328514bb95fca8bc74f9d6f6a8/8ac56/image-20230520165942146.webp 240w,\n/static/1122ec328514bb95fca8bc74f9d6f6a8/d3be9/image-20230520165942146.webp 480w,\n/static/1122ec328514bb95fca8bc74f9d6f6a8/7e03f/image-20230520165942146.webp 678w\"\n              sizes=\"(max-width: 678px) 100vw, 678px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/1122ec328514bb95fca8bc74f9d6f6a8/8ff5a/image-20230520165942146.png 240w,\n/static/1122ec328514bb95fca8bc74f9d6f6a8/e85cb/image-20230520165942146.png 480w,\n/static/1122ec328514bb95fca8bc74f9d6f6a8/38cea/image-20230520165942146.png 678w\"\n            sizes=\"(max-width: 678px) 100vw, 678px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/1122ec328514bb95fca8bc74f9d6f6a8/38cea/image-20230520165942146.png\"\n            alt=\"image-20230520165942146\"\n            title=\"image-20230520165942146\"\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>Reference: <a href=\"https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/registry-entries-for-silent-process-exit\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Monitoring Silent Process Exit - Windows drivers | Microsoft Learn</a></p>\n<p>Reference: <a href=\"https://jpwinsup.github.io/mslog/other/tips-tricks/findprocesskiller.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Finding the Process That Terminated a Process - Information Site for Collecting Windows Materials</a></p>\n<p>By the way, even if you set the debugger path in the Monitor Process setting, unfortunately you cannot attach a debugger to the process immediately before it exits.</p>\n<p>However, there seem to be many possible uses, such as launching a program that notifies you when a program exits or running a tool that collects system information immediately after the program ends.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary 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</h2>\n<p>This time, I summarized GFlags settings that are useful to remember when troubleshooting Windows.</p>\n<p>I only listed the settings that I personally find useful, but I would like to add more in the future if I discover others that prove useful in different situations.</p>","fields":{"slug":"/windbg-gflags-tutorial-en","tagSlugs":["/tag/win-dbg-en/","/tag/reversing-en/","/tag/english/"]},"frontmatter":{"date":"2023-05-20","description":"This article summarizes useful GFlags settings to remember when troubleshooting Windows. It covers settings such as debugger flags and Silent Process Exit that can help when investigating issues on Windows.","tags":["WinDbg (en)","Reversing (en)","English"],"title":"Notes on Useful GFlags Settings for Troubleshooting Windows Environments","socialImage":{"publicURL":"/static/e60d0aaf5c216e959ec0071df61c29af/windbg-gflags-tutorial.png"}}}},"pageContext":{"slug":"/windbg-gflags-tutorial-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}