IonicWind Software

IWBasic => General Questions => Topic started by: zaphod on December 25, 2009, 02:44:02 AM

Title: DLL in memory
Post by: zaphod on December 25, 2009, 02:44:02 AM
Hello all, and merry christmas from France !

My problem : i want to include a dll into my program and use dll functions.
I think of include dll in resource rcdata but after...

Second question : is it possible to use obj files (like minilzo.obj) ?

thanx for any help...
Title: Re: DLL in memory
Post by: Copex on December 25, 2009, 08:21:05 AM

this may help http://www.ionicwind.com/forums/index.php/topic,1361.msg12771.html#msg12771
Title: Re: DLL in memory
Post by: zaphod on December 25, 2009, 09:22:22 AM
Thanx Copex for help.

Not easy but it works.
I look if its possible with obj files.

Thanx again.
Title: Re: DLL in memory
Post by: sapero on December 25, 2009, 10:05:13 AM
Zaphod, loading a .obj file is not so easy as loading dll from memory, because .obj file may import symbols not exported from dll's, and there is no info from which module a symbol is imported. Really, you'll need a mini-linker to load object files, and a function names table.
If you wish to use only data stored in object files, then this will be no problem. But to call code from .obj files when if the object file is importing symbols, then I think, the easiest way to "link" it would be using dbghelp.dll to translate function names to function addresses or offsets.
Title: Re: DLL in memory
Post by: zaphod on December 25, 2009, 11:08:23 AM
Sapero, thanx for explanation.
Too difficult for me.

I give an example of use obj files in purebasic :


ImportC "minilzo.obj"
lzo1x_1_compress(*Source.l, SourceLength.l, *Dest.l, DestLength.l,*WorkMem.l)
lzo1x_decompress(*Source.l, SourceLength.l, *Dest.l, DestLength.l, *WorkMem.l)
lzo1x_decompress_safe(*Source.l, SourceLength.l, *Dest.l, DestLength.l,*WorkMem.l)
lzo_adler32(Adler.l, *Buf.l, Len.l)
;
lzo_version()
lzo_version_string()
lzo_version_date()
EndImport

Title: Re: DLL in memory
Post by: sapero on December 25, 2009, 12:32:06 PM
In ebasic just replace ImportC with $use, or add your .obj file to project. An obj file has the same format as .o file.