diff --git a/src/OpenArk/kernel/storage/storage.cpp b/src/OpenArk/kernel/storage/storage.cpp index bf4089e..fa013f0 100644 --- a/src/OpenArk/kernel/storage/storage.cpp +++ b/src/OpenArk/kernel/storage/storage.cpp @@ -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++) { @@ -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() diff --git a/src/OpenArkDrv/arkdrv-api/api-storage/api-storage.cpp b/src/OpenArkDrv/arkdrv-api/api-storage/api-storage.cpp index ebb69e5..a2340d2 100644 --- a/src/OpenArkDrv/arkdrv-api/api-storage/api-storage.cpp +++ b/src/OpenArkDrv/arkdrv-api/api-storage/api-storage.cpp @@ -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; } diff --git a/src/OpenArkDrv/kstorage/kstorage.cpp b/src/OpenArkDrv/kstorage/kstorage.cpp index e9115ea..63854ed 100644 --- a/src/OpenArkDrv/kstorage/kstorage.cpp +++ b/src/OpenArkDrv/kstorage/kstorage.cpp @@ -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; diff --git a/src/OpenArkDrv/kstorage/unlock/handle.cpp b/src/OpenArkDrv/kstorage/unlock/handle.cpp index 504a58a..ca3a248 100644 --- a/src/OpenArkDrv/kstorage/unlock/handle.cpp +++ b/src/OpenArkDrv/kstorage/unlock/handle.cpp @@ -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)