Esempio n. 1
0
 private void CompareEntryList <T>(EntryList <T> a, EntryList <T> b) where T : EntryBase
 {
     for (var i = 0; i < a.Count; i++)
     {
         BinMapHelper.ModelCompare(a.ToList()[i], b.ToList()[i]);
     }
 }
Esempio n. 2
0
        public void BinaryCompare()
        {
            var wr = ModelFactory.GetModel <StfsPackage>(@"..\..\..\..\Resources\mergeable\aktualis\merge.1x");

            MapPackage(wr);
            var ok = ModelFactory.GetModel <StfsPackage>(@"..\..\..\..\Resources\variations2\8");

            MapPackage(ok);

            Debug.WriteLine("{0} {1}", wr.VolumeDescriptor.AllocatedBlockCount, ok.VolumeDescriptor.AllocatedBlockCount);

            //for (var i = 0; i < wr.FileStructure.Files.Count; i++)
            //{
            //    if (wr.FileStructure.Files[i].Flags != ok.FileStructure.Files[i].Flags)
            //    {
            //        Debug.WriteLine("{0} {1}", wr.FileStructure.Files[i].BlocksAreConsecutive, ok.FileStructure.Files[i].BlocksAreConsecutive);
            //    }
            //}

            //for (var i = 0; i < wr.FileStructure.Files.Count; i++)
            //{
            //    wr.FileStructure.Files[i].CreatedTimeStamp = ok.FileStructure.Files[i].CreatedTimeStamp;
            //    wr.FileStructure.Files[i].AccessTimeStamp = ok.FileStructure.Files[i].AccessTimeStamp;
            //}

            //wr.GetHashEntry(6224).BlockHash = wr.HashBlock(wr.GetRealAddressOfBlock(6224));
            //wr.Binary.WriteBytes(wr.TopTable.StartOffset + 4083, ok.Binary.ReadBytes(ok.TopTable.StartOffset + 4083, 0x1), 0, 0x1);

            //wr.TopTable.Entries[0].BlockHash = wr.HashBlock(wr.TopTable.Tables[0].StartOffset);
            //wr.VolumeDescriptor.TopHashTableHash = wr.HashBlock(wr.TopTable.StartOffset);

            //wr.Binary.WriteBytes(4, ok.Binary.ReadBytes(4, ok.Certificate.OffsetTableSize), 0, ok.Certificate.OffsetTableSize);
            //wr.Binary.WriteBytes(0x14F7240, ok.Binary.ReadBytes(0x14F7240, 64), 0, 64);
            //wr.HeaderHash = ok.HeaderHash;
            //wr.ThumbnailImage = ok.ThumbnailImage;

            File.WriteAllBytes(@"..\..\..\..\Resources\mergeable\aktualis\merge.1xx", wr.Binary.ReadAll());
            //return;

            //wr.Save(@"..\..\..\..\Resources\compare\deathspank.wr2");

            //var w = wr.FileStructure.Files.First(f => f.Name == "58410A6F.gpd");
            //var o = ok.FileStructure.Files.First(f => f.Name == "58410A6F.gpd");

            //Debug.WriteLine("WR: ");
            //var block = w.StartingBlockNum;
            //for (var i = 0; i < w.BlocksForFile; i++)
            //{
            //    var he = wr.GetHashEntry(block);
            //    Debug.WriteLine("{0,4}\t{1}", block, he.BlockHash.ToHex());
            //    block = he.NextBlock;
            //}

            //Debug.WriteLine("OK: ");
            //block = o.StartingBlockNum;
            //for (var i = 0; i < o.BlocksForFile; i++)
            //{
            //    var he = ok.GetHashEntry(block);
            //    Debug.WriteLine("{0,4}\t{1}", block, he.BlockHash.ToHex());
            //    block = he.NextBlock;
            //}

            BinMapHelper.ModelCompare(wr, ok);

            //Debug.WriteLine("{0} {1}", wr.TopTable.Entries[13].BlockHash.ToHex(), ok.TopTable.Entries[13].BlockHash.ToHex());
            //var wrTable = wr.TopTable.Tables[13];
            ////var wrData = wr.Binary.ReadBytes(wrTable.StartOffset, 0x1000);

            ////Debug.WriteLine(wrData.ToHex());

            //var okTable = ok.TopTable.Tables[13];
            ////var okData = ok.Binary.ReadBytes(okTable.StartOffset, 0x1000);

            //for (var j = 0; j < wrTable.EntryCount; j++)
            //{
            //    var entry = wrTable.Entries[j];
            //    if (entry.Status == BlockStatus.NewlyAllocated) entry.Status = BlockStatus.Allocated;
            //}

            ////Assert.AreEqual(wrData, okData);
            //Debug.WriteLine("{0} {1}", wr.HashBlock(wrTable.StartOffset).ToHex(), ok.HashBlock(okTable.StartOffset).ToHex());

            //Debug.WriteLine("WR: {0}%", (double)wrCoverage / wr.Binary.Length * 100);
        }