首页
社区
课程
招聘
[原创]某鹅浏览器中jcestruct协议原理分析
2023-3-9 23:19 20856

[原创]某鹅浏览器中jcestruct协议原理分析

2023-3-9 23:19
20856

jcestruct是鹅厂自研的一个协议,本篇文章相对于全面的进行分析下实现过程及其分析的心得,本文仅以技术角度分析下某鹅浏览器采用该协议的优良性,希望更多的人能认识到除了json,protobuf外还有个藏在我们眼皮子底下的技术。

 

⊙一. 什么是jcestruct
⊙二. jcestruct在某浏览器的应用
⊙三. 010editor手动还原jcestruct协议
⊙四. js实现的jcestruct
⊙总结

一. 什么是jcestruct

jcestruct顾名思义是一个二进制传输协议,能够把传输的字段抽象为某种结构的一种传输协议。

 

有些形似protobuf协议,但是与protobuf协议存在数据组包的一些差异。

1.1节省传输空间

客户端和服务器端要通讯,如果正常的json请求,客户端发送的是 {"客户端小杜":我要下单3070显卡},服务端回复的{"老黄的回复": 早卖给矿老板了},这时完成了一次请求的发送。
但是我们看这次发送有什么问题呢,首先发送数据的长度为整个json字符串的长度,读者读到这里有可能说这么短能占用多少流量呢,其实不然,如果在京东/天猫双11抢购的时候,发送的报文远远超过这个长度,同时服务器要发送大量的相应报文给客户端,这样同时1000w人下单对于服务器的压力就比较大了,jcestruct相对于json请求有什么区别呢?

 

下面是客户端和服务端发送信息时类结构体的封装

1
2
3
4
5
6
7
8
9
struct 小杜{
String message;
}
小杜.message = "我要下单3070显卡"
 
struct 老黄{
String message;
}
老黄.message = "早卖给矿老板了"

这时候 客户端发送给服务器的为bin("我要下单3070显卡"),服务器则直接返回bin("早卖给矿老板了") ,这时其实已经节省了传输中很大的占用空间了。

 

图片描述

1.2可扩展空间强

在电商平台我们要是购买东西的时候发往后台的数据包括一些价格(整数型),商品名称(字符串型),风控时手机的一些信息(map型),上传图片识别地址(字节集型),针对那么多的类型在json里面不是那么好处理,但是jcestruct从设计上面包括以下的类型。
图片描述
图片描述
这些类型足够可以满足复杂通信过程中所必须的数据类型。

 

有了类型我们探讨下一个问题,这些类型到底组合拼接后发送到服务器的呢?
图片描述

 

jce的编码及其结构:

 

//在文本存储中的结构
keyvaluekeyvaluekeyvalue

 

读者朋友们这时又说了 你骗人,前面不是说不用传key的吗?

 

当然了这里的key是抽象结构体的key。key也就是头的一种抽象描述,等同于下面的
结构体为:

1
2
3
4
node HeadData {
     int tag;
     unsigned char type;
}

key的数据解析的规则是:低4位为类型,高四位为tag 如果 tag 为0xF 则下一个字节为tag.
key由tag和type组成。Key为1个字节或两个字节.两个字节时第二个字节为tag否则第一个字节的高4位为tag.type始终为第一个字节的低4位。type最多有16种类型,tag最大为256(2的八次方)。

 

图片描述

 

key为了描述后方的value,key中的type为上方表中的数据类型中的一种,其中key中的tag为了表示序列(0,1,2,3,4.....255)

 

这个时候可能有认真的读者就说了,我用json字段可以超过255个,jcestruct听你介绍这意思就是不行呗,果然我大json才是最牛的?

 

图片描述
其实不然 255个序列确实是线性排布的,但是TYPE_SIMPLE_LIST类型存储的是字节数组,而且jcestruct这个序列传输的时候确实是字节数组,那么在这种情况下,就可以把A的jcestruct转为字节集的结构存放在B的结构体中,可以形象的称谓套娃,通过这种操作其实jcestruct可以结构可以存储的数据容量是非常大的(我也不知道有多大 很大就是了)

1.3 多语言可实现兼容多种客户端

图片描述

 

jcestruct广泛运用于多个产品(多是腾旭的),在腾讯qq 的内部传输实现,包括马总其他app也是广泛运用这个协议,目前作者已知的在c语言、c#、go、python、java、js、易语言中均已经有实现的api调用。那么在这种情况下,在使用该语言的服务端上面和使用如上语言实现的客户端上面均可建立通信,只要遵从这个协议就可非常完美的进行通信了。

1.4 安全性

jce本身这种协议的解码对于不懂这个协议的人来说就是一个不小的挑战,明明数据就在那,替换了也没法伪造;当然对于了解此协议比较熟悉的大佬,看见这个协议利用010editor即可还原其协议本来的面目,那么如果我们身为一个开发者如果不从加密算法上下功夫,如何保护我们的数据不被攻击方所获取呢,有一个很容易的操作就是对jcestruct进行魔改,这时有读者说了,我再怎么魔改也是13个数据类型呀,的确是这样,但是我们可以在开发过程中把数据类型标志换为其他的数据类型,例如0在上方表示的byte但是通过我们偷换为1位byte剩下的随机切换,这样一进行修改,对于逆向分析的人来说,首先要找到每个标号所对应的数据类型,其次再去修改jcestruct的实现,已经实现了保护的目的;另一种我们可以在jcestruct里面嵌入protobuf协议,因为jcestruct可以涵盖字节,广而推之不止protobuf协议可以集成进去,只要可以被转为二进制的协议我们都可以放入;这只是从协议层进行防护,同样的,可以从传输时gzip+对称加密算法,基本上可以拦截大多数的人了,大佬就是你,你除外。
图片描述

二.jcestruct在某浏览器的应用

app逆向分析加密过程写出来可能会侵犯厂商的利益,所以用以下几句概括下,从浏览器旧版本升级到新版本之后,原有的java层代码实现的jcestruct协议已经不再走(通过hook验证确实没走),之后经过读者分析,浏览器换了种更优雅的方式,即通过js实现jcestruct协议然后在webview这个里面实现自己的逻辑,这种实现方法方便以后更新主页的显示的时候直接通过改动index的js文件即可替换逻辑,方只从jcestruct协议的实现和使用上面来写。

 

在这个app当时进行分析的目的是看一下广告包存在于那个请求内,经过了抓包分析定位之后定位到了广告包。

 

从charles里面保存响应包的二进制数据。

 

然后进行解密,代码如下:

1
2
3
4
5
6
7
8
9
10
def decode_content(key = "3B73D4C094BB98234508E97E1037FD1C",  iv = "706c65b5016ccb24"):
 
    key = bytes.fromhex(key)
    f = open(r"C:\Users\Administrator\Desktop\浏览器pac", "rb").read()
    aes_decrpyt_data = utils().aesDecrypt(key, iv, f)
 
    uncompress_data = utils().zlibDeCompress(aes_decrpyt_data)
    with open("encodedata","wb") as  f:
        f.write(bytes.fromhex(uncompress_data.hex()[8:]))
    print(result)

