Skip to content

Commit

Permalink
Upgrade to v2.7.0
Browse files Browse the repository at this point in the history
Use cloud services to deliver digital certificates.
  • Loading branch information
TGSAN committed Oct 7, 2023
1 parent d3d41c5 commit fbb64b4
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 128 deletions.
4 changes: 0 additions & 4 deletions CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@
</ItemGroup>
<ItemGroup>
<Content Include="Res\ClipUp.exe" />
<Content Include="Res\gatherosstate.exe" />
<Content Include="Res\gatherosstateltsc.exe" />
<Content Include="Res\slc.dll" />
<EmbeddedResource Include="Res\LibGatherOsState.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MaterialDesignThemes.4.5.0\build\MaterialDesignThemes.targets" Condition="Exists('..\packages\MaterialDesignThemes.4.5.0\build\MaterialDesignThemes.targets')" />
Expand Down
125 changes: 46 additions & 79 deletions CMWTAT_DIGITAL/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ public void ExportTempFile()
ConsoleLog("开始写入缓存文件");
File.WriteAllBytes(tempfile + "ClipUp" + ".exe", Properties.Resources.ClipUp);
File.WriteAllBytes(tempfile + "slmgr" + ".vbs", Properties.Resources.slmgr);
File.WriteAllBytes(tempfile + "gatherosstate" + ".exe", Properties.Resources.gatherosstate);
File.WriteAllBytes(tempfile + "gatherosstateltsc" + ".exe", Properties.Resources.gatherosstateltsc);
File.WriteAllBytes(tempfile + "slc" + ".dll", Properties.Resources.slc);
ConsoleLog("写入缓存文件完毕");
}

Expand Down Expand Up @@ -367,7 +364,7 @@ public MainWindow()
DataContext = new ViewModel();

this.DialogHostGrid.Visibility = Visibility.Visible;

DialogWait.IsOpen = true;
try
{
Expand Down Expand Up @@ -446,6 +443,7 @@ private void CheckUpdate()
}
}

public static string StaticServerDomain = "https://uwa-static.cloudmoe.com"; // 静态服务器
public static string MainServerDomain = "https://cmwtat.cloudmoe.com"; // 主要服务器
public static string BackupServerDomain = "https://kms.kumo.moe"; // 备用服务器

Expand All @@ -464,14 +462,14 @@ private void LoadOSList()
string json;
try
{
json = GetHttpWebRequest(MainServerDomain + "/api/digital?list=1&ver=3"); // 主要服务器
json = GetHttpWebRequest(MainServerDomain + "/api/digital?list=1&ver=4"); // 主要服务器
}
catch (Exception e)
{
ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
ConsoleLog("Error Message:" + e.Message);
ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=1&ver=3"); // 备用服务器
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=1&ver=4"); // 备用服务器
}
JObject jsonobj = JObject.Parse(json);
List<Frequency> list = new List<Frequency>();
Expand Down Expand Up @@ -661,12 +659,12 @@ private void installbtn_Click(object sender, RoutedEventArgs e)
Thread installthread = new Thread(RunInstall);
installthread.Start();
}

private void upgradefullbtn_Click(object sender, RoutedEventArgs e)
{
this.DialogUpgradeFullVersion.IsOpen = true;
}

private void UpgradeFullVersionWindows_Click(object sender, RoutedEventArgs e)
{
this.DialogUpgradeFullVersion.IsOpen = false;
Expand Down Expand Up @@ -781,14 +779,14 @@ private void RunInstall()
string json;
try
{
json = GetHttpWebRequest(MainServerDomain + "/api/digital?list=0&ver=3"); // 主要服务器
json = GetHttpWebRequest(MainServerDomain + "/api/digital?list=0&ver=4"); // 主要服务器
}
catch (Exception e)
{
ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
ConsoleLog("Error Message:" + e.Message);
ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=4"); // 备用服务器
}
JObject jsonobj = JObject.Parse(json);
List<Frequency> list = new List<Frequency>();
Expand Down Expand Up @@ -946,7 +944,7 @@ private void RunAct()
string targetFile = slmgr_self;
bool isrewrite = true; // true=覆盖已存在的同名文件,false则反之
ConsoleLog("Copy Start: " + sourceFile + " To " + targetFile);
System.IO.File.Copy(sourceFile, targetFile, isrewrite);
File.Copy(sourceFile, targetFile, isrewrite);
ConsoleLog("Copy Completed.");
}
catch (Exception CopyExc)
Expand All @@ -955,7 +953,6 @@ private void RunAct()
}

