private void SetGameMode(GameMode mode) { IniFileName ini = new IniFileName(Environment.CurrentDirectory + @"\ini\GameSetUp.ini"); int lowTimes = 0; int highTimes = 0; try { lowTimes = int.Parse(ini.GetEntryValue("GameMode", "LowTimes").ToString()); highTimes = int.Parse(ini.GetEntryValue("GameMode", "HighTimes").ToString()); } catch { } switch (mode) { case GameMode.HighDefinition: highTimes++; break; case GameMode.LowDefinition: lowTimes++; break; } ini.SetValue("GameMode", "LowTimes", lowTimes); ini.SetValue("GameMode", "GameModeRecord", (int)mode); ini.SetValue("GameMode", "HighTimes", highTimes); }
public void ProcessPacket(PatchServer server, byte[] buffer) { if (InvokeRequired) { Invoke(new Action <PatchServer, byte[]>(ProcessPacket), server, buffer); return; } if (buffer.Length < 4) { return; } PacketType type = (PacketType)BitConverter.ToUInt32(buffer, 2); switch (type) { case PacketType.MsgClientInfo: MsgClientInfo msg = new MsgClientInfo(buffer); List <string> list = msg.GetStrings(); if (list.Count <= 0) { Kernel.HasAgreedPrivacy = true; RequestPatches(AutoUpdateRequestType.CheckForLauncherUpdates, server); return; } string strPrivacyDate = m_ifConfig.GetEntryValue("Config", "TermsOfPrivacy").ToString(); if (!DateTime.TryParse(strPrivacyDate, out DateTime date) || !DateTime.TryParse(list[0], out DateTime serverTime) || serverTime > date) { if (new FrmTermsOfPrivacy(m_szPrivacyTerms).ShowDialog(this) != DialogResult.OK) { NoDownload(UpdateReturnMessage.PrivacyNotAccepted, false); return; } m_ifConfig.SetValue("Config", "TermsOfPrivacy", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } Kernel.HasAgreedPrivacy = true; Kernel.Stage = AutoPatchStage.WaitingForUpdaterPatchs; RequestPatches(AutoUpdateRequestType.CheckForLauncherUpdates, server); break; } }
private void btnGenerateKeys_Click(object sender, EventArgs e) { string path = Environment.CurrentDirectory + @"\" + _KEYS_FILENAME; if (!File.Exists(path)) { File.Create(path).Close(); StreamWriter file = new StreamWriter(path, false); file.WriteLine("; the asymmetric encryption will be used to store the key and iv of the"); file.WriteLine("; symmetric protocol."); file.WriteLine(""); file.WriteLine("; used for encryption"); file.WriteLine("[Public]"); file.WriteLine("Modulus="); file.WriteLine("Exponent="); file.WriteLine(""); file.WriteLine("; used for decryption"); file.WriteLine("[Private]"); file.WriteLine("Modulus="); file.WriteLine("Exponent="); file.WriteLine("P="); file.WriteLine("Q="); file.WriteLine("DP="); file.WriteLine("DQ="); file.WriteLine("Inverse="); file.WriteLine("D="); file.WriteLine(""); file.WriteLine("[Symmetric]"); file.WriteLine("Key="); file.WriteLine("IV="); file.Close(); file.Dispose(); file = null; } IniFileName iniFile = new IniFileName(path); //Generate a public/private key pair. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); //Save the public key information to an RSAParameters structure. RSAParameters publicInfo = rsa.ExportParameters(false); TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider(); tdes.GenerateIV(); tdes.GenerateKey(); AsymmetricCryptoHandler crypto = new AsymmetricCryptoHandler(publicInfo, true); byte[] key = crypto.Encrypt(tdes.Key); byte[] iv = crypto.Encrypt(tdes.IV); iniFile.SetValue("Public", "Modulus", Convert.ToBase64String(publicInfo.Modulus)); iniFile.SetValue("Public", "Exponent", Convert.ToBase64String(publicInfo.Exponent)); RSAParameters keyInfo = rsa.ExportParameters(true); iniFile.SetValue("Private", "Modulus", Convert.ToBase64String(keyInfo.Modulus)); iniFile.SetValue("Private", "Exponent", Convert.ToBase64String(keyInfo.Exponent)); iniFile.SetValue("Private", "P", Convert.ToBase64String(keyInfo.P)); iniFile.SetValue("Private", "Q", Convert.ToBase64String(keyInfo.Q)); iniFile.SetValue("Private", "DP", Convert.ToBase64String(keyInfo.DP)); iniFile.SetValue("Private", "DQ", Convert.ToBase64String(keyInfo.DQ)); iniFile.SetValue("Private", "Inverse", Convert.ToBase64String(keyInfo.InverseQ)); iniFile.SetValue("Private", "D", Convert.ToBase64String(keyInfo.D)); iniFile.SetValue("Symmetric", "Key", Convert.ToBase64String(key)); iniFile.SetValue("Symmetric", "IV", Convert.ToBase64String(iv)); StreamWriter csFile = new StreamWriter(Environment.CurrentDirectory + @"\csharp.cs", false); csFile.WriteLine($"private byte[] _MODULUS = {GenerateArrayString(keyInfo.Modulus)};"); csFile.WriteLine($"private byte[] _EXPONENT = {GenerateArrayString(keyInfo.Exponent)};"); csFile.WriteLine($"private byte[] _P = {GenerateArrayString(keyInfo.P)};"); csFile.WriteLine($"private byte[] _Q = {GenerateArrayString(keyInfo.Q)};"); csFile.WriteLine($"private byte[] _DP = {GenerateArrayString(keyInfo.DP)};"); csFile.WriteLine($"private byte[] _DQ = {GenerateArrayString(keyInfo.DQ)};"); csFile.WriteLine($"private byte[] _INVERSE = {GenerateArrayString(keyInfo.InverseQ)};"); csFile.WriteLine($"private byte[] _D = {GenerateArrayString(keyInfo.D)};"); csFile.WriteLine($""); csFile.WriteLine($"private byte[] _SYM_KEY = {GenerateArrayString(key)};"); csFile.WriteLine($"private byte[] _SYM_IV = {GenerateArrayString(iv)};"); csFile.Close(); csFile.Dispose(); }
public static void SetClientConfiguration(int width, int height, bool fullScreen, int fpsMode) { IniFileName ini = new IniFileName(Environment.CurrentDirectory + @"\ini\GameSetUp.ini"); ini.SetValue("ScreenMode", "ScreenModeRecord", 2); ini = new IniFileName(Environment.CurrentDirectory + @"\Config.ini"); ini.SetValue("GameResolution", "Width", width); ini.SetValue("GameResolution", "Height", height); ini.SetValue("GameSetup", "FpsMode", fpsMode); ini = new IniFileName(Environment.CurrentDirectory + @"\ini\GUI.ini"); // Main interface ini.SetValue("0-130", "x", (width - 1024) / 2); ini.SetValue("0-130", "y", height - 141); // Chat panel ini.SetValue("0-145", "x", ((width - 1024) / 2) + 82); ini.SetValue("0-145", "y", height - 71); // Chat Player Names ini.SetValue("0-148", "x", ((width - 1024) / 2) + 82 + 35); ini.SetValue("0-148", "y", height - 65 - 300); // Chat Channel ini.SetValue("0-174", "x", ((width - 1024) / 2) + 82 + 172); ini.SetValue("0-174", "y", height - 65 - 260); // Path Finding Button ini.SetValue("0-304", "x", width - 110); // Path Finding GUI ini.SetValue("0-303", "x", width - 530); // Exit Game ini.SetValue("0-158", "x", (width - 288) / 2); ini.SetValue("0-158", "y", (height - 120) / 2); // Options ini.SetValue("0-138", "x", (width - 370) / 2); ini.SetValue("0-138", "y", (height - 350) / 2); // Team ini.SetValue("0-141", "x", (width - 290) / 2); ini.SetValue("0-268", "x", (width - 58) / 2); //VIP Button ini.SetValue("0-339", "x", ((width - 1024) / 2) + 82 + 202); ini.SetValue("0-339", "y", height - 115); // My Talisman UI //ini.SetValue("0-345", "x", 9999); // Target Talisman UI //ini.SetValue("0-346", "x", 9999); // Shopping Mall ini.SetValue("0-289", "x", ((width - 1024) / 2) + 82 + 50); ini.SetValue("0-289", "y", height - 115); // Mentor ini.SetValue("0-325", "x", ((width - 1024) / 2) + 82 + 85); ini.SetValue("0-325", "y", height - 130); // Item Lock ini.SetValue("0-328", "x", ((width - 1024) / 2) + 82 + 145); ini.SetValue("0-328", "y", height - 110); // Whisper Player Avatars ini.SetValue("0-3", "x", ((width - 1024) / 2) + 82 + 530); ini.SetValue("0-3", "y", height - 115); // PKModes ini.SetValue("0-191", "x", ((width - 1024) / 2) + 82 + 500); ini.SetValue("0-191", "y", height - 100); // Map Mini ini.SetValue("0-1199", "x", width - 40); // Map Full ini.SetValue("0-1200", "x", width - 20); // Arena ini.SetValue("0-403", "x", ((width - 1024) / 2) + 82 + 250); ini.SetValue("0-403", "y", height - 115); // Action Express Interact Combobox ini.SetValue("0-367", "x", ((width - 1024) / 2) + 82 + 350); ini.SetValue("0-367", "y", height - 245); // Action ini.SetValue("0-140", "x", ((width - 1024) / 2) + 82 + 350); ini.SetValue("0-140", "y", height - 225); // Express ini.SetValue("0-274", "x", ((width - 1024) / 2) + 82 + 350); ini.SetValue("0-274", "y", height - 215); // Interact ini.SetValue("0-360", "x", ((width - 1024) / 2) + 82 + 350); ini.SetValue("0-360", "y", height - 215); // Group UI ini.SetValue("0-371", "x", ((width - 1024) / 2) + 82 + 600); ini.SetValue("0-371", "y", height - 140); // Message Channel ini.SetValue("0-357", "y", height - 452); // Message Scrollbar ini.SetValue("0-1198", "y", height - 477); // Mount Vigor ini.SetValue("0-383", "x", width - 200); ini.SetValue("0-383", "y", height - 200); // Target Talisman UI ini.SetValue("0-346", "x", width - 345); // Arena qualifier main ui ini.SetValue("0-402", "x", (width - 665) / 2); ini.SetValue("0-402", "y", (height - 560) / 2); // Arena qualifier opponent info ini.SetValue("0-409", "x", (width - 290) / 2); ini.SetValue("0-409", "y", (height - 120) / 2); // Arena qualifier fighting points info ini.SetValue("0-411", "x", (width - 310) / 2); // Arena qualifier quit button ini.SetValue("0-412", "x", ((width - 1024) / 2) + 82 + 320); ini.SetValue("0-412", "y", height - 130); // Arena qualifier count down box ini.SetValue("0-407", "x", (width - 290) / 2); ini.SetValue("0-407", "y", (height - 110) / 2); // Arena qualifier result box ini.SetValue("0-408", "x", (width - 300) / 2); ini.SetValue("0-408", "y", (height - 150) / 2); ini = new IniFileName(Environment.CurrentDirectory + @"\ini\info.ini"); // Exp ini.SetValue("ExpShowPos", "Exp_XPos", (width / 2) - 100); ini.SetValue("ExpShowPos", "Exp_YPos", height - 90); // AddExp ini.SetValue("ExpShowPos", "AddExp_XPos", (width / 2) - 100 + 90); ini.SetValue("ExpShowPos", "AddExp_YPos", height - 90); }
private void btnAccept_Click(object sender, EventArgs e) { IniFileName ini = new IniFileName(Environment.CurrentDirectory + @"\ini\GameSetUp.ini"); ini.SetValue("ScreenMode", "ScreenModeRecord", 2); string selectedResolution = cmbScreenResolution.Items[cmbScreenResolution.SelectedIndex].ToString(); int width = Math.Max(1024, int.Parse(selectedResolution.Split('x')[0]) - 20); int height = Math.Max(768, int.Parse(selectedResolution.Split('x')[1]) - 60); int windowInjection = chkNoInjection.Checked ? 1 : 0; ini = new IniFileName(Environment.CurrentDirectory + @"\Config.ini"); ini.SetValue("GameResolution", "Width", width); ini.SetValue("GameResolution", "Height", height); ini.SetValue("GameResolution", "NoWindowInjection", windowInjection.ToString()); int fpsMode = 0; if (radioNormalFps.Checked) { fpsMode = 0; } else if (radio60Fps.Checked) { fpsMode = 1; } else if (radioUnlockedFps.Checked) { fpsMode = 2; } ini.SetValue("GameSetup", "FpsMode", fpsMode); ini = new IniFileName(Environment.CurrentDirectory + @"\ini\GUI.ini"); // Main interface ini.SetValue("0-130", "x", (width - 1024) / 2); ini.SetValue("0-130", "y", height - 141); // Chat panel ini.SetValue("0-145", "x", ((width - 1024) / 2) + 82); ini.SetValue("0-145", "y", height - 71); // Chat Player Names ini.SetValue("0-148", "x", ((width - 1024) / 2) + 82 + 35); ini.SetValue("0-148", "y", height - 65 - 300); // Chat Channel ini.SetValue("0-174", "x", ((width - 1024) / 2) + 82 + 172); ini.SetValue("0-174", "y", height - 65 - 205); // Path Finding Button ini.SetValue("0-304", "x", width - 110); // Path Finding GUI ini.SetValue("0-303", "x", width - 530); // Exit Game ini.SetValue("0-158", "x", (width - 288) / 2); ini.SetValue("0-158", "y", (height - 120) / 2); // Options ini.SetValue("0-138", "x", (width - 370) / 2); ini.SetValue("0-138", "y", (height - 350) / 2); // Team ini.SetValue("0-141", "x", (width - 290) / 2); ini.SetValue("0-268", "x", (width - 58) / 2); //VIP Button ini.SetValue("0-339", "x", ((width - 1024) / 2) + 82 + 205); ini.SetValue("0-339", "y", height - 115); // My Talisman UI ini.SetValue("0-345", "x", 9999); // Target Talisman UI ini.SetValue("0-346", "x", 9999); // Shopping Mall ini.SetValue("0-289", "x", ((width - 1024) / 2) + 82 + 50); ini.SetValue("0-289", "y", height - 115); // Mentor ini.SetValue("0-325", "x", ((width - 1024) / 2) + 82 + 85); ini.SetValue("0-325", "y", height - 130); // Item Lock ini.SetValue("0-328", "x", ((width - 1024) / 2) + 82 + 145); ini.SetValue("0-328", "y", height - 110); // Whisper Player Avatars ini.SetValue("0-3", "x", ((width - 1024) / 2) + 82 + 400); ini.SetValue("0-3", "y", height - 115); // PKModes ini.SetValue("0-191", "x", ((width - 1024) / 2) + 82 + 500); ini.SetValue("0-191", "y", height - 100); // Map Mini ini.SetValue("0-1199", "x", width - 40); // Map Full ini.SetValue("0-1200", "x", width - 20); // Actions ini.SetValue("0-140", "x", ((width - 1024) / 2) + 250); ini.SetValue("0-140", "y", height - 180); ini = new IniFileName(Environment.CurrentDirectory + @"\ini\info.ini"); // Exp ini.SetValue("ExpShowPos", "Exp_XPos", (width / 2) - 150); ini.SetValue("ExpShowPos", "Exp_YPos", height - 90); // AddExp ini.SetValue("ExpShowPos", "AddExp_XPos", (width / 2) - 150 + 90); ini.SetValue("ExpShowPos", "AddExp_YPos", height - 90); Close(); }