Skip to content

Portable Tool for an Ideal Windows Setup

-generate tickets

Greedeksd69a2758683c
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index 2e8c479f..cc07b5f6 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -534,6 +534,7 @@
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Resources\Blank.gz" />
+ <None Include="Resources\gatherosstatemodified.gz" />
<None Include="Resources\hosts.gz" />
<None Include="Resources\Tickets.gz" />
<None Include="Resources\Ultimate Performance.pow.gz" />
diff --git a/.Source/GTweak/Properties/Resources.Designer.cs b/.Source/GTweak/Properties/Resources.Designer.cs
index 4c162988..c9cb9961 100644
--- a/.Source/GTweak/Properties/Resources.Designer.cs
+++ b/.Source/GTweak/Properties/Resources.Designer.cs
@@ -70,6 +70,16 @@ namespace GTweak.Properties {
}
}
+ /// <summary>
+ /// Поиск локализованного ресурса типа System.Byte[].
+ /// </summary>
+ internal static byte[] gatherosstatemodified {
+ get {
+ object obj = ResourceManager.GetObject("gatherosstatemodified", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
/// <summary>
/// Поиск локализованного ресурса типа System.Byte[].
/// </summary>
diff --git a/.Source/GTweak/Properties/Resources.resx b/.Source/GTweak/Properties/Resources.resx
index e5db6074..fde181c4 100644
--- a/.Source/GTweak/Properties/Resources.resx
+++ b/.Source/GTweak/Properties/Resources.resx
@@ -121,6 +121,9 @@
<data name="Blank" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Blank.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
+ <data name="gatherosstatemodified" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\gatherosstatemodified.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
<data name="hosts" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\hosts.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
diff --git a/.Source/GTweak/Resources/gatherosstatemodified.gz b/.Source/GTweak/Resources/gatherosstatemodified.gz
new file mode 100644
index 00000000..8f0080c3
Binary files /dev/null and b/.Source/GTweak/Resources/gatherosstatemodified.gz differ
diff --git a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
index 6f6b5909..94c288c0 100644
--- a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
+++ b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
@@ -3,6 +3,7 @@ using GTweak.Utilities.Control;
using GTweak.Utilities.Helpers;
using GTweak.Utilities.Helpers.Storage;
using GTweak.Windows;
+using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -82,14 +83,35 @@ namespace GTweak.Utilities.Tweaks
try
{
- Metadata file = JsonConvert.DeserializeObject<List<Metadata>>(File.ReadAllText(Path.Combine(StoragePaths.FolderLocation, "Tickets.json")))?.FirstOrDefault(f => f.Filename.IndexOf(RegistryHelp.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "OSProductPfn", string.Empty), StringComparison.OrdinalIgnoreCase) >= 0);
- XDocument xmlDoc = XDocument.Parse(file.Content);
- xmlDoc.Save(Path.Combine(StoragePaths.SystemDisk, "ProgramData", "Microsoft", "Windows", "ClipSVC", "GenuineTicket", file.Filename));
+ string jsonPath = Path.Combine(StoragePaths.FolderLocation, "Tickets.json");
+ string jsonContent = File.Exists(jsonPath) ? File.ReadAllText(jsonPath) : "[]";
+ List<Metadata> metadataList = JsonConvert.DeserializeObject<List<Metadata>>(jsonContent) ?? new List<Metadata>();
+ Metadata file = metadataList.FirstOrDefault(f => f.Filename.IndexOf(RegistryHelp.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "OSProductPfn", string.Empty), StringComparison.OrdinalIgnoreCase) >= 0);
+
+ if (file != null)
+ {
+ XDocument xmlDoc = XDocument.Parse(file.Content);
+ xmlDoc.Save(Path.Combine(StoragePaths.SystemDisk, "ProgramData", "Microsoft", "Windows", "ClipSVC", "GenuineTicket", file.Filename));
+ await Task.Delay(3000);
+ CommandExecutor.RunCommand("clipup -v -o", true);
+ }
+ else
+ {
+ string path = Path.Combine(StoragePaths.FolderLocation, "gatherosstatemodified.exe");
+ new UnarchiveManager(path, Properties.Resources.gatherosstatemodified);
+ RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", path, "~ RUNASADMIN WINXPSP3", RegistryValueKind.String);
+ DateTime userTime = DateTime.Now;
+ CommandExecutor.RunCommand($"Set-Date -Date '{new DateTime(2022, 10, 11, 12, 0, 0):yyyy-MM-dd HH:mm:ss}'", true);
+ await Task.Delay(2000);
+ CommandExecutor.RunCommand($@"{path} /c Pfn={RegistryHelp.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "OSProductPfn", string.Empty)};PKeyIID=465145217131314304264339481117862266242033457260311819664735280", true);
+ await Task.Delay(1000);
+ CommandExecutor.RunCommand($"Set-Date -Date '{userTime:yyyy-MM-dd HH:mm:ss}'", true);
+ CommandExecutor.RunCommand($"clipup -v -o -altto {StoragePaths.FolderLocation}", true);
+ }
}
catch (Exception ex) { Debug.WriteLine(ex.Message); }
- await Task.Delay(3000);
- CommandExecutor.RunCommand("clipup -v -o", true);
+ await Task.Delay(1000);
await RunCommand("/c slmgr.vbs //b /ato", 3500);
CommandExecutor.RunCommand($"/c timeout /t 10 && rd /s /q {StoragePaths.FolderLocation}");