Hello Charles
In a old topic from o2 forum you said:
In Oxygen:Quoteexe=getfile "C:\minGUI.exe"
src=getfile "C:\CaptionString.abp"
putfile "C:\MRuntime.exe",exe+src
So let say if my exe file is 1000 bytes in size
then my string binded file code file must start from 1001 that
final exe is continued....right?
That part is fine :
But then how i can load that binded file from 1001 location from the final exe?
Hi Aurel,
The easiest way: (ok for files up to around 20 meg)
string s=getfile("C:\MRuntime.exe")
string src=mid(s,1001)
Thanks Charles
This looks almost to simple to be true
so runtime exe call string from himself hmm
ok i will try just to see is possible on that way
ok
Yes, this is a much simplified way of handling files. Otherwise there is always fopen .. fclose
Hello Charles ..and others of course..
I finally find some time to try to rebuild this Binder program.
I can say that Binding work ...
here is my prog:
$ filename "Bind32.exe"
uses RTL32
' embedfile "t.txt",d
' byte exef,srcf
exef = getfile "C:\GUIApp.exe"
print len(exef) + " bytes"
srcf = getfile "C:\mySrc.txt"
print len(srcf) + " bytes"
putfile "C:\MyRuntime.exe",exef + srcf
print "OK..." + len exef + srcf
and here is simple GUI program with one button
which should trigg or better to say load binded string from the end of exe .
Binded string is just ordinary .txt file called mySrc.txt which contain text ---> "Aurel"
so i tried to load with your suggested method
case b1ID 'open file
if notifycode=0
'call our binded string ....
sf = getfile("C:\GUIApp.exe")
src = mid(sf,22528,5) '22528 + 1 ..add LEN of src
print strptr src
end if
when i try it without strptr then i get nothing in message box
when i use strptr then i get adress ( number)
so my question is how to get it as string text ?
here is code of GUI app
'test GUI app as runtime to call binded string from himself
$ filename "GUIApp.exe"
include "rtl32.inc" : include "awinh037.inc" : #lookahead
'globals
INT win,x=0,y=0,w=400,h=300,wstyle = WS_MINMAXSIZE
INT button1, b1ID = 100
STRING sf ' src file
STRING src ' source str
' open window
win = SetWindow("Skeleton GUI 038 App...",x,y,w,h,0,wstyle)
'create button control
SetButton(win ,10,40,100,32,"Call String ?",0x50001000,0x200,b1ID)
Wait() '/// message loop function ///
Function WndProc(sys hwnd,wmsg,wparam,lparam) as sys callback
win = hwnd 'assign WIN with HWND
SELECT hwnd
CASE win
Select wmsg
'case WM_CREATE
'button1 = SetButton(win,10,40,80,26,"Call string ...",0x50001000,0x200,b1ID)
case WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
select controlID
'...................................................
case b1ID 'open file
if notifycode=0
'call our binded string ....
sf = getfile("C:\GUIApp.exe")
src = mid(sf,22528,5) '22528 + 1 ..add LEN of src
print strptr src
end if
'...................................................
end select
CASE WM_CLOSE
CloseWindow(win)
EndProgram
End Select
END SELECT
RETURN Default
END FUNCTION
Well...this method ..if work can be used for so many things like config inside .exe or similar..
thnx
Hi Aurel,
EmbedFile allows files to be embedded as bstrings at compile-time. (Up to 255 of them):
bstring dat 'must be global
embedfile "t.txt",dat 'must be global
...
print left(dat,100)
print len(dat)
Hi Charles
First thanks for reply !
Yes i know and tried embedfile function
( ..and i will try again)
but embedfile not work with .exe files ....
or i am doing something wrong
you say:
bstring d ' as global ....Ok
but this bstring cannot hold or i cannot load executable in it with getfile
when i tried that
bstring d
d = getfile("C:\myExe.exe")
'and then
embedfile "C:\mytext.txt" , d
then i get broken executable ??
Charles
The first method connecting two files work :
$ filename "Bind32.exe"
uses RTL32
' embedfile "t.txt",d
' byte exef,srcf
exef = getfile "C:\GUIApp.exe"
print len(exef) + " bytes"
srcf = getfile "C:\mySrc.txt"
print len(srcf) + " bytes"
putfile "C:\MyRuntime.exe",exef + srcf
print "OK..." + len exef + srcf
but when i try to call then i get nothing with mid(s,pos,len)
'call our binded string ....
sf = getfile("C:\GUIApp.exe")
src = mid(sf,22529,2) '22528 + 1 ..add LEN of src
int p at strptr src
print strptr p
As you see i even tried with byte p at strptr s method but still i get just a address only.
Charles sorry if i bothering you with all this things ...
In fact i triead again all examples in hope that i will find some interesting file operation but i simply cannot found
anything useful for me in this case .
Do you maybe have ,you probably know i guess
How load .exe file into memory buffer ...or any file to memory buffer then
connect this two files in memory like
memBuff1 = getfile ("myExe-exe")
memBuff2 = getfile ("myText.txt")
outBuff = memBuff1 + memBuff2
putfile ("C:\NewExe.exe"),outBuff
So how to do that ?...I simply dont know how to use memory commands in o2
thanks
Ok. I suggest recording the length of the original exe file in a separate (.cfg) file. This figure will always give the correct position especially when working with different versions of the exe.
'embedder
string memBuff1 = getfile ("o.exe")
string memBuff2 = getfile ("t.txt")
string outBuff = memBuff1 + memBuff2
putfile ("ot.exe",outBuff)
'putfile ("ot.exe",memBuff1 + memBuff2) 'also works
putfile ("ot.cfg",str(len(membuff1)) ) 'save length of t.exe
...
'recover embedded data from ot.exe
string s=getfile("ot.exe")
int lo=val(getfile("ot.cfg"))
string d=mid(s,lo+1,200)
print d
Hi Charles
Thank you very much for that ...
I know that must work somehow ...but i cannot figure it...
This config file is good idea !! cool
Ok i will test it and tell you how work. :)
PS..Do you watch small video about o2 ..
I am not very good on making videos ...but next time...
i will prepare folder with better examples
all best
Aurel
Hi Charles
I tested and little modify main or original exe that know
to check his own final size and with simple calculation find len of source.
It looks that work well... :)
'embedder
$ filename "CHembedder.exe"
string memBuff1 = getfile ("GUIApp.exe")
string memBuff2 = getfile ("mySrc.txt")
string outBuff = memBuff1 + memBuff2
putfile ("C:\NewApp.exe",outBuff)
'putfile ("ot.exe",memBuff1 + memBuff2) 'also works
putfile ("ot.cfg",str(len(membuff1)) ) 'save length of t.exe
...
'recover embedded data from ot.exe
string s=getfile("C:\NewApp.exe")
int lo=val(getfile("ot.cfg"))
string d=mid(s,lo+1,200) '22528 + 1 /lo + 1
print d
testing app in which we embed file :
'test GUI app as runtime to call binded string from himself
$ filename "GUIApp.exe"
include "rtl32.inc"
include "awinh037.inc"
#lookahead
'globals
INT win,x=0,y=0,w=400,h=300,wstyle = WS_MINMAXSIZE
INT button1, b1ID = 100, fsize,loc = 23040, srclen
STRING ef ' src file
string src
' open window
win = SetWindow("New App GUI 039...",x,y,w,h,0,wstyle)
'create button control
SetButton(win ,10,40,100,32,"Call String ?",0x50001000,0x200,b1ID)
Wait() '/// message loop function ///
Function WndProc(sys hwnd,wmsg,wparam,lparam) as sys callback
win = hwnd 'assign WIN with HWND
SELECT hwnd
CASE win
Select wmsg
'case WM_CREATE
'button1 = SetButton(win,10,40,80,26,"Call string ...",0x50001000,0x200,b1ID)
case WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
select controlID
'...................................................
case b1ID 'open file
if notifycode=0
'call our binded string ....
ef = getfile("C:\NewApp.exe")
fsize = len(getfile("C:\NewApp.exe"))
'22528 + 1 ..add LEN of src 255 is size of this buffer 22533
print "EXE SIZE : " + str(fsize)
srcLen = fsize - loc
print "source len: " + str(srclen)
src = mid(ef, loc+1, srclen)
print src
'recover embedded data from ot.exe
'string s=getfile("ot.exe")
'int lo=val(getfile("ot.cfg"))
'string d=mid(s,lo+1,200)
end if
'...................................................
end select
CASE WM_CLOSE
CloseWindow(win)
EndProgram
End Select
END SELECT
RETURN Default
END FUNCTION