Merge pull request #1099 from C-o-r-E/master
wfreerdp-server: stabilization of handling mirror driver on windows < 8
This commit is contained in:
commit
c885da8dec
@ -495,7 +495,6 @@ void rfx_init_sse2(RFX_CONTEXT* context)
|
||||
if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
printf("\n\nIs this causing crashes???\n\n");
|
||||
DEBUG_RFX("Using SSE2 optimizations");
|
||||
|
||||
IF_PROFILER(context->priv->prof_rfx_quantization_decode->name = "rfx_quantization_decode_sse2");
|
||||
|
@ -225,7 +225,12 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
|
||||
if (wfi->peerCount == 0)
|
||||
wf_dxgi_init(wfi);
|
||||
#else
|
||||
wf_mirror_driver_activate(wfi);
|
||||
if (wf_mirror_driver_activate(wfi) == FALSE)
|
||||
{
|
||||
context->socketClose = TRUE;
|
||||
wf_info_unlock(wfi);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
//look trhough the array of peers until an empty slot
|
||||
for(i=0; i<WF_INFO_MAXPEERS; ++i)
|
||||
|
@ -3,6 +3,7 @@
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2012-2013 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -49,7 +50,7 @@ BOOL wf_mirror_driver_find_display_device(wfInfo* wfi)
|
||||
|
||||
deviceKeyPrefixLength = _tcslen(DEVICE_KEY_PREFIX);
|
||||
|
||||
if (_tcsncmp(deviceInfo.DeviceKey, DEVICE_KEY_PREFIX, deviceKeyPrefixLength) == 0)
|
||||
if (_tcsnicmp(deviceInfo.DeviceKey, DEVICE_KEY_PREFIX, deviceKeyPrefixLength) == 0)
|
||||
{
|
||||
deviceKeyLength = _tcslen(deviceInfo.DeviceKey) - deviceKeyPrefixLength;
|
||||
wfi->deviceKey = (LPTSTR) malloc((deviceKeyLength + 1) * sizeof(TCHAR));
|
||||
@ -87,7 +88,7 @@ BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode)
|
||||
DWORD dwValue;
|
||||
|
||||
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, wfi->deviceKey,
|
||||
0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
||||
0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hKey);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
@ -99,16 +100,22 @@ BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode)
|
||||
if (status != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
if (dwValue == 1)
|
||||
if (dwValue ^ mode) //only if we want to change modes
|
||||
{
|
||||
dwValue = mode;
|
||||
dwSize = sizeof(DWORD);
|
||||
|
||||
status = RegSetValueEx(HKEY_LOCAL_MACHINE, _T("Attach.ToDesktop"),
|
||||
status = RegSetValueEx(hKey, _T("Attach.ToDesktop"),
|
||||
0, REG_DWORD, (BYTE*) &dwValue, dwSize);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
printf("Error writing registry key: %d ", status);
|
||||
if (status == ERROR_ACCESS_DENIED)
|
||||
printf("access denied. Do you have admin privleges?");
|
||||
printf("\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -167,10 +174,10 @@ void wf_mirror_driver_print_display_change_status(LONG status)
|
||||
* This function will attempt to apply the currently configured display settings
|
||||
* in the registry to the display driver. It will return TRUE if successful
|
||||
* otherwise it returns FALSE.
|
||||
* If unload is nonzero then the the driver will be asked to remove itself.
|
||||
* If mode is MIRROR_UNLOAD then the the driver will be asked to remove itself.
|
||||
*/
|
||||
|
||||
BOOL wf_mirror_driver_update(wfInfo* wfi, int unload)
|
||||
BOOL wf_mirror_driver_update(wfInfo* wfi, int mode)
|
||||
{
|
||||
HDC dc;
|
||||
BOOL status;
|
||||
@ -180,7 +187,7 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int unload)
|
||||
LONG disp_change_status;
|
||||
DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE;
|
||||
|
||||
if (!unload)
|
||||
if (mode == MIRROR_LOAD)
|
||||
{
|
||||
//first let's get the virtual screen dimentions
|
||||
wfi->virtscreen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
@ -196,12 +203,17 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int unload)
|
||||
ReleaseDC(NULL, dc);*/
|
||||
|
||||
}
|
||||
else
|
||||
else if (mode == MIRROR_UNLOAD)
|
||||
{
|
||||
wfi->servscreen_width = 0;
|
||||
wfi->servscreen_height = 0;
|
||||
wfi->bitsPerPixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid mirror mode!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
deviceMode = (DEVMODE*) malloc(sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX);
|
||||
deviceMode->dmDriverExtra = 2 * sizeof(DWORD);
|
||||
@ -238,13 +250,12 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int unload)
|
||||
BOOL wf_mirror_driver_map_memory(wfInfo* wfi)
|
||||
{
|
||||
int status;
|
||||
GETCHANGESBUF* b;
|
||||
|
||||
wfi->driverDC = CreateDC(wfi->deviceName, NULL, NULL, NULL);
|
||||
|
||||
if (wfi->driverDC == NULL)
|
||||
{
|
||||
_tprintf(_T("Could not create device driver wfi!\n"));
|
||||
_tprintf(_T("Could not create device driver context!\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -256,10 +267,9 @@ BOOL wf_mirror_driver_map_memory(wfInfo* wfi)
|
||||
if (status <= 0)
|
||||
{
|
||||
_tprintf(_T("Failed to map shared memory from the driver! code %d\n"), status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
b = (GETCHANGESBUF*) wfi->changeBuffer;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -291,18 +301,39 @@ BOOL wf_mirror_driver_cleanup(wfInfo* wfi)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wf_mirror_driver_activate(wfInfo* wfi)
|
||||
BOOL wf_mirror_driver_activate(wfInfo* wfi)
|
||||
{
|
||||
if (!wfi->mirrorDriverActive)
|
||||
{
|
||||
printf("Activating Mirror Driver\n");
|
||||
|
||||
wf_mirror_driver_find_display_device(wfi);
|
||||
wf_mirror_driver_display_device_attach(wfi, 1);
|
||||
wf_mirror_driver_update(wfi, FALSE);
|
||||
wf_mirror_driver_map_memory(wfi);
|
||||
if (wf_mirror_driver_find_display_device(wfi) == FALSE)
|
||||
{
|
||||
printf("Could not find dfmirage mirror driver! Is it installed?\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (wf_mirror_driver_display_device_attach(wfi, 1) == FALSE)
|
||||
{
|
||||
printf("Could not attach display device!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (wf_mirror_driver_update(wfi, MIRROR_LOAD) == FALSE)
|
||||
{
|
||||
printf("could not update system with new display settings!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (wf_mirror_driver_map_memory(wfi) == FALSE)
|
||||
{
|
||||
printf("Unable to map memory for mirror driver!\n");
|
||||
return FALSE;
|
||||
}
|
||||
wfi->mirrorDriverActive = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wf_mirror_driver_deactivate(wfInfo* wfi)
|
||||
@ -313,7 +344,7 @@ void wf_mirror_driver_deactivate(wfInfo* wfi)
|
||||
|
||||
wf_mirror_driver_cleanup(wfi);
|
||||
wf_mirror_driver_display_device_attach(wfi, 0);
|
||||
wf_mirror_driver_update(wfi, 1);
|
||||
wf_mirror_driver_update(wfi, MIRROR_UNLOAD);
|
||||
wfi->mirrorDriverActive = FALSE;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
* FreeRDP Windows Server
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2012-2013 Corey Clayton <can.of.tuna@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,6 +23,14 @@
|
||||
|
||||
#include "wf_interface.h"
|
||||
|
||||
enum
|
||||
{
|
||||
MIRROR_LOAD = 0,
|
||||
MIRROR_UNLOAD = 1
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
DMF_ESCAPE_BASE_1_VB = 1030,
|
||||
@ -202,11 +211,11 @@ typedef struct
|
||||
|
||||
BOOL wf_mirror_driver_find_display_device(wfInfo* wfi);
|
||||
BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode);
|
||||
BOOL wf_mirror_driver_update(wfInfo* wfi, int unload);
|
||||
BOOL wf_mirror_driver_update(wfInfo* wfi, int mode);
|
||||
BOOL wf_mirror_driver_map_memory(wfInfo* wfi);
|
||||
BOOL wf_mirror_driver_cleanup(wfInfo* wfi);
|
||||
|
||||
void wf_mirror_driver_activate(wfInfo* wfi);
|
||||
BOOL wf_mirror_driver_activate(wfInfo* wfi);
|
||||
void wf_mirror_driver_deactivate(wfInfo* wfi);
|
||||
|
||||
#endif /* WF_MIRAGE_H */
|
||||
|
@ -51,7 +51,6 @@ void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context)
|
||||
|
||||
if (context->rdpsnd)
|
||||
{
|
||||
printf("snd_free\n");
|
||||
wf_rdpsnd_lock();
|
||||
context->info->snd_stop = TRUE;
|
||||
rdpsnd_server_context_free(context->rdpsnd);
|
||||
@ -80,8 +79,7 @@ BOOL wf_peer_post_connect(freerdp_peer* client)
|
||||
wfi = context->info;
|
||||
settings = client->settings;
|
||||
|
||||
if (
|
||||
(get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) ||
|
||||
if ( (get_screen_info(wfi->screenID, NULL, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) ||
|
||||
(wfi->servscreen_width == 0) ||
|
||||
(wfi->servscreen_height == 0) ||
|
||||
(wfi->bitsPerPixel == 0) )
|
||||
@ -92,8 +90,10 @@ BOOL wf_peer_post_connect(freerdp_peer* client)
|
||||
|
||||
if ((settings->DesktopWidth != wfi->servscreen_width) || (settings->DesktopHeight != wfi->servscreen_height))
|
||||
{
|
||||
/*
|
||||
printf("Client requested resolution %dx%d, but will resize to %dx%d\n",
|
||||
settings->DesktopWidth, settings->DesktopHeight, wfi->servscreen_width, wfi->servscreen_height);
|
||||
*/
|
||||
|
||||
settings->DesktopWidth = wfi->servscreen_width;
|
||||
settings->DesktopHeight = wfi->servscreen_height;
|
||||
@ -121,8 +121,6 @@ BOOL wf_peer_activate(freerdp_peer* client)
|
||||
wfInfo* wfi;
|
||||
wfPeerContext* context = (wfPeerContext*) client->context;
|
||||
|
||||
printf("PeerActivate\n");
|
||||
|
||||
wfi = context->info;
|
||||
client->activated = TRUE;
|
||||
wf_update_peer_activate(wfi, context);
|
||||
@ -134,14 +132,13 @@ BOOL wf_peer_activate(freerdp_peer* client)
|
||||
|
||||
BOOL wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic)
|
||||
{
|
||||
printf("PeerLogon\n");
|
||||
|
||||
/*
|
||||
if (automatic)
|
||||
{
|
||||
_tprintf(_T("Logon: User:%s Domain:%s Password:%s\n"),
|
||||
identity->User, identity->Domain, identity->Password);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH);
|
||||
return TRUE;
|
||||
@ -170,15 +167,13 @@ DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam)
|
||||
ZeroMemory(rfds, sizeof(rfds));
|
||||
context = (wfPeerContext*) client->context;
|
||||
|
||||
printf("PeerSocketListener\n");
|
||||
|
||||
while (1)
|
||||
{
|
||||
rcount = 0;
|
||||
|
||||
if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE)
|
||||
{
|
||||
printf("Failed to get peer file descriptor\n");
|
||||
//printf("Failed to get peer file descriptor\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -207,8 +202,6 @@ DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Exiting Peer Socket Listener Thread\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -268,15 +261,12 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
|
||||
}
|
||||
|
||||
context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
printf("socketEvent created\n");
|
||||
|
||||
|
||||
context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL);
|
||||
|
||||
printf("We've got a client %s\n", client->local ? "(local)" : client->hostname);
|
||||
|
||||
printf("Setting Handles\n");
|
||||
|
||||
nCount = 0;
|
||||
handles[nCount++] = context->updateEvent;
|
||||
handles[nCount++] = context->socketEvent;
|
||||
@ -304,7 +294,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
|
||||
{
|
||||
if (client->CheckFileDescriptor(client) != TRUE)
|
||||
{
|
||||
printf("Failed to check peer file descriptor\n");
|
||||
//printf("Failed to check peer file descriptor\n");
|
||||
context->socketClose = TRUE;
|
||||
}
|
||||
|
||||
@ -342,7 +332,5 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
|
||||
freerdp_peer_context_free(client);
|
||||
freerdp_peer_free(client);
|
||||
|
||||
printf("Exiting Peer Main Loop Thread\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user