//旧的位置
//string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";

string changepk = Environment.SystemDirectory + "\\changepk.exe";

Expand All @@ -980,14 +977,14 @@ private void RunAct()
string json;
try
{
json = GetHttpWebRequest(MainServerDomain + "/api/digital?list=0&ver=3"); // 主要服务器
json = GetHttpWebRequest(MainServerDomain + "/api/digital?list=0&ver=4"); // 主要服务器
}
catch (Exception e)
{
ConsoleLog("MainServer:" + MainServerDomain + " is not working.");
ConsoleLog("Error Message:" + e.Message);
ConsoleLog("Ready to use BackupServer:" + BackupServerDomain);
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=3"); // 备用服务器
json = GetHttpWebRequest(BackupServerDomain + "/api/digital?list=0&ver=4"); // 备用服务器
}
JObject jsonobj = JObject.Parse(json);
List<Frequency> list = new List<Frequency>();
Expand Down Expand Up @@ -1117,28 +1114,6 @@ private void RunAct()
}
}

//写入旧系统特征(用于旧版保底方案)
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = (string)this.Resources["RunAct_Writing_old_OS"]; // "Writing feature of old Windows version";
ShowBallSameDig();
}));

if (mode == "4")
{
//长期KMS
ConsoleLog(RunCScript(slmgr_self, "-skms 1.1.45.14:1919").Trim()); // いいよ、来いよ www
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens"" /v ""Channel"" /t REG_SZ /d ""Volume:GVLK"" /f"); // 用于旧版保底方案
}
else
{
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens"" /v ""Channel"" /t REG_SZ /d ""Retail"" /f"); // 用于旧版保底方案
}

// 写入注册表模拟激活和产品信息(用于旧版保底方案)
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens\Kernel"" /v ""Kernel-ProductInfo"" /t REG_DWORD /d " + sku + " /f");
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens\Kernel"" /v ""Security-SPP-GenuineLocalStatus"" /t REG_DWORD /d 1 /f");

actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = (string)this.Resources["RunAct_Installing_Key"]; //提示正在安装密钥
Expand All @@ -1159,37 +1134,45 @@ private void RunAct()
ShowBallSameDig();
}));

//LibGatherOsState.GatherOsState.SetLibHWIDPath(tempfile + "LibHWIDx86.dll", tempfile + "LibHWIDx64.dll");
string ticket = null;

var licenseType = LibGatherOsState.GatherOsState.LicenseType.Retail;

if (mode == "4")
try
{
//长期KMS
licenseType = LibGatherOsState.GatherOsState.LicenseType.GVLK;
RunCLI(tempfile + "gatherosstateltsc.exe", tempfile);
ConsoleLog("进入下一步(CUR:LTSC OLD)");
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\ProductOptions", true);
var packageFamilyName = registryKey.GetValue("OSProductPfn").ToString();
try
{
if (mode == "4")
{
//长期KMS
ticket = GetHttpWebRequest(StaticServerDomain + "/Tickets/KMS.xml");
}
else
{
ticket = GetHttpWebRequest(StaticServerDomain + "/Tickets/" + packageFamilyName + ".xml");
}
//System.Windows.MessageBox.Show(ticket);
}
catch (Exception e)
{
ConsoleLog("StaticServer:" + StaticServerDomain + " is not working.");
ConsoleLog("Error Message:" + e.Message);
}
}
else
catch (Exception e)
{
RunCLI(tempfile + "gatherosstate.exe", tempfile);
ConsoleLog("进入下一步(CUR:OLD)");
ConsoleLog("Get PackageFamilyName failed.");
ConsoleLog("Error Message:" + e.Message);
}

var result = LibGatherOsState.GatherOsState.GenActivateLicenseXML(licenseType);
File.WriteAllText(tempfile + "GenuineTicketvNext.xml", ticket, Encoding.UTF8);
ConsoleLog("进入下一步(CUR:VNEXT)");

if (result.state == LibGatherOsState.GatherOsState.ActivateLicenseXMLResultState.OK)
{
File.WriteAllText(tempfile + "GenuineTicketvNext.xml", result.xml, Encoding.UTF8);
ConsoleLog("进入下一步(CUR:VNEXT)");
}

var hasOldTicket = File.Exists(tempfile + "GenuineTicket.xml");
var hasvNextTicket = File.Exists(tempfile + "GenuineTicketvNext.xml");

