summaryrefslogtreecommitdiffstats
path: root/xmrstak/cli/cli-miner.cpp
diff options
context:
space:
mode:
authorpsychocrypt <psychocryptHPC@gmail.com>2017-12-22 09:35:42 +0100
committerGitHub <noreply@github.com>2017-12-22 09:35:42 +0100
commitbbba9467ad77f160295e3e38a91727952c66aa7d (patch)
treee86a6eb475ce874ce3bcfda82193031774f93c3d /xmrstak/cli/cli-miner.cpp
parente99da8b68302a310644648e2864903a404fef9fe (diff)
parentc4391ac6f3239d81093449948d16b2233cacdb3f (diff)
downloadxmr-stak-bbba9467ad77f160295e3e38a91727952c66aa7d.zip
xmr-stak-bbba9467ad77f160295e3e38a91727952c66aa7d.tar.gz
Merge pull request #649 from fireice-uk/topic-fix-uac
Stop UAC popup for elevated ctx
Diffstat (limited to 'xmrstak/cli/cli-miner.cpp')
-rw-r--r--xmrstak/cli/cli-miner.cpp40
1 files changed, 3 insertions, 37 deletions
diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp
index 828f714..145e4e6 100644
--- a/xmrstak/cli/cli-miner.cpp
+++ b/xmrstak/cli/cli-miner.cpp
@@ -52,6 +52,7 @@
#ifdef _WIN32
# define strcasecmp _stricmp
# include <windows.h>
+# include "xmrstak/misc/uac.hpp"
#endif // _WIN32
void do_benchmark();
@@ -309,41 +310,6 @@ void do_guided_config()
std::cout<<"Configuration stored in file '"<<params::inst().configFile<<"'"<<std::endl;
}
-#ifdef _WIN32
-/** start the miner as administrator
- *
- * This function based on the stackoverflow post
- * - source: https://stackoverflow.com/a/4893508
- * - author: Cody Gray
- * - date: Feb 4 '11
- */
-void UACDialog(const std::string& binaryName, std::string& args)
-{
- args += " --noUAC";
- SHELLEXECUTEINFO shExInfo = {0};
- shExInfo.cbSize = sizeof(shExInfo);
- shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
- shExInfo.hwnd = 0;
- shExInfo.lpVerb = "runas";
- shExInfo.lpFile = binaryName.c_str();
- // disable UAC dialog (else the miner will go into a infinite loop)
- shExInfo.lpParameters = args.c_str();
- shExInfo.lpDirectory = 0;
- shExInfo.nShow = SW_SHOW;
- shExInfo.hInstApp = 0;
-
- if(ShellExecuteEx(&shExInfo))
- {
- printer::inst()->print_msg(L0,
- "This window has been opened because xmr-stak needed to run as administrator. It can be safely closed now.");
- WaitForSingleObject(shExInfo.hProcess, INFINITE);
- CloseHandle(shExInfo.hProcess);
- // do not start the miner twice
- std::exit(0);
- }
-}
-#endif
-
int main(int argc, char *argv[])
{
#ifndef CONF_NO_TLS
@@ -551,7 +517,7 @@ int main(int argc, char *argv[])
}
#ifdef _WIN32
- if(uacDialog)
+ if(uacDialog && !IsElevated())
{
std::string minerArgs;
for(int i = 1; i < argc; i++)
@@ -560,7 +526,7 @@ int main(int argc, char *argv[])
minerArgs += argv[i];
}
- UACDialog(argv[0], minerArgs);
+ SelfElevate(argv[0], minerArgs);
}
#endif
OpenPOWER on IntegriCloud