Add source
This commit is contained in:
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Bunifu.Licensing.Properties;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000033 RID: 51
|
||||
[DebuggerStepThrough]
|
||||
internal sealed class Cryptography
|
||||
{
|
||||
// Token: 0x06000242 RID: 578 RVA: 0x00016B48 File Offset: 0x00014D48
|
||||
public static string Encrypt(string text)
|
||||
{
|
||||
string sha = Resources.SHA;
|
||||
bool flag = string.IsNullOrWhiteSpace(text);
|
||||
if (flag)
|
||||
{
|
||||
throw new ArgumentNullException("text");
|
||||
}
|
||||
RijndaelManaged rijndaelManaged = Cryptography.NewRijndaelManaged(sha);
|
||||
ICryptoTransform cryptoTransform = rijndaelManaged.CreateEncryptor(rijndaelManaged.Key, rijndaelManaged.IV);
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write))
|
||||
{
|
||||
using (StreamWriter streamWriter = new StreamWriter(cryptoStream))
|
||||
{
|
||||
streamWriter.Write(text);
|
||||
}
|
||||
}
|
||||
return Convert.ToBase64String(memoryStream.ToArray());
|
||||
}
|
||||
|
||||
// Token: 0x06000243 RID: 579 RVA: 0x00016BFC File Offset: 0x00014DFC
|
||||
public static string Encrypt2(string text)
|
||||
{
|
||||
string sha = Resources.SHA2;
|
||||
bool flag = string.IsNullOrWhiteSpace(text);
|
||||
if (flag)
|
||||
{
|
||||
throw new ArgumentNullException("text");
|
||||
}
|
||||
RijndaelManaged rijndaelManaged = Cryptography.NewRijndaelManaged(sha);
|
||||
ICryptoTransform cryptoTransform = rijndaelManaged.CreateEncryptor(rijndaelManaged.Key, rijndaelManaged.IV);
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write))
|
||||
{
|
||||
using (StreamWriter streamWriter = new StreamWriter(cryptoStream))
|
||||
{
|
||||
streamWriter.Write(text);
|
||||
}
|
||||
}
|
||||
return Convert.ToBase64String(memoryStream.ToArray());
|
||||
}
|
||||
|
||||
// Token: 0x06000244 RID: 580 RVA: 0x00016CB0 File Offset: 0x00014EB0
|
||||
public static string Decrypt(string cipherText)
|
||||
{
|
||||
string sha = Resources.SHA;
|
||||
bool flag = string.IsNullOrEmpty(cipherText);
|
||||
if (flag)
|
||||
{
|
||||
throw new ArgumentNullException("cipherText");
|
||||
}
|
||||
bool flag2 = !Cryptography.IsBase64String(cipherText);
|
||||
if (flag2)
|
||||
{
|
||||
throw new Exception("The cipherText input parameter is not base64 encoded");
|
||||
}
|
||||
RijndaelManaged rijndaelManaged = Cryptography.NewRijndaelManaged(sha);
|
||||
ICryptoTransform cryptoTransform = rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV);
|
||||
byte[] array = Convert.FromBase64String(cipherText);
|
||||
string text;
|
||||
using (MemoryStream memoryStream = new MemoryStream(array))
|
||||
{
|
||||
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read))
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(cryptoStream))
|
||||
{
|
||||
text = streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000245 RID: 581 RVA: 0x00016DA0 File Offset: 0x00014FA0
|
||||
public static string Decrypt2(string cipherText)
|
||||
{
|
||||
string sha = Resources.SHA2;
|
||||
bool flag = string.IsNullOrEmpty(cipherText);
|
||||
if (flag)
|
||||
{
|
||||
throw new ArgumentNullException("cipherText");
|
||||
}
|
||||
bool flag2 = !Cryptography.IsBase64String(cipherText);
|
||||
if (flag2)
|
||||
{
|
||||
throw new Exception("The cipherText input parameter is not base64 encoded");
|
||||
}
|
||||
RijndaelManaged rijndaelManaged = Cryptography.NewRijndaelManaged(sha);
|
||||
ICryptoTransform cryptoTransform = rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV);
|
||||
byte[] array = Convert.FromBase64String(cipherText);
|
||||
string text;
|
||||
using (MemoryStream memoryStream = new MemoryStream(array))
|
||||
{
|
||||
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read))
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(cryptoStream))
|
||||
{
|
||||
text = streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000246 RID: 582 RVA: 0x00016E90 File Offset: 0x00015090
|
||||
public static string Base64Encode(string plainText)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(plainText);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
// Token: 0x06000247 RID: 583 RVA: 0x00016EB4 File Offset: 0x000150B4
|
||||
public static string Base64Decode(string base64EncodedData)
|
||||
{
|
||||
byte[] array = Convert.FromBase64String(base64EncodedData);
|
||||
return Encoding.UTF8.GetString(array);
|
||||
}
|
||||
|
||||
// Token: 0x06000248 RID: 584 RVA: 0x00016ED8 File Offset: 0x000150D8
|
||||
public static bool IsBase64String(string base64String)
|
||||
{
|
||||
base64String = base64String.Trim();
|
||||
return base64String.Length % 4 == 0 && Regex.IsMatch(base64String, "^[a-zA-Z0-9\\+/]*={0,3}$", RegexOptions.None);
|
||||
}
|
||||
|
||||
// Token: 0x06000249 RID: 585 RVA: 0x00016F0C File Offset: 0x0001510C
|
||||
public static string ComputeMD5(string rawData)
|
||||
{
|
||||
bool flag = rawData == null || rawData.Length == 0;
|
||||
string text;
|
||||
if (flag)
|
||||
{
|
||||
text = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
MD5 md = new MD5CryptoServiceProvider();
|
||||
byte[] bytes = Encoding.Default.GetBytes(rawData);
|
||||
byte[] array = md.ComputeHash(bytes);
|
||||
text = BitConverter.ToString(array).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x0600024A RID: 586 RVA: 0x00016F74 File Offset: 0x00015174
|
||||
public static string ComputeSHA1(string rawData)
|
||||
{
|
||||
string text;
|
||||
using (SHA1Managed sha1Managed = new SHA1Managed())
|
||||
{
|
||||
byte[] array = sha1Managed.ComputeHash(Encoding.UTF8.GetBytes(rawData));
|
||||
StringBuilder stringBuilder = new StringBuilder(array.Length * 2);
|
||||
foreach (byte b in array)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("x2"));
|
||||
}
|
||||
text = stringBuilder.ToString();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x0600024B RID: 587 RVA: 0x00017000 File Offset: 0x00015200
|
||||
public static string ComputeSHA256(string rawData)
|
||||
{
|
||||
string text;
|
||||
using (SHA256 sha = SHA256.Create())
|
||||
{
|
||||
byte[] array = sha.ComputeHash(Encoding.UTF8.GetBytes(rawData));
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
stringBuilder.Append(array[i].ToString("x2"));
|
||||
}
|
||||
text = stringBuilder.ToString();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x0600024C RID: 588 RVA: 0x00017084 File Offset: 0x00015284
|
||||
private static RijndaelManaged NewRijndaelManaged(string salt)
|
||||
{
|
||||
bool flag = salt == null;
|
||||
if (flag)
|
||||
{
|
||||
throw new ArgumentNullException("salt");
|
||||
}
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(salt);
|
||||
Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(Resources.SHA, bytes);
|
||||
RijndaelManaged rijndaelManaged = new RijndaelManaged();
|
||||
rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8);
|
||||
rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(rijndaelManaged.BlockSize / 8);
|
||||
return rijndaelManaged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Management;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000034 RID: 52
|
||||
[DebuggerStepThrough]
|
||||
internal sealed class Hardware
|
||||
{
|
||||
// Token: 0x0600024E RID: 590 RVA: 0x00017100 File Offset: 0x00015300
|
||||
public static string GetUniqueID()
|
||||
{
|
||||
return Hardware.Value();
|
||||
}
|
||||
|
||||
// Token: 0x0600024F RID: 591 RVA: 0x00017118 File Offset: 0x00015318
|
||||
public static string GetOSSerial()
|
||||
{
|
||||
ManagementObject managementObject = new ManagementObject("Win32_OperatingSystem=@");
|
||||
return (string)managementObject["SerialNumber"];
|
||||
}
|
||||
|
||||
// Token: 0x06000250 RID: 592 RVA: 0x00017148 File Offset: 0x00015348
|
||||
public static string GetOSName()
|
||||
{
|
||||
string text = string.Empty;
|
||||
try
|
||||
{
|
||||
ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
|
||||
using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = managementObjectSearcher.Get().GetEnumerator())
|
||||
{
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
ManagementObject managementObject = (ManagementObject)enumerator.Current;
|
||||
text = managementObject["Caption"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000251 RID: 593 RVA: 0x000171D8 File Offset: 0x000153D8
|
||||
public override string ToString()
|
||||
{
|
||||
return Hardware.Value();
|
||||
}
|
||||
|
||||
// Token: 0x06000252 RID: 594 RVA: 0x000171F0 File Offset: 0x000153F0
|
||||
private static string Value()
|
||||
{
|
||||
bool flag = string.IsNullOrEmpty(Hardware._fingerPrint);
|
||||
if (flag)
|
||||
{
|
||||
Hardware._fingerPrint = Hardware.GetHash(string.Concat(new string[]
|
||||
{
|
||||
"CPU >> ",
|
||||
Hardware.CpuId(),
|
||||
"\nBIOS >> ",
|
||||
Hardware.BiosId(),
|
||||
"\nBASE >> ",
|
||||
Hardware.BaseId(),
|
||||
"\nVIDEO >> ",
|
||||
Hardware.VideoId()
|
||||
}));
|
||||
}
|
||||
return Hardware._fingerPrint;
|
||||
}
|
||||
|
||||
// Token: 0x06000253 RID: 595 RVA: 0x0001726C File Offset: 0x0001546C
|
||||
private static string GetHash(string s)
|
||||
{
|
||||
MD5 md = new MD5CryptoServiceProvider();
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(s);
|
||||
return Hardware.GetHexString(md.ComputeHash(bytes));
|
||||
}
|
||||
|
||||
// Token: 0x06000254 RID: 596 RVA: 0x0001729C File Offset: 0x0001549C
|
||||
private static string GetHexString(IList<byte> bt)
|
||||
{
|
||||
string text = string.Empty;
|
||||
for (int i = 0; i < bt.Count; i++)
|
||||
{
|
||||
byte b = bt[i];
|
||||
int num = (int)b;
|
||||
int num2 = num & 15;
|
||||
int num3 = (num >> 4) & 15;
|
||||
bool flag = num3 > 9;
|
||||
if (flag)
|
||||
{
|
||||
text += ((char)(num3 - 10 + 65)).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
text += num3.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
bool flag2 = num2 > 9;
|
||||
if (flag2)
|
||||
{
|
||||
text += ((char)(num2 - 10 + 65)).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
text += num2.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
bool flag3 = i + 1 != bt.Count && (i + 1) % 2 == 0;
|
||||
if (flag3)
|
||||
{
|
||||
text += "-";
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000255 RID: 597 RVA: 0x00017394 File Offset: 0x00015594
|
||||
private static string Identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)
|
||||
{
|
||||
string text = "";
|
||||
ManagementClass managementClass = new ManagementClass(wmiClass);
|
||||
ManagementObjectCollection instances = managementClass.GetInstances();
|
||||
foreach (ManagementBaseObject managementBaseObject in instances)
|
||||
{
|
||||
bool flag = managementBaseObject[wmiMustBeTrue].ToString() != "True";
|
||||
if (!flag)
|
||||
{
|
||||
bool flag2 = text != "";
|
||||
if (!flag2)
|
||||
{
|
||||
try
|
||||
{
|
||||
text = managementBaseObject[wmiProperty].ToString();
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000256 RID: 598 RVA: 0x0001744C File Offset: 0x0001564C
|
||||
private static string Identifier(string wmiClass, string wmiProperty)
|
||||
{
|
||||
string text = "";
|
||||
ManagementClass managementClass = new ManagementClass(wmiClass);
|
||||
ManagementObjectCollection instances = managementClass.GetInstances();
|
||||
foreach (ManagementBaseObject managementBaseObject in instances)
|
||||
{
|
||||
bool flag = text != "";
|
||||
if (!flag)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool flag2 = managementBaseObject[wmiProperty] != null;
|
||||
if (flag2)
|
||||
{
|
||||
text = managementBaseObject[wmiProperty].ToString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000257 RID: 599 RVA: 0x000174F8 File Offset: 0x000156F8
|
||||
private static string CpuId()
|
||||
{
|
||||
string text = Hardware.Identifier("Win32_Processor", "UniqueId");
|
||||
bool flag = text != "";
|
||||
string text2;
|
||||
if (flag)
|
||||
{
|
||||
text2 = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Hardware.Identifier("Win32_Processor", "ProcessorId");
|
||||
bool flag2 = text != "";
|
||||
if (flag2)
|
||||
{
|
||||
text2 = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Hardware.Identifier("Win32_Processor", "Name");
|
||||
bool flag3 = text == "";
|
||||
if (flag3)
|
||||
{
|
||||
text = Hardware.Identifier("Win32_Processor", "Manufacturer");
|
||||
}
|
||||
text += Hardware.Identifier("Win32_Processor", "MaxClockSpeed");
|
||||
text2 = text;
|
||||
}
|
||||
}
|
||||
return text2;
|
||||
}
|
||||
|
||||
// Token: 0x06000258 RID: 600 RVA: 0x00017598 File Offset: 0x00015798
|
||||
private static string BiosId()
|
||||
{
|
||||
return string.Concat(new string[]
|
||||
{
|
||||
Hardware.Identifier("Win32_BIOS", "Manufacturer"),
|
||||
Hardware.Identifier("Win32_BIOS", "SMBIOSBIOSVersion"),
|
||||
Hardware.Identifier("Win32_BIOS", "IdentificationCode"),
|
||||
Hardware.Identifier("Win32_BIOS", "SerialNumber"),
|
||||
Hardware.Identifier("Win32_BIOS", "ReleaseDate"),
|
||||
Hardware.Identifier("Win32_BIOS", "Version")
|
||||
});
|
||||
}
|
||||
|
||||
// Token: 0x06000259 RID: 601 RVA: 0x00017624 File Offset: 0x00015824
|
||||
private static string DiskId()
|
||||
{
|
||||
return Hardware.Identifier("Win32_DiskDrive", "Model") + Hardware.Identifier("Win32_DiskDrive", "Manufacturer") + Hardware.Identifier("Win32_DiskDrive", "Signature") + Hardware.Identifier("Win32_DiskDrive", "TotalHeads");
|
||||
}
|
||||
|
||||
// Token: 0x0600025A RID: 602 RVA: 0x00017678 File Offset: 0x00015878
|
||||
private static string BaseId()
|
||||
{
|
||||
return Hardware.Identifier("Win32_BaseBoard", "Model") + Hardware.Identifier("Win32_BaseBoard", "Manufacturer") + Hardware.Identifier("Win32_BaseBoard", "Name") + Hardware.Identifier("Win32_BaseBoard", "SerialNumber");
|
||||
}
|
||||
|
||||
// Token: 0x0600025B RID: 603 RVA: 0x000176CC File Offset: 0x000158CC
|
||||
private static string VideoId()
|
||||
{
|
||||
return Hardware.Identifier("Win32_VideoController", "DriverVersion") + Hardware.Identifier("Win32_VideoController", "Name");
|
||||
}
|
||||
|
||||
// Token: 0x0600025C RID: 604 RVA: 0x00017704 File Offset: 0x00015904
|
||||
private static string MacId()
|
||||
{
|
||||
return Hardware.Identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");
|
||||
}
|
||||
|
||||
// Token: 0x04000187 RID: 391
|
||||
private static string _fingerPrint = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000035 RID: 53
|
||||
[DebuggerStepThrough]
|
||||
internal sealed class InternetTime
|
||||
{
|
||||
// Token: 0x0600025F RID: 607 RVA: 0x00017740 File Offset: 0x00015940
|
||||
public static DateTime GetDateTime()
|
||||
{
|
||||
DateTime dateTime;
|
||||
try
|
||||
{
|
||||
using (WebResponse response = WebRequest.Create("http://www.google.com").GetResponse())
|
||||
{
|
||||
dateTime = DateTime.ParseExact(response.Headers["date"], "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal);
|
||||
}
|
||||
}
|
||||
catch (WebException)
|
||||
{
|
||||
dateTime = DateTime.Now;
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#if NET5_0_OR_NETFRAMEWORK
|
||||
using System.Runtime.CompilerServices;
|
||||
#endif
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Bunifu.Licensing.Options;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000036 RID: 54
|
||||
[DebuggerStepThrough]
|
||||
internal static class Logger
|
||||
{
|
||||
// Token: 0x06000261 RID: 609 RVA: 0x000177C8 File Offset: 0x000159C8
|
||||
public static bool Add(string message)
|
||||
{
|
||||
bool flag2;
|
||||
try
|
||||
{
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(8, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(LicenseValidator.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\Log.txt");
|
||||
string text = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
Registry.Licensing.CreateDirectoryIfNoneExists(LicenseValidator.Product.ToString());
|
||||
bool flag = !File.Exists(text);
|
||||
if (flag)
|
||||
{
|
||||
File.WriteAllText(text, string.Empty);
|
||||
}
|
||||
using (StreamWriter streamWriter = File.AppendText(text))
|
||||
{
|
||||
streamWriter.WriteLine("[" + DateTime.Now.ToString("dd/MM/yy hh:mm:ss") + "] " + message);
|
||||
}
|
||||
flag2 = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
// Token: 0x06000262 RID: 610 RVA: 0x000178B0 File Offset: 0x00015AB0
|
||||
public static bool Clear()
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(8, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(LicenseValidator.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\Log.txt");
|
||||
string text = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
Registry.Licensing.CreateDirectoryIfNoneExists(LicenseValidator.Product.ToString());
|
||||
File.WriteAllText(text, string.Empty);
|
||||
flag = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000037 RID: 55
|
||||
[DebuggerStepThrough]
|
||||
internal sealed class Network
|
||||
{
|
||||
// Token: 0x06000263 RID: 611
|
||||
[DllImport("wininet.dll")]
|
||||
private static extern bool InternetGetConnectedState(out int Description, int ReservedValue);
|
||||
|
||||
// Token: 0x06000264 RID: 612 RVA: 0x00017938 File Offset: 0x00015B38
|
||||
public static bool IsAvailable()
|
||||
{
|
||||
int num;
|
||||
return Network.InternetGetConnectedState(out num, 0);
|
||||
}
|
||||
|
||||
// Token: 0x06000265 RID: 613 RVA: 0x00017954 File Offset: 0x00015B54
|
||||
public static bool IsAvailable(long minimumSpeed)
|
||||
{
|
||||
bool flag = !NetworkInterface.GetIsNetworkAvailable();
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
bool flag3 = networkInterface.OperationalStatus != OperationalStatus.Up || networkInterface.NetworkInterfaceType == NetworkInterfaceType.Loopback || networkInterface.NetworkInterfaceType == NetworkInterfaceType.Tunnel;
|
||||
if (!flag3)
|
||||
{
|
||||
bool flag4 = networkInterface.Speed < minimumSpeed;
|
||||
if (!flag4)
|
||||
{
|
||||
bool flag5 = networkInterface.Description.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0 || networkInterface.Name.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
if (!flag5)
|
||||
{
|
||||
bool flag6 = networkInterface.Description.Equals("Microsoft Loopback Adapter", StringComparison.OrdinalIgnoreCase);
|
||||
if (!flag6)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,581 @@
|
||||
#if NET5_0_OR_NETFRAMEWORK
|
||||
using System.Runtime.CompilerServices;
|
||||
#endif
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Bunifu.Licensing.Models;
|
||||
using Bunifu.Licensing.Options;
|
||||
using Bunifu.Licensing.Properties;
|
||||
using Bunifu.Licensing.Views;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000038 RID: 56
|
||||
[DebuggerStepThrough]
|
||||
internal sealed class Registry
|
||||
{
|
||||
// Token: 0x04000188 RID: 392
|
||||
private static int _UIUpgradeCalls = 0;
|
||||
|
||||
// Token: 0x04000189 RID: 393
|
||||
private static int _DBUpgradeCalls = 0;
|
||||
|
||||
// Token: 0x0400018A RID: 394
|
||||
private static int _DAUpgradeCalls = 0;
|
||||
|
||||
// Token: 0x0400018B RID: 395
|
||||
private static string RegistryPath = "Software\\";
|
||||
|
||||
// Token: 0x0400018C RID: 396
|
||||
public static string FolderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Bunifu Technologies\\";
|
||||
|
||||
// Token: 0x0200004B RID: 75
|
||||
public static class Base
|
||||
{
|
||||
// Token: 0x06000289 RID: 649 RVA: 0x00018184 File Offset: 0x00016384
|
||||
public static void SaveValue(string company, string product, string key, object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = Registry.RegistryPath;
|
||||
bool flag = !string.IsNullOrEmpty(company);
|
||||
if (flag)
|
||||
{
|
||||
text = text + company + "\\";
|
||||
}
|
||||
text += product;
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(text);
|
||||
registryKey.SetValue(key, value.ToString());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600028A RID: 650 RVA: 0x000181F0 File Offset: 0x000163F0
|
||||
public static string GetValue(string company, string product, string key)
|
||||
{
|
||||
string text2;
|
||||
try
|
||||
{
|
||||
string text = Registry.RegistryPath;
|
||||
bool flag = !string.IsNullOrEmpty(company);
|
||||
if (flag)
|
||||
{
|
||||
text = text + company + "\\";
|
||||
}
|
||||
text += product;
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(text);
|
||||
bool flag2 = registryKey != null;
|
||||
if (flag2)
|
||||
{
|
||||
text2 = registryKey.GetValue(key).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
text2 = "";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
text2 = "";
|
||||
}
|
||||
return text2;
|
||||
}
|
||||
|
||||
// Token: 0x0600028B RID: 651 RVA: 0x00018274 File Offset: 0x00016474
|
||||
public static bool DeleteValue(string company, string product, string key)
|
||||
{
|
||||
bool flag3;
|
||||
try
|
||||
{
|
||||
string text = Registry.RegistryPath;
|
||||
bool flag = !string.IsNullOrEmpty(company);
|
||||
if (flag)
|
||||
{
|
||||
text = text + company + "\\";
|
||||
}
|
||||
text += product;
|
||||
using (RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(text, true))
|
||||
{
|
||||
bool flag2 = registryKey != null;
|
||||
if (flag2)
|
||||
{
|
||||
registryKey.DeleteValue(key);
|
||||
}
|
||||
}
|
||||
flag3 = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag3 = false;
|
||||
}
|
||||
return flag3;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0200004C RID: 76
|
||||
public static class Options
|
||||
{
|
||||
// Token: 0x0600028C RID: 652 RVA: 0x00018308 File Offset: 0x00016508
|
||||
public static bool SaveLastNotificationTime(ProductTypes product, DateTime notificationTime)
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
Registry.Base.SaveValue(Resources.CPA, product.ToString(), "LNT", Registry.Options.Base64Encode(notificationTime.ToString()));
|
||||
flag = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x0600028D RID: 653 RVA: 0x0001835C File Offset: 0x0001655C
|
||||
public static DateTime GetLastNotificationTime(ProductTypes product)
|
||||
{
|
||||
DateTime dateTime;
|
||||
try
|
||||
{
|
||||
string text = Registry.Base.GetValue(Resources.CPA, product.ToString(), "LNT");
|
||||
text = Registry.Options.Base64Decode(text);
|
||||
dateTime = Convert.ToDateTime(text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
dateTime = DateTime.Now.AddDays(-1.0);
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
// Token: 0x0600028E RID: 654 RVA: 0x000183C4 File Offset: 0x000165C4
|
||||
private static string Base64Encode(string plainText)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(plainText);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
// Token: 0x0600028F RID: 655 RVA: 0x000183E8 File Offset: 0x000165E8
|
||||
private static string Base64Decode(string base64EncodedData)
|
||||
{
|
||||
byte[] array = Convert.FromBase64String(base64EncodedData);
|
||||
return Encoding.UTF8.GetString(array);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0200004D RID: 77
|
||||
public static class Licensing
|
||||
{
|
||||
// Token: 0x06000290 RID: 656 RVA: 0x0001840C File Offset: 0x0001660C
|
||||
public static Record GetLicense(ProductTypes product)
|
||||
{
|
||||
Record record2;
|
||||
try
|
||||
{
|
||||
Logger.Add("Validating any installed licenses...");
|
||||
string text = Registry.Base.GetValue(Resources.CPA, product.ToString(), "CLI");
|
||||
text = Cryptography.Decrypt(text);
|
||||
Logger.Add("Valid product license found.");
|
||||
Logger.Add("License validated successfully.");
|
||||
bool flag = false;
|
||||
bool flag2 = false;
|
||||
Record record = new Record();
|
||||
string text2 = string.Empty;
|
||||
bool flag3 = flag;
|
||||
if (flag3)
|
||||
{
|
||||
Logger.Add("Checking license version...");
|
||||
try
|
||||
{
|
||||
JObject jobject = JObject.Parse(text);
|
||||
bool flag4 = jobject["HardwareID"] != null;
|
||||
if (flag4)
|
||||
{
|
||||
text2 = jobject["HardwareID"].ToString();
|
||||
}
|
||||
bool flag5 = text2 != null || !string.IsNullOrEmpty(text2);
|
||||
if (flag5)
|
||||
{
|
||||
Logger.Add("License verified as v1. Requesting for upgrade...");
|
||||
bool flag6 = product == ProductTypes.UIWinForms && Registry._UIUpgradeCalls == 0;
|
||||
if (flag6)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag7 = product == ProductTypes.DatavizBasicWinForms && Registry._DBUpgradeCalls == 0;
|
||||
if (flag7)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag8 = product == ProductTypes.DatavizAdvancedWinForms && Registry._DAUpgradeCalls == 0;
|
||||
if (flag8)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool flag9 = flag2;
|
||||
if (flag9)
|
||||
{
|
||||
bool flag10 = LicenseValidator.GetHardwareID() == text2;
|
||||
if (flag10)
|
||||
{
|
||||
v1License v1License = JsonConvert.DeserializeObject<v1License>(text);
|
||||
v1License._licenseKey = JObject.Parse(text).SelectToken("LicenseKey").ToString();
|
||||
bool flag11 = InformationBoxHelper.Show("We recently updated our client licensing and are about to upgrade your old license to the newly updated license format in this device.", "New Licensing Upgrade", "", InformationBox.InformationBoxIcons.Information, "Upgrade", "");
|
||||
Logger.Add("Upgrade started...");
|
||||
bool flag12 = product == ProductTypes.UIWinForms;
|
||||
if (flag12)
|
||||
{
|
||||
Registry._UIUpgradeCalls++;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag13 = product == ProductTypes.DatavizBasicWinForms;
|
||||
if (flag13)
|
||||
{
|
||||
Registry._DBUpgradeCalls++;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag14 = product == ProductTypes.DatavizAdvancedWinForms;
|
||||
if (flag14)
|
||||
{
|
||||
Registry._DAUpgradeCalls++;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool flag15 = flag11;
|
||||
if (flag15)
|
||||
{
|
||||
Logger.Add("License v2 activation upgrade starting...");
|
||||
ActivationResults activationResults = LicenseValidator.Activate(v1License.Email, v1License._licenseKey);
|
||||
bool flag16 = activationResults == ActivationResults.Success;
|
||||
if (flag16)
|
||||
{
|
||||
Logger.Add("License successfully upgraded to v2.");
|
||||
record = LicenseValidator.RetrievedLicense;
|
||||
try
|
||||
{
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(24, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License Information.txt");
|
||||
string text3 = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(12, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(record.License.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License.lic");
|
||||
string text4 = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
Registry.Licensing.CreateDirectoryIfNoneExists(product.ToString());
|
||||
Registry.Licensing.UpdateLicenseFile(text3, text4, record);
|
||||
InformationBoxHelper.Show("Your license has been successfully upgraded.Happy coding!", "License Upgrade Successful", "", InformationBox.InformationBoxIcons.Information, "Okay", "");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Add("License upgraded failed.");
|
||||
record = new Record
|
||||
{
|
||||
IsValid = false
|
||||
};
|
||||
bool flag17 = InformationBoxHelper.Show(LicenseValidator.ResponseError, "Upgrade Failed", "", InformationBox.InformationBoxIcons.Warning, "Okay", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Add("License verified as v2.");
|
||||
Logger.Add("License validation passed.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Add("Exception L1: " + ex.Message);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
record = JsonConvert.DeserializeObject<Record>(text);
|
||||
record._licenseKey = JObject.Parse(text).SelectToken("LicenseKey").ToString();
|
||||
try
|
||||
{
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(24, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License Information.txt");
|
||||
string text5 = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(12, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(record.License.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License.lic");
|
||||
string text6 = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
Registry.Licensing.CreateDirectoryIfNoneExists(product.ToString());
|
||||
Registry.Licensing.UpdateLicenseFile(text5, text6, record);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
Logger.Add("Exception L2: " + ex2.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex3)
|
||||
{
|
||||
Logger.Add("Exception L3: " + ex3.Message);
|
||||
Registry.Licensing.DeleteLicense(product, false);
|
||||
record = new Record
|
||||
{
|
||||
IsValid = false
|
||||
};
|
||||
}
|
||||
record2 = record;
|
||||
}
|
||||
catch (Exception ex4)
|
||||
{
|
||||
Logger.Add("Exception L4: " + ex4.Message);
|
||||
Registry.Licensing.DeleteLicense(product, false);
|
||||
record2 = Registry.Licensing.GetBackupLicense(product);
|
||||
}
|
||||
return record2;
|
||||
}
|
||||
|
||||
// Token: 0x06000291 RID: 657 RVA: 0x0001892C File Offset: 0x00016B2C
|
||||
public static void SaveLicense(Record license)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool isValid = license.IsValid;
|
||||
if (isValid)
|
||||
{
|
||||
Registry.Base.SaveValue(Resources.CPA, license.License.Product.ToString(), "CLI", Cryptography.Encrypt(JsonConvert.SerializeObject(license)));
|
||||
try
|
||||
{
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(24, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(license.License.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License Information.txt");
|
||||
string text = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(12, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(license.License.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License.lic");
|
||||
string text2 = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
Registry.Licensing.CreateDirectoryIfNoneExists(license.License.Product.ToString());
|
||||
Registry.Licensing.UpdateLicenseFile(text, text2, license);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000292 RID: 658 RVA: 0x00018A54 File Offset: 0x00016C54
|
||||
public static bool DeleteLicense(ProductTypes product, bool deleteLicenseInfoFile)
|
||||
{
|
||||
if (deleteLicenseInfoFile)
|
||||
{
|
||||
Registry.Licensing.DeleteDirectoryIfExists(product.ToString());
|
||||
}
|
||||
return Registry.Base.DeleteValue(Resources.CPA, product.ToString(), "CLI");
|
||||
}
|
||||
|
||||
// Token: 0x06000293 RID: 659 RVA: 0x00018A9C File Offset: 0x00016C9C
|
||||
public static void CreateDirectoryIfNoneExists(string product)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = Registry.FolderPath + product + "\\";
|
||||
bool flag = !Directory.Exists(text);
|
||||
if (flag)
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000294 RID: 660 RVA: 0x00018AE8 File Offset: 0x00016CE8
|
||||
private static void DeleteDirectoryIfExists(string product)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = Registry.FolderPath + product + "\\";
|
||||
bool flag = Directory.Exists(text);
|
||||
if (flag)
|
||||
{
|
||||
Directory.Delete(text, true);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000295 RID: 661 RVA: 0x00018B34 File Offset: 0x00016D34
|
||||
private static void UpdateLicenseFile(string licenseFile, string backupLicense, Record license)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = license.License.TotalDays.ToString();
|
||||
string text2 = license.License.RemainingDays.ToString();
|
||||
string text3 = license.License.ExpiryDate.ToString("dddd, MMMM dd, yyyy");
|
||||
bool flag = license.License.Type == LicenseTypes.Enterprise;
|
||||
if (flag)
|
||||
{
|
||||
text = "Unlimited";
|
||||
text2 = "Unlimited";
|
||||
text3 = "Perpetual";
|
||||
}
|
||||
File.WriteAllText(backupLicense, Cryptography.Encrypt(JsonConvert.SerializeObject(license)));
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(84, 7);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Product: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(license.License.Product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\n");
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Email: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted(license.Client.Email);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\n");
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Status: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted<StatusOptions>(license.License.Status);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\n");
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Activations: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted<int>(license.License.MaxDevices);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\n");
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Total Days: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted(text);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\n");
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Remaining Days: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted(text2);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\n");
|
||||
defaultInterpolatedStringHandler.AppendLiteral("Expiry Date: ");
|
||||
defaultInterpolatedStringHandler.AppendFormatted(text3);
|
||||
File.WriteAllText(licenseFile, defaultInterpolatedStringHandler.ToStringAndClear());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000296 RID: 662 RVA: 0x00018D0C File Offset: 0x00016F0C
|
||||
private static Record GetBackupLicense(ProductTypes product)
|
||||
{
|
||||
Record record2;
|
||||
try
|
||||
{
|
||||
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(12, 2);
|
||||
defaultInterpolatedStringHandler.AppendFormatted(Registry.FolderPath);
|
||||
defaultInterpolatedStringHandler.AppendFormatted<ProductTypes>(product);
|
||||
defaultInterpolatedStringHandler.AppendLiteral("\\License.lic");
|
||||
string text = defaultInterpolatedStringHandler.ToStringAndClear();
|
||||
bool flag = File.Exists(text);
|
||||
if (flag)
|
||||
{
|
||||
string text2 = Cryptography.Decrypt(File.ReadAllText(text));
|
||||
Record record = JsonConvert.DeserializeObject<Record>(text2);
|
||||
record._licenseKey = JObject.Parse(text2).SelectToken("LicenseKey").ToString();
|
||||
Registry.Base.SaveValue(Resources.CPA, record.License.Product.ToString(), "CLI", Cryptography.Encrypt(JsonConvert.SerializeObject(record)));
|
||||
record2 = record;
|
||||
}
|
||||
else
|
||||
{
|
||||
record2 = new Record
|
||||
{
|
||||
IsValid = false
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
record2 = new Record
|
||||
{
|
||||
IsValid = false
|
||||
};
|
||||
}
|
||||
return record2;
|
||||
}
|
||||
|
||||
// Token: 0x06000297 RID: 663 RVA: 0x00018E00 File Offset: 0x00017000
|
||||
public static bool sMDed()
|
||||
{
|
||||
bool flag2;
|
||||
try
|
||||
{
|
||||
string text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\" + Resources.XLD + "\\";
|
||||
string text2 = text + Resources.XLF;
|
||||
bool flag = !Directory.Exists(text);
|
||||
if (flag)
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
File.WriteAllText(text2, Cryptography.Encrypt(Resources.XLV));
|
||||
flag2 = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
// Token: 0x06000298 RID: 664 RVA: 0x00018E78 File Offset: 0x00017078
|
||||
public static bool xMDed()
|
||||
{
|
||||
bool flag4;
|
||||
try
|
||||
{
|
||||
string text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\" + Resources.XLD + "\\";
|
||||
string text2 = text + Resources.XLF;
|
||||
bool flag = !Directory.Exists(text);
|
||||
if (flag)
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
bool flag2 = File.Exists(text2);
|
||||
if (flag2)
|
||||
{
|
||||
string text3 = Cryptography.Decrypt(File.ReadAllText(text2));
|
||||
bool flag3 = text3 == Resources.XLV;
|
||||
if (flag3)
|
||||
{
|
||||
flag4 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag4 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag4 = false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag4 = false;
|
||||
}
|
||||
return flag4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Bunifu.Licensing.Helpers
|
||||
{
|
||||
// Token: 0x02000039 RID: 57
|
||||
[DebuggerStepThrough]
|
||||
internal static class Shadower
|
||||
{
|
||||
// Token: 0x06000269 RID: 617
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DllImport("dwmapi.dll")]
|
||||
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Shadower.MARGINS pMarInset);
|
||||
|
||||
// Token: 0x0600026A RID: 618
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DllImport("dwmapi.dll")]
|
||||
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
||||
|
||||
// Token: 0x0600026B RID: 619
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DllImport("dwmapi.dll")]
|
||||
public static extern int DwmIsCompositionEnabled(ref int pfEnabled);
|
||||
|
||||
// Token: 0x0600026C RID: 620 RVA: 0x00017A78 File Offset: 0x00015C78
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static bool IsCompositionEnabled()
|
||||
{
|
||||
bool flag = Environment.OSVersion.Version.Major < 6;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag3;
|
||||
Shadower.DwmIsCompositionEnabled(out flag3);
|
||||
flag2 = flag3;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
// Token: 0x0600026D RID: 621 RVA: 0x00017AB0 File Offset: 0x00015CB0
|
||||
public static void ApplyShadows(Form form)
|
||||
{
|
||||
int num = 2;
|
||||
Shadower.DwmSetWindowAttribute(form.Handle, 2, ref num, 4);
|
||||
Shadower.MARGINS margins = new Shadower.MARGINS
|
||||
{
|
||||
bottomHeight = 1,
|
||||
leftWidth = 0,
|
||||
rightWidth = 0,
|
||||
topHeight = 0
|
||||
};
|
||||
Shadower.DwmExtendFrameIntoClientArea(form.Handle, ref margins);
|
||||
}
|
||||
|
||||
// Token: 0x0600026E RID: 622 RVA: 0x00017B08 File Offset: 0x00015D08
|
||||
public static bool IsAeroEnabled()
|
||||
{
|
||||
bool flag = Environment.OSVersion.Version.Major >= 6;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
int num = 0;
|
||||
Shadower.DwmIsCompositionEnabled(ref num);
|
||||
flag2 = num == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
// Token: 0x0600026F RID: 623
|
||||
[DllImport("dwmapi.dll")]
|
||||
private static extern int DwmIsCompositionEnabled(out bool enabled);
|
||||
|
||||
// Token: 0x06000270 RID: 624
|
||||
[DllImport("Gdi32.dll")]
|
||||
private static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
// Token: 0x0400018D RID: 397
|
||||
private static bool _isAeroEnabled;
|
||||
|
||||
// Token: 0x0400018E RID: 398
|
||||
private static bool _isDraggingEnabled;
|
||||
|
||||
// Token: 0x0400018F RID: 399
|
||||
private const int WM_NCHITTEST = 132;
|
||||
|
||||
// Token: 0x04000190 RID: 400
|
||||
private const int WS_MINIMIZEBOX = 131072;
|
||||
|
||||
// Token: 0x04000191 RID: 401
|
||||
private const int HTCLIENT = 1;
|
||||
|
||||
// Token: 0x04000192 RID: 402
|
||||
private const int HTCAPTION = 2;
|
||||
|
||||
// Token: 0x04000193 RID: 403
|
||||
private const int CS_DBLCLKS = 8;
|
||||
|
||||
// Token: 0x04000194 RID: 404
|
||||
private const int CS_DROPSHADOW = 131072;
|
||||
|
||||
// Token: 0x04000195 RID: 405
|
||||
private const int WM_NCPAINT = 133;
|
||||
|
||||
// Token: 0x04000196 RID: 406
|
||||
private const int WM_ACTIVATEAPP = 28;
|
||||
|
||||
// Token: 0x0200004E RID: 78
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public struct MARGINS
|
||||
{
|
||||
// Token: 0x040001DD RID: 477
|
||||
public int leftWidth;
|
||||
|
||||
// Token: 0x040001DE RID: 478
|
||||
public int rightWidth;
|
||||
|
||||
// Token: 0x040001DF RID: 479
|
||||
public int topHeight;
|
||||
|
||||
// Token: 0x040001E0 RID: 480
|
||||
public int bottomHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user