Browse Source

Merge pull request 'Add de-amelioration & more' (#13) from review into master

Reviewed-on: #13
master
he3als 1 month ago
parent
commit
97c2790bb8
13 changed files with 653 additions and 220 deletions
  1. +46
    -135
      src/Actions/.NET.cs
  2. +239
    -0
      src/Actions/Deameliorate.cs
  3. +1
    -0
      src/Ameliorated.ConsoleUtils/ConsoleTUI/FrameWriteMethods.cs
  4. +4
    -4
      src/Ameliorated.ConsoleUtils/ConsoleTUI/Menu.cs
  5. +10
    -0
      src/App.config
  6. +1
    -1
      src/Globals.cs
  7. +1
    -1
      src/Misc/FolderPicker.cs
  8. +261
    -0
      src/Misc/SelectWindowsImage.cs
  9. +15
    -2
      src/NSudo.cs
  10. +3
    -30
      src/Program.cs
  11. +41
    -27
      src/amecs.csproj
  12. +7
    -0
      src/app.manifest
  13. +24
    -20
      src/packages.config

+ 46
- 135
src/Actions/.NET.cs View File

@ -7,8 +7,7 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Misc.FolderPicker;
using amecs.Misc;
using Ameliorated.ConsoleUtils;
using Microsoft.Dism;
@ -16,103 +15,28 @@ namespace amecs.Actions
{
public class _NET
{
private static string file;
private static bool CheckFileViolation(string inputFile)
{
try
{
file = inputFile;
}
catch (SecurityException e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Security error: " + e.Message, ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return true;
}
private static string _mountedPath;
private static string _isoPath;
return false;
}
private static bool DismountImage()
private static void Unmount()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"Dismount-DiskImage '{file}'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
return true;
if (_isoPath == "none")
return;
SelectWindowsImage.DismountIso(_isoPath);
}
public static bool Install()
{
string letter;
var choice = new ChoicePrompt() { Text = "To install .NET 3.5, Windows installation media is needed.\r\nDo you have a Windows USB instead of an ISO? (Y/N): " }.Start();
if (choice == null) return false;
var usingFolder = choice == 0;
if (usingFolder)
{
var dlg = new FolderPicker();
dlg.InputPath = Globals.UserFolder;
if (!dlg.ShowDialog(IntPtr.Zero, false).GetValueOrDefault())
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select a folder or drive.", new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
if (CheckFileViolation(dlg.ResultPath)) return false;
letter = dlg.ResultPath;
}
else
{
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "ISO Files (*.ISO)| *.ISO"; // Filter files by extension
dialog.Multiselect = false;
dialog.InitialDirectory = Globals.UserFolder;
(_mountedPath, _isoPath, _, _, _) = SelectWindowsImage.GetMediaPath(true);
if (_mountedPath == null) return false;
NativeWindow window = new NativeWindow();
window.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
if (dialog.ShowDialog(window) == DialogResult.OK)
{
if (CheckFileViolation(dialog.FileName)) return false;
Console.WriteLine();
ConsoleTUI.OpenFrame.WriteCentered("\r\nMounting ISO");
}
else
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select an ISO.", new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
using (new ConsoleUtils.LoadingIndicator(true))
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments =
$"-NoP -C \"(Mount-DiskImage '{file}' -PassThru | Get-Volume).DriveLetter + ':\'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
letter = proc.StandardOutput.ReadLine();
}
}
if (!Directory.Exists(letter + @"\sources\sxs") || !Directory.GetFiles(letter + @"\sources\sxs", "*netfx3*").Any())
if (!Directory.Exists(_mountedPath + @"\sources\sxs") || !Directory.GetFiles(_mountedPath + @"\sources\sxs", "*netfx3*").Any())
{
DismountImage();
Unmount();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("ISO/USB/folder does not contain the required files.", ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
ConsoleTUI.OpenFrame.Close("ISO/USB/folder does not contain the required files.",
ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return false;
}
@ -120,63 +44,51 @@ namespace amecs.Actions
var topCache = Console.CursorTop;
var leftCache = Console.CursorLeft;
Console.WriteLine();
bool inProgress = false;
var inProgress = false;
try
{
using (var indicator = new ConsoleUtils.LoadingIndicator())
using var indicator = new ConsoleUtils.LoadingIndicator();
DismApi.Initialize(DismLogLevel.LogErrors);
using (var session = DismApi.OpenOnlineSession())
{
DismApi.Initialize(DismLogLevel.LogErrors);
using (var session = DismApi.OpenOnlineSession())
var stdout = GetStdHandle(-11);
var indicatorStopped = false;
var maxHashTags = (ConsoleTUI.OpenFrame.DisplayWidth - 5);
DismApi.EnableFeatureByPackagePath(session, "NetFX3", null, true, true, new List<string>() { _mountedPath + @"\sources\sxs" }, delegate(DismProgress progress)
{
var stdout = GetStdHandle(-11);
bool indicatorStopped = false;
var maxHashTags = (ConsoleTUI.OpenFrame.DisplayWidth - 5);
DismApi.EnableFeatureByPackagePath(session, "NetFX3", null, true, true, new List<string>() { letter + @"\sources\sxs" }, delegate(DismProgress progress)
inProgress = true;
if (!indicatorStopped)
{
inProgress = true;
if (!indicatorStopped)
{
indicator.Stop();
Console.SetCursorPosition(leftCache, topCache);
Console.WriteLine(" ");
}
indicatorStopped = true;
var progressPerc = progress.Current / 10;
var currentHashTags = (int)Math.Ceiling(Math.Min(((double)progressPerc / 100) * maxHashTags, maxHashTags));
var spaces = maxHashTags - currentHashTags + (4 - progressPerc.ToString().Length);
var sb = new StringBuilder(new string('#', currentHashTags) + new string(' ', spaces) + progressPerc + "%");
uint throwaway;
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out throwaway);
inProgress = false;
});
session.Close();
Thread.Sleep(100);
var sb = new StringBuilder(new string('#', maxHashTags) + " 100%");
uint throwaway;
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out throwaway);
}
indicator.Stop();
Console.SetCursorPosition(leftCache, topCache);
Console.WriteLine(" ");
}
DismApi.Shutdown();
if (!usingFolder) DismountImage();
indicatorStopped = true;
var progressPercentage = progress.Current / 10;
var currentHashTags = (int)Math.Ceiling(Math.Min(((double)progressPercentage / 100) * maxHashTags, maxHashTags));
var spaces = maxHashTags - currentHashTags + (4 - progressPercentage.ToString().Length);
var sb = new StringBuilder(new string('#', currentHashTags) + new string(' ', spaces) + progressPercentage + "%");
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out _);
inProgress = false;
});
session.Close();
Thread.Sleep(100);
var sb = new StringBuilder(new string('#', maxHashTags) + " 100%");
uint throwaway;
WriteConsoleOutputCharacter(stdout, sb, (uint)sb.Length, new Languages.COORD((short)ConsoleTUI.OpenFrame.DisplayOffset, (short)Console.CursorTop), out throwaway);
}
DismApi.Shutdown();
Unmount();
} catch (Exception e)
{
while (inProgress)
{
Thread.Sleep(50);
}
if (!usingFolder)
{
try
{
DismountImage();
}
catch (Exception ex)
{
}
}
Unmount();
Console.WriteLine();
Console.WriteLine();
@ -190,7 +102,6 @@ namespace amecs.Actions
Console.WriteLine();
Console.WriteLine();
if (!usingFolder)
ConsoleTUI.OpenFrame.Close(".NET 3.5 installed successfully", ConsoleColor.Green, Console.BackgroundColor, new ChoicePrompt()
{
AnyKey = true,


+ 239
- 0
src/Actions/Deameliorate.cs View File

@ -0,0 +1,239 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Security.Principal;
using System.Threading;
using amecs.Misc;
using Ameliorated.ConsoleUtils;
using Microsoft.Win32;
namespace amecs.Actions
{
public class Deameliorate
{
private static string _mountedPath;
private static string _winVer;
private static string _win11Setup = "";
private static bool _win11 = Environment.OSVersion.Version.Build >= 22000;
private const string ExplorerPatcherId = "D17F1E1A-5919-4427-8F89-A1A8503CA3EB";
public static bool DeAme()
{
if (new ChoicePrompt()
{
Text = @"
This will de-ameliorate by reinstalling Windows.
Although user data should be kept, we strongly recommend
making backups of any important user data.
Continue? (Y/N): "
}.Start().Value == 1) return true;
Program.Frame.Clear();
(_mountedPath, _, _winVer, _, _) = SelectWindowsImage.GetMediaPath();
if (_mountedPath == null) return false;
if (new ChoicePrompt {Text = $"\r\nYour Windows image is {_winVer}. Continue? (Y/N): "}.Start().Value == 1)
return true;
var fc = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
string userSid = null;
try
{
NSudo.GetSystemPrivilege();
NSudo.RunAsUser(() =>
{
userSid = WindowsIdentity.GetCurrent().User.ToString();
});
}
catch
{
// do nothing
}
try
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nUninstalling AME-installed UI software...");
string openShellId = null;
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (var item in key.GetSubKeyNames())
{
try
{
if (((string)key.OpenSubKey(item).GetValue("DisplayName")).Equals("Open-Shell"))
openShellId = item;
}
catch
{
// do nothing
}
}
if (openShellId != null)
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nUninstalling Open-Shell...");
Process.Start("MsiExec.exe", $"/X{openShellId} /quiet")?.WaitForExit();
if (userSid != null)
{
var appData = (string)Registry.Users.OpenSubKey(userSid + @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders").GetValue("AppData");
if (Directory.Exists(Path.Combine(appData, "OpenShell")))
Directory.Delete(Path.Combine(appData, "OpenShell"), true);
}
}
var epSetupPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\ExplorerPatcher\ep_setup.exe";
if (File.Exists(epSetupPath))
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nUninstalling ExplorerPatcher...");
var winlogon = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
winlogon?.SetValue("AutoRestartShell", 0);
// kill processes that the files use
foreach (var processName in new[] {"explorer.exe", "rundll32.exe", "dllhost.exe", "ShellExperienceHost.exe", "StartMenuExperienceHost.exe"})
{
foreach (var process in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(processName)))
{
process.Kill();
process.WaitForExit();
}
}
// delete DWM service that removes rounded corners
Process.Start("sc", $"stop \"ep_dwm_{ExplorerPatcherId}\"")?.WaitForExit();
Process.Start("sc", $"delete \"ep_dwm_{ExplorerPatcherId}\"")?.WaitForExit();
// remove registered DLL
var explorerPatcherDllPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "ExplorerPatcher", "ExplorerPatcher.amd64.dll");
Process.Start("regsvr32.exe", $"/s /u \"{explorerPatcherDllPath}\"")?.WaitForExit();
// delete files
foreach (var file in new[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\ShellExperienceHost_cw5n1h2txyewy\dxgi.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\ShellExperienceHost_cw5n1h2txyewy\wincorlib.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\ShellExperienceHost_cw5n1h2txyewy\wincorlib_orig.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\dxgi.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\wincorlib.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\wincorlib_orig.dll"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
"dxgi.dll")
})
{
if (File.Exists(file)) File.Delete(file);
}
foreach (var folder in new[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"ExplorerPatcher"),
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
@"Microsoft\Windows\Start Menu\Programs\ExplorerPatcher")
})
{
if (Directory.Exists(folder)) Directory.Delete(folder, true);
}
winlogon?.SetValue("AutoRestartShell", 1);
}
Program.Frame.Clear();
} catch (Exception e)
{
ConsoleTUI.OpenFrame.Close(
"Error when uninstalling software: " + e.Message,
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to continue anyways: " });
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nContinuing without uninstalling software...\r\n");
}
// restart Explorer
if (Process.GetProcessesByName("explorer").Length == 0)
NSudo.RunProcessAsUser(NSudo.GetUserToken(), "explorer.exe", "", 0);
// all policies are cleared as a user that's de-ameliorating is unlikely to have their own policies in the first place
// also clear ExplorerPatcher Registry entries
ConsoleTUI.OpenFrame.WriteCentered("\r\nClearing policies...");
foreach (var keyPath in new[] {
$@"HKU\{userSid}\Software\Microsoft\Windows\CurrentVersion\Policies",
$@"HKU\{userSid}\Software\Policies",
$@"HKU\{userSid}\Software\ExplorerPatcher",
$@"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{{ExplorerPatcherId}}}_ExplorerPatcher",
@"HKLM\Software\Microsoft\Windows\CurrentVersion\Policies",
@"HKLM\Software\Policies",
@"HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies"
})
{
var hive = RegistryHive.LocalMachine;
if (keyPath.StartsWith("HKU"))
hive = RegistryHive.Users;
var baseKey = RegistryKey.OpenBaseKey(hive, RegistryView.Default);
var subKeyPath = keyPath.Substring(keyPath.IndexOf('\\') + 1);
var key = baseKey.OpenSubKey(subKeyPath, true);
if (key == null) continue;
try
{
baseKey.DeleteSubKeyTree(subKeyPath);
}
catch
{
// do nothing - some values might fail, but almost all are deleted
}
key.Close();
}
Thread.Sleep(3000);
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nCompleted initial setup!", ConsoleColor.Green);
if (_win11)
{
ConsoleTUI.OpenFrame.WriteCentered("\r\nWindows Setup will display as 'Windows Server,' but it's not actually installing Windows Server and is only set as such to bypass hardware requirements.");
Console.WriteLine();
}
ConsoleTUI.OpenFrame.WriteCentered("\r\nWaiting 10 seconds and starting Windows Setup...");
Console.ForegroundColor = fc;
Thread.Sleep(10000);
Console.WriteLine();
try
{
if (_win11) _win11Setup = "/Product Server";
Process.Start(Path.Combine(_mountedPath, "setup.exe"), $"/Auto Upgrade /DynamicUpdate Disable {_win11Setup}");
} catch (Exception e)
{
ConsoleTUI.OpenFrame.Close(
$"There was an error when trying to run the Windows Setup: {e}\r\nTry running the Windows Setup manually from File Explorer.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = $"Press any key to exit: " });
return false;
}
ConsoleTUI.OpenFrame.Close(
"Completed, Windows Setup should have started.",
ConsoleColor.Cyan, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = $"Press any key to go back: " });
return true;
}
}
}

