.NET DllExport
Clone or download
3F Fixed support of the special symbols in path: ' &!~`@#$^(+)_=%-;. Rel…
…ated Issue #88

Back to the old label-goto logic instead of `for` (d4b46cd) because of more hard escaping for all special symbols above. This is the moment when you finally start to feel sick from batch scripts -_-

This changes also provides new `__p_call` flag - To use the call-type logic when invoking DllExport.

And also adds handling of unknown action. Just not to scare users...

Other details in #88
Latest commit 2488b0c Dec 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Updated nuspec info + turning off creating zip archives for Debug con… Jul 28, 2018
Configurator Public release of the .NET DllExport v1.6.1 Aug 5, 2018
GetNuTool @ a200982 Fixed support of the special symbols in path: ' &!~`@#$^(+)_=%-;. Rel… Dec 8, 2018
Manager/batch Fixed support of the special symbols in path: ' &!~`@#$^(+)_=%-;. Rel… Dec 8, 2018
Metadata Public release of the .NET DllExport v1.6.1 Aug 5, 2018
MvsSln @ 0f62a82 Public release of the .NET DllExport v1.6.1 Aug 5, 2018
NSBin Updated License header Jan 5, 2018
NSBinTest Updated broken test after 8517887 & `lib/net20/_._` details in #36 Aug 12, 2017
PeViewer Updated License header Jan 5, 2018
RGiesecke.DllExport.MSBuild CA1901 for SendMessage() & CA1063 for DxpIsolatedEnv, +cleanup Sep 15, 2018
RGiesecke.DllExport x32; x86; win32; anycpu; any cpu; aliases Sep 15, 2018
Resources/img Public final v1.6 release of the .NET DllExport: Dec 29, 2017
Wizard Pack of fixes for manager. New structure and tests: Nov 24, 2018
bin hMSBuild v1.1.0.5136 & sln to VS2017 + updated 'How to Build' in readme Apr 15, 2017
coreclr @ 05afa4f Updated IlAsm 4.5.1 & coreclr project - now we can correctly work wit… Nov 3, 2016
hMSBuild @ 3ee58c3 Added hMSBuild project as an git submodule. Jul 30, 2018
tools Added option 'auto' into panel of platforms as an automatic configuri… Sep 15, 2018
.gitignore +ConfVersion Oct 29, 2016
.gitmodules Added hMSBuild project as an git submodule. Jul 30, 2018
.release.version Public final v1.6 release of the .NET DllExport: Dec 29, 2017
.version Public release of the .NET DllExport v1.6.1 Aug 5, 2018
.vssbe Fixed support of the special symbols in path: ' &!~`@#$^(+)_=%-;. Rel… Dec 8, 2018
3rd-party.txt Public beta3 release of the .NET DllExport - v1.6-beta3: Oct 27, 2017
DllExport.sln Pack of fixes for manager. New structure and tests: Nov 24, 2018
LICENSE Updated License header Jan 5, 2018
Readme.md Fixed MSB3073 for paths with `%` and `;` and avoids problem when argu… Nov 23, 2018
build.bat Added batch installer, Based on hMSBuild logic and includes GetNuTool… Jul 30, 2017
build_coreclr_x86.cmd added coreclr + updated build scripts Oct 30, 2016
build_coreclr_x86_x64.cmd added coreclr + updated build scripts Oct 30, 2016
changelog.txt Public release of the .NET DllExport v1.6.1 Aug 5, 2018
packages.config Updated GetNuTool v1.6 & ILAsm v4.5.1.1 (Package #2) Mar 6, 2017
packages_restore.cmd MvsSln project has been added as an git submodule for more convenient… Jul 14, 2018
submodules.bat Added hMSBuild project as an git submodule. Jul 30, 2018

Readme.md

DllExport

.NET DllExport

Copyright (c) 2009-2015  Robert Giesecke
Copyright (c) 2016-2018  Denis Kuzmin <entry.reg@gmail.com> :: github.com/3F

Build status Latest-Release License NuGet package coreclr_ILAsm GetNuTool core MvsSln Conari

DllExport -action Configure [?]

1:[ Quick start ] 2:[ Basic examples for C++ and C# ] 3:[ Complex types and Strings ] -> { 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 code/libraries (binding between .NET and unmanaged native C/C++ etc.), see Conari
  • If you need convenient work with Lua (5.1, 5.2, 5.3, ...), see LunaRoad
[DllExport("Init", CallingConvention.Cdecl)]
// __cdecl is the default calling convention for our library as and for C and C++ programs
[DllExport(CallingConvention.StdCall)]
[DllExport("MyFunc")]
[DllExport]

Support of Modules: Library (.dll) and Executable (.exe) [?]

Where to look ? v1.2+ provides dynamic definitions of namespaces (ddNS feature), thus you can use what you need - details here

    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..........  <<<-

Our Wizard and embeddable manager:

DllExport.bat

youtube.com/watch?v=sBWt-KdQtoc PeViewer


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)

&_

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 explanations from here: about mscoree; DllMain & the export-table; DllExport.dll; .exp & .lib; ordinals ...

How to get DllExport

v1.6+ have no official support of NuGet clients. [?]

Get our manager from any place. For example, you can still get it from packages via NuGet server (how to) or it also can be embedded inside any other your scripts/project files/etc.

DllExport.bat was based on GetNuTool core that's Cross-Platform Embeddable Package Manager that requires only MSBuild. Finally it just aggregates calling to Wizard that was based on MvsSln. [?]

Please note: You do not need to call manually DllExport.bat after initial configuration. It will be automatically restored by any Build operation for your configured projects.

[ Please read the documentation. ]

Other way:

  • gnt /p:ngpackages="DllExport" [?]
    • GetNuTool: msbuild gnt.core /p:ngpackages="DllExport" or gnt /p:ngpackages="DllExport"
  • (deprecated) NuGet PM: Install-Package DllExport
  • (deprecated) NuGet Commandline: nuget install DllExport
  • /releases [ latest stable ]
  • Nightly builds (/artifacts page). But remember: It can be unstable or not work at all. Use this for tests of latest changes.

How to Build

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. So 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 use our custom versions on coreclr, special for DllExport project - https://github.com/3F/coreclr

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

To build minimal version (means that it does 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
build_s x86 Release

or use

build_coreclr_x86.cmd
build_coreclr_x86_x64.cmd

You can also use our binaries of coreclr separately if needed:

Donation

Please note again, the initial UnmanagedExports was created by Robert Giesecke. You should visit its page if you need.

But this repository does not related with Robert and generally still being developed by github.com/3F developer (Follow: [GitHub]; [G+]). So if you think that our improvements, fixes, other changes, support, information, I don't know... if something are helpful for you from this, donations are welcome, and thanks !

Donate ( github.com/3F )