#Include Once "MemoryModule/libMemoryModule.bi"
' Created by v1ctor's bin2bas, original Source of
' the dll found in "TestDll_src.bas"
#Include Once "TestDll.bas"
Dim As HMEMORYMODULE hDll
Dim As Integer iRval
' Prototype of the Procedure
Dim zStrPrint As Function Cdecl (zStr As ZString ptr) As Integer
' LoadLibrary
hDll = MemoryLoadLibrary(@TestDll_data(0))
If hDll = 0 Then
Print "Error in MemoryLoadLibrary() Call"
Sleep : System(1)
EndIf
' GetProcAddress
zStrPrint = MemoryGetProcAddress(hDll,"szStringPrint")
If zStrPrint = 0 Then
Print "Error in MemoryGetProcAddress() Call"
Sleep : System(1)
EndIf
' Call It
iRval = zStrPrint(StrPtr("Test It")) ' Displays the zString and
Print "iRval =";iRval ' returns the len() of it
' FreeLibrary
MemoryFreeLibrary(hDll)
Sleep
The static lib and everything needed to build the example can be
found in this archive (MemMod.zip).
Happy studying :)
Last edited by piccaso on May 08, 2007 17:35, edited 1 time in total.
I compiled the memory lib loader self as a library
but this version will work only with realy simple types of DLL's
and with a short number of exported function.
if i use any COM interfaces in the dll MemoryLoadLibrary will crash.
same with your static version.
by the way the COM interfaces as file library loaded with
DyLibLoad() works without any trouble.
since the os isnt aware of the module there are many things can that go wrong.
Like the HINSTANCE passed to DllMain is just an address in memory and windows' api's dont know what to do with it...
And there is no magic inside so COM will never work with this :)
but there are some alternatives you could try: Virtual PE - the example is for loading exe's but look inseide the zip... Dll to Lib - not free but supports COM
piccaso wrote:since the os isnt aware of the module there are many things can that go wrong.
Like the HINSTANCE passed to DllMain is just an address in memory and windows' api's dont know what to do with it...
And there is no magic inside so COM will never work with this :)
Yeah, but this lib is more for "Quick and dirty" implementations, nothing complex, but as long as you know what you're doing all should go well.. ;)