コード例 #1
0
 public static void SetFeatures(ProcessorFeature features)
 {
     if (allowSetFeatures)
     {
         PdnNativeMethods.SetProcessorFeatures(features);
     }
 }
コード例 #2
0
        public static bool IsFeaturePresent(ProcessorFeature feature)
        {
            if (feature == 0)
            {
                return(false);
            }

            return((PdnNativeMethods.GetProcessorFeatures() & feature) != 0);
        }
コード例 #3
0
ファイル: Win32Hacks.cs プロジェクト: radtek/BizHawk
 public static extern bool IsProcessorFeaturePresent(ProcessorFeature processorFeature);
コード例 #4
0
ファイル: Startup.cs プロジェクト: cyberjaxx/OpenPDN
        private static void WriteCrashLog(Exception ex, TextWriter stream)
        {
            string headerFormat;

            try
            {
                headerFormat = PdnResources.GetString("CrashLog.HeaderText.Format");
            }

            catch (Exception ex13)
            {
                headerFormat =
                    InvariantStrings.CrashLogHeaderTextFormatFallback +
                    ", --- Exception while calling PdnResources.GetString(\"CrashLog.HeaderText.Format\"): " +
                    ex13.ToString() +
                    Environment.NewLine;
            }

            string header;

            try
            {
                header = string.Format(headerFormat, InvariantStrings.CrashlogEmail);
            }

            catch
            {
                header = string.Empty;
            }

            stream.WriteLine(header);

            const string noInfoString = "err";

            string fullAppName = noInfoString;
            string timeOfCrash = noInfoString;
            string appUptime   = noInfoString;
            string osVersion   = noInfoString;
            string osRevision  = noInfoString;
            string osType      = noInfoString;
            string processorNativeArchitecture = noInfoString;
            string clrVersion            = noInfoString;
            string fxInventory           = noInfoString;
            string processorArchitecture = noInfoString;
            string cpuName            = noInfoString;
            string cpuCount           = noInfoString;
            string cpuSpeed           = noInfoString;
            string cpuFeatures        = noInfoString;
            string totalPhysicalBytes = noInfoString;
            string dpiInfo            = noInfoString;
            string localeName         = noInfoString;
            string inkInfo            = noInfoString;
            string updaterInfo        = noInfoString;
            string featuresInfo       = noInfoString;
            string assembliesInfo     = noInfoString;

            try
            {
                try
                {
                    fullAppName = PdnInfo.GetFullAppName();
                }

                catch (Exception ex1)
                {
                    fullAppName = Application.ProductVersion + ", --- Exception while calling PdnInfo.GetFullAppName(): " + ex1.ToString() + Environment.NewLine;
                }

                try
                {
                    timeOfCrash = DateTime.Now.ToString();
                }

                catch (Exception ex2)
                {
                    timeOfCrash = "--- Exception while populating timeOfCrash: " + ex2.ToString() + Environment.NewLine;
                }

                try
                {
                    appUptime = (DateTime.Now - startupTime).ToString();
                }

                catch (Exception ex13)
                {
                    appUptime = "--- Exception while populating appUptime: " + ex13.ToString() + Environment.NewLine;
                }

                try
                {
                    osVersion = System.Environment.OSVersion.Version.ToString();
                }

                catch (Exception ex3)
                {
                    osVersion = "--- Exception while populating osVersion: " + ex3.ToString() + Environment.NewLine;
                }

                try
                {
                    osRevision = OS.Revision;
                }

                catch (Exception ex4)
                {
                    osRevision = "--- Exception while populating osRevision: " + ex4.ToString() + Environment.NewLine;
                }

                try
                {
                    osType = OS.Type.ToString();
                }

                catch (Exception ex5)
                {
                    osType = "--- Exception while populating osType: " + ex5.ToString() + Environment.NewLine;
                }

                try
                {
                    processorNativeArchitecture = Processor.NativeArchitecture.ToString().ToLower();
                }

                catch (Exception ex6)
                {
                    processorNativeArchitecture = "--- Exception while populating processorNativeArchitecture: " + ex6.ToString() + Environment.NewLine;
                }

                try
                {
                    clrVersion = System.Environment.Version.ToString();
                }

                catch (Exception ex7)
                {
                    clrVersion = "--- Exception while populating clrVersion: " + ex7.ToString() + Environment.NewLine;
                }

                try
                {
                    fxInventory =
                        (SystemLayer.OS.IsDotNetVersionInstalled(2, 0, 0, false) ? "2.0 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(2, 0, 1, false) ? "2.0SP1 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(2, 0, 2, false) ? "2.0SP2 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 0, 0, false) ? "3.0 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 0, 1, false) ? "3.0SP1 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 0, 2, false) ? "3.0SP2 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 5, 0, false) ? "3.5 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 5, 1, false) ? "3.5SP1 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 5, 1, true) ? "3.5SP1_Client " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(3, 5, 2, false) ? "3.5SP2 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(4, 0, 0, false) ? "4.0 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(4, 0, 1, false) ? "4.0SP1 " : "") +
                        (SystemLayer.OS.IsDotNetVersionInstalled(4, 0, 2, false) ? "4.0SP2 " : "")
                        .Trim();
                }

                catch (Exception ex30)
                {
                    fxInventory = "--- Exception while populating fxInventory: " + ex30.ToString() + Environment.NewLine;
                }

                try
                {
                    processorArchitecture = Processor.Architecture.ToString().ToLower();
                }

                catch (Exception ex8)
                {
                    processorArchitecture = "--- Exception while populating processorArchitecture: " + ex8.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuName = SystemLayer.Processor.CpuName;
                }

                catch (Exception ex9)
                {
                    cpuName = "--- Exception while populating cpuName: " + ex9.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuCount = SystemLayer.Processor.LogicalCpuCount.ToString() + "x";
                }

                catch (Exception ex10)
                {
                    cpuCount = "--- Exception while populating cpuCount: " + ex10.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuSpeed = "@ ~" + SystemLayer.Processor.ApproximateSpeedMhz.ToString() + "MHz";
                }

                catch (Exception ex16)
                {
                    cpuSpeed = "--- Exception while populating cpuSpeed: " + ex16.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuFeatures = string.Empty;
                    string[] featureNames = Enum.GetNames(typeof(ProcessorFeature));
                    bool     firstFeature = true;

                    for (int i = 0; i < featureNames.Length; ++i)
                    {
                        string           featureName = featureNames[i];
                        ProcessorFeature feature     = (ProcessorFeature)Enum.Parse(typeof(ProcessorFeature), featureName);

                        if (Processor.IsFeaturePresent(feature))
                        {
                            if (firstFeature)
                            {
                                cpuFeatures  = "(";
                                firstFeature = false;
                            }
                            else
                            {
                                cpuFeatures += ", ";
                            }

                            cpuFeatures += featureName;
                        }
                    }

                    if (cpuFeatures.Length > 0)
                    {
                        cpuFeatures += ")";
                    }
                }

                catch (Exception ex17)
                {
                    cpuFeatures = "--- Exception while populating cpuFeatures: " + ex17.ToString() + Environment.NewLine;
                }

                try
                {
                    totalPhysicalBytes = ((SystemLayer.Memory.TotalPhysicalBytes / 1024) / 1024) + " MB";
                }

                catch (Exception ex11)
                {
                    totalPhysicalBytes = "--- Exception while populating totalPhysicalBytes: " + ex11.ToString() + Environment.NewLine;
                }

                try
                {
                    float xScale;

                    try
                    {
                        xScale = UI.GetXScaleFactor();
                    }

                    catch (Exception)
                    {
                        using (Control c = new Control())
                        {
                            UI.InitScaling(c);
                            xScale = UI.GetXScaleFactor();
                        }
                    }

                    dpiInfo = string.Format("{0} dpi ({1}x scale)", (96.0f * xScale).ToString("F2"), xScale.ToString("F2"));
                }

                catch (Exception ex19)
                {
                    dpiInfo = "--- Exception while populating dpiInfo: " + ex19.ToString() + Environment.NewLine;
                }

                try
                {
                    localeName =
                        "pdnr.c: " + PdnResources.Culture.Name +
                        ", hklm: " + Settings.SystemWide.GetString(SettingNames.LanguageName, "n/a") +
                        ", hkcu: " + Settings.CurrentUser.GetString(SettingNames.LanguageName, "n/a") +
                        ", cc: " + CultureInfo.CurrentCulture.Name +
                        ", cuic: " + CultureInfo.CurrentUICulture.Name;
                }

                catch (Exception ex14)
                {
                    localeName = "--- Exception while populating localeName: " + ex14.ToString() + Environment.NewLine;
                }

                try
                {
                    inkInfo = Ink.IsAvailable() ? "yes" : "no";
                }

                catch (Exception ex15)
                {
                    inkInfo = "--- Exception while populating inkInfo: " + ex15.ToString() + Environment.NewLine;
                }

                try
                {
                    string autoCheckForUpdates = Settings.SystemWide.GetString(SettingNames.AutoCheckForUpdates, noInfoString);

                    string lastUpdateCheckTimeInfo;

                    try
                    {
                        string   lastUpdateCheckTimeString = Settings.CurrentUser.Get(SettingNames.LastUpdateCheckTimeTicks);
                        long     lastUpdateCheckTimeTicks  = long.Parse(lastUpdateCheckTimeString);
                        DateTime lastUpdateCheckTime       = new DateTime(lastUpdateCheckTimeTicks);
                        lastUpdateCheckTimeInfo = lastUpdateCheckTime.ToShortDateString();
                    }

                    catch (Exception)
                    {
                        lastUpdateCheckTimeInfo = noInfoString;
                    }

                    updaterInfo = string.Format(
                        "{0}, {1}",
                        (autoCheckForUpdates == "1") ? "true" : (autoCheckForUpdates == "0" ? "false" : (autoCheckForUpdates ?? "null")),
                        lastUpdateCheckTimeInfo);
                }

                catch (Exception ex17)
                {
                    updaterInfo = "--- Exception while populating updaterInfo: " + ex17.ToString() + Environment.NewLine;
                }

                try
                {
                    StringBuilder featureSB = new StringBuilder();

                    IEnumerable <string> featureList = SystemLayer.Tracing.GetLoggedFeatures();

                    bool first = true;
                    foreach (string feature in featureList)
                    {
                        if (!first)
                        {
                            featureSB.Append(", ");
                        }

                        featureSB.Append(feature);

                        first = false;
                    }

                    featuresInfo = featureSB.ToString();
                }

                catch (Exception ex18)
                {
                    featuresInfo = "--- Exception while populating featuresInfo: " + ex18.ToString() + Environment.NewLine;
                }

                try
                {
                    StringBuilder assembliesInfoSB = new StringBuilder();

                    Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

                    foreach (Assembly assembly in loadedAssemblies)
                    {
                        assembliesInfoSB.AppendFormat("{0}    {1} @ {2}", Environment.NewLine, assembly.FullName, assembly.Location);
                    }

                    assembliesInfo = assembliesInfoSB.ToString();
                }

                catch (Exception ex16)
                {
                    assembliesInfo = "--- Exception while populating assembliesInfo: " + ex16.ToString() + Environment.NewLine;
                }
            }

            catch (Exception ex12)
            {
                stream.WriteLine("Exception while gathering app and system info: " + ex12.ToString());
            }

            stream.WriteLine("Application version: " + fullAppName);
            stream.WriteLine("Time of crash: " + timeOfCrash);
            stream.WriteLine("Application uptime: " + appUptime);

            stream.WriteLine("OS Version: " + osVersion + (string.IsNullOrEmpty(osRevision) ? "" : (" " + osRevision)) + " " + osType + " " + processorNativeArchitecture);
            stream.WriteLine(".NET version: CLR " + clrVersion + " " + processorArchitecture + ", FX " + fxInventory);
            stream.WriteLine("Processor: " + cpuCount + " \"" + cpuName + "\" " + cpuSpeed + " " + cpuFeatures);
            stream.WriteLine("Physical memory: " + totalPhysicalBytes);
            stream.WriteLine("UI DPI: " + dpiInfo);
            stream.WriteLine("Tablet PC: " + inkInfo);
            stream.WriteLine("Updates: " + updaterInfo);
            stream.WriteLine("Locale: " + localeName);
            stream.WriteLine("Features log: " + featuresInfo);
            stream.WriteLine("Loaded assemblies: " + assembliesInfo);
            stream.WriteLine();

            stream.WriteLine("Exception details:");

            if (ex == null)
            {
                stream.WriteLine("(null)");
            }
            else
            {
                stream.WriteLine(ex.ToString());

                // Determine if there is any 'secondary' exception to report
                Exception[] otherEx = null;

                if (ex is System.Reflection.ReflectionTypeLoadException)
                {
                    otherEx = ((System.Reflection.ReflectionTypeLoadException)ex).LoaderExceptions;
                }

                if (otherEx != null)
                {
                    for (int i = 0; i < otherEx.Length; ++i)
                    {
                        stream.WriteLine();
                        stream.WriteLine("Secondary exception details:");

                        if (otherEx[i] == null)
                        {
                            stream.WriteLine("(null)");
                        }
                        else
                        {
                            stream.WriteLine(otherEx[i].ToString());
                        }
                    }
                }
            }

            stream.WriteLine("------------------------------------------------------------------------------");
            stream.Flush();
        }
