Skip to content

Commit

Permalink
Add kernel storage filter ui
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackINT3 committed Aug 5, 2020
1 parent 6c36b31 commit 35db2f3
Show file tree
Hide file tree
Showing 8 changed files with 465 additions and 424 deletions.
4 changes: 2 additions & 2 deletions src/OpenArk/common/utils/disassembly/disassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ std::string DisasmMemory(ULONG64 pc, char *mem, ULONG memsize, int bits /*= 64*/
/* disassembly loop */
while (ud_disassemble(&ud_obj)) {
if (o_do_off)
disasm += UNONE::StrFormatA("%016llx ", ud_insn_off(&ud_obj));
disasm += UNONE::StrFormatA("%016llX ", ud_insn_off(&ud_obj));
if (o_do_hex) {
const char* hex1, *hex2;
hex1 = ud_insn_hex(&ud_obj);
Expand Down Expand Up @@ -93,7 +93,7 @@ std::string HexDumpMemory(ULONG64 pc, char *mem, ULONG memsize)
auto padsize = (32 - (line.size() % 32));
data += " " + UNONE::StrInsertA(std::string(padsize, ' '), 2, " ");
}
formated += UNONE::StrFormatA("%016llx %s %s\n", pc, data.c_str(), hexchars(line).c_str());
formated += UNONE::StrFormatA("%016llX %s %s\n", pc, data.c_str(), hexchars(line).c_str());
pc += line.size() / 2;
}
return formated;
Expand Down
1 change: 1 addition & 0 deletions src/OpenArk/kernel/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void KernelDriver::InitDriversView()

void KernelDriver::InitDriverKitView()
{
ui->groupWDF->setVisible(false);
connect(ui->browseBtn, &QPushButton::clicked, this, [&]() {
QString file = QFileDialog::getOpenFileName(kernel_, tr("Open File"), "", tr("Driver Files (*.sys);;All Files (*.*)"));
kernel_->onOpenFile(file);
Expand Down
72 changes: 52 additions & 20 deletions src/OpenArk/kernel/storage/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,45 +35,77 @@ void KernelStorage::onTabChanged(int index)
{
}

bool KernelStorage::EventFilter()
bool KernelStorage::eventFilter(QObject *obj, QEvent *e)
{
return true;
if (e->type() == QEvent::ContextMenu) {
QMenu *menu = nullptr;
if (obj == ui_->driverView->viewport()) menu = unlock_menu_;
QContextMenuEvent *ctxevt = dynamic_cast<QContextMenuEvent*>(e);
if (ctxevt && menu) {
menu->move(ctxevt->globalPos());
menu->show();
}
}
return QWidget::eventFilter(obj, e);
}

void KernelStorage::ModuleInit(Ui::Kernel *ui, Kernel *kernel)
{
unlockfile_model_ = new QStandardItemModel;
QTreeView *view = ui->wfpView;
proxy_unlockfile_ = new UnlockFileSortFilterProxyModel(view);
proxy_unlockfile_->setSourceModel(unlockfile_model_);
proxy_unlockfile_->setDynamicSortFilter(true);
proxy_unlockfile_->setFilterKeyColumn(1);
view->setModel(proxy_unlockfile_);
view->selectionModel()->setModel(proxy_unlockfile_);
this->ui_ = ui;

InitFileUnlockView();
InitFileFilterView();

connect(ui->tabStorage, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int)));
}

void KernelStorage::InitFileUnlockView()
{
unlock_model_ = new QStandardItemModel;
QTreeView *view = ui_->unlockView;
proxy_unlock_ = new UnlockFileSortFilterProxyModel(view);
proxy_unlock_->setSourceModel(unlock_model_);
proxy_unlock_->setDynamicSortFilter(true);
proxy_unlock_->setFilterKeyColumn(1);
view->setModel(proxy_unlock_);
view->selectionModel()->setModel(proxy_unlock_);
view->header()->setSortIndicator(-1, Qt::AscendingOrder);
view->setSortingEnabled(true);
view->viewport()->installEventFilter(kernel);
view->installEventFilter(kernel);
view->viewport()->installEventFilter(this);
view->installEventFilter(this);
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
std::pair<int, QString> colum_layout[] = {
{ 130, tr("ID") },
{ 100, tr("Key") },
{ 200, tr("Name") },
{ 130, tr("FileObject") },
{ 200, tr("FilePath") },
{ 100, tr("PID") },
{ 100, tr("ProcessName") },
{ 200, tr("ProcessPath") },
};
QStringList name_list;
for (auto p : colum_layout) {
name_list << p.second;
}
unlockfile_model_->setHorizontalHeaderLabels(name_list);
unlock_model_->setHorizontalHeaderLabels(name_list);
for (int i = 0; i < _countof(colum_layout); i++) {
view->setColumnWidth(i, colum_layout[i].first);
}
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
unlockfile_menu_ = new QMenu();
unlockfile_menu_->addAction(tr("Refresh"), kernel, [&] {});
unlock_menu_ = new QMenu();
unlock_menu_->addAction(tr("Refresh"), this, [&] {});
}

connect(ui->tabNetwork, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int)));
void KernelStorage::InitFileFilterView()
{
fsflt_model_ = new QStandardItemModel;
fsflt_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value"));
SetDefaultTreeViewStyle(ui_->fsfltView, fsflt_model_);
ui_->fsfltView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui_->fsfltView->viewport()->installEventFilter(this);
ui_->fsfltView->installEventFilter(this);
fsflt_menu_ = new QMenu();
fsflt_menu_->addAction(tr("ExpandAll"), this, SLOT(onExpandAll()));
}

void KernelStorage::ShowUnlockFiles()
{

}
16 changes: 10 additions & 6 deletions src/OpenArk/kernel/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,23 @@ class KernelStorage : public CommonTabObject {
KernelStorage();
~KernelStorage();
public:
bool EventFilter();
bool eventFilter(QObject *obj, QEvent *e);
void ModuleInit(Ui::Kernel *ui, Kernel *kernel);

private slots:
void onTabChanged(int index);

private:
void ShowUnlockFiles();

void InitFileUnlockView();
void InitFileFilterView();

private:
Ui::Kernel *ui;
QMenu *unlockfile_menu_;
QStandardItemModel *unlockfile_model_;
UnlockFileSortFilterProxyModel *proxy_unlockfile_;
Ui::Kernel *ui_;
QMenu *unlock_menu_;
QMenu *fsflt_menu_;
QStandardItemModel *fsflt_model_;
QStandardItemModel *unlock_model_;
UnlockFileSortFilterProxyModel *proxy_unlock_;
UnlockFileSortFilterProxyModel *proxy_fsflt_;
};
Loading

0 comments on commit 35db2f3

Please sign in to comment.