Questiondetours/hook Connect

Posts 1–9 of 9 · Page 1 of 1
detours/hook Connect
I like to hook the connection funktion from CA, but if i hook this than cant connect Combat Arms. I use Detours. Is Detours detected? In other brogramm my hook work good but not in CA. Do you have an idea why?

PS: Sry for my bad english. I like german more.
No Body Can Help you With Out see Your Our Code
This is an argument here is it:

Code:
#include <cstdio>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <string>
#include <windows.h>
#include <detours.h>

#pragma comment( lib, "Ws2_32.lib" )
#pragma comment( lib, "detours.lib" )
#pragma comment( lib, "detoured.lib" )
#pragma comment( lib, "Mswsock.lib" )

std::ofstream Logger;

std::string NowToString() {
    time_t rawtime;
    tm *timeinfo = new tm();
    char buffer[32];

    time( &rawtime );
    localtime_s( timeinfo, &rawtime );

    strftime( buffer, 32, "%m/%d/%Y %I:%M:%S %p", timeinfo );

    delete timeinfo;

    return std::string( buffer );
}

std::string TimeToString() {
    time_t rawtime;
    tm *timeinfo = new tm();
    char buffer[32];

    time( &rawtime );
    localtime_s( timeinfo, &rawtime );

    strftime( buffer, 32, "%I:%M:%S %p", timeinfo );

    delete timeinfo;

    return std::string( buffer );
}

void LogPacket( const char *buf, int len ) {
    Logger << "        0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F\n";
    Logger << "       -- -- -- -- -- -- -- --  -- -- -- -- -- -- -- --\n";
    Logger << "0000   ";

    for ( int i = 0; i < len; ++i ) {
     if ( i != 0 && i % 16 == 0 ) {
      Logger << "  ";

      int line = ( i / 16 ) - 1;

      for ( int j = 0; j < 16; ++j ) {
       char c = buf[line * 16 + j];

       if ( c >= 32 && c <= 126 ) {
        Logger << c;
       } else {
        Logger << '.';
       }
      }

      Logger << "\n" << std::hex << std::setw( 4 ) << std::setfill( '0' ) << i << std::dec << std::setw( 0 ) << "   ";
     } else if ( i % 16 == 8 ) {
      Logger << ' ';
     }

     Logger << std::hex << std::setw( 2 ) << std::setfill( '0' ) << ( int( buf[i] ) & 0xFF ) << ' ';
     Logger << std::dec << std::setw( 0 );

     if ( i == len - 1 ) {
      int remaining = 16 - ( len % 16 );
      int fill = ( remaining * 3 ) + 2;

      if ( remaining >= 8 ) {
       ++fill;
      }

      for ( int j = 0; j < fill; ++j ) {
       Logger << ' ';
      }

      int line = ( i - ( ( len % 16 ) - 1 ) ) / 16 ;

      //for ( int k = 0; k < ( len % 16 ); ++k ) {
	  for ( int k = 0; k < ( len-i); ++k ) {
       char c = buf[line * 16 + k];

       if ( c >= 32 && c <= 126 ) {
        Logger << c;
       } else {
        Logger << '.';
       }
      }
     }
    }

    Logger << "\n\n";
}

int ( WINAPI *Real_Send )( SOCKET s, const char *buf, int len, int flags ) = send;
int ( WINAPI *Real_Recv )( SOCKET s, char *buf, int len, int flags ) = recv;
int ( WINAPI *Real_RecvFrom )( SOCKET s, char *buf, int len, int flags, sockaddr *from, int *fromlen ) = recvfrom;
int ( WINAPI *Real_WSARecvEx )( SOCKET s, char *buf, int len, int *flags ) = WSARecvEx;

int ( WINAPI *Real_Connect )( SOCKET s, const sockaddr *serv_addr, int addrlen ) = connect;

int WINAPI Mine_Send( SOCKET s, const char* buf, int len, int flags );
int WINAPI Mine_Recv( SOCKET s, char *buf, int len, int flags );
int WINAPI Mine_RecvFrom( SOCKET s, char *buf, int len, int flags, sockaddr *from, int *fromlen );
int WINAPI Mine_WSARecvEx( SOCKET s, char *buf, int len, int *flags );

int WINAPI Mine_Connect( SOCKET s, sockaddr *serv_addr, int addrlen );

int WINAPI Mine_Send( SOCKET s, const char *buf, int len, int flags ) {
    Logger << "Send\n";
	Logger << TimeToString() << ": Client -> Server (Length: " << len << " bytes)\n\n";
    LogPacket( buf, len );
    Logger << std::endl;

    return Real_Send( s, buf, len, flags );
}

