Skip to content

Commit

Permalink
Started working on #7.
Browse files Browse the repository at this point in the history
Simplified how to fill array and definition of node parsing
  • Loading branch information
julian-poidevin committed Apr 5, 2017
1 parent d31b6a8 commit d01b566
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 12 deletions.
64 changes: 52 additions & 12 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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)
Expand Down Expand Up @@ -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 }
};

Expand Down Expand Up @@ -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]));
Expand Down
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QSettings>
#include <QList>
#include <QtXml>
#include <QDesktopServices>

using namespace std; // Indique quel espace de noms on va utiliser

Expand Down Expand Up @@ -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

0 comments on commit d01b566

Please sign in to comment.