/[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 1073 by ossman_, Thu Mar 9 12:26:31 2006 UTC revision 1080 by ossman_, Thu Mar 9 15:57:10 2006 UTC
# Line 52  static HANDLE g_mutex = NULL; Line 52  static HANDLE g_mutex = NULL;
52  static LRESULT CALLBACK  static LRESULT CALLBACK
53  wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)  wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
54  {  {
55          HWND hwnd = ((CWPSTRUCT *) details)->hwnd;          HWND hwnd;
56          UINT msg = ((CWPSTRUCT *) details)->message;          UINT msg;
57          WPARAM wparam = ((CWPSTRUCT *) details)->wParam;          WPARAM wparam;
58          LPARAM lparam = ((CWPSTRUCT *) details)->lParam;          LPARAM lparam;
59    
60          LONG style = GetWindowLong(hwnd, GWL_STYLE);          LONG style;
         WINDOWPOS *wp = (WINDOWPOS *) lparam;  
         RECT rect;  
61    
62          if (code < 0)          if (code < 0)
63                  goto end;                  goto end;
64    
65            hwnd = ((CWPSTRUCT *) details)->hwnd;
66            msg = ((CWPSTRUCT *) details)->message;
67            wparam = ((CWPSTRUCT *) details)->wParam;
68            lparam = ((CWPSTRUCT *) details)->lParam;
69    
70            style = GetWindowLong(hwnd, GWL_STYLE);
71    
72            if (style & WS_CHILD)
73                    goto end;
74    
75          switch (msg)          switch (msg)
76          {          {
77    
78                  case WM_WINDOWPOSCHANGED:                  case WM_WINDOWPOSCHANGED:
                         if (style & WS_CHILD)  
                                 break;  
   
   
                         if (wp->flags & SWP_SHOWWINDOW)  
79                          {                          {
80                                  // FIXME: Now, just like create!                                  RECT rect;
81                                  debug("SWP_SHOWWINDOW for %p!", hwnd);                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;
                                 vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0);  
82    
83                                  // FIXME: SETSTATE                                  if (wp->flags & SWP_SHOWWINDOW)
   
                                 if (!GetWindowRect(hwnd, &rect))  
84                                  {                                  {
85                                          debug("GetWindowRect failed!\n");                                          // FIXME: Now, just like create!
86                                          break;                                          debug("SWP_SHOWWINDOW for %p!", hwnd);
87                                            vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0);
88    
89                                            // FIXME: SETSTATE
90    
91                                            if (!GetWindowRect(hwnd, &rect))
92                                            {
93                                                    debug("GetWindowRect failed!\n");
94                                                    break;
95                                            }
96                                            vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",
97                                                           hwnd,
98                                                           rect.left, rect.top,
99                                                           rect.right - rect.left,
100                                                           rect.bottom - rect.top, 0);
101                                  }                                  }
                                 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);  
                         }  
   
102    
103                          if (wp->flags & SWP_HIDEWINDOW)                                  if (wp->flags & SWP_HIDEWINDOW)
104                                  vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);
105    
106                                    if (!(style & WS_VISIBLE))
107                                            break;
108    
109                          if (!(style & WS_VISIBLE))                                  if (!(wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE))
110                                  break;                                  {
111                                            if (!GetWindowRect(hwnd, &rect))
112                                            {
113                                                    debug("GetWindowRect failed!\n");
114                                                    break;
115                                            }
116    
117                                            vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",
118                                                           hwnd,
119                                                           rect.left, rect.top,
120                                                           rect.right - rect.left,
121                                                           rect.bottom - rect.top, 0);
122                                    }
123    
124                          if (wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)                                  if (!(wp->flags & SWP_NOZORDER))
125                                  break;                                  {
126                                            vchannel_write("ZCHANGE1,0x%p,0x%p,0x%x",
127                                                           hwnd,
128                                                           wp->flags & SWP_NOACTIVATE ? wp->
129                                                           hwndInsertAfter : 0, 0);
130                                    }
131    
                         if (!GetWindowRect(hwnd, &rect))  
                         {  
                                 debug("GetWindowRect failed!\n");  
132                                  break;                                  break;
133                          }                          }
134    
                         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);  
   
                         break;  
   
   
                         /* Note: WM_WINDOWPOSCHANGING/WM_WINDOWPOSCHANGED are  
                            strange. Sometimes, for example when bringing up the  
                            Notepad About dialog, only an WM_WINDOWPOSCHANGING is  
                            sent. In some other cases, for exmaple when opening  
                            Format->Text in Notepad, both events are sent. Also, for  
                            some reason, when closing the Notepad About dialog, an  
                            WM_WINDOWPOSCHANGING event is sent which looks just like  
                            the event that was sent when the About dialog was opened...  */  
                 case WM_WINDOWPOSCHANGING:  
                         if (style & WS_CHILD)  
                                 break;  
   
                         if (!(style & WS_VISIBLE))  
                                 break;  
   
                         if (!(wp->flags & SWP_NOZORDER))  
                                 vchannel_write("ZCHANGE1,0x%p,0x%p,0x%x",  
                                                hwnd,  
                                                wp->flags & SWP_NOACTIVATE ? wp->hwndInsertAfter : 0,  
                                                0);  
   
                         break;  
   
   
   
   
135                  case WM_DESTROY:                  case WM_DESTROY:
                         if (style & WS_CHILD)  
                                 break;  
   
136                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);
   
137                          break;                          break;
138    
   
139                  default:                  default:
140                          break;                          break;
141          }          }
# Line 171  cbt_hook_proc(int code, WPARAM wparam, L Line 156  cbt_hook_proc(int code, WPARAM wparam, L
156          {          {
157                  case HCBT_MINMAX:                  case HCBT_MINMAX:
158                          {                          {
159                                  int show;                                  int show, state;
160    
161                                  show = LOWORD(lparam);                                  show = LOWORD(lparam);
162    
# Line 187  cbt_hook_proc(int code, WPARAM wparam, L Line 172  cbt_hook_proc(int code, WPARAM wparam, L
172    
173                                  /* FIXME: Strip title of dangerous characters */                                  /* FIXME: Strip title of dangerous characters */
174    
175                                    if (show == SW_SHOWNORMAL)
176                                            state = 0;
177                                    else if (show == SW_SHOWMINIMIZED)
178                                            state = 1;
179                                    else if (show == SW_SHOWMAXIMIZED)
180                                            state = 2;
181                                  vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",                                  vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",
182                                                 (HWND) wparam, title, show, 0);                                                 (HWND) wparam, title, state, 0);
183                                  break;                                  break;
184                          }                          }
185    

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

  ViewVC Help
Powered by ViewVC 1.1.26