Skip to content
forked from 3F/DllExport

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

License

Notifications You must be signed in to change notification settings

dkxce/3F-DllExport

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Copyright (c) 2009-2015  Robert Giesecke
Copyright (c) 2016-2021  Denis Kuzmin <x-3F@outlook.com> 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 ]

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 72.9%
  • Rich Text Format 20.5%
  • Batchfile 6.5%
  • PowerShell 0.1%