+ 1
- 0
src/Ameliorated.ConsoleUtils/ConsoleTUI/FrameWriteMethods.cs View File

@ -323,6 +323,7 @@ namespace Ameliorated.ConsoleUtils
ConsoleUtils.ResetColor();
}
// TODO: Fix this splitting lines when a piece of text can fit on one line
private List<CenteredString> CenterLines(string text, LineCenterOptions options, int maxWidth = 0)
{
var _maxWidth = DisplayWidth;


+ 4
- 4
src/Ameliorated.ConsoleUtils/ConsoleTUI/Menu.cs View File

@ -164,7 +164,7 @@ namespace Ameliorated.ConsoleUtils
while (true)
{
keyPressed = Console.ReadKey(true).Key;
if (keyPressed == ConsoleKey.DownArrow)
if (keyPressed == ConsoleKey.DownArrow || keyPressed == ConsoleKey.S)
{
if (validIndex >= currentValidChoices.Count - 1) continue;
Console.SetCursorPosition(Math.Max(TotalOffset - 2, 0), Console.CursorTop);
@ -182,7 +182,7 @@ namespace Ameliorated.ConsoleUtils
validIndex += 1;
}
if (keyPressed == ConsoleKey.UpArrow)
if (keyPressed == ConsoleKey.UpArrow || keyPressed == ConsoleKey.W)
{
if (!(validIndex > 0)) continue;
@ -201,7 +201,7 @@ namespace Ameliorated.ConsoleUtils
validIndex -= 1;
}
if (keyPressed == ConsoleKey.RightArrow || keyPressed == ConsoleKey.PageUp ||
if (keyPressed == ConsoleKey.RightArrow || keyPressed == ConsoleKey.A || keyPressed == ConsoleKey.PageUp ||
(keyPressed == ConsoleKey.Enter && currentValidChoices[validIndex].IsNextButton))
{
if (pageIndex == pages)
@ -245,7 +245,7 @@ namespace Ameliorated.ConsoleUtils
continue;
}
if (keyPressed == ConsoleKey.LeftArrow || keyPressed == ConsoleKey.PageDown ||
if (keyPressed == ConsoleKey.LeftArrow || keyPressed == ConsoleKey.D || keyPressed == ConsoleKey.PageDown ||
(keyPressed == ConsoleKey.Enter && currentValidChoices[validIndex].IsPreviousButton))
{
if (pageIndex == 1)


+ 10
- 0
src/App.config View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

+ 1
- 1
src/Globals.cs View File

@ -36,6 +36,6 @@ namespace amecs
return true;
}
public static readonly int WinVer = Int32.Parse(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue("CurrentBuildNumber").ToString());
public static readonly int WinVer = int.Parse(Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue("CurrentBuildNumber").ToString());
}
}

src/Misc.FolderPicker/FolderPicker.cs → src/Misc/FolderPicker.cs View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Misc.FolderPicker
namespace amecs.Misc
{
public class FolderPicker
{

+ 261
- 0
src/Misc/SelectWindowsImage.cs View File

@ -0,0 +1,261 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security;
using System.Windows.Forms;
using Ameliorated.ConsoleUtils;
using Microsoft.Dism;
// Asks user to select Windows installation media, and mounts it if applicable
// Returns path to where it's mounted
namespace amecs.Misc
{
public static class SelectWindowsImage
{
private static string _fileViolationTest;
private static bool CheckFileViolation(string inputFile)
{
try
{
_fileViolationTest = inputFile;
}
catch (SecurityException e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("Security exception: " + e.Message, ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return true;
}
return false;
}
public static string GetWindowsVersion(float majorMinor, int isoBuild)
{
return (majorMinor, isoBuild) switch
{
(6, _) => "Windows Vista",
(6.1f, _) => "Windows 7",
(6.2f, _) => "Windows 8",
(6.3f, _) => "Windows 8.1",
(10, var a) when a < 19041 => "Windows 10 (Old)",
(10, var a) when a >= 22000 => "Windows 11",
(10, _) => "Windows 10",
_ => "Unknown"
};
}
public static bool DismountIso(string imagePath)
{
var startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "PowerShell.exe",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"-NoP -C \"Dismount-DiskImage '{imagePath}'\"",
RedirectStandardOutput = true
};
var proc = Process.Start(startInfo);
if (proc == null) return false;
proc.WaitForExit();
return true;
}
private static string _mountedPath;
private static string _isoPath;
private static string _isoWinVer;
private static int _isoBuild;
/// <summary>
/// Asks user to select Windows installation media, mounts it if applicable, and checks its version
/// </summary>
/// <param name="winVersionsMustMatch">If true when ISO and host versions mismatch, prompts user that things can break if they continue</param>
/// <param name="isoBuildMustBeReturned">If true and the ISO build can't be retrieved, prompts a user with an error</param>
public static (
string MountedPath, string IsoPath, string Winver, int? Build, bool? VersionsMatch
) GetMediaPath(bool winVersionsMustMatch = false, bool isoBuildMustBeReturned = false)
{
var error = ((string)null, "none", (string)null, (int?)null, (bool?)null);
var choice =
new ChoicePrompt { Text = "To continue, Windows installation media is needed.\r\nDo you have a Windows USB instead of an ISO file? (Y/N): " }.Start();
if (!choice.HasValue) return error;
// Folder/drive chosen
var usingFolder = choice == 0;
if (usingFolder)
{
var dlg = new FolderPicker
{
InputPath = Globals.UserFolder
};
if (dlg.ShowDialog(IntPtr.Zero).GetValueOrDefault())
{
if (CheckFileViolation(dlg.ResultPath))
return error;
_mountedPath = dlg.ResultPath;
}
else
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select a folder or drive containing Windows installation media.",
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
}
else
{
// Mounting the ISO
var dialog = new OpenFileDialog();
dialog.Filter = "ISO Files (*.ISO)| *.ISO";
dialog.Multiselect = false;
dialog.InitialDirectory = Globals.UserFolder;
var window = new NativeWindow();
window.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
if (dialog.ShowDialog(window) == DialogResult.OK)
{
_isoPath = dialog.FileName;
if (CheckFileViolation(_isoPath)) return error;
Console.WriteLine();
ConsoleTUI.OpenFrame.WriteCentered("\r\nMounting ISO");
}
else
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("\r\nYou must select an ISO.",
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
using (new ConsoleUtils.LoadingIndicator(true))
{
var startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "PowerShell.exe",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"-NoP -C \"(Mount-DiskImage '{_isoPath}' -PassThru | Get-Volume).DriveLetter + ':\'\"",
RedirectStandardOutput = true
};
var proc = Process.Start(startInfo);
if (proc == null) return error;
proc.WaitForExit();
_mountedPath = proc.StandardOutput.ReadLine();
}
}
// Check WIM version
var wimOrEsdPath = new[] { $@"{_mountedPath}\sources\install.esd", $@"{_mountedPath}\sources\install.wim" }.FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(wimOrEsdPath))
{
try
{
DismApi.Initialize(DismLogLevel.LogErrors);
string previousIndexVersion = null;
string isoFullVersion = null;
var multiVersion = false;
var imageInfos = DismApi.GetImageInfo(wimOrEsdPath);
foreach (var imageInfo in imageInfos)
{
isoFullVersion = imageInfo.ProductVersion.ToString();
if (isoFullVersion != previousIndexVersion && previousIndexVersion != null)
{
// If it's multi-version, WinVer will be "Unknown" as well
multiVersion = true;
isoFullVersion = "0.0.0.0";
break;
}
previousIndexVersion = isoFullVersion;
}
switch (multiVersion)
{
case true when isoBuildMustBeReturned:
ConsoleTUI.OpenFrame.Close(
"Multiple Windows versions were found in the Windows image, can't determine which Windows build it is. Please use an unmodified Windows ISO.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
case true when winVersionsMustMatch:
ConsoleTUI.OpenFrame.Close(
"Multiple Windows versions were found in the Windows image, can't determine which Windows build it is. If your Windows version doesn't match the ISO, there will be problems.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to continue anyways: " });
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nContinuing without version check...\r\n");
break;
}
var buildSplit = isoFullVersion.Split('.');
_isoBuild = int.Parse(buildSplit[2]);
_isoWinVer = GetWindowsVersion(float.Parse($"{buildSplit[0]}.{buildSplit[1]}"), _isoBuild);
}
catch (Exception e)
{
Console.WriteLine();
ConsoleTUI.OpenFrame.Close(
"Error checking ISO version: " + e.Message.TrimEnd('\n').TrimEnd('\r'),
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
finally
{
try
{
DismApi.Shutdown();
}
catch
{
// do nothing
}
}
// Check the current OS version
var hostVersion = Environment.OSVersion.Version;
var hostWinver = GetWindowsVersion(float.Parse($"{hostVersion.Major}.{hostVersion.Minor}"), hostVersion.Build);
// If it all matches & winVersionsMustMatch
if (hostWinver == _isoWinVer) return (_mountedPath, _isoPath, _isoWinVer, _isoBuild, true);
// If ISO version doesn't match host version & winVersionsMustMatch
if (hostWinver != _isoWinVer && winVersionsMustMatch)
{
if (!string.IsNullOrEmpty(_isoPath)) DismountIso(_isoPath);
ConsoleTUI.OpenFrame.Close(
$"You're on {hostWinver}, but the selected image is {_isoWinVer}. You can only use an ISO that matches your Windows version.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = "Press any key to return to the Menu: " });
return error;
}
// If ISO version doesn't match host version, and winVersionsMustMatch is true
if (hostWinver != _isoWinVer) return (_mountedPath, _isoPath, _isoWinVer, _isoBuild, false);
}
var noWimText = isoBuildMustBeReturned
? "Press any key to return to the Menu"
: "Press any key to continue anyways";
ConsoleTUI.OpenFrame.Close(
"No Windows installation image was found inside the selected Windows media. No version check can be done, things might break.",
ConsoleColor.Red, Console.BackgroundColor,
new ChoicePrompt { AnyKey = true, Text = $"{noWimText}: " });
Program.Frame.Clear();
ConsoleTUI.OpenFrame.WriteCentered("\r\nContinuing without version check\r\n");
return isoBuildMustBeReturned ? error : (_mountedPath, _isoPath, null, null, null);
}
}
}

+ 15
- 2
src/NSudo.cs View File

@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32.SafeHandles;
namespace amecs
@ -505,8 +506,20 @@ namespace amecs
RtlAdjustPrivilege((int)luid, true, true, out throwaway);
}
public class Win32 {
public static void RunAsUser(Action action)
{
var token = NSudo.GetUserToken();
Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action)).Wait();
Marshal.FreeHGlobal(token);
}
private static async Task RunAsUserAsync(Action action)
{
var token = NSudo.GetUserToken();
await Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action));
Marshal.FreeHGlobal(token);
}
}
}

