Subfolder locations in PRJ

Binary formats and related hacking.

Moderator: Skyfaller

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Subfolder locations in PRJ

Post by Col.Kell » Sat Dec 20, 2008 9:41 am

I was curious, at the way top of the PRJ file is that list of subfolders, and along next to each subfolder seems to be a set of numbers. When I changed the numbers around it refered to different locations in the PRJ.
Do you Skyfaller have any information I can study on this? That would be cool, actualy ADDING stuff rather than REPLACING.
MechWarrior 2: 31stCC
Image

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: Subfolder locations in PRJ

Post by Skyfaller » Sat Dec 20, 2008 10:28 am

I'm working on it. Adding files is more difficult than replacing them because the old directories do not have space left for new entries. Therefore, all directory entries must be copied into a larger table. I'm currently testing code that may accomplish that, given some more testing. I could share details, but it would a lot of technical stuff.
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: Subfolder locations in PRJ

Post by Col.Kell » Sat Dec 20, 2008 10:37 am

I could share details, but it would a lot of technical stuff.
Fire away! ;)
MechWarrior 2: 31stCC
Image

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: Subfolder locations in PRJ

Post by Skyfaller » Sat Dec 20, 2008 11:00 am

OK, you asked. It's all currently in a state of flux, with some parts contradicting others. I'm not really happy with it atm, but I'm currently a bit busy so I can't work these contradictions out. If you find mistakes, correct me please, this may cut from the time I spend on adding and replacing files in the PRJ. I'll edit this post later as we make progress.
Notes
=====
MW2.prj
=====

MW2.prj is a binary archive.
There is a PROJ signature at offset 0, followed by the file size-7 (dword).
The names in the main directory are 4 bytes long, and are
immediately followed by the file offset (dword). These entries
begin at offset 26 = 1Ah. There may be an additional entry at
offset 12 = 0ch, but it does not fit into this pattern.

The number of entries in the main directory is stored in a WORD at offset 18h.

The offsets from the main directory point to the string INDX,
which is part of the structure MW2_PRJ_directory_header in the code.
After that follow records describing each file, MW2_PRJ_Directory_Entries.
These records are followed by the symbol table. It stores the file names
without extensions, therefore MechVM prefers to read the file names from the
local file headers. The header of the symbol table is defined in
structure SymbolTableHeader. The file names are stored in records of
structure SymbolTableEntry.

The offset stored in the MW2_PRJ_Directory_Entries points to the file's local
header. The local header is described in structure MW2_PRJ_local_file_header.
The actual file data follows immediately after the file's local header.
C Record definitions, taken from MechWarriorIIPRJ.cpp
struct MW2_PRJ_directory_header {
char marker[4]; // Marker string INDX
DWORD structSize; // Size of this record, plus MW2_PRJ_Directory_Entries, minus 8
char unknown[12];
DWORD entries; // Number of entries, plus one
char unknown2[6]; // zero in all tested cases
}; // 30 bytes

struct MW2_PRJ_Directory_Entries {
DWORD offset;
DWORD size;
}; // 8 bytes

struct MW2_PRJ_local_file_header {
char marker[4]; // Marker string DATA
DWORD SizeOfThisFile, // Size of file plus 54 bytes
unknown1;
char parentDir[4]; // Name of directory containing the file
char unknown2[8];
WORD FileNumberInParentDir; // Entry number of this file in parent dir + 1
char unknown3[4]; // A flag?
char nameWithoutExt[16]; // Null-terminated file name without extension
char nameWithExt[16]; // Null-terminated file name with extension
}; // 62 bytes

struct SymbolTableHeader {
char marker[4]; // "SYMB"
DWORD size; // Size of this record, plus file name records, minus 8
DWORD unknown1, unknown2;
WORD unknown3;
DWORD entries; // Exact number of entries
}; // 16h=22 bytes

struct SymbolTableEntry {
char FileName[16]; // File name without extension, zero-padded
WORD FileNum; // 1 for first file, 2 for second, ...
}; // 12h=18 bytes
Feel free to explore the meaning of the fields marked as unknown.

(Last edited on 12/28/2008: added information on the symbol table following the directory definition)
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: Subfolder locations in PRJ

Post by Col.Kell » Sat Dec 20, 2008 12:06 pm

I'll test this out, see how it goes and report any former unknowns.
MechWarrior 2: 31stCC
Image

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: Subfolder locations in PRJ

Post by Skyfaller » Sat Dec 20, 2008 12:32 pm

Thanks for helping me with this. Do you understand the record definitions (called structures in C)?
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: Subfolder locations in PRJ

Post by Col.Kell » Sat Dec 20, 2008 1:49 pm

No prob.
atm, no. I'm still scaning through this, I take in info a little bit at a time. The offset locations and such make sense. But when you say "structures in C", you don't mean C/C++ do you? That's WAY beyond me :shock:
MechWarrior 2: 31stCC
Image

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: Subfolder locations in PRJ

Post by Skyfaller » Sat Dec 20, 2008 2:01 pm

Well, yes, I mean C structures. But have no fear. It's the foldout "C record definitions". It simply lists the type first, then a field name, followed by optional repetitions in []. The latter define arrays. That's all there is to it. You can do it.

We're in race posting today ;)
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: Subfolder locations in PRJ

Post by Col.Kell » Sat Dec 20, 2008 2:06 pm

So... I don't need to know C++ to do his? Great then!

*Whpeew*... :lol:
MechWarrior 2: 31stCC
Image

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: Subfolder locations in PRJ

Post by Col.Kell » Sun Dec 21, 2008 10:34 am

:? ...Your guesses are as good as mine.
MechWarrior 2: 31stCC
Image

Post Reply