/[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 1079 by ossman_, Thu Mar 9 15:48:55 2006 UTC revision 1131 by ossman_, Wed Mar 15 12:15:23 2006 UTC
# Line 49  static HINSTANCE g_instance = NULL; Line 49  static HINSTANCE g_instance = NULL;
49    
50  static HANDLE g_mutex = NULL;  static HANDLE g_mutex = NULL;
51    
52    static void
53    update_position(HWND hwnd)
54    {
55            RECT rect;
56    
57            if (!GetWindowRect(hwnd, &rect))
58            {
59                    debug("GetWindowRect failed!\n");
60                    return;
61            }
62    
63            vchannel_write("POSITION,0x%p,%d,%d,%d,%d,0x%x",
64                           hwnd,
65                           rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0);
66    }
67    
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;
# Line 69  wndproc_hook_proc(int code, WPARAM cur_t Line 85  wndproc_hook_proc(int code, WPARAM cur_t
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    
105                  case WM_WINDOWPOSCHANGED:                  case WM_WINDOWPOSCHANGED:
106                          {                          {
                                 RECT rect;  
107                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;
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                                          // FIXME: SETSTATE  
116                                            GetWindowText(hwnd, title, sizeof(title));
117                                          if (!GetWindowRect(hwnd, &rect))  
118                                          {                                          vchannel_write("TITLE,0x%x,%s,0x%x", hwnd,
119                                                  debug("GetWindowRect failed!\n");                                                         vchannel_strfilter(title), 0);
120                                                  break;  
121                                          }                                          if (style & WS_MAXIMIZE)
122                                          vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",                                                  state = 2;
123                                                         hwnd,                                          else if (style & WS_MINIMIZE)
124                                                         rect.left, rect.top,                                                  state = 1;
125                                                         rect.right - rect.left,                                          else
126                                                         rect.bottom - rect.top, 0);                                                  state = 0;
127    
128                                            update_position(hwnd);
129    
130                                            vchannel_write("STATE,0x%p,0x%x,0x%x", hwnd, state, 0);
131                                  }                                  }
132    
133                                  if (wp->flags & SWP_HIDEWINDOW)                                  if (wp->flags & SWP_HIDEWINDOW)
134                                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                                          vchannel_write("DESTROY,0x%p,0x%x", hwnd, 0);
135    
136                                  if (!(style & WS_VISIBLE))                                  if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
137                                          break;                                          break;
138    
139                                  if (wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)                                  if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE))
140                                          break;                                          update_position(hwnd);
141    
142                                  if (!GetWindowRect(hwnd, &rect))                                  if (!(wp->flags & SWP_NOZORDER))
143                                  {                                  {
144                                          debug("GetWindowRect failed!\n");                                          vchannel_write("ZCHANGE,0x%p,0x%p,0x%x",
145                                          break;                                                         hwnd,
146                                                           wp->flags & SWP_NOACTIVATE ? wp->
147                                                           hwndInsertAfter : 0, 0);
148                                  }                                  }
149    
                                 vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",  
                                                hwnd,  
                                                rect.left, rect.top,  
                                                rect.right - rect.left, rect.bottom - rect.top, 0);  
   
150                                  break;                                  break;
151                          }                          }
152    
153                  case WM_WINDOWPOSCHANGING:                  case WM_SIZE:
154                          {                          if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
155                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;                                  break;
156                            update_position(hwnd);
157                            break;
158    
159                    case WM_MOVE:
160                            if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
161                                    break;
162                            update_position(hwnd);
163                            break;
164    
165                    case WM_SETTEXT:
166                            {
167                                    char *title;
168                                  if (!(style & WS_VISIBLE))                                  if (!(style & WS_VISIBLE))
169                                          break;                                          break;
170                                    title = _strdup((char *) lparam);
171                                  if (!(wp->flags & SWP_NOZORDER))                                  vchannel_write("TITLE,0x%p,%s,0x%x", hwnd,
172                                          vchannel_write("ZCHANGE1,0x%p,0x%p,0x%x",                                                 vchannel_strfilter(title), 0);
173                                                         hwnd,                                  free(title);
                                                        wp->flags & SWP_NOACTIVATE ? wp->  
                                                        hwndInsertAfter : 0, 0);  
   
174                                  break;                                  break;
175                          }                          }
176    
177                  case WM_DESTROY:                  case WM_DESTROY:
178                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                          if (!(style & WS_VISIBLE))
179                                    break;
180                            vchannel_write("DESTROY,0x%p,0x%x", hwnd, 0);
181                          break;                          break;
182    
183                  default:                  default:
# Line 154  wndproc_hook_proc(int code, WPARAM cur_t Line 191  wndproc_hook_proc(int code, WPARAM cur_t
191  static LRESULT CALLBACK  static LRESULT CALLBACK
192  cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam)  cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam)
193  {  {
         char title[150];  
   
194          if (code < 0)          if (code < 0)
195                  goto end;                  goto end;
196    
# Line 167  cbt_hook_proc(int code, WPARAM wparam, L Line 202  cbt_hook_proc(int code, WPARAM wparam, L
202    
203                                  show = LOWORD(lparam);                                  show = LOWORD(lparam);
204    
205                                  if ((show == SW_SHOWMINIMIZED) || (show == SW_MINIMIZE))                                  if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL)
206                                  {                                      || (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)  
207                                          state = 0;                                          state = 0;
208                                  else if (show == SW_SHOWMINIMIZED)                                  else if ((show == SW_MINIMIZE) || (show == SW_SHOWMINIMIZED))
209                                          state = 1;                                          state = 1;
210                                  else if (show == SW_SHOWMAXIMIZED)                                  else if ((show == SW_MAXIMIZE) || (show == SW_SHOWMAXIMIZED))
211                                          state = 2;                                          state = 2;
212                                  vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",                                  else
213                                                 (HWND) wparam, title, state, 0);                                  {
214                                            debug("Unexpected show: %d", show);
215                                            break;
216                                    }
217                                    vchannel_write("STATE,0x%p,0x%x,0x%x", (HWND) wparam, state, 0);
218                                  break;                                  break;
219                          }                          }
220    

Legend:
Removed from v.1079  
changed lines
  Added in v.1131

  ViewVC Help
Powered by ViewVC 1.1.26