Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 21:15

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help] WSARecv Hook

Discussion on [Help] WSARecv Hook within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1

 
Flyff_Service's Avatar
 
elite*gold: 0
Join Date: Oct 2008
Posts: 680
Received Thanks: 337
[Help] WSARecv Hook

Ich hooke mit Microsoft's Detour Library die Funktion WSASend & WSARecv.
Die Packet-Auswertung erfolgt bei WSASend ohne Probleme, aber bei WSARecv kommen oft nur 0'en an.
Weiß jemand vielleicht warum?
Flyff_Service is offline  
Old 08/06/2009, 16:34   #2
 
elite*gold: 0
Join Date: May 2008
Posts: 489
Received Thanks: 210
Um wirklich zu wissen was da nicht stimmt fehlen Informationen.

Zu erst mal solltest du den Code posten.

Auch darauf achten, wenn du den Buffer versuchst auszugeben, wirklich durch's gesamte Paket durchloopen, da Funktionen wie operator << bei '\0' aufhören.
schlurmann is offline  
Old 08/06/2009, 16:56   #3


 
Cholik's Avatar
 
elite*gold: 4
Join Date: Aug 2008
Posts: 6,783
Received Thanks: 4,992
War das bei WSARecv nicht so, dass sofern overlapped I/O verwendet wird man generell anders handeln muss ?
Im Vergleich zu recv und send.
Cholik is offline  
Old 08/06/2009, 17:47   #4

 
Flyff_Service's Avatar
 
elite*gold: 0
Join Date: Oct 2008
Posts: 680
Received Thanks: 337
Danke für eure Antworten.
@Cholik:
Falls du weißt wie man handeln muss, und es funktioniert. Danke
Code:
typedef int (WINAPI *RecvTyp)(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
RecvTyp origRecv = NULL;

int WINAPI MyRecv(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
	int iResult = (*origRecv)(s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine);
	return iResult;
};

DWORD WINAPI ThreadMain(LPVOID data){
	origRecv = reinterpret_cast<RecvTyp>(DetourFunction((PBYTE)&WSARecv, (PBYTE)&MyRecv));
	return 0;
}
Flyff_Service is offline  
Old 08/06/2009, 20:19   #5
 
elite*gold: 0
Join Date: May 2008
Posts: 489
Received Thanks: 210
Ich sehe dich nirgendwo den Buffer checken, woher weißt du, dass nur 0en ankommen?
schlurmann is offline  
Old 08/25/2011, 12:42   #6
 
.BritainAndy's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,385
Received Thanks: 1,006
Sorry fürs Pushen wollte jetzt aber kein neuen Thread aufmachen.
Ich wollte mich jetzt auch mal mit packets usw auseinander setzen und hab mehrere Fragen und wäre euch sehr verbunden wenn ihr sie ohne irgendwelche blöden Kommentare beantworten könnten.

Erstmal hab ich folgenden Beitrag im Internet gefunden der mir sehr geholfen hab zudem ich aber eine Frage habe:

Quote:
Look at WS2_32.dll in Depends.exe, load it in to IDA Pro or something similar. Most of the time you will want to hook send(), recv(), for TCP, and sendto() and recvfrom() for UDP. But some times other calls are used. In particular WSASend() for example. You should really see "call chains" with these if you really want to make some universal capture. Look in IDA Pro to figure the chains out then you can just hook the root functions. Most games use TCP for main packets
Woher weiß ich hab ich send() oder WSASend() benutzen muss? Das gleiche für recv?
Muss ich das in Olly oder so heraufinden?

So und meine zweite Frage ist, was falsch an folgendem Source code ist?
Ich wollte mal die WSA_Recv func hooken testweise aber der compiler spuckt mir errors aus der winsock2.h raus, hier der Source:

Code:
#include <Windows.h>
#include <detours.h>
#include <winsock2.h>
#pragma comment(lib, "detours.lib")


typedef int (WINAPI *WSA_recv) (SOCKET, LPWSABUF , DWORD, LPDWORD, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE );
	WSA_recv Recv_original = NULL;




int WINAPI Recv_hook(SOCKET s,LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
	return Recv_original( s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine);
}



BOOL APIENTRY DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
    case DLL_PROCESS_ATTACH:
		Recv_original = (WSA_recv)DetourFunction((PBYTE)&WSARecv, (PBYTE)&Recv_hook);
        break;
    }
    return true;
}
Lg!



Edit:

Sorry, hier die Compilerfehler:

Quote:
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2304): error C2375: 'WSASetBlockingHook': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(889): Siehe Deklaration von 'WSASetBlockingHook'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2321): error C2375: 'WSACancelBlockingCall': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(891): Siehe Deklaration von 'WSACancelBlockingCall'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2343): error C2375: 'WSAAsyncGetServByName': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(893): Siehe Deklaration von 'WSAAsyncGetServByName'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2370): error C2375: 'WSAAsyncGetServByPort': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(901): Siehe Deklaration von 'WSAAsyncGetServByPort'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2396): error C2375: 'WSAAsyncGetProtoByName': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(909): Siehe Deklaration von 'WSAAsyncGetProtoByName'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2421): error C2375: 'WSAAsyncGetProtoByNumber': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(916): Siehe Deklaration von 'WSAAsyncGetProtoByNumber'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2446): error C2375: 'WSAAsyncGetHostByName': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(923): Siehe Deklaration von 'WSAAsyncGetHostByName'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2473): error C2375: 'WSAAsyncGetHostByAddr': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(930): Siehe Deklaration von 'WSAAsyncGetHostByAddr'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2496): error C2375: 'WSACancelAsyncRequest': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(939): Siehe Deklaration von 'WSACancelAsyncRequest'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock2.h(2517): error C2375: 'WSAAsyncSelect': Neudefinition; unterschiedliche Bindung
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winsock.h(941): Siehe Deklaration von 'WSAAsyncSelect
.BritainAndy is offline  
Old 08/25/2011, 21:24   #7
 
elite*gold: 0
Join Date: Jun 2011
Posts: 161
Received Thanks: 470
versuch´s so:
Code:
#include <winsock2.h>
#include <windows.h>
Yazzn :) is offline  
Thanks
1 User
Old 08/26/2011, 06:58   #8


 
buFFy!'s Avatar
 
elite*gold: 1826
Join Date: Mar 2009
Posts: 4,310
Received Thanks: 6,287
schauen welche funktion verwendet wird ! das geht mit olly, ida oder dependency walker

ich sehe bei dir kein
Code:
#pragma comment(lib, "ws2_32.lib")
ist das gewollt?
buFFy! is offline  
Thanks
1 User
Old 08/26/2011, 14:34   #9
 
.BritainAndy's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,385
Received Thanks: 1,006
Danke euch beiden, funktioniert jetzt
.BritainAndy is offline  
Reply


Similar Threads Similar Threads
Hook VIP
08/31/2010 - WarRock Hacks, Bots, Cheats & Exploits - 12 Replies
Virus Scan URL : VirusTotal - Free Online Virus, Malware and URL Scanner LEVEL HACK IVX GUN HACK IVX Speed 10% - 600% JUMP 20% - 800% ANTI KICK ANTI FLOOD PING CONFIG FLY 200% - 1000%
Hook for Int
09/28/2009 - Kal Online - 5 Replies
Hi.. hatte viel im RL zu tun und wollte mien bot wieder zum laufen bringen... kann mir wer nen tipp geben wie ich mein hook wieder zum laufen bring? haben den hooksource hier ausm forum.. wäre echt super!



All times are GMT +1. The time now is 21:16.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.