From d01b56660a81548df3b9328996731a2957ac5e1d Mon Sep 17 00:00:00 2001 From: julian-poidevin Date: Wed, 5 Apr 2017 16:24:29 +0200 Subject: [PATCH] Started working on #7. Simplified how to fill array and definition of node parsing --- mainwindow.cpp | 64 ++++++++++++++++++++++++++++++++++++++++---------- mainwindow.h | 2 ++ 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c9db494..293d020 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -81,6 +81,27 @@ bool MainWindow::init() isInitOk = false; } + //Search for SIP Status + if(isSIPEnabled()) + { + ui->patchButton->setEnabled(false); + ui->restoreButton->setEnabled(false); + + QMessageBox msgBox; + + QAbstractButton* pButtonYes = msgBox.addButton(tr("Take me to tutorial"), QMessageBox::YesRole); + msgBox.addButton(tr("Nope"), QMessageBox::NoRole); + msgBox.show(); + + int answer = QMessageBox::information(this,"SIP Enabled","The System Integrity Protection is enabled\nPlease follow the instructions to disable it", QMessageBox::Yes | QMessageBox::No); + + if (answer == QMessageBox::YesRole) + { + QString link = "http://www.google.com"; + QDesktopServices::openUrl(QUrl(link)); + } + } + return isInitOk; } @@ -104,6 +125,34 @@ QString MainWindow::getMBPModelVersion() return MBPModelVersion; } +bool MainWindow::isSIPEnabled(void) +{ + QString SIPStatus; + QProcess process; + + //Execute commande line + process.start("csrutil status"); + + //Wait forever until finished + process.waitForFinished(-1); + + //Get command line output + SIPStatus = process.readAllStandardOutput(); + +//#ifndef WINDOWS + if(SIPStatus.contains("disable")) + { + return false; + } + else + { + return true; + } +//#else + // return false; +//#endif +} + //Parse system directory searching for AppleGraphicsPowerManagement.kext file bool MainWindow::searchKernelExtensionFile(QFile* kernelExtensionFile) @@ -277,29 +326,17 @@ void MainWindow::patchKernelExtensionFile(QFile *kernelFile) {"dict" , {} , NextSibling }, {"Vendor10deDevice0a29" , {} , FindChild }, {"BoostPState" , {} , FindSibling }, - {"array" , {} , NextSibling }, - {"integer" , {} , FirstChild }, {"" , {1,1,1,1} , FillArray }, {"BoostTime" , {} , FindSibling }, - {"array" , {} , NextSibling }, - {"integer" , {} , FirstChild }, {"" , {3,3,3,3} , FillArray }, {"Heuristic" , {} , FindSibling }, {"Threshold_High" , {} , FindSibling }, - {"array" , {} , NextSibling }, - {"integer" , {} , FirstChild }, {"" , {4,4,4,4} , FillArray }, {"Threshold_High_v" , {} , FindSibling }, - {"array" , {} , NextSibling }, - {"integer" , {} , FirstChild }, {"" , {5,5,5,5} , FillArray }, {"Threshold_Low" , {} , FindSibling }, - {"array" , {} , NextSibling }, - {"integer" , {} , FirstChild }, {"" , {6,6,6,6} , FillArray }, {"Threshold_Low_v" , {} , FindSibling }, - {"array" , {} , NextSibling }, - {"integer" , {} , FirstChild }, {"" , {7,7,7,7} , FillArray } }; @@ -331,6 +368,9 @@ void MainWindow::patchKernelExtensionFile(QFile *kernelFile) break; case FillArray: + + currentNode = currentNode.nextSiblingElement("array").firstChildElement("integer"); + currentNode.firstChild().setNodeValue(QString::number(confTree.at(i).ArrayValues[0])); currentNode.nextSibling().firstChild().setNodeValue(QString::number(confTree.at(i).ArrayValues[1])); currentNode.nextSibling().nextSibling().firstChild().setNodeValue(QString::number(confTree.at(i).ArrayValues[2])); diff --git a/mainwindow.h b/mainwindow.h index ea4b1d9..b3529d6 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -21,6 +21,7 @@ #include #include #include +#include using namespace std; // Indique quel espace de noms on va utiliser @@ -59,6 +60,7 @@ private slots: int restoreOldKernelExtension(QFile* kernelFile); QDomElement findElementChild(QDomElement parent, const QString &textToFind); QDomElement findElementSibling(QDomElement parent, const QString &textToFind); + bool isSIPEnabled(void); }; #endif // MAINWINDOW_H