private void LogInstalledCategoryNames(string iniFileName, string action_prefix)
        {
            int num = 40000;
            SafeHGlobalHandle safeHGlobalHandle2;
            SafeHGlobalHandle safeHGlobalHandle = safeHGlobalHandle2 = new SafeHGlobalHandle(Marshal.AllocHGlobal(num * 2));

            try
            {
                int privateProfileStringSpecial = ManagePerfCounters.GetPrivateProfileStringSpecial("objects", null, null, safeHGlobalHandle, num, iniFileName);
                if (privateProfileStringSpecial > 0 && privateProfileStringSpecial < num - 2)
                {
                    int num2 = 160000;
                    SafeHGlobalHandle safeHGlobalHandle4;
                    SafeHGlobalHandle safeHGlobalHandle3 = safeHGlobalHandle4 = new SafeHGlobalHandle(Marshal.AllocHGlobal(num2 * 2));
                    try
                    {
                        int privateProfileStringSpecial2 = ManagePerfCounters.GetPrivateProfileStringSpecial("text", null, null, safeHGlobalHandle3, num2, iniFileName);
                        if (privateProfileStringSpecial2 > 0 && privateProfileStringSpecial2 < num2 - 2)
                        {
                            StringBuilder stringBuilder = new StringBuilder(10000);
                            string        path          = Path.Combine(ConfigurationContext.Setup.LoggingPath, "lodctr_backups\\InstalledPerfCategories.log");
                            IntPtr        ptr           = safeHGlobalHandle.DangerousGetHandle();
                            for (;;)
                            {
                                string text = Marshal.PtrToStringUni(ptr);
                                if (string.IsNullOrEmpty(text))
                                {
                                    break;
                                }
                                int num3 = text.LastIndexOf('_');
                                if (num3 > 0)
                                {
                                    int num4 = text.LastIndexOf('_', num3 - 1, num3);
                                    if (num4 > 0)
                                    {
                                        string strA = text.Substring(0, num4);
                                        IntPtr ptr2 = safeHGlobalHandle3.DangerousGetHandle();
                                        for (;;)
                                        {
                                            string text2 = Marshal.PtrToStringUni(ptr2);
                                            if (string.IsNullOrEmpty(text2))
                                            {
                                                break;
                                            }
                                            int num5 = text2.LastIndexOf('_');
                                            if (num5 > 0)
                                            {
                                                int num6 = text2.LastIndexOf('_', num5 - 1, num5);
                                                if (num6 > 0)
                                                {
                                                    string strB = text2.Substring(0, num6);
                                                    if (string.Compare(strA, strB) == 0 && !text2.EndsWith("_HELP") && ManagePerfCounters.GetPrivateProfileString("text", text2, null, stringBuilder, stringBuilder.Capacity, iniFileName) != 0)
                                                    {
                                                        File.AppendAllText(path, string.Format("{0}-{1}-{2}={3}\r\n", new object[]
                                                        {
                                                            action_prefix,
                                                            Path.GetFileName(iniFileName),
                                                            text2,
                                                            stringBuilder
                                                        }), new UnicodeEncoding());
                                                    }
                                                }
                                            }
                                            ptr2 = (IntPtr)(ptr2.ToInt64() + (long)((text2.Length + 1) * 2));
                                        }
                                    }
                                }
                                ptr = (IntPtr)(ptr.ToInt64() + (long)((text.Length + 1) * 2));
                            }
                        }
                    }
                    finally
                    {
                        if (safeHGlobalHandle4 != null)
                        {
                            ((IDisposable)safeHGlobalHandle4).Dispose();
                        }
                    }
                }
            }
            finally
            {
                if (safeHGlobalHandle2 != null)
                {
                    ((IDisposable)safeHGlobalHandle2).Dispose();
                }
            }
        }
        private void ReadDefinitionFile()
        {
            TaskLogger.LogEnter();
            XmlDocument xmlDocument = new XmlDocument();

            try
            {
                base.WriteVerbose(Strings.PerfCounterProcessingFile(this.DefinitionFileName));
                xmlDocument.Load(this.DefinitionFileName);
                this.CategoryName = ManagePerfCounters.ReadStringElement(xmlDocument, "Category/Name");
                this.iniFileName  = ManagePerfCounters.ReadStringElement(xmlDocument, "Category/IniFileName");
                string text = ManagePerfCounters.ReadStringElement(xmlDocument, "Category/CategoryType");
                if (!text.Equals("SingleInstance", StringComparison.OrdinalIgnoreCase))
                {
                    this.categoryType = PerformanceCounterCategoryType.MultiInstance;
                }
                this.iniFileName = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(this.DefinitionFileName)), this.iniFileName);
                XmlNode xmlNode = xmlDocument.SelectSingleNode("Category/PerfmonExtensionDll");
                if (xmlNode != null)
                {
                    this.unmanagedCategory        = true;
                    this.extensionDllInfo.Library = ManagePerfCounters.ReadStringElement(xmlNode, "Library");
                    this.extensionDllInfo.Open    = ManagePerfCounters.ReadStringElement(xmlNode, "Open");
                    this.extensionDllInfo.Collect = ManagePerfCounters.ReadStringElement(xmlNode, "Collect");
                    this.extensionDllInfo.Close   = ManagePerfCounters.ReadStringElement(xmlNode, "Close");
                    this.extensionDllInfo.UseExpandedStringForLibrary = false;
                    string directoryName = Path.GetDirectoryName(Path.GetFullPath(this.DefinitionFileName));
                    string text2         = Path.Combine(ConfigurationContext.Setup.BinPerfProcessorPath, this.extensionDllInfo.Library);
                    if (File.Exists(text2))
                    {
                        text2 = string.Format("{0}\\Perf\\{1}\\{2}", ConfigurationContext.Setup.BinPath, "%PROCESSOR_ARCHITECTURE%", this.extensionDllInfo.Library);
                        this.extensionDllInfo.UseExpandedStringForLibrary = true;
                    }
                    else
                    {
                        text2 = Path.Combine(directoryName, this.extensionDllInfo.Library);
                        if (!File.Exists(text2))
                        {
                            text2 = Path.Combine(Path.Combine(directoryName, "..\\..\\bin"), this.extensionDllInfo.Library);
                            if (!File.Exists(text2))
                            {
                                text2 = Path.Combine(Path.Combine(directoryName, "..\\..\\common"), this.extensionDllInfo.Library);
                                if (!File.Exists(text2))
                                {
                                    base.WriteError(new TaskException(Strings.ExceptionPerfCounterInvalidDefinitionFile), ErrorCategory.InvalidData, null);
                                }
                            }
                        }
                    }
                    this.extensionDllInfo.Library = text2;
                }
                else
                {
                    using (XmlNodeList xmlNodeList = xmlDocument.SelectNodes("Category/Counters/Counter"))
                    {
                        if (xmlNodeList.Count == 0)
                        {
                            base.WriteError(new TaskException(Strings.ExceptionPerfCounterInvalidDefinitionFile), ErrorCategory.InvalidData, null);
                        }
                        this.counterDataCollection = new CounterCreationDataCollection();
                        for (int i = 0; i < xmlNodeList.Count; i++)
                        {
                            string counterName = ManagePerfCounters.ReadStringElement(xmlNodeList[i], "Name");
                            try
                            {
                                PerformanceCounterType counterType = (PerformanceCounterType)Enum.Parse(typeof(PerformanceCounterType), ManagePerfCounters.ReadStringElement(xmlNodeList[i], "Type"), true);
                                this.counterDataCollection.Add(new CounterCreationData(counterName, string.Empty, counterType));
                                base.WriteVerbose(Strings.PerfCounterDefinition(counterName, counterType));
                            }
                            catch (ArgumentException innerException)
                            {
                                base.WriteError(new TaskException(Strings.ExceptionPerfCounterInvalidDefinitionFile, innerException), ErrorCategory.InvalidData, null);
                            }
                        }
                    }
                }
            }
            catch (XmlException innerException2)
            {
                base.WriteError(new TaskException(Strings.ExceptionPerfCounterInvalidDefinitionFile, innerException2), ErrorCategory.InvalidData, null);
            }
            TaskLogger.LogExit();
        }