예제 #1
0
 private uint CreateNewProcess(bool attached, Scheduler wanted, uint newPID)
 {
     if (!attached)
     {
         try
         {
             try
             {
                 if (Directory.Exists(wanted.BotPath) &&
                     File.Exists(wanted.BotPath + "\\GW2MinionLauncherDLL.dll"))
                     SetDllDirectory(wanted.BotPath);
                 Logger.LoggingObject.Log(Level.Verbose, "Launching instance for {0} with {1}.",
                                          LoginName, wanted.BotPath + "\\GW2MinionLauncherDLL.dll");
                 newPID = LaunchAccount(Config.Singleton.GeneralSettings.GW2Path, LoginName, Password, NoSound);
             }
             catch (AccessViolationException ex)
             {
                 Logger.LoggingObject.Log(Level.Critical, ex.Message);
             }
             wanted.SetLastStartTime(DateTime.Now);
             wanted.SetShouldBeRunning(true);
         }
         catch (DllNotFoundException ex)
         {
             Logger.LoggingObject.Log(Level.Error, ex.Message);
         }
         catch (BadImageFormatException ex)
         {
             Logger.LoggingObject.Log(Level.Error, ex.Message);
         }
     }
     return newPID;
 }
예제 #2
0
 private void StopSessionOfExpiredSchedule(Scheduler schedule)
 {
     Logger.LoggingObject.Log(Level.Info,
                              "Stopping {0}, bot has been running for {1:0.##} minutes.",
                              schedule.Account.LoginName,
                              (DateTime.Now - schedule.StartTime).TotalMinutes);
     Logger.LoggingObject.Log(Level.Info, "Start time: {0}, End time: {0}.",
                              schedule.StartTime.ToShortTimeString(),
                              DateTime.Now);
     schedule.SetShouldBeRunning(false);
     schedule.Account.Kill();
     LauncherCustomControls[schedule.Account.Index].BtnKill.Invoke(
         (MethodInvoker)
         (() =>
          LauncherCustomControls[schedule.Account.Index].BtnKill.Enabled = false));
     LauncherCustomControls[schedule.Account.Index].BtnStart.Invoke(
         (MethodInvoker)
         (() =>
          LauncherCustomControls[schedule.Account.Index].BtnStart.Enabled = false));
 }
예제 #3
0
        private bool CheckIfProcessAlreadyExists(Process[] gw2, Scheduler wanted, bool attached, ref uint newPID)
        {
            foreach (Process p in gw2)
            {
                if (GetAccountName((uint) p.Id) == LoginName)
                {
                    Logger.LoggingObject.Log(Level.Verbose, "Found wanted process for {0}, no need to launch.",
                                             LoginName);
                    try
                    {
                        Logger.LoggingObject.Log(Level.Verbose, "Attaching to {0} with {1}.",
                                                 LoginName, wanted.BotPath + "\\GW2MinionLauncherDLL.dll");
                        if (Directory.Exists(wanted.BotPath) &&
                            File.Exists(wanted.BotPath + "\\GW2MinionLauncherDLL.dll"))
                            SetDllDirectory(wanted.BotPath);
                        attached = Attach((uint) p.Id);
                    }
                    catch (AccessViolationException ex)
                    {
                        Logger.LoggingObject.Log(Level.Critical, ex.Message);
                    }
                    newPID = (uint) p.Id;

                    wanted.SetLastStartTime(DateTime.Now);
                    wanted.SetShouldBeRunning(true);
                }
            }
            return attached;
        }