Forum: Archive RSS
BNK File Format
technical

Announcement

2008-11-05, 14:54 by Keshire
Rules for posting on this site.
Follow them or have your posting rights removed or be banned.

[cut=Full List Of Rules]*  If a topic makes no sense to you, do not ask broad questions about it.  We have a lot of developer posts that will make no sense to someone who doesn't know how to program or has not taken the time to explore the game files.


*  All modifications we release for the xbox will require a modified xbox.  Ask for instruction and then tell us you don't have one will result in banning/deletion of all posts for failure to read instructions.  THERE WILL BE NO SAVES ON THIS SITE SO DO NOT REQUEST THEM.


*  We do not endorse pirating.  Suggesting or asking for such will get you banned.  If you like a game BUY IT.  People worked hard to make something to entertain you, it's the least you can do.  If you are caught without one of these you will be banned.


*  Posting of original game files is strictly prohibited.  If you have code to share post just the code you have made.  Only attach files if you have created an application or something similar that requires the attachment.  If you made many changes to a file but did not change ALL of it then post a PPF or something similar to avoid posting any original code at all.  Do not link to original files either.  Either way it's just the same as posting them here.


*  Harassing admins/moderators through PM/Email because of your own inability to work things out with other people in the forums will result in loss of PM an removal of ability to post.


*  Harassing admins/moderators through PM/Email because of your own inability to read posts and stickies in the forums with any compitence will result in loss of PM an removal of ability to post.


*  Harassing or just flooding a topic/person because you are too lazy to use search will get your posting rights removed.  Search exists for a reason and we won't deal with people that constantly ask for things that are easy to find with search.


*  Public bashing of other members will get your posts removed.  If it is done repeatedly you will get your account banned.


*  Posting a reply to merely say you don't know or you also want to know something is a waste of space and all of our collective time (assuming you weren't asked directly, but if you were it probably should have been done in PM).  Repeated offenders will get their posting rights removed.

*  Do not cross post questions/requests in forums.  Pick the appropriate forum and post it there.  People read in all of the forums and don't need to see the extra spam.


*  Everything on this site is provided AS IS.  If you use a tool that someone wrote here and it crashes your computer, we don't care.  The programmer should be informed with as much information as you can provide in order to prevent that from happening again though.

*  Being an open forum, try to contribute to it.  As in by helping crack file formats or developing new tools or game modifications.  Leeches are never appreciated.  Especially when they are ungrateful for the work that other people put into doing something for them.  Being ungrateful is a very quick path to being banned.


*  Lack of acting like a mature person or inability to type in proper english or something close to it will not be tolerated (i.e. l33t,ALL CAPS, or IM shorthand).


Basically, this is a technically based Fable modding site.  This is NOT a playground. [/cut]

If you have a problem with these rules, don't come here.

Failure to not read the stickies on forums (like this one) is not an excuse.  Failure to read this post is also not an excuse.
Avatar
Keshire Administrator #1
Member since Nov 2008 · 29 posts
Group memberships: Administrators, Members
Show profile · Link to this post
Subject: Formats
#include "standard-types.hsl"

#pragma byteorder(big_endian)

typedef struct BNK
{
    DWORD    FileDataSectionOffset;
    char    Unknown[4]; //Probably Version
    byte    CompressFileData; //I'm pretty sure this is a bool for compressing the file data
    DWORD    CompressedTableSize;
    DWORD    DecompressedTableSize;
    char    CompressedTable[CompressedTableSize];
} BNK;


typedef struct FileEntry
{
    DWORD    NameLength ;
    char     FileName[NameLength];
    DWORD    FileStartOffset;
    DWORD    FileSize;
} FileEntry;

typedef struct CompressedFileEntry
{
        DWORD        NameLength ;
        char         FileName[NameLength];
        DWORD        FileStartOffset;
    DWORD        DecompressedFileSize;
    DWORD        CompressedFileSize;
    DWORD        Count; //Compressed Chunks. 32k padded?
    DWORD        DecompressedSizes[Count];
} CompressedFileEntry;


typedef struct FileTable
{
    DWORD FileCount;
    FileEntry Files[FileCount];
}FileTable;

typedef struct ADB
{
    char    Header[12]; //LhCoMpReSsEd always
    DWORD    Unknown; //number of files?

} ADB;

typedef struct ADBEntry
{
    DWORD    sizeDecompressed;
    DWORD    sizeCompressed;

} ADBEntry;
Apathy Cannot Inspire.
Ambivalence cannot lead.
Loved me. Feared me.
Changed me. Killed me.
Anything would be something.
But nothing is worst of all.
LittleCodingFox #2
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
What's the compression algorithm used?
TodX Administrator #3
Member since Oct 2008 · 16 posts · Location: San Diego
Group memberships: Administrators, Members
Show profile · Link to this post
They're using zlib's deflate/inflate and 'managing' the streams themselves.  Thus there are no checksums at the end of compression blocks.  This means that if you use pre-setup uncompress() call it will fail since it looks for a checksum at the end of the compressed block.  Also for the file table they are maintaining the same context through out all the compressed blocks, effectively treating it as one big stream that has been broken up into peices which makes sense.  However, in the compressed files they start a new context for each block, treating each block as a new stream and then combining the outputs.
LittleCodingFox #4
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
By context do you mean file handle?
TodX Administrator #5
Member since Oct 2008 · 16 posts · Location: San Diego
Group memberships: Administrators, Members
Show profile · Link to this post
I'm refering to the z_stream struct and its internal data.  See this page for details http://www.zlib.net/manual.html.
LittleCodingFox #6
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
Is there any way to know if a BNK file is really a BNK file?

As far as i understand it, BNK files have no "header identification". Do i just read the BNK struct from a BNK file?
TodX Administrator #7
Member since Oct 2008 · 16 posts · Location: San Diego
Group memberships: Administrators, Members
Show profile · Link to this post
Yeah, you're right.  There is no good way of telling if a BNK is a BNK.  I guess they decided to leave the tag off for some odd reason.  Pretty much if it's extension is bnk then try reading it.  And yeah, just read the BNK struct starting at the beginning of the file.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Not logged in. · Lost password · Registration disabled
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Page created in 246.1 ms (81.2 ms) · 52 database queries in 205.5 ms
Current time: 2024-11-30, 05:48:19 (UTC -07:00)