<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[kann sich eine DLL selber injecten?]]></title><description><![CDATA[<p>Ich habs mal so probiert - ohne Erfolg. Geht es nicht oder ist mein Code falsch?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;cstdio&gt;

typedef HINSTANCE (*fpLoadLibrary)(char*);
typedef LPVOID (*fpGetProcAddress)(HINSTANCE, char*);
typedef void (*fpFunktion)(void);

struct INJECTSTRUCT
{
      fpLoadLibrary LoadLibrary;
      fpGetProcAddress GetProcAddress;
      char path[255];
      char func[255];
};

DWORD WINAPI threadstart(LPVOID addr)
{
	HINSTANCE hDll;
	fpFunktion funktion;
	INJECTSTRUCT * is = (INJECTSTRUCT*)addr;       
	hDll = is-&gt;LoadLibrary(is-&gt;path);
	funktion = (fpFunktion)is-&gt;GetProcAddress(hDll, is-&gt;func);
	funktion();
	return 0;
}
void threadend()
{
}

extern &quot;C&quot; void __declspec(dllexport) Funktion()
{
   HANDLE hProc;
   LPVOID start, thread;
   DWORD funcsize, written;
   HINSTANCE hDll;
   INJECTSTRUCT is;
   DWORD id = 3972;
   hDll = LoadLibrary(&quot;KERNEL32&quot;);
   is.LoadLibrary = (fpLoadLibrary)GetProcAddress(hDll, &quot;LoadLibraryA&quot;);
   is.GetProcAddress = (fpGetProcAddress)GetProcAddress(hDll, &quot;GetProcAddress&quot;);
   strcpy(is.path, &quot;C:\\DLL.dll&quot;);
   strcpy(is.func, &quot;Funktion2&quot;);

   hProc = OpenProcess(PROCESS_ALL_ACCESS, false, id);
   printf(&quot;Prozess Handle:       %x\n&quot;, hProc);
start = VirtualAllocEx(hProc, 0, funcsize+sizeof(INJECTSTRUCT), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
printf(&quot;Memory:               %x\n&quot;, start);
WriteProcessMemory(hProc, start, (LPVOID)&amp;is, sizeof(INJECTSTRUCT), NULL);

thread = (LPVOID)((DWORD)start+sizeof(INJECTSTRUCT));

WriteProcessMemory(hProc, thread, (LPVOID)threadstart, funcsize, NULL);
CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)thread, start, 0, 0);
   CloseHandle(hProc);
}

extern &quot;C&quot; void __declspec(dllexport) Funktion2()
{
    MessageBox(0, &quot;selbst ist die DLL!&quot;, &quot;xD&quot;, 0);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/234566/kann-sich-eine-dll-selber-injecten</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 00:10:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/234566.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Feb 2009 13:44:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 13:44:39 GMT]]></title><description><![CDATA[<p>Ich habs mal so probiert - ohne Erfolg. Geht es nicht oder ist mein Code falsch?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;cstdio&gt;

typedef HINSTANCE (*fpLoadLibrary)(char*);
typedef LPVOID (*fpGetProcAddress)(HINSTANCE, char*);
typedef void (*fpFunktion)(void);

struct INJECTSTRUCT
{
      fpLoadLibrary LoadLibrary;
      fpGetProcAddress GetProcAddress;
      char path[255];
      char func[255];
};

DWORD WINAPI threadstart(LPVOID addr)
{
	HINSTANCE hDll;
	fpFunktion funktion;
	INJECTSTRUCT * is = (INJECTSTRUCT*)addr;       
	hDll = is-&gt;LoadLibrary(is-&gt;path);
	funktion = (fpFunktion)is-&gt;GetProcAddress(hDll, is-&gt;func);
	funktion();
	return 0;
}
void threadend()
{
}

extern &quot;C&quot; void __declspec(dllexport) Funktion()
{
   HANDLE hProc;
   LPVOID start, thread;
   DWORD funcsize, written;
   HINSTANCE hDll;
   INJECTSTRUCT is;
   DWORD id = 3972;
   hDll = LoadLibrary(&quot;KERNEL32&quot;);
   is.LoadLibrary = (fpLoadLibrary)GetProcAddress(hDll, &quot;LoadLibraryA&quot;);
   is.GetProcAddress = (fpGetProcAddress)GetProcAddress(hDll, &quot;GetProcAddress&quot;);
   strcpy(is.path, &quot;C:\\DLL.dll&quot;);
   strcpy(is.func, &quot;Funktion2&quot;);

   hProc = OpenProcess(PROCESS_ALL_ACCESS, false, id);
   printf(&quot;Prozess Handle:       %x\n&quot;, hProc);
start = VirtualAllocEx(hProc, 0, funcsize+sizeof(INJECTSTRUCT), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
printf(&quot;Memory:               %x\n&quot;, start);
WriteProcessMemory(hProc, start, (LPVOID)&amp;is, sizeof(INJECTSTRUCT), NULL);

thread = (LPVOID)((DWORD)start+sizeof(INJECTSTRUCT));

WriteProcessMemory(hProc, thread, (LPVOID)threadstart, funcsize, NULL);
CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)thread, start, 0, 0);
   CloseHandle(hProc);
}

extern &quot;C&quot; void __declspec(dllexport) Funktion2()
{
    MessageBox(0, &quot;selbst ist die DLL!&quot;, &quot;xD&quot;, 0);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1666425</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666425</guid><dc:creator><![CDATA[dllinjectorx3]]></dc:creator><pubDate>Thu, 19 Feb 2009 13:44:39 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 14:41:57 GMT]]></title><description><![CDATA[<p>GetLastError(). It helps.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666475</guid><dc:creator><![CDATA[Advisory]]></dc:creator><pubDate>Thu, 19 Feb 2009 14:41:57 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 15:22:06 GMT]]></title><description><![CDATA[<p>Verwende erstmal unfrickligeren Code. Eine DLL in einen Prozessraum mappen geht sauber mit 7 Zeilen, du brauchst nur das Prozess-Handle und den Pfad zur DLL.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666489</guid><dc:creator><![CDATA[Entfrickler]]></dc:creator><pubDate>Thu, 19 Feb 2009 15:22:06 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 15:37:07 GMT]]></title><description><![CDATA[<p>der Code hab ich ja aus einem Tutorial, der stimmt sicherlich. Es geht hier nur darum dass eine DLL sich selber in einen anderen Prozess lädt(natürlich muss sie von einer exe gestartet werden) ist das möglich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666508</guid><dc:creator><![CDATA[dllinjectorx3]]></dc:creator><pubDate>Thu, 19 Feb 2009 15:37:07 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 15:45:14 GMT]]></title><description><![CDATA[<p>ja na klar wieso soll das nich gehen, is doch völlig egal ob der die aufrufe zu VirtualWrite etc inner exe oder inner dll sind is genau das gleiche <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666515</guid><dc:creator><![CDATA[sappari_nai]]></dc:creator><pubDate>Thu, 19 Feb 2009 15:45:14 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 16:15:28 GMT]]></title><description><![CDATA[<p>ja aber die Funktion die ich injecte befindet sich in der selben DLL!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666532</guid><dc:creator><![CDATA[dllinjectorx3]]></dc:creator><pubDate>Thu, 19 Feb 2009 16:15:28 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 16:38:13 GMT]]></title><description><![CDATA[<p>na und, des is doch völlig latex, dieser frickel code is aber echt ma hässlich, mach das ordentlich schritt für schritt und dann wirds auch gehen. irgendwelchen frickel code aus tutorials von irgendwelchen selbsternannten &quot;experten&quot; zu kopieren is meist keine gute idee und ich hab jetzt och kene lust dei code zu debugg0rn. also entweder mit GetLastError() schauen wo es hakt oder sauberen eigenen code schreibz0rn</p>
<p>have fun</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666551</guid><dc:creator><![CDATA[sappari_nai]]></dc:creator><pubDate>Thu, 19 Feb 2009 16:38:13 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 17:19:31 GMT]]></title><description><![CDATA[<p>GetLastError gibt 87 zurück und das heißt Invalide Parameter aber das hilft mir auch nicht weiter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666578</guid><dc:creator><![CDATA[dllinjectorx3]]></dc:creator><pubDate>Thu, 19 Feb 2009 17:19:31 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 17:21:34 GMT]]></title><description><![CDATA[<p>GetLastError() nach welcher Funktion <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666579</guid><dc:creator><![CDATA[Entfrickler]]></dc:creator><pubDate>Thu, 19 Feb 2009 17:21:34 GMT</pubDate></item><item><title><![CDATA[Reply to kann sich eine DLL selber injecten? on Thu, 19 Feb 2009 17:32:31 GMT]]></title><description><![CDATA[<p>ups hab mich vertan, nach dem 2. WriteProcessMemory bekomme ich 487 Error Code</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1666586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1666586</guid><dc:creator><![CDATA[dllinjectorx3]]></dc:creator><pubDate>Thu, 19 Feb 2009 17:32:31 GMT</pubDate></item></channel></rss>