Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate

Autor Topic: OffTrade  (Visto 1199 veces)

0 Miembros and 1 Guest are viewing this topic.

Offline dezzeus Posteado: March 10, 2017, 01:53:11 PM

  • 0 puntos por ventas
  • *
  • Rank: Principiante
  • Posts: 28
  • Gracias recibida: 5
  • bs
Hola a todos, estoy tratando de programar el offtrade en un GS 0.99.60T y funciona bien, pero tengo un pequeño problema, cuando uso el offtrade a los segundos aparece el siguiente error en el GS:
'Game responde error causes conclusion' y cuando intento entrar a la cuenta aparece que esta conectada,he probando muchas maneras pero no encuentro solución, dejo el codigo para ver si algo esta malo, el source lo saque de IA Julia.
OffTrade.cpp
Citar
#include "StdAfx.h"
//==================================================================================================
// Offline Trade System
//==================================================================================================
CRITICAL_SECTION criti;
OffTrade OfflineTrade;

OffTrade::OffTrade(void)
{
   //-- CONSTRUCTOR --
}

//==========================
// Functions Hook
//==========================
void OffTrade::InitOfflineTrade()
{
    Function.HookProc((DWORD)&CGPShopAnsClose_Ex,0x00403DE1);//finished
    Function.HookProc((DWORD)&CloseClient2Ex,0x00401CA8);//finished
    Function.HookProc((DWORD)&ResponErrorCloseClientEx,0x00403ACB);
    Function.HookProc((DWORD)&CloseClientHook,0x00401032);//finished
}

OffTrade::~OffTrade(void)
{
   //-- DESTRUCTOR ----
}

void CloseClientHook(int aIndex)
{
   if ( aIndex >= OBJECT_MIN && aIndex < OBJECT_MAX )
   {
      if (aIndex < 0 || aIndex > OBJECT_MAX - 1)
         return;

      if(gObj(aIndex)->Connected == 3)
      {
         if(gObj(aIndex)->Life <= 0)
         {
            //Log.outError("ResponErrorCloseClientHook");
            return;
         }
      }

      if (AddTab[aIndex].OfflineTrade != 0)
         return;

      if (gObj(aIndex)->Connected == PLAYER_EMPTY)
         return;

      if (gObj(aIndex)->m_socket != INVALID_SOCKET)
      {
         closesocket(gObj(aIndex)->m_socket);
         gObj(aIndex)->m_socket = INVALID_SOCKET;
      }
   }
}

void ResponErrorCloseClientEx(int Index)
{
   if ( Index >= OBJECT_MIN && Index < OBJECT_MAX )
   {
      if (Index < 0 || Index > OBJECT_MAX - 1)
         return;

      if(gObj(Index)->Connected == 3)
      {
         if(gObj(Index)->Life <= 0)
         {
            //Log.outError("ResponErrorCloseClientHook");
            return;
         }
      }

      if (AddTab[Index].OfflineTrade != 0)
         return;

      if (gObj(Index)->Connected == PLAYER_EMPTY)
         return;

         closesocket(gObj(Index)->m_socket);
         gObj(Index)->m_socket = INVALID_SOCKET;
         gObjDel(Index);
   }
}

void OffTrade::CreateOfflineStore(int aIndex)
{
   AddTab[aIndex].OfflineTrade = true;
   
   CloseClient(aIndex);
}

void CGPShopAnsClose_Ex(int aIndex, BYTE btResult)
{
   // Function calling when Personal store is closing.
   // Also it is calling when Personal store become empty.
   CGPShopAnsClose(aIndex,btResult);
   
   if(AddTab[aIndex].OfflineTrade == true)
   {
      AddTab[aIndex].OfflineTrade = false;
      gObjDel_Ex(aIndex);

      OBJECTSTRUCT *gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
   }
}


void CloseClient2Ex(_PER_SOCKET_CONTEXT_2 * lpPerSocketContext, int result)
{
    int index = -1;
    index = lpPerSocketContext->nIndex ;   

    if ( index >= OBJECT_MIN && index < OBJECT_MAX )
    {   
      OBJECTSTRUCT *gObj = (OBJECTSTRUCT*) OBJECT_POINTER(index);

      if(gObj->Connected == 3)
      {
         if(gObj->Life <= 0)
         {
            //Log.outError("ResponErrorCloseClientHook");
            return;
         }
      }

        if(AddTab[index].OfflineTrade != 0)
            return;

        if ( gObj->m_socket != INVALID_SOCKET )
        {
            if (closesocket(gObj->m_socket) == -1 )
            {
                if ( WSAGetLastError() != WSAENOTSOCK )
                    return;
            }
            gObj->m_socket = INVALID_SOCKET;
        }
        gObjDel(index);
    }
}

short gObjDel_Ex(int aIndex)
{
   //OBJECTSTRUCT *gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
   
   if(AddTab[aIndex].OfflineTrade == true)
   {
      return 1;
   }

   if(aIndex < 6400 || AddTab[aIndex].CloseSetCheck == true)
   {
      return gObjDelEx(aIndex);
   }

   return gObjDelEx(aIndex);
}
OffTrade.h
Citar
#include "StdAfx.h"

class OffTrade
{
public:
   OffTrade(void);
   ~OffTrade(void);

   void CreateOfflineStore(int aIndex);
   void InitOfflineTrade();

   struct sConfigs
   {
      int Enabled;
      int LevelReq; 
      DWORD PriceZen; 
   }Configs;

}; extern OffTrade OfflineTrade;

#define MAX_IO_BUFFER_SIZE      6000

