Open landv opened 4 weeks ago
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Management; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OneVueRegistr { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.Text = getWthHid2(); textBox3.Text = getHexidecimalString(get4ByteHash2(textBox1.Text + "OV")); textBox2.Text = GenerateLicenseString(); } public static string GenerateLicenseString() { string prefix = "L"; string suffix = "OV"; int numberLength = 7; // 中间数字的长度 // 生成中间的随机数字 string randomNumber = GenerateRandomNumber(numberLength); // 拼接最终字符串 string result = prefix + randomNumber + suffix; return result; } private static Random random = new Random(); private static string GenerateRandomNumber(int length) { char[] digits = new char[length]; for (int i = 0; i < length; i++) { digits[i] = (char)('0' + random.Next(0, 10)); } return new string(digits); } private static byte[] get4ByteHash2(string s) { int length = s.Length; byte[] array = new byte[4]; int[] array2 = new int[4]; for (int i = 0; i < s.Length; i++) { byte b = (byte)s[i]; // 使用 (byte) 进行转换 array2[0] += b; array2[1] ^= b; array2[2] += b * (i + 1); if (i % 2 == 1) { array2[3] += b; } } for (int j = 0; j < 4; j++) { array[j] = (byte)(array2[j] % 256); } return array; } public static string getWthHid2() { string text = "abcdefg"; try { text = getBaseId(); text += getBiosId(); } catch { } return "H" + getHexidecimalString(get4ByteHash2(text)); } public static string getHardwareProperty(string wmiClass, string wmiProperty, string wmiMustBeTrue) { foreach (ManagementBaseObject managementBaseObject in new ManagementClass(wmiClass).GetInstances()) { ManagementObject managementObject = (ManagementObject)managementBaseObject; if ((wmiMustBeTrue == null || wmiMustBeTrue.Length <= 0 || !(managementObject[wmiMustBeTrue].ToString().ToLower() != "true")) && managementObject[wmiProperty] != null) { return managementObject[wmiProperty].ToString(); } } return ""; } private static string getBaseId() { return getHardwareProperty("Win32_BaseBoard", "Model", "") + getHardwareProperty("Win32_BaseBoard", "Manufacturer", "") + getHardwareProperty("Win32_BaseBoard", "Name", "") + getHardwareProperty("Win32_BaseBoard", "SerialNumber", ""); } private static string getBiosId() { return string.Concat(new string[] { getHardwareProperty("Win32_BIOS", "Manufacturer",""), getHardwareProperty("Win32_BIOS", "SMBIOSBIOSVersion",""), getHardwareProperty("Win32_BIOS", "IdentificationCode",""), getHardwareProperty("Win32_BIOS", "SerialNumber",""), getHardwareProperty("Win32_BIOS", "ReleaseDate",""), getHardwareProperty("Win32_BIOS", "Version","") }); } private static string getHexidecimalString(byte[] hash) { string text = ""; for (int i = 0; i < hash.Length; i++) { text += hash[i].ToString("X2"); } return text; } private void button1_Click(object sender, EventArgs e) { textBox1.Text = string.Empty; textBox2.Text = string.Empty; textBox3.Text = string.Empty; } private void button2_Click(object sender, EventArgs e) { if (textBox1.Text == string.Empty) { textBox1.Text = getWthHid2(); } textBox3.Text = getHexidecimalString(get4ByteHash2(textBox1.Text + "OV")); textBox2.Text = GenerateLicenseString(); } } }
Form1.Designer.cs
namespace OneVueRegistr { partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要修改 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox3 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("宋体", 15F); this.label1.Location = new System.Drawing.Point(12, 34); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(59, 20); this.label1.TabIndex = 0; this.label1.Text = "HID:"; // // label2 // this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("宋体", 15F); this.label2.Location = new System.Drawing.Point(12, 78); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(109, 20); this.label2.TabIndex = 1; this.label2.Text = "许可证号:"; // // label3 // this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("宋体", 15F); this.label3.Location = new System.Drawing.Point(12, 121); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(89, 20); this.label3.TabIndex = 2; this.label3.Text = "授权码:"; // // textBox1 // this.textBox1.Font = new System.Drawing.Font("宋体", 15F); this.textBox1.Location = new System.Drawing.Point(121, 24); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(311, 30); this.textBox1.TabIndex = 3; this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // textBox2 // this.textBox2.Font = new System.Drawing.Font("宋体", 15F); this.textBox2.Location = new System.Drawing.Point(121, 68); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(311, 30); this.textBox2.TabIndex = 4; this.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // textBox3 // this.textBox3.Font = new System.Drawing.Font("宋体", 15F); this.textBox3.Location = new System.Drawing.Point(121, 111); this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(311, 30); this.textBox3.TabIndex = 5; this.textBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // button1 // this.button1.Location = new System.Drawing.Point(121, 147); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(116, 37); this.button1.TabIndex = 6; this.button1.Text = "清除"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(316, 147); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(116, 37); this.button2.TabIndex = 7; this.button2.Text = "生成"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(460, 194); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox3); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "OneVue注册机"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; } }
安装,默认安装在C:\Program Files\OneVue目录下,运行OneVue.exe - -Help - - Register OneVue - -Register - -Manual Registration 或者 UpdateRegistration.exe,更换电脑后HID不一样了,所以以前的注册码用不了。 HID:HE44E8367 License Number:L6658196OV Auth Code:C620E92F Auth Code: text "C620E92F" string License Number: text2 "L6658196OV" string HID: text3 "HA1C57112" string text4 "OV" string License Number: text2 需要以L开头,或者大于8个字符 校验3和4 HA1C57112 和 OV 等不等于 C620E92F global::c.a(A_0 + A_1) HA1C57112+OV 需要等于 C620E92F 得到Auth Code 可以得到HID,通过本机进行计算。 得到Authcode 通过HID+OV进行计算 然后就是License Number如何解析了 //写入ini配置里面 this.a(text, text2); private bool a(string A_0, string A_1) { string fullPath = Path.GetFullPath("OneVue.ini"); IniFile iniFile = new IniFile(); iniFile.Open(fullPath); iniFile.WriteString("OneVue", "AuthCode", A_0); iniFile.WriteString("OneVue", "License", A_1); iniFile.Close(); return true; } private bool checkAuthCode() { if (hardwareId.getAuthCode(this.m_hid, this.m_fullProductName) == this.m_authCode) { this.authorized = true; this.updateDisplayPerAuthorized(); } else { this.authorized = false; this.updateDisplayPerAuthorized(); } return this.authorized; } private bool checkAuthCode() { // 调用 hardwareId.getAuthCode 方法获取授权码,并与当前对象的 m_authCode 进行比较 if (hardwareId.getAuthCode(this.m_hid, this.m_fullProductName) == this.m_authCode) { // 如果授权码匹配,将 authorized 设置为 true this.authorized = true; // 调用方法更新显示状态 this.updateDisplayPerAuthorized(); } else { // 如果授权码不匹配,将 authorized 设置为 false this.authorized = false; // 调用方法更新显示状态 this.updateDisplayPerAuthorized(); } // 返回 authorized 的值 return this.authorized; } private void repairMissingLicenseNum() { // 遍历预定义的产品名称列表 foreach (string text in "OV,XL1000,XL10000,XL100000,XL1000000,XL10000000,XL1K,XL10K,XL100K,XL1M,XL10M,SC".Split(",".ToCharArray())) { // 检查当前授权码是否与生成的授权码匹配 if (this.m_authCode == hardwareId.getAuthCode(this.m_hid, text)) { // 修复许可证号 this.m_licenseNum = "L0000000" + text; // 设置产品名称 this.m_productName = text; // 设置完整产品名称 this.m_fullProductName = this.m_productName; // 退出方法 return; } } } m_fullProductName "OV" string m_productName "OV" string
Form1.cs
Form1.Designer.cs