-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublicStuff.vb
813 lines (577 loc) · 24.7 KB
/
PublicStuff.vb
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
Imports System.Data.SQLite
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Security
Module PublicStuff
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
' SHARED VAR
Public WOW_SESSIONS As New List(Of WoW_Session)
Public Const CONSTRING As String = "Data Source=VanillaLauncher.db;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory;foreign keys=true;;"
Public IsMainFormLoaded As Boolean
' STORED PARAMETERS (From database)
Public DB_VERSION As Integer
Public VANILLA_EXE As String
Public VANILLA_DIR As String
Public BC_EXE As String
Public BC_DIR As String
Public TURTLE_EXE As String
Public TURTLE_DIR As String
Public WAIT_LOAD As Integer
Public WAIT_LOGIN As Integer
Public WAIT_DOWN As Integer
Public ISCRYPT As Boolean
Public LANG As String
Public TRAY_DEFAULT_WINDOW As Integer
Public TRAY_SHOW_FOLDER As Boolean
Public TRAY_SHOW_KILL As Boolean
Public TRAY_SHOW_SUB_WINDOWED As Boolean
Public TRAY_SHOW_SUBSUB_WINDOWED As Boolean
Public SHOW_TASKBAR As Boolean
Public TRAY_SHOW_LINKS As Boolean
Public CHAR_IMAGE As String
Public GUILD_LINKS As Boolean
Public GUILD_NAME As String
Public SOFT_KILL As Boolean
Public MONITORING As Boolean
' COMPUTED PARAMETERS
Public TOTAL_RAM As Long
Public SKEY As SecureString
Public NBR_MONITORS As Integer
Public SCREEN1_RATIO As Single
Public SCREEN2_RATIO As Single
' EASTER EGG
Public RAGNA_SPEECH As New List(Of String)(New String() {"TOO SOON! YOU HAVE AWAKENED ME TOO SOON, EXECUTUS!",
"WHAT IS THE MEANING OF THIS INTRUSION?",
"PAR LE FEU, SOYEZ PURIFIÉS !",
"GOÛTEZ AUX FLAMMES DE SULFURON !",
"MEURS, INSECTE !"
})
Public Sub Get_Params()
Dim objConn = New SQLiteConnection(CONSTRING)
Dim objCommand As SQLiteCommand
Dim objReader As SQLiteDataReader
Try
Dim sql As String = "SELECT ParamName, ParamValue FROM param "
objConn = New SQLiteConnection(CONSTRING & "New=True;")
Using (objConn)
objConn.Open()
objCommand = objConn.CreateCommand()
objCommand.CommandText = sql
objReader = objCommand.ExecuteReader()
While (objReader.Read())
Select Case objReader("ParamName")
Case "VANILLA_EXE"
VANILLA_EXE = objReader("ParamValue")
Case "BC_EXE"
BC_EXE = objReader("ParamValue")
Case "TURTLE_EXE"
TURTLE_EXE = objReader("ParamValue")
Case "Wait_Load"
WAIT_LOAD = CInt(objReader("ParamValue"))
Case "Wait_Login"
WAIT_LOGIN = CInt(objReader("ParamValue"))
Case "Wait_Down"
WAIT_DOWN = CInt(objReader("ParamValue"))
Case "IsCrypt"
ISCRYPT = CInt(objReader("ParamValue"))
Case "DB_Version"
DB_VERSION = CInt(objReader("ParamValue"))
Case "Default_Window"
TRAY_DEFAULT_WINDOW = CInt(objReader("ParamValue"))
Case "ShowFolder"
If CInt(objReader("ParamValue")) = 1 Then
TRAY_SHOW_FOLDER = True
Else
TRAY_SHOW_FOLDER = False
End If
Case "ShowLinks"
If CInt(objReader("ParamValue")) = 1 Then
TRAY_SHOW_LINKS = True
Else
TRAY_SHOW_LINKS = False
End If
Case "Char_Image"
CHAR_IMAGE = objReader("ParamValue")
Case "ShowKill"
If CInt(objReader("ParamValue")) = 1 Then
TRAY_SHOW_KILL = True
Else
TRAY_SHOW_KILL = False
End If
Case "ShowTaskBar"
If CInt(objReader("ParamValue")) = 1 Then
SHOW_TASKBAR = True
Else
SHOW_TASKBAR = False
End If
Case "GuildLinks"
If CInt(objReader("ParamValue")) = 1 Then
GUILD_LINKS = True
Else
GUILD_LINKS = False
End If
Case "GuildName"
GUILD_NAME = objReader("ParamValue")
Case "ShowSubWindowed"
If CInt(objReader("ParamValue")) = 1 Then
TRAY_SHOW_SUB_WINDOWED = True
Else
TRAY_SHOW_SUB_WINDOWED = False
End If
Case "ShowSubSubWindowed"
If CInt(objReader("ParamValue")) = 1 Then
TRAY_SHOW_SUBSUB_WINDOWED = True
Else
TRAY_SHOW_SUBSUB_WINDOWED = False
End If
Case "Monitoring"
If CInt(objReader("ParamValue")) = 1 Then
MONITORING = True
Else
MONITORING = False
End If
Case "SoftKill"
If CInt(objReader("ParamValue")) = 1 Then
SOFT_KILL = True
Else
SOFT_KILL = False
End If
End Select
End While
If File.Exists(VANILLA_EXE) Then
VANILLA_DIR = Path.GetDirectoryName(VANILLA_EXE)
End If
If File.Exists(BC_EXE) Then
BC_DIR = Path.GetDirectoryName(BC_EXE)
End If
If File.Exists(TURTLE_EXE) Then
TURTLE_DIR = Path.GetDirectoryName(TURTLE_EXE)
End If
End Using
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
Public Sub Start_Macro(ID As Integer)
Dim objConn = New SQLiteConnection(CONSTRING)
Dim objCommand As SQLiteCommand
Dim objReader As SQLiteDataReader
Dim WaitTime As Integer
Dim WS As WoW_Session
Try
If ID = 0 Then Exit Sub
objConn = New SQLiteConnection(CONSTRING & "New=True;")
Using (objConn)
objConn.Open()
objCommand = objConn.CreateCommand()
objCommand.CommandText = " SELECT s.*, COALESCE(s.CharID,0) AS CI FROM macro_step s WHERE s.MacroID=" & ID & " ORDER BY s.StepOrder"
objReader = objCommand.ExecuteReader()
While (objReader.Read())
WaitTime = CInt(objReader("StepWait"))
WS = New WoW_Session
Select Case objReader("StepWindow")
Case "Windowed"
WS.Screen = 1
WS.IsWindowed = True
Case "Windowed1"
WS.Screen = 1
WS.IsWindowed = True
Case "Windowed2"
WS.Screen = 2
WS.IsWindowed = True
Case Else
WS.Screen = 1
WS.IsWindowed = False
End Select
If Not IsDBNull(objReader("StepX")) Then
WS.WindowX = CInt(objReader("StepX"))
End If
If Not IsDBNull(objReader("StepY")) Then
WS.WindowY = CInt(objReader("StepY"))
End If
If Not IsDBNull(objReader("StepW")) Then
WS.WindowW = CInt(objReader("StepW"))
End If
If Not IsDBNull(objReader("StepH")) Then
WS.WindowH = CInt(objReader("StepH"))
End If
If objReader("CI") = 0 Then
WS.Set_AccountID(CInt(objReader("AccountID")))
Else
WS.Set_CharID(CInt(objReader("CharID")))
End If
WS.Start_WoW()
Threading.Thread.Sleep(WaitTime)
End While
End Using
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
Public Sub Kill_WoW_Process(ProcID)
Dim proc As System.Diagnostics.Process
Dim WS As WoW_Session
Try
If ProcID = 0 Then
For Each WS In WOW_SESSIONS
proc = Process.GetProcessById(WS.ProcID)
If Strings.UCase(proc.ProcessName) = "WOW" Then
If SOFT_KILL Then
proc.CloseMainWindow()
Else
proc.Kill()
End If
End If
Next
WOW_SESSIONS.Clear()
Else
proc = Process.GetProcessById(ProcID)
If Strings.UCase(proc.ProcessName) = "WOW" Then
If SOFT_KILL Then
proc.CloseMainWindow()
Else
proc.Kill()
End If
For Each WS In WOW_SESSIONS
If WS.ProcID = ProcID Then
WOW_SESSIONS.Remove(WS)
Exit For
End If
Next
End If
End If
Catch ex As Exception
End Try
End Sub
Public Sub Set_Param(strParam As String, strValue As String)
Dim objConn As SQLiteConnection
Dim objCommand As SQLiteCommand
Try
objConn = New SQLiteConnection(CONSTRING & "New=True;")
Using (objConn)
objConn.Open()
objCommand = objConn.CreateCommand()
objCommand.CommandText = "UPDATE param SET ParamValue=$VAL WHERE ParamName=$PARAM"
objCommand.Parameters.Add("$PARAM", DbType.String).Value = strParam
objCommand.Parameters.Add("$VAL", DbType.String).Value = strValue
objCommand.ExecuteNonQuery()
End Using
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Sub
Public Function PWD_Encrypt(plainText As String) As String
Try
Dim myPtr As IntPtr = Marshal.SecureStringToBSTR(SKEY)
' MessageBox.Show("key=" & Marshal.PtrToStringUni(myPtr))
Dim wrapper As New Simple3Des(Marshal.PtrToStringUni(myPtr))
Dim cipherText As String = wrapper.EncryptData(plainText)
Return cipherText
Catch ex As Exception
MessageBox.Show("Can't encrypt password: " & ex.Message)
Return ""
End Try
End Function
Public Function PWD_Decrypt(plainText As String) As String
Try
Dim myPtr As IntPtr = Marshal.SecureStringToBSTR(SKEY)
'MessageBox.Show("key=" & Marshal.PtrToStringUni(myPtr))
Dim wrapper As New Simple3Des(Marshal.PtrToStringUni(myPtr))
Dim cipherText As String = wrapper.DecryptData(plainText)
Return cipherText
Catch ex As Exception
MessageBox.Show("Can't decrypt password: " & ex.Message)
Return ""
End Try
End Function
Public Function GetAllScreensResolution() As Point
Try
Dim ResX As Integer =
(From scr As Screen In Screen.AllScreens Select scr.Bounds.Width).Sum
Dim ResY As Integer =
(From scr As Screen In Screen.AllScreens Select scr.Bounds.Height).Sum
Return New Point(ResX, ResY)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Function
Public Function GetPrimaryScreenResolution() As Point
Try
Return New Point(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Function
Public Function GetPrimaryScreenWorkingArea() As Point
Try
Return New Point(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Function
Public Function GetSecondaryScreenResolution() As Point
Try
Dim ResX As Integer =
(From scr As Screen In Screen.AllScreens Select scr.Bounds.Width).Sum
Dim ResY As Integer =
(From scr As Screen In Screen.AllScreens Select scr.Bounds.Height).Sum
Return New Point(ResX - Screen.PrimaryScreen.Bounds.Width, ResY - Screen.PrimaryScreen.Bounds.Height)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Function
Public Function GetSecondaryScreenWorkingArea() As Point
Try
Dim ResX As Integer =
(From scr As Screen In Screen.AllScreens Select scr.WorkingArea.Width).Sum
Dim ResY As Integer =
(From scr As Screen In Screen.AllScreens Select scr.WorkingArea.Height).Sum
Return New Point(ResX - Screen.PrimaryScreen.WorkingArea.Width, ResY - Screen.PrimaryScreen.WorkingArea.Height)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
End Function
Public Function GetPingMs(ByRef hostNameOrAddress As String)
Dim ping As New System.Net.NetworkInformation.Ping
Return ping.Send(hostNameOrAddress).RoundtripTime
End Function
Public Function Easter_Egg() As String
Try
' Rand 1-100
Dim IntChance As Integer = CInt(Math.Ceiling(Rnd() * 100))
If IntChance > RAGNA_SPEECH.Count Then
Return ""
Else
Return RAGNA_SPEECH(IntChance - 1)
End If
Catch ex As Exception
End Try
End Function
Public Function Image_Class(strClass As String) As Image
Dim img As Image
Try
Select Case strClass
Case "Death Knight"
img = My.Resources.class_deathknight
Case "Demon Hunter"
img = My.Resources.class_demonhunter
Case "Druid"
img = My.Resources.class_druid
Case "Hunter"
img = My.Resources.class_hunter
Case "Mage"
img = My.Resources.class_mage
Case "Monk"
img = My.Resources.class_monk
Case "Paladin"
img = My.Resources.class_paladin
Case "Priest"
img = My.Resources.class_priest
Case "Rogue"
img = My.Resources.class_rogue
Case "Shaman"
img = My.Resources.class_shaman
Case "Warlock"
img = My.Resources.class_warlock
Case "Warrior"
img = My.Resources.class_warrior
Case "Mule"
img = My.Resources.mule
Case Else
img = My.Resources.question_mark
End Select
Return img
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
Return My.Resources.question_mark
End Try
End Function
Public Function Image_Race(strRace As String, strGender As String) As Image
Dim img As Image
Try
Select Case strRace
Case "Goblin"
If strGender = "M" Then
img = My.Resources.IconSmall_Goblin2_Male
Else
img = My.Resources.IconSmall_Goblin2_Female
End If
Case "Blood Elf"
If strGender = "M" Then
img = My.Resources.IconSmall_BloodElf_Male
Else
img = My.Resources.IconSmall_BloodElf_Female
End If
Case "Troll"
If strGender = "M" Then
img = My.Resources.IconSmall_Troll_Male
Else
img = My.Resources.IconSmall_Troll_Female
End If
Case "Tauren"
If strGender = "M" Then
img = My.Resources.IconSmall_Tauren_Male
Else
img = My.Resources.IconSmall_Tauren_Female
End If
Case "Undead"
If strGender = "M" Then
img = My.Resources.IconSmall_Undead_Male
Else
img = My.Resources.IconSmall_Undead_Female
End If
Case "Orc"
If strGender = "M" Then
img = My.Resources.IconSmall_Orc_Male
Else
img = My.Resources.IconSmall_Orc_Female
End If
Case "Pandaren"
If strGender = "M" Then
img = My.Resources.IconSmall_Pandaren_Male
Else
img = My.Resources.IconSmall_Pandaren_Female
End If
Case "Worgen"
If strGender = "M" Then
img = My.Resources.IconSmall_Worgen2_Male
Else
img = My.Resources.IconSmall_Worgen2_Female
End If
Case "Dranei"
If strGender = "M" Then
img = My.Resources.IconSmall_Draenei_Male
Else
img = My.Resources.IconSmall_Draenei_Female
End If
Case "Gnome"
If strGender = "M" Then
img = My.Resources.IconSmall_Gnome_Male
Else
img = My.Resources.IconSmall_Gnome_Female
End If
Case "Night Elf"
If strGender = "M" Then
img = My.Resources.IconSmall_NightElf_Male
Else
img = My.Resources.IconSmall_NightElf_Female
End If
Case "Dwarf"
If strGender = "M" Then
img = My.Resources.IconSmall_Dwarf_Male
Else
img = My.Resources.IconSmall_Dwarf_Female
End If
Case "Human"
If strGender = "M" Then
img = My.Resources.IconSmall_Human_Male
Else
img = My.Resources.IconSmall_Human_Female
End If
Case "High Elf"
If strGender = "M" Then
img = My.Resources.IconSmall_BloodElf_Male
Else
img = My.Resources.IconSmall_BloodElf_Female
End If
Case "Goblin"
If strGender = "M" Then
img = My.Resources.IconSmall_Goblin2_Male
Else
img = My.Resources.IconSmall_Goblin2_Female
End If
Case Else
img = My.Resources.question_mark
End Select
Return img
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
Return My.Resources.question_mark
End Try
End Function
Public Function Image_Race_Big(strRace As String, strGender As String) As Image
Dim img As Image
Try
Select Case strRace
Case "Blood Elf"
If strGender = "M" Then
img = My.Resources.achievement_character_bloodelf_male
Else
img = My.Resources.achievement_character_bloodelf_female
End If
Case "Troll"
If strGender = "M" Then
img = My.Resources.achievement_character_troll_male
Else
img = My.Resources.achievement_character_troll_female
End If
Case "Tauren"
If strGender = "M" Then
img = My.Resources.achievement_character_tauren_male
Else
img = My.Resources.achievement_character_tauren_female
End If
Case "Undead"
If strGender = "M" Then
img = My.Resources.achievement_character_undead_male
Else
img = My.Resources.achievement_character_undead_female
End If
Case "Orc"
If strGender = "M" Then
img = My.Resources.achievement_character_orc_male
Else
img = My.Resources.achievement_character_orc_female
End If
Case "Dranei"
If strGender = "M" Then
img = My.Resources.achievement_character_draenei_male
Else
img = My.Resources.achievement_character_draenei_female
End If
Case "Gnome"
If strGender = "M" Then
img = My.Resources.achievement_character_gnome_male
Else
img = My.Resources.achievement_character_gnome_female
End If
Case "Night Elf"
If strGender = "M" Then
img = My.Resources.achievement_character_nightelf_male
Else
img = My.Resources.achievement_character_nightelf_female
End If
Case "Dwarf"
If strGender = "M" Then
img = My.Resources.achievement_character_dwarf_male
Else
img = My.Resources.achievement_character_dwarf_female
End If
Case "Human"
If strGender = "M" Then
img = My.Resources.achievement_character_human_male
Else
img = My.Resources.achievement_character_human_female
End If
Case "High Elf"
If strGender = "M" Then
img = My.Resources.highelf_male
Else
img = My.Resources.highelf_female
End If
Case "Goblin"
If strGender = "M" Then
img = My.Resources.goblin_male
Else
img = My.Resources.goblin_female
End If
Case Else
img = My.Resources.question_mark
End Select
Return img
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
Return My.Resources.question_mark
End Try
End Function
End Module