这时候就会得出经过aes解密和gzip解压之后的jce二进制文件,然后下一个章节我们介绍,如何根据以上的内容手动解析一下jcestruct。

 

jcestruct被加密后
图片描述

 

jcestruct被解密后
图片描述

三.010editor手动还原jcestruct协议

图片描述

 

10 :高位为1,低位为0,那么tag=1,0代表后面有一个字节 为 02
2C:高位为2,低位为C,那么tag=2,C代表的为zero,所以后面没有任何值
3C,4C和上面的解释相同

 

图片描述
56:tag=5 类型为6,字符串后加一个字符串的长度(0A),之后跟的是数据(红色方块中的AdsGateWay)

 

图片描述
66:tag=6 类型为6,长度(0F),getBatchAdsData

 

图片描述

 

simelist一直到
图片描述

 

7D:tag=7 类型为D,相当于是个字节字节数组 ,00为死数没有含义,01表示数组的类型为short,0x6e3=1763;那么 0x6e3+0x26 =0x709

 

图片描述

 

8c: tag =8,类型为c zero
98:tag=9 ,类型为map 长度为0
a8:tag=10,类型为map 长度为0

 

大体上已经手动解析完了,但是tag =7的时候包含的为TYPE_SIMPLE_LIST,其实也是jcestruct结构被转为二进制之后的数据,想分析的读者,也可按照上方的方法来进行推算。

 

很多读者其实看到这里会说,你怎么知道每个类型后面跟的是长度还是数据,当然了 我也是看了源码后才知道的
首先看几个函数

 

0 byte bool
如果是0 直接走的是type12类型(ZERO_TAG) 写一个头就完事了,其他的情况下还得写入一个头 后面直接存储一个字节的内容

1
2
3
4
5
6
7
8
9
public void write(byte b, int i) {
        reserve(3);
        if (b == (byte) 0) {
            writeHead((byte) 12, i);
            return;
        }
        writeHead((byte) 0, i);
        this.bs.put(b);
    }

我们看到存取bool类型的操作也跑到上面的函数里面去了

1
2
3
public void write(boolean z, int i) {
       write((byte) (z ? 1 : 0), i);
   }

1 short
超过一个字节的会以short的类型进行存储,如果一个字节的情况下直接转为 0的方式存储了 这样可以节省内存空间

1
2
3
4
5
6
7
8
9
public void write(short s, int i) {
        reserve(4);
        if (s < (short) -128 || s > (short) 127) {
            writeHead((byte) 1, i);
            this.bs.putShort(s);
            return;
        }
        write((byte) s, i);
    }

2 int
数据长度如果超过二个字节存储不下就会存int,如果否则就走short的存储方式

1
2
3
4
5
6
7
8
9
public void write(int i, int i2) {
        reserve(6);
        if (i < -32768 || i > 32767) {
            writeHead((byte) 2, i2);
            this.bs.putInt(i);
            return;
        }
        write((short) i, i2);
    }

3 long
数据所能容纳的最大的长度为超过四个字节的时候就会使用long类型,如果没超过就使用int'

1
2
3
4
5
6
7
8
9
public void write(long j, int i) {
       reserve(10);
       if (j < -2147483648L || j > 2147483647L) {
           writeHead((byte) 3, i);
           this.bs.putLong(j);
           return;
       }
       write((int) j, i);
   }

对 0 1 2 3 的归纳
byte short int long这四种发现jcestruct对他们的处理是能省则省,就是能用小的存储空间代替就不用大的,特别是byte 表示零的情况下直接用zerotag来表示。

 

4 float
float不会向前面那四个类型一样进行节省空间而转换为其他的类型, float占用四个字节

1
2
3
4
5
public void write(float f, int i) {
        reserve(6);
        writeHead((byte) 4, i);
        this.bs.putFloat(f);
    }

5 double
double也不会像前面那四个类型一样进行节省空间而转换为其他的类型 double 占用的也为 8个字节

1
2
3
4
5
public void write(double d, int i) {
       reserve(10);
       writeHead((byte) 5, i);
       this.bs.putDouble(d);
   }

6.7 string
都是存储的字符串
type6存储额短符串如果字符串的长度小于等于255(这个255正好是一个字节 2^8)
type7存储长字符串 当字符串长度大于255(一个字节装不下的时候)就用四个字节来装长度了,然后再押入字符串

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public void write(String str, int i) {
        byte[] bytes;
        try {
            bytes = str.getBytes(this.sServerEncoding);
        } catch (UnsupportedEncodingException e) {
            bytes = str.getBytes();
        }
        reserve(bytes.length + 10);
        if (bytes.length > 255) {
            writeHead((byte) 7, i);
            this.bs.putInt(bytes.length);
            this.bs.put(bytes);
            return;
        }
        writeHead((byte) 6, i);
        this.bs.put((byte) bytes.length);
        this.bs.put(bytes);
    }

8 map
maptype +maptag +(lenghtype + tag0),然后将键值依次排列后面 key的tag统一为0 value的tag统一为1

1
2
3
4
5
6
7
8
9
10
11
public <K, V> void write(Map<K, V> map, int i) {
       reserve(8);
       writeHead((byte) 8, i);
       write(map == null ? 0 : map.size(), 0);
       if (map != null) {
           for (Entry entry : map.entrySet()) {
               write(entry.getKey(), 0);
               write(entry.getValue(), 1);
           }
       }
   }

9 list
list顾名思义可以存放任意类型的,同样用 byte short int long 来表示长度,同时list每个元素的tag都为0 ,从这套代码的设计来看,都可以进行循环嵌套进行赋值

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
public <T> void write(Collection<T> collection, int i) {
        reserve(8);
        writeHead((byte) 9, i);
        write(collection == null ? 0 : collection.size(), 0);
        if (collection != null) {
            for (T write : collection) {
                write((Object) write, 0);
            }
        }
    }
 
    public void write(Object obj, int i) {
        if (obj instanceof Byte) {
            write(((Byte) obj).byteValue(), i);
        } else if (obj instanceof Boolean) {
            write(((Boolean) obj).booleanValue(), i);
        } else if (obj instanceof Short) {
            write(((Short) obj).shortValue(), i);
        } else if (obj instanceof Integer) {
            write(((Integer) obj).intValue(), i);
        } else if (obj instanceof Long) {
            write(((Long) obj).longValue(), i);
        } else if (obj instanceof Float) {
            write(((Float) obj).floatValue(), i);
        } else if (obj instanceof Double) {
            write(((Double) obj).doubleValue(), i);
        } else if (obj instanceof String) {
            write((String) obj, i);
        } else if (obj instanceof Map) {
            write((Map) obj, i);
        } else if (obj instanceof List) {
            write((List) obj, i);
        } else if (obj instanceof JceStruct) {
            write((JceStruct) obj, i);
        } else if (obj instanceof byte[]) {
            write((byte[]) obj, i);
        } else if (obj instanceof boolean[]) {
            write((boolean[]) obj, i);
        } else if (obj instanceof short[]) {
            write((short[]) obj, i);
        } else if (obj instanceof int[]) {
            write((int[]) obj, i);
        } else if (obj instanceof long[]) {
            write((long[]) obj, i);
        } else if (obj instanceof float[]) {
            write((float[]) obj, i);
        } else if (obj instanceof double[]) {
            write((double[]) obj, i);
        } else if (obj.getClass().isArray()) {
            writeArray((Object[]) obj, i);
        } else if (obj instanceof Collection) {
            write((Collection) obj, i);
        } else {
            throw new JceEncodeException("write object error: unsupport type. " + obj.getClass());
        }
    }

