summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/registryKey.cpp6
-rw-r--r--src/win32/tunDevice.cpp26
-rw-r--r--src/win32/winService.cpp20
3 files changed, 26 insertions, 26 deletions
diff --git a/src/win32/registryKey.cpp b/src/win32/registryKey.cpp
index 4ce92b9..9f4b653 100644
--- a/src/win32/registryKey.cpp
+++ b/src/win32/registryKey.cpp
@@ -87,19 +87,19 @@ void RegistryKey::close()
std::string RegistryKey::operator[](std::string const& name) const
{
if(!opened_)
- throw LogErrno(ERROR_INVALID_HANDLE);
+ throw AnytunErrno(ERROR_INVALID_HANDLE);
char value[STRING_VALUE_LENGTH];
DWORD len = sizeof(value);
LONG err = RegQueryValueExA(key_, name.c_str(), NULL, NULL, (LPBYTE)value, &len);
if(err != ERROR_SUCCESS)
- throw LogErrno(err);
+ throw AnytunErrno(err);
if(value[len-1] != 0) {
if(len < sizeof(value))
value[len++] = 0;
else
- throw LogErrno(ERROR_INSUFFICIENT_BUFFER);
+ throw AnytunErrno(ERROR_INSUFFICIENT_BUFFER);
}
return std::string(value);
}
diff --git a/src/win32/tunDevice.cpp b/src/win32/tunDevice.cpp
index 9761997..f9b9092 100644
--- a/src/win32/tunDevice.cpp
+++ b/src/win32/tunDevice.cpp
@@ -38,7 +38,7 @@
#include "../tunDevice.h"
#include "../threadUtils.hpp"
#include "../log.h"
-#include "../anytunError.hpp"
+#include "../anytunError.h"
#include "registryKey.h"
#include "common.h"
@@ -60,7 +60,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
tapname << USERMODEDEVICEDIR << actual_node_ << TAPSUFFIX;
handle_ = CreateFileA(tapname.str().c_str(), GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0);
if(handle_ == INVALID_HANDLE_VALUE)
- AnytunError::throwErr() << "Unable to open device: " << actual_node_ << " (" << actual_name_ << "): " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Unable to open device: " << actual_node_ << " (" << actual_name_ << "): " << AnytunErrno(GetLastError());
}
DWORD err;
@@ -69,7 +69,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
err = performIoControl(TAP_IOCTL_GET_VERSION, info, sizeof(info), info, sizeof(info));
if(err != ERROR_SUCCESS) {
CloseHandle(handle_);
- AnytunError::throwErr() << "Unable to get device version: " << LogErrno(err);
+ AnytunError::throwErr() << "Unable to get device version: " << AnytunErrno(err);
}
cLog.msg(Log::PRIO_NOTICE) << "Windows TAP Driver Version " << info[0] << "." << info[1] << " " << (info[2] ? "(DEBUG)" : "");
if(!(info[0] > MIN_TAP_VER_MAJOR || (info[0] == MIN_TAP_VER_MAJOR && info[1] >= MIN_TAP_VER_MINOR))) {
@@ -85,7 +85,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
err = performIoControl(TAP_IOCTL_CONFIG_TUN, ep, sizeof(ep), ep, sizeof(ep));
if(err != ERROR_SUCCESS) {
CloseHandle(handle_);
- AnytunError::throwErr() << "Unable to set device tun mode: " << LogErrno(err);
+ AnytunError::throwErr() << "Unable to set device tun mode: " << AnytunErrno(err);
}
}
@@ -96,7 +96,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
err = performIoControl(TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status));
if(err != ERROR_SUCCESS) {
CloseHandle(handle_);
- AnytunError::throwErr() << "Unable to set device media status: " << LogErrno(err);
+ AnytunError::throwErr() << "Unable to set device media status: " << AnytunErrno(err);
}
roverlapped_.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -108,7 +108,7 @@ bool TunDevice::getAdapter(std::string const& dev_name)
RegistryKey akey;
DWORD err = akey.open(HKEY_LOCAL_MACHINE, ADAPTER_KEY, KEY_ENUMERATE_SUB_KEYS);
if(err != ERROR_SUCCESS)
- AnytunError::throwErr() << "Unable to open registry key (HKLM\\" << ADAPTER_KEY << "): " << LogErrno(err);
+ AnytunError::throwErr() << "Unable to open registry key (HKLM\\" << ADAPTER_KEY << "): " << AnytunErrno(err);
bool found = false;
for(int i=0; ; ++i) {
@@ -132,7 +132,7 @@ bool TunDevice::getAdapter(std::string const& dev_name)
continue;
actual_name_ = nkey["Name"];
- } catch(LogErrno& e) { continue; }
+ } catch(AnytunErrno& e) { continue; }
if(dev_name != "") {
if(dev_name == actual_name_) {
@@ -207,12 +207,12 @@ int TunDevice::read(u_int8_t* buf, u_int32_t len)
if(err == ERROR_IO_PENDING) {
WaitForSingleObject(roverlapped_.hEvent, INFINITE);
if(!GetOverlappedResult(handle_, &roverlapped_, &lenout, FALSE)) {
- cLog.msg(Log::PRIO_ERR) << "Error while trying to get overlapped result: " << LogErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERR) << "Error while trying to get overlapped result: " << AnytunErrno(GetLastError());
return -1;
}
}
else {
- cLog.msg(Log::PRIO_ERR) << "Error while reading from device: " << LogErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERR) << "Error while reading from device: " << AnytunErrno(GetLastError());
return -1;
}
}
@@ -231,12 +231,12 @@ int TunDevice::write(u_int8_t* buf, u_int32_t len)
if(err == ERROR_IO_PENDING) {
WaitForSingleObject(woverlapped_.hEvent, INFINITE);
if(!GetOverlappedResult(handle_, &woverlapped_, &lenout, FALSE)) {
- cLog.msg(Log::PRIO_ERR) << "Error while trying to get overlapped result: " << LogErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERR) << "Error while trying to get overlapped result: " << AnytunErrno(GetLastError());
return -1;
}
}
else {
- cLog.msg(Log::PRIO_ERR) << "Error while writing to device: " << LogErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERR) << "Error while writing to device: " << AnytunErrno(GetLastError());
return -1;
}
}
@@ -258,14 +258,14 @@ void TunDevice::do_ifconfig()
DWORD err = performIoControl(TAP_IOCTL_CONFIG_DHCP_MASQ, ep, sizeof(ep), ep, sizeof(ep));
if(err != ERROR_SUCCESS) {
CloseHandle(handle_);
- AnytunError::throwErr() << "Unable to set device dhcp masq mode: " << LogErrno(err);
+ AnytunError::throwErr() << "Unable to set device dhcp masq mode: " << AnytunErrno(err);
}
u_long mtu;
err = performIoControl(TAP_IOCTL_GET_MTU, &mtu, sizeof(mtu), &mtu, sizeof(mtu));
if(err != ERROR_SUCCESS) {
CloseHandle(handle_);
- AnytunError::throwErr() << "Unable to get device mtu: " << LogErrno(err);
+ AnytunError::throwErr() << "Unable to get device mtu: " << AnytunErrno(err);
}
conf_.mtu_ = static_cast<u_int16_t>(mtu);
}
diff --git a/src/win32/winService.cpp b/src/win32/winService.cpp
index 58ad3ca..fefa725 100644
--- a/src/win32/winService.cpp
+++ b/src/win32/winService.cpp
@@ -37,7 +37,7 @@
#include "winService.h"
#include "../log.h"
-#include "../anytunError.hpp"
+#include "../anytunError.h"
#include "../threadUtils.hpp"
WinService* WinService::inst = NULL;
@@ -67,17 +67,17 @@ void WinService::install()
char szPath[MAX_PATH];
if(!GetModuleFileNameA(NULL, szPath, MAX_PATH))
- AnytunError::throwErr() << "Error on GetModuleFileName: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on GetModuleFileName: " << AnytunErrno(GetLastError());
schSCManager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(NULL == schSCManager)
- AnytunError::throwErr() << "Error on OpenSCManager: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on OpenSCManager: " << AnytunErrno(GetLastError());
schService = CreateServiceA(schSCManager, SVC_NAME, SVC_NAME, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, szPath, NULL, NULL, NULL, NULL, NULL);
if(schService == NULL) {
CloseServiceHandle(schSCManager);
- AnytunError::throwErr() << "Error on CreateService: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on CreateService: " << AnytunErrno(GetLastError());
}
std::cout << "Service installed successfully" << std::endl;
@@ -93,18 +93,18 @@ void WinService::uninstall()
schSCManager = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(NULL == schSCManager)
- AnytunError::throwErr() << "Error on OpenSCManager: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on OpenSCManager: " << AnytunErrno(GetLastError());
schService = OpenServiceA(schSCManager, SVC_NAME, SERVICE_ALL_ACCESS);
if(schService == NULL) {
CloseServiceHandle(schSCManager);
- AnytunError::throwErr() << "Error on CreateService: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on CreateService: " << AnytunErrno(GetLastError());
}
if(!DeleteService(schService)) {
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
- AnytunError::throwErr() << "Error on DeleteService: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on DeleteService: " << AnytunErrno(GetLastError());
}
std::cout << "Service uninstalled successfully" << std::endl;
@@ -121,7 +121,7 @@ void WinService::start()
};
if(!StartServiceCtrlDispatcherA(DispatchTable))
- AnytunError::throwErr() << "Error on StartServiceCtrlDispatcher: " << LogErrno(GetLastError());
+ AnytunError::throwErr() << "Error on StartServiceCtrlDispatcher: " << AnytunErrno(GetLastError());
}
void WinService::waitForStop()
@@ -153,7 +153,7 @@ VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv)
gWinService.status_handle_ = RegisterServiceCtrlHandlerA(SVC_NAME, WinService::ctrlHandler);
if(!gWinService.status_handle_) {
- cLog.msg(Log::PRIO_ERR) << "Error on RegisterServiceCtrlHandler: " << LogErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERR) << "Error on RegisterServiceCtrlHandler: " << AnytunErrno(GetLastError());
return;
}
gWinService.status_.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
@@ -163,7 +163,7 @@ VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv)
gWinService.stop_event_ = CreateEvent(NULL, true, false, NULL);
if(!gWinService.stop_event_) {
- cLog.msg(Log::PRIO_ERR) << "WinService Error on CreateEvent: " << LogErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERR) << "WinService Error on CreateEvent: " << AnytunErrno(GetLastError());
gWinService.reportStatus(SERVICE_STOPPED, -1);
return;
}