Skip to content

Commit

Permalink
add ADMIN-FIX.reg
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Jun 5, 2023
1 parent 3bfe944 commit 282542b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions dist/FIX-ADMIN.reg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000001
1 change: 1 addition & 0 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ copy2folder() {
mkdir -p "$2/cslol-tools"

cp "./dist/"*.bat "$2/cslol-tools"
cp "./dist/FIX-ADMIN.reg" "$2"
cp "./dist/FIX-NON-ENGLISH.reg" "$2"
cp "./dist/SOURCE.URL" "$2"
cp "./LICENSE" "$2"
Expand Down
11 changes: 10 additions & 1 deletion src/CSLOLToolsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <QVersionNumber>
#include <fstream>

#include "CSLOLUtils.h"
#include "CSLOLVersion.h"
#ifdef _WIN32
#define MOD_TOOLS_EXE "/cslol-tools/mod-tools.exe"
Expand Down Expand Up @@ -227,7 +228,7 @@ void CSLOLToolsImpl::doReportError(QString name, QString message, QString trace)
logFile_->write(trace.toUtf8() + "\n");
}
if (message.contains("OpenProcess: ") || trace.contains("OpenProcess: ")) {
QFile file(prog_ + "/allow_admin.txt");
QFile file(prog_ + "/admin_allow.txt");
file.open(QIODevice::WriteOnly);
file.close();
trace += '\n';
Expand Down Expand Up @@ -280,6 +281,14 @@ void CSLOLToolsImpl::init() {
if (state_ == CSLOLState::StateUnitialized) {
setState(CSLOLState::StateBusy);

if (CSLOLUtils utils{}; utils.isUnnecessaryAdmin()) {
doReportError("Unnecessary admin",
"Try running without admin at least once.\nIf this issue still persist import FIX-ADMIN.reg",
"Running as admin is disabled by default");
setState(CSLOLState::StateCriticalError);
return;
}

patcherProcess_ = nullptr;
setStatus("Acquire lock");
lockfile_ = new QLockFile(prog_ + "/lockfile");
Expand Down
4 changes: 2 additions & 2 deletions src/CSLOLUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ QString CSLOLUtils::detectGamePath() {
}

bool CSLOLUtils::isUnnecessaryAdmin() {
if (QFileInfo info(QCoreApplication::applicationDirPath() + "/allow_admin.txt"); info.exists()) {
if (QFileInfo info(QCoreApplication::applicationDirPath() + "/admin_allow.txt"); info.exists()) {
return false;
}
bool result = 0;
Expand Down Expand Up @@ -206,4 +206,4 @@ bool CSLOLUtils::isUnnecessaryAdmin() { return false; }
QString CSLOLUtils::detectGamePath() { return ""; }

bool CSLOLUtils::isUnnecessaryAdmin() { return false; }
#endif
#endif
6 changes: 1 addition & 5 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,7 @@ ApplicationWindow {
}
}
firstTick = true;
if (CSLOLUtils.isUnnecessaryAdmin()) {
window.showUserError("Unnecessary admin", "Running as admin is disabled by default.\nTry running without admin at least once.")
} else {
cslolTools.init()
}
cslolTools.init()
cslolDialogUpdate.checkForUpdates()
}
}

0 comments on commit 282542b

Please sign in to comment.