diff --git a/src/common/common.h b/src/common/common.h index 22acbdb8..f76b9231 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -91,4 +91,7 @@ DEFINE_GUID(FORT_GUID_FILTER_REAUTH_OUT, #define NT_SUCCESS(status) ((LONG) (status) >= 0) #endif +#define FORT_STATUS_USER_ERROR STATUS_INVALID_PARAMETER +#define FORT_ERROR_USER_ERROR ERROR_INVALID_PARAMETER + #endif COMMON_H diff --git a/src/driver/fortcnf.c b/src/driver/fortcnf.c index 47c1ac17..733e44d0 100644 --- a/src/driver/fortcnf.c +++ b/src/driver/fortcnf.c @@ -227,7 +227,7 @@ fort_conf_ref_exe_add_path_locked (PFORT_CONF_REF conf_ref, return TRUE; } else { if (flags.is_new) - return STATUS_INVALID_PARAMETER; + return FORT_STATUS_USER_ERROR; // Replace flags { diff --git a/src/driver/fortdrv.c b/src/driver/fortdrv.c index 23ce6978..295d613c 100644 --- a/src/driver/fortdrv.c +++ b/src/driver/fortdrv.c @@ -991,7 +991,7 @@ fort_device_control (PDEVICE_OBJECT device, PIRP irp) PIO_STACK_LOCATION irp_stack; ULONG_PTR info = 0; ULONG control_code; - NTSTATUS status = STATUS_INVALID_PARAMETER; + NTSTATUS status = STATUS_UNSUCCESSFUL; irp_stack = IoGetCurrentIrpStackLocation(irp); control_code = irp_stack->Parameters.DeviceIoControl.IoControlCode; @@ -1102,7 +1102,7 @@ fort_device_control (PDEVICE_OBJECT device, PIRP irp) default: break; } - if (!NT_SUCCESS(status)) { + if (!NT_SUCCESS(status) && status != FORT_STATUS_USER_ERROR) { DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "FORT: Device Control: Error: %x\n", status); } diff --git a/src/driver/fortpkt.c b/src/driver/fortpkt.c index d8bfb685..fc6fabd6 100644 --- a/src/driver/fortpkt.c +++ b/src/driver/fortpkt.c @@ -486,7 +486,7 @@ fort_defer_stream_add (PFORT_DEFER defer, if (dataOffset->streamDataOffset != 0 && (dataOffset->netBuffer != netBuf || dataOffset->mdl != NET_BUFFER_CURRENT_MDL(netBuf))) - return STATUS_INVALID_PARAMETER; + return STATUS_FWP_CANNOT_PEND; } KeAcquireInStackQueuedSpinLock(&defer->lock, &lock_queue); diff --git a/src/ui/driver/drivermanager.cpp b/src/ui/driver/drivermanager.cpp index 269ff2fa..53c7912a 100644 --- a/src/ui/driver/drivermanager.cpp +++ b/src/ui/driver/drivermanager.cpp @@ -23,24 +23,22 @@ DriverManager::~DriverManager() abortWorker(); } -void DriverManager::setErrorMessage(const QString &errorMessage) +QString DriverManager::errorMessage() const { - if (m_errorMessage != errorMessage) { - m_errorMessage = errorMessage; - emit errorMessageChanged(); - } + return (m_errorCode == 0) ? QString() + : OsUtil::errorMessage(m_errorCode); } void DriverManager::updateError(bool success) { m_errorCode = success ? 0 : OsUtil::lastErrorCode(); - setErrorMessage(success ? QString() - : OsUtil::lastErrorMessage(m_errorCode)); + emit errorMessageChanged(); } bool DriverManager::isDeviceError() const { - return m_errorCode == OsUtil::userErrorCode(); + return m_errorCode != 0 + && m_errorCode != FortCommon::userErrorCode(); } void DriverManager::setupWorker() diff --git a/src/ui/driver/drivermanager.h b/src/ui/driver/drivermanager.h index bda337a6..7239e4e0 100644 --- a/src/ui/driver/drivermanager.h +++ b/src/ui/driver/drivermanager.h @@ -22,7 +22,7 @@ public: DriverWorker *driverWorker() const { return m_driverWorker; } - QString errorMessage() const { return m_errorMessage; } + QString errorMessage() const; bool isDeviceError() const; bool isDeviceOpened() const; @@ -59,8 +59,6 @@ private: Device *m_device = nullptr; DriverWorker *m_driverWorker = nullptr; - - QString m_errorMessage; }; #endif // DRIVERMANAGER_H diff --git a/src/ui/driver/driverworker.cpp b/src/ui/driver/driverworker.cpp index a2c2a346..dd779bfb 100644 --- a/src/ui/driver/driverworker.cpp +++ b/src/ui/driver/driverworker.cpp @@ -109,7 +109,7 @@ void DriverWorker::readLog() if (success) { m_logBuffer->reset(nr); } else if (!m_cancelled) { - errorMessage = OsUtil::lastErrorMessage(); + errorMessage = OsUtil::errorMessage(); } emitReadLogResult(success, errorMessage); diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index c89a4ea2..694fe19b 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -310,13 +310,12 @@ void OptionsPage::setupDriverIcon() : ":/images/plugin_disabled.png"; m_iconDriver->setPixmap(QPixmap(iconPath)); - - retranslateDriverMessage(); }; refreshDriverIcon(); connect(driverManager(), &DriverManager::isDeviceOpenedChanged, this, refreshDriverIcon); + connect(driverManager(), &DriverManager::errorMessageChanged, this, &OptionsPage::retranslateDriverMessage); } void OptionsPage::setupNewVersionBox() diff --git a/src/ui/fortcommon.cpp b/src/ui/fortcommon.cpp index ea7fc28d..df9b42da 100644 --- a/src/ui/fortcommon.cpp +++ b/src/ui/fortcommon.cpp @@ -53,6 +53,11 @@ quint32 FortCommon::ioctlDelApp() return FORT_IOCTL_DELAPP; } +quint32 FortCommon::userErrorCode() +{ + return FORT_ERROR_USER_ERROR; +} + int FortCommon::bufferSize() { return FORT_BUFFER_SIZE; diff --git a/src/ui/fortcommon.h b/src/ui/fortcommon.h index 97ecc132..e67b9eef 100644 --- a/src/ui/fortcommon.h +++ b/src/ui/fortcommon.h @@ -20,6 +20,8 @@ public: static quint32 ioctlAddApp(); static quint32 ioctlDelApp(); + static quint32 userErrorCode(); + static int bufferSize(); static quint32 confIoConfOff(); diff --git a/src/ui/util/osutil.cpp b/src/ui/util/osutil.cpp index 1f65c7bd..e8e37dc7 100644 --- a/src/ui/util/osutil.cpp +++ b/src/ui/util/osutil.cpp @@ -28,17 +28,12 @@ bool OsUtil::createGlobalMutex(const char *name) && GetLastError() != ERROR_ALREADY_EXISTS; } -quint32 OsUtil::userErrorCode() -{ - return STATUS_INVALID_PARAMETER; -} - quint32 OsUtil::lastErrorCode() { return GetLastError(); } -QString OsUtil::lastErrorMessage(quint32 errorCode) +QString OsUtil::errorMessage(quint32 errorCode) { LPWSTR buf = nullptr; diff --git a/src/ui/util/osutil.h b/src/ui/util/osutil.h index 2065375f..9d67f54b 100644 --- a/src/ui/util/osutil.h +++ b/src/ui/util/osutil.h @@ -14,9 +14,8 @@ public: static bool createGlobalMutex(const char *name); - static quint32 userErrorCode(); static quint32 lastErrorCode(); - static QString lastErrorMessage(quint32 errorCode = lastErrorCode()); + static QString errorMessage(quint32 errorCode = lastErrorCode()); static qint32 getTickCount(); };