日期:2014-05-18  浏览次数:20878 次

C# 实现鬼泣4修改器,玩的朋友进来看看。我贴点源码 ,散分吧~
在网上看到好多外挂,大部分都是用VC VB 等其他语言做的,唉!做了C#的粉丝,这能忍.....最近研究了一下,用了近3

天的时间找相关基址,编码测试,大功告成了,现在来分享一下,那个代码比较多,我就贴一部分吧..呵呵

运行界面:



部分代码

C# code

        /// <summary>
        /// 从指定地址读取数据
        /// </summary>
        /// <param name="address">读取数据的地址</param>
        /// <returns>返回读取的数值</returns>
        public int ReadValueFromAddress(int pid, int address)
        {
            IntPtr handle = CheatAPI.OpenProcess(CheatAPI.PROCESS_ALL_ACCESS, false, pid);
            byte[] buffer = new byte[4];
            IntPtr byteAddress = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0); //获取缓冲区地址
            bool read = CheatAPI.ReadProcessMemory(handle, (IntPtr)address, byteAddress, 4, IntPtr.Zero);
            CheatAPI.CloseHandle(handle);
            return Marshal.ReadInt32(byteAddress);
        }
        /// <summary>
        /// 向指定地址写数据
        /// </summary>
        /// <param name="address">写数据的地址</param>
        /// <param name="name">是修改的名称</param>
        /// <param name="StartOrNo">修改还是还原 true修改 false 还原 </param>
        /// <returns>写入成功返回true</returns>
        public bool WriteValueToAddress(int pid, string name, bool StartOrNo)
        {
            //无限 修改  开启
            try
            {
                IntPtr handle = CheatAPI.OpenProcess(CheatAPI.PROCESS_ALL_ACCESS, false, pid);
                if (StartOrNo)
                {
                    foreach (DevilClass item in ChangeList)
                    {
                        string ne = item.CheatName.Substring(0, item.CheatName.IndexOf('_'));
                        if (ne == name)
                        {
                            CheatAPI.WriteProcessMemory(handle, (IntPtr)item.Address, item.Data, item.Data.Length, IntPtr.Zero);                           
                        }                      
                    }
                    if (name == "无限魔人")
                    {
                        int ad1 = ReadValueFromAddress(pid, ReadValueFromAddress(pid, 0x00e558b8) + 0x24);
                        CheatAPI.WriteProcessMemory(handle, (IntPtr)(ad1 + 0x1f24), new byte[] { 0x00, 0x40, 0x1c, 0x46 }, 4, IntPtr.Zero); //魔法量
                        CheatAPI.WriteProcessMemory(handle, (IntPtr)(ad1 + 0x1f28), new byte[] { 0x00, 0x40, 0x1c, 0x46 }, 4, IntPtr.Zero);//格子数
                    }
                    if (name == "无限灾厄")
                    {
                        int ad2 = ReadValueFromAddress(pid, ReadValueFromAddress(pid, 0x00e558b8) + 0x24);
                        CheatAPI.WriteProcessMemory(handle, (IntPtr)(ad2 + 0x151f4), new byte[] { 0x00, 0x34, 0x1c, 0x46 }, 4, IntPtr.Zero);
                    }
                    if (name == "瞬间加速")
                    {
                        int ad3 = ReadValueFromAddress(pid, ReadValueFromAddress(pid, 0x00e558b8) + 0x24);
                        CheatAPI.WriteProcessMemory(handle, (IntPtr)(ad3 + 0x2834), new byte[] { 0x23, 0xFF, 0x61, 0x43 }, 4, IntPtr.Zero);
                    }
                    if (name == "无限RG")
                    {
                        int ad4 = ReadValueFromAddress(pid, ReadValueFromAddress(pid, 0x00E558B8) + 0x24);
                        CheatAPI.WriteProcessMemory(handle, (IntPtr)(ad4 + 0x14dac), new byte[] { 0x46, 0x65 }, 4, IntPtr.Zero);
                    }
                }
                else
                {
                    foreach (DevilClass item in RecoverList)
                    {
                        string na=item.CheatName.Substring(3, item.CheatName.IndexOf('_') - 3);                      
                        if (na == name)