Compare commits

...

2 Commits

Author SHA1 Message Date
393ef60c82 7-Zip License 2025-10-28 10:48:36 +01:00
c27646dfa0 Changes 2025-10-28 10:46:46 +01:00
5 changed files with 185 additions and 18 deletions

View File

@@ -24,7 +24,7 @@ namespace Perfect11
private List<IPlugin> _tweaks = new List<IPlugin>();
private CancellationTokenSource _cts;
private bool _isDownloading = false;
string url = $"https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/26200.6584.250915-1905.25h2_ge_release_svc_refresh_CLIENT_CONSUMER_x64FRE_{Utilities.GetLanguageCode()}.iso";
string url = $"https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/26200.6584.250915-1905.25h2_ge_release_svc_refresh_CLIENT_CONSUMER_{Utilities.GetSystemArchitecture()}FRE_{Utilities.GetLanguageCode()}.iso";
string destination = Path.Combine(@"C:\Temp", @"windows.iso");
private static string AppEdition = "Perfect11 Community Edition";
public Form1()
@@ -464,6 +464,11 @@ namespace Perfect11
private void poisonComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (Utilities.GetSystemArchitecture().ToLower() == "a64" && upgradeMethod.SelectedIndex != 0 && upgradeMethod.SelectedIndex != 3)
{
upgradeMethod.SelectedIndex = 0;
MessageBox.Show("You're running Windows on ARM, some options are not available.", "Perfect11", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
statusLabel.Text = "Ready.";
installProgress.Value = 0;
upgradeButton.Enabled = true;
@@ -669,21 +674,16 @@ namespace Perfect11
byte[] buffer = new byte[8192];
int bytesRead;
DateTime lastUpdate = DateTime.Now;
while ((bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length, token)) > 0)
{
await fileStream.WriteAsync(buffer, 0, bytesRead, token);
totalRead += bytesRead;
if (totalBytes.HasValue)
{
int progress = (int)((totalRead * 100L) / totalBytes.Value);
if (progress > 100) progress = 100;
installProgress.Value = progress;
statusLabel.Text = $"ISO Download Progress: {progress}%";
// Aggiorna la UI ogni ~200ms
if ((DateTime.Now - lastUpdate).TotalMilliseconds > 200)
{
Application.DoEvents();
@@ -699,7 +699,6 @@ namespace Perfect11
string sevenZipPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Tools\7z.exe");
if (!File.Exists(sevenZipPath))
throw new FileNotFoundException("7-Zip not found.");
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = sevenZipPath,
@@ -708,15 +707,12 @@ namespace Perfect11
UseShellExecute = false,
CreateNoWindow = true
};
using (Process proc = new Process { StartInfo = psi })
{
proc.Start();
string line;
int lastPercent = 0;
var regex = new Regex(@"(\d+)%");
Invoke(new Action(() =>
{
installProgress.Value = 0;
@@ -727,11 +723,9 @@ namespace Perfect11
while (!proc.HasExited)
{
token.ThrowIfCancellationRequested();
line = proc.StandardOutput.ReadLine();
if (line == null)
continue;
var match = regex.Match(line);
if (match.Success)
{
@@ -749,7 +743,6 @@ namespace Perfect11
}
}, token);
proc.WaitForExit();
if (proc.ExitCode != 0)
throw new Exception($"7-Zip exited with code {proc.ExitCode}");
}

View File

@@ -1,13 +1,14 @@
using Microsoft.Win32;
using Newtonsoft.Json;
using Perfect11.TweaksInterface;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Principal;
using Microsoft.Win32;
using Newtonsoft.Json;
using Perfect11.TweaksInterface;
namespace Perfect11.Library
{
@@ -147,5 +148,18 @@ namespace Perfect11.Library
}
}
}
public static string GetSystemArchitecture()
{
string arch = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
string archWow64 = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432");
string osArch;
if (!string.IsNullOrEmpty(archWow64))
osArch = archWow64; // 64-bit OS, 32-bit process
else
osArch = arch;
if (osArch.ToLower() == "arm64")
osArch = "A64";
return osArch;
}
}
}

View File

@@ -142,6 +142,9 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Tools\license.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Tools\7-zip.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@@ -24,6 +24,17 @@ namespace Perfect11
#else
Application.ThreadException += (s, e) => { };
#endif
if (Utilities.GetSystemArchitecture().ToLower() == "x86")
{
MessageBox.Show("You're running on Windows 32 bits, this program requires Windows 64 bits.","Perfect11",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
else if (Utilities.GetSystemArchitecture().ToLower() == "a64")
{
var dialog = MessageBox.Show("You're running Windows on ARM. ARM64 support for this tool is experimental, and not everything will work fine. Are you sure to continue?","Perfect11",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2);
if (dialog == DialogResult.No)
return;
}
Application.Run(new Form1());
}
}

146
Perfect11/Tools/license.txt Normal file
View File

@@ -0,0 +1,146 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7-Zip Copyright (C) 1999-2025 Igor Pavlov.
The licenses for files are:
- 7z.dll:
- The "GNU LGPL" as main license for most of the code
- The "GNU LGPL" with "unRAR license restriction" for some code
- The "BSD 3-clause License" for some code
- The "BSD 2-clause License" for some code
- All other files: the "GNU LGPL".
Redistributions in binary form must reproduce related license information from this file.
Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
BSD 3-clause License in 7-Zip code
----------------------------------
The "BSD 3-clause License" is used for the following code in 7z.dll
1) LZFSE data decompression.
That code was derived from the code in the "LZFSE compression library" developed by Apple Inc,
that also uses the "BSD 3-clause License".
2) ZSTD data decompression.
that code was developed using original zstd decoder code as reference code.
The original zstd decoder code was developed by Facebook Inc,
that also uses the "BSD 3-clause License".
Copyright (c) 2015-2016, Apple Inc. All rights reserved.
Copyright (c) Facebook, Inc. All rights reserved.
Copyright (c) 2023-2025 Igor Pavlov.
Text of the "BSD 3-clause License"
----------------------------------
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
BSD 2-clause License in 7-Zip code
----------------------------------
The "BSD 2-clause License" is used for the XXH64 code in 7-Zip.
XXH64 code in 7-Zip was derived from the original XXH64 code developed by Yann Collet.
Copyright (c) 2012-2021 Yann Collet.
Copyright (c) 2023-2025 Igor Pavlov.
Text of the "BSD 2-clause License"
----------------------------------
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
unRAR license restriction
-------------------------
The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.
The license for original unRAR code has the following restriction:
The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.
--