I know that DLLs export functions... I also know EXE's do, just look at the ntoskernel.exe and others... COM EXE's can do it... how do I create my own EXE that can export functions that can be linked to and called, how do I call them?


Thanks,
_Shawn
Posted on 2002-11-01 02:12:42 by _Shawn
Hey Shawn,
you can export it by using the /EXPORT switch in the linker.
so with code like this

.586

.model flat, stdcall

include d:\masm32\include\windows.inc
include d:\masm32\include\kernel32.inc

includelib d:\masm32\lib\kernel32.lib

.data


.code

start:


invoke ExitProcess, eax

Exe_Export proc

ret
Exe_Export endp


end start

just do ml /c /coff /Cp file.asm
then link /SUBSYSTEM:WINDOWS /EXPORT:Exe_Export file.obj


this will also create a l.lib and .exp file that can be included in a project and use them like
you would a dll. you could also use loadlibrary and getprocaddress as well.
i can give you a working project if you would like.

hope this helps
take care
prs
Posted on 2002-11-01 03:33:41 by prs
If you want export many functions, you can use a .DEF file. You add in the .DEF file:


EXPORTS Function_Name1
Function_Name2
...
Function_NameN

And in the command line to link:
link /DLL /SUBSYSTEM:WINDOWS /DEF:DEF_name program_name.obj
Posted on 2002-11-02 00:27:09 by n u M I T_o r
Or much simpler to define visibility in proc declaration.

Expoprted proc EXPORT

ret
Expoprted endp
Posted on 2002-11-02 02:34:44 by Four-F
Would it be used the same way as a dll? Would it be linked the same way? or linked at all?


Thanks,
_Shawn
Posted on 2002-11-02 04:07:22 by _Shawn
Would it be used the same way as a dll? Would it be linked the same way? or linked at all?
Of course it will. The way is the same.
Posted on 2002-11-02 07:40:01 by Four-F
Sorry, but I wrote incorrectly the command line to link .EXE files with export functions :(

I wrote:
link /DLL /SUBSYSTEM:WINDOWS /DEF:DEF_name program_name.obj

But this will produce a DLL file because I'm including the /DLL switch. So,
would be:

link /SUBSYSTEM:WINDOWS /DEF:DEF_name program_name.obj

If you use a .DEF file, you must include the /DEF:FILENAME option.
Posted on 2002-11-02 11:20:03 by n u M I T_o r