Download: https://dl.dropbox.com/u/2068143/GreyMagic.7z

So, I wrote this a while back for our bots (Honorbuddy, Demonbuddy, BuddyWing, etc). It's a full-featured memory lib for both in and out of process memory handling. Performance tests show that it's barely a tick slower than calling ReadProcessMemory directly on simple data types, and slightly over a tick slower than reading structures. (Write speeds have not been tested, as writing is not done nearly as often)

The following are for perf tests over 1 million iterations:

Read<int>(addr, relative: true) - 4.57 ticks
ReadProcessMemory (direct) - 3.54 ticks
Deref on ReadBytes(addr, relative: true) - 3.90 ticks
Read<NonMarshalStruct>(addr, relative: true) - 5.06 ticks
Read<MarshalStruct>(addr, relative: true) - 6.48 ticks

The library itself implements a neat little trick to avoid using the marshaler wherever possible. MarshalCache<T> provides a way to cache certain data for types (size, typeof(), whether the type needs to be run through the marshaler, etc), as well as implements a way for C# to take a pointer to a generic type. (You can't do &T in C#... well... at least you couldn't)

The lib itself takes into account quite a few things, and should hopefully be plug-and-play ready. It includes a few other things that aren't really useful (but tossed in for the sake of tossing it in). I will be adding more features in the future (it lacks a pattern scanner). Feel free to use and abuse, please let me know of any bugs you run into.

In-process memory class: InProcessMemoryReader
OOP memory class: ExternalProcessMemoryReader

Enjoy folks!