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 |
|
typedef void (*set_state_proc_t) (HWND hwnd, int state); |
55 |
|
|
56 |
static move_window_proc_t g_move_window_fn = NULL; |
static move_window_proc_t g_move_window_fn = NULL; |
57 |
|
static zchange_proc_t g_zchange_fn = NULL; |
58 |
|
static focus_proc_t g_focus_fn = NULL; |
59 |
|
static set_state_proc_t g_set_state_fn = NULL; |
60 |
|
|
61 |
static void |
static void |
62 |
message(const char *text) |
message(const char *text) |
151 |
static void |
static void |
152 |
do_state(HWND hwnd, int state) |
do_state(HWND hwnd, int state) |
153 |
{ |
{ |
154 |
if (state == 0) |
g_set_state_fn(hwnd, state); |
|
ShowWindow(hwnd, SW_RESTORE); |
|
|
else if (state == 1) |
|
|
ShowWindow(hwnd, SW_MINIMIZE); |
|
|
else if (state == 2) |
|
|
ShowWindow(hwnd, SW_MAXIMIZE); |
|
|
else |
|
|
debug("Invalid state %d sent.", state); |
|
155 |
} |
} |
156 |
|
|
157 |
static void |
static void |
163 |
static void |
static void |
164 |
do_zchange(HWND hwnd, HWND behind) |
do_zchange(HWND hwnd, HWND behind) |
165 |
{ |
{ |
166 |
if (behind == NULL) |
g_zchange_fn(hwnd, behind); |
167 |
behind = HWND_TOP; |
} |
168 |
SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); |
|
169 |
|
static void |
170 |
|
do_focus(HWND hwnd) |
171 |
|
{ |
172 |
|
g_focus_fn(hwnd); |
173 |
} |
} |
174 |
|
|
175 |
static void |
static void |
203 |
0)); |
0)); |
204 |
else if (strcmp(tok1, "ZCHANGE") == 0) |
else if (strcmp(tok1, "ZCHANGE") == 0) |
205 |
do_zchange((HWND) strtoul(tok2, NULL, 0), (HWND) strtoul(tok3, NULL, 0)); |
do_zchange((HWND) strtoul(tok2, NULL, 0), (HWND) strtoul(tok3, NULL, 0)); |
206 |
|
else if (strcmp(tok1, "FOCUS") == 0) |
207 |
|
do_focus((HWND) strtoul(tok2, NULL, 0)); |
208 |
} |
} |
209 |
} |
} |
210 |
|
|
214 |
if (message == WM_WTSSESSION_CHANGE) |
if (message == WM_WTSSESSION_CHANGE) |
215 |
{ |
{ |
216 |
if (wparam == WTS_REMOTE_CONNECT) |
if (wparam == WTS_REMOTE_CONNECT) |
217 |
|
{ |
218 |
|
/* These get reset on each reconnect */ |
219 |
|
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0); |
220 |
|
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0); |
221 |
vchannel_write("HELLO,0x%08x", 1); |
vchannel_write("HELLO,0x%08x", 1); |
222 |
|
} |
223 |
} |
} |
224 |
|
|
225 |
return DefWindowProc(hwnd, message, wparam, lparam); |
return DefWindowProc(hwnd, message, wparam, lparam); |
282 |
remove_hooks_fn = (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); |
remove_hooks_fn = (remove_hooks_proc_t) GetProcAddress(hookdll, "RemoveHooks"); |
283 |
instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); |
instance_count_fn = (get_instance_count_proc_t) GetProcAddress(hookdll, "GetInstanceCount"); |
284 |
g_move_window_fn = (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); |
g_move_window_fn = (move_window_proc_t) GetProcAddress(hookdll, "SafeMoveWindow"); |
285 |
|
g_zchange_fn = (zchange_proc_t) GetProcAddress(hookdll, "SafeZChange"); |
286 |
|
g_focus_fn = (focus_proc_t) GetProcAddress(hookdll, "SafeFocus"); |
287 |
|
g_set_state_fn = (set_state_proc_t) GetProcAddress(hookdll, "SafeSetState"); |
288 |
|
|
289 |
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 |
290 |
|
|| !g_zchange_fn || !g_focus_fn || !g_set_state_fn) |
291 |
{ |
{ |
292 |
FreeLibrary(hookdll); |
FreeLibrary(hookdll); |
293 |
message("Hook DLL doesn't contain the correct functions. Unable to continue."); |
message("Hook DLL doesn't contain the correct functions. Unable to continue."); |