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; }