GithubHelp home page GithubHelp logo

rtforks / dllfrommemory-net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from schellingb/dllfrommemory-net

0.0 0.0 0.0 21 KB

C# library to load a native DLL from memory without the need to allow unsafe code

License: Mozilla Public License 2.0

C++ 0.61% C# 99.39%

dllfrommemory-net's Introduction

DLLFromMemory.Net

A C# library to load a native DLL from memory without the need to allow unsafe code.

By default C# can load external libraries only via files on the filesystem. A common workaround for this problem is to write the DLL into a temporary file first and import it from there. This library can be used to load a DLL completely from memory - without storing on the disk first.

It supports both 32bit and 64bit processes/DLLs, as well as AnyCPU builds.
For AnyCPU, both 32bit and 64bit DLLs must be available in memory (see Sample)

Example

[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate int AddDelegate(int a, int b);

static void RunAdd(byte[] dllBytes)
{
    DLLFromMemory dll = new DLLFromMemory(dllBytes);

    AddDelegate addFunc = dll.GetDelegateFromFuncName<AddDelegate>("Add");
    Console.WriteLine("Calling add(1, 2): " + addFunc(1, 2) + "\n");

    dll.Close();
}

Contributions

DLLFromMemory.Net is based on Memory Module.net 0.2
Copyright (C) 2012 - 2018 by Andreas Kanzler
https://github.com/Scavanger/MemoryModule.net

Memory Module.net is based on Memory DLL loading code Version 0.0.4
Copyright (C) 2004 - 2015 by Joachim Bauch
https://github.com/fancycode/MemoryModule

License

DLLFromMemory.Net is available under the MPL 2.0.

dllfrommemory-net's People

Contributors

schellingb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.