-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtoolbox_core.lua
More file actions
3976 lines (3936 loc) · 164 KB
/
toolbox_core.lua
File metadata and controls
3976 lines (3936 loc) · 164 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
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
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function hex_o(n)
return "0x" .. string.upper(string.format("%x", n))
end
function hexnx(n)
return string.format("%X", n)
end
------------------------
-----Select Lib End-----
------------------------
script_title = "🧰 BadCase's Toolbox 🧰\nGame: " .. gg.getTargetInfo().label .. "\nPackage: " .. gg.getTargetPackage()
dataPath = gg.EXT_STORAGE .. "/BC_DATA/"
pluginsDataPath = gg.EXT_STORAGE .. "/BC_DATA/plugins/"
configDataPath = gg.EXT_STORAGE .. "/BC_DATA/config/"
arch = gg.getTargetInfo()
game_path = gg.getTargetPackage()
dump_cs_table = {}
bc_toolbox_method_types = {}
bc_toolbox_method_types_all = {}
save_dump = false
dH = {
-- dumpHandler.createDirectory()
-- dH.createDirectory()
createDirectory = function()
directory_created = true
bc.createDirectory(dataPath .. game_path .. "/")
bc.createDirectory(dataPath .. game_path .. "/scripts/")
end,
-- dH.importDump()
importDump = function()
local startTime = os.time()
local fileName = gg.prompt({ bc.Prompt("Select Dump.cs","ℹ️")}, nil, { "file" })
if fileName ~= nil then
local tempDumpTable = {}
local content = bc.readFile(fileName[1])
local delimiter = "\n"
for match in (content .. delimiter):gmatch("(.-)" .. delimiter) do
table.insert(tempDumpTable, match);
end
local temp_dump_cs_table = {}
if tempDumpTable[1]:find("/%*") then
local current_namespace = "Global"
local capturing_fields = false
local capturing_enums = false
local capturing_methods = false
local capturing_properties = false
for i, v in pairs(tempDumpTable) do
if v:find("^namespace .+") then
current_namespace = v:gsub("^namespace (.+)", "%1")
end
if v:find(" .+ class .+ // TypeDefIndex.+") then
current_class = v:gsub("(.+) // .+", "%1")
table.insert(temp_dump_cs_table, {
class = current_class,
namespace = current_namespace
})
elseif v:find(".+ class .+ // TypeDefIndex.+") then
current_namespace = "Global"
current_class = v:gsub("(.+) // .+", "%1")
table.insert(temp_dump_cs_table, {
class = current_class,
namespace = current_namespace
})
elseif v:find(" .+ struct .+ // TypeDefIndex.+") then
current_class = v:gsub("(.+) // .+", "%1")
table.insert(temp_dump_cs_table, {
struct = current_class,
namespace = current_namespace
})
elseif v:find(".+ struct .+ // TypeDefIndex.+") then
current_namespace = "Global"
current_class = v:gsub("(.+) // .+", "%1")
table.insert(temp_dump_cs_table, {
struct = current_class,
namespace = current_namespace
})
elseif v:find(" .+ enum .+ // TypeDefIndex.+") then
current_class = v:gsub("(.+) // .+", "%1")
capturing_enums = true
table.insert(temp_dump_cs_table, {
enum = current_class,
namespace = current_namespace
})
temp_dump_cs_table[#temp_dump_cs_table].fields = {}
elseif v:find(".+ enum .+ // TypeDefIndex.+") then
current_namespace = "Global"
current_class = v:gsub("(.+) // .+", "%1")
capturing_enums = true
table.insert(temp_dump_cs_table, {
enum = current_class,
namespace = current_namespace
})
temp_dump_cs_table[#temp_dump_cs_table].fields = {}
end
if capturing_fields == true and (v:find("}") or v:find("// [A-Z]")) then
capturing_fields = false
end
if v:find("// Fields") then
capturing_fields = true
temp_dump_cs_table[#temp_dump_cs_table].fields = {}
end
if capturing_methods == true and v:find("}") then
capturing_methods = false
end
if v:find("// Methods") then
capturing_methods = true
if not temp_dump_cs_table[#temp_dump_cs_table].methods then
temp_dump_cs_table[#temp_dump_cs_table].methods = {}
end
end
if capturing_enums == true and v:find("}") then
capturing_enums = false
end
if capturing_properties == true and v:find("// [A-Z]") then
capturing_properties = false
end
if v:find("// Properties") then
capturing_properties = true
if not temp_dump_cs_table[#temp_dump_cs_table].methods then
temp_dump_cs_table[#temp_dump_cs_table].methods = {}
end
end
if capturing_properties == true and v:find("CompilerGenerated") then
method_name_get = v:gsub("(.+ )(.+) {.+", "%1get_%2() { }")
method_type_get = v:gsub(".+ (.+) (.+ {).+", "%1"):gsub("[>?%[%]]", "")
method_offset_get = v:gsub(".+} // (.+)", "%1"):gsub("(.+)-.+ .+", "%1")
table.insert(temp_dump_cs_table[#temp_dump_cs_table].methods, {
method_offset = method_offset_get,
method_name = method_name_get,
method_type = method_type_get
})
method_name_set = v:gsub("(.+ )(.+) (.+) {.+", "%1void set_%3(%2 value) { }")
method_type_set = "void"
method_offset_set = v:gsub(".+} // (.+)", "%1"):gsub(".+-.+ (.+)-.+", "%1")
table.insert(temp_dump_cs_table[#temp_dump_cs_table].methods, {
method_offset = method_offset_set,
method_name = method_name_set,
method_type = method_type_set
})
elseif capturing_properties == true and v:find("{ get; }") then
method_name_get = v:gsub("(.+ )(.+) {.+", "%1get_%2() { }")
method_type_get = v:gsub(".+ (.+) (.+ {).+", "%1"):gsub("[>?%[%]]", "")
method_offset_get = v:gsub(".+} // (.+)", "%1"):gsub("(.+)-.+", "%1")
table.insert(temp_dump_cs_table[#temp_dump_cs_table].methods, {
method_offset = method_offset_get,
method_name = method_name_get,
method_type = method_type_get
})
elseif capturing_properties == true and v:find("{ set; }") then
method_name_set = v:gsub("(.+ )(.+) (.+) {.+", "%1void set_%3(%2 value) { }")
method_type_set = "void"
method_offset_set = v:gsub(".+} // (.+)", "%1"):gsub("(.+)-.+", "%1")
table.insert(temp_dump_cs_table[#temp_dump_cs_table].methods, {
method_offset = method_offset_set,
method_name = method_name_set,
method_type = method_type_set
})
end
if capturing_methods == true and v:find("%); // 0x") then
local method_offset = v:gsub(".+// (.+)-.+", "%1")
local method_name = v:gsub("(.+);.+", "%1"):gsub(" ", "")
local method_type = ""
if method_name:find(" static ") or method_name:find(" override ") or
method_name:find(" internal ") or method_name:find(" virtual ") then
method_type = method_name:gsub(".+ .+ (.+) .+%(.+", "%1"):gsub("[ *%[%]]", ""):gsub("[>,]", "")
else
method_type = method_name:gsub(".+ (.+) .+%(.+", "%1"):gsub("[ *%[%]]", ""):gsub("[>,]", "")
end
table.insert(temp_dump_cs_table[#temp_dump_cs_table].methods, {
method_offset = method_offset,
method_name = method_name,
method_type = method_type
})
end
if capturing_enums == true and v:find("[A-Za-z0-9]+ =") then
local enum_value = v:gsub(".+ = (.+)", "%1"):gsub(",", "")
local enum_name = v:gsub("([A-Za-z]+) = .+", "%1"):gsub(" ", "")
local enum_type = ""
table.insert(temp_dump_cs_table[#temp_dump_cs_table].fields, {
enum_type = enum_type,
enum_value = enum_value,
enum_name = enum_name
})
end
if capturing_fields == true and v:find("; // 0x") then
local field_type = ""
local field_offset = ""
local field_name = ""
if v:find(" static ") or v:find(" readonly ") then
field_type = v:gsub(".+ .+ (.+) .+; // 0x.+", "%1"):gsub("[ *%[%]]", "")
field_offset = v:gsub(".+ .+ .+ .+; // (0x.+)", "%1")
field_name = v:gsub(".+ .+ .+ (.+); // 0x.+", "%1"):gsub(" ", "")
else
field_type = v:gsub(".+ (.+) .+; // 0x.+", "%1"):gsub("[ *%[%]]", "")
field_offset = v:gsub(".+ .+ .+; // (0x.+)", "%1")
field_name = v:gsub(".+ .+ (.+); // 0x.+", "%1"):gsub(" ", "")
end
table.insert(temp_dump_cs_table[#temp_dump_cs_table].fields, {
field_type = field_type,
field_offset = field_offset,
field_name = field_name
})
end
end
else
for i, v in pairs(tempDumpTable) do
if v:find(" Namespace:") then
capturing = false
capturing_fields = false
capturing_methods = false
if tempDumpTable[i + 1]:find(".+ class .+") then
capturing = true
temp_dump_cs_table[#temp_dump_cs_table + 1] = {
namespace = tempDumpTable[i],
class = tempDumpTable[i + 1]
}
elseif tempDumpTable[i + 1]:find(".+ struct .+") then
capturing = true
temp_dump_cs_table[#temp_dump_cs_table + 1] = {
namespace = tempDumpTable[i],
struct = tempDumpTable[i + 1]
}
elseif tempDumpTable[i + 1]:find(".+ enum .+") then
capturing = true
temp_dump_cs_table[#temp_dump_cs_table + 1] = {
namespace = tempDumpTable[i],
enum = tempDumpTable[i + 1]
}
end
end
if capturing == true and v:find("// Methods") then
temp_dump_cs_table[#temp_dump_cs_table].methods = {}
capturing_methods = true
capturing_fields = false
end
if v:find("// Properties") then
capturing_fields = false
end
if capturing_fields == true then
if #v > 0 and v:find(" // 0x") and temp_dump_cs_table[#temp_dump_cs_table].class then
local field_type = ""
local field_offset = ""
local field_name = ""
if v:find(" static ") or v:find(" readonly ") then
field_type = v:gsub(".+ .+ (.+) .+; // 0x.+", "%1"):gsub("[ *%[%]]", "")
field_offset = v:gsub(".+ .+ .+ .+; // (0x.+)", "%1")
field_name = v:gsub(".+ .+ .+ (.+); // 0x.+", "%1")
else
field_type = v:gsub(".+ (.+) .+; // 0x.+", "%1"):gsub("[ *%[%]]", "")
field_offset = v:gsub(".+ .+ .+; // (0x.+)", "%1")
field_name = v:gsub(".+ .+ (.+); // 0x.+", "%1")
end
table.insert(temp_dump_cs_table[#temp_dump_cs_table].fields, {
field_type = field_type,
field_offset = field_offset,
field_name = field_name
})
elseif #v > 0 and v:find(" %= ") and temp_dump_cs_table[#temp_dump_cs_table].enum then
local field_type = ""
local field_value = ""
local field_name = ""
field_type = v:gsub(".+ const (.+) .+ %= [%-0-9]+;", "%1"):gsub("[ *%[%]]", "")
field_value = v:gsub(".+ const .+ .+ %= ([%-0-9]+);", "%1")
field_name = v:gsub(".+ const .+ (.+) %= [%-0-9]+;", "%1")
table.insert(temp_dump_cs_table[#temp_dump_cs_table].fields, {
enum_type = field_type,
enum_value = field_value,
enum_name = field_name
})
end
end
if capturing_methods == true and v:find(" // RVA:") and v:find(" VA: ") and v:find("MoveNext") ==
nil then
capturing_fields = false
local method_offset = tempDumpTable[i]:gsub(".+// RVA: (0x[A-Za-z0-9]+) .+: .+", "%1")
local method_name = tempDumpTable[i + 1]:gsub(" ", "")
local method_type = ""
if method_name:find(" static ") or method_name:find(" override ") or
method_name:find(" internal ") or method_name:find(" virtual ") then
method_type = method_name:gsub(".+ .+ (.+) .+%(.+", "%1"):gsub("[ *%[%]]", ""):gsub("[>,]",
"")
else
method_type = method_name:gsub(".+ (.+) .+%(.+", "%1"):gsub("[ *%[%]]", ""):gsub("[>,]", "")
end
table.insert(temp_dump_cs_table[#temp_dump_cs_table].methods, {
method_offset = method_offset,
method_name = method_name,
method_type = method_type
})
end
if capturing == true and tempDumpTable[i]:find("// Fields") then
temp_dump_cs_table[#temp_dump_cs_table].fields = {}
capturing_fields = true
end
end
end
dump_cs_table = temp_dump_cs_table
end
save_dump = true
end,
-- dH.saveJSON()
saveJSON = function()
bc.saveTable("dump_cs_table",dataPath .. game_path .. "/processed_dump_" .. gg.getTargetInfo().versionName .. ".json",true)
end,
-- dH.loadJSON()
loadJSON = function()
dump_cs_table = bc.readFile(dataPath .. game_path .. "/processed_dump_" .. gg.getTargetInfo().versionName .. ".json", true)
end,
-- dH.loadDumpData()
loadDumpData = function()
if #dump_cs_table == 0 then
Il2Cpp.selectLibrary()
if pcall(dH.loadJSON) == false then
dH.createDirectory()
dH.importDump()
end
local temp_types = {}
for i, v in pairs(dump_cs_table) do
if v.methods then
for index, value in pairs(v.methods) do
if value.method_type:find("-") or value.method_type:find(" [0-9]+ ") or value.method_type:find("^[0-9]+$") then else
if not temp_types[value.method_type] then
temp_types[value.method_type] = value.method_type
end
end
end
end
end
local always_add = { "Boolean", "Single", "Double", "Int16", "Int32", "Int64", "UInt16", "UInt32", "UInt64", "String", "Byte", "SByte", "Char", "Void" }
for i, v in pairs(always_add) do
bc_toolbox_method_types[#bc_toolbox_method_types + 1] = v
end
for k, v in pairs(temp_types) do
local added = false
table.insert(bc_toolbox_method_types_all, v)
if v:find("[_]") then else
if added == false then
bc_toolbox_method_types[#bc_toolbox_method_types + 1] = v
end
end
end
end
end
}
dumpHandler = dH
pM = {
-- pluginManager.configMenu()
-- pM.configMenu()
configMenu = function()
local menu = gg.choice({
"↕️ Change Menu Order",
"🔢 Set Menu Item Limit",
"🔗 Configure Default Plugins",
"📥 Install Plugin",
"✏️ Rename Plugin",
"✅ Enable/Disable Plugins"
}, nil, bc.Choice("Plugin Manager", "", "ℹ️"))
if menu ~= nil then
if menu == 1 then
pM.menuOrder()
pM.configMenu()
end
if menu == 2 then
pM.menuLimit()
pM.configMenu()
end
if menu == 3 then
pM.defaultPlugins()
pM.configMenu()
end
if menu == 4 then
pM.installPlugin()
pM.configMenu()
end
if menu == 5 then
pM.renamePlugin()
pM.configMenu()
end
if menu == 6 then
pM.togglePlugins()
pM.configMenu()
end
end
end,
-- pM.callPlugin(plugin_path, function_table, passed_data)
callPlugin = function(plugin_path, function_table, passed_data)
if _G[function_table] then
_G[function_table].home(passed_data)
else
dofile(plugin_path)
if passed_data ~= nil then
_G[function_table].home(passed_data)
end
end
end,
-- pM.defaultHandler(handler, passed_data)
defaultHandler = function(handler, passed_data)
for i, v in pairs(pM.toolboxPlugins) do
if v.default_handler == handler then
pM.callPlugin(v.plugin_path, v.function_table, passed_data)
end
end
end,
-- pM.initPluginManager()
initPluginManager = function()
pM.toolboxPlugins = bc.readFile(configDataPath .. "plugin_manager.json",true)
dofile(configDataPath .. "plugin_manager_config.lua")
end,
-- pM.initAllPluginManager()
initAllPluginManager = function()
pM.toolboxAllPlugins = bc.readFile(configDataPath .. "plugin_manager_all_plugins.json",true)
end,
-- pM.menuOrder()
menuOrder = function()
if pcall(check_plugin_manager) == false then
pM.savePlugins()
end
local slider_range = ' [1; ' .. #pM.toolboxPlugins .. ']'
local sliders = {}
local numbers = {}
local menu = {}
for i, v in pairs(pM.toolboxPlugins) do
sliders[i] = v.menu_name .. slider_range
numbers[i] = "number"
menu[i] = i
end
sliders[1] = bc.Prompt("Set order of main menu items below. ","ℹ️").."\n\n" .. sliders[1]
::duplicate_index::
menu = gg.prompt(sliders, menu, numbers)
if menu ~= nil then
local check_duplicate_indexes = {}
for i, v in pairs(menu) do
if check_duplicate_indexes[v] then
bc.Alert("Duplicate Indexes Found", "", "⚠️")
goto duplicate_index
else
check_duplicate_indexes[v] = v
end
end
local temp_plugins = {}
for i, v in pairs(menu) do
temp_plugins[tonumber(v)] = pM.toolboxPlugins[i]
end
pM.toolboxPlugins = temp_plugins
pM.savePlugins()
bc.Toast("Menu order set. ","ℹ️")
end
end,
-- pM.defaultPlugins()
defaultPlugins = function()
local handler_indexes = {
method = "",
field = "",
enum = "",
class = ""
}
local method_results_handler = "Method search result handler:\n"
for i, v in pairs(pM.toolboxPlugins) do
if v.default_handler == "method_results" then
handler_indexes.method = i
method_results_handler = method_results_handler .. v.menu_name
end
end
local field_results_handler = "Field search result handler:\n"
for i, v in pairs(pM.toolboxPlugins) do
if v.default_handler == "field_results" then
handler_indexes.field = i
field_results_handler = field_results_handler .. v.menu_name
end
end
local enum_results_handler = "Enum search result handler:\n"
for i, v in pairs(pM.toolboxPlugins) do
if v.default_handler == "enum_results" then
handler_indexes.enum = i
enum_results_handler = enum_results_handler .. v.menu_name
end
end
local class_results_handler = "Class/Field search result handler:\n"
for i, v in pairs(pM.toolboxPlugins) do
if v.default_handler == "class_results" then
handler_indexes.class = i
class_results_handler = class_results_handler .. v.menu_name
end
end
local handlerMenu = gg.choice({ method_results_handler,
field_results_handler,
enum_results_handler,
class_results_handler },
nil,
bc.Choice("Set Default Plugins", "", "ℹ️"))
if handlerMenu ~= nil then
local handler_types = {
[1] = "method",
[2] = "field",
[3] = "enum",
[4] = "class"
}
local handler_names = {
[1] = "method_results",
[2] = "field_results",
[3] = "enum_results",
[4] = "class_results"
}
local plugins_menu_items = {}
for i, v in pairs(pM.toolboxPlugins) do
plugins_menu_items[i] = v.menu_name
end
local selectHandlerMenu = gg.choice(plugins_menu_items, nil, bc.Choice("Select Default Plugins", "", "ℹ️"))
if selectHandlerMenu ~= nil then
pM.toolboxPlugins[handler_indexes[handler_types[handlerMenu]]].default_handler = nil
pM.toolboxPlugins[selectHandlerMenu].default_handler = handler_names[handlerMenu]
pM.savePlugins()
bc.Toast("Default plugin set. ","ℹ️")
end
end
end,
-- pM.installPlugin()
installPlugin = function()
local selectPluginLua = gg.prompt({ bc.Prompt("Select Plugin To Install","ℹ️")}, { gg.EXT_STORAGE .. "/Download/" }, { "file" })
if selectPluginLua ~= nil and selectPluginLua ~= gg.EXT_STORAGE .. "/Download/" then
pM.installingPlugin = true
dofile(selectPluginLua[1])
pM.installingPlugin = false
local installMenu = gg.prompt({ bc.Prompt("Installing Plugin","ℹ️") .. "\n\nMenu name for Plugin",
"Name of function table containing plugins home() menu." },
{
pM.installingPluginName,
pM.installingPluginTable },
{
"text",
"text" })
if installMenu ~= nil then
if #installMenu[1] > 0 and #installMenu[2] > 0 then
local filename = selectPluginLua[1]:gsub(".+/(.+)", "%1")
local allready_installed = false
for i, v in pairs(pM.toolboxPlugins) do
if pluginsDataPath .. filename == v.plugin_path then
allready_installed = true
end
end
if allready_installed == true then
bc.Alert("File Name Conflict", "A plugin with this filename is already installed try renaming the lua file first if you are sure it is a different plugin.", "⚠️")
goto done
end
os.rename(selectPluginLua[1], pluginsDataPath .. filename)
local temp_plugin = {
function_table = installMenu[2],
menu_name = installMenu[1],
plugin_path = pluginsDataPath .. filename
}
table.insert(pM.toolboxPlugins, temp_plugin)
pM.savePlugins()
pM.initAllPluginManager()
table.insert(pM.toolboxAllPlugins, temp_plugin)
pM.saveAllPlugins()
bc.Toast("Plugin has been installed. ","ℹ️")
end
end
end
::done::
end,
-- pM.removePlugin()
removePlugin = function()
local plugins_menu_items = {}
for i, v in pairs(pM.toolboxPlugins) do
plugins_menu_items[i] = v.menu_name
end
local removePluginMenu = gg.choice(plugins_menu_items, nil, bc.Choice("Select Plugin To Uninstall", "", "⚠️"))
if removePluginMenu ~= nil then
local confirmRemove = gg.choice({
"✅ Yes",
"❌ No"
},
nil,
bc.Choice("Removing Plugin", "Remove the " .. plugins_menu_items[removePluginMenu] .. " plugin?", "⚠️"))
if confirmRemove ~= nil then
if confirmRemove == 1 then
table.remove(pM.toolboxPlugins, removePluginMenu)
pM.savePlugins()
bc.Toast("Plugin has been removed from the menu. ","ℹ️")
end
end
end
end,
-- pM.savePlugins()
savePlugins = function()
bc.saveTable("pM.toolboxPlugins",configDataPath .. "plugin_manager.json",true)
end,
-- pM.saveAllPlugins()
saveAllPlugins = function()
bc.saveTable("pM.toolboxAllPlugins",configDataPath .. "plugin_manager_all_plugins.json",true)
end,
-- pM.saveMenuLimit()
saveMenuLimit = function()
file = io.open(configDataPath .. "plugin_manager_config.lua", "w+")
file:write("pM.menuItemLimit = " .. pM.menuItemLimit)
file:close()
end,
-- pM.renamePlugin()
renamePlugin = function()
local plugins_menu_items = {}
for i, v in pairs(pM.toolboxPlugins) do
plugins_menu_items[i] = v.menu_name
end
local renamePluginMenu = gg.choice(plugins_menu_items, nil, bc.Choice("Renaming Plugin", "Select plugin to rename.", "ℹ️"))
if renamePluginMenu ~= nil then
local renamePrompt = gg.prompt({ bc.Prompt("Enter a new menu name for the plugin. ","ℹ️")},
{ plugins_menu_items[renamePluginMenu] }, { "text" })
if renamePrompt ~= nil then
pM.toolboxPlugins[renamePluginMenu].menu_name = renamePrompt[1]
pM.savePlugins()
end
end
end,
-- pM.menuLimit()
menuLimit = function()
local menu = gg.prompt({ bc.Prompt("Set limit for number of items per menu.","ℹ️") .. "\n\nSet menu item limit [0; 20]" }, { pM.menuItemLimit }, { 'number' })
if menu ~= nil then
pM.menuItemLimit = menu[1]
pM.saveMenuLimit()
end
end,
-- pM.togglePlugins()
togglePlugins = function()
if not pM.toolboxAllPlugins then
pM.initAllPluginManager()
end
local menu_names = {}
local menu_checkboxes = {}
local menu_values = {}
local menu_paths = {}
for i, v in pairs(pM.toolboxAllPlugins) do
menu_names[i] = v.menu_name
menu_checkboxes[i] = "checkbox"
menu_values[i] = false
menu_paths[i] = v.plugin_path
for index, value in pairs(pM.toolboxPlugins) do
if v.plugin_path == value.plugin_path then
menu_values[i] = true
end
end
end
local menu = gg.prompt(menu_names, menu_values, menu_checkboxes)
if menu ~= nil then
for i, v in pairs(menu) do
if v == true and menu_values[i] == false then
table.insert(pM.toolboxPlugins, pM.toolboxAllPlugins[i])
pM.savePlugins()
end
if v == false and menu_values[i] == true then
for index, value in pairs(pM.toolboxPlugins) do
if value.plugin_path == menu_paths[i] then
table.remove(pM.toolboxPlugins, index)
pM.savePlugins()
end
end
end
end
end
end,
-- pM.toolboxPlugins
toolboxPlugins = { {
function_table = "metadataDumper",
menu_name = "💾 Global-Metadata Dumper",
plugin_path = pluginsDataPath .. "plugin_bc_metadata_dumper.lua"
}, {
function_table = "libDumper",
menu_name = "💾 Lib Dumper",
plugin_path = pluginsDataPath .. "plugin_bc_lib_dumper.lua"
}, {
function_table = "bcpp_dumper",
menu_name = "💩 BCppDumper",
plugin_path = pluginsDataPath .. "plugin_bc_bcpp_dumper.lua"
}, {
function_table = "classFieldSearcher",
menu_name = "🔎 Class Field Searcher",
plugin_path = pluginsDataPath .. "plugin_bc_class_field_search.lua"
}, {
function_table = "dumpSearcher",
menu_name = "🔍 Search Dump.cs",
plugin_path = pluginsDataPath .. "plugin_bc_dump_search.lua"
}, {
function_table = "methodSearchResults",
default_handler = "method_results",
menu_name = "🗒️ Method Search Results",
menu_count_table = "dumpSearcher.methodResults",
plugin_path = pluginsDataPath .. "plugin_bc_method_search_results.lua"
}, {
function_table = "fieldSearchResults",
default_handler = "field_results",
menu_name = "🗒️ Field Search Results",
menu_count_table = "dumpSearcher.fieldResults",
plugin_path = pluginsDataPath .. "plugin_bc_field_search_results.lua"
}, {
function_table = "enumSearchResults",
default_handler = "enum_results",
menu_name = "🗒️ Enum Search Results",
menu_count_table = "dumpSearcher.enumResults",
plugin_path = pluginsDataPath .. "plugin_bc_enum_search_results.lua"
}, {
function_table = "il2cppFields",
default_handler = "class_results",
menu_name = "📝 BadCase's Il2Cpp Fields",
plugin_path = pluginsDataPath .. "plugin_bc_il2cpp_fields.lua"
}, {
function_table = "il2cppEdits",
menu_name = "📝 BadCase's Il2Cpp Edits by Name",
plugin_path = pluginsDataPath .. "plugin_bc_il2cpp_edits.lua"
},{
function_table = "editByOffset",
menu_name = "📝 Lib Edits By Offset",
plugin_path = pluginsDataPath .. "plugin_bc_edit_by_offset.lua"
} , {
function_table = "staticValueFinder",
menu_name = "🕵️ Static Value Finder",
plugin_path = pluginsDataPath .. "plugin_bc_static_value_finder.lua"
}, {
function_table = "saveListManager",
menu_name = "📑 Save List Manager",
plugin_path = pluginsDataPath .. "plugin_bc_save_list.lua"
} , {
function_table = "scriptCreator",
menu_name = "🏗️ Script Creator",
plugin_path = pluginsDataPath .. "plugin_bc_script_creator.lua"
}},
menuItemLimit = 0,
returnHome = false,
returnPluginTable = "",
-- pM.home(menu_number)
home = function(menu_number)
if pM.returnHome == true then
_G[pM.returnPluginTable].home()
elseif pM.menuItemLimit == 0 then
local menu_names = {}
for i, v in pairs(pM.toolboxPlugins) do
menu_names[i] = v.menu_name
if v.menu_count_table and _G[v.menu_count_table:gsub("(.+)%..+", "%1")] then
menu_names[i] = menu_names[i] .. " (" .. #_G[v.menu_count_table:gsub("(.+)%..+", "%1")][v.menu_count_table:gsub(".+%.(.+)", "%1")] .. ")"
end
end
menu_names[#menu_names + 1] = "⚙️ Plugin Manager"
menu_names[#menu_names + 1] = "❌ Exit"
local menu = gg.choice(menu_names, nil, script_title)
if menu ~= nil then
if menu == #menu_names then
os.exit()
elseif menu == #menu_names - 1 then
pM.configMenu()
else
local status, retval = pcall(pM.callPlugin,
pM.toolboxPlugins[menu].plugin_path,
pM.toolboxPlugins[menu].function_table);
if status == false then
local error_menu = gg.alert(retval, "OK", "Copy Error")
if error_menu ~= nil then
if error_menu == 2 then
gg.copyText(retval)
end
end
end
end
end
else
local current_menu = 1
if menu_number ~= nil then
current_menu = menu_number
end
local limit = current_menu - 1
local menu_names = {}
local total_plugins = #pM.toolboxPlugins
local menu_limit = pM.menuItemLimit
menu_count = total_plugins / menu_limit
if total_plugins % menu_limit ~= 0 then
menu_count = menu_count + 1
end
for i, v in pairs(pM.toolboxPlugins) do
if i <= pM.menuItemLimit * current_menu and i > pM.menuItemLimit * limit then
menu_names[#menu_names + 1] = v.menu_name
if v.menu_count_table and _G[v.menu_count_table:gsub("(.+)%..+", "%1")] then
menu_names[#menu_names] = menu_names[#menu_names] .. " (" .. #_G[v.menu_count_table:gsub("(.+)%..+", "%1")][v.menu_count_table:gsub(".+%.(.+)", "%1")] .. ")"
end
end
if #menu_names == pM.menuItemLimit then
break
end
end
if menu_count and current_menu == menu_count then
menu_names[#menu_names + 1] = "🏠 Home Menu"
elseif menu_count then
menu_names[#menu_names + 1] = "⏭️ Next Menu"
end
menu_names[#menu_names + 1] = "⚙️ Plugin Manager"
menu_names[#menu_names + 1] = "❌ Exit"
local menu = gg.choice(menu_names, nil, script_title)
if menu ~= nil then
local menuRange = pM.menuItemLimit * limit
if menu == #menu_names then
os.exit()
elseif menu == #menu_names - 1 then
pM.configMenu()
elseif menu <= #menu_names - 3 then
if current_menu > 1 then
call_index = menu + pM.menuItemLimit * limit
else
call_index = menu
end
local status, retval = pcall(pM.callPlugin,
pM.toolboxPlugins[call_index].plugin_path,
pM.toolboxPlugins[call_index].function_table);
if status == false then
local error_menu = gg.alert(retval, "OK", "Copy Error")
if error_menu ~= nil then
if error_menu == 2 then
gg.copyText(retval)
end
end
end
elseif menu >= #menu_names - 2 - menu_count and menu <= #menu_names - 2 then
if current_menu == menu_count then
pM.home(1)
else
pM.home(current_menu + 1)
end
end
end
end
end,
whileLoop = {},
doWhileLoop = function()
for i, v in pairs(pM.whileLoop) do
local ms_to_sec = v.run_every / 1000
if os.time() - v.last_run > ms_to_sec then
if v.do_pcall == true then
pcall(_G[v.plugin_table][v.call_function])
else
_G[v.plugin_table][v.call_function]()
end
v.last_run = os.time()
end
end
end
}
pluginManager = pM
Il2Cpp = {
arch = gg.getTargetInfo(),
ggHex = function(n, zero)
if type(n) ~= "table" then
local dwordValueToHex = string.format('%x', n)
if #dwordValueToHex == 8 or #dwordValueToHex == 10 or #dwordValueToHex == 12 then
if zero == false then
return dwordValueToHex .. "h"
else
return "0x" .. dwordValueToHex
end
else
local sub = #dwordValueToHex / 2
sub = tonumber("-" .. sub)
dwordValueToHex = dwordValueToHex:sub(sub)
if zero == false then
return dwordValueToHex .. "h"
else
return "0x" .. dwordValueToHex
end
end
else
return nil
end
end,
utf8FromTable = function(t)
local bytearr = {}
for _, v in ipairs(t) do
local utf8byte = v < 0 and (0xff + v + 1) or v
if utf8byte ~= 0 then
table.insert(bytearr, string.char(utf8byte))
end
end
return table.concat(bytearr)
end,
mySplit = function(inputstr, sep)
sep = sep or "%s"
local t = {}
for field, s in string.gmatch(inputstr, "([^" .. sep .. "]*)(" .. sep .. "?)") do
table.insert(t, field)
if s == "" then
end
end
return t
end,
filters = {},
class_names = {},
namespace_names = {},
image_names = {},
Il2cppApi = {
["v24"] = {
FieldApiOffset = {
ARM8 = 0x18,
ARM7 = 0xC
},
FieldApiType = {
ARM8 = 0x8,
ARM7 = 0x4
},
FieldApiClassOffset = {
ARM8 = 0x10,
ARM7 = 0x8
},
ClassApiNameOffset = {
ARM8 = 0x10,
ARM7 = 0x8
},
ClassApiMethodsStep = {
ARM8 = 3,
ARM7 = 2
},
ClassApiCountMethods = {
ARM8 = 0x114,
ARM7 = 0x9C
},
ClassApiMethodsLink = {
ARM8 = 0x98,
ARM7 = 0x40
},
ClassApiFieldsLink = {
ARM8 = 0x80,
ARM7 = 0x34
},
ClassApiFieldsStep = {
ARM8 = 0x28,
ARM7 = 0x18
},
ClassApiCountFields = {
ARM8 = 0x118,
ARM7 = 0xA0
},
ClassApiParentOffset = {
ARM8 = 0x58,
ARM7 = 0x24
},
ClassApiNameSpaceOffset = {
ARM8 = 0x18,
ARM7 = 0xC
},
ClassApiStaticFieldDataOffset = {
ARM8 = 0xB8,
ARM7 = 0x5C
},
MethodsApiClassOffset = {
ARM8 = 0x18,
ARM7 = 0xC
},
MethodsApiNameOffset = {
ARM8 = 0x10,
ARM7 = 0x8
},
MethodsApiParamCount = {
ARM8 = 0x4A,
ARM7 = 0x2A
},
MethodsApiReturnType = {
ARM8 = 0x20,
ARM7 = 0x10
},
typeDefinitionsSize = 92,
typeDefinitionsOffset = 0xA0,
stringOffset = 0x18,
TypeApiType = {
ARM8 = 0xA,
ARM7 = 0x6
}
},
["v24.1"] = {
FieldApiOffset = {
ARM8 = 0x18,
ARM7 = 0xC
},
FieldApiType = {
ARM8 = 0x8,
ARM7 = 0x4
},
FieldApiClassOffset = {
ARM8 = 0x10,
ARM7 = 0x8
},
ClassApiNameOffset = {
ARM8 = 0x10,
ARM7 = 0x8
},
ClassApiMethodsStep = {
ARM8 = 3,
ARM7 = 2
},
ClassApiCountMethods = {
ARM8 = 0x110,
ARM7 = 0xA8