abstract extension loading code

This commit is contained in:
Akash Mozumdar 2018-08-17 14:37:37 -04:00
parent 16cf2eb9b2
commit b290392034
2 changed files with 11 additions and 8 deletions

View File

@ -62,8 +62,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(hostSignaller, &HostSignaller::AddThread, this, &MainWindow::AddThread);
connect(hostSignaller, &HostSignaller::RemoveThread, this, &MainWindow::RemoveThread);
connect(this, &MainWindow::ThreadOutputReceived, this, &MainWindow::ThreadOutput);
std::map<int, QString> extensions = LoadExtensions();
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second);
ReloadExtensions();
Host::Open();
Host::AddConsoleOutput(L"NextHooker beta v2.1.2 by Artikash\r\nSource code and more information available under GPLv3 at https://github.com/Artikash/NextHooker");
}
@ -139,6 +138,13 @@ void MainWindow::ThreadOutput(TextThread* thread, QString output)
}
}
void MainWindow::ReloadExtensions()
{
extenCombo->clear();
std::map<int, QString> extensions = LoadExtensions();
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second);
}
std::unordered_map<std::string, int> MainWindow::GetInfoForExtensions(TextThread* thread)
{
return
@ -236,9 +242,7 @@ void MainWindow::on_addExtenButton_clicked()
extenName +
"_nexthooker_extension.dll";
QFile::copy(extenFileName, copyTo);
extenCombo->clear();
std::map<int, QString> extensions = LoadExtensions();
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second);
ReloadExtensions();
}
void MainWindow::on_rmvExtenButton_clicked()
@ -247,7 +251,5 @@ void MainWindow::on_rmvExtenButton_clicked()
QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(": ")[1] + "_nexthooker_extension.dll";
FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str()));
DeleteFileW(extenFileName.toStdWString().c_str());
extenCombo->clear();
std::map<int, QString> extensions = LoadExtensions();
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second);
ReloadExtensions();
}

View File

@ -41,6 +41,7 @@ private slots:
void on_rmvExtenButton_clicked();
private:
void ReloadExtensions();
std::unordered_map<std::string, int> GetInfoForExtensions(TextThread* thread);
QVector<HookParam> GetAllHooks(DWORD processId);