"AppendData" command to append data to end of exe

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

"AppendData" command to append data to end of exe

Post by Mistrel »

I would like to see a command similar to DataSection but have the data be appended to the end of the file instead of being placed inside the exe section, something like VBin_ or DBin_ but without the need to append after compilation.

This would alleviate problems like this:
http://www.purebasic.fr/english/viewtopic.php?t=31908

Here is a link to DoubleDutch's DBin_ code:
http://www.purebasic.fr/english/viewtopic.php?t=22037
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It would be *very* handy. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

Do you mean something like this?

Code: Select all

Procedure AppendData(ExeFile.s, DataFile.s) 
  ; (c) TS-Soft
  Protected File.l, Pack.l, Size.l, *mem 
  If OpenFile(0, ExeFile) 
    ReadFile(1, DataFile) 
    Size = Lof(1) 
    *mem = AllocateMemory(Size) 
    If *mem 
      ReadData(1, *mem, Size) 
      CloseFile(1) 
      FileSeek(0, Lof(File)) 
      WriteData(0, *mem, Size)
      WriteLong(0, Size)
      CloseFile(0) 
      FreeMemory(*mem) 
      ProcedureReturn #True 
    EndIf 
  EndIf 
  ProcedureReturn #False 
EndProcedure
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

it seems to me more like a hack just appending datas to an exe file.

Also, I think, the initial request was to access the datafile in the exe-file itself.
Tranquil
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It would be very good if this was a built-in system.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The idea is good.
If you use IncludeBinary, windows load allways the datas with the exe in
memory. Better is to solve this: Using Resources or Append Data.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Post by GG »

With AppenData, if you insert an exe into your exe file, how do you do to extract it from your exe ?

Example : I've got an exe which names install.exe. I want it to include program.exe. I use AppendData, that's OK.
Then I want to tell install.exe to "extract" program.exe from it. How do i do that ?

Thanks in advance.
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

FileSeek Lof(0) - AppendDatalength !
I hope you can with this info write your own code :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Post by GG »

Appenddatalength ? Where does it come from ? Sorry for my movice questions... :oops:
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The length of the datas you have append! or write the length after the datas
and read this first on the end of the file and then seek back.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Post by GG »

Right, I'll try this, thanks a lot for your help and replies.
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

GG: Why don't you just use DBin? If it doesn't do what you want then improve it and resubmit it to the forum.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Post by GG »

Yes, thanks Doubledutch, I'll try DBin also.
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

For those who are interested, it would appear that UPX does not compress appended data. UPX will only compress data found in the exe section.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Didn't know that - thats handy. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply