Hooking wsock32::send function using dll redirection is crashing mozilla firefox

I am trying to hook the send api using dll redirection. I am having a proxy dll which is present in Mozilla Firefox’s installation directory (“C:Program Files (x86)Mozilla Firefox”) , since my firefox is 32 bit application so I am taking wsock32.dll from C:WindowsSysWOW64 directory renaming it to wsock32_.dll and pasting it in firefox installation directory.

In my proxy dll I hook two functions 1. WSAStartup and another is 2. Send function. Below are the the body of these two proxy functions:

Proxy WSAStartup:

extern "C" int  __stdcall ProxyWSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData)


   typedef int(__stdcall *FptrWSAStartup)(WORD , LPWSADATA );

  FptrWSAStartup pp = (FptrWSAStartup)function;
  int nret = pp(wVersionRequired, lpWSAData);

  if (myfile.is_open())
  myfile << "WSAStartup return type = "<<nret << "rn";

  return nret;

Proxy WSAStartup

extern "C" int  Proxysend(SOCKET s, const char *buf, int len, int flags)
    typedef int (__stdcall *FptrSend)(SOCKET, const char*, int, int);

    FptrSend pp = (FptrSend)functionII;

    int  nRet = pp(s, buf, len, flags);

    if (myfile.is_open())
    myfile << "send return type = " << nRet <<" and len = "<< len<<"rn";

    return nRet;

Mozilla firefox is crashing and the mozilla crash reporter windows is poping up very time. If I dont proxy the send method mozilla is launching with no issues.
So I am not sure what is the problem here?

Source: dll

Leave a Reply