<?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 == virus wtf?]]></title><description><![CDATA[<p>hallo<br />
mit Hilfe eines Tutorials, habe ich mir nen DLL injector für meine eigenen Anwendungen geschrieben. Problem ist, dass er nur mit ASCII funzt aber das nur nebenbei. Hauptproblem: Wenn ich mit Debug kompiliere wird er von Avira als virus &quot;Malware&quot; erkannt (genauer: wenn ich CreateRemoteThread auskommentiere, dann nicht mehr). Was soll das denn? Ich schreibe doch keinen Virus.<br />
In Release mode wird es zwar nicht erkannt, aber ich möchte ja keinen Virus schreiben und ich will nicht, dass der Scanner denkt ich mach einen Virus.<br />
Hier mal mein Code:</p>
<pre><code class="language-cpp">#ifdef UNICODE
#define LoadLibraryTCHAR  &quot;LoadLibraryW&quot;
#else
#define LoadLibraryTCHAR  &quot;LoadLibraryA&quot;
#endif

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

struct INJECTSTRUCT
{
      fpLoadLibrary LoadLibrary;
      fpGetProcAddress GetProcAddress;
      TCHAR path[255];
      TCHAR 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()
{
}

bool EnableDebugPrivilege()
{
	TOKEN_PRIVILEGES priv;
	HANDLE hThis, hToken;
	LUID luid;
	hThis = GetCurrentProcess();
	OpenProcessToken(hThis, TOKEN_ADJUST_PRIVILEGES, &amp;hToken);
	LookupPrivilegeValue(0, TEXT(&quot;seDebugPrivilege&quot;), &amp;luid);
	priv.PrivilegeCount = 1;
	priv.Privileges[0].Luid = luid;
	priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	AdjustTokenPrivileges(hToken, false, &amp;priv, 0, 0, 0);
	CloseHandle(hToken);
	CloseHandle(hThis);
	return true;
}

HANDLE InjectDll(unsigned ProcessId, TCHAR *DllFile, TCHAR* FunctionName)
{
	if(ExistFile(DllFile) == false)
	{
		MessageBox(0, TEXT(&quot;Can't find the DLL file!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	INJECTSTRUCT is;
	_tcscpy_s(is.path, DllFile);
	_tcscpy_s(is.func, FunctionName);
	DWORD funcsize = (DWORD)threadend - (DWORD)threadstart;

	EnableDebugPrivilege();

	HINSTANCE hDll = LoadLibrary(TEXT(&quot;KERNEL32&quot;));
	if(hDll == NULL)
	{
		MessageBox(0, TEXT(&quot;LoadLibrary failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	is.LoadLibrary = (fpLoadLibrary)GetProcAddress(hDll, LoadLibraryTCHAR);
	is.GetProcAddress = (fpGetProcAddress)GetProcAddress(hDll, &quot;GetProcAddress&quot;);
	if(is.LoadLibrary == NULL || is.GetProcAddress == NULL)
	{
		MessageBox(0, TEXT(&quot;GetProcAddress failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessId);
	if(hProc == NULL)
	{
		MessageBox(0, TEXT(&quot;OpenProcess failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	LPVOID start = VirtualAllocEx(hProc, 0, funcsize+sizeof(INJECTSTRUCT), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	if(start == NULL)
	{
		MessageBox(0, TEXT(&quot;VirtualAllocEx failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	if(WriteProcessMemory(hProc, start, (LPVOID)&amp;is, sizeof(INJECTSTRUCT), NULL) == 0)
	{
		MessageBox(0, TEXT(&quot;WriteProcessMemory failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

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

	if(WriteProcessMemory(hProc, thread, (LPVOID)threadstart, funcsize, NULL) == 0)
	{
		MessageBox(0, TEXT(&quot;WriteProcessMemory failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	HANDLE threadID = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)thread, start, 0, 0);
	if(threadID == NULL)
	{
		MessageBox(0, TEXT(&quot;CreateRemoteThread failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	if(CloseHandle(hProc) == 0)
	{
		MessageBox(0, TEXT(&quot;CloseHandle failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	return threadID;
}
</code></pre>
<p>Würde mich wahnsinnig freuen, wenn jemand weiß, warum das als Virus erkannt wird oder was ich ändern muss. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/240913/createremotethread-virus-wtf</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 04:07:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/240913.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 May 2009 12:34:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 12:34:25 GMT]]></title><description><![CDATA[<p>hallo<br />
mit Hilfe eines Tutorials, habe ich mir nen DLL injector für meine eigenen Anwendungen geschrieben. Problem ist, dass er nur mit ASCII funzt aber das nur nebenbei. Hauptproblem: Wenn ich mit Debug kompiliere wird er von Avira als virus &quot;Malware&quot; erkannt (genauer: wenn ich CreateRemoteThread auskommentiere, dann nicht mehr). Was soll das denn? Ich schreibe doch keinen Virus.<br />
In Release mode wird es zwar nicht erkannt, aber ich möchte ja keinen Virus schreiben und ich will nicht, dass der Scanner denkt ich mach einen Virus.<br />
Hier mal mein Code:</p>
<pre><code class="language-cpp">#ifdef UNICODE
#define LoadLibraryTCHAR  &quot;LoadLibraryW&quot;
#else
#define LoadLibraryTCHAR  &quot;LoadLibraryA&quot;
#endif

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

struct INJECTSTRUCT
{
      fpLoadLibrary LoadLibrary;
      fpGetProcAddress GetProcAddress;
      TCHAR path[255];
      TCHAR 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()
{
}

bool EnableDebugPrivilege()
{
	TOKEN_PRIVILEGES priv;
	HANDLE hThis, hToken;
	LUID luid;
	hThis = GetCurrentProcess();
	OpenProcessToken(hThis, TOKEN_ADJUST_PRIVILEGES, &amp;hToken);
	LookupPrivilegeValue(0, TEXT(&quot;seDebugPrivilege&quot;), &amp;luid);
	priv.PrivilegeCount = 1;
	priv.Privileges[0].Luid = luid;
	priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	AdjustTokenPrivileges(hToken, false, &amp;priv, 0, 0, 0);
	CloseHandle(hToken);
	CloseHandle(hThis);
	return true;
}

HANDLE InjectDll(unsigned ProcessId, TCHAR *DllFile, TCHAR* FunctionName)
{
	if(ExistFile(DllFile) == false)
	{
		MessageBox(0, TEXT(&quot;Can't find the DLL file!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	INJECTSTRUCT is;
	_tcscpy_s(is.path, DllFile);
	_tcscpy_s(is.func, FunctionName);
	DWORD funcsize = (DWORD)threadend - (DWORD)threadstart;

	EnableDebugPrivilege();

	HINSTANCE hDll = LoadLibrary(TEXT(&quot;KERNEL32&quot;));
	if(hDll == NULL)
	{
		MessageBox(0, TEXT(&quot;LoadLibrary failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	is.LoadLibrary = (fpLoadLibrary)GetProcAddress(hDll, LoadLibraryTCHAR);
	is.GetProcAddress = (fpGetProcAddress)GetProcAddress(hDll, &quot;GetProcAddress&quot;);
	if(is.LoadLibrary == NULL || is.GetProcAddress == NULL)
	{
		MessageBox(0, TEXT(&quot;GetProcAddress failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessId);
	if(hProc == NULL)
	{
		MessageBox(0, TEXT(&quot;OpenProcess failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	LPVOID start = VirtualAllocEx(hProc, 0, funcsize+sizeof(INJECTSTRUCT), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	if(start == NULL)
	{
		MessageBox(0, TEXT(&quot;VirtualAllocEx failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	if(WriteProcessMemory(hProc, start, (LPVOID)&amp;is, sizeof(INJECTSTRUCT), NULL) == 0)
	{
		MessageBox(0, TEXT(&quot;WriteProcessMemory failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

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

	if(WriteProcessMemory(hProc, thread, (LPVOID)threadstart, funcsize, NULL) == 0)
	{
		MessageBox(0, TEXT(&quot;WriteProcessMemory failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	HANDLE threadID = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)thread, start, 0, 0);
	if(threadID == NULL)
	{
		MessageBox(0, TEXT(&quot;CreateRemoteThread failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	if(CloseHandle(hProc) == 0)
	{
		MessageBox(0, TEXT(&quot;CloseHandle failed!&quot;), szAppName, MB_ICONERROR);
		return 0;
	}

	return threadID;
}
</code></pre>
<p>Würde mich wahnsinnig freuen, wenn jemand weiß, warum das als Virus erkannt wird oder was ich ändern muss. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1709937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1709937</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Wed, 13 May 2009 12:34:25 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 13:19:24 GMT]]></title><description><![CDATA[<p>DLL injection ist per Definition ein Virus: Ein Programm welches sich in anderen Programme einschleust, ohne dass der Wirt etwas davon weis.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1709949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1709949</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 13 May 2009 13:19:24 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 15:24:00 GMT]]></title><description><![CDATA[<p>ok, aber wieso dann nur im debug mode? Und wie kann ich das ändern? Einfach den code bisschen umstellen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710024</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Wed, 13 May 2009 15:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 17:23:56 GMT]]></title><description><![CDATA[<p>Your name answers the questions.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710084</guid><dc:creator><![CDATA[brain.exe]]></dc:creator><pubDate>Wed, 13 May 2009 17:23:56 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 17:41:53 GMT]]></title><description><![CDATA[<p>ok ist egal, aber warum crashed das programm in das ich injecte?<br />
Und warum geht unicode nicht? Mir ist klar, dass das warscheinlich keiner weiß, aber vielleicht weiß es zufällig jemand.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710093</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Wed, 13 May 2009 17:41:53 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 17:54:12 GMT]]></title><description><![CDATA[<p>hab den crash bug gefixt. Aber UNICODE wäre schon geil.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710101</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Wed, 13 May 2009 17:54:12 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 18:06:00 GMT]]></title><description><![CDATA[<p>Deine Deklaration von fpGetProcAddress ist falsch.</p>
<p>Kleiner Tipp:<br />
<a href="http://msdn.microsoft.com/en-us/library/ms683212" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms683212</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710106</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710106</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 13 May 2009 18:06:00 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 18:14:47 GMT]]></title><description><![CDATA[<p>die ist anscheinend nicht falsch. Es geht ja in ASCII. Das Problem ist nur UNICODE <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710112</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Wed, 13 May 2009 18:14:47 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 18:31:53 GMT]]></title><description><![CDATA[<p>HINSTANCE mit HMODULE auszutauschen ändert da leider auch nichts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710119</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Wed, 13 May 2009 18:31:53 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Wed, 13 May 2009 20:30:11 GMT]]></title><description><![CDATA[<p>avirasucks schrieb:</p>
<blockquote>
<p>die ist anscheinend nicht falsch. Es geht ja in ASCII. Das Problem ist nur UNICODE <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Na, wenn Du das sagst, dann wird das schon stimmen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710164</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 13 May 2009 20:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 04:49:22 GMT]]></title><description><![CDATA[<p>natürlich bin ich nicht so arrogant und widerspreche einem MVP <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="😃"
    /><br />
ich habs ja getestet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710232</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Thu, 14 May 2009 04:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 05:49:01 GMT]]></title><description><![CDATA[<p>Dann wirst Du ja festgestellt haben, das die Unicode-Version nicht geht, oder?</p>
<p>Also gut, ich geb Dir noch ein Tipp: Der 2. Parameter ist falsch deklariert...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710238</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710238</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 14 May 2009 05:49:01 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 08:54:47 GMT]]></title><description><![CDATA[<p>hi Jochen,<br />
nein Unicode klappt noch nicht.<br />
wieso ist TCHAR falsch?</p>
<pre><code class="language-cpp">typedef LPVOID (*fpGetProcAddress)(HMODULE , TCHAR*); 

msdn:
FARPROC WINAPI GetProcAddress(
  __in  HMODULE hModule,
  __in  LPCSTR lpProcName // pointer zu char array und da unicode TCHAR.
);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1710312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710312</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Thu, 14 May 2009 08:54:47 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 09:28:37 GMT]]></title><description><![CDATA[<p>Weil Du die Doku nicht lesen kannst!?<br />
Warum steht in der MSDN LPCSTR und bei Dir TCHAR*?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710333</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 14 May 2009 09:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 09:34:09 GMT]]></title><description><![CDATA[<p>&quot;kalt&quot;, &quot;kalt&quot;</p>
<p>etwas &quot;wärmer&quot; wirds, wenn Du dort suchst, wo der zweite Parameter als fixen Text-String an die besagte Funktion übergeben wird (kommt nur einmal in Deinem Code vor)</p>
<p>na, dann müßtest Du drauf kommen wo der Unicode-Fehler steckt!<br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710338</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Thu, 14 May 2009 09:34:09 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 10:03:42 GMT]]></title><description><![CDATA[<p>Na, dass ist erst der Folgefehler <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 />
Das hätte ja dann der Compiler bemängelt...</p>
<p>Und auch die falsche definition des &quot;func&quot; Feldes in der Struktur...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710354</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 14 May 2009 10:03:42 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 10:18:03 GMT]]></title><description><![CDATA[<p>jetzt geht es nicht mal mehr mit ASCII <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
obwohl ich LPCSTR verwendet habe.</p>
<pre><code class="language-cpp">typedef HINSTANCE (__stdcall *fpLoadLibrary)   (TCHAR*);
typedef LPVOID    (__stdcall *fpGetProcAddress)(HINSTANCE, LPCSTR);  
typedef void (*fpFunktion)(void);

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

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()
{
}

bool EnableDebugPrivilege()
{
    TOKEN_PRIVILEGES priv;
    HANDLE hThis, hToken;
    LUID luid;
    hThis = GetCurrentProcess();
    OpenProcessToken(hThis, TOKEN_ADJUST_PRIVILEGES, &amp;hToken);
    LookupPrivilegeValue(0, TEXT(&quot;seDebugPrivilege&quot;), &amp;luid);
    priv.PrivilegeCount = 1;
    priv.Privileges[0].Luid = luid;
    priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(hToken, false, &amp;priv, 0, 0, 0);
    CloseHandle(hToken);
    CloseHandle(hThis);
    return true;
}

HANDLE InjectDll(unsigned ProcessId, TCHAR *DllFile, LPCSTR FunctionName)
{
    if(ExistFile(DllFile) == false)
    {
        MessageBox(0, TEXT(&quot;Can't find the DLL file!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    INJECTSTRUCT is;
    _tcscpy_s(is.path, DllFile);
    is.func = FunctionName;
    DWORD funcsize = (DWORD)threadend - (DWORD)threadstart;

    EnableDebugPrivilege();

    HINSTANCE hDll = LoadLibrary(TEXT(&quot;KERNEL32&quot;));
    if(hDll == NULL)
    {
        MessageBox(0, TEXT(&quot;LoadLibrary failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    is.LoadLibrary = (fpLoadLibrary)GetProcAddress(hDll, &quot;LoadLibraryA&quot;);
    is.GetProcAddress = (fpGetProcAddress)GetProcAddress(hDll, &quot;GetProcAddress&quot;);
    if(is.LoadLibrary == NULL || is.GetProcAddress == NULL)
    {
        MessageBox(0, TEXT(&quot;GetProcAddress failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessId);
    if(hProc == NULL)
    {
        MessageBox(0, TEXT(&quot;OpenProcess failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    LPVOID start = VirtualAllocEx(hProc, 0, funcsize+sizeof(INJECTSTRUCT), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if(start == NULL)
    {
        MessageBox(0, TEXT(&quot;VirtualAllocEx failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    if(WriteProcessMemory(hProc, start, (LPVOID)&amp;is, sizeof(INJECTSTRUCT), NULL) == 0)
    {
        MessageBox(0, TEXT(&quot;WriteProcessMemory failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

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

    if(WriteProcessMemory(hProc, thread, (LPVOID)threadstart, funcsize, NULL) == 0)
    {
        MessageBox(0, TEXT(&quot;WriteProcessMemory failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    HANDLE threadID = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)thread, start, 0, 0);
    if(threadID == NULL)
    {
        MessageBox(0, TEXT(&quot;CreateRemoteThread failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    if(CloseHandle(hProc) == 0)
    {
        MessageBox(0, TEXT(&quot;CloseHandle failed!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    return threadID;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1710367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710367</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Thu, 14 May 2009 10:18:03 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 10:19:53 GMT]]></title><description><![CDATA[<p>Du solltest zuerst mal die Grundlagen lernen...<br />
Du deklarierst jetzt in Deiner Struktur einen Pointer und kein Feld, wo man Zeichen ablegen kann...<br />
Ersetze LPCSTR in der *Struktur* (und nur da) durch char[255]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710369</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 14 May 2009 10:19:53 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 10:27:49 GMT]]></title><description><![CDATA[<p>jetzt geht es mit ASCII wieder aber nicht mit UNICODE.</p>
<pre><code class="language-cpp">struct INJECTSTRUCT
{
      fpLoadLibrary LoadLibrary;
      fpGetProcAddress GetProcAddress;
      TCHAR path[255];
      char func[255];
};

HANDLE InjectDll(unsigned ProcessId, TCHAR *DllFile, LPCSTR FunctionName)
{
    if(ExistFile(DllFile) == false)
    {
        MessageBox(0, TEXT(&quot;Can't find the DLL file!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }

    INJECTSTRUCT is;
    _tcscpy_s(is.path, DllFile);
    strcpy_s(is.func, FunctionName);
    DWORD funcsize = (DWORD)threadend - (DWORD)threadstart;
    [...]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1710373</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710373</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Thu, 14 May 2009 10:27:49 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 12:50:14 GMT]]></title><description><![CDATA[<p>Was denn?<br />
Du nimmst Visual Studio her, stellst in den general project properties all configurations auf multibyte character set und verwendest dann kein L oder _T oder sonstigen unnötigen Mist sondern schreibst einfach den Text.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710462</guid><dc:creator><![CDATA[HerstAmoi]]></dc:creator><pubDate>Thu, 14 May 2009 12:50:14 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 13:04:07 GMT]]></title><description><![CDATA[<p>HerstAmoi schrieb:</p>
<blockquote>
<p>Was denn?<br />
Du nimmst Visual Studio her, stellst in den general project properties all configurations auf multibyte character set und verwendest dann kein L oder _T oder sonstigen unnötigen Mist sondern schreibst einfach den Text.</p>
</blockquote>
<p>Und dann geht's mit UNICODE?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710474</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Thu, 14 May 2009 13:04:07 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 14:11:06 GMT]]></title><description><![CDATA[<p>UNICODE ist mist kapiert das endlich -.- man kann außerdem keine dll injection mit unicode <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710517</guid><dc:creator><![CDATA[omg]]></dc:creator><pubDate>Thu, 14 May 2009 14:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 14:54:05 GMT]]></title><description><![CDATA[<p>omg hätte noch statt LoadLibraryA W verwenden müssen, damit klappt es jetzt.<br />
Und ihr braucht mir nicht mehr sagen wie dämlich dieser Fehler war.<br />
Ich sollte erstmal besser die Grundlagen lernen. Aber wenigstens klappt es jetzt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710550</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Thu, 14 May 2009 14:54:05 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 14:54:38 GMT]]></title><description><![CDATA[<p>Die UNICODE-Fanboys haben versäumt das PE-Format zu aktualisieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710551</guid><dc:creator><![CDATA[so_siehts_aus]]></dc:creator><pubDate>Thu, 14 May 2009 14:54:38 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 16:51:50 GMT]]></title><description><![CDATA[<p>Hätte er nur den Fehler behoben, den ich ganz am Anfang gepostet hab, hätte es gleich getan.... <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1710597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710597</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 14 May 2009 16:51:50 GMT</pubDate></item><item><title><![CDATA[Reply to CreateRemoteThread == virus wtf? on Thu, 14 May 2009 17:03:55 GMT]]></title><description><![CDATA[<p>jo war meine schuld, natürlich vielen dank für deine Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1710606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1710606</guid><dc:creator><![CDATA[avirasucks]]></dc:creator><pubDate>Thu, 14 May 2009 17:03:55 GMT</pubDate></item></channel></rss>