PackExeData()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

PackExeData()

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: PackExeData()

Post by ShadowStorm »

What's this ????
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: PackExeData()

Post 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.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: PackExeData()

Post 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. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
Thorium
Addict
Addict
Posts: 1271
Joined: Sat Aug 15, 2009 6:59 pm

Re: PackExeData()

Post 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.
Post Reply