-
Notifications
You must be signed in to change notification settings - Fork 0
/
bencode.asm
838 lines (736 loc) · 21.4 KB
/
bencode.asm
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (C) 2015 Ivan Baravy (dunkaist)
; Modified by Utsav Chokshi (Utsav_Chokshi)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; Description ;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;This file involves method which are helpful in decoding bencoded data.
;.torrent file and tracker response are the examples of bencoded data.
;Bencoding only supports four data types : byte strings, integers, lists, and dictionaries.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Procedure Area;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
proc torrent._.bdecode_dict _torrent, _dataend, _keytable
DEBUGF 2, "INFO : In torrent._.bdecode_dict\n"
.next_key:
cmp esi, [_dataend]
jae .quit
cmp byte[esi], 'e'
jz .quit
stdcall torrent._.bdecode_get_type
cmp al, BT_BENCODE_STR
jnz .error
stdcall torrent._.bdecode_readnum
DEBUGF 2,'key: %s\n',esi:eax
.value:
stdcall torrent._.bdecode_process_key, eax, [_keytable]
test eax, eax
jnz .found
DEBUGF 2,'skip\n'
stdcall torrent._.bdecode_skip_element
jmp .next_key
.found:
DEBUGF 2,'value: '
stdcall eax, [_torrent], ecx
jmp .next_key
.error:
DEBUGF 2,'ERROR: torrent.bdecode\n'
.quit:
ret
endp
;Converts string of numbers to number and stores in eax
proc torrent._.bdecode_readnum
push ebx ecx edx
xor eax, eax
xor edx, edx
xor ecx, ecx
.next_char:
lodsb
cmp al, '0'
jb .quit
cmp al, '9'
ja .quit
sub eax, '0'
imul ecx, 10
add ecx, eax
jmp .next_char
.quit:
mov eax, ecx
pop edx ecx ebx
ret
endp
;Identifies type[dictionary,list,integer,string] and stores in eax
proc torrent._.bdecode_get_type
movzx eax, byte[esi]
cmp al, 'd'
jnz @f
mov eax, BT_BENCODE_DICT
inc esi
jmp .quit
@@:
cmp al, 'l'
jnz @f
mov eax, BT_BENCODE_LIST
inc esi
jmp .quit
@@:
cmp al, 'i'
jnz @f
mov eax, BT_BENCODE_INT
inc esi
jmp .quit
@@:
cmp al, 'e'
jnz @f
mov eax, BT_BENCODE_END
inc esi
jmp .quit
@@:
mov eax, BT_BENCODE_STR
jmp .quit
.quit:
ret
endp
proc torrent._.bdecode_process_key _len, _keytable
mov eax, [_len]
mov edi, [_keytable]
.next:
movzx ecx, byte[edi]
test ecx, ecx
jnz @f
xor eax, eax
jmp .quit
@@:
cmp eax, ecx
jz @f
inc edi
add edi, ecx
add edi, 4
add edi, 4
jmp .next
@@:
inc edi
push esi
rep cmpsb
pop esi
jz @f
add edi, ecx
add edi, 4
add edi, 4
jmp .next
@@:
mov eax, [edi]
mov ecx, [edi+4]
.quit:
add esi, [_len]
ret
endp
proc torrent._.bdecode_announce _torrent, _arg
push ebx edi
mov ebx, [_torrent]
mov [ebx + torrent.trackers_cnt], 0
mov edi, [ebx + torrent.trackers]
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_STR
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
stdcall torrent._.bdecode_readnum
DEBUGF 2,'%s\n',esi:eax
mov [edi + tracker.announce_len], eax
add edi, tracker.announce
mov ecx, eax
rep movsb
mov byte[edi], 0
inc [ebx + torrent.trackers_cnt]
jmp .quit
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_announce_list _torrent, _arg
DEBUGF 2,'list\n'
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
mov ebx, [_torrent]
mov [ebx + torrent.trackers_cnt], 0
.next:
mov edi, [ebx + torrent.trackers]
mov eax, sizeof.tracker
imul eax, [ebx + torrent.trackers_cnt]
add edi, eax
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz @f
cmp eax, BT_BENCODE_END
jz .quit
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
stdcall torrent._.bdecode_readnum
DEBUGF 2,' %s\n',esi:eax
mov [edi + tracker.announce_len], eax
add edi, tracker.announce
mov ecx, eax
rep movsb
xor eax, eax
stosb
inc esi ; 'e'
inc [ebx + torrent.trackers_cnt]
jmp .next
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_skip_element
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz .list
cmp eax, BT_BENCODE_DICT
jz .dict
cmp eax, BT_BENCODE_STR
jz .str
cmp eax, BT_BENCODE_INT
jz .int
DEBUGF 3,'ERROR: bdecode_skip_element bad type\n'
jmp .error
.list:
cmp byte[esi], 'e'
jnz @f
inc esi
jmp .quit
@@:
stdcall torrent._.bdecode_skip_element
jmp .list
.dict:
cmp byte[esi], 'e'
jnz @f
inc esi
jmp .quit
@@:
stdcall torrent._.bdecode_skip_element
jmp .dict
.str:
stdcall torrent._.bdecode_readnum
add esi, eax
jmp .quit
.int:
stdcall torrent._.bdecode_readnum
jmp .quit
.error:
.quit:
ret
endp
proc torrent._.bdecode_httpseeds _torrent, _arg
DEBUGF 2,'list\n'
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
mov ebx, [_torrent]
mov [ebx + torrent.peers_cnt], 0
mov edx, [ebx + torrent.peers]
.next:
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_STR
jz @f
cmp eax, BT_BENCODE_END
jz .quit
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
xor eax, eax
mov [edx + peer.am_interested], al
mov [edx + peer.is_interested], al
inc eax
mov [edx + peer.am_choking], al
mov [edx + peer.is_choking], al
push edx
stdcall torrent._.bdecode_readnum
pop edx
DEBUGF 2,' %s\n',esi:eax
mov byte[edx + peer.protocol], BT_PEER_PROTOCOL_HTTP
lea edi, [edx + peer.url]
mov ecx, eax
rep movsb
inc [ebx + torrent.peers_cnt]
mov byte[edi], 0
add edx, sizeof.peer
jmp .next
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_info _torrent, _arg
locals
info_begin dd ?
info_end dd ?
info_len dd ?
;msglen dd ?
;hex rb 128
endl
DEBUGF 2,'dict\n'
push ebx edx edi
mov [info_begin], esi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_DICT
jz @f
DEBUGF 3,'ERROR: bdecode_info bad type: not a dict\n'
jmp .error
@@:
stdcall torrent._.bdecode_dict, [_torrent], -1, [_arg]
mov [info_end], esi
mov eax, esi
sub eax, [info_begin]
inc eax
mov [info_len], eax
mov ebx, [_torrent]
lea edx, [ebx + torrent.info_hash]
stdcall torrent._.generate_hash, [info_begin], [info_len] ,edx
;mov ebx, [_torrent]
;lea edx, [ebx + torrent.info_hash]
;mov [msglen], 0
;lea ecx, [msglen]
;push edx esi
;invoke crash.hash, LIBCRASH_SHA1, edx, [info_begin], [info_len], callback, ecx
;pop esi edx
;lea eax, [hex]
;push esi
;invoke crash.bin2hex, edx, eax, LIBCRASH_SHA1
;pop esi
;mov ebx, [_torrent]
;lea edx, [ebx + torrent.info_hash]
;lea eax, [hex]
.error:
.quit:
pop edi edx ebx
ret
endp
proc callback _left
xor eax, eax
ret
endp
proc torrent._.bdecode_string _torrent, _arg
stdcall torrent._.bdecode_readnum
DEBUGF 2,'%s\n',esi:eax
add esi, eax
ret
endp
proc torrent._.bdecode_info_name _torrent, _arg
push ebx edi
mov ebx, [_torrent]
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_STR
jz @f
DEBUGF 2,'ERROR: bad type\n'
jmp .error
@@:
stdcall torrent._.bdecode_readnum
DEBUGF 2,'%s\n',esi:eax
lea edi, [ebx + torrent.name]
mov ecx, eax
rep movsb
mov byte[edi], 0
cmp [ebx + torrent.files_cnt], 1
jne .quit
push esi
lea esi, [ebx + torrent.name]
mov edi, [ebx + torrent.files]
add edi, 4
mov ecx, eax
rep movsb
mov byte[edi], 0
pop esi
jmp .quit
.error:
.quit:
pop edi ebx
ret
ret
endp
proc torrent._.bdecode_info_piece_length _torrent, _arg
locals
blocklength_constant dd BLOCKLENGTH
endl
push ebx edx edi
mov ebx, [_torrent]
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_INT
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
stdcall torrent._.bdecode_readnum
DEBUGF 2,'%u\n',eax
mov [ebx + torrent.piece_length], eax
mov edx, 0
div [blocklength_constant]
mov [ebx + torrent.num_blocks], eax
jmp .quit
.error:
.quit:
pop edi edx ebx
ret
endp
proc torrent._.bdecode_info_length _torrent, _arg
push ebx edi
mov ebx, [_torrent]
mov [ebx + torrent.files_cnt], 1
invoke mem.alloc, (0x1000 * 1)
test eax, eax
jnz @f
DEBUGF 3,'ERROR: bdecode_info_length alloc\n'
jmp .error
@@:
mov [ebx + torrent.files], eax
mov edi, eax
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_INT
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
stdcall torrent._.bdecode_readnum
DEBUGF 2,'%d\n',eax
stosd
mov [ebx + torrent.left], eax
jmp .quit
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_info_pieces _torrent, _arg
DEBUGF 2,'list\n'
locals
byte_constant dw 8
endl
push ebx edx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_STR
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
;stores count of pieces
mov ebx, [_torrent]
stdcall torrent._.bdecode_readnum
xor edx, edx
mov edi, 20
div edi
mov [ebx + torrent.pieces_cnt], eax
DEBUGF 2, "INFO : piece count : %d\n", eax
;initializes bit-field
lea eax, [ebx + torrent.bitfield]
stdcall torrent._.init_bitfield, [_torrent], eax
mov eax, [ebx + torrent.pieces_cnt]
;allocates memory : (pieces_cnt*sizeof.piece)
xor edx, edx
mov ecx, sizeof.piece
mul ecx
push ecx
invoke mem.alloc, eax
pop ecx
test eax, eax
jnz @f
DEBUGF 3,'ERROR: bdecode_pieces alloc\n'
jmp .error
;fills piece structure
@@: mov [ebx + torrent.pieces], eax
stdcall piece._.fill_all_pieces, [_torrent], eax
;print first piece
DEBUGF 2, "First Piece\n"
mov eax, [ebx + torrent.pieces]
DEBUGF 2, "Index : %d\n", [eax+piece.index]
push edx
lea edx, [eax+piece.piece_hash]
DEBUGF 2, "Hash : %x%x%x%x%x\n", [edx+0x0],[edx+0x4],[edx+0x8],[edx+0xc],[edx+0x10]
pop edx
DEBUGF 2, "Download Status : %d\n", [eax+piece.download_status]
DEBUGF 2, "Blocks downloaded : %d\n", [eax+piece.num_blocks_downloaded]
DEBUGF 2, "Number of offsets : %d\n", [eax+piece.num_offsets]
DEBUGF 2, "Piece Offset : %d\n", [eax+piece.piece_offset]
DEBUGF 2, "Length : %d\n", [eax+piece.length]
DEBUGF 2, "File Offset : %d\n", [eax+piece.file_offset]
DEBUGF 2, "File Index : %d\n", [eax+piece.file_index]
;print last piece
DEBUGF 2, "Last Piece\n"
mov ecx, [ebx+torrent.pieces_cnt]
dec ecx
imul ecx, sizeof.piece
add eax, ecx
DEBUGF 2, "Index : %d\n", [eax+piece.index]
push edx
lea edx, [eax+piece.piece_hash]
DEBUGF 2, "Hash : %x%x%x%x%x\n", [edx+0x0],[edx+0x4],[edx+0x8],[edx+0xc],[edx+0x10]
pop edx
DEBUGF 2, "Download Status : %d\n", [eax+piece.download_status]
DEBUGF 2, "Blocks downloaded : %d\n", [eax+piece.num_blocks_downloaded]
DEBUGF 2, "Number of offsets : %d\n", [eax+piece.num_offsets]
DEBUGF 2, "Piece Offset : %d\n", [eax+piece.piece_offset]
DEBUGF 2, "Length : %d\n", [eax+piece.length]
DEBUGF 2, "File Offset : %d\n", [eax+piece.file_offset]
DEBUGF 2, "File Index : %d\n", [eax+piece.file_index]
;stdcall piece._.set_piece, [_torrent], 1,
jmp .quit
.error:
.quit:
pop edi edx ebx
ret
endp
proc torrent._.bdecode_info_files _torrent, _arg
DEBUGF 2,'list\n'
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
mov ebx, [_torrent]
invoke mem.alloc, (0x1000 * 1000)
test eax, eax
jnz @f
DEBUGF 3,'ERROR: bdecode_info_files alloc\n'
jmp .error
@@:
mov [ebx + torrent.files], eax
mov [ebx + torrent.files_cnt], 0
.next:
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_DICT
jz @f
cmp eax, BT_BENCODE_END
jz .quit
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
stdcall torrent._.bdecode_dict, [_torrent], -1, [_arg]
inc esi
jmp .next
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_info_files_length _torrent, _arg
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_INT
jz @f
DEBUGF 3,'ERROR: bad type\n'
jmp .error
@@:
mov ebx, [_torrent]
stdcall torrent._.bdecode_readnum
mov edi, [ebx + torrent.files_cnt]
imul edi, 0x1000
add edi, [ebx + torrent.files]
stosd
add [ebx + torrent.left], eax
DEBUGF 2,'%d\n',eax
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_info_files_path _torrent, _arg
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz @f
DEBUGF 3,'ERROR: bad type not a list\n'
jmp .error
@@:
mov ebx, [_torrent]
mov edi, [ebx + torrent.files_cnt]
imul edi, 0x1000
add edi, 4
add edi, [ebx + torrent.files]
.next:
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_STR
jz @f
cmp eax, BT_BENCODE_END
jz .quit
DEBUGF 3,'ERROR: bad type not a string\n'
jmp .error
@@:
stdcall torrent._.bdecode_readnum
mov ecx, eax
rep movsb
mov al, '/'
stosb
jmp .next
.error:
.quit:
mov byte[edi-1], 0
mov edi, [ebx + torrent.files_cnt]
imul edi, 0x1000
add edi, 4
add edi, [ebx + torrent.files]
DEBUGF 2,'%s\n',edi
inc [ebx + torrent.files_cnt]
pop edi ebx
ret
endp
proc torrent._.bdecode_tracker_interval _torrent, _arg
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_INT
jz @f
DEBUGF 3,'ERROR: bad type not an int\n'
jmp .error
@@:
mov ebx, [_torrent]
mov edx, [ebx + torrent.trackers]
stdcall torrent._.bdecode_readnum
mov [edx + tracker.interval], eax
DEBUGF 2,'%d\n',eax
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_tracker_min_interval _torrent, _arg
push ebx edi
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_INT
jz @f
DEBUGF 3,'ERROR: bad type not an int\n'
jmp .error
@@:
mov ebx, [_torrent]
mov edx, [ebx + torrent.trackers]
stdcall torrent._.bdecode_readnum
mov [edx + tracker.min_interval], eax
DEBUGF 2,'%d\n',eax
.error:
.quit:
pop edi ebx
ret
endp
proc torrent._.bdecode_tracker_peers _torrent, _arg
push ebx edi
mov ebx, [_torrent]
stdcall torrent._.bdecode_get_type
cmp eax, BT_BENCODE_LIST
jz .nocompact
cmp eax, BT_BENCODE_STR
jz .compact
DEBUGF 3,'ERROR: bad type not a list or string\n'
jmp .error
.nocompact:
DEBUGF 2,'nocompact\n'
DEBUGF 3,'ERROR: nocompact is not implemented\n'
jmp .error
.compact:
DEBUGF 2,'compact\n'
mov edi, [ebx + torrent.peers]
mov eax, [ebx + torrent.peers_cnt]
imul eax, sizeof.peer
add edi, eax
stdcall torrent._.bdecode_readnum
xor edx, edx
mov ecx, 6 ; ipv4 + port
div ecx
test edx, edx
jnz .error
add [ebx + torrent.peers_cnt], eax
mov ecx, eax
.next_peer:
jecxz .quit
xor eax, eax
mov [edi + peer.am_interested], al
mov [edi + peer.is_interested], al
mov [edi + peer.peer_id_present], eax
inc eax
mov [edi + peer.am_choking], al
mov [edi + peer.is_choking], al
mov [edi + peer.cur_piece], -1
lea eax, [edi + peer.bitfield]
stdcall torrent._.init_bitfield, [_torrent], eax
lodsd
;bswap eax
mov [edi + peer.ipv4], eax
xor eax, eax
lodsw
xchg al, ah
mov [edi + peer.port], eax
add edi, sizeof.peer
dec ecx
jmp .next_peer
.error:
DEBUGF 3,'ERROR: bdecode_tracker_peers\n'
.quit:
DEBUGF 3,'bdecode_tracker_peers done: %d\n',[ebx + torrent.peers_cnt]
pop edi ebx
ret
endp
known_keys_0:
db 8, 'announce'
dd torrent._.bdecode_announce, 0
db 13, 'announce-list'
dd torrent._.bdecode_announce_list, 0
db 7, 'comment'
dd torrent._.bdecode_string, 0
db 9, 'httpseeds'
dd torrent._.bdecode_httpseeds, 0
db 4, 'info'
dd torrent._.bdecode_info, known_keys_info
db 0
known_keys_info:
db 5, 'files'
dd torrent._.bdecode_info_files, known_keys_files
db 6, 'length'
dd torrent._.bdecode_info_length, 0
db 4, 'name'
dd torrent._.bdecode_info_name, 0
db 12, 'piece length'
dd torrent._.bdecode_info_piece_length, 0
db 6, 'pieces'
dd torrent._.bdecode_info_pieces, 0
db 0
known_keys_files:
db 6, 'length'
dd torrent._.bdecode_info_files_length, 0
db 4, 'path'
dd torrent._.bdecode_info_files_path, 0
db 0
keys_tracker_response0:
db 8, 'interval'
dd torrent._.bdecode_tracker_interval, 0
db 12, 'min interval'
dd torrent._.bdecode_tracker_min_interval, 0
db 5, 'peers'
dd torrent._.bdecode_tracker_peers, keys_tracker_response_peers
db 0
keys_tracker_response_peers:
db 0