44.x86游戏实战-C++实现吸怪加秒杀

免责声明:内容仅供学习参考,请合法利用知识,禁止进行违法犯罪活动!

本次游戏没法给

内容参考于:微尘网络安全

工具下载:

链接:https://pan.baidu.com/s/1rEEJnt85npn7N38Ai0_F2Q?pwd=6tw3

提取码:6tw3

复制这段内容后打开百度网盘手机App,操作更方便哦

上一个内容:43.x86游戏实战-DXX寻找吸怪坐标

上一个内容找到了吸怪的基址(修改坐标有反应的坐标地址),然后本次就利用这个地址来实现吸怪(有一些怪物不走过去它会在地低下无法秒杀,需要走过去才能秒杀,所以利用吸怪让怪物从地底下出来),吸怪就是把怪物移动到我们角色的坐标上,接下来上代码

MyStrust.cpp文件

全图秒杀按钮

它的点击事件处理函数

MyStrust.cpp文件:修改了 FindMaster函数、AllKill函数

#include "pch.h"
#include "MyStrust.h"

void MyStrust::InitMy()
{
	//  [[0x1AB7CDC]+0x258] 名字
	/*
		*这个符号表示地址,在c++中被称为指针或指针类型
		int表示4字节数字
		int*就表示指针类型的int
		(int*)0x1AB7CDC;这样表示0x1AB7CDC地址里的内容是4字节的数字
	*/
	int* address = (int*)0x1AB7CDC;
	/*
		取出地址中的值,也就是取出0x1AB7CDC里的内容
		*address这样在左边只写一个*表示取内存地址里的值
		也就是取address它的值,address是0x1AB7CDC,也就是取0x1AB7CDC它的值

	*/
	int addressValue = *address;
	/*
		(*(int*)addressValue)意思是
		把addressValue转成int*,也就是把
		addressValue的值当成内存地址,addressValue的值现在是[0x1AB7CDC]+0x258这个
		现在这个地址里面的值是名字的地址,所以在左边加了一个*让把名字的地址去除了出来
		取出来之后就得到了名字,名字是UNICODE类型,UNICODE又被称为宽字节,宽字节的数据是用两个字节描述一个文字或字母
		在c++里wchar_t类型就是UNICODE
		然后在c++中名字这种数据被称为字符串,如果要用字符串必须用指针类型也就是wchar_t*
		右边加上*让wchar_t变成指针类型的wchar_t,才能在c++中使用字符串

	*/
	this->My.Name = (wchar_t*)(*(int*)(addressValue+0x258));
	// 一般函数名后面是W就表示有UNICODE,也就是要用宽字节
	// OutputDebugStringW(this->My.Name);
	// L""这两个"之间表示字符串,L""表示这个字符串是宽字节(使用Unicode编码)
	call_logW(L"wetool:人物姓名=%ws,测试=%ws", this->My.Name,L" 52am");
	//  [[0x1AB7CDC]+0x18C]x坐标
	//  [[0x1AB7CDC]+0x190]y坐标
	/*
		取出地址中的值,也就是取出0x1AB7CDC里的内容
		*address这样在左边只写一个*表示取内存地址里的值
		也就是取address它的值,address是0x1AB7CDC,也就是取0x1AB7CDC它的值

	*/
 
	this->My.X= *(float*)(addressValue + 0x18C);
	this->My.Y = *(float*)(addressValue + 0x190);
	char buf[256] = { 0 };
	// 拼接文字,%f表示拼接一个小数(单浮点数)
	sprintf(buf, "wetool:x=%f;y=%f", this->My.X, this->My.Y);
	OutputDebugStringA(buf);

	// [[0x1AB7CDC]+0x36A0]血量
	this->My.Blood = *(int*)(addressValue + 0x36A0);
	// 拼接文字,%d表示拼接一个整数(32位的整数)
	sprintf(buf, "wetool:血量 = %d", this->My.Blood);
	OutputDebugStringA(buf);
}

void MyStrust::UseObject(DWORD object)
{
	object += 3; // 背包物品序号
	/*
	  try的作用
		如果
		__asm {
			pushad
			push object
			mov ecx, 0x1A5FB24 // 背包基址
			mov ecx, [ecx]
			mov eax, 0x7B9130 // 使用物品的函数地址
			call eax
			popad
		}
		这个代码运行过程中出现错误了,我不会让游戏崩溃,出现错误之后会执行
		catch (...) {
			OutputDebugStringA("MyStrust::UseObject error");
		}
		这个catch里面的代码,现在也就是执行OutputDebugStringA("MyStrust::UseObject error");这一行
	*/
	try { 
		__asm {
			pushad
			push object
			mov ecx, 0x1A5FB24 // 背包基址
			mov ecx, [ecx]
			mov eax, 0x7B9130 // 使用物品的函数地址
			call eax 
			popad
		}
	}
	catch (...) {
		OutputDebugStringA("MyStrust::UseObject error");
	}
}

void MyStrust::ChangeBlooad(int v)
{
	try {
		__asm {
			pushad
			push 0
			push 0
			push 0
			push v
			mov ecx, 0x1AB7CDC // 里面有我们玩家角色数据的基址
			mov ecx, [ecx]
			mov eax, 0x8174E0 // 修改血量的函数地址
			call eax
			popad
		}
	}
	catch (...) {
		OutputDebugStringA("MyStrust::ChangeBlooad error");
	}
}

void MyStrust::NewChangeBlooad(DWORD nEcx)
{
	try {
		__asm {
			pushad
			push 0
			push 0
			push 0
			push 0
			mov ecx, nEcx
			mov eax, 0x8174E0 // 修改血量的函数地址
			call eax
			popad
		}
	}
	catch (...) {
		OutputDebugStringA("MyStrust::NewChangeBlooad error");
	}
}

// 遍历怪物列表函数,加吸怪
void MyStrust::FindMaster()
{
	wchar_t* Tmp1;
	/* 
		[[[[[0x1A5E258]+3*4+0xA8]+0x14]+0x88]+0x10]
		下方 ReadDword 函数通过 [[[[[0x1A5E258]+3*4+0xA8]+0x14]+0x88]+0x10] 这个取值算法得到附近列表(怪物列表)
	*/
	DWORD Tmp = ReadDword(ReadDword(ReadDword(ReadDword(ReadDword(0x1A5E258) + 0x3 * 4 + 0xA8) + 0x14) + 0x88) + 0x10);
	if (Tmp != 0) {// 如果是0说明没有找到怪物列表
		for (size_t i = 0; i < 100; i++)// 这里的100是随便写的
		{
			if (ReadDword(Tmp + i * 4)>0 && (ReadDword(ReadDword(Tmp + i * 4) + 0x90) == 0x211)) {
			//if (ReadDword(Tmp + i * 4)>0) {
				Tmp1 = (wchar_t*)ReadDword(ReadDword(Tmp + i * 4) + 0x258); // 0x258位置是名字
				if (Tmp1 == 0) {// 如果是0说明没有名字
					 //call_logW(L"wetool:NULL\n");
					 this->masterNum.Name[i] = L"";
				}
				else {
					/*
						打印名字到 Dbgview.exe,其中 wetool这个是为了过滤 Dbgview.exe打印的一些跟我们不相关的日志

					*/
					//call_logW(L"wetool:%ws\n", Tmp1);
					this->masterNum.Name[i] = Tmp1;
				}
				// 血量与玩家角色不是一个位置,可以在修改血量的位置追,这个不重要,后面有机会再找
				//masterNum.Blood[i] = ReadDword(ReadDword(Tmp + i * 4) + 0x90); 
				this->masterNum.type[i] = ReadDword(ReadDword(Tmp + i * 4) + 0x90);
				this->masterNum.x[i] = ReadFloat(ReadDword(Tmp + i * 4) + 0x18C);
				this->masterNum.y[i] = ReadFloat(ReadDword(Tmp + i * 4) + 0x190);
				
				this->masterNum.x[i] = this->My.X;
				this->masterNum.y[i] = this->My.Y;
				this->masterNum.Object[i] = ReadDword(Tmp + i * 4);
				
				*(FLOAT*)(ReadDword(ReadDword(Tmp + i * 4) + 0xA8) + 0xC) = this->My.X; // 修改之后会瞬移的坐标,把它的值赋值成我们玩家的坐标
				*(FLOAT*)(ReadDword(ReadDword(Tmp + i * 4) + 0xA8) + 0x10) = this->My.Y; // 修改之后会瞬移的坐标,把它的值赋值成我们玩家的坐标
				call_logW(L"wetool:第%d个对象:%x 怪物名字:%ls type:0x%x x:%f y:%f", i, this->masterNum.Object[i], this->masterNum.Name[i], this->masterNum.type[i], this->masterNum.x[i], this->masterNum.y[i]);
			}
		}
	}
	else {
		call_loaA("wetool:Tmp error");
	}
}

