private void BuildJarInBackground(LauncherProfile Profil, bool force = false) { if (!Profil.Settings.MinecraftRememberPassword && !force) { Profil.Setting_LauncherModAnalyzeStatus = 0; RefreshModIcon(); AddModInfo("Cache kann nur bei Remember Password im Hintergrund gebildet werden.", Profil); return; } if (ModCompatibilityChecker.IsBusy) { if (ProfileInCheck != null && ProfileInCheck.ProfileName == Profil.ProfileName) ModCompatibilityChecker.CancelAsync(); if (RebuildJarList.Contains(Profil)) return; RebuildJarList.Add(Profil); } else { ModCompatibilityChecker.RunWorkerAsync(Profil); } }
public static bool ProfileAuth(LauncherProfile Profil, out string SessionID, out string MC_User, string optpass = "") { string pass = DeScrambleString(Profil.Settings.MinecraftLoginPassword); if (pass == "") { pass = optpass; } string sid = ""; try { string CorrectUser; sid = MinecraftAuth.TestAuth(Profil.Settings.MinecraftLoginUser, pass, out CorrectUser); MC_User = CorrectUser; //Profil.Settings.MinecraftLoginUser = CorrectUser; SessionID = sid; return(true); } catch (Exception ex) { SessionID = ex.Message; MC_User = null; return(false); } }
public void NewProfile() { var NewProfileKey = Guid.NewGuid().ToString(); var NewProfile = new LauncherProfile() { Key = NewProfileKey, ProfileName = "[Profile Name]" }; if (LauncherVM.LauncherProfileList == null) { LauncherVM.LauncherProfileList = new System.Collections.ObjectModel.ObservableCollection <LauncherProfile>(); } LauncherVM.LauncherProfileList.Add(NewProfile); if (LauncherVM.SelectedLauncherProfile == null) { LauncherVM.SelectedLauncherProfile = NewProfile; LauncherVM.ProfileName = NewProfile.ProfileName; //ConfigVM.Cert = ConfigVM.HpioCertList.SingleOrDefault(x => x.FingerPrint == NewProfile.CertificateFingerPrint); LauncherVM.ProfileName = NewProfile.ProfileName; LauncherVM.Dob = NewProfile.Dob; LauncherVM.DvaNumber = NewProfile.DvaNumber; LauncherVM.Family = NewProfile.Family; LauncherVM.Gender = NewProfile.Gender; LauncherVM.Ihi = NewProfile.Ihi; LauncherVM.MedicareNumber = NewProfile.MedicareNumber; } SaveProfile(); LoadProfiles(); LauncherVM.SelectedProfileName = LauncherVM.LauncherProfileList.Single(x => x.Key == NewProfileKey).ProfileName; LauncherVM.SelectedLauncherProfile = LauncherVM.LauncherProfileList.Single(x => x.Key == NewProfileKey); LauncherVM.ProfileName = LauncherVM.SelectedLauncherProfile.ProfileName; LauncherVM.Dob = LauncherVM.SelectedLauncherProfile.Dob; LauncherVM.DvaNumber = LauncherVM.SelectedLauncherProfile.DvaNumber; LauncherVM.Family = LauncherVM.SelectedLauncherProfile.Family; LauncherVM.Gender = LauncherVM.SelectedLauncherProfile.Gender; LauncherVM.Ihi = LauncherVM.SelectedLauncherProfile.Ihi; LauncherVM.MedicareNumber = LauncherVM.SelectedLauncherProfile.MedicareNumber; }
public static bool ProfileAuth(LauncherProfile Profil,out string SessionID,out string MC_User,string optpass="") { string pass = DeScrambleString(Profil.Settings.MinecraftLoginPassword); if (pass == "") { pass = optpass; } string sid = ""; try { string CorrectUser; sid = MinecraftAuth.TestAuth(Profil.Settings.MinecraftLoginUser, pass, out CorrectUser); MC_User = CorrectUser; //Profil.Settings.MinecraftLoginUser = CorrectUser; SessionID = sid; return true; } catch (Exception ex) { SessionID = ex.Message; MC_User = null; return false; } }
static void Main() { if (!Application.MessageLoop) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); } Dictionary <string, string> ArgMap = new Dictionary <string, string>(); string[] args = Environment.GetCommandLineArgs(); foreach (string arg in args) { if (!arg.StartsWith("/")) { continue; } string[] sd = arg.Split('='); if (sd.Length != 2) { continue; } string key = sd[0].Substring(1); string val = sd[1]; if (!(key.Length > 0 && val.Length > 0)) { continue; } ArgMap.Add(key, val); } WischiLauncherMainForm MainFrm = new WischiLauncherMainForm(); if (ArgMap.ContainsKey("offline")) { if (ArgMap["offline"] == "true") { MainFrm.AllowOffline = true; } } if (ArgMap.ContainsKey("profil")) { List <LauncherProfile> fff = LauncherProfile.GetLauncherProfileList(); LauncherProfile p = null; foreach (LauncherProfile lp in fff) { if (lp.ProfileName == ArgMap["profil"]) { p = lp; break; } } if (p != null && p.Settings.MinecraftAutoLogin) { MainFrm.SwitchToConsoleScreen(); MainFrm.Show(); MainFrm.AddConsoleLine("Lade MinecraftJar-Infos"); MainFrm.RebuildLocations(true); MainFrm.KillOnExit = true; MainFrm.StartMinecraft(WischisLauncherCore.LauncherProfile.Load(ArgMap["profil"])); MainFrm.Hide(); } else { MessageBox.Show("Konnte Profil nicht direkt starten. Mögliche Gründe:" + Environment.NewLine + " - AutoLogin wurde nicht aktiviert." + Environment.NewLine + " - Das Profil konnte nicht gefunden werden (umbenannte, gelöscht usw.)"); MainFrm.Show(); } if (!Application.MessageLoop) { Application.Run(); } } else { if (!Application.MessageLoop) { Application.Run(MainFrm); } MainFrm.Show(); } }
private void AddModInfo(string Element, LauncherProfile Profil, bool Enabled = true) { MethodInvoker asdf = delegate { ToolStripItem it; if (Element == "separator") { it = new ToolStripSeparator(); ModAnalyzeInfo.DropDownItems.Add(it); } else { it = ModAnalyzeInfo.DropDownItems.Add(DateTime.Now.ToString("HH:mm:ss.fff") + " [" + Profil.ProfileName + "] " + Element); AddConsoleLine(Element); } while (ModAnalyzeInfo.DropDownItems.Count > 30) ModAnalyzeInfo.DropDownItems.RemoveAt(0); it.Enabled = Enabled; }; if (this.InvokeRequired) this.Invoke(asdf); else asdf.Invoke(); }
public void InvalidateJarOfProfile(LauncherProfile Profil) { }
public bool StartMinecraft(WischisLauncherCore.LauncherProfile Profil) { ClearConsole(); SwitchToConsoleScreen(); #region Check running Processes foreach (Process proc in Process.GetProcesses()) { if (proc.ProcessName.Contains("java")) { ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + proc.Id); foreach (ManagementObject mo in mos.Get()) { object abc = mo["CommandLine"]; if (!(abc is string)) continue; string cmd = (string)abc; Regex mineEx = new Regex("-cp[ ]+[\"]?([a-zA-Z]:\\\\([^|/:*\\\\?<>]+\\\\)+).minecraft\\\\[^|/:*\\\\?<>]+.jar[\"]? net.minecraft.LauncherFrame"); Match MineMatch = mineEx.Match(cmd); //checke ob der aktuelle Start im gleichen Profil passiert. if (MineMatch.Groups.Count > 2) { string a = MineMatch.Groups[1].Value; string b = Path.GetDirectoryName(a); //TODO: schau dir das mal an /* if (b.ToLower() == CurrentAppPath.ToLower()) { AddLogLine("> Minecraft läuft bereits im Verzeichnis: " + b + ". Bitte beende die offene Instanz."); //proc. this.Show(); return false; }*/ } } } } #endregion #region Check Java Path if (Profil.Settings.JavaExecutable == "") { AddLogLine("$WMCL> JavaPfad nicht eingetragen!"); this.Show(); return false; } #endregion Application.DoEvents(); minecraft = new Process(); minecraft.StartInfo.FileName = Profil.Settings.JavaExecutable; //TODO: Pfad verbiegen minecraft.StartInfo.EnvironmentVariables["appdata"] = LauncherFolderStructure.GetSpecificProfilePath(Profil); if (!MinecraftLocations.ContainsKey(Profil.Settings.MinecraftBinJarHash)) { AddLogLine("$WMCL> FEHLER: Es ist keine gültige Minecraft-Version gewählt"); return false; } AddConsoleLine("Login: http://login.minecraft.net"); Application.DoEvents(); while (RebuildJarList.Count > 0 || ModCompatibilityChecker.IsBusy) Application.DoEvents(); if (!File.Exists(Profil.Settings.MinecraftBinJarCache)) { AddModInfo("Keine Jar im Cache gefunden -> neu bilden.", Profil); BuildJarInBackground(Profil, true); Thread.Sleep(200); } while (RebuildJarList.Count > 0 || ModCompatibilityChecker.IsBusy) Application.DoEvents(); if (!File.Exists(Profil.Settings.MinecraftBinJarCache)) { label22.Text = "minecraft.jar nicht gefunden."; label22.Visible = true; return false; #region Weg damit /*AddConsoleLine("Erstelle MinecraftBinJar"); while (ModCompatibilityChecker.IsBusy || RebuildJarList.Count > 0) Application.DoEvents(); CookieContainer cc = null; MinecraftBinJarLocation loc = MinecraftLocations[Profil.Settings.MinecraftBinJarHash]; AddConsoleLine("Lade Jar: " + loc.Name); if (loc.NeedAuth) { AddConsoleLine("Verbinde zu http://dev.wischenbart.org/minecraft"); AddLogLine("$WMCL> Verbinde zu http://dev.wischenbart.org/minecraft"); string Hinweis; cc = MinecraftAuth.WischiAuth(sid, Profil.Settings.MinecraftLoginUser,out Hinweis); AddLogLine("$WMCL> AuthResp.: " + Hinweis); AddLogLine("$WMCL> Rückmeldung: " + MinecraftAuth.CheckWischiAuth(cc)); } AddConsoleLine("> " + loc.DownloadLocation); Application.DoEvents(); MinecraftBinJar mjar = null; try { mjar = loc.GetMinecraftBinJar(cc); } catch (Exception ex) { AddLogLine("$WMCL> MinecraftJar konnte nicht geladen werden: " + ex.Message); return false; } if (Profil.Settings.MinecraftServerAutoConnect) { string WischiPatch = Assembly.GetExecutingAssembly().GetName().Name + ".Resources." + "WMLPatch.class"; Stream WischiPatchStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(WischiPatch); mjar.AddModFile(WischiPatchStream, "net/minecraft/client/WMLPatch.class"); } Application.DoEvents(); AddConsoleLine("Patche Mods in Binjar"); foreach (ListViewItem it in ModListe.Items) { if (!it.Checked) continue; AddConsoleLine("Mod: " + it.Text); string mod = LauncherFolderStructure.ModFolder + Path.DirectorySeparatorChar + it.Text; if (File.Exists(mod) && ZipFile.CheckZip(mod)) { ZipFile modfile = new ZipFile(mod); mjar.AddModPack(modfile,Profil); } else { AddLogLine("$WMCL> Der Mod konnte nicht geladen werden: '" + mod + "'"); } } Application.DoEvents(); string tempString = Guid.NewGuid().ToString().ToUpper(); Profil.Settings.MinecraftBinJarCache = LauncherFolderStructure.GetSpecificBinFolder(Profil) + Path.DirectorySeparatorChar + tempString; mjar.Save(Profil.Settings.MinecraftBinJarCache);*/ #endregion } else { AddConsoleLine("MinecraftBinJar Cache gefunden."); } string sid; string mcuser; if (!MinecraftAuth.ProfileAuth(Profil, out sid, out mcuser, textBox11.Text)) { label22.Text = "Can't connect to minecraft.net"; label22.Visible = true; AddLogLine("Error minecraft.net: " + sid); return false; } if (AllowOffline) { Random rnd = new Random(); sid = rnd.Next().ToString(); mcuser = FakePlayerName.Text.Replace(" ", ""); } AddConsoleLine("Lade Resourcen"); MinecraftRessourceDownloader.DownloadBins(LauncherFolderStructure.GetSpecificBinFolder(Profil), this); string arguments = ""; //RAM Einstellungen if (checkBox3.Checked) arguments += " -Xmx" + regler_max.Value + "M -Xms" + regler_init.Value + "M"; //Set Proxy if (checkBox4.Checked) { arguments += " -DsocksproxyHost=" + textBox1.Text + " -DsocksproxyPort=" + textBox2.Text; arguments += " -Dhttp.proxyHost=" + textBox1.Text + " -Dhttp.proxyPort=" + textBox2.Text; arguments += " -Dhttps.proxyHost=" + textBox1.Text + " -Dhttps.proxyPort=" + textBox2.Text; arguments += " -Dhttp.proxyUser="******" -Dhttp.proxyPassword="******" -Djava.library.path=\"" + LauncherFolderStructure.GetSpecificBinFolder(Profil) + Path.DirectorySeparatorChar + "natives\""; string Classes = ""; Classes += "\"" + Profil.Settings.MinecraftBinJarCache + "\";"; Classes += "\"" + LauncherFolderStructure.GetSpecificBinFolder(Profil) + Path.DirectorySeparatorChar + "lwjgl.jar\";"; Classes += "\"" + LauncherFolderStructure.GetSpecificBinFolder(Profil) + Path.DirectorySeparatorChar + "lwjgl_util.jar\";"; Classes += "\"" + LauncherFolderStructure.GetSpecificBinFolder(Profil) + Path.DirectorySeparatorChar + "jinput.jar\";"; if (Profil.Settings.MinecraftServerAutoConnect) arguments += " -cp " + Classes + " net.minecraft.client.WMLPatch"; else arguments += " -cp " + Classes + " net.minecraft.client.Minecraft"; arguments += " \"" + mcuser + "\" \"" + sid + "\""; if (Profil.Settings.MinecraftServerAutoConnect) arguments += " " + Profil.Settings.MinecraftServerAutoconnectHost; minecraft.StartInfo.Arguments = arguments; minecraft.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; AddLogLine("$WMCL> Java: " + minecraft.StartInfo.FileName); AddLogLine("$WMCL> Attrib: " + arguments); minecraft.StartInfo.CreateNoWindow = true; minecraft.StartInfo.RedirectStandardOutput = true; minecraft.StartInfo.RedirectStandardError = true; minecraft.StartInfo.UseShellExecute = false; minecraft.EnableRaisingEvents = true; minecraft.OutputDataReceived += new DataReceivedEventHandler(minecraft_OutputDataReceived); minecraft.ErrorDataReceived += new DataReceivedEventHandler(minecraft_ErrorDataReceived); AddLogLine("$WMCL> Starte Minecraft."); MCstart = DateTime.Now; LastWindowTime = DateTime.Now; AddConsoleLine("Starte Minecraft..."); RunningProfile = Profil; minecraft.Exited += new EventHandler(minecraft_Exited); minecraft.Start(); object Prio = Enum.Parse(typeof(ProcessPriorityClass), Profil.Settings.MinecraftPrio); if (Prio is ProcessPriorityClass && Profil.Settings.JavaMemoryUse) { minecraft.PriorityClass = (ProcessPriorityClass)Prio; } else { minecraft.PriorityClass = ProcessPriorityClass.Normal; Profil.Settings.MinecraftPrio = ProcessPriorityClass.Normal.ToString(); } button10.Enabled = false; SetSize = true; timer1.Enabled = true; minecraft.BeginErrorReadLine(); minecraft.BeginOutputReadLine(); return true; }
public bool GUISelectProfile(ToolStripItem Item) { if (Selected != null) { Selected.Image = null; } Selected = Item; Selected.Image = imageList3.Images["right"]; StatusProfilListe.Text = Selected.Text; CurrentProfile = LauncherProfile.Load(Selected.Text); LoadSettings(); return true; }
private void RebuildProfileList() { #region MinecraftProfileList - Old /*string oldtext = MinecraftProfileList.Text; MinecraftProfileList.BeginUpdate(); MinecraftProfileList.Items.Clear(); foreach (string prof in LauncherProfile.GetLauncherProfileList()) { MinecraftProfileList.Items.Add(prof); } MinecraftProfileList.EndUpdate(); MinecraftProfileList.Text = oldtext; if (MinecraftProfileList.Text == "" && MinecraftProfileList.Items.Count > 0) { MinecraftProfileList.SelectedIndex = 0; }*/ #endregion string oldtext = StatusProfilListe.Text; //StatusProfilListe.up StatusProfilListe.DropDownItems.Clear(); foreach (LauncherProfile prof in LauncherProfile.GetLauncherProfileList()) { GUINewProfile(prof.ProfileName); } if (!GUISelectProfile(oldtext) && StatusProfilListe.DropDownItems.Count > 0) { GUISelectProfile(StatusProfilListe.DropDownItems[0]); } List<LauncherProfile> Profile = LauncherProfile.GetLauncherProfileList(); if (Profile.Count > 0) { GUISelectProfile(StatusProfilListe.DropDownItems[0]); } else { string DefaultName = "Default"; CurrentProfile = LauncherProfile.Load(DefaultName); CurrentProfile.Save(); GUISelectProfile(GUINewProfile(DefaultName)); } }
private void ModCompatibilityChecker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { ProfileInCheck = null; if (RebuildJarList.Count > 0) { LauncherProfile RenderProfil = RebuildJarList[0]; ModCompatibilityChecker.RunWorkerAsync(RenderProfil); for (int i = RebuildJarList.Count - 1; i >= 0; i--) { if (RebuildJarList[i].ProfileName == RenderProfil.ProfileName) RebuildJarList.RemoveAt(i); } AddModInfo("Erstelle minecraft.jar für Profil aus Warteschlange. (noch verbleibend: " + RebuildJarList.Count + ")", RenderProfil); } RefreshModIcon(); }
private void ModCompatibilityChecker_DoWork(object sender, DoWorkEventArgs e) { if (!(e.Argument is LauncherProfile && sender is BackgroundWorker)) return; BackgroundWorker s = sender as BackgroundWorker; Dictionary<string, string> ModListControl = new Dictionary<string, string>(); LauncherProfile Profil = e.Argument as LauncherProfile; MethodInvoker asdf = delegate { ProfileInCheck = Profil; Profil.Setting_LauncherModAnalyzeStatus = 0; RefreshModIcon(); ModAnalyzeInfo.DropDown.Items.Clear(); }; if (this.InvokeRequired) this.Invoke(asdf); else asdf.Invoke(); Profil.Settings.MinecraftBinJarCache = ""; string sid; if (s.CancellationPending) return; CookieContainer cc = null; if (!MinecraftLocations.ContainsKey(Profil.Settings.MinecraftBinJarHash)) { Profil.Setting_LauncherModAnalyzeStatus = 0; AddModInfo("Wähle eine andere Minecraft-Version aus!", Profil); return; } string minecraftuser = ""; MinecraftBinJarLocation loc = MinecraftLocations[Profil.Settings.MinecraftBinJarHash]; AddModInfo("Lade Jar: " + loc.Name, Profil); if (loc.NeedAuth) { AddConsoleLine("Verifiziere Account..."); AddModInfo("Verifiziere Account...", Profil); if (!MinecraftAuth.ProfileAuth(Profil, out sid, out minecraftuser, textBox11.Text)) { Profil.Setting_LauncherModAnalyzeStatus = 0; AddModInfo("minecraft.net Fehler: " + sid, Profil); return; } AddModInfo("Verbinde zu http://dev.wischenbart.org/minecraft", Profil); string Hinweis; cc = MinecraftAuth.WischiAuth(sid, minecraftuser, out Hinweis); } if (s.CancellationPending) return; AddModInfo("> " + loc.DownloadLocation, Profil); Application.DoEvents(); MinecraftBinJar mjar = null; try { mjar = loc.GetMinecraftBinJar(cc); } catch (Exception ex) { AddLogLine("$WMCL> MinecraftJar konnte nicht geladen werden: " + ex.Message); AddModInfo("JarFehler: " + ex.Message, Profil); Profil.Setting_LauncherModAnalyzeStatus = 0; return; } if (loc.NeedAuth) { string location = LauncherFolderStructure.BinjarPath + Path.DirectorySeparatorChar + SanitizeFileName(loc.Name) + ".jar"; mjar.Save(location); } if (s.CancellationPending) return; if (Profil.Settings.MinecraftServerAutoConnect) { string WischiPatch = Assembly.GetExecutingAssembly().GetName().Name + ".Resources." + "WMLPatch.class"; Stream WischiPatchStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(WischiPatch); mjar.AddModFile(WischiPatchStream, "net/minecraft/client/WMLPatch.class"); ModListControl.Add("patch|net/minecraft/client/WMLPatch.class", "WischiPatch"); } Application.DoEvents(); AddModInfo("Patche Mods in Binjar", Profil); string[] mdlist = Profil.Settings.MinecraftModListe.Split('|'); foreach (string it in mdlist) { if (s.CancellationPending) return; if (it.Trim() == "") continue; AddModInfo("Mod: " + it, Profil); string mod = LauncherFolderStructure.ModFolder + Path.DirectorySeparatorChar + it; if (File.Exists(mod) && ZipFile.CheckZip(mod)) { ZipFile modfile = new ZipFile(mod); Dictionary<string, string> mods = mjar.AddModPack(modfile, Profil); MergeList(ModListControl, mods); modfile.Dispose(); } else { AddLogLine("$WMCL> Der Mod konnte nicht geladen werden: '" + mod + "'"); AddModInfo("ModFehler: " + mod, Profil); } } Application.DoEvents(); string tempString = Guid.NewGuid().ToString().ToUpper(); Profil.Settings.MinecraftBinJarCache = LauncherFolderStructure.GetSpecificBinFolder(Profil) + Path.DirectorySeparatorChar + tempString; mjar.Save(Profil.Settings.MinecraftBinJarCache); Dictionary<string, List<string>> Compatibilitylist = new Dictionary<string, List<string>>(); foreach (KeyValuePair<string, string> it in ModListControl) { string[] dd = it.Value.Split('|'); if (dd.Length > 1) { Compatibilitylist.Add(it.Key, new List<string>(dd)); } } MethodInvoker fff = delegate { foreach (KeyValuePair<string, List<string>> iii in Compatibilitylist) { ToolStripItem kkk = ModAnalyzeInfo.DropDownItems.Add(iii.Key); kkk.Enabled = false; ModAnalyzeInfo.DropDownItems.Add(new ToolStripSeparator()); foreach (string mod in iii.Value) { ToolStripItem uuu = ModAnalyzeInfo.DropDownItems.Add(mod); uuu.Enabled = false; } ModAnalyzeInfo.DropDownItems.Add(""); } if (Compatibilitylist.Count == 0) { AddModInfo("keine Inkompatibilitäten gefunden", Profil); Profil.Setting_LauncherModAnalyzeStatus = 1; } else { Profil.Setting_LauncherModAnalyzeStatus = -1; } }; if (this.InvokeRequired) this.Invoke(fff); else fff.Invoke(); }
void minecraft_Exited(object sender, EventArgs e) { RunningProfile = null; MethodInvoker RefreshText = delegate { timer1.Enabled = false; if (minecraft.ExitCode != 0) { MessageBox.Show("Es ist ein Fehler aufgetreten und Minecraft wurde beendet." + Environment.NewLine + " -Falsche Mod Version?" + Environment.NewLine + " -Ungünstige Ram-Einstellungen?" + Environment.NewLine + Environment.NewLine + "Details findest du im Log-Fenster." ); } button10.Enabled = true; SwitchToMainWindow(); }; if (this.InvokeRequired) this.Invoke(RefreshText); else RefreshText.Invoke(); AddLogLine("$WMCL> minecraft beendet. Code: " + minecraft.ExitCode); if (KillOnExit) { Application.Exit(); } else { MethodInvoker ShowMe = delegate { this.Show(); SetForegroundWindow(this.Handle); }; if (this.InvokeRequired) this.Invoke(ShowMe); else ShowMe.Invoke(); } }