CVS: seamlessrdp/ServerExe/HookDll hookdll.cpp,1.10,1.11

Peter Åstrand <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20426

Modified Files:
	hookdll.cpp 
Log Message:
Added a function for sending debug printouts to the other end. 

Re-implemented the code on WM_SIZING/WM_MOVING: Now generating
messages according to the new protocol.

Do not catch WM_WINDOWPOSCHANGED; WM_WINDOWPOSCHANGING is enough. In
response, generate a ZCHANGE1 messages according to the new protocol.


Index: hookdll.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** hookdll.cpp	29 Aug 2005 09:31:51 -0000	1.10
--- hookdll.cpp	30 Aug 2005 09:15:44 -0000	1.11
***************
*** 7,10 ****
--- 7,11 ----
  #include <winuser.h>
  #include <stdio.h>
+ #include <stdarg.h>
  
  #include "wtsapi32.h"
***************
*** 24,27 ****
--- 25,30 ----
  #pragma comment(linker, "/section:SHAREDDATA,rws")
  
+ #define snprintf _snprintf
+ 
  bool bHooked = false;
  bool bHooked2 = false;
***************
*** 33,36 ****
--- 36,58 ----
  HANDLE m_vcHandle = 0;
  
+ 
+ void SendDebug( char *format, ... )
+ {
+     va_list argp;
+     char buf [ 256 ];
+     
+     va_start( argp, format );
+     vsprintf( buf, format, argp );
+     va_end( argp );
+     
+     if ( ChannelIsOpen() ) {
+         WriteToChannel( "DEBUG1," );
+         WriteToChannel( buf );
+         WriteToChannel( "\n" );
+     }
+ }
+ 
+ 
+ 
  BOOL APIENTRY DllMain( HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpReserved )
  {
***************
*** 79,228 ****
      char strW[ 5 ];
      char strH[ 5 ];
-     RECT rect;
      
      CWPSTRUCT *details = ( CWPSTRUCT * ) lParam;
      CREATESTRUCT *cs = ( CREATESTRUCT * ) details->lParam;
      LONG dwStyle = GetWindowLong( details->hwnd, GWL_STYLE );
!     WINDOWPOS *wp = (WINDOWPOS *) details->lParam;
      
      switch ( details->message ) {
          case WM_SIZING:
-         windowHandle = details->hwnd;
-         //get win name
-         GetWindowText( windowHandle, windowTitle, 150 );
-         
-         //get an id for it
-         itoa( ( int ) windowHandle, strWindowId, 10 );
-         
-         //get coords
-         GetWindowRect( windowHandle, &rect );
-         b = rect.bottom;
-         t = rect.top;
-         l = rect.left;
-         r = rect.right;
-         ltoa( b - t, strH, 10 );
-         ltoa( t, strY, 10 );
-         ltoa( r - l, strW, 10 );
-         ltoa( l, strX, 10 );
-         
-         ////setup return string
-         strcat( result, "MSG=CALLWNDPROC_WM_SIZING;OP=6;" );
-         strcat( result, "ID=" );
-         strcat( result, strWindowId );
-         strcat( result, ";" );
-         strcat( result, "TITLE=" );
-         strcat( result, windowTitle );
-         strcat( result, ";" );
-         strcat( result, "X=" );
-         strcat( result, strX );
-         strcat( result, ";" );
-         strcat( result, "Y=" );
-         strcat( result, strY );
-         strcat( result, ";" );
-         strcat( result, "H=" );
-         strcat( result, strH );
-         strcat( result, ";" );
-         strcat( result, "W=" );
-         strcat( result, strW );
-         strcat( result, "." );
-         
-         buffer = result;
-         
-         break;
          case WM_MOVING:
!         
!         windowHandle = details->hwnd;
!         //get win name
!         GetWindowText( windowHandle, windowTitle, 150 );
!         
!         //get an id for it
!         itoa( ( int ) windowHandle, strWindowId, 10 );
!         
!         //get coords
!         GetWindowRect( windowHandle, &rect );
!         b = rect.bottom;
!         t = rect.top;
!         l = rect.left;
!         r = rect.right;
!         ltoa( b - t, strH, 10 );
!         ltoa( t, strY, 10 );
!         ltoa( r - l, strW, 10 );
!         ltoa( l, strX, 10 );
!         
!         ////setup return string
!         strcat( result, "MSG=CALLWNDPROC_WM_MOVING;OP=2;" );
!         strcat( result, "ID=" );
!         strcat( result, strWindowId );
!         strcat( result, ";" );
!         strcat( result, "TITLE=" );
!         strcat( result, windowTitle );
!         strcat( result, ";" );
!         strcat( result, "X=" );
!         strcat( result, strX );
!         strcat( result, ";" );
!         strcat( result, "Y=" );
!         strcat( result, strY );
!         strcat( result, ";" );
!         strcat( result, "H=" );
!         strcat( result, strH );
!         strcat( result, ";" );
!         strcat( result, "W=" );
!         strcat( result, strW );
!         strcat( result, "." );
!         
          buffer = result;
          
          break;
          
!         case WM_WINDOWPOSCHANGED:
!         
!         windowHandle = details->hwnd;
!         //windowHandle2 = details->hwndInsertAfter;
!         //get win name
!         GetWindowText( windowHandle, windowTitle, 150 );
!         
!         //get an id for it
!         itoa( ( int ) windowHandle, strWindowId, 10 );
!         
!         //get coords
!         GetWindowRect( windowHandle, &rect );
!         b = rect.bottom;
!         t = rect.top;
!         l = rect.left;
!         r = rect.right;
!         ltoa( b - t, strH, 10 );
!         ltoa( t, strY, 10 );
!         ltoa( r - l, strW, 10 );
!         ltoa( l, strX, 10 );
! 
! 	// FIXME: This is a crude hack to shut up the language bar and
! 	// the Office XP speech/handwriting recognition.
! 	if (!strcmp(windowTitle, "TF_FloatingLangBar_WndTitle") || 
! 	    !strcmp(windowTitle, "CiceroUIWndFrame")) {
! 	    break;
! 	}
!         
!         ////setup return string
! 	//sprintf( result, "WM_WINDOWPOSCHANGED: title=%s, flags=0x%lx", windowTitle,  wp->flags);
!         strcat( result, "MSG=CALLWNDPROC_WM_WINDOWPOSCHANGED;OP=8;" );
!         strcat( result, "ID=" );
!         strcat( result, strWindowId );
!         strcat( result, ";" );
!         strcat( result, "TITLE=" );
!         strcat( result, windowTitle );
!         strcat( result, ";" );
!         strcat( result, "X=" );
!         strcat( result, strX );
!         strcat( result, ";" );
!         strcat( result, "Y=" );
!         strcat( result, strY );
!         strcat( result, ";" );
!         strcat( result, "H=" );
!         strcat( result, strH );
!         strcat( result, ";" );
!         strcat( result, "W=" );
!         strcat( result, strW );
!         strcat( result, "." );
          
          buffer = result;
          
--- 101,151 ----
      char strW[ 5 ];
      char strH[ 5 ];
      
      CWPSTRUCT *details = ( CWPSTRUCT * ) lParam;
      CREATESTRUCT *cs = ( CREATESTRUCT * ) details->lParam;
      LONG dwStyle = GetWindowLong( details->hwnd, GWL_STYLE );
!     WINDOWPOS *wp = ( WINDOWPOS * ) details->lParam;
!     RECT *rect = ( RECT * ) details->lParam;
      
      switch ( details->message ) {
+     
          case WM_SIZING:
          case WM_MOVING:
!         snprintf( result, sizeof( result ),
!                   "POSITION1,0x%x,%d,%d,%d,%d,0x%x",
!                   ( int ) details->hwnd,
!                   rect->left, rect->top,
!                   rect->right - rect->left,
!                   rect->bottom - rect->top,
!                   0 );
!         result[ sizeof( result ) - 1 ] = '\0';
          buffer = result;
          
          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 ( !( dwStyle & WS_VISIBLE ) )
+             break;
+             
+         if ( !( dwStyle & WS_DLGFRAME ) )
+             break;
+             
+         if ( !( wp->flags & SWP_NOZORDER ) ) {
+             snprintf( result, sizeof( result ),
+                       "ZCHANGE1,0x%x,0x%x,0x%x\n",
+                       details->hwnd,
+                       wp->flags & SWP_NOACTIVATE ? wp->hwndInsertAfter : 0,
+                       0 );
+             result[ sizeof( result ) - 1 ] = '\0';
+         }
          buffer = result;
          



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.