内容参考于:易道云信息技术研究院VIP课
上一个内容:数据包组织与发送过程逆向分析
码云地址(游戏窗口化助手 分支):https://gitee.com/dye_your_fingers/sro_-ex.git
码云版本号:ec54e9ae1ca0efe96b87d5dca1a2d0f873cba474
代码下载地址,在 SRO_EX 目录下,文件名为:SRO_Ex-C++还原网络通信系统发送功能.zip
链接:https://pan.baidu.com/s/1W-JpUcGOWbSJmMdmtMzYZg
提取码:q9n5
–来自百度网盘超级会员V4的分享
HOOK引擎,文件名为:黑兔sdk.zip
链接:https://pan.baidu.com/s/1IB-Zs6hi3yU8LC2f-8hIEw
提取码:78h8
–来自百度网盘超级会员V4的分享
以窗口化助手与游戏窗口同步移动 它的代码为基础进行修改
完成了C++与游戏网络通信的函数对接
extern_all.cpp文件的修改:
#pragma once#include "GameBase.h"#include "CUI.h"#include "CHelperUI.h"extern CHelperUI* _ui_helper;extern CUI* _ui;extern GameBase* _pgamebase;extern void InitClassProc(LPVOID proc_addr, unsigned value);extern void InitClassProc(LPVOID proc_addr, unsigned* vtable, unsigned index);
新加extern_all.cpp文件:
#include "pch.h"#include "extern_all.h"void InitClassProc(LPVOID proc_addr, unsigned value){unsigned* uWrite = (unsigned*)proc_addr;uWrite[0] = value;}void InitClassProc(LPVOID proc_addr, unsigned* vtable, unsigned index) {unsigned* addr = (unsigned*)vtable[0];InitClassProc(proc_addr, addr[index]);}
GameBase.h文件的修改:删除了InitClassProc函数
#pragma once#include "Res.h"#include "Control.h"#include "AIM.h"#include "ITEM.h"#include "Core.h"#include "Net.h"class GameBase{public:void Init();GameBase();PRes SRO_Res;PControl SRO_Control;PAIM SRO_Player;PCore SRO_Core;PNet SRO_Net;};
GameBase.cpp文件的修改:修改了Init函数,删除了InitClassProc函数
#include "pch.h"#include "GameBase.h"#include "extern_all.h"GameBase* _pgamebase;void GameBase::Init(){unsigned* addrRead = (unsigned*)0x1256E3C;SRO_Res = (PRes)0x1036518;SRO_Control = (PControl)addrRead[0];addrRead = (unsigned*)0x1037D3C;SRO_Player = (PAIM)addrRead[0];SRO_Core = (PCore)0x1036590;addrRead = (unsigned*)0x12A3AB0;SRO_Net = (PNet)addrRead[0];InitClassProc(&Res::_ReadTitle, 0x9A46C0);InitClassProc(&Res::_ReadItemTitle, 0x9A4640);InitClassProc(&Control::_NormalNotice, 0x848580);InitClassProc(&Control::_NetNotice, 0x844E40);InitClassProc(&Control::_ChatNotice, 0x844E80);InitClassProc(&Control::_GetPPack, 0x866140);InitClassProc(&Control::_UseItem, 0x85F640);InitClassProc(&Control::_MangeItem, 0x864220);InitClassProc(&ITEM::_GetItemRes, 0x995800);InitClassProc(&Pack::_GetPackPack, 0x7722C0);InitClassProc(&Pack::_GetEquipPack, 0x772300);InitClassProc(&Core::_GetLvMaxExp, 0xA21F20);InitClassProc(&NetData::_MakeData, 0x47F550);}//void GameBase::InitClassProc(LPVOID proc_addr, unsigned value)//{//unsigned* uWrite = (unsigned*)proc_addr;//uWrite[0] = value;//}GameBase::GameBase(){_pgamebase = this;// Init();// 初始化机制,完成游戏与我们dll的对接}
新加NetData类:
NetData.cpp文件
#include "pch.h"#include "NetData.h"NetData::PROC_P_D NetData::_MakeData{};void NetData::MakeData(LPVOID data, unsigned len){return(this->*_MakeData)(data, len);}
NetData.h文件
#pragma oncetypedef class NetData{typedef void (NetData::* PROC_P_D)(LPVOID, unsigned);public:static PROC_P_D _MakeData;void MakeData(LPVOID, unsigned);}*PNetData;
新加Net类:
Net.cpp文件
#include "pch.h"#include "Net.h"#include "extern_all.h"Net::P_PROC_D_D Net::_CreateNetData{};Net::PROC_P Net::_SendData{};PNetData Net::CreateNetData(unsigned type, unsigned option){InitClassProc(&Net::_CreateNetData, vTable, 0x9);return (this->*_CreateNetData)(type, option);}void Net::SendData(LPVOID data){InitClassProc(&Net::_SendData, vTable, 0xB);return (this->*_SendData)(data);}
Net.h文件
#pragma once#include "NetData.h"typedef class Net{typedef PNetData(Net::* P_PROC_D_D)(unsigned, unsigned);typedef void(Net::* PROC_P)(LPVOID);unsigned* vTable; // 虚表static P_PROC_D_D _CreateNetData;static PROC_P _SendData;public:PNetData CreateNetData(unsigned type, unsigned option);void SendData(LPVOID);}*PNet;