forked from moewcorp/FFXIVNetworkOpcodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffxiv_opcode_finder.py
674 lines (604 loc) · 22.4 KB
/
ffxiv_opcode_finder.py
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
import idaapi
import idc
import idautils
import ida_bytes
import ida_nalt
import ida_xref
import ida_search
import ida_ua
import os
import json
import functools
import re
ConfigPath = os.path.dirname(os.path.realpath(__file__))
OutputPath = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
f"output",
)
print("Begin FFXIVnetworkFinder...")
seg_dict = {
idc.get_segm_name(seg): (idc.get_segm_start(seg), idc.get_segm_end(seg))
for seg in idautils.Segments()
}
min_ea = idaapi.inf_get_min_ea()
max_ea = idaapi.inf_get_max_ea()
min_text_ea = seg_dict[".text"][0]
max_text_ea = seg_dict[".text"][1]
slist = idautils.Strings()
slist_s = [str(s) for s in slist] # s.ea, s.length, s.type, str(s)
for s in slist_s:
if r"/*****ff14******rev" in s:
_splited = s.split("_")
BuildID = _splited[1].replace("/", ".")
VersionID = int(_splited[0][_splited[0].index("rev") + 3:])
break
for s in slist_s:
if r"ffxiv_dx11.pdb" in s:
Region_s,version_s=s.split('\\')[4].split('_')
break
if Region_s == 'shanda':
Region = 'CN'
elif Region_s == 'ver':
Region = 'Global'
elif Region_s == 'actoz':
Region = 'KR'
else:
Region='Unknown'
print(f"{Region} {version_s} {VersionID:08X} {BuildID}")
errors = {
"SigNotFound": [],
"IndexFailed": [],
"FuncNotFound": [],
"ArgvNotFound": [],
"DoubleCase": {},
"DoubleXref": {},
"DoublePath": {},
}
#########
# Utils #
#########
JMP_INS = ["jmp", "jz", "ja", "jb", "jnz"]
CALL_INS = ["call"]
RET_INS = ["ret", "retn"]
CTRL_INS = JMP_INS + CALL_INS + RET_INS
def get_ctrl_target(ea):
xrefs = list(idautils.XrefsFrom(ea, flags=1))
return xrefs[0].to if len(xrefs) > 0 else idc.BADADDR
def find_pattern(pattern, times=1):
address = min_text_ea
while times>0:
address = ida_search.find_binary(
idc.next_head(address), max_text_ea, pattern, 16, idc.SEARCH_DOWN
)
times-=1
if address == idc.BADADDR:
return idc.BADADDR
return address
def find_next_insn(ea, insn, step=30):
for _ in range(step):
if idc.print_insn_mnem(ea) == insn:
return ea
if ea >= max_ea:
break
ea = idc.next_head(ea)
return idc.BADADDR
def find_prev_insn(ea, insn, step=10):
for _ in range(step):
if idc.print_insn_mnem(ea) == insn:
return ea
if ea <= min_ea:
break
ea = idc.prev_head(ea)
return idc.BADADDR
def find_prev_ctrl(cea, up):
while cea > up:
if idc.print_insn_mnem(cea) in CTRL_INS:
return cea
cea = idc.prev_head(cea)
return up
def find_next_ctrl(cea, down):
while cea < down:
if idc.print_insn_mnem(cea) in CTRL_INS:
return cea
cea = idc.next_head(cea)
return down
#'ZoneClientIpc'
#'ChatServerIpc'
#'ChatClientIpc'
#'LobbyServerIpc'
#'LobbyClientIpc'
#####################
# ServerZoneIpcType #
#####################
class SwitchTable:
def __init__(self, ea) -> None:
self.content = []
self.switch_func = idaapi.get_func(ea)
self.switch_address = find_next_insn(ea, "jmp")
print(f"switch table at {self.switch_address:x}")
switch_info = ida_nalt.get_switch_info(self.switch_address)
print(switch_info)
print(switch_info.ncases)
print(switch_info.jumps)
bias = switch_info.jumps
lowcase = switch_info.lowcase
element_num = switch_info.get_jtable_size()
element_size = switch_info.get_jtable_element_size()
for i in range(0, element_num):
table_entry = bias + i * element_size
startea = switch_info.elbase + idc.get_wide_dword(table_entry)
endea = min(
find_next_insn(startea, "jmp", 1000),
find_next_insn(startea, "retn", 1000),
)
print(
f"case 0x{i+lowcase:03x}: table@{table_entry:x} jmp@{startea:x} - {endea:x}"
)
self.content.append({"case": i + lowcase, "start": startea, "end": endea})
return
def in_switch(self, ea) -> bool:
return (
True
if ea > self.switch_func.start_ea and ea < self.switch_func.end_ea
else False
)
def index(self, ea) -> list:
maybe = []
if self.in_switch(ea):
maybe = [
case["case"]
for case in self.content
if (ea >= case["start"] and ea <= case["end"])
]
return maybe
class SimpleSwitch:
def __init__(self, switch_address) -> None:
self.content = []
self.switch_func = idaapi.get_func(switch_address)
self.switch_func_item = list(idautils.FuncItems(switch_address))
self.process_case_block(self.switch_func.start_ea, 0, 0, False,'')
print(self.content)
def process_case_block(self, start, rcase, ccase, iscmp, reg):
_reg=reg #r10d
_reg_case = rcase
_t_mov_op1 = 0
_t_cmp_tmp = ccase
_t_cmp_yes = iscmp
for ea in self.switch_func_item:
if ea < start:
continue
ins = idc.print_insn_mnem(ea)
op0 = idc.print_operand(ea, 0)
op1 = idc.print_operand(ea, 1)
if ins in JMP_INS:
self.process_case_block(
get_ctrl_target(ea), _reg_case, _t_cmp_tmp, _t_cmp_yes, _reg
)
continue
if ins in RET_INS:
continue
if ins == "mov":
_t_mov_op1 = int(op1.strip('h'), 16)
continue
if ins == "movzx" and op1=='r8w':
_reg=op0
print(_reg)
continue
if ins == "call":
_case = _t_cmp_tmp if _t_cmp_yes else _reg_case
if self.index(_t_mov_op1):
continue
self.content.append({"case": _case, "arg": _t_mov_op1})
print(f"case:0x{_case:03x} arg@{_t_mov_op1:x}")
continue
if ins == "cmp" and op0 == _reg:
if idc.print_insn_mnem(idc.next_head(ea)) == 'jnz':
_reg_case += int(op1.strip('h'), 16)
_t_cmp_yes = False
else:
_t_cmp_tmp = int(op1.strip('h'), 16)
_t_cmp_yes = True
continue
if ins == "sub" and op0 == _reg:
_reg_case += int(op1.strip('h'), 16)
_t_cmp_yes = False
continue
def index(self, arg):
for case in self.content:
if case["arg"] == arg:
return case["case"]
return None
def map_switch_jumps(_si: int):
si = ida_nalt.switch_info_t()
res = {}
if ida_nalt.get_switch_info(si, _si):
results = ida_xref.calc_switch_cases(_si, si)
for idx in range(len(results.cases)):
s = res.setdefault(results.targets[idx], set())
for _idx in range(len(cases := results.cases[idx])):
s.add(cases[_idx])
return res
class SwitchTableX:
def __init__(self, ea) -> None:
self.content = []
self.switch_func = idaapi.get_func(ea)
self.switch_address = find_next_insn(ea, "jmp")
print(f"switch table at {self.switch_address:x} <- {ea:x}")
switch_info = ida_nalt.get_switch_info(self.switch_address)
print(switch_info)
print(switch_info.ncases)
print(switch_info.jumps)
print(switch_info.lowcase)
bias = switch_info.jumps
element_num = switch_info.get_jtable_size()
element_size = switch_info.get_jtable_element_size()
mapcase = map_switch_jumps(self.switch_address)
for i in range(0, element_num):
table_entry = bias + i * element_size
startea = switch_info.elbase + idc.get_wide_dword(table_entry)
endea = min(
find_next_insn(startea, "jmp", 1000),
find_next_insn(startea, "retn", 1000),
)
caseid=list(mapcase.get(startea, set()))[0]
movea = find_next_insn(startea, "mov", endea-startea)
op1 = idc.print_operand(movea , 1)
print(op1)
try:
_t_mov_op1 = int(op1.strip('h'), 16)
except:
_t_mov_op1 = 0xffff
print(f"case:{caseid:x} arg:{_t_mov_op1:x}")
self.content.append({"case": caseid, "arg": _t_mov_op1})
def index(self, arg):
for case in self.content:
if case["arg"] == arg:
return case["case"]
return None
class CallTable:
def __init__(self, func_address) -> None:
self.content = []
self.call_fanc = idaapi.get_func(func_address)
self.init_send_table(func_address)
self.content.sort(key=lambda x: x["case"])
print("Sorted CallTable")
for i in self.content:
print(f"Code 0x{i['case']:03x}: between@{i['start']:x} - {i['end']:x}")
def init_send_table(self, ea):
call_ea = ea
func = idaapi.get_func(ea)
if not func:
xrefs = [xref.frm for xref in idautils.XrefsTo(ea, 0) if xref.iscode == 1]
for xref in xrefs:
self.init_send_table(xref)
return
op_var = ""
# find lea rdx [opcode] between func.start-call
ea = call_ea
while ea > func.start_ea:
if (
idc.print_insn_mnem(ea) == "lea"
and idc.print_operand(ea, 0) == "rdx"
and idc.get_operand_type(ea, 1) == idaapi.o_displ
):
op_var = idc.print_operand(ea, 1)
break
ea = idc.prev_head(ea)
if op_var != "":
# find mov [opcode] imm between func.start-call
ea = call_ea
while ea > func.start_ea:
if (
idc.print_insn_mnem(ea) == "mov"
and idc.print_operand(ea, 0) == op_var
and idc.get_operand_type(ea, 1) == idaapi.o_imm
):
op = idc.print_operand(ea, 1)
op = op.replace("h", "")
if op == "":
return
op = int(op, 16)
self.add_send_opcode(
op,
find_prev_ctrl(ea, func.start_ea),
find_next_ctrl(ea, func.end_ea),
)
break
ea = idc.prev_head(ea)
return
else:
for xref in idautils.XrefsTo(func.start_ea, 0):
if xref.iscode == 1:
self.init_send_table(xref.frm)
return
def add_send_opcode(self, op, start, end):
# print(f"Code 0x{op:03x}: between@{start:x} - {end:x}")
self.content.append({"case": op, "start": start, "end": end})
def index(self, ea):
maybe = [i["case"] for i in self.content if ea >= i["start"] and ea < i["end"]]
return list(set(maybe))
class ServerZoneIpcType:
def __init__(self, config) -> None:
self.config = config.content["ServerZoneIpcType"]
self.content = {}
self.table = SwitchTable(self.config["__init__"]["ProcessZonePacketDown"])
del self.config["__init__"]["ProcessZonePacketDown"]
self.funcs = {}
for func in self.config["__init__"]:
if self.config["__init__"][func]:
try:
self.funcs[func] = SimpleSwitch(self.config["__init__"][func])
except:
self.funcs[func] = SwitchTableX(self.config["__init__"][func])
del self.config["__init__"]
print("ServerZone Inited...")
for name in self.config:
if type(self.config[name]) == int:
self.find_in_table(self.config[name], name)
elif type(self.config[name]) == dict:
if "Param" in self.config[name]:
func = self.config[name]["Function"]
argv = self.config[name]["Param"]
self.find_in_simple(func, argv, name)
def find_in_simple(self, func, argv, name):
if func not in self.funcs:
errors["FuncNotFound"].append(name)
return False
op = self.funcs[func].index(argv)
if not op:
print(f"func {func} - {name} {argv} \n{self.funcs[func].content}")
errors["ArgvNotFound"].append(name)
return False
self.content[name] = op
print(f'Opcode 0x{op:03x}({op:03d}): {name}')
return True
def find_in_table_result(self, ea, name):
maybe = self.table.index(ea)
if len(maybe) > 0:
if len(maybe) > 1:
print(f"{name} Double Case")
if name not in errors["DoubleCase"]:
errors["DoubleCase"][name] = maybe
for op in maybe:
print(
f'Opcode 0x{op:03x}({op:03d}): {name} {"?(Double Case)"if(len(maybe)>1)else "?(Double Xref)"if(name in self.content)else""}'
)
if name not in self.content:
self.content[name] = op
else:
if name not in errors["DoubleXref"]:
errors["DoubleXref"][name] = [self.content[name]] + maybe
else:
errors["DoubleXref"][name] += maybe
return True
else:
return False
#todo 递归层数检查
def find_in_table_process(self, ea, name):
print(f'{name} 0x{ea:03x}')
if idaapi.segtype(ea) != idaapi.SEG_CODE:
return False
func = idaapi.get_func(ea)
if func:
ea = func.start_ea
xrefs_all = list(idautils.XrefsTo(ea, flags=1))
if len(xrefs_all) <= 0:
return False
xrefs = [xref.frm for xref in xrefs_all if self.table.in_switch(xref.frm)]
if len(xrefs) < 1:
if functools.reduce(
lambda a, b: a or b,
[self.find_in_table_process(xref.frm, name) for xref in xrefs_all],
):
return True
else:
return False
else:
ea = xrefs[0]
return self.find_in_table_result(ea, name)
def find_in_table(self, ea, name):
if self.find_in_table_result(ea, name):
return True
if self.find_in_table_process(ea, name):
return True
print(f"{name} NotFound")
errors["IndexFailed"].append(name)
return False
class ClientZoneIpcType:
def __init__(self, config) -> None:
self.config = config.content["ClientZoneIpcType"]
self.content = {}
self.table = CallTable(self.config["__init__"]["ProcessZonePacketUp"])
del self.config["__init__"]["ProcessZonePacketUp"]
print("ClientZone Inited...")
for name in self.config:
if type(self.config[name]) == int:
self.find_in_table(self.config[name], name)
def find_in_table(self, ea, name):
maybe = self.table.index(ea)
if len(maybe) > 0:
if len(maybe) > 1:
if name not in errors["DoublePath"]:
errors["DoublePath"][name] = maybe
for op in maybe:
print(
f'Opcode 0x{int(op):03x}({int(op):03d}): {name} {"?(Double Path)"if(len(maybe)>1)else""}'
)
if name not in self.content:
self.content[name] = op
return True
else:
print(f"{name} NotFound")
errors["IndexFailed"].append(name)
return False
class ConfigReader:
def __init__(self) -> None:
self.path = os.path.join(
ConfigPath,
f"signatures.json",
)
with open(self.path, "r") as f:
self.content = json.load(f)
self.instance(self.content["ServerZoneIpcType"])
self.instance(self.content["ClientZoneIpcType"])
def instance(self, item):
for i in item:
if i == "__init__":
self.instance(item[i])
item[i] = self.sig2addr(item[i], i)
def sig2addr(self, sig, name):
address = idc.BADADDR
_sig = None
if type(sig) == str:
_sig = sig
elif type(sig) == dict:
if "Signature" in sig:
_sig = sig["Signature"]
if Region == "Global" and "Global" in sig:
return self.sig2addr(sig["Global"], name)
elif Region == "CN" and "CN" in sig:
return self.sig2addr(sig["CN"], name)
elif Region == "KR" and "KR" in sig:
return self.sig2addr(sig["KR"], name)
if not _sig:
return sig
if "Index" in sig and int(sig["Index"]):
address = find_pattern(_sig, sig["Index"]+1)
else:
address = find_pattern(_sig)
if address == idc.BADADDR:
print(f"Signature {name} Not Found")
errors["SigNotFound"].append(name)
return None
else:
if "Offset" in sig:
address += sig["Offset"]
if "Type" in sig and sig["Type"] == "Call":
address = get_ctrl_target(address)
return address
config = ConfigReader()
print(config.content)
serverzone = ServerZoneIpcType(config)
print(serverzone.content)
clientzone = ClientZoneIpcType(config)
print(clientzone.content)
print(errors)
opcodes_internal = {
"version": BuildID,
"region": Region,
"lists": {
"ServerZoneIpcType": serverzone.content,
"ClientZoneIpcType": clientzone.content,
},
}
opcodes = {
"version": BuildID,
"region": Region,
"lists": {
"ServerZoneIpcType": [
{"name": i, "opcode": serverzone.content[i]} for i in serverzone.content
],
"ClientZoneIpcType": [
{"name": i, "opcode": clientzone.content[i]} for i in clientzone.content
],
},
}
debugs = {"ClientCallTable": clientzone.table.content}
output_dir = os.path.join(
OutputPath,
f"{Region}_{BuildID}",
)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
outpath = lambda name: os.path.join(
output_dir,
name,
)
opcodes_internal_path = outpath("opcodes_internal.json")
if Region != "Global":
ipcs_filename = f"Ipcs_{Region.lower()}.cs"
else:
ipcs_filename = "Ipcs.cs"
opcodes_csharp_path = outpath(ipcs_filename)
errors_path = outpath("errors.json")
debugs_path = outpath("debug.json")
opcodes_path = outpath("opcodes.json")
lemegeton_path = outpath("lemegeton.xml")
with open(opcodes_path, "w+") as f:
json.dump(opcodes, f, sort_keys=False, indent=4, separators=(",", ":"))
print(f"Result saved on {opcodes_path}")
with open(opcodes_internal_path, "w+") as f:
json.dump(opcodes_internal, f, sort_keys=False, indent=4, separators=(",", ":"))
print(f"Result saved on {opcodes_internal_path}")
with open(errors_path, "w+") as f:
json.dump(errors, f, sort_keys=False, indent=4, separators=(",", ":"))
print(f"Error saved on {errors_path}")
with open(debugs_path, "w+") as f:
json.dump(debugs, f, sort_keys=False, indent=4, separators=(",", ":"))
print(f"Dump saved on {debugs_path}")
template_path = os.path.join(ConfigPath, f"machina.template")
mtemplate = []
mresult = []
with open(template_path, "r") as f:
mtemplate = f.readlines()
for l in mtemplate:
opcode_temp = re.match(r".+(?P<opcode_name>\{.+\})", l).groupdict()["opcode_name"]
opcode_name = opcode_temp[1:-1]
for op in (
opcodes["lists"]["ServerZoneIpcType"] + opcodes["lists"]["ClientZoneIpcType"]
):
if op["name"] == opcode_name:
l = l.replace(opcode_temp, f"{op['opcode']:X}")
break
mresult.append(l)
with open(outpath("machina.txt"), "w+") as f:
f.writelines(mresult)
print(f'Gen machina.txt on {outpath("machina.txt")}')
def get_enum_textblock(name, enums, ntype, indent):
res = [f"public enum {name} : {ntype}", "{"]
if len(enums) > 0:
res += [f" {k} = 0x{enums[k]:04X}," for k in enums]
else:
res += ['']
res += ['};', '']
return list(map(lambda l: " " * indent + l, res))
ipcs_line = [
"// Generated by https://github.com/gamous/FFXIVNetworkOpcodes",
f"namespace FFXIVOpcodes.{Region}",
"{",
]
ipcs_line += get_enum_textblock("ServerLobbyIpcType", {}, 'ushort', 4)
ipcs_line += get_enum_textblock("ClientLobbyIpcType", {}, 'ushort', 4)
ipcs_line += get_enum_textblock("ServerZoneIpcType", serverzone.content, 'ushort', 4)
ipcs_line += get_enum_textblock("ClientZoneIpcType", clientzone.content, 'ushort', 4)
ipcs_line += get_enum_textblock("ServerChatIpcType", {}, 'ushort', 4)
ipcs_line += get_enum_textblock("ClientChatIpcType", {}, 'ushort', 4)
ipcs_line += ["}"]
ipcs_line = list(map(lambda l: l + "\n", ipcs_line))
with open(opcodes_csharp_path, "w+") as f:
f.writelines(ipcs_line)
print(f'Gen ipcs on {opcodes_csharp_path,}')
Region_Name="EN/DE/FR/JP" if Region=="Global" else Region
lemegeton_opcodes=f""" <Region Name="{Region_Name}" Version="{BuildID}.0000.0000">
<Opcodes>
<Opcode Name="StatusEffectList" Id="{serverzone.content["StatusEffectList"]}" />
<Opcode Name="StatusEffectList2" Id="{serverzone.content["StatusEffectList2"]}" />
<Opcode Name="StatusEffectList3" Id="{serverzone.content["StatusEffectList3"]}" />
<Opcode Name="Ability1" Id="{serverzone.content["Effect"]}" />
<Opcode Name="Ability8" Id="{serverzone.content["AoeEffect8"]}" />
<Opcode Name="Ability16" Id="{serverzone.content["AoeEffect16"]}" />
<Opcode Name="Ability24" Id="{serverzone.content["AoeEffect24"]}" />
<Opcode Name="Ability32" Id="{serverzone.content["AoeEffect32"]}" />
<Opcode Name="ActorCast" Id="{serverzone.content["ActorCast"]}" />
<Opcode Name="EffectResult" Id="{serverzone.content["EffectResult"]}" />
<Opcode Name="ActorControl" Id="{serverzone.content["ActorControl"]}" />
<Opcode Name="ActorControlSelf" Id="{serverzone.content["ActorControlSelf"]}" />
<Opcode Name="ActorControlTarget" Id="{serverzone.content["ActorControlTarget"]}" />
<Opcode Name="MapEffect" Id="{serverzone.content["EnvironmentControl"]}" />
<Opcode Name="EventPlay" Id="{serverzone.content["EventPlay"]}" />
<Opcode Name="EventPlay64" Id="{serverzone.content["EventPlay64"]}" />
</Opcodes>
</Region>"""
with open(lemegeton_path, "w+") as f:
f.write(lemegeton_opcodes)
print(f'Gen lemegeton_bludprint.xml on {lemegeton_path,}')