88.网游逆向分析与插件开发-物品使用-物品使用策略管理UI的设计

内容参考于:易道云信息技术研究院VIP课

上一个内容:物品交换的逆向分析与C++封装-CSDN博客

码云地址(ui显示角色数据 分支):https://gitee.com/dye_your_fingers/sro_-ex.git

码云版本号:f1b9b1a69ac3e2c32a671a9d34f38bf5b02c9ac1

代码下载地址,在 SRO_EX 目录下,文件名为:SRO_Ex-物品使用策略管理UI的设计.zip

链接:https://pan.baidu.com/s/1W-JpUcGOWbSJmMdmtMzYZg

提取码:q9n5

--来自百度网盘超级会员V4的分享

HOOK引擎,文件名为:黑兔sdk.zip

链接:https://pan.baidu.com/s/1IB-Zs6hi3yU8LC2f-8hIEw

提取码:78h8

--来自百度网盘超级会员V4的分享

以 物品交换的逆向分析与C++封装-CSDN博客 它的代码为基础进行修改

添加控件:

窗口0

88.网游逆向分析与插件开发-物品使用-物品使用策略管理UI的设计_第1张图片

 窗口1

88.网游逆向分析与插件开发-物品使用-物品使用策略管理UI的设计_第2张图片

变量的名是什么详情看:mfc的添加变量

88.网游逆向分析与插件开发-物品使用-物品使用策略管理UI的设计_第3张图片

88.网游逆向分析与插件开发-物品使用-物品使用策略管理UI的设计_第4张图片

CUIWnd_0.h文件的修改:添加ui输入框变量

#pragma once
#include "afxdialogex.h"

// CUIWnd_0 对话框

class CUIWnd_0 : public CDialogEx
{
	DECLARE_DYNAMIC(CUIWnd_0)

public:
	CUIWnd_0(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CUIWnd_0();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_PAGE_0 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	// 玩家信息
	CString txt_Player;
	BOOL OnInitDialog();
	void ShowPlayerTxt();
	CString txtWeapon;
	CString txtMP;
	CString txtHPEx;
	CString txtHP;
	int HpMin;
	int HpExMin;
	int MpMin;
	afx_msg void OnBnClickedButton1();
};

CUIWnd_0.cpp文件的修改:新加 OnBnClickedButton1函数,OnBnClickedButton1函数是应用按钮的点击事件处理函数

// CUIWnd_0.cpp: 实现文件
//

#include "pch.h"
#include "htdMfcDll.h"
#include "CUIWnd_0.h"
#include "GameBase.h"
#include "extern_all.h"

// CUIWnd_0 对话框
CUIWnd_0* UI_0;
void _stdcall TimeProc(HWND, UINT, UINT_PTR, DWORD) {
	if (UI_0) {
		UI_0->ShowPlayerTxt();
	}
}

IMPLEMENT_DYNAMIC(CUIWnd_0, CDialogEx)

CUIWnd_0::CUIWnd_0(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_PAGE_0, pParent)
	, txt_Player(_T(""))
	, txtWeapon(_T("瞬间回城卷轴"))
	, txtMP(_T("MP 回复草药 (特)"))
	, txtHPEx(_T("紫色棒棒糖"))
	, txtHP(_T("HP 回复草药 (特)"))
	, HpMin(75)
	, HpExMin(40)
	, MpMin(60)
{
	UI_0 = this;
}

CUIWnd_0::~CUIWnd_0()
{
}

void CUIWnd_0::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, txt_Player);
	DDX_Text(pDX, IDC_EDIT9, txtWeapon);
	DDX_Text(pDX, IDC_EDIT5, txtMP);
	DDX_Text(pDX, IDC_EDIT6, txtHPEx);
	DDX_Text(pDX, IDC_EDIT7, txtHP);
	DDX_Text(pDX, IDC_EDIT2, HpMin);
	DDX_Text(pDX, IDC_EDIT3, HpExMin);
	DDX_Text(pDX, IDC_EDIT4, MpMin);
}

BOOL CUIWnd_0::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	::SetTimer(this->m_hWnd, 0x100001, 10, TimeProc);
	return TRUE;
}

void CUIWnd_0::ShowPlayerTxt()
{
	UpdateData(TRUE);
	if ((_pgamebase) && (_pgamebase->SRO_Player)) {
		CString txtTmp;
		txtTmp.Format(L"角色名:[%s] 等级[lv:%d]\r\n", _pgamebase->SRO_Player->Name.wcstrByName(), _pgamebase->SRO_Player->LV);
		txt_Player = txtTmp;
		txtTmp.Format(L"经验值:[%d] 技能点[%d]\r\n", _pgamebase->SRO_Player->Exp, _pgamebase->SRO_Player->SkillPoint);
		txt_Player += txtTmp;
		txtTmp.Format(L"血量:[%d/%d]\r\n", _pgamebase->SRO_Player->HP, _pgamebase->SRO_Player->MaxHP);
		txt_Player += txtTmp;
		txtTmp.Format(L"蓝量:[%d/%d]\r\n", _pgamebase->SRO_Player->MP, _pgamebase->SRO_Player->MaxMP);
		txt_Player += txtTmp;
		txtTmp.Format(L"坐标:[%f][%f][%f]\r\n", _pgamebase->SRO_Player->x, _pgamebase->SRO_Player->h, _pgamebase->SRO_Player->y);
		txt_Player += txtTmp;
		// 计算百分比
		txtTmp.Format(L"怒气:[%f/100]\r\n", (float)_pgamebase->SRO_Player->Rage/5*100);
		txt_Player += txtTmp;
	}
	UpdateData(FALSE);
}


BEGIN_MESSAGE_MAP(CUIWnd_0, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CUIWnd_0::OnBnClickedButton1)
END_MESSAGE_MAP()


// CUIWnd_0 消息处理程序


void CUIWnd_0::OnBnClickedButton1()
{
	UpdateData(TRUE);
}

CUIWnd_1.h文件的修改:添加了列表的点击事件

#pragma once
#include "afxdialogex.h"

// CUIWnd_1 对话框

class CUIWnd_1 : public CDialogEx
{
	DECLARE_DYNAMIC(CUIWnd_1)

public:
	CUIWnd_1(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CUIWnd_1();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_PAGE_1 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedButton1();
	CListBox lstPack;
	afx_msg void OnBnClickedButton2();
	afx_msg void OnBnClickedButton3();
	CString txtInfo;
	afx_msg void OnLbnSelchangeList1();
};

CUIWnd_1.cpp文件的修改:添加了列表的点击事件

// CUIWnd_1.cpp: 实现文件
//

#include "pch.h"
#include "htdMfcDll.h"
#include "CUIWnd_1.h"
#include "afxdialogex.h"
#include "extern_all.h"


// CUIWnd_1 对话框

IMPLEMENT_DYNAMIC(CUIWnd_1, CDialogEx)

CUIWnd_1::CUIWnd_1(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_PAGE_1, pParent)
	, txtInfo(_T(""))
{

}

CUIWnd_1::~CUIWnd_1()
{
}

void CUIWnd_1::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, lstPack);
	DDX_Text(pDX, IDC_EDIT1, txtInfo);
}


BEGIN_MESSAGE_MAP(CUIWnd_1, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CUIWnd_1::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &CUIWnd_1::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &CUIWnd_1::OnBnClickedButton3)
	ON_LBN_SELCHANGE(IDC_LIST1, &CUIWnd_1::OnLbnSelchangeList1)
END_MESSAGE_MAP()


// CUIWnd_1 消息处理程序


void CUIWnd_1::OnBnClickedButton1()
{
	// int count = _pgamebase->SRO_Control->GetPPack()->GetPackBack()->PackCount();
	CString tmp;
	// tmp.Format(L"%d", count);
	// AfxMessageBox(tmp);
	PBackPack _PackBack = _pgamebase->SRO_Control->GetPPack()->GetPackBack();

	lstPack.ResetContent();
	for (int i = 0; i < _PackBack->PackCount(); i++)
	{

		PITEM item = _PackBack->GetItem(i);
		if ((item != NULL) && (item->Type)) {
			tmp.Format(L"[%s][数量:%d][耐久:%d/%d]\n", item->GetNameByWide(), item->Count, item->Durabillty, item->MaxDurabillty);
			lstPack.AddString(tmp);
		}
	}

}


void CUIWnd_1::OnBnClickedButton2()
{
	// int count = _pgamebase->SRO_Control->GetPPack()->GetPackBack()->PackCount();
	CString tmp;
	// tmp.Format(L"%d", count);
	// AfxMessageBox(tmp);
	PEquipPack _PackBack = _pgamebase->SRO_Control->GetPPack()->GetEquipBack();

	lstPack.ResetContent();
	for (int i = 0; i < 13; i++)
	{

		PITEM item = _PackBack->GetItem((EquipType)i);
		if ((item != NULL) && (item->Type > 0)) {
			tmp.Format(L"[%s][数量:%d][耐久:%d/%d]\n", item->GetNameByWide(), item->Count, item->Durabillty, item->MaxDurabillty);
			lstPack.AddString(tmp);
		}
	}
}


void CUIWnd_1::OnBnClickedButton3()
{
	// 不能一起调用,如果一起调用只有第一个会生效,可能需要多线程处理,多线程时需要加锁防止出现数据冲突的问题
	// _pgamebase->SRO_Control->MangeItem(0x46, 0x7, 0x0, 0x0);// 丢物品
	// _pgamebase->SRO_Control->MangeItem(0x46, 0x1, 0x47, 0x6);// 穿装备
	// _pgamebase->SRO_Control->MangeItem(0x46, 0x4, 0x47, 0x6);// 换装备
	// _pgamebase->SRO_Control->MangeItem(0x46, 0x10, 0x46, 0x16, -1);// 移动物品
	_pgamebase->SRO_Control->MangeItem(0x46, 0x5, 0x46, 0x17, 2000);// 拆分物品


}

void CUIWnd_1::OnLbnSelchangeList1()
{
	int n = lstPack.GetCurSel();
	if (n > -1) {
		lstPack.GetText(n, txtInfo);
		UpdateData(FALSE);
	}
}

你可能感兴趣的:(c++,网游逆向,逆向)