/[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 1078 by ossman_, Thu Mar 9 12:26:31 2006 UTC revision 1079 by ossman_, Thu Mar 9 15:48:55 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:
79                          if (style & WS_CHILD)                          {
80                                  break;                                  RECT rect;
81                                    WINDOWPOS *wp = (WINDOWPOS *) lparam;
82    
83                                    if (wp->flags & SWP_SHOWWINDOW)
84                                    {
85                                            // FIXME: Now, just like create!
86                                            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                                    }
102    
103                          if (wp->flags & SWP_SHOWWINDOW)                                  if (wp->flags & SWP_HIDEWINDOW)
104                          {                                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);
                                 // FIXME: Now, just like create!  
                                 debug("SWP_SHOWWINDOW for %p!", hwnd);  
                                 vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0);  
105    
106                                  // FIXME: SETSTATE                                  if (!(style & WS_VISIBLE))
107                                            break;
108    
109                                    if (wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)
110                                            break;
111    
112                                  if (!GetWindowRect(hwnd, &rect))                                  if (!GetWindowRect(hwnd, &rect))
113                                  {                                  {
114                                          debug("GetWindowRect failed!\n");                                          debug("GetWindowRect failed!\n");
115                                          break;                                          break;
116                                  }                                  }
117    
118                                  vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",                                  vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",
119                                                 hwnd,                                                 hwnd,
120                                                 rect.left, rect.top,                                                 rect.left, rect.top,
121                                                 rect.right - rect.left, rect.bottom - rect.top, 0);                                                 rect.right - rect.left, rect.bottom - rect.top, 0);
                         }  
   
   
                         if (wp->flags & SWP_HIDEWINDOW)  
                                 vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);  
   
   
                         if (!(style & WS_VISIBLE))  
                                 break;  
   
                         if (wp->flags & SWP_NOMOVE && wp->flags & SWP_NOSIZE)  
                                 break;  
122    
                         if (!GetWindowRect(hwnd, &rect))  
                         {  
                                 debug("GetWindowRect failed!\n");  
123                                  break;                                  break;
124                          }                          }
125    
                         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...  */  
126                  case WM_WINDOWPOSCHANGING:                  case WM_WINDOWPOSCHANGING:
127                          if (style & WS_CHILD)                          {
128                                  break;                                  WINDOWPOS *wp = (WINDOWPOS *) lparam;
   
                         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;  
   
129    
130                                    if (!(style & WS_VISIBLE))
131                                            break;
132    
133                                    if (!(wp->flags & SWP_NOZORDER))
134                                            vchannel_write("ZCHANGE1,0x%p,0x%p,0x%x",
135                                                           hwnd,
136                                                           wp->flags & SWP_NOACTIVATE ? wp->
137                                                           hwndInsertAfter : 0, 0);
138    
                 case WM_DESTROY:  
                         if (style & WS_CHILD)  
139                                  break;                                  break;
140                            }
141    
142                    case WM_DESTROY:
143                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);                          vchannel_write("DESTROY1,0x%p,0x%x", hwnd, 0);
   
144                          break;                          break;
145    
   
146                  default:                  default:
147                          break;                          break;
148          }          }
# Line 171  cbt_hook_proc(int code, WPARAM wparam, L Line 163  cbt_hook_proc(int code, WPARAM wparam, L
163          {          {
164                  case HCBT_MINMAX:                  case HCBT_MINMAX:
165                          {                          {
166                                  int show;                                  int show, state;
167    
168                                  show = LOWORD(lparam);                                  show = LOWORD(lparam);
169    
# Line 187  cbt_hook_proc(int code, WPARAM wparam, L Line 179  cbt_hook_proc(int code, WPARAM wparam, L
179    
180                                  /* FIXME: Strip title of dangerous characters */                                  /* FIXME: Strip title of dangerous characters */
181    
182                                    if (show == SW_SHOWNORMAL)
183                                            state = 0;
184                                    else if (show == SW_SHOWMINIMIZED)
185                                            state = 1;
186                                    else if (show == SW_SHOWMAXIMIZED)
187                                            state = 2;
188                                  vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",                                  vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",
189                                                 (HWND) wparam, title, show, 0);                                                 (HWND) wparam, title, state, 0);
190                                  break;                                  break;
191                          }                          }
192    

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

  ViewVC Help
Powered by ViewVC 1.1.26