开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 714|回复: 14
收起左侧

[其它源码] c#wx3.6.0.18 过低版本前面发的失效了得多改点内存地址

[复制链接]
结帖率:71% (5/7)
发表于 2025-7-29 23:28:21 | 显示全部楼层 |阅读模式   重庆市重庆市
分享源码
界面截图: -
是否带模块: -
备注说明: -
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.Win32;

class Program
{
    static readonly int[] Offsets = new[] { 0x22300E0, 0x223D90C, 0x223D9E8, 0x2253E4C, 0x22585D4, 0x2255AA4 };
    const string RegistryPath = @"SOFTWARE\Tencent\WeChat";
    const string RegistryValueName = "Version";
    const uint RegistryNewValue = 0x63090C33;

    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);

    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool CloseHandle(IntPtr hObject);

    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesRead);

    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);

    static void Main(string[] args)
    {
        try
        {
            Console.WriteLine("开始处理...");

            // 总步骤数:内存地址数 + 注册表操作
            int totalSteps = Offsets.Length + 1;
            int currentStep = 0;

            // 修改内存部分
            ModifyWeChatMemory(
                (offset, success, errorMsg) => {
                    if (!success) LogError($"内存地址 0x{offset:X8} 修改失败: {errorMsg}");
                    UpdateProgress(++currentStep, totalSteps);
                });

            // 修改注册表部分
            ModifyWeChatRegistry(
                (success, errorMsg) => {
                    if (!success) LogError($"注册表修改失败: {errorMsg}");
                    UpdateProgress(++currentStep, totalSteps);
                });

            Console.WriteLine("\n操作完成!");
        }
        catch (Exception ex)
        {
            LogError($"严重错误: {ex.Message}");
        }

        Console.WriteLine("\n按回车键退出...");
        Console.ReadLine(); // 等待用户按回车
    }

    static void ModifyWeChatMemory(Action<int, bool, string> onStepComplete)
    {
        try
        {
            Process[] wechatProcesses = Process.GetProcessesByName("WeChat");
            if (wechatProcesses.Length == 0)
            {
                foreach (var offset in Offsets)
                    onStepComplete(offset, false, "未找到VX进程");
                return;
            }

            byte[] newValueBytes = BitConverter.GetBytes(RegistryNewValue);

            foreach (var wechatProcess in wechatProcesses)
            {
                IntPtr processHandle = OpenProcess(0x001F0FFF, false, wechatProcess.Id);
                if (processHandle == IntPtr.Zero)
                {
                    foreach (var offset in Offsets)
                        onStepComplete(offset, false, "无法打开VX进程");
                    continue;
                }

                try
                {
                    ProcessModule wechatModule = GetWeChatModule(wechatProcess);
                    if (wechatModule == null)
                    {
                        foreach (var offset in Offsets)
                            onStepComplete(offset, false, "未找到WeChatWin.dll模块");
                        continue;
                    }

                    foreach (int offset in Offsets)
                    {
                        IntPtr targetAddress = (IntPtr)(wechatModule.BaseAddress.ToInt64() + offset);
                        bool success = WriteMemory(processHandle, targetAddress, newValueBytes);

                        string errorMsg = success ? "" : GetLastErrorMessage();
                        onStepComplete(offset, success, errorMsg);
                    }
                }
                finally
                {
                    CloseHandle(processHandle);
                }
            }
        }
        catch (Exception ex)
        {
            foreach (var offset in Offsets)
                onStepComplete(offset, false, ex.Message);
        }
    }

    static void ModifyWeChatRegistry(Action<bool, string> onComplete)
    {
        try
        {
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryPath, true))
            {
                if (key == null)
                {
                    onComplete(false, $"未找到注册表项: {RegistryPath}");
                    return;
                }

                key.SetValue(RegistryValueName, RegistryNewValue, RegistryValueKind.DWord);
                onComplete(true, "");
            }
        }
        catch (Exception ex)
        {
            onComplete(false, ex.Message);
        }
    }

    static ProcessModule GetWeChatModule(Process wechatProcess)
    {
        try
        {
            return wechatProcess.Modules.Cast<ProcessModule>().FirstOrDefault(module => module.ModuleName == "WeChatWin.dll");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"获取模块错误: {ex.Message}");
            return null;
        }
    }

    static bool ReadMemory(IntPtr processHandle, IntPtr address, byte[] buffer)
    {
        int bytesRead;
        return ReadProcessMemory(processHandle, address, buffer, (uint)buffer.Length, out bytesRead);
    }

    static bool WriteMemory(IntPtr processHandle, IntPtr address, byte[] buffer)
    {
        int bytesWritten;
        return WriteProcessMemory(processHandle, address, buffer, (uint)buffer.Length, out bytesWritten);
    }

    static string GetLastErrorMessage()
    {
        int errorCode = Marshal.GetLastWin32Error();
        return $"错误代码: {errorCode}";
    }

    static void LogError(string message)
    {
        ConsoleColor originalColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.Red;

        // 清除当前行(进度条)
        Console.SetCursorPosition(0, Console.CursorTop);
        Console.Write(new string(' ', Console.WindowWidth));
        Console.SetCursorPosition(0, Console.CursorTop);

        Console.WriteLine($"[错误] {message}");
        Console.ForegroundColor = originalColor;
    }

    static void UpdateProgress(int current, int total)
    {
        const int progressBarWidth = 50;
        float percent = (float)current / total;
        int completedWidth = (int)(percent * progressBarWidth);

        ConsoleColor originalColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.Gray;

        Console.SetCursorPosition(0, Console.CursorTop);
        Console.Write("[");

        Console.ForegroundColor = ConsoleColor.Green;
        Console.Write(new string('=', completedWidth));

        Console.ForegroundColor = ConsoleColor.Gray;
        Console.Write(new string(' ', progressBarWidth - completedWidth));

        Console.Write($"] {current}/{total}");
        Console.ForegroundColor = originalColor;
    }
}

评分

参与人数 1好评 +1 收起 理由
多多帅吧 + 1 YYDS~!

查看全部评分


签到天数: 8 天

发表于 2025-8-1 09:36:35 | 显示全部楼层   浙江省宁波市
感谢分享,支持开源!!!
回复 支持 反对

使用道具 举报

结帖率:95% (99/104)

签到天数: 4 天

发表于 2025-7-31 21:59:22 | 显示全部楼层   内蒙古自治区通辽市
        感谢分享,很给力!~
回复 支持 反对

使用道具 举报

签到天数: 9 天

发表于 2025-7-30 18:29:10 | 显示全部楼层   安徽省合肥市
支持!!!!支持!!!!
回复 支持 反对

使用道具 举报

签到天数: 10 天

发表于 2025-7-30 15:52:50 | 显示全部楼层   河北省石家庄市
感谢分享
回复 支持 反对

使用道具 举报

签到天数: 5 天

发表于 2025-7-30 10:45:56 | 显示全部楼层   安徽省滁州市
回复 支持 反对

使用道具 举报

结帖率:96% (415/434)

签到天数: 3 天

发表于 2025-7-30 09:58:28 | 显示全部楼层   内蒙古自治区乌海市
谢谢分享
回复 支持 反对

使用道具 举报

签到天数: 9 天

发表于 2025-7-30 09:01:26 | 显示全部楼层   新疆维吾尔自治区巴音郭楞蒙古自治州
谢谢分享
回复 支持 反对

使用道具 举报

结帖率:0% (0/2)

签到天数: 8 天

发表于 2025-7-30 08:45:03 | 显示全部楼层   广西壮族自治区玉林市
感谢开源
回复 支持 反对

使用道具 举报

签到天数: 5 天

发表于 2025-7-30 08:25:01 | 显示全部楼层   河北省邯郸市
6666666666666666
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备2025452707号) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表