Esempio n. 1
0
        public void SortTable(PckClass pck)
        {
            uint count = pck.EntryCount;

            uint[] entry = new uint[count];

            for (int i = 0; i < count; i++)
            {
                entry[i] = pck.FileTable[i].DataOffset;
            }
        }
Esempio n. 2
0
        // Returns the incorrect offset on some versions. Using another PCK
        // tool and rebuilding it fixes the problem. Will have to research
        // this and account for it. I suppose the best way to do this would
        // be to rebuild the tables... no clue at this point.
        private uint GetSpannedTableEntry(PckClass pck)
        {
            uint offset = 0;
            uint i      = 0;

            while (offset < TwoGb)
            {
                offset = pck.FileTable[i].DataOffset;
                i++;
            }

            return(i - 2);
        }
Esempio n. 3
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog open = new OpenFileDialog())
            {
                open.Filter = @"PCK Archive (*.pck)|*.pck|All Files (*.*)|*.*";
                open.Title  = @"Open PCK Archive";

                if (open.ShowDialog() != DialogResult.OK || !File.Exists(open.FileName))
                {
                    return;
                }

                try
                {
                    Cursor = Cursors.AppStarting;

                    lblStatus.Text = @"Retrieving data...";
                    lblStatus.Refresh();

                    using (FileStream fs = File.OpenRead(open.FileName))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            _pck = new PckClass(open.FileName);

                            fs.Seek(4, SeekOrigin.Begin);
                            uint filesize = br.ReadUInt32();

                            SetFlags();

                            txtFileName.Text = open.FileName;

                            if (_pck.OpenArchive(fs, br, AlgoId) == -1)
                            {
                                lblStatus.Text = "Unsupported format!\nWhen will it be supported?!";
                                Cursor         = Cursors.Default;
                                return;
                            }
                        }
                    }

                    long cSize = 0;
                    long dSize = 0;

                    for (int i = 0; i < _pck.EntryCount; i++)
                    {
                        cSize += _pck.FileTable[i].CompressedSize;
                        dSize += _pck.FileTable[i].DecompressedSize;
                    }

                    _pck.CompressedSize   = cSize;
                    _pck.DecompressedSize = dSize;

                    Text = $@"Simple UnPCKer : v{Program.Version}  ::  {_pck.GameName}";

                    lblStatus.Text =
                        "Version:  0x" + _pck.Version.ToString("X8") +
                        "\nEntry Count:  " + _pck.EntryCount +
                        "\nCompressed Size:  " + cSize.ToString("##,###,###,###") + " bytes" +
                        "\nDecompressed Size:  " + dSize.ToString("##,###,###,###") + " bytes";

                    Cursor = Cursors.Default;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The following error occurred while opening:\n" + ex.Message);
                    Cursor = Cursors.Default;
                }
            }
        }