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
| .686
.model flat,stdcall
option casemap:none
include web_to_offline.inc
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
CONSTANT readme db '\readme.htm',0
invoke GetCurrentDirectory,sizeof InitDir,addr InitDir
invoke crt_strcat,addr InitDir,addr readme
invoke GetCommandLine
invoke InitCommonControls
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,IDM_MENU
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
mov hThread,NULL
mov ThreadID,NULL
.elseif eax==WM_COMMAND
mov eax,wParam
mov edx,lParam
and eax,0FFFFh
.if !edx
.if eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDM_LOAD
invoke CreateThread,NULL,128 shl 10,offset StartLoad,hWin,NULL,addr ThreadID
mov hThread,eax
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
.elseif eax==IDM_HELP
CONSTANT open db 'open',0
invoke ShellExecute,hWin,addr open,addr InitDir,NULL,addr InitDir,SW_SHOW
.endif
.else
.if eax==START_BUTTON
invoke CreateThread,NULL,128 shl 10,offset StartLoad,hWin,NULL,addr ThreadID
mov hThread,eax
.elseif eax==DIR_BUTTON ;ÂÛÁÎÐ ÏÀÏÊÈ
STATIC ChooseDir db 'Âûáåðèòå ïàïêó, æåëàòåëüíî ïóñòóþ.',0
STATIC binf BROWSEINFO !<0,0,0,offset ChooseDir,1,0,0,0!>
mov eax,hWnd
mov binf.hwndOwner,eax
invoke SHBrowseForFolder,addr binf
.if eax
invoke SHGetPathFromIDList,eax,addr StartDir
invoke SetDlgItemText,hWnd,START_DIR,addr StartDir
.endif
.elseif eax==STOP_BUTTON
invoke GetDlgItem,hWin,STOP_BUTTON
invoke EnableWindow,eax,FALSE
invoke GetDlgItem,hWin,CONT_BUTTON
invoke EnableWindow,eax,TRUE
mov Stop,TRUE
STATIC Paused db 'Ïðèîñòàíîâëåíî...',0
invoke SetDlgItemText,hWin,ERR_OUTPUT,offset Paused
.elseif eax==CONT_BUTTON
invoke GetDlgItem,hWin,CONT_BUTTON
invoke EnableWindow,eax,FALSE
invoke GetDlgItem,hWin,STOP_BUTTON
invoke EnableWindow,eax,TRUE
mov Stop,NULL
STATIC Continue db 'Âîçîáíîâëåíî...',0
invoke SetDlgItemText,hWin,ERR_OUTPUT,addr Continue
.endif
.endif
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
;ÑÒÀÐÒÎÂÀß ÔÓÍÊÖÈß ÇÀÃÐÓÇÊÈ HTML ÑÒÐÀÍÈÖ
StartLoad proc uses edi esi ebx hWin
LOCAL FFile:HTML
invoke GetDlgItemInt,hWin,LEVEL_LOAD,NULL,FALSE
mov LevelLoad,eax
invoke GetDlgItemInt,hWin,MAX_FILE_SIZE,NULL,FALSE
shl eax,10
mov MaxFileSize,eax
invoke GetDlgItemText,hWin,R_ZONE,addr Zone,sizeof Zone
invoke crt_strlen,addr Zone
mov lenZone,eax
invoke GetDlgItemText,hWin,START_URL,addr StartUrl,sizeof StartUrl
mov eax,offset StartUrl
mov FFile.URL,eax
invoke GetDlgItemText,hWin,START_DIR,offset StartDir,sizeof StartDir
;invoke MakeSureDirectoryPathExists,addr StartDir
invoke SetCurrentDirectory,offset StartDir
invoke crt_strcpy,offset FirstFile,offset StartUrl[7]
mov eax,offset FirstFile
mov FFile.PATH,eax
invoke crt_strrchr,eax,'/'
.if eax && !byte ptr [eax+1]
mov dword ptr [eax+1],'edni'
mov dword ptr [eax+5],'th.x'
mov dword ptr [eax+9],'lm'
.endif
invoke ReplaceUnwantedChars,FFile.PATH
invoke GetDlgItemInt,hWin,MAX_FILE_NUM,NULL,FALSE
mov MaxFileNum,eax
lea eax,[4*eax+4]
invoke VirtualAlloc,NULL,eax,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov pArrayOfUnique,eax
mov ecx,MaxFileNum
inc ecx
mov edi,eax
mov eax,1
;int 3
rep stosd
mov eax,pArrayOfUnique
mov edx,FFile.PATH
mov [eax],edx
CONSTANT logfile db 'logfile.txt',0
invoke CreateFile,addr logfile,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,0,0
.if eax==INVALID_HANDLE_VALUE
invoke CreateFile,addr logfile,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,0,0
.endif
mov hLog,eax
invoke GetFileSize,eax,NULL
mov sizeLog,eax
invoke VirtualAlloc,NULL,MAX_LOG_SIZE,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov pLog,eax
invoke ReadFile,hLog,pLog,sizeLog,addr dwWrite,NULL
mov eax,pLog
add eax,sizeLog
mov byte ptr [eax],0
CONSTANT FirstPattern db 'Ïåðâûé URL: %s',13,10,\
'Ïåðâûé ôàéë: %s',13,10,\
'****',13,10,0
mov eax,pLog
add eax,sizeLog
mov pCurrLog,eax
invoke crt_sprintf,eax,addr FirstPattern,FFile.URL,FFile.PATH
add pCurrLog,eax
invoke WebLoad,addr FFile
mov esi,pArrayOfUnique
.while dword ptr [esi]!=1
invoke VirtualFree,dword ptr [esi],MAX_SIZE,MEM_DECOMMIT
add esi,4
.endw
mov eax,MaxFileNum
lea eax,[4*eax+4]
invoke VirtualFree,pArrayOfUnique,eax,MEM_DECOMMIT
STATIC EndWork db 'Çàãðóçêà çàâåðøåíà.',0
STATIC Ready db 'Ãîòîâî',0
invoke MessageBox,hWnd,addr EndWork,addr Ready,MB_ICONEXCLAMATION
invoke SetFilePointer,hLog,0,0,FILE_BEGIN
invoke crt_strlen,pLog
invoke WriteFile,hLog,pLog,eax,addr dwWrite,NULL
invoke VirtualFree,pLog,MAX_LOG_SIZE,MEM_DECOMMIT
ret
StartLoad endp
;PEÊÓÐÑÈÂÍÀß ÔÓÍÊÖÈß ÇÀÃÐÓÇÊÈ HTML ÑÒÐÀÍÈÖ
WebLoad proc uses ebx esi psHtm:DWORD
LOCAL NextFile:HTML
assume ebx:ptr HTML
;int 3
mov ebx,psHtm
mov [ebx].fBase,NULL
dec LevelLoad
.if !SIGN?
invoke LoadHtm,ebx
.if !eax
inc LevelLoad
ret
.endif
invoke IsHtml,ebx
.if eax
invoke GetCurrentBase,ebx
.while TRUE
invoke PrepareNextUrl,addr NextFile,ebx
.break .if !eax
push ebx
lea ebx,NextFile
mov ebx,[ebx].PATH
mov esi,pArrayOfUnique
.repeat
mov eax,dword ptr [esi]
.break .if eax==1
;int 3
invoke crt_strcmp,ebx,eax
add esi,4
.until !eax
.if !eax
invoke GetFileAttributes,ebx
.if eax!=INVALID_HANDLE_VALUE
xor eax,eax
.endif
.endif
mov ecx,ebx
pop ebx
.if eax
mov dword ptr [esi],ecx
;invoke crt__ltoa,LevelLoad,addr ErrBuff,10
;invoke MessageBox,0,addr ErrBuff,NextFile.URL,MB_OK
invoke WebLoad,addr NextFile
;invoke crt__ltoa,LevelLoad,addr ErrBuff,10
;invoke MessageBox,0,addr ErrBuff,NextFile.URL,MB_OK
;mov dword ptr [esi],1
.endif
.endw
.endif
invoke SaveFile,ebx
.elseif LevelLoad==0FFFFFFFFh
invoke LoadHtm,ebx
.if !eax
inc LevelLoad
ret
.endif
invoke SaveFile,ebx
.endif
inc LevelLoad
ret
assume ebx:nothing
WebLoad endp
SaveFile proc uses ebx psHtm:DWORD
assume ebx:ptr HTML
mov ebx,psHtm
invoke SetFilePointer,[ebx].hFile,0,0,FILE_BEGIN
invoke WriteFile,[ebx].hFile,[ebx].lpCode,[ebx].cSize,offset dwRW,NULL
invoke SetEndOfFile,[ebx].hFile
invoke CloseHandle,[ebx].hFile
invoke VirtualFree,[ebx].lpCode,[ebx].BufferSize,MEM_DECOMMIT
mov eax,[ebx].fBase
.if eax
invoke VirtualFree,[ebx].fBase,MAX_SIZE,MEM_DECOMMIT
invoke VirtualFree,[ebx].uBase,MAX_SIZE,MEM_DECOMMIT
.endif
invoke VirtualFree,[ebx].URL,MAX_SIZE,MEM_DECOMMIT
;invoke VirtualFree,[ebx].PATH,MAX_SIZE,MEM_DECOMMIT
ret
assume ebx:nothing
SaveFile endp
IsHtml proc psHtm:DWORD
assume ecx:ptr HTML
mov ecx,psHtm
mov eax,[ecx].cSize
mov ecx,[ecx].lpCode
.if eax>200h
mov eax,200h
.endif
.if !eax
ret
.endif
.repeat
mov edx,dword ptr [ecx]
or edx,20202020h
.break .if edx=='lmth'
inc ecx
dec eax
.until ZERO?
ret
assume ecx:nothing
IsHtml endp
LoadHtm proc uses ebx psHtm:DWORD
assume ebx:ptr HTML
mov ebx,psHtm
mov edx,[ebx].cSize
.if edx>MaxFileSize || edx==0FFFFFFFFh
xor eax,eax
ret
.endif
invoke GetFileAttributes,[ebx].PATH
inc eax
.if ZERO?
invoke MakeSureDirectoryPathExists,[ebx].PATH
invoke URLDownloadToFile,0,[ebx].URL,[ebx].PATH,0,0
.if eax
xor eax,eax
ret
.endif
.while Stop ;ÅÑËÈ ÊÍÎÏÊÀ ÏÀÓÇÛ ÁÛËÀ ÍÀÆÀÒÀ
invoke Sleep,10000
.endw
.endif
RESERV CurrWide db 8192 dup(?)
invoke crt_mbstowcs,addr CurrWide,[ebx].PATH,sizeof CurrWide shr 1
invoke CreateFileW,addr CurrWide,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,0,0
mov [ebx].hFile,eax
invoke GetFileSize,eax,NULL
mov [ebx].cSize,eax
.if eax<10 || [ebx].hFile==INVALID_HANDLE_VALUE
invoke CloseHandle,[ebx].hFile
xor eax,eax
ret
.endif
add eax,1000h ;ÎÄÍÀ ÑÒÐÀÍÈÖÀ ÏÐÎ ÇÀÏÀÑ
mov [ebx].BufferSize,eax
invoke VirtualAlloc,NULL,eax,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov [ebx].lpCode,eax
mov [ebx].lpSearch,eax ;ÈÍÈÖÈÀËÈÇÀÖÈß ÓÊÀÇÀÒÅËß ÄËß ÏÎÈÑÊÀ
invoke ReadFile,[ebx].hFile,eax,[ebx].cSize,offset dwRW,NULL ;×ÒÅÍÈÅ ÔÀÉËÀ ÖÅËÈÊÎÌ
mov eax,[ebx].lpCode
add eax,[ebx].cSize
mov byte ptr [eax],0 ;HTML ÔÀÉË ÁÓÄÅÒ ÏÐÎÑÒÎ ÄËÈÍÎÉ ÑÒÐÎÊÎÉ ÎÃÐÀÍÈ×ÅÍÍÎÉ ÍÓËÅÂÛÌ ÁÀÉÒÎÌ
ret
assume ebx:nothing
LoadHtm endp
;ôóíêöèÿ äëÿ ïîèñêà áàçû â ñêà÷àíîì html ôàéëå
GetCurrentBase proc uses esi ebx psHtm:DWORD
LOCAL eaxr:DWORD, ecxr:DWORD, edxr:DWORD
LOCAL BeginBase,EndBase
assume esi:ptr HTML
mov BeginBase,0
mov esi,psHtm
mov ecx,[esi].cSize
mov eax,[esi].lpCode
.repeat
inc eax
dec ecx
jz BaseIsNotExist
mov edx,[eax]
or edx,20202020h
cmp edx,'sab<'
je BaseIsExist
.until edx=='dob<'
BaseIsNotExist:
invoke lstrlen,[esi].PATH
add eax,7
mov ecxr,eax
call AllocStrings
invoke lstrcpy,eax,[esi].PATH
mov ecx,ecxr
.repeat
dec ecx
.break .if SIGN?
.until byte ptr [eax+ecx]=='\'
inc ecx
mov byte ptr [eax+ecx],0
mov eax,[esi].uBase
mov dword ptr [eax],'ptth'
mov dword ptr [eax+3],'//:p'
add eax,7
invoke lstrcpy,eax,[esi].fBase
jmp ExitProc
BaseIsExist:
mov edx,eax
xor ecx,ecx
.repeat
inc edx
inc ecx
.until byte ptr [edx]=='>'
mov BeginBase,eax
mov EndBase,edx
.repeat
dec ecx
jz BaseIsNotExist
inc eax
mov ebx,dword ptr [eax]
or ebx,020202020h
.until ebx=='=fer'
SelectBase:
add eax,4
mov edx,eax
xor ecx,ecx
mov ax,' "'
.if byte ptr [edx]=='"'
mov ah,'"'
.endif
BaseLength:
inc edx
inc ecx
cmp byte ptr [edx],ah
jz LengthReady
cmp byte ptr [edx],al
jz LengthReady
cmp byte ptr [edx],'>'
jnz BaseLength
LengthReady:
mov eax,edx
sub eax,ecx
.if byte ptr [eax]=='"'
inc eax
dec ecx
.endif
mov eaxr,eax
mov ecxr,ecx
mov edxr,edx
call AllocStrings
mov edx,edxr
mov cl,byte ptr [edx]
mov byte ptr [edx],0
push ecx
mov ecx,eaxr
.if dword ptr [ecx]=='ptth'
add ecx,7
.endif
invoke lstrcpy,[esi].fBase,ecx
mov ecx,[esi].fBase
call LeftSplash
mov edx,eaxr
mov eax,[esi].uBase
mov ecx,'http'
.if dword ptr [edx]!=ecx
mov dword ptr [eax],ecx
mov dword ptr [eax+3],'//:p'
add eax,7
.endif
invoke lstrcpy,eax,eaxr
pop ecx
mov edx,edxr
mov byte ptr [edx],cl
mov ecx,[esi].uBase
call RightSplash
invoke crt_strrchr,[esi].uBase,'/'
.if word ptr [eax-2]=='/:'
.repeat
inc eax
.until !byte ptr [eax]
mov word ptr [eax],'/'
mov eax,[esi].fBase
.repeat
inc eax
.until !byte ptr [eax]
mov word ptr [eax],'\'
.endif
STATIC BeginComment db '<!--',0
STATIC EndComment db '-->',0
mov eax,BeginBase
.if eax && dword ptr [eax-4]!='--!>'
add EndBase,sizeof BeginComment
invoke InsertString,esi,eax,addr BeginComment
invoke InsertString,esi,EndBase,addr EndComment
.endif
ret
AllocStrings:
invoke VirtualAlloc,NULL,ecxr,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov [esi].uBase,eax
invoke VirtualAlloc,NULL,ecxr,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov [esi].fBase,eax
retn
ExitProc:
mov ecx,[esi].uBase
call RightSplash
invoke crt_strrchr,[esi].uBase,'/'
.if word ptr [eax-2]=='/:'
.repeat
inc eax
.until !byte ptr [eax]
mov word ptr [eax],'/'
mov eax,[esi].fBase
.repeat
inc eax
.until !byte ptr [eax]
mov word ptr [eax],'\'
.endif
ret
assume esi:nothing
GetCurrentBase endp
RightSplash proc
.repeat
inc ecx
.if byte ptr [ecx]=='\'
mov byte ptr [ecx],'/'
.endif
.until byte ptr [ecx]==0
ret
RightSplash endp
LeftSplash proc
.repeat
inc ecx
.if byte ptr [ecx]=='/'
mov byte ptr [ecx],'\'
.endif
.until byte ptr [ecx]==0
ret
LeftSplash endp
refstr db 'href="',0
;ÂÑÒÀÂÊÀ ÑÒÐÎÊÈ Â ÁÓÔÅÐ Ñ ÒÅÊÑÒÎÌ
InsertString proc uses ebx psHtm,pMem,pStr
LOCAL Len
assume ebx:ptr HTML
mov ebx,psHtm
invoke crt_strlen,pStr
mov Len,eax
mov edx,pMem
mov ecx,[ebx].lpCode
sub edx,ecx
mov ecx,[ebx].cSize
sub ecx,edx ;Â ecx ÐÀÇÌÅÐ ÒÅÊÑÒÀ ÊÎÒÎÐÛÉ ÍÓÆÍÎ ÏÅÐÅÌÅÑÒÈÒÜ
mov edx,[ebx].cSize
add edx,Len
.if edx<[ebx].BufferSize ;ÐÀÇÌÅÐ ÒÅÊÑÒÀ ÍÅ ÄÎËÆÅÍ ÁÛÒÜ ÁÎËÜØÅ ÁÓÔÅÐÀ Â ÊÎÒÎÐÎÌ ÎÍ ÍÀÕÎÄÈÒÑß
mov [ebx].cSize,edx
mov edx,pMem
add edx,Len
invoke crt_memmove,edx,pMem,ecx
invoke crt_memmove,pMem,pStr,Len
mov eax,TRUE
.else
mov eax,FALSE
.endif
ret
assume ebx:nothing
InsertString endp
;ÂÛÄÅËÅÍÈÅ ÑÑÛËÊÈ Â ÁÓÔÅÐÅ Ñ HTML ÊÎÄÎÌ
SelectNextUrl proc uses ebx esi edi psHtm2:DWORD, psHtm:DWORD
assume ebx:ptr HTML
assume esi:ptr HTML
LOCAL BeginTag,EndTag ;ÓÊÀÇÀÒÅËÈ ÍÀ ÃÐÀÍÈÖÛ ÎÄÈÍÎ×ÍÛÕ ÒÝÃÎÂ
mov ebx,psHtm
mov esi,psHtm2
mov [esi].URL,0
.while TRUE
invoke crt_strchr,[ebx].lpSearch,'<'
.break .if !eax
mov BeginTag,eax
invoke crt_strchr,eax,'>'
.break .if !eax
mov EndTag,eax ;ÍÀÉÄÅÍ È ÂÛÄÅËÅÍ ÒÝÃ
mov byte ptr [eax],0
mov eax,BeginTag
.while TRUE ;ÏÎÈÑÊ Â ÒÝÃÅ ÑÑÛËÊÈ
invoke crt_strchr,eax,'='
.break .if !eax
inc eax
.continue .if byte ptr [eax]=="'"
xor ecx,ecx
cmp byte ptr [eax],'"'
setz cl
mov edx,[eax+ecx]
or edx,20202020h
mov edi,[eax-5]
or edi,20202020h
.break .if edi=='ferh' && byte ptr [eax-6]!='.' && !(edx=='liam' && byte ptr [eax+ecx][6]==':')
mov edi,[eax-4] ;ÌÛËÜÍÈÊÈ ÏÐÎÏÓÑÊÀÞÒÑß
or edi,20202020h
.break .if edi=='=crs' && byte ptr [eax-5]!='.'
.endw
mov ecx,BeginTag
mov ecx,[ecx+1]
or ecx,20202020h
.if eax && (dword ptr [eax]=='ptth' || dword ptr [eax+1]=='ptth') && edi!='=crs' && ecx!='knil' && Zone
mov edi,eax
invoke crt_strstr,eax,addr Zone
.if eax
mov edx,eax
add edx,lenZone
.repeat
dec eax
.until byte ptr [eax]=='/' || eax<=edi
xor ecx,ecx
.if word ptr [eax-2]=='/:' && (byte ptr [edx]=='/' || byte ptr [edx]=='"' || byte ptr [edx]==' ')
mov eax,edi
.endif
cmovne eax,ecx
.endif
.endif
.if eax
mov edi,eax
.if byte ptr [eax]=='"'
inc edi
invoke crt_strchr,edi,'"'
or eax,eax
jz @F
sub eax,edi
call AllocString
.else
@@: invoke crt_strchr,edi,' '
.if !eax
mov eax,EndTag
sub eax,edi
call AllocString
.else
sub eax,edi
call AllocString
.endif
.endif
mov eax,edi
.endif
mov edx,EndTag
mov [ebx].lpSearch,edx
.if !byte ptr [edx]
mov byte ptr [edx],'>'
.endif
mov edi,eax
.if [esi].URL
invoke crt_strchr,[esi].URL,"'"
.if eax
xor edi,edi
.endif
invoke crt_strrchr,[esi].URL,'#'
.if eax
mov byte ptr [eax],0
mov eax,[ebx].lpSearch
.while byte ptr [eax]!='#'
dec eax
.endw
mov [ebx].lpSearch,eax
.endif
.endif
mov eax,edi
.break .if eax
.endw
ret
AllocString:
push eax
.if ![esi].URL
invoke VirtualAlloc,NULL,MAX_SIZE,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov [esi].URL,eax
.endif
mov ecx,[esp]
invoke crt_strncpy,[esi].URL,edi,ecx
mov edx,EndTag
mov byte ptr [edx],'>'
pop edx
add edx,edi
mov EndTag,edx
retn
assume esi:nothing
assume ebx:nothing
SelectNextUrl endp
PrepareNextUrl proc uses ebx esi edi psNextHtm:DWORD, psHtm:DWORD
LOCAL pUrl,Attribute
assume ebx:ptr HTML
assume esi:ptr HTML
invoke SelectNextUrl,psNextHtm,psHtm
.if eax
mov ebx,psHtm
mov esi,psNextHtm
mov pUrl,eax
call FixSplash
invoke VirtualAlloc,NULL,MAX_SIZE,MEM_COMMIT,PAGE_EXECUTE_READWRITE
mov [esi].PATH,eax
invoke CutOverURLToAbsoluteURL,[esi].URL,[ebx].uBase
invoke crt_strrchr,[esi].URL,':'
add eax,3
invoke crt_strcpy,[esi].PATH,eax
invoke crt_strrchr,[esi].PATH,'/'
.if eax && !byte ptr [eax+1]
mov dword ptr [eax+1],'edni'
mov dword ptr [eax+5],'th.x'
mov dword ptr [eax+9],'lm'
.endif
invoke ReplaceUnwantedChars,[esi].PATH
invoke GetFileAttributes,[esi].PATH
mov Attribute,eax
invoke crt_strcpy,addr ErrBuff,[esi].PATH
invoke crt_strlen,addr ErrBuff
.if eax
add eax,offset ErrBuff
mov edx,eax
.if (byte ptr [eax-3]!='.' && byte ptr [eax-4]!='.' && byte ptr [eax-5]!='.' && byte ptr [eax-6]!='.') || dword ptr [eax-4]=='php.'
mov dword ptr [eax],'mth.'
mov byte ptr [eax+4],0
.endif
.endif
invoke GetFileAttributes,addr ErrBuff
.if eax!=INVALID_HANDLE_VALUE
mov Attribute,eax
.endif
invoke SetDlgItemText,hWnd,ERR_OUTPUT,[esi].URL
mov edx,pUrl
.if byte ptr [edx-1]=='"'
dec edx
.endif
mov edx,[edx-4]
or edx,20202020h
mov CurrHeader,NULL
.if Attribute==INVALID_HANDLE_VALUE && (LevelLoad || edx=='=crs')
invoke SizeURL,esi
.else
xor eax,eax
.endif
mov [esi].cSize,eax
invoke GetFileAttributes,[esi].PATH
mov Attribute,eax
.if !LevelLoad && Attribute==INVALID_HANDLE_VALUE
mov eax,pUrl
.if byte ptr [eax-1]=='"'
dec eax
.endif
mov eax,[eax-4]
or eax,20202020h
.if eax!='=crs'
mov eax,pUrl
.repeat
dec eax
.until byte ptr [eax]=='<'
mov eax,[eax+1]
or eax,20202020h
.if eax!='knil'
mov [esi].cSize,0FFFFFFFFh
.else
invoke SizeURL,esi
mov [esi].cSize,eax
.endif
.endif
.endif
invoke crt_strlen,[esi].PATH
.if !eax
mov [esi].cSize,0FFFFFFFFh
.else
add eax,[esi].PATH
mov edx,eax
.if (byte ptr [eax-3]!='.' && byte ptr [eax-4]!='.' && byte ptr [eax-5]!='.' && byte ptr [eax-6]!='.') || dword ptr [eax-4]=='php.'
mov dword ptr [eax],'mth.'
mov byte ptr [eax+4],0
.endif
.endif
invoke GetFileAttributes,[esi].PATH
mov Attribute,eax
invoke crt_strlen,[esi].PATH
.if eax>MAX_SIZE
mov edx,[esi].PATH
mov byte ptr [edx][MAX_SIZE],0
.endif
invoke crt_strlen,[esi].URL
.if eax>MAX_SIZE
mov [esi].cSize,-1
.endif
mov eax,[esi].cSize
.if (eax<=MaxFileSize && (CurrHeader || !httpscheme)) || Attribute!=INVALID_HANDLE_VALUE
STATIC PatternState db 'Òåêóùèé URL: %s',13,10,\
'Òåêóùèé ôàéë: %s',13,10,\
'Çàÿâëåííûé ñåðâåðîì ðàçìåð: %u áàéò',13,10,\
'Ññûëêà âçÿòà èç ôàéëà: %s',13,10,\
'Òåêóùàÿ áàçà: %s',13,10,13,10,'Çàãîëîâîê:',13,10,'%s',13,10,'****',13,10,0
mov edx,[esi].cSize
invoke crt_sprintf,addr ErrBuff,addr PatternState,\
[esi].URL,[esi].PATH,edx,[ebx].PATH,[ebx].uBase,addr CurrHeader
invoke SetDlgItemText,hWnd,ERR_OUTPUT,addr ErrBuff
invoke crt_strcpy,pCurrLog,addr ErrBuff
invoke crt_strlen,addr ErrBuff
add pCurrLog,eax
invoke ReplaceURLByRelativePath,psHtm,pUrl,[esi].PATH
.endif
.endif
ret
FixSplash:
mov eax,[esi].URL
.while byte ptr [eax]
.if byte ptr [eax]=='\'
mov byte ptr [eax],'/'
.endif
inc eax
.endw
mov eax,[esi].URL
.if dword ptr [eax]=='ptth'
add eax,7
.while byte ptr [eax]!='/' && byte ptr [eax]
inc eax
.endw
.if !byte ptr [eax]
mov word ptr [eax],'/'
.endif
.endif
retn
assume ebx:nothing
assume esi:nothing
PrepareNextUrl endp
ReplaceURLByRelativePath proc uses edi esi ebx psHtm,pUrl,pPath
LOCAL Buff[1024]:BYTE
LOCAL Len
assume ebx:ptr HTML
mov ebx,psHtm
lea edi,Buff
mov esi,pPath
mov edx,[ebx].fBase
.repeat
mov al,[edx]
inc edx
inc esi
.until byte ptr [esi-1]!=al
dec edx
dec esi
lea edi,Buff
.if al
.if byte ptr [edx]=='\'
dec edx
.endif
.while byte ptr [edx]!='\' && edx>[ebx].fBase
dec edx
.endw
.if byte ptr [edx]=='\'
inc edx
.endif
.if byte ptr [esi]=='\'
dec esi
.endif
.while byte ptr [esi]!='\' && esi>pPath
dec esi
.endw
.if byte ptr [esi]=='\'
inc esi
.endif
.while TRUE
.while byte ptr [edx]!='\' && byte ptr [edx]
inc edx
.endw
.break .if !byte ptr [edx]
inc edx
mov word ptr [edi],'..'
mov byte ptr [edi+2],'\'
add edi,3
.endw
.endif
invoke crt_strcpy,edi,esi
lea eax,Buff
mov edx,eax
.while byte ptr [eax]
.if byte ptr [eax]=='\'
mov byte ptr [eax],'/'
.endif
inc eax
.endw
invoke crt_strlen,edx
mov ecx,[ebx].lpSearch
.if byte ptr [ecx]==' '
dec [ebx].lpSearch
mov eax,[ebx].lpSearch
mov byte ptr [eax],'"'
.endif
mov eax,pUrl
.if byte ptr [eax-1]!='"'
mov byte ptr [eax],'"'
inc pUrl
.endif
mov eax,pUrl
lea esi,Buff
.repeat
mov dl,[esi]
mov [eax],dl
inc eax
inc esi
.until eax>=[ebx].lpSearch || !byte ptr [esi]
.if eax>=[ebx].lpSearch
.if byte ptr [esi]
invoke InsertString,ebx,eax,esi
.endif
.else
mov esi,[ebx].lpSearch
sub esi,eax
invoke DeleteString,ebx,eax,esi
.endif
ret
assume ebx:nothing
ReplaceURLByRelativePath endp
ReplaceUnwantedChars proc pPath
mov ecx,pPath
.while byte ptr [ecx]
mov al,[ecx]
.if al==':' || al=='?' || al=='<' || al=='>' || al=='*' || al=='|' || al=='"'
mov byte ptr [ecx],'q'
.elseif al=='/'
mov byte ptr [ecx],'\'
.endif
inc ecx
.endw
ret
ReplaceUnwantedChars endp
DeleteString proc uses edi esi ebx psHtm,pStr,Len
assume ebx:ptr HTML
mov ebx,psHtm
mov edi,pStr
mov esi,Len
add esi,edi
mov ecx,[ebx].lpCode
mov edx,esi
sub edx,ecx
mov ecx,[ebx].cSize
sub ecx,edx
invoke crt_memmove,edi,esi,ecx
mov eax,Len
sub [ebx].cSize,eax
mov eax,[ebx].cSize
add eax,[ebx].lpCode
mov ecx,Len
sub [ebx].lpSearch,ecx
.repeat
mov byte ptr [eax],0
inc eax
.untilcxz
ret |