60 |
return; |
return; |
61 |
} |
} |
62 |
|
|
63 |
vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x", |
vchannel_write("POSITION,0x%p,%d,%d,%d,%d,0x%x", |
64 |
hwnd, |
hwnd, |
65 |
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); |
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); |
66 |
} |
} |
68 |
static LRESULT CALLBACK |
static LRESULT CALLBACK |
69 |
wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details) |
wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details) |
70 |
{ |
{ |
71 |
HWND hwnd; |
HWND hwnd, parent; |
72 |
UINT msg; |
UINT msg; |
73 |
WPARAM wparam; |
WPARAM wparam; |
74 |
LPARAM lparam; |
LPARAM lparam; |
85 |
|
|
86 |
style = GetWindowLong(hwnd, GWL_STYLE); |
style = GetWindowLong(hwnd, GWL_STYLE); |
87 |
|
|
88 |
if (style & WS_CHILD) |
/* Docs say that WS_CHILD and WS_POPUP is an illegal combination, |
89 |
|
but they exist nonetheless. */ |
90 |
|
if ((style & WS_CHILD) && !(style & WS_POPUP)) |
91 |
goto end; |
goto end; |
92 |
|
|
93 |
|
if (style & WS_POPUP) |
94 |
|
{ |
95 |
|
parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT); |
96 |
|
if (!parent) |
97 |
|
parent = (HWND) - 1; |
98 |
|
} |
99 |
|
else |
100 |
|
parent = NULL; |
101 |
|
|
102 |
switch (msg) |
switch (msg) |
103 |
{ |
{ |
104 |
|
|
108 |
|
|
109 |
if (wp->flags & SWP_SHOWWINDOW) |
if (wp->flags & SWP_SHOWWINDOW) |
110 |
{ |
{ |
111 |
// FIXME: Now, just like create! |
char title[150]; |
112 |
debug("SWP_SHOWWINDOW for %p!", hwnd); |
int state; |
113 |
vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0); |
|
114 |
|
vchannel_write("CREATE,0x%p,0x%p,0x%x", hwnd, parent, 0); |
115 |
|
|
116 |
|
GetWindowText(hwnd, title, sizeof(title)); |
117 |
|
|
118 |
|
vchannel_write("TITLE,0x%x,%s,0x%x", hwnd, |
119 |
|
vchannel_strfilter(title), 0); |
120 |
|
|
121 |
|
if (style & WS_MAXIMIZE) |
122 |
|
state = 2; |
123 |
|
else if (style & WS_MINIMIZE) |
124 |
|
state = 1; |
125 |
|
else |
126 |
|
state = 0; |
127 |
|
|
128 |
// FIXME: SETSTATE |
vchannel_write("STATE,0x%p,0x%x,0x%x", hwnd, state, 0); |
129 |
|
|
130 |
update_position(hwnd); |
update_position(hwnd); |
131 |
|
|
132 |
|
/* FIXME: Figure out z order */ |
133 |
} |
} |
134 |
|
|
135 |
if (wp->flags & SWP_HIDEWINDOW) |
if (wp->flags & SWP_HIDEWINDOW) |
136 |
vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0); |
vchannel_write("DESTROY,0x%p,0x%x", hwnd, 0); |
137 |
|
|
138 |
if (!(style & WS_VISIBLE)) |
if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) |
139 |
break; |
break; |
140 |
|
|
141 |
if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)) |
if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)) |
143 |
|
|
144 |
if (!(wp->flags & SWP_NOZORDER)) |
if (!(wp->flags & SWP_NOZORDER)) |
145 |
{ |
{ |
146 |
vchannel_write("ZCHANGE1,0x%p,0x%p,0x%x", |
vchannel_write("ZCHANGE,0x%p,0x%p,0x%x", |
147 |
hwnd, |
hwnd, |
148 |
wp->flags & SWP_NOACTIVATE ? wp-> |
wp->flags & SWP_NOACTIVATE ? wp-> |
149 |
hwndInsertAfter : 0, 0); |
hwndInsertAfter : 0, 0); |
153 |
} |
} |
154 |
|
|
155 |
case WM_SIZE: |
case WM_SIZE: |
156 |
|
if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) |
157 |
|
break; |
158 |
update_position(hwnd); |
update_position(hwnd); |
159 |
break; |
break; |
160 |
|
|
161 |
case WM_MOVE: |
case WM_MOVE: |
162 |
|
if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE)) |
163 |
|
break; |
164 |
update_position(hwnd); |
update_position(hwnd); |
165 |
break; |
break; |
166 |
|
|
167 |
|
case WM_SETTEXT: |
168 |
|
{ |
169 |
|
char *title; |
170 |
|
if (!(style & WS_VISIBLE)) |
171 |
|
break; |
172 |
|
title = _strdup((char *) lparam); |
173 |
|
vchannel_write("TITLE,0x%p,%s,0x%x", hwnd, |
174 |
|
vchannel_strfilter(title), 0); |
175 |
|
free(title); |
176 |
|
break; |
177 |
|
} |
178 |
|
|
179 |
case WM_DESTROY: |
case WM_DESTROY: |
180 |
vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0); |
if (!(style & WS_VISIBLE)) |
181 |
|
break; |
182 |
|
vchannel_write("DESTROY,0x%p,0x%x", hwnd, 0); |
183 |
break; |
break; |
184 |
|
|
185 |
default: |
default: |
193 |
static LRESULT CALLBACK |
static LRESULT CALLBACK |
194 |
cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam) |
cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam) |
195 |
{ |
{ |
|
char title[150]; |
|
|
|
|
196 |
if (code < 0) |
if (code < 0) |
197 |
goto end; |
goto end; |
198 |
|
|
204 |
|
|
205 |
show = LOWORD(lparam); |
show = LOWORD(lparam); |
206 |
|
|
207 |
if ((show == SW_SHOWMINIMIZED) || (show == SW_MINIMIZE)) |
if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL) |
208 |
{ |
|| (show == SW_RESTORE)) |
|
MessageBox(0, |
|
|
"Minimizing windows is not allowed in this version. Sorry!", |
|
|
"SeamlessRDP", MB_OK); |
|
|
return 1; |
|
|
} |
|
|
|
|
|
GetWindowText((HWND) wparam, title, sizeof(title)); |
|
|
|
|
|
/* FIXME: Strip title of dangerous characters */ |
|
|
|
|
|
if (show == SW_SHOWNORMAL) |
|
209 |
state = 0; |
state = 0; |
210 |
else if (show == SW_SHOWMINIMIZED) |
else if ((show == SW_MINIMIZE) || (show == SW_SHOWMINIMIZED)) |
211 |
state = 1; |
state = 1; |
212 |
else if (show == SW_SHOWMAXIMIZED) |
else if ((show == SW_MAXIMIZE) || (show == SW_SHOWMAXIMIZED)) |
213 |
state = 2; |
state = 2; |
214 |
vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x", |
else |
215 |
(HWND) wparam, title, state, 0); |
{ |
216 |
|
debug("Unexpected show: %d", show); |
217 |
|
break; |
218 |
|
} |
219 |
|
vchannel_write("STATE,0x%p,0x%x,0x%x", (HWND) wparam, state, 0); |
220 |
break; |
break; |
221 |
} |
} |
222 |
|
|