コード例 #5
0
 public static bool IsFeaturePresent(ProcessorFeature feature)
 {
     return ((Features & feature) == feature);
 }
コード例 #6
0
        public static void WriteCrashLog(Exception crashEx, TextWriter stream)
        {
            string   str;
            string   str2;
            DateTime startupTime = Startup.StartupTime;

            try
            {
                str = PdnResources.GetString("CrashLog.HeaderText.Format");
            }
            catch (Exception exception)
            {
                str = "This text file was created because paint.net crashed.\r\nPlease e-mail this file to {0} so we can diagnose and fix the problem.\r\n, --- Exception while calling PdnResources.GetString(\"CrashLog.HeaderText.Format\"): " + exception.ToString() + Environment.NewLine;
            }
            try
            {
                str2 = string.Format(str, "*****@*****.**");
            }
            catch (Exception)
            {
                str2 = string.Empty;
            }
            stream.WriteLine(str2);
            string fullAppName      = "err";
            string str4             = "err";
            string str5             = "err";
            string str6             = "err";
            string str7             = "err";
            string str8             = "err";
            string str9             = "err";
            string currentDirectory = "err";
            string str11            = "err";
            string revision         = "err";
            string str13            = "err";
            string str14            = "err";
            string str15            = "err";
            string str16            = "err";
            string str17            = "err";
            string cpuName          = "err";
            string str19            = "err";
            string str20            = "err";
            string str21            = "err";
            string str22            = "err";
            string str23            = "err";
            string str24            = "err";
            string str25            = "err";
            string str26            = "err";
            string str27            = "err";
            string str28            = "err";
            string str29            = "err";
            string str30            = "err";
            string str31            = "err";
            string str32            = "err";

            try
            {
                try
                {
                    fullAppName = PdnInfo.FullAppName;
                }
                catch (Exception exception2)
                {
                    fullAppName = Application.ProductVersion + ", --- Exception while calling PdnInfo.GetFullAppName(): " + exception2.ToString() + Environment.NewLine;
                }
                try
                {
                    str4 = DateTime.Now.ToString();
                }
                catch (Exception exception3)
                {
                    str4 = "--- Exception while populating timeOfCrash: " + exception3.ToString() + Environment.NewLine;
                }
                try
                {
                    str5 = ((TimeSpan)(DateTime.Now - startupTime)).ToString();
                }
                catch (Exception exception4)
                {
                    str5 = "--- Exception while populating appUptime: " + exception4.ToString() + Environment.NewLine;
                }
                try
                {
                    bool hasShutdownStarted = Environment.HasShutdownStarted;
                    bool flag2 = AppDomain.CurrentDomain.IsFinalizingForUnload();
                    str6 = Startup.State.ToString() + " " + (hasShutdownStarted ? "Environment.HasShutdownStarted " : string.Empty) + (flag2 ? "AppDomain.IsFinalizingForUnload " : string.Empty).Trim();
                }
                catch (Exception exception5)
                {
                    str6 = "--- Exception while populating applicationState: " + exception5.ToString() + Environment.NewLine;
                }
                try
                {
                    str7 = ((((double)Environment.WorkingSet) / 1024.0)).ToString("N0") + " KiB";
                }
                catch (Exception exception6)
                {
                    str7 = "--- Exception while populating workingSet: " + exception6.ToString() + Environment.NewLine;
                }
                try
                {
                    int     num4;
                    int     num5;
                    Process currentProcess = Process.GetCurrentProcess();
                    int     handleCount    = currentProcess.HandleCount;
                    int     count          = currentProcess.Threads.Count;
                    ProcessStatus.GetCurrentProcessGuiResources(out num4, out num5);
                    str8 = $"{handleCount} handles, {count} threads, {num4} gdi, {num5} user";
                }
                catch (Exception exception7)
                {
                    str8 = "--- Exception while populating threadCount: " + exception7.ToString() + Environment.NewLine;
                }
                try
                {
                    currentDirectory = Environment.CurrentDirectory;
                }
                catch (Exception exception8)
                {
                    currentDirectory = "--- Exception while populating currentDir: " + exception8.ToString() + Environment.NewLine;
                }
                try
                {
                    str9 = RegistrySettings.SystemWide.GetString("TARGETDIR", "n/a");
                }
                catch (Exception exception9)
                {
                    str9 = "--- Exception while populating targetDir: " + exception9.ToString() + Environment.NewLine;
                }
                try
                {
                    str11 = Environment.OSVersion.Version.ToString();
                }
                catch (Exception exception10)
                {
                    str11 = "--- Exception while populating osVersion: " + exception10.ToString() + Environment.NewLine;
                }
                try
                {
                    revision = OS.Revision;
                }
                catch (Exception exception11)
                {
                    revision = "--- Exception while populating osRevision: " + exception11.ToString() + Environment.NewLine;
                }
                try
                {
                    str13 = OS.OSType.ToString();
                }
                catch (Exception exception12)
                {
                    str13 = "--- Exception while populating osType: " + exception12.ToString() + Environment.NewLine;
                }
                try
                {
                    str14 = Processor.NativeArchitecture.ToString().ToLower();
                }
                catch (Exception exception13)
                {
                    str14 = "--- Exception while populating processorNativeArchitecture: " + exception13.ToString() + Environment.NewLine;
                }
                try
                {
                    str15 = Environment.Version.ToString();
                }
                catch (Exception exception14)
                {
                    str15 = "--- Exception while populating clrVersion: " + exception14.ToString() + Environment.NewLine;
                }
                try
                {
                    bool flag3 = OS.VerifyFrameworkVersion(4, 6, 0, OS.FrameworkProfile.Client);
                    bool flag4 = OS.VerifyFrameworkVersion(4, 6, 0, OS.FrameworkProfile.Full);
                    str16 = ((flag3 | flag4) ? "4.6 " : string.Empty).Trim();
                }
                catch (Exception exception15)
                {
                    str16 = "--- Exception while populating fxInventory: " + exception15.ToString() + Environment.NewLine;
                }
                try
                {
                    str17 = Processor.Architecture.ToString().ToLower();
                }
                catch (Exception exception16)
                {
                    str17 = "--- Exception while populating processorArchitecture: " + exception16.ToString() + Environment.NewLine;
                }
                try
                {
                    cpuName = Processor.CpuName;
                }
                catch (Exception exception17)
                {
                    cpuName = "--- Exception while populating cpuName: " + exception17.ToString() + Environment.NewLine;
                }
                try
                {
                    LogicalProcessorInfo logicalProcessorInformation = Processor.GetLogicalProcessorInformation();
                    int num6 = logicalProcessorInformation.Packages.Count;
                    int physicalCoreCount = logicalProcessorInformation.GetPhysicalCoreCount();
                    int logicalCpuCount   = Processor.LogicalCpuCount;
                    if (num6 > 1)
                    {
                        str19 = $"{num6.ToString()}S/{physicalCoreCount.ToString()}C/{logicalCpuCount.ToString()}T";
                    }
                    else
                    {
                        str19 = $"{physicalCoreCount.ToString()}C/{logicalCpuCount.ToString()}T";
                    }
                }
                catch (Exception exception18)
                {
                    str19 = "--- Exception while populating cpuCount: " + exception18.ToString() + Environment.NewLine;
                }
                try
                {
                    str20 = "@ ~" + Processor.ApproximateSpeedMhz.ToString() + "MHz";
                }
                catch (Exception exception19)
                {
                    str20 = "--- Exception while populating cpuSpeed: " + exception19.ToString() + Environment.NewLine;
                }
                try
                {
                    str21 = "(" + str19;
                    foreach (string str33 in Enum.GetNames(typeof(ProcessorFeature)))
                    {
                        ProcessorFeature feature = (ProcessorFeature)Enum.Parse(typeof(ProcessorFeature), str33);
                        if (Processor.IsFeaturePresent(feature))
                        {
                            str21 = str21 + ", ";
                            str21 = str21 + str33;
                        }
                    }
                    if (str21.Length > 0)
                    {
                        str21 = str21 + ")";
                    }
                }
                catch (Exception exception20)
                {
                    str21 = "--- Exception while populating cpuFeatures: " + exception20.ToString() + Environment.NewLine;
                }
                try
                {
                    str22 = ((Memory.TotalPhysicalBytes / ((ulong)0x400L)) / ((ulong)0x400L)) + " MB";
                }
                catch (Exception exception21)
                {
                    str22 = "--- Exception while populating totalPhysicalBytes: " + exception21.ToString() + Environment.NewLine;
                }
                try
                {
                    BooleanSetting enableHardwareAcceleration = AppSettings.Instance.UI.EnableHardwareAcceleration;
                    str23 = enableHardwareAcceleration.Value.ToString() + " (default: " + enableHardwareAcceleration.DefaultValue.ToString() + ")";
                }
                catch (Exception exception22)
                {
                    str23 = "--- Exception while populating hwAcceleration: " + exception22.ToString() + Environment.NewLine;
                }
                try
                {
                    using (IDxgiFactory1 factory = DxgiFactory1.CreateFactory1())
                    {
                        IDxgiAdapter1[] items = factory.EnumerateAdapters1().ToArrayEx <IDxgiAdapter1>();
                        str24 = items.Select <IDxgiAdapter1, AdapterDescription1>(a => a.Description1).Select <AdapterDescription1, string>(d => $"{d.Description} (v:{d.VendorID.ToString("X")}, d:{d.DeviceID.ToString("X")}, r:{d.Revision.ToString()})").Join(", ");
                        DisposableUtil.FreeContents <IDxgiAdapter1>(items);
                    }
                }
                catch (Exception exception23)
                {
                    str24 = "--- Exception while populating videoCardNames: " + exception23.ToString() + Environment.NewLine;
                }
                try
                {
                    str25 = AppSettings.Instance.UI.EnableAnimations.Value.ToString();
                }
                catch (Exception exception24)
                {
                    str25 = "--- Exception while populating animations: " + exception24.ToString() + Environment.NewLine;
                }
                try
                {
                    float xScaleFactor = UIUtil.GetXScaleFactor();
                    str26 = $"{(96f * xScaleFactor).ToString("F2")} dpi ({xScaleFactor.ToString("F2")}x scale)";
                }
                catch (Exception exception25)
                {
                    str26 = "--- Exception while populating dpiInfo: " + exception25.ToString() + Environment.NewLine;
                }
                try
                {
                    VisualStyleClass visualStyleClass        = UIUtil.VisualStyleClass;
                    PdnTheme         effectiveTheme          = ThemeConfig.EffectiveTheme;
                    bool             isDwmCompositionEnabled = UIUtil.IsDwmCompositionEnabled;
                    string           themeFileName           = UIUtil.ThemeFileName;
                    str27 = $"{visualStyleClass.ToString()}/{effectiveTheme.ToString()}{isDwmCompositionEnabled ? " + DWM" : ""} ({themeFileName})";
                }
                catch (Exception exception26)
                {
                    str27 = "--- Exception while populating themeInfo: " + exception26.ToString() + Environment.NewLine;
                }
                try
                {
                    string   str36;
                    string   str37;
                    string   path       = AppSettings.Instance.UI.Language.Path;
                    bool     flag8      = AppSettings.Instance.StorageHandler.TryGet(SettingsHive.CurrentUser, path, out str36);
                    bool     flag9      = AppSettings.Instance.StorageHandler.TryGet(SettingsHive.SystemWide, path, out str37);
                    string[] textArray1 = new string[] { "pdnr.c: ", PdnResources.Culture.Name, ", hklm: ", flag9 ? str37 : "n/a", ", hkcu: ", flag8 ? str36 : "n/a", ", cc: ", CultureInfo.CurrentCulture.Name, ", cuic: ", CultureInfo.CurrentUICulture.Name };
                    str29 = string.Concat(textArray1);
                }
                catch (Exception exception27)
                {
                    str29 = "--- Exception while populating localeName: " + exception27.ToString() + Environment.NewLine;
                }
                try
                {
                    bool flag10 = AppSettings.Instance.Updates.AutoCheck.Value;
                    str28 = $"{flag10}, {AppSettings.Instance.Updates.LastCheckTimeUtc.Value.ToShortDateString()}";
                }
                catch (Exception exception28)
                {
                    str28 = "--- Exception while populating updaterInfo: " + exception28.ToString() + Environment.NewLine;
                }
                try
                {
                    List <string> strings = new List <string>();
                    if (AppSettings.Instance.UI.ErrorFlagsAtStartup.Value != AppSettings.Instance.UI.ErrorFlags.Value)
                    {
                        strings.Add("ErrorFlagsAtStartup=(" + AppSettings.Instance.UI.ErrorFlagsAtStartup.Value.ToString() + ")");
                    }
                    if (AppSettings.Instance.UI.ErrorFlags.Value != AppSettings.Instance.UI.ErrorFlags.DefaultValue)
                    {
                        strings.Add("ErrorFlags=(" + AppSettings.Instance.UI.ErrorFlags.Value.ToString() + ")");
                    }
                    if (AppSettings.Instance.UI.DefaultTextAntialiasMode.Value != AppSettings.Instance.UI.DefaultTextAntialiasMode.DefaultValue)
                    {
                        strings.Add("DefaultTextAntialiasMode=" + AppSettings.Instance.UI.DefaultTextAntialiasMode.Value.ToString());
                    }
                    if (AppSettings.Instance.UI.DefaultTextRenderingMode.Value != AppSettings.Instance.UI.DefaultTextRenderingMode.DefaultValue)
                    {
                        strings.Add("DefaultTextRenderingMode=" + AppSettings.Instance.UI.DefaultTextRenderingMode.Value.ToString());
                    }
                    if (AppSettings.Instance.UI.EnableCanvasHwndRenderTarget.Value != AppSettings.Instance.UI.EnableCanvasHwndRenderTarget.DefaultValue)
                    {
                        strings.Add("EnableCanvasHwndRenderTarget=" + AppSettings.Instance.UI.EnableCanvasHwndRenderTarget.Value.ToString());
                    }
                    if (AppSettings.Instance.UI.EnableHighQualityScaling.Value != AppSettings.Instance.UI.EnableHighQualityScaling.DefaultValue)
                    {
                        strings.Add("EnableHighQualityScaling=" + AppSettings.Instance.UI.EnableHighQualityScaling.Value.ToString());
                    }
                    if (AppSettings.Instance.UI.EnableSmoothMouseInput.Value != AppSettings.Instance.UI.EnableSmoothMouseInput.DefaultValue)
                    {
                        strings.Add("EnableSmoothMouseInput=" + AppSettings.Instance.UI.EnableSmoothMouseInput.Value.ToString());
                    }
                    str30 = strings.Join(", ");
                }
                catch (Exception exception29)
                {
                    str30 = "--- Exception while populating flagsInfo: " + exception29.ToString() + Environment.NewLine;
                }
                try
                {
                    StringBuilder builder    = new StringBuilder();
                    Assembly[]    assemblies = AppDomain.CurrentDomain.GetAssemblies();
                    for (int i = 0; i < assemblies.Length; i++)
                    {
                        Assembly assembly = assemblies[i];
                        string   str38    = () => assembly.FullName.Eval <string>().GetValueOrDefault() ?? "<FullName?>";
                        string   str39    = () => assembly.Location.Eval <string>().GetValueOrDefault() ?? "<Location?>";
                        builder.AppendFormat("{0}    {1} @ {2}", Environment.NewLine, str38, str39);
                    }
                    str31 = builder.ToString();
                }
                catch (Exception exception30)
                {
                    str31 = "--- Exception while populating assembliesInfo: " + exception30.ToString() + Environment.NewLine;
                }
                try
                {
                    StringBuilder builder2 = new StringBuilder();
                    int           num14    = Processor.Architecture.ToBitness();
                    foreach (ProcessStatus.ModuleFileNameAndBitness bitness in ProcessStatus.GetCurrentProcessModuleNames())
                    {
                        string fileVersion;
                        string str40 = string.Empty;
                        if (bitness.Bitness != num14)
                        {
                            str40 = $" ({bitness.Bitness.ToString()}-bit)";
                        }
                        try
                        {
                            fileVersion = FileVersionInfo.GetVersionInfo(bitness.FileName).FileVersion;
                        }
                        catch (Exception exception31)
                        {
                            fileVersion = $"ex: {exception31.GetType().FullName}";
                        }
                        object[] args = new object[] { Environment.NewLine, bitness.FileName, str40, fileVersion };
                        builder2.AppendFormat("{0}    {1}{2}, version={3}", args);
                    }
                    str32 = builder2.ToString();
                }
                catch (Exception exception32)
                {
                    str32 = "--- Exception while populating nativeModulesInfo: " + exception32.ToString() + Environment.NewLine;
                }
            }
            catch (Exception exception33)
            {
                stream.WriteLine("Exception while gathering app and system info: " + exception33.ToString());
            }
            stream.WriteLine("Application version: " + fullAppName);
            stream.WriteLine("Time of crash: " + str4);
            stream.WriteLine("Application uptime: " + str5);
            stream.WriteLine("Application state: " + str6);
            stream.WriteLine("Working set: " + str7);
            stream.WriteLine("Handles and threads: " + str8);
            stream.WriteLine("Install directory: " + str9);
            stream.WriteLine("Current directory: " + currentDirectory);
            stream.WriteLine("OS Version: " + str11 + (string.IsNullOrEmpty(revision) ? "" : (" " + revision)) + " " + str13 + " " + str14);
            stream.WriteLine(".NET version: CLR " + str15 + " " + str17 + ", FX " + str16);
            stream.WriteLine("Processor: \"" + cpuName + "\" " + str20 + " " + str21);
            stream.WriteLine("Physical memory: " + str22);
            stream.WriteLine("Video card: " + str24);
            stream.WriteLine("Hardware acceleration: " + str23);
            stream.WriteLine("UI animations: " + str25);
            stream.WriteLine("UI DPI: " + str26);
            stream.WriteLine("UI theme: " + str27);
            stream.WriteLine("Updates: " + str28);
            stream.WriteLine("Locale: " + str29);
            stream.WriteLine("Flags: " + str30);
            stream.WriteLine();
            stream.WriteLine("Exception details:");
            if (crashEx == null)
            {
                stream.WriteLine("(null)");
            }
            else
            {
                stream.WriteLine(crashEx.ToString());
                Exception[] loaderExceptions = null;
                if (crashEx is ReflectionTypeLoadException)
                {
                    loaderExceptions = ((ReflectionTypeLoadException)crashEx).LoaderExceptions;
                }
                if (loaderExceptions != null)
                {
                    for (int j = 0; j < loaderExceptions.Length; j++)
                    {
                        stream.WriteLine();
                        stream.WriteLine("Secondary exception details:");
                        if (loaderExceptions[j] == null)
                        {
                            stream.WriteLine("(null)");
                        }
                        else
                        {
                            stream.WriteLine(loaderExceptions[j].ToString());
                        }
                    }
                }
            }
            stream.WriteLine();
            stream.WriteLine("Managed assemblies: " + str31);
            stream.WriteLine();
            stream.WriteLine("Native modules: " + str32);
            stream.WriteLine("------------------------------------------------------------------------------");
            stream.Flush();
        }
