

Joined: Wed Aug 10, 2016 5:20 pm

Posts: 19

warrantyvoider wrote:



greetz



PS: about cas data:





cat tells you to load a region from cas, then start reading blocks, with this 8 byte header. cat files can also contain a second list, where one entry is 80 bytes and has additional 20 bytes (in compare to a normal entry) that look like encryption keys again... (because no block header to see when reading where it says there, and also theres no cas number as far as I can see) I had no time yet to look at the actual chunk contents, but as far as ive seen, each entry is missings its header and I dont see no magic for encryption anywhere. dunno, im busy with the two filesystems before I can look at content datagreetzPS: about cas data:cat tells you to load a region from cas, then start reading blocks, with this 8 byte header. cat files can also contain a second list, where one entry is 80 bytes and has additional 20 bytes (in compare to a normal entry) that look like encryption keys again... (because no block header to see when reading where it says there, and also theres no cas number as far as I can see)





cat file 010 Editor Template

Code: uint flag; //0x01CED100

int zero;

byte signaturedata[0x224]; //rsa signature info, 0x224 bytes

byte nyan[0x10]; //NyanNyanNyanNyan, 0x10 bytes

int list1count;

int list3count;

int list2count;

byte padding[0xc];

struct {

byte sha1[0x14];

int offset;

int size;

int unknown;

int cas_num;

} list1[list1count];

struct {

byte sha1[0x14];

int offset;

int size;

int unknown1;

int unknown2;

int size2; // size2 should equal to size

byte unk1[0x28];

} list2[list2count];

struct {

byte unknown[0x3c];

} list3[list3count];





cas is compressed in chunks using zstandard

format:

Code: int decompressedsize;

ushort flag?;

ushort compressedsize;

byte[] compresseddata; //compressed data starts with magic header 0xfd2fb528



Decompression code

Code: [DllImport("libzstd.dll")]

static extern UIntPtr ZSTD_decompress(IntPtr dst, int dstCapacity,

IntPtr src, int compressedSize);



public static byte[] Decompress(byte[] buffer, long decompressedsize)

{

byte[] decbuffer = new byte[decompressedsize];

int offset = 0;

var cmphandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

var decmphandle = GCHandle.Alloc(decbuffer, GCHandleType.Pinned);

using (BinaryReaderEx br = new BinaryReaderEx(new MemoryStream(buffer), Endianness.Big))

{

while (br.BaseStream.Position < br.BaseStream.Length)

{

int framedecsize = br.ReadInt32();

short flag = br.ReadInt16();

ushort framesize = br.ReadUInt16();

int decsize = (int)ZSTD_decompress(decmphandle.AddrOfPinnedObject()+ offset, decbuffer.Length,cmphandle.AddrOfPinnedObject() + (int)br.BaseStream.Position, (int)framesize);

offset += decsize;

br.BaseStream.Position += (int)framesize;

}

}

cmphandle.Free();

decmphandle.Free();

return decbuffer;

}





I decompressed the texture data with the correct size, but the pixel format seems wrong.



cat file 010 Editor Templatecas is compressed in chunks using zstandardformat:Decompression codeI decompressed the texture data with the correct size, but the pixel format seems wrong.



