libwinpr-wtsapi: fix WtsApi32.dll dynamic loading on Windows
This commit is contained in:
parent
ef04373628
commit
2036b443eb
@ -102,6 +102,28 @@ HANDLE freerdp_client_get_thread(rdpContext* context)
|
||||
return ((rdpClientContext*) context)->thread;
|
||||
}
|
||||
|
||||
int freerdp_client_combined_logic(rdpSettings* settings)
|
||||
{
|
||||
/* Moved GatewayUseSameCredentials logic outside of cmdline.c, so
|
||||
* that the rdp file also triggers this functionality */
|
||||
if (settings->GatewayEnabled)
|
||||
{
|
||||
if (settings->GatewayUseSameCredentials)
|
||||
{
|
||||
if (settings->Username)
|
||||
settings->GatewayUsername = _strdup(settings->Username);
|
||||
|
||||
if (settings->Domain)
|
||||
settings->GatewayDomain = _strdup(settings->Domain);
|
||||
|
||||
if (settings->Password)
|
||||
settings->GatewayPassword = _strdup(settings->Password);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv)
|
||||
{
|
||||
int status;
|
||||
@ -131,28 +153,6 @@ int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
|
||||
return status;
|
||||
}
|
||||
|
||||
int freerdp_client_combined_logic(rdpSettings* settings)
|
||||
{
|
||||
/* Moved GatewayUseSameCredentials logic outside of cmdline.c, so
|
||||
* that the rdp file also triggers this functionality */
|
||||
if (settings->GatewayEnabled)
|
||||
{
|
||||
if (settings->GatewayUseSameCredentials)
|
||||
{
|
||||
if (settings->Username)
|
||||
settings->GatewayUsername = _strdup(settings->Username);
|
||||
|
||||
if (settings->Domain)
|
||||
settings->GatewayDomain = _strdup(settings->Domain);
|
||||
|
||||
if (settings->Password)
|
||||
settings->GatewayPassword = _strdup(settings->Password);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename)
|
||||
{
|
||||
rdpFile* file;
|
||||
|
@ -44,6 +44,159 @@ static HMODULE g_WtsApiModule = NULL;
|
||||
|
||||
static PWtsApiFunctionTable g_WtsApi = NULL;
|
||||
|
||||
static HMODULE g_WtsApi32Module = NULL;
|
||||
|
||||
static WtsApiFunctionTable WtsApi32_WtsApiFunctionTable =
|
||||
{
|
||||
0, /* dwVersion */
|
||||
0, /* dwFlags */
|
||||
|
||||
NULL, /* StopRemoteControlSession */
|
||||
NULL, /* StartRemoteControlSessionW */
|
||||
NULL, /* StartRemoteControlSessionA */
|
||||
NULL, /* ConnectSessionW */
|
||||
NULL, /* ConnectSessionA */
|
||||
NULL, /* EnumerateServersW */
|
||||
NULL, /* EnumerateServersA */
|
||||
NULL, /* OpenServerW */
|
||||
NULL, /* OpenServerA */
|
||||
NULL, /* OpenServerExW */
|
||||
NULL, /* OpenServerExA */
|
||||
NULL, /* CloseServer */
|
||||
NULL, /* EnumerateSessionsW */
|
||||
NULL, /* EnumerateSessionsA */
|
||||
NULL, /* EnumerateSessionsExW */
|
||||
NULL, /* EnumerateSessionsExA */
|
||||
NULL, /* EnumerateProcessesW */
|
||||
NULL, /* EnumerateProcessesA */
|
||||
NULL, /* TerminateProcess */
|
||||
NULL, /* QuerySessionInformationW */
|
||||
NULL, /* QuerySessionInformationA */
|
||||
NULL, /* QueryUserConfigW */
|
||||
NULL, /* QueryUserConfigA */
|
||||
NULL, /* SetUserConfigW */
|
||||
NULL, /* SetUserConfigA */
|
||||
NULL, /* SendMessageW */
|
||||
NULL, /* SendMessageA */
|
||||
NULL, /* DisconnectSession */
|
||||
NULL, /* LogoffSession */
|
||||
NULL, /* ShutdownSystem */
|
||||
NULL, /* WaitSystemEvent */
|
||||
NULL, /* VirtualChannelOpen */
|
||||
NULL, /* VirtualChannelOpenEx */
|
||||
NULL, /* VirtualChannelClose */
|
||||
NULL, /* VirtualChannelRead */
|
||||
NULL, /* VirtualChannelWrite */
|
||||
NULL, /* VirtualChannelPurgeInput */
|
||||
NULL, /* VirtualChannelPurgeOutput */
|
||||
NULL, /* VirtualChannelQuery */
|
||||
NULL, /* FreeMemory */
|
||||
NULL, /* RegisterSessionNotification */
|
||||
NULL, /* UnRegisterSessionNotification */
|
||||
NULL, /* RegisterSessionNotificationEx */
|
||||
NULL, /* UnRegisterSessionNotificationEx */
|
||||
NULL, /* QueryUserToken */
|
||||
NULL, /* FreeMemoryExW */
|
||||
NULL, /* FreeMemoryExA */
|
||||
NULL, /* EnumerateProcessesExW */
|
||||
NULL, /* EnumerateProcessesExA */
|
||||
NULL, /* EnumerateListenersW */
|
||||
NULL, /* EnumerateListenersA */
|
||||
NULL, /* QueryListenerConfigW */
|
||||
NULL, /* QueryListenerConfigA */
|
||||
NULL, /* CreateListenerW */
|
||||
NULL, /* CreateListenerA */
|
||||
NULL, /* SetListenerSecurityW */
|
||||
NULL, /* SetListenerSecurityA */
|
||||
NULL, /* GetListenerSecurityW */
|
||||
NULL, /* GetListenerSecurityA */
|
||||
NULL, /* EnableChildSessions */
|
||||
NULL, /* IsChildSessionsEnabled */
|
||||
NULL, /* GetChildSessionId */
|
||||
NULL /* GetActiveConsoleSessionId */
|
||||
};
|
||||
|
||||
#define WTSAPI32_LOAD_PROC(_name, _type) \
|
||||
WtsApi32_WtsApiFunctionTable.p ## _name = (## _type) GetProcAddress(g_WtsApi32Module, "WTS" #_name);
|
||||
|
||||
int WtsApi32_InitializeWtsApi(void)
|
||||
{
|
||||
g_WtsApi32Module = LoadLibraryA("wtsapi32.dll");
|
||||
|
||||
if (!g_WtsApi32Module)
|
||||
return -1;
|
||||
|
||||
WTSAPI32_LOAD_PROC(StopRemoteControlSession, WTS_STOP_REMOTE_CONTROL_SESSION_FN);
|
||||
WTSAPI32_LOAD_PROC(StartRemoteControlSessionW, WTS_START_REMOTE_CONTROL_SESSION_FN_W);
|
||||
WTSAPI32_LOAD_PROC(StartRemoteControlSessionA, WTS_START_REMOTE_CONTROL_SESSION_FN_A);
|
||||
WTSAPI32_LOAD_PROC(ConnectSessionW, WTS_CONNECT_SESSION_FN_W);
|
||||
WTSAPI32_LOAD_PROC(ConnectSessionA, WTS_CONNECT_SESSION_FN_A);
|
||||
WTSAPI32_LOAD_PROC(EnumerateServersW, WTS_ENUMERATE_SERVERS_FN_W);
|
||||
WTSAPI32_LOAD_PROC(EnumerateServersA, WTS_ENUMERATE_SERVERS_FN_A);
|
||||
WTSAPI32_LOAD_PROC(OpenServerW, WTS_OPEN_SERVER_FN_W);
|
||||
WTSAPI32_LOAD_PROC(OpenServerA, WTS_OPEN_SERVER_FN_A);
|
||||
WTSAPI32_LOAD_PROC(OpenServerExW, WTS_OPEN_SERVER_EX_FN_W);
|
||||
WTSAPI32_LOAD_PROC(OpenServerExA, WTS_OPEN_SERVER_EX_FN_A);
|
||||
WTSAPI32_LOAD_PROC(CloseServer, WTS_CLOSE_SERVER_FN);
|
||||
WTSAPI32_LOAD_PROC(EnumerateSessionsW, WTS_ENUMERATE_SESSIONS_FN_W);
|
||||
WTSAPI32_LOAD_PROC(EnumerateSessionsA, WTS_ENUMERATE_SESSIONS_FN_A);
|
||||
WTSAPI32_LOAD_PROC(EnumerateSessionsExW, WTS_ENUMERATE_SESSIONS_EX_FN_W);
|
||||
WTSAPI32_LOAD_PROC(EnumerateSessionsExA, WTS_ENUMERATE_SESSIONS_EX_FN_A);
|
||||
WTSAPI32_LOAD_PROC(EnumerateProcessesW, WTS_ENUMERATE_PROCESSES_FN_W);
|
||||
WTSAPI32_LOAD_PROC(EnumerateProcessesA, WTS_ENUMERATE_PROCESSES_FN_A);
|
||||
WTSAPI32_LOAD_PROC(TerminateProcess, WTS_TERMINATE_PROCESS_FN);
|
||||
WTSAPI32_LOAD_PROC(QuerySessionInformationW, WTS_QUERY_SESSION_INFORMATION_FN_W);
|
||||
WTSAPI32_LOAD_PROC(QuerySessionInformationA, WTS_QUERY_SESSION_INFORMATION_FN_A);
|
||||
WTSAPI32_LOAD_PROC(QueryUserConfigW, WTS_QUERY_USER_CONFIG_FN_W);
|
||||
WTSAPI32_LOAD_PROC(QueryUserConfigA, WTS_QUERY_USER_CONFIG_FN_A);
|
||||
WTSAPI32_LOAD_PROC(SetUserConfigW, WTS_SET_USER_CONFIG_FN_W);
|
||||
WTSAPI32_LOAD_PROC(SetUserConfigA, WTS_SET_USER_CONFIG_FN_A);
|
||||
WTSAPI32_LOAD_PROC(SendMessageW, WTS_SEND_MESSAGE_FN_W);
|
||||
WTSAPI32_LOAD_PROC(SendMessageA, WTS_SEND_MESSAGE_FN_A);
|
||||
WTSAPI32_LOAD_PROC(DisconnectSession, WTS_DISCONNECT_SESSION_FN);
|
||||
WTSAPI32_LOAD_PROC(LogoffSession, WTS_LOGOFF_SESSION_FN);
|
||||
WTSAPI32_LOAD_PROC(ShutdownSystem, WTS_SHUTDOWN_SYSTEM_FN);
|
||||
WTSAPI32_LOAD_PROC(WaitSystemEvent, WTS_WAIT_SYSTEM_EVENT_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelOpen, WTS_VIRTUAL_CHANNEL_OPEN_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelOpenEx, WTS_VIRTUAL_CHANNEL_OPEN_EX_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelClose, WTS_VIRTUAL_CHANNEL_CLOSE_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelRead, WTS_VIRTUAL_CHANNEL_READ_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelWrite, WTS_VIRTUAL_CHANNEL_WRITE_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelPurgeInput, WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelPurgeOutput, WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN);
|
||||
WTSAPI32_LOAD_PROC(VirtualChannelQuery, WTS_VIRTUAL_CHANNEL_QUERY_FN);
|
||||
WTSAPI32_LOAD_PROC(FreeMemory, WTS_FREE_MEMORY_FN);
|
||||
WTSAPI32_LOAD_PROC(RegisterSessionNotification, WTS_REGISTER_SESSION_NOTIFICATION_FN);
|
||||
WTSAPI32_LOAD_PROC(UnRegisterSessionNotification, WTS_UNREGISTER_SESSION_NOTIFICATION_FN);
|
||||
WTSAPI32_LOAD_PROC(RegisterSessionNotificationEx, WTS_REGISTER_SESSION_NOTIFICATION_EX_FN);
|
||||
WTSAPI32_LOAD_PROC(UnRegisterSessionNotificationEx, WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN);
|
||||
WTSAPI32_LOAD_PROC(QueryUserToken, WTS_QUERY_USER_TOKEN_FN);
|
||||
WTSAPI32_LOAD_PROC(FreeMemoryExW, WTS_FREE_MEMORY_EX_FN_W);
|
||||
WTSAPI32_LOAD_PROC(FreeMemoryExA, WTS_FREE_MEMORY_EX_FN_A);
|
||||
WTSAPI32_LOAD_PROC(EnumerateProcessesExW, WTS_ENUMERATE_PROCESSES_EX_FN_W);
|
||||
WTSAPI32_LOAD_PROC(EnumerateProcessesExA, WTS_ENUMERATE_PROCESSES_EX_FN_A);
|
||||
WTSAPI32_LOAD_PROC(EnumerateListenersW, WTS_ENUMERATE_LISTENERS_FN_W);
|
||||
WTSAPI32_LOAD_PROC(EnumerateListenersA, WTS_ENUMERATE_LISTENERS_FN_A);
|
||||
WTSAPI32_LOAD_PROC(QueryListenerConfigW, WTS_QUERY_LISTENER_CONFIG_FN_W);
|
||||
WTSAPI32_LOAD_PROC(QueryListenerConfigA, WTS_QUERY_LISTENER_CONFIG_FN_A);
|
||||
WTSAPI32_LOAD_PROC(CreateListenerW, WTS_CREATE_LISTENER_FN_W);
|
||||
WTSAPI32_LOAD_PROC(CreateListenerA, WTS_CREATE_LISTENER_FN_A);
|
||||
WTSAPI32_LOAD_PROC(SetListenerSecurityW, WTS_SET_LISTENER_SECURITY_FN_W);
|
||||
WTSAPI32_LOAD_PROC(SetListenerSecurityA, WTS_SET_LISTENER_SECURITY_FN_A);
|
||||
WTSAPI32_LOAD_PROC(GetListenerSecurityW, WTS_GET_LISTENER_SECURITY_FN_W);
|
||||
WTSAPI32_LOAD_PROC(GetListenerSecurityA, WTS_GET_LISTENER_SECURITY_FN_A);
|
||||
WTSAPI32_LOAD_PROC(EnableChildSessions, WTS_ENABLE_CHILD_SESSIONS_FN);
|
||||
WTSAPI32_LOAD_PROC(IsChildSessionsEnabled, WTS_IS_CHILD_SESSIONS_ENABLED_FN);
|
||||
WTSAPI32_LOAD_PROC(GetChildSessionId, WTS_GET_CHILD_SESSION_ID_FN);
|
||||
WTSAPI32_LOAD_PROC(GetActiveConsoleSessionId, WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN);
|
||||
|
||||
g_WtsApi = &WtsApi32_WtsApiFunctionTable;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* WtsApi Functions */
|
||||
|
||||
BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId, BYTE HotkeyVk, USHORT HotkeyModifiers)
|
||||
{
|
||||
WTSAPI_STUB_CALL_BOOL(StartRemoteControlSessionW, pTargetServerName, TargetLogonId, HotkeyVk, HotkeyModifiers);
|
||||
@ -432,11 +585,13 @@ void InitializeWtsApiStubs_Env()
|
||||
|
||||
env = (LPSTR) malloc(nSize);
|
||||
nSize = GetEnvironmentVariableA("WTSAPI_LIBRARY", env, nSize);
|
||||
|
||||
if (env)
|
||||
LoadAndInitialize(env);
|
||||
}
|
||||
|
||||
#define FREERDS_LIBRARY_NAME "libfreerds-fdsapi.so"
|
||||
|
||||
void InitializeWtsApiStubs_FreeRDS()
|
||||
{
|
||||
char* prefix;
|
||||
@ -490,6 +645,10 @@ void InitializeWtsApiStubs(void)
|
||||
|
||||
InitializeWtsApiStubs_Env();
|
||||
|
||||
#ifdef _WIN32
|
||||
WtsApi32_InitializeWtsApi();
|
||||
#endif
|
||||
|
||||
if (!g_WtsApi)
|
||||
InitializeWtsApiStubs_FreeRDS();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user