public void Comparse(RawHSD toCompare) { for (int i = 0; i < Math.Min(RootNodes.Count, toCompare.RootNodes.Count); i++) { var root1 = RootNodes[i]; var root2 = toCompare.RootNodes[i]; //CompareOffsets(toCompare, root1.Offset, root2.Offset, ""); } }
private void CompareOffsets(RawHSD toCompare, int offset1, int offset2, string depth) { if (offsetToData[offset1].Length != toCompare.offsetToData[offset2].Length) { Console.WriteLine($"{depth}: Size Mismatch sections at: {offset1.ToString("X")} {offset2.ToString("X")} {offsetToData[offset1].Length.ToString("X")} {toCompare.offsetToData[offset2].Length.ToString("X")}"); } if (offsetToOffsets[offset1].Count != toCompare.offsetToOffsets[offset2].Count) { Console.WriteLine($"{depth}: pointer count mismatch"); } // compare content var data1 = offsetToData[offset1]; var data2 = toCompare.offsetToData[offset2]; for (int j = 0; j < Math.Min(offsetToOffsets[offset1].Count, toCompare.offsetToOffsets[offset2].Count); j++) { int relativeOffset = (offsetToInnerOffsets[offset1][j] - offset1); int relativeOffset2 = (toCompare.offsetToInnerOffsets[offset2][j] - offset2); var nextoffset1 = offsetToOffsets[offset1][j]; var nextoffset2 = toCompare.offsetToOffsets[offset2][j]; CompareOffsets(toCompare, nextoffset1, nextoffset2, $"{depth}{relativeOffset.ToString("X")}->"); data1[relativeOffset] = 0; data1[relativeOffset + 1] = 0; data1[relativeOffset + 2] = 0; data1[relativeOffset + 3] = 0; data2[relativeOffset2] = 0; data2[relativeOffset2 + 1] = 0; data2[relativeOffset2 + 2] = 0; data2[relativeOffset2 + 3] = 0; } if (!data1.SequenceEqual(data2)) { Console.WriteLine($"{depth}: content mismatch"); } }