flat assembler
Message board for the users of flat assembler.

Index > Windows > [How?]MS COFF + dll export

Author
Thread Post new topic Reply to topic
roxaz



Joined: 27 Jul 2008
Posts: 25
roxaz
Im in need of exporting making dll export of function written in asm (MS COFF). Microsoft c++ compiler.. Idea was to make simpe function, declare it as public and export it using def file, however i get unresolved external saying that my function does not exist. How do i make dll export from MS COFF file and manually set ordinal for that export?
Post 18 Sep 2009, 19:58
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
Maybe your forgot to mangle a name of your function?
Code:
; foo.asm
        format  ms coff

public DllEntryPoint as '__DllMainCRTStartup@12'
public Foo as '_Foo@8'

DllEntryPoint:
        xor     eax,eax
        inc     eax
        retn    0x0c

Foo:
        mov     eax,[esp+0x04]
        add     eax,[esp+0x08]
        retn    0x08

; foo.def
LIBRARY FOO
EXPORTS
  Foo

; to link it:
link /DLL /DEF:foo.def foo.obj 
    


And here you can read about setting ordinals in def-files.
Post 20 Sep 2009, 05:17
View user's profile Send private message Reply with quote
roxaz



Joined: 27 Jul 2008
Posts: 25
roxaz
well yah i did not mangle names, thought i got to provide exact name in def file as it is in def..

EDIT:
question tho.. i still have to specify mangled name in def file, so why cant i have unmangled name and specify it in def file? My def is like this:
Code:
EXPORTS
    SysAllocString=___func__SysAllocString@0 @2
     
Post 20 Sep 2009, 07:49
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
You should have the same public name as you specify in .def file:
Code:
DEF: SysAllocaString @2
ASM: public SysAllocString

DEF: SysAllocaString=SysAllocString @2
ASM: public SysAllocString as 'SysAllocString' (any combinations)

DEF: SysAllocString=___func__SysAllocString@0 @2
ASM: public mySysAllocString as '___func__SysAllocString@0'
    
Post 20 Sep 2009, 18:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.