From 0812a8e9fcf197eca618992b588272bc3677a031 Mon Sep 17 00:00:00 2001 From: Corey C Date: Tue, 19 Mar 2013 15:19:26 -0400 Subject: [PATCH 1/4] wfreerdp-server: fixed mirror driver unloading issue --- server/Windows/wf_mirage.c | 40 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/server/Windows/wf_mirage.c b/server/Windows/wf_mirage.c index c81825f21..d9f3b49ab 100644 --- a/server/Windows/wf_mirage.c +++ b/server/Windows/wf_mirage.c @@ -187,29 +187,7 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) LONG disp_change_status; DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE; - if (mode == MIRROR_LOAD) - { - //first let's get the virtual screen dimentions - wfi->virtscreen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); - wfi->virtscreen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); - - /* - * Will have to come back to this for supporting non primary displays and multimonitor setups - */ - /*dc = GetDC(NULL); - wfi->servscreen_width = GetDeviceCaps(dc, HORZRES); - wfi->servscreen_height = GetDeviceCaps(dc, VERTRES); - wfi->bitsPerPixel = GetDeviceCaps(dc, BITSPIXEL); - ReleaseDC(NULL, dc);*/ - - } - else if (mode == MIRROR_UNLOAD) - { - wfi->servscreen_width = 0; - wfi->servscreen_height = 0; - wfi->bitsPerPixel = 0; - } - else + if ( (mode != MIRROR_LOAD) && (mode != MIRROR_UNLOAD) ) { printf("Invalid mirror mode!\n"); return FALSE; @@ -227,11 +205,17 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) deviceMode->dmSize = sizeof(DEVMODE); deviceMode->dmDriverExtra = drvExtraSaved; - deviceMode->dmPelsWidth = wfi->virtscreen_width; - deviceMode->dmPelsHeight = wfi->virtscreen_height; - deviceMode->dmBitsPerPel = wfi->bitsPerPixel; - deviceMode->dmPosition.x = wfi->servscreen_xoffset; - deviceMode->dmPosition.y = wfi->servscreen_yoffset; + if (mode == MIRROR_LOAD) + { + wfi->virtscreen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + wfi->virtscreen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); + + deviceMode->dmPelsWidth = wfi->virtscreen_width; + deviceMode->dmPelsHeight = wfi->virtscreen_height; + deviceMode->dmBitsPerPel = wfi->bitsPerPixel; + deviceMode->dmPosition.x = wfi->servscreen_xoffset; + deviceMode->dmPosition.y = wfi->servscreen_yoffset; + } deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION; From 65577d138e516725290571ada000d941faed9754 Mon Sep 17 00:00:00 2001 From: Florian Holzapfel Date: Wed, 20 Mar 2013 14:16:09 +0100 Subject: [PATCH 2/4] fix some memory leaks on iOS --- client/iOS/Controllers/AboutController.m | 2 +- client/iOS/Controllers/AppSettingsController.m | 2 +- client/iOS/Controllers/BookmarkListController.m | 12 ++++++++---- client/iOS/Controllers/HelpController.m | 2 +- client/iOS/Models/Encryptor.m | 2 ++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/client/iOS/Controllers/AboutController.m b/client/iOS/Controllers/AboutController.m index fe4ba3189..a30bb40ba 100644 --- a/client/iOS/Controllers/AboutController.m +++ b/client/iOS/Controllers/AboutController.m @@ -19,7 +19,7 @@ // set title and tab-bar image [self setTitle:NSLocalizedString(@"About", @"About Controller title")]; UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about" ofType:@"png"]]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"About", @"Tabbar item about") image:tabBarIcon tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"About", @"Tabbar item about") image:tabBarIcon tag:0] autorelease]]; last_link_clicked = nil; } diff --git a/client/iOS/Controllers/AppSettingsController.m b/client/iOS/Controllers/AppSettingsController.m index 5eaa75807..90b58dbb6 100644 --- a/client/iOS/Controllers/AppSettingsController.m +++ b/client/iOS/Controllers/AppSettingsController.m @@ -27,7 +27,7 @@ if ((self = [super initWithStyle:style])) { UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_settings" ofType:@"png"]]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings") image:tabBarIcon tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings") image:tabBarIcon tag:0] autorelease]]; } return self; } diff --git a/client/iOS/Controllers/BookmarkListController.m b/client/iOS/Controllers/BookmarkListController.m index 301bd5f5d..b3f43c732 100644 --- a/client/iOS/Controllers/BookmarkListController.m +++ b/client/iOS/Controllers/BookmarkListController.m @@ -59,7 +59,7 @@ // set title and tabbar controller image [self setTitle:NSLocalizedString(@"Connections", @"'Connections': bookmark controller title")]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0] autorelease]]; // load images _star_on_img = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_accessory_star_on" ofType:@"png"]] retain]; @@ -151,6 +151,9 @@ [_manual_search_result release]; [_manual_bookmarks release]; [_tsxconnect_bookmarks release]; + + [_star_on_img release]; + [_star_off_img release]; [super dealloc]; } @@ -451,7 +454,7 @@ { // resume session RDPSession* session = [_active_sessions objectAtIndex:[indexPath row]]; - UIViewController* ctrl = [[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session]; + UIViewController* ctrl = [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session] autorelease]; [ctrl setHidesBottomBarWhenPushed:YES]; [[self navigationController] pushViewController:ctrl animated:YES]; } @@ -466,7 +469,8 @@ if ([[_searchBar text] length] == 0) { // show add bookmark controller - BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:[[ComputerBookmark alloc] initWithBaseDefaultParameters]] autorelease]; + ComputerBookmark *bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease]; + BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease]; [bookmarkEditorController setTitle:NSLocalizedString(@"Add Connection", @"Add Connection title")]; [bookmarkEditorController setDelegate:self]; [bookmarkEditorController setHidesBottomBarWhenPushed:YES]; @@ -509,7 +513,7 @@ { // create rdp session RDPSession* session = [[[RDPSession alloc] initWithBookmark:bookmark] autorelease]; - UIViewController* ctrl = [[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session]; + UIViewController* ctrl = [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session] autorelease]; [ctrl setHidesBottomBarWhenPushed:YES]; [[self navigationController] pushViewController:ctrl animated:YES]; [_active_sessions addObject:session]; diff --git a/client/iOS/Controllers/HelpController.m b/client/iOS/Controllers/HelpController.m index 61a05a46c..5ed3bc90b 100644 --- a/client/iOS/Controllers/HelpController.m +++ b/client/iOS/Controllers/HelpController.m @@ -19,7 +19,7 @@ // set title and tab-bar image [self setTitle:NSLocalizedString(@"Help", @"Help Controller title")]; UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_help" ofType:@"png"]]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help") image:tabBarIcon tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help") image:tabBarIcon tag:0] autorelease]]; } return self; } diff --git a/client/iOS/Models/Encryptor.m b/client/iOS/Models/Encryptor.m index eae578e12..112572218 100644 --- a/client/iOS/Models/Encryptor.m +++ b/client/iOS/Models/Encryptor.m @@ -51,6 +51,7 @@ if (ret) { NSLog(@"%s: CCKeyDerivationPBKDF ret == %d, indicating some sort of failure.", __func__, ret); + free(derived_key); [self autorelease]; return nil; } @@ -64,6 +65,7 @@ if (ret != 1) { NSLog(@"%s: PKCS5_PBKDF2_HMAC_SHA1 ret == %lu, indicating some sort of failure.", __func__, ret); + free(derived_key); [self release]; return nil; } From bf7a370760eb7d9fda4c97ced226be01a8e0590e Mon Sep 17 00:00:00 2001 From: Corey C Date: Thu, 21 Mar 2013 16:31:55 -0400 Subject: [PATCH 3/4] wfreerdp-server: Fixed screen detection issue and home directory issue --- server/Windows/cli/wfreerdp.c | 34 ++++++++++++++++++++++++++++++++++ server/Windows/wf_interface.c | 2 +- server/Windows/wf_mirage.c | 2 +- server/Windows/wf_peer.c | 9 +++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/server/Windows/cli/wfreerdp.c b/server/Windows/cli/wfreerdp.c index c7aba35fd..43e4e3ef1 100644 --- a/server/Windows/cli/wfreerdp.c +++ b/server/Windows/cli/wfreerdp.c @@ -52,6 +52,7 @@ BOOL CALLBACK moncb(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARA int main(int argc, char* argv[]) { + BOOL screen_selected = FALSE; int index; wfServer* server; @@ -108,6 +109,7 @@ int main(int argc, char* argv[]) if (strcmp("--screen", argv[index]) == 0) { + screen_selected = TRUE; index++; if (index == argc) { @@ -127,6 +129,38 @@ int main(int argc, char* argv[]) } } + if (screen_selected == FALSE) + { + _TCHAR name[128]; + int width; + int height; + int bpp; + int i; + + _tprintf(_T("screen id not provided. attempting to detect...\n")); + _tprintf(_T("Detecting screens...\n")); + _tprintf(_T("\nID\tResolution\t\tName (Interface)\n\n")); + + for (i=0; ; i++) + { + if (get_screen_info(i, name, &width, &height, &bpp) != 0) + { + if ( (width * height * bpp) == 0 ) + continue; + + _tprintf(_T("%d\t%dx%dx%d\t"), i, width, height, bpp); + _tprintf(_T("%s\n"), name); + set_screen_id(i); + break; + } + else + { + break; + } + } + } + + printf("Starting server\n"); wfreerdp_server_start(server); diff --git a/server/Windows/wf_interface.c b/server/Windows/wf_interface.c index 9889e398e..724f74c2a 100644 --- a/server/Windows/wf_interface.c +++ b/server/Windows/wf_interface.c @@ -50,7 +50,7 @@ int get_screen_info(int id, _TCHAR* name, int* width, int* height, int* bpp) if (name != NULL) _stprintf(name, _T("%s (%s)"), dd.DeviceName, dd.DeviceString); - dc = CreateDC(NULL, dd.DeviceName, NULL, NULL); + dc = CreateDC(dd.DeviceName, NULL, NULL, NULL); *width = GetDeviceCaps(dc, HORZRES); *height = GetDeviceCaps(dc, VERTRES); *bpp = GetDeviceCaps(dc, BITSPIXEL); diff --git a/server/Windows/wf_mirage.c b/server/Windows/wf_mirage.c index d9f3b49ab..29f131e31 100644 --- a/server/Windows/wf_mirage.c +++ b/server/Windows/wf_mirage.c @@ -186,7 +186,7 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) DEVMODE* deviceMode; LONG disp_change_status; DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE; - + if ( (mode != MIRROR_LOAD) && (mode != MIRROR_UNLOAD) ) { printf("Invalid mirror mode!\n"); diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index 42b6f2c20..695e1b5ce 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -85,6 +85,7 @@ BOOL wf_peer_post_connect(freerdp_peer* client) (wfi->bitsPerPixel == 0) ) { _tprintf(_T("postconnect: error getting screen info for screen %d\n"), wfi->screenID); + _tprintf(_T("\t%dx%dx%d\n"), wfi->servscreen_height, wfi->servscreen_width, wfi->bitsPerPixel); return FALSE; } @@ -224,6 +225,14 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) wfPeerContext* context; freerdp_peer* client = (freerdp_peer*) lpParam; + if (!getenv("HOME")) + { + char home[MAX_PATH * 2] = "HOME="; + strcat(home, getenv("HOMEDRIVE")); + strcat(home, getenv("HOMEPATH")); + _putenv(home); + } + wf_peer_init(client); settings = client->settings; From 1964a2e4f17955dc2f0c102f662806de86a03449 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Thu, 21 Mar 2013 15:13:33 -0700 Subject: [PATCH 4/4] include/winpr/synch.h: add missing extern C decl. --- winpr/include/winpr/synch.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winpr/include/winpr/synch.h b/winpr/include/winpr/synch.h index e0bf0eed7..dd9bd13b4 100644 --- a/winpr/include/winpr/synch.h +++ b/winpr/include/winpr/synch.h @@ -29,6 +29,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef _WIN32 /* Mutex */ @@ -271,5 +275,9 @@ WINPR_API HANDLE CreateWaitObjectEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, WINPR_API int GetEventFileDescriptor(HANDLE hEvent); WINPR_API void* GetEventWaitObject(HANDLE hEvent); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_SYNCH_H */