<?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[CreateRemoteThread funktioniert nicht richtig]]></title><description><![CDATA[<p>Ich wollte mein Programm mit Hilfe von CreateRemoteThread in ein anderes Programm laden, das komische ist nur, dass alles im Loader richtig funktioniert und die DLL ebenfalls, doch wenn dich den Loader starte, dann wird die DLL nicht aufgerufen (DllMain wird nie betreten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> ). Habe es erst 2mal hinbekommen, dass es ganz kurz das Programm startet, aber es wurde sofort wieder beendet.</p>
<p>Der Loader sieht so aus (Die DllMain hatte mal zum test nur eine MessageBox+ return TRUE drin, doch nichtmal das ging <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> ):</p>
<p>Die log-datei hab ich nur mal zu testzwecken reingetan.</p>
<p>Die Prozess-ID hab ich mir aus dem Task Manager geholt und gehört im mom dem VC++</p>
<p>Habe auch keine Programme drauf die solche &quot;bösen&quot; Programme blockieren und nen Testprogramm ausm Inet funktioniert auch (das lädt, aber keine dll sondern ne funktion in den anderen prozess).</p>
<pre><code class="language-cpp">int WINAPI WinMain (IN HINSTANCE hinst, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
{
	char lib[] = &quot;hookd32.dll&quot;;
	HANDLE process = NULL;
	HANDLE thread = NULL;
	PSTR LibFileRemote = NULL;
	ofstream log (&quot;log.txt&quot;);

	log &lt;&lt; &quot;process = ::OpenProcess (PROCESS_ALL_ACCESS, FALSE, 2076);&quot; &lt;&lt; endl;
	process = ::OpenProcess (PROCESS_ALL_ACCESS, FALSE, 2076);
	if (process == NULL)
	{
		log &lt;&lt; &quot;Open Process fehlgeschlagen&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Open Process fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	log &lt;&lt; &quot;LibFileRemote = (PSTR)::VirtualAllocEx (process,&quot;
		&lt;&lt; &quot;NULL, 13, MEM_COMMIT,PAGE_READWRITE);&quot; &lt;&lt; endl;
	LibFileRemote = (PSTR)::VirtualAllocEx (process, NULL, 13, MEM_COMMIT,
											PAGE_READWRITE);
	if (LibFileRemote == NULL)
	{	
		log &lt;&lt; &quot;Virtual Alloc Ex fehlgeschlagen&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Virtual Alloc Ex fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	log &lt;&lt; &quot;WriteProcessMemory (process, (PVOID)LibFileRemote,lib, 13, NULL)&quot; &lt;&lt; endl;
	if (!::WriteProcessMemory (process, (PVOID)LibFileRemote,lib,
							   13, NULL))
	{
		log &lt;&lt; &quot;Write Process Memory fehlgeschlagen&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Write Process Memory fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}
	char buffer[128];
	::ReadProcessMemory (process, (LPCVOID)LibFileRemote, buffer, 128, NULL);
	log &lt;&lt; endl &lt;&lt; endl &lt;&lt; buffer &lt;&lt; endl &lt;&lt; endl;

	log &lt;&lt; &quot;PTHREAD_START_ROUTINE pLoadLibraryA =&quot; 
		&lt;&lt; &quot;(PTHREAD_START_ROUTINE)::GetProcAddress (&quot;
		&lt;&lt; &quot;::GetModuleHandle (\&quot;kernel32\&quot;), \&quot;LoadLibraryA\&quot;);&quot; &lt;&lt; endl;
	PTHREAD_START_ROUTINE pLoadLibraryA = 
		(PTHREAD_START_ROUTINE)::GetProcAddress (
									::GetModuleHandle (&quot;kernel32&quot;), &quot;LoadLibraryA&quot;);

	if (pLoadLibraryA == NULL)
	{
		log &lt;&lt; &quot;Load Library A konnte nicht geladen werden&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Load Library A konnte nicht geladen werden&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	log &lt;&lt; &quot;thread = ::CreateRemoteThread (process, NULL, 0, pLoadLibraryA, (PVOID)LibFileRemote, 0, NULL);&quot; &lt;&lt; endl;
	thread = ::CreateRemoteThread (process, NULL, 0, pLoadLibraryA, (PVOID)LibFileRemote,
						  0, NULL);

	if (thread == NULL)
	{
		log &lt;&lt; &quot;Create Remote Thread fehlgeschlagen&quot; &lt;&lt; endl; 
		MessageBox (0, &quot;Create Remote Thread fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	HMODULE libr = LoadLibrary (&quot;sensui32.dll&quot;);

	log &lt;&lt; &quot;::CloseHandle (thread);&quot; &lt;&lt; endl;
	::CloseHandle (thread);
	log &lt;&lt; &quot;::CloseHandle (process);&quot; &lt;&lt; endl;
	::CloseHandle (process);

return 0;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/86547/createremotethread-funktioniert-nicht-richtig</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 18:30:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/86547.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Sep 2004 15:25:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Mon, 20 Sep 2004 15:25:38 GMT]]></title><description><![CDATA[<p>Ich wollte mein Programm mit Hilfe von CreateRemoteThread in ein anderes Programm laden, das komische ist nur, dass alles im Loader richtig funktioniert und die DLL ebenfalls, doch wenn dich den Loader starte, dann wird die DLL nicht aufgerufen (DllMain wird nie betreten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> ). Habe es erst 2mal hinbekommen, dass es ganz kurz das Programm startet, aber es wurde sofort wieder beendet.</p>
<p>Der Loader sieht so aus (Die DllMain hatte mal zum test nur eine MessageBox+ return TRUE drin, doch nichtmal das ging <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> ):</p>
<p>Die log-datei hab ich nur mal zu testzwecken reingetan.</p>
<p>Die Prozess-ID hab ich mir aus dem Task Manager geholt und gehört im mom dem VC++</p>
<p>Habe auch keine Programme drauf die solche &quot;bösen&quot; Programme blockieren und nen Testprogramm ausm Inet funktioniert auch (das lädt, aber keine dll sondern ne funktion in den anderen prozess).</p>
<pre><code class="language-cpp">int WINAPI WinMain (IN HINSTANCE hinst, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
{
	char lib[] = &quot;hookd32.dll&quot;;
	HANDLE process = NULL;
	HANDLE thread = NULL;
	PSTR LibFileRemote = NULL;
	ofstream log (&quot;log.txt&quot;);

	log &lt;&lt; &quot;process = ::OpenProcess (PROCESS_ALL_ACCESS, FALSE, 2076);&quot; &lt;&lt; endl;
	process = ::OpenProcess (PROCESS_ALL_ACCESS, FALSE, 2076);
	if (process == NULL)
	{
		log &lt;&lt; &quot;Open Process fehlgeschlagen&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Open Process fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	log &lt;&lt; &quot;LibFileRemote = (PSTR)::VirtualAllocEx (process,&quot;
		&lt;&lt; &quot;NULL, 13, MEM_COMMIT,PAGE_READWRITE);&quot; &lt;&lt; endl;
	LibFileRemote = (PSTR)::VirtualAllocEx (process, NULL, 13, MEM_COMMIT,
											PAGE_READWRITE);
	if (LibFileRemote == NULL)
	{	
		log &lt;&lt; &quot;Virtual Alloc Ex fehlgeschlagen&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Virtual Alloc Ex fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	log &lt;&lt; &quot;WriteProcessMemory (process, (PVOID)LibFileRemote,lib, 13, NULL)&quot; &lt;&lt; endl;
	if (!::WriteProcessMemory (process, (PVOID)LibFileRemote,lib,
							   13, NULL))
	{
		log &lt;&lt; &quot;Write Process Memory fehlgeschlagen&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Write Process Memory fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}
	char buffer[128];
	::ReadProcessMemory (process, (LPCVOID)LibFileRemote, buffer, 128, NULL);
	log &lt;&lt; endl &lt;&lt; endl &lt;&lt; buffer &lt;&lt; endl &lt;&lt; endl;

	log &lt;&lt; &quot;PTHREAD_START_ROUTINE pLoadLibraryA =&quot; 
		&lt;&lt; &quot;(PTHREAD_START_ROUTINE)::GetProcAddress (&quot;
		&lt;&lt; &quot;::GetModuleHandle (\&quot;kernel32\&quot;), \&quot;LoadLibraryA\&quot;);&quot; &lt;&lt; endl;
	PTHREAD_START_ROUTINE pLoadLibraryA = 
		(PTHREAD_START_ROUTINE)::GetProcAddress (
									::GetModuleHandle (&quot;kernel32&quot;), &quot;LoadLibraryA&quot;);

	if (pLoadLibraryA == NULL)
	{
		log &lt;&lt; &quot;Load Library A konnte nicht geladen werden&quot; &lt;&lt; endl;
		MessageBox (0, &quot;Load Library A konnte nicht geladen werden&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	log &lt;&lt; &quot;thread = ::CreateRemoteThread (process, NULL, 0, pLoadLibraryA, (PVOID)LibFileRemote, 0, NULL);&quot; &lt;&lt; endl;
	thread = ::CreateRemoteThread (process, NULL, 0, pLoadLibraryA, (PVOID)LibFileRemote,
						  0, NULL);

	if (thread == NULL)
	{
		log &lt;&lt; &quot;Create Remote Thread fehlgeschlagen&quot; &lt;&lt; endl; 
		MessageBox (0, &quot;Create Remote Thread fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return 0;
	}

	HMODULE libr = LoadLibrary (&quot;sensui32.dll&quot;);

	log &lt;&lt; &quot;::CloseHandle (thread);&quot; &lt;&lt; endl;
	::CloseHandle (thread);
	log &lt;&lt; &quot;::CloseHandle (process);&quot; &lt;&lt; endl;
	::CloseHandle (process);

return 0;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/611059</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/611059</guid><dc:creator><![CDATA[Aussenstehender]]></dc:creator><pubDate>Mon, 20 Sep 2004 15:25:38 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Mon, 20 Sep 2004 16:37:17 GMT]]></title><description><![CDATA[<p>Öhm,der Prozess hat bei jedem Start ne andere ID <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .<br />
Hast du das ganze mal im Debugger nachvollzogen?<br />
Und vor allem was für ein Betriebssystem hast du eigentlich?<br />
Unter 98/ME besitzt CreateREmoteThread keine Implementierung und gibt immer NULL zurück.<br />
Abgesehen davon funktioniert das bei denen auch nicht weil der Adressraum anders aufgebaut ist.<br />
Ein wesentlicher Bestandteil dieser Technik ist die Tatsache das die System Dll´s immer an die gleiche Adresse geladen werden.Ansonsten könnte man CreateRemoteThread nicht die Adresse von LoadLibrary übergeben...</p>
<p>MfG Spacelord</p>
]]></description><link>https://www.c-plusplus.net/forum/post/611120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/611120</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Mon, 20 Sep 2004 16:37:17 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Mon, 20 Sep 2004 16:58:53 GMT]]></title><description><![CDATA[<p>Ich benutze Windows2000 SP4 und ich sagte doch oben, dass ich die PID einfach ausm Taskmanager ausgelesen habe, die ändert sich ja während der Prozess läuft nicht und ich hab natürlich immer eine gültige verwendet (auch verschiedene Versucht).</p>
<p>Nein den Debugger habe ich noch nicht eingesetzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/611146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/611146</guid><dc:creator><![CDATA[Aussenstehender]]></dc:creator><pubDate>Mon, 20 Sep 2004 16:58:53 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Mon, 20 Sep 2004 17:32:31 GMT]]></title><description><![CDATA[<p>Ich denke das Problem liegt bei der Zeichenkette die du als Dll Namen &quot;übergibst&quot; der Code sieht soweit ok aus aber die länge des Strings solltest du besser mit strlen ermitteln.<br />
Und probier mal die Endung .dll wegzulassen.</p>
<p>MfG Spacelord</p>
]]></description><link>https://www.c-plusplus.net/forum/post/611183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/611183</guid><dc:creator><![CDATA[Spacelord]]></dc:creator><pubDate>Mon, 20 Sep 2004 17:32:31 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Mon, 20 Sep 2004 19:50:36 GMT]]></title><description><![CDATA[<p>hookd32.dll - wenn du den Namen ohne Pfad angibst setz das vorraus, dass die Dll sich in dem Dll-Such-Pfad der <strong>remote</strong> Anwendung befindet. Sprich standardmaßig in C:\WINNT;C:\WINNT\system,C:\WINNT\system32 bzw. C:\WINDOWS;C:\WINDOWS\system,C:\WINDOWS\system32 oder der im momentanen Pfad der Anwendung.</p>
<p>bevor du CloseHandle( thread ) aufrufst für mal das noch aus:</p>
<pre><code class="language-cpp">DWORD nExitCode
GetExitCodeThread( thread, &amp;ExitCode );
</code></pre>
<p>dann kannst schauen ob LoadLibraryA NULL zurück gibt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/611360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/611360</guid><dc:creator><![CDATA[ScriptGod]]></dc:creator><pubDate>Mon, 20 Sep 2004 19:50:36 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Mon, 20 Sep 2004 20:54:33 GMT]]></title><description><![CDATA[<p>Danke das mit dem Pfad ist es, jetzt klappt es <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Ich könnt euch knutschen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/611408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/611408</guid><dc:creator><![CDATA[Aussenstehender]]></dc:creator><pubDate>Mon, 20 Sep 2004 20:54:33 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread funktioniert nicht richtig on Tue, 21 Sep 2004 23:04:12 GMT]]></title><description><![CDATA[<p>Aussenstehender schrieb:</p>
<blockquote>
<p>Danke das mit dem Pfad ist es, jetzt klappt es <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Ich könnt euch knutschen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>@Aussenstehender: post mal deinen code, würd mich interessieren wie du das nun gelöst hast...mit loader usw...</p>
<p>cu</p>
]]></description><link>https://www.c-plusplus.net/forum/post/612471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/612471</guid><dc:creator><![CDATA[unik]]></dc:creator><pubDate>Tue, 21 Sep 2004 23:04:12 GMT</pubDate></item></channel></rss>