33 |
|
|
34 |
#define APP_NAME "SeamlessRDP Shell" |
#define APP_NAME "SeamlessRDP Shell" |
35 |
|
|
|
#define FOCUS_MSG_NAME "WM_SEAMLESS_FOCUS" |
|
|
static UINT g_wm_seamless_focus; |
|
|
|
|
36 |
#ifndef WM_WTSSESSION_CHANGE |
#ifndef WM_WTSSESSION_CHANGE |
37 |
#define WM_WTSSESSION_CHANGE 0x02B1 |
#define WM_WTSSESSION_CHANGE 0x02B1 |
38 |
#endif |
#endif |
49 |
typedef int (*get_instance_count_proc_t) (); |
typedef int (*get_instance_count_proc_t) (); |
50 |
|
|
51 |
typedef void (*move_window_proc_t) (HWND hwnd, int x, int y, int width, int height); |
typedef void (*move_window_proc_t) (HWND hwnd, int x, int y, int width, int height); |
52 |
|
typedef void (*zchange_proc_t) (HWND hwnd, HWND behind); |
53 |
|
typedef void (*focus_proc_t) (HWND hwnd); |
54 |
|
|
55 |
static move_window_proc_t g_move_window_fn = NULL; |
static move_window_proc_t g_move_window_fn = NULL; |
56 |
|
static zchange_proc_t g_zchange_fn = NULL; |
57 |
|
static focus_proc_t g_focus_fn = NULL; |
58 |
|
|
59 |
static void |
static void |
60 |
message(const char *text) |
message(const char *text) |
168 |
static void |
static void |
169 |
do_zchange(HWND hwnd, HWND behind) |
do_zchange(HWND hwnd, HWND behind) |
170 |
{ |
{ |
171 |
if (behind == NULL) |
g_zchange_fn(hwnd, behind); |
|
behind = HWND_TOP; |
|
|
SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); |
|
172 |
} |
} |
173 |
|
|
174 |
static void |
static void |
175 |
do_focus(HWND hwnd) |
do_focus(HWND hwnd) |
176 |
{ |
{ |
177 |
SendMessage(hwnd, g_wm_seamless_focus, 0, 0); |
g_focus_fn(hwnd); |
178 |
} |
} |
179 |
|
|
180 |
static void |
static void |
287 |
remove_hooks_fn = (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); |
remove_hooks_fn = (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); |
288 |
instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); |
instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); |
289 |
g_move_window_fn = (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); |
g_move_window_fn = (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); |
290 |
|
g_zchange_fn = (zchange_proc_t) GetProcAddress(hookdll, "SafeZChange"); |
291 |
|
g_focus_fn = (focus_proc_t) GetProcAddress(hookdll, "SafeFocus"); |
292 |
|
|
293 |
if (!set_hooks_fn || !remove_hooks_fn || !instance_count_fn || !g_move_window_fn) |
if (!set_hooks_fn || !remove_hooks_fn || !instance_count_fn || !g_move_window_fn |
294 |
|
|| !g_zchange_fn || !g_focus_fn) |
295 |
{ |
{ |
296 |
FreeLibrary(hookdll); |
FreeLibrary(hookdll); |
297 |
message("Hook DLL doesn't contain the correct functions. Unable to continue."); |
message("Hook DLL doesn't contain the correct functions. Unable to continue."); |
313 |
return -1; |
return -1; |
314 |
} |
} |
315 |
|
|
|
g_wm_seamless_focus = RegisterWindowMessage(FOCUS_MSG_NAME); |
|
|
|
|
316 |
WTSRegisterSessionNotification(g_hwnd, NOTIFY_FOR_THIS_SESSION); |
WTSRegisterSessionNotification(g_hwnd, NOTIFY_FOR_THIS_SESSION); |
317 |
|
|
318 |
vchannel_open(); |
vchannel_open(); |