Code Monkey home page Code Monkey logo

3f-dllexport's Introduction

.NET DllExport with .NET Core support (aka 3F/DllExport)

Copyright (c) 2009-2015  Robert Giesecke
Copyright (c) 2016-2021  Denis Kuzmin <[email protected]> github/3F

Build status Latest-Release License coreclr_ILAsm Cecil MvsSln GetNuTool hMSBuild Conari

Build history

DllExport -action Configure [?]

[ Quick start ] [ Examples: C++, C#, Java ] -> { Wiki } { ๐Ÿงช Demo src }

[DllExport]
public static int entrypoint(IntPtr L)
{
    // ... it will be called from Lua script

    lua_pushcclosure(L, onProc, 0);
    lua_setglobal(L, "onKeyDown");

    return 0;
}
  • For work with Unmanaged memory including native or binary data from the heap and binding between .NET and unmanaged native C/C++ etc, use Conari
  • For related work with Lua (5.4, 5.3, 5.2, 5.1, ...), use LuNari
[DllExport("Init", CallingConvention.Cdecl)]
// __cdecl is the default calling convention for our library
[DllExport(CallingConvention.StdCall)]
[DllExport("MyFunc")]
[DllExport]

We're supporting the following PE modules: Library (.dll) and Executable (.exe) [?]

License

The MIT License (MIT)

.NET DllExport contributors: https://github.com/3F/DllExport/graphs/contributors

&_

How does it work

Current features has been implemented through ILDasm & ILAsm that prepares the all required steps via .export directive (it's specific directive for ILAsm compiler only).

What inside ? or how does work the .export directive ?

Read about format PE32/PE32+, start with grammar from asmparse and move to writer:

...
//yacc
if(PASM->m_pCurMethod->m_dwExportOrdinal == 0xFFFFFFFF)
{
  PASM->m_pCurMethod->m_dwExportOrdinal = $3;
  PASM->m_pCurMethod->m_szExportAlias = $6;
  if(PASM->m_pCurMethod->m_wVTEntry == 0) PASM->m_pCurMethod->m_wVTEntry = 1;
  if(PASM->m_pCurMethod->m_wVTSlot  == 0) PASM->m_pCurMethod->m_wVTSlot = $3 + 0x8000;
}
...
EATEntry*   pEATE = new EATEntry;
pEATE->dwOrdinal = pMD->m_dwExportOrdinal;
pEATE->szAlias = pMD->m_szExportAlias ? pMD->m_szExportAlias : pMD->m_szName;
pEATE->dwStubRVA = EmitExportStub(pGlobalLabel->m_GlobalOffset+dwDelta);
m_EATList.PUSH(pEATE);
...
// logic of definition of records into EXPORT_DIRECTORY (see details from PE format)
HRESULT Assembler::CreateExportDirectory()  
{
...
    IMAGE_EXPORT_DIRECTORY  exportDirIDD;
    DWORD                   exportDirDataSize;
    BYTE                   *exportDirData;
    EATEntry               *pEATE;
    unsigned                i, L, ordBase = 0xFFFFFFFF, Ldllname;
    ...
    ~ now we're ready to miracles ~

Read also my brief explanations here: AssemblyRef encoding / about mscoree / DllMain & the export-table / DllExport.dll / ordinals ...

How to get DllExport

tl;dr: put this inside solution folder, then click it there.

Since v1.6+ have no official support of NuGet clients ([?]), you need just use this inside your solution folder. Wiki: [ Quick start ]

Get our manager (~20 Kbytes) from any trusted place. Official GHR is recommended. But you can also get it from official packages via NuGet server NuGet package, etc. [ Documentation ]

How to Build .NET DllExport

Just use build.bat if you need final binaries (NuGet package as DllExport.<version>.nupkg, Manager, zip-archives, and others).

.\build Debug

Part of the build works through vssbe (including CI that uses CIM version). But you don't need to do anything at all. For Visual Studio IDE you can also use vsix version

Modified ILAsm + ILDasm on coreclr

We're using our modified versions on coreclr specially for our .NET DllExport project - https://github.com/3F/coreclr

This helps to avoid some problems (like this, or this) and more...

To build minimal version (it will not include all components as for original coreclr repo):

Restore git submodule or use repo: https://github.com/3F/coreclr.git

git submodule update --init --recursive

Make sure that you have installed CMake, then build simply:

build-s -all -x86 -x64 Release

You can also use our compiled versions: NuGet package

Donation

Please note again, the UnmanagedExports was created by Robert Giesecke. His page is here. [?]

But .NET DllExport is not related to him.

โœ” .NET DllExport is developed for you by GitHub/3F ([ GitHub ]; [ twitter ]).

If something is helpful from 3F/DllExport, donations are welcomed, and thanks !

[ โ˜• Donate ]

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.