Skip to content

Commit

Permalink
Add unlock UI button function
Browse files Browse the repository at this point in the history
  • Loading branch information
pboy0922 committed Aug 25, 2020
1 parent a675daa commit 29c3570
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
29 changes: 28 additions & 1 deletion src/OpenArk/kernel/storage/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ void KernelStorage::InitFileUnlockView()
});

connect(ui_->unlockFileBtn, &QPushButton::clicked, [&]{
INFO(L"Click the unlockFileBtn button");
DISABLE_RECOVER();
auto selected = ui_->unlockView->selectionModel()->selectedIndexes();
if (selected.empty()) {
WARN(L"Not select the item of unlock file!");
return;
}
for (int i = 0; i < selected.size() / 6; i++) {
Expand All @@ -144,10 +146,35 @@ void KernelStorage::InitFileUnlockView()
QString qshandle = fhandle.replace(QRegExp("0x"), "");
handle_item.handle = HANDLE(UNONE::StrToHexA(qshandle.toStdString().c_str()));
ArkDrvApi::Storage::UnlockClose(handle_item);
INFO(L"Unlock file handle(pid: %i, handle: %p)", pid, handle_item.handle);
}
ui_->showHoldBtn->click();
INFO(L"Reflush the unlock file handle");
});


connect(ui_->unlockFileAllBtn, &QPushButton::clicked, [&] {
DISABLE_RECOVER();
for (int i = 0; i < unlock_model_->rowCount(); i++) {
QStandardItem *item = unlock_model_->item(i, 1); //pid
auto pid = item->text().toUInt();

item = unlock_model_->item(i, 5); //handle
auto handle = HANDLE(UNONE::StrToHexA(item->text().replace(QRegExp("0x"), "").toStdString().c_str()));
HANDLE_ITEM handle_item = { 0 };
handle_item.pid = HANDLE(pid);
handle_item.handle = handle;
ArkDrvApi::Storage::UnlockClose(handle_item);
INFO(L"Unlock file handle all(pid: %i, handle: %p)", pid, handle_item.handle);
}
ui_->showHoldBtn->click();
INFO(L"Reflush the unlock file handle");

});

connect(ui_->killProcessBtn, &QPushButton::clicked, [&] {
DISABLE_RECOVER();

});
}

void KernelStorage::InitFileFilterView()
Expand Down
1 change: 1 addition & 0 deletions src/OpenArkDrv/arkdrv-api/api-storage/api-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ bool UnlockClose(HANDLE_ITEM &item)
std::string outdata;
indata.assign((char *)&item, sizeof(HANDLE_ITEM));
bool ret = IoControlDriver(IOCTL_ARK_STORAGE, STORAGE_UNLOCK_CLOSE, indata, outdata);
if (!ret) return false;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/OpenArkDrv/kstorage/kstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ NTSTATUS StorageDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, IN PIRP irp)
irpstack = IoGetCurrentIrpStackLocation(irp);
inlen = irpstack->Parameters.DeviceIoControl.InputBufferLength - 4;
inbuf = (UCHAR*)irp->AssociatedIrp.SystemBuffer + 4;
KdBreakPoint();
//KdBreakPoint();
status = DuplicateInputBuffer(irp, inbuf);
if (!NT_SUCCESS(status)) return status;

Expand Down
4 changes: 3 additions & 1 deletion src/OpenArkDrv/kstorage/unlock/handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ BOOLEAN ForceCloseHandle(HANDLE pid, HANDLE handle)
objectinfo.Inherit = 0;
objectinfo.ProtectFromClose = 0;
status = ObSetHandleAttributes(handle, &objectinfo, mode);
status = ZwClose(handle);
if (NT_SUCCESS(status)) {
status = ZwClose(handle);
}
KeUnstackDetachProcess(&apcstate);
}
__except (EXCEPTION_EXECUTE_HANDLER)
Expand Down

0 comments on commit 29c3570

Please sign in to comment.