@@ -135,9 +135,6 @@ public void ExportTempFile()
135
135
ConsoleLog ( "开始写入缓存文件" ) ;
136
136
File . WriteAllBytes ( tempfile + "ClipUp" + ".exe" , Properties . Resources . ClipUp ) ;
137
137
File . WriteAllBytes ( tempfile + "slmgr" + ".vbs" , Properties . Resources . slmgr ) ;
138
- File . WriteAllBytes ( tempfile + "gatherosstate" + ".exe" , Properties . Resources . gatherosstate ) ;
139
- File . WriteAllBytes ( tempfile + "gatherosstateltsc" + ".exe" , Properties . Resources . gatherosstateltsc ) ;
140
- File . WriteAllBytes ( tempfile + "slc" + ".dll" , Properties . Resources . slc ) ;
141
138
ConsoleLog ( "写入缓存文件完毕" ) ;
142
139
}
143
140
@@ -367,7 +364,7 @@ public MainWindow()
367
364
DataContext = new ViewModel ( ) ;
368
365
369
366
this . DialogHostGrid . Visibility = Visibility . Visible ;
370
-
367
+
371
368
DialogWait . IsOpen = true ;
372
369
try
373
370
{
@@ -446,6 +443,7 @@ private void CheckUpdate()
446
443
}
447
444
}
448
445
446
+ public static string StaticServerDomain = "https://uwa-static.cloudmoe.com" ; // 静态服务器
449
447
public static string MainServerDomain = "https://cmwtat.cloudmoe.com" ; // 主要服务器
450
448
public static string BackupServerDomain = "https://kms.kumo.moe" ; // 备用服务器
451
449
@@ -464,14 +462,14 @@ private void LoadOSList()
464
462
string json ;
465
463
try
466
464
{
467
- json = GetHttpWebRequest ( MainServerDomain + "/api/digital?list=1&ver=3 " ) ; // 主要服务器
465
+ json = GetHttpWebRequest ( MainServerDomain + "/api/digital?list=1&ver=4 " ) ; // 主要服务器
468
466
}
469
467
catch ( Exception e )
470
468
{
471
469
ConsoleLog ( "MainServer:" + MainServerDomain + " is not working." ) ;
472
470
ConsoleLog ( "Error Message:" + e . Message ) ;
473
471
ConsoleLog ( "Ready to use BackupServer:" + BackupServerDomain ) ;
474
- json = GetHttpWebRequest ( BackupServerDomain + "/api/digital?list=1&ver=3 " ) ; // 备用服务器
472
+ json = GetHttpWebRequest ( BackupServerDomain + "/api/digital?list=1&ver=4 " ) ; // 备用服务器
475
473
}
476
474
JObject jsonobj = JObject . Parse ( json ) ;
477
475
List < Frequency > list = new List < Frequency > ( ) ;
@@ -661,12 +659,12 @@ private void installbtn_Click(object sender, RoutedEventArgs e)
661
659
Thread installthread = new Thread ( RunInstall ) ;
662
660
installthread . Start ( ) ;
663
661
}
664
-
662
+
665
663
private void upgradefullbtn_Click ( object sender , RoutedEventArgs e )
666
664
{
667
665
this . DialogUpgradeFullVersion . IsOpen = true ;
668
666
}
669
-
667
+
670
668
private void UpgradeFullVersionWindows_Click ( object sender , RoutedEventArgs e )
671
669
{
672
670
this . DialogUpgradeFullVersion . IsOpen = false ;
@@ -781,14 +779,14 @@ private void RunInstall()
781
779
string json ;
782
780
try
783
781
{
784
- json = GetHttpWebRequest ( MainServerDomain + "/api/digital?list=0&ver=3 " ) ; // 主要服务器
782
+ json = GetHttpWebRequest ( MainServerDomain + "/api/digital?list=0&ver=4 " ) ; // 主要服务器
785
783
}
786
784
catch ( Exception e )
787
785
{
788
786
ConsoleLog ( "MainServer:" + MainServerDomain + " is not working." ) ;
789
787
ConsoleLog ( "Error Message:" + e . Message ) ;
790
788
ConsoleLog ( "Ready to use BackupServer:" + BackupServerDomain ) ;
791
- json = GetHttpWebRequest ( BackupServerDomain + "/api/digital?list=0&ver=3 " ) ; // 备用服务器
789
+ json = GetHttpWebRequest ( BackupServerDomain + "/api/digital?list=0&ver=4 " ) ; // 备用服务器
792
790
}
793
791
JObject jsonobj = JObject . Parse ( json ) ;
794
792
List < Frequency > list = new List < Frequency > ( ) ;
@@ -946,7 +944,7 @@ private void RunAct()
946
944
string targetFile = slmgr_self ;
947
945
bool isrewrite = true ; // true=覆盖已存在的同名文件,false则反之
948
946
ConsoleLog ( "Copy Start: " + sourceFile + " To " + targetFile ) ;
949
- System . IO . File . Copy ( sourceFile , targetFile , isrewrite ) ;
947
+ File . Copy ( sourceFile , targetFile , isrewrite ) ;
950
948
ConsoleLog ( "Copy Completed." ) ;
951
949
}
952
950
catch ( Exception CopyExc )
@@ -955,7 +953,6 @@ private void RunAct()
955
953
}
956
954
957
955
//旧的位置
958
- //string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
959
956
960
957
string changepk = Environment . SystemDirectory + "\\ changepk.exe" ;
961
958
@@ -980,14 +977,14 @@ private void RunAct()
980
977
string json ;
981
978
try
982
979
{
983
- json = GetHttpWebRequest ( MainServerDomain + "/api/digital?list=0&ver=3 " ) ; // 主要服务器
980
+ json = GetHttpWebRequest ( MainServerDomain + "/api/digital?list=0&ver=4 " ) ; // 主要服务器
984
981
}
985
982
catch ( Exception e )
986
983
{
987
984
ConsoleLog ( "MainServer:" + MainServerDomain + " is not working." ) ;
988
985
ConsoleLog ( "Error Message:" + e . Message ) ;
989
986
ConsoleLog ( "Ready to use BackupServer:" + BackupServerDomain ) ;
990
- json = GetHttpWebRequest ( BackupServerDomain + "/api/digital?list=0&ver=3 " ) ; // 备用服务器
987
+ json = GetHttpWebRequest ( BackupServerDomain + "/api/digital?list=0&ver=4 " ) ; // 备用服务器
991
988
}
992
989
JObject jsonobj = JObject . Parse ( json ) ;
993
990
List < Frequency > list = new List < Frequency > ( ) ;
@@ -1117,28 +1114,6 @@ private void RunAct()
1117
1114
}
1118
1115
}
1119
1116
1120
- //写入旧系统特征(用于旧版保底方案)
1121
- actbtn . Dispatcher . Invoke ( new Action ( ( ) =>
1122
- {
1123
- this . activatingtext . Text = ( string ) this . Resources [ "RunAct_Writing_old_OS" ] ; // "Writing feature of old Windows version";
1124
- ShowBallSameDig ( ) ;
1125
- } ) ) ;
1126
-
1127
- if ( mode == "4" )
1128
- {
1129
- //长期KMS
1130
- ConsoleLog ( RunCScript ( slmgr_self , "-skms 1.1.45.14:1919" ) . Trim ( ) ) ; // いいよ、来いよ www
1131
- RunCMD ( @"reg add ""HKLM\SYSTEM\Tokens"" /v ""Channel"" /t REG_SZ /d ""Volume:GVLK"" /f" ) ; // 用于旧版保底方案
1132
- }
1133
- else
1134
- {
1135
- RunCMD ( @"reg add ""HKLM\SYSTEM\Tokens"" /v ""Channel"" /t REG_SZ /d ""Retail"" /f" ) ; // 用于旧版保底方案
1136
- }
1137
-
1138
- // 写入注册表模拟激活和产品信息(用于旧版保底方案)
1139
- RunCMD ( @"reg add ""HKLM\SYSTEM\Tokens\Kernel"" /v ""Kernel-ProductInfo"" /t REG_DWORD /d " + sku + " /f" ) ;
1140
- RunCMD ( @"reg add ""HKLM\SYSTEM\Tokens\Kernel"" /v ""Security-SPP-GenuineLocalStatus"" /t REG_DWORD /d 1 /f" ) ;
1141
-
1142
1117
actbtn . Dispatcher . Invoke ( new Action ( ( ) =>
1143
1118
{
1144
1119
this . activatingtext . Text = ( string ) this . Resources [ "RunAct_Installing_Key" ] ; //提示正在安装密钥
@@ -1159,37 +1134,45 @@ private void RunAct()
1159
1134
ShowBallSameDig ( ) ;
1160
1135
} ) ) ;
1161
1136
1162
- //LibGatherOsState.GatherOsState.SetLibHWIDPath(tempfile + "LibHWIDx86.dll", tempfile + "LibHWIDx64.dll") ;
1137
+ string ticket = null ;
1163
1138
1164
- var licenseType = LibGatherOsState . GatherOsState . LicenseType . Retail ;
1165
-
1166
- if ( mode == "4" )
1139
+ try
1167
1140
{
1168
- //长期KMS
1169
- licenseType = LibGatherOsState . GatherOsState . LicenseType . GVLK ;
1170
- RunCLI ( tempfile + "gatherosstateltsc.exe" , tempfile ) ;
1171
- ConsoleLog ( "进入下一步(CUR:LTSC OLD)" ) ;
1141
+ RegistryKey registryKey = Registry . LocalMachine . OpenSubKey ( "SYSTEM\\ CurrentControlSet\\ Control\\ ProductOptions" , true ) ;
1142
+ var packageFamilyName = registryKey . GetValue ( "OSProductPfn" ) . ToString ( ) ;
1143
+ try
1144
+ {
1145
+ if ( mode == "4" )
1146
+ {
1147
+ //长期KMS
1148
+ ticket = GetHttpWebRequest ( StaticServerDomain + "/Tickets/KMS.xml" ) ;
1149
+ }
1150
+ else
1151
+ {
1152
+ ticket = GetHttpWebRequest ( StaticServerDomain + "/Tickets/" + packageFamilyName + ".xml" ) ;
1153
+ }
1154
+ //System.Windows.MessageBox.Show(ticket);
1155
+ }
1156
+ catch ( Exception e )
1157
+ {
1158
+ ConsoleLog ( "StaticServer:" + StaticServerDomain + " is not working." ) ;
1159
+ ConsoleLog ( "Error Message:" + e . Message ) ;
1160
+ }
1172
1161
}
1173
- else
1162
+ catch ( Exception e )
1174
1163
{
1175
- RunCLI ( tempfile + "gatherosstate.exe" , tempfile ) ;
1176
- ConsoleLog ( "进入下一步(CUR:OLD)" ) ;
1164
+ ConsoleLog ( "Get PackageFamilyName failed." ) ;
1165
+ ConsoleLog ( "Error Message:" + e . Message ) ;
1177
1166
}
1178
1167
1179
- var result = LibGatherOsState . GatherOsState . GenActivateLicenseXML ( licenseType ) ;
1168
+ File . WriteAllText ( tempfile + "GenuineTicketvNext.xml" , ticket , Encoding . UTF8 ) ;
1169
+ ConsoleLog ( "进入下一步(CUR:VNEXT)" ) ;
1180
1170
1181
- if ( result . state == LibGatherOsState . GatherOsState . ActivateLicenseXMLResultState . OK )
1182
- {
1183
- File . WriteAllText ( tempfile + "GenuineTicketvNext.xml" , result . xml , Encoding . UTF8 ) ;
1184
- ConsoleLog ( "进入下一步(CUR:VNEXT)" ) ;
1185
- }
1186
-
1187
- var hasOldTicket = File . Exists ( tempfile + "GenuineTicket.xml" ) ;
1188
1171
var hasvNextTicket = File . Exists ( tempfile + "GenuineTicketvNext.xml" ) ;
1189
1172
1190
- if ( hasOldTicket || hasvNextTicket )
1173
+ if ( hasvNextTicket )
1191
1174
{
1192
-
1175
+
1193
1176
actbtn . Dispatcher . Invoke ( new Action ( ( ) =>
1194
1177
{
1195
1178
this . activatingtext . Text = ( string ) this . Resources [ "RunAct_Getting_digital_license" ] ; // "Getting digital license";
@@ -1198,11 +1181,11 @@ private void RunAct()
1198
1181
1199
1182
RunCMD ( @"sc start wuauserv" ) ;
1200
1183
RunCMD ( @"sc start clipsvc" ) ;
1201
-
1184
+
1202
1185
RunCMD ( @"clipup -v -o -altto " + tempfile ) ;
1203
1186
RunCMD ( @"clipup -v -o -altto " + tempfile . TrimEnd ( '\\ ' ) ) ; // 旧版本系统的 ClipUp 路径不能带最后的反斜杠
1204
- if ( OSVersionInfo . BuildVersion >= 20348 )
1205
- {
1187
+ if ( OSVersionInfo . BuildVersion >= 20348 )
1188
+ {
1206
1189
RunCLI ( tempfile + "ClipUp.exe" , "." , "-v -o -altto " + tempfile ) ; // 固定版本解决 22H2 后 ARM64 许可证接收问题
1207
1190
RunCLI ( tempfile + "ClipUp.exe" , "." , "-v -o -altto " + tempfile . TrimEnd ( '\\ ' ) ) ;
1208
1191
}
@@ -1216,17 +1199,16 @@ private void RunAct()
1216
1199
int try_max_count = 30 ;
1217
1200
for ( int i = 0 ; i < try_max_count + 1 ; i ++ )
1218
1201
{
1219
- if ( hasOldTicket && ! File . Exists ( tempfile + "GenuineTicket .xml" ) )
1202
+ if ( ! File . Exists ( tempfile + "GenuineTicketvNext .xml" ) )
1220
1203
{
1221
1204
break ;
1222
1205
}
1223
- if ( hasvNextTicket && ! File . Exists ( tempfile + "GenuineTicketvNext.xml" ) )
1224
1206
Thread . Sleep ( 1000 ) ;
1225
1207
ConsoleLog ( $ "应用许可证 重试 { i } /{ try_max_count } ") ;
1226
1208
}
1227
1209
1228
1210
runend = RunCScript ( slmgr_self , "-ato" ) . Trim ( ) ;
1229
-
1211
+
1230
1212
ConsoleLog ( runend ) ;
1231
1213
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. 是因为未连接激活服务器,下次连接时会自动激活。
1232
1214
{
@@ -1261,21 +1243,6 @@ private void RunAct()
1261
1243
}
1262
1244
//string runend = RunCScript(slmgr_self, "-upk").Trim();
1263
1245
EndLine : ;
1264
- // 此处确保注册表清理一定进行
1265
- try
1266
- {
1267
- actbtn . Dispatcher . Invoke ( new Action ( ( ) =>
1268
- {
1269
- this . activatingtext . Text = ( string ) this . Resources [ "RunAct_Cleaning_changes" ] ; // "Cleaning changes";
1270
- ShowBallSameDig ( ) ;
1271
- } ) ) ;
1272
-
1273
- RunCMD ( @"reg delete ""HKLM\SYSTEM\Tokens"" /f" ) ;
1274
- }
1275
- catch
1276
- {
1277
- ConsoleLog ( "Delete Reg Error" ) ;
1278
- }
1279
1246
if ( code != "200" )
1280
1247
{
1281
1248
actbtn . Dispatcher . Invoke ( new Action ( ( ) =>
@@ -1510,7 +1477,7 @@ private void UpdateInputMatch()
1510
1477
try
1511
1478
{
1512
1479
if ( actbtn != null )
1513
- {
1480
+ {
1514
1481
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}$" ;
1515
1482
if ( is_auto == false )
1516
1483
{
0 commit comments