Imports System.Net Imports System Imports System.IO Imports System.Text Imports System.Globalization Imports RARNET Imports System.Net.Sockets Public Class Form1 Friend WithEvents webdownloader As New System.Net.WebClient Dim cpx, cpy As Int32 Dim donereading As String = Nothing Dim TextLines() As String = Nothing Dim TextLines2() As String = Nothing Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown cpx = e.X cpy = e.Y End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove If e.Button = Windows.Forms.MouseButtons.Left Then Me.Top = Windows.Forms.Cursor.Position.Y() - cpy Me.Left = Windows.Forms.Cursor.Position.X() - cpx End If End Sub Public Sub DownloadNewPatch() On Error Resume Next Dim PatcherVersion As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "Version", "") Dim NeedVersion As Integer = TextLines(1).Split("=")(1) Dim NewAviableVersion As Integer = Val(PatcherVersion) + 1 ' If Val(PatcherVersion) < Val(NeedVersion) Then Launch.Enabled = False ProgressBar1.Value = 0 Dim Replace As String = "#Patch" & NewAviableVersion Dim Zeilen() As String = donereading.Split(Chr(9)) ' For i As Integer = 0 To Zeilen.Length - 1 If Zeilen(i).Contains(Replace) = True Then Dim PatchLine As String = TextLines2(i) Dim Data As String = PatchLine.Split(Chr(9))(1) VersionDownload.Text = "Download: " & Replace webdownloader.DownloadFileAsync(New Uri(Data), "patch.rar") End If Next ElseIf PatcherVersion > NeedVersion Then Launch.Enabled = False MessageBox.Show("Over Patch - Please select ""Reset Patcher""", "Xeni - Patching") Infoform.Show() Else Launch.Enabled = True ProgressBar1.Visible = False VersionDownload.Visible = False Prozent.Visible = False UsernameTextbox.Visible = True PasswordTextBox.Visible = True End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim TCP As New TcpClient("212.83.143.24", 11101) Dim NetStream As NetworkStream = TCP.GetStream() Dim swriter As New StreamWriter(NetStream) Dim sreader As New StreamReader(NetStream) swriter.WriteLine("getcfg") swriter.Flush() Do While sreader.Peek >= 1 donereading &= sreader.ReadLine & vbNewLine Loop TextLines = donereading.Split(Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries) swriter.WriteLine("getplist") swriter.Flush() donereading = Nothing donereading &= sreader.ReadLine & vbNewLine Do While sreader.Peek >= 1 donereading &= sreader.ReadLine & vbNewLine Loop TextLines2 = donereading.Split(Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries) TCP.Close() NetStream.Close() swriter.Close() sreader.Close() Catch ex As Exception MessageBox.Show("Can not connect to Remote Server: " & ex.Message & vbNewLine & "Error code: RS01", "Error :: Connection", MessageBoxButtons.OK, MessageBoxIcon.Error) Application.Exit() End Try Dim STPatcher As String = TextLines(0).Split("=")(1) ' If Val(My.Settings.Version) < Val(STPatcher) Then webdownloader.DownloadFile(TextLines(6).Split("=")(1), "Updater.exe") System.Diagnostics.Process.Start("Updater.exe") Application.Exit() Else '######## Vote ############# Dim OldDate As String If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "TimeVote", "") <> "" Then OldDate = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "TimeVote", "") Else My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "TimeVote", DateTime.Now.AddHours(-1).ToString) OldDate = DateTime.Now.AddHours(-1).ToString End If ' If DateTime.Compare(DateTime.Parse(OldDate), DateTime.Parse(DateTime.Now.ToString)) < 0 Then If TextLines(5).Split("=")(1) = True Then VoteForm.ShowDialog() My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "TimeVote", DateTime.Now.AddHours(12).ToString) End If End If '######### Main Login ################### Dim LoginID As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "LoginID", "") Dim Version As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "Version", "") UsernameTextbox.MaxLength = 100 PasswordTextBox.MaxLength = 100 If LoginID.ToString.Length >= 1 Then UsernameTextbox.Text = LoginID If UsernameTextbox.Text.Length >= 1 Then PasswordTextBox.Select() End If Else If Version.ToString.Length = 0 Then My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "Version", "1") End If End If DownloadNewPatch() End If End Sub Private Sub downloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles webdownloader.DownloadFileCompleted Dim PatcherVersion As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "Version", "") Dim NewAviableVersion As Integer = Val(PatcherVersion) + 1 ' If File.Exists("patch.rar") Then Prozent.Visible = False Dim d As Decompressor d = New Decompressor("patch.rar") AddHandler d.OnUnpack, AddressOf Unpacked AddHandler Decompressor.Unpacking, AddressOf InProgress d.UnPackAll(My.Application.Info.DirectoryPath) Application.DoEvents() Prozent.Visible = True ' File.Delete("patch.rar") My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "Version", NewAviableVersion) DownloadNewPatch() End If End Sub Private Sub downloader_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles webdownloader.DownloadProgressChanged ProgressBar1.Value = e.ProgressPercentage Prozent.Text = e.ProgressPercentage & "%" End Sub Private Sub Launch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Launch.Click If UsernameTextbox.Text = "plsrepatch" And PasswordTextBox.Text = "" Then Infoform.Show() Else Launch.Enabled = False UsernameTextbox.Enabled = False PasswordTextBox.Enabled = False If UsernameTextbox.Text.Length >= 1 AndAlso PasswordTextBox.Text.Length >= 1 Then Dim wc As New WebClient Dim wcanswer As String = wc.DownloadString("http://patch.xenionline.net/patchesv2/loginnew.php?username=" & UsernameTextbox.Text & "&password=" & MyFunction.MD5StringHash(PasswordTextBox.Text).ToLower) If wcanswer.Contains("offline") Then Dim ReasonString As String = TextLines(3).Split("=")(1) MessageBox.Show("Xeni Online is currently Offline!" & vbNewLine & "Reason: " & ReasonString, "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Information) Application.Exit() ElseIf wcanswer.Contains("success") Then Dim Token As String = wcanswer.ToString.Split("#")(1) My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Sign-Gaming\LauncherXeni", "LoginID", UsernameTextbox.Text) '################## If Not File.Exists("NANOFS.exe") Then MessageBox.Show("NANOFS.exe not found! Application Exit now!", "Xeni - Run") Application.Exit() Else If TextLines(2).Split("=")(1) = False Then Process.Start("NANOFS.exe", "NAFSSTART " & Token) Environment.Exit(0) Else MessageBox.Show(TextLines(4).Split("=")(1), "Xeni Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Process.Start("NANOFS.exe", "NAFSSTART " & Token) Environment.Exit(0) End If End If ElseIf wcanswer.ToString = "Account0" Then Launch.Enabled = True UsernameTextbox.Enabled = True PasswordTextBox.Enabled = True MessageBox.Show("Please check your ID!", "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Error) ElseIf wcanswer.ToString = "Account1" Then Launch.Enabled = True UsernameTextbox.Enabled = True PasswordTextBox.Enabled = True MessageBox.Show("Please check your Password!", "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Error) ElseIf wcanswer.ToString = "Banned0" Then MessageBox.Show("Your Account is banned!", "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Error) End ElseIf wcanswer.ToString = "Maintenance0" Then MessageBox.Show("Server is currently in Maintenance Mode!", "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Information) End Else ' My.Computer.FileSystem.WriteAllText("txt.txt", webbrowser1.DocumentText.ToString, False) 'Debugging MessageBox.Show("Could not connect to Xeni Login Server!" & vbNewLine & "Output: " & wcanswer.ToString, "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Warning) End End If Else Launch.Enabled = True UsernameTextbox.Enabled = True PasswordTextBox.Enabled = True MessageBox.Show("Please Enter your Account Information", "Xeni - Login", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End If End Sub Private Sub ExitIMG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitIMG.Click Application.Exit() End Sub Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UsernameTextbox.KeyUp, PasswordTextBox.KeyUp If e.KeyCode = Keys.Enter Then Launch_Click(sender, e) End Sub Public Sub Unpacked(ByVal r As Decompressor.RAREntry) If r.FileName.Length >= 100 Then VersionDownload.Text = "Processing: " & Mid(r.FileName, 0, 100) & " ..." Else VersionDownload.Text = "Processing: " & r.FileName End If End Sub Public Sub InProgress(ByVal TotalFileSize As Long, ByVal CurrentFileSize As Long, ByRef bDisposition As Decompressor.RarDisposition) If TotalFileSize = 0 Then Exit Sub ProgressBar1.Value = CInt(CDbl(Format(CurrentFileSize / TotalFileSize)) * 100) Application.DoEvents() End Sub End Class