
  == MEA Exe Archive ==

If you are creating your own programs you can use this thingie to add some files 
to EXE file to avoid too-many-files mess. 
Adding and removing can be done easy by Unmass, using files by your program is easy too,
you need only some basic file-reading skills in your programming language.
To add files to exe file you have just to open exe file in Unmass and add files, thats all.

Exe archive consists of these parts:

-- start of file --
|                 |
   original exe
|                 |
- end of orig exe -
|                 |
   1st added file
|                 |
-------------------
|                 |
   2nd added file
|                 |
-------------------
|                 |
       .....
|                 |
-------------------
|                 |
     last file
|                 |
----- ====== ------
|                 |
  archive library
|                 |
----- ====== ------
|                 |
   archive info      
|                 |
--- end of file ---


Info header stored at the end of file is 20 bytes long and consists 
of these parts:

item name           offset   length  type
------------------------------------------
orig exe file size  eof-20   4      long
library offset      eof-16   4      long
files count         eof-12   4      long
file size           eof-8    4      long
ident               eof-4    4      "MEAF"


Files library precedes end-of-file ident header, there are records about
stored files. Original exe is stored in lib too, as 1st rec.
One library record is 72 bytes long. Nuber of records can be found 
in the ident-header. Offset of the library is also stored in the 
header as variable [library offset]

One library record:

item name           offset   length  type
------------------------------------------
name                0        64      ASCIZ
offset              64       4       long
size                68       4       long


That was the info, look for the source code at the end of document.
If you want to say me something, or you (dont)like something, mail me,
i'll be glad to see some responses.

My mail is mirex@centrum.sk


-------- c source code for reading contents of archive ----------

struct s_MeaHeader {
	unsigned long	orig_file_size;
	unsigned long	lib_offset;
	unsigned long	files_count;
	unsigned long	file_size;
	char			ident[4];
} MeaHeader;


#define MeaNameLen 64
#define SizeOfMeaRec 72

struct s_MeaRec {
	char			name[ MeaNameLen ];
	unsigned long	offset;
	unsigned long	size;
} MeaRec;       //len:72


// parameter is opened binary archive file
// returns 1 if file looks to be MEA archive, 0 if not
int ReadHeader( FILE *f )
{
	fseek( f, -20, SEEK_END );
	if ( fread( &MeaHeader, 1, 20, f ) != 20 )
		return 0;
	return ( memcmp( MeaHeader.ident, "MEAF", 4 ) == 0 );
}

// parameter is opened binary archive file
// num should be number of file, it should not be greater than number of enteries 
//  (which can be found in MeaHeader)
// returns 1 if read succesfully
// MeaRec is then filled with file's name, offset and size
int ReadRecord( FILE *f, int num )
{
	if (( num < 0 ) || ( num >= MeaHeader.files_count ))
		return 0;

	fseek( f, MeaHeader.lib_offset + num * SizeOfMeaRec, SEEK_SET );
	fread( &MeaRec, 1, SizeOfMeaRec, f );

	return 1;
}
