{"componentChunkName":"component---src-templates-post-template-js","path":"/windows-create-dll-en","result":{"data":{"markdownRemark":{"id":"73465f4e-fe2e-5f8d-90cc-06697f041207","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/windows-create-dll\">original page</a>.</p>\n</blockquote>\n<p>This time, I tried several methods for creating a DLL file on Windows and loading it into a process.</p>\n<p>This article is not intended to publish information that violates laws or ethics.</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=\"#create-a-hello-world-dll\">Create a Hello World DLL</a></li>\n<li><a href=\"#dll-reason-code\">DLL Reason Code</a></li>\n<li><a href=\"#best-practices-for-dllmain\">Best Practices for DLLMain</a></li>\n<li><a href=\"#load-a-dll-into-a-process\">Load a DLL into a Process</a></li>\n<li><a href=\"#dll-search-order\">DLL Search Order</a></li>\n<li><a href=\"#run-an-exported-function-from-a-process-with-rundll32exe\">Run an Exported Function from a Process with rundll32.exe</a></li>\n<li><a href=\"#load-a-dll-into-a-remote-process\">Load a DLL into a Remote Process</a></li>\n<li><a href=\"#load-a-dll-into-a-remote-process-with-virtualallocex-and-writeproessmemory\">Load a DLL into a Remote Process with VirtualAllocEx and WriteProessMemory</a></li>\n<li><a href=\"#about-reflective-dll-injection\">About Reflective DLL Injection</a></li>\n<li><a href=\"#summary\">Summary</a></li>\n</ul>\n<h2 id=\"create-a-hello-world-dll\" style=\"position:relative;\"><a href=\"#create-a-hello-world-dll\" aria-label=\"create a hello world dll 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>Create a Hello World DLL</h2>\n<p>In Visual Studio, create a new DLL project and replace <code class=\"language-text\">dllmain.cpp</code> with the following code to create a DLL that displays the string <code class=\"language-text\">Hello, World!</code> in a message box when it is loaded.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;Windows.h></span></span>\n\n<span class=\"token comment\">// Exported function</span>\n<span class=\"token keyword\">extern</span> <span class=\"token string\">\"C\"</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token function\">__declspec</span><span class=\"token punctuation\">(</span>dllexport<span class=\"token punctuation\">)</span> <span class=\"token keyword\">void</span> <span class=\"token function\">ShowMessage</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token function\">MessageBoxA</span><span class=\"token punctuation\">(</span><span class=\"token constant\">NULL</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"Hello, World!\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"DLL Message\"</span><span class=\"token punctuation\">,</span> MB_OK <span class=\"token operator\">|</span> MB_ICONINFORMATION<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span>\n\n    <span class=\"token function\">__declspec</span><span class=\"token punctuation\">(</span>dllexport<span class=\"token punctuation\">)</span> <span class=\"token keyword\">void</span> <span class=\"token function\">ShowMessage2</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token function\">MessageBoxA</span><span class=\"token punctuation\">(</span><span class=\"token constant\">NULL</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"Hello, New World!\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"DLL Message\"</span><span class=\"token punctuation\">,</span> MB_OK <span class=\"token operator\">|</span> MB_ICONINFORMATION<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span>\n\nBOOL APIENTRY <span class=\"token function\">DllMain</span><span class=\"token punctuation\">(</span> HMODULE hModule<span class=\"token punctuation\">,</span>\n                       DWORD  ul_reason_for_call<span class=\"token punctuation\">,</span>\n                       LPVOID lpReserved\n                     <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">switch</span> <span class=\"token punctuation\">(</span>ul_reason_for_call<span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">case</span> DLL_PROCESS_ATTACH<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token function\">ShowMessage</span><span class=\"token punctuation\">(</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><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">case</span> DLL_THREAD_ATTACH<span class=\"token operator\">:</span>\n    <span class=\"token keyword\">case</span> DLL_THREAD_DETACH<span class=\"token operator\">:</span>\n    <span class=\"token keyword\">case</span> DLL_PROCESS_DETACH<span class=\"token operator\">:</span>\n        <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span>\n    <span class=\"token keyword\">return</span> TRUE<span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>At this time, <code class=\"language-text\">ShowMessage</code>, which is the function that displays the message box, is defined as an exported function by <code class=\"language-text\">extern __declspec(dllexport) void ShowMessage()</code>.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/cpp/build/exporting-from-a-dll-using-declspec-dllexport?view=msvc-170&#x26;redirectedfrom=MSDN\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Exporting from a DLL Using __declspec(dllexport) | Microsoft Learn</a></p>\n<p>Because this <code class=\"language-text\">ShowMessage</code> function is called during <code class=\"language-text\">DLL_PROCESS_ATTACH</code>, it runs when the DLL is loaded into the process.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 611px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/a7c2979eb7dad6724f0be7287549abd2/36bb5/image-20241231221242487.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: 32.916666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsTAAALEwEAmpwYAAABZUlEQVQoz43RXW/SUByA8X4JL6QtLfRF2p6+jdLRUNjokKKAHYPoNhdn/BheeGOW+a0fT5eFzBgTL355zklOTs4/R4m9BM+2GDg9nL7xVNc2sXs6vu9h2za6rtPtdv+L4rkCK6mwsxpXctqO2vWSvuWgaxodtUOn8ydVVf+iybPKMB1T3H5nev+Ls/tHis8PJFc/GF//ZFScIQKPMIyIo5QoSo6EEARBcNTuB4MBiiNHqqcz8lTgeyaBZ6G+fkWaCD5e33A47LlsrthuWnu2653sjreLBdV8TlVVsucsLi4oikJeaLlYPZd+38E0bQyjR1fK84K7r9+4uftCc/jEcv2B5eoddVtptd2x2jSs1lvqzSXvmz2TcoqShbl8bkaalpSTDcOTkjybkw0n+CLED0KCMEbIMcMokmTj9ImI4qMwTnjTjlyezIjiMaf5gtm0YZSdU5wuKcY1pmE8f4D0sv+gaSq/Aakk22e3n/OtAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/a7c2979eb7dad6724f0be7287549abd2/8ac56/image-20241231221242487.webp 240w,\n/static/a7c2979eb7dad6724f0be7287549abd2/d3be9/image-20241231221242487.webp 480w,\n/static/a7c2979eb7dad6724f0be7287549abd2/ef8bf/image-20241231221242487.webp 611w\"\n              sizes=\"(max-width: 611px) 100vw, 611px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/a7c2979eb7dad6724f0be7287549abd2/8ff5a/image-20241231221242487.png 240w,\n/static/a7c2979eb7dad6724f0be7287549abd2/e85cb/image-20241231221242487.png 480w,\n/static/a7c2979eb7dad6724f0be7287549abd2/36bb5/image-20241231221242487.png 611w\"\n            sizes=\"(max-width: 611px) 100vw, 611px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/a7c2979eb7dad6724f0be7287549abd2/36bb5/image-20241231221242487.png\"\n            alt=\"image-20241231221242487\"\n            title=\"image-20241231221242487\"\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>When building the sample DLL code, disable the precompiled header, which is not particularly necessary here.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 778px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/3ad78361341f1ea1e481cf55e20fbc23/20982/image-20250102103357561.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: 70.41666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB60lEQVQ4y51U25KbMAzl//8q6Uu7eSjt0HA14RYIhJALIcnmdiqJOMt2OrPbekZj2VjHsnQORlVVKIoCi8UC7K/Xa2w2G+x2O5nr5ZL2GvH1/n6/l1mf5blpGmy3WxhZlsH3fSRJgiUFp1kKpRQd6oNVGMpleV4gjhM0FNwSIJ+dzWaI4ohiU/oWC6jBqHmeYzqdIgiUHFzWDYIwgu16cH1Fs49m0yJNM1jWL0RRhGgWycVKhQQc4fX1jOPxSICUxXw+B2fKT+ZsmvVWgmzHhus6cGxbXuAHAa1dlGUlSRR0drVa4Xq7gcflcukzZOMMi0cdu67Dn+N+f/Ov16vYjYDY7o+P5/O5B2wpS89zpZYh1eVwODxA7k97wA784WUDQC581+3hyPNchNSE7i+AH9kTMEkXCFSGl4mJr99MOK56l+FnxjtA7mhZ1TDNH/hu/qRMPenWf2coTyZehUSBmDiVUjc14L+OZ5cZ1LIsqqGHuq5lzbcx8Ol0Ep+7ygFsQ3+4x6Xqu9y21AwlqmBe2USh0WiEL+MxxjS/TCZISAmshohMFEI8TdOU+BkLR3nNEjZqAijLUojNpGal8Frru5ddjpzIz3vssxA0sQueH/vMYYP1p0WuhT5cs2nys88/Bi4LP08ri/f0z+E3jdMm9dAXH3IAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/3ad78361341f1ea1e481cf55e20fbc23/8ac56/image-20250102103357561.webp 240w,\n/static/3ad78361341f1ea1e481cf55e20fbc23/d3be9/image-20250102103357561.webp 480w,\n/static/3ad78361341f1ea1e481cf55e20fbc23/10884/image-20250102103357561.webp 778w\"\n              sizes=\"(max-width: 778px) 100vw, 778px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/3ad78361341f1ea1e481cf55e20fbc23/8ff5a/image-20250102103357561.png 240w,\n/static/3ad78361341f1ea1e481cf55e20fbc23/e85cb/image-20250102103357561.png 480w,\n/static/3ad78361341f1ea1e481cf55e20fbc23/20982/image-20250102103357561.png 778w\"\n            sizes=\"(max-width: 778px) 100vw, 778px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/3ad78361341f1ea1e481cf55e20fbc23/20982/image-20250102103357561.png\"\n            alt=\"image-20250102103357561\"\n            title=\"image-20250102103357561\"\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<h3 id=\"dll-reason-code\" style=\"position:relative;\"><a href=\"#dll-reason-code\" aria-label=\"dll reason code 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>DLL Reason Code</h3>\n<p><code class=\"language-text\">DLL_PROCESS_ATTACH</code> corresponds to the Reason Code passed as the <code class=\"language-text\">fdwReason</code> argument to the DllMain function (the value that indicates why the DLL entry point was called).</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">BOOL WINAPI <span class=\"token function\">DllMain</span><span class=\"token punctuation\">(</span>\n  _In_ HINSTANCE hinstDLL<span class=\"token punctuation\">,</span>\n  _In_ DWORD     fdwReason<span class=\"token punctuation\">,</span>\n  _In_ LPVOID    lpvReserved\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>When <code class=\"language-text\">DLL_PROCESS_ATTACH</code> is used, it seems to apply when the DLL is loaded into the process by <code class=\"language-text\">LoadLibrary</code>, as shown below.</p>\n<blockquote>\n<p>DLL<em>PROCESS</em>ATTACH 1:\nThe DLL is being loaded into the virtual address space of the current process as a result of the process starting up or as a result of a call to LoadLibrary.\nDLLs can use this opportunity to initialize any instance data or to use the TlsAlloc function to allocate a thread local storage (TLS) index.\nThe lpvReserved parameter indicates whether the DLL is being loaded statically or dynamically.</p>\n</blockquote>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/dlls/dllmain\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">DllMain entry point (Process.h) - Win32 apps | Microsoft Learn</a></p>\n<p>By the way, when I analyzed this DLL with Binary Ninja, I was able to obtain the following decompiled output.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 748px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/1146c995d7949b4a5a04b4bd1a20ccb8/f8915/image-20241231221310375.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: 21.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA00lEQVQY01WNy27CMBBF8ycUSERVUqDOQ3ZsTxySwK6bthv6/99xOqGqRBdHnrn3yJPFFOgkYmXEiejsiRLo+4iPQhzOeO1D8oxJ+JpnPqaJz2lmTunuizoyDHTqZ530jEPi+zJxu87cLlfeVfbpTJCk9Cr2+nm67zYIbjmWlmOaa299uONCJCuPR6rKMAZLci3BdrSNxZiGumpplMPJ6F5jG6eZ5u0brquwrsLUhpfywP71l6zY7diXz2z1XW1yVtucJ2X9wCYvWOePWfFvXvo/fgCnPoIULiBtMgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/1146c995d7949b4a5a04b4bd1a20ccb8/8ac56/image-20241231221310375.webp 240w,\n/static/1146c995d7949b4a5a04b4bd1a20ccb8/d3be9/image-20241231221310375.webp 480w,\n/static/1146c995d7949b4a5a04b4bd1a20ccb8/0bb9d/image-20241231221310375.webp 748w\"\n              sizes=\"(max-width: 748px) 100vw, 748px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/1146c995d7949b4a5a04b4bd1a20ccb8/8ff5a/image-20241231221310375.png 240w,\n/static/1146c995d7949b4a5a04b4bd1a20ccb8/e85cb/image-20241231221310375.png 480w,\n/static/1146c995d7949b4a5a04b4bd1a20ccb8/f8915/image-20241231221310375.png 748w\"\n            sizes=\"(max-width: 748px) 100vw, 748px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/1146c995d7949b4a5a04b4bd1a20ccb8/f8915/image-20241231221310375.png\"\n            alt=\"image-20241231221310375\"\n            title=\"image-20241231221310375\"\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<h3 id=\"best-practices-for-dllmain\" style=\"position:relative;\"><a href=\"#best-practices-for-dllmain\" aria-label=\"best practices for dllmain 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>Best Practices for DLLMain</h3>\n<p>The DllMain function appears to have several restrictions because it runs while the loader lock is held, as shown in the following diagram.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 258px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/47ca549f07eef12df075a503229b5feb/d9489/fig1.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: 245.41666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAxCAIAAABVih7fAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAE70lEQVRIx5VWS28bVRT2X4CfwBqkwqIrNkhdARFiwYZd1F1pJQRigVgAQoguABUKpVBUJSitkigxCUkcJ46dJ3n5kfgV14/x2+NnMva8PB57xnwzNw5OPHaSszi5vnO/c+55fTemdkdYlq1UKie6MAwDXa1WmY6Uy2VRFNvnxUT+tFotgI+Pj4GBTiaTpVIpGo0Wi8WyLkDyPN8XjM9ut3ttbW1mZmZpaQnricnJ9fV1i8WCn9lsttFoqKpqAG42mxzHSZIEE9CyLDcaUl2q64sG2cfVjMHYRWCIGXeGrjIngTAVTWbqolCr1QBD/LBifO1uIeZjqXw8Ww4FA1Q8TlEUru31epELcoCc6QtOpAuxTCEY8G9tba2srHg8HsS/v79/dmAwOEeli5IoQBALTdO4NhKOEBAgfhqDFR3sjNA7wYRrf3dx0To9PT0+Pg7/kUgEmUdFHA4Hcmnq9auphhR98mdu9p+6jExL8CnrgqIg7dAorYFnVVGgwz/86Lh7zzE8nLdYzjZ7xdTrVmaLye9vM+uPK+Zvjh58XG82ujOsduQimHgo+1f5J0P5X95jf3/fc/+deCTUneG+nlVFi4R2Lpx8/eoft29a770e/PLN52N/JRJJQ7yBZ8q789OHNz56+8ZnQ689vnPLf+ih84XLwUTkZitNF7b2PC7vC8yU0X0va88Alc2Uqv2ivQhG9WqnwooCt+eLBCNJrlYFM2DrksFgdUEPYPTBBFAcWyPDWK/XMbAw0RdMiALm7Xb72NjYyMjI8vLy/Py81WolPtHkg8CKgr5WCRmBvzDd2WwOt0AzYr8vDUEQFWDQuDwuWSxhXYM3rMknDFNfMNyKuvC8AApyesP54rFUF3lBIPtkGK5UqiMqw4lSe6CYztwSgXlF6zPVHYxWOQGWzj6pnfX/YJxGPXo9r7ljlarQmbRzguQTE6ZQKGSz2XK5HBbxePzw8DAcDmcymRhF7e7upNPpeDwB6kqlUvl8/uDgADlHLUGJGhj8Bk4hGhQHutne3gbjBAIBm22ZLMgnUOfs7Cx8AOxyuTTw4uLi3t7eWdhYoMjILTgHFULPgn0QCKJDn5GEw+Lm5qYGdjqdsKqNMU2Pjo4+0wVdZVmYn5qaMpvNsO7z+dBqoMFCQZtN7OA6GhhPGQkAVtEG6CdBb+ZIPKMnXiFucQWyxkk8gLidcZ21EFpNfzTn9hz4/X64TSQSSFgsFiOv7DnS753YliwHojmX27NktSJCJGxjYwN5QpMOfjHUU8+RDMcLkp4kxIKGJ30OjZ9YGPG2bhQ073BG9l3u1dVVlGdiAk/1JJ4rZBdNgUcDYRuAmyrbajOgsUAsh34QBB7JQwtCI2HYwQLFO+2w7pZkhNSC94t5/+cpxqlvKlcaDHLO7v15buehz23esn+i0EdiylWvlsjX3ueiC6znKZk9KjJl1vGb8PQD7vlw8dcht/lRocI05cZVqFdtttvZZ59Wvrs5cu+tzFdvbI9+u7L+b6lQuMqLobWu/cHdR0Mv37n1ysN3X1p6el9W26LAX+6Z2KaomGXu7xnztM1qKdC5Abxv3J5SQ36RKHVX/hpgjuP94bSWY0W5vFQXbl7jBFcw0WnWa4A1XWHY5d2QzhDqNcCDn8W+YILBf3pzc3OYB9ALyAzD0Mv1fcGYOFCcDyQQCGABWxiDfuD/AFH0sOgcDzhaAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/47ca549f07eef12df075a503229b5feb/8ac56/fig1.webp 240w,\n/static/47ca549f07eef12df075a503229b5feb/6976b/fig1.webp 258w\"\n              sizes=\"(max-width: 258px) 100vw, 258px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/47ca549f07eef12df075a503229b5feb/8ff5a/fig1.png 240w,\n/static/47ca549f07eef12df075a503229b5feb/d9489/fig1.png 258w\"\n            sizes=\"(max-width: 258px) 100vw, 258px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/47ca549f07eef12df075a503229b5feb/d9489/fig1.png\"\n            alt=\"what happens when a library is loaded\"\n            title=\"what happens when a library is loaded\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>As described in the public information below, which summarizes best practices for DllMain, you need to be careful not to cause deadlocks or crashes through DllMain behavior.</p>\n<p>For example, because the DllMain thread holds the loader lock, it cannot dynamically load additional DLLs.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/dlls/dynamic-link-library-best-practices\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Dynamic-Link Library Best Practices - Win32 apps | Microsoft Learn</a></p>\n<h2 id=\"load-a-dll-into-a-process\" style=\"position:relative;\"><a href=\"#load-a-dll-into-a-process\" aria-label=\"load a dll into a process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Load a DLL into a Process</h2>\n<p>A process can load a module file from disk by using the <code class=\"language-text\">LoadLibrary</code> function and specifying the module’s file name.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">HMODULE <span class=\"token function\">LoadLibraryA</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> LPCSTR lpLibFileName\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">LoadLibraryA function (libloaderapi.h) - Win32 apps | Microsoft Learn</a></p>\n<p>At this time, it seems that you can specify either a full path or just a file name for <code class=\"language-text\">lpLibFileName</code>, but if you specify only the file name, the DLL is loaded according to the standard search order.</p>\n<h3 id=\"dll-search-order\" style=\"position:relative;\"><a href=\"#dll-search-order\" aria-label=\"dll search order 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>DLL Search Order</h3>\n<p>The standard search order varies depending on several conditions, but for now, if the “safe DLL search mode,” which is enabled by default, is active and the application is not using an alternate search order, DLLs appear to be searched in the following order.</p>\n<ol>\n<li>The directory from which the application loaded.</li>\n<li>The system directory.</li>\n<li>The 16-bit system directory.</li>\n<li>The Windows directory.</li>\n<li>The current directory.</li>\n<li>The directories that are listed in the PATH environment variable.</li>\n</ol>\n<p>The key point is that the current directory, which is relatively easy to abuse, is lower in the order.</p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/dlls/dynamic-link-library-search-order\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Dynamic-link library search order - Win32 apps | Microsoft Learn</a></p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/dlls/dynamic-link-library-security\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Dynamic-Link Library Security - Win32 apps | Microsoft Learn</a></p>\n<p>In fact, when I tried this on my local Windows 10 environment, I was able to confirm events that seemed to show the DLL search proceeding in the order above, starting from the folder where the application’s executable file was located.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 895px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7ece8755ccd375b221b0c1e6a5a0aecf/fcbaf/image-20250101104959674.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: 64.58333333333334%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAACAElEQVQ4y4VT147bMBDk///c5S55sEhRstWLZRX3uplZn4zAwCEEFhJEcnbKyqRpLOM4yW63k6ZtZLvdyn6/l/v9LrfbTZ8/FdfhsJeyLPX+6XQSkyYLWXc9PmwlSVYSL5eyWq2krEoF/t86Ho84/7yz6Xsxof3A5UamcRTnLMpJFMcKXtW1bDYbBT4cDjJNE9SM+n77ZkgiQbCQoihkxL6J/B9pmk52kBpFXmKALcEySRLJi1zattXquk5qNGiaRptcr1cFZLMojrBXqV0mz5z0/age5HmGyrVbt+n0wOl80ouPx+NHyVmWSlEWyt5E4afUzRqSBwnDUIuyrbXKOMsyZUTwy+X8ApobkKELLVTFes6E7gtetSrZAyyKIgm9V9k0m4AV5FBuDbk9jH+CX16AHo3TNHkCZqmFvAEbO3xM1Tc+WXVTy/l8fjHiGNE71jw2lEy/C9wbKNm7X1JVrWyRUBAEYpE05abwhWzoC9N91qgA75J5PoYy+m58+BtyWo3fWYIF4iE5hieU+5RcY3gLZcG0OcBzRgSMkTIVkYDJUwftg27MUpl0gic95IAPQ68MyW7+e2aGmjKmgynzjIn9F7ziiExI2Ck7VgKTGcQwDAryvv6VzGlg8x6NjbOf8LBRwAUm3sJH9w28hrwB40QfmSCZUu47oPeh/lkdzvwFkw/W7OOhvGkAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/7ece8755ccd375b221b0c1e6a5a0aecf/8ac56/image-20250101104959674.webp 240w,\n/static/7ece8755ccd375b221b0c1e6a5a0aecf/d3be9/image-20250101104959674.webp 480w,\n/static/7ece8755ccd375b221b0c1e6a5a0aecf/dcb2d/image-20250101104959674.webp 895w\"\n              sizes=\"(max-width: 895px) 100vw, 895px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/7ece8755ccd375b221b0c1e6a5a0aecf/8ff5a/image-20250101104959674.png 240w,\n/static/7ece8755ccd375b221b0c1e6a5a0aecf/e85cb/image-20250101104959674.png 480w,\n/static/7ece8755ccd375b221b0c1e6a5a0aecf/fcbaf/image-20250101104959674.png 895w\"\n            sizes=\"(max-width: 895px) 100vw, 895px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/7ece8755ccd375b221b0c1e6a5a0aecf/fcbaf/image-20250101104959674.png\"\n            alt=\"image-20250101104959674\"\n            title=\"image-20250101104959674\"\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<h3 id=\"run-an-exported-function-from-a-process-with-rundll32exe\" style=\"position:relative;\"><a href=\"#run-an-exported-function-from-a-process-with-rundll32exe\" aria-label=\"run an exported function from a process with rundll32exe 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>Run an Exported Function from a Process with rundll32.exe</h3>\n<p>You can also call functions exported by the DLL you created by using <code class=\"language-text\">rundll32.exe</code>.</p>\n<p>Below is the command that runs the <code class=\"language-text\">ShowMessage2</code> function exported by the <code class=\"language-text\">TESTDLL.dll</code> created earlier.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># rundll32.exe &lt;DLL file>,&lt;Export function></span>\nrundll32.exe TESTDLL.dll,ShowMessage2</code></pre></div>\n<p>When you actually run the command above, you can confirm that the exported function you defined is called.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 545px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/29015ebd9e723ba65027a2a3d18e64e5/3ddad/image-20250101121830055.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: 42.91666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAABhUlEQVQoz5WSzWrCQBSFowsRjaJudVGDWEjbZGEtNrHtzpW6En0NH6Au4s8b9KmK4FqFaiGa1koTBU1NjKeZCUJXtr1wcoch891z7wwj3fK4uT6HKHAQrjhcXpwhm80il8shn88jlUpBFEWaM5kMBEEAz/NIp9M0x2IxMAwDv9+PcDgMhmVZuohEIiBrlg0jFApRkf1oNIpgMIhkMolqtYpKpYJyuYxarYZGo0FzvV5HqVSi/zLk0BF6lAf2RAqR6pIkYT6fQ9M0TCYTrNdr7Pd7WJYFEoPBAIlEwnN4SqQqAcqyDNu24cXB+x4OFEpiOBwiHo+fBh5b9vl8eLi/g/ZuQHl6xnQ6w8di4bp9g6rOsNvtMBqNvHn+FVgsytiaX3h51d02bTiOA+eHw/F4/HcgablQKMAwdNjWls5vtVpB1z+xXC6x2WzQ7/f/55DMkFwAcUVmZ5qmCzWgzlTXuUmBv17K8TkFAgFwHId2u41er4dut4tOp4NWq4VHV4qioNls0uLfEEll1LuwvJgAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/29015ebd9e723ba65027a2a3d18e64e5/8ac56/image-20250101121830055.webp 240w,\n/static/29015ebd9e723ba65027a2a3d18e64e5/d3be9/image-20250101121830055.webp 480w,\n/static/29015ebd9e723ba65027a2a3d18e64e5/6305f/image-20250101121830055.webp 545w\"\n              sizes=\"(max-width: 545px) 100vw, 545px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/29015ebd9e723ba65027a2a3d18e64e5/8ff5a/image-20250101121830055.png 240w,\n/static/29015ebd9e723ba65027a2a3d18e64e5/e85cb/image-20250101121830055.png 480w,\n/static/29015ebd9e723ba65027a2a3d18e64e5/3ddad/image-20250101121830055.png 545w\"\n            sizes=\"(max-width: 545px) 100vw, 545px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/29015ebd9e723ba65027a2a3d18e64e5/3ddad/image-20250101121830055.png\"\n            alt=\"image-20250101121830055\"\n            title=\"image-20250101121830055\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows-server/administration/windows-commands/rundll32\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">rundll32 | Microsoft Learn</a></p>\n<p>This <code class=\"language-text\">rundll32.exe</code> appears to load DLLs by using the <code class=\"language-text\">LoadLibraryExW</code> function.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">HMODULE <span class=\"token function\">LoadLibraryExW</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> LPCWSTR lpLibFileName<span class=\"token punctuation\">,</span>\n       HANDLE  hFile<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> DWORD   dwFlags\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://www.cybereason.co.jp/blog/security/8909/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Rundll32: The Infamous Proxy for Executing Malicious Code | BLOG | Cybereason | EDR (Next-Generation Endpoint Security)</a></p>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">LoadLibraryExW function (libloaderapi.h) - Win32 apps | Microsoft Learn</a></p>\n<h2 id=\"load-a-dll-into-a-remote-process\" style=\"position:relative;\"><a href=\"#load-a-dll-into-a-remote-process\" aria-label=\"load a dll into a remote process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Load a DLL into a Remote Process</h2>\n<p>After the method for loading a DLL within a local process, next I will try a method for loading a specific DLL into a remote process.</p>\n<p>Note that the DLL injection technique itself is not something used exclusively for malware; it is also used by commercial software such as security software.</p>\n<p>For example, official documentation explains that SEP depends on injecting <code class=\"language-text\">sysfer.dll</code> into other processes in the system.</p>\n<p>Reference: <a href=\"https://knowledge.broadcom.com/external/article/181736/how-to-create-an-application-control-exc.html?utm_source=chatgpt.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">How to create an Application Control exception or stop sysfer.dll injection into a process with Endpoint Protection</a></p>\n<p>There was no official information describing the technique SEP uses for DLL injection, but according to the article below, there is a description suggesting that it uses <code class=\"language-text\">KeInitializeApc</code> and <code class=\"language-text\">KeInsertQueueApc</code>.</p>\n<p>Reference: <a href=\"https://community.osr.com/t/security-software-and-undocumented-api-usage/53297\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Security Software and Undocumented API Usage - NTDEV - OSR Developer Community</a></p>\n<h3 id=\"load-a-dll-into-a-remote-process-with-virtualallocex-and-writeproessmemory\" style=\"position:relative;\"><a href=\"#load-a-dll-into-a-remote-process-with-virtualallocex-and-writeproessmemory\" aria-label=\"load a dll into a remote process with virtualallocex and writeproessmemory 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>Load a DLL into a Remote Process with VirtualAllocEx and WriteProessMemory</h3>\n<p>This time, I will try a DLL injection technique in which memory allocated in a remote process with the <code class=\"language-text\">VirtualAllocEx</code> function is used to store the path of the DLL to load by using the <code class=\"language-text\">WriteProessMemory</code> function, and then the code is loaded by the <code class=\"language-text\">LoadLibrary</code> function executed through the <code class=\"language-text\">CreateRemoteThread</code> function.</p>\n<p>Note that the method tried here loads a DLL into a remote process by using legitimate APIs provided by Microsoft.</p>\n<p>As mentioned above, the DLL injection technique itself is also used by legitimate tools, and this operation itself does not perform any kind of unauthorized attack.</p>\n<p><em>However, just to be safe, this article does not include copy-and-paste-ready code and instead includes only general Windows API call code.</em></p>\n<p>To load a DLL into a remote process, first use the PID of the target process received by the <code class=\"language-text\">scanf_s</code> function, and obtain a handle to the target process with the <code class=\"language-text\">OpenProcess</code> function.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">HANDLE <span class=\"token function\">OpenProcess</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> DWORD dwDesiredAccess<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> BOOL  bInheritHandle<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span> DWORD dwProcessId\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OpenProcess function (processthreadsapi.h) - Win32 apps | Microsoft Learn</a></p>\n<p>Although this assumes that the PID is entered manually, you can also obtain a handle to the target process by enumerating and searching processes in the system from within the program.</p>\n<p>Reference: <a href=\"/win32api-getprocesslist\">Trying to Enumerate Process Information in the System with the Win32 API - Kaeru no Himitsukichi</a></p>\n<p>Once you have obtained the process handle, call the <code class=\"language-text\">VirtualAllocEx</code> function with that process handle as an argument to allocate memory in the remote process for writing the file name of the DLL to load.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">pAddress <span class=\"token operator\">=</span> <span class=\"token function\">VirtualAllocEx</span><span class=\"token punctuation\">(</span>hProcess<span class=\"token punctuation\">,</span> <span class=\"token constant\">NULL</span><span class=\"token punctuation\">,</span> dwSizeToWrite<span class=\"token punctuation\">,</span> MEM_COMMIT <span class=\"token operator\">|</span> MEM_RESERVE<span class=\"token punctuation\">,</span> PAGE_READWRITE<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/memoryapi/nf-memoryapi-virtualallocex\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">VirtualAllocEx function (memoryapi.h) - Win32 apps | Microsoft Learn</a></p>\n<p>Next, use the <code class=\"language-text\">WriteProcessMemory</code> function to write the DLL file name into the memory region allocated in the remote process.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token function\">WriteProcessMemory</span><span class=\"token punctuation\">(</span>hProcess<span class=\"token punctuation\">,</span> pAddress<span class=\"token punctuation\">,</span> DLLFileName<span class=\"token punctuation\">,</span> dwSizeToWrite<span class=\"token punctuation\">,</span> <span class=\"token operator\">&amp;</span>lpNumberOfBytesWritten<span class=\"token punctuation\">)</span> <span class=\"token operator\">||</span> lpNumberOfBytesWritten <span class=\"token operator\">!=</span> dwSizeToWrite<span class=\"token punctuation\">)</span></code></pre></div>\n<p>The data to write is specified by the third argument of the <code class=\"language-text\">WriteProcessMemory</code> function.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">BOOL <span class=\"token function\">WriteProcessMemory</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  HANDLE  hProcess<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  LPVOID  lpBaseAddress<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  LPCVOID lpBuffer<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  SIZE_T  nSize<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>out<span class=\"token punctuation\">]</span> SIZE_T  <span class=\"token operator\">*</span>lpNumberOfBytesWritten\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/memoryapi/nf-memoryapi-writeprocessmemory\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">WriteProcessMemory function (memoryapi.h) - Win32 apps | Microsoft Learn</a></p>\n<p>Finally, use the <code class=\"language-text\">GetProcAddress</code> function to obtain the address of the <code class=\"language-text\">LoadLibraryW</code> function exported by <code class=\"language-text\">kernel32.dll</code>, and start a thread in the target process by using the <code class=\"language-text\">CreateRemoteThread</code> function.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">LPVOIDpLoadLibraryW <span class=\"token operator\">=</span> <span class=\"token function\">GetProcAddress</span><span class=\"token punctuation\">(</span><span class=\"token function\">GetModuleHandle</span><span class=\"token punctuation\">(</span>L<span class=\"token string\">\"kernel32.dll\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"LoadLibraryW\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\nHANDLEhThread <span class=\"token operator\">=</span> <span class=\"token function\">CreateRemoteThread</span><span class=\"token punctuation\">(</span>hProcess<span class=\"token punctuation\">,</span> <span class=\"token constant\">NULL</span><span class=\"token punctuation\">,</span> <span class=\"token constant\">NULL</span><span class=\"token punctuation\">,</span> pLoadLibraryW<span class=\"token punctuation\">,</span> pAddress<span class=\"token punctuation\">,</span> <span class=\"token constant\">NULL</span><span class=\"token punctuation\">,</span> <span class=\"token constant\">NULL</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GetProcAddress function (libloaderapi.h) - Win32 apps | Microsoft Learn</a></p>\n<p>The <code class=\"language-text\">CreateRemoteThread</code> function can create a thread that runs in the virtual address space of another process.</p>\n<p>You specify the address of the obtained <code class=\"language-text\">LoadLibraryW</code> function for <code class=\"language-text\">lpStartAddress</code>, and for <code class=\"language-text\">lpParameter</code>, which is the argument passed to the thread function, you specify a pointer to the file name of the DLL to load that was written into the target process’s memory.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">HANDLE <span class=\"token function\">CreateRemoteThread</span><span class=\"token punctuation\">(</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  HANDLE                 hProcess<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  LPSECURITY_ATTRIBUTES  lpThreadAttributes<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  SIZE_T                 dwStackSize<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  LPTHREAD_START_ROUTINE lpStartAddress<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  LPVOID                 lpParameter<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>in<span class=\"token punctuation\">]</span>  DWORD                  dwCreationFlags<span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">[</span>out<span class=\"token punctuation\">]</span> LPDWORD                lpThreadId\n<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Reference: <a href=\"https://learn.microsoft.com/ja-jp/windows/win32/api/processthreadsapi/nf-processthreadsapi-createremotethread\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CreateRemoteThread function (processthreadsapi.h) - Win32 apps | Microsoft Learn</a></p>\n<p>By the way, the reason the address of the <code class=\"language-text\">LoadLibraryW</code> function obtained in the local process can be reused as-is in the arguments to the <code class=\"language-text\">CreateRemoteThread</code> function that runs in the remote process is that the address of <code class=\"language-text\">kernel32.dll</code> is shared across processes. (Therefore, if the local process and the target process have different bitness, it seems this method cannot be used to load the DLL.)</p>\n<p>By performing this series of operations, I was able to load an arbitrary DLL into the target process specified by PID.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 769px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/672e8592891711b170d621a278a048cb/227ba/image-20250105203913817.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: 26.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsTAAALEwEAmpwYAAABHklEQVQY01VPzUrDYBDMNU2bhuaXxjS/TQgJDYQc+nD2GfIOXgrSgEiDShsUb6IP4DtU2oMgarBj9pMe/GCYZb7d2VnOcRx4nocwDBFFEeI4Zuz7HqZTG0niI02CrucM/b4Anu9BEP54sTjH1eoSy+USdV2jqipwQRCgKArkeY40TTGbzZBlWWeUMG0+n7N/3/ehqip0XcdoNMKgM79rHvCO/48zDAOU0nVdjMdjltayLDZITLppmlAUBZIkQZZliKKIQY/HRbXG6vUDh7cdDvs92rYFRyY0RKC0J0Ni27YZJpMJS0U69ROTcbPdsFSf3y2+2iN+jl3C01Y6h0A1DVMiTdOYRjWBrjnpw+EQZVni6fkF69strm82aO4f8QvGmroAi2+XQwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/672e8592891711b170d621a278a048cb/8ac56/image-20250105203913817.webp 240w,\n/static/672e8592891711b170d621a278a048cb/d3be9/image-20250105203913817.webp 480w,\n/static/672e8592891711b170d621a278a048cb/85eee/image-20250105203913817.webp 769w\"\n              sizes=\"(max-width: 769px) 100vw, 769px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/672e8592891711b170d621a278a048cb/8ff5a/image-20250105203913817.png 240w,\n/static/672e8592891711b170d621a278a048cb/e85cb/image-20250105203913817.png 480w,\n/static/672e8592891711b170d621a278a048cb/227ba/image-20250105203913817.png 769w\"\n            sizes=\"(max-width: 769px) 100vw, 769px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/672e8592891711b170d621a278a048cb/227ba/image-20250105203913817.png\"\n            alt=\"image-20250105203913817\"\n            title=\"image-20250105203913817\"\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><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 451px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ecdfe4ed5d5f15894adb16580d2db139/38070/image-20250105204019521.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 43.333333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3klEQVQozzVS2Y7aQBD0/39JoiiK8ggIknDtwoYFDMaA7xsMxge2weao9AyKpVLXVFe3umcsqJsPSNIa67UMTdMorrFarbDdbiGKIo9ZlqEsS+R5jqIoOC+KF8/zM48vnkPQdQNBEMA0LQ7P82EYBnETvh9w7nkeXNflZ9f1SLOI77h/vw/hOA73e74PgU3lE2EFDpmPxyMZXG6KohN8ahYEOyrcYx+GXGNNDoeI+9iZ5Vk904WIGogLCeHhiPJyodFLVFXNwc/lS2MoiTOtqmtcrxXneU7rlq8c8wg2TXIh4fm4A3giS1PYlkkrGDjQRJTA/VbzfBju+AZsPdPQcaWGTH/cbxzMJ0zmEkRZhWJ6sIIIh7jAx2yJ8XSB0V8RXpigvAHO7oTpYo39KUdKQpxXKGrw3H+crw8IP3orfPs1x883FUO9wEBJ8LUzw/ffc3xpfqI13eHTf6KvZKQt0N2cMNTO6Ckp/mxiHrvbBAM1w9ipIDi2BVmWsd1sECcx6usVK0nChn4jmWISx2BffIqgKlt6BBYVntdUhXt1XSdodHUFhPFohEajiX5vCMu2EUcxBoMBOu0O2o02HNvjDdM0Qa/bg+14eH8fYTKZYjabYbFcotVsoT94o4es8A9yHpUiH8TP3gAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ecdfe4ed5d5f15894adb16580d2db139/8ac56/image-20250105204019521.webp 240w,\n/static/ecdfe4ed5d5f15894adb16580d2db139/8f864/image-20250105204019521.webp 451w\"\n              sizes=\"(max-width: 451px) 100vw, 451px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ecdfe4ed5d5f15894adb16580d2db139/8ff5a/image-20250105204019521.png 240w,\n/static/ecdfe4ed5d5f15894adb16580d2db139/38070/image-20250105204019521.png 451w\"\n            sizes=\"(max-width: 451px) 100vw, 451px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ecdfe4ed5d5f15894adb16580d2db139/38070/image-20250105204019521.png\"\n            alt=\"image-20250105204019521\"\n            title=\"image-20250105204019521\"\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>At that time, the search order for the DLL to load was, by default, the same as the standard search order.</p>\n<p>However, because the process doing the loading is the remote process, the preferred lookup location is not the execution folder of the program performing the DLL injection, but the folder where the target process’s executable file exists.</p>\n<p>Therefore, when performing DLL injection with this method, you need to specify the full path to the target DLL file or place the DLL file to be loaded in advance in the application folder, system folder, or another folder included in PATH.</p>\n<p><em>Below is the search order for <code class=\"language-text\">TESTDLL.dll</code> when attempting DLL injection into Notepad++.</em></p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 872px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/1416430c82907b0d64507f9dd2ae1368/65654/image-20250105204238809.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.666666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGUlEQVQoz22SW3OiQBCF+f8/JsatZN/2bSvKVQUhROQuN4FdVESMl7M9Y9akaneqTjFUz3zdfXoE208QBgGWXoCAvp7vwyd5no88L9AdOuy7A9r9ATtS1/U49Mcv6tHTt//YC1VSY1O3SKMQ+zKFEzhoYw91nqKpIlwuLbSigeoGkCwftmcCOJGun7qeP/aA8CD6GIyXGCgJhpMcg5GFoZbhQUkxlCM8T3M8qgl+vG3wZO3wzWzw3W65nl93pBaPGp0RAzzpJQTrzYI6kWA71HKcQpmOsfBCREmOnyMJoqJhbtmI0xxNe+D6vd2j3rTYHd7xToW5YYwXUUa4yiB4ng1zriCOYqyLHKYpIVmtUJVrTCcTvFomls6C4iGPl+uCx4o8Q0/+spWlKXR9hl91BWG5fKUfGX4QIssy6IaEKIpoIDkURaGYTklMuB75Wtdo25Z8veDrSpIEsiwjjmMIjmPBMAjoB0gp00wfIQwjFEXBgdPpFKqqcii7wJKu12s0TUOT7e9AURQ/gbOZBNf1b8DZmJ5PyIGSJHHohFpnhzebDQcxdV2H8/n8L3CxMKktib+7NE0I+EIV3oDsEIMahgHHcSipy8Xe6Xa7xfV6/X+Fhn5rOcuYueM7kPnCqmMts9bZRVbl8XjE6XS6e8lsuHvoujbmNOWQRs8GYcxvmaqq4iAGtG0bZVnyVtlQWLts/a2QATVN45b9Af05IjRpLSz0AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/1416430c82907b0d64507f9dd2ae1368/8ac56/image-20250105204238809.webp 240w,\n/static/1416430c82907b0d64507f9dd2ae1368/d3be9/image-20250105204238809.webp 480w,\n/static/1416430c82907b0d64507f9dd2ae1368/a8a2c/image-20250105204238809.webp 872w\"\n              sizes=\"(max-width: 872px) 100vw, 872px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/1416430c82907b0d64507f9dd2ae1368/8ff5a/image-20250105204238809.png 240w,\n/static/1416430c82907b0d64507f9dd2ae1368/e85cb/image-20250105204238809.png 480w,\n/static/1416430c82907b0d64507f9dd2ae1368/65654/image-20250105204238809.png 872w\"\n            sizes=\"(max-width: 872px) 100vw, 872px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/1416430c82907b0d64507f9dd2ae1368/65654/image-20250105204238809.png\"\n            alt=\"image-20250105204238809\"\n            title=\"image-20250105204238809\"\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<h2 id=\"about-reflective-dll-injection\" style=\"position:relative;\"><a href=\"#about-reflective-dll-injection\" aria-label=\"about reflective dll injection 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>About Reflective DLL Injection</h2>\n<p>The DLL injection method above simply loads a DLL that exists as a file.</p>\n<p>However, when DLL injection techniques are used for malicious purposes, it seems that a technique called Reflective DLL Injection is often abused instead of this kind of classic method.</p>\n<p>Reference: <a href=\"https://msmania.github.io/2015/04/27/reflective-dll-injection.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Reflective DLL Injection | Sunano Katamari</a></p>\n<p>Reference: <a href=\"https://cyberfortress.jp/2020/10/30/reflective-dll-injection/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Investigating Malware with Reflective DLL Injection - CyberFortress</a></p>\n<p>I will not describe the detailed implementation because it could potentially cause some trouble, but the articles above explained it in great detail and were very helpful.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>This time, I summarized several methods for loading DLLs on Windows.</p>","fields":{"slug":"/windows-create-dll-en","tagSlugs":["/tag/win-dbg/","/tag/reversing/","/tag/english/"]},"frontmatter":{"date":"2025-01-05","description":"I created a DLL file on Windows and tried loading it into a process in various ways.","tags":["WinDbg","Reversing","English"],"title":"Create a DLL File on Windows and Try Loading It into a Process in Various Ways","socialImage":{"publicURL":"/static/ef75a61ab35d3aa8f659b3ad8e77557e/windows-create-dll.png"}}}},"pageContext":{"slug":"/windows-create-dll-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}