|
想要查看内容赶紧注册登陆吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
作者:--啊冲
这是很久以前的代码了 哄孩子玩的,现在拿出来分享一下吧.
下面是核心代码:
PVZ_FYLDlg.cpp : implementation file
//
#include "stdafx.h"
#include " VZ_FYL.h"
#include " VZ_FYLDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
HWND gameh=0;
DWORD processid=0;
DWORD nbuffer=0;
DWORD byread=0;
HANDLE processH=0;
DWORD pbase = 0x7794f8;
int Sun=0;
BOOL BCold=TRUE;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg: oDataExchange(CDataExchange* pDX)
{
CDialog: oDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPVZ_FYLDlg dialog
CPVZ_FYLDlg::CPVZ_FYLDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPVZ_FYLDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPVZ_FYLDlg)
m_BT = _T("");
m_Sun = _T("");
m_checkAuto = FALSE;
m_checkCD = FALSE;
m_checkSun = FALSE;
m_BMP = _T("");
m_Cold = FALSE;
m_Kill = FALSE;
m_Pause = FALSE;
m_Speed = FALSE;
m_All = FALSE;
m_Speed2 = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
}
void CPVZ_FYLDlg: oDataExchange(CDataExchange* pDX)
{
CDialog: oDataExchange(pDX);
//{{AFX_DATA_MAP(CPVZ_FYLDlg)
DDX_Text(pDX, IDC_STATIC_BT, m_BT);
DDX_Text(pDX, IDC_STATIC_SUN, m_Sun);
DDX_Check(pDX, IDC_CHECK_AUTO, m_checkAuto);
DDX_Check(pDX, IDC_CHECK_CD, m_checkCD);
DDX_Check(pDX, IDC_CHECK_SUN, m_checkSun);
DDX_Text(pDX, IDC_STATIC_BMP, m_BMP);
DDX_Check(pDX, IDC_CHECK_COLD, m_Cold);
DDX_Check(pDX, IDC_CHECK_KILL, m_Kill);
DDX_Check(pDX, IDC_CHECK_PAUSE, m_Pause);
DDX_Check(pDX, IDC_CHECK_SPEED, m_Speed);
DDX_Check(pDX, IDC_CHECK_ALL, m_All);
DDX_Check(pDX, IDC_CHECK_Speed2, m_Speed2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPVZ_FYLDlg, CDialog)
//{{AFX_MSG_MAP(CPVZ_FYLDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPVZ_FYLDlg message handlers
BOOL CPVZ_FYLDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SetTimer(1, 1000, NULL);
// SetTimer(9999, 1000, NULL);
// MessageBox("部分功能还未做好请耐心等等");
return TRUE; // return TRUE unless you set the focus to a control
}
void CPVZ_FYLDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPVZ_FYLDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPVZ_FYLDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPVZ_FYLDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
switch (nIDEvent)
{
case 1://查找标题和阳光
gameh = ::FindWindow(NULL," lants vs. Zombies GOTY ");
UpdateData(TRUE);
if (gameh)
{
::GetWindowThreadProcessId(gameh,&processid);
processH = ::OpenProcess(PROCESS_ALL_ACCESS, false, processid);
ReadProcessMemory(processH, (void*) pbase ,&nbuffer,4,&byread);
ReadProcessMemory(processH, (void*)(nbuffer + 0x868),&nbuffer,4,&byread);
ReadProcessMemory(processH, (void*)(nbuffer + 0x5578), &Sun, 4, &byread);
//m_Sun.Format(_T("阳光%d"), Sun);
m_BT.Format(_T("欢迎使用本外挂,当前阳光%d"), Sun);
UpdateData(FALSE);
if (m_checkSun==TRUE)
{
Sun = 9999;
nbuffer = nbuffer + 0x5578;
::WriteProcessMemory(processH, (void*)nbuffer, &Sun, 4, 0);
}
if (m_checkCD== TRUE)//CD冷却时间
{
DWORD CD = 0x7428473B;
::WriteProcessMemory(processH, (void*)0x004B2FF0, &CD, 4, 0);
}
else
{
DWORD CD = 0x7E28473B;
::WriteProcessMemory(processH, (void*)0x004B2FF0, &CD, 4, 0);
}
if (m_checkAuto == TRUE)//自动收集
{
DWORD Auto = 0XFB8B09EB;
::WriteProcessMemory(processH, (void*)0X0044C5F2, &Auto, 4, 0);
}
else
{
DWORD Auto = 0XFB8B0975;
::WriteProcessMemory(processH, (void*)0X0044C5F2, &Auto, 4, 0);
}
if (m_Pause == TRUE)//去除暂停
{
DWORD Pause = 0xFF909000 ;
::WriteProcessMemory(processH,(void*)0x005cb2c6,& ause,4,0);
}else
{
DWORD Pause =0xFFD2FF00 ;
::WriteProcessMemory(processH,(void*)0x005cb2c6,& ause,4,0);
}
if (m_Speed==TRUE)//攻击加速
{
DWORD Speed=0x0023B900;
::WriteProcessMemory(processH,(void*)0x004838D0,&Speed,4,0);
Speed = 0x438B0000;
::WriteProcessMemory(processH,(void*)0x004838D4,&Speed,4,0);
}else
{
DWORD Speed = 0x5C4B8B00;
::WriteProcessMemory(processH,(void*)0x004838D0,&Speed,4,0);
Speed = 0x438BC82B;
::WriteProcessMemory(processH,(void*)0x004838D4,&Speed,4,0);
}
if (m_Kill == TRUE)//攻击秒杀
{
DWORD Kill = 999;
::WriteProcessMemory(processH,(void*)0x0076C558,&Kill,4,0);
}else
{
DWORD Kill = 20;
::WriteProcessMemory(processH,(void*)0x0076C558,&Kill,4,0);
}
if (m_Speed2 == TRUE)//攻击加速,必须先去掉内存只读属性.
{
DWORD dwOldProtect;
DWORD* lpAddr= (DWORD*)0x007467FC;
VirtualProtectEx (processH,lpAddr,4,PAGE_READWRITE,&dwOldProtect);
DWORD Speed=0x40400000;
::WriteProcessMemory(processH,(void*)0x007467FC,&Speed,4,0);
}else
{
DWORD Speed=0x400aa3d7;
::WriteProcessMemory(processH,(void*)0x007467FC,&Speed,4,0);
}
if (m_Cold== TRUE)//冰冻状态
{
DWORD Cold=0x00CC878B;//冰冻状态
::WriteProcessMemory(processH,(void*)0x00560E36,&Cold,4,0);
if (BCold==TRUE)//减缓移动速度
{
DWORD Cold=0x90909090;
::WriteProcessMemory(processH,(void*)0x005604d6,&Cold,4,0);
BCold=FALSE;
}else
{
DWORD Cold=0x82464d8;
::WriteProcessMemory(processH,(void*)0x005604d6,&Cold,4,0);
BCold=TRUE;
}
}else
{
DWORD Cold=0x00AC878B;//冰冻状态
::WriteProcessMemory(processH,(void*)0x00560E36,&Cold,4,0);
Cold=0x082464d8;//移动速度
::WriteProcessMemory(processH,(void*)0x005604d6,&Cold,4,0);
}
}
else
{
m_BT=("请打开植物VS僵尸年度版");
UpdateData(false);
}
if (m_All==TRUE)//一决胜负
{
DWORD All=0x010e840f;
::WriteProcessMemory(processH,(void*)0x00429b8f,&All,4,0);
}else
{
DWORD All=0x010e850f;
::WriteProcessMemory(processH,(void*)0x00429b8f,&All,4,0);
}
}
UpdateData(TRUE);
CDialog::OnTimer(nIDEvent);
}
|
|