Remove legacy Windows code
We have lots of code that deals with Windows versions that we no
longer support anyway. Clean out all of this old cruft.
diff --git a/win/rfb_win32/TsSessions.cxx b/win/rfb_win32/TsSessions.cxx
index b02f619..6d16adb 100644
--- a/win/rfb_win32/TsSessions.cxx
+++ b/win/rfb_win32/TsSessions.cxx
@@ -17,50 +17,28 @@
*/
#include <rfb_win32/TsSessions.h>
-#include <rfb_win32/DynamicFn.h>
#include <rfb/LogWriter.h>
#include <rdr/Exception.h>
#include <tchar.h>
-
-#ifdef ERROR_CTX_WINSTATION_BUSY
-#define RFB_HAVE_WINSTATION_CONNECT
-#else
-#pragma message(" NOTE: Not building WinStationConnect support.")
-#endif
+#include <wtsapi32.h>
static rfb::LogWriter vlog("TsSessions");
namespace rfb {
namespace win32 {
- // Windows XP (and later) functions used to handle session Ids
- typedef BOOLEAN (WINAPI *_WinStationConnect_proto) (HANDLE,ULONG,ULONG,PCWSTR,ULONG);
- DynamicFn<_WinStationConnect_proto> _WinStationConnect(_T("winsta.dll"), "WinStationConnectW");
- typedef DWORD (WINAPI *_WTSGetActiveConsoleSessionId_proto) ();
- DynamicFn<_WTSGetActiveConsoleSessionId_proto> _WTSGetActiveConsoleSessionId(_T("kernel32.dll"), "WTSGetActiveConsoleSessionId");
- typedef BOOL (WINAPI *_ProcessIdToSessionId_proto) (DWORD, DWORD*);
- DynamicFn<_ProcessIdToSessionId_proto> _ProcessIdToSessionId(_T("kernel32.dll"), "ProcessIdToSessionId");
- typedef BOOL (WINAPI *_LockWorkStation_proto)();
- DynamicFn<_LockWorkStation_proto> _LockWorkStation(_T("user32.dll"), "LockWorkStation");
-
-
ProcessSessionId::ProcessSessionId(DWORD processId) {
id = 0;
- if (!_ProcessIdToSessionId.isValid())
- return;
if (processId == (DWORD)-1)
processId = GetCurrentProcessId();
- if (!(*_ProcessIdToSessionId)(GetCurrentProcessId(), &id))
+ if (!ProcessIdToSessionId(GetCurrentProcessId(), &id))
throw rdr::SystemException("ProcessIdToSessionId", GetLastError());
}
ProcessSessionId mySessionId;
ConsoleSessionId::ConsoleSessionId() {
- if (_WTSGetActiveConsoleSessionId.isValid())
- id = (*_WTSGetActiveConsoleSessionId)();
- else
- id = 0;
+ id = WTSGetActiveConsoleSessionId();
}
bool inConsoleSession() {
@@ -69,24 +47,17 @@
}
void setConsoleSession(DWORD sessionId) {
-#ifdef RFB_HAVE_WINSTATION_CONNECT
- if (!_WinStationConnect.isValid())
- throw rdr::Exception("WinSta APIs missing");
if (sessionId == (DWORD)-1)
sessionId = mySessionId.id;
// Try to reconnect our session to the console
ConsoleSessionId console;
vlog.info("Console session is %lu", console.id);
- if (!(*_WinStationConnect)(0, sessionId, console.id, L"", 0))
+ if (!WTSConnectSession(sessionId, console.id, (PTSTR)_T(""), 0))
throw rdr::SystemException("Unable to connect session to Console", GetLastError());
// Lock the newly connected session, for security
- if (_LockWorkStation.isValid())
- (*_LockWorkStation)();
-#else
- throw rdr::Exception("setConsoleSession not implemented");
-#endif
+ LockWorkStation();
}
};