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);
            }
        }
Esempio n. 2
0
        private static void SetLastError(int error)
        {
            int num = error;

            if (num == 8)
            {
                DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.NoFreeBuffers;
                return;
            }
            if (num != 234 && num != 534)
            {
                return;
            }
            DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
        }
        private static void SetLastError(int error)
        {
            int num = error;

            if (num == 8)
            {
                DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.NoFreeBuffers;
                return;
            }
            else
            {
                if (num == 234 || num == 0x216)
                {
                    DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
                    return;
                }
                else
                {
                    return;
                }
            }
        }
Esempio n. 4
0
        public unsafe bool WriteMessageEvent(string eventMessage, byte eventLevel, long eventKeywords)
        {
            int num = 0;

            if (eventMessage == null)
            {
                throw Fx.Exception.AsError(new ArgumentNullException("eventMessage"), null);
            }
            if (this.IsEnabled(eventLevel, eventKeywords))
            {
                if (eventMessage.Length > 32724)
                {
                    DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
                    return(false);
                }

                fixed(string str = eventMessage)
                {
                    string *offsetToStringData = &str;

                    if (offsetToStringData != null)
                    {
                        offsetToStringData = offsetToStringData + RuntimeHelpers.OffsetToStringData;
                    }
                    char *chrPointer = (char *)offsetToStringData;

                    num = (int)UnsafeNativeMethods.EventWriteString(this.traceRegistrationHandle, eventLevel, eventKeywords, chrPointer);
                }

                if (num != 0)
                {
                    DiagnosticsEventProvider.SetLastError(num);
                    return(false);
                }
            }
            return(true);
        }
        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"));
            }
        }
Esempio n. 6
0
        public unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, string data)
        {
            UnsafeNativeMethods.EventData length = new UnsafeNativeMethods.EventData();
            uint num = 0;

            data = data ?? string.Empty;
            if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                if (data.Length > 32724)
                {
                    DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
                    return(false);
                }
                Guid activityId = DiagnosticsEventProvider.GetActivityId();
                DiagnosticsEventProvider.SetActivityId(ref activityId);
                length.Size     = (uint)((data.Length + 1) * 2);
                length.Reserved = 0;
                fixed(string str = data)
                {
                    string *offsetToStringData = &str;

                    if (offsetToStringData != null)
                    {
                        offsetToStringData = offsetToStringData + RuntimeHelpers.OffsetToStringData;
                    }
                    length.DataPointer = (ulong)((char *)offsetToStringData);
                    num = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, 1, ref length);
                }
            }
            if (num == 0)
            {
                return(true);
            }
            DiagnosticsEventProvider.SetLastError((int)num);
            return(false);
        }
