Export function name character name

I have a D DLL loaded by a C ++ program that I have no control over. The LoadLibrarys program is my DLL and uses GetProcAddress to search for a function called "extension_load" that takes one argument (pointer). In my D DLL, I have:

extern (C) int extension_load(void* ptr) {
    return 0;
}

And this name needs to be exported as extension_load, but it is exported as extension_load @ 4, so GetProcAddress cannot find it. How to make this simple extension_load without changing the name?

+3
source share
3 answers

.def, . Docs , .

+5

Hans Passant. .def , (, ):

EXETYPE NT

EXPORTS
    extension_load
    DllMain

.def, , dll.def. , :

extern (C++) int extension_load(void* ptr) {

IDE - D-IDE, , def, Project > Properties > Build Options

nameofdef.def

" ". , nameofdef.def D-IDE.

+4

def. export, :

    export extern (C) int extension_load(void* ptr) {
    return 0;
}

: dmd -ofmydll.dll mydll.d. , DllMain().

+1

Source: https://habr.com/ru/post/1779858/


All Articles