// PVsZ_MFCDlg.cpp: 实现文件
//
#include "pch.h"
#include "framework.h"
#include "PVsZ_MFC.h"
#include "PVsZ_MFCDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 监控线程的刷新时间
#define MONITOR_REFRESH_TIME_INTERVAL 1000
// 植物大战僵尸的进程句柄
static HANDLE g_processHandle;
// 用来监控植物大战僵尸的线程句柄
static HANDLE g_monitoringThreadHandle;
// 辅助窗口
static CPVsZMFCDlg* g_dlg;
// 将某个值写入植物大战僵尸内存(后面的可变参数是地址链,要以-1结尾)
void WriteMemory(void* value, DWORD valueSize, ...)
{
if (value == NULL || valueSize == 0 || g_processHandle == NULL) return;
DWORD tempValue = 0;
va_list addresses;
va_start(addresses, valueSize);
DWORD offset = 0;
DWORD lastAddress = 0;
while ((offset = va_arg(addresses, DWORD)) != -1)
{
lastAddress = tempValue + offset;
::ReadProcessMemory(g_processHandle, (LPCVOID)lastAddress, &tempValue, sizeof(DWORD), NULL);
}
va_end(addresses);
::WriteProcessMemory(g_processHandle, (LPVOID)lastAddress, value, valueSize, NULL);
}
void WriteMemory(void* value, DWORD valueSize, DWORD address) {
WriteMemory(value, valueSize, address, -1);
}
// 用来监控植物大战僵尸的线程
DWORD WINAPI MonitoringThreadProc(LPVOID lpParam)
{
while (1)
{
// 找窗口
HWND hwnd = ::FindWindow(TEXT("MainWindow"), TEXT("植物大战僵尸中文版"));
if (hwnd == NULL)
{
::CloseHandle(g_processHandle);
g_processHandle = NULL;
// 所有功能都取消,禁止点击,修改源代码都改回来
g_dlg->m_sunshine.SetCheck(FALSE);
g_dlg->m_sunshine.EnableWindow(FALSE);
g_dlg->m_unbreakable.SetCheck(FALSE);
g_dlg->m_unbreakable.EnableWindow(FALSE);
g_dlg->OnBnClickedUnbreakable();
g_dlg->m_cd.SetCheck(FALSE);
g_dlg->m_cd.EnableWindow(FALSE);
g_dlg->OnBnClickedCd();
g_dlg->m_background.SetCheck(FALSE);
g_dlg->m_background.EnableWindow(FALSE);
g_dlg->OnBnClickedBackground();
g_dlg->m_kill.SetCheck(FALSE);
g_dlg->m_kill.EnableWindow(FALSE);
g_dlg->OnBnClickedKill();
g_dlg->m_zoombieUnbreakable.SetCheck(FALSE);
g_dlg->m_zoombieUnbreakable.EnableWindow(FALSE);
g_dlg->OnBnClickedZoombieUnbreakable();
g_dlg->m_cancel.EnableWindow(FALSE);
g_dlg->m_coin.EnableWindow(FALSE);
g_dlg->m_consume.SetCheck(FALSE);
g_dlg->m_consume.EnableWindow(FALSE);
g_dlg->OnBnClickedDontusesun();
g_dlg->m_collectsunshine.SetCheck(FALSE);
g_dlg->m_collectsunshine.EnableWindow(FALSE);
g_dlg->OnBnClickedCollectsunshine();
g_dlg->m_bullet.SetCheck(FALSE);
g_dlg->m_bullet.EnableWindow(FALSE);
g_dlg->OnBnClickedManybullet();
}
else if (g_processHandle == NULL)
{
// 找进程ID
DWORD pid = NULL;
::GetWindowThreadProcessId(hwnd, &pid);
// 找进程句柄
g_processHandle = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
// 开启点击
g_dlg->m_sunshine.EnableWindow(TRUE);
g_dlg->m_unbreakable.EnableWindow(TRUE);
g_dlg->m_cd.EnableWindow(TRUE);
g_dlg->m_coin.EnableWindow(TRUE);
g_dlg->m_cancel.EnableWindow(TRUE);
g_dlg->m_background.EnableWindow(TRUE);
g_dlg->m_kill.EnableWindow(TRUE);
g_dlg->m_zoombieUnbreakable.EnableWindow(TRUE);
g_dlg->m_consume.EnableWindow(TRUE);
g_dlg->m_collectsunshine.EnableWindow(TRUE);
g_dlg->m_bullet.EnableWindow(TRUE);
}
if (g_dlg->m_sunshine.GetCheck())
{ // 如果需要无限阳光
DWORD value = 9990;
//WriteMemory(&value, sizeof(value), 0x6A9EC0, 0x320, 0x8, 0x0, 0x8, 0x144, 0x2c, 0x5560, -1);
//无限阳光的另一个地址找法
WriteMemory(&value, sizeof(value), 0x6A9EC0, 0x768, 0x5560, -1);
}
::Sleep(MONITOR_REFRESH_TIME_INTERVAL);
}
return 0;
}
// 针对XP提高程序的访问权限
BOOL ImproveAccessPrivilege()
{
HANDLE tokenHandle;
LUID privilegeValue;
if (!::OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle)) return FALSE;
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &privilegeValue))
{
::CloseHandle(tokenHandle);
return FALSE;
}
TOKEN_PRIVILEGES privileges;
privileges.PrivilegeCount = 1;
privileges.Privileges[0].Luid = privilegeValue;
privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!::AdjustTokenPrivileges(tokenHandle, FALSE, &privileges, sizeof(privileges), NULL, NULL))
{
::CloseHandle(tokenHandle);
return FALSE;
}
return TRUE;
}
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CPVsZMFCDlg 对话框
CPVsZMFCDlg::CPVsZMFCDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_PVSZ_MFC_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPVsZMFCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_Sunshine, m_sunshine);
DDX_Control(pDX, IDC_UNBREAKABLE, m_unbreakable);
DDX_Control(pDX, IDC_COIN, m_coin);
DDX_Control(pDX, IDC_CANCEL, m_cancel);
DDX_Control(pDX, IDC_KILL, m_kill);
DDX_Control(pDX, IDC_BACKGROUND, m_background);
DDX_Control(pDX, IDC_ZOOMBIE_UNBREAKABLE, m_zoombieUnbreakable);
DDX_Control(pDX, IDC_CD, m_cd);
DDX_Control(pDX, IDC_DontUseSun, m_consume);
DDX_Control(pDX, IDC_CollectSunShine, m_collectsunshine);
DDX_Control(pDX, IDC_ManyBullet, m_bullet);
}
BEGIN_MESSAGE_MAP(CPVsZMFCDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_COIN, &CPVsZMFCDlg::OnBnClickedCoin)
ON_BN_CLICKED(IDC_CANCEL, &CPVsZMFCDlg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_UNBREAKABLE, &CPVsZMFCDlg::OnBnClickedUnbreakable)
ON_BN_CLICKED(IDC_KILL, &CPVsZMFCDlg::OnBnClickedKill)
ON_BN_CLICKED(IDC_BACKGROUND, &CPVsZMFCDlg::OnBnClickedBackground)
ON_BN_CLICKED(IDC_CD, &CPVsZMFCDlg::OnBnClickedCd)
ON_BN_CLICKED(IDC_ZOOMBIE_UNBREAKABLE, &CPVsZMFCDlg::OnBnClickedZoombieUnbreakable)
ON_WM_CLOSE()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_BN_CLICKED(IDC_COURSE, &CPVsZMFCDlg::OnBnClickedCourse)
ON_BN_CLICKED(IDC_DontUseSun, &CPVsZMFCDlg::OnBnClickedDontusesun)
ON_BN_CLICKED(IDC_CollectSunShine, &CPVsZMFCDlg::OnBnClickedCollectsunshine)
ON_BN_CLICKED(IDC_ManyBullet, &CPVsZMFCDlg::OnBnClickedManybullet)
END_MESSAGE_MAP()
// CPVsZMFCDlg 消息处理程序
BOOL CPVsZMFCDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != nullptr)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
// 针对XP系统提高程序的权限
ImproveAccessPrivilege();
// 辅助窗口
g_dlg = this;
// 启动监控线程
g_monitoringThreadHandle = ::CreateThread(NULL, 0, MonitoringThreadProc, NULL, 0, NULL);
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
void CPVsZMFCDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
C
编程ID
- 粉丝: 9w+
- 资源: 921
最新资源
- 电信口令兑换0.88~100亓话费.mp4
- 抖店精细化运营详细的精细化运营抖店玩法.mp4
- 抖看小说app 覆盖各类题材.mp4
- 抖音快手小红书养号工具,安卓手机通用不限制数量,截流自热必备养号神器解放双手.mp4
- C语言实践作业飞机大战.zip
- 抖音热门华语劲爆车载DJ歌曲合集.mp4
- 抖音评论采集抓取获客系统v2.4.mp4
- 基于Android Studio开发的安卓的音乐播放器app源码+报告(安卓期末大作业)
- 抖音小红书留微信不屏蔽生成工具.mp4
- 独居治愈系视频制作,日变现多张,多平台发布(抖音、视频号、小红书).mp4
- 短视频上热门的20个流量密码实战案例.mp4
- 多邻国语言Duolingo v6.10.4.0解锁vip付费版.mp4
- 发光霓虹灯文字闪烁特效源码.mp4
- 番茄小说领券0.01亓撸书本等.mp4
- 锂电池项目 欧姆龙NJ501-1400系列plc程序 自动二封机,PLC程序,无触摸屏程序 1.松下A6系列总线伺服驱动器控制,位置模式控制 2.雷赛总线节点步进电机控制,参数读写,电流,极性,感应器
- 饭团追书app 拥有非常多的分类.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