Page 1 of 1
PackExeData()
Posted: Sat Aug 22, 2020 4:10 pm
by J. Baker
PackExeData(Filename$, LabelStart$, LabelEnd$, File$)
Filename$ = Location of executable to want to pack data to.
LabelStart$ = Starting label name.
LabelEnd$ = Ending label name.
File$ = Location of the file (image, audio, text) to pack to the executables data section.
For creating software that creates software. You would have to run it more than once to pack multiple files to an already compiled exe.
Re: PackExeData()
Posted: Sat Aug 22, 2020 7:27 pm
by ShadowStorm
What's this ????
Re: PackExeData()
Posted: Sun Aug 23, 2020 3:50 am
by kenmo
I don't understand what you mean by Labels here.
The labels within your PB source code do not end up in your compiled executable. At least not as text. They end up as numeric memory offsets.
So how would this function know where to patch the executable??
A current solution might be:
Code: Select all
DataSection
Data.s "UniqueStartString" ; mark the beginning
MyFileStart:
Data.q 0, 0, 0, 0, 0, 0, 0 ; allocate some blank memory
MyFileEnd:
Data.s "UniqueEndString" ; mark the end
EndDataSection
Then your normal program can use the labels to read the data. And a patcher program can scan the executable for the unique Start/End strings and inject patch data between them.
Re: PackExeData()
Posted: Sun Aug 23, 2020 4:35 am
by J. Baker
You're correct. Labels are not text but we write them out that way in PureBasic itself. Then PureBasic takes care of that at compile. It's written as text, so to speak, in the procedure so we can at least give our data pointers to the data. Just like you do in PureBasic's editor.
As for knowing how to read the newly packed labels and data. You have to create a procedure in your exe that you will be packing. That procedure will read information from a text file, made from your "editor" app, that you also pack into that exe. You packed exe will of course need other procedures on what to do with the rest of the information from that packed text file on images, sound, etc, as well.
Software such as GameMaker and so forth have used this method for years. That's why I have requested it. It would be nice to make a program where you could also create your own exec's for games, screensavers, etc.
Hope that helps you understand.

Re: PackExeData()
Posted: Tue Nov 24, 2020 5:51 pm
by Thorium
I guess this would be not a normal procedure but a compiler directive and run at compile time.
I did something similar and wrote an archive to the end of the .exe and the length of the archive as the last few bytes in the .exe. On runtime the program could read the .exe length, the archive length from the end of the .exe and with that calculate the start position of the archive header and read the files. It's not exactly the same but you would use it for the same purpose.