10 ,11 STRUCT_BEGIN STRUCT_END
这个主要运用于一个类里面的成员还有其他jcestruct的子类的实现的时候就会使用这种方法

1
2
3
4
5
6
7
public void write(JceStruct jceStruct, int i) {
        reserve(2);
        writeHead((byte) 10, i);
        jceStruct.writeTo(this);
        reserve(2);
        writeHead((byte) 11, 0);
    }

12 zero_tag
一般表示空的直接一个空的头占领了位置

1
writeHead((byte) 12, i);

13TYPE_SIMPLE_LIST
后来加的一个结构,就是个bytes数组,不知道为什么要有这个结构,先接一个byte表示长度类型,

1
2
3
4
5
6
7
public void write(byte[] bArr, int i) {
        reserve(bArr.length + 8);
        writeHead((byte) 13, i);
        writeHead((byte) 0, 0);
        write(bArr.length, 0);
        this.bs.put(bArr);
    }

四.js实现的jcestruct

这里放一份可以组包的js作为彩蛋

 

python调用端代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import execjs
def get_js():
    f = open(r"jcestruct.js", 'r', encoding="utf-8")
    line = f.readline()
    htmlstr = ''
    while line:
        htmlstr = htmlstr + line
        line = f.readline()
    ctx = execjs.compile(htmlstr)
    content = bytes.fromhex(ctx.call('main'))
    print(content)
    return ctx.call('main')
 
print(get_js())

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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
const Taf = {};
 
Taf.INT8 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt8(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt8(e, true, i)
    }
 
    this._className = function () {
        return Taf.CHAR
    }
}
 
Taf.INT16 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt16(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt16(e, true, i)
    }
 
    this._className = function () {
        return Taf.SHORT
    }
}
 
Taf.INT32 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt32(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt32(e, true, i)
    }
 
    this._className = function () {
        return Taf.INT32
    }
}
 
Taf.INT64 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt64(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt64(e, true, i)
    }
 
    this._className = function () {
        return Taf.INT64
    }
}
 
Taf.UINT8 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt16(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt16(e, true, i)
    }
 
    this._className = function () {
        return Taf.SHORT
    }
}
 
Taf.UInt16 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt32(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt32(e, true, i)
    }
 
    this._className = function () {
        return Taf.INT32
    }
}
 
Taf.UInt32 = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt64(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt64(e, true, i)
    }
 
    this._className = function () {
        return Taf.INT64
    }
}
 
Taf.Float = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeFloat(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readFloat(e, true, i)
    }
 
    this._className = function () {
        return Taf.FLOAT
    }
}
 
Taf.Double = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeDouble(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readDouble(e, true, i)
    }
 
    this._className = function () {
        return Taf.DOUBLE
    }
}
 
Taf.STRING = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeString(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readString(e, true, i)
    }
 
    this._className = function () {
        return Taf.STRING
    }
}
 
