-
Notifications
You must be signed in to change notification settings - Fork 29
/
script.js
1454 lines (1349 loc) · 64.1 KB
/
script.js
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
var moduleBase;
var appId;
var GUObjectArray;
var GName;
var nameIds = [];
var enumClasses = [];
var enumClassStr = "";
var platform = Process.platform;
var arch = Process.arch;
var isBeforeUE425 = false;
var isActorDump = false;
var processInternal_offset = null;
var processEvent_offset = null;
var processEvent = null;
var doHookProcessEvent = false;
var processEventFilterOutRegex;
var O_RDONLY = 0;
var SEEK_SET = 0;
var open = new NativeFunction(Module.findExportByName(null, "open"), "int", ["pointer", "int", "int"])
var close = new NativeFunction(Module.findExportByName(null, "close"), "int", ["int"]);
var lseek = new NativeFunction(Module.findExportByName(null, "lseek"), "int", ["int", "int", "int"]);
var read = new NativeFunction(Module.findExportByName(null, "read"), "int", ["int", "pointer", "int"]);
// Global
var FUObjectItemPadd = 0x0;
var FUObjectItemSize = 0x18;
// SDK
var offset_FUObjectArray_TUObjectArray = 0x10;
var offset_TUObjectArray_NumElements = 0x14;
// FNamePool
var FNameStride = 0x2
var offset_GName_FNamePool = platform == "linux" ? 0x30 : 0xc0;
var offset_FNamePool_CurrentBlock = 0x8;
var offset_FNamePool_CurrentByteCursor = 0xc;
var offset_FNamePool_Blocks = 0x10;
// FNameEntry
var offset_FNameEntry_Info = 0;
var FNameEntry_LenBit = 6;
var offset_FNameEntry_String = 0x2;
//Class: UObject
var offset_UObject_InternalIndex = 0xC;
var offset_UObject_ClassPrivate = 0x10;
var offset_UObject_FNameIndex = 0x18;
var offset_UObject_OuterPrivate = 0x20;
//Class: UField
var offset_UField_Next = 0x28;
//Class: UStruct
var offset_UStruct_SuperStruct = 0x40;
var offset_UStruct_Children = 0x48;
var offset_UStruct_ChildProperties = 0x50;
//Class: FField
var offset_FField_Class = 0x8;
var offset_FField_Next = 0x20;
var offset_FField_Name = 0x28;
//Class: UEnum
var offset_UENum_Names = null;
var offset_UENum_Count = null;
var offset_UENum_Max = null;
var enumItemSize = null;
//Class: UFunction
var offset_UFunction_FunctionFlags = 0xb0;
var offset_UFunction_Func = offset_UFunction_FunctionFlags + 0x28;
//Class: UProperty (FProperty in UE4.25+)
var offset_UProperty_ElementSize = 0x38;
var offset_UProperty_PropertyFlags = 0x40;
var offset_UProperty_OffsetInternal = 0x4c;
var offset_UProperty_size = 0x78;
//Class: UBoolProperty
var offset_UBoolProperty_FieldSize = null;
var offset_UBoolProperty_ByteOffset = null;
var offset_UBoolProperty_ByteMask = null;
var offset_UBoolProperty_FieldMask = null;
//Class: UObjectProperty
var offset_UObjectProperty_PropertyClass = null;
//Class: UClassProperty
var offset_UClassProperty_MetaClass = null;
//Class: UInterfaceProperty
var offset_UInterfaceProperty_InterfaceClass = null;
//Class: UArrayProperty
var offset_UArrayProperty_InnerProperty = null;
//Class: UMapProperty
var offset_UMapProperty_KeyProp = null;
var offset_UMapProperty_ValueProp = null;
//Class: USetProperty
var offset_USetProperty_ElementProp = null;
//Class: UStructProperty
var offset_UStructProperty_Struct = null;
//Class: UEnumProperty
var offset_UEnumProperty_EnumClass = null;
//Class: UWorld
var offset_UWorld_PersistentLevel = 0x30;
//Class: ULevel
var offset_ULevel_AActors = 0x98;
var offset_ULevel_AActorsCount = 0xA0;
function setOffsetProperty(offset_UProperty_size) {
offset_UBoolProperty_FieldMask = offset_UProperty_size + 0x3
offset_UBoolProperty_ByteMask = offset_UBoolProperty_FieldMask - 0x1;
offset_UBoolProperty_ByteOffset = offset_UBoolProperty_ByteMask - 0x1;
offset_UBoolProperty_FieldSize = offset_UBoolProperty_ByteOffset - 0x1;
offset_UObjectProperty_PropertyClass = offset_UProperty_size;
offset_UClassProperty_MetaClass = offset_UProperty_size + Process.pointerSize;
offset_UInterfaceProperty_InterfaceClass = offset_UProperty_size;
offset_UArrayProperty_InnerProperty = offset_UProperty_size;
offset_UMapProperty_KeyProp = offset_UProperty_size;
offset_UMapProperty_ValueProp = offset_UProperty_size + Process.pointerSize;
offset_USetProperty_ElementProp = offset_UProperty_size;
offset_UStructProperty_Struct = offset_UProperty_size;
offset_UEnumProperty_EnumClass = offset_UProperty_size + Process.pointerSize;
}
function setOffset(appId) {
// Mortal Kombat(Android) offsets from AndUE4Dumper(https://github.com/MJx0/AndUE4Dumper)
if (appId === "com.wb.goog.mkx") { // UE 4.27.2
// FNamePool
FNameStride = 0x4
// FNameEntry
offset_FNameEntry_Info = 0x4;
FNameEntry_LenBit = 1;
offset_FNameEntry_String = 0x6;
//Class: UField
offset_UField_Next = 0x30;
//Class: UObject
offset_UObject_OuterPrivate = 0x28;
//Class: UStruct
offset_UStruct_SuperStruct = 0x48;
offset_UStruct_Children = 0x50;
offset_UStruct_ChildProperties = 0x58;
//Class: UFunction
offset_UFunction_FunctionFlags = 0xb8;
offset_UFunction_Func = offset_UFunction_FunctionFlags + 0x28;
//Class: UProperty
offset_UProperty_ElementSize = 0x3c;
offset_UProperty_size = 0x80;
//UEnum
offset_UENum_Names = 0x48;
offset_UENum_Count = offset_UENum_Names + Process.pointerSize;
offset_UENum_Max = offset_UENum_Count + 0x4;
enumItemSize = 0x18;
setOffsetProperty(offset_UProperty_size);
} else if (appId === "com.vividgames.realboxing2" || appId === "com.kakaogames.odin" || appId === "com.kakaogames.twodin") { // Real Boxing 2, Odin Vahalla Rising. UE4.24.3
isBeforeUE425 = true;
//Class: UStruct
offset_UStruct_SuperStruct = 0x40;
offset_UStruct_Children = 0x48;
// no need before UE4.25
offset_UStruct_ChildProperties = 0x0;
//Class: UFunction
offset_UFunction_FunctionFlags = 0x98;
offset_UFunction_Func = offset_UFunction_FunctionFlags + 0x28;
//Class: UProperty
offset_UProperty_ElementSize = 0x34;
offset_UProperty_PropertyFlags = 0x38;
offset_UProperty_OffsetInternal = 0x44;
offset_UProperty_size = 0x70;
//UEnum
offset_UENum_Names = 0x40;
offset_UENum_Count = offset_UENum_Names + Process.pointerSize;
offset_UENum_Max = offset_UENum_Count + 0x4;
enumItemSize = 0x10;
setOffsetProperty(offset_UProperty_size);
} else if (appId === "com.farlightgames.xgame.gp.kr") { // Dislyte(Android) from AndUE4Dumper(https://github.com/MJx0/AndUE4Dumper)
isBeforeUE425 = true;
//Class: UStruct
offset_UStruct_SuperStruct = 0x40;
offset_UStruct_Children = 0x48;
offset_UStruct_ChildProperties = 0x0;
//Class: UFunction
offset_UFunction_FunctionFlags = 0x98;
offset_UFunction_Func = offset_UFunction_FunctionFlags + 0x28;
//Class: UProperty
offset_UProperty_ElementSize = 0x34;
offset_UProperty_PropertyFlags = 0x38;
offset_UProperty_OffsetInternal = 0x44;
offset_UProperty_size = 0x70;
//UEnum
offset_UENum_Names = 0x40;
offset_UENum_Count = offset_UENum_Names + Process.pointerSize;
offset_UENum_Max = offset_UENum_Count + 0x4;
enumItemSize = 0x10;
setOffsetProperty(offset_UProperty_size);
} else if (appId === 'com.farlightgames.farlight84.iosglobal' || appId === 'com.miraclegames.farlight84' || appId === 'com.proximabeta.mf.uamo' || appId === 'com.tencent.mf.uam' || appId === 'com.wemade.nightcrows' || appId === 'com.ncsoft.lineagew' || appId === 'com.netease.octopath.kr' || appId === 'com.xd.TLglobal' || appId === 'com.vic.bc.kr' || appId ==='com.vic.bc.jp' || appId === "com.perfect.tof.gp" || appId === "com.tof.ios" || appId === 'com.netmarble.arthdal' || appId === 'com.kakaogames.archewar') { // farlight 84(UE 4.25.3), Arena Breakout(kr, cn)(UE 4.26.1), Night Crows, LineageW, octopath traveler(UE 4.26.2), torchlight infinite(UE 4.26.2), Black Clover Mobile(kr, jp)(UE 4.27.2), Tower of Fantasy, Arthdal Chronicles(UE 4.27.1), ArcheAge War
//UEnum
offset_UENum_Names = 0x40;
offset_UENum_Count = offset_UENum_Names + Process.pointerSize;
offset_UENum_Max = offset_UENum_Count + 0x4;
enumItemSize = 0x10;
setOffsetProperty(offset_UProperty_size);
} else if (appId === 'com.netease.ma100asia' || appId === 'com.netease.dbdena' || appId === 'com.kurogame.wutheringwaves.global') { // Dead by Daylight(UE 4.27.2), Wuthering Waves(UE 4.26.2)
// FNamePool
FNameStride = 0x4
// FNameEntry
offset_FNameEntry_Info = 0x4;
FNameEntry_LenBit = 1;
offset_FNameEntry_String = 0x6;
//Class: UField
offset_UField_Next = 0x30;
//Class: UStruct
offset_UStruct_SuperStruct = 0x48;
offset_UStruct_Children = 0x50;
offset_UStruct_ChildProperties = 0x58;
//Class: UFunction
offset_UFunction_FunctionFlags = 0xb8;
offset_UFunction_Func = offset_UFunction_FunctionFlags + 0x28;
//Class: UProperty
offset_UProperty_ElementSize = 0x3c;
offset_UProperty_PropertyFlags = 0x40;
offset_UProperty_OffsetInternal = 0x4c;
offset_UProperty_size = 0x80;
//UEnum
offset_UENum_Names = 0x48;
offset_UENum_Count = offset_UENum_Names + Process.pointerSize;
offset_UENum_Max = offset_UENum_Count + 0x4;
enumItemSize = 0x18;
setOffsetProperty(offset_UProperty_size);
} else if (appId === 'com.GreenGoGames.RooftopPrakourFreerun') { // Rooftops Parkour Freerun (UE 5.4.2)
//Class: FField
offset_FField_Class = 0x8;
offset_FField_Next = 0x18;
offset_FField_Name = 0x20;
//Class: UProperty
offset_UProperty_ElementSize = 0x30;
offset_UProperty_PropertyFlags = 0x38;
offset_UProperty_OffsetInternal = 0x44;
offset_UProperty_size = 0x70;
//UEnum
offset_UENum_Names = 0x40;
offset_UENum_Count = offset_UENum_Names + Process.pointerSize;
offset_UENum_Max = offset_UENum_Count + 0x4;
enumItemSize = 0x10;
setOffsetProperty(offset_UProperty_size);
offset_UArrayProperty_InnerProperty = offset_UProperty_size + Process.pointerSize;
} else { // default
setOffsetProperty(offset_UProperty_size);
}
}
var UObject = {
getClass: function(obj) {
var classPrivate = ptr(obj).add(offset_UObject_ClassPrivate).readPointer();
// console.log(`classPrivate: ${classPrivate}`);
return classPrivate;
},
getNameId: function(obj) {
// console.log(`obj: ${obj}`);
try {
var nameId = ptr(obj).add(offset_UObject_FNameIndex).readU32();
// console.log(`nameId: ${nameId}`);
return nameId;
} catch(e) {
return 0;
}
},
getName: function(obj) {
if (this.isValid(obj)){
return getFNameFromID(this.getNameId(obj));
} else {
return "None";
}
},
getClassName: function(obj) {
if (this.isValid(obj)) {
var classPrivate = this.getClass(obj);
return this.getName(classPrivate);
} else {
return "None";
}
},
isValid: function(obj) {
var isValid = (ptr(obj) > 0 && this.getNameId(obj) > 0 && this.getClass(obj) > 0);
// console.log(`isValid: ${isValid}`);
return isValid;
}
}
var UField = {
getNext: function(field) {//UField*
// console.log(`field: ${field}`);
return field.add(offset_UField_Next).readPointer();
}
};
var FField = {
getName: function(fField) {
return getFNameFromID(fField.add(offset_FField_Name).readU32());
},
getClassName: function(fField) {
return getFNameFromID(fField.add(offset_FField_Class).readPointer().readU32());
},
getNext: function(fField) {//UField*
return fField.add(offset_FField_Next).readPointer();
}
};
var UStruct = {
getSuperClass: function(structz) {//UStruct*
// console.log(`UStruct.getSuperClass structz: ${structz}`);
return structz.add(offset_UStruct_SuperStruct).readPointer()
},
getChildren: function(structz) {//UField*
// console.log(`UStruct.getChildren structz: ${structz}`);
return structz.add(offset_UStruct_Children).readPointer();
},
getChildProperties: function(structz) {//UField*
// console.log(`UStruct.getChildProperties structz: ${structz}`);
return structz.add(offset_UStruct_ChildProperties).readPointer();
},
getClassName: function(clazz) {
return UObject.getName(clazz);
},
getClassPath: function(object) {
var clazz = UObject.getClass(object);
var classname = UObject.getName(clazz);
var superclass = this.getSuperClass(clazz);
while (UObject.isValid(superclass)) {
classname += ".";
classname += UObject.getName(superclass);
superclass = this.getSuperClass(superclass);
}
return classname;
},
getStructClassPath: function(clazz) {
var classname = UObject.getName(clazz);
var superclass = this.getSuperClass(clazz);
while (UObject.isValid(superclass)) {
// console.log(`superclass: ${superclass}`)
classname += ".";
classname += UObject.getName(superclass);
superclass = this.getSuperClass(superclass);
}
return classname;
}
}
var UFunction = {
getFunctionFlags: function(func) {
return func.add(offset_UFunction_FunctionFlags).readU32();
},
getFunc: function(func) {
// console.log(`func: ${func}`)
return func.add(offset_UFunction_Func).readPointer();
}
};
var UProperty = {
getElementSize: function(prop) {
return prop.add(offset_UProperty_ElementSize).readU32();
},
getPropertyFlags: function(prop) {
return prop.add(offset_UProperty_PropertyFlags).readU64()
},
getOffset: function(prop) {
return prop.add(offset_UProperty_OffsetInternal).readU32();
}
};
var UBoolProperty = {
getFieldSize: function(prop) {
return prop.add(offset_UBoolProperty_FieldSize).readU8();
},
getByteOffset: function(prop) {
// console.log(`prop: ${prop}`)
return prop.add(offset_UBoolProperty_ByteOffset).readU8();
},
getByteMask: function(prop) {
return prop.add(offset_UBoolProperty_ByteMask).readU8();
},
getFieldMask: function(prop) {
return prop.add(offset_UBoolProperty_FieldMask).readU8();
},
};
var UObjectProperty = {
getPropertyClass: function(prop) {//class UClass*
return prop.add(offset_UObjectProperty_PropertyClass).readPointer();
}
};
var UClassProperty = {
getMetaClass: function(prop) {//class UClass*
return prop.add(offset_UClassProperty_MetaClass).readPointer();
}
};
var UInterfaceProperty = {
getInterfaceClass: function(prop) {//class UClass*
return prop.add(offset_UInterfaceProperty_InterfaceClass).readPointer();
}
};
var UArrayProperty = {
getInner: function(prop) {//UProperty*
return prop.add(offset_UArrayProperty_InnerProperty).readPointer();
}
};
var UMapProperty = {
getKeyProp: function(prop) {//UProperty*
return prop.add(offset_UMapProperty_KeyProp).readPointer();
},
getValueProp: function(prop) {//UProperty*
return prop.add(offset_UMapProperty_ValueProp).readPointer();
}
};
var USetProperty = {
getElementProp: function(prop) {//UProperty*
return prop.add(offset_USetProperty_ElementProp).readPointer();
}
};
var UStructProperty = {
getStruct: function(prop) {//UStruct*
return prop.add(offset_UStructProperty_Struct).readPointer();
}
};
var UEnum = {
getNamesArray: function(en) {
return en.add(offset_UENum_Names).readPointer();
},
getCount: function(en) {
return en.add(offset_UENum_Count).readU32();
}
}
var UEnumProperty = {
getEnum: function(prop) {
return prop.add(offset_UEnumProperty_EnumClass).readPointer();
},
getName: function(prop) {
return UObject.getName(this.getEnum(prop));
}
}
var UByteProperty = {
getEnum: function(prop) {
return prop.add(offset_UProperty_size).readPointer();
},
getName: function(prop) {
return UObject.getName(this.getEnum(prop));
}
}
function getFNameFromID(index) {
var Block = index >> 16;
var Offset = index & 65535;
var FNamePool = GName.add(offset_GName_FNamePool);
// console.log(`FNamePool: ${FNamePool}`);
// console.log(`Block: ${Block}`);
var NamePoolChunk = FNamePool.add(offset_FNamePool_Blocks + Block * Process.pointerSize).readPointer();
// console.log(`NamePoolChunk: ${NamePoolChunk}`);
var FNameEntry = NamePoolChunk.add(FNameStride * Offset);
// console.log(`FNameEntry: ${FNameEntry}`);
try {
if (offset_FNameEntry_Info !== 0) {
var FNameEntryHeader = FNameEntry.add(offset_FNameEntry_Info).readU16();
} else {
var FNameEntryHeader = FNameEntry.readU16();
}
} catch(e) {
// console.log(e);
return "";
}
// console.log(`FNameEntryHeader: ${FNameEntryHeader}`);
var str_addr = FNameEntry.add(offset_FNameEntry_String);
// console.log(`str_addr: ${str_addr}`);
var str_length = FNameEntryHeader >> FNameEntry_LenBit;
var wide = FNameEntryHeader & 1;
if (wide) return "widestr";
if (str_length > 0 && str_length < 250) {
var str = str_addr.readUtf8String(str_length);
return str;
} else {
return "None";
}
}
function getUObjectBaseObjectFromId(index) {
var TUObjectArray = GUObjectArray.add(offset_FUObjectArray_TUObjectArray).readPointer();
// console.log(`TUObjectArray: ${TUObjectArray}`)
var chunk = TUObjectArray.add(parseInt(index / 0x10000) * Process.pointerSize);
var FUObjectItemObjects = chunk.readPointer();
// console.log(`FUObjectItemObjects: ${FUObjectItemObjects}`);
var UObjectBaseObject = FUObjectItemObjects.add(FUObjectItemPadd + (index % 0x10000) * FUObjectItemSize).readPointer();
// console.log(`UObjectBaseObject: ${UObjectBaseObject}`);
return UObjectBaseObject;
}
function resolveProp(recurrce, prop) {
if (prop) {
if (isBeforeUE425) {
var cname = UObject.getClassName(prop);
} else {
var cname = FField.getClassName(prop);
}
// console.log(`resolveProp cname: ${cname}`);
if (cname === "ObjectProperty" || cname === "WeakObjectProperty"
|| cname === "LazyObjectProperty" || cname === "AssetObjectProperty"
|| cname === "SoftObjectProperty") {
var propertyClass = UObjectProperty.getPropertyClass(prop);
recurrce.push(...[propertyClass]);
return UObject.getName(propertyClass) + "*";
} else if (cname === "ClassProperty" || cname === "AssetClassProperty" ||
cname === "SoftClassProperty") {
var metaClass = UClassProperty.getMetaClass(prop);
recurrce.push(...[metaClass]);
return "class " + UObject.getName(metaClass);
} else if (cname === "InterfaceProperty") {
var interfaceClass = UInterfaceProperty.getInterfaceClass(prop);
recurrce.push(...[interfaceClass]);
return "interface class" + UObject.getName(interfaceClass);
} else if (cname === "StructProperty") {
var Struct = UStructProperty.getStruct(prop);
// console.log(`StructProperty addr: ${Struct}`);
recurrce.push(...[Struct]);
return UObject.getName(Struct);
} else if (cname === "ArrayProperty") {
return resolveProp(recurrce, UArrayProperty.getInner(prop)) + "[]";
} else if (cname === "SetProperty") {
return "<" + resolveProp(recurrce, USetProperty.getElementProp(prop)) + ">";
} else if (cname === "MapProperty") {
return "<" + resolveProp(recurrce, UMapProperty.getKeyProp(prop)) + "," +
resolveProp(recurrce, UMapProperty.getValueProp(prop)) + ">";
} else if (cname === "BoolProperty") {
return "bool";
} else if (cname === "ByteProperty") {
var enumObj = UByteProperty.getEnum(prop);
if (offset_UENum_Names !== null && UObject.isValid(enumObj)) {
var enumName = UByteProperty.getName(prop);
if (!enumClasses.includes(enumName)) {
enumClasses.push(enumName);
enumClassStr += "enum " + enumName + " {";
for (var count = 0; count < UEnum.getCount(enumObj); count++) {
var index = UEnum.getNamesArray(enumObj).add(count * enumItemSize).readU32();
enumClassStr += "\n\t" + getFNameFromID(index).replace(enumName + "::", "")
}
enumClassStr += "\n};\n";
return "enum " + enumName;
} else {
return "enum " + enumName;
}
} else {
return "byte";
}
} else if (cname === "IntProperty") {
return "int";
} else if (cname === "Int8Property") {
return "int8";
} else if (cname === "Int16Property") {
return "int16";
} else if (cname === "Int64Property") {
return "int64";
} else if (cname === "UInt16Property") {
return "uint16";
} else if (cname === "UInt32Property") {
return "uint32";
} else if (cname === "UInt64Property") {
return "uint64";
} else if (cname === "DoubleProperty") {
return "double";
} else if (cname === "FloatProperty") {
return "float";
} else if (cname === "EnumProperty") {
var enumName = UEnumProperty.getName(prop);
if (offset_UENum_Names !== null) {
var enumObj = UEnumProperty.getEnum(prop);
if (!enumClasses.includes(enumName)) {
enumClasses.push(enumName);
enumClassStr += "enum " + enumName + " {";
for (var count = 0; count < UEnum.getCount(enumObj); count++) {
var index = UEnum.getNamesArray(enumObj).add(count * enumItemSize).readU32();
enumClassStr += "\n\t" + getFNameFromID(index).replace(enumName + "::", "")
}
enumClassStr += "\n};\n";
return "enum " + enumName;
} else {
return "enum " + enumName;
}
} else {
return "enum " + enumName;
}
} else if (cname === "StrProperty") {
return "FString";
} else if (cname === "TextProperty") {
return "FText";
} else if (cname === "NameProperty") {
return "FName";
} else if (cname === "DelegateProperty" || cname === "MulticastDelegateProperty") {
return "delegate";
} else {
if (isBeforeUE425) {
return UObject.getName(prop) + "(" + cname + ")";
} else {
return FField.getName(prop) + "(" + cname + ")";
}
}
}
return "NULL";
}
function writeStructChild(childprop) {
var recurrce = [];
var child = childprop;
// console.log(`writeStructChild child before validation: ${child}`);
while (UObject.isValid(child)) {
var prop = child;
if (isBeforeUE425) {
var oname = UObject.getName(prop);
var cname = UObject.getClassName(prop);
} else {
var oname = FField.getName(prop);
var cname = FField.getClassName(prop);
}
// console.log(`writeStructChild child after validation: ${child}`);
// console.log(`oname: ${oname}, cname: ${cname}`);
if (cname === "ObjectProperty" || cname === "WeakObjectProperty" || cname === "LazyObjectProperty" || cname === "AssetObjectProperty" || cname === "SoftObjectProperty") {
var propertyClass = UObjectProperty.getPropertyClass(prop);
console.log(`\t${UObject.getName(propertyClass)}* ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
recurrce.push(propertyClass);
} else if (cname === "ClassProperty" || cname === "AssetClassProperty" || cname === "SoftClassProperty") {
var metaClass = UClassProperty.getMetaClass(prop);
console.log(`\tclass ${UObject.getName(metaClass)}* ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
recurrce.push(metaClass);
} else if (cname === "InterfaceProperty") {
var interfaceClass = UInterfaceProperty.getInterfaceClass(prop);
console.log(`\tinterface class ${UObject.getName(interfaceClass)}* ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`)
} else if (cname === "StructProperty") {
var Struct = UStructProperty.getStruct(prop);
console.log(`\t${UObject.getName(Struct)} ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
recurrce.push(Struct);
} else if (cname === "ArrayProperty") {
console.log(`\t${resolveProp(recurrce, UArrayProperty.getInner(prop))}[] ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "SetProperty") {
console.log(`\t${resolveProp(recurrce, USetProperty.getElementProp(prop))} ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "MapProperty") {
console.log(`\t<${resolveProp(recurrce, UMapProperty.getKeyProp(prop))}, ${resolveProp(recurrce, UMapProperty.getValueProp(prop))}> ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "BoolProperty") {
console.log(`\tbool ${oname} //(ByteOffset: ${ptr(UBoolProperty.getByteOffset(prop))}, ByteMask: ${UBoolProperty.getByteMask(prop)}, FieldMask: ${UBoolProperty.getFieldMask(prop)}) [Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "ByteProperty") {
var enumObj = UByteProperty.getEnum(prop);
if (offset_UENum_Names !== null && UObject.isValid(enumObj)) {
var enumName = UByteProperty.getName(prop);
console.log(`\tenum ${enumName} ${oname} { //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
for (var count = 0; count < UEnum.getCount(enumObj); count++) {
var index = UEnum.getNamesArray(enumObj).add(count * enumItemSize).readU32();
console.log(`\t\t${getFNameFromID(index).replace(enumName + "::", "")}`)
}
console.log("\t};")
} else {
console.log(`\tbyte ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
}
} else if (cname === "IntProperty") {
console.log(`\tint ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "Int8Property") {
console.log(`\tint8 ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "Int16Property") {
console.log(`\tint16 ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "Int64Property") {
console.log(`\tint64 ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "UInt16Property") {
console.log(`\tint16 ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "UInt32Property") {
console.log(`\tint32 ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "UInt64Property") {
console.log(`\tint64 ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "DoubleProperty") {
console.log(`\tdouble ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "FloatProperty") {
console.log(`\tfloat ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "EnumProperty") {
var enumName = UEnumProperty.getName(prop);
if (offset_UENum_Names !== null) {
var enumObj = UEnumProperty.getEnum(prop);
console.log(`\tenum ${enumName} ${oname} { //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
for (var count = 0; count < UEnum.getCount(enumObj); count++) {
var index = UEnum.getNamesArray(enumObj).add(count * enumItemSize).readU32();
console.log(`\t\t${getFNameFromID(index).replace(enumName + "::", "")}`)
}
console.log("\t};")
} else {
console.log(`\tenum ${enumName} ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
}
} else if (cname === "StrProperty") {
console.log(`\tFString ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "TextProperty") {
console.log(`\tFText ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "NameProperty") {
console.log(`\tFName ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "DelegateProperty" || cname === "MulticastDelegateProperty" || cname === "MulticastInlineDelegateProperty" || cname === "MulticastSparseDelegateProperty") {
console.log(`\tdelegate ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (cname === "XigPtrProperty") {
console.log(`\tXigPtrProperty ${oname}; //[Offset: ${ptr(UProperty.getOffset(prop))}, Size: ${UProperty.getElementSize(prop)}]`);
} else if (isBeforeUE425) {
if (cname.startsWith("Function") || cname === "DelegateFunction") {
var returnVal = "void";
var params = "";
var flags = "";
var funcParam = UStruct.getChildren(prop);
// console.log(`funcParam: ${funcParam});
while (UObject.isValid(funcParam)) {
var PropertyFlags = UProperty.getPropertyFlags(funcParam);
// console.log(`PropertyFlags: ${PropertyFlags});
if ((PropertyFlags & 0x0000000000000400) == 0x0000000000000400) {
returnVal = resolveProp(recurrce, funcParam);
} else {
if ((PropertyFlags & 0x0000000000000100) == 0x0000000000000100) {
params += "out ";
}
/*if((PropertyFlags & 0x0000000008000000) == 0x0000000008000000){
params += "ref ";
}*/
if ((PropertyFlags & 0x0000000000000002) == 0x0000000000000002) {
params += "const ";
}
// console.log(`funcParam will go in...: ${funcParam});
params += resolveProp(recurrce, funcParam);
// params += "blahblah";
params += " ";
params += UObject.getName(funcParam);
params += ", ";
}
funcParam = UField.getNext(funcParam);
}
if (params.length > 0) {
params = params.slice(0, -2);
}
var FunctionFlags = UFunction.getFunctionFlags(prop);
// console.log(`FunctionFlags: ${FunctionFlags});
if ((FunctionFlags & 0x00002000) == 0x00002000) {
returnVal = "static " + returnVal;
}
/*if((FunctionFlags & 0x00000001) == 0x00000001){
returnVal = "final " + returnVal;
}
if((FunctionFlags & 0x00020000) == 0x00020000){
returnVal = "public " + returnVal;
}
if((FunctionFlags & 0x00040000) == 0x00040000){
returnVal = "private " + returnVal;
}
if((FunctionFlags & 0x00080000) == 0x00080000){
returnVal = "protected " + returnVal;
}*/
for (let mapping of funcFlags) {
if ((FunctionFlags & mapping.flag) == mapping.flag) {
flags += `${mapping.name}|`
}
}
console.log(`\t${returnVal} ${oname}(${params}); // ${UFunction.getFunc(prop).sub(moduleBase)} ${flags !== "" ? ("[" + flags.slice(0, -1) + "]") : ""} ${isActorDump ? ("// Object addr: " + child) : ""}`);
} else if (cname === "Class" || cname === "Package") {
} else {
console.log(`\t${cname} ${oname}; //[Size: ${UProperty.getElementSize(prop)}]`);
}
} else {
console.log(`\t${cname} ${oname}; //[Size: ${UProperty.getElementSize(prop)}]`);
}
if (isBeforeUE425) {
child = UField.getNext(child);
} else {
child = FField.getNext(child);
}
}
return recurrce;
}
var funcFlags = [
{flag:0x00000001, name: "Final"}, // Function is final (prebindable, non-overridable function).
{flag:0x00000004, name: "BlueprintAuthorityOly"}, // Function will only run if the object has network authority
{flag:0x00000008, name: "BlueprinCosmetic"}, // Function is cosmetic in nature and should not be invoked on dedicated servers
{flag:0x00000400, name: "Native"}, // Native function.
{flag:0x00000800, name: "Event"}, // Event function.
{flag:0x00002000, name: "Static"}, // Static function.
{flag:0x00008000, name: "UbergraphFunction"}, // Function is used as the merge 'ubergraph' for a blueprint, only assigned when using the persistent 'ubergraph' frame
{flag:0x00010000, name: "MulticastDlegate"}, // Function is a multi-cast delegate signature (also requires FUNC_Delegate to be set!)
{flag:0x00100000, name: "Delegate"}, // Function is delegate signature (either single-cast or multi-cast, depending on whether FUNC_MulticastDelegate is set.)
{flag:0x04000000, name: "BlueprintCallable"}, // function can be called from blueprint code
{flag:0x08000000, name: "BlueprintEvent"}, // function can be overridden/implemented from a blueprint
{flag:0x10000000, name: "BlueprintPure"}, // function can be called from blueprint code, and is also pure (produces no side effects). If you set this, you should set FUNC_BlueprintCallable as well.
{flag:0x20000000, name: "EditorOnly"}, // function can only be called from an editor scrippt.
{flag:0x40000000, name: "Const"}, // function can be called from blueprint code, and only reads state (never writes state)
]
function writeStructChild_Func(childprop) {
var recurrce = [];
var child = childprop;
// console.log(`child: ${child}`);
while (UObject.isValid(child)) {
var prop = child;
var oname = UObject.getName(prop);
if (doHookProcessEvent && oname.match(processEventFilterOutRegex))
break;
var cname = UObject.getClassName(prop);
// console.log(`writeStructChild_Func child: ${child}`);
// console.log(`cname: ${cname}`);
if (cname.startsWith("Function") || cname === "DelegateFunction") {
var returnVal = "void";
var params = "";
var flags = "";
var funcParam = UStruct.getChildProperties(prop);
// console.log(`funcParam: ${funcParam});
while (UObject.isValid(funcParam)) {
var PropertyFlags = UProperty.getPropertyFlags(funcParam);
// console.log(`PropertyFlags: ${PropertyFlags});
if ((PropertyFlags & 0x0000000000000400) == 0x0000000000000400) {
returnVal = resolveProp(recurrce, funcParam);
} else {
if ((PropertyFlags & 0x0000000000000100) == 0x0000000000000100) {
params += "out ";
}
/*if((PropertyFlags & 0x0000000008000000) == 0x0000000008000000){
params += "ref ";
}*/
if ((PropertyFlags & 0x0000000000000002) == 0x0000000000000002) {
params += "const ";
}
// console.log(`funcParam will go in...: ${funcParam});
params += resolveProp(recurrce, funcParam);
// params += "blahblah";
params += " ";
params += FField.getName(funcParam);
params += ", ";
}
funcParam = FField.getNext(funcParam);
}
if (params.length > 0) {
params = params.slice(0, -2);
}
var FunctionFlags = UFunction.getFunctionFlags(prop);
// console.log(`FunctionFlags: ${FunctionFlags});
if ((FunctionFlags & 0x00002000) == 0x00002000) {
returnVal = "static " + returnVal;
}
/*if((FunctionFlags & 0x00000001) == 0x00000001){
returnVal = "final " + returnVal;
}
if((FunctionFlags & 0x00020000) == 0x00020000){
returnVal = "public " + returnVal;
}
if((FunctionFlags & 0x00040000) == 0x00040000){
returnVal = "private " + returnVal;
}
if((FunctionFlags & 0x00080000) == 0x00080000){
returnVal = "protected " + returnVal;
}*/
for (let mapping of funcFlags) {
if ((FunctionFlags & mapping.flag) == mapping.flag) {
flags += `${mapping.name}|`
}
}
console.log(`\t${returnVal} ${oname}(${params}); // ${UFunction.getFunc(prop).sub(moduleBase)} ${flags !== "" ? ("[" + flags.slice(0, -1) + "]") : ""} ${isActorDump ? ("// Object addr: " + child) : ""}`);
if (processInternal_offset === null && flags.slice(0, -1).match(/^(?!.*Native).*Blue.*/)) {
processInternal_offset = UFunction.getFunc(prop).sub(moduleBase);
}
} else if (cname === "Class" || cname === "Package") {
} else {
console.log(`\t${cname} ${oname}; //[Size: ${UProperty.getElementSize(prop)}]`);
}
if (doHookProcessEvent)
break;
child = UField.getNext(child);
}
return recurrce;
}
function writeStruct(clazz) {
var recurrce = [];
var currStruct = clazz;
while (UObject.isValid(currStruct)) {
// console.log(`currStruct: ${currStruct}`)
var name = UObject.getName(currStruct);
// console.log(`name: ${name}`);
if (name === "None" || name.indexOf("/Game/") > -1 || name.indexOf("_png") > -1 || name === "") {
// console.log(`name is ${name} gonna break`);
break;
}
var nameId = UObject.getNameId(currStruct);
// console.log(nameId);
if (!nameIds.includes(nameId)) {
nameIds.push(nameId);
if (isActorDump) {
if (UStruct.getStructClassPath(currStruct) === 'Actor.Object') {
console.log(`Class: ${UStruct.getStructClassPath(currStruct)} // ${currStruct}`) // for debugging
if (isBeforeUE425) {
recurrce.push(...writeStructChild(UStruct.getChildren(currStruct)));
} else {
recurrce.push(...writeStructChild(UStruct.getChildProperties(currStruct)));
recurrce.push(...writeStructChild_Func(UStruct.getChildren(currStruct)));
}
}
} else {
console.log(`Class: ${UStruct.getStructClassPath(currStruct)}`)
if (isBeforeUE425) {
recurrce.push(...writeStructChild(UStruct.getChildren(currStruct)));
} else {
recurrce.push(...writeStructChild(UStruct.getChildProperties(currStruct)));
recurrce.push(...writeStructChild_Func(UStruct.getChildren(currStruct)));
}
}
}
currStruct = UStruct.getSuperClass(currStruct);
}
// console.log(`recurse: ${recurrce}`);
for (var key in recurrce) {
writeStruct(recurrce[key]);
}
}
function dumpActor() {
isActorDump = true;
dumpSdk();
}
function dumpObjects() {
if (GUObjectArray === undefined) {
console.log(`Do set(<moduleName>) first`);
return;
} else if (GUObjectArray === null) {
console.log(`Provide GUObjectArray address by GUObjectArray = moduleBase.add(<offset of GUObjectArray>);`);
return;
}
var ObjectCount = GUObjectArray.add(offset_FUObjectArray_TUObjectArray).add(offset_TUObjectArray_NumElements).readU32();
console.log(`ObjectCount: ${ObjectCount}`);
for (var i = 0; i < ObjectCount; i++) {
var UObjectBaseObject = getUObjectBaseObjectFromId(i);
if (UObject.isValid(UObjectBaseObject)) {
var name = UObject.getName(UObjectBaseObject);
var className = UObject.getClassName(UObjectBaseObject);
console.log(`${i}. Class: ${className}\n\tObjectName: ${name} // ${UObjectBaseObject}`);
}
}
}
function dumpSdk() {
if (GUObjectArray === undefined) {
console.log(`Do set(<moduleName>) first`);
return;
} else if (GUObjectArray === null) {
console.log(`Provide GUObjectArray address by GUObjectArray = moduleBase.add(<offset of GUObjectArray>);`);
return;
}
// empty below variables before performing the dump
if (nameIds.length > 0) nameIds.length = 0;
if (enumClasses.length > 0) enumClasses.length = 0;
if (enumClassStr != "") enumClassStr = "";
var ObjectCount = GUObjectArray.add(offset_FUObjectArray_TUObjectArray).add(offset_TUObjectArray_NumElements).readU32();
for (var i = 0; i < ObjectCount; i++) {
var UObjectBaseObject = getUObjectBaseObjectFromId(i);
if (UObject.isValid(UObjectBaseObject)) {
// console.log(`UObjectBaseObject: ${UObjectBaseObject}`);
var clazz = UObject.getClass(UObjectBaseObject);
writeStruct(clazz);
}
}
if (offset_UENum_Names !== null) console.log(enumClassStr);