// Token: 0x06000E43 RID: 3651 RVA: 0x0003DBA0 File Offset: 0x0003BDA0 public unsafe static bool Decompress(byte[] inBuf, int inOffset, int inLength, byte[] outBuf, int outOffset, int expectedDecompressedLength) { if (expectedDecompressedLength == inLength) { Array.Copy(inBuf, inOffset, outBuf, outOffset, inLength); return(true); } int num = expectedDecompressedLength; fixed(byte *ptr = inBuf) { fixed(byte *ptr2 = outBuf) { if (Xpress.EcDecompressEx(new IntPtr((void *)((byte *)ptr + inOffset)), inLength, new IntPtr((void *)((byte *)ptr2 + outOffset)), ref num) == 0) { bool result; if (num != expectedDecompressedLength) { result = false; } else { result = true; } return(result); } } } return(false); }
// Token: 0x060017DA RID: 6106 RVA: 0x00062B9C File Offset: 0x00060D9C private int ReadXpressBlock(byte[] buf, int off, int len) { if (this.m_xpressReadBuf == null) { this.m_xpressReadBuf = new byte[65536]; } this.ReadChunk(this.m_readPacketHeaderBuf, 0, 4); ushort num = BitConverter.ToUInt16(this.m_readPacketHeaderBuf, 0); int num2 = (int)(num + 1); num = BitConverter.ToUInt16(this.m_readPacketHeaderBuf, 2); int num3 = (int)(num + 1); this.ReadChunk(this.m_xpressReadBuf, 0, num2); bool flag; if (num3 <= len) { flag = Xpress.Decompress(this.m_xpressReadBuf, 0, num2, buf, off, num3); } else { if (this.m_decompressBuf == null) { this.m_decompressBuf = new byte[65536]; } flag = Xpress.Decompress(this.m_xpressReadBuf, 0, num2, this.m_decompressBuf, 0, num3); } if (!flag) { NetworkPackagingLayer.Tracer.TraceError((long)this.GetHashCode(), "Decompression failed"); throw new NetworkCorruptDataException(this.PartnerNodeName); } ExchangeNetworkPerfmonCounters perfCounters = this.m_netChannel.PerfCounters; if (perfCounters != null && this.m_netChannel.NetworkPath != null) { perfCounters.RecordCompressedDataReceived(num2, num3, this.m_netChannel.NetworkPath.Purpose); } this.TotalDecompressedBytesReceived += (long)num3; this.TotalCompressedBytesReceived += (long)num2; if (num3 <= len) { this.m_bytesRemainingToReadInCurrentBlock = 0; return(num3); } this.m_decompressBufContentLen = num3; this.m_bytesRemainingToReadInCurrentBlock = num3 - len; Array.Copy(this.m_decompressBuf, 0, buf, off, len); NetworkPackagingLayer.Tracer.TraceError <int, int>((long)this.GetHashCode(), "NetPkg.ReadXpressBlock: Had to buffer 0x{0:X} uncompressed bytes for the next fetch since only 0x{1:X} were requested.", this.m_bytesRemainingToReadInCurrentBlock, len); return(len); }
// Token: 0x060017CF RID: 6095 RVA: 0x000624DC File Offset: 0x000606DC protected void WriteXpressBlock(byte[] buf, int offset, int length) { int num; Xpress.Compress(buf, offset, length, this.CompressBuf, 5, 65536, out num); this.CompressBuf[0] = 2; int num2 = 1; ushort val = (ushort)(num - 1); Serialization.SerializeUInt16(this.CompressBuf, ref num2, val); val = (ushort)(length - 1); Serialization.SerializeUInt16(this.CompressBuf, ref num2, val); this.m_tcpChannel.Write(this.CompressBuf, 0, 5 + num); }
private QueuedBlockMsg ReadCompressedMsg(NetworkChannel netChan, NetworkChannelMessageHeader msgHdr) { byte[] networkReadWorkingBuf = this.m_networkReadWorkingBuf; BlockModeCompressedDataMsg blockModeCompressedDataMsg = BlockModeCompressedDataMsg.ReadFromNet(netChan, networkReadWorkingBuf, 0); byte[] array = null; int num = 0; int num2 = 0; if (blockModeCompressedDataMsg.LogDataLength > 0) { this.GetAppendSpace(blockModeCompressedDataMsg.LogDataLength); array = this.m_currentBuffer.Buffer; num = this.m_currentBuffer.AppendOffset; int num3 = blockModeCompressedDataMsg.LogDataLength; int num4 = num; foreach (int num5 in blockModeCompressedDataMsg.CompressedLengths) { num2 += num5; netChan.Read(networkReadWorkingBuf, 0, num5); int num6 = Math.Min(num3, 65536); if (!Xpress.Decompress(networkReadWorkingBuf, 0, num5, array, num4, num6)) { throw new NetworkCorruptDataException(this.m_netChannel.PartnerNodeName); } num3 -= num6; num4 += num6; } this.m_currentBuffer.AppendOffset = num + blockModeCompressedDataMsg.LogDataLength; } return(new QueuedBlockMsg(blockModeCompressedDataMsg.EmitContext, array, num, num2) { RequestAckCounter = blockModeCompressedDataMsg.RequestAckCounter, IOBuffer = this.m_currentBuffer }); }
// Token: 0x06000E42 RID: 3650 RVA: 0x0003DADC File Offset: 0x0003BCDC public unsafe static bool Compress(byte[] inBuf, int inOffset, int inLength, byte[] outBuf, int outOffset, int maxOutLength, out int compressedSize) { DiagCore.RetailAssert(outBuf.Length >= outOffset + maxOutLength, "BufferOverflow: Offset({0}) + Len({1}) exceeds buffer length({2})", new object[] { outOffset, maxOutLength, outBuf.Length }); compressedSize = maxOutLength; fixed(byte *ptr = inBuf) { fixed(byte *ptr2 = outBuf) { if (Xpress.EcCompressEx(new IntPtr((void *)((byte *)ptr + inOffset)), inLength, new IntPtr((void *)((byte *)ptr2 + outOffset)), ref compressedSize) == 0 && compressedSize < inLength) { return(true); } } } compressedSize = inLength; Array.Copy(inBuf, inOffset, outBuf, outOffset, inLength); return(false); }
public static int SerializeToBuffer(JET_EMITDATACTX emitContext, byte[] logdata, int cblogdata, byte[] targetBuffer, int targetBufferOffsetToStart, out int totalCompressedSize) { NetworkChannelPacket networkChannelPacket = new NetworkChannelPacket(targetBuffer, targetBufferOffsetToStart); networkChannelPacket.GrowthDisabled = true; int num = BlockModeCompressedDataMsg.CalculateBlockCount(cblogdata); int[] array = new int[num]; int num2 = 73 + 4 * num; int num3 = num2 + targetBufferOffsetToStart; int num4 = 0; totalCompressedSize = 0; int num5 = cblogdata; for (int i = 0; i < num; i++) { int num6 = Math.Min(num5, 65536); Xpress.Compress(logdata, num4, num6, targetBuffer, num3, num6, out array[i]); num4 += num6; num3 += array[i]; totalCompressedSize += array[i]; num5 -= num6; } networkChannelPacket.Append(1); int val = num2 - 5 + totalCompressedSize; networkChannelPacket.Append(val); val = 1145261378; networkChannelPacket.Append(val); val = num2 - 5; networkChannelPacket.Append(val); DateTime utcNow = DateTime.UtcNow; networkChannelPacket.Append(utcNow); long val2 = 0L; networkChannelPacket.Append(val2); val2 = Win32StopWatch.GetSystemPerformanceCounter(); networkChannelPacket.Append(val2); networkChannelPacket.Append(cblogdata); val = emitContext.dwVersion; networkChannelPacket.Append(val); val2 = (long)emitContext.qwSequenceNum; networkChannelPacket.Append(val2); val = (int)emitContext.grbitOperationalFlags; networkChannelPacket.Append(val); DateTime time = DateTime.SpecifyKind(emitContext.logtimeEmit, DateTimeKind.Utc); networkChannelPacket.Append(time); val = emitContext.lgposLogData.lGeneration; networkChannelPacket.Append(val); ushort val3 = (ushort)emitContext.lgposLogData.isec; networkChannelPacket.Append(val3); val3 = (ushort)emitContext.lgposLogData.ib; networkChannelPacket.Append(val3); for (int j = 0; j < num; j++) { networkChannelPacket.Append(array[j]); } return(num2 + totalCompressedSize); }