Esempio n. 7
0
        public unsafe bool WriteTransferEvent(ref EventDescriptor eventDescriptor, Guid relatedActivityId, params object[] eventPayload)
        {
            uint num = 0;

            if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                Guid activityId = DiagnosticsEventProvider.GetActivityId();
                if (eventPayload == null || (int)eventPayload.Length == 0)
                {
                    num = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref activityId, ref relatedActivityId, 0, 0);
                }
                else
                {
                    int length = (int)eventPayload.Length;
                    if (length > 32)
                    {
                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload", SRCore.EtwMaxNumberArgumentsExceeded(32)), null);
                    }
                    uint     size      = 0;
                    int      num1      = 0;
                    int[]    numArray  = new int[8];
                    string[] strArrays = new string[8];
                    UnsafeNativeMethods.EventData *eventDataPointer  = stackalloc UnsafeNativeMethods.EventData[checked (length * sizeof(UnsafeNativeMethods.EventData))];
                    UnsafeNativeMethods.EventData *eventDataPointer1 = eventDataPointer;
                    byte *numPointer = stackalloc byte[16 * length];
                    for (int i = 0; i < (int)eventPayload.Length; i++)
                    {
                        if (eventPayload[i] != null)
                        {
                            string str = DiagnosticsEventProvider.EncodeObject(ref eventPayload[i], eventDataPointer1, numPointer);
                            numPointer        = numPointer + 16;
                            size              = size + (*eventDataPointer1).Size;
                            eventDataPointer1 = eventDataPointer1 + sizeof(UnsafeNativeMethods.EventData);
                            if (str != null)
                            {
                                if (num1 >= 8)
                                {
                                    throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload", SRCore.EtwAPIMaxStringCountExceeded(8)), null);
                                }
                                strArrays[num1] = str;
                                numArray[num1]  = i;
                                num1++;
                            }
                        }
                    }
                    if (size > 65482)
                    {
                        DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
                        return(false);
                    }

                    fixed(string str1 = strArrays[0])
                    {
                        string *offsetToStringData = &str1;

                        if (offsetToStringData != null)
                        {
                            offsetToStringData = offsetToStringData + RuntimeHelpers.OffsetToStringData;
                        }
                        char *chrPointer = (char *)offsetToStringData;

                        fixed(string str2 = strArrays[1])
                        {
                            string *strPointers = &str2;

                            if (strPointers != null)
                            {
                                strPointers = strPointers + RuntimeHelpers.OffsetToStringData;
                            }
                            char *chrPointer1 = (char *)strPointers;

                            fixed(string str3 = strArrays[2])
                            {
                                string *offsetToStringData1 = &str3;

                                if (offsetToStringData1 != null)
                                {
                                    offsetToStringData1 = offsetToStringData1 + RuntimeHelpers.OffsetToStringData;
                                }
                                char *chrPointer2 = (char *)offsetToStringData1;

                                fixed(string str4 = strArrays[3])
                                {
                                    string *strPointers1 = &str4;

                                    if (strPointers1 != null)
                                    {
                                        strPointers1 = strPointers1 + RuntimeHelpers.OffsetToStringData;
                                    }
                                    char *chrPointer3 = (char *)strPointers1;

                                    fixed(string str5 = strArrays[4])
                                    {
                                        string *offsetToStringData2 = &str5;

                                        if (offsetToStringData2 != null)
                                        {
                                            offsetToStringData2 = offsetToStringData2 + RuntimeHelpers.OffsetToStringData;
                                        }
                                        char *chrPointer4 = (char *)offsetToStringData2;

                                        fixed(string str6 = strArrays[5])
                                        {
                                            string *strPointers2 = &str6;

                                            if (strPointers2 != null)
                                            {
                                                strPointers2 = strPointers2 + RuntimeHelpers.OffsetToStringData;
                                            }
                                            char *chrPointer5 = (char *)strPointers2;

                                            fixed(string str7 = strArrays[6])
                                            {
                                                string *offsetToStringData3 = &str7;

                                                if (offsetToStringData3 != null)
                                                {
                                                    offsetToStringData3 = offsetToStringData3 + RuntimeHelpers.OffsetToStringData;
                                                }
                                                char *chrPointer6 = (char *)offsetToStringData3;

                                                fixed(string str8 = strArrays[7])
                                                {
                                                    string *strPointers3 = &str8;

                                                    if (strPointers3 != null)
                                                    {
                                                        strPointers3 = strPointers3 + RuntimeHelpers.OffsetToStringData;
                                                    }
                                                    char *chrPointer7 = (char *)strPointers3;

                                                    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 activityId, ref relatedActivityId, (uint)length, eventDataPointer);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    str2 = null;
                    str3 = null;
                    str4 = null;
                    str5 = null;
                    str6 = null;
                    str7 = null;
                    str8 = null;
                }
            }
            if (num == 0)
            {
                return(true);
            }
            DiagnosticsEventProvider.SetLastError((int)num);
            return(false);
        }
        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);
            }
        }
Esempio n. 9
0
		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;
			}
		}
Esempio n. 10
0
		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"));
			}
		}
Esempio n. 11
0
		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;
			}
		}
Esempio n. 12
0
		private static void SetLastError(int error)
		{
			int num = error;
			if (num == 8)
			{
				DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.NoFreeBuffers;
				return;
			}
			else
			{
				if (num == 234 || num == 0x216)
				{
					DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
					return;
				}
				else
				{
					return;
				}
			}
		}