int WINAPI Mine_Recv( SOCKET s, char *buf, int len, int flags ) {
    Logger << "Recv\n";
	Logger << TimeToString() << ": Server -> Client (Length: " << len << " bytes)\n\n";
    LogPacket( buf, len );
    Logger << std::endl;

    return Real_Recv( s, buf, len, flags );
}

int WINAPI Mine_RecvFrom( SOCKET s, char *buf, int len, int flags, sockaddr *from, int *fromlen ) {
    Logger << "RecvFrom\n";
	Logger << TimeToString() << ": Server -> Client (Length: " << len << " bytes)*\n\n";
    LogPacket( buf, len );
    Logger << std::endl;

    return Real_RecvFrom( s, buf, len, flags, from, fromlen );
}

int WINAPI Mine_WSARecvEx( SOCKET s, char *buf, int len, int *flags ) {
    Logger << "WSARecvEx\n";
	Logger << TimeToString() << ": Server -> Client (Length: " << len << " bytes)**\n\n";
    LogPacket( buf, len );
    Logger << std::endl;

    return Real_WSARecvEx( s, buf, len, flags );
}

int WINAPI Mine_Connect(SOCKET sockfd, sockaddr *serv_addr, int addrlen )
{
	sockaddr_in *a = (sockaddr_in *)serv_addr;
	ULONG IP=a->sin_addr.S_un.S_addr;
	int IP_1, IP_2, IP_3, IP_4;
	IP_1=int(IP%256);
	IP=(IP-IP_1)/256;
	IP_2=int(IP%256);
	IP=(IP-IP_2)/256;
	IP_3=int(IP%256);
	IP=(IP-IP_3)/256;
	IP_4=int(IP%256);
	Logger << "Connect to \n";
	Logger << "IP:   " << IP_1<<"."<<IP_2<<"."<<IP_3<<"."<<IP_4<<"\n";
	Logger << "Port: " << a->sin_port;
	a->sin_port=htons(10001);
	Logger << "\nPort: " << a->sin_port;
	Logger << std::endl;
	return Real_Connect(sockfd,serv_addr,addrlen);
}

__declspec(dllexport) BOOL WINAPI DllMain( HINSTANCE, DWORD dwReason, LPVOID ) {
   	switch ( dwReason ) {
     case DLL_PROCESS_ATTACH:
	  Beep(1000,1000);
		 //DebugBreak();
      Logger.open( "R:\\Packets.txt", std::ios::out | std::ios::app | std::ios::ate );

      if ( Logger.tellp() > 0 ) {
       Logger << "\n\n\n";
      }

      Logger << "##\n## Logging Started (" << NowToString() << ")\n##\n\n\n";
	
      DetourTransactionBegin();
      DetourUpdateThread( GetCurrentThread() );
	
      DetourAttach( &(PVOID &)Real_Send, Mine_Send );
      DetourAttach( &(PVOID &)Real_Recv, Mine_Recv );
      DetourAttach( &(PVOID &)Real_RecvFrom, Mine_RecvFrom );
      DetourAttach( &(PVOID &)Real_WSARecvEx, Mine_WSARecvEx );
	  
	  DetourAttach( &(PVOID &)Real_Connect, Mine_Connect );
      DetourTransactionCommit();
	
      break;

     case DLL_PROCESS_DETACH:
      Logger << "##\n## Logging Stopped (" << NowToString() << ")\n##";
      Logger.close();
	
      DetourTransactionBegin();
      DetourUpdateThread( GetCurrentThread() );
	
      DetourDetach( &(PVOID &)Real_Send, Mine_Send );
      DetourDetach( &(PVOID &)Real_Recv, Mine_Recv );
      DetourDetach( &(PVOID &)Real_RecvFrom, Mine_RecvFrom );
      DetourDetach( &(PVOID &)Real_WSARecvEx, Mine_WSARecvEx );
	
	  DetourDetach( &(PVOID &)Real_Connect, Mine_Connect );
      DetourTransactionCommit();
	
      break;
    }

    return TRUE;
}
what do you want to use that for.
Semistic codecs are used to fake packets.
Do you want to read the packets or edit them?

I woulnd't do packet faking or something else
gfgf

Edit:

