internal unsafe bool WriteEventRaw(ref EventDescriptor eventDescriptor, Guid *activityID, Guid *relatedActivityID, int dataCount, IntPtr data)
        {
            int num = UnsafeNativeMethods.ManifestEtw.EventWriteTransferWrapper(this.m_regHandle, ref eventDescriptor, activityID, relatedActivityID, dataCount, (EventProvider.EventData *)((void *)data));

            if (num != 0)
            {
                EventProvider.SetLastError(num);
                return(false);
            }
            return(true);
        }
        internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, Guid *activityID, Guid *childActivityID, params object[] eventPayload)
        {
            int num = 0;

            if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                int num2 = eventPayload.Length;
                if (num2 > 128)
                {
                    EventProvider.s_returnCode = EventProvider.WriteEventErrorCode.TooManyArgs;
                    return(false);
                }
                uint                     num3  = 0U;
                int                      i     = 0;
                List <int>               list  = new List <int>(8);
                List <object>            list2 = new List <object>(8);
                EventProvider.EventData *ptr;
                EventProvider.EventData *ptr2;
                byte *                   ptr4;
                bool                     flag;
                checked
                {
                    ptr  = stackalloc EventProvider.EventData[unchecked ((UIntPtr)(2 * num2)) * (UIntPtr)sizeof(EventProvider.EventData)];
                    ptr2 = ptr;
                    byte *ptr3 = stackalloc byte[unchecked ((UIntPtr)(32 * num2)) * 1];
                    ptr4 = ptr3;
                    flag = false;
                }
                for (int j = 0; j < eventPayload.Length; j++)
                {
                    if (eventPayload[j] == null)
                    {
                        EventProvider.s_returnCode = EventProvider.WriteEventErrorCode.NullInput;
                        return(false);
                    }
                    object obj = EventProvider.EncodeObject(ref eventPayload[j], ref ptr2, ref ptr4, ref num3);
                    if (obj != null)
                    {
                        int num4 = (int)((long)(ptr2 - ptr) - 1L);
                        if (!(obj is string))
                        {
                            if (eventPayload.Length + num4 + 1 - j > 128)
                            {
                                EventProvider.s_returnCode = EventProvider.WriteEventErrorCode.TooManyArgs;
                                return(false);
                            }
                            flag = true;
                        }
                        list2.Add(obj);
                        list.Add(num4);
                        i++;
                    }
                }
                num2 = (int)((long)(ptr2 - ptr));
                if (num3 > 65482U)
                {
                    EventProvider.s_returnCode = EventProvider.WriteEventErrorCode.EventTooBig;
                    return(false);
                }
                if (!flag && i < 8)
                {
                    while (i < 8)
                    {
                        list2.Add(null);
                        i++;
                    }

                    fixed(string text = (string)list2[0])
                    {
                        char *ptr5 = text;

                        if (ptr5 != null)
                        {
                            ptr5 += RuntimeHelpers.OffsetToStringData / 2;
                        }

                        fixed(string text2 = (string)list2[1])
                        {
                            char *ptr6 = text2;

                            if (ptr6 != null)
                            {
                                ptr6 += RuntimeHelpers.OffsetToStringData / 2;
                            }

                            fixed(string text3 = (string)list2[2])
                            {
                                char *ptr7 = text3;

                                if (ptr7 != null)
                                {
                                    ptr7 += RuntimeHelpers.OffsetToStringData / 2;
                                }

                                fixed(string text4 = (string)list2[3])
                                {
                                    char *ptr8 = text4;

                                    if (ptr8 != null)
                                    {
                                        ptr8 += RuntimeHelpers.OffsetToStringData / 2;
                                    }

                                    fixed(string text5 = (string)list2[4])
                                    {
                                        char *ptr9 = text5;

                                        if (ptr9 != null)
                                        {
                                            ptr9 += RuntimeHelpers.OffsetToStringData / 2;
                                        }

                                        fixed(string text6 = (string)list2[5])
                                        {
                                            char *ptr10 = text6;

                                            if (ptr10 != null)
                                            {
                                                ptr10 += RuntimeHelpers.OffsetToStringData / 2;
                                            }

                                            fixed(string text7 = (string)list2[6])
                                            {
                                                char *ptr11 = text7;

                                                if (ptr11 != null)
                                                {
                                                    ptr11 += RuntimeHelpers.OffsetToStringData / 2;
                                                }

                                                fixed(string text8 = (string)list2[7])
                                                {
                                                    char *ptr12 = text8;

                                                    if (ptr12 != null)
                                                    {
                                                        ptr12 += RuntimeHelpers.OffsetToStringData / 2;
                                                    }
                                                    ptr2 = ptr;
                                                    if (list2[0] != null)
                                                    {
                                                        ptr2[list[0]].Ptr = ptr5;
                                                    }
                                                    if (list2[1] != null)
                                                    {
                                                        ptr2[list[1]].Ptr = ptr6;
                                                    }
                                                    if (list2[2] != null)
                                                    {
                                                        ptr2[list[2]].Ptr = ptr7;
                                                    }
                                                    if (list2[3] != null)
                                                    {
                                                        ptr2[list[3]].Ptr = ptr8;
                                                    }
                                                    if (list2[4] != null)
                                                    {
                                                        ptr2[list[4]].Ptr = ptr9;
                                                    }
                                                    if (list2[5] != null)
                                                    {
                                                        ptr2[list[5]].Ptr = ptr10;
                                                    }
                                                    if (list2[6] != null)
                                                    {
                                                        ptr2[list[6]].Ptr = ptr11;
                                                    }
                                                    if (list2[7] != null)
                                                    {
                                                        ptr2[list[7]].Ptr = ptr12;
                                                    }
                                                    num   = UnsafeNativeMethods.ManifestEtw.EventWriteTransferWrapper(this.m_regHandle, ref eventDescriptor, activityID, childActivityID, num2, ptr);
                                                    text  = null;
                                                    text2 = null;
                                                    text3 = null;
                                                    text4 = null;
                                                    text5 = null;
                                                    text6 = null;
                                                    text7 = null;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    ptr2 = ptr;
                    GCHandle[] array = new GCHandle[i];
                    for (int k = 0; k < i; k++)
                    {
                        array[k] = GCHandle.Alloc(list2[k], GCHandleType.Pinned);
                        if (list2[k] is string)
                        {
                            fixed(string text9 = (string)list2[k])
                            {
                                char *ptr13 = text9;

                                if (ptr13 != null)
                                {
                                    ptr13 += RuntimeHelpers.OffsetToStringData / 2;
                                }
                                ptr2[list[k]].Ptr = ptr13;
                            }
                        }
                        else
                        {
                            fixed(byte *ptr14 = (byte[])list2[k])
                            {
                                ptr2[list[k]].Ptr = ptr14;
                            }
                        }
                    }
                    num = UnsafeNativeMethods.ManifestEtw.EventWriteTransferWrapper(this.m_regHandle, ref eventDescriptor, activityID, childActivityID, num2, ptr);
                    for (int l = 0; l < i; l++)
                    {
                        array[l].Free();
                    }
                }
            }
            if (num != 0)
            {
                EventProvider.SetLastError(num);
                return(false);
            }
            return(true);
        }