Rev 7 | Rev 32 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "pch.h"
#pragma hdrstop
#include "CGlueMgr.h"
#include <Engine/Base/CDataStore.h>
#include <Console/ConsoleClient.h>
#include <FrameScript/FrameScript.h>
#include <WowSvcs/ClientServices.h>
#include <DB/WowClientDB.h>
CVar* g_password = NULL;
/****************************************************************************
*
* Client memory addresses
*
***/
#define CGLUEMGR_NETDISCONNECTHANDLER 0x004DA9D0
#define CGLUEMGR__RESUME 0x004DA5F0
#define CGLUEMGR__SUSPEND 0x004D8930
#define CGLUEMGR__SHUTDOWN 0x004DBBC0
/****************************************************************************
*
* Client function pointers
*
***/
void (*NetDisconnectHandlerPtr)(void const*,void*) = *(void(*)(void const*,void*))CGLUEMGR_NETDISCONNECTHANDLER;
void (*ResumePtr)(int) = *(void (*)(int))CGLUEMGR__RESUME;
void (*SuspendPtr)() = *(void (*)())CGLUEMGR__SUSPEND;
void (*ShutdownPtr)() = *(void (*)())CGLUEMGR__SHUTDOWN;
/****************************************************************************
*
* Detours setup
*
***/
//===========================================================================
void WowGM::CGlueMgr::Initialize () {
DETOUR_INIT;
DETOUR_ATTACH(NetDisconnectHandlerPtr,::CGlueMgr::NetDisconnectHandler);
DETOUR_ATTACH(ResumePtr,::CGlueMgr::Resume);
DETOUR_ATTACH(SuspendPtr,::CGlueMgr::Suspend);
DETOUR_ATTACH(ShutdownPtr,::CGlueMgr::Shutdown);
DETOUR_COMMIT;
}
//===========================================================================
void WowGM::CGlueMgr::Shutdown () {
DETOUR_INIT;
DETOUR_DETACH(NetDisconnectHandlerPtr,::CGlueMgr::NetDisconnectHandler);
DETOUR_DETACH(ResumePtr,::CGlueMgr::Resume);
DETOUR_DETACH(SuspendPtr,::CGlueMgr::Suspend);
DETOUR_DETACH(ShutdownPtr,::CGlueMgr::Shutdown);
DETOUR_COMMIT;
}
//===========================================================================
void WowGM::CGlueMgr::RegisterConsoleCommands() {
::CGlueMgr::RegisterConsoleCommands();
}
//===========================================================================
void WowGM::CGlueMgr::UnregisterConsoleCommands () {
::CGlueMgr::UnregisterConsoleCommands();
}
/****************************************************************************
*
* Console commands and scripts
*
***/
//===========================================================================
int CCommand_Script2 (const char* cmd, char const* arguments) {
FrameScript_Execute(arguments, arguments, NULL);
return 0;
}
//===========================================================================
int CCommand_MoveCharacter (const char* command, const char* arguments) {
if ((*(int*)0x00B6A9E0)) { // CGlueMgr::m_currentScreen == 2
int characterIndex = (*(int*)0x00AC436C); //CCharacterSelection::s_selectionIndex
int numCharacters = (*(int*)0x00B6B23C);
int sumtingwong = (*(int*)0xB6B240);
unsigned long long guid = *(unsigned long long*)(sumtingwong + 408 * characterIndex);
CDataStore netMsg;
netMsg.Put(CMSG_MOVE_CHARACTER_CHEAT);
netMsg.Put(NULL);
netMsg.Put(1);
netMsg.Put(guid);
netMsg.Put(16310.325195f);
netMsg.Put(16268.939453f);
netMsg.Put(69.444290f);
netMsg.Put(0.00f);
netMsg.Finalize();
ClientServices_SendOnConnection(&netMsg);
FrameScript_Execute("GetCharacterListUpdate()", "GetCharacterListUpdate()", NULL);
//ClientConnection::GetCharacterList();
}
else {
ConsoleWrite("You can only use this command on the character selection screen", ERROR_COLOR);
}
return 0;
}
//===========================================================================
int Script_DebugTest (lua_State* L) {
ConsoleWrite("Hello from Script_DebugTest!",DEFAULT_COLOR);
return TRUE;
}
/****************************************************************************
*
* CGlueMgr class implementation
*
***/
//===========================================================================
int CGlueMgr::NetDisconnectHandler (void const *a1, void *a2) {
NetDisconnectHandlerPtr(a1, a2);
WowGM::CGlueMgr::SetLoginPassword();
return 1;
}
//===========================================================================
void CGlueMgr::Resume (int initialized) {
ResumePtr(initialized);
RegisterConsoleCommands();
}
//===========================================================================
void WowGM::CGlueMgr::SetLoginPassword() {
char command[256] = {};
// TODO: Call SStrPrintF here
sprintf_s(command,
sizeof(command),
"AccountLoginPasswordEdit:SetText(\"%s\")",
g_password->m_stringValue.m_string);
FrameScript_Execute(command,command,NULL);
}
//===========================================================================
void CGlueMgr::Suspend () {
SuspendPtr();
UnregisterConsoleCommands();
}
//===========================================================================
void CGlueMgr::Shutdown () {
ShutdownPtr();
}
//===========================================================================
void CGlueMgr::RegisterConsoleCommands () {
ConsoleCommandRegister("script", CCommand_Script2, DEFAULT, 0);
ConsoleCommandRegister("movecharacter", CCommand_MoveCharacter, GAME, NOHELP);
ConsoleCommandRegister("worldport", CCommand_MoveCharacter, GAME, NOHELP);
// TODO: Move the below line under FrameScript.cpp (see FrameScript_Initialize)
//ConsoleCommandRegister("signalevent", CCommand_SignalEvent, DEFAULT, 0);
FrameScript_RegisterFunction("debugtest",Script_DebugTest);
}
//===========================================================================
void CGlueMgr::UnregisterConsoleCommands () {
ConsoleCommandUnregister("script");
ConsoleCommandUnregister("movecharacter");
ConsoleCommandUnregister("worldport");
//ConsoleCommandUnregister("signalevent");
FrameScript_UnregisterFunction("debugtest");
}