{"componentChunkName":"component---src-templates-post-template-js","path":"/magical-windbg-vol2-05-en","result":{"data":{"markdownRemark":{"id":"cb741a13-3b5d-56fa-ba3e-686881b21646","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/magical-windbg-vol2-05\">original page</a>.</p>\n</blockquote>\n<p>In Chapters 3 and 4, we analyzed DoPClient and identified the password (the first Flag).</p>\n<p>As confirmed in Chapter 3, when the correct password is entered into DoPClient, the program prints the strings <code class=\"language-text\">Password is Correct</code> and <code class=\"language-text\">Clear Stage1</code> in sequence, then loads the kernel driver DoPDriver.sys and uses the CreateFileW function on the driver object.</p>\n<p>In Chapters 4 and 5, we analyze the kernel driver module DoPDriver in order to identify the second Flag.</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=\"#identifying-the-driverentry-function\">Identifying the DriverEntry Function</a></li>\n<li><a href=\"#analyzing-the-driverentry-function\">Analyzing the DriverEntry Function</a></li>\n<li><a href=\"#analyzing-the-dispatch-routine-callback-functions\">Analyzing the Dispatch Routine Callback Functions</a></li>\n<li><a href=\"#analyzing-the-irp_mj_create-callback-function\">Analyzing the <code class=\"language-text\">IRP_MJ_CREATE</code> Callback Function</a></li>\n<li><a href=\"#analyzing-the-irp_mj_close-callback-function\">Analyzing the <code class=\"language-text\">IRP_MJ_CLOSE</code> Callback Function</a></li>\n<li><a href=\"#analyzing-the-callback-function-registered-with-pssetcreateprocessnotifyroutine\">Analyzing the Callback Function Registered with PsSetCreateProcessNotifyRoutine</a></li>\n<li><a href=\"#analyzing-the-function-that-validates-the-image-file-name\">Analyzing the Function That Validates the Image File Name</a></li>\n<li><a href=\"#summary\">Summary</a></li>\n<li><a href=\"#links-to-the-chapters\">Links to the Chapters</a></li>\n</ul>\n<h2 id=\"identifying-the-driverentry-function\" style=\"position:relative;\"><a href=\"#identifying-the-driverentry-function\" aria-label=\"identifying the driverentry function 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>Identifying the DriverEntry Function</h2>\n<p>As confirmed in Chapter 2, the DoPDriver.sys file, which is a Windows kernel driver module, is also built as a file in PE format, just like a user-mode program.</p>\n<p>Therefore, DoPDriver.sys can also be statically analyzed with analysis tools such as Binary Ninja, just like DoPClient.exe.</p>\n<p>However, you need to be careful because a kernel driver module like DoPDriver has a slightly different structure from a user-mode program like DoPClient.</p>\n<p>For example, a user-mode program written in C starts from the main function, but Windows kernel drivers do not have a main function.</p>\n<p>In Windows kernel drivers, the DriverEntry function is configured as the entry point, and it is executed first when the kernel starts the driver module.<sup id=\"fnref-1\"><a href=\"#fn-1\" class=\"footnote-ref\">1</a></sup></p>\n<p>Therefore, when statically analyzing a kernel driver file, identifying this DriverEntry function first is one useful approach.</p>\n<p>The DriverEntry function of a Windows kernel driver module is defined as follows. The first argument is a pointer to a <code class=\"language-text\">DRIVER_OBJECT</code> structure, and the second argument is a pointer to the path string of the driver’s registry key.<sup id=\"fnref-2\"><a href=\"#fn-2\" class=\"footnote-ref\">2</a></sup></p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">DRIVER_INITIALIZE DriverEntry<span class=\"token punctuation\">;</span>\n\n_Use_decl_annotations_ NTSTATUS <span class=\"token function\">DriverEntry</span><span class=\"token punctuation\">(</span> \n<span class=\"token keyword\">struct</span> <span class=\"token class-name\">_DRIVER_OBJECT</span>  <span class=\"token operator\">*</span>DriverObject<span class=\"token punctuation\">,</span>\nPUNICODE_STRING  RegistryPath \n<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n    <span class=\"token comment\">// Function body</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>Note that the example above is code for creating a WDM (Windows Driver Model) driver, which has been available since Windows 98. However, the fact that the DriverEntry function is executed when the driver starts and that pointers to a <code class=\"language-text\">DRIVER_OBJECT</code> structure and a registry-key path string are passed as arguments is also common to KMDF/UMDF, which are supported from Windows Vista onward. (That said, KMDF and UMDF drivers require significantly different code from WDM drivers—for example, they must create a WDFDRIVER object with the WdfDriverCreate function.)<sup id=\"fnref-3\"><a href=\"#fn-3\" class=\"footnote-ref\">3</a></sup></p>\n<p>The easiest way to identify the DriverEntry function is to use an analysis tool such as Binary Ninja to find the entry point that receives DriverObject and RegistryPath as arguments, and then identify the function called with DriverObject as an argument.</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/8b9cf72cf2f92bffcbfa3ad2566db5c4/5df5d/driver-binary-ninja-013.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,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABxUlEQVQoz22R3W+aYBSHuZrpEr+WLVmCVURBBESsNlXLh5g008RSPgSkdTVLt2RX+//vfjsvq6TLdvHkHCDneX/nhVssl5hNRhhIEkRBgG7oGJsGjBG9G8hwbAue52HtreBYt7AsCzZVx6betrFYLDCfz0u4Xl/ExNTAtwV8/MxDMnVosyuoIxNdSYaqaSQeEAqGw2GBoigFb/sz3NTbYLkNod+uMbi2YK7vMPHuoC89TFdfYE5nNKhAVdV/hv8HJ7TbkPs9XFTe4X2lgnb/EkKvg08fmmDfdErIkmgkdNwVXMKmVR3HKXFdt4D13OxmgavrG8jygJChjXS6xxFJVBiGgfF4XJyskXh/zHB4fkQcx4iTBFl+oBojCAMEQQDf98HJNNiXJXToh3S6IgShg1arBZ7n0SLY/bF1NVVDlMdIScqG78MIfhRhs91is9mUcLV6HbVaDUUl6q/P1Wq1oNvtFumYNDmmyClhst8jzXLkTyf49z52u10J12w2SdJAo8Gov9Y/MLkoimXCw+kRzy8n5HmO76dv+PXjJ74ej0iyFNkhQ5qmZ+HfordClpAJGWzl5ClDGITYPTwgyvYI4whbWvvMb5ZrHYnkkjouAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/8ac56/driver-binary-ninja-013.webp 240w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/d3be9/driver-binary-ninja-013.webp 480w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/e46b2/driver-binary-ninja-013.webp 960w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/f992d/driver-binary-ninja-013.webp 1440w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/c6231/driver-binary-ninja-013.webp 1572w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/8ff5a/driver-binary-ninja-013.png 240w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/e85cb/driver-binary-ninja-013.png 480w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/d9199/driver-binary-ninja-013.png 960w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/07a9c/driver-binary-ninja-013.png 1440w,\n/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/5df5d/driver-binary-ninja-013.png 1572w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/8b9cf72cf2f92bffcbfa3ad2566db5c4/d9199/driver-binary-ninja-013.png\"\n            alt=\"The _start function in DoPDriver\"\n            title=\"The _start function in DoPDriver\"\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>However, in this chapter, we will try another approach that uses the characteristics of the DriverEntry function to identify its address.</p>\n<p>To identify the DriverEntry function by analyzing DoPDriver.sys, first load DoPDriver.sys into Binary Ninja and open the Symbols window.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 682px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/d757507cfc8080b0580af5e7f5ca2585/160a3/driver-binary-ninja-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: 131.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAEF0lEQVRIx4WV2U4jaQyFuZwAWViSkNTy175vSWUFJs0IGBT1NJpRi/d/lDO2i0qapqW+sGpJ5atj+9h18vDlC9bbW/zz73d8e33Fy8sLnp4esVgskGUZkiSRiONY4nh+vJ+mqZyv12uc7Pd77L+94ut/37G9u8d8PsdqtcJ2uxXobDaTWC1XWNJ1VVby+2JRo6L7y+USZVlKPD8/4+T+/h41Pbh7+AtPL3uJYlYjLSrk1Qz5bI6immPz5y12fz9gcbvChl7GL3YcB3ckYrvZ0rmN27u7BqhpOnzfx7yuJYVer4ezszOcnZ81R4qppSOcp9A9E6ZpYjKZoNPpwPU8+U+n8weKomiAlm0jiiKSv5KbV5eXGAwGuLi4kCOH8m3k6wpO7MF1XYHyiyOCZVmOPp1zCU52ux1MpeB7Pup6gTwvBMQP9/t9gvXlaLgKySIXoGVZ0CkrfoYzYzHdbhdVVTUKlTIRBw7yJKQIYBsTWPoN9MlIYP3+AIZDz1DKKrAboH4Ecsrd7nkDfHx8JKCC59oo8hxJHGE8usblxUCiBeoEjAhohc4B2CWgR5nF0Q/At7c3GIYBPwiQpJn4y6EacdGHw6HU76gwOwA1TTsqJGCvTZn9xgVOogBlnqLIUpj6lGAjXF8Pjym/19COXNhkF86KFYZhiDAI0T1/V8getEwdeWBQmKgiJWHpY4yHVxheXaJHUNOzkG9mCKoYtu0goIwGdJ8zGo1GYiEegBN2uiIgQ+axjSq2UKcOylAh9gy45kQUNsAKXkZNI5sxsP8OvBmPj8AFAVuFVdTAOGzjRlJqUz4oLKODwhY4/hHICk0CFpRuC0tc/WDotikC3FYN0PkN0DA0xAQpSSHXUWljjKh+jbHbLiukywIupayoyzwt/HtADflUQ9NoFBZUN47Q1nBDXux2e9IQ8aFNtqEucw2t3wGV1NBE6pvIfIUZNca3NJkUfTqSURRg3QDZMgcg2Wb8WaEmdUupq6mnY5bY0qCMXsCpc9o8KexDN/VFoUdbhu+zQh6AD0Aeoyj06SGXOm6I/3j8RtdXNA3H5cA1ZIVBGGA6ncqksEJZDq2x2TZKGchCC/M8RJ0HiBwd2s3wQ1OaLje24XRbhRGNHY/u6enpxxpmvkHGtiQ8NcU1TcgvgTIptnxDuLbNpAw/d5kno04cqZ+rJphQyp+AmyOQF0IDjBsfkkL+rhyA3Nk5wRpz2wfb/AwM32eZQa1CBnLK/JX8YBvuahYoAaZUAkfmmJoyeDf2qoRfhGIb3jAM5Ilh2zAwp336wTZcRw42N7+AzW5qI/kMaJZBPsxoUnxZdwHtQX6Z7wcH2xwUOraFMnZo07goIqpj6sl1SdcxGZ3/YAcusmWJoIhou3u02WOZEG4OL1suDdvmf0zK2jIGBV7QAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/d757507cfc8080b0580af5e7f5ca2585/8ac56/driver-binary-ninja-001.webp 240w,\n/static/d757507cfc8080b0580af5e7f5ca2585/d3be9/driver-binary-ninja-001.webp 480w,\n/static/d757507cfc8080b0580af5e7f5ca2585/57e27/driver-binary-ninja-001.webp 682w\"\n              sizes=\"(max-width: 682px) 100vw, 682px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/d757507cfc8080b0580af5e7f5ca2585/8ff5a/driver-binary-ninja-001.png 240w,\n/static/d757507cfc8080b0580af5e7f5ca2585/e85cb/driver-binary-ninja-001.png 480w,\n/static/d757507cfc8080b0580af5e7f5ca2585/160a3/driver-binary-ninja-001.png 682w\"\n            sizes=\"(max-width: 682px) 100vw, 682px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/d757507cfc8080b0580af5e7f5ca2585/160a3/driver-binary-ninja-001.png\"\n            alt=\"List of symbols in DoPDriver\"\n            title=\"List of symbols in DoPDriver\"\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 no symbols are present, you cannot find the DriverEntry function from the Symbols window.</p>\n<p>However, because the exported functions do not include <code class=\"language-text\">Wdf*</code> or <code class=\"language-text\">Wpp*</code>, we can judge that it is more likely a WDM driver than a KMDF/UMDF driver.</p>\n<p>For example, a simple KMDF driver looks like the following when analyzed in Binary Ninja. (This is not the DoPDriver.sys analysis 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: 485px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/a58a1636ed7d143aafe627d665da793e/44c61/driver-binary-ninja-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: 47.91666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABlElEQVQoz22SW3OCMBBGfe20goJ3JAEElATkqq3T//+7vu4Gi2j7kMkLnDlnN5NGhbiVMc5HiZJOdQpQ0L3bLGHZNmzLwnKzRv5ZofxuUHxV8KQHKSXatoXrupjSN8fjCVprTKosQBb7KAnE0IU7x9v7B2yCzWazHrhe4dTkUF1Ot4Y4CAhfoK7rARjHCZTKMGHDPBXo8gNqgm9WCzjzmYGNgVlXkGUJfS3hhz6EkGjIcMHAqYU0PZKhwoStsnhPdoEBFgQ/yB2268U92e6BbQ/kex/s4ZNhVVdk6AyGWZb1QJ30yWxbnmh+BHtNZpC+nCm7gIilMaybpjekb5IkhVbqAWx0ZJYS+JsnoHUHqlEyG5pkAv7OcEjmRJ6hosWwYRrsEBHUcebmw3Gyvp7N8WgkffJjKWyoOLkmSMupNMNLEdEMJS55RHPcYrV0n5bCMDb1I38w/JPc0c+a7BjU0FKS0MN+u6SzMsd+Sc7pHQZpaAzHwCH5VibodGiSOT1PBJLAQ0xZ/IT4STwthY4x5Hf4j+EPN3oUY6dd9JkAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/a58a1636ed7d143aafe627d665da793e/8ac56/driver-binary-ninja-002.webp 240w,\n/static/a58a1636ed7d143aafe627d665da793e/d3be9/driver-binary-ninja-002.webp 480w,\n/static/a58a1636ed7d143aafe627d665da793e/749af/driver-binary-ninja-002.webp 485w\"\n              sizes=\"(max-width: 485px) 100vw, 485px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/a58a1636ed7d143aafe627d665da793e/8ff5a/driver-binary-ninja-002.png 240w,\n/static/a58a1636ed7d143aafe627d665da793e/e85cb/driver-binary-ninja-002.png 480w,\n/static/a58a1636ed7d143aafe627d665da793e/44c61/driver-binary-ninja-002.png 485w\"\n            sizes=\"(max-width: 485px) 100vw, 485px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/a58a1636ed7d143aafe627d665da793e/44c61/driver-binary-ninja-002.png\"\n            alt=\"Example symbol list for a KMDF driver\"\n            title=\"Example symbol list for a KMDF driver\"\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 WDM drivers, as a rule, one or more device objects representing devices must first be created in DriverEntry.<sup id=\"fnref-4\"><a href=\"#fn-4\" class=\"footnote-ref\">4</a></sup></p>\n<p>Because device objects are created with the IoCreateDevice function <sup id=\"fnref-5\"><a href=\"#fn-5\" class=\"footnote-ref\">5</a></sup>, in many cases you can identify the code executed by the DriverEntry function by checking where this API function is called.</p>\n<p>If you are using Binary Ninja, click IoCreateDevice in the .rdata section of the Symbols window.</p>\n<p>Then the address 0x1400011cc appears in the [Code References] area of the Cross References window.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 788px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/84231d4d2c2bef85a91342120d314663/ea7fb/driver-binary-ninja-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: 40.416666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABmUlEQVQoz22QzU/CUBDEexEKDSeFlraU0iqlhQBCVRQRQaVQJIoJiQcTI2I0kviJ8c8f97WiBz38MrOzs3nJ4ybXM4yvpuj0T9EbncMfT3DoDbHXOUGz20O756N90sduu0udIfaPPLSO+zgg2H5J69jD+PIKnH8zx2j6iLPbOYbTJ3jTFwxmb/Dv3jEgRg8LjOcLnN6/4mL+idH9B7HAGeVs738zuHtD7+YZXEKIIxHnA4RYFHw08kskghgfhUAdQYjRng9mRpw8H1n56S1vOC2rQ85oyJCqmgZVVf+ihKoov5nyT0+je67V7qDr+WgeHmGn2UK97qLuuqEucUPcIK8HuD+dcK7Vamg0GuCqm1Uy29jacVGtlOAUNmBbGyjaefJ5UgslOx/MlmXBcRzYto2ClYddsALPMkalXAFnUVCml9y9JpyiDTOnwchlSUPWDZ1gXoeu6zBNE4ZhkM8iRzBvUGaSloolcClRgkR/qJo5yEoamXQKkiQimUxCJZ+RU5DTElKUiaJIf6dQT4ZI2WpyLVA2s5ztvwByjvSFELFa/AAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/84231d4d2c2bef85a91342120d314663/8ac56/driver-binary-ninja-003.webp 240w,\n/static/84231d4d2c2bef85a91342120d314663/d3be9/driver-binary-ninja-003.webp 480w,\n/static/84231d4d2c2bef85a91342120d314663/4d911/driver-binary-ninja-003.webp 788w\"\n              sizes=\"(max-width: 788px) 100vw, 788px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/84231d4d2c2bef85a91342120d314663/8ff5a/driver-binary-ninja-003.png 240w,\n/static/84231d4d2c2bef85a91342120d314663/e85cb/driver-binary-ninja-003.png 480w,\n/static/84231d4d2c2bef85a91342120d314663/ea7fb/driver-binary-ninja-003.png 788w\"\n            sizes=\"(max-width: 788px) 100vw, 788px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/84231d4d2c2bef85a91342120d314663/ea7fb/driver-binary-ninja-003.png\"\n            alt=\"Code References screen\"\n            title=\"Code References screen\"\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>Clicking this address reveals a function that receives a pointer to a <code class=\"language-text\">DRIVER_OBJECT</code> structure as an argument and calls the IoCreateDevice function.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 890px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/c89148b9d19e03704989b8a11c40bcc2/4ef49/driver-binary-ninja-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: 51.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABr0lEQVQoz22SbW6jMBiEuUvUhAABDPgLg01CSUkr9f63mR07irTazY8RwjbjZ+YlC+uCOcxY/IR5crBuxuQX+HlKa8HP8MFjmiaM4whjDIy1z+cbZe7TQ80GfT+gaVrkpxP6roMQlFRQVqNXCmIYUBQFjh8fOB2PyPP8rbLxNkPTUGudCLq+h5QSgqYuUpFUk1Q7anTotYEcLcqyTBf8q8yEEYOVUKSIRufzGR3pmraFjGtGQ7MKQ3NlLC6NoFp+fE5n/zOc7oEENhHGDireHOMLIWCcI5VFx72Wa9GoqhtUl/otXTJ06ww1PSNHyrquadgnQ8uYlqaGQ+m0palEHdV2OLOvqJyUr/4icYqsnE5xLacXjTr21zKyZl+K1JI9mhAwMLIyIy/xMOyz46AigODZlvSX6sKhkFA6legGHjgcDmnCTdOk30MxsvYjHAdj2WXLC5tOQCiJggZlUSajqqqehPffHbfHimW5Yts2GksE0gTv8dgfuO87vn42fD823L+2ZGxS389UEeKl+J5d9xX+c4FjhEgZ+3PsLSqsN/grhyYHGDVA8Rn3X/rb7KU/w8VC+07gMMkAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/c89148b9d19e03704989b8a11c40bcc2/8ac56/driver-binary-ninja-004.webp 240w,\n/static/c89148b9d19e03704989b8a11c40bcc2/d3be9/driver-binary-ninja-004.webp 480w,\n/static/c89148b9d19e03704989b8a11c40bcc2/8d1ba/driver-binary-ninja-004.webp 890w\"\n              sizes=\"(max-width: 890px) 100vw, 890px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/c89148b9d19e03704989b8a11c40bcc2/8ff5a/driver-binary-ninja-004.png 240w,\n/static/c89148b9d19e03704989b8a11c40bcc2/e85cb/driver-binary-ninja-004.png 480w,\n/static/c89148b9d19e03704989b8a11c40bcc2/4ef49/driver-binary-ninja-004.png 890w\"\n            sizes=\"(max-width: 890px) 100vw, 890px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/c89148b9d19e03704989b8a11c40bcc2/4ef49/driver-binary-ninja-004.png\"\n            alt=\"Identifying the DriverEntry function\"\n            title=\"Identifying the DriverEntry function\"\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 function is DriverEntry, so rename it if necessary.</p>\n<p>At this point, we have identified the DriverEntry function.</p>\n<p>Also, if a device driver implements an IOCTL interface <sup id=\"fnref-6\"><a href=\"#fn-6\" class=\"footnote-ref\">6</a></sup>, it should register an IOCTL dispatch routine in DriverEntry to handle each IOCTL request.</p>\n<p>An IOCTL dispatch routine is registered with assembly code such as <code class=\"language-text\">mov  qword [rcx+0x70], &lt;function pointer of the dispatch routine></code> starting at offset 0x70 of the <code class=\"language-text\">DRIVER_OBJECT</code> structure <sup id=\"fnref-7\"><a href=\"#fn-7\" class=\"footnote-ref\">7</a></sup>.<sup id=\"fnref-8\"><a href=\"#fn-8\" class=\"footnote-ref\">8</a></sup></p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">typedef</span> <span class=\"token keyword\">struct</span> <span class=\"token class-name\">_DRIVER_OBJECT</span> <span class=\"token punctuation\">{</span>\n  CSHORT             Type<span class=\"token punctuation\">;</span>\n  CSHORT             Size<span class=\"token punctuation\">;</span>\n  PDEVICE_OBJECT     DeviceObject<span class=\"token punctuation\">;</span>\n  ULONG              Flags<span class=\"token punctuation\">;</span>\n  PVOID              DriverStart<span class=\"token punctuation\">;</span>\n  ULONG              DriverSize<span class=\"token punctuation\">;</span>\n  PVOID              DriverSection<span class=\"token punctuation\">;</span>\n  PDRIVER_EXTENSION  DriverExtension<span class=\"token punctuation\">;</span>\n  UNICODE_STRING     DriverName<span class=\"token punctuation\">;</span>\n  PUNICODE_STRING    HardwareDatabase<span class=\"token punctuation\">;</span>\n  PFAST_IO_DISPATCH  FastIoDispatch<span class=\"token punctuation\">;</span>\n  PDRIVER_INITIALIZE DriverInit<span class=\"token punctuation\">;</span>\n  PDRIVER_STARTIO    DriverStartIo<span class=\"token punctuation\">;</span>\n  PDRIVER_UNLOAD     DriverUnload<span class=\"token punctuation\">;</span>\n  PDRIVER_DISPATCH   MajorFunction<span class=\"token punctuation\">[</span>IRP_MJ_MAXIMUM_FUNCTION <span class=\"token operator\">+</span> <span class=\"token number\">1</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span> DRIVER_OBJECT<span class=\"token punctuation\">,</span> <span class=\"token operator\">*</span>PDRIVER_OBJECT<span class=\"token punctuation\">;</span></code></pre></div>\n<p>Therefore, another possible way to identify the DriverEntry function is to look for code that accesses offset 0x70 of the <code class=\"language-text\">DRIVER_OBJECT</code> structure.</p>\n<p>If you are using Binary Ninja, first click the <code class=\"language-text\">{T}</code> icon in the menu on the left side of the screen to open the Types window.</p>\n<p>There, search for the <code class=\"language-text\">DRIVER_OBJECT</code> structure and click it to display its information.</p>\n<p>After clicking <code class=\"language-text\">PDRIVER_DISPATCH MajorFunction[***];</code> at offset 0x70 of the <code class=\"language-text\">DRIVER_OBJECT</code> structure and then checking the Code References window, you can confirm that it shows the address of the DriverEntry function we renamed earlier.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 950px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/36fe303c861819a4a0fad2df0ac85c76/906b5/driver-binary-ninja-005.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,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABsklEQVQoz32S3baaMBCFeQAVPeVXgRCBAyHyr3Iq2Gq77OpFz/s/zu4ktWv1pufiW0kGZmcye4z7/Y6fv94xTTNutxvmeUZd1zgej6iqCmwfw/dcZDzUJJwhjDmCMITnebBtG47jwLIsHA4HGNPlgkpKdF2Hvu8hyxLb7Ra+7yNiEXiewnUs1DkjIuR5gkSU4NkrbBIyTRObzQar1QpBEMAYxxFv42ddmdrHcYyQbmeM4dDXyKoCHgn2kqMvY8hCCUrw15yE1lpwvV5juVzqHON8PiNLUpRUmSgK7HY7/ZTFYkEV2GjHAaXIMZ1qvA0Sl/GE9+8/8O0yIRcFkjRFSnDO0bYtjOv1irob0AwnVF2v+6BQF0hqRdM2z7OEUDHiQHENxeVzVf8PwwDj8Xhg/nLD9PWOlgRVlUIohKZQZ6IshU7SL/mL+CdG+7ahCpumgR/FSKRAnHGE1Idovyd39wiikL5RLBOwbEf3ShnwPxxy3PjjrEDfVXRTTs4yMDJGEUURidKYME69DbT7H8EpR1fo+R52gQ+2c7F1Lbhkiktj84lmy6RxMM0V1k83P+Jl84LfIYn+WWqpgccAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/36fe303c861819a4a0fad2df0ac85c76/8ac56/driver-binary-ninja-005.webp 240w,\n/static/36fe303c861819a4a0fad2df0ac85c76/d3be9/driver-binary-ninja-005.webp 480w,\n/static/36fe303c861819a4a0fad2df0ac85c76/4a41d/driver-binary-ninja-005.webp 950w\"\n              sizes=\"(max-width: 950px) 100vw, 950px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/36fe303c861819a4a0fad2df0ac85c76/8ff5a/driver-binary-ninja-005.png 240w,\n/static/36fe303c861819a4a0fad2df0ac85c76/e85cb/driver-binary-ninja-005.png 480w,\n/static/36fe303c861819a4a0fad2df0ac85c76/906b5/driver-binary-ninja-005.png 950w\"\n            sizes=\"(max-width: 950px) 100vw, 950px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/36fe303c861819a4a0fad2df0ac85c76/906b5/driver-binary-ninja-005.png\"\n            alt=\"Identifying the DriverEntry function from structure information\"\n            title=\"Identifying the DriverEntry function from structure information\"\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 this way, information from structures and similar sources can sometimes also be used to refer to the address of the function you want to identify.</p>\n<h2 id=\"analyzing-the-driverentry-function\" style=\"position:relative;\"><a href=\"#analyzing-the-driverentry-function\" aria-label=\"analyzing the driverentry function 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>Analyzing the DriverEntry Function</h2>\n<p>Now that we have identified the address of the DriverEntry function, we can analyze its execution code in Binary Ninja’s Graph view, just as we did in Chapter 3.</p>\n<p>The following is the disassembly of the DriverEntry function shown in Graph view.</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/063abcc6a605c746d5a9a9c8d8f4726c/e4900/driver-binary-ninja-006.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: 88.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACrElEQVQ4y41U23aiQBD0Y9aoKLpxvQGCUaMRhssAI6DmZP//K2p7GsXc9pw81GluU1NdNU3LMAxodDod2O4S5dsrVHFEmmfIqapCIVc5EpkgSZK6XpFlGZ53z+h2u7jxtBrChw4cjwj/nmqCNMWxKiGVouscYRhCRCGCIIDv+wwhBJ7Wa3R7ve8JbddB8VYhI3VpmjGhOlcoLxdkxwJxnjPJV8L/KLS9O6EkQlUWSKitME4gCEEUN2Q/JtQt3wiPFZFXJySK1NF9TK1H4b3tn7ec6ZZTVpifKhSXM/l6pJDonjaIE4mY1KYyxWa7/aiwd2XXKTehkFcqVyhPJ5TnI87nEpmi1imU8F0wOqj1Zo3eZ4X6QftXG9bSgnotqF0JmaUUhEIchwSBQAQ4HA41/AP8wGdib+XhofPAR0eDFY5GIzyOHzGZTGA5NhaWhQVVZ+XyvbNcwrFt2NaCYHGdTP5guXSwdBxMad14PGaelm5157+gfK1ISQxJvuTkXVYVUHRsUvJThxSTag7i2u5wOMR2/0zph3Xqwof3tKoJ9+KAiryTUrL5JZ296updQZMS0kYhvRNhxGFEVLWaZkIGA7ZNo6XT3QUvDWFGSWr/IvIsCgVCcZ8M7VnwTuGNsD8wa8JbKPP5HDZ7RZ54Lhya6fliAUt7Se809DfT6QzT2QwzgmmaTbo3Qk7ZpJ1W2w1czyOsGJpoT6qPl4LOmqSfguQqZUTX1Db9JFzX5aP2hbCRS9AnXrfRbrex2W0oGEUhCA4kljECCs9nHHjT7wnNIT/o9wdU7xjo5/TMMPr83hw9om+OMBj+xvD3mMHr+Pt3hHqB0f8ITdTt9rCiKRBJiAOp9CP6OcQRtrtdvRkLGdRrrsPRjN5n3EZxtXliwv1+zxCRwIY2MYzv1+j6D34Ja2bAjOFbAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/063abcc6a605c746d5a9a9c8d8f4726c/8ac56/driver-binary-ninja-006.webp 240w,\n/static/063abcc6a605c746d5a9a9c8d8f4726c/d3be9/driver-binary-ninja-006.webp 480w,\n/static/063abcc6a605c746d5a9a9c8d8f4726c/e46b2/driver-binary-ninja-006.webp 960w,\n/static/063abcc6a605c746d5a9a9c8d8f4726c/6257a/driver-binary-ninja-006.webp 988w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/063abcc6a605c746d5a9a9c8d8f4726c/8ff5a/driver-binary-ninja-006.png 240w,\n/static/063abcc6a605c746d5a9a9c8d8f4726c/e85cb/driver-binary-ninja-006.png 480w,\n/static/063abcc6a605c746d5a9a9c8d8f4726c/d9199/driver-binary-ninja-006.png 960w,\n/static/063abcc6a605c746d5a9a9c8d8f4726c/e4900/driver-binary-ninja-006.png 988w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/063abcc6a605c746d5a9a9c8d8f4726c/d9199/driver-binary-ninja-006.png\"\n            alt=\"Graph view of the DriverEntry function\"\n            title=\"Graph view of the DriverEntry function\"\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 first block creates a device object with the IoCreateDevice function.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">DriverEntry:\nmov     r11, rsp {__return_addr}\npush    rbx {__saved_rbx}\nsub     rsp, 0x60\nlea     rax, [rel sub_140001280]\nmov     dword [rsp+0x40 {DeviceName}], 0x240022\nmov     qword [rcx+0x68], rax  {sub_140001280}\nlea     r8, [r11-0x28 {DeviceName}]\nlea     rax, [rel sub_1400011a0]\nmov     r9d, 0x22\nmov     qword [rcx+0x70], rax  {sub_1400011a0}\nxor     edx, edx  {0x0}\nlea     rax, [rel sub_140001180]\nmov     qword [rcx+0x80], rax  {sub_140001180}\nlea     rax, [rel data_140001590]  {u\"\\Device\\DoPDriver\"}\nmov     qword [r11-0x20 {var_20}], rax  {data_140001590, u\"\\Device\\DoPDriver\"}\nlea     rax, [r11+0x8 {DeviceObject}]\nmov     qword [r11-0x38 {var_38}], rax {DeviceObject}\nmov     byte [rsp+0x28 {var_40}], 0x0\nand     dword [rsp+0x20 {var_48}], 0x0\ncall    qword [rel IoCreateDevice]\ntest    eax, eax\njns     0x140001238</code></pre></div>\n<p>The IoCreateDevice function takes the following arguments and creates the device object used by the driver.<sup id=\"fnref-5\"><a href=\"#fn-5\" class=\"footnote-ref\">5</a></sup></p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">NTSTATUS <span class=\"token function\">IoCreateDevice</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>           PDRIVER_OBJECT  DriverObject<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>           ULONG           DeviceExtensionSize<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">,</span> optional<span class=\"token punctuation\">]</span> PUNICODE_STRING DeviceName<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>           DEVICE_TYPE     DeviceType<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>           ULONG           DeviceCharacteristics<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>           BOOLEAN         Exclusive<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>out<span class=\"token punctuation\">]</span>          PDEVICE_OBJECT  <span class=\"token operator\">*</span>DeviceObject\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Clicking the IoCreateDevice function in Binary Ninja’s Graph view is very convenient because it analyzes the arguments for you in the Cross References window, 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: 801px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/c470f7d63fb69cd8aed6bb0b5af39979/2ad15/driver-binary-ninja-007.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,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAnElEQVQY053KSw6CMBRGYXbAgJaW0jICI2ACJaDBZxxo4v4XdAQ0OmdwBv93b3B7vhjvD/bHC13Xrc57zziOBNfzicPQ49uWbVlSVdWq6rqmbRqCne9p+4FiU+BsinMOay2Z+/ezLFuy8558NreYW7zIcwKhNcoaYiWwWqBiiRAR5ruNltMtRkhJYhKSNEHOOxZE09/HDEorwjDkDVe6cwcNUA/fAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/c470f7d63fb69cd8aed6bb0b5af39979/8ac56/driver-binary-ninja-007.webp 240w,\n/static/c470f7d63fb69cd8aed6bb0b5af39979/d3be9/driver-binary-ninja-007.webp 480w,\n/static/c470f7d63fb69cd8aed6bb0b5af39979/99a1d/driver-binary-ninja-007.webp 801w\"\n              sizes=\"(max-width: 801px) 100vw, 801px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/c470f7d63fb69cd8aed6bb0b5af39979/8ff5a/driver-binary-ninja-007.png 240w,\n/static/c470f7d63fb69cd8aed6bb0b5af39979/e85cb/driver-binary-ninja-007.png 480w,\n/static/c470f7d63fb69cd8aed6bb0b5af39979/2ad15/driver-binary-ninja-007.png 801w\"\n            sizes=\"(max-width: 801px) 100vw, 801px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/c470f7d63fb69cd8aed6bb0b5af39979/2ad15/driver-binary-ninja-007.png\"\n            alt=\"Values passed as arguments to IoCreateDevice\"\n            title=\"Values passed as arguments to IoCreateDevice\"\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 first argument, arg1, uses the pointer to the <code class=\"language-text\">DRIVER_OBJECT</code> structure that the DriverEntry function received as an argument.</p>\n<p>Also, DeviceName uses the name of the device object defined inside the function.</p>\n<p>At this point, note that the string used as DeviceName is a pointer to an object of the <code class=\"language-text\">UNICODE_STRING</code> structure <sup id=\"fnref-9\"><a href=\"#fn-9\" class=\"footnote-ref\">9</a></sup>.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">typedef</span> <span class=\"token keyword\">struct</span> <span class=\"token class-name\">_UNICODE_STRING</span> <span class=\"token punctuation\">{</span>\n  USHORT Length<span class=\"token punctuation\">;</span>\n  USHORT MaximumLength<span class=\"token punctuation\">;</span>\n  PWSTR  Buffer<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span> UNICODE_STRING<span class=\"token punctuation\">,</span> <span class=\"token operator\">*</span>PUNICODE_STRING<span class=\"token punctuation\">;</span></code></pre></div>\n<p>Many functions used by Windows kernel drivers use safe string objects, such as the <code class=\"language-text\">UNICODE_STRING</code> structure, that take proper buffer handling into account from the standpoint of software safety.<sup id=\"fnref-10\"><a href=\"#fn-10\" class=\"footnote-ref\">10</a></sup></p>\n<p>As mentioned above, a string represented by a <code class=\"language-text\">UNICODE_STRING</code> structure is not a simple string. It is passed to functions such as IoCreateDevice as a structure that includes elements such as the buffer size.</p>\n<p>For that reason, you need to keep this point in mind especially when performing dynamic analysis with a debugger.</p>\n<p>Let’s actually read the code that prepares DeviceName, which is an argument to IoCreateDevice.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">mov     r11, rsp {__return_addr}\npush    rbx {__saved_rbx}\nsub     rsp, 0x60\n***\nmov     dword [rsp+0x40 {DeviceName}], 0x240022\n***\nlea     r8, [r11-0x28 {DeviceName}]\n***\nlea     rax, [rel data_140001590]  {u\"\\Device\\DoPDriver\"}\nmov     qword [r11-0x20 {var_20}], rax  {data_140001590, u\"\\Device\\DoPDriver\"}</code></pre></div>\n<p>Binary Ninja interprets the stack area at address <code class=\"language-text\">RSP+0x40</code> as DeviceName.</p>\n<p>However, in the code <code class=\"language-text\">mov  dword [rsp+0x40 {DeviceName}], 0x240022</code>, the value stored in that area is 0x240022 rather than a string.</p>\n<p>This is because, as explained earlier, DeviceName is defined not as a plain string but as an object of the <code class=\"language-text\">UNICODE_STRING</code> structure.</p>\n<p>In a <code class=\"language-text\">UNICODE_STRING</code> structure, the first 2 bytes store Length and the next 2 bytes store MaximumLength.</p>\n<p>In other words, storing 0x240022 in the stack area at <code class=\"language-text\">RSP+0x40</code> corresponds to writing a <code class=\"language-text\">UNICODE_STRING</code> structure whose Length is 0x22 and whose MaximumLength is 0x24.</p>\n<p>The pointer to the actual string (<code class=\"language-text\">\\Device\\DoPDriver</code>) is stored in the Buffer field of the <code class=\"language-text\">UNICODE_STRING</code> structure.</p>\n<p>You can also confirm this by running the <code class=\"language-text\">dt nt!_UNICODE_STRING rsp+0x40</code> command when dynamically analyzing the DriverEntry function during kernel debugging.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">kd> dt nt!_UNICODE_STRING rsp+0x40\n<span class=\"token operator\">*</span><span class=\"token operator\">*</span><span class=\"token operator\">*</span>\n<span class=\"token operator\">+</span>0x000 Length           : 0x22\n<span class=\"token operator\">+</span>0x002 MaximumLength    : 0x24\n<span class=\"token operator\">+</span>0x008 Buffer           : 0xfffff807`100a1590  <span class=\"token string\">\"\\Device\\DoPDriver\"</span></code></pre></div>\n<p>Also, DeviceType, the argument after DeviceName, receives a value indicating the device type.</p>\n<p>In DoPDriver, DeviceType is set to 0x22, which corresponds to <code class=\"language-text\">FILE_DEVICE_UNKNOWN</code>, indicating that it is not a standard Windows device.<sup id=\"fnref-11\"><a href=\"#fn-11\" class=\"footnote-ref\">11</a></sup></p>\n<p>When the IoCreateDevice function is called with these arguments, a pointer to the <code class=\"language-text\">DEVICE_OBJECT</code> structure is stored at the address pointed to by the DeviceObject argument.</p>\n<p>If creating the device object succeeds, the following code after 0x140001238 is executed.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">lea     rax, [rel data_140001570]  {u\"\\??\\DoPDriver\"}\nmov     dword [rsp+0x50 {SymbolicLinkName}], 0x1c001a\nlea     rdx, [rsp+0x40 {DeviceName}]\nmov     qword [rsp+0x58 {var_10_1}], rax  {data_140001570, u\"\\??\\DoPDriver\"}\nlea     rcx, [rsp+0x50 {SymbolicLinkName}]\ncall    qword [rel IoCreateSymbolicLink]\nmov     ebx, eax\ntest    eax, eax\njns     0x140001274</code></pre></div>\n<p>This code uses the IoCreateSymbolicLink function <sup id=\"fnref-12\"><a href=\"#fn-12\" class=\"footnote-ref\">12</a></sup> to create a symbolic link (<code class=\"language-text\">\\??\\DoPDriver</code>) corresponding to the device object.</p>\n<p>The actual device object created by the IoCreateDevice function exists at <code class=\"language-text\">\\Device\\DoPDriver</code>, but as explained in Chapter 3, a user-mode process cannot directly access device objects in the <code class=\"language-text\">\\Device</code> directory.</p>\n<p>Therefore, if a user-mode program such as DoPClient needs to access the driver, the kernel driver must create a symbolic link in the <code class=\"language-text\">\\GLOBAL\\??</code> directory and link it to the name of the device object in the <code class=\"language-text\">\\Device</code> directory.</p>\n<p>In the code above, the symbolic link for the device object at <code class=\"language-text\">\\Device\\DoPDriver</code> is registered as <code class=\"language-text\">\\??\\DoPDriver</code>.</p>\n<h2 id=\"analyzing-the-dispatch-routine-callback-functions\" style=\"position:relative;\"><a href=\"#analyzing-the-dispatch-routine-callback-functions\" aria-label=\"analyzing the dispatch routine callback functions 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>Analyzing the Dispatch Routine Callback Functions</h2>\n<p>In the DriverEntry function, only the device object was created and the symbolic link for that device object was registered.</p>\n<p>So where is the code that runs when the user-mode program DoPClient uses DoPDriver?</p>\n<p>In the case of WDM drivers, the interface commonly used to execute driver operations in response to requests from applications is the dispatch routine defined by the entries in the MajorFunction array of the driver object.</p>\n<p>The MajorFunction array of the driver object contains callback functions corresponding to open (CreateFile) and close (CloseHandle), as well as read and write (ReadFile/WriteFile), and DeviceIoControl operations from user-mode programs.</p>\n<p>When a user-mode program performs these operations on a device driver, the system’s I/O manager allocates an I/O Request Packet (IRP) and executes the driver’s dispatch routine corresponding to that request.<sup id=\"fnref-13\"><a href=\"#fn-13\" class=\"footnote-ref\">13</a></sup></p>\n<p>As confirmed earlier in this chapter, the MajorFunction array is defined as <code class=\"language-text\">PDRIVER_DISPATCH MajorFunction[***];</code> starting at offset 0x70 of the <code class=\"language-text\">DRIVER_OBJECT</code> structure.</p>\n<p>In DoPDriver, the callback functions for two dispatch routines were set in the driver object at 0x1400011f8 and 0x1400011fe in the DriverEntry function.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">mov     qword [rcx+0x70], rax  {sub_1400011a0}\n***\nmov     qword [rcx+0x80], rax  {sub_140001180}</code></pre></div>\n<p>The MajorFunction array is defined as <code class=\"language-text\">PDRIVER_DISPATCH MajorFunction[***];</code>, and in a C implementation it would be written as <code class=\"language-text\">DriverObject->MajorFunction[IRP_MJ_CREATE] = &lt;pointer to the callback function></code>.</p>\n<p>Constants such as <code class=\"language-text\">IRP_MJ_CREATE</code> and <code class=\"language-text\">IRP_MJ_CLOSE</code> are defined in wdm.h and correspond to the following values.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">IRP_MJ_CREATE                   0x00\nIRP_MJ_CREATE_NAMED_PIPE        0x01\nIRP_MJ_CLOSE                    0x02\nIRP_MJ_READ                     0x03\nIRP_MJ_WRITE                    0x04\nIRP_MJ_QUERY_INFORMATION        0x05\nIRP_MJ_SET_INFORMATION          0x06\nIRP_MJ_QUERY_EA                 0x07\nIRP_MJ_SET_EA                   0x08\nIRP_MJ_FLUSH_BUFFERS            0x09\nIRP_MJ_QUERY_VOLUME_INFORMATION 0x0a\nIRP_MJ_SET_VOLUME_INFORMATION   0x0b\nIRP_MJ_DIRECTORY_CONTROL        0x0c\nIRP_MJ_FILE_SYSTEM_CONTROL      0x0d\nIRP_MJ_DEVICE_CONTROL           0x0e\nIRP_MJ_INTERNAL_DEVICE_CONTROL  0x0f\nIRP_MJ_SHUTDOWN                 0x10\nIRP_MJ_LOCK_CONTROL             0x11\nIRP_MJ_CLEANUP                  0x12\nIRP_MJ_CREATE_MAILSLOT          0x13\nIRP_MJ_QUERY_SECURITY           0x14\nIRP_MJ_SET_SECURITY             0x15\nIRP_MJ_POWER                    0x16\nIRP_MJ_SYSTEM_CONTROL           0x17\nIRP_MJ_DEVICE_CHANGE            0x18\nIRP_MJ_QUERY_QUOTA              0x19\nIRP_MJ_SET_QUOTA                0x1a\nIRP_MJ_PNP                      0x1b\nIRP_MJ_PNP_POWER                IRP_MJ_PNP\nIRP_MJ_MAXIMUM_FUNCTION         0x1b</code></pre></div>\n<p>In other words, because DoPDriver registers dispatch routines at <code class=\"language-text\">RCX+0x70</code> and <code class=\"language-text\">RCX+0x80</code>, we can determine that <code class=\"language-text\">DriverObject->MajorFunction[0(IRP_MJ_CREATE)]</code> and <code class=\"language-text\">DriverObject->MajorFunction[2(IRP_MJ_CLOSE)]</code> are implemented.</p>\n<h2 id=\"analyzing-the-irp_mj_create-callback-function\" style=\"position:relative;\"><a href=\"#analyzing-the-irp_mj_create-callback-function\" aria-label=\"analyzing the irp_mj_create callback function 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>Analyzing the <code class=\"language-text\">IRP_MJ_CREATE</code> Callback Function</h2>\n<p>The callback function registered in <code class=\"language-text\">DriverObject->MajorFunction[0(IRP_MJ_CREATE)]</code> is at address 0x1400011a0.</p>\n<p>The result of analyzing this function in Binary Ninja’s Graph view is 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: 524px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/59dde0be8f82114e49a96a3fba91bd4c/664c8/driver-binary-ninja-008.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,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABb0lEQVQoz32S2W6DMBBF+bW0SVi9r0BRVpoofetD+vm3g0OqVon6cGWLMYczY7KiqlFzhUZ7NMaj4gJFniP/J0VRPE1Zlsi4VuhPO7ihg44BbdejqipoY+GCh+08pFFggqFhDIyzVH+WpmmQNYKjPfQEM1BWIYaYvmScQ4gRxnsod6sJKSC0mAFlWqez99R1jYzRoW4cyMRBe4MY/wK18/TcEVSTpQAjYEH1orhB7naPwJ5eJJPJsKKiI1jsOlgf4KNDPwRYxaEVg5EMSjRg1OId+gs4tfxGQDIki8mwrqsECm0L6wgYLLrWIhgOr/nPKud51nPmGTLEaYatgTCSDEO6Sa40uNbUdgCjCyqtR24i1spjzSQWr0ssliu8rNZzVmkUmYsep88LNuMWw2bA+XxOltv9AePpHfvTEeNug+thh6/x8JBryp72R2xoRFlJqoZakvT7SCVhrQXnHMaYtFdk2TqLSxf/zUdP46H7+AZygmGL3fHhSQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/59dde0be8f82114e49a96a3fba91bd4c/8ac56/driver-binary-ninja-008.webp 240w,\n/static/59dde0be8f82114e49a96a3fba91bd4c/d3be9/driver-binary-ninja-008.webp 480w,\n/static/59dde0be8f82114e49a96a3fba91bd4c/1c5aa/driver-binary-ninja-008.webp 524w\"\n              sizes=\"(max-width: 524px) 100vw, 524px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/59dde0be8f82114e49a96a3fba91bd4c/8ff5a/driver-binary-ninja-008.png 240w,\n/static/59dde0be8f82114e49a96a3fba91bd4c/e85cb/driver-binary-ninja-008.png 480w,\n/static/59dde0be8f82114e49a96a3fba91bd4c/664c8/driver-binary-ninja-008.png 524w\"\n            sizes=\"(max-width: 524px) 100vw, 524px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/59dde0be8f82114e49a96a3fba91bd4c/664c8/driver-binary-ninja-008.png\"\n            alt=\"Function at address 0x1400011a0\"\n            title=\"Function at address 0x1400011a0\"\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\">IofCompleteRequest</code> function <sup id=\"fnref-14\"><a href=\"#fn-14\" class=\"footnote-ref\">14</a></sup> called first is a macro that completes I/O processing and returns the IRP received by the driver to the I/O manager.</p>\n<p>This code appears to return the IRP immediately without performing any I/O processing, but if a device driver uses an IRP, some operation is performed on that IRP before <code class=\"language-text\">IofCompleteRequest</code> is executed.</p>\n<p>Besides IofCompleteRequest, this callback function also executes the PsSetCreateProcessNotifyRoutine function <sup id=\"fnref-15\"><a href=\"#fn-15\" class=\"footnote-ref\">15</a></sup>.</p>\n<p>PsSetCreateProcessNotifyRoutine is a function that can add or remove a callback routine specified by the device driver to the routines executed each time a process is created or deleted.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">NTSTATUS <span class=\"token function\">PsSetCreateProcessNotifyRoutine</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> BOOLEAN                        Remove\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>By using this function, a device driver can execute arbitrary code whenever a new process is created or deleted in the system.</p>\n<p>PsSetCreateProcessNotifyRoutine is also used in part by PROCMON24.SYS, which Sysinternals Procmon depends on.</p>\n<p>Inside DoPDriver, PsSetCreateProcessNotifyRoutine is called with the following code.</p>\n<p>Here, the function pointer at 0x1400012e0 is passed as the first argument, and PsSetCreateProcessNotifyRoutine adds it as a callback routine.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">xor     edx, edx  {0x0}\nlea     rcx, [rel sub_1400012e0]\nadd     rsp, 0x28\njmp     qword [rel PsSetCreateProcessNotifyRoutine]</code></pre></div>\n<p>Because the function at address 0x1400012e0 that is added to the callback routine is related to identifying the second Flag, we will analyze it in a later section.</p>\n<h2 id=\"analyzing-the-irp_mj_close-callback-function\" style=\"position:relative;\"><a href=\"#analyzing-the-irp_mj_close-callback-function\" aria-label=\"analyzing the irp_mj_close callback function 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>Analyzing the <code class=\"language-text\">IRP_MJ_CLOSE</code> Callback Function</h2>\n<p>The address of the callback function registered in the other <code class=\"language-text\">DriverObject->MajorFunction[2(IRP_MJ_CLOSE)]</code> is 0x140001180.</p>\n<p>The disassembled code for this function is shown below, and it does nothing except return the IRP through IofCompleteRequest.</p>\n<p>Therefore, it seems safe to ignore this function.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">sub_140001180:\nsub     rsp, 0x28\nand     dword [rdx+0x30], 0x0\nmov     rcx, rdx\nand     qword [rdx+0x38], 0x0\nxor     edx, edx  {0x0}\ncall    qword [rel IofCompleteRequest]\nxor     eax, eax  {0x0}\nadd     rsp, 0x28\nretn     {__return_addr}</code></pre></div>\n<h2 id=\"analyzing-the-callback-function-registered-with-pssetcreateprocessnotifyroutine\" style=\"position:relative;\"><a href=\"#analyzing-the-callback-function-registered-with-pssetcreateprocessnotifyroutine\" aria-label=\"analyzing the callback function registered with pssetcreateprocessnotifyroutine 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>Analyzing the Callback Function Registered with PsSetCreateProcessNotifyRoutine</h2>\n<p>The address of the callback function registered with PsSetCreateProcessNotifyRoutine inside the dispatch routine registered by <code class=\"language-text\">DriverObject->MajorFunction[0(IRP_MJ_CREATE)]</code> was 0x1400012e0.</p>\n<p>Because this function references the string <code class=\"language-text\">FLAG{The_important_process_is_</code>, we can expect that it performs some processing related to identifying the second Flag.</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/69bfb63567c2d934a920c5120ae77023/46e30/driver-binary-ninja-009.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: 71.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACB0lEQVQ4y5WU547iQBCEeRiCwSYIY4RxwoQFR4ID2AatdPv+z1DXPYRjD1an+1Eah/E3Nd01rjmOg9lihdl8AdM04dgmLMuEaVmYTqdCzsyF7cxgGAZ0XX8rnmfbNmqSJKHFakng67Z0G9ttNOp19Ho9+HGEcL/DaDxCnZ5JtznPajabUFUVtU6nA5Ysy1C6CmRFgaJcR22swTANcj+D4zqYksPxeCze84L3b1kM1TTtChQvZYIq8mMij0EQID+dkBVHHNIEO3IZb7fo9/sC8AxstVoYjUZ/AeXvQM/zkOQ5dsmBQDGCMITne/8BVF6BOQGPxwzFMUGW7LCNQwwGgxcg3/8TuCFglqU4EfB0ImC6R0hl+Mnhaw1vW74r8AOqX4l9liMKA8RRgJC2/Q74xiF3uSug3GEeOXfucg534VI2Leq4KbLapXnvujwcDv8AebvdXveWQUlsQaUVl6sl1t4ai80GK3I3mepoNBrfMngHPnJ4B6qaKk6I5dgif+zG5pPkUg7pFFgkdj2ZTIT4hLAr/v4FyDXUDR1JkiIrC+zTA3xqCnf6g9ytb/J8X+TTpzGKIlEK3s2PwIKaUF0uqD7PKM8FPqsSX9UFv6oKX+cLjvkRCYWclVGk3Pn8CiTGo4adJ2CWUkTKEsWFwSVKcnumRU78PE2xjWLRadaWTg3/EO61ZIe/AUzszhHS7DPmAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/69bfb63567c2d934a920c5120ae77023/8ac56/driver-binary-ninja-009.webp 240w,\n/static/69bfb63567c2d934a920c5120ae77023/d3be9/driver-binary-ninja-009.webp 480w,\n/static/69bfb63567c2d934a920c5120ae77023/e46b2/driver-binary-ninja-009.webp 960w,\n/static/69bfb63567c2d934a920c5120ae77023/78953/driver-binary-ninja-009.webp 1303w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/69bfb63567c2d934a920c5120ae77023/8ff5a/driver-binary-ninja-009.png 240w,\n/static/69bfb63567c2d934a920c5120ae77023/e85cb/driver-binary-ninja-009.png 480w,\n/static/69bfb63567c2d934a920c5120ae77023/d9199/driver-binary-ninja-009.png 960w,\n/static/69bfb63567c2d934a920c5120ae77023/46e30/driver-binary-ninja-009.png 1303w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/69bfb63567c2d934a920c5120ae77023/d9199/driver-binary-ninja-009.png\"\n            alt=\"Function at address 0x1400012e0\"\n            title=\"Function at address 0x1400012e0\"\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>First, let’s analyze the following code block immediately after the function call.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">mov     qword [rsp+0x8 {__saved_rbx}], rbx\nmov     qword [rsp+0x18 {__saved_rdi}], rdi\npush    rbp {__saved_rbp}\nmov     rbp, rsp {__saved_rbp}\nsub     rsp, 0x80\nand     qword [rbp-0x60 {var_68}], 0x0\nmov     rax, rdx\nmov     rcx, rax\nlea     rdx, [rbp-0x60 {var_68}]\ncall    qword [rel PsLookupProcessByProcessId]\nmov     rcx, qword [rbp-0x60 {var_68}]\ncall    PsGetProcessImageFileName\nmov     rcx, qword [rbp-0x60 {var_68}]\nmov     rbx, rax\ncall    qword [rel ObfDereferenceObject]\nmov     rcx, rbx\ncall    sub_140001000\ntest    eax, eax\njne     0x1400013ec</code></pre></div>\n<p>This code block first calls the PsLookupProcessByProcessId function <sup id=\"fnref-16\"><a href=\"#fn-16\" class=\"footnote-ref\">16</a></sup> with the process ID that the callback function received as its second argument.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">NTSTATUS <span class=\"token function\">PsLookupProcessByProcessId</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  HANDLE    ProcessId<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>out<span class=\"token punctuation\">]</span> PEPROCESS <span class=\"token operator\">*</span>Process\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Because this function is the callback routine registered with PsSetCreateProcessNotifyRoutine, it receives three arguments: ParentId, ProcessId, and Create.<sup id=\"fnref-17\"><a href=\"#fn-17\" class=\"footnote-ref\">17</a></sup></p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">PCREATE_PROCESS_NOTIFY_ROUTINE PcreateProcessNotifyRoutine<span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">void</span> <span class=\"token function\">PcreateProcessNotifyRoutine</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> HANDLE ParentId<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> HANDLE ProcessId<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> BOOLEAN Create\n<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span><span class=\"token punctuation\">.</span><span class=\"token punctuation\">.</span><span class=\"token punctuation\">.</span><span class=\"token punctuation\">}</span></code></pre></div>\n<p>In other words, the PsLookupProcessByProcessId function receives the ProcessId value taken by this callback routine and obtains a pointer to the EPROCESS structure for that process.</p>\n<p>The pointer to the EPROCESS structure obtained here is stored in the stack area <code class=\"language-text\">RBP-0x60</code>.</p>\n<p>The next code uses this pointer address to execute the PsGetProcessImageFileName function <sup id=\"fnref-18\"><a href=\"#fn-18\" class=\"footnote-ref\">18</a></sup>, obtaining the image file name of the process captured by the callback routine.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">LPSTR NTAPI <span class=\"token function\">PsGetProcessImageFileName</span><span class=\"token punctuation\">(</span>PEPROCESS Process<span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>LPSTR<span class=\"token punctuation\">)</span>Process<span class=\"token operator\">-></span>ImageFileName<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>PsGetProcessImageFileName is an undocumented function, but it has been introduced in sources such as Sysinternals newsletters as a function that can be used to obtain a process image file name.</p>\n<p>After PsGetProcessImageFileName obtains the image file name, the function at address 0x140001000 is executed using the obtained file name as an argument.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">call    PsGetProcessImageFileName\n***\nmov     rbx, rax\n***\nmov     rcx, rbx\ncall    sub_140001000</code></pre></div>\n<p>When analyzing this function in Graph view, you can see that it implements very complex branching using the received file name, and at first glance it is difficult to determine the detailed behavior.</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/cbf1b53251766c7dd2b12a2a3ef4628e/d56b5/driver-binary-ninja-011.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: 77.08333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAB3ElEQVQ4y3VU2ZKbQAzka2yumeE+bAx4j2SPh1QlX5Cq5P8/oaMWzC7E64dGjJBa5xBM04Tp+oCH5++4jCPOw4C+7z/QdR3qukbbNDv9/zidThjENzgej1gQIgz3OBwOcJnDy/sbxnlGFEU3Nh7kiOMYAR/3QKOmbfH77x/8+PUTaZoijr62ZTBjDILUpEjSRI0p+ZEy4TlJYJ3Fy9srzpeLOnnn7buX5Ajo6A1IVJQFYiEiGc+h6NuuRZZlCCVj6unIbFjqNkMlLKoSeZHDWKMfzsNZh+CNaVjJuZahsJ8+Iw6Tdr53uwyzPEfXdyiFnC3g1HLRfRgLnGTYcaKnXonpzODOOQ1+UzIdWVYv42+kxHEaUUmAKPKZsjRpSVEoeVVXknWtpL58kivhZx8WaawV0g7Xx0cdDnuqWEsLw0ht2IaLBGZw7a3ZZqiDSFeChSQSGJchMUt/PbGxDk5aQju+F3UDk+Vwkr2szWocJ/vdWjNKjYXNSwlk9J3SinMpJAyUiI7ElFlZ7Xt4b2GHaUbd9QupZJRKuSRjAMV6tuwh18Xv3C2WYPN1/lyRdWdvIEPRKS83JdXDDl4vkveYVzDaLPJXlShhdCdivP4IrJTz9PxN/yTx5srdI/wHuEfNtFQR1PoAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/cbf1b53251766c7dd2b12a2a3ef4628e/8ac56/driver-binary-ninja-011.webp 240w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/d3be9/driver-binary-ninja-011.webp 480w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/e46b2/driver-binary-ninja-011.webp 960w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/34ce3/driver-binary-ninja-011.webp 1215w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/cbf1b53251766c7dd2b12a2a3ef4628e/8ff5a/driver-binary-ninja-011.png 240w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/e85cb/driver-binary-ninja-011.png 480w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/d9199/driver-binary-ninja-011.png 960w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/d56b5/driver-binary-ninja-011.png 1215w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/cbf1b53251766c7dd2b12a2a3ef4628e/d9199/driver-binary-ninja-011.png\"\n            alt=\"Function at address 0x140001000\"\n            title=\"Function at address 0x140001000\"\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>However, as shown below, a code block containing <code class=\"language-text\">FLAG{The_important_process_is_</code> can be reached only when the function at address 0x140001000 returns 0, so it is highly likely that the function at address 0x140001000 performs some kind of check on the process image file name. (The detailed behavior of the function at address 0x140001000 will be described later.)</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 905px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/f3e95873469691a0e07a43f4f5308d9c/65d79/driver-binary-ninja-010.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.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACOUlEQVQ4y32U2Y7aQBBF+RmC2RISHDMGs4UBb93e7TaeRUoiRSMlykv+XzdVbWaCmAkPR71QdbvqdpvOaDxC3+ij3//HcDiEUgrfv37Dn1+/8fPHE2pV672qqtA0Dfb7PbrdLgaDgc7hkemMP7zXExZhBsMBRqMR5vM5ZvYNZksblj3DjWXBnE41Fs2nNBqG8VpwYn7UQlxpy1iLWjMLB/dAuAhFCNcPcCskDsRmu3kRuKQzmU7Q6/X0aYbRju9obX42sdvtsNvvsPcPNO6xPbi4JeHlaqXjOO8c3utMZyYcx8Hmy1azptNX6xWc5RILZ4HFomVJ2DNqnbBtW+9x3oLh3yneNM1WMIlj5GUJ9XBPHCGkQBAECMPwOkELx0optagWFKFAmmUo6BbzukRaZhDkGwuH5FkoxGlOUKKIIlpLLcIjx0RUFFvR+WRNIWkjLwrUda2fhWroadzVaOoCqiqRZTnyPEfGUFycpFpMkrA8icdJgtVq3VYY0QZXWDd3UI/EQ4Pm8R4lv7tjg7JSSNMMSZoSCQLfh/+M58PzPG2BQ162LYu2ZcUV1lThscSxUSiLFHEcIaBgTuZE7yTEvj3Da9bgS9KCrM4l88UUFVNo4SQmf04J5wLBxd4rwYh8yE4tl1WOKo+gCjogjfRhb4lcrVDSgivkW06LjNonsTzVQe5Zm9e4EJTacDZfe6ioWmo7S+iyYoEkkm9W9t8K2WxJ5meqpGcg6OZcTeB7L3j0TbtXYFH+Q/kLA3YdCiMkPqMAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/f3e95873469691a0e07a43f4f5308d9c/8ac56/driver-binary-ninja-010.webp 240w,\n/static/f3e95873469691a0e07a43f4f5308d9c/d3be9/driver-binary-ninja-010.webp 480w,\n/static/f3e95873469691a0e07a43f4f5308d9c/4d060/driver-binary-ninja-010.webp 905w\"\n              sizes=\"(max-width: 905px) 100vw, 905px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/f3e95873469691a0e07a43f4f5308d9c/8ff5a/driver-binary-ninja-010.png 240w,\n/static/f3e95873469691a0e07a43f4f5308d9c/e85cb/driver-binary-ninja-010.png 480w,\n/static/f3e95873469691a0e07a43f4f5308d9c/65d79/driver-binary-ninja-010.png 905w\"\n            sizes=\"(max-width: 905px) 100vw, 905px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/f3e95873469691a0e07a43f4f5308d9c/65d79/driver-binary-ninja-010.png\"\n            alt=\"Function at address 0x1400011a0\"\n            title=\"Function at address 0x1400011a0\"\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 the image file name passes the validation performed by the function at address 0x140001000, the following code is executed inside the callback function registered with PsSetCreateProcessNotifyRoutine.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">xorps   xmm0, xmm0\nlea     ecx, [rax+0x1]\nmov     edi, 0x100\nmov     r8d, 0x67616c66\nmov     edx, edi  {0x100}\nmovups  xmmword [rbp-0x58 {Destination.Length} {Destination.MaximumLength} {Destination.Buffer}], xmm0\ncall    qword [rel ExAllocatePoolWithTag]</code></pre></div>\n<p>The ExAllocatePoolWithTag function <sup id=\"fnref-19\"><a href=\"#fn-19\" class=\"footnote-ref\">19</a></sup> executed here allocates a memory pool in the system and returns the allocated pointer.</p>\n<p>This function’s third argument specifies the pool tag to assign to the allocated memory area.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">PVOID ExAllocatePoolWithTag(\n  [in] __drv_strictTypeMatch(__drv_typeExpr)POOL_TYPE PoolType,\n  [in] SIZE_T                                         NumberOfBytes,\n  [in] ULONG                                          Tag\n);</code></pre></div>\n<p>Therefore, although Binary Ninja does not recognize it, the 0x67616c66 loaded into the R8 register by the line <code class=\"language-text\">mov  r8d, 0x67616c66</code> is a 4-byte string used to specify the pool tag <code class=\"language-text\">g(0x67) a(0x61) l(0x6c) f(0x66)</code>.</p>\n<p>The subsequent processing is somewhat difficult to analyze from the disassembly result alone, but if you refer to Binary Ninja’s decompilation, the behavior becomes easy to understand.</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/bfd49b4ea82dd5711252f2824777f547/7b775/driver-binary-ninja-012.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: 56.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABqUlEQVQoz32S626bQBSEeZqAbUywY9O45n4nMWDoGtNKVdoqSt//CSaz28ZyI5ofn86y4ozm7BzNXi4xn8+xkCwWmM1mWK9WOIkW4tSj7TuUZYE8z5FlmaIoCux2OxiGoXqv0W7NJQyKSCF5IX9ardf48fMJv19e8Pz8C0/fv2IYBIQgrOO3EWEUQdf1CUE6fBO7CNLhOAoMZ4HzSaDvezRti5Y0dY2mabHf7//jcFLQxnjqMIgjRRrUFKqPHR6bBlVZ4XA4fCA4NTIdnocvfMcj+q5FRxopTMFaOuTZc71pQfudwznPlmUhikLEUYAo8JGwxnGMIAiIr+rm7k4Jzv6aeUPzmFZV5ngsMzwUf6iqEmmaIqJIQvIsJQlSCqexJGTSGXKmnTH9PGdfVSBJYmgbjmfbthrzujrbrWqMQ1+5lI4932e6IVzXvfx7jbxTI9/oN9BpX66Bbuj81mFyJz/fO4gDD3kScv8SJSb3b821kuNOoW1ubVimCZm2DMgi8izvTL7pznHgM1GXOJ8c9c5T+3cJZbkwVfMUUliGdL+l03eL/E+QV7wC4IdpdY/YX5wAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/bfd49b4ea82dd5711252f2824777f547/8ac56/driver-binary-ninja-012.webp 240w,\n/static/bfd49b4ea82dd5711252f2824777f547/d3be9/driver-binary-ninja-012.webp 480w,\n/static/bfd49b4ea82dd5711252f2824777f547/e46b2/driver-binary-ninja-012.webp 960w,\n/static/bfd49b4ea82dd5711252f2824777f547/f992d/driver-binary-ninja-012.webp 1440w,\n/static/bfd49b4ea82dd5711252f2824777f547/8b025/driver-binary-ninja-012.webp 1445w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/bfd49b4ea82dd5711252f2824777f547/8ff5a/driver-binary-ninja-012.png 240w,\n/static/bfd49b4ea82dd5711252f2824777f547/e85cb/driver-binary-ninja-012.png 480w,\n/static/bfd49b4ea82dd5711252f2824777f547/d9199/driver-binary-ninja-012.png 960w,\n/static/bfd49b4ea82dd5711252f2824777f547/07a9c/driver-binary-ninja-012.png 1440w,\n/static/bfd49b4ea82dd5711252f2824777f547/7b775/driver-binary-ninja-012.png 1445w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/bfd49b4ea82dd5711252f2824777f547/d9199/driver-binary-ninja-012.png\"\n            alt=\"Decompilation result of the callback routine\"\n            title=\"Decompilation result of the callback routine\"\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>First, the pool region obtained by ExAllocatePoolWithTag is associated with the Buffer of a <code class=\"language-text\">UNICODE_STRING</code> structure named Destination.</p>\n<p>Then, the image file name obtained by PsGetProcessImageFileName is converted into a <code class=\"language-text\">UNICODE_STRING</code> structure by the RtlInitAnsiString and RtlAnsiStringToUnicodeString functions.</p>\n<p>Finally, the image file name is appended to the Flag string by RtlAppendUnicodeStringToString, which concatenates <code class=\"language-text\">UNICODE_STRING</code> structures, and the string <code class=\"language-text\">FLAG{The_important_process_is_&lt;image file name>}</code> is written into the memory pool with the pool tag flag.</p>\n<h2 id=\"analyzing-the-function-that-validates-the-image-file-name\" style=\"position:relative;\"><a href=\"#analyzing-the-function-that-validates-the-image-file-name\" aria-label=\"analyzing the function that validates the image file name 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>Analyzing the Function That Validates the Image File Name</h2>\n<p>From the analysis so far, we now know that if a process with an image file name that passes the validation performed by the function at address 0x140001000 starts, the correct Flag will be written into the memory pool.</p>\n<p>As mentioned earlier, this function implements extremely complex branching that uses the received file name, and at first glance it is impossible to determine the detailed behavior.</p>\n<p>However, if we can identify the file name that passes this validation, it looks like we should be able to identify the second Flag.</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/cbf1b53251766c7dd2b12a2a3ef4628e/d56b5/driver-binary-ninja-011.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: 77.08333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAB3ElEQVQ4y3VU2ZKbQAzka2yumeE+bAx4j2SPh1QlX5Cq5P8/oaMWzC7E64dGjJBa5xBM04Tp+oCH5++4jCPOw4C+7z/QdR3qukbbNDv9/zidThjENzgej1gQIgz3OBwOcJnDy/sbxnlGFEU3Nh7kiOMYAR/3QKOmbfH77x/8+PUTaZoijr62ZTBjDILUpEjSRI0p+ZEy4TlJYJ3Fy9srzpeLOnnn7buX5Ajo6A1IVJQFYiEiGc+h6NuuRZZlCCVj6unIbFjqNkMlLKoSeZHDWKMfzsNZh+CNaVjJuZahsJ8+Iw6Tdr53uwyzPEfXdyiFnC3g1HLRfRgLnGTYcaKnXonpzODOOQ1+UzIdWVYv42+kxHEaUUmAKPKZsjRpSVEoeVVXknWtpL58kivhZx8WaawV0g7Xx0cdDnuqWEsLw0ht2IaLBGZw7a3ZZqiDSFeChSQSGJchMUt/PbGxDk5aQju+F3UDk+Vwkr2szWocJ/vdWjNKjYXNSwlk9J3SinMpJAyUiI7ElFlZ7Xt4b2GHaUbd9QupZJRKuSRjAMV6tuwh18Xv3C2WYPN1/lyRdWdvIEPRKS83JdXDDl4vkveYVzDaLPJXlShhdCdivP4IrJTz9PxN/yTx5srdI/wHuEfNtFQR1PoAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/cbf1b53251766c7dd2b12a2a3ef4628e/8ac56/driver-binary-ninja-011.webp 240w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/d3be9/driver-binary-ninja-011.webp 480w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/e46b2/driver-binary-ninja-011.webp 960w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/34ce3/driver-binary-ninja-011.webp 1215w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/cbf1b53251766c7dd2b12a2a3ef4628e/8ff5a/driver-binary-ninja-011.png 240w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/e85cb/driver-binary-ninja-011.png 480w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/d9199/driver-binary-ninja-011.png 960w,\n/static/cbf1b53251766c7dd2b12a2a3ef4628e/d56b5/driver-binary-ninja-011.png 1215w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/cbf1b53251766c7dd2b12a2a3ef4628e/d9199/driver-binary-ninja-011.png\"\n            alt=\"Function at address 0x140001000\"\n            title=\"Function at address 0x140001000\"\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>So, to make the analysis easier, we will refer to the decompilation result of this function.</p>\n<p>The structure of the function is very similar to the function in DoPClient that was validating the password.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token class-name\">int64_t</span> <span class=\"token function\">sub_140001000</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">char</span><span class=\"token operator\">*</span> arg1<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n  <span class=\"token class-name\">int128_t</span> var_48<span class=\"token punctuation\">;</span>\n  <span class=\"token class-name\">int64_t</span> rax_1 <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span>__security_cookie <span class=\"token operator\">^</span> <span class=\"token operator\">&amp;</span>var_48<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token class-name\">int128_t</span><span class=\"token operator\">*</span> r10 <span class=\"token operator\">=</span> <span class=\"token operator\">&amp;</span>var_48<span class=\"token punctuation\">;</span>\n\n  <span class=\"token class-name\">int32_t</span> rdx <span class=\"token operator\">=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n  <span class=\"token function\">__builtin_memcpy</span><span class=\"token punctuation\">(</span><span class=\"token operator\">&amp;</span>var_48<span class=\"token punctuation\">,</span> <span class=\"token string\">\"&lt;hardcoded byte sequence>\"</span><span class=\"token punctuation\">,</span> <span class=\"token number\">0x34</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">char</span><span class=\"token operator\">*</span> r11 <span class=\"token operator\">=</span> arg1<span class=\"token punctuation\">;</span>\n  <span class=\"token class-name\">int32_t</span> r9 <span class=\"token operator\">=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n  <span class=\"token class-name\">int64_t</span> rax_3<span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">while</span> <span class=\"token punctuation\">(</span>true<span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">{</span>\n    <span class=\"token class-name\">int32_t</span> rax_2 <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token class-name\">int32_t</span><span class=\"token punctuation\">)</span><span class=\"token operator\">*</span><span class=\"token punctuation\">(</span><span class=\"token class-name\">uint8_t</span><span class=\"token operator\">*</span><span class=\"token punctuation\">)</span>r11<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>rax_2 <span class=\"token operator\">!=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">{</span>\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>r9 <span class=\"token operator\">&lt;=</span> <span class=\"token number\">6</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">{</span>\n        <span class=\"token class-name\">int32_t</span> rdx_3<span class=\"token punctuation\">;</span>\n        <span class=\"token keyword\">switch</span> <span class=\"token punctuation\">(</span>r9<span class=\"token punctuation\">)</span>\n        <span class=\"token punctuation\">{</span>\n          <span class=\"token keyword\">case</span> <span class=\"token number\">0</span><span class=\"token operator\">:</span>\n          <span class=\"token punctuation\">{</span>\n            rdx <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>rax_2 <span class=\"token operator\">*</span> <span class=\"token number\">0x1c</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">+</span> <span class=\"token number\">0xf74</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n            <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n          <span class=\"token punctuation\">}</span>\n\n      <span class=\"token punctuation\">{</span>omitted<span class=\"token punctuation\">}</span>\n\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>rdx <span class=\"token operator\">==</span> <span class=\"token operator\">*</span><span class=\"token punctuation\">(</span><span class=\"token class-name\">uint32_t</span><span class=\"token operator\">*</span><span class=\"token punctuation\">)</span>r10<span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">{</span>\n        r9 <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span>r9 <span class=\"token operator\">+</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        r11 <span class=\"token operator\">=</span> <span class=\"token operator\">&amp;</span>r11<span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\n        r10 <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">char</span><span class=\"token operator\">*</span><span class=\"token punctuation\">)</span>r10 <span class=\"token operator\">+</span> <span class=\"token number\">4</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>r9 <span class=\"token operator\">>=</span> <span class=\"token number\">0xd</span><span class=\"token punctuation\">)</span>\n        <span class=\"token punctuation\">{</span>\n            rax_3 <span class=\"token operator\">=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n            <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n        <span class=\"token punctuation\">}</span>\n        <span class=\"token keyword\">continue</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span>\n    rax_3 <span class=\"token operator\">=</span> <span class=\"token number\">1</span><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token function\">sub_140001420</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>rax_1 <span class=\"token operator\">^</span> <span class=\"token operator\">&amp;</span>var_48<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">return</span> rax_3<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>We know that if validation ultimately succeeds, this function returns 0.</p>\n<p>In other words, the important part is the following section executed inside the while loop above.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>rdx <span class=\"token operator\">==</span> <span class=\"token operator\">*</span><span class=\"token punctuation\">(</span><span class=\"token class-name\">uint32_t</span><span class=\"token operator\">*</span><span class=\"token punctuation\">)</span>r10<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n  r9 <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span>r9 <span class=\"token operator\">+</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  r11 <span class=\"token operator\">=</span> <span class=\"token operator\">&amp;</span>r11<span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\n  r10 <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">char</span><span class=\"token operator\">*</span><span class=\"token punctuation\">)</span>r10 <span class=\"token operator\">+</span> <span class=\"token number\">4</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>r9 <span class=\"token operator\">>=</span> <span class=\"token number\">0xd</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">{</span>\n      rax_3 <span class=\"token operator\">=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n      <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token keyword\">continue</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>In this code, the first thing it does is compare the value in the RDX register with the UINT32 value pointed to by the R10 register.</p>\n<p>Also, if the value in the RDX register matches the UINT32 value pointed to by the R10 register, it increments the R9 register and updates the values of the R10 and R11 registers to the next elements.</p>\n<p>Then, if the incremented value in the R9 register becomes 13 (0xd) or more, the loop exits and the function returns 0.</p>\n<p>Because the R9 register is initialized to 0 and incremented inside the while loop, it can be considered a counter for the number of loop iterations.</p>\n<p>We can also see that the R11 register stores the pointer to the image file name received by the function as an argument, as shown by the code <code class=\"language-text\">char* r11 = arg1;</code>.</p>\n<p>Furthermore, it appears that the RDX register holds the result of some operation performed on the characters of the image file name one at a time, as shown by code such as <code class=\"language-text\">rdx = ((rax_2 * 0x1c) + 0xf74);</code>.</p>\n<p>From the analysis so far, we can see that this function takes the image file name string received as an argument, extracts it one character at a time, performs some operation on it, and compares the result with hardcoded integer values.</p>\n<p>Also, because the loop exits when the loop counter, whose initial value is 0, becomes 13 (0xd) or more, we can determine that the correct image file name is 13 characters long.</p>\n<p>All that remains is to perform a brute-force attack with a debugger, just as we did for DoPClient, and we should be able to identify the correct image file name that becomes the second Flag.</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>In this chapter, we performed static analysis of DoPDriver using Binary Ninja.</p>\n<p>It seems likely that the Flag in DoPDriver can also be identified by brute-forcing it with a debugger.</p>\n<p>We will perform dynamic analysis using kernel debugging in Chapter 6.</p>\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-vol2-00-en\">Preface</a></li>\n<li><a href=\"/magical-windbg-vol2-01-en\">Chapter 1: Environment Setup</a></li>\n<li><a href=\"/magical-windbg-vol2-02-en\">Chapter 2: Surface Analysis of DoPClient and DoPDriver</a></li>\n<li><a href=\"/magical-windbg-vol2-03-en\">Chapter 3: Static Analysis of DoPClient</a></li>\n<li><a href=\"/magical-windbg-vol2-04-en\">Chapter 4: Dynamic Analysis of DoPClient</a></li>\n<li><a href=\"/magical-windbg-vol2-05-en\">Chapter 5: Static Analysis of DoPDriver</a></li>\n<li><a href=\"/magical-windbg-vol2-06-en\">Chapter 6: Dynamic Analysis of DoPDriver</a></li>\n</ul>\n<div class=\"footnotes\">\n<hr>\n<ol>\n<li id=\"fn-1\">\n<p>Windows Vista Device Driver Programming, p.36 (浜田 憲一郎 / SoftBank Creative / 2007)</p>\n<a href=\"#fnref-1\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-2\">\n<p>DRIVER<em>INITIALIZE callback function (wdm.h) [<a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nc-wdm-driver\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nc-wdm-driver</a></em>initialize](<a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nc-wdm-driver_initialize\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nc-wdm-driver_initialize</a>)</p>\n<a href=\"#fnref-2\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-3\">\n<p>DriverEntry routine for WDF drivers <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/wdf/driverentry-for-kmdf-drivers\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/wdf/driverentry-for-kmdf-drivers</a></p>\n<a href=\"#fnref-3\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-4\">\n<p>Complete Guide to WDM Device Driver Programming, Vol. 1, p.185 (Edward N. Dekker, Joseph M. Newcomer / translated by クイック / ASCII / 2000)</p>\n<a href=\"#fnref-4\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-5\">\n<p>IoCreateDevice function (wdm.h) <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-iocreatedevice\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-iocreatedevice</a></p>\n<a href=\"#fnref-5\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-6\">\n<p>Device Input and Output Control (IOCTL) <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/devio/device-input-and-output-control-ioctl-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows/win32/devio/device-input-and-output-control-ioctl-</a></p>\n<a href=\"#fnref-6\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-7\">\n<p>DRIVER<em>OBJECT structure (wdm.h) [<a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/ns-wdm-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/ns-wdm-</a></em>driver<em>object](<a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/ns-wdm-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/ns-wdm-</a></em>driver_object)</p>\n<a href=\"#fnref-7\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-8\">\n<p>Reverse Engineering - Binary Analysis Techniques with Python, p.172 (Justin Seitz / translated by 安藤 慶一 / O’Reilly Japan / 2010)</p>\n<a href=\"#fnref-8\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-9\">\n<p>UNICODE<em>STRING structure (ntdef.h) [<a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/ntdef/ns-ntdef-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows/win32/api/ntdef/ns-ntdef-</a></em>unicode<em>string](<a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/ntdef/ns-ntdef-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows/win32/api/ntdef/ns-ntdef-</a></em>unicode_string)</p>\n<a href=\"#fnref-9\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-10\">\n<p>Windows kernel-mode safe string library <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/kernel/windows-kernel-mode-safe-string-library\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/kernel/windows-kernel-mode-safe-string-library</a></p>\n<a href=\"#fnref-10\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-11\">\n<p>Specifying device types <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/kernel/specifying-device-types\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/kernel/specifying-device-types</a></p>\n<a href=\"#fnref-11\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-12\">\n<p>IoCreateSymbolicLink function (wdm.h) <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-iocreatesymboliclink\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-iocreatesymboliclink</a></p>\n<a href=\"#fnref-12\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-13\">\n<p>Complete Guide to WDM Device Driver Programming, Vol. 1, p.146 (Edward N. Dekker, Joseph M. Newcomer / translated by クイック / ASCII / 2000)</p>\n<a href=\"#fnref-13\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-14\">\n<p>IofCompleteRequest function (wdm.h) <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-iocompleterequest\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-iocompleterequest</a></p>\n<a href=\"#fnref-14\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-15\">\n<p>PsSetCreateProcessNotifyRoutine function (ntddk.h) <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/ntddk/nf-ntddk-pssetcreateprocessnotifyroutine\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/ntddk/nf-ntddk-pssetcreateprocessnotifyroutine</a></p>\n<a href=\"#fnref-15\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-16\">\n<p>PsLookupProcessByProcessId function (ntifs.h) <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/ntifs/nf-ntifs-pslookupprocessbyprocessid\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/ntifs/nf-ntifs-pslookupprocessbyprocessid</a></p>\n<a href=\"#fnref-16\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-17\">\n<p><code class=\"language-text\">PCREATE_PROCESS_NOTIFY_ROUTINE</code> callback function (ntddk.h) <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/ntddk/nc-ntddk-pcreate_process_notify_routine\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/ntddk/nc-ntddk-pcreate<em>process</em>notify_routine</a></p>\n<a href=\"#fnref-17\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-18\">\n<p>PsGetProcessImageFileName <a href=\"https://doxygen.reactos.org/d2/d9f/ntoskrnl_2ps_2process_8c.html#a3f0cede0033a188f9525531fb104c482\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://doxygen.reactos.org/d2/d9f/ntoskrnl<em>2ps</em>2process_8c.html#a3f0cede0033a188f9525531fb104c482</a></p>\n<a href=\"#fnref-18\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-19\">\n<p>ExAllocatePoolWithTag function <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepoolwithtag\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepoolwithtag</a></p>\n<a href=\"#fnref-19\" class=\"footnote-backref\">↩</a>\n</li>\n</ol>\n</div>","fields":{"slug":"/magical-windbg-vol2-05-en","tagSlugs":["/tag/magical-win-dbg/","/tag/windows/","/tag/win-dbg/","/tag/english/"]},"frontmatter":{"date":"2024-05-26","description":"This is the web edition of Magical WinDbg 2 - Learn User-Mode & Kernel Debugging Through CTFs -, distributed at Tech Book Fest 16.","tags":["Magical WinDbg","Windows","WinDbg","English"],"title":"Magical WinDbg VOL.2 [Chapter 5: Static Analysis of DoPDriver]","socialImage":{"publicURL":"/static/e9bfc3718fd53ab58623a496fc9a302e/magical-windbg-vol2.png"}}}},"pageContext":{"slug":"/magical-windbg-vol2-05-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}