Taf.BOOLEAN = function () {
    this._clone = function () {
        return false
    }
 
    this._write = function (t, e, i) {
        return t.writeBoolean(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readBoolean(e, true, i)
    }
 
    this._className = function () {
        return Taf.BOOLEAN
    }
}
 
Taf.ENUM = function () {
    this._clone = function () {
        return 0
    }
 
    this._write = function (t, e, i) {
        return t.writeInt32(e, i)
    }
 
    this._read = function (t, e, i) {
        return t.readInt32(e, true, i)
    }
}
 
Taf.Vector = function (t) {
    this.proto = t
    this.value = new Array
}
 
Taf.Vector.prototype._clone = function () {
    return new Taf.Vector(this.proto)
}
 
Taf.Vector.prototype._write = function (t, e, i) {
    return t.writeVector(e, i)
}
 
Taf.Vector.prototype._read = function (t, e, i) {
    return t.readVector(e, true, i)
}
 
Taf.Vector.prototype._className = function () {
    return Taf.TypeHelp.VECTOR.replace("$t", this.proto._className())
}
 
Taf.Map = function (t, e) {
    this.kproto = t
    this.vproto = e
    this.value = new Object
}
 
Taf.Map.prototype._clone = function () {
    return new Taf.Map(this.kproto, this.vproto)
}
 
Taf.Map.prototype._write = function (t, e, i) {
    return t.writeMap(e, i)
}
 
Taf.Map.prototype._read = function (t, e, i) {
    return t.readMap(e, true, i)
}
 
Taf.Map.prototype.put = function (t, e) {
    this.value[t] = e
}
 
Taf.Map.prototype.get = function (t) {
    return this.value[t]
}
 
Taf.Map.prototype.remove = function (t) {
    delete this.value[t]
}
 
Taf.Map.prototype.clear = function () {
    this.value = new Object
}
 
Taf.Map.prototype.size = function () {
    var t = 0
    for (var e in this.value) {
        t++
    }
    return t
}
 
Taf.Vector.prototype._className = function () {
    return Taf.TypeHelp.Map.replace("$k", this.kproto._className()).replace("$v", this.vproto._className())
}
 
Taf.DataHelp = {
    EN_INT8: 0,
    EN_INT16: 1,
    EN_INT32: 2,
    EN_INT64: 3,
    EN_FLOAT: 4,
    EN_DOUBLE: 5,
    EN_STRING1: 6,
    EN_STRING4: 7,
    EN_MAP: 8,
    EN_LIST: 9,
    EN_STRUCTBEGIN: 10,
    EN_STRUCTEND: 11,
    EN_ZERO: 12,
    EN_SIMPLELIST: 13
}
Taf.TypeHelp = {
    BOOLEAN: "bool",
    CHAR: "char",
    SHORT: "short",
    INT32: "int32",
    INT64: "int64",
    FLOAT: "float",
    DOUBLE: "double",
    STRING: "string",
    VECTOR: "list<$t>",
    MAP: "map<$k, $v>"
}
Taf.BinBuffer = function (t) {
    this.buf = null
    this.vew = null
    this.len = 0
    this.position = 0
    if (t != null && t != undefined && t instanceof Taf.BinBuffer) {
        this.buf = t.buf
        this.vew = new DataView(this.buf)
        this.len = t.length
        this.position = t.position
    }
    if (t != null && t != undefined && t instanceof ArrayBuffer) {
        this.buf = t
        this.vew = new DataView(this.buf)
        this.len = this.vew.byteLength
        this.position = 0
    }
    this.__defineGetter__("length", function () {
        return this.len
    })
    this.__defineGetter__("buffer", function () {
        return this.buf
    })
}
 
Taf.BinBuffer.prototype._write = function (t, e, i) {
    return t.writeBytes(e, i)
}
 
Taf.BinBuffer.prototype._read = function (t, e, i) {
    return t.readBytes(e, true, i)
}
 
Taf.BinBuffer.prototype._clone = function () {
    return new Taf.BinBuffer
}
 
Taf.BinBuffer.prototype.allocate = function (t) {
    t = this.position + t
    if (this.buf != null && this.buf.length > t) {
        return
    }
    var e = new ArrayBuffer(Math.max(256, t * 2))
    if (this.buf != null) {
        new Uint8Array(e).set(new Uint8Array(this.buf))
        this.buf = undefined
    }
    this.buf = e
    this.vew = undefined
    this.vew = new DataView(this.buf)
}
 
Taf.BinBuffer.prototype.getBuffer = function () {
    var t = new ArrayBuffer(this.len)
    new Uint8Array(t).set(new Uint8Array(this.buf, 0, this.len))
    return t
}
 
Taf.BinBuffer.prototype.memset = function (t, e, i) {
    this.allocate(i)
    new Uint8Array(this.buf).set(new Uint8Array(t, e, i), this.position)
}
 
Taf.BinBuffer.prototype.writeInt8 = function (t) {
    this.allocate(1)
    this.vew.setInt8(this.position, t)
    this.position += 1
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeUInt8 = function (t) {
    this.allocate(1)
    this.vew.setUint8(this.position++, t)
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeInt16 = function (t) {
    this.allocate(2)
    this.vew.setInt16(this.position, t)
    this.position += 2
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeUInt16 = function (t) {
    this.allocate(2)
    this.vew.setUint16(this.position, t)
    this.position += 2
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeInt32 = function (t) {
    this.allocate(4)
    this.vew.setInt32(this.position, t)
    this.position += 4
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeUInt32 = function (t) {
    this.allocate(4)
    this.vew.setUint32(this.position, t)
    this.position += 4
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeInt64 = function (t) {
    this.allocate(8)
    this.vew.setUint32(this.position, parseInt(t / 4294967296))
    this.vew.setUint32(this.position + 4, t % 4294967296)
    this.position += 8
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeFloat = function (t) {
    this.allocate(4)
    this.vew.setFloat32(this.position, t)
    this.position += 4
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeDouble = function (t) {
    this.allocate(8)
    this.vew.setFloat64(this.position, t)
    this.position += 8
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeString = function (t) {
    for (var e = [], i = 0; i < t.length; i++) {
        e.push(t.charCodeAt(i) & 255)
    }
    this.allocate(e.length)
    new Uint8Array(this.buf).set(new Uint8Array(e), this.position)
    this.position += e.length
    this.len = this.position
}
 
Taf.BinBuffer.prototype.writeBytes = function (t) {
    if (t.length == 0 || t.buf == null)
        return
    this.allocate(t.length)
    new Uint8Array(this.buf).set(new Uint8Array(t.buf, 0, t.length), this.position)
    this.position += t.length
    this.len = this.position
}
 
Taf.BinBuffer.prototype.readInt8 = function () {
    return this.vew.getInt8(this.position++)
}
 
Taf.BinBuffer.prototype.readInt16 = function () {
    this.position += 2
    return this.vew.getInt16(this.position - 2)
}
 
Taf.BinBuffer.prototype.readInt32 = function () {
    this.position += 4
    return this.vew.getInt32(this.position - 4)
}
 
Taf.BinBuffer.prototype.readUInt8 = function () {
    this.position += 1
    return this.vew.getUint8(this.position - 1)
}
 
Taf.BinBuffer.prototype.readUInt16 = function () {
    this.position += 2
    return this.vew.getUint16(this.position - 2)
}
 
Taf.BinBuffer.prototype.readUInt32 = function () {
    this.position += 4
    return this.vew.getUint32(this.position - 4)
}
 
Taf.BinBuffer.prototype.readInt64 = function () {
    var t = this.vew.getUint32(this.position)
    var e = this.vew.getUint32(this.position + 4)
    this.position += 8
    return t * 4294967296 + e
}
 
Taf.BinBuffer.prototype.readFloat = function () {
    var t = this.vew.getFloat32(this.position)
    this.position += 4
    return t
}
 
Taf.BinBuffer.prototype.readDouble = function () {
    var t = this.vew.getFloat64(this.position)
    this.position += 8
    return t
}
 
Taf.BinBuffer.prototype.readString = function (t) {
    for (var e = [], i = 0; i < t; i++) {
        e.push(String.fromCharCode(this.vew.getUint8(this.position++)))
    }
    var r = e.join("")
    try {
        r = decodeURIComponent(escape(r))
    } catch (t) {
    }
    return r
}
 
Taf.BinBuffer.prototype.readBytes = function (t) {
    var e = new Taf.BinBuffer
    e.allocate(t)
    e.memset(this.buf, this.position, t)
    e.position = 0
    e.len = t
    this.position = this.position + t
    return e
}
 
Taf.JceOutputStream = function () {
    this.buf = new Taf.BinBuffer
    this.getBinBuffer = function () {
        return this.buf
    }
 
    this.getBuffer = function () {
        return this.buf.getBuffer()
    }
}
 
Taf.JceOutputStream.prototype.writeTo = function (t, e) {
    if (t < 15) {
        this.buf.writeUInt8(t << 4 & 240 | e)
    } else {
        this.buf.writeUInt16((240 | e) << 8 | t)
    }
}
 
Taf.JceOutputStream.prototype.writeBoolean = function (t, e) {
    this.writeInt8(t, e == true ? 1 : 0)
}
 
Taf.JceOutputStream.prototype.writeInt8 = function (t, e) {
    if (e == 0) {
        this.writeTo(t, Taf.DataHelp.EN_ZERO)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_INT8)
        this.buf.writeInt8(e)
    }
}
 
Taf.JceOutputStream.prototype.writeInt16 = function (t, e) {
    if (e >= -128 && e <= 127) {
        this.writeInt8(t, e)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_INT16)
        this.buf.writeInt16(e)
    }
}
 
Taf.JceOutputStream.prototype.writeInt32 = function (t, e) {
    if (e >= -32768 && e <= 32767) {
        this.writeInt16(t, e)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_INT32)
        this.buf.writeInt32(e)
    }
}
 
Taf.JceOutputStream.prototype.writeInt64 = function (t, e) {
    if (e >= -2147483648 && e <= 2147483647) {
        this.writeInt32(t, e)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_INT64)
        this.buf.writeInt64(e)
    }
}
 
Taf.JceOutputStream.prototype.writeUInt8 = function (t, e) {
    this.writeInt16(t, e)
}
 
Taf.JceOutputStream.prototype.writeUInt16 = function (t, e) {
    this.writeInt32(t, e)
}
 
Taf.JceOutputStream.prototype.writeUInt32 = function (t, e) {
    this.writeInt64(t, e)
}
 
Taf.JceOutputStream.prototype.writeFloat = function (t, e) {
    if (e == 0) {
        this.writeTo(t, Taf.DataHelp.EN_ZERO)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_FLOAT)
        this.buf.writeFloat(e)
    }
}
 
Taf.JceOutputStream.prototype.writeDouble = function (t, e) {
    if (e == 0) {
        this.writeTo(t, Taf.DataHelp.EN_ZERO)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_DOUBLE)
        this.buf.writeDouble(e)
    }
}
 
Taf.JceOutputStream.prototype.writeStruct = function (t, e) {
    if (e.writeTo == undefined) {
        throw Error("not defined writeTo Function")
    }
    this.writeTo(t, Taf.DataHelp.EN_STRUCTBEGIN)
    e.writeTo(this)
    this.writeTo(0, Taf.DataHelp.EN_STRUCTEND)
}
 
Taf.JceOutputStream.prototype.writeString = function (t, e) {
    var i = e
    try {
        i = unescape(encodeURIComponent(i))
    } catch (t) {
    }
    if (i.length > 255) {
        this.writeTo(t, Taf.DataHelp.EN_STRING4)
        this.buf.writeUInt32(i.length)
    } else {
        this.writeTo(t, Taf.DataHelp.EN_STRING1)
        this.buf.writeUInt8(i.length)
    }
    this.buf.writeString(i)
}
 
Taf.JceOutputStream.prototype.writeBytes = function (t, e) {
    if (!(e instanceof Taf.BinBuffer)) {
        throw Error("value not instanceof Taf.BinBuffer")
    }
    this.writeTo(t, Taf.DataHelp.EN_SIMPLELIST)
    this.writeTo(0, Taf.DataHelp.EN_INT8)
    this.writeInt32(0, e.length)
    this.buf.writeBytes(e)
}
 
Taf.JceOutputStream.prototype.writeVector = function (t, e) {
    this.writeTo(t, Taf.DataHelp.EN_LIST)
    this.writeInt32(0, e.value.length)
    for (var i = 0; i < e.value.length; i++) {
        e.proto._write(this, 0, e.value[i])
    }
}
 
Taf.JceOutputStream.prototype.writeMap = function (t, e) {
    this.writeTo(t, Taf.DataHelp.EN_MAP)
    this.writeInt32(0, e.size())
    for (var i in e.value) {
        e.kproto._write(this, 0, i)
        e.vproto._write(this, 1, e.value[i])
    }
}
 
Taf.JceInputStream = function (t) {
    this.buf = new Taf.BinBuffer(t)
}
 
Taf.JceInputStream.prototype.readFrom = function () {
    var t = this.buf.readUInt8()
    var e = (t & 240) >> 4
    var i = t & 15
    if (e >= 15)
        e = this.buf.readUInt8()
    return {
        tag: e,
        type: i
    }
}
 
Taf.JceInputStream.prototype.peekFrom = function () {
    var t = this.buf.position
    var e = this.readFrom()
    this.buf.position = t
    return {
        tag: e.tag,
        type: e.type,
        size: e.tag >= 15 ? 2 : 1
    }
}
 
Taf.JceInputStream.prototype.skipField = function (t) {
    switch (t) {
        case Taf.DataHelp.EN_INT8:
            this.buf.position += 1
            break
        case Taf.DataHelp.EN_INT16:
            this.buf.position += 2
            break
        case Taf.DataHelp.EN_INT32:
            this.buf.position += 4
            break
        case Taf.DataHelp.EN_INT64:
            this.buf.position += 8
            break
        case Taf.DataHelp.EN_STRING1:
            var e = this.buf.readUInt8()
            this.buf.position += e
            break
        case Taf.DataHelp.EN_STRING4:
            var i = this.buf.readInt32()
            this.buf.position += i
            break
        case Taf.DataHelp.EN_STRUCTBEGIN:
            this.skipToStructEnd()
            break
        case Taf.DataHelp.EN_STRUCTEND:
        case Taf.DataHelp.EN_ZERO:
            break
        case Taf.DataHelp.EN_MAP: {
            var r = this.readInt32(0, true)
            for (var n = 0; n < r * 2; ++n) {
                var s = this.readFrom()
                this.skipField(s.type)
            }
            break
        }
        case Taf.DataHelp.EN_SIMPLELIST: {
            var s = this.readFrom()
            if (s.type != Taf.DataHelp.EN_INT8) {
                throw Error("skipField with invalid type, type value: " + t + "," + s.type)
            }
            var e = this.readInt32(0, true)
            this.buf.position += e
            break
        }
        case Taf.DataHelp.EN_LIST: {
            var r = this.readInt32(0, true)
            for (var n = 0; n < r; ++n) {
                var s = this.readFrom()
                this.skipField(s.type)
            }
            break
        }
        default:
            throw new Error("skipField with invalid type, type value: " + t)
    }
}
 
Taf.JceInputStream.prototype.skipToStructEnd = function () {
    for (; ;) {
        var t = this.readFrom()
        this.skipField(t.type)
        if (t.type == Taf.DataHelp.EN_STRUCTEND) {
            return
        }
    }
}
 
Taf.JceInputStream.prototype.skipToTag = function (t, e) {
    while (this.buf.position < this.buf.length) {
        var i = this.peekFrom()
        if (t <= i.tag || i.type == Taf.DataHelp.EN_STRUCTEND) {
            return i.type == Taf.DataHelp.EN_STRUCTEND ? false : t == i.tag
        }
        this.buf.position += i.size
        this.skipField(i.type)
    }
    if (e)
        throw Error("require field not exist, tag:" + t)
    return false
}
 
Taf.JceInputStream.prototype.readBoolean = function (t, e, i) {
    return this.readInt8(t, e, i) == 1 ? true : false
}
 
Taf.JceInputStream.prototype.readInt8 = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    switch (r.type) {
        case Taf.DataHelp.EN_ZERO:
            return 0
        case Taf.DataHelp.EN_INT8:
            return this.buf.readInt8()
    }
    throw Error("read int8 type mismatch, tag:" + t + ", get type:" + r.type)
}
 
Taf.JceInputStream.prototype.readInt16 = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    switch (r.type) {
        case Taf.DataHelp.EN_ZERO:
            return 0
        case Taf.DataHelp.EN_INT8:
            return this.buf.readInt8()
        case Taf.DataHelp.EN_INT16:
            return this.buf.readInt16()
    }
    throw Error("read int8 type mismatch, tag:" + t + ", get type:" + r.type)
}
 
Taf.JceInputStream.prototype.readInt32 = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    switch (r.type) {
        case Taf.DataHelp.EN_ZERO:
            return 0
        case Taf.DataHelp.EN_INT8:
            return this.buf.readInt8()
        case Taf.DataHelp.EN_INT16:
            return this.buf.readInt16()
        case Taf.DataHelp.EN_INT32:
            return this.buf.readInt32()
    }
    throw Error("read int8 type mismatch, tag:" + t + ", get type:" + r.type)
}
 
Taf.JceInputStream.prototype.readInt64 = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    switch (r.type) {
        case Taf.DataHelp.EN_ZERO:
            return 0
        case Taf.DataHelp.EN_INT8:
            return this.buf.readInt8()
        case Taf.DataHelp.EN_INT16:
            return this.buf.readInt16()
        case Taf.DataHelp.EN_INT32:
            return this.buf.readInt32()
        case Taf.DataHelp.EN_INT64:
            return this.buf.readInt64()
    }
    throw Error("read int64 type mismatch, tag:" + t + ", get type:" + h.type)
}
 
