Page 1 of 1

"AppendData" command to append data to end of exe

Posted: Wed Apr 16, 2008 6:48 am
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

Posted: Wed Apr 16, 2008 11:33 am
by DoubleDutch
It would be *very* handy. :)

Posted: Wed Apr 16, 2008 4:20 pm
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

Posted: Wed Apr 16, 2008 6:01 pm
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.

Posted: Wed Apr 16, 2008 6:19 pm
by DoubleDutch
It would be very good if this was a built-in system.

Posted: Wed Apr 16, 2008 6:22 pm
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.

Posted: Wed Apr 23, 2008 8:57 am
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.

Posted: Wed Apr 23, 2008 9:05 am
by ts-soft
FileSeek Lof(0) - AppendDatalength !
I hope you can with this info write your own code :wink:

Posted: Wed Apr 23, 2008 9:24 am
by GG
Appenddatalength ? Where does it come from ? Sorry for my movice questions... :oops:

Posted: Wed Apr 23, 2008 9:29 am
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.

Posted: Wed Apr 23, 2008 9:33 am
by GG
Right, I'll try this, thanks a lot for your help and replies.

Posted: Wed Apr 23, 2008 10:43 am
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.

Posted: Wed Apr 23, 2008 2:07 pm
by GG
Yes, thanks Doubledutch, I'll try DBin also.

Posted: Wed Apr 23, 2008 7:01 pm
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.

Posted: Wed Apr 23, 2008 7:29 pm
by DoubleDutch
Didn't know that - thats handy. :)