systemMutex = new pthread_mutex_t;
ret = pthread_mutex_init((pthread_mutex_t*)systemMutex, nullptr);
if (ret != 0)
- throw rdr::SystemException("Failed to create mutex", ret);
+ throw rdr::PosixException("Failed to create mutex", ret);
#endif
}
ret = pthread_mutex_lock((pthread_mutex_t*)systemMutex);
if (ret != 0)
- throw rdr::SystemException("Failed to lock mutex", ret);
+ throw rdr::PosixException("Failed to lock mutex", ret);
#endif
}
ret = pthread_mutex_unlock((pthread_mutex_t*)systemMutex);
if (ret != 0)
- throw rdr::SystemException("Failed to unlock mutex", ret);
+ throw rdr::PosixException("Failed to unlock mutex", ret);
#endif
}
systemCondition = new pthread_cond_t;
ret = pthread_cond_init((pthread_cond_t*)systemCondition, nullptr);
if (ret != 0)
- throw rdr::SystemException("Failed to create condition variable", ret);
+ throw rdr::PosixException("Failed to create condition variable", ret);
#endif
}
(CRITICAL_SECTION*)mutex->systemMutex,
INFINITE);
if (!ret)
- throw rdr::SystemException("Failed to wait on condition variable", GetLastError());
+ throw rdr::Win32Exception("Failed to wait on condition variable", GetLastError());
#else
int ret;
ret = pthread_cond_wait((pthread_cond_t*)systemCondition,
(pthread_mutex_t*)mutex->systemMutex);
if (ret != 0)
- throw rdr::SystemException("Failed to wait on condition variable", ret);
+ throw rdr::PosixException("Failed to wait on condition variable", ret);
#endif
}
ret = pthread_cond_signal((pthread_cond_t*)systemCondition);
if (ret != 0)
- throw rdr::SystemException("Failed to signal condition variable", ret);
+ throw rdr::PosixException("Failed to signal condition variable", ret);
#endif
}
ret = pthread_cond_broadcast((pthread_cond_t*)systemCondition);
if (ret != 0)
- throw rdr::SystemException("Failed to broadcast condition variable", ret);
+ throw rdr::PosixException("Failed to broadcast condition variable", ret);
#endif
}
#ifdef WIN32
*(HANDLE*)threadId = CreateThread(nullptr, 0, startRoutine, this, 0, nullptr);
if (*(HANDLE*)threadId == nullptr)
- throw rdr::SystemException("Failed to create thread", GetLastError());
+ throw rdr::Win32Exception("Failed to create thread", GetLastError());
#else
int ret;
sigset_t all, old;
sigfillset(&all);
ret = pthread_sigmask(SIG_SETMASK, &all, &old);
if (ret != 0)
- throw rdr::SystemException("Failed to mask signals", ret);
+ throw rdr::PosixException("Failed to mask signals", ret);
ret = pthread_create((pthread_t*)threadId, nullptr, startRoutine, this);
pthread_sigmask(SIG_SETMASK, &old, nullptr);
if (ret != 0)
- throw rdr::SystemException("Failed to create thread", ret);
+ throw rdr::PosixException("Failed to create thread", ret);
#endif
running = true;
ret = WaitForSingleObject(*(HANDLE*)threadId, INFINITE);
if (ret != WAIT_OBJECT_0)
- throw rdr::SystemException("Failed to join thread", GetLastError());
+ throw rdr::Win32Exception("Failed to join thread", GetLastError());
#else
int ret;
ret = pthread_join(*(pthread_t*)threadId, nullptr);
if (ret != 0)
- throw rdr::SystemException("Failed to join thread", ret);
+ throw rdr::PosixException("Failed to join thread", ret);
#endif
}
strncat(str_, ")", len-1-strlen(str_));
}
-SystemException::SystemException(const char* s, int err_)
+PosixException::PosixException(const char* s, int err_)
+ : Exception("%s", s), err(err_)
+{
+ strncat(str_, ": ", len-1-strlen(str_));
+ strncat(str_, strerror(err), len-1-strlen(str_));
+ strncat(str_, " (", len-1-strlen(str_));
+ char buf[20];
+ sprintf(buf,"%d",err);
+ strncat(str_, buf, len-1-strlen(str_));
+ strncat(str_, ")", len-1-strlen(str_));
+}
+
+#ifdef WIN32
+Win32Exception::Win32Exception(const char* s, unsigned err_)
: Exception("%s", s), err(err_)
{
strncat(str_, ": ", len-1-strlen(str_));
-#ifdef _WIN32
wchar_t *currStr = new wchar_t[len-strlen(str_)];
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, err, 0, currStr, len-1-strlen(str_), nullptr);
if ((l >= 2) && (str_[l-2] == '\r') && (str_[l-1] == '\n'))
str_[l-2] = 0;
-#else
- strncat(str_, strerror(err), len-1-strlen(str_));
-#endif
strncat(str_, " (", len-1-strlen(str_));
char buf[20];
-#ifdef WIN32
- if (err < 0)
- sprintf(buf, "%x", err);
- else
-#endif
- sprintf(buf,"%d",err);
+ sprintf(buf,"%d",err);
strncat(str_, buf, len-1-strlen(str_));
strncat(str_, ")", len-1-strlen(str_));
}
-
+#endif
virtual const char* str() const { return str_; }
};
- struct SystemException : public Exception {
+ struct PosixException : public Exception {
int err;
- SystemException(const char* s, int err_);
+ PosixException(const char* s, int err_);
};
- struct SocketException : public SystemException {
- SocketException(const char* text, int err_) : SystemException(text, err_) {}
+#ifdef WIN32
+ struct Win32Exception : public Exception {
+ unsigned err;
+ Win32Exception(const char* s, unsigned err_);
};
+#endif
+
+#ifdef WIN32
+ struct SocketException : public Win32Exception {
+ SocketException(const char* text, unsigned err_) : Win32Exception(text, err_) {}
+ };
+#else
+ struct SocketException : public PosixException {
+ SocketException(const char* text, int err_) : PosixException(text, err_) {}
+ };
+#endif
struct GAIException : public Exception {
int err;
{
file = fopen(fileName, "rb");
if (!file)
- throw SystemException("fopen", errno);
+ throw PosixException("fopen", errno);
}
FileInStream::~FileInStream(void) {
size_t n = fread((uint8_t*)end, 1, availSpace(), file);
if (n == 0) {
if (ferror(file))
- throw SystemException("fread", errno);
+ throw PosixException("fread", errno);
if (feof(file))
throw EndOfStream();
return false;
#ifdef RFB_HAVE_WINCRYPT
if (provider) {
if (!CryptGenRandom(provider, availSpace(), (uint8_t*)end))
- throw rdr::SystemException("unable to CryptGenRandom", GetLastError());
+ throw rdr::Win32Exception("unable to CryptGenRandom", GetLastError());
end += availSpace();
} else {
#else
if (fp) {
size_t n = fread((uint8_t*)end, 1, availSpace(), fp);
if (n <= 0)
- throw rdr::SystemException("reading /dev/urandom or /dev/random failed",
- errno);
+ throw rdr::PosixException("reading /dev/urandom or /dev/random failed",
+ errno);
end += n;
} else {
#else
{
FILE* file = fopen(keyFile, "rb");
if (!file)
- throw rdr::SystemException("failed to open key file", errno);
+ throw rdr::PosixException("failed to open key file", errno);
fseek(file, 0, SEEK_END);
size_t size = ftell(file);
if (size == 0 || size > MaxKeyFileSize) {
std::vector<uint8_t> data(size);
if (fread(data.data(), 1, data.size(), file) != size) {
fclose(file);
- throw rdr::SystemException("failed to read key", errno);
+ throw rdr::PosixException("failed to read key", errno);
}
fclose(file);
return;
}
std::string msg = format(_("Could not open \"%s\""), filepath);
- throw rdr::SystemException(msg.c_str(), errno);
+ throw rdr::PosixException(msg.c_str(), errno);
}
int lineNr = 0;
fclose(f);
std::string msg = format(_("Failed to read line %d in "
"file \"%s\""), lineNr, filepath);
- throw rdr::SystemException(msg.c_str(), errno);
+ throw rdr::PosixException(msg.c_str(), errno);
}
int len = strlen(line);
FILE* f = fopen(filepath, "w+");
if (!f) {
std::string msg = format(_("Could not open \"%s\""), filepath);
- throw rdr::SystemException(msg.c_str(), errno);
+ throw rdr::PosixException(msg.c_str(), errno);
}
// Save the last X elements to the config file.
dc = CreateCompatibleDC(fl_gc);
if (!dc)
- throw rdr::SystemException("CreateCompatibleDC", GetLastError());
+ throw rdr::Win32Exception("CreateCompatibleDC", GetLastError());
if (!SelectObject(dc, bitmap))
- throw rdr::SystemException("SelectObject", GetLastError());
+ throw rdr::Win32Exception("SelectObject", GetLastError());
if (!BitBlt(fl_gc, dst_x, dst_y, dst_w, dst_h,
dc, src_x, src_y, SRCCOPY)) {
// with it. For now, we've only seen this error and for this function
// so only ignore this combination.
if (GetLastError() != ERROR_INVALID_HANDLE)
- throw rdr::SystemException("BitBlt", GetLastError());
+ throw rdr::Win32Exception("BitBlt", GetLastError());
}
DeleteDC(dc);
dstdc = CreateCompatibleDC(nullptr);
if (!dstdc)
- throw rdr::SystemException("CreateCompatibleDC", GetLastError());
+ throw rdr::Win32Exception("CreateCompatibleDC", GetLastError());
if (!SelectObject(dstdc, dst->bitmap))
- throw rdr::SystemException("SelectObject", GetLastError());
+ throw rdr::Win32Exception("SelectObject", GetLastError());
origdc = fl_gc;
fl_gc = dstdc;
dstdc = CreateCompatibleDC(nullptr);
if (!dstdc)
- throw rdr::SystemException("CreateCompatibleDC", GetLastError());
+ throw rdr::Win32Exception("CreateCompatibleDC", GetLastError());
srcdc = CreateCompatibleDC(nullptr);
if (!srcdc)
- throw rdr::SystemException("CreateCompatibleDC", GetLastError());
+ throw rdr::Win32Exception("CreateCompatibleDC", GetLastError());
if (!SelectObject(dstdc, dst->bitmap))
- throw rdr::SystemException("SelectObject", GetLastError());
+ throw rdr::Win32Exception("SelectObject", GetLastError());
if (!SelectObject(srcdc, bitmap))
- throw rdr::SystemException("SelectObject", GetLastError());
+ throw rdr::Win32Exception("SelectObject", GetLastError());
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
// with it. For now, we've only seen this error and for this function
// so only ignore this combination.
if (GetLastError() != ERROR_INVALID_HANDLE)
- throw rdr::SystemException("BitBlt", GetLastError());
+ throw rdr::Win32Exception("BitBlt", GetLastError());
}
DeleteDC(srcdc);
bitmap = CreateDIBSection(nullptr, (BITMAPINFO*)&bih,
DIB_RGB_COLORS, (void**)&data, nullptr, 0);
if (!bitmap)
- throw rdr::SystemException("CreateDIBSection", GetLastError());
+ throw rdr::Win32Exception("CreateDIBSection", GetLastError());
}
void Surface::dealloc()
fp = fopen(passwordFileName, "rb");
if (!fp)
- throw rdr::SystemException(_("Opening password file failed"), errno);
+ throw rdr::PosixException(_("Opening password file failed"), errno);
obfPwd.resize(fread(obfPwd.data(), 1, obfPwd.size(), fp));
fclose(fp);
LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException("RegSetValueExW", res);
+ throw rdr::Win32Exception("RegSetValueExW", res);
}
LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD));
if (res != ERROR_SUCCESS)
- throw rdr::SystemException("RegSetValueExW", res);
+ throw rdr::Win32Exception("RegSetValueExW", res);
}
if (res != ERROR_SUCCESS){
delete [] value;
if (res != ERROR_FILE_NOT_FOUND)
- throw rdr::SystemException("RegQueryValueExW", res);
+ throw rdr::Win32Exception("RegQueryValueExW", res);
// The value does not exist, defaults will be used.
return false;
}
LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)&value, &dwordsize);
if (res != ERROR_SUCCESS){
if (res != ERROR_FILE_NOT_FOUND)
- throw rdr::SystemException("RegQueryValueExW", res);
+ throw rdr::Win32Exception("RegQueryValueExW", res);
// The value does not exist, defaults will be used.
return false;
}
LONG res = RegDeleteValueW(*hKey, name);
if (res != ERROR_SUCCESS) {
if (res != ERROR_FILE_NOT_FOUND)
- throw rdr::SystemException("RegDeleteValueW", res);
+ throw rdr::Win32Exception("RegDeleteValueW", res);
// The value does not exist, no need to remove it.
return;
}
&hKey, nullptr);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException(_("Failed to create registry key"), res);
+ throw rdr::Win32Exception(_("Failed to create registry key"), res);
unsigned index = 0;
assert(SERVER_HISTORY_SIZE < 100);
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException(_("Failed to close registry key"), res);
+ throw rdr::Win32Exception(_("Failed to close registry key"), res);
}
static void saveToReg(const char* servername) {
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
&hKey, nullptr);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException(_("Failed to create registry key"), res);
+ throw rdr::Win32Exception(_("Failed to create registry key"), res);
try {
setKeyString("ServerName", servername, &hKey);
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException(_("Failed to close registry key"), res);
+ throw rdr::Win32Exception(_("Failed to close registry key"), res);
}
list<string> loadHistoryFromRegKey() {
return serverHistory;
}
- throw rdr::SystemException(_("Failed to open registry key"), res);
+ throw rdr::Win32Exception(_("Failed to open registry key"), res);
}
unsigned index;
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException(_("Failed to close registry key"), res);
+ throw rdr::Win32Exception(_("Failed to close registry key"), res);
return serverHistory;
}
return nullptr;
}
- throw rdr::SystemException(_("Failed to open registry key"), res);
+ throw rdr::Win32Exception(_("Failed to open registry key"), res);
}
const size_t buffersize = 256;
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS)
- throw rdr::SystemException(_("Failed to close registry key"), res);
+ throw rdr::Win32Exception(_("Failed to close registry key"), res);
return servername;
}
FILE* f = fopen(filepath, "w+");
if (!f) {
std::string msg = format(_("Could not open \"%s\""), filepath);
- throw rdr::SystemException(msg.c_str(), errno);
+ throw rdr::PosixException(msg.c_str(), errno);
}
fprintf(f, "%s\n", IDENTIFIER_STRING);
if (!filename)
return nullptr; // Use defaults.
std::string msg = format(_("Could not open \"%s\""), filepath);
- throw rdr::SystemException(msg.c_str(), errno);
+ throw rdr::PosixException(msg.c_str(), errno);
}
int lineNr = 0;
fclose(f);
std::string msg = format(_("Failed to read line %d in "
"file \"%s\""), lineNr, filepath);
- throw rdr::SystemException(msg.c_str(), errno);
+ throw rdr::PosixException(msg.c_str(), errno);
}
if (strlen(line) == (sizeof(line) - 1)) {
HRESULT result = CoCreateInstance(CLSID_ActiveDesktop, nullptr, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (PVOID*)&handle);
if (result != S_OK)
- throw rdr::SystemException("failed to contact Active Desktop", result);
+ throw rdr::Win32Exception("failed to contact Active Desktop", HRESULT_CODE(result));
}
~ActiveDesktop() {
if (handle)
// - Firstly, we must open the clipboard
if (!OpenClipboard(getHandle()))
- throw rdr::SystemException("unable to open Win32 clipboard", GetLastError());
+ throw rdr::Win32Exception("unable to open Win32 clipboard", GetLastError());
// - Convert the supplied clipboard text into UTF-16 format with CRLF
std::string filtered(convertCRLF(text));
// - Next, we must clear out any existing data
if (!EmptyClipboard())
- throw rdr::SystemException("unable to empty Win32 clipboard", GetLastError());
+ throw rdr::Win32Exception("unable to empty Win32 clipboard", GetLastError());
// - Set the new clipboard data
if (!SetClipboardData(CF_UNICODETEXT, clip_handle))
- throw rdr::SystemException("unable to set Win32 clipboard", GetLastError());
+ throw rdr::Win32Exception("unable to set Win32 clipboard", GetLastError());
clip_handle = nullptr;
vlog.debug("set clipboard");
CompatibleBitmap(HDC hdc, int width, int height) {
hbmp = CreateCompatibleBitmap(hdc, width, height);
if (!hbmp)
- throw rdr::SystemException("CreateCompatibleBitmap() failed", GetLastError());
+ throw rdr::Win32Exception("CreateCompatibleBitmap() failed", GetLastError());
}
virtual ~CompatibleBitmap() {
if (hbmp) DeleteObject(hbmp);
if (!OpenProcessToken(GetCurrentProcess(), GENERIC_ALL, &h)) {
DWORD err = GetLastError();
if (err != ERROR_CALL_NOT_IMPLEMENTED)
- throw rdr::SystemException("OpenProcessToken failed", err);
+ throw rdr::Win32Exception("OpenProcessToken failed", err);
h = INVALID_HANDLE_VALUE;
}
}
if (!ImpersonateLoggedOnUser(token)) {
DWORD err = GetLastError();
if (err != ERROR_CALL_NOT_IMPLEMENTED)
- throw rdr::SystemException("Failed to impersonate user", GetLastError());
+ throw rdr::Win32Exception("Failed to impersonate user", GetLastError());
}
}
char buf[UNLEN+1];
DWORD len = UNLEN+1;
if (!GetUserName(buf, &len))
- throw rdr::SystemException("GetUserName failed", GetLastError());
+ throw rdr::Win32Exception("GetUserName failed", GetLastError());
assign(buf);
}
if (!new_bitmap) {
int err = GetLastError();
- throw rdr::SystemException("unable to create DIB section", err);
+ throw rdr::Win32Exception("unable to create DIB section", err);
}
vlog.debug("recreateBuffer()");
// Determine the *actual* DIBSection format
DIBSECTION ds;
if (!GetObject(bitmap, sizeof(ds), &ds))
- throw rdr::SystemException("GetObject", GetLastError());
+ throw rdr::Win32Exception("GetObject", GetLastError());
// Correct the "stride" of the DIB
// *** This code DWORD aligns each row - is that right???
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biBitCount = 0;
if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
- throw rdr::SystemException("unable to determine device pixel format", GetLastError());
+ throw rdr::Win32Exception("unable to determine device pixel format", GetLastError());
}
if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
- throw rdr::SystemException("unable to determine pixel shifts/palette", GetLastError());
+ throw rdr::Win32Exception("unable to determine pixel shifts/palette", GetLastError());
}
// Set the initial format information
// Get the display dimensions
RECT cr;
if (!GetClipBox(dc, &cr))
- throw rdr::SystemException("GetClipBox", GetLastError());
+ throw rdr::Win32Exception("GetClipBox", GetLastError());
return Rect(cr.left, cr.top, cr.right, cr.bottom);
}
DeviceDC::DeviceDC(const char* deviceName) {
dc = ::CreateDC("DISPLAY", deviceName, nullptr, nullptr);
if (!dc)
- throw rdr::SystemException("failed to create DeviceDC", GetLastError());
+ throw rdr::Win32Exception("failed to create DeviceDC", GetLastError());
}
DeviceDC::~DeviceDC() {
WindowDC::WindowDC(HWND wnd) : hwnd(wnd) {
dc = GetDC(wnd);
if (!dc)
- throw rdr::SystemException("GetDC failed", GetLastError());
+ throw rdr::Win32Exception("GetDC failed", GetLastError());
}
WindowDC::~WindowDC() {
CompatibleDC::CompatibleDC(HDC existing) {
dc = CreateCompatibleDC(existing);
if (!dc)
- throw rdr::SystemException("CreateCompatibleDC failed", GetLastError());
+ throw rdr::Win32Exception("CreateCompatibleDC failed", GetLastError());
}
CompatibleDC::~CompatibleDC() {
BitmapDC::BitmapDC(HDC hdc, HBITMAP hbitmap) : CompatibleDC(hdc){
oldBitmap = (HBITMAP)SelectObject(dc, hbitmap);
if (!oldBitmap)
- throw rdr::SystemException("SelectObject to CompatibleDC failed",
+ throw rdr::Win32Exception("SelectObject to CompatibleDC failed",
GetLastError());
}
if (ignoreGrabErrors)
vlog.error("BitBlt failed:%ld", GetLastError());
else
- throw rdr::SystemException("BitBlt failed", GetLastError());
+ throw rdr::Win32Exception("BitBlt failed", GetLastError());
}
}
BITMAP maskInfo;
if (!GetObject(iconInfo.hbmMask, sizeof(BITMAP), &maskInfo))
- throw rdr::SystemException("GetObject() failed", GetLastError());
+ throw rdr::Win32Exception("GetObject() failed", GetLastError());
if (maskInfo.bmPlanes != 1)
throw rdr::Exception("unsupported multi-plane cursor");
if (maskInfo.bmBitsPixel != 1)
if (!GetDIBits(dc, iconInfo.hbmColor, 0, height,
buffer.data(), (LPBITMAPINFO)&bi, DIB_RGB_COLORS))
- throw rdr::SystemException("GetDIBits", GetLastError());
+ throw rdr::Win32Exception("GetDIBits", GetLastError());
// We may not get the RGBA order we want, so shuffle things around
int ridx, gidx, bidx, aidx;
if (!GetBitmapBits(iconInfo.hbmMask,
maskInfo.bmWidthBytes * maskInfo.bmHeight, mask.data()))
- throw rdr::SystemException("GetBitmapBits", GetLastError());
+ throw rdr::Win32Exception("GetBitmapBits", GetLastError());
bool doOutline = false;
uint8_t* rwbuffer = buffer.data();
INT_PTR result = DialogBoxParam(inst, resource, owner,
staticDialogProc, (LPARAM)this);
if (result<0)
- throw rdr::SystemException("DialogBoxParam failed", GetLastError());
+ throw rdr::Win32Exception("DialogBoxParam failed", GetLastError());
alreadyShowing = false;
return (result == 1);
}
handle = (HWND)PropertySheet(&header);
if ((handle == nullptr) || (handle == (HWND)-1))
- throw rdr::SystemException("PropertySheet failed", GetLastError());
+ throw rdr::Win32Exception("PropertySheet failed", GetLastError());
centerWindow(handle, owner_);
plog.info("created %p", handle);
struct IconInfo : public ICONINFO {
IconInfo(HICON icon) {
if (!GetIconInfo(icon, this))
- throw rdr::SystemException("GetIconInfo() failed", GetLastError());
+ throw rdr::Win32Exception("GetIconInfo() failed", GetLastError());
}
~IconInfo() {
if (hbmColor)
if (!active || interval_ != interval) {
interval = interval_;
if (!SetTimer(hwnd, id, interval, nullptr))
- throw rdr::SystemException("SetTimer", GetLastError());
+ throw rdr::Win32Exception("SetTimer", GetLastError());
active = true;
}
}
char buf[256];
HDESK desktop = GetThreadDesktop(GetCurrentThreadId());
if (!GetUserObjectInformation(desktop, UOI_NAME, buf, 256, &size))
- throw rdr::SystemException("unable to launch process", GetLastError());
+ throw rdr::Win32Exception("unable to launch process", GetLastError());
snprintf(desktopName, 256, "WinSta0\\%s", buf);
flags, nullptr, nullptr,
&sinfo, &procInfo);
if (!success)
- throw rdr::SystemException("unable to launch process", GetLastError());
+ throw rdr::Win32Exception("unable to launch process", GetLastError());
// Wait for it to finish initialising
WaitForInputIdle(procInfo.hProcess, 15000);
detach();
return true;
} else if (result == WAIT_FAILED) {
- throw rdr::SystemException("await() failed", GetLastError());
+ throw rdr::Win32Exception("await() failed", GetLastError());
}
return false;
}
// Allocate and/or manage LocalAlloc memory.
struct LocalMem {
LocalMem(int size) : ptr(LocalAlloc(LMEM_FIXED, size)) {
- if (!ptr) throw rdr::SystemException("LocalAlloc", GetLastError());
+ if (!ptr) throw rdr::Win32Exception("LocalAlloc", GetLastError());
}
LocalMem(void* p) : ptr(p) {}
~LocalMem() {LocalFree(ptr);}
memset(mi, 0, sizeof(MONITORINFOEXA));
mi->cbSize = sizeof(MONITORINFOEXA);
if (!GetMonitorInfo(monitor, mi))
- throw rdr::SystemException("failed to GetMonitorInfo", GetLastError());
+ throw rdr::Win32Exception("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);
HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST);
if (!monitor)
- throw rdr::SystemException("failed to get monitor", GetLastError());
+ throw rdr::Win32Exception("failed to get monitor", GetLastError());
fillMonitorInfo(monitor, this);
}
HMONITOR monitor = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST);
if (!monitor)
- throw rdr::SystemException("failed to get monitor", GetLastError());
+ throw rdr::Win32Exception("failed to get monitor", GetLastError());
fillMonitorInfo(monitor, this);
}
wndClass.lpszClassName = "rfb::win32::MsgWindowClass";
classAtom = RegisterClass(&wndClass);
if (!classAtom) {
- throw rdr::SystemException("unable to register MsgWindow window class", GetLastError());
+ throw rdr::Win32Exception("unable to register MsgWindow window class", GetLastError());
}
}
name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10,
nullptr, nullptr, baseClass.instance, this);
if (!handle) {
- throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
+ throw rdr::Win32Exception("unable to create WMNotifier window instance", GetLastError());
}
vlog.debug("created window \"%s\" (%p)", name.c_str(), handle);
}
if (!Configuration::setParam(name, value.c_str()))
vlog.info("unable to process %s", name);
}
- } catch (rdr::SystemException& e) {
- if (e.err != 6)
+ } catch (rdr::Win32Exception& e) {
+ if (e.err != ERROR_INVALID_HANDLE)
vlog.error("%s", e.str());
}
}
thread_id = GetCurrentThreadId();
while ((result = eventMgr.getMessage(&msg, nullptr, 0, 0)) > 0) {}
if (result < 0)
- throw rdr::SystemException("RegConfigThread failed", GetLastError());
+ throw rdr::Win32Exception("RegConfigThread failed", GetLastError());
}
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::SystemException("RegOpenKeyEx(HKEY)", result);
+ throw rdr::Win32Exception("RegOpenKeyEx(HKEY)", result);
vlog.debug("duplicated %p to %p", k, key);
freeKey = true;
}
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::SystemException("RegOpenKeyEx(RegKey&)", result);
+ throw rdr::Win32Exception("RegOpenKeyEx(RegKey&)", result);
vlog.debug("duplicated %p to %p", k.key, key);
freeKey = true;
}
LONG result = RegCreateKey(root.key, name, &key);
if (result != ERROR_SUCCESS) {
vlog.error("RegCreateKey(%p, %s): %lx", root.key, name, result);
- throw rdr::SystemException("RegCreateKeyEx", result);
+ throw rdr::Win32Exception("RegCreateKeyEx", result);
}
vlog.debug("createKey(%p,%s) = %p", root.key, name, key);
freeKey = true;
close();
LONG result = RegOpenKeyEx(root.key, name, 0, readOnly ? KEY_READ : KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegOpenKeyEx (open)", result);
+ throw rdr::Win32Exception("RegOpenKeyEx (open)", result);
vlog.debug("openKey(%p,%s,%s) = %p", root.key, name,
readOnly ? "ro" : "rw", key);
freeKey = true;
DACL_SECURITY_INFORMATION |
(inherit ? UNPROTECTED_DACL_SECURITY_INFORMATION : PROTECTED_DACL_SECURITY_INFORMATION),
nullptr, nullptr, acl, nullptr)) != ERROR_SUCCESS)
- throw rdr::SystemException("RegKey::setDACL failed", result);
+ throw rdr::Win32Exception("RegKey::setDACL failed", result);
}
void RegKey::close() {
void RegKey::deleteKey(const char* name) const {
LONG result = RegDeleteKey(key, name);
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegDeleteKey", result);
+ throw rdr::Win32Exception("RegDeleteKey", result);
}
void RegKey::deleteValue(const char* name) const {
LONG result = RegDeleteValue(key, name);
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegDeleteValue", result);
+ throw rdr::Win32Exception("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::SystemException("RegNotifyChangeKeyValue", result);
+ throw rdr::Win32Exception("RegNotifyChangeKeyValue", result);
}
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::SystemException("setExpandString", result);
+ if (result != ERROR_SUCCESS) throw rdr::Win32Exception("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::SystemException("setString", result);
+ if (result != ERROR_SUCCESS) throw rdr::Win32Exception("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::SystemException("setBinary", result);
+ if (result != ERROR_SUCCESS) throw rdr::Win32Exception("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::SystemException("setInt", result);
+ if (result != ERROR_SUCCESS) throw rdr::Win32Exception("setInt", result);
}
void RegKey::setBool(const char* valname, bool value) const {
DWORD type, length;
LONG result = RegQueryValueEx(key, valname, nullptr, &type, nullptr, &length);
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("get registry value length", result);
+ throw rdr::Win32Exception("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::SystemException("get registry value", result);
+ throw rdr::Win32Exception("get registry value", result);
switch (type) {
case REG_BINARY:
std::string str((char*)data.data(), length);
DWORD required = ExpandEnvironmentStrings(str.c_str(), nullptr, 0);
if (required==0)
- throw rdr::SystemException("ExpandEnvironmentStrings", GetLastError());
+ throw rdr::Win32Exception("ExpandEnvironmentStrings", GetLastError());
std::vector<char> expanded(required);
length = ExpandEnvironmentStrings(str.c_str(), expanded.data(), required);
if (required<length)
DWORD maxValueNameLen;
LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr);
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegQueryInfoKey", result);
+ throw rdr::Win32Exception("RegQueryInfoKey", result);
if (valueNameBufLen < maxValueNameLen + 1) {
valueNameBufLen = maxValueNameLen + 1;
delete [] valueName;
result = RegEnumValue(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
if (result == ERROR_NO_MORE_ITEMS) return nullptr;
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegEnumValue", result);
+ throw rdr::Win32Exception("RegEnumValue", result);
return valueName;
}
DWORD maxValueNameLen;
LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegQueryInfoKey", result);
+ throw rdr::Win32Exception("RegQueryInfoKey", result);
if (valueNameBufLen < maxValueNameLen + 1) {
valueNameBufLen = maxValueNameLen + 1;
delete [] valueName;
result = RegEnumKeyEx(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
if (result == ERROR_NO_MORE_ITEMS) return nullptr;
if (result != ERROR_SUCCESS)
- throw rdr::SystemException("RegEnumKey", result);
+ throw rdr::Win32Exception("RegEnumKey", result);
return valueName;
}
evt.mi.mouseData = data;
evt.mi.time = 0;
if (SendInput(1, &evt, sizeof(evt)) != 1)
- throw rdr::SystemException("SendInput", GetLastError());
+ throw rdr::Win32Exception("SendInput", GetLastError());
}
}
throw rdr::Exception("invalid SID in copyPSID");
PSID buf = (PSID)new uint8_t[GetLengthSid(sid)];
if (!CopySid(GetLengthSid(sid), buf, sid))
- throw rdr::SystemException("CopySid failed", GetLastError());
+ throw rdr::Win32Exception("CopySid failed", GetLastError());
return buf;
}
throw rdr::Exception("invalid SID in copyPSID");
resize(GetLengthSid(sid));
if (!CopySid(GetLengthSid(sid), data(), sid))
- throw rdr::SystemException("CopySid failed", GetLastError());
+ throw rdr::Win32Exception("CopySid failed", GetLastError());
}
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::SystemException("Unable to determine SID name lengths", GetLastError());
+ throw rdr::Win32Exception("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::SystemException("Unable to lookup account SID", GetLastError());
+ throw rdr::Win32Exception("Unable to lookup account SID", GetLastError());
}
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &sid))
- throw rdr::SystemException("Sid::Administrators", GetLastError());
+ throw rdr::Win32Exception("Sid::Administrators", GetLastError());
setSID(sid);
FreeSid(sid);
}
if (!AllocateAndInitializeSid(&ntAuth, 1,
SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0, &sid))
- throw rdr::SystemException("Sid::SYSTEM", GetLastError());
+ throw rdr::Win32Exception("Sid::SYSTEM", GetLastError());
setSID(sid);
FreeSid(sid);
}
GetTokenInformation(h, TokenUser, nullptr, 0, &required);
std::vector<uint8_t> tmp(required);
if (!GetTokenInformation(h, TokenUser, tmp.data(), tmp.size(), &required))
- throw rdr::SystemException("GetTokenInformation", GetLastError());
+ throw rdr::Win32Exception("GetTokenInformation", GetLastError());
TOKEN_USER* tokenUser = (TOKEN_USER*)tmp.data();
setSID(tokenUser->User.Sid);
}
PACL new_dacl;
DWORD result;
if ((result = SetEntriesInAcl(ae.entry_count, ae.entries, existing_acl, &new_dacl)) != ERROR_SUCCESS)
- throw rdr::SystemException("SetEntriesInAcl", result);
+ throw rdr::Win32Exception("SetEntriesInAcl", result);
return new_dacl;
}
PSECURITY_DESCRIPTOR rfb::win32::CreateSdWithDacl(const PACL dacl) {
SECURITY_DESCRIPTOR absSD;
if (!InitializeSecurityDescriptor(&absSD, SECURITY_DESCRIPTOR_REVISION))
- throw rdr::SystemException("InitializeSecurityDescriptor", GetLastError());
+ throw rdr::Win32Exception("InitializeSecurityDescriptor", GetLastError());
Sid::SYSTEM owner;
if (!SetSecurityDescriptorOwner(&absSD, owner, FALSE))
- throw rdr::SystemException("SetSecurityDescriptorOwner", GetLastError());
+ throw rdr::Win32Exception("SetSecurityDescriptorOwner", GetLastError());
Sid::Administrators group;
if (!SetSecurityDescriptorGroup(&absSD, group, FALSE))
- throw rdr::SystemException("SetSecurityDescriptorGroupp", GetLastError());
+ throw rdr::Win32Exception("SetSecurityDescriptorGroupp", GetLastError());
if (!SetSecurityDescriptorDacl(&absSD, TRUE, dacl, FALSE))
- throw rdr::SystemException("SetSecurityDescriptorDacl", GetLastError());
+ throw rdr::Win32Exception("SetSecurityDescriptorDacl", GetLastError());
DWORD sdSize = GetSecurityDescriptorLength(&absSD);
SecurityDescriptorPtr sd(sdSize);
if (!MakeSelfRelativeSD(&absSD, (PSECURITY_DESCRIPTOR)sd.ptr, &sdSize))
- throw rdr::SystemException("MakeSelfRelativeSD", GetLastError());
+ throw rdr::Win32Exception("MakeSelfRelativeSD", GetLastError());
return sd.takeSD();
}
vlog.error("unable to set shutdown parameters: %lu", GetLastError());
service = this;
if (!StartServiceCtrlDispatcher(entry))
- throw SystemException("unable to start service", GetLastError());
+ throw Win32Exception("unable to start service", GetLastError());
}
void
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
+ throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
// - Add the service
ServiceHandle handle = CreateService(scm,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr);
if (!handle)
- throw rdr::SystemException("unable to create service", GetLastError());
+ throw rdr::Win32Exception("unable to create service", GetLastError());
// - Set a description
SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc};
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
- throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
+ throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
// - Create the service
ServiceHandle handle = OpenService(scm, name, SC_MANAGER_ALL_ACCESS);
if (!handle)
- throw rdr::SystemException("unable to locate the service", GetLastError());
+ throw rdr::Win32Exception("unable to locate the service", GetLastError());
if (!DeleteService(handle))
- throw rdr::SystemException("unable to remove the service", GetLastError());
+ throw rdr::Win32Exception("unable to remove the service", GetLastError());
// - Register the event log source
RegKey hk;
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
+ throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_START);
if (!handle)
- throw rdr::SystemException("unable to open the service", GetLastError());
+ throw rdr::Win32Exception("unable to open the service", GetLastError());
// - Start the service
if (!StartService(handle, 0, nullptr))
- throw rdr::SystemException("unable to start the service", GetLastError());
+ throw rdr::Win32Exception("unable to start the service", GetLastError());
Sleep(500);
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
+ throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_STOP);
if (!handle)
- throw rdr::SystemException("unable to open the service", GetLastError());
+ throw rdr::Win32Exception("unable to open the service", GetLastError());
// - Start the service
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_STOP, &status))
- throw rdr::SystemException("unable to stop the service", GetLastError());
+ throw rdr::Win32Exception("unable to stop the service", GetLastError());
Sleep(500);
// - Open the SCM
ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
- throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
+ throw rdr::Win32Exception("unable to open Service Control Manager", GetLastError());
// - Locate the service
ServiceHandle handle = OpenService(scm, name, SERVICE_INTERROGATE);
if (!handle)
- throw rdr::SystemException("unable to open the service", GetLastError());
+ throw rdr::Win32Exception("unable to open the service", GetLastError());
// - Get the service status
SERVICE_STATUS status;
if (!ControlService(handle, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status))
- throw rdr::SystemException("unable to query the service", GetLastError());
+ throw rdr::Win32Exception("unable to query the service", GetLastError());
return status.dwCurrentState;
}
if (processId == (DWORD)-1)
processId = GetCurrentProcessId();
if (!ProcessIdToSessionId(GetCurrentProcessId(), &id))
- throw rdr::SystemException("ProcessIdToSessionId", GetLastError());
+ throw rdr::Win32Exception("ProcessIdToSessionId", GetLastError());
}
ProcessSessionId mySessionId;
ConsoleSessionId console;
vlog.info("Console session is %lu", console.id);
if (!WTSConnectSession(sessionId, console.id, (PTSTR)"", 0))
- throw rdr::SystemException("Unable to connect session to Console", GetLastError());
+ throw rdr::Win32Exception("Unable to connect session to Console", GetLastError());
// Lock the newly connected session, for security
LockWorkStation();
CURSORINFO info;
info.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&info))
- throw rdr::SystemException("GetCursorInfo failed", GetLastError());
+ throw rdr::Win32Exception("GetCursorInfo failed", GetLastError());
result.cursor = info.hCursor;
result.position = Point(info.ptScreenPos.x, info.ptScreenPos.y);
result.visible = info.flags & CURSOR_SHOWING;
rfb::win32::WMPoller::checkPollWindow(HWND w) {
char buffer[128];
if (!GetClassName(w, buffer, 128))
- throw rdr::SystemException("unable to get window class:%u", GetLastError());
+ throw rdr::Win32Exception("unable to get window class:%u", GetLastError());
if ((strcmp(buffer, "tty") != 0) &&
(strcmp(buffer, "ConsoleWindowClass") != 0)) {
return false;
{
Handle file(CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (file.h == INVALID_HANDLE_VALUE)
- throw rdr::SystemException("Failed to open file", GetLastError());
+ throw rdr::Win32Exception("Failed to open file", GetLastError());
}
// Get version info size
DWORD handle;
int size = GetFileVersionInfoSize((char*)filename, &handle);
if (!size)
- throw rdr::SystemException("GetVersionInfoSize failed", GetLastError());
+ throw rdr::Win32Exception("GetVersionInfoSize failed", GetLastError());
// Get version info
buf = new char[size];
if (!GetFileVersionInfo((char*)filename, handle, size, buf))
- throw rdr::SystemException("GetVersionInfo failed", GetLastError());
+ throw rdr::Win32Exception("GetVersionInfo failed", GetLastError());
}
FileVersionInfo::~FileVersionInfo() {
std::string username;
try {
username = UserName();
- } catch (rdr::SystemException& e) {
+ } catch (rdr::Win32Exception& e) {
if (e.err != ERROR_NOT_LOGGED_ON)
throw;
}
// Set the DACL, and don't allow the key to inherit its parent's DACL
rootKey.setDACL(acl, false);
- } catch (rdr::SystemException& e) {
+ } catch (rdr::Win32Exception& 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) {
#else
sheet.showPropSheet(nullptr, true, false);
#endif
- } catch (rdr::SystemException& e) {
+ } catch (rdr::Win32Exception& e) {
switch (e.err) {
case ERROR_ACCESS_DENIED:
MsgBox(nullptr, "You do not have sufficient access rights to run the VNC Configuration applet",
void QueryConnectDialog::initDialog() {
if (!SetTimer(handle, 1, 1000, nullptr))
- throw rdr::SystemException("SetTimer", GetLastError());
+ throw rdr::Win32Exception("SetTimer", GetLastError());
setItemString(IDC_QUERY_HOST, peerIp.c_str());
if (userName.empty())
userName = "(anonymous)";
while (runServer) {
result = sockMgr.getMessage(&msg, nullptr, 0, 0);
if (result < 0)
- throw rdr::SystemException("getMessage", GetLastError());
+ throw rdr::Win32Exception("getMessage", GetLastError());
if (!isServiceProcess() && (result == 0))
break;
TranslateMessage(&msg);
}
vlog.debug("Server exited cleanly");
- } catch (rdr::SystemException &s) {
+ } catch (rdr::Win32Exception &s) {
vlog.error("%s", s.str());
result = s.err;
} catch (rdr::Exception &e) {
// Try to clean up earlier services we've had
try {
rfb::win32::unregisterService("WinVNC4");
- } catch (rdr::SystemException&) {
+ } catch (rdr::Win32Exception&) {
// Do nothing as we might fail simply because there was no
// service to remove
}
try {
rfb::win32::unregisterService("TigerVNC Server");
- } catch (rdr::SystemException&) {
+ } catch (rdr::Win32Exception&) {
}
if (rfb::win32::registerService(VNCServerService::Name,