Skip to content

Commit

Permalink
enhanced kernel's ui
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackINT3 committed Jun 24, 2019
1 parent b3387dd commit 71bf1cb
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 243 deletions.
4 changes: 0 additions & 4 deletions src/OpenArk/bundler/bundler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ void Bundler::dragEnterEvent(QDragEnterEvent *event)
event->acceptProposedAction();
}

void Bundler::dragMoveEvent(QDragMoveEvent *event)
{
}

void Bundler::dropEvent(QDropEvent *event)
{
if (!event->mimeData()->hasUrls())
Expand Down
1 change: 0 additions & 1 deletion src/OpenArk/bundler/bundler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Bundler : public QWidget {

private slots:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void onRefresh();
void onOpenFolder();
Expand Down
56 changes: 53 additions & 3 deletions src/OpenArk/kernel/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "../common/common.h"
#include "../openark/openark.h"

#define KernelTabDrivers 1
#define KernelTabDrivers 0

struct {
int s = 0;
Expand All @@ -34,7 +34,8 @@ bool DriversSortFilterProxyModel::lessThan(const QModelIndex &left, const QModel
{
auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right);
auto column = left.column();
if ((column == DRV.base || column == DRV.number)) return s1.toUInt() < s2.toUInt();
if ((column == DRV.base || column == DRV.number))
return UNONE::StrToHex64W(s1.toString().toStdWString()) < UNONE::StrToHex64W(s2.toString().toStdWString());
return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0;
}

Expand All @@ -44,6 +45,7 @@ Kernel::Kernel(QWidget* parent) :
ui.setupUi(this);
ui.tabWidget->setTabPosition(QTabWidget::West);
ui.tabWidget->tabBar()->setStyle(new OpenArkTabStyle);
setAcceptDrops(true);

drivers_model_ = new QStandardItemModel;
QTreeView *dview = ui.driverView;
Expand Down Expand Up @@ -82,6 +84,13 @@ Kernel::Kernel(QWidget* parent) :
WinShowProperties(path.toStdWString());
});

connect(ui.installBtn, &QPushButton::clicked, this, [&]() {
InstallDriver(ui.driverFileEdit->text());
});
connect(ui.browseBtn, &QPushButton::clicked, this, [&]() {
QString file = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Driver Files (*.sys);;All Files (*.*)"));
onOpenFile(file);
});
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int)));
connect(this, SIGNAL(signalOpen(QString)), parent_, SLOT(onOpen(QString)));
}
Expand All @@ -90,6 +99,7 @@ Kernel::~Kernel()
{
}


bool Kernel::eventFilter(QObject *obj, QEvent *e)
{
bool filtered = false;
Expand All @@ -109,13 +119,50 @@ bool Kernel::eventFilter(QObject *obj, QEvent *e)
return QWidget::eventFilter(obj, e);
}

void Kernel::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}

void Kernel::dropEvent(QDropEvent *event)
{
if (!event->mimeData()->hasUrls())
return;
QString& path = event->mimeData()->urls()[0].toLocalFile();
onOpenFile(path);
}

void Kernel::onOpenFile(QString path)
{
if (!UNONE::FsIsFileW(path.toStdWString()))
return;
ui.driverFileEdit->setText(path);
auto &&name = UNONE::FsPathToPureNameW(path.toStdWString());
ui.serviceEdit->setText(WStrToQ(name));
}

void Kernel::onTabChanged(int index)
{
if (index == KernelTabDrivers) {
ShowDrivers();
}
}

void Kernel::InstallDriver(QString driver)
{
if (driver.isEmpty()) return;
auto &&path = driver.toStdWString();
auto &&name = UNONE::FsPathToPureNameW(path);
if (UNONE::ObLoadDriverW(path, name)) {
ui.infoLabel->setText(tr("Install ok..."));
ui.infoLabel->setStyleSheet("color:green");
} else {
ui.infoLabel->setText(tr("Install failed, open console window to view detail..."));
ui.infoLabel->setStyleSheet("color:red");
}
}

void Kernel::ShowDrivers()
{
DISABLE_RECOVER();
Expand All @@ -132,10 +179,12 @@ void Kernel::ShowDrivers()
name.compare("apisetschema.dll", Qt::CaseInsensitive) == 0) {
continue;
}
bool existed = true;
auto info = CacheGetFileBaseInfo(path);
if (info.desc.isEmpty()) {
if (!UNONE::FsIsExistedW(info.desc.toStdWString())) {
if (!UNONE::FsIsExistedW(info.path.toStdWString())) {
info.desc = tr("[-] Driver file not existed!");
existed = false;
}
}
QStandardItem *name_item = new QStandardItem(name);
Expand All @@ -154,6 +203,7 @@ void Kernel::ShowDrivers()
drivers_model_->setItem(count, DRV.desc, desc_item);
drivers_model_->setItem(count, DRV.ver, ver_item);
drivers_model_->setItem(count, DRV.corp, corp_item);
if (!existed) SetLineBgColor(drivers_model_, count, Qt::red);
number++;
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/OpenArk/kernel/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ class Kernel : public QWidget {
Kernel(QWidget* parent);
~Kernel();

protected:
bool eventFilter(QObject *obj, QEvent *e);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);

signals:
void signalOpen(QString);

private slots:
void onTabChanged(int index);
void onOpenFile(QString path);

private:
bool eventFilter(QObject *obj, QEvent *e);
void InstallDriver(QString driver);
void ShowDrivers();
int DriversCurRow();
QString DriversCurViewItemData(int column);
Expand Down
Loading

0 comments on commit 71bf1cb

Please sign in to comment.