Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork143
.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
License
3F/DllExport
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
.NET DllExport with .NET Core support (aka3F/DllExport akaDllExport.bat)
[DllExport("Init",CallingConvention.Cdecl)][DllExport(CallingConvention.StdCall)]// Cdecl is the default calling convention in .NET DllExport[DllExport("MyFunc")][DllExport]
Based onUnmanagedExports that was created by Robert Giesecke. Hispage.
.NET DllExport is adifferent project that was developed by Denis Kuzmin 「 ☕ 」
Copyright (c) 2009-2015 Robert GieseckeCopyright (c) 2016-2025 Denis Kuzmin <x-3F@outlook.com> github/3F[Quick start ] [Examples: C++, C#, Java, ... ]-> {Wiki } {🧪 Demo }
Example of using DllExport +Conari:
[DllExport]// DllExportModifiedClassLibrary.dllpublicstaticIntPtrcallme(TCharPtrstr,IntPtrstructure){if(str!="Hello world!")returnIntPtr.Zero;structure.Native().f<int>("x","y").build(outdynamicv);if(v.x>v.y){structure.Access().write<int>(8);}returnnewNativeArray<int>(-1,v.x,1,v.y);}
...// host side via C/C++, Java, Rust, Python, ... or even same dotnet C#usingNativeString<TCharPtr>ns=new("Hello world!");usingNativeStruct<Arg>nstruct=new(newArg(){x=7,y=5});usingdynamicl=newConariX("DllExportModifiedClassLibrary.dll");IntPtrptr=l.callme<IntPtr>(ns,nstruct);usingNativeArray<int>nr=new(4,ptr);// (nstruct.Data.x == 8) != (nr[1] == 7)
For Lua, consider usingLuNari
[DllExport]publicstaticintentrypoint(IntPtrL){usingLua<ILua53>lua=new("Lua.dll"); ...lua.pushcclosure(L,onProc,0);lua.setglobal(L,"onKeyDown");LuaNumbernum=lua.tonumber<LuaNumber>(L,7); ...}
.NET DllExport supports both Library (.dll) and Executable (.exe) PE modules.
Current features has been implemented throughILDasm &ILAsm that prepares all the necessary steps via.export directive (it's part of the ILAsm compiler,not CLR).
What inside ? how does work the .export directive ?
Read about format PE32/PE32+, start with grammar from asmparse and move to writer:
...//yaccif(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)HRESULTAssembler::CreateExportDirectory() {... IMAGE_EXPORT_DIRECTORY exportDirIDD; DWORD exportDirDataSize; BYTE *exportDirData; EATEntry *pEATE;unsigned i, L, ordBase =0xFFFFFFFF, Ldllname; ... ~ now we're ready to miracles ~ vtfxup thunk stubs and ~...
Read also my brief explanations here:AssemblyRef encoding /about mscoree /DllMain & the export-table /DllExport.dll /ordinals ...
Does DllExport support NuGet ?
Most likelyyes. But NuGet features arenot guaranteed (tl;dr something may not work or not work properly)
Use directlylatest stableDllExport.bat (~28 KB). ReadWiki
- Get it fromGitHub Releases. Or link to latest stable:https://3F.github.io/DllExport/releases/latest/manager/
- Or from
Visual Studio Package Manager can still distribute and activateDllExport.bat for solution folder in most default setup cases.
- Or useembeddable package managerGetNuTool
Read [Documentation ]
git clone https://github.com/3F/DllExport.git DllExportcd DllExportCallbuild.bat to build final binaries likeDllExport.<version>.nupkg, Manager, tests, zip-archives, and related:
.\build Release
Note, this relies onvsSolutionBuildEvent scriptingif you're using Visual StudioIDE.
We're using3F's modified versions specially for.NET DllExport project
This helps to avoid some problemslike this, orthis, and more ...
To build minimal version:
.\build # ilasm -x64
Make sure you have installedCMake before build.
To build assembler and use exactly this compiled version withDllExport, command like:
.\build # ilasm -x64& .\build ReleaseAlternatively you can get official compiled versions via
Or like:
.tools\gnt ILAsm& .\build ReleaseAbout
.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.

