| Package | Version |
|---|---|
| Cross platform | |
| Windows | |
| Linux | Coming soon (see the Abstractions branch) |
| MacOS | Coming soon (see the Abstractions branch) |
Loads unmanaged libraries right from your embedded resources! Works on Windows and Linux only, both on .NET Framework and .NET Core (and of course .NET 5.0+)
- Load x86 and x64 assemblies, right from the memory. No P/Invoke, no temporary files.
- Correctly resolves loaded unmanaged libraries, and exposes a
AssemblyResolveevent for users to manually handle it. - Linux x86 (32 and 64 bit) support, through interoperation with
glibc.
usingMemoryModule;[UnmanagedFunctionPointer(CallingConvention.Cdecl)]delegateintaddNumberProc(inta,intb);varasmBytes=File.ReadAllBytes($"SampleDLL.dll");varasm=NativeAssembly.Load(asmBytes);Console.WriteLine("Successfully loaded library.");varaddNumberFunc=asm.GetDelegate<addNumberProc>("addNumbers");varrand=newRandom();intnum1=rand.Next(0,20);intnum2=rand.Next(0,20);Console.WriteLine($"{num1}+{num2}={addNumberFunc(num1,num2)}");vargreetFunc=asm.GetDelegate<GreetProc>("Greet");greetFunc();asm.Dispose();See the DemoApp for more details.
- MemoryModule: Cross platform package, with support for x86 and x86_64, Windows and Linux.
- MemoryModule.Compact.Windows: Compact module for small, standalone Windows applications.
MemoryModule.NET, unlike other projects of the MemoryModule family, aims to have a simple
design and a consistent interface across platforms. (see the
Abstractions
branch for an overview of the future of MemoryModule.NET).
Therefore, features requiring a high amount of integration, like
TLS support (#34) or
Interoperability with native APIs (#42)
will not be included in MemoryModule.NET in the foreseeable future.
However, MemoryModule.NETshould be able to bootstrap other native MemoryModules. For
example, C# applications targeting only Windows can enjoy the above features by bootstrapping
MemoryModulePP, as demonstrated in
this repo.
- Windows: Beware of
64-bitdllfiles compiled using g++: fancycode/MemoryModule#108. These files must be compiled using-static-libgccand-static-libstdc++to load properly, in both the original C version and this version. - Windows: Resources are not supported.
- Linux: Support is limited. While basic C/C++ libraries, such as
libcurl, can be properly loaded, MemoryModule.NET may not work with other advanced libraries that contain unknown ELF relocations. If that's the case, please open an issue. - Linux: As MemoryModule.NET relies on certain
glibcdata structures, it may fail on systems that use beta/customglibcversion. Please open an issue for support.
This repo is a part of Project Reality.
Need help using this project? Join me on Discord, and let's find a solution together.