<?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[recv Hook; packet auslesen -&amp;gt; bekomme nur nullen]]></title><description><![CDATA[<p>Hallo.<br />
Ich hoffe es kann mir jemand helfen.<br />
Also ich versuche die recv() funktion mit detours zu hooken und 2 bestimmte bytes vom inhalt der packets auszulesen..<br />
der recv hook mit detours funktioniert, das weiss ich, aber wenn ich den inhalt ausgeben lassen will bekomme ich nur nullen..<br />
ich muss dazu sagen dass ich eine DLL schreibe, deren DLLMain funktion exportiert wird, damit die dll bei programmstart<br />
direkt mitgeladen werden kann, wenn sie in der IAT eingetragen ist.</p>
<p>in WPE bestehen die packets nicht nur aus 00 sondern aus daten, verschlüsselt mit Xor 0xFF.<br />
Benutzt wird ausschließlich recv die anderen wie recvfrom und WSArecv werden nicht benutzt.</p>
<p>ich benutze MS Visual C++ 2008 Express<br />
weiss jemand was ich falsch mache??<br />
oder gibt es vielleicht noch einen anderen weg das zu machen?</p>
<p>danke im voraus<br />
Karlson</p>
<p>hier mein code:</p>
<pre><code>#include &lt;WinSock2.h&gt;
#include &lt;windows.h&gt;
#include &quot;detours.h&quot;
#include &lt;stdio.h&gt;

#pragma comment(lib, &quot;detours.lib&quot;)
#pragma comment(lib, &quot;Ws2_32.lib&quot;)

typedef int (WINAPI * tRecv)(SOCKET s, char *buf, int len, int flags);
tRecv oRecv = NULL;

int WINAPI myRecv(SOCKET s, char *buf, int len, int flags)
{
	printf(&quot;recieved: %X %X\n&quot;,buf[2],buf[3]);
	return (oRecv)(s, buf, len, flags);
}

__declspec(dllexport) BOOL WINAPI DllMain(HANDLE HDllHandle, DWORD reason, LPVOID Reserved)
{
    if(DLL_PROCESS_ATTACH == reason)
    {
		oRecv = reinterpret_cast&lt;tRecv&gt;(DetourFunction((PBYTE)&amp;recv, (PBYTE)&amp;myRecv));
		AllocConsole();
			freopen(&quot;conin$&quot;, &quot;r&quot;, stdin);
			freopen(&quot;conout$&quot;, &quot;w&quot;, stdout);
			freopen(&quot;conout$&quot;, &quot;w&quot;, stderr);

		printf( &quot;Console Started!\n&quot; );
    }
    return TRUE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/244597/recv-hook-packet-auslesen-gt-bekomme-nur-nullen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Apr 2026 23:03:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/244597.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Jul 2009 13:46:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to recv Hook; packet auslesen -&amp;gt; bekomme nur nullen on Thu, 02 Jul 2009 13:59:52 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Ich hoffe es kann mir jemand helfen.<br />
Also ich versuche die recv() funktion mit detours zu hooken und 2 bestimmte bytes vom inhalt der packets auszulesen..<br />
der recv hook mit detours funktioniert, das weiss ich, aber wenn ich den inhalt ausgeben lassen will bekomme ich nur nullen..<br />
ich muss dazu sagen dass ich eine DLL schreibe, deren DLLMain funktion exportiert wird, damit die dll bei programmstart<br />
direkt mitgeladen werden kann, wenn sie in der IAT eingetragen ist.</p>
<p>in WPE bestehen die packets nicht nur aus 00 sondern aus daten, verschlüsselt mit Xor 0xFF.<br />
Benutzt wird ausschließlich recv die anderen wie recvfrom und WSArecv werden nicht benutzt.</p>
<p>ich benutze MS Visual C++ 2008 Express<br />
weiss jemand was ich falsch mache??<br />
oder gibt es vielleicht noch einen anderen weg das zu machen?</p>
<p>danke im voraus<br />
Karlson</p>
<p>hier mein code:</p>
<pre><code>#include &lt;WinSock2.h&gt;
#include &lt;windows.h&gt;
#include &quot;detours.h&quot;
#include &lt;stdio.h&gt;

#pragma comment(lib, &quot;detours.lib&quot;)
#pragma comment(lib, &quot;Ws2_32.lib&quot;)

typedef int (WINAPI * tRecv)(SOCKET s, char *buf, int len, int flags);
tRecv oRecv = NULL;

int WINAPI myRecv(SOCKET s, char *buf, int len, int flags)
{
	printf(&quot;recieved: %X %X\n&quot;,buf[2],buf[3]);
	return (oRecv)(s, buf, len, flags);
}

__declspec(dllexport) BOOL WINAPI DllMain(HANDLE HDllHandle, DWORD reason, LPVOID Reserved)
{
    if(DLL_PROCESS_ATTACH == reason)
    {
		oRecv = reinterpret_cast&lt;tRecv&gt;(DetourFunction((PBYTE)&amp;recv, (PBYTE)&amp;myRecv));
		AllocConsole();
			freopen(&quot;conin$&quot;, &quot;r&quot;, stdin);
			freopen(&quot;conout$&quot;, &quot;w&quot;, stdout);
			freopen(&quot;conout$&quot;, &quot;w&quot;, stderr);

		printf( &quot;Console Started!\n&quot; );
    }
    return TRUE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1736069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1736069</guid><dc:creator><![CDATA[Karlson]]></dc:creator><pubDate>Thu, 02 Jul 2009 13:59:52 GMT</pubDate></item><item><title><![CDATA[Reply to recv Hook; packet auslesen -&amp;gt; bekomme nur nullen on Thu, 02 Jul 2009 14:30:49 GMT]]></title><description><![CDATA[<p>Nimm erstmal Detours 2.1.<br />
Codebeispiel:</p>
<pre><code class="language-cpp">long (__stdcall *RealDirectInputCreate)(HINSTANCE hInst, unsigned long dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter) = DirectInputCreateA;
long (__stdcall *TramDirectInputCreate)(HINSTANCE hInst, unsigned long dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter);
long __stdcall HookDirectInputCreate(HINSTANCE hInst, unsigned long dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter);

bool __stdcall DllMain(HMODULE, unsigned long reason, void*)
{
    if(reason == DLL_PROCESS_ATTACH)
    {
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourAttachEx(&amp;reinterpret_cast&lt;void*&amp;&gt;(RealDirectInputCreate), HookDirectInputCreate, &amp;reinterpret_cast&lt;DETOUR_TRAMPOLINE*&amp;&gt;(TramDirectInputCreate), 0, 0);
        DetourTransactionCommit();
    }
    else if(reason == DLL_PROCESS_DETACH)
    {
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourDetach(&amp;reinterpret_cast&lt;void*&amp;&gt;(RealDirectInputCreate), HookDirectInputCreate);
        DetourTransactionCommit();
    }

    return true;
}

long __stdcall HookDirectInputCreate(HINSTANCE hInst, unsigned long dwVersion, LPDIRECTINPUTA* ppDI, LPUNKNOWN punkOuter)
{
    long result = TramDirectInputCreate(hInst, dwVersion, ppDI, punkOuter);

    // ...

    return result;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1736107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1736107</guid><dc:creator><![CDATA[bronson]]></dc:creator><pubDate>Thu, 02 Jul 2009 14:30:49 GMT</pubDate></item><item><title><![CDATA[Reply to recv Hook; packet auslesen -&amp;gt; bekomme nur nullen on Thu, 02 Jul 2009 14:39:07 GMT]]></title><description><![CDATA[<p>oha .. und erm .. wo kann cih da jetz meinen code einfügen zum auslesen der zwei bytes? Oo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1736117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1736117</guid><dc:creator><![CDATA[Karlson]]></dc:creator><pubDate>Thu, 02 Jul 2009 14:39:07 GMT</pubDate></item><item><title><![CDATA[Reply to recv Hook; packet auslesen -&amp;gt; bekomme nur nullen on Thu, 02 Jul 2009 14:48:22 GMT]]></title><description><![CDATA[<p>Ein bisschen Eigeninitiative bitte.<br />
Die Funktionszeiger und die Funktion änderst du halt auf recv() ab.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1736123</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1736123</guid><dc:creator><![CDATA[bronson]]></dc:creator><pubDate>Thu, 02 Jul 2009 14:48:22 GMT</pubDate></item><item><title><![CDATA[Reply to recv Hook; packet auslesen -&amp;gt; bekomme nur nullen on Thu, 02 Jul 2009 15:15:12 GMT]]></title><description><![CDATA[<p>achsoo xD nu hab ich den code auch verstanden .. danke erstmal .. mal schaun ob es damit klappt.<br />
ich melde mich nochmal, wenn jemand noch was weiss bitte trotzdem schreiben <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="🙂"
    /><br />
bin für alles dankbar</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1736136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1736136</guid><dc:creator><![CDATA[Karlson]]></dc:creator><pubDate>Thu, 02 Jul 2009 15:15:12 GMT</pubDate></item><item><title><![CDATA[Reply to recv Hook; packet auslesen -&amp;gt; bekomme nur nullen on Thu, 02 Jul 2009 20:05:03 GMT]]></title><description><![CDATA[<p>danke bronson es funktioniert <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="😃"
    /> <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 />
sry nochmal für die blöde frage &quot;oha .. und erm .. wo kann cih da jetz meinen code einfügen zum auslesen der zwei bytes? Oo&quot; .. musste erstmal umdenken vom doch sehr einfachen detours 1.5 xD hab es aber nu verstanden und es geht</p>
<p>weiss ja nich wie das hier gehandhabt wird, aber thread kann geclosed werden oder so <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>greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1736275</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1736275</guid><dc:creator><![CDATA[Karlson]]></dc:creator><pubDate>Thu, 02 Jul 2009 20:05:03 GMT</pubDate></item></channel></rss>