News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Extract attached file

Started by DerCoder, March 21, 2012, 06:44:26 PM

Previous topic - Next topic

DerCoder

Hey guyz,

i come from C++ and i want to write a program in assembler, coz it's compiled much more smaller than C++ exes (using Dev C++).
Okay, now my problem: I want to write a program which has 2 operations
1) Start the program WITH a parameter (e.g. parameter: 'any_file.txt') and doing this, the program reads itself, write itself's content (the binary exe stuff) into a new file (packed program) and attach the content of 'any_file.txt' to the very end. Then at the end there is a '$' delemiter and then a number which stands for that point in the new created file, where the exe's content ends and the txt-file's content starts.
2) Start the program (this must be a packed program) WITHOUT a parameter and the program reads itselfes content backwards, so it extractes number where the exe ends (this number is behind the '$'). After reading this number, the program sets the file read ponter to that point and reads the stuff and write it into a new file, so the 'packed' content, which is saved in the packed exe in step 1) is going to be extracted.

I am glad, i did step 1 on my own, but i have problems with step 2 (the backward reading of a string). To read from/write into files i use the winapi commands and i try to use as less as asm-code as possible, because it is difficult to understand that code.

If you want to read the current code (step 1), just tell me that and imma upload the file.

Thx for your attention, DerCoder :))

Vortex

Hi DerCoder,

You can choose a much more easy and practical method. Why not to embed the .txt file ( or any other type of file ) into the main executable as a resource section \ binary data section?

The nested file can be specified in a resouce script or you can convert it to a linkable MS COFF object module.

unpacking res

Binary to MS COFF object file converter

Binary to resource file ( .res ) converter

how to exec exe file from resource

DerCoder

Hey Vortex,

thanks for your fast answer.
For sure, i could embed the file in ressource section, but i want to keep it dynamic. My plan is, to 'attach' another program (executable) or some batch-code.
Think about a 'batch-compiler': my program saves the content of the bat-file and when you run the program, it extracts the code again and then runs it.

It also should be widely applicable. So you give the (unpacked/clean) program to your friend, he knows, how to use it (via parameter) and voilá: he can create the packed exe ^^

Best regards, DerCoder

dedndave


BogdanOntanu

Locked, until you explain me the reason for such debatable actions :D
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro