Process.Net

ProcessSharp的构造函数,对应的测试是

https://github.com/lolp1/Process.NET/blob/master/test/Process.NET.Test/Core/ProcessSharpTest.cs

  /// <summary>
        ///     Initializes a new instance of the <see cref="ProcessSharp" /> class.
        /// </summary>
        /// <param name="native">The native process.</param>
        /// <param name="type">The type of memory being manipulated.</param>
        public ProcessSharp(System.Diagnostics.Process native,MemoryType type)
        {
            native.EnableRaisingEvents = true;

            native.Exited += (s, e) =>
            {
                ProcessExited?.Invoke(s, e);
                HandleProcessExiting();
            };

            Native = native;

            Handle = MemoryHelper.OpenProcess(ProcessAccessFlags.AllAccess, Native.Id);
            switch (type)
            {
                case MemoryType.Local:
                    Memory = new LocalProcessMemory(Handle);
                    break;
                case MemoryType.Remote:
                    Memory = new ExternalProcessMemory(Handle);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            native.ErrorDataReceived += OutputDataReceived;
            native.OutputDataReceived += OutputDataReceived;

            ThreadFactory = new ThreadFactory(this);
            ModuleFactory = new ModuleFactory(this);
            MemoryFactory = new MemoryFactory(this);
            WindowFactory = new WindowFactory(this);
        }

 

https://github.com/lolp1/Process.NET/blob/master/src/Process.NET/Memory/ExternalProcessMemory.cs

 

可以尝试转换HearthBuddy中的Class276中的方法

internal IntPtr method_33(IntPtr intptr_37, string string_0, params Class276.Enum20[] enum20_0)
        {
            while (intptr_37 != IntPtr.Zero)
            {
                using (AllocatedMemory allocatedMemory = this.externalProcessMemory_0.CreateAllocatedMemory(256))
                {
                    allocatedMemory.AllocateOfChunk<IntPtr>("Itr");
                    IntPtr intPtr;
                    while ((intPtr = this.method_35(intptr_37, allocatedMemory["Itr"])) != IntPtr.Zero)
                    {
                        IntPtr intPtr2 = this.method_37(intPtr);
                        if (this.externalProcessMemory_0.ReadStringA(intPtr2) == string_0)
                        {
                            if (enum20_0 != null)
                            {
                                Class276.Enum20[] array = this.method_31(intPtr);
                                if (array.Length != enum20_0.Length || !array.SequenceEqual(enum20_0))
                                {
                                    continue;
                                }
                            }
                            return intPtr;
                        }
                    }
                    intptr_37 = this.method_25(intptr_37);
                }
            }
            return IntPtr.Zero;
        }

 

转载于:https://www.cnblogs.com/chucklu/p/11376479.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值