Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DllExport from the command line compiler #28

Closed
Arno0x opened this issue Feb 23, 2017 · 3 comments
Closed

Using DllExport from the command line compiler #28

Arno0x opened this issue Feb 23, 2017 · 3 comments
Labels

Comments

@Arno0x
Copy link

Arno0x commented Feb 23, 2017

Hi,

I'm using DllExport Nuget package within Visual Studio and it works just great.

However, I was wondering how (if possible) to get the same result using only command line compiler such as csc.exe. Of course, I can add the /reference:path_to_dll_export.dll and the cs files will compile just fine, but the resulting DLL doesn't actually export any function. I guess that's because the DllExport magic happens after compilation by modifying the export section of the IL... (I barely understand this part).

So, does it sound feasible ?

Thanks,
Arno

@3F 3F added the question label Feb 23, 2017
@3F
Copy link
Owner

3F commented Feb 23, 2017

No.

DllExport.dll is only as a marker for your code and actually has no any logic at all.

This feature works via executable ILAsm (my version here) that contains special logic to prepare final PE file.

// logic of definition of records into EXPORT_DIRECTORY (see details from PE format)
HRESULT Assembler::CreateExportDirectory()  
{
...
    IMAGE_EXPORT_DIRECTORY  exportDirIDD;
...
    EATEntry               *pEATE;
    unsigned                i, L, ordBase = 0xFFFFFFFF, Ldllname;

where pEATE will contain list of your prepared methods like this:

for(WORD j = 0; (pMD = pClass->m_MethodList.PEEK(j)); j++)
{
...
    EATEntry* pEATE;
    /*
        struct	EATEntry
        {
            DWORD	dwStubRVA;
            DWORD	dwOrdinal;
            char*	szAlias;
        };    
    */
    ...
    m_EATList.PUSH(pEATE);

The DllExport only controls all these processes via MSBuild

What problem you're trying to solve ?

Use latest portable & embeddable gnt.bat (GetNuTool) if you need to get this manually via command-line:

gnt /p:ngpackages="DllExport"

etc.

side note.., from my msg:

the open #ilasm on #CoreCLR has a lot of restrictions and I also think about individual PE32/PE32+ tool at all, instead of IL Assembler.

@Arno0x
Copy link
Author

Arno0x commented Feb 23, 2017

Thanks for your answer.

The problem I'm trying to solve is simple: I like the fact that most of my published C# application/code can be compiled by anyone on Win7+ (any Windows OS with a decent .Net framework) without the need for VisualStudio. So I always provide with the csc.exe command line such that anyone can get its own compiled version of my app.

So it seems it's not feasible if I want to use DllExport functionalities ? Unless there's also a command line to trigger the whole work performed by DllExport on the PE file ?

@3F
Copy link
Owner

3F commented Feb 23, 2017

without the need for VisualStudio

DllExport is ready for CI ! and works with most popular build-servers like Teamcity, AppVeyor, etc.

So why you do not want to use msbuild for build your projects ?

if you still need to call it manually, see msbuild task here:

For direct modifications without DllExport: first you need to modify your IL code - how, you can look this repo.

@Arno0x Arno0x closed this as completed Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants