当前位置: 首页 > article >正文

Vidmore Screen Recorde 2.0.20 学习 体验 不错!

有难度,历时5个小时,两个文件交叉验证,网络验证,QT5,源码都在图片里面。

补充补丁类
 

public class PatchManager : INotifyPropertyChanged
{
    public class PatchOperation
    {
        public long Offset { get; set; }
        public byte[] OriginalValue { get; set; }
        public byte[] NewValue { get; set; }
    }

    public class PatchFile
    {
        public string FileName { get; set; }
        public List<PatchOperation> Operations { get; set; } = new List<PatchOperation>();
    }

    public List<PatchFile> PatchFiles { get; set; } = new List<PatchFile>();

    private string _status;
    public string Status
    {
        get => _status;
        set { _status = value; OnPropertyChanged(); }
    }

    public bool ValidateAndApplyPatch(string filePath)
    {
        if (!File.Exists(filePath))
        {
            Status = "文件不存在";
            return false;
        }

        var patchFile = PatchFiles.Find(f => f.FileName == Path.GetFileName(filePath));
        if (patchFile == null)
        {
            Status = "未找到匹配的文件定义";
            return false;
        }

        try
        {
            using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite))
            {
                foreach (var operation in patchFile.Operations)
                {
                    if (!ValidateAndApplyOperation(fileStream, operation))
                    {
                        return false;
                    }
                }
            }

            Status = "补丁应用成功";
            return true;
        }
        catch (Exception ex)
        {
            Status = $"应用补丁时出错: {ex.Message}";
            return false;
        }
    }

    private bool ValidateAndApplyOperation(FileStream fileStream, PatchOperation operation)
    {
        fileStream.Seek(operation.Offset, SeekOrigin.Begin);
        byte[] buffer = new byte[operation.OriginalValue.Length];
        fileStream.Read(buffer, 0, buffer.Length);

        if (!buffer.SequenceEqual(operation.OriginalValue))
        {
            Status = $"偏移量 {operation.Offset} 处的值不匹配";
            return false;
        }

        fileStream.Seek(operation.Offset, SeekOrigin.Begin);
        fileStream.Write(operation.NewValue, 0, operation.NewValue.Length);
        return true;
    }

    public event PropertyChangedEventHandler PropertyChanged;
    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

调用列子

  var patchFile = new PatchManager.PatchFile
        {
            FileName = "example.dll",
            Operations = new List<PatchManager.PatchOperation>
            {
                new PatchManager.PatchOperation
                {
                    Offset = 1000,
                    OriginalValue = new byte[] { 0x00, 0x01, 0x02 },
                    NewValue = new byte[] { 0x03, 0x04, 0x05 }
                },
                new PatchManager.PatchOperation
                {
                    Offset = 2000,
                    OriginalValue = new byte[] { 0x10, 0x11, 0x12 },
                    NewValue = new byte[] { 0x13, 0x14, 0x15 }
                }
                // 可以添加更多的操作...
            }
        };

        PatchManager.PatchFiles.Add(patchFile);
        // 可以添加更多的 PatchFile...

还是需要自己动一下手哈,代码cody 生成,没验证大概就是这个样子。


http://www.kler.cn/news/353640.html

相关文章:

  • 【VUE】Vue2中 v-model 的原理
  • 使用 Bash 脚本实现交互式用户输入(参数选择)
  • vue3基础入门以及常用api使用
  • 视频智能分析平台LiteAIServer摄像机视频分析软件下载水土识别算法方案
  • 爬虫post收尾以及cookie加代理
  • BWA-mem Smith-Waterman 算法
  • 【VUE】Vue2中如何监听(检测)对象或者数组某个属性的变化
  • 第七课:Python学习之算数运算符
  • 强化学习之DQN算法
  • yocto编辑软件包-devtool的使用方法
  • 微服务中的负载均衡算法与策略深度解析
  • k8s--二进制包部署及常见报错解决方法
  • 请用python写一个小程序,把浏览器中打开的页面设置为深色模式
  • [LeetCode] 面试题01.02 判定是否互为字符重拍
  • 代码随想录 -- 贪心 -- 跳跃游戏
  • MapReduce工作机制源码解析
  • Kafka服务端SASL/PLAIN+ACL认证授权安装操作
  • 关于Git Bash中如何定义alias
  • 【2024软考高级架构师】论文篇——3、论Web系统的测试技术及其应用
  • 深入了解React 工作原理是什么