Taf.JceInputStream.prototype.readFloat = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    switch (r.type) {
        case Taf.DataHelp.EN_ZERO:
            return 0
        case Taf.DataHelp.EN_FLOAT:
            return this.buf.readFloat()
    }
    throw Error("read float type mismatch, tag:" + t + ", get type:" + h.type)
}
 
Taf.JceInputStream.prototype.readDouble = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    switch (r.type) {
        case Taf.DataHelp.EN_ZERO:
            return 0
        case Taf.DataHelp.EN_DOUBLE:
            return this.buf.readDouble()
    }
    throw Error("read double type mismatch, tag:" + t + ", get type:" + h.type)
}
 
Taf.JceInputStream.prototype.readUInt8 = function (t, e, i) {
    return this.readInt16(t, e, i)
}
 
Taf.JceInputStream.prototype.readUInt16 = function (t, e, i) {
    return this.readInt32(t, e, i)
}
 
Taf.JceInputStream.prototype.readUInt32 = function (t, e, i) {
    return this.readInt64(t, e, i)
}
 
Taf.JceInputStream.prototype.readStruct = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    if (r.type != Taf.DataHelp.EN_STRUCTBEGIN) {
        return
    }
    // i.readFrom(this)
    // this.skipToStructEnd()
    // return i
 
    var new_instance = i.readFrom(this)
    this.skipToStructEnd()
    return new_instance
}
 
