Hi there,
i've a problem. I'm not sure if i've done some misstakes. But every time i inject my dll the game will crash while i get or send a packet. Maybe someone can help me? I'll post the source code.
I don't know why i'll get a crash. The game log says: "EXCEPTION_ACCESS_VIOLATION". I tried some various types of detouring. I'll ever get a crash.
Here's the assembler part of (ingame) send:
I hope someone can help me.
Greetings,
hijax.
i've a problem. I'm not sure if i've done some misstakes. But every time i inject my dll the game will crash while i get or send a packet. Maybe someone can help me? I'll post the source code.
Code:
#include <windows.h>
#include "detours.h"
#pragma comment(lib, "detours.lib")
DWORD RecvOffset = 0x00D95060;
DWORD SendOffset = 0x00D950B0;
int (__stdcall *Recv)(SOCKET Socket, char *Buffer, int Length, int Flags);
int XRecv(SOCKET Socket, char *Buffer, int Length, int Flags) {
return Recv(Socket, Buffer, Length, Flags);
}
int (__stdcall *Send)(SOCKET Socket, char *Buffer, int Length, int Flags);
int XSend(SOCKET Socket, char *Buffer, int Length, int Flags) {
return Send(Socket, Buffer, Length, Flags);
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) {
switch(dwReason) {
case DLL_PROCESS_ATTACH:
Recv = (int (__stdcall *)(SOCKET, char *, int, int))DetourFunction((PBYTE)RecvOffset, (PBYTE)XRecv);
Send = (int (__stdcall *)(SOCKET, char *, int, int))DetourFunction((PBYTE)SendOffset, (PBYTE)XSend);
break;
case DLL_PROCESS_DETACH:
DetourRemove((PBYTE)Recv, (PBYTE)XRecv);
DetourRemove((PBYTE)Send, (PBYTE)XSend);
break;
}
return true;
}
Here's the assembler part of (ingame) send:
Code:
mov eax, [esp+len] push ebx push esi mov esi, [esp+8+arg_0] push edi imul esi, 78h push 0 ; flags mov edi, ecx mov ecx, [esp+10h+buf] mov edx, [edi+10h] push eax ; len mov eax, [edx+esi] push ecx ; buf push eax ; s call ds:send cmp eax, 0FFFFFFFFh mov ebx, [esp+0Ch+arg_C] mov [ebx], eax jnz short loc_D95100 call ds:WSAGetLastError cmp eax, 2733h mov [ebx], eax jnz short loc_D950F8 mov ecx, [edi+10h] lea eax, [ecx+esi+50h] inc dword ptr [eax] loc_D950F8: pop edi pop esi xor al, al pop ebx retn 10h loc_D95100: pop edi pop esi mov al, 1 pop ebx retn 10h endp
Greetings,
hijax.