Skip to content

Commit

Permalink
add protection from running as admin
Browse files Browse the repository at this point in the history
  • Loading branch information
13xforever committed Nov 26, 2022
1 parent ced7d15 commit 42f7277
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Ps3DiscDumper/Dumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace Ps3DiscDumper
{
public class Dumper: IDisposable
{
public const string Version = "3.3.3";
public const string Version = "3.3.4";

private static readonly Regex VersionParts = new Regex(@"(?<ver>\d+(\.\d+){0,2})[ \-]*(?<pre>.*)", RegexOptions.Singleline | RegexOptions.ExplicitCapture);
private static readonly Regex VersionParts = new(@"(?<ver>\d+(\.\d+){0,2})[ \-]*(?<pre>.*)", RegexOptions.Singleline | RegexOptions.ExplicitCapture);
private static readonly HashSet<char> InvalidChars = new(Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()));
private static readonly char[] MultilineSplit = {'\r', '\n'};
private long currentSector;
Expand Down
17 changes: 16 additions & 1 deletion UI.WinForms.Msil/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace UI.WinForms.Msil
Expand All @@ -9,11 +13,22 @@ static class Program
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
using var identity = System.Security.Principal.WindowsIdentity.GetCurrent();
var principal = new System.Security.Principal.WindowsPrincipal(identity);
if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)
&& !args.Any(p => p.Equals("/IUnderstandThatRunningSoftwareAsAdministratorIsDangerousAndNotRecommendedForAnyone")))
{
MessageBox.Show("Please do not run software as Administrator unless application was designed to properly handle it, and it is explicitly required.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(-1);
}
}
Application.Run(new MainForm());
}
}
Expand Down

2 comments on commit 42f7277

@egdose
Copy link

@egdose egdose commented on 42f7277 Jul 1, 2023

Choose a reason for hiding this comment

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

This breaks the functionality if I'm the only user of my computer and my account is admin. I can't find a way to run the software because all I can do is run it as admin. Not sure if I'm missing something here.

@13xforever
Copy link
Owner Author

@13xforever 13xforever commented on 42f7277 Jul 1, 2023

Choose a reason for hiding this comment

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

it does not; what you did is you have disabled UAC, which is not supported

Please sign in to comment.