コード例 #7
0
 /// <summary>
 /// Returns true if the specified processor feature is present.
 /// </summary>
 public static bool IsProcessorFeaturePresent(ProcessorFeature feature)
 {
     return(Imports.IsProcessorFeaturePresent(feature));
 }
コード例 #8
0
 public static bool IsFeaturePresent(ProcessorFeature feature)
 {
     return((Features & feature) == feature);
 }
コード例 #9
0
 public static bool IsProcessorFeaturePresent(ProcessorFeature feature)
 {
     return(IsProcessorFeaturePresent((uint)feature));
 }
コード例 #10
0
        private void WriteCrashLog(Exception ex, TextWriter stream)
        {
            const string noInfoString = "err";

            string fullAppName = noInfoString;
            string timeOfCrash = noInfoString;
            string appUptime   = noInfoString;
            string osVersion   = noInfoString;
            string osRevision  = noInfoString;
            string osType      = noInfoString;
            string processorNativeArchitecture = noInfoString;
            string clrVersion            = noInfoString;
            string fxInventory           = noInfoString;
            string processorArchitecture = noInfoString;
            string cpuName             = noInfoString;
            string cpuCount            = noInfoString;
            string cpuSpeed            = noInfoString;
            string cpuFeatures         = noInfoString;
            string totalPhysicalBytes  = noInfoString;
            string dpiInfo             = noInfoString;
            string localeName          = noInfoString;
            string inkInfo             = noInfoString;
            string updaterInfo         = noInfoString;
            string featuresInfo        = noInfoString;
            string assembliesInfo      = noInfoString;
            string transmissionVersion = noInfoString;

            stream.WriteLine("This text file was created because transmission-remote-dotnet crashed. Please search similar issue in http://code.google.com/p/transmission-remote-dotnet/issues/list or open a new one. Attach this file to your comment so we can diagnose and fix the problem.");

            try
            {
                try
                {
                    string fullAppNameFormat = "{0} ({1})";
                    //    <comment>{0} is the product name ("transmission-remote-dotnet"), {1} is the version string ("2.2.2000.3000")</comment>
                    fullAppName = string.Format(fullAppNameFormat, "TRD", GetVersionString());
                }
                catch (Exception ex1)
                {
                    fullAppName = Application.ProductVersion + ", --- Exception while calling PdnInfo.GetFullAppName(): " + ex1.ToString() + Environment.NewLine;
                }

                try
                {
                    string fullAppNameFormat = "{0} ({1})";
                    transmissionVersion = string.Format(fullAppNameFormat, Program.DaemonDescriptor.Version, Program.DaemonDescriptor.Revision);
                }
                catch (Exception ex1)
                {
                    transmissionVersion = Program.DaemonDescriptor.Version.ToString() + " " + Program.DaemonDescriptor.Revision.ToString() +
                                          ", --- Exception while calling PdnInfo.GetFullAppName(): " + ex1.ToString() + Environment.NewLine;
                }

                try
                {
                    timeOfCrash = DateTime.Now.ToString();
                }
                catch (Exception ex2)
                {
                    timeOfCrash = "--- Exception while populating timeOfCrash: " + ex2.ToString() + Environment.NewLine;
                }

                try
                {
                    appUptime = (DateTime.Now - startupTime).ToString();
                }
                catch (Exception ex13)
                {
                    appUptime = "--- Exception while populating appUptime: " + ex13.ToString() + Environment.NewLine;
                }

                try
                {
                    osVersion = System.Environment.OSVersion.Version.ToString();
                }
                catch (Exception ex3)
                {
                    osVersion = "--- Exception while populating osVersion: " + ex3.ToString() + Environment.NewLine;
                }

                try
                {
                    osRevision = OS.Revision;
                }
                catch (Exception ex4)
                {
                    osRevision = "--- Exception while populating osRevision: " + ex4.ToString() + Environment.NewLine;
                }

                try
                {
                    osType = OS.Type.ToString();
                }
                catch (Exception ex5)
                {
                    osType = "--- Exception while populating osType: " + ex5.ToString() + Environment.NewLine;
                }

                try
                {
                    processorNativeArchitecture = Processor.NativeArchitecture.ToString().ToLower();
                }
                catch (Exception ex6)
                {
                    processorNativeArchitecture = "--- Exception while populating processorNativeArchitecture: " + ex6.ToString() + Environment.NewLine;
                }

                try
                {
                    clrVersion = System.Environment.Version.ToString();
                }
                catch (Exception ex7)
                {
                    clrVersion = "--- Exception while populating clrVersion: " + ex7.ToString() + Environment.NewLine;
                }

                try
                {
                    fxInventory =
                        (OS.IsDotNetVersionInstalled(2, 0, 0, false) ? "2.0 " : "") +
                        (OS.IsDotNetVersionInstalled(2, 0, 1, false) ? "2.0SP1 " : "") +
                        (OS.IsDotNetVersionInstalled(2, 0, 2, false) ? "2.0SP2 " : "") +
                        (OS.IsDotNetVersionInstalled(3, 0, 0, false) ? "3.0 " : "") +
                        (OS.IsDotNetVersionInstalled(3, 0, 1, false) ? "3.0SP1 " : "") +
                        (OS.IsDotNetVersionInstalled(3, 0, 2, false) ? "3.0SP2 " : "") +
                        (OS.IsDotNetVersionInstalled(3, 5, 0, false) ? "3.5 " : "") +
                        (OS.IsDotNetVersionInstalled(3, 5, 1, false) ? "3.5SP1 " : "") +
                        (OS.IsDotNetVersionInstalled(3, 5, 1, true) ? "3.5SP1_Client " : "") +
                        (OS.IsDotNetVersionInstalled(3, 5, 2, false) ? "3.5SP2 " : "") +
                        (OS.IsDotNetVersionInstalled(4, 0, 0, false) ? "4.0 " : "") +
                        (OS.IsDotNetVersionInstalled(4, 0, 1, false) ? "4.0SP1 " : "") +
                        (OS.IsDotNetVersionInstalled(4, 0, 2, false) ? "4.0SP2 " : "")
                        .Trim();
                }
                catch (Exception ex30)
                {
                    fxInventory = "--- Exception while populating fxInventory: " + ex30.ToString() + Environment.NewLine;
                }

                try
                {
                    processorArchitecture = Processor.Architecture.ToString().ToLower();
                }
                catch (Exception ex8)
                {
                    processorArchitecture = "--- Exception while populating processorArchitecture: " + ex8.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuName = Processor.CpuName;
                }
                catch (Exception ex9)
                {
                    cpuName = "--- Exception while populating cpuName: " + ex9.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuCount = Processor.LogicalCpuCount.ToString() + "x";
                }
                catch (Exception ex10)
                {
                    cpuCount = "--- Exception while populating cpuCount: " + ex10.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuSpeed = "@ ~" + Processor.ApproximateSpeedMhz.ToString() + "MHz";
                }
                catch (Exception ex16)
                {
                    cpuSpeed = "--- Exception while populating cpuSpeed: " + ex16.ToString() + Environment.NewLine;
                }

                try
                {
                    cpuFeatures = string.Empty;
                    string[] featureNames = Enum.GetNames(typeof(ProcessorFeature));
                    bool     firstFeature = true;

                    for (int i = 0; i < featureNames.Length; ++i)
                    {
                        string           featureName = featureNames[i];
                        ProcessorFeature feature     = (ProcessorFeature)Enum.Parse(typeof(ProcessorFeature), featureName);
                        if (Processor.IsFeaturePresent(feature))
                        {
                            if (firstFeature)
                            {
                                cpuFeatures  = "(";
                                firstFeature = false;
                            }
                            else
                            {
                                cpuFeatures += ", ";
                            }
                            cpuFeatures += featureName;
                        }
                    }
                    if (cpuFeatures.Length > 0)
                    {
                        cpuFeatures += ")";
                    }
                }
                catch (Exception ex17)
                {
                    cpuFeatures = "--- Exception while populating cpuFeatures: " + ex17.ToString() + Environment.NewLine;
                }

                try
                {
                    totalPhysicalBytes = ((Memory.TotalPhysicalBytes / 1024) / 1024) + " MB";
                }
                catch (Exception ex11)
                {
                    totalPhysicalBytes = "--- Exception while populating totalPhysicalBytes: " + ex11.ToString() + Environment.NewLine;
                }

                try
                {
                    float xScale;

                    try
                    {
                        xScale = UI.GetXScaleFactor();
                    }
                    catch (Exception)
                    {
                        using (Control c = new Control())
                        {
                            UI.InitScaling(c);
                            xScale = UI.GetXScaleFactor();
                        }
                    }
                    dpiInfo = string.Format("{0} dpi ({1}x scale)", (96.0f * xScale).ToString("F2"), xScale.ToString("F2"));
                }
                catch (Exception ex19)
                {
                    dpiInfo = "--- Exception while populating dpiInfo: " + ex19.ToString() + Environment.NewLine;
                }

                try
                {
                    localeName =
                        //                        "pdnr.c: " + CultureInfo.CurrentUICulture.Name +
                        //                        ", hklm: " + Settings.SystemWide.GetString(LanguageName, "n/a") +
                        //                        ", hkcu: " + Settings.CurrentUser.GetString(SettingNames.LanguageName, "n/a") +
                        "cc: " + CultureInfo.CurrentCulture.Name +
                        ", cuic: " + CultureInfo.CurrentUICulture.Name;
                }
                catch (Exception ex14)
                {
                    localeName = "--- Exception while populating localeName: " + ex14.ToString() + Environment.NewLine;
                }
#if DUMMY
                try
                {
                    string autoCheckForUpdates = Settings.SystemWide.GetString(SettingNames.AutoCheckForUpdates, noInfoString);

                    string lastUpdateCheckTimeInfo;

                    try
                    {
                        string   lastUpdateCheckTimeString = Settings.CurrentUser.Get(SettingNames.LastUpdateCheckTimeTicks);
                        long     lastUpdateCheckTimeTicks  = long.Parse(lastUpdateCheckTimeString);
                        DateTime lastUpdateCheckTime       = new DateTime(lastUpdateCheckTimeTicks);
                        lastUpdateCheckTimeInfo = lastUpdateCheckTime.ToShortDateString();
                    }
                    catch (Exception)
                    {
                        lastUpdateCheckTimeInfo = noInfoString;
                    }

                    updaterInfo = string.Format(
                        "{0}, {1}",
                        (autoCheckForUpdates == "1") ? "true" : (autoCheckForUpdates == "0" ? "false" : (autoCheckForUpdates ?? "null")),
                        lastUpdateCheckTimeInfo);
                }
                catch (Exception ex17)
                {
                    updaterInfo = "--- Exception while populating updaterInfo: " + ex17.ToString() + Environment.NewLine;
                }
#endif
                try
                {
                    StringBuilder        featureSB   = new StringBuilder();
                    IEnumerable <string> featureList = Tracing.GetLoggedFeatures();
                    bool first = true;
                    foreach (string feature in featureList)
                    {
                        if (!first)
                        {
                            featureSB.Append(", ");
                        }
                        featureSB.Append(feature);
                        first = false;
                    }
                    featuresInfo = featureSB.ToString();
                }
                catch (Exception ex18)
                {
                    featuresInfo = "--- Exception while populating featuresInfo: " + ex18.ToString() + Environment.NewLine;
                }

                try
                {
                    StringBuilder assembliesInfoSB = new StringBuilder();
                    Assembly[]    loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (Assembly assembly in loadedAssemblies)
                    {
                        assembliesInfoSB.AppendFormat("{0}    {1} @ {2}", Environment.NewLine, assembly.FullName, assembly.Location);
                    }
                    assembliesInfo = assembliesInfoSB.ToString();
                }
                catch (Exception ex16)
                {
                    assembliesInfo = "--- Exception while populating assembliesInfo: " + ex16.ToString() + Environment.NewLine;
                }
            }
            catch (Exception ex12)
            {
                stream.WriteLine("Exception while gathering app and system info: " + ex12.ToString());
            }

            stream.WriteLine();
            stream.WriteLine("Exception details:");

            if (ex == null)
            {
                stream.WriteLine("(null)");
            }
            else
            {
                stream.WriteLine(ex.ToString());

                if (ex.InnerException != null)
                {
                    stream.WriteLine("InnerException details:");
                    stream.WriteLine(ex.InnerException.ToString());
                }

                // Determine if there is any 'secondary' exception to report
                Exception[] otherEx = null;

                if (ex is System.Reflection.ReflectionTypeLoadException)
                {
                    otherEx = ((System.Reflection.ReflectionTypeLoadException)ex).LoaderExceptions;
                }

                if (otherEx != null)
                {
                    for (int i = 0; i < otherEx.Length; ++i)
                    {
                        stream.WriteLine();
                        stream.WriteLine("Secondary exception details:");

                        if (otherEx[i] == null)
                        {
                            stream.WriteLine("(null)");
                        }
                        else
                        {
                            stream.WriteLine(otherEx[i].ToString());
                        }
                    }
                }
            }

            stream.WriteLine("------------------------------------------------------------------------------");
            stream.WriteLine();

            stream.WriteLine("Application version: " + fullAppName);
            stream.WriteLine("Transmission version: " + transmissionVersion);
            stream.WriteLine("Time of crash: " + timeOfCrash);
            stream.WriteLine("Application uptime: " + appUptime);

            stream.WriteLine("OS Version: " + osVersion + (string.IsNullOrEmpty(osRevision) ? "" : (" " + osRevision)) + " " + osType + " " + processorNativeArchitecture);
            stream.WriteLine(".NET version: CLR " + clrVersion + " " + processorArchitecture + ", FX " + fxInventory);
            stream.WriteLine("Processor: " + cpuCount + " \"" + cpuName + "\" " + cpuSpeed + " " + cpuFeatures);
            stream.WriteLine("Physical memory: " + totalPhysicalBytes);
            stream.WriteLine("UI DPI: " + dpiInfo);
            stream.WriteLine("Tablet PC: " + inkInfo);
            stream.WriteLine("Updates: " + updaterInfo);
            stream.WriteLine("Locale: " + localeName);
            stream.WriteLine("Features log: " + featuresInfo);
            stream.WriteLine("Loaded assemblies: " + assembliesInfo);

            stream.Flush();
        }
