The basis of this article is to demonstrate a way of including other files within you're executable without corruption (too much anyway ;).
The basics:
The reason this is so simple is you can append data to the end of you're executable file, along with delimiters you could append files, their privilages, even an entire directory tree with compression and encryption.
Some code:
to add a file to you're executable
public function AddFile(ExecPath as string, FileToAdd_Path as string, Result as string)
dim TMP as string
open execpath for binary access read as #1
tmp = input(lof(1),1)
close #1
tmp = tmp & "[START]"
open filetoadd_path for binary access read as #1
tmp = tmp & input(lof(1),1)
close #1
open Result for binary access write as #1
put #1,1, tmp
close #1
end function
Code to put inside you're executable to enable extraction of the file.
public function ExtractFile()
dim TMP as string
open app.path & "\" & app.exename & ".exe" for binary access read as #1
tmp = input(lof(1),1)
close #1
tmp = mid(tmp, instr(tmp, "[START]") + 7, len(tmp))
open app.path & "\" & app.exename & "-Extracted.exe" for binary access write as #1
put #1,1, tmp
close #1
end function
This will cause the executable to open and read its contents into the TMP variable, it will then parse all data after the string "[START]" and output that to a file, this is our extracted data, ofcourse its only one file with no compression/encryption and the extraction could be improved by only reading the data from the end of the executable and not the entire thing, but im sure you grasp the idea.
Executable Map:
[Extractor]
[Extractor's Code]
[End of Extractor]
[COMPRESSION + ENCRYPTION START]
[START1]
[Test.TXT]
[Test.TXT's contents]
[PRIVS]
[777]
[START2]
[Whatever.exe]
[Whatever.exe's Contents]
[PRIVS]
[755] |