• Stars
    star
    960
  • Rank 47,640 (Top 1.0 %)
  • Language
    C#
  • License
    MIT License
  • Created over 8 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

.NET DllExport

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

More Repositories

1

Conari

🧬 One-touch unmanaged memory, runtime dynamic use of the unmanaged native C/C++ in .NET world, related P/Invoke features, and …
C#
252
star
2

MvsSln

🧩 Customizable VisualStudio .sln parser with project support (.vcxproj, .csproj., …). Pluggable lightweight r/w handlers at runtime, and more …
C#
140
star
3

vsSolutionBuildEvent

πŸŽ› Event-Catcher with variety of advanced Actions to service projects, libraries, build processes, runtime environment of the Visual Studio, MSBuild Tools, and …
C#
78
star
4

aml_s905_uboot

u-boot DDR mods ~
C
67
star
5

LuNari

πŸ—¦πŸŒ” Lua for .NET :: Lua 5.4, 5.3, 5.2, 5.1, ...
C#
50
star
6

netfx4sdk

Developer Pack (SDK). NETFX 4: Visual Studio 2022 / MSBuild 17 / or other modern tools
Batchfile
38
star
7

GetNuTool

Embeddable Package Manager (+core in .bat); πŸ•Š Lightweight tool to Create or Distribute using basic shell scripts (no powershell no dotnet-cli)
Batchfile
29
star
8

Examples

An complete examples and related support for various popular projects, and more.
C++
28
star
9

regXwild

⏱ Superfast ^Advanced wildcards++? | Unique algorithms that was implemented on native unmanaged C++ but easily accessible in .NET via Conari (with caching of 0x29 opcodes +optimizations) etc.
C++
27
star
10

hMSBuild

.bat scripts with full Package Manager inside for searching and wrapping MSBuild tools. All Visual Studio and .NET Framework versions
Batchfile
20
star
11

vsCommandEvent

Extending Visual Studio on the fly via E-MSBuild, SobaScript, C#, ...
C#
19
star
12

IeXod

The most portable alternative to Microsoft.Build for evaluating, manipulating, and other progressive data processing in a compatible XML-like syntax
C#
16
star
13

Huid

🎫 High-speed a FNV-1a-128 hash-based UUID.
C#
16
star
14

7z.Libs

πŸ“¦πŸ“¦ πŸ—œ An automated build of the `7z.Libs` NuGet packages.
Batchfile
15
star
15

UnmanagedEmitCalli

A tiny hack of the System.Private.CoreLib to provide an Unmanaged EmitCalli implementation at the .NET Standard 2.0 layer.
C#
10
star
16

TmVTweaks

A variety of patches and tweaks for TeamViewer software such as a completely hidden ugly toolbar, screen fixes, hotkeys, etc.
C#
6
star
17

LX4Cnh

Algorithm for high-speed multiplication of LARGE numbers
C#
6
star
18

sandbox

:: β›± Experimental or incomplete components and libraries or tests for different languages, frameworks, components, platforms, etc.
C++
6
star
19

GhrMeter.user.js

πŸ“ŠπŸ“ˆ Displays statistics for attachments on GitHub Releases page
JavaScript
3
star
20

E-MSBuild

Advanced Evaluator of MSBuild scripts with user-variables support through Varhead and more
C#
3
star
21

Fnv1a128

FNV-1a γ€Œ 128-bit 」 High-Speed implementations πŸš€ using LX4Cnh etc.
C#
3
star
22

3F

2
star
23

SobaScript

Extensible Modular Scripting Programming Language -- #SobaScript
C#
2
star
24

CI.MSBuild.Demo

[Archived] Samples with native C++ and .NET (CLR) projects for work with CI.MSBuild / vsSolutionBuildEvent. Has been moved to here β†’: https://github.com/3F/Examples
C#
1
star
25

MoConTool

A variety of patches and tweaks for your favorite mouse.
C#
1
star
26

FlightSDCpp

FlightSDC++ project - client for Direct Connect protocol
C++
1
star
27

FlightSDC.RPC-WebSockets

RPC-WebSockets variant of flightSDC project - migrated from my public repository on Bitbucket
C++
1
star
28

N7z

[ planned ] 7-Zip file archiver for .NET via github.com/3F/Conari
Batchfile
1
star
29

3F.github.io

HTML
1
star
30

mos3sms-smsb

mos3sms - SMSb (plugin for moservices 3) - migrated from my public repository on Bitbucket
PHP
1
star
31

web.vsSBE

To support the vsSolutionBuildEvent / `_doc` folder has been imported from - bitbucket.org/3F/vssolutionbuildevent/wiki/
HTML
1
star
32

Jt

Extremely Small, Fast, and damn Customizable βš™ template engine on Native low-level implementation. / Mr. Jt / [ TypeScript & JavaScript ]
JavaScript
1
star