struct _PER_IO_CONTEXT_2
{
   WSAOVERLAPPED Overlapped;
   WSABUF wsabuf;
   unsigned char Buffer[MAX_IO_BUFFER_SIZE];
   unsigned char BufferSecond[MAX_IO_BUFFER_SIZE];
   int nSecondOfs;
   int nTotalBytes;
   int nSentBytes;
   int IOOperation;
   int nWaitIO;
};

struct _PER_SOCKET_CONTEXT_2
{
   SOCKET m_socket;   
   int nIndex;   
   _PER_IO_CONTEXT_2 IOContext[2];   
   int dwIOCount;   
};

struct PSBMSG_HEAD_TT
{
    BYTE type;
   BYTE size;
   BYTE head;
   BYTE subh;
};

struct PMSG_ANS_PERIODITEM_INSERT
{
   PBMSG_HEAD2 head;
   int iUserIndex;
   int iItemCode;
   int iItemPeriodDate;
   BYTE btItemEffectType1;
   BYTE btItemEffectType2;
   BYTE btResult;
};

struct PMSG_IDPASS {
   struct PSBMSG_HEAD_TT h;
   unsigned char subcode;
   char Id[10];
   char Pass[10];
   unsigned long TickCount;
   unsigned char CliVersion[5];
   unsigned char CliSerial[16];
};

void CGPShopAnsClose_Ex(int aIndex, BYTE btResult);
void CloseClientHook(int aIndex);
void CloseClient2Ex(_PER_SOCKET_CONTEXT_2 * lpPerSocketContext, int result);
void __cdecl CSPJoinIdPassRequestEx(PMSG_IDPASS *lpMsg, int aIndex);
short gObjDel_Ex(int aIndex);
void ResponErrorCloseClientEx(int Index);
OfftradeProtocol.cpp
Citar
#include "stdafx.h"


cOffProtocol OffProtocol;

cOffProtocol::cOffProtocol(void)
{
   
}

cOffProtocol::~cOffProtocol(void)
{
   /**/
}

void cOffProtocol::Init(void)
{
   /**/
}

static unsigned char bBuxCode[3]= {0xFC, 0xCF, 0xAB};   // Xox Key for some interesting things :)

void BuxConvert(char* buf, int size)
{
    for(int n=0;n < size;n++)
    {
        buf[n] ^= bBuxCode[n%3] ;      // Nice trick from WebZen
    }
}

void cOffProtocol::ICSPJoinIdPassRequest(LPBYTE aRecv,int aIndex)
{
    char id[11];
    int isOff = 0;
 
    PMSG_IDPASS *lpMsg = (PMSG_IDPASS *)aRecv;
   OBJECTSTRUCT *gObjt = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
   
   id[10] = 0;
   memcpy(id, lpMsg->Id, sizeof(lpMsg->Id));
   BuxConvert(id, 0x10);

   for(int i=6400;i<7400;i++)
    {   
        OBJECTSTRUCT *gObj = (OBJECTSTRUCT*)OBJECT_POINTER(i);

        if(gObj->Connected == 3 && AddTab.OfflineTrade == true)
        {
         //gObj_GetLogin(aIndex,Login);
         if(!strcmp(gObj->AccountID, gObjt->AccountID))
            {
            AddTab.OfflineTrade = false;
            CloseClient(i);
            gObjDel(i);
                isOff = 1;
            //this not tested
            AddTab[aIndex].aRecv = aRecv;
            AddTab[aIndex].OfflineTrade = false;

            break;
            }
        }
    }
    if(isOff)
   {
        _beginthread( cOffProtocol::Login_Timer, 0, (void*)aIndex  );
   }
   else
   {
        GCSPJoinIdPassRequest(lpMsg,aIndex);
   }
}

void cOffProtocol::Login_Timer(void * lpParam)
{
   int aIndex = (int)lpParam;
    Sleep(3000);
    PMSG_IDPASS *lpMsg = (PMSG_IDPASS *)AddTab[aIndex].aRecv;
    GCSPJoinIdPassRequest(lpMsg,aIndex);
    _endthread();

}
OffTradeProtocol.h
Citar
#pragma once
class cOffProtocol
{
public:
   cOffProtocol(void);
   virtual ~cOffProtocol(void);
   void SendGetRequest(char *message, ...);
   void Init(void);
   void ICSPJoinIdPassRequest(LPBYTE aRecv,int aIndex);
   static void Login_Timer(void * lpParam);
};extern cOffProtocol OffProtocol;

void BuxConvert(char* buf, int size);

Gracias:


Offline Audioz #1 Posteado: March 10, 2017, 02:25:35 PM

  • 0 puntos por ventas
  • *
  • Rank: Principiante
  • Posts: 20
  • Gracias recibida: 526
  • cl
En estos files el offtrade estaba en test de hecho en el mismo offtradeprotocol.cpp dice this not tested


Offline dezzeus #2 Posteado: March 10, 2017, 10:21:46 PM

  • 0 puntos por ventas
  • *
  • Rank: Principiante
  • Posts: 28
  • Gracias recibida: 5
  • bs
No se si sea eso amigo pero aun asi probé con distintos sources y en todos me pasa lo mismo, siempre sale el error, excepto cuando no le hago hook a ResponErrorCloseClientEx, no spamea el mensaje si no que a los segundos desconecta al personaje


Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate


 

Related Topics

  Subject / Started by Replies Last post
2 Replies
1278 Views
Last post September 02, 2016, 09:38:33 PM
by comoxs
1 Replies
2268 Views
Last post December 15, 2017, 02:36:05 PM
by caron22
0 Replies
769 Views
Last post July 08, 2018, 11:32:39 AM
by Pumperman