This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
frmM.frm
3193 lines (3024 loc) · 110 KB
/
frmM.frm
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
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
ClientHeight = 7575
ClientLeft = 45
ClientTop = 705
ClientWidth = 4215
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 7575
ScaleWidth = 4215
StartUpPosition = 2 'CenterScreen
Visible = 0 'False
Begin VB.CommandButton cmdClear
Caption = "Clear log"
Enabled = 0 'False
Height = 255
Index = 0
Left = 2100
TabIndex = 2
Top = 120
Width = 1985
End
Begin VB.CommandButton cmdSave
Caption = "Save log"
Enabled = 0 'False
Height = 255
Index = 0
Left = 120
TabIndex = 1
Top = 120
Width = 1985
End
Begin VB.ListBox lstLog
Height = 3180
Left = 120
TabIndex = 0
Top = 360
Width = 3975
End
Begin VB.CommandButton cmdSave
Caption = "Save output"
Enabled = 0 'False
Height = 255
Index = 1
Left = 120
TabIndex = 4
Top = 6615
Width = 1985
End
Begin VB.CommandButton cmdClear
Caption = "Clear output"
Enabled = 0 'False
Height = 255
Index = 1
Left = 2100
TabIndex = 5
Top = 6615
Width = 1985
End
Begin VB.CommandButton cmdStart
Caption = "Start"
Default = -1 'True
Height = 255
Left = 2700
TabIndex = 6
Top = 7210
Width = 1395
End
Begin prjUB.UniTextBox txtOutput
Height = 3015
Left = 120
TabIndex = 3
Top = 3600
Width = 3975
_ExtentX = 7011
_ExtentY = 5318
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 238
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = -2147483643
Text = ""
MultiLine = -1 'True
Locked = -1 'True
Scrollbar = 3
End
Begin VB.Timer tmrQ
Enabled = 0 'False
Interval = 1
Left = 3600
Top = 6600
End
Begin VB.Timer tmrU
Enabled = 0 'False
Index = 0
Interval = 1
Left = 2640
Top = 6600
End
Begin VB.Timer tmrI
Enabled = 0 'False
Index = 0
Interval = 1
Left = 2880
Top = 6600
End
Begin VB.Timer tmrW
Enabled = 0 'False
Index = 0
Interval = 1000
Left = 3360
Top = 6600
End
Begin VB.Label lblS1
Caption = "Status:"
Height = 255
Left = 120
TabIndex = 10
Top = 6960
Width = 495
End
Begin VB.Label lblStatus
Caption = "Idle..."
Height = 255
Left = 720
TabIndex = 9
Top = 6960
Width = 3375
End
Begin VB.Label lbl1
Caption = "UniBot"
DragIcon = "frmM.frx":0000
BeginProperty Font
Name = "Times New Roman"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Left = 1815
TabIndex = 8
Top = 7210
Width = 735
End
Begin VB.Label Label1
Caption = "Bot created with"
BeginProperty Font
Name = "Times New Roman"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 7
Top = 7210
Width = 1695
End
Begin VB.Menu adv
Caption = "Window"
Begin VB.Menu chkOnTop
Caption = "Always on top"
Shortcut = {F1}
End
Begin VB.Menu cmdMintoTray
Caption = "Minimize to tray"
Shortcut = {F2}
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'UniBot Stand-alone Application
Option Explicit
Private Plugins As New Collection
Private Const strDigit = "0123456789"
Private Const strLett = "qwertyuiopasdfghjklzxcvbnm"
Private Const strULett = "QWERTYUIOPASDFGHJKLZXCVBNM"
Private Const strSym = "~`!@#$%^&*()-=_+[]\{}|;':"",./<>?"
Dim Hash As New MD5Hash
Private Const GW_OWNER As Long = 4
Private Const IMAGE_ICON As Long = 1
Private Const ICON_SMALL As Long = 0
Private Const ICON_BIG As Long = 1
Private Const LR_DEFAULTSIZE As Long = &H40
Private Const LR_SHARED As Long = &H8000
Private Const SM_CXICON As Long = 11
Private Const SM_CYICON As Long = 12
Private Const SM_CXSMICON As Long = 49
Private Const SM_CYSMICON As Long = 50
Private Const WM_SETICON As Long = &H80
Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Private Declare Function GetWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal uCmd As Long) As Long
Private Declare Function LoadImageA Lib "user32.dll" (ByVal hInst As Long, ByVal lpszName As Long, Optional ByVal uType As Long, Optional ByVal cxDesired As Long, Optional ByVal cyDesired As Long, Optional ByVal fuLoad As Long) As Long
Private Declare Function SendMessageA Lib "user32.dll" (ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private hWndOwner As Long
Private Declare Function CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal _
dest As Long, ByVal src As Long, ByVal Length As Long) As Long
Private Declare Function PathRelativePathTo Lib "shlwapi.dll" Alias "PathRelativePathToA" (ByVal pszPath As String, ByVal pszFrom As String, ByVal dwAttrFrom As Long, ByVal pszTo As String, ByVal dwAttrTo As Long) As Long
Private Const MAX_PATH As Long = 260
Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10
Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Declare Function FindMimeFromData Lib "Urlmon.dll" ( _
ByVal pBC As Long, _
ByVal pwzUrl As Long, _
ByVal pBuffer As Long, _
ByVal cbSize As Long, _
ByVal pwzMimeProposed As Long, _
ByVal dwMimeFlags As Long, _
ByRef ppwzMimeOut As Long, _
ByVal dwReserved As Long _
) As Long
Private Const FMFD_DEFAULT As Long = &H0
Private Const FMFD_URLASFILENAME As Long = &H1
Private Const FMFD_ENABLEMIMESNIFFING As Long = &H2
Private Const FMFD_IGNOREMIMETEXTPLAIN As Long = &H4
Private Const FMFD_SERVERMIME As Long = &H8
Private Const FMFD_RESPECTTEXTPLAIN As Long = &H10
Private Const FMFD_RETURNUPDATEDIMGMIMES As Long = &H20
Private Const S_OK As Long = 0&
Private Const E_FAIL As Long = &H80000008
Private Const E_INVALIDARG As Long = &H80000003
Private Const E_OUTOFMEMORY As Long = &H80000002
Private Declare Function lstrlen Lib "Kernel32.dll" Alias "lstrlenW" ( _
ByVal lpString As Long _
) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" ( _
ByVal pv As Long _
)
Private Declare Function WideCharToMultiByte Lib "Kernel32.dll" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpWideCharStr As Long, _
ByVal cchWideChar As Long, _
ByVal lpMultiByteStr As Long, _
ByVal cbMultiByte As Long, _
ByVal lpDefaultChar As Long, _
ByVal lpUsedDefaultChar As Long _
) As Long
Private Declare Function MultiByteToWideChar Lib "Kernel32.dll" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As Long, _
ByVal cbMultiByte As Long, _
ByVal lpWideCharStr As Long, _
ByVal cchWideChar As Long _
) As Long
Private Declare Function SetCurrentDirectoryA Lib "kernel32" (ByVal lpPathName As String) As Long
Private Const CP_ACP As Long = 0 ' Default ANSI code page.
Private Const CP_UTF8 As Long = 65001 ' UTF8.
Private Const CP_UTF16_LE As Long = 1200 ' UTF16 - little endian.
Private Const CP_UTF16_BE As Long = 1201 ' UTF16 - big endian.
Private Const CP_UTF32_LE As Long = 12000 ' UTF32 - little endian.
Private Const CP_UTF32_BE As Long = 12001 ' UTF32 - big endian.
Private Declare Function CreateActCtx Lib "kernel32" Alias "CreateActCtxA" (ByRef pActCtx As ACTCTX_) As Long
Private Declare Sub ReleaseActCtx Lib "kernel32" (ByVal hActCtx As Long)
Private Declare Function ActivateActCtx Lib "kernel32" (ByVal hActCtx As Long, ByRef lpCookie As Long) As Boolean
Private Declare Function DeactivateActCtx Lib "kernel32" (ByVal dwFlags As Long, ByVal ulCookie As Long) As Boolean
Private Const INVALID_HANDLE_VALUE = -1
Private Const ACTCTX_FLAG_RESOURCE_NAME_VALID = 8&
Private Type ACTCTX_
cbSize As Long
dwFlags As Long
lpSource As String
wProcessorArchitecture As Integer
wLangId As Integer
lpAssemblyDirectory As String
lpResourceName As String
lpApplicationName As String
hModule As Long
End Type
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) _
As Long
Private WithEvents SystemTray As clsInTray
Attribute SystemTray.VB_VarHelpID = -1
Private Const Comms As String = ",rg,rpl,num,dech,dec,enc,u,l,b64,md5,"
Private WithEvents rh As cAsyncRequests
Attribute rh.VB_VarHelpID = -1
Dim strCmd As String, strPath(1) As String, bolAb As Boolean, bolEx As Boolean, strPlC As String, bytSh() As Byte, strPO As String, strInitD As String, strLastPath As String, strDrP As String
Dim bolNoRetry As Boolean, bytTimeout As Byte, bytThreads As Byte, bytSubThr As Byte, bytDelay As Byte, bytMaxR As Byte
Dim intAfter As Integer, bolHours As Boolean, strTemplate0 As String, strTemplate1 As String, bytTOrigin0 As Byte, bytTOrigin1 As Byte, bolNoEach As Boolean, intLogMax As Integer, intOutMax As Integer, bolColl As Boolean, bytPlgUse As Byte, bolUnl As Boolean, bolLO(1) As Boolean
Dim strC As String, bytActive As Byte, intSubT As Integer, intLTmr(1) As Integer, intTmrCount As Integer, bytOrigin As Byte, bolTmp As Boolean, bytSilent As Byte, bolMT As Boolean, bolSkipErr As Boolean, bolRg As Boolean, datCompl As Date
Dim bytIC As Byte, bytLimit As Byte, strURLData() As String, strHeaders() As String, strStrings() As String, strIf() As String, strWait() As String, intGoto() As Integer
Dim colSrc As Collection, colStr As Collection, colPubStr As Collection, colMax As Collection, colInput As Collection, colMaxR As Collection, colCurrO As Collection
Public bolDebug As Boolean
Private Sub Form_QueryUnlaod(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = 0 And Not bolDebug Then If MsgBox("Are you sure?", vbExclamation + vbYesNo) = vbNo Then Cancel = 1 'If cmdStart.Caption = "Stop" Then
End Sub
Private Sub lbl1_DragDrop(Source As Control, x As Single, y As Single)
If Source Is lbl1 Then Shell "cmd.exe /c START http://unibot.boards.net", vbHide
End Sub
Private Sub lbl1_DragOver(Source As Control, x As Single, y As Single, State As Integer)
If State = vbLeave Then lbl1.Drag vbEndDrag
End Sub
Private Sub lbl1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
lbl1.Drag vbBeginDrag
End Sub
Sub addLog(txt As String, Optional D As Boolean)
txt = "[" & Now & "] " & txt
If D Then txt = "DEBUG: " & txt
If lstLog.ListCount = intLogMax Then lstLog.RemoveItem 0
lstLog.AddItem txt
SetListboxScrollbar
lstLog.ListIndex = lstLog.ListCount - 1
lstLog.Text = vbNullString
End Sub
Private Sub lstLog_DblClick()
On Error Resume Next
Clipboard.Clear
Clipboard.SetText lstLog.Text
End Sub
Private Function LoadFile1(strPath As String) As String
On Error GoTo E
If Dir$(strPath, vbHidden) = vbNullString Then Exit Function
With CreateObject("ADODB.Stream")
.Open
If ContainsUTF8(strPath) Then .Charset = "utf-8" Else: .Charset = "_autodetect_all"
.LoadFromFile strPath
LoadFile1 = .ReadText
End With
E:
End Function
Private Function LoadFile2(strPath As String) As Byte()
On Error GoTo E
Open strPath For Binary Access Read As #1
ReDim LoadFile2(LOF(1) - 1)
Get #1, , LoadFile2
Close #1
E:
End Function
Private Function ContainsUTF8(File As String) As Boolean
On Error GoTo E
Dim MLang As CMultiLanguage
Dim IMLang2 As IMultiLanguage2
Dim Encoding() As tagDetectEncodingInfo
Dim encCount As Long
Dim inp() As Byte
Dim Index As Long
Open File For Binary As #1
ReDim inp(LOF(1) - 1)
Get #1, , inp()
Close #1
Set MLang = New CMultiLanguage
Set IMLang2 = MLang
encCount = 16
ReDim Encoding(encCount - 1)
IMLang2.DetectInputCodepage 0, 0, inp(0), UBound(inp) + 1, Encoding(0), encCount
For Index = 0 To encCount - 1
If Encoding(Index).nCodePage = 65001 Then 'UTF-8
ContainsUTF8 = True
Exit For
End If
Next
E:
Set IMLang2 = Nothing
Set MLang = Nothing
End Function
Public Function URLdecshort(ByRef Text As String) As String
On Error Resume Next
Dim strArray() As String, lngA As Long
strArray = Split(Replace(Text, "+", " "), "%")
For lngA = 1 To UBound(strArray)
strArray(lngA) = Chr$("&H" & Left$(strArray(lngA), 2)) & Mid$(strArray(lngA), 3)
Next lngA
URLdecshort = Join(strArray, vbNullString)
End Function
Private Function URLencshort(ByRef Text As String) As String
Dim lngA As Long, strChar As String
For lngA = 1 To Len(Text)
strChar = Mid$(Text, lngA, 1)
If Not strChar Like "[A-Za-z0-9]" Then
strChar = "%" & Right$("0" & Hex$(Asc(strChar)), 2)
ElseIf strChar = " " Then
strChar = "+"
End If
URLencshort = URLencshort & strChar
Next lngA
End Function
Function ProcessNumber(strT As Variant, Optional bolI As Boolean, Optional bolA As Boolean) As Integer
Dim intT As Integer
If Not bolI Then intT = 255 Else: intT = 32767
If strT <= intT Then
If strT < 0 Then ProcessNumber = strT * (-1) Else: ProcessNumber = strT
Else: If Not bolA Then ProcessNumber = intT Else: ProcessNumber = 0
End If
End Function
Private Function RegExpr(myPattern As String, myString As String, Optional myReplace As String, Optional bytResults As Byte, Optional intStart As Integer, Optional intCount As Integer) As Variant
'Modified by MikiSoft; Note: Must have "Microsoft VBScript Regular Expressions 5.5" library.
On Error GoTo E
Dim objRegExp As RegExp
Set objRegExp = New RegExp
objRegExp.Pattern = myPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
If bytResults > 0 Then
'If objRegExp.Test(myString) Then
Dim colMatches As MatchCollection
Set colMatches = objRegExp.Execute(myString)
If intCount = 0 Then intCount = colMatches.count - intStart
Dim i As Integer
For i = intStart To intStart + intCount - 1
If myReplace = vbNullString Then RegExpr = RegExpr & colMatches.Item(i).Value & vbNewLine Else: RegExpr = RegExpr & objRegExp.Replace(colMatches.Item(i).Value, myReplace) & vbNewLine
If i = colMatches.count - 1 Or bytResults = 2 Then Exit For
Next
RegExpr = Left$(RegExpr, Len(RegExpr) - 2)
'End If
Else: RegExpr = objRegExp.Test(myString)
End If
E: Set objRegExp = Nothing
End Function
Private Function RegExpr1(myPattern As String, myString As String, myReplace As String, bytResults As Byte, intStart As Integer, Optional intCount As Integer) As Variant
On Error GoTo E
Dim objRegExp As Object
Set objRegExp = CreateRG
objRegExp.Pattern = myPattern
objRegExp.IgnoreCase = True
If bytResults > 0 Then
'If objRegExp.Test(myString) Then
Dim strMatches() As String
strMatches = objRegExp.Execute(myString)
If UBound(strMatches) < LBound(strMatches) Then Exit Function
If intCount = 0 Then intCount = UBound(strMatches) + 1 - intStart
Dim i As Integer
For i = intStart To intStart + intCount - 1
If myReplace = vbNullString Then RegExpr1 = RegExpr1 & strMatches(i) & vbNewLine Else: RegExpr1 = RegExpr1 & objRegExp.Replace(strMatches(i), myReplace) & vbNewLine
If i = UBound(strMatches) Or bytResults = 2 Then Exit For
Next
RegExpr1 = Left$(RegExpr1, Len(RegExpr1) - 2)
'End If
Else: RegExpr1 = objRegExp.IsMatch(myString)
End If
E: Set objRegExp = Nothing
End Function
Private Function ReplaceString(ByVal strInp As String, Optional strSrc As String = vbNullChar) As String
If strInp = vbNullString Then Exit Function
strInp = Replace(strInp, "[nl]", vbNewLine)
'If InStr(strInp, "[inp") > 0 Then FindRI strInp
Dim strT As String, s() As String, intL As Integer, strR As String, strN As String 'strT(1) As String
'If bolR Then strT(0) = "rnd" Else: strT(0) = "inp"
s() = Split(strInp, "[rnd") '"[" & strT(0)
If UBound(s()) > 0 Then
Dim i As Byte
For i = 1 To UBound(s())
If InStr(s(i), "]") > 0 Then
strT = Left$(s(i), FindSep(s(i), , "]", "`") - 1)
If Len(strT) > 0 Then
intL = 0
AddChrs strR, strT, strInp, intL
If strR <> vbNullString Then strN = RandStr(strR, intL)
GoTo C
Else
strN = RandStr
C:
If strSrc = vbNullChar Then strN = Replace(strN, "'", "''")
strInp = Replace(strInp, "[rnd" & strT & "]", strN)
End If
End If
Next
End If
If InStr(strInp, "<") > 0 And InStr(strInp, ">") > 0 Then
Dim intC(1) As Long
intC(1) = 1
On Error GoTo N
Do
intC(0) = FindSep(strInp, intC(1), "<") + 1
If intC(0) = 1 Then Exit Do
intC(1) = FindSep(strInp, intC(0), ">")
If intC(1) = 0 Then Exit Do
strT = Mid$(strInp, intC(0), intC(1) - intC(0))
strN = vbNullString
On Error Resume Next
If Dir$(strT, vbHidden) <> vbNullString Then
strN = LoadFile1(strT)
If strSrc = vbNullChar Then strN = "'" & Replace(Replace(Replace(strN, "''", "'"), "'", "''"), "[src]", "['+'src]") & "'"
ElseIf strSrc <> vbNullChar Then GoTo N
End If
On Error GoTo 0
intC(0) = intC(0) - 1
strInp = Left$(strInp, intC(0) - 1) & Replace(strInp, "<" & strT & ">", strN, intC(0), 1)
intC(1) = intC(0) + Len(strN)
N:
Loop Until intC(1) > Len(strInp) - 3
End If
ReplaceString = Replace(strInp, "[dt]", Now)
If strSrc <> vbNullChar Then ReplaceString = Replace(ReplaceString, "[src]", strSrc)
'If InStr(strInp, "[rnd") > 0 Then FindRI ReplaceString ', True
End Function
Private Function AddChrs(strR As String, strT As String, Optional strInp As String, Optional intL As Integer, Optional intM As Variant) As String
Dim a As Byte, intT As Integer
On Error Resume Next
For a = 1 To Len(strT)
Select Case Mid$(strT, a, 1)
Case "D": strR = strR & strDigit
Case "L": strR = strR & strLett
Case "U": strR = strR & strULett
Case "M": strR = strR & strLett & strULett
Case "S": strR = strR & strSym
Case "`"
intT = FindC1(strT, a + 1, "`")
If intT = 0 Then Exit For
strR = strR & Replace(Mid$(strT, a + 1, intT - a - 1), "``", "`")
a = intT
Case Else
If Not IsMissing(intM) Then
Dim strT1 As String, s() As String
strT1 = Mid$(strT, a)
If IsNumeric(Replace(strT1, "-", vbNullString)) Then
If InStr(strT1, "-") > 0 Then
s() = Split(strT1, "-")
s(0) = Val(s(0))
s(1) = Val(s(1))
If CInt(s(0)) > CInt(s(1)) And CInt(s(1)) > 0 Then Exit For
If s(0) > 0 Then If intM(0) = 0 Then intM(0) = s(0) Else: If s(0) > intM(0) Then intM(0) = s(0)
If intM(1) = 0 Then intM(1) = s(1) Else: If s(1) < intM(1) Then intM(1) = s(1)
Else: If intM(1) = 0 Then intM(1) = strT1 Else: If strT1 < intM(1) Then intM(1) = strT1
End If
End If
ElseIf InStr(Mid$(strT, a), "-") > 0 Then strInp = Replace(strInp, "[rnd" & strT & "]", RandNum(Trim$(Split(strT, "-")(0)), Trim$(Split(strT, "-")(1))))
ElseIf IsNumeric(Mid$(strT, a)) Then intL = Mid$(strT, a)
End If
Exit For
End Select
Next
If Not IsMissing(intM) Then AddChrs = strR
End Function
Function ProcessString(ByVal strExp As String, strS As String, Optional intS As Integer = 1, Optional intStart As Integer, Optional intCount As Integer) As String
'On Error GoTo E
If strExp = vbNullString Then Exit Function
Dim intC(2) As Long, strT As String, intP As Long, bytC As Byte, strT2(2) As String, intL(1) As Long, tmpObj As IPluginInterface
strExp = strExp & "+"
R:
intC(0) = intS
Do
If InStr(intC(0), strExp, "+") > 0 Then
strT = Split(Mid$(strExp, intC(0)), "+")(0)
If strT = vbNullString Then
intC(0) = intC(0) + 1
GoTo N1
End If
End If
intC(1) = intC(0)
If Mid$(strExp, intC(0), 1) <> "'" And Not IsNumeric(strT) Then
If InStr(intC(0), strExp, "'") = 0 Then Exit Function
strExp = strExp & ")"
intS = intC(0)
Do
intC(2) = intC(1)
intC(0) = InStr(intC(2), strExp, "'") + 1
If intC(0) = 1 Then
intC(0) = Len(strExp) - 1
strT = Mid$(strExp, intS) & ")"
Else
intC(1) = FindC1(strExp, intC(0)) + 1
If intC(1) < 2 Then Exit Function
strT = Mid$(strExp, intC(2), intC(0) - intC(2) - 1)
End If
If InStr(strT, ")") > 0 Then
If intP = 0 Then Exit Function
If UBound(Split(strT, ")")) < bytC Then bytC = bytC - UBound(Split(strT, ")")) Else: bytC = 0
If InStr(intC(2), strExp, ")") < InStr(intC(2), strExp & "'", "'") Then intC(2) = InStr(intC(2), strExp, ")")
Dim strT1 As String
strT = Mid$(strExp, intP, intC(2) - intP + 1)
strT1 = strT
If Left$(strT, 3) = "rg(" Or Left$(strT, 4) = "rg1(" Then
If Left$(strT, 4) = "rg1(" Then intL(1) = 1 Else: intL(1) = 0
intL(0) = FindSep(strT, 4 + intL(1))
If intL(0) = 0 Then Exit Function
strT2(0) = ProcessString(Mid$(strT, 4 + intL(1), intL(0) - 4 - intL(1)), strS)
intL(0) = intL(0) + 1
intL(1) = FindSep(strT, intL(0))
If intL(1) = 0 Then intL(1) = Len(strT)
strT2(1) = ProcessString(Mid$(strT, intL(0), intL(1) - intL(0)), strS)
intL(0) = intL(1) + 1
strT2(2) = vbNullString
Dim intSt As Integer: intSt = 0
If intL(0) > Len(strT) - 1 Then GoTo N
If InStr("0123456789", Mid$(strT, intL(0), 1)) = 0 Then
intL(1) = FindSep(strT, intL(0))
If intL(1) = 0 Then intL(1) = Len(strT)
strT2(2) = ProcessString(Mid$(strT, intL(0), intL(1) - intL(0)), strS)
intL(0) = intL(1) + 1
If intL(0) > Len(strT) - 1 Then GoTo N
End If
intL(1) = FindSep(strT, intL(0))
If intL(1) > 0 Then
intSt = ProcessNumber(ProcessString(Mid$(strT, intL(0), intL(1) - intL(0)), strS), True, True)
intL(0) = intL(1) + 1
intL(1) = Len(strT)
Else: intSt = ProcessNumber(ProcessString(Mid$(Left$(strT, Len(strT) - 1), intL(0)), strS), True, True)
End If
N:
Dim intT As Integer: intT = 0 ': intT = intCount
If intStart = 0 Then
If intL(1) > intL(0) Then
'Dim intT1 As Integer
intT = ProcessNumber(ProcessString(Mid$(strT1, intL(0), intL(1) - intL(0)), strS), True, True) 'intT1
'If intT1 > intCount Then intCount = intT1
End If
If Left$(strT, 3) = "rg(" Then strT = RegExpr(strT2(1), strT2(0), strT2(2), 2, intSt, intT) Else: strT = RegExpr1(strT2(1), strT2(0), strT2(2), 2, intSt, intT)
If intCount < 1 Or intCount > intT Then intCount = intT
Else
If CLng(intSt) + CLng(intStart) < 32767 Then intT = intSt + intStart Else: intT = 32767
If Left$(strT, 3) = "rg(" Then strT = RegExpr(strT2(1), strT2(0), strT2(2), 2, intT) Else: strT = RegExpr1(strT2(1), strT2(0), strT2(2), 2, intT)
End If
strT = "'" & Replace(strT, "'", "''") & "'"
ElseIf Left$(strT, 4) = "rpl(" Then
intL(0) = FindSep(strT, 5)
If intL(0) = 0 Then Exit Function
strT2(0) = ProcessString(Mid$(strT, 5, intL(0) - 5), strS)
intL(0) = intL(0) + 1
intL(1) = FindSep(strT, intL(0))
If intL(1) = 0 Then Exit Function
strT2(1) = ProcessString(Mid$(strT, intL(0), intL(1) - intL(0)), strS)
intL(0) = intL(1) + 1
strT2(2) = ProcessString(Mid$(strT, intL(0), Len(strT) - intL(0)), strS)
strT = "'" & Replace(Replace(strT2(0), strT2(1), strT2(2)), "'", "''") & "'"
ElseIf InStr(strPlC, "," & Left$(strT, InStr(strT, "(") - 1) & ",") > 0 Then
ReDim strComm(0) As String
Dim i As Integer
strComm(0) = Left$(strT, InStr(strT, "(") - 1)
intL(0) = Len(strComm(0)) + 1
Do
intL(0) = intL(0) + 1
intL(1) = FindSep(strT, intL(0))
If intL(1) = 0 Then intL(1) = Len(strT)
ReDim Preserve strComm(UBound(strComm) + 1)
strComm(UBound(strComm)) = ProcessString(Mid$(strT, intL(0), intL(1) - intL(0)), strS)
intL(0) = intL(0) + (intL(1) - intL(0))
Loop Until intL(1) = Len(strT)
strT2(0) = Split(strPlC, "," & strComm(0) & ",")(0)
strT2(0) = Mid$(strT2(0), InStrRev(vbLf & strT2(0), vbLf, Len(strT2(0)) - 1) + 1)
Set tmpObj = Plugins.Item(Left$(strT2(0), InStr(strT2(0) & "|", "|") - 1))
bytPlgUse = bytPlgUse + 1
strT = "'" & Replace(tmpObj.Execute(strComm), "'", "''") & "'"
bytPlgUse = bytPlgUse - 1
If bolUnl And bytPlgUse = 0 Then Unload Me: Exit Function
Set tmpObj = Nothing
Else
strT2(0) = Mid$(strT, InStr(strT, "(") + 1)
strT2(0) = ProcessString(Left$(strT2(0), Len(strT2(0)) - 1), strS)
If Left$(strT, 5) = "dech(" Then
On Error GoTo E
Dim xml As Object
Set xml = CreateObject("MSXML2.DOMDocument.3.0")
With xml
.loadXML "<p>" & strT2(0) & "</p>"
strT = "'" & .selectSingleNode("p").nodeTypedValue & "'"
End With
Set xml = Nothing
E:
If err.Number <> 0 Then strT = "''"
On Error GoTo 0
ElseIf Left$(strT, 4) = "dec(" Then
strT = "'" & URLdecshort(strT2(0)) & "'"
ElseIf Left$(strT, 4) = "enc(" Then
strT = "'" & URLencshort(strT2(0)) & "'"
ElseIf Left$(strT, 2) = "u(" Then strT = "'" & Replace(UCase$(strT2(0)), "'", "''") & "'"
ElseIf Left$(strT, 2) = "l(" Then strT = "'" & Replace(LCase$(strT2(0)), "'", "''") & "'"
ElseIf Left$(strT, 4) = "b64(" Then strT = "'" & Encode64(strT2(0)) & "'"
ElseIf Left$(strT, 5) = "b64d(" Then strT = "'" & Decode64(strT2(0)) & "'"
ElseIf Left$(strT, 4) = "md5(" Then strT = "'" & LCase$(Hash.HashBytes(StrConv(strT2(0), vbFromUnicode))) & "'"
ElseIf Left$(strT, 4) = "num(" Then strT = Val(strT2(0))
End If
'Else
'E: strT = "''"
End If
If strT1 = strT Then Exit Function
strExp = Replace(strExp, strT1, strT)
bytC = 0
GoTo R
ElseIf InStr(strT, "(") > 0 Then
bytC = bytC + UBound(Split(strT, "("))
intP = intC(0) - Len(Mid$(strT, InStrRev(strT, "("))) - 1
Do
intP = intP - 1
If intP = 0 Then Exit Do
Loop Until Mid$(strExp, intP, 1) = "," Or Mid$(strExp, intP, 1) = "+" Or Mid$(strExp, intP, 1) = "("
intP = intP + 1
End If
Loop Until bytC = 0
intC(1) = intC(1) - 1
ElseIf Mid$(strExp, intC(0), 1) = "'" Then
intC(0) = intC(0) + 1
intC(1) = FindC1(strExp, intC(0))
If intC(1) < 2 Then Exit Function
ProcessString = ProcessString & Replace(Replace(Mid$(strExp, intC(0), intC(1) - intC(0)), "''", "'"), "[src]", strS)
Else
intC(1) = InStr(intC(0), strExp, "+")
If intC(1) > 0 Then
If IsNumeric(ProcessString) Then ProcessString = ProcessString + Val(Mid$(strExp, intC(0), intC(1) - intC(0))) Else: ProcessString = ProcessString & Mid$(strExp, intC(0), intC(1) - intC(0))
intC(1) = intC(1) - 1
Else: Exit Do
End If
End If
intC(0) = intC(1) + 2
'If IsNumeric(ProcessString) And IsNumeric(strT) Then ProcessString = CDbl(ProcessString + strT) Else: ProcessString = ProcessString & strT
N1:
Loop Until intC(0) >= Len(strExp)
'E:
End Function
Private Function FindC1(strS As String, Optional intC As Long = 2, Optional strC As String = "'") As Long
FindC1 = InStr(intC, Left$(strS, intC - 1) & Replace(Mid$(strS, intC), strC & strC, " "), strC)
End Function
Private Function FindC(ByVal strS As String, Optional ByVal intC As Integer = 2) As Integer
FindC = InStr(intC, Left$(strS, intC - 1) & Replace(Mid$(strS, intC), strC, " "), """")
End Function
Private Function FindSep(strExp As String, Optional intS As Long = 1, Optional strC As String = ",", Optional strE As String = "'") As Long
Dim intC(2) As Long
intC(1) = intS
intC(2) = intS
Do
intC(0) = intC(2)
intC(1) = InStr(intC(2), strExp, strE) + 1
If intC(1) = 1 Then Exit Do
intC(2) = FindC1(strExp, intC(1), strE) + 1
Loop Until InStr(Mid$(strExp, intC(0), intC(1) - intC(0) - 1), strC) > 0 Or intC(2) = 1
If intC(2) = 1 Then FindSep = InStr(intC(1), strExp, strC) Else: FindSep = InStr(intC(0), strExp, strC)
End Function
Private Function RandNum(ByVal Low As Long, ByVal High As Long) As Long
RandNum = Int((High - Low + 1) * Rnd) + Low
End Function
Private Function RandStr(Optional strR As String, Optional intL As Integer) As String
If strR = vbNullString Then strR = strDigit & strLett & strULett & strSym
If intL = 0 Then intL = 15
Dim i As Integer
For i = 1 To intL
RandStr = RandStr & Mid$(strR, Int(Rnd() * Len(strR) + 1), 1)
Next
End Function
Private Function CreateRG() As Object
Dim ActCtx As ACTCTX_
Dim res As Boolean, actHandle As Long, actCookie As Long
ActCtx.cbSize = Len(ActCtx)
ActCtx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID
ActCtx.lpSource = App.path & IIf(Right$(App.path, 1) <> "\", "\", vbNullString) & App.EXEName & ".exe" & vbNullChar
ActCtx.lpResourceName = "#3"
actHandle = CreateActCtx(ActCtx)
If actHandle = INVALID_HANDLE_VALUE Then Exit Function
res = ActivateActCtx(actHandle, actCookie)
If Not res Then
Call ReleaseActCtx(actHandle)
actHandle = 0
Exit Function
End If
On Error Resume Next
Set CreateRG = CreateObject("DotNetCOMRegExLib.DotNetRegEx")
Call ReleaseActCtx(actHandle)
Call DeactivateActCtx(0, actCookie)
actHandle = 0
actCookie = 0
End Function
Private Function TrimComma(strT As String) As String
TrimComma = strT
Do While InStr(TrimComma, ",,") > 0
TrimComma = Replace(TrimComma, ",,", ",")
Loop
TrimComma = Replace(Replace(Replace(Replace(TrimComma, "(", vbNullString), ")", vbNullString), "+", vbNullString), "'", vbNullString)
End Function
Private Function get_relative_path_to(ByVal child_path As String, Optional folder As Boolean, Optional parent_path As String) As String
If parent_path = vbNullString Then parent_path = strInitD
If LCase$(Left$(child_path, 1)) <> LCase$(Left$(parent_path, 1)) Or InStr(child_path, "\") = 0 Then
get_relative_path_to = child_path
Exit Function
End If
Dim attr As Long
If folder Then attr = FILE_ATTRIBUTE_DIRECTORY Else: attr = FILE_ATTRIBUTE_NORMAL
Dim out_str As String
Dim par_str As String
Dim child_str As String
out_str = String$(MAX_PATH, 0)
par_str = parent_path + String$(100, 0)
child_str = child_path + String$(100, 0)
PathRelativePathTo out_str, par_str, FILE_ATTRIBUTE_DIRECTORY, child_str, attr
out_str = StripTerminator(out_str)
If Left$(out_str, 2) <> ".\" Then
If folder Then If Right$(out_str, 1) <> "\" Then out_str = out_str & "\"
If UBound(Split(out_str, "..\")) = UBound(Split(parent_path & IIf(Right$(parent_path, 1) <> "\", "\", vbNullString), "\")) - 1 Then out_str = Mid$(out_str, InStrRev(out_str, "..\") + 2) Else: If Left$(out_str, 1) = "\" Then out_str = Mid$(out_str, 2)
Else: out_str = Mid$(out_str, 3)
End If
If Len(out_str) > 1 Then If Right$(out_str, 1) = "\" Then out_str = Left$(out_str, Len(out_str) - 1)
get_relative_path_to = out_str
End Function
'Remove all trailing Chr$(0)'s
Private Function StripTerminator(sInput As String) As String
Dim ZeroPos As Long
ZeroPos = InStr(1, sInput, Chr$(0))
If ZeroPos > 0 Then
StripTerminator = Left$(sInput, ZeroPos - 1)
Else
StripTerminator = sInput
End If
End Function
Private Sub SetListboxScrollbar()
Dim new_len As Long
Static max_len As Long
If lstLog.ListCount > 0 Then
new_len = 10 + lstLog.Parent.ScaleX( _
lstLog.Parent.TextWidth(lstLog.list(lstLog.ListCount - 1)), _
lstLog.Parent.ScaleMode, vbPixels)
If max_len < new_len Then
max_len = new_len
E:
SendMessage lstLog.hwnd, _
LB_SETHORIZONTALEXTENT, _
max_len, 0
End If
Else
max_len = 0
GoTo E
End If
End Sub
' Purpose: Take a string whose bytes are in the byte array <the_abytCPString>, with code page <the_nCodePage>, convert to a VB string.
Private Function FromCPString(ByRef the_abytCPString() As Byte, ByVal the_nCodePage As Long) As String
Dim sOutput As String
Dim nValueLen As Long
Dim nOutputCharLen As Long
' If the code page says this is already compatible with the VB string, then just copy it into the string. No messing.
If the_nCodePage = CP_UTF16_LE Then
FromCPString = the_abytCPString()
Else
' Cache the input length.
nValueLen = UBound(the_abytCPString) - LBound(the_abytCPString) + 1
' See how big the output buffer will be.
nOutputCharLen = MultiByteToWideChar(the_nCodePage, 0&, VarPtr(the_abytCPString(LBound(the_abytCPString))), nValueLen, 0&, 0&)
' Resize output byte array to the size of the UTF-8 string.
sOutput = Space$(nOutputCharLen)
' Make this API call again, this time giving a pointer to the output byte array.
MultiByteToWideChar the_nCodePage, 0&, VarPtr(the_abytCPString(LBound(the_abytCPString))), nValueLen, StrPtr(sOutput), nOutputCharLen
' Return the array.
FromCPString = sOutput
End If
End Function
' Purpose: Converts a VB string (UTF-16) to UTF8 - as a binary array.
Private Function ToCPString(ByRef the_sValue As String, Optional ByVal the_nCodePage As Long = CP_ACP) As Byte()
Dim abytOutput() As Byte
Dim nValueLen As Long
Dim nOutputByteLen As Long
If the_nCodePage = CP_UTF16_LE Then
ToCPString = the_sValue
Else
' Cache the input length.
nValueLen = Len(the_sValue)
' See how big the output buffer will be.
nOutputByteLen = WideCharToMultiByte(the_nCodePage, 0&, StrPtr(the_sValue), nValueLen, 0&, 0&, 0&, 0&)
If nOutputByteLen > 0 Then
' Resize output byte array to the size of the UTF-8 string.
ReDim abytOutput(1 To nOutputByteLen)
' Make this API call again, this time giving a pointer to the output byte array.
WideCharToMultiByte the_nCodePage, 0&, StrPtr(the_sValue), nValueLen, VarPtr(abytOutput(1)), nOutputByteLen, 0&, 0&
End If
' Return the array.
ToCPString = abytOutput()
End If
End Function
Private Sub CatBinary(bytData() As Byte, Bytes() As Byte)
Dim BytesLen As Long, BinaryNext As Long
BinaryNext = UBound(bytData) + 1
BytesLen = UBound(Bytes) - LBound(Bytes) + 1
If BinaryNext + BytesLen > BinaryNext Then ReDim Preserve bytData(BinaryNext + BytesLen - 1)
CopyMemory VarPtr(bytData(BinaryNext)), VarPtr(Bytes(LBound(Bytes))), BytesLen
End Sub
Private Sub CatBinaryString(bytData() As Byte, Text As String)
Dim Bytes() As Byte
Bytes = ToCPString(Text)
CatBinary bytData, Bytes
End Sub
Private Function CopyPointerToString(ByVal in_pString As Long) As String
Dim nLen As Long
' Need to copy the data at the string pointer to a VB string buffer.
' Get the length of the string, allocate space, and copy to that buffer.
nLen = lstrlen(in_pString)
CopyPointerToString = Space$(nLen)
CopyMemory StrPtr(CopyPointerToString), in_pString, nLen * 2
End Function