Esempio n. 1
0
            public static FileName[] Read_FileName(Stream s)
            {
                helper help = new helper();

                FileName[] result = new FileName[Header.FileCount];
                for (int i = 0; i < Header.FileCount; i++)
                {
                    FileName fn = new FileName();
                    if (Header.MagicNumber.ToString("X8").Equals("A1B2C3D4"))
                    {
                        fn.offset = help.ReadU32(s);
                    }
                    if (Header.MagicNumber.ToString("X8").Equals("D4C3B2A1"))
                    {
                        fn.offset = help.ReverseUInt32(help.ReadU32(s));
                    }
                    result[i] = fn;
                }
                long pos = s.Position;

                for (int i = 0; i < Header.FileCount; i++)
                {
                    s.Seek(pos + result[i].offset, 0);
                    result[i].filename = help.ReadString(s);
                    result[i].fileHash = help.GetFileHash(result[i].filename);
                }
                return(result);
            }
Esempio n. 2
0
            public HeaderStruct(Stream s, int rev)
            {
                s.Seek(0, SeekOrigin.End);
                FileSize = (uint)s.Position;
                helper help = new helper();

                s.Seek(0, 0);
                MagicNumber          = help.ReadU32(s);
                PackageVersion       = help.RUInt32(s, rev);
                DecompressedFileSize = help.RUInt64(s, rev);
                Flags                            = help.RUInt32(s, rev);
                FileCount                        = help.RUInt32(s, rev);
                LocationCount                    = help.RUInt32(s, rev);
                HeaderSector                     = help.RUInt32(s, rev);
                FileSizeBitCount                 = help.RUInt32(s, rev);
                FileLocationCountBitCount        = help.RUInt32(s, rev);
                FileLocationIndexBitCount        = help.RUInt32(s, rev);
                LocationBitCount                 = help.RUInt32(s, rev);
                CompSectorToDecomOffsetBitCount  = help.RUInt32(s, rev);
                DecompSectorToCompSectorBitCount = help.RUInt32(s, rev);
                CRC = help.RUInt32(s, rev);
                if (PackageVersion == 6)
                {
                    Unknown        = help.ReadU32(s);
                    ReadSectorSize = 0x10000;
                    CompSectorSize = 0x4000;
                    HeaderSize     = 64;
                }
                if (PackageVersion == 7)
                {
                    ReadSectorSize = (uint)help.RInt32(s, rev);
                    CompSectorSize = (uint)help.RInt32(s, rev);
                    HeaderSize     = 72;
                }
                CompSectorCount     = ((uint)CompSectorSize + FileSize - 1 - (uint)ReadSectorSize * HeaderSector) / (uint)CompSectorSize;
                FirstSectorPosition = (uint)(ReadSectorSize * HeaderSector) & 0xFFFF0000;
                if ((FirstSectorPosition % ReadSectorSize) != 0)
                {
                    FirstSectorPosition += ReadSectorSize;
                }
            }