/[rdesktop]/sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1167 by ossman_, Mon Mar 20 14:35:02 2006 UTC revision 1233 by ossman_, Fri Apr 28 07:56:57 2006 UTC
# Line 99  update_position(HWND hwnd) Line 99  update_position(HWND hwnd)
99              && (rect.right == blocked.right) && (rect.bottom == blocked.bottom))              && (rect.right == blocked.right) && (rect.bottom == blocked.bottom))
100                  goto end;                  goto end;
101    
102          vchannel_write("POSITION", "0x%p,%d,%d,%d,%d,0x%x",          vchannel_write("POSITION", "0x%08lx,%d,%d,%d,%d,0x%08x",
103                         hwnd,                         hwnd,
104                         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);
105    
# Line 138  update_zorder(HWND hwnd) Line 138  update_zorder(HWND hwnd)
138          if ((hwnd == block_hwnd) && (behind == block_behind))          if ((hwnd == block_hwnd) && (behind == block_behind))
139                  vchannel_write("ACK", "%u", serial);                  vchannel_write("ACK", "%u", serial);
140          else          else
141                  vchannel_write("ZCHANGE", "0x%p,0x%p,0x%x", hwnd, behind, 0);                  vchannel_write("ZCHANGE", "0x%08lx,0x%08lx,0x%08x", hwnd, behind, 0);
142    
143          vchannel_unblock();          vchannel_unblock();
144  }  }
145    
146    static HWND
147    get_parent(HWND hwnd)
148    {
149            LONG style;
150            HWND parent;
151    
152            style = GetWindowLong(hwnd, GWL_STYLE);
153    
154            if (style & (WS_POPUP | DS_MODALFRAME))
155            {
156                    parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);
157    
158                    if (parent)
159                    {
160                            style = GetWindowLong(parent, GWL_STYLE);
161                            if (((style & WS_CHILD) && !(style & WS_POPUP)) || !(style & WS_VISIBLE))
162                                    parent = NULL;
163                    }
164    
165                    if (!parent)
166                            parent = GetWindow(hwnd, GW_OWNER);
167    
168                    if (parent)
169                    {
170                            style = GetWindowLong(parent, GWL_STYLE);
171                            if (((style & WS_CHILD) && !(style & WS_POPUP)) || !(style & WS_VISIBLE))
172                                    parent = NULL;
173                    }
174    
175                    if (!parent)
176                            parent = (HWND) - 1;
177            }
178            else
179                    parent = NULL;
180    
181            return parent;
182    }
183    
184  static LRESULT CALLBACK  static LRESULT CALLBACK
185  wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)  wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
186  {  {
# Line 168  wndproc_hook_proc(int code, WPARAM cur_t Line 206  wndproc_hook_proc(int code, WPARAM cur_t
206          if ((style & WS_CHILD) && !(style & WS_POPUP))          if ((style & WS_CHILD) && !(style & WS_POPUP))
207                  goto end;                  goto end;
208    
209          if (style & WS_POPUP)          parent = get_parent(hwnd);
         {  
                 parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);  
                 if (!parent)  
                         parent = (HWND) - 1;  
         }  
         else  
                 parent = NULL;  
210    
211          switch (msg)          switch (msg)
212          {          {
# Line 187  wndproc_hook_proc(int code, WPARAM cur_t Line 218  wndproc_hook_proc(int code, WPARAM cur_t
218                                  {                                  {
219                                          unsigned short title[150];                                          unsigned short title[150];
220                                          int state;                                          int state;
221                                            DWORD pid;
222                                            int flags;
223    
224                                            GetWindowThreadProcessId(hwnd, &pid);
225    
226                                          vchannel_write("CREATE", "0x%p,0x%p,0x%x", hwnd, parent, 0);                                          flags = 0;
227                                            if (style & DS_MODALFRAME)
228                                                    flags |= SEAMLESS_CREATE_MODAL;
229    
230                                            vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x",
231                                                           (long) hwnd, (long) pid, (long) parent,
232                                                           flags);
233    
234                                          GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title));                                          GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title));
235    
236                                          vchannel_write("TITLE", "0x%x,%s,0x%x", hwnd,                                          vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd,
237                                                         vchannel_strfilter_unicode(title), 0);                                                         vchannel_strfilter_unicode(title), 0);
238    
239                                          if (style & WS_MAXIMIZE)                                          if (style & WS_MAXIMIZE)
# Line 204  wndproc_hook_proc(int code, WPARAM cur_t Line 245  wndproc_hook_proc(int code, WPARAM cur_t
245    
246                                          update_position(hwnd);                                          update_position(hwnd);
247    
248                                          vchannel_write("STATE", "0x%p,0x%x,0x%x", hwnd, state, 0);                                          vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x", hwnd,
249                                                           state, 0);
250                                  }                                  }
251    
252                                  if (wp->flags & SWP_HIDEWINDOW)                                  if (wp->flags & SWP_HIDEWINDOW)
253                                          vchannel_write("DESTROY", "0x%p,0x%x", hwnd, 0);                                          vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0);
254    
255                                  if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))                                  if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
256                                          break;                                          break;
# Line 234  wndproc_hook_proc(int code, WPARAM cur_t Line 276  wndproc_hook_proc(int code, WPARAM cur_t
276                  case WM_DESTROY:                  case WM_DESTROY:
277                          if (!(style & WS_VISIBLE))                          if (!(style & WS_VISIBLE))
278                                  break;                                  break;
279                          vchannel_write("DESTROY", "0x%p,0x%x", hwnd, 0);                          vchannel_write("DESTROY", "0x%08lx,0x%08x", hwnd, 0);
280                          break;                          break;
281    
282                  default:                  default:
# Line 270  wndprocret_hook_proc(int code, WPARAM cu Line 312  wndprocret_hook_proc(int code, WPARAM cu
312          if ((style & WS_CHILD) && !(style & WS_POPUP))          if ((style & WS_CHILD) && !(style & WS_POPUP))
313                  goto end;                  goto end;
314    
315          if (style & WS_POPUP)          parent = get_parent(hwnd);
         {  
                 parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);  
                 if (!parent)  
                         parent = (HWND) - 1;  
         }  
         else  
                 parent = NULL;  
