summaryrefslogtreecommitdiffstats
path: root/xmrstak/misc
diff options
context:
space:
mode:
authorfireice-uk <fireice-uk@users.noreply.github.com>2017-12-25 16:36:44 +0000
committerfireice-uk <fireice-uk@users.noreply.github.com>2017-12-25 16:36:44 +0000
commit038a4eb34d40abac8d0242f9ca881b0dac344723 (patch)
tree12ed16c47d2cac7b8af49259c17f4b17bc1caea9 /xmrstak/misc
parent52c305796127258f29d119843e86906541ea27b3 (diff)
downloadxmr-stak-038a4eb34d40abac8d0242f9ca881b0dac344723.zip
xmr-stak-038a4eb34d40abac8d0242f9ca881b0dac344723.tar.gz
On-demand elevation
Diffstat (limited to 'xmrstak/misc')
-rw-r--r--xmrstak/misc/uac.hpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/xmrstak/misc/uac.hpp b/xmrstak/misc/uac.hpp
index 55c5f1a..4fb5b0c 100644
--- a/xmrstak/misc/uac.hpp
+++ b/xmrstak/misc/uac.hpp
@@ -2,6 +2,7 @@
#ifdef _WIN32
#include "xmrstak/misc/console.hpp"
+#include "xmrstak/params.hpp"
#include <string>
#include <windows.h>
@@ -22,7 +23,7 @@ BOOL IsElevated()
return fRet;
}
-BOOL SelfElevate(const char* my_path, const std::string& params)
+BOOL SelfElevate(const std::string& my_path, const std::string& params)
{
if (IsElevated())
return FALSE;
@@ -32,7 +33,7 @@ BOOL SelfElevate(const char* my_path, const std::string& params)
shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = "runas";
- shExecInfo.lpFile = my_path;
+ shExecInfo.lpFile = my_path.c_str();
shExecInfo.lpParameters = params.c_str();
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_SHOW;
@@ -48,4 +49,19 @@ BOOL SelfElevate(const char* my_path, const std::string& params)
return TRUE;
}
+
+VOID RequestElevation()
+{
+ if(IsElevated())
+ return;
+
+ if(!xmrstak::params::inst().allowUAC)
+ {
+ printer::inst()->print_msg(L0, "The miner needs to run as administrator, but you passed --noUAC option. Please remove it or set use_slow_memory to always.");
+ win_exit();
+ return;
+ }
+
+ SelfElevate(xmrstak::params::inst().minerArg0, xmrstak::params::inst().minerArgs);
+}
#endif
OpenPOWER on IntegriCloud