コード例 #11
0
        internal Processor(uint _index)
        {
            Asm.CLI();

            index = _index;

            bool haveCPU = HaveCPUID();

            if (!haveCPU)
            {
                archType   = ProcessorType.IA32;
                vendorName = CString8.Copy("Unknown");
                brandName  = CString8.Copy("Unknown");
                familyName = CString8.Copy("Unknown");
                modelName  = CString8.Copy("Unknown");
            }
            if (haveCPU)
            {
                UInt32 stepping;
                UInt32 family;
                UInt32 model;

                textBuffer = StringBuilder.CREATE((uint)(20));
                vendorName = GetVendorName();

                if (vendorName->Compare("GenuineIntel", 12) == 0)
                {
                    SetIntel();
                }
                else
                if (vendorName->Compare("AuthenticAMD", 12) == 0)
                {
                    SetAMD();
                }
                else
                {
                    brandName  = GetBrandName();
                    familyName = CString8.Copy("Not implemented yet");
                    modelName  = CString8.Copy("Not implemented yet");
                }

                GetProcessorInfo(out stepping, out family, out model, out featureFlags);

                if (0 != (featureFlags & ProcessorFeatureFlags.IA64))
                {
                    archType = ProcessorType.IA64;
                }
                else
                {
                    archType = ProcessorType.IA32;
                }

                ulong flags        = ((ulong)featureFlags) & ((ulong)ProcessorFeatureFlags.ReservedFlagsMask);
                uint  featureCount = MemoryUtil.BitCount(flags);

                features     = new ProcessorFeature[featureCount];
                featureCount = 0;

                // TODO: this could be improved upon if we had:
                //	constructor support
                //	enum.ToString support
                // etc.
                if (0 != (flags & (ulong)ProcessorFeatureFlags.FPU))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("FPU"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.VME))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("VME"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.DE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PSE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PSE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.TSC))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("TSC"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.MSR))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MSR"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PAE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PAE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.MCE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MCE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.CX8))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CX8"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.APIC))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("APIC"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SEP))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SEP"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.MTRR))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MTRR"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PGE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PGE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.MCA))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MCA"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.CMOV))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CMOV"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PAT))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PAT"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PSE36))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PSE36"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PSN))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PSN"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.CLFSH))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CLFSH"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.DTES))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DTES"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.ACPI))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("ACPI"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.MMX))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MMX"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.FXSR))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("FXSR"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE2))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE2"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SS))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SS"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.HTT))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("HTT"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.TM1))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("TM1"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.IA64))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("IA64"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PBE))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PBE"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE3))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE3"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.DTSE64))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DTSE64"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.MON))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("MON"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.DSCPL))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DSCPL"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.VMX))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("VMX"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SMX))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SMX"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.EST))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("EST"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.TM2))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("TM2"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SSSE3))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSSE3"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.CID))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CID"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.CX16))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("CX16"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.ETPRD))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("ETPRD"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.PDCM))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("PDCM"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.DCA))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("DCA"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE4_1))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE4.1"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.SSE4_2))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("SSE4.2"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.X2APIC))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("X2APIC"); featureCount++;
                }
                if (0 != (flags & (ulong)ProcessorFeatureFlags.POPCNT))
                {
                    features[featureCount] = new ProcessorFeature(); features[featureCount].FeatureName = ("POPCNT"); featureCount++;
                }
            }
            Asm.STI();
        }
コード例 #12
0
		static extern bool IsProcessorFeaturePresent(ProcessorFeature processorFeature);
コード例 #13
0
ファイル: SystemInformation.cs プロジェクト: bangush/WInterop
 /// <summary>
 ///  Returns true if the specified processor feature is present.
 /// </summary>
 public static bool IsProcessorFeaturePresent(ProcessorFeature feature)
 => Imports.IsProcessorFeaturePresent(feature);
コード例 #14
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Queries whether the user's CPU supports a particular feature. </summary>
        ///
        /// <exception cref="ArgumentException">
        ///     Thrown when one or more arguments have unsupported or illegal values.
        /// </exception>
        ///
        /// <param name="queryArgs">	The query arguments. </param>
        ///
        /// <returns>	A string boolean. </returns>
        public static string Execute(string queryArgs)
        {
            ProcessorFeature processorFeature = (ProcessorFeature)Enum.Parse(typeof(ProcessorFeature), queryArgs, true);

            return(IsProcessorFeaturePresent(processorFeature).ToString());
        }