Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning for unhandled exceptions for faulty CPUs #861

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NLog;
using NLog.Targets;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;
Expand Down Expand Up @@ -133,6 +134,15 @@ private static void Main()
#endregion
catch (Exception e)
{
var cpuError = WinApi.GetCpuErrorMessage();
if (cpuError != null)
{
var messageBoxResult = MessageBox.Show(cpuError.Value.Item1, "Potentially Faulty CPU Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (messageBoxResult == DialogResult.Yes)
{
Process.Start(cpuError.Value.Item2);
}
}
logger.Fatal(e, "Unhandled Exception, program dying");
MessageBox.Show(e.ToString(), "PLEASE REPORT IN https://vrcx.app/discord", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
Expand Down
29 changes: 29 additions & 0 deletions Dotnet/WinApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace VRCX
{
public static class WinApi
{
private static List<(List<string>, string, string)> CpuErrorMessages = new List<(List<string>, string, string)>()
{
(["Intel", "Core", "-13"], "VRCX has detected that you're using a 13th or 14th generation Intel CPU.\nThese CPUs are known to have issues which can lead to crashes.\nThis crash was unlikely caused by VRCX itself, therefore limited support can be offered.\nWould you like to open a link with more information?", "https://www.youtube.com/watch?v=b6vQlvefGxk"),
(["Intel", "Core", "-14"], "VRCX has detected that you're using a 13th or 14th generation Intel CPU.\nThese CPUs are known to have issues which can lead to crashes.\nThis crash was unlikely caused by VRCX itself, therefore limited support can be offered.\nWould you like to open a link with more information?", "https://www.youtube.com/watch?v=b6vQlvefGxk"),
Comment on lines +19 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The majority of users aren't very tech savvy, and while Gamers Nexus does go into great detail about the mountains of issues intel has cooked up, for this I believe something clear and concise would be better.

Copy link
Contributor

@Myrkie Myrkie Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion's welcome. best I could come up with would be the post by alderon games as it has a bunch of linked references https://alderongames.com/intel-crashes

Copy link
Member

@DubyaDude DubyaDude Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's tough considering that it's still 'developing news' and Intel's supposed solution has yet to be released/the replacement process is not yet fully known. But, the alderon post is much more concise and to the point, for the time being, I'd be okay with that.

};

[DllImport("kernel32.dll", SetLastError = false)]
public static extern void RtlCopyMemory(IntPtr destination, IntPtr source, uint length);

Expand Down Expand Up @@ -76,5 +85,25 @@ internal static bool HasProcessExited(int processId)

return exited;
}

internal static string GetCpuName()
{
return Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0\")?.GetValue("ProcessorNameString").ToString() ?? null;
}

internal static (string, string)? GetCpuErrorMessage()
{
string cpuName = GetCpuName();
if (cpuName == null)
return null;

foreach (var errorInfo in CpuErrorMessages)
{
if (errorInfo.Item1.All(cpuName.Contains))
return (errorInfo.Item2, errorInfo.Item3);
}

return null;
}
}
}