summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2019-12-16 16:58:38 +0100
committerDavid Lönnhager <david.l@mullvad.net>2019-12-16 17:19:46 +0100
commite12497775b0e01d53ae72fd2b32e16d11e277049 (patch)
treed7486a25e5cd98ee0469a1f1589ae046bd8b72e5
parent35410b88c9ef4ae7b7be2b3cc650ee5f26892a3e (diff)
downloadmullvadvpn-e12497775b0e01d53ae72fd2b32e16d11e277049.tar.xz
mullvadvpn-e12497775b0e01d53ae72fd2b32e16d11e277049.zip
Add more logging to driverlogic
-rw-r--r--windows/nsis-plugins/src/driverlogic/context.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/windows/nsis-plugins/src/driverlogic/context.cpp b/windows/nsis-plugins/src/driverlogic/context.cpp
index 2598377091..e65900582c 100644
--- a/windows/nsis-plugins/src/driverlogic/context.cpp
+++ b/windows/nsis-plugins/src/driverlogic/context.cpp
@@ -64,7 +64,7 @@ std::wstring GetNetCfgInstanceId(HDEVINFO devInfo, const SP_DEVINFO_DATA &devInf
if (hNet == INVALID_HANDLE_VALUE)
{
- throw std::runtime_error("SetupDiOpenDevRegKey Failed");
+ THROW_GLE("SetupDiOpenDevRegKey");
}
std::vector<wchar_t> instanceId(MAX_PATH + sizeof(L'\0'));
@@ -82,10 +82,7 @@ std::wstring GetNetCfgInstanceId(HDEVINFO devInfo, const SP_DEVINFO_DATA &devInf
RegCloseKey(hNet);
- if (ERROR_SUCCESS != status)
- {
- throw std::runtime_error("RegGetValue for NetCfgInstanceId failed");
- }
+ THROW_UNLESS(ERROR_SUCCESS, status, "RegGetValueW");
instanceId[strSize / sizeof(wchar_t)] = L'\0';
@@ -146,13 +143,9 @@ std::wstring GetDeviceStringProperty(
0
);
- const DWORD lastError = GetLastError();
- if (FALSE == sizeStatus && ERROR_INSUFFICIENT_BUFFER != lastError)
+ if (FALSE == sizeStatus)
{
- common::error::Throw(
- "Error obtaining device property length",
- lastError
- );
+ THROW_UNLESS(ERROR_INSUFFICIENT_BUFFER, GetLastError(), "SetupDiGetDevicePropertyW");
}
std::vector<wchar_t> buffer;
@@ -203,13 +196,10 @@ std::optional<std::wstring> GetDeviceRegistryStringProperty(
const DWORD lastError = GetLastError();
if (FALSE == sizeStatus && ERROR_INSUFFICIENT_BUFFER != lastError)
{
- if (ERROR_INVALID_DATA == lastError)
- {
- // ERROR_INVALID_DATA may mean that the property does not exist
- // TODO: Check if there may be other causes.
- return std::nullopt;
- }
- THROW_GLE("Error obtaining device property length");
+ // ERROR_INVALID_DATA may mean that the property does not exist
+ // TODO: Check if there may be other causes.
+ THROW_UNLESS(ERROR_INVALID_DATA, lastError, "SetupDiGetDeviceRegistryPropertyW");
+ return std::nullopt;
}
//