コード例 #1
0
        internal static R_MythicPackageBlock Pack(List <R_MythicPackageIndex> indexes, int k, ref int i)
        {
            /*
             * [2] - Index Block Header (sizeof: 24bytes)
             * There can be multiple index blocks, they are splitted into chunks.
             * DWORD 0x28 -> Amount of contained files in this index, max 100/0x64
             * QWORD 0x2c -> Offset to the next index block header OR Zero
             * When a index block doesn't contain 100 index definitions, it will be padded with nulls
             */
            R_MythicPackageBlock final = new R_MythicPackageBlock();

            for (int j = 0; j < 100; j++)  //Should fill single block
            {
                if (k < indexes.Count)
                {
                    final.Adds(indexes[k]);
                    final.FileCount++;      //Amount of contained files in this index, max 100/0x64
                    k++;
                    i = k;
                }
                else
                {
                    final.Adds(R_MythicPackageIndex.Empty());
                }
            }
            final.NextBlock = 0;    //Offset to the next index block header OR Zero

            return(final);
        }
コード例 #2
0
        public R_MythicPackageIndex Adds(R_MythicPackageIndex index)
        {
            if (m_Files == null)
                m_Files = new List<R_MythicPackageIndex>();

            m_Files.Add(index);
            return index;
        }
コード例 #3
0
        public R_MythicPackageIndex Adds(R_MythicPackageIndex index)
        {
            if (m_Files == null)
            {
                m_Files = new List <R_MythicPackageIndex>();
            }

            m_Files.Add(index);
            return(index);
        }
コード例 #4
0
        internal static R_MythicPackageIndex Pack(string current_file, ref bool error)
        {
            /*- Create index for each data (sizeof: 34bytes )
             * QWORD 0x34 -> Offset to start of Data Block of this file
             * DWORD 0x3c -> Length of Data Block header (usually 0x0C)
             * DWORD 0x40 -> Lenght of compressed data
             * DWORD 0x44 -> Size of decompressed file
             * QWORD 0x48 -> Filehash
             * DWORD 0x50 -> Adler32 CRC of Data in littleEndian ( flag offset data )
             * WORD  0x54 -> Compressed Flag
             */
            R_MythicPackageData  datas = new R_MythicPackageData();
            R_MythicPackageIndex final = new R_MythicPackageIndex();

            datas = R_MythicPackageData.Pack(current_file); //Pack current file datas

            string toHash = "";                             //Initialized "" to prevent error in hashing

            /*error = false;      //Actually we does not want to get out of the cycle
             * //We are looking fo Build folder, that is the root.
             * int inde = current_file.IndexOf("build\\");
             * if (inde != -1) //if found
             *  toHash = current_file.Substring(Form1.FolderName.Length+1);
             *  toHash = toHash.Replace("\\", "/");
             *  //toHash = current_file.Substring(inde, current_file.Length - inde);
             * else
             * {
             *  MessageBox.Show("NO BUILD FOLDER FOUND!");
             *  error = true;//We are going out from cycle
             * }*/
            toHash = current_file.Substring(Form1.FolderName.Length + 1);
            toHash = toHash.Replace("\\", "/");

            bool compr = datas.Compressed;         //Are datas compressed?

            final.DataBlockOffset  = 0;            //Offset to start of Data Block of this file
            final.HeadLength       = 0x0C;         //Is this fixed?
            final.CompressedSize   = datas.C_size; //Ok
            final.DecompressedSize = datas.U_size; //Ok
            long hash = 0;

            Form1.Dictionary.TryGetValue(toHash, out hash);
            final.FileHash  = hash;                            //FileHash To Check
            final.CRC       = final.find_CRC(datas);           //See find_CRC
            final.Flag      = compr ? (short)0x1 : (short)0x0; //Flag Compressed data To check
            final.DataBlock = datas;                           //Tocheck

            if (final.CRC == 0)
            {
                MessageBox.Show("Unable to find CRC!");
                error = true; //We are going out from cycle
            }
            return(final);
        }
