-
Notifications
You must be signed in to change notification settings - Fork 1
/
dumper.patch
973 lines (964 loc) · 39.5 KB
/
dumper.patch
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
diff --git a/module/src/main/cpp/And64InlineHook.cpp b/module/src/main/cpp/And64InlineHook.cpp
new file mode 100644
index 0000000..dac87e1
--- /dev/null
+++ b/module/src/main/cpp/And64InlineHook.cpp
@@ -0,0 +1,611 @@
+/*
+ * @date : 2018/04/18
+ * @author : Rprop ([email protected])
+ * https://github.com/Rprop/And64InlineHook
+ */
+/*
+ MIT License
+
+ Copyright (c) 2018 Rprop ([email protected])
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <android/log.h>
+
+#include "log.h"
+
+#if defined(__aarch64__)
+
+#include "And64InlineHook.hpp"
+#define A64_MAX_INSTRUCTIONS 5
+#define A64_MAX_REFERENCES (A64_MAX_INSTRUCTIONS * 2)
+#define A64_NOP 0xd503201fu
+#define A64_JNIEXPORT __attribute__((visibility("default")))
+#define A64_LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "A64_HOOK", __VA_ARGS__))
+#ifndef NDEBUG
+# define A64_LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "A64_HOOK", __VA_ARGS__))
+#else
+# define A64_LOGI(...) ((void)0)
+#endif // NDEBUG
+typedef uint32_t *__restrict *__restrict instruction;
+struct context
+{
+ struct fix_info
+ {
+ uint32_t *bp;
+ uint32_t ls; // left-shift counts
+ uint32_t ad; // & operand
+ };
+ struct insns_info
+ {
+ union
+ {
+ uint64_t insu;
+ int64_t ins;
+ void *insp;
+ };
+ fix_info fmap[A64_MAX_REFERENCES];
+ };
+ int64_t basep;
+ int64_t endp;
+ insns_info dat[A64_MAX_INSTRUCTIONS];
+
+public:
+ inline bool is_in_fixing_range(const int64_t absolute_addr) {
+ return absolute_addr >= this->basep && absolute_addr < this->endp;
+ }
+ inline intptr_t get_ref_ins_index(const int64_t absolute_addr) {
+ return static_cast<intptr_t>((absolute_addr - this->basep) / sizeof(uint32_t));
+ }
+ inline intptr_t get_and_set_current_index(uint32_t *__restrict inp, uint32_t *__restrict outp) {
+ intptr_t current_idx = this->get_ref_ins_index(reinterpret_cast<int64_t>(inp));
+ this->dat[current_idx].insp = outp;
+ return current_idx;
+ }
+ inline void reset_current_ins(const intptr_t idx, uint32_t *__restrict outp) {
+ this->dat[idx].insp = outp;
+ }
+ void insert_fix_map(const intptr_t idx, uint32_t *bp, uint32_t ls = 0u, uint32_t ad = 0xffffffffu) {
+ for (auto &f : this->dat[idx].fmap) {
+ if (f.bp == NULL) {
+ f.bp = bp;
+ f.ls = ls;
+ f.ad = ad;
+ return;
+ } //if
+ }
+ // What? GGing..
+ }
+ void process_fix_map(const intptr_t idx) {
+ for (auto &f : this->dat[idx].fmap) {
+ if (f.bp == NULL) break;
+ *(f.bp) = *(f.bp) | (((int32_t(this->dat[idx].ins - reinterpret_cast<int64_t>(f.bp)) >> 2) << f.ls) & f.ad);
+ f.bp = NULL;
+ }
+ }
+};
+
+//-------------------------------------------------------------------------
+
+#define __intval(p) reinterpret_cast<intptr_t>(p)
+#define __uintval(p) reinterpret_cast<uintptr_t>(p)
+#define __ptr(p) reinterpret_cast<void *>(p)
+#define __page_size 4096
+#define __page_align(n) __align_up(static_cast<uintptr_t>(n), __page_size)
+#define __ptr_align(x) __ptr(__align_down(reinterpret_cast<uintptr_t>(x), __page_size))
+#define __align_up(x, n) (((x) + ((n) - 1)) & ~((n) - 1))
+#define __align_down(x, n) ((x) & -(n))
+#define __countof(x) static_cast<intptr_t>(sizeof(x) / sizeof((x)[0])) // must be signed
+#define __atomic_increase(p) __sync_add_and_fetch(p, 1)
+#define __sync_cmpswap(p, v, n) __sync_bool_compare_and_swap(p, v, n)
+#define __predict_true(exp) __builtin_expect((exp) != 0, 1)
+#define __flush_cache(c, n) __builtin___clear_cache(reinterpret_cast<char *>(c), reinterpret_cast<char *>(c) + n)
+#define __make_rwx(p, n) ::mprotect(__ptr_align(p), \
+ __page_align(__uintval(p) + n) != __page_align(__uintval(p)) ? __page_align(n) + __page_size : __page_align(n), \
+ PROT_READ | PROT_WRITE | PROT_EXEC)
+
+//-------------------------------------------------------------------------
+
+static bool __fix_branch_imm(instruction inpp, instruction outpp, context *ctxp)
+{
+ static constexpr uint32_t mbits = 6u;
+ static constexpr uint32_t mask = 0xfc000000u; // 0b11111100000000000000000000000000
+ static constexpr uint32_t rmask = 0x03ffffffu; // 0b00000011111111111111111111111111
+ static constexpr uint32_t op_b = 0x14000000u; // "b" ADDR_PCREL26
+ static constexpr uint32_t op_bl = 0x94000000u; // "bl" ADDR_PCREL26
+
+ const uint32_t ins = *(*inpp);
+ const uint32_t opc = ins & mask;
+ switch (opc) {
+ case op_b:
+ case op_bl:
+ {
+ intptr_t current_idx = ctxp->get_and_set_current_index(*inpp, *outpp);
+ int64_t absolute_addr = reinterpret_cast<int64_t>(*inpp) + (static_cast<int32_t>(ins << mbits) >> (mbits - 2u)); // sign-extended
+ int64_t new_pc_offset = static_cast<int64_t>(absolute_addr - reinterpret_cast<int64_t>(*outpp)) >> 2; // shifted
+ bool special_fix_type = ctxp->is_in_fixing_range(absolute_addr);
+ // whether the branch should be converted to absolute jump
+ if (!special_fix_type && llabs(new_pc_offset) >= (rmask >> 1)) {
+ bool b_aligned = (reinterpret_cast<uint64_t>(*outpp + 2) & 7u) == 0u;
+ if (opc == op_b) {
+ if (b_aligned != true) {
+ (*outpp)[0] = A64_NOP;
+ ctxp->reset_current_ins(current_idx, ++(*outpp));
+ } //if
+ (*outpp)[0] = 0x58000051u; // LDR X17, #0x8
+ (*outpp)[1] = 0xd61f0220u; // BR X17
+ memcpy(*outpp + 2, &absolute_addr, sizeof(absolute_addr));
+ *outpp += 4;
+ } else {
+ if (b_aligned == true) {
+ (*outpp)[0] = A64_NOP;
+ ctxp->reset_current_ins(current_idx, ++(*outpp));
+ } //if
+ (*outpp)[0] = 0x58000071u; // LDR X17, #12
+ (*outpp)[1] = 0x1000009eu; // ADR X30, #16
+ (*outpp)[2] = 0xd61f0220u; // BR X17
+ memcpy(*outpp + 3, &absolute_addr, sizeof(absolute_addr));
+ *outpp += 5;
+ } //if
+ } else {
+ if (special_fix_type) {
+ intptr_t ref_idx = ctxp->get_ref_ins_index(absolute_addr);
+ if (ref_idx <= current_idx) {
+ new_pc_offset = static_cast<int64_t>(ctxp->dat[ref_idx].ins - reinterpret_cast<int64_t>(*outpp)) >> 2;
+ } else {
+ ctxp->insert_fix_map(ref_idx, *outpp, 0u, rmask);
+ new_pc_offset = 0;
+ } //if
+ } //if
+
+ (*outpp)[0] = opc | (new_pc_offset & ~mask);
+ ++(*outpp);
+ } //if
+
+ ++(*inpp);
+ return ctxp->process_fix_map(current_idx), true;
+ }
+ }
+ return false;
+}
+
+//-------------------------------------------------------------------------
+
+static bool __fix_cond_comp_test_branch(instruction inpp, instruction outpp, context *ctxp)
+{
+ static constexpr uint32_t lsb = 5u;
+ static constexpr uint32_t lmask01 = 0xff00001fu; // 0b11111111000000000000000000011111
+ static constexpr uint32_t mask0 = 0xff000010u; // 0b11111111000000000000000000010000
+ static constexpr uint32_t op_bc = 0x54000000u; // "b.c" ADDR_PCREL19
+ static constexpr uint32_t mask1 = 0x7f000000u; // 0b01111111000000000000000000000000
+ static constexpr uint32_t op_cbz = 0x34000000u; // "cbz" Rt, ADDR_PCREL19
+ static constexpr uint32_t op_cbnz = 0x35000000u; // "cbnz" Rt, ADDR_PCREL19
+ static constexpr uint32_t lmask2 = 0xfff8001fu; // 0b11111111111110000000000000011111
+ static constexpr uint32_t mask2 = 0x7f000000u; // 0b01111111000000000000000000000000
+ static constexpr uint32_t op_tbz = 0x36000000u; // 0b00110110000000000000000000000000 "tbz" Rt, BIT_NUM, ADDR_PCREL14
+ static constexpr uint32_t op_tbnz = 0x37000000u; // 0b00110111000000000000000000000000 "tbnz" Rt, BIT_NUM, ADDR_PCREL14
+
+ const uint32_t ins = *(*inpp);
+ uint32_t lmask = lmask01;
+ if ((ins & mask0) != op_bc) {
+ uint32_t opc = ins & mask1;
+ if (opc != op_cbz && opc != op_cbnz) {
+ opc = ins & mask2;
+ if (opc != op_tbz && opc != op_tbnz) {
+ return false;
+ } //if
+ lmask = lmask2;
+ } //if
+ } //if
+
+ const uint32_t msb = __builtin_clz(~lmask);
+ intptr_t current_idx = ctxp->get_and_set_current_index(*inpp, *outpp);
+ int64_t absolute_addr = reinterpret_cast<int64_t>(*inpp) + (static_cast<int32_t>((ins & ~lmask) << msb) >> (lsb - 2u + msb));
+ int64_t new_pc_offset = static_cast<int64_t>(absolute_addr - reinterpret_cast<int64_t>(*outpp)) >> 2; // shifted
+ bool special_fix_type = ctxp->is_in_fixing_range(absolute_addr);
+ if (!special_fix_type && llabs(new_pc_offset) >= (~lmask >> (lsb + 1))) {
+ if ((reinterpret_cast<uint64_t>(*outpp + 4) & 7u) != 0u) {
+ (*outpp)[0] = A64_NOP;
+ ctxp->reset_current_ins(current_idx, ++(*outpp));
+ } //if
+ (*outpp)[0] = (((8u >> 2u) << lsb) & ~lmask) | (ins & lmask); // B.C #0x8
+ (*outpp)[1] = 0x14000005u; // B #0x14
+ (*outpp)[2] = 0x58000051u; // LDR X17, #0x8
+ (*outpp)[3] = 0xd61f0220u; // BR X17
+ memcpy(*outpp + 4, &absolute_addr, sizeof(absolute_addr));
+ *outpp += 6;
+ } else {
+ if (special_fix_type) {
+ intptr_t ref_idx = ctxp->get_ref_ins_index(absolute_addr);
+ if (ref_idx <= current_idx) {
+ new_pc_offset = static_cast<int64_t>(ctxp->dat[ref_idx].ins - reinterpret_cast<int64_t>(*outpp)) >> 2;
+ } else {
+ ctxp->insert_fix_map(ref_idx, *outpp, lsb, ~lmask);
+ new_pc_offset = 0;
+ } //if
+ } //if
+
+ (*outpp)[0] = (static_cast<uint32_t>(new_pc_offset << lsb) & ~lmask) | (ins & lmask);
+ ++(*outpp);
+ } //if
+
+ ++(*inpp);
+ return ctxp->process_fix_map(current_idx), true;
+}
+
+//-------------------------------------------------------------------------
+
+static bool __fix_loadlit(instruction inpp, instruction outpp, context *ctxp)
+{
+ const uint32_t ins = *(*inpp);
+
+ // memory prefetch("prfm"), just skip it
+ // http://infocenter.arm.com/help/topic/com.arm.doc.100069_0608_00_en/pge1427897420050.html
+ if ((ins & 0xff000000u) == 0xd8000000u) {
+ ctxp->process_fix_map(ctxp->get_and_set_current_index(*inpp, *outpp));
+ ++(*inpp);
+ return true;
+ } //if
+
+ static constexpr uint32_t msb = 8u;
+ static constexpr uint32_t lsb = 5u;
+ static constexpr uint32_t mask_30 = 0x40000000u; // 0b01000000000000000000000000000000
+ static constexpr uint32_t mask_31 = 0x80000000u; // 0b10000000000000000000000000000000
+ static constexpr uint32_t lmask = 0xff00001fu; // 0b11111111000000000000000000011111
+ static constexpr uint32_t mask_ldr = 0xbf000000u; // 0b10111111000000000000000000000000
+ static constexpr uint32_t op_ldr = 0x18000000u; // 0b00011000000000000000000000000000 "LDR Wt/Xt, label" | ADDR_PCREL19
+ static constexpr uint32_t mask_ldrv = 0x3f000000u; // 0b00111111000000000000000000000000
+ static constexpr uint32_t op_ldrv = 0x1c000000u; // 0b00011100000000000000000000000000 "LDR St/Dt/Qt, label" | ADDR_PCREL19
+ static constexpr uint32_t mask_ldrsw = 0xff000000u; // 0b11111111000000000000000000000000
+ static constexpr uint32_t op_ldrsw = 0x98000000u; // "LDRSW Xt, label" | ADDR_PCREL19 | load register signed word
+ // LDR S0, #0 | 0b00011100000000000000000000000000 | 32-bit
+ // LDR D0, #0 | 0b01011100000000000000000000000000 | 64-bit
+ // LDR Q0, #0 | 0b10011100000000000000000000000000 | 128-bit
+ // INVALID | 0b11011100000000000000000000000000 | may be 256-bit
+
+ uint32_t mask = mask_ldr;
+ uintptr_t faligned = (ins & mask_30) ? 7u : 3u;
+ if ((ins & mask_ldr) != op_ldr) {
+ mask = mask_ldrv;
+ if (faligned != 7u)
+ faligned = (ins & mask_31) ? 15u : 3u;
+ if ((ins & mask_ldrv) != op_ldrv) {
+ if ((ins & mask_ldrsw) != op_ldrsw) {
+ return false;
+ } //if
+ mask = mask_ldrsw;
+ faligned = 7u;
+ } //if
+ } //if
+
+ intptr_t current_idx = ctxp->get_and_set_current_index(*inpp, *outpp);
+ int64_t absolute_addr = reinterpret_cast<int64_t>(*inpp) + ((static_cast<int32_t>(ins << msb) >> (msb + lsb - 2u)) & ~3u);
+ int64_t new_pc_offset = static_cast<int64_t>(absolute_addr - reinterpret_cast<int64_t>(*outpp)) >> 2; // shifted
+ bool special_fix_type = ctxp->is_in_fixing_range(absolute_addr);
+ // special_fix_type may encounter issue when there are mixed data and code
+ if (special_fix_type || (llabs(new_pc_offset) + (faligned + 1u - 4u) / 4u) >= (~lmask >> (lsb + 1))) { // inaccurate, but it works
+ while ((reinterpret_cast<uint64_t>(*outpp + 2) & faligned) != 0u) {
+ *(*outpp)++ = A64_NOP;
+ }
+ ctxp->reset_current_ins(current_idx, *outpp);
+
+ // Note that if memory at absolute_addr is writeable (non-const), we will fail to fetch it.
+ // And what's worse, we may unexpectedly overwrite something if special_fix_type is true...
+ uint32_t ns = static_cast<uint32_t>((faligned + 1) / sizeof(uint32_t));
+ (*outpp)[0] = (((8u >> 2u) << lsb) & ~mask) | (ins & lmask); // LDR #0x8
+ (*outpp)[1] = 0x14000001u + ns; // B #0xc
+ memcpy(*outpp + 2, reinterpret_cast<void *>(absolute_addr), faligned + 1);
+ *outpp += 2 + ns;
+ } else {
+ faligned >>= 2; // new_pc_offset is shifted and 4-byte aligned
+ while ((new_pc_offset & faligned) != 0) {
+ *(*outpp)++ = A64_NOP;
+ new_pc_offset = static_cast<int64_t>(absolute_addr - reinterpret_cast<int64_t>(*outpp)) >> 2;
+ }
+ ctxp->reset_current_ins(current_idx, *outpp);
+
+ (*outpp)[0] = (static_cast<uint32_t>(new_pc_offset << lsb) & ~mask) | (ins & lmask);
+ ++(*outpp);
+ } //if
+
+ ++(*inpp);
+ return ctxp->process_fix_map(current_idx), true;
+}
+
+//-------------------------------------------------------------------------
+
+static bool __fix_pcreladdr(instruction inpp, instruction outpp, context *ctxp)
+{
+ // Load a PC-relative address into a register
+ // http://infocenter.arm.com/help/topic/com.arm.doc.100069_0608_00_en/pge1427897645644.html
+ static constexpr uint32_t msb = 8u;
+ static constexpr uint32_t lsb = 5u;
+ static constexpr uint32_t mask = 0x9f000000u; // 0b10011111000000000000000000000000
+ static constexpr uint32_t rmask = 0x0000001fu; // 0b00000000000000000000000000011111
+ static constexpr uint32_t lmask = 0xff00001fu; // 0b11111111000000000000000000011111
+ static constexpr uint32_t fmask = 0x00ffffffu; // 0b00000000111111111111111111111111
+ static constexpr uint32_t max_val = 0x001fffffu; // 0b00000000000111111111111111111111
+ static constexpr uint32_t op_adr = 0x10000000u; // "adr" Rd, ADDR_PCREL21
+ static constexpr uint32_t op_adrp = 0x90000000u; // "adrp" Rd, ADDR_ADRP
+
+ const uint32_t ins = *(*inpp);
+ intptr_t current_idx;
+ switch (ins & mask) {
+ case op_adr:
+ {
+ current_idx = ctxp->get_and_set_current_index(*inpp, *outpp);
+ int64_t lsb_bytes = static_cast<uint32_t>(ins << 1u) >> 30u;
+ int64_t absolute_addr = reinterpret_cast<int64_t>(*inpp) + (((static_cast<int32_t>(ins << msb) >> (msb + lsb - 2u)) & ~3u) | lsb_bytes);
+ int64_t new_pc_offset = static_cast<int64_t>(absolute_addr - reinterpret_cast<int64_t>(*outpp));
+ bool special_fix_type = ctxp->is_in_fixing_range(absolute_addr);
+ if (!special_fix_type && llabs(new_pc_offset) >= (max_val >> 1)) {
+ if ((reinterpret_cast<uint64_t>(*outpp + 2) & 7u) != 0u) {
+ (*outpp)[0] = A64_NOP;
+ ctxp->reset_current_ins(current_idx, ++(*outpp));
+ } //if
+
+ (*outpp)[0] = 0x58000000u | (((8u >> 2u) << lsb) & ~mask) | (ins & rmask); // LDR #0x8
+ (*outpp)[1] = 0x14000003u; // B #0xc
+ memcpy(*outpp + 2, &absolute_addr, sizeof(absolute_addr));
+ *outpp += 4;
+ } else {
+ if (special_fix_type) {
+ intptr_t ref_idx = ctxp->get_ref_ins_index(absolute_addr & ~3ull);
+ if (ref_idx <= current_idx) {
+ new_pc_offset = static_cast<int64_t>(ctxp->dat[ref_idx].ins - reinterpret_cast<int64_t>(*outpp));
+ } else {
+ ctxp->insert_fix_map(ref_idx, *outpp, lsb, fmask);
+ new_pc_offset = 0;
+ } //if
+ } //if
+
+ // the lsb_bytes will never be changed, so we can use lmask to keep it
+ (*outpp)[0] = (static_cast<uint32_t>(new_pc_offset << (lsb - 2u)) & fmask) | (ins & lmask);
+ ++(*outpp);
+ } //if
+ }
+ break;
+ case op_adrp:
+ {
+ current_idx = ctxp->get_and_set_current_index(*inpp, *outpp);
+ int32_t lsb_bytes = static_cast<uint32_t>(ins << 1u) >> 30u;
+ int64_t absolute_addr = (reinterpret_cast<int64_t>(*inpp) & ~0xfffll) + ((((static_cast<int32_t>(ins << msb) >> (msb + lsb - 2u)) & ~3u) | lsb_bytes) << 12);
+ A64_LOGI("ins = 0x%.8X, pc = %p, abs_addr = %p",
+ ins, *inpp, reinterpret_cast<int64_t *>(absolute_addr));
+ if (ctxp->is_in_fixing_range(absolute_addr)) {
+ intptr_t ref_idx = ctxp->get_ref_ins_index(absolute_addr/* & ~3ull*/);
+ if (ref_idx > current_idx) {
+ // the bottom 12 bits of absolute_addr are masked out,
+ // so ref_idx must be less than or equal to current_idx!
+ A64_LOGE("ref_idx must be less than or equal to current_idx!");
+ } //if
+
+ // *absolute_addr may be changed due to relocation fixing
+ A64_LOGI("What is the correct way to fix this?");
+ *(*outpp)++ = ins; // 0x90000000u;
+ } else {
+ if ((reinterpret_cast<uint64_t>(*outpp + 2) & 7u) != 0u) {
+ (*outpp)[0] = A64_NOP;
+ ctxp->reset_current_ins(current_idx, ++(*outpp));
+ } //if
+
+ (*outpp)[0] = 0x58000000u | (((8u >> 2u) << lsb) & ~mask) | (ins & rmask); // LDR #0x8
+ (*outpp)[1] = 0x14000003u; // B #0xc
+ memcpy(*outpp + 2, &absolute_addr, sizeof(absolute_addr)); // potential overflow?
+ *outpp += 4;
+ } //if
+ }
+ break;
+ default:
+ return false;
+ }
+
+ ctxp->process_fix_map(current_idx);
+ ++(*inpp);
+ return true;
+}
+
+//-------------------------------------------------------------------------
+
+static void __fix_instructions(uint32_t *__restrict inp, int32_t count, uint32_t *__restrict outp)
+{
+ context ctx;
+ ctx.basep = reinterpret_cast<int64_t>(inp);
+ ctx.endp = reinterpret_cast<int64_t>(inp + count);
+ memset(ctx.dat, 0, sizeof(ctx.dat));
+ static_assert(sizeof(ctx.dat) / sizeof(ctx.dat[0]) == A64_MAX_INSTRUCTIONS,
+ "please use A64_MAX_INSTRUCTIONS!");
+#ifndef NDEBUG
+ if (count > A64_MAX_INSTRUCTIONS) {
+ A64_LOGE("too many fixing instructions!");
+ } //if
+#endif // NDEBUG
+
+ uint32_t *const outp_base = outp;
+
+ while (--count >= 0) {
+ if (__fix_branch_imm(&inp, &outp, &ctx)) continue;
+ if (__fix_cond_comp_test_branch(&inp, &outp, &ctx)) continue;
+ if (__fix_loadlit(&inp, &outp, &ctx)) continue;
+ if (__fix_pcreladdr(&inp, &outp, &ctx)) continue;
+
+ // without PC-relative offset
+ ctx.process_fix_map(ctx.get_and_set_current_index(inp, outp));
+ *(outp++) = *(inp++);
+ }
+
+ static constexpr uint_fast64_t mask = 0x03ffffffu; // 0b00000011111111111111111111111111
+ auto callback = reinterpret_cast<int64_t>(inp);
+ auto pc_offset = static_cast<int64_t>(callback - reinterpret_cast<int64_t>(outp)) >> 2;
+ if (llabs(pc_offset) >= (mask >> 1)) {
+ if ((reinterpret_cast<uint64_t>(outp + 2) & 7u) != 0u) {
+ outp[0] = A64_NOP;
+ ++outp;
+ } //if
+ outp[0] = 0x58000051u; // LDR X17, #0x8
+ outp[1] = 0xd61f0220u; // BR X17
+ *reinterpret_cast<int64_t *>(outp + 2) = callback;
+ outp += 4;
+ } else {
+ outp[0] = 0x14000000u | (pc_offset & mask); // "B" ADDR_PCREL26
+ ++outp;
+ } //if
+
+ const uintptr_t total = (outp - outp_base) * sizeof(uint32_t);
+ __flush_cache(outp_base, total); // necessary
+}
+
+//-------------------------------------------------------------------------
+
+extern "C" {
+ static __attribute__((__aligned__(__page_size))) uint32_t __insns_pool[A64_MAX_BACKUPS][A64_MAX_INSTRUCTIONS * 10];
+
+ //-------------------------------------------------------------------------
+
+ class A64HookInit
+ {
+ public:
+ A64HookInit()
+ {
+ __make_rwx(__insns_pool, sizeof(__insns_pool));
+ A64_LOGI("insns pool initialized.");
+ }
+ };
+ static A64HookInit __init;
+
+ //-------------------------------------------------------------------------
+
+ static uint32_t *FastAllocateTrampoline()
+ {
+ static_assert((A64_MAX_INSTRUCTIONS * 10 * sizeof(uint32_t)) % 8 == 0, "8-byte align");
+ static volatile int32_t __index = -1;
+
+ int32_t i = __atomic_increase(&__index);
+ if (__predict_true(i >= 0 && i < __countof(__insns_pool))) {
+ return __insns_pool[i];
+ } //if
+
+ A64_LOGE("failed to allocate trampoline!");
+ return NULL;
+ }
+
+ //-------------------------------------------------------------------------
+
+ A64_JNIEXPORT void *A64HookFunctionV(void *const symbol, void *const replace,
+ void *const rwx, const uintptr_t rwx_size)
+ {
+ static constexpr uint_fast64_t mask = 0x03ffffffu; // 0b00000011111111111111111111111111
+
+ uint32_t *trampoline = static_cast<uint32_t *>(rwx), *original = static_cast<uint32_t *>(symbol);
+
+ static_assert(A64_MAX_INSTRUCTIONS >= 5, "please fix A64_MAX_INSTRUCTIONS!");
+ auto pc_offset = static_cast<int64_t>(__intval(replace) - __intval(symbol)) >> 2;
+ if (llabs(pc_offset) >= (mask >>1)) {
+ int32_t count = (reinterpret_cast<uint64_t>(original + 2) & 7u) != 0u ? 5 : 4;
+ if (trampoline) {
+ if (rwx_size < count * 10u) {
+ A64_LOGE("rwx size is too small to hold %u bytes backup instructions!", count * 10u);
+ return NULL;
+ } //if
+ __fix_instructions(original, count, trampoline);
+ } //if
+
+ if (__make_rwx(original, 5 * sizeof(uint32_t)) == 0) {
+ if (count == 5) {
+ original[0] = A64_NOP;
+ ++original;
+ } //if
+ original[0] = 0x58000051u; // LDR X17, #0x8
+ original[1] = 0xd61f0220u; // BR X17
+ *reinterpret_cast<int64_t *>(original + 2) = __intval(replace);
+ __flush_cache(symbol, 5 * sizeof(uint32_t));
+
+ A64_LOGI("inline hook %p->%p successfully! %zu bytes overwritten",
+ symbol, replace, 5 * sizeof(uint32_t));
+ } else {
+ A64_LOGE("mprotect failed with errno = %d, p = %p, size = %zu",
+ errno, original, 5 * sizeof(uint32_t));
+ trampoline = NULL;
+ } //if
+ } else {
+ if (trampoline) {
+ if (rwx_size < 1u * 10u) {
+ A64_LOGE("rwx size is too small to hold %u bytes backup instructions!", 1u * 10u);
+ return NULL;
+ } //if
+ __fix_instructions(original, 1, trampoline);
+ } //if
+
+ if (__make_rwx(original, 1 * sizeof(uint32_t)) == 0) {
+ __sync_cmpswap(original, *original, 0x14000000u | (pc_offset & mask)); // "B" ADDR_PCREL26
+ __flush_cache(symbol, 1 * sizeof(uint32_t));
+
+ A64_LOGI("inline hook %p->%p successfully! %zu bytes overwritten",
+ symbol, replace, 1 * sizeof(uint32_t));
+ } else {
+ A64_LOGE("mprotect failed with errno = %d, p = %p, size = %zu",
+ errno, original, 1 * sizeof(uint32_t));
+ trampoline = NULL;
+ } //if
+ } //if
+
+ return trampoline;
+ }
+
+ //-------------------------------------------------------------------------
+
+ A64_JNIEXPORT void A64HookFunction(void *const symbol, void *const replace, void **result)
+ {
+ void *trampoline = NULL;
+ if (result != NULL) {
+ trampoline = FastAllocateTrampoline();
+ *result = trampoline;
+ if (trampoline == NULL) return;
+ } //if
+
+ // fix Android 10 .text segment is read-only by default
+ __make_rwx(symbol, 5 * sizeof(size_t));
+
+ trampoline = A64HookFunctionV(symbol, replace, trampoline, A64_MAX_INSTRUCTIONS * 10u);
+ if (trampoline == NULL && result != NULL) {
+ *result = NULL;
+ } //if
+ }
+}
+
+#else // defined(__aarch64__)
+
+extern "C" {
+__attribute__((visibility("default"))) void
+A64HookFunction(void *const symbol, void *const replace, void **result) {
+ LOGE("Hook on unsupported arch");
+}
+__attribute__((visibility("default"))) void *
+A64HookFunctionV(void *const symbol, void *const replace,
+ void *const rwx, const uintptr_t rwx_size) {
+ LOGE("Hook on unsupported arch");
+}
+}
+#endif
diff --git a/module/src/main/cpp/And64InlineHook.hpp b/module/src/main/cpp/And64InlineHook.hpp
new file mode 100644
index 0000000..c76c852
--- /dev/null
+++ b/module/src/main/cpp/And64InlineHook.hpp
@@ -0,0 +1,42 @@
+/*
+ * @date : 2018/04/18
+ * @author : Rprop ([email protected])
+ * https://github.com/Rprop/And64InlineHook
+ */
+/*
+ MIT License
+
+ Copyright (c) 2018 Rprop ([email protected])
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
+#pragma once
+#define A64_MAX_BACKUPS 256
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void A64HookFunction(void *const symbol, void *const replace, void **result);
+void *A64HookFunctionV(void *const symbol, void *const replace,
+ void *const rwx, const uintptr_t rwx_size);
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
diff --git a/module/src/main/cpp/CMakeLists.txt b/module/src/main/cpp/CMakeLists.txt
index 280b151..f194582 100644
--- a/module/src/main/cpp/CMakeLists.txt
+++ b/module/src/main/cpp/CMakeLists.txt
@@ -37,6 +37,7 @@ add_library(${MODULE_NAME} SHARED
main.cpp
hack.cpp
il2cpp_dump.cpp
+ And64InlineHook.cpp
${xdl-src})
target_link_libraries(${MODULE_NAME} log)
diff --git a/module/src/main/cpp/game.h b/module/src/main/cpp/game.h
index 12bc5b6..37e174c 100644
--- a/module/src/main/cpp/game.h
+++ b/module/src/main/cpp/game.h
@@ -5,6 +5,6 @@
#ifndef ZYGISK_IL2CPPDUMPER_GAME_H
#define ZYGISK_IL2CPPDUMPER_GAME_H
-#define GamePackageName "com.game.packagename"
+#define GamePackageName "com.YoStarEN.Arknights"
#endif //ZYGISK_IL2CPPDUMPER_GAME_H
diff --git a/module/src/main/cpp/hack.cpp b/module/src/main/cpp/hack.cpp
index 8bc71c3..ed9e814 100644
--- a/module/src/main/cpp/hack.cpp
+++ b/module/src/main/cpp/hack.cpp
@@ -1,11 +1,14 @@
//
// Created by Perfare on 2020/7/4.
//
+// Modified by DJPadbit on 2024/08/02
+//
#include "hack.h"
#include "il2cpp_dump.h"
#include "log.h"
#include "xdl.h"
+#include "And64InlineHook.hpp"
#include <cstring>
#include <string>
#include <ios>
@@ -20,6 +23,7 @@
#include <sys/mman.h>
#include <linux/unistd.h>
#include <array>
+#include <vector>
unsigned long get_module_base(const char * module_name) {
FILE * fp;
@@ -42,23 +46,221 @@ unsigned long get_module_base(const char * module_name) {
return addr;
}
-void * hack_thread(const char * game_data_dir) {
+void hack_lib(const char * game_data_dir, std::string modName) {
+ std::string outPathRo = std::string(game_data_dir).append("/files/ro_").append(modName);
+ std::string outPathRw = std::string(game_data_dir).append("/files/").append(modName);
+
+ std::string line;
+ std::ifstream file("/proc/self/maps");
+ if (!file.is_open()) {
+ LOGI("hack_lib: couldn't open maps");
+ return;
+ }
+ LOGI("hack_lib: map open, looking for '%s'", modName.c_str());
+
+ struct segment {
+ unsigned long start_addr;
+ unsigned long size;
+ unsigned long offset;
+ bool writable;
+ };
+
+ std::vector<segment> segments;
+ unsigned long total_size = 0;
+
+ while (getline(file, line)) {
+ if (line.find(modName) != std::string::npos) {
+ segment seg;
+
+ int pos = line.find(" ");
+ std::string addr_st = line.substr(0,pos);
+ line.erase(0, pos+1); // eat
+ // start_addr-end_addr
+ pos = addr_st.find("-");
+ seg.start_addr = std::strtoul(addr_st.substr(0, pos).c_str(), NULL, 16);
+ seg.size = std::strtoul(addr_st.substr(pos+1).c_str(), NULL, 16) - seg.start_addr;
+ // perms
+ pos = line.find(" ");
+ std::string perms = line.substr(0,pos);
+ line.erase(0, pos+1); // eat
+ seg.writable = perms.find("w") != std::string::npos;
+ // offset
+ pos = line.find(" ");
+ std::string offset_st = line.substr(0,pos);
+ line.erase(0, pos+1); // eat
+
+ seg.offset = std::strtoul(offset_st.c_str(), NULL, 16);
+
+ unsigned long seg_last = seg.offset+seg.size;
+ if (seg_last > total_size)
+ total_size = seg_last;
+
+ LOGI("hack_lib: seg st:%lx, sz:%lx, of:%lx, w:%i", seg.start_addr, seg.size, seg.offset, seg.writable);
+
+ segments.push_back(seg);
+ }
+ }
+ file.close();
+
+ LOGI("hack_lib: tot_size: %lu", total_size);
+
+ char * data = new char[total_size];
+ if (!data) {
+ LOGI("hack_lib: can't allocate memory for dump");
+ return;
+ }
+
+ // Only do read-only segments first, then add potential modifications
+ for (segment &seg : segments) {
+ if (seg.writable)
+ continue;
+
+ LOGI("hack_lib: reading Ro segment: %lx", seg.start_addr);
+ char* start = reinterpret_cast<char*>(seg.start_addr);
+ std::memcpy(data+seg.offset, start, seg.size);
+ }
+
+ // Write out the Ro file
+ // Not really needed
+ /*LOGI("hack_lib: read all ro segs");
+ std::ofstream outfileRo(outPathRo, std::ios::binary | std::ios::out);
+ if (outfileRo.is_open()) {
+ outfileRo.write(data, total_size);
+ outfileRo.close();
+ } else {
+ LOGI("hack_lib: couldn't open ro outfile");
+ }*/
+
+ // Read the write segs now
+ for (segment &seg : segments) {
+ if (!seg.writable)
+ continue;
+
+ LOGI("hack_lib: reading Rw segment: %lx", seg.start_addr);
+ char* start = reinterpret_cast<char*>(seg.start_addr);
+ std::memcpy(data+seg.offset, start, seg.size);
+ }
+
+ // Write out the Rw file
+ LOGI("hack_lib: read all rw segs");
+ std::ofstream outfileRw(outPathRw, std::ios::binary | std::ios::out);
+ if (outfileRw.is_open()) {
+ outfileRw.write(data, total_size);
+ outfileRw.close();
+ } else {
+ LOGI("hack_lib: couldn't open rw outfile");
+ }
+
+ LOGI("hack_lib: cleanup");
+ delete[] data;
+}
+
+void hack_thread(const char * game_data_dir) {
unsigned long base_addr;
base_addr = get_module_base("libil2cpp.so");
-
- char * hack_addr = *(char **)(base_addr + GlobalMetadataAddr);
+ LOGI("hack_thread: libil2cpp.so addr %lx", base_addr);
+
+ char * hack_addr = *(char **)(base_addr + GlobalMetadataAddr);
+ unsigned long codereg_addr = *(unsigned long*)(base_addr + CodeRegAddr);
+ unsigned long metareg_addr = *(unsigned long*)(base_addr + MetaRegAddr);
+ unsigned long codegenopt_addr = *(unsigned long*)(base_addr + CodeGenOptAddr);
+
+ LOGI("hack_thread: cr:%lx mr:%lx co:%lx", codereg_addr, metareg_addr, codegenopt_addr);
+ LOGI("hack_thread: -base cr:%lx mr:%lx co:%lx", codereg_addr-base_addr, metareg_addr-base_addr, codegenopt_addr-base_addr);
+
auto outPath = std::string(game_data_dir).append("/files/global-metadata.dat");
std::ofstream outfile(outPath, std::ios::binary | std::ios::out);
if (outfile.is_open()) {
// deref once to get correct pointer to GM
const char * variable_data = reinterpret_cast < char * > (hack_addr);
- int difinitionOffset_size = *(reinterpret_cast < const int * > (variable_data + 0x100));
- int definitionsCount_size = *(reinterpret_cast < const int * > (variable_data + 0x104));
- outfile.write(variable_data, difinitionOffset_size + definitionsCount_size);
+ int definitionOffset_size = *(reinterpret_cast < const int * > (variable_data + 0x108));
+ int definitionsCount_size = *(reinterpret_cast < const int * > (variable_data + 0x10C));
+ if (definitionsCount_size < 10) {
+ definitionOffset_size = *(reinterpret_cast < const int * > (variable_data + 0x100));
+ definitionsCount_size = *(reinterpret_cast < const int * > (variable_data + 0x104));
+ }
+ LOGI("hack_thread: defOffsetSize %x defCountSize %x", definitionOffset_size, definitionsCount_size);
+ outfile.write(variable_data, definitionOffset_size + definitionsCount_size);
outfile.close();
}
}
+struct System_String_Fields {
+ int32_t length;
+ uint16_t start_char;
+};
+
+struct System_String_o {
+ void *klass;
+ void *monitor;
+ System_String_Fields fields;
+};
+
+struct Torappu_PlayerData_Fields {
+ System_String_o* m_logToken;
+ System_String_o* m_accessToken;
+ System_String_o* m_chatMask;
+ void* m_data;
+ void* m_rawData;
+ void* m_charIdInstMap;
+ void* m_existActSet;
+ void* m_existSandboxPermSet;
+ void* m_jsonSettings;
+ void* m_luaPlayerData;
+};
+
+struct Torappu_PlayerData_o {
+ void *klass;
+ void *monitor;
+ Torappu_PlayerData_Fields fields;
+};
+
+System_String_o* (*old_getChatMask)(Torappu_PlayerData_o*, const void*) = nullptr;
+
+std::string& getStringFromNet(System_String_o* in_string, std::string& out_string) {
+ int32_t size = in_string->fields.length;
+ uint16_t *start = &in_string->fields.start_char;
+
+ out_string.resize(size);
+ char *st = out_string.data();
+ for (int i=0;i<size;i++)
+ st[i] = start[i];
+
+ return out_string;
+}
+
+System_String_o* getChatMask_hook(Torappu_PlayerData_o* __this, void* method) {
+ LOGI("getChatMask_hook: hello");
+ if (!old_getChatMask) {
+ LOGE("getChatMask_hook: No old func ??? help");
+ return nullptr;
+ }
+ System_String_o* ret = old_getChatMask(__this, method);
+ LOGI("getChatMask_hook: Called old func, ret %lx", (unsigned long)ret);
+ if (ret != nullptr) {
+ std::string chatmask;
+ getStringFromNet(ret, chatmask);
+ LOGI("getChatMask_hook: data => '%s'", chatmask.c_str());
+ }
+ return ret;
+}
+
+void hack_chatmask() {
+ LOGI("hack_chatmask: entry");
+
+ if (old_getChatMask != nullptr) {
+ LOGI("hack_chatmask: Already hooked ??? fuck");
+ return;
+ }
+
+ unsigned long base_addr = get_module_base("libil2cpp.so");
+ LOGI("hack_chatmask: libil2cpp.so addr %lx", base_addr);
+ unsigned long getChatMask_addr = base_addr + GetChatMaskFuncAddr;
+
+ A64HookFunction((void *const)getChatMask_addr, (void *)getChatMask_hook, (void **)&old_getChatMask);
+ LOGI("hack_chatmask: Hooked getchatmask, res %lx", (unsigned long)old_getChatMask);
+}
+
void hack_start(const char *game_data_dir) {
bool load = false;
for (int i = 0; i < 10; i++) {
@@ -68,6 +270,9 @@ void hack_start(const char *game_data_dir) {
il2cpp_api_init(handle);
il2cpp_dump(game_data_dir);
hack_thread(game_data_dir);
+ hack_lib(game_data_dir, "libil2cpp.so");
+ hack_lib(game_data_dir, "libanort.so");
+ hack_chatmask();
break;
} else {
sleep(1);
diff --git a/module/src/main/cpp/hack.h b/module/src/main/cpp/hack.h
index fbf47f4..8aca744 100644
--- a/module/src/main/cpp/hack.h
+++ b/module/src/main/cpp/hack.h
@@ -10,6 +10,12 @@
void hack_prepare(const char *game_data_dir, void *data, size_t length);
// The address of the pointer to decrypted global metadata
-#define GlobalMetadataAddr 0x000000UL
+#define GlobalMetadataAddr 0xA67D770UL
+
+#define CodeRegAddr 0xA67D758UL
+#define MetaRegAddr 0xA67D760UL
+#define CodeGenOptAddr 0xA67D768UL
+
+#define GetChatMaskFuncAddr 0x37E5404UL
#endif //ZYGISK_IL2CPPDUMPER_HACK_H