if (hasOldTicket || hasvNextTicket)
if (hasvNextTicket)
{

actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = (string)this.Resources["RunAct_Getting_digital_license"]; // "Getting digital license";
Expand All @@ -1198,11 +1181,11 @@ private void RunAct()

RunCMD(@"sc start wuauserv");
RunCMD(@"sc start clipsvc");

RunCMD(@"clipup -v -o -altto " + tempfile);
RunCMD(@"clipup -v -o -altto " + tempfile.TrimEnd('\\')); // 旧版本系统的 ClipUp 路径不能带最后的反斜杠
if (OSVersionInfo.BuildVersion >= 20348)
{
if (OSVersionInfo.BuildVersion >= 20348)
{
RunCLI(tempfile + "ClipUp.exe", ".", "-v -o -altto " + tempfile); // 固定版本解决 22H2 后 ARM64 许可证接收问题
RunCLI(tempfile + "ClipUp.exe", ".", "-v -o -altto " + tempfile.TrimEnd('\\'));
}
Expand All @@ -1216,17 +1199,16 @@ private void RunAct()
int try_max_count = 30;
for (int i = 0; i < try_max_count + 1; i++)
{
if (hasOldTicket && !File.Exists(tempfile + "GenuineTicket.xml"))
if (!File.Exists(tempfile + "GenuineTicketvNext.xml"))
{
break;
}
if (hasvNextTicket && !File.Exists(tempfile + "GenuineTicketvNext.xml"))
Thread.Sleep(1000);
ConsoleLog($"应用许可证 重试 {i}/{try_max_count}");
}

runend = RunCScript(slmgr_self, "-ato").Trim();

ConsoleLog(runend);
if (runend.EndsWith("successfully.") || runend.Contains("0xC004F074") || runend.Contains("0xC004C003")) //0xC004F074 是 KMS38 长期激活会出的提示,Error 0xC004C003: The activation server determined that the specified product key is blocked. 是因为未连接激活服务器,下次连接时会自动激活。
{
Expand Down Expand Up @@ -1261,21 +1243,6 @@ private void RunAct()
}
//string runend = RunCScript(slmgr_self, "-upk").Trim();
EndLine:;
// 此处确保注册表清理一定进行
try
{
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = (string)this.Resources["RunAct_Cleaning_changes"]; // "Cleaning changes";
ShowBallSameDig();
}));

RunCMD(@"reg delete ""HKLM\SYSTEM\Tokens"" /f");
}
catch
{
ConsoleLog("Delete Reg Error");
}
if (code != "200")
{
actbtn.Dispatcher.Invoke(new Action(() =>
Expand Down Expand Up @@ -1510,7 +1477,7 @@ private void UpdateInputMatch()
try
{
if (actbtn != null)
{
{
string pattern = @"^[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}$";
if (is_auto == false)
{
Expand Down
4 changes: 2 additions & 2 deletions CMWTAT_DIGITAL/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.6.4.0")]
[assembly: AssemblyFileVersion("2.6.4.0")]
[assembly: AssemblyVersion("2.7.0.0")]
[assembly: AssemblyFileVersion("2.7.0.0")]
30 changes: 0 additions & 30 deletions CMWTAT_DIGITAL/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions CMWTAT_DIGITAL/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@
<data name="CMWTAT_ICON" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\CMWTAT.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gatherosstate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Res\gatherosstate.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="gatherosstateltsc" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Res\gatherosstateltsc.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="slc" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Res\slc.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="slmgr" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Res\slmgr.vbs;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand Down
Binary file removed CMWTAT_Digital_Release_2_6_4_0.zip
Binary file not shown.
Binary file not shown.
Binary file added CMWTAT_Digital_Release_2_7_0_0.zip
Binary file not shown.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
> Due to the closure of the Microsoft Digital License Issuance service, CMWTAT has temporarily disabled digital license activation. However, this does not affect the "Offline KMS" activation feature. There is no need to update CMWTAT; it should automatically switch to "Offline KMS" activation mode.
> 由于微软数字许可证下发服务关闭,CMWTAT 暂时关闭了数字许可证激活功能,但是这并不影响“离线 KMS”激活功能,无需更新 CMWTAT,它应该会自动切换到“离线 KMS”激活模式。
# Official Site 官方网站

[https://cmwtat.cloudmoe.com]
Expand Down

0 comments on commit fbb64b4

Please sign in to comment.