public void processMetadata(byte[] rawROMData, string metadataName) { metadata = new MetadataManager(metadataName); byte[][] init_table = metadata.getMetadataTable("INIT"); //INIT metadata only has 1 row. if(init_table == null) //INIT { setUpMetadata(); } else { //In case something happened to the data addTableIfDoesNotExist("XORD"); addTableIfDoesNotExist("FREE"); //XORD //Read XOR diffs from base byte[][] xorDiffs_raw = metadata.getMetadataTable("XORD"); foreach (byte[] xorDiff in xorDiffs_raw) { int offset = BitConverter.ToInt32(xorDiff, 0); byte[] diff = xorDiff.Skip(4).ToArray(); //xorDiffs.Add(Tuple.Create(offset, diff)); //Only keep logs from start of current session. condensedDiffs.Add(Tuple.Create(offset, diff)); applyXORDiff(offset, diff); //Get ROM to most recent ver } /* //Read XOR diffs LOG xorDiffs_raw = metadata.tryToGetTable("XORL"); foreach (byte[] xorDiff in xorDiffs_raw) { int offset = BitConverter.ToInt32(xorDiff, 0); byte[] diff = xorDiff.Skip(4).ToArray(); xorDiffsLog.Add(Tuple.Create(offset, diff)); }*/ //FREE byte[][] freeList = metadata.getMetadataTable("FREE"); foreach(byte[] free in freeList) { int start = BitConverter.ToInt32(free, 0); int end = BitConverter.ToInt32(free, 4); freeSpace.addRange(start, end); } } }