Taf.JceInputStream.prototype.readString = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    if (r.type == Taf.DataHelp.EN_STRING1) {
        return this.buf.readString(this.buf.readUInt8())
    }
    if (r.type == Taf.DataHelp.EN_STRING4) {
        return this.buf.readString(this.buf.readUInt32())
    }
    throw Error("read 'string' type mismatch, tag: " + t + ", get type: " + r.type + ".")
}
 
Taf.JceInputStream.prototype.readString2 = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    if (r.type == Taf.DataHelp.EN_STRING1) {
        return this.buf.readBytes(this.buf.readUInt8())
    }
    if (r.type == Taf.DataHelp.EN_STRING4) {
        return this.buf.readBytes(this.buf.readUInt32())
    }
    throw Error("read 'string' type mismatch, tag: " + t + ", get type: " + r.type + ".")
}
 
Taf.JceInputStream.prototype.readBytes = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    if (r.type == Taf.DataHelp.EN_SIMPLELIST) {
        var n = this.readFrom()
        if (n.type != Taf.DataHelp.EN_INT8) {
            throw Error("type mismatch, tag:" + t + ",type:" + r.type + "," + n.type)
        }
        var s = this.readInt32(0, true)
        if (s < 0) {
            throw Error("invalid size, tag:" + t + ",type:" + r.type + "," + n.type)
        }
        return this.buf.readBytes(s)
    }
    if (r.type == Taf.DataHelp.EN_LIST) {
        var s = this.readInt32(0, true)
        return this.buf.readBytes(s)
    }
    throw Error("type mismatch, tag:" + t + ",type:" + r.type)
}
 
Taf.JceInputStream.prototype.readVector = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    if (r.type != Taf.DataHelp.EN_LIST) {
        throw Error("read 'vector' type mismatch, tag: " + t + ", get type: " + r.type)
    }
    var n = this.readInt32(0, true)
    if (n < 0) {
        throw Error("invalid size, tag: " + t + ", type: " + r.type + ", size: " + n)
    }
    for (var s = 0; s < n; ++s) {
        i.value.push(i.proto._read(this, 0, i.proto._clone()))
    }
    return i
}
 
Taf.JceInputStream.prototype.readMap = function (t, e, i) {
    if (this.skipToTag(t, e) == false) {
        return i
    }
    var r = this.readFrom()
    if (r.type != Taf.DataHelp.EN_MAP) {
        throw Error("read 'map' type mismatch, tag: " + t + ", get type: " + r.type)
    }
    var n = this.readInt32(0, true)
    if (n < 0) {
        throw Error("invalid map, tag: " + t + ", size: " + n)
    }
    for (var s = 0; s < n; s++) {
        var a = i.kproto._read(this, 0, i.kproto._clone())
        var o = i.vproto._read(this, 1, i.vproto._clone())
        i.put(a, o)
    }
    return i
}
 
Taf.Wup = function () {
    this.iVersion = 3
    this.cPacketType = 0
    this.iMessageType = 0
    this.iRequestId = 0
    this.sServantName = ""
    this.sFuncName = ""
    this.sBuffer = new Taf.BinBuffer
    this.iTimeout = 0
    this.context = new Taf.Map(new Taf.STRING, new Taf.STRING)
    this.status = new Taf.Map(new Taf.STRING, new Taf.STRING)
    this.data = new Taf.Map(new Taf.STRING, new Taf.Map(new Taf.STRING, new Taf.BinBuffer))
    this.newdata = new Taf.Map(new Taf.STRING, new Taf.BinBuffer)
}
 
Taf.Wup.prototype.setVersion = function (t) {
    this.iVersion = t
}
 
Taf.Wup.prototype.getVersion = function (t) {
    return this.iVersion
}
 
Taf.Wup.prototype.setServant = function (t) {
    this.sServantName = t
}
 
Taf.Wup.prototype.setFunc = function (t) {
    this.sFuncName = t
}
 
Taf.Wup.prototype.setRequestId = function (t) {
    this.iRequestId = t ? t : ++this.iRequestId
}
 
Taf.Wup.prototype.getRequestId = function () {
    return this.iRequestId
}
 
Taf.Wup.prototype.setTimeOut = function (t) {
    this.iTimeout = t
}
 
Taf.Wup.prototype.getTimeOut = function () {
    return this.iTimeout
}
 
Taf.Wup.prototype.writeTo = function () {
    var t = new Taf.JceOutputStream
    t.writeInt16(1, this.iVersion)
    t.writeInt8(2, this.cPacketType)
    t.writeInt32(3, this.iMessageType)
    t.writeInt32(4, this.iRequestId)
    t.writeString(5, this.sServantName)
    t.writeString(6, this.sFuncName)
    t.writeBytes(7, this.sBuffer)
    t.writeInt32(8, this.iTimeout)
    t.writeMap(9, this.context)
    t.writeMap(10, this.status)
    return new Taf.BinBuffer(t.getBuffer())
}
 