int WINAPI Mine_Connect(SOCKET sockfd, sockaddr *serv_addr, int addrlen )
{
sockaddr_in *a = (sockaddr_in *)serv_addr;
ULONG IP=a->sin_addr.S_un.S_addr;
int IP_1, IP_2, IP_3, IP_4;
IP_1=int(IP%256);
IP=(IP-IP_1)/256;
IP_2=int(IP%256);
IP=(IP-IP_2)/256;
IP_3=int(IP%256);
IP=(IP-IP_3)/256;
IP_4=int(IP%256);
Logger << "Connect to \n";
Logger << "IP: " << IP_1<<"."<<IP_2<<"."<<IP_3<<"."<<IP_4<<"\n";
Logger << "Port: " << a->sin_port;
a->sin_port=htons(10001);
Logger << "\nPort: " << a->sin_port;
Logger << std::endl;
return Real_Connect(sockfd,serv_addr,addrlen);
}
ohh ok now I understand
I don't think we can help you here
Why?
How do you hook the d3d functions? It should be the same how hook connet.
I use E9Detours for Warrock and Combat Arms
(Just a part of it : )
Code:
void *E9(BYTE *src, const BYTE *dst, int minlen)
{
	BYTE *jmp, *org;
	DWORD dwBack;
	int  len;

	
	len=AsmDet(src,(minlen<6)?6:minlen);
	if (len==0 && minlen>=6)  len=minlen;
	if (len==0) return 0;
	
	org=jmp = (BYTE*)malloc(len+5+1);
    jmp[0]=len;
    jmp++;
	
	VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
	memcpy(jmp, src, len); 
	jmp += len;
	jmp[0] = 0xE9;
	*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
	
	src[0] = 0x68;
	*(DWORD*)(src+1) = (DWORD)(dst);
	src[5] = 0xc3;
	for (int i=6; i<len; i++)  src[i] = 0x90;
	VirtualProtect(src, len, dwBack, &dwBack);
	
	return &org[1];
}
Oh and look into the CA EU section I've posted some hotkey hack with present there, Yeah it's C&pe'd, but it should help you..

Wait I'm quoting:

#include <windows.h>
#include <stdio.h>
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment (lib, "d3dx9.lib")
#pragma comment (lib, "d3d9.lib")
#pragma warning( disable : 4244 )

void CreateDev(DWORD * dwVTable){
LPDIRECT3D9 pD3d9 = NULL;
LPDIRECT3DDEVICE9 pD3DDevice = NULL;
pD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
if(pD3d9 == NULL){
return;
}
D3DPRESENT_PARAMETERS pPresentParms;
ZeroMemory(&pPresentParms,sizeof(pPresentParms));
pPresentParms.Windowed = TRUE;
pPresentParms.BackBufferFormat = D3DFMT_UNKNOWN;
pPresentParms.SwapEffect = D3DSWAPEFFECT_DISCARD;
if(FAILED(pD3d9->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,Ge tDesktopWindow(),D3DCREATE_SOFTWARE_VERTEXPROCESSI NG,&pPresentParms,&pD3DDevice))){
return;
}
DWORD * dwTable = ( DWORD* )pD3DDevice;
dwTable = ( DWORD* ) dwTable[0];
dwVTable[0] = dwTable[16];
dwVTable[1] = dwTable[17];
dwVTable[2] = dwTable[82];
}

typedef HRESULT (WINAPI* tPresent)(LPDIRECT3DDEVICE9 pDevice,CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion);
tPresent oPresent;

void *MBDetour(BYTE *src,const BYTE *dst,const int len){
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len); jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}



HRESULT WINAPI hkPresent(LPDIRECT3DDEVICE9 pDevice,CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion){

//Present
}
return oPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}

DWORD WINAPI WaitnLoad(LPVOID lpArgs){
DWORD dwD3D9 = NULL;
while(!dwD3D9){
Sleep(25);
dwD3D9 = (DWORD)GetModuleHandleA("D3d9.dll");
}
DWORD dwVTable[3] = {0};

CreateDev( dwVTable );
oPresent = ( tPresent )MBDetour(( PBYTE ) dwVTable[1], ( PBYTE ) &hkPresent ,5);
return FALSE;
}

BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
{
DisableThreadLibraryCalls(hDll);
if ( dwReason == DLL_PROCESS_ATTACH )
{
CreateThread(NULL, NULL, WaitnLoad, NULL, NULL, NULL);
}
return TRUE;
}
I don't know if the Detour Function works, but I guess so cuz some C&p public hacks r using it.
Please don't care about the ulgy, bulky code how I said I've just added the functions and C&pe'd the guys PTC into present, cuz I wanted to show him something dunno.
I have found my problem: the injector...

have one a code from a injector that works with hack shild?
Quote Originally Posted by Neoticer View Post
I have found my problem: the injector...

have one a code from a injector that works with hack shild?
try remote dll, it's better than all the vb crap here (no offence, but it's all the same...)
ok the Injector is not the problem :-(
how work the anti hook from Hackshild?

i have hooked all fkt but not one is called

EDIT: or did one know how i kan change the IP Adress from the Loginserver?
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

Need help?