Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.26 KB | None | 0 0
  1.     public static string GetProductCode(LicenseProduct product, LicenseUtility.ProductCode type)
  2.     {
  3.       switch (type)
  4.       {
  5.         case LicenseUtility.ProductCode.MachineGuid:
  6.           string str1 = (string) null;
  7.           using (RegistryKey registryKey1 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, (RegistryView) 256))
  8.           {
  9.             using (RegistryKey registryKey2 = registryKey1.OpenSubKey("SOFTWARE\\Microsoft\\Cryptography", RegistryKeyPermissionCheck.ReadSubTree))
  10.             {
  11.               using (RegistryKey registryKey3 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, (RegistryView) 512))
  12.               {
  13.                 using (RegistryKey registryKey4 = registryKey3.OpenSubKey("SOFTWARE\\Microsoft\\Cryptography", RegistryKeyPermissionCheck.ReadSubTree))
  14.                 {
  15.                   if (registryKey4 != null)
  16.                   {
  17.                     str1 = registryKey4.GetValue("MachineGuid", (object) "default").ToString();
  18.                     registryKey4.Close();
  19.                   }
  20.                   if ((str1 == null || str1 == "default") && registryKey2 != null)
  21.                   {
  22.                     str1 = registryKey2.GetValue("MachineGuid", (object) "default").ToString();
  23.                     registryKey2.Close();
  24.                   }
  25.                   registryKey1?.Close();
  26.                   registryKey3?.Close();
  27.                 }
  28.               }
  29.             }
  30.           }
  31.           if (str1 != null && str1 != "default")
  32.             return LicenseUtility.GetProductCode(product, LicenseUtility.GetHash(str1));
  33.           throw new Exception("MachineGuid is empty");
  34.         case LicenseUtility.ProductCode.ProductId:
  35.           string str2 = (string) null;
  36.           using (RegistryKey registryKey1 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, (RegistryView) 256))
  37.           {
  38.             using (RegistryKey registryKey2 = registryKey1.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", RegistryKeyPermissionCheck.ReadSubTree))
  39.             {
  40.               using (RegistryKey registryKey3 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, (RegistryView) 512))
  41.               {
  42.                 using (RegistryKey registryKey4 = registryKey3.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", RegistryKeyPermissionCheck.ReadSubTree))
  43.                 {
  44.                   if (registryKey4 != null)
  45.                   {
  46.                     str2 = registryKey4.GetValue("MachineGuid", (object) "default").ToString();
  47.                     registryKey4.Close();
  48.                   }
  49.                   if ((str2 == null || str2 == "default") && registryKey2 != null)
  50.                   {
  51.                     str2 = registryKey2.GetValue("MachineGuid", (object) "default").ToString();
  52.                     registryKey2.Close();
  53.                   }
  54.                   registryKey1?.Close();
  55.                   registryKey3?.Close();
  56.                 }
  57.               }
  58.             }
  59.           }
  60.           if (str2 != null && str2 != "default")
  61.             return LicenseUtility.GetProductCode(product, LicenseUtility.GetHash(str2));
  62.           throw new Exception("ProductId is empty");
  63.         default:
  64.           return LicenseUtility.GetProductCode(product, FingerPrint.Value());
  65.       }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement