aboutsummaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/rfb_win32/RegConfig.cxx10
-rw-r--r--win/rfb_win32/RegConfig.h7
-rw-r--r--win/rfb_win32/SecurityPage.cxx3
-rw-r--r--win/rfb_win32/WMHooks.cxx30
-rw-r--r--win/vncconfig/vncconfig.rc2
-rw-r--r--win/winvnc/ControlPanel.cxx6
-rw-r--r--win/winvnc/ControlPanel.h2
-rw-r--r--win/winvnc/QueryConnectDialog.cxx13
-rw-r--r--win/winvnc/QueryConnectDialog.h8
-rw-r--r--win/winvnc/STrayIcon.cxx13
-rw-r--r--win/winvnc/STrayIcon.h11
-rw-r--r--win/winvnc/VNCServerWin32.cxx36
-rw-r--r--win/winvnc/VNCServerWin32.h11
-rw-r--r--win/winvnc/winvnc.rc2
-rw-r--r--win/wm_hooks/wm_hooks.rc4
15 files changed, 80 insertions, 78 deletions
diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx
index 7d80871f..057882b9 100644
--- a/win/rfb_win32/RegConfig.cxx
+++ b/win/rfb_win32/RegConfig.cxx
@@ -93,17 +93,21 @@ void RegConfig::processEvent(HANDLE /*event*/) {
}
-RegConfigThread::RegConfigThread() : config(&eventMgr), thread_id(-1) {
+RegConfigThread::RegConfigThread() : config(&eventMgr), thread(nullptr),
+ thread_id(-1) {
}
RegConfigThread::~RegConfigThread() {
PostThreadMessage(thread_id, WM_QUIT, 0, 0);
- wait();
+ if (thread != nullptr) {
+ thread->join();
+ delete thread;
+ }
}
bool RegConfigThread::start(const HKEY rootKey, const char* keyname) {
if (config.setKey(rootKey, keyname)) {
- Thread::start();
+ thread = new std::thread(&RegConfigThread::worker, this);
while (thread_id == (DWORD)-1)
Sleep(0);
return true;
diff --git a/win/rfb_win32/RegConfig.h b/win/rfb_win32/RegConfig.h
index 89e724f8..4a2f8ca8 100644
--- a/win/rfb_win32/RegConfig.h
+++ b/win/rfb_win32/RegConfig.h
@@ -24,7 +24,7 @@
#ifndef __RFB_WIN32_REG_CONFIG_H__
#define __RFB_WIN32_REG_CONFIG_H__
-#include <core/Thread.h>
+#include <thread>
#include <rfb_win32/Registry.h>
#include <rfb_win32/EventManager.h>
@@ -63,7 +63,7 @@ namespace rfb {
RegKey key;
};
- class RegConfigThread : core::Thread {
+ class RegConfigThread {
public:
RegConfigThread();
~RegConfigThread();
@@ -71,9 +71,10 @@ namespace rfb {
// Start the thread, reading from the specified key
bool start(const HKEY rootkey, const char* keyname);
protected:
- void worker() override;
+ void worker();
EventManager eventMgr;
RegConfig config;
+ std::thread* thread;
DWORD thread_id;
};
diff --git a/win/rfb_win32/SecurityPage.cxx b/win/rfb_win32/SecurityPage.cxx
index f9321160..94a88492 100644
--- a/win/rfb_win32/SecurityPage.cxx
+++ b/win/rfb_win32/SecurityPage.cxx
@@ -123,9 +123,6 @@ SecurityPage::onOk() {
bool vnc_loaded = false;
list<uint32_t> secTypes;
- /* Keep same priorities as in common/rfb/SecurityClient::secTypes */
- secTypes.push_back(secTypeVeNCrypt);
-
#ifdef HAVE_GNUTLS
/* X509Plain */
if (authMethodEnabled(IDC_ENC_X509, IDC_AUTH_PLAIN)) {
diff --git a/win/rfb_win32/WMHooks.cxx b/win/rfb_win32/WMHooks.cxx
index 6b444166..e3285948 100644
--- a/win/rfb_win32/WMHooks.cxx
+++ b/win/rfb_win32/WMHooks.cxx
@@ -22,9 +22,10 @@
#include <config.h>
#endif
+#include <mutex>
+#include <thread>
+
#include <core/LogWriter.h>
-#include <core/Mutex.h>
-#include <core/Thread.h>
#include <rfb_win32/WMHooks.h>
#include <rfb_win32/Service.h>
@@ -115,21 +116,23 @@ error:
}
-class WMHooksThread : public Thread {
+class WMHooksThread {
public:
- WMHooksThread() : active(true), thread_id(-1) { }
+ WMHooksThread() : active(true), thread(WMHooksThread::worker, this),
+ thread_id(-1) { }
void stop();
DWORD getThreadId() { return thread_id; }
protected:
- void worker() override;
+ void worker();
protected:
bool active;
+ std::thread thread;
DWORD thread_id;
};
static WMHooksThread* hook_mgr = nullptr;
static std::list<WMHooks*> hooks;
-static Mutex hook_mgr_lock;
+static std::mutex hook_mgr_lock;
static bool StartHookThread() {
@@ -139,7 +142,6 @@ static bool StartHookThread() {
return false;
vlog.debug("Creating thread");
hook_mgr = new WMHooksThread();
- hook_mgr->start();
while (hook_mgr->getThreadId() == (DWORD)-1)
Sleep(0);
vlog.debug("Installing hooks");
@@ -167,7 +169,7 @@ static void StopHookThread() {
static bool AddHook(WMHooks* hook) {
vlog.debug("Adding hook");
- AutoMutex a(&hook_mgr_lock);
+ const std::lock_guard<std::mutex> lock(hook_mgr_lock);
if (!StartHookThread())
return false;
hooks.push_back(hook);
@@ -177,7 +179,7 @@ static bool AddHook(WMHooks* hook) {
static bool RemHook(WMHooks* hook) {
{
vlog.debug("Removing hook");
- AutoMutex a(&hook_mgr_lock);
+ const std::lock_guard<std::mutex> lock(hook_mgr_lock);
hooks.remove(hook);
}
StopHookThread();
@@ -185,7 +187,7 @@ static bool RemHook(WMHooks* hook) {
}
static void NotifyHooksRegion(const Region& r) {
- AutoMutex a(&hook_mgr_lock);
+ const std::lock_guard<std::mutex> lock(hook_mgr_lock);
std::list<WMHooks*>::iterator i;
for (i=hooks.begin(); i!=hooks.end(); i++)
(*i)->NotifyHooksRegion(r);
@@ -302,7 +304,7 @@ WMHooksThread::stop() {
active = false;
PostThreadMessage(thread_id, WM_QUIT, 0, 0);
vlog.debug("Waiting for WMHooks thread");
- wait();
+ thread.join();
}
// -=- WMHooks class
@@ -324,7 +326,7 @@ bool rfb::win32::WMHooks::setEvent(HANDLE ue) {
bool rfb::win32::WMHooks::getUpdates(UpdateTracker* ut) {
if (!updatesReady) return false;
- AutoMutex a(&hook_mgr_lock);
+ const std::lock_guard<std::mutex> lock(hook_mgr_lock);
updates.copyTo(ut);
updates.clear();
updatesReady = false;
@@ -376,12 +378,12 @@ static bool blockRealInputs(bool block_) {
return block_ == blocking;
}
-static Mutex blockMutex;
+static std::mutex blockMutex;
static int blockCount = 0;
bool rfb::win32::WMBlockInput::blockInputs(bool on) {
if (active == on) return true;
- AutoMutex a(&blockMutex);
+ const std::lock_guard<std::mutex> lock(blockMutex);
int newCount = on ? blockCount+1 : blockCount-1;
if (!blockRealInputs(newCount > 0))
return false;
diff --git a/win/vncconfig/vncconfig.rc b/win/vncconfig/vncconfig.rc
index f4b856dd..e8b50ed1 100644
--- a/win/vncconfig/vncconfig.rc
+++ b/win/vncconfig/vncconfig.rc
@@ -459,7 +459,7 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "\0"
- VALUE "CompanyName", "TigerVNC project\0"
+ VALUE "CompanyName", "TigerVNC team\0"
#ifdef WIN64
VALUE "FileDescription", "TigerVNC server configuration applet for Win64\0"
VALUE "ProductName", "TigerVNC server configuration applet for Win64\0"
diff --git a/win/winvnc/ControlPanel.cxx b/win/winvnc/ControlPanel.cxx
index 6c593c45..9041d81f 100644
--- a/win/winvnc/ControlPanel.cxx
+++ b/win/winvnc/ControlPanel.cxx
@@ -31,9 +31,9 @@ void ControlPanel::initDialog()
SendCommand(4, -1);
}
-bool ControlPanel::onCommand(int cmd)
+bool ControlPanel::onCommand(int item, int /*cmd*/)
{
- switch (cmd) {
+ switch (item) {
case IDC_PROPERTIES:
SendMessage(m_hSTIcon, WM_COMMAND, ID_OPTIONS, 0);
return false;
@@ -122,7 +122,7 @@ BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM /*lPara
EndDialog(hwnd, 0);
return TRUE;
default:
- return onCommand(LOWORD(wParam));
+ return onCommand(LOWORD(wParam), HIWORD(wParam));
}
}
return FALSE;
diff --git a/win/winvnc/ControlPanel.h b/win/winvnc/ControlPanel.h
index 23aff0a5..3b994a59 100644
--- a/win/winvnc/ControlPanel.h
+++ b/win/winvnc/ControlPanel.h
@@ -26,7 +26,7 @@ namespace winvnc {
};
virtual bool showDialog();
void initDialog() override;
- virtual bool onCommand(int cmd);
+ bool onCommand(int item, int cmd) override;
void UpdateListView(ListConnInfo* LCInfo);
HWND GetHandle() {return handle;};
void SendCommand(DWORD command, int data);
diff --git a/win/winvnc/QueryConnectDialog.cxx b/win/winvnc/QueryConnectDialog.cxx
index 5d609898..1b03af5d 100644
--- a/win/winvnc/QueryConnectDialog.cxx
+++ b/win/winvnc/QueryConnectDialog.cxx
@@ -48,12 +48,21 @@ QueryConnectDialog::QueryConnectDialog(network::Socket* sock_,
const char* userName_,
VNCServerWin32* s)
: Dialog(GetModuleHandle(nullptr)),
- sock(sock_), peerIp(sock->getPeerAddress()), userName(userName_),
+ thread(nullptr), sock(sock_), peerIp(sock->getPeerAddress()),
+ userName(userName_?userName_:""),
approve(false), server(s) {
}
+QueryConnectDialog::~QueryConnectDialog()
+{
+ if (thread != nullptr) {
+ thread->join();
+ delete thread;
+ }
+}
+
void QueryConnectDialog::startDialog() {
- start();
+ thread = new std::thread(&QueryConnectDialog::worker, this);
}
diff --git a/win/winvnc/QueryConnectDialog.h b/win/winvnc/QueryConnectDialog.h
index 52a71ce2..102199af 100644
--- a/win/winvnc/QueryConnectDialog.h
+++ b/win/winvnc/QueryConnectDialog.h
@@ -21,7 +21,7 @@
#ifndef __WINVNC_QUERY_CONNECT_DIALOG_H__
#define __WINVNC_QUERY_CONNECT_DIALOG_H__
-#include <core/Thread.h>
+#include <thread>
#include <rfb_win32/Dialog.h>
@@ -31,15 +31,16 @@ namespace winvnc {
class VNCServerWin32;
- class QueryConnectDialog : public core::Thread, rfb::win32::Dialog {
+ class QueryConnectDialog : rfb::win32::Dialog {
public:
QueryConnectDialog(network::Socket* sock, const char* userName, VNCServerWin32* s);
+ ~QueryConnectDialog();
virtual void startDialog();
network::Socket* getSock() {return sock;}
bool isAccepted() const {return approve;}
protected:
// Thread methods
- void worker() override;
+ void worker();
// Dialog methods (protected)
void initDialog() override;
@@ -48,6 +49,7 @@ namespace winvnc {
// Custom internal methods
void setCountdownLabel();
+ std::thread* thread;
int countdown;
network::Socket* sock;
std::string peerIp;
diff --git a/win/winvnc/STrayIcon.cxx b/win/winvnc/STrayIcon.cxx
index b8a57330..fc079e76 100644
--- a/win/winvnc/STrayIcon.cxx
+++ b/win/winvnc/STrayIcon.cxx
@@ -28,8 +28,6 @@
#include <core/Configuration.h>
#include <core/LogWriter.h>
-#include <core/Mutex.h>
-#include <core/Thread.h>
#include <rfb_win32/LaunchProcess.h>
#include <rfb_win32/TrayIcon.h>
@@ -217,7 +215,7 @@ public:
case WM_SET_TOOLTIP:
{
- AutoMutex a(thread.lock);
+ const std::lock_guard<std::mutex> a(thread.lock);
if (!thread.toolTip.empty())
setToolTip(thread.toolTip.c_str());
}
@@ -239,12 +237,11 @@ protected:
STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT activeIcon_,
UINT dis_inactiveIcon_, UINT dis_activeIcon_, UINT menu_)
-: thread_id(-1), windowHandle(nullptr), server(sm),
+: thread(&STrayIconThread::worker, this), thread_id(-1),
+ windowHandle(nullptr), server(sm),
inactiveIcon(inactiveIcon_), activeIcon(activeIcon_),
dis_inactiveIcon(dis_inactiveIcon_), dis_activeIcon(dis_activeIcon_),
menu(menu_), runTrayIcon(true) {
- lock = new Mutex;
- start();
while (thread_id == (DWORD)-1)
Sleep(0);
}
@@ -252,7 +249,7 @@ STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT ac
STrayIconThread::~STrayIconThread() {
runTrayIcon = false;
PostThreadMessage(thread_id, WM_QUIT, 0, 0);
- delete lock;
+ thread.join();
}
void STrayIconThread::worker() {
@@ -277,7 +274,7 @@ void STrayIconThread::worker() {
void STrayIconThread::setToolTip(const char* text) {
if (!windowHandle) return;
- AutoMutex a(lock);
+ const std::lock_guard<std::mutex> a(lock);
toolTip = text;
PostMessage(windowHandle, WM_SET_TOOLTIP, 0, 0);
}
diff --git a/win/winvnc/STrayIcon.h b/win/winvnc/STrayIcon.h
index 0df8ecab..0398757c 100644
--- a/win/winvnc/STrayIcon.h
+++ b/win/winvnc/STrayIcon.h
@@ -19,14 +19,16 @@
#ifndef WINVNC_TRAYICON_H
#define WINVNC_TRAYICON_H
+#include <mutex>
+#include <thread>
+
#include <winvnc/VNCServerWin32.h>
#include <core/Configuration.h>
-#include <core/Thread.h>
namespace winvnc {
- class STrayIconThread : core::Thread {
+ class STrayIconThread {
public:
STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon,
UINT activeIcon, UINT dis_inactiveIcon, UINT dis_activeIcon, UINT menu);
@@ -39,9 +41,10 @@ namespace winvnc {
friend class STrayIcon;
protected:
- void worker() override;
+ void worker();
- core::Mutex* lock;
+ std::mutex lock;
+ std::thread thread;
DWORD thread_id;
HWND windowHandle;
std::string toolTip;
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index 4c81cec3..b09b6706 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -28,7 +28,6 @@
#include <winvnc/STrayIcon.h>
#include <core/LogWriter.h>
-#include <core/Mutex.h>
#include <network/TcpSocket.h>
@@ -73,11 +72,6 @@ VNCServerWin32::VNCServerWin32()
config(&sockMgr), rfbSock(&sockMgr), trayIcon(nullptr),
queryConnectDialog(nullptr)
{
- commandLock = new Mutex;
- commandSig = new Condition(commandLock);
-
- runLock = new Mutex;
-
// Initialise the desktop
desktop.setStatusLocation(&isDesktopStarted);
desktop.setQueryConnectionHandler(this);
@@ -99,15 +93,8 @@ VNCServerWin32::~VNCServerWin32() {
desktop.setStatusLocation(nullptr);
// Join the Accept/Reject dialog thread
- if (queryConnectDialog) {
- queryConnectDialog->wait();
+ if (queryConnectDialog)
delete queryConnectDialog;
- }
-
- delete runLock;
-
- delete commandSig;
- delete commandLock;
}
@@ -162,7 +149,7 @@ void VNCServerWin32::regConfigChanged() {
int VNCServerWin32::run() {
{
- AutoMutex a(runLock);
+ const std::lock_guard<std::mutex> a(runLock);
thread_id = GetCurrentThreadId();
runServer = true;
}
@@ -208,7 +195,7 @@ int VNCServerWin32::run() {
}
{
- AutoMutex a(runLock);
+ const std::lock_guard<std::mutex> a(runLock);
runServer = false;
thread_id = (DWORD)-1;
}
@@ -217,7 +204,7 @@ int VNCServerWin32::run() {
}
void VNCServerWin32::stop() {
- AutoMutex a(runLock);
+ const std::lock_guard<std::mutex> a(runLock);
runServer = false;
if (thread_id != (DWORD)-1)
PostThreadMessage(thread_id, WM_QUIT, 0, 0);
@@ -274,17 +261,17 @@ void VNCServerWin32::queryConnectionComplete() {
bool VNCServerWin32::queueCommand(Command cmd, const void* data, int len, bool wait) {
- AutoMutex a(commandLock);
+ std::unique_lock<std::mutex> lock(commandLock);
while (command != NoCommand)
- commandSig->wait();
+ commandSig.wait(lock);
command = cmd;
commandData = data;
commandDataLen = len;
SetEvent(commandEvent);
if (wait) {
while (command != NoCommand)
- commandSig->wait();
- commandSig->signal();
+ commandSig.wait(lock);
+ commandSig.notify_one();
}
return true;
}
@@ -295,7 +282,7 @@ void VNCServerWin32::processEvent(HANDLE event_) {
if (event_ == commandEvent.h) {
// If there is no command queued then return immediately
{
- AutoMutex a(commandLock);
+ const std::lock_guard<std::mutex> a(commandLock);
if (command == NoCommand)
return;
}
@@ -325,7 +312,6 @@ void VNCServerWin32::processEvent(HANDLE event_) {
vncServer.approveConnection(queryConnectDialog->getSock(),
queryConnectDialog->isAccepted(),
"Connection rejected by user");
- queryConnectDialog->wait();
delete queryConnectDialog;
queryConnectDialog = nullptr;
break;
@@ -336,9 +322,9 @@ void VNCServerWin32::processEvent(HANDLE event_) {
// Clear the command and signal completion
{
- AutoMutex a(commandLock);
+ std::unique_lock<std::mutex> lock(commandLock);
command = NoCommand;
- commandSig->signal();
+ commandSig.notify_one();
}
} else if ((event_ == sessionEvent.h) ||
(event_ == desktop.getTerminateEvent())) {
diff --git a/win/winvnc/VNCServerWin32.h b/win/winvnc/VNCServerWin32.h
index 820ac905..656e2cfa 100644
--- a/win/winvnc/VNCServerWin32.h
+++ b/win/winvnc/VNCServerWin32.h
@@ -19,6 +19,9 @@
#ifndef __VNCSERVER_WIN32_H__
#define __VNCSERVER_WIN32_H__
+#include <condition_variable>
+#include <mutex>
+
#include <winsock2.h>
#include <network/TcpSocket.h>
#include <rfb/VNCServerST.h>
@@ -29,8 +32,6 @@
#include <winvnc/ManagedListener.h>
namespace core {
- class Mutex;
- class Condition;
class Thread;
}
@@ -106,15 +107,15 @@ namespace winvnc {
Command command;
const void* commandData;
int commandDataLen;
- core::Mutex* commandLock;
- core::Condition* commandSig;
+ std::mutex commandLock;
+ std::condition_variable commandSig;
rfb::win32::Handle commandEvent;
rfb::win32::Handle sessionEvent;
// VNCServerWin32 Server-internal state
rfb::win32::SDisplay desktop;
rfb::VNCServerST vncServer;
- core::Mutex* runLock;
+ std::mutex runLock;
DWORD thread_id;
bool runServer;
bool isDesktopStarted;
diff --git a/win/winvnc/winvnc.rc b/win/winvnc/winvnc.rc
index 0c756054..acaa0dbd 100644
--- a/win/winvnc/winvnc.rc
+++ b/win/winvnc/winvnc.rc
@@ -76,7 +76,7 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "\0"
- VALUE "CompanyName", "TigerVNC project\0"
+ VALUE "CompanyName", "TigerVNC team\0"
VALUE "FileDescription", "TigerVNC server\0"
VALUE "ProductName", "TigerVNC server\0"
VALUE "FileVersion", __RCVERSIONSTR
diff --git a/win/wm_hooks/wm_hooks.rc b/win/wm_hooks/wm_hooks.rc
index ae56b314..2bf38f3d 100644
--- a/win/wm_hooks/wm_hooks.rc
+++ b/win/wm_hooks/wm_hooks.rc
@@ -72,12 +72,12 @@ BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "\0"
- VALUE "CompanyName", "TigerVNC project\0"
+ VALUE "CompanyName", "TigerVNC team\0"
VALUE "FileDescription", "TigerVNC server hooking DLL\0"
VALUE "ProductName", "TigerVNC server hooking DLL\0"
VALUE "FileVersion", __RCVERSIONSTR
VALUE "InternalName", "\0"
- VALUE "LegalCopyright", "Copyright (C) 1999-2005 [many holders]\0"
+ VALUE "LegalCopyright", "Copyright (C) 1999-2025 TigerVNC team and many others (see README.rst)\0"
VALUE "LegalTrademarks", "TigerVNC\0"
VALUE "OriginalFilename", "wm_hooks.dll\0"
VALUE "PrivateBuild", "\0"