用于与进程交互的 C# 类库。
Process.NET is a tool for interacting with processes based around a library called "MemorySharp" by Jämes Ménétrey aka ZenLulz under the license on the pages linked below. Below are the mentioned authors original library's and his official website for the library.
https://github.com/ZenLulz/MemorySharp/
Process.NET is simply a result of both me learning to program as a newer developer interested in both C# and native code, and the lack of a few features I desired in the library I enjoyed using as a new programmer.
The core features of the original MemorySharp all or mostly library still exist. However, they have been implemented as a set of interfaces instead.
This is to allow different implementations of the already great design MemorySharp has, such as support for internal (aka, injected) operations or the need for specific implementation details.
Original features
- Most original features listed here still exist. https://github.com/ZenLulz/MemorySharp.
**General feature, changes, and additions from the original library **
- Interface based design.
- Keyboard and mouse hooks.
- Pattern scanning for both functions and data patterns.
- Reduced dependency on FASM.net and Improved x64 support.
- Patches.
Internal process (aka injected) support
- Detours
- Hooks
- Fast memory reads using pointers/marshaling tricks
- Implementation of existing features to better suite internal-process operations.
public interface IProcess : IDisposable
{
System.Diagnostics.Process Native { get; }
SafeMemoryHandle Handle { get; }
IMemory Memory { get; }
IThreadFactory ThreadFactory { get; }
IModuleFactory ModuleFactory { get; }
IMemoryFactory MemoryFactory { get; }
IWindowFactory WindowFactory { get; }
IProcessModule this[string moduleName] { get; }
IPointer this[IntPtr addr] { get; }
}
Also, this abstraction is used to provide easier memory read/write implementations.
…
The way pattern scanning has been added is through interfaces, and a default implementation for both function and data patterns have been included. In most cases, they will be all you need. Here are the default implementation examples.
Pattern scanning for a function offset:
…
…
And an example of using it:
public class TestClass
{
private WindowHook _window;
public void Install(IntPtr handle)
{
_window = new WindowHook(handle);
_window.Enable();
_window.Invoke(UserMessage.SayHi);
}
public void Uninstall()
{
_window.Invoke(WindowHook.UserMessage.SayBye);
_window.Disable();
}
}
A basic keyboard hook use
public class TestClass
{
private KeyboardHook _keyboardHook;
public void Install(string name)
{
_keyboardHook = new KeyboardHook(name);
_keyboardHook.KeyDownEvent += args =>
{
if (args.IsAltPressed && args.Key == Keys.A)
Console.WriteLine("The A and alt keys were pressed together.");
};
}
}
And the mouse hook
public class TestClass
{
private MouseHook _mouseHook;
public void Install()
{
_mouseHook = new MouseHook();
_mouseHook.LeftButtonDown +=
(sender, args) =>
Console.WriteLine($"The mouse was at the position: {args.Position} when left clicked.");
_mouseHook.Enable();
}
}
Using the Marshal.GetDelegateForFunctionPointer to call user32.dll messagebox
…
Implementing the assembly factory the way MemorySharp does with FASM.Net and using it
…
Window operations
…
Memory operations
…
暂无开放 Issues,或尚未同步最近议题。