Repository navigation
Expand file tree
/
Copy pathreg.cs
More file actions
113 lines (105 loc) · 3.57 KB
/
Copy pathreg.cs
File metadata and controls
113 lines (105 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
namespace PDF_Convert
{
using System;
using System.Management;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
internal class reg
{
private readonly int[] encode = new int[] { 8, 7, 8, 6, 5, 7, 9, 9, 8 };
private ini_config ini = new ini_config("config.ini");
private registry register = new registry("XJPDF Convert");
private int get_cpu_code()
{
string str = "";
string str2 = "";
ManagementObjectCollection instances = new ManagementClass("Win32_Processor").GetInstances();
foreach (ManagementObject obj2 in instances)
{
str = obj2.Properties["ProcessorId"].Value.ToString();
break;
}
if (str == string.Empty)
{
return 0;
}
if (str.Length == 0x10)
{
str = string.Format("{0}-{1}-00000000-00000000", str.Substring(0, 8), str.Substring(8, 8));
}
else if (str.Length == 0x20)
{
str = string.Format("{0}-{1}-{2}-{3}", new object[] { str.Substring(0, 8), str.Substring(8, 8), str.Substring(0x10, 8), str.Substring(0x18, 8) });
}
str2 = this.get_md5(str, 0x20, true);
string s = "";
string str4 = "";
for (int i = 1; i <= 0x1b; i += 3)
{
s = str2.Substring(i + 2, 1);
int num = Encoding.ASCII.GetBytes(s)[0];
int num2 = num % this.encode[((i + 2) / 3) - 1];
if (0 == num2)
{
num2 = 8;
}
str4 = str4 + num2.ToString();
}
return int.Parse(str4);
}
public string get_machine_code()
{
return this.get_cpu_code().ToString();
}
private string get_md5(string str, int bit, bool lower_case)
{
string str2 = "";
byte[] buffer = new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(str));
for (int i = 0; i < buffer.Length; i++)
{
if (0x20 == bit)
{
str2 = str2 + System.Convert.ToString(buffer[i], 0x10).PadLeft(2, '0');
}
else
{
str2 = str2 + System.Convert.ToString(buffer[i], 0x10);
}
}
return (lower_case ? str2 : str2.ToUpper());
}
public string get_reg_code(string machine_code)
{
if (machine_code == string.Empty)
{
machine_code = this.get_machine_code();
}
long num = System.Convert.ToInt64(machine_code);
string str = "";
for (int i = 0; i < 100; i++)
{
num *= 2L;
str = num.ToString();
if (str.Length <= 12)
{
num = System.Convert.ToInt64(str);
}
else
{
num = System.Convert.ToInt64(str.Substring(0, 12));
}
}
//str = num.ToString();
return num.ToString();
}
public bool is_reg()
{
return (this.ini.read_ini("RegCode", "App") == this.get_reg_code(""));
}
public bool write_reg_code(string reg_code)
{
return this.ini.write_ini("RegCode", reg_code, "App");
}
}
}