After I injected my dll, any program using winsock2's recv crashes. I'm using DllInjector.exe from the madCollection to inject this dll.
Code: Select all
#pragma comment(lib, "madCHook.lib")
#pragma comment(lib, "Ws2_32.lib")
#include <winsock2.h>
#include <windows.h>
#include <madCHook.h>
int (WINAPI *org_recv) (SOCKET s, char * buf, int len, int flags);
int hook_recv (SOCKET s, char * buf, int len, int flags)
{
return org_recv(s, buf, len, flags);
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD callReason, LPVOID lpReserved)
{
if (callReason == DLL_PROCESS_ATTACH)
{
InitializeMadCHook();
HookAPI("ws2_32.dll", "recv", hook_recv, (PVOID*) &org_recv);
}
else if (callReason == DLL_PROCESS_DETACH)
{
FinalizeMadCHook();
}
return true;
}