Author Topic: Binder?  (Read 9503 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Binder?
« on: August 26, 2013, 08:31:22 AM »
Hi Charles...
I know how create binder in CB/EB but i am not sure how to do this in Oxygen.
As you know binder must add source file(in binary format) to already existing executable PE file.
so final exe must look like this:

finalEXE = exeFILE + sourceFILE

Do you have maybe something already created?
Or maybe you can show me how to do this?

JRS

  • Guest
Re: Binder?
« Reply #1 on: August 26, 2013, 08:46:17 AM »
Aurel,

ScriptBasic allows binding it's tokenized binary script to the end of the interpreter to create a standalone app. Take of look at the SB source to see how it's done.


Aurel

  • Guest
Re: Binder?
« Reply #2 on: August 26, 2013, 08:58:51 AM »
Ok John...i will
But i am in first place interested how to do this in Oxygen.. ;)

JRS

  • Guest
Re: Binder?
« Reply #3 on: August 26, 2013, 09:23:41 AM »
I don't understand why you would want to do this with a compiler as this is a way to give interpreters that standalone feel.



Aurel

  • Guest
Re: Binder?
« Reply #4 on: August 26, 2013, 09:49:42 AM »
And i don't understand your question at all ???
This is something what i need for my interpreter not for oxygen compiler...
do you get it now ?

JRS

  • Guest
Re: Binder?
« Reply #5 on: August 26, 2013, 10:23:49 AM »
Quote
do you get it now ?

Yes. Thanks for the clarification.

Quote
But i am in first place interested how to do this in Oxygen..

In SB before the command line is checked for it's options and program to run, it first looks to see if there is a binary SB script attached. If so it runs that script and ends otherwise it's standard scriba.
« Last Edit: August 26, 2013, 11:27:25 AM by JRS »

Charles Pegge

  • Guest
Re: Binder?
« Reply #6 on: August 26, 2013, 02:10:29 PM »
Hi Aurel,

You need to compile the interpreter/script engine with the script.

Something like this:

% filename "t.exe"
includepath "$/inc/"
include "RTL32.inc"

bstring src
includepath ""
embedfile src,"t.bas"

print src 'test

'include script engine here to interpret src string...


Alternatively, treat the script as a string resource, and use GoRc and Res2Exe to bind it to the script engine exe.
« Last Edit: August 26, 2013, 02:24:04 PM by Charles Pegge »

Aurel

  • Guest
Re: Binder?
« Reply #7 on: August 26, 2013, 08:40:02 PM »
Hmmm
Charles i will try your way but something is not like i say to you.
i need this:

'in folder ...folder1,already exists
runtime.exe
'and we must add src.txt file but in binary format

so do i need just
embedfile src,"t.exe"

 ???

In my work in EB i create two memory buffers and connect them into one memory buffer
then save this new memory buffer as final exe.
Do you can show me that way ?

JRS

  • Guest
Re: Binder?
« Reply #8 on: August 26, 2013, 08:55:41 PM »
Here is how it is done in SB.

Linux
Code: [Select]
jrs@laptop:~/sb/sb22/test$ cat hello.sb
PRINT "Hello World\n"

jrs@laptop:~/sb/sb22/test$ /home/jrs/sb/sb22/bin/scriba -Eo hello hello.sb
jrs@laptop:~/sb/sb22/test$ chmod 755 hello
jrs@laptop:~/sb/sb22/test$ ./hello
Hello World
jrs@laptop:~/sb/sb22/test$

Windows
Code: [Select]
C:\SB22\test>type hello.sb
PRINT "Hello World\n"

C:\SB22\test>scriba -Eo hello.exe hello.sb
C:\SB22\test>hello
Hello World
C:\SB22\test>

On my Windows XP VirtualBox, I have associated .sb with scriba.exe so anytime I click on a script it executes from the Windows explorer or the console without having to prefix it with scriba. Isn't that really the same thing as binding but without the bloat of the interpreter attached to each copy of your script?



« Last Edit: August 26, 2013, 11:31:00 PM by JRS »

Aurel

  • Guest
Re: Binder?
« Reply #9 on: August 26, 2013, 11:38:34 PM »
No is not ( i think)  that this is more like thinBasic binding is .
i use this method in Aurelbasic to bind source file on the end of runtime.exe

JRS

  • Guest
Re: Binder?
« Reply #10 on: August 27, 2013, 12:16:39 AM »
No, this is NOT like thinBasic which uses a utility to pack all the files into a self extracting exe. Like I said in the beginning, SB appends the binary/tokenized script to the end of the ScriptBasic interpreter and check if one is present before processing anything on the command line.

I can't make it any more simple than that!  ::)




Aurel

  • Guest
Re: Binder?
« Reply #11 on: August 27, 2013, 12:37:10 AM »
So then it is the same,right...
i think that i need some memory operation here like:

INT buff1,buff2,buffOut

'here is problem -> how load runtime.exe into memory buffer?
ef = Getfile "runtime.exe" ... or something like that ?
buff1 = getmemory bfile

JRS

  • Guest
Re: Binder?
« Reply #12 on: August 27, 2013, 12:45:21 AM »
Aurel,

You're making this much harder than it needs to be.

Create a utility that makes a copy of your interpreter and tags the tokenized script to it. Modify your interpreter on startup to check to see if a script has been appended. If so run it and end the program. The only difference between your standard interpreter and the standalone script is it's name is different and has a script attached.


Charles Pegge

  • Guest
Re: Binder?
« Reply #13 on: August 27, 2013, 12:46:07 AM »
You can embed any kinds of files into Oxygen and access them as bstring constants, text or binary. But it has to be compiled with the source of your runtime.

Aurel

  • Guest
Re: Binder?
« Reply #14 on: August 27, 2013, 01:16:05 AM »
Quote
Create a utility that makes a copy of your interpreter and tags the tokenized script to it. Modify your interpreter on startup to check to see if a script has been appended. If so run it and end the program. The only difference between your standard interpreter and the standalone script is it's name is different and has a script attached.

John...
This is what my binder written in EB do.

Charles
So from you,you mean that there is no need to use any memory allocation and getmemory functions.
And one thing is not clear to me how i can put binary file runtime.exe into bstring ???
Or i completelly don't undertand what you mean :-\