MRS File Specification by CBWhiz.
File version 1.0 - 11/12/05
This file spec / implementation design was helped greatly by the ZIP file format spec, located at
PKWARE, Inc. - Developer’s Tools. It is assumed you read it.
When Gunz starts, it enumerates, starting at its local folder, all files.
Each file (unless it starts with mrs or zip, or is a folder) is treated exactly the same, wrapped in an MZFile class, and stored inside the MZFilesystem.
If it is a folder, it calls itself again to enumerate /that/ folder.
If it is a MRS / ZIP, it treats these as file system extentions. This means MZip::Initalize is called, and that adds each file inside to the MZFilesystem itself.
To access a file, Gunz talks to the MZFileSystem and asks for a file.
This subroutine checks the file list, sees if it is a MZFile or if it is stored in an MZip. If it is in a MZip, it calls MZip::Readfile and returns it, otherwise it just returns the file normally.
This has the following benifits:
-Gunz code doesnt care where the file comes from
-MAIET can easily debug by simply removeing (say) system.mrs and creating a folder called system.
How Gunz Reads MRS files:
MZip::Initalize(mrsfile, 4); //Called to set it up
MZip::ReadFile(filename, length);
--------------------------------------------------------------------------------------------
MZip::ReadFile(char* filename, int length) {
/*
lookup file in central directory
(not shown)
*/
SEEK to local file header for file
READ local file header beginning (1E bytes, doesnt include filename, etc)
DECRYPT lfh:
LEA ECX,DWORD PTR SS:[(lfh)]
MOV EDI,1E
L002:
MOV AL,BYTE PTR DS:[ECX]
MOV DL,AL
SHR DL,3
SHL AL,5
OR DL,AL
NOT DL
MOV BYTE PTR DS:[ECX],DL
INC ECX
DEC EDI
JNZ L002 //(same scheme as always)
CHECK lfh magic number:
CMP EAX, 4034B50 //ZIP lfh magic number - seems like all v2 MRS files have this also
CMP EAX,85840000 //Theoreticly MRS version 1 magic number, but I have no edvidance. I think MAIET just got lazy.
ADD filename length and extra feild length
CHECK if the file is uncompressed.
If so, READ it and return it.
CHECK compression method. If it is not deflate, it returns. (MZip can only handle delfate)
READ file