316    
317          switch (msg)          switch (msg)
318          {          {
# Line 303  wndprocret_hook_proc(int code, WPARAM cu Line 338  wndprocret_hook_proc(int code, WPARAM cu
338                                  /* We cannot use the string in lparam because                                  /* We cannot use the string in lparam because
339                                     we need unicode. */                                     we need unicode. */
340                                  GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title));                                  GetWindowTextW(hwnd, title, sizeof(title) / sizeof(*title));
341                                  vchannel_write("TITLE", "0x%p,%s,0x%x", hwnd,                                  vchannel_write("TITLE", "0x%08lx,%s,0x%08x", hwnd,
342                                                 vchannel_strfilter_unicode(title), 0);                                                 vchannel_strfilter_unicode(title), 0);
343                                  break;                                  break;
344                          }                          }
# Line 314  wndprocret_hook_proc(int code, WPARAM cu Line 349  wndprocret_hook_proc(int code, WPARAM cu
349    
350          if (msg == g_wm_seamless_focus)          if (msg == g_wm_seamless_focus)
351          {          {
352                  /* FIXME: SetActiveWindow() kills menus. Need to find a clean                  /* FIXME: SetForegroundWindow() kills menus. Need to find a
353                     way to solve this. */                     clean way to solve this. */
354                  if ((GetActiveWindow() != hwnd) && !parent)                  if ((GetForegroundWindow() != hwnd) && !parent)
355                          SetActiveWindow(hwnd);                          SetForegroundWindow(hwnd);
356    
357                  vchannel_write("ACK", "%u", g_blocked_focus_serial);                  vchannel_write("ACK", "%u", g_blocked_focus_serial);
358          }          }
# Line 337  cbt_hook_proc(int code, WPARAM wparam, L Line 372  cbt_hook_proc(int code, WPARAM wparam, L
372                  case HCBT_MINMAX:                  case HCBT_MINMAX:
373                          {                          {
374                                  int show, state, blocked;                                  int show, state, blocked;
375                                  HWND blocked_hwnd;                                  HWND hwnd, blocked_hwnd;
376                                  unsigned int serial;                                  unsigned int serial;
377                                    LONG style;
378    
379                                  WaitForSingleObject(g_mutex, INFINITE);                                  WaitForSingleObject(g_mutex, INFINITE);
380                                  blocked_hwnd = g_blocked_state_hwnd;                                  blocked_hwnd = g_blocked_state_hwnd;
# Line 346  cbt_hook_proc(int code, WPARAM wparam, L Line 382  cbt_hook_proc(int code, WPARAM wparam, L
382                                  blocked = g_blocked_state;                                  blocked = g_blocked_state;
383                                  ReleaseMutex(g_mutex);                                  ReleaseMutex(g_mutex);
384    
385                                    hwnd = (HWND) wparam;
386    
387                                    style = GetWindowLong(hwnd, GWL_STYLE);
388    
389                                    if (!(style & WS_VISIBLE))
390                                            break;
391    
392                                  show = LOWORD(lparam);                                  show = LOWORD(lparam);
393    
394                                  if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL)                                  if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL)
# Line 361  cbt_hook_proc(int code, WPARAM wparam, L Line 404  cbt_hook_proc(int code, WPARAM wparam, L
404                                          break;                                          break;
405                                  }                                  }
406    
407                                  if ((blocked_hwnd == (HWND) wparam) && (blocked == state))                                  if ((blocked_hwnd == hwnd) && (blocked == state))
408                                          vchannel_write("ACK", "%u", serial);                                          vchannel_write("ACK", "%u", serial);
409                                  else                                  else
410                                          vchannel_write("STATE", "0x%p,0x%x,0x%x", (HWND) wparam,                                          vchannel_write("STATE", "0x%08lx,0x%08x,0x%08x",
411                                                         state, 0);                                                         hwnd, state, 0);
412    
413                                  break;                                  break;
414                          }                          }
# Line 553  DllMain(HINSTANCE hinstDLL, DWORD ul_rea Line 596  DllMain(HINSTANCE hinstDLL, DWORD ul_rea
596                          break;                          break;
597    
598                  case DLL_PROCESS_DETACH:                  case DLL_PROCESS_DETACH:
599                            vchannel_write("DESTROYGRP", "0x%08lx, 0x%08lx", GetCurrentProcessId(), 0);
600    
601                          WaitForSingleObject(g_mutex, INFINITE);                          WaitForSingleObject(g_mutex, INFINITE);
602                          --g_instance_count;                          --g_instance_count;
603                          ReleaseMutex(g_mutex);                          ReleaseMutex(g_mutex);

Legend:
Removed from v.1167  
changed lines
  Added in v.1233

  ViewVC Help
Powered by ViewVC 1.1.26