Skip to content

Commit

Permalink
feat: add warning popup for windows about xmrig outside of Gupaxx
Browse files Browse the repository at this point in the history
if an xmrig instance run on Windows OS outside of Gupaxx, the later can
freeze since xmrig has been started without "below priority". A popup
warning the user in the case a xmrig instance is detected whithout the
xmrig process started in Gupaxx is added in this commit.
  • Loading branch information
Cyrix126 committed Oct 2, 2024
1 parent eff8573 commit ed81c89
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/eframe_impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use super::App;
#[cfg(target_os = "windows")]
use crate::errors::{process_running, ErrorButtons, ErrorFerris};
#[cfg(target_os = "windows")]
use crate::helper::ProcessName;
use crate::helper::ProcessState;
use crate::macros::lock;
use crate::SECOND;
Expand Down Expand Up @@ -63,7 +67,16 @@ impl eframe::App for App {
self.size.y = ui.available_height();
});
self.resize(ctx);

// check for windows that a local instance of xmrig is not running outside of Gupaxx. Important because it could lead to crashes on this platform.
// Warn only once per restart of Gupaxx.
#[cfg(target_os = "windows")]
if !self.xmrig_outside_warning_acknowledge
&& process_running(ProcessName::Xmrig)
&& !xmrig_is_alive
{
self.error_state.set("An instance of xmrig is running outside of Gupaxx.\nThis is not supported and could lead to crashes on this platform.\nPlease stop your local instance and start xmrig from Gupaxx Xmrig tab.", ErrorFerris::Error, ErrorButtons::Okay);
self.xmrig_outside_warning_acknowledge = true;
}
// If there's an error, display [ErrorState] on the whole screen until user responds
debug!("App | Checking if there is an error in [ErrorState]");
if self.error_state.error {
Expand Down
22 changes: 22 additions & 0 deletions src/utils/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use std::sync::{Arc, Mutex};

#[cfg(target_os = "windows")]
use sysinfo::System;

#[cfg(target_os = "windows")]
use crate::helper::ProcessName;

use super::sudo::SudoState;

//---------------------------------------------------------------------------------------------------- [ErrorState] struct
Expand Down Expand Up @@ -91,3 +97,19 @@ impl ErrorState {
SudoState::reset(state)
}
}

#[cfg(target_os = "windows")]
pub fn process_running(process_name: ProcessName) -> bool {
let name = match process_name {
ProcessName::P2pool => "p2pool",
ProcessName::Xmrig => "xmrig",
ProcessName::XmrigProxy => "xmrig-proxy",
ProcessName::Node => "monerod",
ProcessName::Xvb => panic!("XvB does not exist as a process outside of Gupaxx"),
};
let s = System::new_all();
if s.processes_by_name(name.as_ref()).next().is_some() {
return true;
}
false
}

0 comments on commit ed81c89

Please sign in to comment.