The Wayback Machine - https://web.archive.org/web/20200603123948/https://github.com/3F/DllExport
Skip to content
.NET DllExport with .NET Core support (aka 3F/DllExport)
C# Rich Text Format Batchfile PowerShell
Branch: master
Clone or download

Latest commit

3F Public Release; .NET DllExport 1.7.1
* NEW: Pre-Processing feature. PR #146.
       Related issue #40

       Official ILMerge support;
       https://github.com/dotnet/ILMerge

       Quick integration with Conari for most easy access to unmanaged features;
       https://github.com/3F/Conari

       +Other related tools and assembly manipulations.
       Manual configuring: #40 (comment)

* NEW: Post-Processing. PR #148.
       Continues direction of Pre-Processing feature. PR #146
       Related issue #144

       Explanation and details:
       https://ko-fi.com/Blog/Post/ILMerge---Conari---Debug-information---DllExport-=-O5O61MV8A

       1.7.1 Provides only basic GUI support for predefined options. Thus,

        *! Some Post-Proc features are not yet available in GUI.
        But you can already configure it with msbuild:
        ```
        <Target Name="DllExportPostProc">

            <!-- After activation, you can access the following properties and items:

            $(DllExport)     - version
            $(DllExportSln)  - full path to .sln which controls current project
            $(DllExportPrj)  - full path to current project where processed .NET DllExport

            @(DllExportDirX64)    - $(TargetDir)x64\*.*
            @(DllExportDirX86)    - $(TargetDir)x86\*.*
            @(DllExportDirBefore) - $(TargetDir)Before\*.*
            @(DllExportDirAfter)  - $(TargetDir)After\*.*

            @(DllExportDependents + populated property name)
               - each populated properties from DllExportProcEnv,
                  e.g. DllExportDependentsTargetDir

            @(DllExportDependencies + populated property name)
              - each populated properties from DllExportProcEnv,
                  e.g. DllExportDependenciesTargetDir

            @(DllExportSeqDependents + populated property name)
               - each populated properties from DllExportProcEnv,
                  e.g. DllExportSeqDependentsTargetDir

            -->

        </Target>
        ```
        #148 (comment)

* NEW: Optional copying of intermediate files + x86+x64 directories into output
           for projects that dependent on projects where used DllExport. Issue #144.

           Including sequential referencing through other projects:
           #148 (comment)

* FIXED: Fixed #140 ... failed to create safe SSL/TLS context.

* FIXED: Pack of fixes for .net.dllexport.targets. PR #147.

        * Fixed "Cannot modify an evaluated object originating in an imported file".
        * Fixed possible duplication in .net.dllexport.targets when configuring.
        * Adds removing TargetsFile if not used.
        * Fixed possible loss of settings in .targets when configuring.

* FIXED: Fixed #143 'Microsoft.NET.Sdk' specified could not be found.

* FIXED: A multiple empty `<PropertyGroup />` in project files during new configuration.

* CHANGED: Wizard. Dropped support for ssl3 + tls1.0 + tls1.1

* CHANGED: Wizard. Simplified notification for stable versions.

* CHANGED: Manager. Access to hMSBuild tool (packed) via `-hMSBuild` key.
                    https://github.com/3F/hMSBuild
                    Since it uses packed version (while GetNuTool is integrated inside),
                    you need use -dxp-version to control specific version.

* CHANGED: Updated Cecil 0.11.2
           https://github.com/jbevain/cecil/releases/tag/0.11.2

* CHANGED: Updated MvsSln 2.5.2
           https://github.com/3F/MvsSln/releases/tag/2.5.2
