Skip to content

Commit 155fdbc

Browse files
Merge branch 'dev' of https://github.com/SummerofOrange/O-Z-IL2CPP into dev
2 parents a1c8751 + bca22c8 commit 155fdbc

17 files changed

+511
-40
lines changed

OZ_Il2cpp_Console/OZ_Il2cpp_Console.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ int main(int argc, char* const argv[], const char* optstr)
1414
wcout.imbue(locale("chs"));
1515

1616
//Dbg
17-
cpp_mgr::proc_cpp("MetadataCache.cpp", "test.cpp", "mdc.txt");
17+
//cpp_mgr::proc_cpp("MetadataCache.cpp", "MetadataCache_encrypted.cpp", "./oz_scripts/mdc.ozs");
18+
cpp_mgr::proc_cpp("il2cpp-metadata.h", "il2cpp-metadata_encrypted.h", "./oz_scripts/metadataheader.ozs");
1819
system("pause");
1920

2021
if (argc == 1) {

OZ_Il2cpp_Console/OZ_Il2cpp_Console.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
<SDLCheck>true</SDLCheck>
103103
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
104104
<ConformanceMode>true</ConformanceMode>
105+
<LanguageStandard>stdcpp20</LanguageStandard>
105106
</ClCompile>
106107
<Link>
107108
<SubSystem>Console</SubSystem>

OZ_Il2cpp_Console/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# OZ-Libil2cpp-Generator
2+
3+
##实验性功能,正在开发中,敬请期待
4+
5+
自动生成libil2cpp代码,以后将会结合gui一键安装,支持绝大多数unity版本
6+
7+
## Unity versions will be supported
8+
9+
| Il2Cpp Version | Unity Version | Support |
10+
| -------------- | ---------------------------- |-------------- |
11+
| 24.0 | 2017.x - 2018.2.x | ✔️ |
12+
| 24.1 | 2018.3.x - 2018.4.x | ✔️ |
13+
| 24.2 | 2019.1.x - 2019.2.x | ✔️ |
14+
| 24.3 | 2019.3.x, 2019.4.x, 2020.1.x |✔️ |
15+
| 24.4 | 2019.4.x and 2020.1.x |✔️ |
16+
| 27.0 | 2021.2.x | ✔️ |
17+
| 27.1 | 2020.2.x - 2020.3.x | ✔️ |
18+
| 27.2 | 2021.1.x, 2021.2.x | ✔️ |
19+
| 28 | 2021.3.x, 2022.1.x |✔️ |
20+

OZ_Il2cpp_Console/cpp_mgr.cpp

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace cpp_mgr {
3636
if (num >= off) {
3737
bool find = false;
3838
if (line.find(str) != string::npos) {
39+
find = true;
3940
}
4041
else {
4142
bool find = false;
@@ -89,53 +90,33 @@ namespace cpp_mgr {
8990
insert_from_file(lines, insert_a, fp);
9091
}
9192

93+
void repl_line(vector<wstring>& lines, int ln, wstring s) {
94+
lines[ln-1] = s;
95+
}
96+
97+
void repl_line_from_file(vector<wstring>& lines, int ln, const char* fp) {
98+
vector<wstring> a;
99+
utils::read_file_lines_w(fp, a);
100+
lines[ln -1] = a[0];
101+
}
102+
103+
void swap_line(vector<wstring>& lines, int ln1, int ln2) {
104+
wstring ss = lines[ln1-1];
105+
lines[ln1-1] = lines[ln2-1];
106+
lines[ln2-1] = ss;
107+
}
108+
92109
void proc_cpp(const char* ifp, const char* ofp, const char* sfp) {
93110
vector<wstring> lines;
94111
utils::read_file_lines_w(ifp, lines);
95112

96113
vector<wstring> l_script;
97114
utils::read_file_lines_w(sfp, l_script);
98115

99-
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
116+
std::vector<oz_script_var> vars;
100117

101118
for (auto c : l_script) {
102-
if (c.length() == 0) {
103-
//empty line
104-
continue;
105-
}
106-
else if (c[0] == '#') {
107-
//comment
108-
continue;
109-
}
110-
else {
111-
vector<wstring> cmd;
112-
utils::string_split_w(c, L" ", cmd);
113-
wcout << "cmd:" << cmd[0] << endl;
114-
115-
int opcode = ozil2_script_mgr::str2opcode(cmd[0]);
116-
117-
string fp;
118-
119-
switch (opcode) {
120-
case 100:
121-
fp = "./src_res/"+conv.to_bytes(cmd[3]);
122-
insert_method_at_from_file(lines, cmd[1], cmd[2], fp.c_str());
123-
break;
124-
case 101:
125-
insert_line(lines, 10, cmd[2]);
126-
break;
127-
case 102:
128-
fp = "./src_res/" + conv.to_bytes(cmd[2]);
129-
insert_from_file(lines, 10, fp.c_str());
130-
break;
131-
case 103:
132-
insert_header(lines, cmd[1]);
133-
break;
134-
case -1:
135-
continue;
136-
break;
137-
}
138-
}
119+
ozil2_script_mgr::run_line(lines, vars, c);
139120
}
140121

141122
utils::write_file_lines_w(ofp, lines);

OZ_Il2cpp_Console/cpp_mgr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ namespace cpp_mgr
1919
void insert_lines(vector<wstring>& lines, int line_num, vector<wstring> strs);
2020
void insert_header(vector<wstring>& lines, wstring head);
2121
void insert_from_file(vector<wstring>& lines, int line_num, const char* fp);
22+
void repl_line(vector<wstring>& lines, int ln, wstring s);
2223
void insert_method_at_from_file(vector<wstring>& lines, wstring m_n, wstring v_2, const char* fp);
2324
void proc_cpp(const char* ifp, const char* ofp, const char* sfp);
25+
void repl_line_from_file(vector<wstring>& lines, int ln, const char* fp);
26+
void swap_line(vector<wstring>& lines, int ln1, int ln2);
2427
}
2528

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/python
2+
# -*- coding: UTF-8 -*-
3+
4+
file_path = 'metadataheader.ozs'
5+
file=open(file_path,"w")
6+
file.write("find_str_in_file Il2CppGlobalMetadataHeader 0 $head\n")
7+
8+
file.write("\n\n")
9+
10+
for i in range(1,60):#60*4=240 ,240<264 比最短的header少
11+
file.write("$h"+str(i)+" = $head\n")
12+
file.write("$h"+str(i)+" += "+str(i+1)+"\n")
13+
14+
file.write("\n\n")
15+
16+
for i in range(1,30):
17+
file.write("swap_line ")
18+
file.write("$h"+str(i)+" ")
19+
file.write("$h"+str(60-i)+"\n")
20+
21+
file.write("\n\n")
22+
23+
file.close()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#通过这些脚本来编辑libil2cpp代码,可轻松适配更多版本
2+
3+
#删除版本校验
4+
find_method_in_file Initialize $lineInit
5+
find_str_in_file Header->sanity $lineInit $sanity
6+
$check_ver = $sanity
7+
$check_ver += 1
8+
repl_line_from_file $sanity mdc_init_assert.cpp
9+
repl_line_from_file $check_ver mdc_init_assert.cpp
10+
11+
#变量
12+
$head
13+
find_str_in_file s_GlobalMetadata 0 $head
14+
printd $head
15+
insert_from_file $head mdc.cpp
16+
17+
#头引用
18+
insert_header xxtea.h
19+
20+
#解密方法
21+
insert_method_at_from_file Initialize s_GlobalMetadata mdc_init.cpp
22+
insert_method_at_from_file GetStringFromIndex strings mdc_getstr.cpp
23+
insert_method_at_from_file GetStringLiteralFromIndex GarbageCollector::SetWriteBarrier mdc_getstrlit.cpp
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
find_str_in_file Il2CppGlobalMetadataHeader 0 $head
2+
3+
4+
$h1 = $head
5+
$h1 += 2
6+
$h2 = $head
7+
$h2 += 3
8+
$h3 = $head
9+
$h3 += 4
10+
$h4 = $head
11+
$h4 += 5
12+
$h5 = $head
13+
$h5 += 6
14+
$h6 = $head
15+
$h6 += 7
16+
$h7 = $head
17+
$h7 += 8
18+
$h8 = $head
19+
$h8 += 9
20+
$h9 = $head
21+
$h9 += 10
22+
$h10 = $head
23+
$h10 += 11
24+
$h11 = $head
25+
$h11 += 12
26+
$h12 = $head
27+
$h12 += 13
28+
$h13 = $head
29+
$h13 += 14
30+
$h14 = $head
31+
$h14 += 15
32+
$h15 = $head
33+
$h15 += 16
34+
$h16 = $head
35+
$h16 += 17
36+
$h17 = $head
37+
$h17 += 18
38+
$h18 = $head
39+
$h18 += 19
40+
$h19 = $head
41+
$h19 += 20
42+
$h20 = $head
43+
$h20 += 21
44+
$h21 = $head
45+
$h21 += 22
46+
$h22 = $head
47+
$h22 += 23
48+
$h23 = $head
49+
$h23 += 24
50+
$h24 = $head
51+
$h24 += 25
52+
$h25 = $head
53+
$h25 += 26
54+
$h26 = $head
55+
$h26 += 27
56+
$h27 = $head
57+
$h27 += 28
58+
$h28 = $head
59+
$h28 += 29
60+
$h29 = $head
61+
$h29 += 30
62+
$h30 = $head
63+
$h30 += 31
64+
$h31 = $head
65+
$h31 += 32
66+
$h32 = $head
67+
$h32 += 33
68+
$h33 = $head
69+
$h33 += 34
70+
$h34 = $head
71+
$h34 += 35
72+
$h35 = $head
73+
$h35 += 36
74+
$h36 = $head
75+
$h36 += 37
76+
$h37 = $head
77+
$h37 += 38
78+
$h38 = $head
79+
$h38 += 39
80+
$h39 = $head
81+
$h39 += 40
82+
$h40 = $head
83+
$h40 += 41
84+
$h41 = $head
85+
$h41 += 42
86+
$h42 = $head
87+
$h42 += 43
88+
$h43 = $head
89+
$h43 += 44
90+
$h44 = $head
91+
$h44 += 45
92+
$h45 = $head
93+
$h45 += 46
94+
$h46 = $head
95+
$h46 += 47
96+
$h47 = $head
97+
$h47 += 48
98+
$h48 = $head
99+
$h48 += 49
100+
$h49 = $head
101+
$h49 += 50
102+
$h50 = $head
103+
$h50 += 51
104+
$h51 = $head
105+
$h51 += 52
106+
$h52 = $head
107+
$h52 += 53
108+
$h53 = $head
109+
$h53 += 54
110+
$h54 = $head
111+
$h54 += 55
112+
$h55 = $head
113+
$h55 += 56
114+
$h56 = $head
115+
$h56 += 57
116+
$h57 = $head
117+
$h57 += 58
118+
$h58 = $head
119+
$h58 += 59
120+
$h59 = $head
121+
$h59 += 60
122+
123+
124+
swap_line $h1 $h59
125+
swap_line $h2 $h58
126+
swap_line $h3 $h57
127+
swap_line $h4 $h56
128+
swap_line $h5 $h55
129+
swap_line $h6 $h54
130+
swap_line $h7 $h53
131+
swap_line $h8 $h52
132+
swap_line $h9 $h51
133+
swap_line $h10 $h50
134+
swap_line $h11 $h49
135+
swap_line $h12 $h48
136+
swap_line $h13 $h47
137+
swap_line $h14 $h46
138+
swap_line $h15 $h45
139+
swap_line $h16 $h44
140+
swap_line $h17 $h43
141+
swap_line $h18 $h42
142+
swap_line $h19 $h41
143+
swap_line $h20 $h40
144+
swap_line $h21 $h39
145+
swap_line $h22 $h38
146+
swap_line $h23 $h37
147+
swap_line $h24 $h36
148+
swap_line $h25 $h35
149+
swap_line $h26 $h34
150+
swap_line $h27 $h33
151+
swap_line $h28 $h32
152+
swap_line $h29 $h31
153+
swap_line $h30 $h30
154+
swap_line $h31 $h29
155+
swap_line $h32 $h28
156+
swap_line $h33 $h27
157+
swap_line $h34 $h26
158+
swap_line $h35 $h25
159+
swap_line $h36 $h24
160+
swap_line $h37 $h23
161+
swap_line $h38 $h22
162+
swap_line $h39 $h21
163+
swap_line $h40 $h20
164+
swap_line $h41 $h19
165+
swap_line $h42 $h18
166+
swap_line $h43 $h17
167+
swap_line $h44 $h16
168+
swap_line $h45 $h15
169+
swap_line $h46 $h14
170+
swap_line $h47 $h13
171+
swap_line $h48 $h12
172+
swap_line $h49 $h11
173+
swap_line $h50 $h10
174+
swap_line $h51 $h9
175+
swap_line $h52 $h8
176+
swap_line $h53 $h7
177+
swap_line $h54 $h6
178+
swap_line $h55 $h5
179+
swap_line $h56 $h4
180+
swap_line $h57 $h3
181+
swap_line $h58 $h2
182+
swap_line $h59 $h1
183+
184+

0 commit comments

Comments
 (0)