Taf.Wup.prototype.encode = function () {
    var t = new Taf.JceOutputStream
    if (this.iVersion == 3) {
        t.writeMap(0, this.newdata)
    } else {
        t.writeMap(0, this.data)
    }
    this.sBuffer = t.getBinBuffer()
    var e = new Taf.BinBuffer
    e = this.writeTo()
    var i = new Taf.BinBuffer
    i.writeInt32(4 + e.len)
    i.writeBytes(e)
    return i
}
 
Taf.Wup.prototype.writeBoolean = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeBoolean(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.BOOLEAN
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Taf.BinBuffer(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeInt8 = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeInt8(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.CHAR
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Taf.BinBuffer(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeInt16 = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeInt16(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.SHORT
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeInt32 = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeInt32(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.INT32
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeInt64 = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeInt64(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.INT64
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeFloat = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeFloat(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.FLOAT
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeDouble = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeDouble(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = TAF.TypeHelp.DOUBLE
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeString = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeString(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = Taf.TypeHelp.STRING
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeVector = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeVector(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBinBuffer()))
    } else {
        var r = this.data.get(t)
        var n = e._className()
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeStruct = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeStruct(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = " "
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeBytes = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeBytes(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = "vec"
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.writeMap = function (t, e) {
    var i = new Taf.JceOutputStream
    i.writeMap(0, e)
    if (this.iVersion == 3) {
        this.newdata.put(t, new Taf.BinBuffer(i.getBuffer()))
    } else {
        var r = this.data.get(t)
        var n = Taf.Util.getClassType(e)
        if (r == undefined) {
            var s = new Taf.Map(Taf.STRING, Taf.STRING)
            r = s
        }
        r.put(n, new Uint8Array(i.getBuffer()))
        this.data.put(t, r)
    }
}
 
Taf.Wup.prototype.readFrom = function (t) {
    this.iVersion = t.readInt16(1, true)
    this.cPacketType = t.readInt8(2, true)
    this.iMessageType = t.readInt32(3, true)
    this.iRequestId = t.readInt32(4, true)
    this.sServantName = t.readString(5, true)
    this.sFuncName = t.readString(6, true)
    if (localStorage.__wup) {
        console.info("%c@@@ " + this.sServantName + "." + this.sFuncName, "color:whitebackground:black;", this)
    }
    this.sBuffer = t.readBytes(7, true)
    this.iTimeout = t.readInt32(8, true)
    this.context = t.readMap(9, true)
    this.status = t.readMap(10, true)
}
 
Taf.Wup.prototype.decode = function (t) {
    var e = new Taf.JceInputStream(t)
    var i = e.buf.vew.getInt32(e.buf.position)
    if (i < 4) {
        throw Error("packet length too short")
    }
    e.buf.position += 4
    this.readFrom(e)
    e = new Taf.JceInputStream(this.sBuffer.getBuffer())
    if (this.iVersion == 3) {
        this.newdata.clear()
        e.readMap(0, true, this.newdata)
    } else {
        this.data.clear()
        e.readMap(0, true, this.newdata)
    }
}
 
Taf.Wup.prototype.readBoolean = function (t) {
    var e, i
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = new Taf.JceInputStream(e.buffer)
        i = r.readBoolean(0, true, i)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = Taf.TypeHelp.BOOLEAN
        var s = e.get(n)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + n)
        }
        var r = new Taf.JceInputStream(s)
        i = r.readBoolean(0, true, i)
    }
    return i
}
 
Taf.Wup.prototype.readInt8 = function (t) {
    var e, i
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = new Taf.JceInputStream(e.buffer)
        i = r.readInt8(0, true, i)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = Taf.TypeHelp.CHAR
        var s = e.get(n)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + n)
        }
        var r = new Taf.JceInputStream(s)
        i = r.readInt8(0, true, i)
    }
    return i
}
 
Taf.Wup.prototype.readInt16 = function (t) {
    var e, i
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = new Taf.JceInputStream(e.buffer)
        i = r.readInt16(0, true, i)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = Taf.TypeHelp.SHORT
        var s = e.get(n)
        var r = new Taf.JceInputStream(s)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + n)
        }
        i = r.readInt16(0, true, i)
    }
    return i
}
 
Taf.Wup.prototype.readInt32 = function (t) {
    var e, i
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = new Taf.JceInputStream(e.buffer)
        i = r.readInt32(0, true, i)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = Taf.TypeHelp.INT32
        var s = e.get(n)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + n)
        }
        var r = new Taf.JceInputStream(s)
        i = r.readInt32(0, true, i)
    }
    return i
}
 
Taf.Wup.prototype.readInt64 = function (t) {
    var e, i
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = new Taf.JceInputStream(e.buffer)
        i = r.readInt64(0, true, i)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = Taf.TypeHelp.INT64
        var s = e.get(n)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + n)
        }
        var r = new Taf.JceInputStream(s)
        i = r.readInt64(0, true, i)
    }
    return i
}
 
Taf.Wup.prototype.readFloat = function (t) {
    var e, i
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = new Taf.JceInputStream(e.buffer)
        i = r.readFloat(0, true, i)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = Taf.TypeHelp.FLOAT
        var s = e.get(n)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + n)
        }
        var r = new Taf.JceInputStream(s)
        i = r.readFloat(0, true, i)
    }
    return i
}
 
Taf.Wup.prototype.readDouble = function (t) {
    let def;
    var e
    if (this.iVersion == 3) {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var i = new Taf.JceInputStream(e.buffer)
        def = i.readDouble(0, true, def)
    } else {
        e = this.newdata.get(t)
        if (e == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var r = Taf.TypeHelp.DOUBLE
        var n = e.get(r)
        if (n == undefined) {
            throw Error("UniAttribute not found type:" + r)
        }
        var i = new Taf.JceInputStream(n)
        def = i.readDouble(0, true, def)
    }
    return def
}
 
Taf.Wup.prototype.readVector = function (t, e, i) {
    var r
    if (this.iVersion == 3) {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = new Taf.JceInputStream(r.buffer)
        e = n.readVector(0, true, e)
    } else {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var s = r.get(i)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + i)
        }
        var n = new Taf.JceInputStream(s)
        e = n.readVector(0, true, e)
    }
    return e
}
 
Taf.Wup.prototype.readStruct = function (t, e, i) {
    var r
    if (this.iVersion == 3) {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = new Taf.JceInputStream(r.buffer)
        e = n.readStruct(0, true, e)
    } else {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var s = r.get(i)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + i)
        }
        var n = new Taf.JceInputStream(s)
        e = n.readStruct(0, true, e)
    }
    return e
}
 
Taf.Wup.prototype.readMap = function (t, e, i) {
    var r
    if (this.iVersion == 3) {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = new Taf.JceInputStream(r.buffer)
        e = n.readMap(0, true, e)
    } else {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var s = r.get(i)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + i)
        }
        var n = new Taf.JceInputStream(s)
        e = n.readMap(0, true, e)
    }
    return e
}
 
