Exemplo n.º 1
0
        void HashBIFFFile(string Name, ref HashAlgorithm Ha)
        {
            IList <CFItem> Lst = CF.GetAllNamedEntries(Name);

            foreach (CFItem Itm in Lst)
            {
                BIFFFile B = GetBIFF(Itm);
                B.IterateChunks(HashChunk);
            }
        }
Exemplo n.º 2
0
        //Loads a table from a VPT file
        public void Load(string Filename)
        {
            CF = new CompoundFile(Filename);

            IList <CFItem> Lst = CF.GetAllNamedEntries("TableName");

            foreach (CFItem Itm in Lst)
            {
                Name = ReadTextFileUnicode(Itm.Size, Itm);
            }
            Lst = CF.GetAllNamedEntries("AuthorName");
            foreach (CFItem Itm in Lst)
            {
                Author = ReadTextFileUnicode(Itm.Size, Itm);
            }
            Lst = CF.GetAllNamedEntries("TableVersion");
            foreach (CFItem Itm in Lst)
            {
                Version = ReadTextFileUnicode(Itm.Size, Itm);
            }
            Lst = CF.GetAllNamedEntries("TableDescription");
            foreach (CFItem Itm in Lst)
            {
                Description = ReadTextFileUnicode(Itm.Size, Itm);
            }
            Lst = CF.GetAllNamedEntries("Version");
            foreach (CFItem Itm in Lst)
            {
                m_VPVersion = ReadIntBinary(Itm) / 100;
            }
            Lst = CF.GetAllNamedEntries("MAC");
            foreach (CFItem Itm in Lst)
            {
                MD5Hash = GetFile(Itm);
            }

            Lst = CF.GetAllNamedEntries("GameData");
            foreach (CFItem Itm in Lst)
            {
                BIFFFile F = GetBIFF(Itm);
                F.IterateChunks(BlowChunk);
            }

            Script = GetScript();

            GetScriptDetails();

            if (ROMNameVar == "")
            {
                ROMNameVar = "\"" + ROM + "\"";
            }
        }
Exemplo n.º 3
0
        //Calculates the MD5 hash for the VPT file.
        //Note that order is important.

        //In BIFF files, the chunk length is NOT added to the hash, although the chunk
        //four-letter code and the contents of the chunk ARE.

        void CalculateHash()
        {
            //MD5 md5 = new MD5CryptoServiceProvider();
            //Hasher = md5;

            byte[] bf = Encoding.ASCII.GetBytes("Visual Pinball");
            HashData.AddRange(bf);

            HashRawFile("Version", ref Hasher);
            HashRawFile("TableName", ref Hasher);
            HashRawFile("AuthorName", ref Hasher);
            HashRawFile("TableVersion", ref Hasher);
            HashRawFile("ReleaseDate", ref Hasher);
            HashRawFile("AuthorEmail", ref Hasher);
            HashRawFile("AuthorWebSite", ref Hasher);
            HashRawFile("TableBlurb", ref Hasher);
            HashRawFile("TableDescription", ref Hasher);
            HashRawFile("TableRules", ref Hasher);
            HashRawFile("Screenshot", ref Hasher);

            HashBIFFFile("CustomInfoTags", ref Hasher);
            HashBIFFFile("GameData", ref Hasher);

            //Hasher.TransformFinalBlock(new byte[0], 0, 0);

            int Ttl = Int32.Parse(Properties["Total Objects"]);

            for (int x = 0; x < Ttl; x++)
            {
                IList <CFItem> Lstx = CF.GetAllNamedEntries("GameItem" + x);
                foreach (CFItem Itm in Lstx)
                {
                    BIFFFile F = GetBIFF(Itm);

                    byte[] NewBuffer = new byte[F.Buffer.Length - 4];
                    Buffer.BlockCopy(F.Buffer, 4, NewBuffer, 0, NewBuffer.Length);
                    F.Buffer = NewBuffer;
                    F.IterateChunks(HashChunk);

                    //Console.WriteLine("   Hashed GameItem BFF File: " + Itm.Name);
                }
            }

            Ttl = Int32.Parse(Properties["Total Collections"]);
            for (int x = 0; x < Ttl; x++)
            {
                IList <CFItem> Lstx = CF.GetAllNamedEntries("Collection" + x);
                foreach (CFItem Itm in Lstx)
                {
                    BIFFFile F = GetBIFF(Itm);

                    F.IterateChunks(HashChunk);

                    //Console.WriteLine("   Hashed GameItem BFF File: " + Itm.Name);
                }
            }

            var hash   = HashFactory.Crypto.CreateMD2();
            var result = hash.ComputeBytes(HashData.ToArray());

            /*System.IO.BinaryWriter Wri = new System.IO.BinaryWriter(System.IO.File.Create("c:\\tmp\\hashb.bin"));
             * Wri.Write(HashData.ToArray(), 0, HashData.Count);
             * Wri.Flush();
             * Wri.Close();*/

            MD5Hash = result.GetBytes();

            IList <CFItem> Lst = CF.GetAllNamedEntries("MAC");

            foreach (CFItem Itm in Lst)
            {
                WriteBinaryFile(MD5Hash, Itm);
            }
        }