Hmm o to sendto chodzi???
int WSAAPI sendto (
SOCKET s,
const char FAR * buf,
int len,
int flags,
const struct sockaddr FAR * to,
int tolen
);
gdzie WSAAPI to FAR PASCAL.
void __declspec(naked) custom_sendto(void)
{
_asm
{
push ebp
mov ebp, esp
sub esp, 0x24
}
SOCKET s;
char* buf;
int len;
int flags;
sockaddr* to;
int tolen;
char* text="MyInject: wykryto custom_sendto";
_asm
{
mov eax, [ebp+8]
mov s, eax
mov eax, [ebp+8+4]
mov buf, eax
mov eax, [ebp+8+8]
mov len, eax
mov eax, [ebp+8+12]
mov flags, eax
mov eax, [ebp+8+16]
mov to, eax
mov eax, [ebp+8+20]
mov tolen, eax
}
ATOM Atom = ::GlobalAddAtom( text );
UINT uiMyMessage = ::RegisterWindowMessage("InetMessage");
::SendMessage( HWND_BROADCAST , uiMyMessage , (WPARAM)Atom , 0 );
_asm
{
mov eax,len //<--- zwracana wartość
mov esp, ebp
pop ebp
ret 24
}
};
i przykładowe wywołanie:
typedef int PASCAL(*sendto_ptr)(SOCKET,const char*,int,int,const struct sockaddr*,int);
sendto_ptr foo=(sendto_ptr)custom_sendto;
foo(1,(const char*)2,3,4,(const struct sockaddr*)5,6); //paramerty dla przykładu ;)
Z drugiej strony nie prościej tak:
int WSAAPI custom_sendto (SOCKET s,const char FAR * buf,int len,
int flags,const struct sockaddr FAR * to,int tolen)
{
char* text="MyInject: wykryto custom_sendto";
ATOM Atom = ::GlobalAddAtom( text );
UINT uiMyMessage = ::RegisterWindowMessage("InetMessage");
::SendMessage( HWND_BROADCAST , uiMyMessage , (WPARAM)Atom , 0 );
return len;
}
??? :P