aboutsummaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-11-07 10:37:53 +0100
committerPierre Ossman <ossman@cendio.se>2024-11-07 10:37:53 +0100
commitf7507aea98b1a428d02fe5c41d25ee69dd5436bb (patch)
tree49f9349a1d7441874d1cb6d4428e2bcb0d63b422 /win
parent7508e9887de022e127d8fadb9f6a6bd8e9778864 (diff)
parent2b7857283b834391266e414adcff8c20f8fe3067 (diff)
downloadtigervnc-f7507aea98b1a428d02fe5c41d25ee69dd5436bb.tar.gz
tigervnc-f7507aea98b1a428d02fe5c41d25ee69dd5436bb.zip
Merge branch 'stdexcept' of github.com:CendioOssman/tigervnc
Diffstat (limited to 'win')
-rw-r--r--win/rfb_win32/CleanDesktop.cxx26
-rw-r--r--win/rfb_win32/Clipboard.cxx12
-rw-r--r--win/rfb_win32/CompatibleBitmap.h2
-rw-r--r--win/rfb_win32/CurrentUser.cxx8
-rw-r--r--win/rfb_win32/DIBSectionBuffer.cxx10
-rw-r--r--win/rfb_win32/DeviceContext.cxx16
-rw-r--r--win/rfb_win32/DeviceFrameBuffer.cxx24
-rw-r--r--win/rfb_win32/Dialog.cxx8
-rw-r--r--win/rfb_win32/EventManager.cxx5
-rw-r--r--win/rfb_win32/IconInfo.h2
-rw-r--r--win/rfb_win32/IntervalTimer.h2
-rw-r--r--win/rfb_win32/LaunchProcess.cxx6
-rw-r--r--win/rfb_win32/LocalMem.h2
-rw-r--r--win/rfb_win32/MonitorInfo.cxx6
-rw-r--r--win/rfb_win32/MsgWindow.cxx8
-rw-r--r--win/rfb_win32/RegConfig.cxx10
-rw-r--r--win/rfb_win32/Registry.cxx50
-rw-r--r--win/rfb_win32/SDisplay.cxx21
-rw-r--r--win/rfb_win32/SDisplayCoreWMHooks.cxx2
-rw-r--r--win/rfb_win32/SInput.cxx2
-rw-r--r--win/rfb_win32/Security.cxx30
-rw-r--r--win/rfb_win32/Service.cxx30
-rw-r--r--win/rfb_win32/SocketManager.cxx30
-rw-r--r--win/rfb_win32/TsSessions.cxx4
-rw-r--r--win/rfb_win32/WMCursor.cxx2
-rw-r--r--win/rfb_win32/WMPoller.cxx5
-rw-r--r--win/rfb_win32/Win32Util.cxx8
-rw-r--r--win/vncconfig/Connections.h6
-rw-r--r--win/vncconfig/Legacy.cxx20
-rw-r--r--win/vncconfig/vncconfig.cxx8
-rw-r--r--win/winvnc/ManagedListener.cxx4
-rw-r--r--win/winvnc/QueryConnectDialog.cxx4
-rw-r--r--win/winvnc/STrayIcon.cxx4
-rw-r--r--win/winvnc/VNCServerWin32.cxx10
-rw-r--r--win/winvnc/winvnc.cxx16
35 files changed, 205 insertions, 198 deletions
diff --git a/win/rfb_win32/CleanDesktop.cxx b/win/rfb_win32/CleanDesktop.cxx
index 6d933b22..02fdd374 100644
--- a/win/rfb_win32/CleanDesktop.cxx
+++ b/win/rfb_win32/CleanDesktop.cxx
@@ -45,7 +45,7 @@ struct ActiveDesktop {
HRESULT result = CoCreateInstance(CLSID_ActiveDesktop, nullptr, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (PVOID*)&handle);
if (result != S_OK)
- throw rdr::Win32Exception("failed to contact Active Desktop", HRESULT_CODE(result));
+ throw rdr::win32_error("failed to contact Active Desktop", HRESULT_CODE(result));
}
~ActiveDesktop() {
if (handle)
@@ -173,16 +173,16 @@ void CleanDesktop::disableWallpaper() {
ActiveDesktop ad;
if (ad.enable(false))
restoreActiveDesktop = true;
- } catch (rdr::Exception& e) {
- vlog.error("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.error("%s", e.what());
}
// -=- Switch of normal wallpaper and notify apps
SysParamsInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) "", SPIF_SENDCHANGE);
restoreWallpaper = true;
- } catch (rdr::Exception& e) {
- vlog.info("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.info("%s", e.what());
}
}
@@ -198,8 +198,8 @@ void CleanDesktop::enableWallpaper() {
ActiveDesktop ad;
ad.enable(true);
restoreActiveDesktop = false;
- } catch (rdr::Exception& e) {
- vlog.error("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.error("%s", e.what());
}
}
@@ -211,8 +211,8 @@ void CleanDesktop::enableWallpaper() {
restoreWallpaper = false;
}
- } catch (rdr::Exception& e) {
- vlog.info("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.info("%s", e.what());
}
}
@@ -243,8 +243,8 @@ void CleanDesktop::disableEffects() {
}
restoreEffects = true;
- } catch (rdr::Exception& e) {
- vlog.info("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.info("%s", e.what());
}
}
@@ -268,7 +268,7 @@ void CleanDesktop::enableEffects() {
restoreEffects = false;
}
- } catch (rdr::Exception& e) {
- vlog.info("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.info("%s", e.what());
}
}
diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx
index 242ebf34..8577df46 100644
--- a/win/rfb_win32/Clipboard.cxx
+++ b/win/rfb_win32/Clipboard.cxx
@@ -23,6 +23,8 @@
#include <config.h>
#endif
+#include <rdr/Exception.h>
+
#include <rfb_win32/Clipboard.h>
#include <rfb_win32/WMShatter.h>
#include <rfb/util.h>
@@ -127,7 +129,7 @@ Clipboard::setClipText(const char* text) {
// - Firstly, we must open the clipboard
if (!OpenClipboard(getHandle()))
- throw rdr::Win32Exception("unable to open Win32 clipboard", GetLastError());
+ throw rdr::win32_error("unable to open Win32 clipboard", GetLastError());
// - Convert the supplied clipboard text into UTF-16 format with CRLF
std::string filtered(convertCRLF(text));
@@ -142,16 +144,16 @@ Clipboard::setClipText(const char* text) {
// - Next, we must clear out any existing data
if (!EmptyClipboard())
- throw rdr::Win32Exception("unable to empty Win32 clipboard", GetLastError());
+ throw rdr::win32_error("unable to empty Win32 clipboard", GetLastError());
// - Set the new clipboard data
if (!SetClipboardData(CF_UNICODETEXT, clip_handle))
- throw rdr::Win32Exception("unable to set Win32 clipboard", GetLastError());
+ throw rdr::win32_error("unable to set Win32 clipboard", GetLastError());
clip_handle = nullptr;
vlog.debug("set clipboard");
- } catch (rdr::Exception& e) {
- vlog.debug("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.debug("%s", e.what());
}
// - Close the clipboard
diff --git a/win/rfb_win32/CompatibleBitmap.h b/win/rfb_win32/CompatibleBitmap.h
index 0ecc6a3d..c8fdf829 100644
--- a/win/rfb_win32/CompatibleBitmap.h
+++ b/win/rfb_win32/CompatibleBitmap.h
@@ -30,7 +30,7 @@ namespace rfb {
CompatibleBitmap(HDC hdc, int width, int height) {
hbmp = CreateCompatibleBitmap(hdc, width, height);
if (!hbmp)
- throw rdr::Win32Exception("CreateCompatibleBitmap() failed", GetLastError());
+ throw rdr::win32_error("CreateCompatibleBitmap() failed", GetLastError());
}
virtual ~CompatibleBitmap() {
if (hbmp) DeleteObject(hbmp);
diff --git a/win/rfb_win32/CurrentUser.cxx b/win/rfb_win32/CurrentUser.cxx
index fc0f689e..be363682 100644
--- a/win/rfb_win32/CurrentUser.cxx
+++ b/win/rfb_win32/CurrentUser.cxx
@@ -80,7 +80,7 @@ CurrentUserToken::CurrentUserToken() {
if (!OpenProcessToken(GetCurrentProcess(), GENERIC_ALL, &h)) {
DWORD err = GetLastError();
if (err != ERROR_CALL_NOT_IMPLEMENTED)
- throw rdr::Win32Exception("OpenProcessToken failed", err);
+ throw rdr::win32_error("OpenProcessToken failed", err);
h = INVALID_HANDLE_VALUE;
}
}
@@ -92,11 +92,11 @@ ImpersonateCurrentUser::ImpersonateCurrentUser() {
if (!isServiceProcess())
return;
if (!token.canImpersonate())
- throw rdr::Exception("Cannot impersonate unsafe or null token");
+ throw std::runtime_error("Cannot impersonate unsafe or null token");
if (!ImpersonateLoggedOnUser(token)) {
DWORD err = GetLastError();
if (err != ERROR_CALL_NOT_IMPLEMENTED)
- throw rdr::Win32Exception("Failed to impersonate user", GetLastError());
+ throw rdr::win32_error("Failed to impersonate user", GetLastError());
}
}
@@ -114,7 +114,7 @@ UserName::UserName() {
char buf[UNLEN+1];
DWORD len = UNLEN+1;
if (!GetUserName(buf, &len))
- throw rdr::Win32Exception("GetUserName failed", GetLastError());
+ throw rdr::win32_error("GetUserName failed", GetLastError());
assign(buf);
}
diff --git a/win/rfb_win32/DIBSectionBuffer.cxx b/win/rfb_win32/DIBSectionBuffer.cxx
index ca6f3c9a..440fe6b1 100644
--- a/win/rfb_win32/DIBSectionBuffer.cxx
+++ b/win/rfb_win32/DIBSectionBuffer.cxx
@@ -21,6 +21,8 @@
#include <config.h>
#endif
+#include <rdr/Exception.h>
+
#include <rfb_win32/DIBSectionBuffer.h>
#include <rfb_win32/DeviceContext.h>
#include <rfb_win32/BitmapInfo.h>
@@ -56,7 +58,7 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
uint8_t* new_data = nullptr;
if (!pf.trueColour)
- throw rfb::Exception("palette format not supported");
+ throw std::invalid_argument("palette format not supported");
format = pf;
@@ -85,7 +87,7 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
if (!new_bitmap) {
int err = GetLastError();
- throw rdr::Win32Exception("unable to create DIB section", err);
+ throw rdr::win32_error("unable to create DIB section", err);
}
vlog.debug("recreateBuffer()");
@@ -128,7 +130,7 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
// Determine the *actual* DIBSection format
DIBSECTION ds;
if (!GetObject(bitmap, sizeof(ds), &ds))
- throw rdr::Win32Exception("GetObject", GetLastError());
+ throw rdr::win32_error("GetObject", GetLastError());
// Correct the "stride" of the DIB
// *** This code DWORD aligns each row - is that right???
@@ -158,7 +160,7 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
bits = bits >> 1;
}
if (depth > bpp)
- throw Exception("Bad DIBSection format (depth exceeds bpp)");
+ throw std::runtime_error("Bad DIBSection format (depth exceeds bpp)");
format = PixelFormat(bpp, depth, false, true,
redMax, greenMax, blueMax,
diff --git a/win/rfb_win32/DeviceContext.cxx b/win/rfb_win32/DeviceContext.cxx
index fa0beaf9..1c64e1f5 100644
--- a/win/rfb_win32/DeviceContext.cxx
+++ b/win/rfb_win32/DeviceContext.cxx
@@ -51,10 +51,10 @@ PixelFormat DeviceContext::getPF(HDC dc) {
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biBitCount = 0;
if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
- throw rdr::Win32Exception("unable to determine device pixel format", GetLastError());
+ throw rdr::win32_error("unable to determine device pixel format", GetLastError());
}
if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
- throw rdr::Win32Exception("unable to determine pixel shifts/palette", GetLastError());
+ throw rdr::win32_error("unable to determine pixel shifts/palette", GetLastError());
}
// Set the initial format information
@@ -87,7 +87,7 @@ PixelFormat DeviceContext::getPF(HDC dc) {
break;
default:
vlog.error("bits per pixel %u not supported", bi.bmiHeader.biBitCount);
- throw rdr::Exception("unknown bits per pixel specified");
+ throw std::invalid_argument("unknown bits per pixel specified");
};
break;
case BI_BITFIELDS:
@@ -151,7 +151,7 @@ Rect DeviceContext::getClipBox(HDC dc) {
// Get the display dimensions
RECT cr;
if (!GetClipBox(dc, &cr))
- throw rdr::Win32Exception("GetClipBox", GetLastError());
+ throw rdr::win32_error("GetClipBox", GetLastError());
return Rect(cr.left, cr.top, cr.right, cr.bottom);
}
@@ -159,7 +159,7 @@ Rect DeviceContext::getClipBox(HDC dc) {
DeviceDC::DeviceDC(const char* deviceName) {
dc = ::CreateDC("DISPLAY", deviceName, nullptr, nullptr);
if (!dc)
- throw rdr::Win32Exception("failed to create DeviceDC", GetLastError());
+ throw rdr::win32_error("failed to create DeviceDC", GetLastError());
}
DeviceDC::~DeviceDC() {
@@ -171,7 +171,7 @@ DeviceDC::~DeviceDC() {
WindowDC::WindowDC(HWND wnd) : hwnd(wnd) {
dc = GetDC(wnd);
if (!dc)
- throw rdr::Win32Exception("GetDC failed", GetLastError());
+ throw rdr::win32_error("GetDC failed", GetLastError());
}
WindowDC::~WindowDC() {
@@ -183,7 +183,7 @@ WindowDC::~WindowDC() {
CompatibleDC::CompatibleDC(HDC existing) {
dc = CreateCompatibleDC(existing);
if (!dc)
- throw rdr::Win32Exception("CreateCompatibleDC failed", GetLastError());
+ throw rdr::win32_error("CreateCompatibleDC failed", GetLastError());
}
CompatibleDC::~CompatibleDC() {
@@ -195,7 +195,7 @@ CompatibleDC::~CompatibleDC() {
BitmapDC::BitmapDC(HDC hdc, HBITMAP hbitmap) : CompatibleDC(hdc){
oldBitmap = (HBITMAP)SelectObject(dc, hbitmap);
if (!oldBitmap)
- throw rdr::Win32Exception("SelectObject to CompatibleDC failed",
+ throw rdr::win32_error("SelectObject to CompatibleDC failed",
GetLastError());
}
diff --git a/win/rfb_win32/DeviceFrameBuffer.cxx b/win/rfb_win32/DeviceFrameBuffer.cxx
index ca2f57d4..1c3e9575 100644
--- a/win/rfb_win32/DeviceFrameBuffer.cxx
+++ b/win/rfb_win32/DeviceFrameBuffer.cxx
@@ -54,14 +54,14 @@ DeviceFrameBuffer::DeviceFrameBuffer(HDC deviceContext, const Rect& wRect)
int capabilities = GetDeviceCaps(device, RASTERCAPS);
if (!(capabilities & RC_BITBLT)) {
- throw Exception("device does not support BitBlt");
+ throw std::invalid_argument("device does not support BitBlt");
}
if (!(capabilities & RC_DI_BITMAP)) {
- throw Exception("device does not support GetDIBits");
+ throw std::invalid_argument("device does not support GetDIBits");
}
/*
if (GetDeviceCaps(device, PLANES) != 1) {
- throw Exception("device does not support planar displays");
+ throw std::invalid_argument("device does not support planar displays");
}
*/
@@ -102,7 +102,7 @@ DeviceFrameBuffer::grabRect(const Rect &rect) {
if (ignoreGrabErrors)
vlog.error("BitBlt failed:%ld", GetLastError());
else
- throw rdr::Win32Exception("BitBlt failed", GetLastError());
+ throw rdr::win32_error("BitBlt failed", GetLastError());
}
}
@@ -138,11 +138,11 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
BITMAP maskInfo;
if (!GetObject(iconInfo.hbmMask, sizeof(BITMAP), &maskInfo))
- throw rdr::Win32Exception("GetObject() failed", GetLastError());
+ throw rdr::win32_error("GetObject() failed", GetLastError());
if (maskInfo.bmPlanes != 1)
- throw rdr::Exception("unsupported multi-plane cursor");
+ throw std::invalid_argument("unsupported multi-plane cursor");
if (maskInfo.bmBitsPixel != 1)
- throw rdr::Exception("unsupported cursor mask format");
+ throw std::invalid_argument("unsupported cursor mask format");
width = maskInfo.bmWidth;
height = maskInfo.bmHeight;
@@ -174,7 +174,7 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
if (!GetDIBits(dc, iconInfo.hbmColor, 0, height,
buffer.data(), (LPBITMAPINFO)&bi, DIB_RGB_COLORS))
- throw rdr::Win32Exception("GetDIBits", GetLastError());
+ throw rdr::win32_error("GetDIBits", GetLastError());
// We may not get the RGBA order we want, so shuffle things around
int ridx, gidx, bidx, aidx;
@@ -188,7 +188,7 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
if ((bi.bV5RedMask != ((unsigned)0xff << ridx*8)) ||
(bi.bV5GreenMask != ((unsigned)0xff << gidx*8)) ||
(bi.bV5BlueMask != ((unsigned)0xff << bidx*8)))
- throw rdr::Exception("unsupported cursor colour format");
+ throw std::invalid_argument("unsupported cursor colour format");
uint8_t* rwbuffer = buffer.data();
for (int y = 0; y < height; y++) {
@@ -217,7 +217,7 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
if (!GetBitmapBits(iconInfo.hbmMask,
maskInfo.bmWidthBytes * maskInfo.bmHeight, mask.data()))
- throw rdr::Win32Exception("GetBitmapBits", GetLastError());
+ throw rdr::win32_error("GetBitmapBits", GetLastError());
bool doOutline = false;
uint8_t* rwbuffer = buffer.data();
@@ -308,7 +308,7 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
server->setCursor(width, height, hotspot, buffer.data());
- } catch (rdr::Exception& e) {
- vlog.error("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.error("%s", e.what());
}
}
diff --git a/win/rfb_win32/Dialog.cxx b/win/rfb_win32/Dialog.cxx
index 35ec065e..e8af0846 100644
--- a/win/rfb_win32/Dialog.cxx
+++ b/win/rfb_win32/Dialog.cxx
@@ -65,7 +65,7 @@ bool Dialog::showDialog(const char* resource, HWND owner)
INT_PTR result = DialogBoxParam(inst, resource, owner,
staticDialogProc, (LPARAM)this);
if (result<0)
- throw rdr::Win32Exception("DialogBoxParam failed", GetLastError());
+ throw rdr::win32_error("DialogBoxParam failed", GetLastError());
alreadyShowing = false;
return (result == 1);
}
@@ -78,7 +78,7 @@ int Dialog::getItemInt(int id) {
BOOL trans;
int result = GetDlgItemInt(handle, id, &trans, TRUE);
if (!trans)
- throw rdr::Exception("unable to read dialog Int");
+ throw std::runtime_error("unable to read dialog Int");
return result;
}
const char* Dialog::getItemString(int id) {
@@ -275,7 +275,7 @@ bool PropSheet::showPropSheet(HWND owner_, bool showApply, bool showCtxtHelp, bo
handle = (HWND)PropertySheet(&header);
if ((handle == nullptr) || (handle == (HWND)-1))
- throw rdr::Win32Exception("PropertySheet failed", GetLastError());
+ throw rdr::win32_error("PropertySheet failed", GetLastError());
centerWindow(handle, owner_);
plog.info("created %p", handle);
@@ -347,7 +347,7 @@ bool PropSheet::showPropSheet(HWND owner_, bool showApply, bool showCtxtHelp, bo
delete [] hpages; hpages = nullptr;
return true;
- } catch (rdr::Exception&) {
+ } catch (std::exception&) {
alreadyShowing = false;
std::list<PropSheetPage*>::iterator pspi;
diff --git a/win/rfb_win32/EventManager.cxx b/win/rfb_win32/EventManager.cxx
index f034d36d..995c4fe2 100644
--- a/win/rfb_win32/EventManager.cxx
+++ b/win/rfb_win32/EventManager.cxx
@@ -22,8 +22,9 @@
#include <windows.h>
+#include <stdexcept>
+
#include <rfb_win32/EventManager.h>
-#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
using namespace rfb;
@@ -59,7 +60,7 @@ void EventManager::removeEvent(HANDLE event) {
return;
}
}
- throw rdr::Exception("Event not registered");
+ throw std::runtime_error("Event not registered");
}
diff --git a/win/rfb_win32/IconInfo.h b/win/rfb_win32/IconInfo.h
index ca234514..991a5a13 100644
--- a/win/rfb_win32/IconInfo.h
+++ b/win/rfb_win32/IconInfo.h
@@ -28,7 +28,7 @@ namespace rfb {
struct IconInfo : public ICONINFO {
IconInfo(HICON icon) {
if (!GetIconInfo(icon, this))
- throw rdr::Win32Exception("GetIconInfo() failed", GetLastError());
+ throw rdr::win32_error("GetIconInfo() failed", GetLastError());
}
~IconInfo() {
if (hbmColor)
diff --git a/win/rfb_win32/IntervalTimer.h b/win/rfb_win32/IntervalTimer.h
index 5ced2c5e..b62040b3 100644
--- a/win/rfb_win32/IntervalTimer.h
+++ b/win/rfb_win32/IntervalTimer.h
@@ -41,7 +41,7 @@ namespace rfb {
if (!active || interval_ != interval) {
interval = interval_;
if (!SetTimer(hwnd, id, interval, nullptr))
- throw rdr::Win32Exception("SetTimer", GetLastError());
+ throw rdr::win32_error("SetTimer", GetLastError());
active = true;
}
}
diff --git a/win/rfb_win32/LaunchProcess.cxx b/win/rfb_win32/LaunchProcess.cxx
index beb7e6b7..38aa720f 100644
--- a/win/rfb_win32/LaunchProcess.cxx
+++ b/win/rfb_win32/LaunchProcess.cxx
@@ -53,7 +53,7 @@ void LaunchProcess::start(HANDLE userToken, bool createConsole) {
char buf[256];
HDESK desktop = GetThreadDesktop(GetCurrentThreadId());
if (!GetUserObjectInformation(desktop, UOI_NAME, buf, 256, &size))
- throw rdr::Win32Exception("unable to launch process", GetLastError());
+ throw rdr::win32_error("unable to launch process", GetLastError());
snprintf(desktopName, 256, "WinSta0\\%s", buf);
@@ -95,7 +95,7 @@ void LaunchProcess::start(HANDLE userToken, bool createConsole) {
flags, nullptr, nullptr,
&sinfo, &procInfo);
if (!success)
- throw rdr::Win32Exception("unable to launch process", GetLastError());
+ throw rdr::win32_error("unable to launch process", GetLastError());
// Wait for it to finish initialising
WaitForInputIdle(procInfo.hProcess, 15000);
@@ -119,7 +119,7 @@ bool LaunchProcess::await(DWORD timeoutMs) {
detach();
return true;
} else if (result == WAIT_FAILED) {
- throw rdr::Win32Exception("await() failed", GetLastError());
+ throw rdr::win32_error("await() failed", GetLastError());
}
return false;
}
diff --git a/win/rfb_win32/LocalMem.h b/win/rfb_win32/LocalMem.h
index e2dc80bd..5280dea3 100644
--- a/win/rfb_win32/LocalMem.h
+++ b/win/rfb_win32/LocalMem.h
@@ -28,7 +28,7 @@ namespace rfb {
// Allocate and/or manage LocalAlloc memory.
struct LocalMem {
LocalMem(int size) : ptr(LocalAlloc(LMEM_FIXED, size)) {
- if (!ptr) throw rdr::Win32Exception("LocalAlloc", GetLastError());
+ if (!ptr) throw rdr::win32_error("LocalAlloc", GetLastError());
}
LocalMem(void* p) : ptr(p) {}
~LocalMem() {LocalFree(ptr);}
diff --git a/win/rfb_win32/MonitorInfo.cxx b/win/rfb_win32/MonitorInfo.cxx
index 854b467a..84a8d501 100644
--- a/win/rfb_win32/MonitorInfo.cxx
+++ b/win/rfb_win32/MonitorInfo.cxx
@@ -44,7 +44,7 @@ static void fillMonitorInfo(HMONITOR monitor, MONITORINFOEXA* mi) {
memset(mi, 0, sizeof(MONITORINFOEXA));
mi->cbSize = sizeof(MONITORINFOEXA);
if (!GetMonitorInfo(monitor, mi))
- throw rdr::Win32Exception("failed to GetMonitorInfo", GetLastError());
+ throw rdr::win32_error("failed to GetMonitorInfo", GetLastError());
vlog.debug("monitor is %ld,%ld-%ld,%ld", mi->rcMonitor.left, mi->rcMonitor.top, mi->rcMonitor.right, mi->rcMonitor.bottom);
vlog.debug("work area is %ld,%ld-%ld,%ld", mi->rcWork.left, mi->rcWork.top, mi->rcWork.right, mi->rcWork.bottom);
vlog.debug("device is \"%s\"", mi->szDevice);
@@ -57,7 +57,7 @@ MonitorInfo::MonitorInfo(HWND window) {
HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST);
if (!monitor)
- throw rdr::Win32Exception("failed to get monitor", GetLastError());
+ throw rdr::win32_error("failed to get monitor", GetLastError());
fillMonitorInfo(monitor, this);
}
@@ -67,7 +67,7 @@ MonitorInfo::MonitorInfo(const RECT& r) {
HMONITOR monitor = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST);
if (!monitor)
- throw rdr::Win32Exception("failed to get monitor", GetLastError());
+ throw rdr::win32_error("failed to get monitor", GetLastError());
fillMonitorInfo(monitor, this);
}
diff --git a/win/rfb_win32/MsgWindow.cxx b/win/rfb_win32/MsgWindow.cxx
index e94b60a8..4908126e 100644
--- a/win/rfb_win32/MsgWindow.cxx
+++ b/win/rfb_win32/MsgWindow.cxx
@@ -61,8 +61,8 @@ LRESULT CALLBACK MsgWindowProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
try {
result = _this->processMessage(msg, wParam, lParam);
- } catch (rdr::Exception& e) {
- vlog.error("untrapped: %s", e.str());
+ } catch (std::exception& e) {
+ vlog.error("untrapped: %s", e.what());
}
return result;
@@ -82,7 +82,7 @@ MsgWindowClass::MsgWindowClass() : classAtom(0) {
wndClass.lpszClassName = "rfb::win32::MsgWindowClass";
classAtom = RegisterClass(&wndClass);
if (!classAtom) {
- throw rdr::Win32Exception("unable to register MsgWindow window class", GetLastError());
+ throw rdr::win32_error("unable to register MsgWindow window class", GetLastError());
}
}
@@ -104,7 +104,7 @@ MsgWindow::MsgWindow(const char* name_) : name(name_), handle(nullptr) {
name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10,
nullptr, nullptr, baseClass.instance, this);
if (!handle) {
- throw rdr::Win32Exception("unable to create WMNotifier window instance", GetLastError());
+ throw rdr::win32_error("unable to create WMNotifier window instance", GetLastError());
}
vlog.debug("created window \"%s\" (%p)", name.c_str(), handle);
}
diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx
index fc006b21..211570ca 100644
--- a/win/rfb_win32/RegConfig.cxx
+++ b/win/rfb_win32/RegConfig.cxx
@@ -53,8 +53,8 @@ bool RegConfig::setKey(const HKEY rootkey, const char* keyname) {
key.createKey(rootkey, keyname);
processEvent(event);
return true;
- } catch (rdr::Exception& e) {
- vlog.debug("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.debug("%s", e.what());
return false;
}
}
@@ -69,9 +69,9 @@ void RegConfig::loadRegistryConfig(RegKey& key) {
if (!Configuration::setParam(name, value.c_str()))
vlog.info("unable to process %s", name);
}
- } catch (rdr::Win32Exception& e) {
+ } catch (rdr::win32_error& e) {
if (e.err != ERROR_INVALID_HANDLE)
- vlog.error("%s", e.str());
+ vlog.error("%s", e.what());
}
}
@@ -115,5 +115,5 @@ void RegConfigThread::worker() {
thread_id = GetCurrentThreadId();
while ((result = eventMgr.getMessage(&msg, nullptr, 0, 0)) > 0) {}
if (result < 0)
- throw rdr::Win32Exception("RegConfigThread failed", GetLastError());
+ throw rdr::win32_error("RegConfigThread failed", GetLastError());
}
diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx
index bbe15f47..47756950 100644
--- a/win/rfb_win32/Registry.cxx
+++ b/win/rfb_win32/Registry.cxx
@@ -54,7 +54,7 @@ RegKey::RegKey() : key(nullptr), freeKey(false), valueName(nullptr), valueNameBu
RegKey::RegKey(const HKEY k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
LONG result = RegOpenKeyEx(k, nullptr, 0, KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegOpenKeyEx(HKEY)", result);
+ throw rdr::win32_error("RegOpenKeyEx(HKEY)", result);
vlog.debug("duplicated %p to %p", k, key);
freeKey = true;
}
@@ -62,7 +62,7 @@ RegKey::RegKey(const HKEY k) : key(nullptr), freeKey(false), valueName(nullptr),
RegKey::RegKey(const RegKey& k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
LONG result = RegOpenKeyEx(k.key, nullptr, 0, KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegOpenKeyEx(RegKey&)", result);
+ throw rdr::win32_error("RegOpenKeyEx(RegKey&)", result);
vlog.debug("duplicated %p to %p", k.key, key);
freeKey = true;
}
@@ -86,7 +86,7 @@ bool RegKey::createKey(const RegKey& root, const char* name) {
LONG result = RegCreateKey(root.key, name, &key);
if (result != ERROR_SUCCESS) {
vlog.error("RegCreateKey(%p, %s): %lx", root.key, name, result);
- throw rdr::Win32Exception("RegCreateKeyEx", result);
+ throw rdr::win32_error("RegCreateKeyEx", result);
}
vlog.debug("createKey(%p,%s) = %p", root.key, name, key);
freeKey = true;
@@ -97,7 +97,7 @@ void RegKey::openKey(const RegKey& root, const char* name, bool readOnly) {
close();
LONG result = RegOpenKeyEx(root.key, name, 0, readOnly ? KEY_READ : KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegOpenKeyEx (open)", result);
+ throw rdr::win32_error("RegOpenKeyEx (open)", result);
vlog.debug("openKey(%p,%s,%s) = %p", root.key, name,
readOnly ? "ro" : "rw", key);
freeKey = true;
@@ -109,7 +109,7 @@ void RegKey::setDACL(const PACL acl, bool inherit) {
DACL_SECURITY_INFORMATION |
(inherit ? UNPROTECTED_DACL_SECURITY_INFORMATION : PROTECTED_DACL_SECURITY_INFORMATION),
nullptr, nullptr, acl, nullptr)) != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegKey::setDACL failed", result);
+ throw rdr::win32_error("RegKey::setDACL failed", result);
}
void RegKey::close() {
@@ -123,19 +123,19 @@ void RegKey::close() {
void RegKey::deleteKey(const char* name) const {
LONG result = RegDeleteKey(key, name);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegDeleteKey", result);
+ throw rdr::win32_error("RegDeleteKey", result);
}
void RegKey::deleteValue(const char* name) const {
LONG result = RegDeleteValue(key, name);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegDeleteValue", result);
+ throw rdr::win32_error("RegDeleteValue", result);
}
void RegKey::awaitChange(bool watchSubTree, DWORD filter, HANDLE event) const {
LONG result = RegNotifyChangeKeyValue(key, watchSubTree, filter, event, event != nullptr);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegNotifyChangeKeyValue", result);
+ throw rdr::win32_error("RegNotifyChangeKeyValue", result);
}
@@ -144,22 +144,22 @@ RegKey::operator HKEY() const {return key;}
void RegKey::setExpandString(const char* valname, const char* value) const {
LONG result = RegSetValueEx(key, valname, 0, REG_EXPAND_SZ, (const BYTE*)value, (strlen(value)+1)*sizeof(char));
- if (result != ERROR_SUCCESS) throw rdr::Win32Exception("setExpandString", result);
+ if (result != ERROR_SUCCESS) throw rdr::win32_error("setExpandString", result);
}
void RegKey::setString(const char* valname, const char* value) const {
LONG result = RegSetValueEx(key, valname, 0, REG_SZ, (const BYTE*)value, (strlen(value)+1)*sizeof(char));
- if (result != ERROR_SUCCESS) throw rdr::Win32Exception("setString", result);
+ if (result != ERROR_SUCCESS) throw rdr::win32_error("setString", result);
}
void RegKey::setBinary(const char* valname, const void* value, size_t length) const {
LONG result = RegSetValueEx(key, valname, 0, REG_BINARY, (const BYTE*)value, length);
- if (result != ERROR_SUCCESS) throw rdr::Win32Exception("setBinary", result);
+ if (result != ERROR_SUCCESS) throw rdr::win32_error("setBinary", result);
}
void RegKey::setInt(const char* valname, int value) const {
LONG result = RegSetValueEx(key, valname, 0, REG_DWORD, (const BYTE*)&value, sizeof(value));
- if (result != ERROR_SUCCESS) throw rdr::Win32Exception("setInt", result);
+ if (result != ERROR_SUCCESS) throw rdr::win32_error("setInt", result);
}
void RegKey::setBool(const char* valname, bool value) const {
@@ -173,7 +173,7 @@ std::string RegKey::getString(const char* valname) const {
std::string RegKey::getString(const char* valname, const char* def) const {
try {
return getString(valname);
- } catch(rdr::Exception&) {
+ } catch(std::exception&) {
return def;
}
}
@@ -185,7 +185,7 @@ std::vector<uint8_t> RegKey::getBinary(const char* valname) const {
std::vector<uint8_t> RegKey::getBinary(const char* valname, const uint8_t* def, size_t deflen) const {
try {
return getBinary(valname);
- } catch(rdr::Exception&) {
+ } catch(std::exception&) {
std::vector<uint8_t> out(deflen);
memcpy(out.data(), def, deflen);
return out;
@@ -198,7 +198,7 @@ int RegKey::getInt(const char* valname) const {
int RegKey::getInt(const char* valname, int def) const {
try {
return getInt(valname);
- } catch(rdr::Exception&) {
+ } catch(std::exception&) {
return def;
}
}
@@ -214,11 +214,11 @@ std::string RegKey::getRepresentation(const char* valname) const {
DWORD type, length;
LONG result = RegQueryValueEx(key, valname, nullptr, &type, nullptr, &length);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("get registry value length", result);
+ throw rdr::win32_error("get registry value length", result);
std::vector<uint8_t> data(length);
result = RegQueryValueEx(key, valname, nullptr, &type, (BYTE*)data.data(), &length);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("get registry value", result);
+ throw rdr::win32_error("get registry value", result);
switch (type) {
case REG_BINARY:
@@ -243,18 +243,18 @@ std::string RegKey::getRepresentation(const char* valname) const {
std::string str((char*)data.data(), length);
DWORD required = ExpandEnvironmentStrings(str.c_str(), nullptr, 0);
if (required==0)
- throw rdr::Win32Exception("ExpandEnvironmentStrings", GetLastError());
+ throw rdr::win32_error("ExpandEnvironmentStrings", GetLastError());
std::vector<char> expanded(required);
length = ExpandEnvironmentStrings(str.c_str(), expanded.data(), required);
if (required<length)
- throw rdr::Exception("unable to expand environment strings");
+ throw std::runtime_error("unable to expand environment strings");
return expanded.data();
} else {
return "";
}
}
default:
- throw rdr::Exception("unsupported registry type");
+ throw std::logic_error("unsupported registry type");
}
}
@@ -262,7 +262,7 @@ bool RegKey::isValue(const char* valname) const {
try {
getRepresentation(valname);
return true;
- } catch(rdr::Exception&) {
+ } catch(std::exception&) {
return false;
}
}
@@ -271,7 +271,7 @@ const char* RegKey::getValueName(int i) {
DWORD maxValueNameLen;
LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegQueryInfoKey", result);
+ throw rdr::win32_error("RegQueryInfoKey", result);
if (valueNameBufLen < maxValueNameLen + 1) {
valueNameBufLen = maxValueNameLen + 1;
delete [] valueName;
@@ -281,7 +281,7 @@ const char* RegKey::getValueName(int i) {
result = RegEnumValue(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
if (result == ERROR_NO_MORE_ITEMS) return nullptr;
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegEnumValue", result);
+ throw rdr::win32_error("RegEnumValue", result);
return valueName;
}
@@ -289,7 +289,7 @@ const char* RegKey::getKeyName(int i) {
DWORD maxValueNameLen;
LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegQueryInfoKey", result);
+ throw rdr::win32_error("RegQueryInfoKey", result);
if (valueNameBufLen < maxValueNameLen + 1) {
valueNameBufLen = maxValueNameLen + 1;
delete [] valueName;
@@ -299,6 +299,6 @@ const char* RegKey::getKeyName(int i) {
result = RegEnumKeyEx(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
if (result == ERROR_NO_MORE_ITEMS) return nullptr;
if (result != ERROR_SUCCESS)
- throw rdr::Win32Exception("RegEnumKey", result);
+ throw rdr::win32_error("RegEnumKey", result);
return valueName;
}
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index 0ec5e231..94b02a6d 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -35,7 +35,6 @@
#include <rfb_win32/MonitorInfo.h>
#include <rfb_win32/SDisplayCorePolling.h>
#include <rfb_win32/SDisplayCoreWMHooks.h>
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/ledStates.h>
@@ -172,12 +171,12 @@ void SDisplay::startCore() {
// Currently, we just check whether we're in the console session, and
// fail if not
if (!inConsoleSession())
- throw rdr::Exception("Console is not session zero - oreconnect to restore Console sessin");
+ throw std::runtime_error("Console is not session zero - oreconnect to restore Console sessin");
// Switch to the current input desktop
if (rfb::win32::desktopChangeRequired()) {
if (!rfb::win32::changeDesktop())
- throw rdr::Exception("unable to switch into input desktop");
+ throw std::runtime_error("unable to switch into input desktop");
}
// Initialise the change tracker and clipper
@@ -197,12 +196,12 @@ void SDisplay::startCore() {
else
core = new SDisplayCorePolling(this, &updates);
core->setScreenRect(screenRect);
- } catch (rdr::Exception& e) {
+ } catch (std::exception& e) {
delete core; core = nullptr;
if (tryMethod == 0)
- throw rdr::Exception("unable to access desktop");
+ throw std::runtime_error("unable to access desktop");
tryMethod--;
- vlog.error("%s", e.str());
+ vlog.error("%s", e.what());
}
}
vlog.info("Started %s", core->methodName());
@@ -287,12 +286,12 @@ void SDisplay::restartCore() {
// Start a new Core if possible
startCore();
vlog.info("restarted");
- } catch (rdr::Exception& e) {
+ } catch (std::exception& e) {
// If startCore() fails then we MUST disconnect all clients,
// to cause the server to stop() the desktop.
// Otherwise, the SDesktop is in an inconsistent state
// and the server will crash.
- server->closeClients(e.str());
+ server->closeClients(e.what());
}
}
@@ -400,8 +399,8 @@ SDisplay::processEvent(HANDLE event) {
// - Flush any updates from the core
try {
core->flushUpdates();
- } catch (rdr::Exception& e) {
- vlog.error("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.error("%s", e.what());
restartCore();
return;
}
@@ -435,7 +434,7 @@ SDisplay::processEvent(HANDLE event) {
}
return;
}
- throw rdr::Exception("No such event");
+ throw std::runtime_error("No such event");
}
diff --git a/win/rfb_win32/SDisplayCoreWMHooks.cxx b/win/rfb_win32/SDisplayCoreWMHooks.cxx
index 8165be3d..4c307600 100644
--- a/win/rfb_win32/SDisplayCoreWMHooks.cxx
+++ b/win/rfb_win32/SDisplayCoreWMHooks.cxx
@@ -40,7 +40,7 @@ SDisplayCoreWMHooks::SDisplayCoreWMHooks(SDisplay* d, UpdateTracker* ut)
consolePollTimer(getHandle(), consolePollTimerId),
pollConsoles(false) {
if (!hooks.setEvent(display->getUpdateEvent()))
- throw rdr::Exception("hook subsystem failed to initialise");
+ throw std::runtime_error("hook subsystem failed to initialise");
poller.setUpdateTracker(updateTracker);
cursorTimer.start(20);
consolePollTimer.start(200);
diff --git a/win/rfb_win32/SInput.cxx b/win/rfb_win32/SInput.cxx
index 37144c29..f32ee1bd 100644
--- a/win/rfb_win32/SInput.cxx
+++ b/win/rfb_win32/SInput.cxx
@@ -126,7 +126,7 @@ win32::SPointer::pointerEvent(const Point& pos, uint8_t buttonmask)
evt.mi.mouseData = data;
evt.mi.time = 0;
if (SendInput(1, &evt, sizeof(evt)) != 1)
- throw rdr::Win32Exception("SendInput", GetLastError());
+ throw rdr::win32_error("SendInput", GetLastError());
}
}
diff --git a/win/rfb_win32/Security.cxx b/win/rfb_win32/Security.cxx
index 04f92402..9f970aeb 100644
--- a/win/rfb_win32/Security.cxx
+++ b/win/rfb_win32/Security.cxx
@@ -96,19 +96,19 @@ void AccessEntries::addEntry(const PSID sid,
PSID Sid::copySID(const PSID sid) {
if (!IsValidSid(sid))
- throw rdr::Exception("invalid SID in copyPSID");
+ throw std::invalid_argument("invalid SID in copyPSID");
PSID buf = (PSID)new uint8_t[GetLengthSid(sid)];
if (!CopySid(GetLengthSid(sid), buf, sid))
- throw rdr::Win32Exception("CopySid failed", GetLastError());
+ throw rdr::win32_error("CopySid failed", GetLastError());
return buf;
}
void Sid::setSID(const PSID sid) {
if (!IsValidSid(sid))
- throw rdr::Exception("invalid SID in copyPSID");
+ throw std::invalid_argument("invalid SID in copyPSID");
resize(GetLengthSid(sid));
if (!CopySid(GetLengthSid(sid), data(), sid))
- throw rdr::Win32Exception("CopySid failed", GetLastError());
+ throw rdr::win32_error("CopySid failed", GetLastError());
}
void Sid::getUserNameAndDomain(char** name, char** domain) {
@@ -117,12 +117,12 @@ void Sid::getUserNameAndDomain(char** name, char** domain) {
SID_NAME_USE use;
LookupAccountSid(nullptr, (PSID)*this, nullptr, &nameLen, nullptr, &domainLen, &use);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
- throw rdr::Win32Exception("Unable to determine SID name lengths", GetLastError());
+ throw rdr::win32_error("Unable to determine SID name lengths", GetLastError());
vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use);
*name = new char[nameLen];
*domain = new char[domainLen];
if (!LookupAccountSid(nullptr, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use))
- throw rdr::Win32Exception("Unable to lookup account SID", GetLastError());
+ throw rdr::win32_error("Unable to lookup account SID", GetLastError());
}
@@ -133,7 +133,7 @@ Sid::Administrators::Administrators() {
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &sid))
- throw rdr::Win32Exception("Sid::Administrators", GetLastError());
+ throw rdr::win32_error("Sid::Administrators", GetLastError());
setSID(sid);
FreeSid(sid);
}
@@ -144,7 +144,7 @@ Sid::SYSTEM::SYSTEM() {
if (!AllocateAndInitializeSid(&ntAuth, 1,
SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0, &sid))
- throw rdr::Win32Exception("Sid::SYSTEM", GetLastError());
+ throw rdr::win32_error("Sid::SYSTEM", GetLastError());
setSID(sid);
FreeSid(sid);
}
@@ -154,7 +154,7 @@ Sid::FromToken::FromToken(HANDLE h) {
GetTokenInformation(h, TokenUser, nullptr, 0, &required);
std::vector<uint8_t> tmp(required);
if (!GetTokenInformation(h, TokenUser, tmp.data(), tmp.size(), &required))
- throw rdr::Win32Exception("GetTokenInformation", GetLastError());
+ throw rdr::win32_error("GetTokenInformation", GetLastError());
TOKEN_USER* tokenUser = (TOKEN_USER*)tmp.data();
setSID(tokenUser->User.Sid);
}
@@ -164,7 +164,7 @@ PACL rfb::win32::CreateACL(const AccessEntries& ae, PACL existing_acl) {
PACL new_dacl;
DWORD result;
if ((result = SetEntriesInAcl(ae.entry_count, ae.entries, existing_acl, &new_dacl)) != ERROR_SUCCESS)
- throw rdr::Win32Exception("SetEntriesInAcl", result);
+ throw rdr::win32_error("SetEntriesInAcl", result);
return new_dacl;
}
@@ -172,18 +172,18 @@ PACL rfb::win32::CreateACL(const AccessEntries& ae, PACL existing_acl) {
PSECURITY_DESCRIPTOR rfb::win32::CreateSdWithDacl(const PACL dacl) {
SECURITY_DESCRIPTOR absSD;
if (!InitializeSecurityDescriptor(&absSD, SECURITY_DESCRIPTOR_REVISION))
- throw rdr::Win32Exception("InitializeSecurityDescriptor", GetLastError());
+ throw rdr::win32_error("InitializeSecurityDescriptor", GetLastError());
Sid::SYSTEM owner;
if (!SetSecurityDescriptorOwner(&absSD, owner, FALSE))
- throw rdr::Win32Exception("SetSecurityDescriptorOwner", GetLastError());
+ throw rdr::win32_error("SetSecurityDescriptorOwner", GetLastError());
Sid::Administrators group;
if (!SetSecurityDescriptorGroup(&absSD, group, FALSE))
- throw rdr::Win32Exception("SetSecurityDescriptorGroupp", GetLastError());
+ throw rdr::win32_error("SetSecurityDescriptorGroupp", GetLastError());
if (!SetSecurityDescriptorDacl(&absSD, TRUE, dacl, FALSE))
- throw rdr::Win32Exception("SetSecurityDescriptorDacl", GetLastError());
+ throw rdr::win32_error("SetSecurityDescriptorDacl", GetLastError());
DWORD sdSize = GetSecurityDescriptorLength(&absSD);
SecurityDescriptorPtr sd(sdSize);
if (!MakeSelfRelativeSD(&absSD, (PSECURITY_DESCRIPTOR)sd.ptr, &sdSize))
- throw rdr::Win32Exception("MakeSelfRelativeSD", GetLastError());
+ throw rdr::win32_error("MakeSelfRelativeSD", GetLastError());
return sd.takeSD();
}
diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx
index be3381da..907e3214 100644
--- a/win/rfb_win32/Service.cxx
+++ b/win/rfb_win32/Service.cxx
@@ -115,7 +115,7 @@ Service::start() {
vlog.error("unable to set shutdown parameters: %lu", GetLastError());
service = this;
if (!StartServiceCtrlDispatcher(entry))
- throw Win32Exception("unable to start service", GetLastError());
+ throw win32_error("unable to start service", GetLastError());
}
void
@@ -335,7 +335,7 @@ bool rfb::win32::registerService(const char* name,
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
+ throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
// - Add the service
ServiceHandle handle = CreateService(scm,
@@ -344,7 +344,7 @@ bool rfb::win32::registerService(const char* name,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr);
if (!handle)
- throw rdr::Win32Exception("unable to create service", GetLastError());
+ throw rdr::win32_error("unable to create service", GetLastError());
// - Set a description
SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc};
@@ -380,14 +380,14 @@ bool rfb::win32::unregisterService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
+ throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
// - Create the service
ServiceHandle handle = OpenService(scm, name, SC_MANAGER_ALL_ACCESS);
if (!handle)
- throw rdr::Win32Exception("unable to locate the service", GetLastError());
+ throw rdr::win32_error("unable to locate the service", GetLastError());
if (!DeleteService(handle))
- throw rdr::Win32Exception("unable to remove the service", GetLastError());
+ throw rdr::win32_error("unable to remove the service", GetLastError());
// - Register the event log source
RegKey hk;
@@ -407,16 +407,16 @@ bool rfb::win32::startService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
+ throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_START);
if (!handle)
- throw rdr::Win32Exception("unable to open the service", GetLastError());
+ throw rdr::win32_error("unable to open the service", GetLastError());
// - Start the service
if (!StartService(handle, 0, nullptr))
- throw rdr::Win32Exception("unable to start the service", GetLastError());
+ throw rdr::win32_error("unable to start the service", GetLastError());
Sleep(500);
@@ -427,17 +427,17 @@ bool rfb::win32::stopService(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
+ throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_STOP);
if (!handle)
- throw rdr::Win32Exception("unable to open the service", GetLastError());
+ throw rdr::win32_error("unable to open the service", GetLastError());
// - Start the service
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_STOP, &status))
- throw rdr::Win32Exception("unable to stop the service", GetLastError());
+ throw rdr::win32_error("unable to stop the service", GetLastError());
Sleep(500);
@@ -448,17 +448,17 @@ DWORD rfb::win32::getServiceState(const char* name) {
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
+ throw rdr::win32_error("unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_INTERROGATE);
if (!handle)
- throw rdr::Win32Exception("unable to open the service", GetLastError());
+ throw rdr::win32_error("unable to open the service", GetLastError());
// - Get the service status
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status))
- throw rdr::Win32Exception("unable to query the service", GetLastError());
+ throw rdr::win32_error("unable to query the service", GetLastError());
return status.dwCurrentState;
}
diff --git a/win/rfb_win32/SocketManager.cxx b/win/rfb_win32/SocketManager.cxx
index 2bc2f53e..b42c66cb 100644
--- a/win/rfb_win32/SocketManager.cxx
+++ b/win/rfb_win32/SocketManager.cxx
@@ -25,6 +25,8 @@
#include <winsock2.h>
#include <list>
+#include <rdr/Exception.h>
+
#include <network/Socket.h>
#include <rfb/LogWriter.h>
@@ -67,7 +69,7 @@ void SocketManager::addListener(network::SocketListener* sock_,
flags |= FD_ADDRESS_LIST_CHANGE;
try {
if (event && (WSAEventSelect(sock_->getFd(), event, flags) == SOCKET_ERROR))
- throw rdr::SocketException("Unable to select on listener", WSAGetLastError());
+ throw rdr::socket_error("Unable to select on listener", WSAGetLastError());
// requestAddressChangeEvents MUST happen after WSAEventSelect, so that the socket is non-blocking
if (acn)
@@ -75,12 +77,12 @@ void SocketManager::addListener(network::SocketListener* sock_,
// addEvent is the last thing we do, so that the event is NOT registered if previous steps fail
if (!event || !addEvent(event, this))
- throw rdr::Exception("Unable to add listener");
- } catch (rdr::Exception& e) {
+ throw std::runtime_error("Unable to add listener");
+ } catch (std::exception& e) {
if (event)
WSACloseEvent(event);
delete sock_;
- vlog.error("%s", e.str());
+ vlog.error("%s", e.what());
throw;
}
@@ -103,7 +105,7 @@ void SocketManager::remListener(network::SocketListener* sock) {
return;
}
}
- throw rdr::Exception("Listener not registered");
+ throw std::runtime_error("Listener not registered");
}
@@ -136,7 +138,7 @@ void SocketManager::remSocket(network::Socket* sock_) {
return;
}
}
- throw rdr::Exception("Socket not registered");
+ throw std::runtime_error("Socket not registered");
}
bool SocketManager::getDisable(VNCServer* srvr)
@@ -147,7 +149,7 @@ bool SocketManager::getDisable(VNCServer* srvr)
return i->second.disable;
}
}
- throw rdr::Exception("Listener not registered");
+ throw std::runtime_error("Listener not registered");
}
void SocketManager::setDisable(VNCServer* srvr, bool disable)
@@ -163,7 +165,7 @@ void SocketManager::setDisable(VNCServer* srvr, bool disable)
}
}
if (!found)
- throw rdr::Exception("Listener not registered");
+ throw std::runtime_error("Listener not registered");
}
int SocketManager::checkTimeouts() {
@@ -184,7 +186,7 @@ int SocketManager::checkTimeouts() {
if (j->second.sock->outStream().hasBufferedData())
eventMask |= FD_WRITE;
if (WSAEventSelect(j->second.sock->getFd(), j->first, eventMask) == SOCKET_ERROR)
- throw rdr::SocketException("unable to adjust WSAEventSelect:%u", WSAGetLastError());
+ throw rdr::socket_error("unable to adjust WSAEventSelect:%u", WSAGetLastError());
}
}
@@ -234,11 +236,11 @@ void SocketManager::processEvent(HANDLE event) {
// Fetch why this event notification triggered
if (WSAEnumNetworkEvents(ci.sock->getFd(), event, &network_events) == SOCKET_ERROR)
- throw rdr::SocketException("unable to get WSAEnumNetworkEvents:%u", WSAGetLastError());
+ throw rdr::socket_error("unable to get WSAEnumNetworkEvents:%u", WSAGetLastError());
// Cancel event notification for this socket
if (WSAEventSelect(ci.sock->getFd(), event, 0) == SOCKET_ERROR)
- throw rdr::SocketException("unable to disable WSAEventSelect:%u", WSAGetLastError());
+ throw rdr::socket_error("unable to disable WSAEventSelect:%u", WSAGetLastError());
// Reset the event object
WSAResetEvent(event);
@@ -266,9 +268,9 @@ void SocketManager::processEvent(HANDLE event) {
if (ci.sock->outStream().hasBufferedData())
eventMask |= FD_WRITE;
if (WSAEventSelect(ci.sock->getFd(), event, eventMask) == SOCKET_ERROR)
- throw rdr::SocketException("unable to re-enable WSAEventSelect:%u", WSAGetLastError());
- } catch (rdr::Exception& e) {
- vlog.error("%s", e.str());
+ throw rdr::socket_error("unable to re-enable WSAEventSelect:%u", WSAGetLastError());
+ } catch (std::exception& e) {
+ vlog.error("%s", e.what());
remSocket(ci.sock);
}
}
diff --git a/win/rfb_win32/TsSessions.cxx b/win/rfb_win32/TsSessions.cxx
index a8602ad2..faf83e89 100644
--- a/win/rfb_win32/TsSessions.cxx
+++ b/win/rfb_win32/TsSessions.cxx
@@ -35,7 +35,7 @@ namespace win32 {
if (processId == (DWORD)-1)
processId = GetCurrentProcessId();
if (!ProcessIdToSessionId(GetCurrentProcessId(), &id))
- throw rdr::Win32Exception("ProcessIdToSessionId", GetLastError());
+ throw rdr::win32_error("ProcessIdToSessionId", GetLastError());
}
ProcessSessionId mySessionId;
@@ -57,7 +57,7 @@ namespace win32 {
ConsoleSessionId console;
vlog.info("Console session is %lu", console.id);
if (!WTSConnectSession(sessionId, console.id, (PTSTR)"", 0))
- throw rdr::Win32Exception("Unable to connect session to Console", GetLastError());
+ throw rdr::win32_error("Unable to connect session to Console", GetLastError());
// Lock the newly connected session, for security
LockWorkStation();
diff --git a/win/rfb_win32/WMCursor.cxx b/win/rfb_win32/WMCursor.cxx
index 603c7bc3..65d7a9d7 100644
--- a/win/rfb_win32/WMCursor.cxx
+++ b/win/rfb_win32/WMCursor.cxx
@@ -45,7 +45,7 @@ WMCursor::getCursorInfo() {
CURSORINFO info;
info.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&info))
- throw rdr::Win32Exception("GetCursorInfo failed", GetLastError());
+ throw rdr::win32_error("GetCursorInfo failed", GetLastError());
result.cursor = info.hCursor;
result.position = Point(info.ptScreenPos.x, info.ptScreenPos.y);
result.visible = info.flags & CURSOR_SHOWING;
diff --git a/win/rfb_win32/WMPoller.cxx b/win/rfb_win32/WMPoller.cxx
index 2c5917e9..98e8dce3 100644
--- a/win/rfb_win32/WMPoller.cxx
+++ b/win/rfb_win32/WMPoller.cxx
@@ -22,8 +22,9 @@
#include <config.h>
#endif
+#include <rdr/Exception.h>
+
#include <rfb_win32/WMPoller.h>
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/Configuration.h>
@@ -57,7 +58,7 @@ bool
rfb::win32::WMPoller::checkPollWindow(HWND w) {
char buffer[128];
if (!GetClassName(w, buffer, 128))
- throw rdr::Win32Exception("unable to get window class:%u", GetLastError());
+ throw rdr::win32_error("unable to get window class:%u", GetLastError());
if ((strcmp(buffer, "tty") != 0) &&
(strcmp(buffer, "ConsoleWindowClass") != 0)) {
return false;
diff --git a/win/rfb_win32/Win32Util.cxx b/win/rfb_win32/Win32Util.cxx
index f7b5b6c7..b35bf629 100644
--- a/win/rfb_win32/Win32Util.cxx
+++ b/win/rfb_win32/Win32Util.cxx
@@ -46,19 +46,19 @@ FileVersionInfo::FileVersionInfo(const char* filename) {
{
Handle file(CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (file.h == INVALID_HANDLE_VALUE)
- throw rdr::Win32Exception("Failed to open file", GetLastError());
+ throw rdr::win32_error("Failed to open file", GetLastError());
}
// Get version info size
DWORD handle;
int size = GetFileVersionInfoSize((char*)filename, &handle);
if (!size)
- throw rdr::Win32Exception("GetVersionInfoSize failed", GetLastError());
+ throw rdr::win32_error("GetVersionInfoSize failed", GetLastError());
// Get version info
buf = new char[size];
if (!GetFileVersionInfo((char*)filename, handle, size, buf))
- throw rdr::Win32Exception("GetVersionInfo failed", GetLastError());
+ throw rdr::win32_error("GetVersionInfo failed", GetLastError());
}
FileVersionInfo::~FileVersionInfo() {
@@ -81,7 +81,7 @@ const char* FileVersionInfo::getVerString(const char* name, DWORD langId) {
UINT length = 0;
if (!VerQueryValue(buf, infoName.c_str(), (void**)&buffer, &length)) {
printf("unable to find %s version string", infoName.c_str());
- throw rdr::Exception("VerQueryValue failed");
+ throw std::runtime_error("VerQueryValue failed");
}
return buffer;
}
diff --git a/win/vncconfig/Connections.h b/win/vncconfig/Connections.h
index a540bd76..dfa5c79f 100644
--- a/win/vncconfig/Connections.h
+++ b/win/vncconfig/Connections.h
@@ -73,8 +73,8 @@ namespace rfb {
try {
network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(newPat.c_str()));
pattern = network::TcpFilter::patternToStr(pat);
- } catch(rdr::Exception& e) {
- MsgBox(nullptr, e.str(), MB_ICONEXCLAMATION | MB_OK);
+ } catch(std::exception& e) {
+ MsgBox(nullptr, e.what(), MB_ICONEXCLAMATION | MB_OK);
return false;
}
return true;
@@ -235,7 +235,7 @@ namespace rfb {
(localHost != isItemChecked(IDC_LOCALHOST)) ||
(port_number != getItemInt(IDC_PORT)) ||
(rfb::Server::idleTimeout != getItemInt(IDC_IDLE_TIMEOUT));
- } catch (rdr::Exception&) {
+ } catch (std::exception&) {
return false;
}
}
diff --git a/win/vncconfig/Legacy.cxx b/win/vncconfig/Legacy.cxx
index 9300bb05..c6b245cc 100644
--- a/win/vncconfig/Legacy.cxx
+++ b/win/vncconfig/Legacy.cxx
@@ -42,7 +42,7 @@ void LegacyPage::LoadPrefs()
std::string username;
try {
username = UserName();
- } catch (rdr::Win32Exception& e) {
+ } catch (rdr::win32_error& e) {
if (e.err != ERROR_NOT_LOGGED_ON)
throw;
}
@@ -85,7 +85,7 @@ void LegacyPage::LoadPrefs()
if (bits)
strcat(pattern, ".");
if (parts[j].size() > 3)
- throw rdr::Exception("Invalid IP address part");
+ throw std::invalid_argument("Invalid IP address part");
if (!parts[j].empty()) {
strcat(pattern, parts[j].c_str());
bits += 8;
@@ -114,7 +114,7 @@ void LegacyPage::LoadPrefs()
// Finally, save the Hosts value
regKey.setString("Hosts", newHosts.c_str());
- } catch (rdr::Exception&) {
+ } catch (std::exception&) {
MsgBox(nullptr, "Unable to convert AuthHosts setting to Hosts format.",
MB_ICONWARNING | MB_OK);
}
@@ -135,7 +135,7 @@ void LegacyPage::LoadPrefs()
regKey.setBool("AlwaysShared", connectPriority == 1);
regKey.setBool("NeverShared", connectPriority == 2);
- } catch(rdr::Exception&) {
+ } catch(std::exception&) {
}
// Open the local, default-user settings
@@ -145,8 +145,8 @@ void LegacyPage::LoadPrefs()
userKey.openKey(winvnc3, "Default");
vlog.info("loading Default prefs");
LoadUserPrefs(userKey);
- } catch(rdr::Exception& e) {
- vlog.error("error reading Default settings:%s", e.str());
+ } catch(std::exception& e) {
+ vlog.error("error reading Default settings:%s", e.what());
}
// Open the local, user-specific settings
@@ -156,8 +156,8 @@ void LegacyPage::LoadPrefs()
userKey.openKey(winvnc3, username.c_str());
vlog.info("loading local User prefs");
LoadUserPrefs(userKey);
- } catch(rdr::Exception& e) {
- vlog.error("error reading local User settings:%s", e.str());
+ } catch(std::exception& e) {
+ vlog.error("error reading local User settings:%s", e.what());
}
// Open the user's own settings
@@ -167,8 +167,8 @@ void LegacyPage::LoadPrefs()
userKey.openKey(HKEY_CURRENT_USER, "Software\\ORL\\WinVNC3");
vlog.info("loading global User prefs");
LoadUserPrefs(userKey);
- } catch(rdr::Exception& e) {
- vlog.error("error reading global User settings:%s", e.str());
+ } catch(std::exception& e) {
+ vlog.error("error reading global User settings:%s", e.what());
}
}
}
diff --git a/win/vncconfig/vncconfig.cxx b/win/vncconfig/vncconfig.cxx
index 55f01d2e..7e692b9b 100644
--- a/win/vncconfig/vncconfig.cxx
+++ b/win/vncconfig/vncconfig.cxx
@@ -125,7 +125,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
// Set the DACL, and don't allow the key to inherit its parent's DACL
rootKey.setDACL(acl, false);
- } catch (rdr::Win32Exception& e) {
+ } catch (rdr::win32_error& e) {
// Something weird happens on NT 4.0 SP5 but I can't reproduce it on other
// NT 4.0 service pack revisions.
if (e.err == ERROR_INVALID_PARAMETER) {
@@ -169,7 +169,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
#else
sheet.showPropSheet(nullptr, true, false);
#endif
- } catch (rdr::Win32Exception& e) {
+ } catch (rdr::win32_error& e) {
switch (e.err) {
case ERROR_ACCESS_DENIED:
MsgBox(nullptr, "You do not have sufficient access rights to run the VNC Configuration applet",
@@ -179,8 +179,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
throw;
}
- } catch (rdr::Exception& e) {
- MsgBox(nullptr, e.str(), MB_ICONEXCLAMATION | MB_OK);
+ } catch (std::exception& e) {
+ MsgBox(nullptr, e.what(), MB_ICONEXCLAMATION | MB_OK);
return 1;
}
diff --git a/win/winvnc/ManagedListener.cxx b/win/winvnc/ManagedListener.cxx
index adc074cf..78f383a6 100644
--- a/win/winvnc/ManagedListener.cxx
+++ b/win/winvnc/ManagedListener.cxx
@@ -100,8 +100,8 @@ void ManagedListener::refresh() {
else
network::createTcpListeners(&sockets, nullptr, port);
}
- } catch (rdr::Exception& e) {
- vlog.error("%s", e.str());
+ } catch (std::exception& e) {
+ vlog.error("%s", e.what());
}
if (!sockets.empty()) {
if (!localOnly) {
diff --git a/win/winvnc/QueryConnectDialog.cxx b/win/winvnc/QueryConnectDialog.cxx
index 24918b2a..1ef26e63 100644
--- a/win/winvnc/QueryConnectDialog.cxx
+++ b/win/winvnc/QueryConnectDialog.cxx
@@ -60,7 +60,7 @@ void QueryConnectDialog::worker() {
countdown = timeout;
try {
if (desktopChangeRequired() && !changeDesktop())
- throw rdr::Exception("changeDesktop failed");
+ throw std::runtime_error("changeDesktop failed");
approve = Dialog::showDialog(MAKEINTRESOURCE(IDD_QUERY_CONNECT));
server->queryConnectionComplete();
} catch (...) {
@@ -74,7 +74,7 @@ void QueryConnectDialog::worker() {
void QueryConnectDialog::initDialog() {
if (!SetTimer(handle, 1, 1000, nullptr))
- throw rdr::Win32Exception("SetTimer", GetLastError());
+ throw rdr::win32_error("SetTimer", GetLastError());
setItemString(IDC_QUERY_HOST, peerIp.c_str());
if (userName.empty())
userName = "(anonymous)";
diff --git a/win/winvnc/STrayIcon.cxx b/win/winvnc/STrayIcon.cxx
index d703f47a..4420b574 100644
--- a/win/winvnc/STrayIcon.cxx
+++ b/win/winvnc/STrayIcon.cxx
@@ -159,8 +159,8 @@ public:
if (isServiceProcess()) {
try {
rfb::win32::stopService(VNCServerService::Name);
- } catch (rdr::Exception& e) {
- MsgBox(nullptr, e.str(), MB_ICONERROR | MB_OK);
+ } catch (std::exception& e) {
+ MsgBox(nullptr, e.what(), MB_ICONERROR | MB_OK);
}
} else {
thread.server.stop();
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index c1545ab6..cea0fe78 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -188,7 +188,7 @@ int VNCServerWin32::run() {
while (runServer) {
result = sockMgr.getMessage(&msg, nullptr, 0, 0);
if (result < 0)
- throw rdr::Win32Exception("getMessage", GetLastError());
+ throw rdr::win32_error("getMessage", GetLastError());
if (!isServiceProcess() && (result == 0))
break;
TranslateMessage(&msg);
@@ -196,11 +196,11 @@ int VNCServerWin32::run() {
}
vlog.debug("Server exited cleanly");
- } catch (rdr::Win32Exception &s) {
- vlog.error("%s", s.str());
+ } catch (rdr::win32_error &s) {
+ vlog.error("%s", s.what());
result = s.err;
- } catch (rdr::Exception &e) {
- vlog.error("%s", e.str());
+ } catch (std::exception &e) {
+ vlog.error("%s", e.what());
}
{
diff --git a/win/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx
index ceee0c6f..1a370522 100644
--- a/win/winvnc/winvnc.cxx
+++ b/win/winvnc/winvnc.cxx
@@ -119,7 +119,7 @@ static void processParams(int argc, char** argv) {
if (host != nullptr) {
HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
if (!hwnd)
- throw rdr::Exception("Unable to locate existing VNC Server.");
+ throw std::runtime_error("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
copyData.dwData = 1; // *** AddNewClient
copyData.cbData = strlen(host);
@@ -132,7 +132,7 @@ static void processParams(int argc, char** argv) {
runServer = false;
HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
if (!hwnd)
- throw rdr::Exception("Unable to locate existing VNC Server.");
+ throw std::runtime_error("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
copyData.dwData = 2; // *** DisconnectClients
copyData.lpData = nullptr;
@@ -177,13 +177,13 @@ static void processParams(int argc, char** argv) {
// Try to clean up earlier services we've had
try {
rfb::win32::unregisterService("WinVNC4");
- } catch (rdr::Win32Exception&) {
+ } catch (rdr::win32_error&) {
// Do nothing as we might fail simply because there was no
// service to remove
}
try {
rfb::win32::unregisterService("TigerVNC Server");
- } catch (rdr::Win32Exception&) {
+ } catch (rdr::win32_error&) {
}
if (rfb::win32::registerService(VNCServerService::Name,
@@ -228,8 +228,8 @@ static void processParams(int argc, char** argv) {
break;
}
- } catch (rdr::Exception& e) {
- MsgBoxOrLog(e.str(), true);
+ } catch (std::exception& e) {
+ MsgBoxOrLog(e.what(), true);
}
}
}
@@ -284,8 +284,8 @@ int WINAPI WinMain(HINSTANCE /*inst*/, HINSTANCE /*prevInst*/, char* /*cmdLine*/
}
vlog.debug("WinVNC service destroyed");
- } catch (rdr::Exception& e) {
- MsgBoxOrLog(e.str(), true);
+ } catch (std::exception& e) {
+ MsgBoxOrLog(e.what(), true);
}
vlog.debug("WinVNC process quitting");