Subject: Bogus BNK File Entries
Hello everyone.
I'm having a bit of an issue regarding BNK File Entries.
I read the BNK File Header, and then seek to the offset of the File Data (as described on the Formats thread), however when i read the File Table, i get a bogus number of entries (about 120 million), which is obviously wrong.
When exactly should i read the BNK File Entries? Should i read it just after reading the BNK Header and CompressedTable?
Here is my File Table reading function:
The BNK Header reading function:
And here's what READV is:
I hope someone can give me a hint as to what i am doing wrong.
Thank you for your time regarding this issue, and have a nice day!
EDIT: If it isn't obvious, the "CompressFileData" flag is 0.
I'm having a bit of an issue regarding BNK File Entries.
I read the BNK File Header, and then seek to the offset of the File Data (as described on the Formats thread), however when i read the File Table, i get a bogus number of entries (about 120 million), which is obviously wrong.
When exactly should i read the BNK File Entries? Should i read it just after reading the BNK Header and CompressedTable?
Here is my File Table reading function:
void IFileTable::DeSerialize(CStream Stream)
{
unsigned long FileCount = 0;
READV(FileCount, sizeof(unsigned long), 1);
Entries.Allocate(FileCount); //I breakpoint here to check FileCount
for(unsigned long i = 0; i < Entries.Size(); i++)
{
Entries[i].Swap(new IFileEntry);
Entries[i]->DeSerialize(Stream);
};
};
{
unsigned long FileCount = 0;
READV(FileCount, sizeof(unsigned long), 1);
Entries.Allocate(FileCount); //I breakpoint here to check FileCount
for(unsigned long i = 0; i < Entries.Size(); i++)
{
Entries[i].Swap(new IFileEntry);
Entries[i]->DeSerialize(Stream);
};
};
The BNK Header reading function:
void IBNKHeader::DeSerialize(CStream Stream)
{
READV(Offset, sizeof(unsigned long), 1);
READV(Unknown, sizeof(char), 4);
READV(CompressFileData, sizeof(unsigned char), 1);
READV(CompressedTableSize, sizeof(unsigned long), 1);
READV(DecompressedTableSize, sizeof(unsigned long), 1);
if(CompressedTableSize)
{
CompressedTable.Allocate(CompressedTableSize);
READV(CompressedTable[0], sizeof(char), CompressedTableSize);
};
};
{
READV(Offset, sizeof(unsigned long), 1);
READV(Unknown, sizeof(char), 4);
READV(CompressFileData, sizeof(unsigned char), 1);
READV(CompressedTableSize, sizeof(unsigned long), 1);
READV(DecompressedTableSize, sizeof(unsigned long), 1);
if(CompressedTableSize)
{
CompressedTable.Allocate(CompressedTableSize);
READV(CompressedTable[0], sizeof(char), CompressedTableSize);
};
};
And here's what READV is:
#define READV(object, size, count)\
Stream->Read(&object, size, count);\
EndianConvert(&object, size * count, true);
Stream->Read(&object, size, count);\
EndianConvert(&object, size * count, true);
I hope someone can give me a hint as to what i am doing wrong.
Thank you for your time regarding this issue, and have a nice day!
EDIT: If it isn't obvious, the "CompressFileData" flag is 0.
This post was edited on 2008-11-11, 10:53 by LittleCodingFox.