-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscript.lua
1984 lines (1883 loc) · 81.3 KB
/
script.lua
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
gs = _G or _ENV
pageMemory = pageMemory or 0
lang = {
['ru'] = {
"УБРАТЬ МАТЕРИАЛЫ С КУЗНЕЧНОГО СТОЛА",
"УБРАТЬ МАТЕРИАЛЫ СО СТОЛА КОНСТРУКТОРА",
"РАЗБЛОКИРОВАТЬ ВСЕ ОРУЖИЕ НА СТОЛЕ КУЗНЕЦА",
"ДОБАВИТЬ ВСЕ БАФЫ",
"УВЕЛИЧИТЬ ДОБАВЛЕННЫЕ АТРИБУТЫ",
"ИЗМЕНИТЬ СОЗДАННЫЕ ПРЕДМЕТЫ НА СТОЛЕ КУЗНЕЦА",
"УСТАНОВИТЬ ЦЕНУ ТОВАРОВ У ПРОДАВЦА",
"РАЗБЛОКИРОВАТЬ ВСЕ САДОВЫЕ УЧАСТКИ",
"ВЫРАСТИТЬ ВСЕ РАСТЕНИЯ",
"РАЗБЛОКИРОВАТЬ МОТОЦИКЛ",
--"ДОБАВИТЬ ЗДОРОВЬЯ, БРОНИ, ЭНЕРГИИ",
'ОГРОМНЫЙ УРОН',
'УБРАТЬ КОЛИЧЕСТВО ПОКУПОК У ПРОДАВЦА',
'ЗАРЯДИТЬ ВОЛНОВОД',
"НЕТ ПЕРЕЗАРЯДКИ НАВЫКОВ",
"УБРАТЬ КОЛИЧЕСТВО ПОПЫТОК BOSS RUSH",
-- "ПОЛУЧИТЬ ЗОЛОТЫЕ ТРОФЕИ ЗА СЕЗОНЫ",
"УСТАНОВИТЬ КОЛИЧЕСТВО СЕМЯН",
"УСТАНОВИТЬ КОЛИЧЕСТВО МАТЕРИАЛОВ",
"УСТАНОВИТЬ КОЛИЧЕСТВО КУПОНОВ",
"УСТАНОВИТЬ ЦЕНУ ДЛЯ ПИТОМЦЕВ",
"УСТАНОВИТЬ ЦЕНУ ДЛЯ ГЕРОЕВ",
"УСТАНОВИТЬ ЦЕНУ ДЛЯ СКИЛЛОВ",
"УСТАНОВИТЬ ЦЕНУ ДЛЯ СКИНОВ",
"УСТАНОВИТЬ ЦЕНУ СКИНА ЛОББИ",
"ДОБАВИТЬ МОНЕТЫ",
'НЕТ СТЕН',
'ВЫХОД'
},
['en_US'] = {
'REMOVE MATERIALS IN THE BLACKSMITH TABLE',
"REMOVE MATERIALS FROM THE DESIGNER'S TABLE",
'UNLOCK ALL WEAPON IN THE BLACKSMITH TABLE',
'ADD ALL BUFFS',
"INCREASE ADDED ATTRIBUTES",
"CHANGE THE CREATED ITEMS ON THE BLACKSMITH'S TABLE",
'SET THE PRICE OF ITEMS FROM THE MERCHANT',
"UNLOCK ALL GARDEN PLOTS",
'GROW ALL THE SEEDS',
"UNLOCK MOTORCYCLE",
--'ADD HEALTH, ARMOR, ENERGY',
'HUGE DAMAGE',
'RESET SELLER',
'CHARGE THE WAVEGUIDE',
"NO SKILL COOLDOWN",
"REMOVE THE NUMBER OF BOSS RUSH ATTEMPTS",
-- "GET GOLD TROPHIES FOR THE SEASONS",
'SET COUNT SEEDS',
'SET MATERIALS COUNT',
'SET TOKENS COUNT',
'SET PET PRICE',
'SET HERO PRICE',
'SET SKILL PRICE',
'SET SKIN PRICE',
'SET SKIN LOBBY PRICE',
'ADD COINS',
'NO WALLS',
'EXIT'
},
['zh_CN'] = {
'锻造台不用材料',
"设计台不用材料",
'解锁锻造台的所有武器',
'添加所有好的buff',
"(机翻)增加添加属性",
"修改锻造台上的物品",
'设定商品的价格',
"解锁所有花园地块",
'?种下所有的种子',
"解锁摩托车",
--'添加生命值、护甲和能量',
'超高的伤害(修改当前武器)',
'?重置商人',
'修改枭首者选择界面右上角的百分比',
"大招无cd",
"修改地牢波数",
-- "?获得每一季的金牌奖杯",
'设置种子数量',
'设置材料数量',
'设置试用券数量',
'设置宠物价格',
'设置英雄价格',
'设置技能价格',
'设置皮肤价格',
'设置皮肤大堂价格',
'添加金币',
'穿墙',
'退出脚本'
},
}
langClass = {
['ru'] = {
SkillInfo = "Скиллы найдены",
RGCharacterInfo = "Герои найдены",
RGPetInfo = "Питомцы найдены",
ItemData = "Информация о предметах найдена",
ItemBluePrint = "Чертежи получены",
WeaponsConfig = "Оружия были найдены",
StatisticData = "Данные найдены",
TermData = "Данные найдены",
UIForge = "Стол найден",
RGGameProcess = "Игровая сессия найдена",
ItemSellPlaceGem = "Предметы на продажу найдены",
PlantInfo = "Растения найдены",
AppNoSK = 'Выбранный процесс не является игрой Soul knight',
ErrorData = 'Скрипт будет работать некорректно',
ManualSK = 'Прочтите инструкцию по установке VMOS Pro для корректной работы скрипта',
RoleAttributePlayer = 'Данные игрока были найдены',
RGGameSceneManager = 'Игровая сцена найдена',
RGHand = 'Рука найдена',
WeaponInfoRow = 'Оружия найдены',
WeaponInfo = 'Оружия найдены',
RGSaveManager = 'Сохранения найдены',
Emtry = 'Пусто',
ErrorLib = 'Game Guardian не нашёл нужную библиотеку. Скрипт запустится, но будет работать частично некорректно',
ErrorAlert = 'При выполнении функции произошла ошибка',
SkinMaterialRelation = 'Чертежи скинов получены',
BattleData = 'Боевые данные найдены',
TroopAchievement = "Достижения первого сезона были найдены",
ArtifactsAchievement = "Достижения второго сезона были найдены",
DecorateSkinData = "Получена информация о скинах лобби",
},
['en_US'] = {
SkillInfo = "Skills found",
RGCharacterInfo = "Heroes found",
RGPetInfo = "Pets found",
ItemData = "Information about items found",
ItemBluePrint = "The drawings have been received",
WeaponsConfig = "The weapons were found",
StatisticData = "Data found",
TermData = "Data found",
UIForge = "The table is found",
RGGameProcess = "Game session found",
ItemSellPlaceGem = "Items for sale found",
PlantInfo = "Plants found",
AppNoSK = 'The selected process is not a Soul knight game',
ErrorData = 'The script will not work correctly',
ManualSK = 'Read the instructions for installing VMOS Pro for the script to work correctly',
RoleAttributePlayer = "The player's data was found",
RGGameSceneManager = 'Game scene found',
RGHand = 'Hand found',
WeaponInfoRow = 'Weapons found',
WeaponInfo = 'Weapons found',
RGSaveManager = 'Saves were found',
Emtry = 'Emtry',
ErrorLib = "Game Guardian didn't find the right library. The script will run, but it will work partially incorrectly",
ErrorAlert = 'An error occurred while executing the function',
SkinMaterialRelation = 'Blueprint of skins have been received',
BattleData = 'Battle data found',
TroopAchievement = "Achievements of the first season were found",
ArtifactsAchievement = "Achievements of the second season were found",
DecorateSkinData = "Received information about lobby skins",
},
}
lang_main = setmetatable(lang[gg.getLocale()] or lang['en_US'], {__index = langClass[gg.getLocale()] or langClass['en_US']})
Utf16 = {}
for s in string.gmatch('АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя', "..") do
local char = gg.bytes(s,'UTF-16LE')
Utf16[char[1] + (char[2] * 256)] = s
end
for s in string.gmatch("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_/0123456789-'", ".") do
local char = gg.bytes(s,'UTF-16LE')
Utf16[char[1] + (char[2] * 256)] = s
end
function switch(check, table, e, ...)
return ({
xpcall(
table[check],
function ()
return table[check] or (
function()
if type(e) ~= 'function' then return e end
return e()
end
)()
end,
...
)
})[2]
end
Protect = {
ErrorHandler = function(err)
gg.alert(lang_main['ErrorAlert'])
print(err)
end,
Call = function(self, fun, ...)
return ({xpcall(fun, self.ErrorHandler, ...)})[2]
end
}
function CheckTableIsNil(t)
if (not t) or type(t) ~= 'table' or #t == 0 then return true end
for k,v in pairs(t) do
if (not v) or v == '' then return true end
end
return false
end
function GetNameTableInGlobalSpace(table)
for k,v in pairs(gs) do
if v == table then return k end
end
return ""
end
function GetInfoFropApps()
local data = gg.getRangesList('global-metadata.dat')
local il2cpp = gg.getRangesList('libil2cpp.so')
local info = gg.getTargetInfo()
if info then return data, il2cpp, info.x64, info.targetSdkVersion end
if #il2cpp ~= 0 then
local check = string.gsub(il2cpp[1].internalName,'%/.-%/lib/','')
check = switch(check,{
['arm64/libil2cpp.so'] = true,
['arm/libil2cpp.so'] = false
})
if check ~= nil then return data, il2cpp, check, info.targetSdkVersion end
end
return nil, nil, nil, nil
end
function GetAppData()
local info = gg.getTargetInfo()
if not info then
info = gg.alert(lang_main.ErrorData .. "\n" .. lang_main.ManualSK, 'OK', 'COPY LINK')
if info == 2 then gg.copyText('http://crusher.ucoz.net/index/manual/0-6') end
return GetInfoFropApps()
end
return gg.getRangesList('global-metadata.dat'), gg.getRangesList('libil2cpp.so'), info.x64, info.targetSdkVersion
end
data, libil, platform, sdk = GetAppData()
if #libil == 0 then
local splitconf = gg.getRangesList('split_config.')
gg.setRanges(gg.REGION_CODE_APP)
for k,v in ipairs(splitconf) do
if (v.state == 'Xa') then
gg.searchNumber(':il2cpp',gg.TYPE_BYTE,false,gg.SIGN_EQUAL,v.start,v['end'])
if (gg.getResultsCount() > 0) then
libil[#libil + 1] = v
end
gg.clearResults()
end
end
end
function setupValues(gf,gm,typeset)
gg.setValues({{address = gf,flags = typeset and typeset or gg.TYPE_DWORD,value = gm:gsub('.', function (c) return string.format('%02X', string.byte(c)) end)..'r'}})
end
function Il2CppName(NameFucntion)
local FinalMethods, name = {}, "00 " .. NameFucntion:gsub('.', function (c) return string.format('%02X', string.byte(c)) .. " " end) .. "00"
gg.clearResults()
gg.setRanges(gg.REGION_C_HEAP | gg.REGION_C_ALLOC | gg.REGION_ANONYMOUS | gg.REGION_C_BSS | gg.REGION_C_DATA | gg.REGION_OTHER)
gg.searchNumber('h ' .. name, gg.TYPE_BYTE, false, gg.SIGN_EQUAL, data[1].start, data[#data]['end'])
if gg.getResultsCount() == 0 then error('the "' .. NameFucntion .. '" function was not found') end
gg.searchNumber('h ' .. string.sub(name,4,5))
local r = gg.getResults(gg.getResultsCount())
gg.clearResults()
for key, value in ipairs(r) do
if gg.BUILD < 16126 then
gg.searchNumber(string.format("%8.8X", fixvalue32(value.address)) .. 'h', Unity.MainType)
else
gg.loadResults({value})
gg.searchPointer(0)
end
local MethodsInfo = gg.getResults(gg.getResultsCount())
gg.clearResults()
for k, v in ipairs(MethodsInfo) do
v.address = v.address - Unity.MethodNameOffset
local FinalAddress = fixvalue32(gg.getValues({v})[1].value)
if (FinalAddress > libil[1].start and FinalAddress < libil[#libil]['end']) then
FinalMethods[#FinalMethods + 1] = {
AddressMethod = FinalAddress,
Address = v.address
}
end
end
end
if (#FinalMethods == 0) then error('the "' .. NameFucntion .. '" function pointer was not found') end
return FinalMethods
end
function addresspath(StartAddress, ...)
args = {...}
for i = 1,#args do
StartAddress = i ~= 1 and StartAddress + 0x4 or StartAddress
setupValues(StartAddress,args[i])
end
end
function GetRegionValue(address)
return gg.getValuesRange({address})[1]
end
function StringToTable(s)
rTable = {}
for str in string.gmatch(s,".") do
for k,v in pairs(Utf16) do
rTable[#rTable + 1] = v == str and k or nil
end
end
return rTable
end
function EditTableLink(t)
for k,v in pairs(t) do
if type(v) ~= 'number' then t[k] = v.value end
end
return t
end
function lpairs(...)
return (
function(t,key)
return table.unpack(setmetatable({next(t, key)},{
__add = function (self,value)
self[3] = value
return self
end
}) + #t)
end
), ..., nil
end
function GetAddressMemory(startAddress, add)
local localPageMemory = ((pageMemory == 0) or (((pageMemory & 0xFFF) + add) > 3500)) and gg.allocatePage(gg.PROT_READ | gg.PROT_WRITE, startAddress) or pageMemory
pageMemory = localPageMemory + add
return localPageMemory
end
function fixvalue32(value)
return platform and value & 0x00FFFFFFFFFFFFFF or value & 0xFFFFFFFF
end
function MyLenTable(t)
local ret = 0
for k,v in pairs(t) do ret = ret + 1 end
return ret
end
function DataCheck(address)
return (fixvalue32(address) > fixvalue32(data[1].start) and fixvalue32(address) < fixvalue32(data[1]['end']))
end
function PatchByteCodes(add, Bytescodes)
local patch = {}
for code in string.gmatch(Bytescodes, '.') do
patch[#patch + 1] = {
address = add,
value = string.byte(code),
flags = gg.TYPE_BYTE
}
add = add + 1
end
gg.setValues(patch)
end
---@param Address number
ReadCompressedUInt32 = function(Address)
local val, offset = 0, 0
local read = gg.getValues(
{
{ -- [1]
address = Address,
flags = gg.TYPE_BYTE
},
{ -- [2]
address = Address + 1,
flags = gg.TYPE_BYTE
},
{ -- [3]
address = Address + 2,
flags = gg.TYPE_BYTE
},
{ -- [4]
address = Address + 3,
flags = gg.TYPE_BYTE
}
})
local read1 = read[1].value & 0xFF
offset = 1
if (read1 & 0x80) == 0 then
val = read1
elseif (read1 & 0xC0) == 0x80 then
val = (read1 & ~0x80) << 8
val = val | (read[2].value & 0xFF)
offset = offset + 1
elseif (read1 & 0xE0) == 0xC0 then
val = (read1 & ~0xC0) << 24
val = val | ((read[2].value & 0xFF) << 16)
val = val | ((read[3].value & 0xFF) << 8)
val = val | (read[4].value & 0xFF)
offset = offset + 3
elseif read1 == 0xF0 then
val = gg.getValues(
{
{
address = Address + 1,
flags = gg.TYPE_DWORD
}
})[1].value
offset = offset + 4
elseif read1 == 0xFE then
val = 0xffffffff - 1
elseif read1 == 0xFF then
val = 0xffffffff
end
return val, offset
end
---@param Address number
ReadCompressedInt32 = function(Address)
local encoded, offset = ReadCompressedUInt32(Address)
if encoded == 0xffffffff then
return -2147483647 - 1
end
local isNegative = (encoded & 1) == 1
encoded = encoded >> 1
if isNegative then
return -(encoded + 1)
end
return encoded, offset
end
Unity = {
ClassNameOffset = platform and 0x10 or 0x8,
ClassNameSpaceOffset = platform and 0x18 or 0xC,
StaticFieldsOffset = platform and 0xB8 or 0x5C,
ParentOffset = platform and 0x58 or 0x2C,
NumFields = platform and 0x120 or 0xA8,
FieldsLink = platform and 0x80 or 0x40,
FieldsStep = platform and 0x20 or 0x14,
FieldsOffset = platform and 0x18 or 0xC,
TypeMetadataHandle = platform and 0x68 or 0x34,
MethodClassOffset = platform and 0x18 or 0xC,
MethodNameOffset = platform and 0x10 or 0x8,
MainType = platform and gg.TYPE_QWORD or gg.TYPE_DWORD,
GetClass = function(self, ClassName)
gg.clearResults()
gg.setRanges(0)
gg.setRanges(gg.REGION_C_HEAP | gg.REGION_C_HEAP | gg.REGION_ANONYMOUS | gg.REGION_C_BSS | gg.REGION_C_DATA | gg.REGION_OTHER | gg.REGION_C_ALLOC)
gg.searchNumber(string.format("Q 00 '%s' 00", ClassName), gg.TYPE_BYTE, false, gg.SIGN_EQUAL,data[1].start,data[1]['end'])
gg.searchPointer(0)
local res = gg.getResults(gg.getResultsCount())
gg.clearResults()
if (#res > 1) then
for k,v in ipairs(res) do
local assembly = gg.getValues({{address = v.address - Unity.ClassNameOffset,flags = v.flags}})[1].value
if Unity.Utf8ToString(gg.getValues({{address = assembly,flags = v.flags}})[1].value):find(".dll") then
if (self.Check) then
if (self:Check(v)) then
res[1] = v
end
else
res[1] = v
end
end
end
end
if not self.ClassLoad then self:SetFields(res[1].address - Unity.ClassNameOffset) end
return res[1]
end,
LoadEnum = function(self)
local ClassName = GetNameTableInGlobalSpace(self)
gg.clearResults()
gg.setRanges(0)
gg.setRanges(gg.REGION_C_HEAP | gg.REGION_C_HEAP | gg.REGION_ANONYMOUS | gg.REGION_C_BSS | gg.REGION_C_DATA | gg.REGION_OTHER | gg.REGION_C_ALLOC)
gg.searchNumber("Q 00 '" .. ClassName .. "' 00",gg.TYPE_BYTE,false,gg.SIGN_EQUAL,data[1].start,data[1]['end'])
gg.searchNumber("Q '" .. ClassName .. "' ")
gg.searchPointer(0)
local res = gg.getResults(gg.getResultsCount())
gg.clearResults()
if (#res > 1) then
for k,v in ipairs(res) do
local assembly = gg.getValues({{address = v.address - Unity.ClassNameOffset,flags = v.flags}})[1].value
if Unity.Utf8ToString(gg.getValues({{address = assembly,flags = v.flags}})[1].value):find(".dll") then res[1] = v end
end
end
if not self.ClassLoad then self:SetConstFields(res[1].address - Unity.ClassNameOffset) end
end,
GetStartLibAddress = function(Address)
local start = 0
for k,v in ipairs(libil) do
if (fixvalue32(Address) > fixvalue32(v.start) and fixvalue32(Address) < fixvalue32(v['end'])) then start = v.start end
end
return start
end,
FilterObject = function (Instances)
gg.clearResults()
gg.loadResults(Instances)
gg.searchPointer(0)
if gg.getResultsCount() <= 0 and platform and sdk >= 30 then
local FixInstances = {}
for k,v in ipairs(Instances) do
v.address = v.address | 0xB400000000000000
gg.searchNumber(tostring(v.address | 0xB400000000000000), gg.TYPE_QWORD)
local RefToObject = gg.getResults(gg.getResultsCount())
RefToObject:move(1, #RefToObject, #FixInstances + 1, FixInstances)
gg.clearResults()
end
gg.loadResults(FixInstances)
end
local r, FilterInstances = gg.getResults(gg.getResultsCount()), {}
for k,v in ipairs(gg.getValuesRange(r)) do
FilterInstances[#FilterInstances + 1] = v == 'A' and {address = fixvalue32(r[k].value), flags = r[k].flags} or nil
end
gg.clearResults()
gg.loadResults(FilterInstances)
FilterInstances = gg.getResults(gg.getResultsCount())
gg.clearResults()
return FilterInstances
end,
GetInstance = function(self)
local Instances, ClassName = {}, GetNameTableInGlobalSpace(self)
local MemClass = self:GetClass(ClassName)
gg.loadResults({MemClass})
gg.searchPointer(self.ClassNameOffset)
if gg.getResultsCount() <= 0 and platform and sdk >= 30 then
gg.searchNumber(tostring(MemClass.address - self.ClassNameOffset | 0xB400000000000000), gg.TYPE_QWORD)
end
local r = gg.getResults(gg.getResultsCount())
for k,v in ipairs(gg.getValuesRange(r)) do
Instances[#Instances + 1] = v == 'A' and r[k] or nil
end
Instances = self.FilterObject(Instances)
-- print(ClassName .. ' -> ' .. #Instances)
gg.toast(lang_main[ClassName] or "")
gg.clearResults()
return Instances
end,
GetLocalInstance = function(self)
local Instances, ClassName = {}, GetNameTableInGlobalSpace(self)
local MemClass = self:GetClass(ClassName)
local tmp = gg.getValues({{address = MemClass.address - self.ClassNameOffset + self.StaticFieldsOffset,flags = MemClass.flags}})
table.move(gg.getValues({{address = tmp[1].value,flags = tmp[1].flags}}),1,1,#Instances + 1,Instances)
gg.toast(lang_main[ClassName] or "")
gg.clearResults()
return Instances
end,
GetParentLocalInstance = function(self)
local Instances, ClassName = {}, GetNameTableInGlobalSpace(self)
local MemClass = self:GetClass(ClassName)
local tmp = gg.getValues({{address = MemClass.address - self.ClassNameOffset + self.ParentOffset,flags = MemClass.flags}})[1].value
tmp = gg.getValues({{address = tmp + self.StaticFieldsOffset,flags = MemClass.flags}})
table.move(gg.getValues({{address = tmp[1].value,flags = tmp[1].flags}}),1,1,#Instances + 1,Instances)
gg.toast(lang_main[ClassName] or "")
gg.clearResults()
return Instances
end,
Utf8ToString = function(Address)
local chars, char = {}, {
address = fixvalue32(Address),
flags = gg.TYPE_BYTE
}
repeat
_char = string.char(gg.getValues({char})[1].value & 0xFF)
chars[#chars + 1] = _char
char.address = char.address + 0x1
until string.find(_char, "[%z%s]")
return table.concat(chars, "", 1, #chars - 1)
end,
Utf16ToString = function(Address)
local bytes, strAddress = {}, fixvalue32(Address) + (platform and 0x10 or 0x8)
local num = gg.getValues({{address = strAddress,flags = gg.TYPE_DWORD}})[1].value
if num > 0 and num < 200 then
for i = 1, num + 1 do
bytes[#bytes + 1] = {address = strAddress + (i << 1), flags = gg.TYPE_WORD}
end
end
return #bytes > 0 and tostring(setmetatable(gg.getValues(bytes), {
__tostring = function(self)
local code = {[[return "]]}
for i, v in ipairs(self) do
code[#code + 1] = string.format([[\u{%x}]], v.value & 0xFFFF)
end
code[#code + 1] = '"'
local read, err = load(table.concat(code))
return read and read() or lang_main.Emtry
end
})) or ""
end,
GetIl2cppFunc = function(...)
local args, RetIl2CppFuncs = {...}, {}
if args[1] == nil or args[1] == "" or args[1] == " " then return {},"you didn't enter the function" end
for keyname,namefucntion in ipairs(args) do
local finaladdres = Il2CppName(namefucntion)
for k,v in pairs(finaladdres) do
if (k ~= 'Error') then
local AddressClass = fixvalue32(gg.getValues({{address = v.Address + Unity.MethodClassOffset,flags = Unity.MainType}})[1].value)
RetIl2CppFuncs[#RetIl2CppFuncs + 1] = {
NameFucntion = namefucntion,
Offset = string.format("%X",v.AddressMethod - Unity.GetStartLibAddress(v.AddressMethod)),
AddressInMemory = string.format("%X",v.AddressMethod),
AddressOffset = v.Address,
Class = Unity.Utf8ToString(gg.getValues({{address = AddressClass + Unity.ClassNameOffset,flags = Unity.MainType}})[1].value),
ClassAddress = string.format('%X', AddressClass)
}
else
RetIl2CppFuncs[#RetIl2CppFuncs + 1] = {
NameFucntion = namefucntion,
Error = v
}
end
end
end
return RetIl2CppFuncs,'true'
end,
GetDefaultValue = function(self, index)
local consts = gg.getValues({
{
address = data[1].start + 0x40,
flags = gg.TYPE_DWORD
},
{
address = data[1].start + 0x44,
flags = gg.TYPE_DWORD
},
{
address = data[1].start + 0x48,
flags = gg.TYPE_DWORD
}
})
gg.clearResults()
gg.setRanges(0)
gg.setRanges(gg.REGION_C_HEAP | gg.REGION_C_HEAP | gg.REGION_ANONYMOUS | gg.REGION_C_BSS | gg.REGION_C_DATA | gg.REGION_OTHER | gg.REGION_C_ALLOC)
gg.searchNumber(
tostring(index),
gg.TYPE_DWORD,
false,
gg.SIGN_EQUAL,
data[1].start + consts[1].value,
data[1].start + consts[1].value + consts[2].value
)
if gg.getResultsCount() > 0 then
local Il2CppFieldDefaultValue = gg.getResults(1)
gg.clearResults()
local dataIndex = gg.getValues({{address = Il2CppFieldDefaultValue[1].address + 8, flags = gg.TYPE_DWORD}})[1].value
local val = ReadCompressedInt32(dataIndex + data[1].start + consts[3].value)
return val
end
return nil
end,
From = function (self, a)
if not self.ClassLoad then self:SetFields(gg.getValues({{address = fixvalue32(a), flags = Unity.MainType}})[1].value) end
return setmetatable({address = a, mClass = self}, {
__index = function(self, key)
local check = switch((self.address and self.mClass) and (self.mClass[key] and 1 or -1) or 0 , {[0] = 'Не все поля заполнены', [-1] = 'В таблице нет поля ' .. key})
return check and error(check) or ((type(self.mClass[key]) == 'function')
and (function(self, ...) return self.mClass[key](self.mClass, self.address, ...) end)
or self.mClass[key])
end
})
end,
GetNumFields = function(self, ClassAddress)
return gg.getValues({{address = ClassAddress + self.NumFields, flags = gg.TYPE_WORD}})[1].value
end,
GetLinkFields = function(self, ClassAddress)
return gg.getValues({{address = ClassAddress + self.FieldsLink, flags = Unity.MainType}})[1].value
end,
SetFields = function(self, AddressClass)
AddressClass = fixvalue32(AddressClass)
self.ClassLoad = true
local FieldsCount, FieldsLink = self:GetNumFields(AddressClass), fixvalue32(self:GetLinkFields(AddressClass))
for i = 1, FieldsCount do
local field = FieldsLink + ((i-1) * self.FieldsStep)
local fieldInfo = gg.getValues({
{--NameField
address = field,
flags = Unity.MainType
},
{--Offset
address = field + self.FieldsOffset,
flags = gg.TYPE_WORD
},
})
self.Fields[self.Utf8ToString(fixvalue32(fieldInfo[1].value))] = fieldInfo[2].value
end
end,
SetConstFields = function(self, AddressClass)
AddressClass = fixvalue32(AddressClass)
self.ClassLoad = true
local ClassChar = gg.getValues({
{
address = AddressClass + self.NumFields,
flags = gg.TYPE_WORD
},
{
address = AddressClass + self.FieldsLink,
flags = Unity.MainType
},
{
address = AddressClass + self.TypeMetadataHandle,
flags = Unity.MainType
}
})
local FieldsLink = fixvalue32(ClassChar[2].value)
local fieldStart = gg.getValues({{address = fixvalue32(ClassChar[3].value) + 0x20, flags = gg.TYPE_DWORD}})[1].value
for i = 1, ClassChar[1].value do
local field = FieldsLink + ((i-1) * self.FieldsStep)
local fieldInfo = gg.getValues({
{--NameField
address = field,
flags = Unity.MainType
},
{--Offset
address = field + self.FieldsOffset,
flags = gg.TYPE_WORD
},
})
local fieldIndex = i + fieldStart - 1
local offsetField = fieldInfo[2].value
self.Fields[self.Utf8ToString(fixvalue32(fieldInfo[1].value))] = offsetField > 0
and nil
or self:GetDefaultValue(i + fieldStart - 1)
end
end,
}
function SetUnityClass(t)
t.ClassLoad = false
t.Fields = {}
return setmetatable(t,{__index = Unity})
end
function SetSubClass(SubClass, MainClass)
return setmetatable(SubClass, {__index = MainClass})
end
EnumClass = {
From = function (self, a)
return setmetatable({address = fixvalue32(a), mClass = self}, {
__index = function(self, key)
local check = switch((self.address and self.mClass) and (self.mClass[key] and 1 or -1) or 0 , {[0] = 'Не все поля заполнены', [-1] = 'В таблице нет поля ' .. key})
return check and error(check) or ((type(self.mClass[key]) == 'function')
and (function(self, ...) return self.mClass[key](self.mClass, self.address, ...) end)
or self.mClass[key])
end
})
end
}
function SetEnumClass(t)
return setmetatable(t, {__index = EnumClass})
end
List = SetEnumClass({
num = platform and 0x18 or 0xC,
link = platform and 0x10 or 0x8,
})
function List:GetNumItem(list)
return gg.getValues({{address = list + self.num, flags = gg.TYPE_DWORD}})[1].value
end
function List:SetNumItem(list,n)
gg.setValues({
{address = list + self.num,flags = gg.TYPE_DWORD,value = n},
{address = list + self.num + 0x4,flags = gg.TYPE_DWORD,value = n}
})
end
function List:GetLink(list)
return gg.getValues({{address = list + self.link,flags = platform and gg.TYPE_QWORD or gg.TYPE_DWORD}})[1].value
end
function List:SetLink(list,link)
gg.setValues({{address = list + self.link,flags = platform and gg.TYPE_QWORD or gg.TYPE_DWORD,value = link}})
end
List['int'] = SetSubClass({
ElementToTable = function(tabl)
local resTab = {}
for k,v in ipairs(tabl) do
resTab[#resTab + 1] = type(v) ~= 'number' and v.value or v
end
return resTab
end,
EditList = function(self, list, newTable, saveOld)
local MainTable, MainHead, num = {}, 0, List:GetNumItem(list)
if (not (num < 0)) and num < 200 then
local link = List:GetLink(list)
MainHead = gg.getValues({{address = link, flags = platform and gg.TYPE_QWORD or gg.TYPE_DWORD}})[1].value
if (saveOld) then table.move(self.ElementToTable(Massiv:GetAllElement(link, 'int')), 1, num, #MainTable + 1, MainTable) end
table.move(newTable, 1, #newTable, #MainTable + 1, MainTable)
self:SetNumItem(list, #MainTable)
self:SetLink(list, Massiv:CreateMassiv(list, MainHead, 'int', MainTable))
end
end
}, List)
List['string'] = SetSubClass({
subType = 'char',
mainType = 'link',
EditList = function(self, list, newTable, saveOld, IsNewTableLink)
local MainTable, MainHead, SubHead, num = {}, 0, 0, List:GetNumItem(list)
if num > 0 and num < 200 then
local link = List:GetLink(list)
MainHead = gg.getValues({{address = link, flags = platform and gg.TYPE_QWORD or gg.TYPE_DWORD}})[1].value
table.move(Massiv:GetAllElement(link, self.mainType),1,num,#MainTable + 1,MainTable)
for _,val in pairs(MainTable) do
if (val.value ~= 0 and SubHead == 0) then
SubHead = gg.getValues({{address = val.value , flags = val.flags}})[1].value
end
end
end
if SubHead ~= 0 then
MainTable = saveOld and EditTableLink(MainTable) or {}
if not IsNewTableLink then
for i = 1, #newTable do
local addTable = StringToTable(newTable[i])
MainTable[#MainTable + 1] = Massiv:CreateMassiv(list, SubHead, self.subType, addTable)
end
else
newTable = EditTableLink(newTable)
table.move(newTable, 1, #newTable, #MainTable + 1, MainTable)
end
self:SetNumItem(list,#MainTable)
self:SetLink(list,Massiv:CreateMassiv(list,MainHead,self.mainType,MainTable))
end
end,
EditIndexList = function(self, list, index, str)
local MainTable, SubHead, num, link = {}, 0, self:GetNumItem(list), self:GetLink(list)
if num > 0 and num < 200 then
table.move(Massiv:GetAllElement(link, self.mainType),1,num,#MainTable + 1,MainTable)
for _,val in pairs(MainTable) do
if (val.value ~= 0 and SubHead == 0) then
SubHead = gg.getValues({{address = val.value, flags = val.flags}})[1].value
end
end
end
if SubHead ~= 0 then
str = StringToTable(str)
Massiv:SetElement(link, Massiv:CreateMassiv(list, SubHead, self.subType, str), self.mainType, index)
end
end,
Filter = function(t)
for k,v in pairs(t) do
t[k] = v.value == 0 and lang_main.Emtry or Unity.Utf16ToString(v.value)
end
return t
end,
GetList = function(self, list)
local num, resTab = self:GetNumItem(list), {}
if num > 0 and num < 200 then
resTab = Massiv:GetAllElement(self:GetLink(list), 'link')
resTab = self.Filter(resTab)
end
return resTab
end
},List)
Massiv = SetEnumClass({
GetElementCount = function(self,link,T)
return gg.getValues({{address = link + self[T].firstStep,flags = gg.TYPE_DWORD}})[1].value
end,
['int'] = {
firstStep = platform and 0x18 or 0xC,
step = 0x4,
size = gg.TYPE_DWORD,
skip = platform and 0x4 or 0,
},
['link'] = {
firstStep = platform and 0x18 or 0xC,
step = platform and 0x8 or 0x4,
size = platform and gg.TYPE_QWORD or gg.TYPE_DWORD,
skip = 0,
},
['char'] = {
firstStep = platform and 0x10 or 0x8,
step = 0x2,
size = gg.TYPE_WORD,
skip = 0x2,
}
})
-- Lua Table to C# Massiv
function Massiv:CreateMassiv(address,head,T,Mtable)
local SizeMassiv = #Mtable
local SizeInMemory = self[T].firstStep + (self[T].step * (SizeMassiv % 2 > 0 and SizeMassiv + 1 or SizeMassiv)) + 0x8
local addressInMemory = GetAddressMemory(address, SizeInMemory)
local SetMass = {
{
address = addressInMemory,
value = head,
flags = platform and gg.TYPE_QWORD or gg.TYPE_DWORD,
},
{
address = addressInMemory + self[T].firstStep,
flags = gg.TYPE_DWORD,
value = SizeMassiv
}
}
for i = 1, SizeMassiv do
SetMass[#SetMass + 1] = {
address = addressInMemory + self[T].firstStep + self[T].skip + (self[T].step * i),
flags = self[T].size,
value = Mtable[i]
}
end
gg.setValues(SetMass)
return addressInMemory
end
function Massiv:SetAllElement(link, value, T)
local count = self:GetElementCount(link,T)
local MassivItem = {}
for i = 1,count do
MassivItem[#MassivItem + 1] = {
address = link + self[T].firstStep + self[T].skip + (self[T].step * i),
flags = self[T].size,
value = value
}
end
gg.setValues(MassivItem)
end
function Massiv:SetElement(link, value, T, index)
local MassivItem = {
[1] = {
address = link + self[T].firstStep + self[T].skip + (self[T].step * index),
flags = self[T].size,
value = value
}
}
gg.setValues(MassivItem)
end
function Massiv:GetAllElement(link, T)
local count = Massiv:GetElementCount(link, T)
local MassivItem = {}
for i = 1,count do
MassivItem[#MassivItem + 1] = {
address = link + self[T].firstStep + self[T].skip + (self[T].step * i),
flags = self[T].size,
}
end
return gg.getValues(MassivItem)
end
Dictionary = SetEnumClass({
num = platform and 0x20 or 0x10,
link = platform and 0x18 or 0xC,
string = {
keySize = platform and 0x8 or 0x4,
int = {
valueSize = 0x4,
missKey = platform and 0x10 or 0xC,
firstStep = platform and 0x18 or 0xC,
step = platform and 0x18 or 0x10
},
struct = {
missKey = platform and 0x10 or 0xC,
firstStep = platform and 0x18 or 0xC,
step = platform and 0x18 or 0x10
}
},
int = {
keySize = 0x4,
int = {
skip = platform and 0x4 or 0,
valueSize = 0x4,
firstStep = platform and 0x18 or 0xC,
step = platform and 0x14 or 0x10,
missKey = 0xC,
hashCode = 0x4,
next = 0x8,
key = 0xC,
value = 0x10,
size = 0x10
}
}
})
function Dictionary:HasKey(dic, key)
local d = Dictionary:GetAllItemIntInt(dic)
return d[key] ~= nil, d
end
function Dictionary:GetAllItemIntInt(dic)
local link, num, tab = self:GetLink(dic), self:GetNumItem(dic), {}