Can an exe export functions same as a dll?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Can an exe export functions same as a dll?
the situation:
app1 load dll1
app1 call's dll1->doanything
dll1 start app2
dll1 call's app2->ScreenRes w,h
app1 call's dll1->getValueFromUser
dll1 return(app2->getValueFromWindow))
...
...
app1 call's dll1->Deactivate
dll1 call's app2->CloseWindowAndExit
app1 freedll(dll1)
is it posible?
thanx for infos
Joshy
app1 load dll1
app1 call's dll1->doanything
dll1 start app2
dll1 call's app2->ScreenRes w,h
app1 call's dll1->getValueFromUser
dll1 return(app2->getValueFromWindow))
...
...
app1 call's dll1->Deactivate
dll1 call's app2->CloseWindowAndExit
app1 freedll(dll1)
is it posible?
thanx for infos
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Can an exe export functions same as a dll?
Ok, wait a minute... how is supposed dll1 will start app2?D.J.Peters wrote:the situation:
app1 load dll1
app1 call's dll1->doanything
dll1 start app2
dll1 call's app2->ScreenRes w,h
AFAIk, exporting functions in executables and loading them with DyLibLoad + DyLibSymbol works.
Maybe you need to establish some API/Plugin interface to support the RPC you're looking for.
This loads an exe dynamically and calls a function in it. I think the exe could determine how it was loaded if it had a functional DLL entry point function, but using DyLibLoad I have never found a way to do that, even for a DLL.
app1.bas:
app2.bas:
app1.bas:
Code: Select all
dim target as function( byval arg as integer ) as integer
dim hndl as any ptr
hndl = dylibload( "app2.exe" )
print hex( hndl )
target = dylibsymbol( hndl, "target" )
print hex( target )
print target( 1 )
print target( 123 )
dylibfree hndl
sleep
Code: Select all
function target alias "target" (byval arg as integer) as integer export
return arg + 1
end function
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
the key is dylibload("the.exe")
i was thinking it's only for *.dll's
by the way i write an plugin for TrueSpace 3.2 (the free version)
and the plugin is simple a renamed plugin.dll plugin.tsx
but if you create a dll you can't link to fbgfx but i need
screenres so i must call a exe from the plugin dll.
or exist a way to use screenres inside a DLL?
thanx Joshy
i was thinking it's only for *.dll's
by the way i write an plugin for TrueSpace 3.2 (the free version)
and the plugin is simple a renamed plugin.dll plugin.tsx
but if you create a dll you can't link to fbgfx but i need
screenres so i must call a exe from the plugin dll.
or exist a way to use screenres inside a DLL?
thanx Joshy
For LoadLibrary and LoadLibraryEx Microsoft clearly states that the executable module can be a DLL or an EXE. If a FB EXE exports a function, then a base relocation table is included in the EXE and Windows will relocate ("rebase") it as necessary. For the code above, both modules have the same image base, 400000h. The module handle returned by DyLibLoad, which is usually the base address of the module, and the procedure address returned by DyLibSymbol, which is always an address in the module, show that the loaded module has been rebased.
Maybe you have problem with name mangling or what. FB is not in reality very windows friendly regarding function exports. Download DependencyWalker open your EXE, with that you can check what functions got exported and how. DLL, SYS, OCX, ACM, SCR or EXE have the same PE file format on windows. If you use CreateProcess you can give it name even BLAH and it will got loaded and linked correctly.
At least Half-Life-s 1.1.1.0 EXE exports VGUI methods as MSVC++ mangled names and it seems to work. Check it using Dependency walker and get the idea.
At least Half-Life-s 1.1.1.0 EXE exports VGUI methods as MSVC++ mangled names and it seems to work. Check it using Dependency walker and get the idea.