public EventDescriptorInternal(int id, byte version, byte channel, byte level, byte opcode, int task, long keywords)
 {
     if (id < 0)
     {
         throw new ArgumentOutOfRangeException("id", SRETW.GetString("ArgumentOutOfRange_NeedNonNegNum"));
     }
     if (id > 0xffff)
     {
         throw new ArgumentOutOfRangeException("id", SRETW.GetString("ArgumentOutOfRange_NeedValidId", new object[] { 1, (ushort)0xffff }));
     }
     this.m_id       = (ushort)id;
     this.m_version  = version;
     this.m_channel  = channel;
     this.m_level    = level;
     this.m_opcode   = opcode;
     this.m_keywords = keywords;
     if (task < 0)
     {
         throw new ArgumentOutOfRangeException("task", SRETW.GetString("ArgumentOutOfRange_NeedNonNegNum"));
     }
     if (task > 0xffff)
     {
         throw new ArgumentOutOfRangeException("task", SRETW.GetString("ArgumentOutOfRange_NeedValidId", new object[] { 1, (ushort)0xffff }));
     }
     this.m_task = (ushort)task;
 }
        public unsafe bool WriteTransferEvent(ref EventDescriptorInternal eventDescriptor, Guid relatedActivityId, params object[] eventPayload)
        {
            uint num = 0;

            if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                Guid activityId = GetActivityId();
                if ((eventPayload != null) && (eventPayload.Length != 0))
                {
                    int length = eventPayload.Length;
                    if (length > 0x20)
                    {
                        throw new ArgumentOutOfRangeException("eventPayload", SRETW.GetString("ArgumentOutOfRange_MaxArgExceeded", new object[] { 0x20 }));
                    }
                    uint       num3           = 0;
                    int        index          = 0;
                    int[]      numArray       = new int[8];
                    string[]   strArray       = new string[8];
                    EventData *userData       = (EventData *)stackalloc byte[(((IntPtr)length) * sizeof(EventData))];
                    EventData *dataDescriptor = userData;
                    byte *     dataBuffer     = stackalloc byte[(IntPtr)(0x10 * length)];
                    for (int i = 0; i < eventPayload.Length; i++)
                    {
                        if (eventPayload[i] != null)
                        {
                            string str = EncodeObject(ref eventPayload[i], dataDescriptor, dataBuffer);
                            dataBuffer += 0x10;
                            num3       += dataDescriptor->Size;
                            dataDescriptor++;
                            if (str != null)
                            {
                                if (index >= 8)
                                {
                                    throw new ArgumentOutOfRangeException("eventPayload", SRETW.GetString("ArgumentOutOfRange_MaxStringsExceeded", new object[] { 8 }));
                                }
                                strArray[index] = str;
                                numArray[index] = i;
                                index++;
                            }
                        }
                    }
                    if (num3 > 0xffca)
                    {
                        s_returnCode = WriteEventErrorCode.EventTooBig;
                        return(false);
                    }

                    fixed(char *str2 = ((char *)strArray[0]))
                    {
                        char *chPtr = str2;

                        fixed(char *str3 = ((char *)strArray[1]))
                        {
                            char *chPtr2 = str3;

                            fixed(char *str4 = ((char *)strArray[2]))
                            {
                                char *chPtr3 = str4;

                                fixed(char *str5 = ((char *)strArray[3]))
                                {
                                    char *chPtr4 = str5;

                                    fixed(char *str6 = ((char *)strArray[4]))
                                    {
                                        char *chPtr5 = str6;

                                        fixed(char *str7 = ((char *)strArray[5]))
                                        {
                                            char *chPtr6 = str7;

                                            fixed(char *str8 = ((char *)strArray[6]))
                                            {
                                                char *chPtr7 = str8;

                                                fixed(char *str9 = ((char *)strArray[7]))
                                                {
                                                    char *chPtr8 = str9;

                                                    dataDescriptor = userData;
                                                    if (strArray[0] != null)
                                                    {
                                                        dataDescriptor[numArray[0]].Ptr = (ulong)chPtr;
                                                    }
                                                    if (strArray[1] != null)
                                                    {
                                                        dataDescriptor[numArray[1]].Ptr = (ulong)chPtr2;
                                                    }
                                                    if (strArray[2] != null)
                                                    {
                                                        dataDescriptor[numArray[2]].Ptr = (ulong)chPtr3;
                                                    }
                                                    if (strArray[3] != null)
                                                    {
                                                        dataDescriptor[numArray[3]].Ptr = (ulong)chPtr4;
                                                    }
                                                    if (strArray[4] != null)
                                                    {
                                                        dataDescriptor[numArray[4]].Ptr = (ulong)chPtr5;
                                                    }
                                                    if (strArray[5] != null)
                                                    {
                                                        dataDescriptor[numArray[5]].Ptr = (ulong)chPtr6;
                                                    }
                                                    if (strArray[6] != null)
                                                    {
                                                        dataDescriptor[numArray[6]].Ptr = (ulong)chPtr7;
                                                    }
                                                    if (strArray[7] != null)
                                                    {
                                                        dataDescriptor[numArray[7]].Ptr = (ulong)chPtr8;
                                                    }
                                                    num = this.EventWriteTransfer(ref eventDescriptor, ref activityId, ref relatedActivityId, (uint)length, userData);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    str4 = null;
                    str5 = null;
                    str6 = null;
                    str7 = null;
                    str8 = null;
                    str9 = null;
                }
                else
                {
                    num = this.EventWriteTransfer(ref eventDescriptor, ref activityId, ref relatedActivityId, 0, null);
                }
            }
            if (num != 0)
            {
                SetLastError((int)num);
                return(false);
            }
            return(true);
        }