Author Topic: load library question  (Read 3866 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
load library question
« on: August 30, 2012, 04:30:24 AM »
hi charles, after having done some new updates for my "funbasic" project I have a question about load library. I have loaded for an example "oxygenbasic.dll" and got a "2" value as return. What does that meaning if that's not "0" (wrong), "1" (ok) and now "2" (I suggest overloaded..) ? "1" should be ok. do you have any tipp for me ? thank, best regards, frank

Charles Pegge

  • Guest
Re: load library question
« Reply #1 on: August 30, 2012, 05:04:21 AM »

Hi frank,

I don't know which compiler you are using but something like this:

dim li as long
li=LoadLibrary("Oxygen.dll")

print li '
The Library handle should be a large number (or 0 for fail)

Charles


Frankolinox

  • Guest
Re: load library question
« Reply #2 on: August 31, 2012, 12:33:31 AM »
oxygen example:

Code: [Select]
Declare Function LoadLibraryA Lib "KERNEL32.DLL" Alias "LoadLibraryA" ( _
   ByRef lpLibFileName As Asciiz _                      ' __in LPCSTR lpLibFileName
 ) As DWord                                             ' HMODULE

Dim RetValue As Long
print "test load library"
RetValue = LoadLibraryA("funbasic.dll") ' ("oxygen.dll")
print "RETURN CODE FROM LoadLib: " & Str$(RetValue)
' correct result for oxygen: 12713984
' correct result for powerbasic: 10551296
' if no DLL is found result is "0" (zero)

a) I am loading my funbasic.dll in oxygen, all is correct there. if there's no dll found or wrong name you will get a "0" return

b) it's strange: my "funbasic interpreter" returns value 2 when I was tried to load "oxygen.dll", not a large number like 12713984 (or other one). I am wondering why.
so I am asking myself if that's perhaps a wrong result, sorry, that case is entirely new for me ;) do you have an answer?

thanks, frank


X

Charles Pegge

  • Guest
Re: load library question
« Reply #3 on: August 31, 2012, 04:04:07 AM »

Hi Frank,

I would trace the value returned from LoadLibrary at each stage, (Using Msgbox/print) as it passes through your interpreter. This is how I do all my debugging if the problem is not apparent :)

Charles

Frankolinox

  • Guest
Re: load library question
« Reply #4 on: August 31, 2012, 05:55:54 AM »
Quote
trace the value returned from LoadLibrary at each stage,

thank you for that tipp charles, I will check if I find the problem :)

btw: for me it's important: do you think it's possible to create an exe/dll file with an basic "interpreter" without using a bundle method? I tried to convert (until today I've managed only circa 25 per cent asm code) your oxygen (hdrs) files for creating pe/coff files? I can see in source file you're using a text file for compiling, so that could be realized in same way as you did it for an interpreter too? what's your professional thinking about that one? thanks a lot if you can make some comments about this topic, best regards, frank

Charles Pegge

  • Guest
Re: load library question
« Reply #5 on: September 01, 2012, 01:12:14 AM »
You could bind the interpreted script into the interpreter program as a string resource. Not something I am familiar with, but most compiler packagage include a resource compiler for attaching resources to a precompiled EXE.

In Oxygen you could simply compile the interpreter, including the script as a string literal.
There is also a new command for embedding any file content into the program, and accessing it as a string or by using a pointer

bstring s 'read only
embedfile "source.txt",s


Code: OxygenBasic
  1. 'COMPILING TO INDEPENDENT EXECUTABLE
  2. '===================================
  3.  
  4. $ FileName "t.exe"
  5. 'include "..\..\inc\RTL64.inc" 'to compile 64bit
  6. 'include "..\..\inc\RTL32.inc" 'to compile 32bit
  7.  
  8.  
  9. 'EMBEDDED SOURCE CODE
  10. '====================
  11.  
  12. bstring s 'read only. do not free
  13. embedfile "source.txt",s
  14.  
  15. include "Interpreter.inc"
  16.  

Charles

JRS

  • Guest
Re: load library question
« Reply #6 on: September 01, 2012, 06:31:49 PM »
Quote
You could bind the interpreted script into the interpreter program as a string resource. Not something I am familiar with, ...

BTW: Thanks Charles for all your help over the years embedding ScriptBasic in multiple compilers including O2.


Charles Pegge

  • Guest
Re: load library question
« Reply #7 on: September 02, 2012, 12:42:47 PM »

Thanks John. In this case we are taking it a little further by embedding everything inside a single exe file.


JRS

  • Guest
Re: load library question
« Reply #8 on: September 02, 2012, 01:41:45 PM »
That may set off a few alarms with virus checkers unless the interpreter is started in another thread. A bit over the edge for me.



Aurel

  • Guest
Re: load library question
« Reply #9 on: September 02, 2012, 03:19:01 PM »
I don't know that we can do this on this way in Oxygen for now.
I am not sure where is this file embeded in existing exe file?
My method which i use is create source file as binary and then put (bind)
this file on the end of exe.
For example if we have exe long
1024 bytes ,source must be binded exactly starting at 1025 to hes size ,right?
This way i use in ABasic and there is no problem with antiviruses at all.

JRS

  • Guest
Re: load library question
« Reply #10 on: September 02, 2012, 06:54:40 PM »
ScriptBasic has an option to wrap the interpreter and it's script(s) into a standalone executable. (-E) Scriba always checks to see if there is code attached to the end and executes that rather then what may be passed on the command line to run.

« Last Edit: September 03, 2012, 12:57:45 AM by JRS »

Frankolinox

  • Guest
Re: load library question
« Reply #11 on: September 03, 2012, 02:04:26 AM »
thanks charles for your reply :)

a) with embedding here's no problem at all.

Code: [Select]
$ FileName "tfun.exe" 
'include "..\..\inc\RTL64.inc" 'to compile 64bit 
'include "..\..\inc\RTL32.inc" 'to compile 32bit 
'extern lib "funbasic.dll" 

library "funbasic.dll" 

include "funbasic.inc" 

dim as sys pProgram

'==================== 
'EMBEDDED SOURCE CODE 
'==================== 
 
bstring s 'read only. do not free 
'embedfile "source.txt",s 

embedfile "01-vlong.bas",s 
print s 

funbasic_run("01-vlong.bas",s)

print "ok!"


b) my idea was to create with oxygen a DLL where's to create an exe for my interpreter, something like a module, where I can load this feature to create exe/dll by loading this module from my "funbasic interpreter" project. but my knowledge about that is still low.

oxygen is very powerful and open for new adventures, I like that :) thanks. best regards, frank