<div align="center">
# ProcessMemoryUtilities.Net
[![Nuget](https://img.shields.io/nuget/v/ProcessMemoryUtilities.Net.svg)](https://www.nuget.org/packages/ProcessMemoryUtilities.Net/ "ProcessMemoryUtilities.Net on NuGet") [![Nuget](https://img.shields.io/nuget/dt/ProcessMemoryUtilities.Net.svg)](https://www.nuget.org/packages/ProcessMemoryUtilities.Net/ "Downloads on NuGet") [![Open issues](https://img.shields.io/github/issues-raw/michel-pi/ProcessMemoryUtilities.Net.svg)](https://github.com/michel-pi/ProcessMemoryUtilities.Net/issues "Open issues on Github") [![Closed issues](https://img.shields.io/github/issues-closed-raw/michel-pi/ProcessMemoryUtilities.Net.svg)](https://github.com/michel-pi/ProcessMemoryUtilities.Net/issues?q=is%3Aissue+is%3Aclosed "Closed issues on Github") [![MIT License](https://img.shields.io/github/license/michel-pi/ProcessMemoryUtilities.Net.svg)](https://github.com/michel-pi/ProcessMemoryUtilities.Net/blob/master/LICENSE "ProcessMemoryUtilities.Net license")
![Net Framework 4.52](https://img.shields.io/badge/.Net-4.52-informational.svg) ![Net Framework 4.7](https://img.shields.io/badge/.Net-4.7-informational.svg) ![Net Framework 4.8](https://img.shields.io/badge/.Net-4.8-informational.svg) ![Net Standard 2.0](https://img.shields.io/badge/.Net_Standard-2.0-informational.svg)
</div>
This library implements performant wrapper methods over, in game hacking, commonly used `NtDll` and `Kernel32` functions. The different classes allow you to use generic type parameters with `ReadProcessMemory` and `WriteProcessMemory` and call simpler functions like `OpenProcess`, `CreateRemoteThread` and more without any overhead.
While most of the methods are implemented using their `NtDll` equivalent instead of `Kernel32` some still require `Kernel32` to work properly or are depricated in `NtDll`.
All methods are tested and working under 32bit and 64bit windows and are well documented.
[Documentation](https://michel-pi.github.io/ProcessMemoryUtilities.Net/ "ProcessMemoryUtilities.Net Documentation")
## NuGet
This library is available in the [NuGet Gallery](https://www.nuget.org/packages/ProcessMemoryUtilities.Net/).
## Features
The `ProcessMemoryUtilities.Native` namespace offers direct access to either `Kernel32` or `NtDll` methods without any overhead. Most of them not only offer the traditional function signature but also implement overloads with common default values set.
All the required enums and constants are available with their XML documentation.
The `ProcessMemoryUtilities.Managed` namespace offers the `NativeWrapper` class which is there to provide a single place to access all the implemented methods with a more user friendly and `Kernel32` like interface. This also adds basic error handling over `ReadProcessMemory` and `WriteProcessMemory` and offers a `Win32` error code when any function failed.
- CloseHandle
- CreateRemoteThread(Ex)
- Generic ReadProcessMemory
- Generic WriteProcessMemory
- OpenProcess
- VirtualAllocEx
- VirtualFreeEx
- VirtualProtectEx
- WaitForSingleObject
Every native method is implemented using the `calli` IL instruction and bypasses type limitations introduced in C#. All native calls are done in a safe manner and use correct types and pinning for pointer variables.
Some important improvements are:
- Direct calls to WinAPI methods
- Using `NtDll` methods instead of `Kernel32` whenever possible
- No performance loss due to marshaling or delegates
- Optimized memory allocations
## Methods
I copied some of the function signatures to give you a quick overview of what kind of methods you can expect from this library.
```cs
// CreateRemoteThreadEx with a reduced set of parameters for easier usage
IntPtr CreateRemoteThreadEx(IntPtr handle, IntPtr startAddress, IntPtr parameter);
// compared to this one which is also available
IntPtr CreateRemoteThreadEx(IntPtr handle, IntPtr threadAttributes, IntPtr stackSize, IntPtr startAddress, IntPtr parameter, ThreadCreationFlags creationFlags, IntPtr attributeList, out uint threadId);
// OpenProcess
IntPtr OpenProcess(ProcessAccessFlags desiredAccess, bool inheritHandle, int processId);
IntPtr OpenProcess(ProcessAccessFlags desiredAccess, int processId);
// WaitForSingleObject
WaitObjectResult WaitForSingleObject(IntPtr handle, uint timeout);
// ReadProcessMemory and WriteProcessMemory
uint NtReadVirtualMemory<T>(IntPtr handle, IntPtr baseAddress, ref T buffer, out IntPtr numberOfBytesRead);
bool WriteProcessMemoryArray<T>(IntPtr handle, IntPtr baseAddress, T[] buffer, int offset, out IntPtr numberOfBytesWritten);
// VirtualMemory functions
uint NtAllocateVirtualMemory(IntPtr handle, IntPtr size, AllocationType allocationType, MemoryProtectionFlags memoryProtection, out IntPtr address);
IntPtr VirtualAllocEx(IntPtr handle, IntPtr address, IntPtr size, AllocationType allocationType, MemoryProtectionFlags memoryProtection);
bool VirtualFreeEx(IntPtr handle, IntPtr address, IntPtr size, FreeType freeType);
bool VirtualProtectEx(IntPtr handle, IntPtr address, IntPtr size, MemoryProtectionFlags newProtect, out MemoryProtectionFlags oldProtect);
```
## Marshaling
While this approach offers a wide range of benefits you may encounter a single drawback.
Because we use the IL instruction `sizeof` instead of `Marshal.SizeOf` the whole marshaling layer is skipped. This means that you can not use classes and the following keywords inside of structs
```cs
[MarshalAs]
string
```
Please use `fixed` arrays instead of `[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]`
```cs
// This does not work with my library because sizeof gives us a wrong size (4 instead of 16)
[StructLayout(LayoutKind.Explicit)]
private struct Wrong
{
[FieldOffset(0)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public int[] Numbers;
[FieldOffset(0)]
public int FirstNumber;
}
// [StructLayout(LayoutKind.Sequential)] is also a valid option
[StructLayout(LayoutKind.Explicit)]
private unsafe struct Correct
{
[FieldOffset(0)]
public fixed int Numbers[4];
[FieldOffset(0)]
public int FirstNumber;
}
```
### Error Handling
The `ProcessMemoryUtilities.NativeWrapper` class offers the `CaptureErrors` property (which is set true by default) to emulate `SetLastError` and `GetLastError`.
The `LastError` property converts the saved `NtStatus` to a equivalent `Win32` error code which you can use in your exceptions.
### [Documentation](https://michel-pi.github.io/ProcessMemoryUtilities.Net/ "ProcessMemoryUtilities.Net Documentation")
## Contribute
The project file was generated using Visual Studio 2019.
Clone or download the repository and restore the required NuGet packages.
You can help by reporting issues, adding new features, fixing bugs and by providing a better documentation.
### Dependencies
Following dependencies are used to build the project but are **NOT** included in the NuGet package.
Fody
InlineIL.Fody
ILRepack.Lib.MSBuild.Task
## Donate
Do you like this project and want to help me to keep working on it?
I appreciate any donation that helps me to continue working on OSS like this.
[![Donate via PayPal](https://media.wtf/assets/img/pp.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YJDWMDUSM8KKQ "Donate via PayPal")
```
BTC bc1qp6zc73vy8pmr6lfe4cxa6eqzvkuer9hrjwpzza
```
## License
- [ProcessMemoryUtilities.Net License](https://github.com/michel-pi/ProcessMemoryUtilities.Net/blob/master/LICENSE "ProcessMemoryUtilities.Net License")
- [Fody License](https://github.com/Fody/Fody/blob/master/License.txt "Fody License")
- [InlineIL.Fody License](https://github.com/ltrzesniewski/InlineIL.Fody/blob/master/LICENSE "InlineIL.Fody License")
- [ILRepack.Lib.MSBuild.Task
License](https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task/blob/master/LICENSE.md "ILRepack.Lib.MSBuild.Task License")
- [BenchmarkDotNet License](https://github.com/dotnet/BenchmarkDotNet "BenchmarkDotNet License")
没有合适的资源?快使用搜索试试~ 我知道了~
使用InlineIL实现具有通用类型参数的高性能ReadProcessMemory和WriteProcessMemory.zip
共109个文件
cs:34个
html:18个
json:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 133 浏览量
2023-04-26
11:02:39
上传
评论
收藏 585KB ZIP 举报
温馨提示
使用InlineIL实现具有通用类型参数的高性能ReadProcessMemory和WriteProcessMemory.zip
资源推荐
资源详情
资源评论
收起资源包目录
使用InlineIL实现具有通用类型参数的高性能ReadProcessMemory和WriteProcessMemory.zip (109个子文件)
serve.bat 46B
build.bat 26B
packages.config 6KB
App.config 3KB
packages.config 224B
packages.config 222B
NtDll.WVM.cs 34KB
NativeWrapper.WPM.cs 34KB
NtDll.RVM.cs 32KB
NativeWrapper.RPM.cs 31KB
Enums.cs 22KB
ProcessMemoryTests.cs 13KB
Kernel32.CRT.cs 12KB
NativeWrapper.CRT.cs 10KB
NtDll.V.cs 8KB
NativeWrapper.V.cs 8KB
Kernel32.cs 7KB
NtDllTests.cs 6KB
NtDll.OP.cs 6KB
WriteVirtualMemoryTests.cs 6KB
UnsafeMarshalTests.cs 5KB
ReadVirtualMemoryTests.cs 5KB
NtDll.cs 5KB
Kernel32Tests.cs 4KB
DynamicImport.cs 4KB
IntPtrExtensionsTests.cs 3KB
NativeWrapper.OP.cs 3KB
StringMarshalTests.cs 3KB
NativeWrapper.Kernel.cs 2KB
ReadProcessMemory.cs 2KB
NativeWrapper.cs 2KB
StaticArrayPoolTests.cs 1KB
AssemblyInfo.cs 1KB
InternalHelper.cs 720B
AssemblyInfo.cs 655B
AssemblyInfo.cs 611B
ObjectAttributes.cs 412B
GlobalSuppressions.cs 367B
Program.cs 309B
ClientID.cs 258B
ProcessMemoryUtilities.Benchmark.csproj 21KB
ProcessMemoryUtilities.Tests.csproj 5KB
ProcessMemoryUtilities.Test.csproj 5KB
NugetBuild.csproj 2KB
ProcessMemoryUtilities.csproj 1KB
ProcessMemoryUtilities.Managed.csproj 703B
docfx.vendor.css 116KB
docfx.css 17KB
main.css 0B
glyphicons-halflings-regular.eot 20KB
.gitignore 5KB
.gitignore 106B
.gitignore 64B
ProcessMemoryUtilities.Managed.NativeWrapper.html 213KB
ProcessMemoryUtilities.Native.NtDll.html 181KB
ProcessMemoryUtilities.Native.Kernel32.html 49KB
ProcessMemoryUtilities.Native.MemoryProtectionFlags.html 12KB
ProcessMemoryUtilities.Native.AllocationType.html 11KB
ProcessMemoryUtilities.Native.ProcessAccessFlags.html 11KB
ProcessMemoryUtilities.Native.FreeType.html 8KB
ProcessMemoryUtilities.Native.NtStatus.html 8KB
ProcessMemoryUtilities.Native.WaitObjectResult.html 7KB
ProcessMemoryUtilities.Native.ThreadCreationFlags.html 7KB
ProcessMemoryUtilities.Native.html 6KB
index.html 6KB
index.html 6KB
ProcessMemoryUtilities.Managed.html 5KB
intro.html 4KB
toc.html 3KB
toc.html 733B
toc.html 707B
favicon.ico 97KB
docfx.vendor.js 664KB
lunr.js 81KB
docfx.js 36KB
lunr.min.js 24KB
search-worker.js 2KB
main.js 148B
index.json 151KB
manifest.json 8KB
toc.raw.json 4KB
toc.raw.json 2KB
toc.raw.json 2KB
docfx.json 2KB
langwordMapping.yml.raw.json 1KB
search-stopwords.json 1KB
LICENSE 2KB
README.md 8KB
index.md 1KB
index.md 990B
intro.md 31B
ILRepack.Config.props 214B
ProcessMemoryUtilities.sln 3KB
glyphicons-halflings-regular.svg 106KB
logo.svg 1KB
ILRepack.targets 886B
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.woff2 18KB
ProcessMemoryUtilities.Native.xml 93KB
共 109 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功