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
Thanks,
_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
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
If you want export many functions, you can use a .DEF file. You add in the .DEF file:
And in the command line to link:
link /DLL /SUBSYSTEM:WINDOWS /DEF:DEF_name program_name.obj
EXPORTS Function_Name1
Function_Name2
...
Function_NameN
And in the command line to link:
link /DLL /SUBSYSTEM:WINDOWS /DEF:DEF_name program_name.obj
Or much simpler to define visibility in proc declaration.
Expoprted proc EXPORT
ret
Expoprted endp
Would it be used the same way as a dll? Would it be linked the same way? or linked at all?
Thanks,
_Shawn
Thanks,
_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.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.
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.