public unsafe static int PackInfo(byte[] destinationBuffer, ref int pos, int maxSize) { BipBuffer buffer = DiagnosticContext.GetBuffer(); if (maxSize < DiagnosticContext.ContextBuffer.StructSize) { return(0); } while (maxSize < DiagnosticContext.Size) { DiagnosticContext.FlushHeadRecord(buffer); } fixed(byte *ptr = &destinationBuffer[pos]) { DiagnosticContext.ContextBuffer *ptr2 = (DiagnosticContext.ContextBuffer *)ptr; ptr2->Format = byte.MaxValue; ptr2->ThreadID = (uint)Environment.CurrentManagedThreadId; ptr2->RequestID = 0U; ptr2->Flags = (byte)(2 | (DiagnosticContext.overFlow ? 1 : 0)); ptr2->Length = (uint)buffer.AllocatedSize; } pos += DiagnosticContext.ContextBuffer.StructSize; maxSize -= DiagnosticContext.ContextBuffer.StructSize; int allocatedSize = buffer.AllocatedSize; buffer.Extract(destinationBuffer, pos, allocatedSize); pos += allocatedSize; return(allocatedSize + DiagnosticContext.ContextBuffer.StructSize); }
private static void FlushHeadRecord(BipBuffer buf) { byte b; buf.Extract(3, out b); int num = (b >> 4) * 8; buf.Release(num - 4); DiagnosticContext.overFlow = true; }
public static void ExtractInfo(BipBuffer buf, int maxSize, out byte[] info) { while (maxSize < buf.AllocatedSize) { DiagnosticContext.FlushHeadRecord(buf); } int allocatedSize = buf.AllocatedSize; info = new byte[allocatedSize]; buf.Extract(info, 0, allocatedSize); }