private unsafe void GetSessionInfo(Action <int, long> action)
        {
            int   num = 256;
            byte *ptr2;
            int   num2;

            do
            {
                byte *ptr = stackalloc byte[checked (unchecked ((UIntPtr)num) * 1)];
                ptr2 = ptr;
                fixed(Guid *ptr3 = &this.m_providerId)
                {
                    num2 = UnsafeNativeMethods.ManifestEtw.EnumerateTraceGuidsEx(UnsafeNativeMethods.ManifestEtw.TRACE_QUERY_INFO_CLASS.TraceGuidQueryInfo, (void *)ptr3, sizeof(Guid), (void *)ptr2, num, ref num);
                }

                if (num2 == 0)
                {
                    goto IL_40;
                }
            }while (num2 == 122);
            return;

IL_40:
            UnsafeNativeMethods.ManifestEtw.TRACE_GUID_INFO * ptr4 = (UnsafeNativeMethods.ManifestEtw.TRACE_GUID_INFO *)ptr2;
            UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO *ptr5 = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO *)(ptr4 + 1);
            int currentProcessId = (int)Win32Native.GetCurrentProcessId();

            for (int i = 0; i < ptr4->InstanceCount; i++)
            {
                if (ptr5->Pid == currentProcessId)
                {
                    UnsafeNativeMethods.ManifestEtw.TRACE_ENABLE_INFO *ptr6 = (UnsafeNativeMethods.ManifestEtw.TRACE_ENABLE_INFO *)(ptr5 + 1);
                    for (int j = 0; j < ptr5->EnableCount; j++)
                    {
                        action((int)ptr6[j].LoggerId, ptr6[j].MatchAllKeyword);
                    }
                }
                if (ptr5->NextOffset == 0)
                {
                    break;
                }
                byte *ptr7 = (byte *)ptr5;
                ptr5 = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO *)(ptr7 + ptr5->NextOffset);
            }
        }
Example #2
0
        private unsafe void GetSessionInfo(Action <int, long> action)
        {
            int   ReturnLength = 256;
            byte *numPtr;
            int   num1;

            do
            {
                numPtr = stackalloc byte[ReturnLength];

                fixed(Guid *guidPtr = &this.m_providerId)
                num1 = UnsafeNativeMethods.ManifestEtw.EnumerateTraceGuidsEx(UnsafeNativeMethods.ManifestEtw.TRACE_QUERY_INFO_CLASS.TraceGuidQueryInfo, (void *)guidPtr, sizeof(Guid), (void *)numPtr, ReturnLength, ref ReturnLength);

                if (num1 == 0)
                {
                    goto label_4;
                }
            }while (num1 == 122);
            return;

label_4:
            UnsafeNativeMethods.ManifestEtw.TRACE_GUID_INFO * traceGuidInfoPtr = (UnsafeNativeMethods.ManifestEtw.TRACE_GUID_INFO *)numPtr;
            UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO *providerInstanceInfoPtr = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO *)(traceGuidInfoPtr + 1);
            int num2 = (int)Win32Native.GetCurrentProcessId();

            for (int index1 = 0; index1 < traceGuidInfoPtr->InstanceCount; ++index1)
            {
                if (providerInstanceInfoPtr->Pid == num2)
                {
                    UnsafeNativeMethods.ManifestEtw.TRACE_ENABLE_INFO *traceEnableInfoPtr = (UnsafeNativeMethods.ManifestEtw.TRACE_ENABLE_INFO *)(providerInstanceInfoPtr + 1);
                    for (int index2 = 0; index2 < providerInstanceInfoPtr->EnableCount; ++index2)
                    {
                        action((int)traceEnableInfoPtr[index2].LoggerId, traceEnableInfoPtr[index2].MatchAllKeyword);
                    }
                }
                if (providerInstanceInfoPtr->NextOffset == 0)
                {
                    break;
                }
                providerInstanceInfoPtr = (UnsafeNativeMethods.ManifestEtw.TRACE_PROVIDER_INSTANCE_INFO *)((UIntPtr)providerInstanceInfoPtr + (UIntPtr)providerInstanceInfoPtr->NextOffset);
            }
        }