0.0 额(⊙﹏⊙)

不知道写点啥好了,发一个以前写的植物大战僵尸的外挂,实现了解锁冷却时间修改阳光的功能。

(ps:适用于steam最新的植物大战僵尸)

image-20220130195902359

核心代码如下

/*
         * 此函数用于将32位数据转换为长度为4的byte类型数组
         */
        public byte[] intToBytes(int value)
        {
            byte[] src = new byte[4];
            src[3] = (byte)((value >> 24) & 0xFF);
            src[2] = (byte)((value >> 16) & 0xFF);
            src[1] = (byte)((value >> 8) & 0xFF);
            src[0] = (byte)(value & 0xFF);
            return src;
        }

        /*
         * 此函数用于判断植物大战僵尸是否运行,植物大战僵尸的窗口句柄保存在hwnd中。
         */
        public Boolean cheat_init(String name)
        {
            hwnd = FindWindow(null, name);
            //判断这个窗体是否有效 
            if (hwnd != IntPtr.Zero)
                return true;
            else return false;
        }

        /*
         * 此函数根据hwnd将32位的数据写入address指向的地址
         */
        public Boolean read_data(out int data,int address)
        {
            int calcID;
            int calcProcess;
            int dataAddress;
            int readByte;
            GetWindowThreadProcessId(hwnd, out calcID);
            calcProcess = OpenProcess(PROCESS_ALL_ACCESS, false, calcID);
            Boolean temp=ReadProcessMemory(calcProcess, address, out dataAddress, 4, out readByte);
            if (temp == true)
                data = dataAddress;
            else
                data = 0;
            
            return temp;
        }

        /*
        * 此函数根据hwnd将address指向的地址的32位的数据读出
        */
        public Boolean write_data(int data, int address)
        {
            int calcID;
            int calcProcess;
            int x = 4;
            GetWindowThreadProcessId(hwnd, out calcID);
            calcProcess = OpenProcess(PROCESS_ALL_ACCESS, false, calcID);
            return WriteProcessMemory(calcProcess, address, intToBytes(data), 4, ref x);
        }

链接:https://pan.baidu.com/s/1m18g6bkkEhNshRr0uNRjFA
提取码:96l2

文章目录