Esempio n. 1
0
        public static GemEntry BuildGemEntry(BinaryReader bnr, GemEntry gem, ASCIIEncoding ascii)
        {
            //Specific file type work goes here!
            gem.Magic = BitConverter.ToString(gem.UncompressedData, 0, 4).Replace("-", string.Empty);
            bnr.BaseStream.Position  = 4;
            gem.EntryCountA          = bnr.ReadByte();
            gem.EntryCountB          = bnr.ReadByte();
            gem.Constant             = bnr.ReadInt16();
            gem.EntryCountTotal      = gem.EntryCountA + gem.EntryCountB + 1;
            gem.InterpolatedFileSize = bnr.ReadInt32();

            //Starts occupying the entry list via structs.
            gem.EntryList = new List <GEMEntries>();
            byte[] PLName  = new byte[] { };
            byte[] PTHName = new byte[] { };

            int p = 12;

            for (int g = 0; g < gem.EntryCountTotal; g++)
            {
                GEMEntries ge = new GEMEntries();
                PLName       = gem.UncompressedData.Skip(p).Take(64).Where(x => x != 0x00).ToArray();
                ge.TotalName = ascii.GetString(PLName);
                gem.EntryList.Add(ge);
                p = p + 64;
            }

            gem.TextBackup = new List <string>();
            return(gem);
        }
Esempio n. 2
0
        public static void RefreshGEMList(TextBox texbox, GemEntry geme)
        {
            //Reconstructs the Entry List.
            geme.EntryCountTotal = geme.TextBackup.Count;
            geme.EntryList       = new List <GEMEntries>();

            for (int g = 0; g < geme.EntryCountTotal; g++)
            {
                GEMEntries pe = new GEMEntries();
                pe.TotalName = geme.TextBackup[g];
                geme.EntryList.Add(pe);
            }
            LoadGEMInTextBox(texbox, geme);
        }
Esempio n. 3
0
        public static GemEntry RenewGemEntry(TextBox texbox, GemEntry gem)
        {
            //Reconstructs the Entry List.
            string txbtxt = texbox.Text;

            string[] SPLT = new string[] { };

            SPLT = txbtxt.Split('\n');

            gem.EntryCountTotal      = SPLT.Length;
            gem.InterpolatedFileSize = gem.EntryCountTotal * 64;
            gem.EntryList            = new List <GEMEntries>();

            for (int g = 0; g < gem.EntryCountTotal; g++)
            {
                GEMEntries pe = new GEMEntries();
                pe.TotalName = SPLT[g];
                gem.EntryList.Add(pe);
            }

            //Rebuilds the Decompressed data Array.
            List <byte> NEWGEM = new List <byte>();

            byte[] HeaderGEM = { 0x47, 0x45, 0x4D, 0x00, 0x01, 0x01, 0xFE, 0xFF };
            NEWGEM.AddRange(HeaderGEM);
            int NewEntryCount = gem.EntryCountTotal;

            //Converts an integer to 4 bytes in a roundabout way.
            string GEMSize = 192.ToString("X8");

            byte[] GEMProjSize = new byte[4];
            GEMProjSize = ByteUtilitarian.StringToByteArray(GEMSize);
            Array.Reverse(GEMProjSize);

            NEWGEM.AddRange(GEMProjSize);

            string ENTemp = "";

            //string RPTemp = "";
            //string HashStr = "";
            byte[] HashTempDX = new byte[4];
            int    counter    = gem.EntryCountTotal - 1;

            for (int k = 0; k < counter; k++)
            {
                ENTemp = gem.EntryList[k].TotalName;
                ENTemp = ENTemp.Replace("\r", "");
                int    NumberChars = ENTemp.Length;
                byte[] namebuffer  = Encoding.ASCII.GetBytes(ENTemp);
                int    nblength    = namebuffer.Length;

                //Space for name is 64 bytes so we make a byte array with that size and then inject the name data in it.
                byte[] writenamedata = new byte[64];
                Array.Clear(writenamedata, 0, writenamedata.Length);

                for (int i = 0; i < namebuffer.Length; ++i)
                {
                    writenamedata[i] = namebuffer[i];
                }

                NEWGEM.AddRange(writenamedata);
            }

            gem.UncompressedData = NEWGEM.ToArray();
            gem.DSize            = gem.UncompressedData.Length;
            gem.CompressedData   = Zlibber.Compressor(gem.UncompressedData);
            gem.CSize            = gem.CompressedData.Length;
            gem._FileLength      = gem.UncompressedData.Length;

            return(gem);
        }