Exemple #1
0
        private static Envelope ParseV1(EtwNativeEvent etwNativeEvent)
        {
            // EventId is one. This is a log written using EventSource Byte Array logging support.
            // Reading like this ensures that if exception is thrown, we know what failed
            long   occurenceFileTimeUtc = etwNativeEvent.ReadInt64();
            long   receiveFileTimeUtc   = etwNativeEvent.ReadInt64();
            string protocol             = etwNativeEvent.ReadUnicodeString();
            string source             = etwNativeEvent.ReadUnicodeString();
            string manifestId         = etwNativeEvent.ReadUnicodeString();
            uint   eventPayloadLength = etwNativeEvent.ReadUInt32(); // There is a side-effect being used here with the binary length.

            etwNativeEvent.ReadInt32();                              // EventSource based byte array writer actually stores the byte array length here. Skip 4 bytes to account for it.
            byte[] eventPayload = etwNativeEvent.ReadBytes();

            return(new Envelope(
                       occurenceFileTimeUtc >= 0
                    ? DateTimeOffset.FromFileTime(occurenceFileTimeUtc)
                    : DateTimeOffset.MinValue,
                       receiveFileTimeUtc >= 0
                    ? DateTimeOffset.FromFileTime(receiveFileTimeUtc)
                    : DateTimeOffset.MinValue,
                       protocol,
                       source,
                       manifestId,
                       eventPayload,
                       null));
        }
Exemple #2
0
        private static BinaryEnvelope ParseV1(EtwNativeEvent etwNativeEvent)
        {
            // EventId is one. This is a log written using EventSource Byte Array logging support.
            // Reading like this ensures that if exception is thrown, we know what failed
            long   occurenceFileTimeUtc = etwNativeEvent.ReadInt64();
            long   receiveFileTimeUtc   = etwNativeEvent.ReadInt64();
            string protocol             = etwNativeEvent.ReadUnicodeString();
            string source             = etwNativeEvent.ReadUnicodeString();
            string manifestId         = etwNativeEvent.ReadUnicodeString();
            uint   eventPayloadLength = etwNativeEvent.ReadUInt32(); // There is a side-effect being used here with the binary length.

            etwNativeEvent.ReadInt32();                              // EventSource based byte array writer actually stores the byte array length here. Skip 4 bytes to account for it.
            byte[] eventPayload = etwNativeEvent.ReadBytes();

            return(new BinaryEnvelope
            {
                ActivityId = etwNativeEvent.ActivityId,
                OccurenceFileTimeUtc = occurenceFileTimeUtc,
                ReceiveFileTimeUtc = receiveFileTimeUtc,
                Protocol = protocol,
                Source = source,
                PayloadId = manifestId,
                EventPayload = eventPayload,
                EventPayloadLength = eventPayloadLength
            });
        }