private int checkClose() { //check the exe every tick, if it is not running then murder the f*****g sys Process[] pname = Process.GetProcessesByName("GenshinImpact"); // get processes that match given name if (pname.Length == 0) // if we have no results { //u ded now bucko, game is closed and your usefulness is at an end //knife.png sc.Stop(); // stop the service sc.WaitForStatus(ServiceControllerStatus.Stopped); // ensure the damn thing is dead if (!silentMode) { IconMain.ShowBalloonTip(3000, "Service Stopped", "mhyprot2.sys has been stopped.", ToolTipIcon.Info); } // toast if (closeLauncher) // if the close flag is up { Process[] items = Process.GetProcessesByName("launcher"); // get processes that match given name foreach (Process proc in items) // launcher is kinda common so we're going to double check before murdering { if (proc.MainModule.FileName.Contains(installPath)) // if the exe exists in the installation path of the game { proc.Kill(); // safe to say we got the right man. Get spaced - 0 processes remain. } } } return(0); // return state for next check to switch } return(1); // return current state for switch }
private int checkRun() { sc = new ServiceController("mhyprot2"); // get handle for system service try // we use try in case the sys is not running atm { sc.WaitForStatus(ServiceControllerStatus.Running); // wait until it's running (in case state is STARTING) if (!silentMode) { IconMain.ShowBalloonTip(3000, "Genshin Impact Launched", "I'll just chill until it closes...", ToolTipIcon.Info); } // toast return(1); // return state for next check to switch } catch (System.InvalidOperationException) // sole error case { Console.WriteLine("Sys not running"); // no need to inform the user tbh } return(0); // return current state for switch }