Estou tentando logar os packets mas fica dando DC. Alguém me ajuda a encontrar o erro?
Essa detour eu peguei em um tópico aqui, mas depois eu vou fazer uma minha.
Ele injeta, loga uns 2 packets e fecha.

Code:
#include <WinSock2.h>
#include <detours.h>
#include <stdio.h>
#include <windows.h>
#pragma comment(lib, "ws2_32.lib")

typedef int (WINAPI *pSend)(SOCKET s, const char* buf, int len, int flags);
pSend oSend = NULL;

int logging = 0;

LPVOID DetourCreate(BYTE *src, CONST BYTE *dst, CONST INT len)
{
	BYTE *jmp = (BYTE*)malloc(len + 5);
	DWORD dwBack;
	VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
	memcpy(jmp, src, len);
	jmp += len;
	jmp[0] = '\xE9';
	*(DWORD*)(jmp + 1) = (DWORD)(src + len - jmp) - 5;
	
	src[0] = '\xB8';
	src[5] = '\x83';
	src[6] = '\xC0';
	src[7] = '\x01';
	src[8] = '\xFF';
	src[9] = '\xE0';
	
	*(DWORD*)(&src[1]) = (DWORD)(dst - 1);
	for (INT i = 10; i < len; i++) src[i] = 0x90;
	VirtualProtect(src, len, dwBack, &dwBack);
    
	return (jmp - len);
}


int WINAPI hkSend(SOCKET s, const char* buf, int len, int flags)
{
	__asm PUSHAD;

	if (logging)
		printf("Novo Packet -> %s\n", buf);

	__asm POPAD;
	return oSend(s, buf, len, flags);
}


void Main()
{

	Sleep(30000);

	printf("Packet Logger\n");
	

	oSend = (pSend)DetourCreate((BYTE*)&send, (BYTE*)&hkSend, 10); 
	
	while (1)
	{
		if (GetAsyncKeyState(VK_INSERT) & 1)
			logging = 1 - logging;

	}
}


BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call,	LPVOID lpReserved )
{
	switch ( ul_reason_for_call )
	{
		case DLL_PROCESS_ATTACH:
			MessageBoxA(0, "a", "a", 0);
			AllocConsole();
			freopen("CONOUT$", "w", stdout);
			CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&Main, NULL, 0,NULL);
		break;
	}
	return TRUE;
}