// Token: 0x060012C3 RID: 4803 RVA: 0x0006D894 File Offset: 0x0006BA94 private static int GetPropertyOffset(PropTag propTagToFind, byte[] propertyDescriptorsBuffer, int propertyDescriptorsOffset, int propertyCount, byte[] recordBuffer) { int num = -1; for (int i = 0; i < propertyCount; i++) { PropTag propTag = (PropTag)BitConverter.ToUInt32(propertyDescriptorsBuffer, propertyDescriptorsOffset + i * 2 * 4); if (propTag == propTagToFind) { num = i; break; } } if (num == -1) { return(0); } if (((int)recordBuffer[4 + num / 8] & 128 >> num % 8) == 0) { return(0); } int result = 4 + (propertyCount + 7) / 8; for (int j = 0; j < num; j++) { if (((int)recordBuffer[4 + j / 8] & 128 >> j % 8) != 0) { PropTag propTag2 = (PropTag)BitConverter.ToUInt32(propertyDescriptorsBuffer, propertyDescriptorsOffset + j * 2 * 4); DiffFileGenerator.SkipProperty(propTag2, recordBuffer, ref result); } } return(result); }
// Token: 0x060012CB RID: 4811 RVA: 0x0006DD94 File Offset: 0x0006BF94 private static void ReadNextRecord(Stream stream, bool isFromOldFile, ref uint recordCount, ref long fileBytesRemaining, ref byte[] recordBuffer, ref int recordBytesRemaining, ref Guid?objectGuid, ref byte[] propertyDescriptorsBuffer, ref int headerPropertyDescriptorsCount, ref int detailPropertyDescriptorsCount) { recordBuffer = DiffFileGenerator.ReadNextUncompressedRecord(stream); fileBytesRemaining -= (long)((ulong)recordBuffer.Length); recordBytesRemaining = recordBuffer.Length; recordCount += 1U; if (recordCount > 2U) { object detailPropertyValue = DiffFileGenerator.GetDetailPropertyValue((PropTag)2355953922U, recordBuffer, propertyDescriptorsBuffer, headerPropertyDescriptorsCount, detailPropertyDescriptorsCount, isFromOldFile); objectGuid = new Guid?(new Guid((byte[])detailPropertyValue)); return; } if (recordCount == 1U) { propertyDescriptorsBuffer = recordBuffer; headerPropertyDescriptorsCount = BitConverter.ToInt32(propertyDescriptorsBuffer, 4); detailPropertyDescriptorsCount = BitConverter.ToInt32(propertyDescriptorsBuffer, 8 + headerPropertyDescriptorsCount * 2 * 4); OABLogger.LogRecord(TraceType.InfoTrace, "PropertyDescriptorsBuffer is: {0}", new object[] { BitConverter.ToString(propertyDescriptorsBuffer) }); OABLogger.LogRecord(TraceType.InfoTrace, "Header property count is {0}, detail property count is {1}", new object[] { headerPropertyDescriptorsCount, detailPropertyDescriptorsCount }); } objectGuid = new Guid?(Guid.Empty); }
// Token: 0x060012BE RID: 4798 RVA: 0x0006D6F8 File Offset: 0x0006B8F8 private void WriteLzxPatch(Stream stream, DataPatching patchGenerator, byte[] oldBuffer, int oldSize, byte[] newBuffer, int newSize) { if (oldBuffer.Length != oldSize) { oldBuffer = DiffFileGenerator.GetArraySegment(oldBuffer, 0, oldSize); } if (newBuffer.Length != newSize) { newBuffer = DiffFileGenerator.GetArraySegment(newBuffer, 0, newSize); } byte[] array; if (patchGenerator.TryGenerate(oldBuffer, newBuffer, out array)) { uint crc = OABCRC.ComputeCRC(OABCRC.DefaultSeed, newBuffer); this.WritePatchBlock(stream, oldBuffer.Length, newBuffer.Length, array, array.Length, crc); return; } byte[][] array2 = DiffFileGenerator.SplitByteArray(oldBuffer); byte[][] array3 = DiffFileGenerator.SplitByteArray(newBuffer); for (int i = 0; i < 2; i++) { if (patchGenerator.TryGenerate(array2[i], array3[i], out array)) { uint crc2 = OABCRC.ComputeCRC(OABCRC.DefaultSeed, array3[i]); this.WritePatchBlock(stream, array2[i].Length, array3[i].Length, array, array.Length, crc2); } } }
// Token: 0x060012BF RID: 4799 RVA: 0x0006D7B4 File Offset: 0x0006B9B4 private static byte[][] SplitByteArray(byte[] byteArray) { int num = byteArray.Length / 2; int length = byteArray.Length - num; return(new byte[][] { DiffFileGenerator.GetArraySegment(byteArray, 0, num), DiffFileGenerator.GetArraySegment(byteArray, num, length) }); }
// Token: 0x060012C4 RID: 4804 RVA: 0x0006D934 File Offset: 0x0006BB34 private static void SkipProperty(PropTag propTag, byte[] recordBuffer, ref int propertyOffset) { int i = 1; int num = 0; if (propTag.IsMultiValued()) { DiffFileGenerator.GetV4IntegerValue(recordBuffer, ref propertyOffset, out i); } while (i > 0) { PropType propType = propTag.ValueType() & (PropType)(-4097); if (propType <= PropType.Boolean) { if (propType != PropType.Int && propType != PropType.Boolean) { goto IL_69; } DiffFileGenerator.GetV4IntegerValue(recordBuffer, ref propertyOffset, out num); } else { switch (propType) { case PropType.AnsiString: case PropType.String: while (recordBuffer[propertyOffset++] != 0) { } break; default: if (propType != PropType.Binary) { goto IL_69; } goto IL_69; } } IL_78: i--; continue; IL_69: DiffFileGenerator.GetV4IntegerValue(recordBuffer, ref propertyOffset, out num); propertyOffset += num; goto IL_78; } }
// Token: 0x060012C5 RID: 4805 RVA: 0x0006D9C4 File Offset: 0x0006BBC4 private static object GetPropertyValue(PropTag propTag, byte[] recordBuffer, ref int propertyOffset, bool isFromOldFile) { PropType propType = propTag.ValueType() & (PropType)(-4097); object result; switch (propType) { case PropType.AnsiString: case PropType.String: { int num = propertyOffset; while (recordBuffer[propertyOffset] != 0) { propertyOffset++; } result = Encoding.UTF8.GetString(recordBuffer, num, propertyOffset - num); break; } default: { if (propType != PropType.Binary) { throw new NotSupportedException(string.Format("GetProperty doesn't support property type {0} now", propTag.ValueType())); } int num2; DiffFileGenerator.GetV4IntegerValue(recordBuffer, ref propertyOffset, out num2); if (num2 <= 0) { OABLogger.LogRecord(TraceType.FatalTrace, "Invalid binary property data for tag {0} from {1} file . The offset is {2}. The binary blob is {3}", new object[] { propTag.ToString(), isFromOldFile ? "old" : "new", propertyOffset, BitConverter.ToString(recordBuffer) }); throw new InvalidDataException(string.Format("Invalid binary property data for tag {0}", propTag.ToString())); } byte[] array = new byte[num2]; Array.Copy(recordBuffer, propertyOffset, array, 0, num2); propertyOffset += num2; result = array; break; } } return(result); }
// Token: 0x060012BC RID: 4796 RVA: 0x0006D26C File Offset: 0x0006B46C private bool CreatePatch(Stream diffStream) { this.abortProcessingOnShutdown(); bool result; using (DataPatching dataPatching = new DataPatching(Globals.MaxCompressionBlockSize, Globals.MaxCompressionBlockSize, Globals.MaxCompressionBlockSize)) { using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(this.oldFile.UncompressedFileStream))) { using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream, this.stats)) { using (IOCostStream iocostStream2 = new IOCostStream(new NoCloseStream(this.newFile.UncompressedFileStream))) { using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream2, this.stats)) { byte[] array = new byte[Globals.MaxCompressionBlockSize]; byte[] array2 = new byte[Globals.MaxCompressionBlockSize]; int num; uint oldCRC; DiffFileGenerator.ReadFileHeader(iocostStream, array, out num, out oldCRC); int num2; uint newCRC; DiffFileGenerator.ReadFileHeader(iocostStream2, array2, out num2, out newCRC); this.WriteDiffFileHeader(diffStream, oldCRC, newCRC); uint num3 = 0U; uint num4 = 0U; long num5 = iocostStream.Length - (long)num; long num6 = iocostStream2.Length - (long)num2; byte[] array3 = null; byte[] array4 = null; int num7 = 0; int num8 = 0; Guid? guid = null; Guid? guid2 = null; byte[] propertyDescriptorsBuffer = null; byte[] propertyDescriptorsBuffer2 = null; int headerPropertyDescriptorsCount = 0; int headerPropertyDescriptorsCount2 = 0; int num9 = 0; int num10 = 0; bool flag = false; int num11 = 0; for (;;) { this.abortProcessingOnShutdown(); if (num5 != 0L && num11 <= 0 && num7 == 0) { DiffFileGenerator.ReadNextRecord(iocostStream, true, ref num3, ref num5, ref array3, ref num7, ref guid, ref propertyDescriptorsBuffer, ref headerPropertyDescriptorsCount, ref num9); } if (num6 != 0L && num11 >= 0 && num8 == 0) { DiffFileGenerator.ReadNextRecord(iocostStream2, false, ref num4, ref num6, ref array4, ref num8, ref guid2, ref propertyDescriptorsBuffer2, ref headerPropertyDescriptorsCount2, ref num10); } bool flag2 = false; if (guid != null && guid2 != null) { num11 = guid.Value.CompareTo(guid2.Value); } else if (guid == null && guid2 != null) { flag = true; num11 = 2; } else { if (guid == null || guid2 != null) { break; } flag = true; num11 = -2; } if (num11 == 0 && num > 0 && num2 > 0 && (num + array3.Length > Globals.MaxCompressionBlockSize || num2 + array4.Length > Globals.MaxCompressionBlockSize)) { flag2 = true; } else { if (num11 != 0) { flag = true; if (num11 < 0) { this.stats.IncrementRecordsDeletedChurn(); } else { this.stats.IncrementRecordsAddedChurn(); } } else if (num3 == 2U && num4 == 2U) { string a = (string)DiffFileGenerator.GetHeaderPropertyValue(OABFilePropTags.OabName, array3, propertyDescriptorsBuffer, headerPropertyDescriptorsCount, true); string b = (string)DiffFileGenerator.GetHeaderPropertyValue(OABFilePropTags.OabName, array4, propertyDescriptorsBuffer2, headerPropertyDescriptorsCount2, false); flag = (a != b); } else if (array3.Length != array4.Length || !array3.SequenceEqual(array4)) { flag = true; this.stats.IncrementRecordsModifiedChurn(); } if (num11 <= 0) { if (num + array3.Length <= Globals.MaxCompressionBlockSize || array3.Length > Globals.MaxCompressionBlockSize) { DiffFileGenerator.ConsumeRecord(array, ref num, array3, ref num7, ref guid, ref flag2); } else { flag2 = true; } } if (num11 >= 0) { if (num2 + array4.Length <= Globals.MaxCompressionBlockSize || array4.Length > Globals.MaxCompressionBlockSize) { DiffFileGenerator.ConsumeRecord(array2, ref num2, array4, ref num8, ref guid2, ref flag2); } else { flag2 = true; } } } if (flag2) { this.WriteLzxPatch(diffStream, dataPatching, array, num, array2, num2); num = 0; num2 = 0; } } if (num5 == 0L && num6 != 0L) { } if (num != 0 || num2 != 0) { this.WriteLzxPatch(diffStream, dataPatching, array, num, array2, num2); } result = flag; } } } } } return(result); }
// Token: 0x060012C9 RID: 4809 RVA: 0x0006DD18 File Offset: 0x0006BF18 private static object GetDetailPropertyValue(PropTag propTag, byte[] recordBuffer, byte[] propertyDescriptorsBuffer, int headerPropertyDescriptorsCount, int detailPropertyDescriptorsCount, bool isFromOldFile) { int propertyOffset = DiffFileGenerator.GetPropertyOffset(propTag, propertyDescriptorsBuffer, 12 + headerPropertyDescriptorsCount * 2 * 4, detailPropertyDescriptorsCount, recordBuffer); return(DiffFileGenerator.GetPropertyValue(propTag, recordBuffer, ref propertyOffset, isFromOldFile)); }