Can you please tell me where in the code it's asked to the prog to use mysendto ... ?
Quote:
/*
  by Luigi Auriemma
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock.h>
#include <windows.h>
static HMODULE wsock = NULL;
static WINAPI int (*real_sendto)(SOCKET s, char *tbuf, int len, int flags, const struct sockaddr *to, int tolen) = NULL;
void init_myproxocket(void) {   // in this example I use this function for loading the real sockets function in case we want to use them
    char    winpath[MAX_PATH];
    if(wsock) return;
    GetSystemDirectory(winpath, sizeof(winpath));
    strcat(winpath, "\\ws2_32.dll");
    wsock = LoadLibrary(winpath);
    if(!wsock) return;
    real_sendto    = (void *)GetProcAddress(wsock, "sendto");
}
void free_myproxocket(void) {
    if(wsock) {
        FreeLibrary(wsock);
        wsock = NULL;
    }
}
int mysendto(SOCKET s, u_char **retbuf, int len, int flags, const struct sockaddr *to, int tolen) {
    u_char  *buf = *retbuf; // do NOT touch this
#define MAXSKIPS    10  // some initial packets to skip from the backbuff operations
#define MAXBACKS    32  // number of packets to store and then send together at the same time
typedef struct {
    u_char  *pck;
    int     len;
    int     maxlen;
} backbuff_t;
    static  int backs   = 0;
    static  int skips   = 0;
    static  backbuff_t  backbuff[MAXBACKS]  = {{NULL,0,0}};
    int     i;
    if((len >= 4) && !memcmp(buf, "\xff\xff\xff\xff", 4)) { // example for the Quake 3 engine
        skips = 0;
    } else if(skips < MAXSKIPS) {
        skips++;
    } else {
        if(backs < MAXBACKS) {  // quick example solution
            if(len > backbuff[backs].maxlen) {
                backbuff[backs].pck = realloc(backbuff[backs].pck, len);
                backbuff[backs].maxlen = len;
            }
            memcpy(backbuff[backs].pck, buf, len);
            backbuff[backs].len = len;
            backs++;
        } else {
            for(i = 0; i < backs; i++) {
                real_sendto(s, backbuff[i].pck, backbuff[i].len, flags, to, tolen);
            }
            backs = 0;
        }
        len = 0;
    }
    *retbuf = buf;  // do NOT touch this
    return(len);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
    switch(fdwReason) {
        case DLL_PROCESS_ATTACH: {
            DisableThreadLibraryCalls(hinstDLL);
            init_myproxocket(); // put your init here
            break;
        }
        case DLL_PROCESS_DETACH: {
            free_myproxocket(); // put anything to free here
            break;
        }
        default: break;
    }
    return(TRUE);
}