Taf.Wup.prototype.readBytes = function (t, e, i) {
    var r
    if (this.iVersion == 3) {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var n = new Taf.JceInputStream(r.buffer)
        e = n.readBytes(0, true, e)
    } else {
        r = this.newdata.get(t)
        if (r == undefined) {
            throw Error("UniAttribute not found key:" + t)
        }
        var s = r.get(i)
        if (s == undefined) {
            throw Error("UniAttribute not found type:" + i)
        }
        var n = new Taf.JceInputStream(s)
        e = n.readBytes(0, true, e)
    }
    return e
}
 
Taf.Util = Taf.Util || {}
Taf.Util.jcestream = function (t, e) {
    if (t == null || t == undefined) {
        console.log("Taf.Util.jcestream::value is null or undefined")
        return
    }
    if (!(t instanceof ArrayBuffer)) {
        console.log("Taf.Util.jcestream::value is not ArrayBuffer")
        return
    }
    e = e || 16
    var i = new Uint8Array(t)
    var r = ""
    for (var n = 0; n < i.length; n++) {
        if (n != 0 && n % e == 0) {
            r += "\n"
        } else if (n != 0) {
            r += " "
        }
        r += (i[n] > 15 ? "" : "0") + i[n].toString(16)
    }
    console.log(r.toUpperCase())
}
 
Taf.Util.str2ab = function (t) {
    var e, i = t.length, r = new Array(i)
    for (e = 0; e < i; ++e) {
        r[e] = t.charCodeAt(e)
    }
    return new Uint8Array(r).buffer
}
 
Taf.Util.ajax = function (t, e, i, r) {
    var n = new XMLHttpRequest
    n.overrideMimeType("text/plain charset=x-user-defined");
    var s = function () {
        if (n.readyState === 4) {
            if (n.status === 200 || n.status === 304) {
                i(Taf.Util.str2ab(n.response))
            } else {
                r(n.status)
            }
            n.removeEventListener("readystatechange", s)
            n = undefined
        }
    }
    n.addEventListener("readystatechange", s)
    n.open("post", t)
    n.send(e)
}
ab2hex = function (buffer) {
    const hexArr = Array.prototype.map.call(
        new Uint8Array(buffer),
        function (bit) {
            return ('00' + bit.toString(16)).slice(-2)
        }
    )
    return hexArr.join('')
}
 
function hex2ab(value) {
    var typedArray = new Uint8Array(value.match(/[\da-f]{2}/gi).map(function (h) {
        return parseInt(h, 16);
    }))
    return typedArray.buffer;
}
 
//组包方式的实现
function main() {
 
    var s = {};
    //定义 HomepageFeedsIconLabel1结构
    s.HomepageFeedsIconLabel1 = function () {
        this.sText = "ddd", this.iColor = 123456, this.usIconId = 0, this._classname = "MTT.HomepageFeedsIconLabel"
    }
    s.HomepageFeedsIconLabel1._classname = "MTT.HomepageFeedsIconLabel1"
    s.HomepageFeedsIconLabel1.write = function (e, t, i) {
        e.writeStruct(t, i)
    }
    s.HomepageFeedsIconLabel1.read = function (e, t, i) {
        return e.readStruct(t, !0, i)
    }
    s.HomepageFeedsIconLabel1.readFrom = function (e) {
        var t = new s.HomepageFeedsIconLabel1;
        t.sText = e.readString(0, !0, "");
        t.iColor = e.readInt32(1, !0, 1);
        t.usIconId = e.readUInt16(2, !1, 0);
        return t
    }
    s.HomepageFeedsIconLabel1.prototype.writeTo = function (e) {
        e.writeString(0, this.sText), e.writeInt32(1, this.iColor), e.writeUInt16(2, this.usIconId)
    }
 
    //定义 HomepageFeedsIconLabel1结构
    s.HomepageFeedsIconLabel = function () {
        this.sText = "ddd", this.iColor = 123456, this.usIconId = 0, this._classname = "MTT.HomepageFeedsIconLabel", this.demo = new s.HomepageFeedsIconLabel1()
    }
    s.HomepageFeedsIconLabel._classname = "MTT.HomepageFeedsIconLabel"
    s.HomepageFeedsIconLabel.write = function (e, t, i) {
        e.writeStruct(t, i)
    }
    s.HomepageFeedsIconLabel.read = function (e, t, i) {
        return e.readStruct(t, !0, i)
    }
    s.HomepageFeedsIconLabel.readFrom = function (e) {
        var t = new s.HomepageFeedsIconLabel;
        t.sText = e.readString(0, !0, "");
        t.iColor = e.readInt32(1, !0, 1);
        t.usIconId = e.readUInt16(2, !1, 0);
        t.stIcon = e.readStruct(3, !1, s.HomepageFeedsIconLabel1);
        return t
    }
    s.HomepageFeedsIconLabel.prototype.writeTo = function (e) {
        e.writeString(0, this.sText), e.writeInt32(1, this.iColor), e.writeUInt16(2, this.usIconId), e.writeStruct(3, this.demo);
    }
 
    //定义HomepageBookInfo结构
    s.HomepageBookInfo = function () {
        this.sPicUrl = "aaaaa", this.stIcon = new s.HomepageFeedsIconLabel, this._classname = "MTT.HomepageBookInfo"
    }, s.HomepageBookInfo._classname = "MTT.HomepageBookInfo", s.HomepageBookInfo._write = function (e, t, i) {
        e.writeStruct(t, i)
    }, s.HomepageBookInfo.read = function (e, t, i) {
        return e.readStruct(t, !0, i)
    }, s.HomepageBookInfo.readFrom = function (e) {
        var t = new s.HomepageBookInfo;
        t.sPicUrl = e.readString(0, !1, "");
        t.stIcon = e.readStruct(5, !1, s.HomepageFeedsIconLabel);
        return t
    }, s.HomepageBookInfo.prototype.writeTo = function (e) {
        e.writeString(0, this.sPicUrl);
        e.writeStruct(5, this.stIcon);
    }
 
    //得到jce的二进制数据
    const jceOutputStream1 = new Taf.JceOutputStream;
    var c = new s.HomepageBookInfo
    c.writeTo(jceOutputStream1);
    console.log(jceOutputStream1.getBuffer());
    //将jce的二进制数据解析位结构
    const jce = new Taf.JceInputStream(jceOutputStream1.getBuffer())
    t = s.HomepageBookInfo.readFrom(jce);
    console.log(JSON.stringify(t));
 
    return ab2hex(jceOutputStream1.getBuffer());
}
 
main()

代码很长,感谢你坚持到了这里。

 

图片描述


[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
点赞2
打赏
分享
最新回复 (3)
雪    币: 414
活跃值: (934)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
Andy_877594 2023-3-9 23:27
2
0
收藏等于看了
雪    币: 216
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
小木马 2023-3-13 15:03
3
0
有个工具叫PB-JCE解析工具,可以直接对jcestruct数据进行解析
雪    币: 39
活跃值: (4172)
能力值: ( LV3,RANK:35 )
在线值:
发帖
回帖
粉丝
ookkaa 2023-3-13 15:35
4
0
写的不错
游客
登录 | 注册 方可回帖
返回