コード例 #5
0
        internal static R_MythicPackageIndex Pack(string current_file, ref bool error)
        {
            /*- Create index for each data (sizeof: 34bytes )
             * QWORD 0x34 -> Offset to start of Data Block of this file 
             * DWORD 0x3c -> Length of Data Block header (usually 0x0C) 
             * DWORD 0x40 -> Lenght of compressed data 
             * DWORD 0x44 -> Size of decompressed file 
             * QWORD 0x48 -> Filehash 
             * DWORD 0x50 -> Adler32 CRC of Data in littleEndian ( flag offset data ) 
             * WORD  0x54 -> Compressed Flag
             */
            R_MythicPackageData datas = new R_MythicPackageData();
            R_MythicPackageIndex final = new R_MythicPackageIndex();

            datas = R_MythicPackageData.Pack(current_file); //Pack current file datas

            string toHash = ""; //Initialized "" to prevent error in hashing
            /*error = false;      //Actually we does not want to get out of the cycle
            //We are looking fo Build folder, that is the root.
            int inde = current_file.IndexOf("build\\");
            if (inde != -1) //if found
                toHash = current_file.Substring(Form1.FolderName.Length+1);
                toHash = toHash.Replace("\\", "/");
                //toHash = current_file.Substring(inde, current_file.Length - inde);
            else
            {
                MessageBox.Show("NO BUILD FOLDER FOUND!");
                error = true;//We are going out from cycle
            }*/
            toHash = current_file.Substring(Form1.FolderName.Length+1);
            toHash = toHash.Replace("\\", "/");

            bool compr = datas.Compressed;  //Are datas compressed?

            final.DataBlockOffset = 0;  //Offset to start of Data Block of this file 
            final.HeadLength = 0x0C;    //Is this fixed? 
            final.CompressedSize = datas.C_size;   //Ok 
            final.DecompressedSize = datas.U_size; //Ok
            long hash = 0;
            Form1.Dictionary.TryGetValue(toHash, out hash);
            final.FileHash = hash; //FileHash To Check
            final.CRC = final.find_CRC(datas);                //See find_CRC
            final.Flag = compr ? (short)0x1 : (short)0x0;         //Flag Compressed data To check
            final.DataBlock = datas;                //Tocheck

            if (final.CRC == 0)
            {
                MessageBox.Show("Unable to find CRC!");
                error = true; //We are going out from cycle
            }
            return final;
        }
コード例 #6
0
        internal static R_MythicPackageIndex Empty()
        {
            R_MythicPackageIndex e = new R_MythicPackageIndex();

            e.CompressedSize   = 0;
            e.CRC              = 0;
            e.DataBlock        = null;
            e.DataBlockOffset  = 0;
            e.DecompressedSize = 0;
            e.FileHash         = 0;
            e.Flag             = 0;
            e.HeadLength       = 0;
            return(e);
        }
コード例 #7
0
 internal static R_MythicPackageIndex Empty()
 {
     R_MythicPackageIndex e = new R_MythicPackageIndex();
     e.CompressedSize = 0;
     e.CRC = 0;
     e.DataBlock = null;
     e.DataBlockOffset = 0;
     e.DecompressedSize = 0;
     e.FileHash = 0;
     e.Flag = 0;
     e.HeadLength = 0;
     return e;
 }
コード例 #8
0
ファイル: Form1.cs プロジェクト: cbnolok/SphereSvrSource
        private void pack_btn_Click(object sender, EventArgs e)
        {
            if (FolderName == null)
            {
                display_box.AppendText("\n\nError: no folder loaded.");
                return;
            }
            load_btn.Enabled = false;
            pack_btn.Enabled = false;
            seehash_btn.Enabled = false;

            //We start reading data's files + data's index and creating a list of them.
            List<R_MythicPackageIndex> toblock = new List<R_MythicPackageIndex>();

            R_MythicPackageIndex final_data = new R_MythicPackageIndex();

            //display_box.AppendText("\n" + Path.GetFileName(FolderName));
            //Read files
            display_box.AppendText("\n\nReading data's files..");
            string[] files = Directory.GetFiles(FolderName, "*", SearchOption.AllDirectories);       //Get all files in directories

            progressBar.Maximum = files.Length;
            Worker.RunWorkerAsync(files); //Worker will create index and datas List

        }