diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-02-21 15:27:00 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-02-25 11:32:09 +0100 |
| commit | 687a2f7bad4aafc55515def59b1ec07a43f1fa50 (patch) | |
| tree | f651795fede6c02b8734719754cb1729eaaf8bc8 | |
| parent | 5ff35bce21fbb535ab5a021611ecabc838fd0f1f (diff) | |
| download | mullvadvpn-687a2f7bad4aafc55515def59b1ec07a43f1fa50.tar.xz mullvadvpn-687a2f7bad4aafc55515def59b1ec07a43f1fa50.zip | |
Return specific error codes from driverlogic and display them in the message box
| -rw-r--r-- | dist-assets/windows/installer.nsh | 12 | ||||
| -rw-r--r-- | windows/driverlogic/src/driverlogic.cpp | 18 | ||||
| -rw-r--r-- | windows/driverlogic/src/error.cpp | 6 |
3 files changed, 23 insertions, 13 deletions
diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh index 83dd72a6d4..c7adccc49e 100644 --- a/dist-assets/windows/installer.nsh +++ b/dist-assets/windows/installer.nsh @@ -25,8 +25,8 @@ !define MULLVAD_SUCCESS 1 # Return codes from driverlogic -!define DL_GENERAL_ERROR 0 -!define DL_GENERAL_SUCCESS 1 +!define DL_GENERAL_ERROR -1 +!define DL_GENERAL_SUCCESS 0 # Log targets !define LOG_FILE 0 @@ -131,8 +131,9 @@ Pop $0 Pop $1 - ${If} $0 == ${DL_GENERAL_ERROR} - StrCpy $R0 "Failed to remove vanilla TAP adapter" + ${If} $0 != ${DL_GENERAL_SUCCESS} + IntFmt $0 "0x%X" $0 + StrCpy $R0 "Failed to remove vanilla TAP adapter: error $0" log::LogWithDetails $R0 $1 Goto RemoveVanillaTap_return @@ -194,7 +195,8 @@ Pop $1 ${If} $0 != ${DL_GENERAL_SUCCESS} - StrCpy $R0 "Failed to create virtual adapter" + IntFmt $0 "0x%X" $0 + StrCpy $R0 "Failed to create virtual adapter: error $0" log::LogWithDetails $R0 $1 Goto InstallTapDriver_return ${EndIf} diff --git a/windows/driverlogic/src/driverlogic.cpp b/windows/driverlogic/src/driverlogic.cpp index 3cb30ab91b..3e482c196f 100644 --- a/windows/driverlogic/src/driverlogic.cpp +++ b/windows/driverlogic/src/driverlogic.cpp @@ -30,8 +30,8 @@ constexpr wchar_t TAP_BASE_ALIAS[] = L"Mullvad"; enum ReturnCodes { - GENERAL_ERROR, - GENERAL_SUCCESS + GENERAL_SUCCESS = 0, + GENERAL_ERROR = -1 }; struct NetworkAdapter @@ -523,11 +523,12 @@ ATTEMPT_UPDATE: if (deviceInstallDisabled) { - THROW_ERROR( + throw common::error::WindowsException( "Device installs must be enabled to continue. " - "Enable them in the Local Group Policy editor, or" - " update the registry value DeviceInstallDisabled in" - " [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DeviceInstall\\Parameters]" + "Enable them in the Local Group Policy editor, or " + "update the registry value DeviceInstallDisabled in " + "[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DeviceInstall\\Parameters]", + lastError ); } } @@ -774,6 +775,11 @@ int wmain(int argc, const wchar_t * argv[], const wchar_t * []) goto INVALID_ARGUMENTS; } } + catch (const common::error::WindowsException &e) + { + LogError(common::string::ToWide(e.what())); + return e.errorCode(); + } catch (const std::exception &e) { LogError(common::string::ToWide(e.what())); diff --git a/windows/driverlogic/src/error.cpp b/windows/driverlogic/src/error.cpp index bdbc8e050d..49909784ca 100644 --- a/windows/driverlogic/src/error.cpp +++ b/windows/driverlogic/src/error.cpp @@ -154,8 +154,10 @@ void ThrowSetupApiError(const char *operation, uint32_t code, const char *file, { std::stringstream ss; ss << operation << ": " << message - << " (0x" << std::setw(8) << std::setfill('0') << std::hex << code << ")"; - common::error::Throw(ss.str().c_str(), file, line); + << " (0x" << std::setw(8) << std::setfill('0') << std::hex << code << ")" + << " (" << IsolateFilename(file) << ": " << line << ")"; + + throw common::error::WindowsException(ss.str().c_str(), code); } // Fallback: Treat as a regular Windows error |
