-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmMain.frm
1406 lines (1128 loc) · 46.4 KB
/
frmMain.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
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.ocx"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "mswinsck.ocx"
Object = "{7888C00A-4808-4D27-9AAE-BD36EC13D16F}#1.0#0"; "LVBUTTONS.OCX"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmMain
BackColor = &H00404040&
BorderStyle = 0 'None
Caption = "GameAnnouncer - by Myst and cHip"
ClientHeight = 5640
ClientLeft = 0
ClientTop = 0
ClientWidth = 8970
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
Picture = "frmMain.frx":F172
ScaleHeight = 5640
ScaleWidth = 8970
StartUpPosition = 3 'Windows Default
Begin InetCtlsObjects.Inet Inet1
Left = 8760
Top = 3600
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
End
Begin VB.PictureBox TrayIcon
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 300
Left = 5040
Picture = "frmMain.frx":155B4
ScaleHeight = 240
ScaleWidth = 240
TabIndex = 5
Top = 5520
Visible = 0 'False
Width = 300
End
Begin LVbuttons.LaVolpeButton LaVolpeButton1
Height = 255
Left = 8520
TabIndex = 3
Top = 120
Width = 255
_ExtentX = 450
_ExtentY = 450
BTYPE = 3
TX = "X"
ENAB = -1 'True
BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Verdana"
Size = 5.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
COLTYPE = 2
BCOL = 0
FCOL = 192
FCOLO = 16777215
EMBOSSM = 16777088
EMBOSSS = 16744703
MPTR = 0
MICON = "frmMain.frx":24726
ALIGN = 1
IMGLST = "(None)"
IMGICON = "(None)"
ICONAlign = 0
ORIENT = 0
STYLE = 0
IconSize = 2
SHOWF = -1 'True
BSTYLE = 0
End
Begin LVbuttons.LaVolpeButton cmdCon
Height = 375
Left = 240
TabIndex = 1
Top = 40
Width = 1695
_ExtentX = 2990
_ExtentY = 661
BTYPE = 3
TX = "Connect"
ENAB = -1 'True
BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Verdana"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
COLTYPE = 2
BCOL = 0
FCOL = 16744576
FCOLO = 12648384
EMBOSSM = 12632064
EMBOSSS = 16777152
MPTR = 0
MICON = "frmMain.frx":24742
ALIGN = 1
IMGLST = "(None)"
IMGICON = "(None)"
ICONAlign = 0
ORIENT = 0
STYLE = 0
IconSize = 2
SHOWF = -1 'True
BSTYLE = 0
End
Begin MSWinsockLib.Winsock sckUDP
Left = 1560
Top = 5760
_ExtentX = 741
_ExtentY = 741
_Version = 393216
Protocol = 1
End
Begin MSWinsockLib.Winsock sckBnet
Left = 1080
Top = 5760
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Timer tmrFlood
Interval = 2750
Left = 360
Top = 5760
End
Begin VB.TextBox txtSend
Appearance = 0 'Flat
BackColor = &H00000000&
BorderStyle = 0 'None
BeginProperty Font
Name = "Verdana"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 255
Left = 140
TabIndex = 0
Text = "Game Announcer ~ Created by Myst & cHip"
Top = 5160
Width = 8520
End
Begin MSWinsockLib.Winsock sckChat
Left = 0
Top = 5760
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin LVbuttons.LaVolpeButton cmdDiscon
Height = 375
Left = 2160
TabIndex = 2
Top = 40
Width = 1695
_ExtentX = 2990
_ExtentY = 661
BTYPE = 3
TX = "Disconnect"
ENAB = -1 'True
BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Verdana"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
COLTYPE = 2
BCOL = 0
FCOL = 16744576
FCOLO = 12648384
EMBOSSM = 0
EMBOSSS = 0
MPTR = 0
MICON = "frmMain.frx":2475E
ALIGN = 1
IMGLST = "(None)"
IMGICON = "(None)"
ICONAlign = 0
ORIENT = 0
STYLE = 0
IconSize = 2
SHOWF = -1 'True
BSTYLE = 0
End
Begin LVbuttons.LaVolpeButton LaVolpeButton2
Height = 255
Left = 8160
TabIndex = 4
Top = 120
Width = 255
_ExtentX = 450
_ExtentY = 450
BTYPE = 3
TX = "-"
ENAB = -1 'True
BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Verdana"
Size = 5.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
COLTYPE = 2
BCOL = 0
FCOL = 192
FCOLO = 16777215
EMBOSSM = 16777088
EMBOSSS = 16744703
MPTR = 0
MICON = "frmMain.frx":2477A
ALIGN = 1
IMGLST = "(None)"
IMGICON = "(None)"
ICONAlign = 0
ORIENT = 0
STYLE = 0
IconSize = 2
SHOWF = -1 'True
BSTYLE = 0
End
Begin LVbuttons.LaVolpeButton LaVolpeButton3
Height = 255
Left = 7800
TabIndex = 7
ToolTipText = "Settings"
Top = 120
Width = 255
_ExtentX = 450
_ExtentY = 450
BTYPE = 3
TX = "S"
ENAB = -1 'True
BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Verdana"
Size = 5.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
COLTYPE = 2
BCOL = 0
FCOL = 192
FCOLO = 16777215
EMBOSSM = 16777088
EMBOSSS = 16744703
MPTR = 0
MICON = "frmMain.frx":24796
ALIGN = 1
IMGLST = "(None)"
IMGICON = "(None)"
ICONAlign = 0
ORIENT = 0
STYLE = 0
IconSize = 2
SHOWF = -1 'True
BSTYLE = 0
End
Begin RichTextLib.RichTextBox txtChan
Height = 3615
Left = 120
TabIndex = 8
Top = 1320
Width = 5415
_ExtentX = 9551
_ExtentY = 6376
_Version = 393217
BackColor = 0
Appearance = 0
TextRTF = $"frmMain.frx":247B2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Verdana"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label Label1
Alignment = 2 'Center
BackStyle = 0 'Transparent
BeginProperty Font
Name = "Verdana"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 375
Left = 240
TabIndex = 6
Top = 840
Width = 2895
End
Begin VB.Shape Shape2
BorderColor = &H00FF8080&
Height = 300
Left = 100
Top = 5150
Width = 8690
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public timrcounter As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "User32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public UpdateChecker As Boolean
Private Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1
Const WS_EX_TRANSPARENT = &H20&
Public GameCol As Collection
Dim CntThis As Integer
Dim FirstRollover As Boolean
Public WindowProc As Long
Dim udpcount As Integer
Public TransON As Boolean
Dim udpst As Long 'udpstamp to be passed
Public strLastUser As String
Private Sub cmdCon_Click()
'First close any possible connection that still may be active
sckBnet.Close
'Then connect to server, with the designated bncs port
Chat.AddChat vbWhite, "Connecting to: " & IniServer
sckBnet.Connect IniServer, 6112
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Form_Load()
LoadCFG
FirstRollover = True
UpdateChecker = True
SetWindowLong txtChan.hWnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
Me.BackColor = vbCyan 'Set the backcolor of the tobe transparent form to w/e color
SetWindowLong Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
'now everything is transparent so you're gonna have to use this to only make what is a certain color transparent
SetLayeredWindowAttributes Me.hWnd, vbCyan, 0&, LWA_COLORKEY
'AddRTB frmMain.txtChan, clrBotInfo, "Game Announcer v" & App.Major & "." & App.Minor & " (Build: " & App.Revision & ") by Myst and cHip."
Chat.AddChat2 vbGreen, "Game Announcer v" & App.Major & "." & App.Minor & " (Build: " & App.Revision & ") by Myst and cHip."
If GrabWebTitle("http://darkblizz.org/thief/GameAnnouncer/UpdateChecker.html") = "v" & App.Major & "." & App.Minor & " Build " & App.Revision Then
' Chat.AddChat2 &HFFCCCC, "You are using the lastest version."
Else
Chat.AddChat2 &H3333FF, "Your bot is out of date, please visit www.DarkBlizz.org to obtain the latest release."
End If
ChangeBackground 'detect product and change bground
'Chat.AddChat2 "&H" & StrReverse("66FFCC"), "www.DarkBlizz.org"
'Chat.AddChat2 "&H" & StrReverse("CCFF00"), "Op Null [USEast]"
Chat.AddChat2 "&H" & StrReverse("66FFCC"), "www.DarkBlizz.org"
Chat.AddChat2 "&H" & StrReverse("CCFF00"), "irc.darkblizz.org #DarkBlizz"
Chat.AddChat2 "&H" & StrReverse("6600CC"), "Detecting " & WatchType & " games."
trigger = ReadINI("Options", "Trigger")
frmMain.Caption = "Game Announcer " & App.Major & "." & App.Minor & " (Build: " & App.Revision & ")"
Set UserList = New Collection
Set Queue = New clsQueue
Set CommandHandler = New clsCommandHandler
'Database.LoadDatabase
LoadAccess "Database.txt"
FirstTime = True
TimeFilter = 30 'deafult 3o secs
Label1.Caption = IniName & " [" & IniHome & "]"
End Sub
Private Sub cmdDiscon_Click()
KillTimer frmMain.hWnd, 1000
sckBnet.Close
'AddTimeStamp frmMain.txtChan
'AddRTB frmMain.txtChan, vbRed, "Disconnected"
Chat.AddChat vbRed, "Disconnected"
frmMain.HandleUnload
frmMain.Caption = "Game Announcer " & App.Major & "." & App.Minor & " (Build: " & App.Revision & ")"
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
ReleaseCapture
SendMessage hWnd, WM_NCLBUTTONDOWN, 2, 0&
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Shape2.BorderWidth = 1
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim ChunkVar As Variant
Dim ChunkStr As String
Select Case State
Case 12 'getchuck
'Chat.AddChat frmGenesis.TabStrip1.SelectedItem.Index, "The request has been completed and all data has been received.", vbWhite
ChunkVar = Inet1.GetChunk(1024, icString)
ChunkStr = ChunkStr & ChunkVar
Do
DoEvents
ChunkVar = Inet1.GetChunk(1024, icString)
If Len(ChunkVar) = 0 Then Exit Do
ChunkStr = ChunkStr & ChunkVar
Loop
If TransON <> True Then
If GotShowID = False Then
TVRageEpisode_GrabShowID ChunkStr
Else
TVRageEpisode_GrabShowINFO ChunkStr
End If
End If
On Error Resume Next
Dim GoogleArray() As String
Dim OutputMSG As String
Dim whatlen As Integer
Dim ForNum As Integer
If TransON = True Then
GoogleArray = Split(LCase(ChunkStr), "translatedtext")
whatlen = Len(Mid$(GoogleArray(1), 4, InStr(1, Mid$(GoogleArray(1), 4), """")))
OutputMSG = Mid$(GoogleArray(1), 4, whatlen - 2)
'HoldGoog = OutputMSG
modPkts.Send0x0E Mid$(GoogleArray(1), 4, whatlen - 2)
TransON = False
End If
Case Else
'Chat.AddChat frmGenesis.TabStrip1.SelectedItem.Index, "Unknown Inet State: " & Inet4.ResponseCode & " - " & Inet4.ResponseInfo, vbRed
End Select
End Sub
Public Function TVRageEpisode_GrabShowID(XMLData As String)
Dim XMLArray() As String 'Array to hold split XML Data
Dim Elements As String 'ID of stuff
Dim ElementData As String 'Stuff between the < >
Dim X As Integer 'count looper
X = 1
XMLArray = Split(XMLData, Chr(&HA)) 'Split incoming XML data by New Line(0x0A)
Do Until X = UBound(XMLArray) + 1
If XMLArray(X) <> "" Then 'Skip empty lines
Elements = Mid$(XMLArray(X), 2, InStr(1, Mid$(XMLArray(X), 2), ">") - 1) 'Parse out each element
ElementData = Replace(Mid$(XMLArray(X), Len(Elements) + 3, InStr(1, Mid$(XMLArray(X), Len(Elements) + 3), "<")), "<", "")
End If
Select Case Elements 'Find the elements
Case "Results"
If ElementData = "0" Then
Send0x0E "Zero Results Found, try to be more specific."
'Chat.AddChat Index, "Zero Results Found", vbRed
Exit Function
End If
Case "showid"
If Inet1.StillExecuting = True Then
pause (2)
End If
If GotShowID <> True Then
Inet1.Execute "http://services.tvrage.com/feeds/episodeinfo.php?sid=" & ElementData
End If
GotShowID = True
Case "name"
End Select
X = X + 1
DoEvents
Loop
End Function
Public Function TVRageEpisode_GrabShowINFO(XMLData As String)
Dim XMLArray() As String 'Array to hold split XML Data
Dim Elements As String 'ID of stuff
Dim ElementData As String 'Stuff between the < >
Dim X As Integer 'count looper
Dim ShowName, WhenOn, TimeOn, Network, LatestEP, LatestEPDate, LatestEPTitle, NextEP, NextEPDate, NextEPTitle As String
X = 1
XMLArray = Split(XMLData, "><") 'Split incoming XML data by ><
Do Until X = UBound(XMLArray) + 1
'MsgBox XMLArray(X)
If XMLArray(X) <> "" Then 'Skip empty lines
Elements = Replace(Mid$(XMLArray(X), 1, InStr(1, Mid$(XMLArray(X), 1), ">")), ">", "") 'Parse out each element
ElementData = Replace(Mid$(XMLArray(X), Len(Elements) + 2, InStr(1, Mid$(XMLArray(X), Len(Elements) + 2), "<")), "<", "")
End If
Select Case Elements 'Find the elements
Case "Results"
If ElementData = "0" Then
Send0x0E "Zero Results Found, try to be more specific."
Exit Function
End If
Case "name"
ShowName = ElementData
Case "airtime"
WhenOn = ElementData
Case "number"
If LatestEP = "" Then
LatestEP = ElementData
Else
NextEP = ElementData
End If
Case "title"
If LatestEPTitle = "" Then
LatestEPTitle = ElementData
Else
NextEPTitle = ElementData
End If
Case "airdate"
If LatestEPDate = "" Then
LatestEPDate = ElementData
Else
NextEPDate = ElementData
End If
End Select
X = X + 1
DoEvents
Loop
'Chat.AddChat Index, ShowName & "--" & WhenOn & " [Latest EP: " & LatestEP & " " & LatestEPTitle & " @" & LatestEPDate & ".] [Next EP " & NextEP & " " & NextEPTitle & " @" & NextEPDate & ".]", vbWhite
'sckIRC(Index).SendData "PRIVMSG " & Chat.Home(Index) & " " & ShowName & "--" & WhenOn & " [Latest EP: " & LatestEP & " " & LatestEPTitle & " @" & LatestEPDate & ".] [Next EP " & NextEP & " " & NextEPTitle & " @" & NextEPDate & ".]" & vbCrLf
Send0x0E ShowName & "--" & WhenOn & " [Latest EP: " & LatestEP & " " & LatestEPTitle & " @" & LatestEPDate & ".] [Next EP " & NextEP & " " & NextEPTitle & " @" & NextEPDate & ".]"
'GotShowID = False
End Function
Sub pause(interval As String)
Dim X
X = Timer
Do While Timer - X < Val(interval)
DoEvents
Loop
End Sub
Private Sub LaVolpeButton1_Click()
If MsgBox("Are you sure you want to quit?", vbOKCancel) = vbOK Then
'Database.SaveDatabase
WriteINI "Options", "Trigger", IniTrigger
Set CommandHandler = Nothing
Set UserList = Nothing
Call KillTimer(frmMain.hWnd, 1000)
Unload Me
KillProcess.KillProcess ("GameAnnouncer.exe")
Else
'nothing
End If
End Sub
Private Sub LaVolpeButton2_Click()
NoSysIcon INTRAY
End Sub
Private Sub LaVolpeButton3_Click()
frmSettings.Show
End Sub
Private Sub sckBnet_Connect()
Chat.AddChat vbGreen, "Connected!"
'////i see it, you dont have UDP_Getdata?
'Since we have connected now you send battle.net a 0x01 byte
'telling them we're using the game protocol
'after you send that out you then send 0x50.
'////
'send 0x01
'send 0x50
'Bind UDP Socket to BNET Server (Removed 1/4/11)
'Dim watport As Integer
' watport = "6113"
' sckUDP.RemoteHost = IniServer
' sckUDP.RemotePort = 6112
' Do Until FreeBind(sckUDP, watport) = True
' watport = watport + 1
'Loop
' Chat.AddChat vbGreen, "UDP Port Binded"
''''''''''''''''''
'MsgBox watport
'what else are udoing?
''what you got multiple router ips uh, what?
buf2.InsertBYTE &H1
buf2.SendPacket sckBnet
Call Send0x50(IniVerByte)
End Sub
Public Function FreeBind(SOCK As Winsock, ByVal PortRange As Long) As Boolean
On Error GoTo NextPORT
With SOCK
.Close
.Bind PortRange, .LocalIP
End With
FreeBind = True
Exit Function
NextPORT:
If Err.Number = 10048 Then
FreeBind = False
Else
FreeBind = True
Chat.AddChat vbRed, "[UDP] Bind Error:" & Err.Number & " Unable to bind " & Err.Description
End If
End Function
Private Sub sckBnet_DataArrival(ByVal bytesTotal As Long)
Static RecvBuffer As String 'we hold the data sent to us from bnet in this string
Dim PacketLengh As Integer
Dim Data As String
Call sckBnet.GetData(Data, vbString)
RecvBuffer = RecvBuffer & Data 'add the recv data to are buffer string from bnet
'now lets split each packet up and parse it baced on the 2 bytes lengh in the header
While Len(RecvBuffer) >= 4
PacketLengh = buf2.GetWORD(Mid(RecvBuffer, 3, 2))
If Len(RecvBuffer) < PacketLengh Then Exit Sub 'we have to wait for the missing data to come before we handle it (packet may have got split up abit)
'cut out the packet from the buffer and put it in are tmp data string
Data = Left(RecvBuffer, PacketLengh)
RecvBuffer = Mid(RecvBuffer, 1 + PacketLengh) 'skip the packet we just cut out
Call ParseBnetData(Data) 'see a few subs below where we hand the packet to the parse sub
Wend
End Sub
Private Sub ParseBnetData(ByVal Data As String)
Dim PacketID As Byte 'Holds unsigned 8-bit (1-byte) integers ranging in
'value from 0 through 255.
'http://msdn.microsoft.com/en-us/library/e2ayt412%28VS.80%29.aspx
PacketID = Asc(Mid(Data, 2, 1)) 'Returns the value from the 2nd byte, the packet id, from incoming data
'''Now we need to parse out all these Packet ID's
'''We'll use the Select Case Statement, due to the multiple different statements that can occur
'''http://msdn.microsoft.com/en-us/library/cy37t14y.aspx
Select Case PacketID
Case &H1C 'GameCreateOK or Not OK
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H0 Then 'good
Call Chat.AddChat(vbRed, "Game Created Successfully")
Send0x0E "Game created Successfully"
Else
Call Chat.AddChat(vbRed, "Game Failed to Create")
Send0x0E "Game Failed to Create!"
End If
Case &H50 'We recieve packet 0x50 (http://www.bnetdocs.org/?op=packet&pid=146)
''' From the packet log below you see the BNCS identifier FF, and then next to that the Packet ID 50.
''' Following that you see 3E 00 (WORD). That is the length of the entire packet, including the
''' FF 50 in the begining.
'0030 ff c4 42 fc 00 00 ff 50 3e 00 00 00 00 00 e7 9a ..B....P >.......
'0040 6d 51 09 29 37 00 00 8b 51 03 70 5f c7 01 6c 6f mQ.)7... Q.p_..lo
'0050 63 6b 64 6f 77 6e 2d 49 58 38 36 2d 31 38 2e 6d ckdown-I X86-18.m
'0060 70 71 00 b4 ce 3d dc 82 53 16 61 3e 05 23 5a 3b pq...=.. S.a>.#Z;
'0070 bb e5 92 00 ....
''''// Packet Header: ff 50 3e 00
''''//(DWORD) Logon Type: 00 00 00 00
''''//(DWORD) Server Token: e7 9a 6d 51 [Saved to be used later on]
''''//(DWORD) UDP Token: 09 29 37 00 [Saved to be used later on in 0x09]
''''//(QWORD) Filetime: 00 8b 51 03 70 5f c7 01 [timestamp for version check used in BNLS 0x1A]
''''//(String) filename: 6c 6f 63 6b 64 6f 77 6e 2d 49 58 38 36 2d 31 38 2e 6d 70 71 00[mpq filename, terminated by a null byte]
''''//(String) b4 ce 3d dc 82 53 16 61 3e 05 23 5a 3b bb e5 92 00 [formula string used to do check revision, terminated by a null byte]
Chat.AddChat vbGreen, "Recieved 0x50"
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H0 Then 'passed our client's logon challenge
'now to parse out the important infomation from the packet
Dim tmpFileTime As String * 8
'this is used later on, so we must remember it, thats why the "ServerToken" String is declared publicly in the modPkts
modPkts.ServerToken = buf2.GetDWORD(Mid(Data, 9, 4)) ' e7 9a 6d 51
tmpFileName = buf2.GetSTRING(Mid(Data, 25)) 'will look for a null byte as from 25th byte on and cut out the string when it finds the null byte
tmpFileTime = Mid$(Data, 17, 8) 'used in BNLS 0x1A
tmpFormula = buf2.GetSTRING(Mid(Data, 26 + Len(tmpFileName))) 'get the string behind the filename string (using the length of the filename)
modPkts.UDPToken = buf2.GetDWORD(Mid(Data, 13, 4)) 'To be sent 3x via 0x09UDP
'Call modPkts.Send0x09 '///call 3x 0x09 UDP
Dim Checksum As Long
Dim exeversion As Long
Dim vidBuf() As Byte
Dim EXEInfo As String * 128 'Allocate enough space
Dim str As String
tmpFileName = Replace(tmpFileName, ".mpq", ".dll") 'Need to replace the .mpq extension with .dll for libbnet
vidBuf = LoadResData(101, "CUSTOM") 'Loads Star.bin data from the resource file
str = StrConv(vidBuf, vbUnicode) 'Need to convert the byte array into Unicode format to be read properly
'///Make a function here to check if user even has Hash files in folder or Lockdown folder
If InStr(1, tmpFileName, "lockdown") = 1 Then
If checkrevision_ld_raw_video(App.Path & "\STAR\starcraft.exe", App.Path & "\STAR\storm.dll", App.Path & "\STAR\battle.snp", tmpFormula, exeversion, Checksum, EXEInfo, App.Path & "\Lockdown\" & tmpFileName, str, Len(str)) = 0 Then
Chat.AddChat vbRed, "CheckRevision Failed"
sckBnet.Close
Exit Sub
Else
Chat.AddChat vbGreen, "CheckRevision Passed!"
End If
Else
If checkrevision(App.Path & "\STAR\starcraft.exe", App.Path & "\STAR\storm.dll", App.Path & "\STAR\battle.snp", tmpFormula, exeversion, Checksum, EXEInfo, tmpFileName) = 0 Then
Chat.AddChat vbRed, "CheckRevision Failed"
sckBnet.Close
Exit Sub
Else
Chat.AddChat vbGreen, "CheckRevision Passed!"
End If
End If
Call modPkts.Send0x51(tmpFormula, tmpFileName, Checksum, exeversion, EXEInfo) ''We now send the next packet in the sequence 0x51, and also send it the two stored variables we got from 0x50
Else 'failed challenge (unless this is w3..)
modPkts.ServerToken = buf2.GetDWORD(Mid(Data, 9, 4)) ' 71 4E 35 B5
tmpFileName = buf2.GetSTRING(Mid(Data, 25)) 'will look for a null byte as from 25th byte on and cut out the string when it finds the null byte
tmpFileTime = Mid$(Data, 17, 8)
tmpFormula = buf2.GetSTRING(Mid(Data, 26 + Len(tmpFileName))) 'get the string behind the filename string (useing the lengh of the filename)
If checkrevision(App.Path & "\WAR3\war3.exe", App.Path & "\WAR3\Storm.dll", App.Path & "\WAR3\game.dll", tmpFormula, exeversion, Checksum, EXEInfo, tmpFileName) = 0 Then
Chat.AddChat vbRed, "CheckRevision Failed"
sckBnet.Close
Exit Sub
Else
Chat.AddChat vbGreen, "CheckRevision Passed!"
Call modPkts.Send0x51(tmpFormula, tmpFileName, Checksum, exeversion, EXEInfo) ''We now send the next packet in the sequence 0x51, and also send it the two stored variables we got from 0x50
End If
End If
Case &H51
Chat.AddChat vbGreen, "Recieved 0x51"
Select Case buf2.GetDWORD(Mid(Data, 5, 4))
Case &H0
Chat.AddChat vbGreen, "CDKey/Version Good"
If ConnectingID(IniCDKey) = "W3" Then
Call modPkts.Send0x53
Else
Call modPkts.Send0x3A
End If
Case &H100
Chat.AddChat vbRed, "Game version recognized, but out of date!"
sckBnet.Close 'Close Connection
Case &H101
Chat.AddChat vbRed, "Game version unrecognized!"
sckBnet.Close 'Close Connection
Case &H102
Chat.AddChat vbRed, "Game version must be downgraded!"
sckBnet.Close 'Close Connection
Case &H200
Chat.AddChat vbRed, "Invalid CD-key!"
sckBnet.Close 'Close Connection
Case &H203
Chat.AddChat vbRed, "Wrong product!"
sckBnet.Close 'Close Connection
Case &H202
Chat.AddChat vbRed, "CD-key banned by Battle.net!"
sckBnet.Close 'Close Connection
Case &H201
Chat.AddChat vbRed, "CD-key in use!"
sckBnet.Close 'Close Connection
End Select
Case &H52 'war3account creation
Select Case buf2.GetDWORD(Mid$(Data, 5, 4))
Case &H0:
AddChat vbGreen, IniName & " has been created!"
'Account Created! (logon it)
Call modPkts.Send0x53
Case &H7, &H8, &H9, &HA, &HB, &HC 'invalid Account
Chat.AddChat vbRed, IniName & " is a Invalid Account"
Call nls_free(NLSVal)
Case Else
'Call Chat.ShowChat(i, vbRed, "Account Already Exists") 'Account Already Exists"
Call nls_free(NLSVal)
End Select
Case &H53 'War3AccountLogOn
Chat.AddChat vbGreen, "Recieved 0x53"
Select Case buf2.GetDWORD(Mid$(Data, 5, 4))
Case &H0:
Chat.AddChat vbGreen, "Account LogOn Good:"
Call modPkts.Send0x54(Data) 'Account And Password Accepted (logon proof)
Case &H1:
AddChat vbRed, "Account doesnt exist"
Call modPkts.Send0x52 'Account Does Not Exist (create acc)
Case &H2:
Chat.AddChat vbRed, "Account needs upgrading" 'Account Requires Upgradeing (failed), vbred)
Case Else
End Select
Case &H54 'accountlogonproof
Chat.AddChat vbGreen, "Recieved 0x54"
Dim tmpResult As Long
tmpResult = buf2.GetDWORD(Mid$(Data, 5, 4))
Select Case tmpResult
Case &H0 'Password Proof Passed! (enter chat time)
Chat.AddChat vbGreen, "Password is right"
Call modPkts.Send0x0A
Call modPkts.Send0x0B
Call modPkts.Send0x0C
Case &H2 'Incorrect password
Chat.AddChat vbRed, "Pass is Wrong!"
Case &HE 'An Email Address Should Be Registered To This Account (can skip and enter chat anyway)
Chat.AddChat vbYellow, "Account is not Registered"
Call modPkts.Send0x0A
Call modPkts.Send0x0B
Call modPkts.Send0x0C
Case &HF 'custom error message
Chat.AddChat vbRed, "0x54 Error"
Case Else
End Select
Case &H3A
Chat.AddChat vbGreen, "Recieved 0x3A"
Select Case buf2.GetDWORD(Mid(Data, 5, 4))
Case &H0
Dim udpstamp As Long
Chat.AddChat vbGreen, "Logon passed!"
Call modPkts.Send0x14
Call modPkts.Send0x0A
'Call modPkts.Send0x0B
Call modPkts.Send0x0C
Case &H1
Chat.AddChat vbRed, "Account does not exist!"
Call modPkts.Send0x3D
Case &H2
Chat.AddChat vbRed, "Invalid password!"
sckBnet.Close 'Close Connection
Case &H6
Chat.AddChat vbRed, "Account closed!"
sckBnet.Close 'Close Connection
Case Else
Chat.AddChat vbRed, "Failed 0x3A Logon"
sckBnet.Close 'Close Connection
End Select
Case &H3D 'Creating Account
Chat.AddChat vbGreen, "Recieved 0x3D"
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H0 Then 'Account Created
Chat.AddChat vbGreen, IniName & " was created!"
Call modPkts.Send0x3A
Else
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H2 Then 'invalid
Chat.AddChat vbRed, IniName & " has invalid characters!"
Exit Sub
Else
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H3 Then 'Name contained bad stuff
Chat.AddChat vbRed, IniName & " contains bad words!"
Exit Sub
Else
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H4 Then 'Account Exists
Chat.AddChat vbRed, IniName & " already exists!"
Exit Sub
Else
If buf2.GetDWORD(Mid(Data, 5, 4)) = &H6 Then 'Account doesnt have enough alphanumeric
Chat.AddChat vbRed, IniName & " doesn't have enough characters!"
Exit Sub
End If
End If
End If
End If
End If
Case &H25
Call modPkts.Send0x25(Data)
Case &H9 ' Game List