Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(4) |
Sep
(3) |
Oct
(9) |
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(41) |
Feb
(1) |
Mar
(24) |
Apr
(5) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(20) |
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(5) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2012 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(4) |
Aug
|
Sep
(2) |
Oct
(3) |
Nov
(14) |
Dec
(2) |
2013 |
Jan
(6) |
Feb
(3) |
Mar
(10) |
Apr
(4) |
May
|
Jun
(12) |
Jul
(2) |
Aug
(10) |
Sep
(14) |
Oct
|
Nov
(21) |
Dec
(9) |
2014 |
Jan
|
Feb
(11) |
Mar
(3) |
Apr
(3) |
May
(14) |
Jun
(8) |
Jul
(5) |
Aug
(4) |
Sep
(10) |
Oct
(2) |
Nov
(4) |
Dec
|
2015 |
Jan
|
Feb
(4) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
1
|
2
(6) |
3
(4) |
4
(3) |
5
|
6
|
7
|
8
(1) |
9
|
10
(1) |
11
(1) |
12
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
27
|
28
|
29
|
30
(1) |
31
(7) |
|
|
|
From: <astrand@us...> - 2010-03-31 12:49:06
|
Revision: 1588 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1588&view=rev Author: astrand Date: 2010-03-31 12:48:59 +0000 (Wed, 31 Mar 2010) Log Message: ----------- New indent style Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c seamlessrdp/trunk/ServerExe/main.c seamlessrdp/trunk/ServerExe/seamlessrdphook.c seamlessrdp/trunk/ServerExe/vchannel.c seamlessrdp/trunk/indent-all Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-31 12:43:15 UTC (rev 1587) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-31 12:48:59 UTC (rev 1588) @@ -113,13 +113,10 @@ http://msdn2.microsoft.com/en-us/library/bb776822.aspx */ owner = GetWindow(hwnd, GW_OWNER); exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); - if (!owner && !(exstyle & WS_EX_TOOLWINDOW)) - { + if (!owner && !(exstyle & WS_EX_TOOLWINDOW)) { /* display taskbar icon */ result = NULL; - } - else - { + } else { /* no taskbar icon */ if (owner) result = owner; @@ -145,21 +142,21 @@ vchannel_block(); - if (!GetWindowRect(hwnd, &rect)) - { + if (!GetWindowRect(hwnd, &rect)) { debug("GetWindowRect failed!"); goto end; } - if ((hwnd == blocked_hwnd) && (rect.left == blocked.left) && (rect.top == blocked.top) - && (rect.right == blocked.right) && (rect.bottom == blocked.bottom)) + if ((hwnd == blocked_hwnd) && (rect.left == blocked.left) + && (rect.top == blocked.top) + && (rect.right == blocked.right) && (rect.bottom == blocked.bottom)) goto end; vchannel_write("POSITION", "0x%08lx,%d,%d,%d,%d,0x%08x", - hwnd, - rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); + hwnd, + rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); - end: + end: vchannel_unblock(); } @@ -179,8 +176,7 @@ vchannel_block(); behind = GetNextWindow(hwnd, GW_HWNDPREV); - while (behind) - { + while (behind) { LONG style; style = GetWindowLong(behind, GWL_STYLE); @@ -193,14 +189,14 @@ if ((hwnd == block_hwnd) && (behind == block_behind)) vchannel_write("ACK", "%u", serial); - else - { + else { int flags = 0; LONG exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); // handle always on top if (exstyle & WS_EX_TOPMOST) flags |= SEAMLESS_CREATE_TOPMOST; - vchannel_write("ZCHANGE", "0x%08lx,0x%08lx,0x%08x", hwnd, behind, flags); + vchannel_write("ZCHANGE", "0x%08lx,0x%08lx,0x%08x", hwnd, behind, + flags); } vchannel_unblock(); @@ -212,7 +208,7 @@ HICON icon; if (!SendMessageTimeout(hwnd, WM_GETICON, large ? ICON_BIG : ICON_SMALL, - 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) & icon)) + 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) & icon)) return NULL; if (icon) @@ -222,10 +218,9 @@ * Modern versions of Windows uses the voodoo value of 2 instead of 0 * for the small icons. */ - if (!large) - { + if (!large) { if (!SendMessageTimeout(hwnd, WM_GETICON, 2, - 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) & icon)) + 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) & icon)) return NULL; } @@ -296,16 +291,17 @@ if (!hdc) goto free_cbuf; - if (!GetDIBits(hdc, info.hbmMask, 0, mask_bmp.bmHeight, mask_buf, &bmi, DIB_RGB_COLORS)) + if (!GetDIBits(hdc, info.hbmMask, 0, mask_bmp.bmHeight, mask_buf, &bmi, + DIB_RGB_COLORS)) goto del_dc; - if (!GetDIBits(hdc, info.hbmColor, 0, color_bmp.bmHeight, color_buf, &bmi, DIB_RGB_COLORS)) + if (!GetDIBits(hdc, info.hbmColor, 0, color_bmp.bmHeight, color_buf, &bmi, + DIB_RGB_COLORS)) goto del_dc; o = buffer; m = mask_buf; c = color_buf; - for (i = 0; i < size / 4; i++) - { + for (i = 0; i < size / 4; i++) { o[0] = c[2]; o[1] = c[1]; o[2] = c[0]; @@ -321,19 +317,19 @@ ret = size; - del_dc: + del_dc: DeleteDC(hdc); - free_cbuf: + free_cbuf: free(color_buf); - free_mbuf: + free_mbuf: free(mask_buf); - free_bmps: + free_bmps: DeleteObject(info.hbmMask); DeleteObject(info.hbmColor); - fail: + fail: return ret; } @@ -350,17 +346,14 @@ if (size <= 0) return; - if ((!large && size != 16 * 16 * 4) || (large && size != 32 * 32 * 4)) - { + if ((!large && size != 16 * 16 * 4) || (large && size != 32 * 32 * 4)) { debug("Unexpected icon size."); return; } chunks = (size + ICON_CHUNK - 1) / ICON_CHUNK; - for (i = 0; i < chunks; i++) - { - for (j = 0; j < ICON_CHUNK; j++) - { + for (i = 0; i < chunks; i++) { + for (j = 0; j < ICON_CHUNK; j++) { if (i * ICON_CHUNK + j >= size) break; sprintf(asciibuf + j * 2, "%02x", @@ -368,7 +361,7 @@ } vchannel_write("SETICON", "0x%08lx,%d,RGBA,%d,%d,%s", hwnd, i, - large ? 32 : 16, large ? 32 : 16, asciibuf); + large ? 32 : 16, large ? 32 : 16, asciibuf); } } @@ -393,136 +386,128 @@ wparam = ((CWPSTRUCT *) details)->wParam; lparam = ((CWPSTRUCT *) details)->lParam; - if (!is_toplevel(hwnd)) - { + if (!is_toplevel(hwnd)) { goto end; } style = GetWindowLong(hwnd, GWL_STYLE); - switch (msg) - { - case WM_WINDOWPOSCHANGED: - { - WINDOWPOS *wp = (WINDOWPOS *) lparam; + switch (msg) { + case WM_WINDOWPOSCHANGED: + { + WINDOWPOS *wp = (WINDOWPOS *) lparam; - if (wp->flags & SWP_SHOWWINDOW) - { - unsigned short title[150]; - int state; - DWORD pid; - int flags; - HICON icon; - LONG exstyle; + if (wp->flags & SWP_SHOWWINDOW) { + unsigned short title[150]; + int state; + DWORD pid; + int flags; + HICON icon; + LONG exstyle; - exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); - GetWindowThreadProcessId(hwnd, &pid); + exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); + GetWindowThreadProcessId(hwnd, &pid); - flags = 0; - if (style & DS_MODALFRAME) - flags |= SEAMLESS_CREATE_MODAL; - // handle always on top - if (exstyle & WS_EX_TOPMOST) - flags |= SEAMLESS_CREATE_TOPMOST; + flags = 0; + if (style & DS_MODALFRAME) + flags |= SEAMLESS_CREATE_MODAL; + // handle always on top + if (exstyle & WS_EX_TOPMOST) + flags |= SEAMLESS_CREATE_TOPMOST; - vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x", - hwnd_to_long(hwnd), (long) pid, - hwnd_to_long(get_parent(hwnd)), flags); + vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x", + hwnd_to_long(hwnd), (long) pid, + hwnd_to_long(get_parent(hwnd)), flags); - GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title)); + GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title)); - vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd, - vchannel_strfilter_unicode(title), 0); + vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd, + vchannel_strfilter_unicode(title), 0); - icon = get_icon(hwnd, 1); - if (icon) - { - update_icon(hwnd, icon, 1); - DeleteObject(icon); - } + icon = get_icon(hwnd, 1); + if (icon) { + update_icon(hwnd, icon, 1); + DeleteObject(icon); + } - icon = get_icon(hwnd, 0); - if (icon) - { - update_icon(hwnd, icon, 0); - DeleteObject(icon); - } - - if (style & WS_MAXIMIZE) - state = 2; - else if (style & WS_MINIMIZE) - state = 1; - else - state = 0; - - update_position(hwnd); - - vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x", hwnd, - state, 0); + icon = get_icon(hwnd, 0); + if (icon) { + update_icon(hwnd, icon, 0); + DeleteObject(icon); } - if (wp->flags & SWP_HIDEWINDOW) - vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0); + if (style & WS_MAXIMIZE) + state = 2; + else if (style & WS_MINIMIZE) + state = 1; + else + state = 0; - if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) - break; + update_position(hwnd); - if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)) - update_position(hwnd); - - break; + vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x", hwnd, + state, 0); } - case WM_SETICON: - if (!(style & WS_VISIBLE)) + if (wp->flags & SWP_HIDEWINDOW) + vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0); + + if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) break; - switch (wparam) - { - case ICON_BIG: - if (lparam) - update_icon(hwnd, (HICON) lparam, 1); - else - vchannel_write("DELICON", "0x%08lx,RGBA,32,32", - hwnd); - break; - case ICON_SMALL: - case 2: - if (lparam) - update_icon(hwnd, (HICON) lparam, 0); - else - vchannel_write("DELICON", "0x%08lx,RGBA,16,16", - hwnd); - break; - default: - debug("Weird icon size %d", (int) wparam); - } + if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)) + update_position(hwnd); break; + } - case WM_SIZE: - if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) - break; - update_position(hwnd); + case WM_SETICON: + if (!(style & WS_VISIBLE)) break; - case WM_MOVE: - if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) - break; - update_position(hwnd); + switch (wparam) { + case ICON_BIG: + if (lparam) + update_icon(hwnd, (HICON) lparam, 1); + else + vchannel_write("DELICON", "0x%08lx,RGBA,32,32", hwnd); break; + case ICON_SMALL: + case 2: + if (lparam) + update_icon(hwnd, (HICON) lparam, 0); + else + vchannel_write("DELICON", "0x%08lx,RGBA,16,16", hwnd); + break; + default: + debug("Weird icon size %d", (int) wparam); + } - case WM_DESTROY: - if (!(style & WS_VISIBLE)) - break; - vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0); + break; + + case WM_SIZE: + if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) break; + update_position(hwnd); + break; - default: + case WM_MOVE: + if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) break; + update_position(hwnd); + break; + + case WM_DESTROY: + if (!(style & WS_VISIBLE)) + break; + vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0); + break; + + default: + break; } - end: + end: return CallNextHookEx(g_wndproc_hook, code, cur_thread, details); } @@ -547,67 +532,63 @@ wparam = ((CWPRETSTRUCT *) details)->wParam; lparam = ((CWPRETSTRUCT *) details)->lParam; - if (!is_toplevel(hwnd)) - { + if (!is_toplevel(hwnd)) { goto end; } style = GetWindowLong(hwnd, GWL_STYLE); - switch (msg) - { - case WM_WINDOWPOSCHANGED: - { - WINDOWPOS *wp = (WINDOWPOS *) lparam; + switch (msg) { + case WM_WINDOWPOSCHANGED: + { + WINDOWPOS *wp = (WINDOWPOS *) lparam; - if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) - break; + if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) + break; - if (!(wp->flags & SWP_NOZORDER)) - update_zorder(hwnd); + if (!(wp->flags & SWP_NOZORDER)) + update_zorder(hwnd); - break; - } + break; + } - case WM_SETTEXT: - { - unsigned short title[150]; - if (!(style & WS_VISIBLE)) - break; - /* We cannot use the string in lparam because - we need unicode. */ - GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title)); - vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd, - vchannel_strfilter_unicode(title), 0); + case WM_SETTEXT: + { + unsigned short title[150]; + if (!(style & WS_VISIBLE)) break; - } + /* We cannot use the string in lparam because + we need unicode. */ + GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title)); + vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd, + vchannel_strfilter_unicode(title), 0); + break; + } - case WM_SETICON: - { - HICON icon; - if (!(style & WS_VISIBLE)) - break; + case WM_SETICON: + { + HICON icon; + if (!(style & WS_VISIBLE)) + break; - /* - * Somehow, we never get WM_SETICON for the small icon. - * So trigger a read of it every time the large one is - * changed. - */ - icon = get_icon(hwnd, 0); - if (icon) - { - update_icon(hwnd, icon, 0); - DeleteObject(icon); - } + /* + * Somehow, we never get WM_SETICON for the small icon. + * So trigger a read of it every time the large one is + * changed. + */ + icon = get_icon(hwnd, 0); + if (icon) { + update_icon(hwnd, icon, 0); + DeleteObject(icon); } + } - default: - break; + default: + break; } - if (msg == g_wm_seamless_focus) - { + if (msg == g_wm_seamless_focus) { /* For some reason, SetForegroundWindow() on menus closes them. Ignore focus requests for menu windows. */ if ((GetForegroundWindow() != hwnd) && !is_menu(hwnd)) @@ -616,7 +597,7 @@ vchannel_write("ACK", "%u", g_shdata->blocked_focus_serial); } - end: + end: return CallNextHookEx(g_wndprocret_hook, code, cur_thread, details); } @@ -629,57 +610,55 @@ if (code < 0) goto end; - switch (code) - { - case HCBT_MINMAX: - { - int show, state, blocked; - HWND hwnd, blocked_hwnd; - unsigned int serial; - LONG style; + switch (code) { + case HCBT_MINMAX: + { + int show, state, blocked; + HWND hwnd, blocked_hwnd; + unsigned int serial; + LONG style; - WaitForSingleObject(g_mutex, INFINITE); - blocked_hwnd = long_to_hwnd(g_shdata->blocked_state_hwnd); - serial = g_shdata->blocked_state_serial; - blocked = g_shdata->blocked_state; - ReleaseMutex(g_mutex); + WaitForSingleObject(g_mutex, INFINITE); + blocked_hwnd = long_to_hwnd(g_shdata->blocked_state_hwnd); + serial = g_shdata->blocked_state_serial; + blocked = g_shdata->blocked_state; + ReleaseMutex(g_mutex); - hwnd = (HWND) wparam; + hwnd = (HWND) wparam; - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLong(hwnd, GWL_STYLE); - if (!(style & WS_VISIBLE)) - break; + if (!(style & WS_VISIBLE)) + break; - show = LOWORD(lparam); + show = LOWORD(lparam); - if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL) - || (show == SW_RESTORE)) - state = 0; - else if ((show == SW_MINIMIZE) || (show == SW_SHOWMINIMIZED)) - state = 1; - else if ((show == SW_MAXIMIZE) || (show == SW_SHOWMAXIMIZED)) - state = 2; - else - { - debug("Unexpected show: %d", show); - break; - } - - if ((blocked_hwnd == hwnd) && (blocked == state)) - vchannel_write("ACK", "%u", serial); - else - vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x", - hwnd, state, 0); - + if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL) + || (show == SW_RESTORE)) + state = 0; + else if ((show == SW_MINIMIZE) || (show == SW_SHOWMINIMIZED)) + state = 1; + else if ((show == SW_MAXIMIZE) || (show == SW_SHOWMAXIMIZED)) + state = 2; + else { + debug("Unexpected show: %d", show); break; } - default: + if ((blocked_hwnd == hwnd) && (blocked == state)) + vchannel_write("ACK", "%u", serial); + else + vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x", + hwnd, state, 0); + break; + } + + default: + break; } - end: + end: return CallNextHookEx(g_cbt_hook, code, wparam, lparam); } @@ -690,11 +669,13 @@ g_cbt_hook = SetWindowsHookEx(WH_CBT, cbt_hook_proc, g_instance, 0); if (!g_wndproc_hook) - g_wndproc_hook = SetWindowsHookEx(WH_CALLWNDPROC, wndproc_hook_proc, g_instance, 0); + g_wndproc_hook = + SetWindowsHookEx(WH_CALLWNDPROC, wndproc_hook_proc, g_instance, 0); if (!g_wndprocret_hook) g_wndprocret_hook = - SetWindowsHookEx(WH_CALLWNDPROCRET, wndprocret_hook_proc, g_instance, 0); + SetWindowsHookEx(WH_CALLWNDPROCRET, wndprocret_hook_proc, + g_instance, 0); } EXTERN void @@ -711,7 +692,8 @@ } EXTERN void -SafeMoveWindow(unsigned int serial, HWND hwnd, int x, int y, int width, int height) +SafeMoveWindow(unsigned int serial, HWND hwnd, int x, int y, int width, + int height) { RECT rect; @@ -727,14 +709,15 @@ g_shdata->block_move.bottom = y + height; ReleaseMutex(g_mutex); - SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER); + SetWindowPos(hwnd, NULL, x, y, width, height, + SWP_NOACTIVATE | SWP_NOZORDER); vchannel_write("ACK", "%u", serial); if (!GetWindowRect(hwnd, &rect)) debug("GetWindowRect failed!"); else if ((rect.left != x) || (rect.top != y) || (rect.right != x + width) - || (rect.bottom != y + height)) + || (rect.bottom != y + height)) update_position(hwnd); WaitForSingleObject(g_mutex, INFINITE); @@ -758,7 +741,8 @@ if (behind == NULL) behind = HWND_TOP; - SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(hwnd, behind, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); WaitForSingleObject(g_mutex, INFINITE); g_shdata->blocked_zchange[0] = 0; @@ -804,8 +788,7 @@ else curstate = 0; - if (state == curstate) - { + if (state == curstate) { vchannel_write("ACK", "%u", serial); vchannel_unblock(); return; @@ -847,70 +830,61 @@ DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpReserved) { HANDLE filemapping = NULL; - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - // remember our instance handle - g_instance = hinstDLL; + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + // remember our instance handle + g_instance = hinstDLL; - g_mutex = CreateMutex(NULL, FALSE, "Local\\SeamlessDLL"); + g_mutex = CreateMutex(NULL, FALSE, "Local\\SeamlessDLL"); - filemapping = CreateFileMapping(INVALID_HANDLE_VALUE, - NULL, - PAGE_READWRITE, - 0, - sizeof(shared_variables), - "Local\\SeamlessRDPData"); + filemapping = CreateFileMapping(INVALID_HANDLE_VALUE, + NULL, + PAGE_READWRITE, + 0, sizeof(shared_variables), "Local\\SeamlessRDPData"); - if (filemapping) - { - /* From MSDN: The initial contents of - the pages in a file mapping object - backed by the paging file are 0 - (zero)." */ - g_shdata = MapViewOfFile(filemapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); - } + if (filemapping) { + /* From MSDN: The initial contents of + the pages in a file mapping object + backed by the paging file are 0 + (zero)." */ + g_shdata = MapViewOfFile(filemapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); + } - if (g_mutex && filemapping && g_shdata && vchannel_open() == 0) - { - WaitForSingleObject(g_mutex, INFINITE); - ++g_shdata->instance_count; - ReleaseMutex(g_mutex); - g_wm_seamless_focus = RegisterWindowMessage(FOCUS_MSG_NAME); - } - break; + if (g_mutex && filemapping && g_shdata && vchannel_open() == 0) { + WaitForSingleObject(g_mutex, INFINITE); + ++g_shdata->instance_count; + ReleaseMutex(g_mutex); + g_wm_seamless_focus = RegisterWindowMessage(FOCUS_MSG_NAME); + } + break; - case DLL_THREAD_ATTACH: - break; + case DLL_THREAD_ATTACH: + break; - case DLL_THREAD_DETACH: - break; + case DLL_THREAD_DETACH: + break; - case DLL_PROCESS_DETACH: - if (vchannel_is_open()) - { - vchannel_write("DESTROYGRP", "0x%08lx, 0x%08lx", - GetCurrentProcessId(), 0); - vchannel_close(); - } + case DLL_PROCESS_DETACH: + if (vchannel_is_open()) { + vchannel_write("DESTROYGRP", "0x%08lx, 0x%08lx", + GetCurrentProcessId(), 0); + vchannel_close(); + } - if (g_mutex) - { - WaitForSingleObject(g_mutex, INFINITE); - if (g_shdata) - { - --g_shdata->instance_count; - UnmapViewOfFile(g_shdata); - } - ReleaseMutex(g_mutex); - CloseHandle(g_mutex); + if (g_mutex) { + WaitForSingleObject(g_mutex, INFINITE); + if (g_shdata) { + --g_shdata->instance_count; + UnmapViewOfFile(g_shdata); } + ReleaseMutex(g_mutex); + CloseHandle(g_mutex); + } - if (filemapping) - { - CloseHandle(filemapping); - } - break; + if (filemapping) { + CloseHandle(filemapping); + } + break; } return TRUE; Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-31 12:43:15 UTC (rev 1587) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-31 12:48:59 UTC (rev 1588) @@ -47,8 +47,8 @@ typedef void (*remove_hooks_proc_t) (); typedef int (*get_instance_count_proc_t) (); -typedef void (*move_window_proc_t) (unsigned int serial, HWND hwnd, int x, int y, int width, - int height); +typedef void (*move_window_proc_t) (unsigned int serial, HWND hwnd, int x, + int y, int width, int height); typedef void (*zchange_proc_t) (unsigned int serial, HWND hwnd, HWND behind); typedef void (*focus_proc_t) (unsigned int serial, HWND hwnd); typedef void (*set_state_proc_t) (unsigned int serial, HWND hwnd, int state); @@ -74,13 +74,10 @@ return NULL; comma = strchr(head, ','); - if (comma) - { + if (comma) { *comma = '\0'; *s = comma + 1; - } - else - { + } else { *s = NULL; } @@ -108,7 +105,7 @@ remove this when cmd.exe support has been added, though. */ char classname[32]; if (GetClassName(hwnd, classname, sizeof(classname)) - && !strcmp(classname, "ConsoleWindowClass")) + && !strcmp(classname, "ConsoleWindowClass")) return TRUE; if (styles & WS_POPUP) @@ -123,21 +120,21 @@ flags |= SEAMLESS_CREATE_MODAL; vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x", - hwnd_to_long(hwnd), (long) pid, hwnd_to_long(parent), flags); + hwnd_to_long(hwnd), (long) pid, hwnd_to_long(parent), flags); - if (!GetWindowRect(hwnd, &rect)) - { + if (!GetWindowRect(hwnd, &rect)) { debug("GetWindowRect failed!"); return TRUE; } vchannel_write("POSITION", "0x%08lx,%d,%d,%d,%d,0x%08x", - hwnd, - rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); + hwnd, + rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title)); - vchannel_write("TITLE", "0x%x,%s,0x%x", hwnd, vchannel_strfilter_unicode(title), 0); + vchannel_write("TITLE", "0x%x,%s,0x%x", hwnd, + vchannel_strfilter_unicode(title), 0); if (styles & WS_MAXIMIZE) state = 2; @@ -205,8 +202,7 @@ char *p, *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8; - while ((size = vchannel_read(line, sizeof(line))) >= 0) - { + while ((size = vchannel_read(line, sizeof(line))) >= 0) { p = line; tok1 = get_token(&p); @@ -221,18 +217,18 @@ if (strcmp(tok1, "SYNC") == 0) do_sync(); else if (strcmp(tok1, "STATE") == 0) - do_state(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), - strtol(tok4, NULL, 0)); + do_state(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, + 0)), strtol(tok4, NULL, 0)); else if (strcmp(tok1, "POSITION") == 0) - do_position(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), - strtol(tok4, NULL, 0), strtol(tok5, NULL, 0), strtol(tok6, NULL, - 0), - strtol(tok7, NULL, 0)); + do_position(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, + 0)), strtol(tok4, NULL, 0), strtol(tok5, NULL, 0), + strtol(tok6, NULL, 0), strtol(tok7, NULL, 0)); else if (strcmp(tok1, "ZCHANGE") == 0) - do_zchange(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), - long_to_hwnd(strtoul(tok4, NULL, 0))); + do_zchange(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, + 0)), long_to_hwnd(strtoul(tok4, NULL, 0))); else if (strcmp(tok1, "FOCUS") == 0) - do_focus(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0))); + do_focus(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, + 0))); else if (strcmp(tok1, "DESTROY") == 0) do_destroy(long_to_hwnd(strtoul(tok3, NULL, 0))); } @@ -249,8 +245,7 @@ g_startup_num_procs = 0; - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { if (pinfo[i].SessionId != g_session_id) continue; @@ -260,8 +255,7 @@ g_startup_procs = malloc(sizeof(DWORD) * g_startup_num_procs); j = 0; - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { if (pinfo[i].SessionId != g_session_id) continue; @@ -292,25 +286,21 @@ if (!WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pinfo, &count)) return TRUE; - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { if (pinfo[i].SessionId != g_session_id) continue; // ieuser.exe hangs around even after IE has exited - if (0 == _stricmp(pinfo[i].pProcessName, "ieuser.exe")) - { + if (0 == _stricmp(pinfo[i].pProcessName, "ieuser.exe")) { continue; } - for (j = 0; j < g_startup_num_procs; j++) - { + for (j = 0; j < g_startup_num_procs; j++) { if (pinfo[i].ProcessId == g_startup_procs[j]) break; } - if (j == g_startup_num_procs) - { + if (j == g_startup_num_procs) { WTSFreeMemory(pinfo); return FALSE; } @@ -329,8 +319,7 @@ DWORD size; res = WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, - WTS_CURRENT_SESSION, WTSConnectState, (LPTSTR *) & state, - &size); + WTS_CURRENT_SESSION, WTSConnectState, (LPTSTR *) & state, &size); if (!res) return TRUE; @@ -368,16 +357,13 @@ startup_info.cb = sizeof(STARTUPINFO); result = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, - NULL, NULL, &startup_info, &proc_info); + NULL, NULL, &startup_info, &proc_info); // Release handles CloseHandle(proc_info.hThread); - if (result) - { + if (result) { return proc_info.hProcess; - } - else - { + } else { return NULL; } } @@ -391,15 +377,13 @@ /* If we are running on a x64 system, hook 32 bit apps as well by launching a 32 bit helper process. */ - if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) - { + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { char cmd[] = "seamlessrdphook32.exe"; app = launch_app(cmd); - if (!app) - { + if (!app) { char msg[256]; _snprintf(msg, sizeof(msg), - "Unable to launch the requested application:\n%s", cmd); + "Unable to launch the requested application:\n%s", cmd); message(msg); } @@ -407,14 +391,13 @@ the process enum */ DWORD ret; ret = WaitForInputIdle(app, HELPER_TIMEOUT); - switch (ret) - { - case 0: - break; - case WAIT_TIMEOUT: - case WAIT_FAILED: - message("Hooking helper failed to start within time limit"); - break; + switch (ret) { + case 0: + break; + case WAIT_TIMEOUT: + case WAIT_FAILED: + message("Hooking helper failed to start within time limit"); + break; } } return app; @@ -428,26 +411,23 @@ HWND procwnd; DWORD ret; procwnd = FindWindowEx(HWND_MESSAGE, NULL, "Message", wndname); - if (procwnd) - { + if (procwnd) { PostMessage(procwnd, WM_CLOSE, 0, 0); } ret = WaitForSingleObject(proc, timeout); - switch (ret) - { - case WAIT_ABANDONED: - case WAIT_OBJECT_0: - break; - case WAIT_TIMEOUT: - // Still running, kill hard - if (!TerminateProcess(proc, 1)) - { - message("Unable to terminate process"); - } - break; - case WAIT_FAILED: - message("Unable to wait for process"); - break; + switch (ret) { + case WAIT_ABANDONED: + case WAIT_OBJECT_0: + break; + case WAIT_TIMEOUT: + // Still running, kill hard + if (!TerminateProcess(proc, 1)) { + message("Unable to terminate process"); + } + break; + case WAIT_FAILED: + message("Unable to wait for process"); + break; } } @@ -465,67 +445,66 @@ int check_counter; - if (strlen(cmdline) == 0) - { + if (strlen(cmdline) == 0) { message("No command line specified."); return -1; } - if (vchannel_open()) - { + if (vchannel_open()) { message("Unable to set up the virtual channel."); return -1; } SYSTEM_INFO si; GetSystemInfo(&si); - switch (si.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_INTEL: - hookdll = LoadLibrary("seamlessrdp32.dll"); - break; - case PROCESSOR_ARCHITECTURE_AMD64: - hookdll = LoadLibrary("seamlessrdp64.dll"); - break; - default: - message("Unsupported processor architecture."); - break; + switch (si.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_INTEL: + hookdll = LoadLibrary("seamlessrdp32.dll"); + break; + case PROCESSOR_ARCHITECTURE_AMD64: + hookdll = LoadLibrary("seamlessrdp64.dll"); + break; + default: + message("Unsupported processor architecture."); + break; } - if (!hookdll) - { + if (!hookdll) { message("Could not load hook DLL. Unable to continue."); goto close_vchannel; } set_hooks_fn = (set_hooks_proc_t) GetProcAddress(hookdll, "SetHooks"); - remove_hooks_fn = (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); - instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); - g_move_window_fn = (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); + remove_hooks_fn = + (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); + instance_count_fn = + (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); + g_move_window_fn = + (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); g_zchange_fn = (zchange_proc_t) GetProcAddress(hookdll, "SafeZChange"); g_focus_fn = (focus_proc_t) GetProcAddress(hookdll, "SafeFocus"); g_set_state_fn = (set_state_proc_t) GetProcAddress(hookdll, "SafeSetState"); - if (!set_hooks_fn || !remove_hooks_fn || !instance_count_fn || !g_move_window_fn - || !g_zchange_fn || !g_focus_fn || !g_set_state_fn) - { - message("Hook DLL doesn't contain the correct functions. Unable to continue."); + if (!set_hooks_fn || !remove_hooks_fn || !instance_count_fn + || !g_move_window_fn || !g_zchange_fn || !g_focus_fn + || !g_set_state_fn) { + message + ("Hook DLL doesn't contain the correct functions. Unable to continue."); goto close_hookdll; } /* Check if the DLL is already loaded */ - switch (instance_count_fn()) - { - case 0: - message("Hook DLL failed to initialize."); - goto close_hookdll; - break; - case 1: - break; - default: - message("Another running instance of Seamless RDP detected."); - goto close_hookdll; + switch (instance_count_fn()) { + case 0: + message("Hook DLL failed to initialize."); + goto close_hookdll; + break; + case 1: + break; + default: + message("Another running instance of Seamless RDP detected."); + goto close_hookdll; } helper = launch_helper(); @@ -537,7 +516,8 @@ g_connected = is_connected(); g_desktop_hidden = is_desktop_hidden(); - vchannel_write("HELLO", "0x%08x", g_desktop_hidden ? SEAMLESS_HELLO_HIDDEN : 0); + vchannel_write("HELLO", "0x%08x", + g_desktop_hidden ? SEAMLESS_HELLO_HIDDEN : 0); set_hooks_fn(); @@ -551,25 +531,22 @@ /* We don't want windows denying requests to activate windows. */ SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0); - if (!launch_app(cmdline)) - { + if (!launch_app(cmdline)) { // CreateProcess failed. char msg[256]; _snprintf(msg, sizeof(msg), - "Unable to launch the requested application:\n%s", cmdline); + "Unable to launch the requested application:\n%s", cmdline); message(msg); goto unhook; } check_counter = 5; - while (check_counter-- || !should_terminate()) - { + while (check_counter-- || !should_terminate()) { BOOL connected; MSG msg; connected = is_connected(); - if (connected && !g_connected) - { + if (connected && !g_connected) { int flags; /* These get reset on each reconnect */ SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0); @@ -584,8 +561,7 @@ g_connected = connected; - if (check_counter < 0) - { + if (check_counter < 0) { BOOL hidden; hidden = is_desktop_hidden(); @@ -599,8 +575,7 @@ check_counter = 5; } - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -610,20 +585,19 @@ success = 1; - unhook: + unhook: remove_hooks_fn(); free_startup_procs(); - if (helper) - { + if (helper) { // Terminate seamlessrdphook32.exe kill_15_9(helper, "SeamlessRDPHook", HELPER_TIMEOUT); } - close_hookdll: + close_hookdll: FreeLibrary(hookdll); - close_vchannel: + close_vchannel: vchannel_close(); // Logoff the user. This is necessary because the session may Modified: seamlessrdp/trunk/ServerExe/seamlessrdphook.c =================================================================== --- seamlessrdp/trunk/ServerExe/seamlessrdphook.c 2010-03-31 12:43:15 UTC (rev 1587) +++ seamlessrdp/trunk/ServerExe/seamlessrdphook.c 2010-03-31 12:48:59 UTC (rev 1588) @@ -42,32 +42,31 @@ SYSTEM_INFO si; GetSystemInfo(&si); - switch (si.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_INTEL: - hookdll = LoadLibrary("seamlessrdp32.dll"); - break; - case PROCESSOR_ARCHITECTURE_AMD64: - hookdll = LoadLibrary("seamlessrdp64.dll"); - break; - default: - message("Unsupported processor architecture."); - break; + switch (si.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_INTEL: + hookdll = LoadLibrary("seamlessrdp32.dll"); + break; + case PROCESSOR_ARCHITECTURE_AMD64: + hookdll = LoadLibrary("seamlessrdp64.dll"); + break; + default: + message("Unsupported processor architecture."); + break; } - if (!hookdll) - { + if (!hookdll) { message("Could not load hook DLL. Unable to continue."); return 1; } set_hooks_fn = (set_hooks_proc_t) GetProcAddress(hookdll, "SetHooks"); - instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); + instance_count_fn = + (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); - if (!set_hooks_fn || !instance_count_fn) - { - message("Hook DLL doesn't contain the correct functions. Unable to continue."); + if (!set_hooks_fn || !instance_count_fn) { + message + ("Hook DLL doesn't contain the correct functions. Unable to continue."); goto close_hookdll; } @@ -79,27 +78,23 @@ dialog, such messages are lost. Instead, we need to create a "Message-Only Window". */ CreateWindow("Message", "SeamlessRDPHook", 0, 0, 0, 0, 0, - HWND_MESSAGE, NULL, instance, NULL); + HWND_MESSAGE, NULL, instance, NULL); MSG msg; - while (1) - { + while (1) { BOOL ret; ret = GetMessage(&msg, NULL, 0, 0); - if (ret == -1) - { + if (ret == -1) { message("GetMessage failed"); break; - } - else if (ret == 0) - { + } else if (ret == 0) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } - close_hookdll: + close_hookdll: FreeLibrary(hookdll); return 0; Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-31 12:43:15 UTC (rev 1587) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-31 12:48:59 UTC (rev 1588) @@ -90,25 +90,19 @@ size = sizeof(convert_buffer) - 1; /* We do not handle characters outside BMP (i.e. we can't do UTF-16) */ - while (*string != 0x0000) - { - if (*string < 0x80) - { + while (*string != 0x0000) { + if (*string < 0x80) { if (size < 1) break; *buf++ = (unsigned char) *string; size--; - } - else if (*string < 0x800) - { + } else if (*string < 0x800) { if (size < 2) break; *buf++ = 0xC0 | (*string >> 6); *buf++ = 0x80 | (*string & 0x3F); size -= 2; - } - else if ((*string < 0xD800) || (*string > 0xDFFF)) - { + } else if ((*string < 0xD800) || (*string > 0xDFFF)) { if (size < 3) break; *buf++ = 0xE0 | (*string >> 12); @@ -133,17 +127,17 @@ return 0; g_vchannel = WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, - WTS_CURRENT_SESSION, CHANNELNAME); + WTS_CURRENT_SESSION, CHANNELNAME); if (g_vchannel == NULL) return -1; g_mutex = CreateMutex(NULL, FALSE, "Local\\SeamlessChannel"); - g_vchannel_serial = CreateSemaphore(NULL, 0, INT_MAX, "Local\\SeamlessRDPSerial"); + g_vchannel_serial = + CreateSemaphore(NULL, 0, INT_MAX, "Local\\SeamlessRDPSerial"); - if (!g_mutex || !g_vchannel_serial) - { + if (!g_mutex || !g_vchannel_serial) { WTSVirtualChannelClose(g_vchannel); g_vchannel = NULL; return -1; @@ -192,38 +186,31 @@ ULONG bytes_read; result = WTSVirtualChannelRead(g_vchannel, 0, buffer + size, - sizeof(buffer) - size, &bytes_read); + sizeof(buffer) - size, &bytes_read); - if (!result) - { + if (!result) { errno = EIO; return -1; } - if (overflow_mode) - { + if (overflow_mode) { newline = strchr(buffer, '\n'); - if (newline && (newline - buffer) < bytes_read) - { + if (newline && (newline - buffer) < bytes_read) { size = bytes_read - (newline - buffer) - 1; memmove(buffer, newline + 1, size); overflow_mode = FALSE; } - } - else + } else size += bytes_read; - if (overflow_mode) - { + if (overflow_mode) { errno = -EAGAIN; return -1; } newline = strchr(buffer, '\n'); - if (!newline || (newline - buffer) >= size) - { - if (size == sizeof(buffer)) - { + if (!newline || (newline - buffer) >= size) { + if (size == sizeof(buffer)) { overflow_mode = TRUE; size = 0; } @@ -231,8 +218,7 @@ return -1; } - if ((newline - buffer) >= length) - { + if ((newline - buffer) >= length) { errno = ENOMEM; return -1; } @@ -263,14 +249,11 @@ WaitForSingleObject(g_mutex, INFINITE); /* Increase serial */ - if (!ReleaseSemaphore(g_vchannel_serial, 1, &prev_serial)) - { - if (GetLastError() == ERROR_TOO_MANY_POSTS) - { + if (!ReleaseSemaphore(g_vchannel_serial, 1, &prev_serial)) { + if (GetLastError() == ERROR_TOO_MANY_POSTS) { /* Reset serial to zero */ while (WaitForSingleObject(g_vchannel_serial, 0) == WAIT_OBJECT_0); - if (!ReleaseSemaphore(g_vchannel_serial, 1, &prev_serial)) - { + if (!ReleaseSemaphore(g_vchannel_serial, 1, &prev_serial)) { return -1; } } @@ -278,14 +261,11 @@ ret = _snprintf(buf, sizeof(buf), "%s,%u,", command, prev_serial); - if (ret < 0) - { + if (ret < 0) { // If the command and serial didn't fit, let's skip // this message return -1; - } - else - { + } else { size = ret; } assert(size <= sizeof(buf)); @@ -295,20 +275,20 @@ ret = _vsnprintf(buf + size, sizeof(buf) - size, format, argp); va_end(argp); - if (ret < 0) - { + if (ret < 0) { // Truncated, but let's write what we have size = sizeof(buf) - 1; - } - else - { + } else { size = ret; } buf[sizeof(buf) - 1] = '\0'; assert(size < sizeof(buf)); - result = WTSVirtualChannelWrite(g_vchannel, buf, (ULONG) strlen(buf), &bytes_written); - result = WTSVirtualChannelWrite(g_vchannel, "\n", (ULONG) 1, &bytes_written); + result = + WTSVirtualChannelWrite(g_vchannel, buf, (ULONG) strlen(buf), + &bytes_written); + result = + WTSVirtualChannelWrite(g_vchannel, "\n", (ULONG) 1, &bytes_written); ReleaseMutex(g_mutex); @@ -335,8 +315,7 @@ { char *c; - for (c = string; *c != '\0'; c++) - { + for (c = string; *c != '\0'; c++) { if (((unsigned char) *c < 0x20) || (strchr(INVALID_CHARS, *c) != NULL)) *c = REPLACEMENT_CHAR; } Modified: seamlessrdp/trunk/indent-all =================================================================== --- seamlessrdp/trunk/indent-all 2010-03-31 12:43:15 UTC (rev 1587) +++ seamlessrdp/trunk/indent-all 2010-03-31 12:48:59 UTC (rev 1588) @@ -1,2 +1,2 @@ #!/bin/sh -indent -bli0 -i8 -cli8 -npcs -l100 ServerExe/*.h ServerExe/*.c +indent -bli0 -i4 -ts4 -cli0 -npcs -nlp -br -ce -l80 ServerExe/*.h ServerExe/*.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-31 12:43:21
|
Revision: 1587 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1587&view=rev Author: astrand Date: 2010-03-31 12:43:15 +0000 (Wed, 31 Mar 2010) Log Message: ----------- Updated to r1585; there are more corner cases. Hopefully this one is correct. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/vchannel.c Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-31 12:26:10 UTC (rev 1586) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-31 12:43:15 UTC (rev 1587) @@ -254,7 +254,7 @@ BOOL result; va_list argp; char buf[VCHANNEL_MAX_LINE]; - int size; + int size, ret; ULONG bytes_written; LONG prev_serial; @@ -276,18 +276,35 @@ } } - size = _snprintf(buf, sizeof(buf), "%s,%u,", command, prev_serial); - if (size < 0) + ret = _snprintf(buf, sizeof(buf), "%s,%u,", command, prev_serial); + + if (ret < 0) { - // Truncated, but let's write what we have - size = sizeof(buf); + // If the command and serial didn't fit, let's skip + // this message + return -1; } - assert(size < sizeof(buf)); + else + { + size = ret; + } + assert(size <= sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; va_start(argp, format); - size += _vsnprintf(buf + size, sizeof(buf) - size, format, argp); + ret = _vsnprintf(buf + size, sizeof(buf) - size, format, argp); va_end(argp); + if (ret < 0) + { + // Truncated, but let's write what we have + size = sizeof(buf) - 1; + } + else + { + size = ret; + } + buf[sizeof(buf) - 1] = '\0'; assert(size < sizeof(buf)); result = WTSVirtualChannelWrite(g_vchannel, buf, (ULONG) strlen(buf), &bytes_written); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-31 12:26:17
|
Revision: 1586 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1586&view=rev Author: astrand Date: 2010-03-31 12:26:10 +0000 (Wed, 31 Mar 2010) Log Message: ----------- Added FIXME for ExitWindows. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/main.c Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-31 11:21:43 UTC (rev 1585) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-31 12:26:10 UTC (rev 1586) @@ -629,6 +629,8 @@ // Logoff the user. This is necessary because the session may // have started processes that are not included in Microsofts // list of processes to ignore. Typically ieuser.exe. + // FIXME: Only do this if WTSQuerySessionInformation indicates + // that we are the initial program. ExitWindows(0, 0); if (success) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-31 11:21:50
|
Revision: 1585 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1585&view=rev Author: astrand Date: 2010-03-31 11:21:43 +0000 (Wed, 31 Mar 2010) Log Message: ----------- _snprintf can return a negative result; make sure we handle this. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/vchannel.c Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-31 10:59:20 UTC (rev 1584) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-31 11:21:43 UTC (rev 1585) @@ -277,6 +277,11 @@ } size = _snprintf(buf, sizeof(buf), "%s,%u,", command, prev_serial); + if (size < 0) + { + // Truncated, but let's write what we have + size = sizeof(buf); + } assert(size < sizeof(buf)); va_start(argp, format); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-31 10:59:28
|
Revision: 1584 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1584&view=rev Author: astrand Date: 2010-03-31 10:59:20 +0000 (Wed, 31 Mar 2010) Log Message: ----------- Avoid crashing with Internet Explorer in Protected mode. For some reason, returning False from DLL_PROCESS_ATTACH is not sufficient; the callbacks will be called anyway. Thus, we must directly exit if we are not properly initialized. We are not bothering with returning False from DLL_PROCESS_ATTACH any longer. The detach has also been adapted. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-31 10:50:14 UTC (rev 1583) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-31 10:59:20 UTC (rev 1584) @@ -33,7 +33,7 @@ #define EXTERN __declspec(dllexport) #define FOCUS_MSG_NAME "WM_SEAMLESS_FOCUS" -static UINT g_wm_seamless_focus; +static UINT g_wm_seamless_focus = 0; // Non-zero if DLL is initialized static HHOOK g_cbt_hook = NULL; static HHOOK g_wndproc_hook = NULL; @@ -382,6 +382,9 @@ LONG style; + if (!g_wm_seamless_focus) + goto end; + if (code < 0) goto end; @@ -533,6 +536,9 @@ LONG style; + if (!g_wm_seamless_focus) + goto end; + if (code < 0) goto end; @@ -617,6 +623,9 @@ static LRESULT CALLBACK cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam) { + if (!g_wm_seamless_focus) + goto end; + if (code < 0) goto end; @@ -706,6 +715,9 @@ { RECT rect; + if (!g_wm_seamless_focus) + return; + WaitForSingleObject(g_mutex, INFINITE); g_shdata->block_move_hwnd = hwnd_to_long(hwnd); g_shdata->block_move_serial = serial; @@ -734,6 +746,9 @@ EXTERN void SafeZChange(unsigned int serial, HWND hwnd, HWND behind) { + if (!g_wm_seamless_focus) + return; + WaitForSingleObject(g_mutex, INFINITE); g_shdata->blocked_zchange_serial = serial; g_shdata->blocked_zchange[0] = hwnd_to_long(hwnd); @@ -754,6 +769,9 @@ EXTERN void SafeFocus(unsigned int serial, HWND hwnd) { + if (!g_wm_seamless_focus) + return; + WaitForSingleObject(g_mutex, INFINITE); g_shdata->blocked_focus_serial = serial; g_shdata->blocked_focus = hwnd_to_long(hwnd); @@ -772,6 +790,9 @@ LONG style; int curstate; + if (!g_wm_seamless_focus) + return; + vchannel_block(); style = GetWindowLong(hwnd, GWL_STYLE); @@ -816,6 +837,9 @@ EXTERN int GetInstanceCount() { + if (!g_wm_seamless_focus) + return 0; + return g_shdata->instance_count; } @@ -847,30 +871,13 @@ g_shdata = MapViewOfFile(filemapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); } - if (!g_mutex || !filemapping || !g_shdata || vchannel_open()) + if (g_mutex && filemapping && g_shdata && vchannel_open() == 0) { - /* Clean up in reverse order */ - if (g_shdata) - { - UnmapViewOfFile(g_shdata); - } - if (filemapping) - { - CloseHandle(filemapping); - } - if (g_mutex) - { - CloseHandle(g_mutex); - } - return FALSE; + WaitForSingleObject(g_mutex, INFINITE); + ++g_shdata->instance_count; + ReleaseMutex(g_mutex); + g_wm_seamless_focus = RegisterWindowMessage(FOCUS_MSG_NAME); } - - WaitForSingleObject(g_mutex, INFINITE); - ++g_shdata->instance_count; - ReleaseMutex(g_mutex); - - g_wm_seamless_focus = RegisterWindowMessage(FOCUS_MSG_NAME); - break; case DLL_THREAD_ATTACH: @@ -880,18 +887,29 @@ break; case DLL_PROCESS_DETACH: - vchannel_write("DESTROYGRP", "0x%08lx, 0x%08lx", GetCurrentProcessId(), 0); + if (vchannel_is_open()) + { + vchannel_write("DESTROYGRP", "0x%08lx, 0x%08lx", + GetCurrentProcessId(), 0); + vchannel_close(); + } - WaitForSingleObject(g_mutex, INFINITE); - --g_shdata->instance_count; - ReleaseMutex(g_mutex); + if (g_mutex) + { + WaitForSingleObject(g_mutex, INFINITE); + if (g_shdata) + { + --g_shdata->instance_count; + UnmapViewOfFile(g_shdata); + } + ReleaseMutex(g_mutex); + CloseHandle(g_mutex); + } - vchannel_close(); - - UnmapViewOfFile(g_shdata); - CloseHandle(filemapping); - CloseHandle(g_mutex); - + if (filemapping) + { + CloseHandle(filemapping); + } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-31 10:50:20
|
Revision: 1583 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1583&view=rev Author: astrand Date: 2010-03-31 10:50:14 +0000 (Wed, 31 Mar 2010) Log Message: ----------- Handle the case where instance count is zero: Display appropriate error message. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/main.c Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-31 08:40:19 UTC (rev 1582) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-31 10:50:14 UTC (rev 1583) @@ -515,10 +515,17 @@ } /* Check if the DLL is already loaded */ - if (instance_count_fn() != 1) + switch (instance_count_fn()) { - message("Another running instance of Seamless RDP detected."); - goto close_hookdll; + case 0: + message("Hook DLL failed to initialize."); + goto close_hookdll; + break; + case 1: + break; + default: + message("Another running instance of Seamless RDP detected."); + goto close_hookdll; } helper = launch_helper(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-31 08:40:26
|
Revision: 1582 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1582&view=rev Author: astrand Date: 2010-03-31 08:40:19 +0000 (Wed, 31 Mar 2010) Log Message: ----------- Fix problem with session not terminating after running recent versions of IE, due to ieuser.exe not terminating. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/main.c Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-30 14:01:54 UTC (rev 1581) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-31 08:40:19 UTC (rev 1582) @@ -297,6 +297,12 @@ if (pinfo[i].SessionId != g_session_id) continue; + // ieuser.exe hangs around even after IE has exited + if (0 == _stricmp(pinfo[i].pProcessName, "ieuser.exe")) + { + continue; + } + for (j = 0; j < g_startup_num_procs; j++) { if (pinfo[i].ProcessId == g_startup_procs[j]) @@ -613,6 +619,11 @@ close_vchannel: vchannel_close(); + // Logoff the user. This is necessary because the session may + // have started processes that are not included in Microsofts + // list of processes to ignore. Typically ieuser.exe. + ExitWindows(0, 0); + if (success) return 1; else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-30 14:02:00
|
Revision: 1581 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1581&view=rev Author: astrand Date: 2010-03-30 14:01:54 +0000 (Tue, 30 Mar 2010) Log Message: ----------- Move back open count check; it was incorrectly moved in r1522. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/vchannel.c Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-11 09:13:58 UTC (rev 1580) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-30 14:01:54 UTC (rev 1581) @@ -128,6 +128,10 @@ EXTERN int vchannel_open() { + g_opencount++; + if (g_opencount > 1) + return 0; + g_vchannel = WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, CHANNELNAME); @@ -145,10 +149,6 @@ return -1; } - g_opencount++; - if (g_opencount > 1) - return 0; - return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-11 09:14:05
|
Revision: 1580 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1580&view=rev Author: astrand Date: 2010-03-11 09:13:58 +0000 (Thu, 11 Mar 2010) Log Message: ----------- Added test case for 32 bit apps on 64 bit system Modified Paths: -------------- rdesktop/trunk/doc/seamlessrdp-channel.txt Modified: rdesktop/trunk/doc/seamlessrdp-channel.txt =================================================================== --- rdesktop/trunk/doc/seamlessrdp-channel.txt 2010-03-10 12:56:27 UTC (rev 1579) +++ rdesktop/trunk/doc/seamlessrdp-channel.txt 2010-03-11 09:13:58 UTC (rev 1580) @@ -435,3 +435,10 @@ overlaps. From Task Manager, execute notepadbehindwordpad.exe. This test is expected to fail when rdesktop emits the warning about broken WM at startup. + + +26 If running on a 64 bit Windows version, try a 32 bit application: + Run Task Manager seamlessly (...\seamlessrdpshell.exe + taskmgr). From Task Manager's File menu, select 'New Task (Run)' + and run %windir%\syswow64\notepad.exe. Try various window + operations. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-10 12:56:36
|
Revision: 1579 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1579&view=rev Author: astrand Date: 2010-03-10 12:56:27 +0000 (Wed, 10 Mar 2010) Log Message: ----------- Support for mixing 32- and 64-bit applications. This requires a few changes: * We must provide both a 32 and 64 bit of the DLL, and Windows requires that the DLL files have different names. seamlessrdpshell.exe has been modified to load the correct DLL depending on its "bitness". * To hook 32 bit apps om a 64 bit system, a separate 32 bit process must be used. seamlessrdpshell.exe has been modified to start and stop such a process. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/Makefile.am seamlessrdp/trunk/ServerExe/configure.ac seamlessrdp/trunk/ServerExe/main.c Added Paths: ----------- seamlessrdp/trunk/ServerExe/seamlessrdphook.c Modified: seamlessrdp/trunk/ServerExe/Makefile.am =================================================================== --- seamlessrdp/trunk/ServerExe/Makefile.am 2010-03-08 08:51:37 UTC (rev 1578) +++ seamlessrdp/trunk/ServerExe/Makefile.am 2010-03-10 12:56:27 UTC (rev 1579) @@ -1,8 +1,5 @@ bin_PROGRAMS = seamlessrdpshell -lib_LTLIBRARIES = \ - seamlessrdp.la - noinst_LTLIBRARIES = libvchannel.la libvchannel_la_SOURCES = vchannel.c libvchannel_la_LIBADD = -lwtsapi32 @@ -11,6 +8,31 @@ seamlessrdpshell_LDADD = libvchannel.la -lwtsapi32 seamlessrdpshell_LDFLAGS = -mwindows -seamlessrdp_la_SOURCES = hookdll.c -seamlessrdp_la_LDFLAGS = -avoid-version -module -no-undefined -seamlessrdp_la_LIBADD = libvchannel.la -lgdi32 +if OS_IS_WIN32 +bin_PROGRAMS += seamlessrdphook32 +seamlessrdphook32_SOURCES = seamlessrdphook.c +seamlessrdphook32_LDADD = +seamlessrdphook32_LDFLAGS = -mwindows +endif + +# seamlessrdphook64 is not used in practice, but built for completeness +if OS_IS_WIN64 +bin_PROGRAMS += seamlessrdphook64 +seamlessrdphook64_SOURCES = seamlessrdphook.c +seamlessrdphook64_LDADD = +seamlessrdphook64_LDFLAGS = -mwindows +endif + +if OS_IS_WIN32 +lib_LTLIBRARIES = seamlessrdp32.la +seamlessrdp32_la_SOURCES = hookdll.c +seamlessrdp32_la_LDFLAGS = -avoid-version -module -no-undefined +seamlessrdp32_la_LIBADD = libvchannel.la -lgdi32 +endif + +if OS_IS_WIN64 +lib_LTLIBRARIES = seamlessrdp64.la +seamlessrdp64_la_SOURCES = hookdll.c +seamlessrdp64_la_LDFLAGS = -avoid-version -module -no-undefined +seamlessrdp64_la_LIBADD = libvchannel.la -lgdi32 +endif Modified: seamlessrdp/trunk/ServerExe/configure.ac =================================================================== --- seamlessrdp/trunk/ServerExe/configure.ac 2010-03-08 08:51:37 UTC (rev 1578) +++ seamlessrdp/trunk/ServerExe/configure.ac 2010-03-10 12:56:27 UTC (rev 1579) @@ -11,6 +11,19 @@ fi AC_PROG_LIBTOOL +os_is_win32=0 +os_is_win64=0 +case "$host" in + i?86-*-mingw*) + os_is_win32=1 + ;; + x86_64-*-mingw*) + os_is_win64=1 + ;; +esac +AM_CONDITIONAL(OS_IS_WIN32, test "x$os_is_win32" = "x1") +AM_CONDITIONAL(OS_IS_WIN64, test "x$os_is_win64" = "x1") + AC_LIBTOOL_WIN32_DLL AC_OUTPUT(Makefile) Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-08 08:51:37 UTC (rev 1578) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-10 12:56:27 UTC (rev 1579) @@ -33,6 +33,7 @@ #include "resource.h" #define APP_NAME "SeamlessRDP Shell" +#define HELPER_TIMEOUT 2000 /* Global data */ static DWORD g_session_id; @@ -349,7 +350,8 @@ return desk == NULL; } -static BOOL +// Returns process handle on success, or NULL on failure +static HANDLE launch_app(LPSTR cmdline) { BOOL result; @@ -362,19 +364,95 @@ result = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup_info, &proc_info); // Release handles - CloseHandle(proc_info.hProcess); CloseHandle(proc_info.hThread); - return result; + if (result) + { + return proc_info.hProcess; + } + else + { + return NULL; + } } +static HANDLE +launch_helper() +{ + HANDLE app = NULL; + SYSTEM_INFO si; + GetSystemInfo(&si); + + /* If we are running on a x64 system, hook 32 bit apps as well + by launching a 32 bit helper process. */ + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) + { + char cmd[] = "seamlessrdphook32.exe"; + app = launch_app(cmd); + if (!app) + { + char msg[256]; + _snprintf(msg, sizeof(msg), + "Unable to launch the requested application:\n%s", cmd); + message(msg); + } + + /* Wait until helper is started, so that it gets included in + the process enum */ + DWORD ret; + ret = WaitForInputIdle(app, HELPER_TIMEOUT); + switch (ret) + { + case 0: + break; + case WAIT_TIMEOUT: + case WAIT_FAILED: + message("Hooking helper failed to start within time limit"); + break; + } + } + return app; +} + + +// Ask process to quit, otherwise kill it +static void +kill_15_9(HANDLE proc, const char *wndname, DWORD timeout) +{ + HWND procwnd; + DWORD ret; + procwnd = FindWindowEx(HWND_MESSAGE, NULL, "Message", wndname); + if (procwnd) + { + PostMessage(procwnd, WM_CLOSE, 0, 0); + } + ret = WaitForSingleObject(proc, timeout); + switch (ret) + { + case WAIT_ABANDONED: + case WAIT_OBJECT_0: + break; + case WAIT_TIMEOUT: + // Still running, kill hard + if (!TerminateProcess(proc, 1)) + { + message("Unable to terminate process"); + } + break; + case WAIT_FAILED: + message("Unable to wait for process"); + break; + } +} + + int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow) { int success = 0; + HANDLE helper = NULL; + HMODULE hookdll = NULL; - HMODULE hookdll; - set_hooks_proc_t set_hooks_fn; remove_hooks_proc_t remove_hooks_fn; get_instance_count_proc_t instance_count_fn; @@ -393,7 +471,22 @@ return -1; } - hookdll = LoadLibrary("seamlessrdp.dll"); + SYSTEM_INFO si; + GetSystemInfo(&si); + switch (si.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_INTEL: + hookdll = LoadLibrary("seamlessrdp32.dll"); + break; + case PROCESSOR_ARCHITECTURE_AMD64: + hookdll = LoadLibrary("seamlessrdp64.dll"); + break; + default: + message("Unsupported processor architecture."); + break; + + } + if (!hookdll) { message("Could not load hook DLL. Unable to continue."); @@ -422,6 +515,8 @@ goto close_hookdll; } + helper = launch_helper(); + ProcessIdToSessionId(GetCurrentProcessId(), &g_session_id); build_startup_procs(); @@ -506,6 +601,11 @@ remove_hooks_fn(); free_startup_procs(); + if (helper) + { + // Terminate seamlessrdphook32.exe + kill_15_9(helper, "SeamlessRDPHook", HELPER_TIMEOUT); + } close_hookdll: FreeLibrary(hookdll); Added: seamlessrdp/trunk/ServerExe/seamlessrdphook.c =================================================================== --- seamlessrdp/trunk/ServerExe/seamlessrdphook.c (rev 0) +++ seamlessrdp/trunk/ServerExe/seamlessrdphook.c 2010-03-10 12:56:27 UTC (rev 1579) @@ -0,0 +1,106 @@ +/* -*- c-basic-offset: 8 -*- + + Copyright 2010 Peter Åstrand <astrand@...> for Cendio AB + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#define WINVER 0x0501 + +#include <windows.h> + +#include "resource.h" + +/* Global data */ +typedef void (*set_hooks_proc_t) (); +typedef int (*get_instance_count_proc_t) (); + +static void +message(const char *text) +{ + MessageBox(GetDesktopWindow(), text, "SeamlessRDP hooking", MB_OK); +} + + +int WINAPI +WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow) +{ + HMODULE hookdll = NULL; + set_hooks_proc_t set_hooks_fn; + get_instance_count_proc_t instance_count_fn; + + SYSTEM_INFO si; + GetSystemInfo(&si); + switch (si.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_INTEL: + hookdll = LoadLibrary("seamlessrdp32.dll"); + break; + case PROCESSOR_ARCHITECTURE_AMD64: + hookdll = LoadLibrary("seamlessrdp64.dll"); + break; + default: + message("Unsupported processor architecture."); + break; + + } + + if (!hookdll) + { + message("Could not load hook DLL. Unable to continue."); + return 1; + } + + set_hooks_fn = (set_hooks_proc_t) GetProcAddress(hookdll, "SetHooks"); + instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); + + if (!set_hooks_fn || !instance_count_fn) + { + message("Hook DLL doesn't contain the correct functions. Unable to continue."); + goto close_hookdll; + } + + set_hooks_fn(); + + + /* Wait until seamlessrdpshell wants us to terminate. It + cannot use PostThreadMessage, because if we are showing a + dialog, such messages are lost. Instead, we need to create + a "Message-Only Window". */ + CreateWindow("Message", "SeamlessRDPHook", 0, 0, 0, 0, 0, + HWND_MESSAGE, NULL, instance, NULL); + + MSG msg; + while (1) + { + BOOL ret; + ret = GetMessage(&msg, NULL, 0, 0); + if (ret == -1) + { + message("GetMessage failed"); + break; + } + else if (ret == 0) + { + break; + } + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + close_hookdll: + FreeLibrary(hookdll); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-08 08:51:43
|
Revision: 1578 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1578&view=rev Author: astrand Date: 2010-03-08 08:51:37 +0000 (Mon, 08 Mar 2010) Log Message: ----------- Do not use shared DLL data any longer. Instead, we are using shared memory (file mapping). The main motivation for this change is to allow mixing 32 and 64 bit Seamless applications. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-04 15:09:53 UTC (rev 1577) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-08 08:51:37 UTC (rev 1578) @@ -32,47 +32,47 @@ #define EXTERN __declspec(dllexport) -#ifdef __GNUC__ -#define SHARED __attribute__((section ("SHAREDDATA"), shared)) -#else -#define SHARED -#endif +#define FOCUS_MSG_NAME "WM_SEAMLESS_FOCUS" +static UINT g_wm_seamless_focus; -// Shared DATA -#pragma data_seg ( "SHAREDDATA" ) +static HHOOK g_cbt_hook = NULL; +static HHOOK g_wndproc_hook = NULL; +static HHOOK g_wndprocret_hook = NULL; -// this is the total number of processes this dll is currently attached to -int g_instance_count SHARED = 0; +static HINSTANCE g_instance = NULL; -// blocks for locally generated events -HWND g_block_move_hwnd SHARED = NULL; -unsigned int g_block_move_serial SHARED = 0; -RECT g_block_move SHARED = { 0, 0, 0, 0 }; +/* + The data shared between 32 and 64 bit processes contains HWNDs. On + win64, HWND is 64 bit but only 32 bits are used. Thus, our + structure only contains 32 bit, using this data type. The structure + alignment is the same on win32 and win64 (the default being 8 byte + boundaries). + */ +typedef ULONG32 HWND32; -unsigned int g_blocked_zchange_serial SHARED = 0; -HWND g_blocked_zchange[2] SHARED = { NULL, NULL }; +typedef struct _shared_variables +{ + int instance_count; -unsigned int g_blocked_focus_serial SHARED = 0; -HWND g_blocked_focus SHARED = NULL; + // blocks for locally generated events + HWND32 block_move_hwnd; + unsigned int block_move_serial; + RECT block_move; -unsigned int g_blocked_state_serial SHARED = 0; -HWND g_blocked_state_hwnd SHARED = NULL; -int g_blocked_state SHARED = -1; + unsigned int blocked_zchange_serial; + HWND32 blocked_zchange[2]; -#pragma data_seg () + unsigned int blocked_focus_serial; + HWND32 blocked_focus; -#pragma comment(linker, "/section:SHAREDDATA,rws") + unsigned int blocked_state_serial; + HWND32 blocked_state_hwnd; + int blocked_state; -#define FOCUS_MSG_NAME "WM_SEAMLESS_FOCUS" -static UINT g_wm_seamless_focus; +} shared_variables; -static HHOOK g_cbt_hook = NULL; -static HHOOK g_wndproc_hook = NULL; -static HHOOK g_wndprocret_hook = NULL; - -static HINSTANCE g_instance = NULL; - static HANDLE g_mutex = NULL; +static shared_variables *g_shdata = NULL; static BOOL is_toplevel(HWND hwnd) @@ -138,9 +138,9 @@ unsigned int serial; WaitForSingleObject(g_mutex, INFINITE); - blocked_hwnd = g_block_move_hwnd; - serial = g_block_move_serial; - memcpy(&blocked, &g_block_move, sizeof(RECT)); + blocked_hwnd = long_to_hwnd(g_shdata->block_move_hwnd); + serial = g_shdata->block_move_serial; + memcpy(&blocked, &g_shdata->block_move, sizeof(RECT)); ReleaseMutex(g_mutex); vchannel_block(); @@ -171,9 +171,9 @@ unsigned int serial; WaitForSingleObject(g_mutex, INFINITE); - serial = g_blocked_zchange_serial; - block_hwnd = g_blocked_zchange[0]; - block_behind = g_blocked_zchange[1]; + serial = g_shdata->blocked_zchange_serial; + block_hwnd = long_to_hwnd(g_shdata->blocked_zchange[0]); + block_behind = long_to_hwnd(g_shdata->blocked_zchange[1]); ReleaseMutex(g_mutex); vchannel_block(); @@ -607,7 +607,7 @@ if ((GetForegroundWindow() != hwnd) && !is_menu(hwnd)) SetForegroundWindow(hwnd); - vchannel_write("ACK", "%u", g_blocked_focus_serial); + vchannel_write("ACK", "%u", g_shdata->blocked_focus_serial); } end: @@ -630,9 +630,9 @@ LONG style; WaitForSingleObject(g_mutex, INFINITE); - blocked_hwnd = g_blocked_state_hwnd; - serial = g_blocked_state_serial; - blocked = g_blocked_state; + blocked_hwnd = long_to_hwnd(g_shdata->blocked_state_hwnd); + serial = g_shdata->blocked_state_serial; + blocked = g_shdata->blocked_state; ReleaseMutex(g_mutex); hwnd = (HWND) wparam; @@ -707,12 +707,12 @@ RECT rect; WaitForSingleObject(g_mutex, INFINITE); - g_block_move_hwnd = hwnd; - g_block_move_serial = serial; - g_block_move.left = x; - g_block_move.top = y; - g_block_move.right = x + width; - g_block_move.bottom = y + height; + g_shdata->block_move_hwnd = hwnd_to_long(hwnd); + g_shdata->block_move_serial = serial; + g_shdata->block_move.left = x; + g_shdata->block_move.top = y; + g_shdata->block_move.right = x + width; + g_shdata->block_move.bottom = y + height; ReleaseMutex(g_mutex); SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER); @@ -726,8 +726,8 @@ update_position(hwnd); WaitForSingleObject(g_mutex, INFINITE); - g_block_move_hwnd = NULL; - memset(&g_block_move, 0, sizeof(RECT)); + g_shdata->block_move_hwnd = 0; + memset(&g_shdata->block_move, 0, sizeof(RECT)); ReleaseMutex(g_mutex); } @@ -735,9 +735,9 @@ SafeZChange(unsigned int serial, HWND hwnd, HWND behind) { WaitForSingleObject(g_mutex, INFINITE); - g_blocked_zchange_serial = serial; - g_blocked_zchange[0] = hwnd; - g_blocked_zchange[1] = behind; + g_shdata->blocked_zchange_serial = serial; + g_shdata->blocked_zchange[0] = hwnd_to_long(hwnd); + g_shdata->blocked_zchange[1] = hwnd_to_long(behind); ReleaseMutex(g_mutex); if (behind == NULL) @@ -746,8 +746,8 @@ SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); WaitForSingleObject(g_mutex, INFINITE); - g_blocked_zchange[0] = NULL; - g_blocked_zchange[1] = NULL; + g_shdata->blocked_zchange[0] = 0; + g_shdata->blocked_zchange[1] = 0; ReleaseMutex(g_mutex); } @@ -755,14 +755,14 @@ SafeFocus(unsigned int serial, HWND hwnd) { WaitForSingleObject(g_mutex, INFINITE); - g_blocked_focus_serial = serial; - g_blocked_focus = hwnd; + g_shdata->blocked_focus_serial = serial; + g_shdata->blocked_focus = hwnd_to_long(hwnd); ReleaseMutex(g_mutex); SendMessage(hwnd, g_wm_seamless_focus, 0, 0); WaitForSingleObject(g_mutex, INFINITE); - g_blocked_focus = NULL; + g_shdata->blocked_focus = 0; ReleaseMutex(g_mutex); } @@ -791,9 +791,9 @@ } WaitForSingleObject(g_mutex, INFINITE); - g_blocked_state_hwnd = hwnd; - g_blocked_state_serial = serial; - g_blocked_state = state; + g_shdata->blocked_state_hwnd = hwnd_to_long(hwnd); + g_shdata->blocked_state_serial = serial; + g_shdata->blocked_state = state; ReleaseMutex(g_mutex); vchannel_unblock(); @@ -808,20 +808,21 @@ debug("Invalid state %d sent.", state); WaitForSingleObject(g_mutex, INFINITE); - g_blocked_state_hwnd = NULL; - g_blocked_state = -1; + g_shdata->blocked_state_hwnd = 0; + g_shdata->blocked_state = -1; ReleaseMutex(g_mutex); } EXTERN int GetInstanceCount() { - return g_instance_count; + return g_shdata->instance_count; } BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpReserved) { + HANDLE filemapping = NULL; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: @@ -829,17 +830,43 @@ g_instance = hinstDLL; g_mutex = CreateMutex(NULL, FALSE, "Local\\SeamlessDLL"); - if (!g_mutex) - return FALSE; - if (vchannel_open()) + filemapping = CreateFileMapping(INVALID_HANDLE_VALUE, + NULL, + PAGE_READWRITE, + 0, + sizeof(shared_variables), + "Local\\SeamlessRDPData"); + + if (filemapping) { - CloseHandle(g_mutex); + /* From MSDN: The initial contents of + the pages in a file mapping object + backed by the paging file are 0 + (zero)." */ + g_shdata = MapViewOfFile(filemapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); + } + + if (!g_mutex || !filemapping || !g_shdata || vchannel_open()) + { + /* Clean up in reverse order */ + if (g_shdata) + { + UnmapViewOfFile(g_shdata); + } + if (filemapping) + { + CloseHandle(filemapping); + } + if (g_mutex) + { + CloseHandle(g_mutex); + } return FALSE; } WaitForSingleObject(g_mutex, INFINITE); - ++g_instance_count; + ++g_shdata->instance_count; ReleaseMutex(g_mutex); g_wm_seamless_focus = RegisterWindowMessage(FOCUS_MSG_NAME); @@ -856,11 +883,13 @@ vchannel_write("DESTROYGRP", "0x%08lx, 0x%08lx", GetCurrentProcessId(), 0); WaitForSingleObject(g_mutex, INFINITE); - --g_instance_count; + --g_shdata->instance_count; ReleaseMutex(g_mutex); vchannel_close(); + UnmapViewOfFile(g_shdata); + CloseHandle(filemapping); CloseHandle(g_mutex); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-04 15:09:59
|
Revision: 1577 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1577&view=rev Author: astrand Date: 2010-03-04 15:09:53 +0000 (Thu, 04 Mar 2010) Log Message: ----------- Moved launching of application into separate function. Moved MSG variable to where it belongs. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/main.c Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-04 12:11:08 UTC (rev 1576) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-04 15:09:53 UTC (rev 1577) @@ -349,6 +349,25 @@ return desk == NULL; } +static BOOL +launch_app(LPSTR cmdline) +{ + BOOL result; + PROCESS_INFORMATION proc_info; + STARTUPINFO startup_info; + + memset(&startup_info, 0, sizeof(STARTUPINFO)); + startup_info.cb = sizeof(STARTUPINFO); + + result = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, + NULL, NULL, &startup_info, &proc_info); + // Release handles + CloseHandle(proc_info.hProcess); + CloseHandle(proc_info.hThread); + + return result; +} + int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow) { @@ -424,21 +443,7 @@ /* We don't want windows denying requests to activate windows. */ SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0); - BOOL result; - PROCESS_INFORMATION proc_info; - STARTUPINFO startup_info; - MSG msg; - - memset(&startup_info, 0, sizeof(STARTUPINFO)); - startup_info.cb = sizeof(STARTUPINFO); - - result = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, - NULL, NULL, &startup_info, &proc_info); - // Release handles - CloseHandle(proc_info.hProcess); - CloseHandle(proc_info.hThread); - - if (!result) + if (!launch_app(cmdline)) { // CreateProcess failed. char msg[256]; @@ -452,6 +457,7 @@ while (check_counter-- || !should_terminate()) { BOOL connected; + MSG msg; connected = is_connected(); if (connected && !g_connected) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-04 12:11:19
|
Revision: 1576 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1576&view=rev Author: astrand Date: 2010-03-04 12:11:08 +0000 (Thu, 04 Mar 2010) Log Message: ----------- Removed unused variable g_instance. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/main.c Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-04 12:03:43 UTC (rev 1575) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-04 12:11:08 UTC (rev 1576) @@ -35,8 +35,6 @@ #define APP_NAME "SeamlessRDP Shell" /* Global data */ -static HINSTANCE g_instance; - static DWORD g_session_id; static DWORD *g_startup_procs; static int g_startup_num_procs; @@ -364,8 +362,6 @@ int check_counter; - g_instance = instance; - if (strlen(cmdline) == 0) { message("No command line specified."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-04 12:03:49
|
Revision: 1575 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1575&view=rev Author: astrand Date: 2010-03-04 12:03:43 +0000 (Thu, 04 Mar 2010) Log Message: ----------- Update my copyright. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c seamlessrdp/trunk/ServerExe/main.c seamlessrdp/trunk/ServerExe/vchannel.c seamlessrdp/trunk/ServerExe/vchannel.h Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-03 13:03:07 UTC (rev 1574) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-04 12:03:43 UTC (rev 1575) @@ -4,7 +4,7 @@ Based on code copyright (C) 2004-2005 Martin Wickett - Copyright 2005-2008 Peter Åstrand <astrand@...> for Cendio AB + Copyright 2005-2010 Peter Åstrand <astrand@...> for Cendio AB Copyright 2006-2008 Pierre Ossman <ossman@...> for Cendio AB This program is free software: you can redistribute it and/or modify Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-03 13:03:07 UTC (rev 1574) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-04 12:03:43 UTC (rev 1575) @@ -4,7 +4,7 @@ Based on code copyright (C) 2004-2005 Martin Wickett - Copyright (C) Peter Åstrand <astrand@...> 2005-2006 + Copyright 2005-2010 Peter Åstrand <astrand@...> for Cendio AB Copyright (C) Pierre Ossman <ossman@...> 2006 This program is free software: you can redistribute it and/or modify Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-03 13:03:07 UTC (rev 1574) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-04 12:03:43 UTC (rev 1575) @@ -3,6 +3,7 @@ Seamless windows - Virtual channel handling Copyright (C) Pierre Ossman <ossman@...> 2006 + Copyright 2010 Peter Åstrand <astrand@...> for Cendio AB This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by Modified: seamlessrdp/trunk/ServerExe/vchannel.h =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.h 2010-03-03 13:03:07 UTC (rev 1574) +++ seamlessrdp/trunk/ServerExe/vchannel.h 2010-03-04 12:03:43 UTC (rev 1575) @@ -3,6 +3,7 @@ Seamless windows - Virtual channel handling Copyright (C) Pierre Ossman <ossman@...> 2006 + Copyright 2010 Peter Åstrand <astrand@...> for Cendio AB This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-03 13:03:15
|
Revision: 1574 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1574&view=rev Author: astrand Date: 2010-03-03 13:03:07 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Use -Wall if GCC Modified Paths: -------------- seamlessrdp/trunk/ServerExe/configure.ac Modified: seamlessrdp/trunk/ServerExe/configure.ac =================================================================== --- seamlessrdp/trunk/ServerExe/configure.ac 2010-03-03 12:39:26 UTC (rev 1573) +++ seamlessrdp/trunk/ServerExe/configure.ac 2010-03-03 13:03:07 UTC (rev 1574) @@ -6,6 +6,9 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AC_PROG_CC +if test "$GCC" = yes; then + CFLAGS="$CFLAGS -Wall" +fi AC_PROG_LIBTOOL AC_LIBTOOL_WIN32_DLL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-03 12:39:32
|
Revision: 1573 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1573&view=rev Author: astrand Date: 2010-03-03 12:39:26 +0000 (Wed, 03 Mar 2010) Log Message: ----------- debug calls shouldn't append newline. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-03 10:05:13 UTC (rev 1572) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-03 12:39:26 UTC (rev 1573) @@ -147,7 +147,7 @@ if (!GetWindowRect(hwnd, &rect)) { - debug("GetWindowRect failed!\n"); + debug("GetWindowRect failed!"); goto end; } @@ -720,7 +720,7 @@ vchannel_write("ACK", "%u", serial); if (!GetWindowRect(hwnd, &rect)) - debug("GetWindowRect failed!\n"); + debug("GetWindowRect failed!"); else if ((rect.left != x) || (rect.top != y) || (rect.right != x + width) || (rect.bottom != y + height)) update_position(hwnd); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-03 10:05:19
|
Revision: 1572 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1572&view=rev Author: astrand Date: 2010-03-03 10:05:13 +0000 (Wed, 03 Mar 2010) Log Message: ----------- INT_MAX is in limits.h Modified Paths: -------------- seamlessrdp/trunk/ServerExe/vchannel.c Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-03 08:35:05 UTC (rev 1571) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-03 10:05:13 UTC (rev 1572) @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdarg.h> #include <errno.h> +#include <limits.h> #include <windows.h> #include <wtsapi32.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-03 08:35:11
|
Revision: 1571 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1571&view=rev Author: astrand Date: 2010-03-03 08:35:05 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Don't make a DLL out of vchannel any longer. Instead, link it statically into seamlessrdp.dll and seamlessrdpshell.exe. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/Makefile.am Modified: seamlessrdp/trunk/ServerExe/Makefile.am =================================================================== --- seamlessrdp/trunk/ServerExe/Makefile.am 2010-03-02 16:24:50 UTC (rev 1570) +++ seamlessrdp/trunk/ServerExe/Makefile.am 2010-03-03 08:35:05 UTC (rev 1571) @@ -1,17 +1,16 @@ bin_PROGRAMS = seamlessrdpshell lib_LTLIBRARIES = \ - vchannel.la \ seamlessrdp.la +noinst_LTLIBRARIES = libvchannel.la +libvchannel_la_SOURCES = vchannel.c +libvchannel_la_LIBADD = -lwtsapi32 + seamlessrdpshell_SOURCES = main.c -seamlessrdpshell_LDADD = vchannel.la +seamlessrdpshell_LDADD = libvchannel.la -lwtsapi32 seamlessrdpshell_LDFLAGS = -mwindows -vchannel_la_SOURCES = vchannel.c vchannel.h -vchannel_la_LDFLAGS = -avoid-version -module -no-undefined -lwtsapi32 - seamlessrdp_la_SOURCES = hookdll.c -seamlessrdp_la_LIBADD = vchannel.la -seamlessrdp_la_LDFLAGS = -avoid-version -module -no-undefined -lgdi32 - +seamlessrdp_la_LDFLAGS = -avoid-version -module -no-undefined +seamlessrdp_la_LIBADD = libvchannel.la -lgdi32 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-02 16:24:56
|
Revision: 1570 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1570&view=rev Author: astrand Date: 2010-03-02 16:24:50 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Eliminate the usage of shared DLL data. Besides being ugly, this mechanism does not work when mixing 32 and 64 bit applications. We are instead using a named semaphore as a counter. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/vchannel.c Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-02 10:28:51 UTC (rev 1569) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-02 16:24:50 UTC (rev 1570) @@ -34,23 +34,9 @@ #define INVALID_CHARS "," #define REPLACEMENT_CHAR '_' -#ifdef __GNUC__ -#define SHARED __attribute__((section ("SHAREDDATA"), shared)) -#else -#define SHARED -#endif - -// Shared DATA -#pragma data_seg ( "SHAREDDATA" ) - -unsigned int g_vchannel_serial SHARED = 0; - -#pragma data_seg () - -#pragma comment(linker, "/section:SHAREDDATA,rws") - static HANDLE g_mutex = NULL; static HANDLE g_vchannel = NULL; +static HANDLE g_vchannel_serial = NULL; static unsigned int g_opencount = 0; EXTERN void @@ -147,7 +133,10 @@ return -1; g_mutex = CreateMutex(NULL, FALSE, "Local\\SeamlessChannel"); - if (!g_mutex) + + g_vchannel_serial = CreateSemaphore(NULL, 0, INT_MAX, "Local\\SeamlessRDPSerial"); + + if (!g_mutex || !g_vchannel_serial) { WTSVirtualChannelClose(g_vchannel); g_vchannel = NULL; @@ -265,13 +254,27 @@ char buf[VCHANNEL_MAX_LINE]; int size; ULONG bytes_written; + LONG prev_serial; assert(vchannel_is_open()); WaitForSingleObject(g_mutex, INFINITE); - size = _snprintf(buf, sizeof(buf), "%s,%u,", command, g_vchannel_serial); + /* Increase serial */ + if (!ReleaseSemaphore(g_vchannel_serial, 1, &prev_serial)) + { + if (GetLastError() == ERROR_TOO_MANY_POSTS) + { + /* Reset serial to zero */ + while (WaitForSingleObject(g_vchannel_serial, 0) == WAIT_OBJECT_0); + if (!ReleaseSemaphore(g_vchannel_serial, 1, &prev_serial)) + { + return -1; + } + } + } + size = _snprintf(buf, sizeof(buf), "%s,%u,", command, prev_serial); assert(size < sizeof(buf)); va_start(argp, format); @@ -283,8 +286,6 @@ result = WTSVirtualChannelWrite(g_vchannel, buf, (ULONG) strlen(buf), &bytes_written); result = WTSVirtualChannelWrite(g_vchannel, "\n", (ULONG) 1, &bytes_written); - g_vchannel_serial++; - ReleaseMutex(g_mutex); if (!result) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-02 10:28:57
|
Revision: 1569 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1569&view=rev Author: astrand Date: 2010-03-02 10:28:51 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Slightly newer INSTALL file Modified Paths: -------------- seamlessrdp/trunk/ServerExe/INSTALL Modified: seamlessrdp/trunk/ServerExe/INSTALL =================================================================== --- seamlessrdp/trunk/ServerExe/INSTALL 2010-03-02 09:47:54 UTC (rev 1568) +++ seamlessrdp/trunk/ServerExe/INSTALL 2010-03-02 10:28:51 UTC (rev 1569) @@ -2,7 +2,7 @@ ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008 Free Software Foundation, Inc. +2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -159,7 +159,7 @@ CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: - ./configure CC="cc -Ae" + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. @@ -174,6 +174,16 @@ ./configure CC="cc -nodtk" + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + Specifying the System Type ========================== @@ -189,7 +199,8 @@ where SYSTEM can have one of these forms: - OS KERNEL-OS + OS + KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-02 09:48:00
|
Revision: 1568 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1568&view=rev Author: astrand Date: 2010-03-02 09:47:54 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Eliminate build errors and warnings on win64. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c seamlessrdp/trunk/ServerExe/main.c seamlessrdp/trunk/ServerExe/vchannel.c seamlessrdp/trunk/ServerExe/vchannel.h Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-02 09:46:44 UTC (rev 1567) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-02 09:47:54 UTC (rev 1568) @@ -232,7 +232,7 @@ if (icon) return icon; - icon = (HICON) GetClassLong(hwnd, large ? GCL_HICON : GCL_HICONSM); + icon = (HICON) GetClassLongPtr(hwnd, large ? GCLP_HICON : GCLP_HICONSM); if (icon) return icon; @@ -423,8 +423,8 @@ flags |= SEAMLESS_CREATE_TOPMOST; vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x", - (long) hwnd, (long) pid, - (long) get_parent(hwnd), flags); + hwnd_to_long(hwnd), (long) pid, + hwnd_to_long(get_parent(hwnd)), flags); GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title)); Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-02 09:46:44 UTC (rev 1567) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-02 09:47:54 UTC (rev 1568) @@ -113,7 +113,7 @@ return TRUE; if (styles & WS_POPUP) - parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT); + parent = (HWND) GetWindowLongPtr(hwnd, GWLP_HWNDPARENT); else parent = NULL; @@ -123,8 +123,8 @@ if (styles & DS_MODALFRAME) flags |= SEAMLESS_CREATE_MODAL; - vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x", (long) hwnd, (long) pid, - (long) parent, flags); + vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x", + hwnd_to_long(hwnd), (long) pid, hwnd_to_long(parent), flags); if (!GetWindowRect(hwnd, &rect)) { @@ -222,20 +222,20 @@ if (strcmp(tok1, "SYNC") == 0) do_sync(); else if (strcmp(tok1, "STATE") == 0) - do_state(strtoul(tok2, NULL, 0), (HWND) strtoul(tok3, NULL, 0), + do_state(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), strtol(tok4, NULL, 0)); else if (strcmp(tok1, "POSITION") == 0) - do_position(strtoul(tok2, NULL, 0), (HWND) strtoul(tok3, NULL, 0), + do_position(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), strtol(tok4, NULL, 0), strtol(tok5, NULL, 0), strtol(tok6, NULL, 0), strtol(tok7, NULL, 0)); else if (strcmp(tok1, "ZCHANGE") == 0) - do_zchange(strtoul(tok2, NULL, 0), (HWND) strtoul(tok3, NULL, 0), - (HWND) strtoul(tok4, NULL, 0)); + do_zchange(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), + long_to_hwnd(strtoul(tok4, NULL, 0))); else if (strcmp(tok1, "FOCUS") == 0) - do_focus(strtoul(tok2, NULL, 0), (HWND) strtoul(tok3, NULL, 0)); + do_focus(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0))); else if (strcmp(tok1, "DESTROY") == 0) - do_destroy((HWND) strtoul(tok3, NULL, 0)); + do_destroy(long_to_hwnd(strtoul(tok3, NULL, 0))); } } Modified: seamlessrdp/trunk/ServerExe/vchannel.c =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-02 09:46:44 UTC (rev 1567) +++ seamlessrdp/trunk/ServerExe/vchannel.c 2010-03-02 09:47:54 UTC (rev 1568) @@ -68,6 +68,27 @@ vchannel_write("DEBUG", buf); } +/* + From http://msdn.microsoft.com/en-us/library/aa384203(VS.85).aspx: + "64-bit versions of Windows use 32-bit handles for interoperability." + */ +long +hwnd_to_long(HWND hwnd) +{ + DWORD_PTR val; + val = (DWORD_PTR) hwnd; + return val; +} + +HWND +long_to_hwnd(long l) +{ + DWORD_PTR val; + val = l; + return (HWND) val; +} + + #define CONVERT_BUFFER_SIZE 1024 static char convert_buffer[CONVERT_BUFFER_SIZE]; Modified: seamlessrdp/trunk/ServerExe/vchannel.h =================================================================== --- seamlessrdp/trunk/ServerExe/vchannel.h 2010-03-02 09:46:44 UTC (rev 1567) +++ seamlessrdp/trunk/ServerExe/vchannel.h 2010-03-02 09:47:54 UTC (rev 1568) @@ -33,6 +33,9 @@ EXTERN void debug(char *format, ...); +EXTERN long hwnd_to_long(HWND hwnd); +EXTERN HWND long_to_hwnd(long val); + EXTERN const char *unicode_to_utf8(const unsigned short *string); EXTERN int vchannel_open(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-02 09:46:50
|
Revision: 1567 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1567&view=rev Author: astrand Date: 2010-03-02 09:46:44 +0000 (Tue, 02 Mar 2010) Log Message: ----------- seamlessrdpshell.exe should not be a console application. Modified Paths: -------------- seamlessrdp/trunk/ServerExe/Makefile.am Modified: seamlessrdp/trunk/ServerExe/Makefile.am =================================================================== --- seamlessrdp/trunk/ServerExe/Makefile.am 2010-03-02 07:53:43 UTC (rev 1566) +++ seamlessrdp/trunk/ServerExe/Makefile.am 2010-03-02 09:46:44 UTC (rev 1567) @@ -6,6 +6,7 @@ seamlessrdpshell_SOURCES = main.c seamlessrdpshell_LDADD = vchannel.la +seamlessrdpshell_LDFLAGS = -mwindows vchannel_la_SOURCES = vchannel.c vchannel.h vchannel_la_LDFLAGS = -avoid-version -module -no-undefined -lwtsapi32 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-02 07:53:50
|
Revision: 1566 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1566&view=rev Author: astrand Date: 2010-03-02 07:53:43 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Indented Modified Paths: -------------- seamlessrdp/trunk/ServerExe/hookdll.c seamlessrdp/trunk/ServerExe/main.c Modified: seamlessrdp/trunk/ServerExe/hookdll.c =================================================================== --- seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-02 07:51:59 UTC (rev 1565) +++ seamlessrdp/trunk/ServerExe/hookdll.c 2010-03-02 07:53:43 UTC (rev 1566) @@ -832,7 +832,8 @@ if (!g_mutex) return FALSE; - if (vchannel_open()) { + if (vchannel_open()) + { CloseHandle(g_mutex); return FALSE; } Modified: seamlessrdp/trunk/ServerExe/main.c =================================================================== --- seamlessrdp/trunk/ServerExe/main.c 2010-03-02 07:51:59 UTC (rev 1565) +++ seamlessrdp/trunk/ServerExe/main.c 2010-03-02 07:53:43 UTC (rev 1566) @@ -442,7 +442,8 @@ CloseHandle(proc_info.hProcess); CloseHandle(proc_info.hThread); - if (!result) { + if (!result) + { // CreateProcess failed. char msg[256]; _snprintf(msg, sizeof(msg), @@ -462,8 +463,7 @@ int flags; /* These get reset on each reconnect */ SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0); - SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, - 0); + SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0); flags = SEAMLESS_HELLO_RECONNECT; @@ -500,19 +500,19 @@ success = 1; -unhook: + unhook: remove_hooks_fn(); free_startup_procs(); -close_hookdll: + close_hookdll: FreeLibrary(hookdll); -close_vchannel: + close_vchannel: vchannel_close(); if (success) - return 1; + return 1; else return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <astrand@us...> - 2010-03-02 07:52:09
|
Revision: 1565 http://rdesktop.svn.sourceforge.net/rdesktop/?rev=1565&view=rev Author: astrand Date: 2010-03-02 07:51:59 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Adapted; HookDll is no longer Modified Paths: -------------- seamlessrdp/trunk/indent-all Modified: seamlessrdp/trunk/indent-all =================================================================== --- seamlessrdp/trunk/indent-all 2010-02-18 14:54:50 UTC (rev 1564) +++ seamlessrdp/trunk/indent-all 2010-03-02 07:51:59 UTC (rev 1565) @@ -1,2 +1,2 @@ #!/bin/sh -indent -bli0 -i8 -cli8 -npcs -l100 ServerExe/*.h ServerExe/*.c ServerExe/HookDll/*.c +indent -bli0 -i8 -cli8 -npcs -l100 ServerExe/*.h ServerExe/*.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |