Subversion Repositories WoWGM

Rev

Rev 17 | Rev 31 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "pch.h"
#pragma hdrstop

#include "ClientServices.h"

/****************************************************************************
*
*  Private
*
***/

#define CLIENTCONNECTION__GETCHARACTERLIST  0x006B14C0;
#define  CLIENTSERVICES_REPORT              0x006B22A0;
#define  CLIENTSERVICES_SEND                                                            0x00406F40
#define  CLIENTSERVICES__SENDONCONNECTION   0x006B0B50
#define  CLIENTSERVICES_INITIALIZE                                      0x005AB1D0
#define  CLIENTSERVICES_DESTROY                                                 0x005AB3D0
#define  CLIENTSERVICES_SETMESSAGEHANDLER       0x006B0B80
#define  CLIENTSERVICES_CLEARMESSAGEHANDLER     0x006B0BC0


//===========================================================================
void (__cdecl*ClientConnection__GetCharacterListPtr) (void* connection) = *(void(__cdecl*)(void*))CLIENTCONNECTION__GETCHARACTERLIST;

//===========================================================================
void (*ClientServices_InitializePtr) () = *(void(*)())CLIENTSERVICES_INITIALIZE;

//===========================================================================
void (*ClientServices_DestroyPtr) () = *(void(*)())CLIENTSERVICES_DESTROY;

//===========================================================================
BOOL (*ClientServices_ReportPtr) (unsigned int category, LPCSTR title) = *(BOOL(*)(unsigned int,LPCSTR))CLIENTSERVICES_REPORT;

//===========================================================================
void (__cdecl* ClientServices_SendPtr) (CDataStore* netMessage) = *(void(__cdecl*)(CDataStore*))CLIENTSERVICES_SEND;

//===========================================================================
void(__cdecl* ClientServices_SendOnConnectionPtr) (CDataStore* msg) = *(void(__cdecl*)(CDataStore*))CLIENTSERVICES__SENDONCONNECTION;

//===========================================================================
void (__cdecl* ClientServices_SetMessageHandlerPtr) (NETMESSAGE msgID,
                                                                                                                                                                                                                 int                            (__cdecl* handler)(void*,
                                                                                                                                                                                                                                                                                                                                         NETMESSAGE,
                                                                                                                                                                                                                                                                                                                                         unsigned int,
                                                                                                                                                                                                                                                                                                                                         CDataStore*),
                                                                                                                                                                                                                 void*                  param) = *(void(*)(NETMESSAGE,
                                                                                                                                                                                                                                                                                                                                         int (__cdecl*)(void*,
                                                                                                                                                                                                                                                                                                                                                                                                        NETMESSAGE,
                                                                                                                                                                                                                                                                                                                                                                                                        unsigned int,
                                                                                                                                                                                                                                                                                                                                                                                                        CDataStore*),
                                                                                                                                                                                                                                                                                                                                         void*))CLIENTSERVICES_SETMESSAGEHANDLER;

//===========================================================================
void (__cdecl* ClientServices_ClearMessageHandlerPtr) (NETMESSAGE msgID) = *(void(*)(NETMESSAGE))CLIENTSERVICES_CLEARMESSAGEHANDLER;


//===========================================================================
void ClientServices_InternalInitialize () {
        ClientServices_InitializePtr();
}

//===========================================================================
void ClientServices_InternalDestroy () {
        ClientServices_DestroyPtr();
}


/****************************************************************************
*
*  External functions
*
***/

void __cdecl ClientConnection::GetCharacterList () {
  ClientConnection__GetCharacterListPtr(ClientServices_Connection());
}


//===========================================================================
void ClientServices_Initialize () {
        DETOUR_INIT;
        
        DETOUR_ATTACH(ClientServices_InitializePtr,ClientServices_InternalInitialize);
        DETOUR_COMMIT;
}

//===========================================================================
void* ClientServices_Connection () {
  return (void*)0x00C79CF4;  // ClientConnection::s_currentConnection
}

//===========================================================================
void ClientServices_Destroy () {
        DETOUR_INIT;

        DETOUR_DETACH(ClientServices_DestroyPtr,ClientServices_InternalDestroy);
        DETOUR_COMMIT;
}

//===========================================================================
BOOL ClientServices_Report (unsigned int category, char const* title) {
  return ClientServices_ReportPtr(category, title);
}

//===========================================================================
void ClientServices_Send (CDataStore *netMessage) {
        ClientServices_SendPtr(netMessage);
}

//===========================================================================
void ClientServices_SendOnConnection(CDataStore* msg) {
  ClientServices_SendOnConnectionPtr(msg);
}

//===========================================================================
void ClientServices_SetMessageHandler (NETMESSAGE msgID,
                                                                           int(*handler)(void*,NETMESSAGE,unsigned int,CDataStore*),
                                                                           void* param)
{
        ClientServices_SetMessageHandlerPtr(msgID,handler,param);
}

//===========================================================================
void ClientServices_ClearMessageHandler (NETMESSAGE msgID) {
        ClientServices_ClearMessageHandlerPtr(msgID);
}