Latest commit 61defd6 May 7, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Removed obsolete snk keys + updated issue templates Mar 28, 2020
GetNuTool @ df76082 Updated GetNuTool 1.8 Jan 16, 2020
Manager/batch Fixes #143 'Microsoft.NET.Sdk' specified could not be found Apr 2, 2020
MetadataCore Public Release; .NET DllExport 1.7.1 May 7, 2020
MetadataFx Consolidating component versions and resources (#149) Apr 30, 2020
MvsSln @ cd39a8d Adds Post-Processing feature. Related issue #144 (#148) May 7, 2020
NSBin Consolidating component versions and resources (#149) Apr 30, 2020
NSBinTest Enables support of unicode characters in namespaces. Issue #80 May 22, 2019
PeViewer Consolidating component versions and resources (#149) Apr 30, 2020
RGiesecke.DllExport.MSBuild Adds Post-Processing feature. Related issue #144 (#148) May 7, 2020
RGiesecke.DllExport Adds Post-Processing feature. Related issue #144 (#148) May 7, 2020
Resources Updated hMSBuild 2.3 Jan 29, 2020
Wizard A bit of Fixes and Improvements when applying data (#150) May 7, 2020
coreclr @ 4fde65a CoreCLR \ ILAsm 4.700.2 with an implemented `/REBASE` feature. Dec 11, 2019
hMSBuild @ 78b6c77 Updated hMSBuild 2.3 Jan 29, 2020
tools Adds Post-Processing feature. Related issue #144 (#148) May 7, 2020
.gitattributes +gitattributes now will be distributed with packages; Jan 25, 2020
.gitignore Basic support for the netcore-based projects. /#90 Oct 28, 2019
.gitmodules Added hMSBuild project as an git submodule. Jul 30, 2018
.release.version Public Release; .NET DllExport 1.7 Jan 31, 2020
.version Public Release; .NET DllExport 1.7.1 May 7, 2020
.vssbe Consolidating component versions and resources (#149) Apr 30, 2020
3rd-party.txt VS project icons Jan 20, 2020
DllExport.sln New installation behavior through official NuGet Dec 11, 2019
DllExportVersion.cs Public Release; .NET DllExport 1.7.1 May 7, 2020
LICENSE Updated License headers Jan 11, 2020
Readme.md Public Release; .NET DllExport 1.7.1 May 7, 2020
build-coreclr-ilasm-x64.cmd Updated CoreCLR 3.0 IL Assembler 4.700.1 Nov 4, 2019
build-coreclr-ilasm-x86+x64.cmd Updated CoreCLR 3.0 IL Assembler 4.700.1 Nov 4, 2019
build-coreclr-ilasm-x86.cmd Updated CoreCLR 3.0 IL Assembler 4.700.1 Nov 4, 2019
build.bat Consolidating component versions and resources (#149) Apr 30, 2020
changelog.txt Public Release; .NET DllExport 1.7.1 May 7, 2020
com.github.3F.DllExport.snk Removed obsolete snk keys + updated issue templates Mar 28, 2020
packages.config CoreCLR \ ILAsm 4.700.2 with an implemented `/REBASE` feature. Dec 11, 2019
test-manager.bat +gitattributes now will be distributed with packages; Jan 25, 2020

Readme.md

.NET DllExport

.NET DllExport (aka 3F/DllExport)

Copyright (c) 2009-2015  Robert Giesecke
Copyright (c) 2016-2020  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 }

~ ~ ~ --- ~ ~ ~

[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) [?]

v1.2+ provides dynamic definitions of namespaces (ddNS feature):

    Via Cecil or direct modification:

    000005B0                 00 C4 7B 01 00 00 00 2F 00 12 05       .Д{..../...
    000005C0  00 00 02 00 00 00 00 00 00 00 00 00 00 00 26 00  ..............&.
    000005D0  20 02 00 00 00 00 00 00 00 49 2E 77 61 6E 74 2E   ........I.want.   <<<-
    000005E0  74 6F 2E 66 6C 79 00 00 00 00 00 00 00 00 00 00  to.fly..........  <<<-


Initially the original tool UnmanagedExports was distributed by Robert Giesecke as an closed-source tool under the MIT License:

Now, we will be more open ! all details here

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 (~19 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 ]

DllExport.bat

Other way:

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

Part of this build scripts works via vssbe (?) and for build via console (including CI etc.) uses CIM version of this. You do not need anything else, just type build.

For Visual Studio use this vsix version for IDE

How to Debug

Wizard through MSBuild, for example:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

Arguments:

"net.r_eg.DllExport.Wizard.targets" /p:wRootPath="<...>" 
/p:wSlnFile="<SolutionFile_for_debugging>.sln" /p:wAction="Configure" 
/p:wPkgPath=packages/DllExport<version>

Working directory:

<path_to>\packages\DllExport<version>\tools

DllExport.MSBuild, for example:

C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe

Arguments:

"<path_to_SolutionFile_for_debugging>.sln" /t:Build /p:Configuration=<Configuration>

use additional Diagnostic key to msbuild if you need more details:

"<SolutionFile>.sln" /verbosity:Diagnostic /t:Rebuild /p:Configuration=<Configuration>

Now you can debug at runtime.

coreclr ILAsm / ILDasm

We're using our custom 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):

git submodule update --init --recursive

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

build-s -all -x86 -x64 Release

or use

build-coreclr-ilasm-x64.cmd
build-coreclr-ilasm-x86+x64.cmd

You can also use our compiled versions:

  • NuGet package

Donation

Please note again, the UnmanagedExports was created by Robert Giesecke. You need visit his page.

But this repository does not related to Robert and generally still being developed by GitHub/3F developer (Follow the news: [ GitHub ]; [ twitter ]).

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

[ Donate ]

You can’t perform that action at this time.