public unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, string data) { uint num = 0; string str = data; string empty = str; if (str == null) { empty = string.Empty; } data = empty; if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords)) { if (data.Length <= 0x7fd4) { if (eventTraceActivity != null) { DiagnosticsEventProvider.SetActivityId(ref eventTraceActivity.ActivityId); } UnsafeNativeMethods.EventData length; length.Size = (data.Length + 1) * 2; length.Reserved = 0; fixed(string str1 = data) { string *strPointers = &str1; char * offsetToStringData = (char *)(&str1); if (&str1 != null) { offsetToStringData = (char *)(strPointers + RuntimeHelpers.OffsetToStringData); } length.DataPointer = (ulong)offsetToStringData; num = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, 1, ref length); } } else { DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig; return(false); } } if (num == 0) { return(true); } else { DiagnosticsEventProvider.SetLastError(num); return(false); } }
protected internal bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, int dataCount, IntPtr data) { if (eventTraceActivity != null) { DiagnosticsEventProvider.SetActivityId(ref eventTraceActivity.ActivityId); } uint num = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, dataCount, (void *)data); if (num == 0) { return(true); } else { DiagnosticsEventProvider.SetLastError(num); return(false); } }
protected bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, int dataCount, IntPtr data) { if (eventTraceActivity != null) { uint num = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, dataCount, (void *)data); if (num == 0) { return(true); } else { DiagnosticsEventProvider.SetLastError(num); return(false); } } else { throw Fx.Exception.ArgumentNull("eventTraceActivity"); } }
public unsafe bool WriteMessageEvent(EventTraceActivity eventTraceActivity, string eventMessage, byte eventLevel, long eventKeywords) { if (eventMessage != null) { if (eventTraceActivity != null) { DiagnosticsEventProvider.SetActivityId(ref eventTraceActivity.ActivityId); } if (this.IsEnabled(eventLevel, eventKeywords)) { if (eventMessage.Length <= 0x7fd4) { fixed(string str = eventMessage) { string *strPointers = &str; char * offsetToStringData = (char *)(&str); if (&str != null) { offsetToStringData = (char *)(strPointers + RuntimeHelpers.OffsetToStringData); } int num = UnsafeNativeMethods.EventWriteString(this.traceRegistrationHandle, eventLevel, eventKeywords, offsetToStringData); } } else { DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig; return(false); } } return(true); } else { throw Fx.Exception.AsError(new ArgumentNullException("eventMessage")); } }
public unsafe bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, object[] eventPayload) { if (eventTraceActivity == null) { eventTraceActivity = EventTraceActivity.Empty; } uint num = 0; if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords)) { if (eventPayload == null || (int)eventPayload.Length == 0) { num = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, 0, 0); } else { int length = (int)eventPayload.Length; if (length <= 32) { uint size = 0; int num1 = 0; int[] numArray = new int[8]; string[] strArrays = new string[8]; UnsafeNativeMethods.EventData *eventDataPointer = (UnsafeNativeMethods.EventData *)length * sizeof(UnsafeNativeMethods.EventData); UnsafeNativeMethods.EventData *eventDataPointer1 = eventDataPointer; byte *numPointer = (byte *)16 * length; byte *numPointer1 = numPointer; for (int i = 0; i < (int)eventPayload.Length; i++) { if (eventPayload[i] != null) { string str = DiagnosticsEventProvider.EncodeObject(ref eventPayload[i], eventDataPointer1, numPointer1); numPointer1 = numPointer1 + 16; size = size + (*(eventDataPointer1)).Size; eventDataPointer1 = (UnsafeNativeMethods.EventData *)(eventDataPointer1 + sizeof(UnsafeNativeMethods.EventData)); if (str != null) { if (num1 >= 8) { throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload", InternalSR.EtwAPIMaxStringCountExceeded(8))); } else { strArrays[num1] = str; numArray[num1] = i; num1++; } } } } if (size <= 0xffca) { fixed(string str1 = strArrays[0]) { string *strPointers = &str1; char * offsetToStringData = (char *)(&str1); if (&str1 != null) { offsetToStringData = (char *)(strPointers + RuntimeHelpers.OffsetToStringData); } char *chrPointer = offsetToStringData; fixed(string str2 = strArrays[1]) { string *strPointers1 = &str2; char * offsetToStringData1 = (char *)(&str2); if (&str2 != null) { offsetToStringData1 = (char *)(strPointers1 + RuntimeHelpers.OffsetToStringData); } char *chrPointer1 = offsetToStringData1; fixed(string str3 = strArrays[2]) { string *strPointers2 = &str3; char * offsetToStringData2 = (char *)(&str3); if (&str3 != null) { offsetToStringData2 = (char *)(strPointers2 + RuntimeHelpers.OffsetToStringData); } char *chrPointer2 = offsetToStringData2; fixed(string str4 = strArrays[3]) { string *strPointers3 = &str4; char * offsetToStringData3 = (char *)(&str4); if (&str4 != null) { offsetToStringData3 = (char *)(strPointers3 + RuntimeHelpers.OffsetToStringData); } char *chrPointer3 = offsetToStringData3; fixed(string str5 = strArrays[4]) { string *strPointers4 = &str5; char * offsetToStringData4 = (char *)(&str5); if (&str5 != null) { offsetToStringData4 = (char *)(strPointers4 + RuntimeHelpers.OffsetToStringData); } char *chrPointer4 = offsetToStringData4; fixed(string str6 = strArrays[5]) { string *strPointers5 = &str6; char * offsetToStringData5 = (char *)(&str6); if (&str6 != null) { offsetToStringData5 = (char *)(strPointers5 + RuntimeHelpers.OffsetToStringData); } char *chrPointer5 = offsetToStringData5; fixed(string str7 = strArrays[6]) { string *strPointers6 = &str7; char * offsetToStringData6 = (char *)(&str7); if (&str7 != null) { offsetToStringData6 = (char *)(strPointers6 + RuntimeHelpers.OffsetToStringData); } char *chrPointer6 = offsetToStringData6; fixed(string str8 = strArrays[7]) { string *strPointers7 = &str8; char * offsetToStringData7 = (char *)(&str8); if (&str8 != null) { offsetToStringData7 = (char *)(strPointers7 + RuntimeHelpers.OffsetToStringData); } char *chrPointer7 = offsetToStringData7; eventDataPointer1 = eventDataPointer; if (strArrays[0] != null) { (eventDataPointer1 + numArray[0] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer; } if (strArrays[1] != null) { (eventDataPointer1 + numArray[1] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer1; } if (strArrays[2] != null) { (eventDataPointer1 + numArray[2] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer2; } if (strArrays[3] != null) { (eventDataPointer1 + numArray[3] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer3; } if (strArrays[4] != null) { (eventDataPointer1 + numArray[4] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer4; } if (strArrays[5] != null) { (eventDataPointer1 + numArray[5] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer5; } if (strArrays[6] != null) { (eventDataPointer1 + numArray[6] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer6; } if (strArrays[7] != null) { (eventDataPointer1 + numArray[7] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer7; } num = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, length, eventDataPointer); } } } } } } } } } else { DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig; return(false); } } else { throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload", InternalSR.EtwMaxNumberArgumentsExceeded(32))); } } } if (num == 0) { return(true); } else { DiagnosticsEventProvider.SetLastError(num); return(false); } }