+ 3
- 30
src/Program.cs View File

@ -1,19 +1,9 @@
using System;
using System.Diagnostics;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using System.Globalization;
using System.Linq;
using System.Management;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using Ameliorated.ConsoleUtils;
using Microsoft.Win32;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using amecs.Actions;
using Menu = Ameliorated.ConsoleUtils.Menu;
@ -21,23 +11,6 @@ namespace amecs
{
internal class Program
{
private static void RunAsUser(Action action)
{
var token = NSudo.GetUserToken();
Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action)).Wait();
Marshal.FreeHGlobal(token);
}
private static async Task RunAsUserAsync(Action action)
{
var token = NSudo.GetUserToken();
await Task.Run((Action)Delegate.Combine((Action)(() => { NSudo.GetUserPrivilege(token); }),
action));
Marshal.FreeHGlobal(token);
}
private const string Ver = "2.1";
public static ConsoleTUI.Frame Frame;
[STAThread]
@ -51,7 +24,7 @@ namespace amecs
NSudo.GetSystemPrivilege();
if (!WindowsIdentity.GetCurrent().IsSystem)
throw new Exception("Identity did not change.");
RunAsUser(() =>
NSudo.RunAsUser(() =>
{
Globals.Username = WindowsIdentity.GetCurrent().Name.Split('\\').Last();
Globals.UserDomain = WindowsIdentity.GetCurrent().Name.Split('\\').FirstOrDefault();
@ -82,9 +55,8 @@ namespace amecs
}
Frame = new ConsoleTUI.Frame($"| Central AME Script v{Ver} |", false);
Frame.Open();
while (true)
{
Globals.UserElevated = Globals.User.IsMemberOf(Globals.Administrators);
@ -137,6 +109,7 @@ namespace amecs
new Menu.MenuItem("Install .NET 3.5", new Func<bool>(_NET.Install)) :
new Menu.MenuItem("Install .NET 3.5", new Func<bool>(_NET.Install)) {SecondaryText = "[Installed]", SecondaryTextForeground = ConsoleColor.Yellow, PrimaryTextForeground = ConsoleColor.DarkGray},
Menu.MenuItem.Blank,
new Menu.MenuItem("Uninstall AME", new Func<bool>(Deameliorate.DeAme)),
new Menu.MenuItem("Extra", new Func<bool>(Extra.Extra.ShowMenu)),
new Menu.MenuItem("Exit", new Func<bool>(Globals.Exit))
},


+ 41
- 27
src/amecs.csproj View File

@ -46,12 +46,11 @@
<HintPath>packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>packages\JetBrains.Annotations.2022.3.1\lib\net20\JetBrains.Annotations.dll</HintPath>
<Private>False</Private>
<HintPath>packages\JetBrains.Annotations.2023.3.0\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Dism, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5bba90053b345501, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Dism.2.5.2\lib\net40\Microsoft.Dism.dll</HintPath>
<HintPath>packages\Microsoft.Dism.3.1.0\lib\net40\Microsoft.Dism.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
@ -61,20 +60,22 @@
<Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>
</Reference>
<Reference Include="System.CodeDom, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.CodeDom.7.0.0\lib\net462\System.CodeDom.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.CodeDom, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.CodeDom.8.0.0\lib\net462\System.CodeDom.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
<Reference Include="System.Console, Version=4.0.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Private>False</Private>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.Tracing, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll</HintPath>
@ -115,22 +116,31 @@
<HintPath>packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll</HintPath>
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reflection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Reference Include="System.Runtime, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.InteropServices, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll</HintPath>
@ -144,7 +154,7 @@
<Private>False</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
@ -152,12 +162,11 @@
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.Security.Permissions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Permissions.7.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
<Private>False</Private>
<Reference Include="System.Security.Permissions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Permissions.8.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
@ -165,20 +174,21 @@
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll</HintPath>
<HintPath>packages\System.Text.RegularExpressions.4.3.1\lib\net463\System.Text.RegularExpressions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
<HintPath>packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actions\.NET.cs" />
<Compile Include="Actions\AutoLogon.cs" />
<Compile Include="Actions\Deameliorate.cs" />
<Compile Include="Actions\Elevation.cs" />
<Compile Include="Actions\Languages.cs" />
<Compile Include="Actions\Lockscreen.cs" />
@ -197,11 +207,12 @@
<Compile Include="Ameliorated.ConsoleUtils\Extensions.cs" />
<Compile Include="Ameliorated.ConsoleUtils\ParentProcess.cs" />
<Compile Include="Ameliorated.ConsoleUtils\Payload.cs" />
<Compile Include="Misc.FolderPicker\FolderPicker.cs" />
<Compile Include="Extra\Extra.cs" />
<Compile Include="Extra\NVCP.cs" />
<Compile Include="Extra\WSH.cs" />
<Compile Include="Globals.cs" />
<Compile Include="Misc\FolderPicker.cs" />
<Compile Include="Misc\SelectWindowsImage.cs" />
<Compile Include="NSudo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -210,6 +221,7 @@
<ItemGroup>
<None Include="amecs.ico" />
<None Include="amecs.png" />
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
@ -231,16 +243,18 @@
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Fody.6.5.5\build\Fody.targets" Condition="Exists('packages\Fody.6.5.5\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Fody.6.5.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.5.5\build\Fody.targets'))" />
<Error Condition="!Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.5.7.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.5.7.0\build\Costura.Fody.targets'))" />
<Error Condition="!Exists('packages\Fody.6.8.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.8.0\build\Fody.targets'))" />
<Error Condition="!Exists('packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
</Target>
<Import Project="packages\Costura.Fody.5.7.0\build\Costura.Fody.targets" Condition="Exists('packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" />
<Import Project="packages\Fody.6.8.0\build\Fody.targets" Condition="Exists('packages\Fody.6.8.0\build\Fody.targets')" />
<Import Project="packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">


+ 7
- 0
src/app.manifest View File

@ -7,4 +7,11 @@
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Support Windows 10 and above - needed for certain functions to return
correct Windows version. https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#supportedOS -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

+ 24
- 20
src/packages.config View File

@ -1,23 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="5.7.0" targetFramework="net472" developmentDependency="true" />
<package id="Fody" version="6.5.5" targetFramework="net472" developmentDependency="true" />
<package id="JetBrains.Annotations" version="2022.3.1" targetFramework="net472" />
<package id="Microsoft.Dism" version="2.5.2" targetFramework="net472" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net472" />
<package id="Fody" version="6.8.0" targetFramework="net472" developmentDependency="true" />
<package id="JetBrains.Annotations" version="2023.3.0" targetFramework="net472" />
<package id="Microsoft.Dism" version="3.1.0" targetFramework="net472" />
<package id="Microsoft.NETCore.Platforms" version="7.0.4" targetFramework="net472" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net472" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
<package id="System.CodeDom" version="7.0.0" targetFramework="net472" />
<package id="System.CodeDom" version="8.0.0" targetFramework="net472" />
<package id="System.Console" version="4.3.1" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="8.0.0" targetFramework="net472" />
<package id="System.DirectoryServices" version="8.0.0" targetFramework="net472" />
<package id="System.DirectoryServices.AccountManagement" version="8.0.0" targetFramework="net472" />
<package id="System.Management" version="8.0.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.3.1" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net472" />
<package id="System.Security.Permissions" version="8.0.0" targetFramework="net472" />
<package id="System.Text.RegularExpressions" version="4.3.1" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Net.Primitives" version="4.3.1" targetFramework="net472" />
<package id="System.Runtime" version="4.3.1" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net472" />
<package id="System.Console" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net472" />
<package id="System.DirectoryServices" version="7.0.1" targetFramework="net472" />
<package id="System.DirectoryServices.AccountManagement" version="7.0.0" targetFramework="net472" />
<package id="System.Drawing.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net472" />
@ -29,34 +41,26 @@
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Linq" version="4.3.0" targetFramework="net472" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net472" />
<package id="System.Management" version="7.0.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net472" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Permissions" version="7.0.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net472" />
<package id="System.Threading" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net472" />
</packages>

Loading…
Cancel
Save