/[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 1080 by ossman_, Thu Mar 9 15:57:10 2006 UTC revision 1106 by ossman_, Fri Mar 10 13:47:41 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                    parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);
95            else
96                    parent = NULL;
97    
98          switch (msg)          switch (msg)
99          {          {
100    
101                  case WM_WINDOWPOSCHANGED:                  case WM_WINDOWPOSCHANGED:
102                          {                          {
                                 RECT rect;  
103                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;
104    
105                                  if (wp->flags & SWP_SHOWWINDOW)                                  if (wp->flags & SWP_SHOWWINDOW)
106                                  {                                  {
107                                          // FIXME: Now, just like create!                                          char title[150];
108                                          debug("SWP_SHOWWINDOW for %p!", hwnd);                                          int state;
109                                          vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0);  
110                                            vchannel_write("CREATE,0x%p,0x%p,0x%x", hwnd, parent, 0);
111                                          // FIXME: SETSTATE  
112                                            GetWindowText(hwnd, title, sizeof(title));
113                                          if (!GetWindowRect(hwnd, &rect))  
114                                          {                                          /* FIXME: Strip title of dangerous characters */
115                                                  debug("GetWindowRect failed!\n");  
116                                                  break;                                          vchannel_write("TITLE,0x%x,%s,0x%x", hwnd, title, 0);
117                                          }  
118                                          vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",                                          if (style & WS_MAXIMIZE)
119                                                         hwnd,                                                  state = 2;
120                                                         rect.left, rect.top,                                          else if (style & WS_MINIMIZE)
121                                                         rect.right - rect.left,                                                  state = 1;
122                                                         rect.bottom - rect.top, 0);                                          else
123                                                    state = 0;
124    
125                                            vchannel_write("STATE,0x%p,0x%x,0x%x", hwnd, state, 0);
126    
127                                            update_position(hwnd);
128    
129                                            /* FIXME: Figure out z order */
130                                  }                                  }
131    
132                                  if (wp->flags & SWP_HIDEWINDOW)                                  if (wp->flags & SWP_HIDEWINDOW)
133                                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                                          vchannel_write("DESTROY,0x%p,0x%x", hwnd, 0);
134    
135                                  if (!(style & WS_VISIBLE))                                  if (!(style & WS_VISIBLE))
136                                          break;                                          break;
137    
138                                  if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE))                                  if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE))
139                                  {                                          update_position(hwnd);
                                         if (!GetWindowRect(hwnd, &rect))  
                                         {  
                                                 debug("GetWindowRect failed!\n");  
                                                 break;  
                                         }  
   
                                         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);  
                                 }  
140    
141                                  if (!(wp->flags & SWP_NOZORDER))                                  if (!(wp->flags & SWP_NOZORDER))
142                                  {                                  {
143                                          vchannel_write("ZCHANGE1,0x%p,0x%p,0x%x",                                          vchannel_write("ZCHANGE,0x%p,0x%p,0x%x",
144                                                         hwnd,                                                         hwnd,
145                                                         wp->flags & SWP_NOACTIVATE ? wp->                                                         wp->flags & SWP_NOACTIVATE ? wp->
146                                                         hwndInsertAfter : 0, 0);                                                         hwndInsertAfter : 0, 0);
# Line 132  wndproc_hook_proc(int code, WPARAM cur_t Line 149  wndproc_hook_proc(int code, WPARAM cur_t
149                                  break;                                  break;
150                          }                          }
151    
152                    case WM_SIZE:
153                            if (!(style & WS_VISIBLE))
154                                    break;
155                            update_position(hwnd);
156                            break;
157    
158                    case WM_MOVE:
159                            if (!(style & WS_VISIBLE))
160                                    break;
161                            update_position(hwnd);
162                            break;
163    
164                    case WM_SETTEXT:
165                            if (!(style & WS_VISIBLE))
166                                    break;
167                            /* FIXME: Strip title of dangerous characters */
168                            vchannel_write("TITLE,0x%p,%s,0x%x", hwnd, (char *) lparam, 0);
169                            break;
170    
171                  case WM_DESTROY:                  case WM_DESTROY:
172                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                          if (!(style & WS_VISIBLE))
173                                    break;
174                            vchannel_write("DESTROY,0x%p,0x%x", hwnd, 0);
175                          break;                          break;
176    
177                  default:                  default:
# Line 147  wndproc_hook_proc(int code, WPARAM cur_t Line 185  wndproc_hook_proc(int code, WPARAM cur_t
185  static LRESULT CALLBACK  static LRESULT CALLBACK
186  cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam)  cbt_hook_proc(int code, WPARAM wparam, LPARAM lparam)
187  {  {
         char title[150];  
   
188          if (code < 0)          if (code < 0)
189                  goto end;                  goto end;
190    
# Line 160  cbt_hook_proc(int code, WPARAM wparam, L Line 196  cbt_hook_proc(int code, WPARAM wparam, L
196    
197                                  show = LOWORD(lparam);                                  show = LOWORD(lparam);
198    
199                                  if ((show == SW_SHOWMINIMIZED) || (show == SW_MINIMIZE))                                  if ((show == SW_NORMAL) || (show == SW_SHOWNORMAL))
                                 {  
                                         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)  
200                                          state = 0;                                          state = 0;
201                                  else if (show == SW_SHOWMINIMIZED)                                  else if ((show == SW_MINIMIZE) || (show == SW_SHOWMINIMIZED))
202                                          state = 1;                                          state = 1;
203                                  else if (show == SW_SHOWMAXIMIZED)                                  else if ((show == SW_MAXIMIZE) || (show == SW_SHOWMAXIMIZED))
204                                          state = 2;                                          state = 2;
205                                  vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",                                  else
206                                                 (HWND) wparam, title, state, 0);                                  {
207                                            debug("Unexpected show: %d", show);
208                                            break;
209                                    }
210                                    vchannel_write("STATE,0x%p,0x%x,0x%x", (HWND) wparam, state, 0);
211                                  break;                                  break;
212                          }                          }
213    

Legend:
Removed from v.1080  
changed lines
  Added in v.1106

  ViewVC Help
Powered by ViewVC 1.1.26