// 吸怪加秒杀
void MyStrust::AllKill()
{
	try {
	this->InitMy();
	this->FindMaster();
	for (size_t i = 0; i < 100; i++)
	{
		if (this->masterNum.Object[i] > 0 && (this->masterNum.type[i] == 0x211)) {
		
				call_logW(L"wetool:AllKill-第%d个对象:%x 怪物名字:%ls type:0x%x x:%f y:%f", i, this->masterNum.Object[i], this->masterNum.Name[i], this->masterNum.type[i], this->masterNum.x[i], this->masterNum.y[i]);
				this->NewChangeBlooad(this->masterNum.Object[i]);// 调用修改血量的函数
		}
	}
	}
	catch (...) {
		OutputDebugStringA("MyStrust::AllKill error");
	}
}

DXXDlg.cpp文件:新加全图秒杀按钮点击事件处理函数

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

#include "pch.h"
#include "WCDXX.h"
#include "afxdialogex.h"
#include "DXXDlg.h"
#include "MyStrust.h"
#include "json.h"

// DXXDlg 对话框

IMPLEMENT_DYNAMIC(DXXDlg, CDialogEx)

DXXDlg::DXXDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG1, pParent)
{
	OutputDebugStringA("执行流程-执行DXXDlg构造函数流程1");
}

DXXDlg::~DXXDlg()
{
	OutputDebugStringA("执行流程-执行DXXDlg析构函数流程1");
}

void DXXDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(DXXDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &DXXDlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &DXXDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &DXXDlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &DXXDlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &DXXDlg::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &DXXDlg::OnBnClickedButton6)
END_MESSAGE_MAP()


// DXXDlg 消息处理程序


void DXXDlg::OnBnClickedButton1()
{
	MyStrust mystruct;
	mystruct.InitMy();
}


void DXXDlg::OnBnClickedButton2()
{

}


void DXXDlg::OnBnClickedButton3()
{
	
}


void DXXDlg::OnBnClickedButton4()
{
	MyStrust mystruct;
	mystruct.InitMy(); // 初始化玩家角色数据
	mystruct.ChangeBlooad(mystruct.My.Blood/2); // 修改血量
	
	// TODO: 在此添加控件通知处理程序代码
}


void DXXDlg::OnBnClickedButton5()
{
	MyStrust mystruct;
	mystruct.FindMaster();
}


void DXXDlg::OnBnClickedButton6()
{
	MyStrust mystruct;
	mystruct.AllKill();
}

上方的代码不全,只有手写的代码

完整代码:以 42.x86游戏实战-C++实现全图秒杀功能 它的代码为基础进行修改

链接:https://pan.baidu.com/s/1W-JpUcGOWbSJmMdmtMzYZg?pwd=q9n5

提取码:q9n5

复制这段内容后打开百度网盘手机App,操作更方便哦


img

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值