CVS: seamlessrdp/ServerExe/HookDll hookdll.cpp,1.30,1.31 hookdll.h,1.8,1.9

Pierre Ossman <[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-serv5618

Modified Files:
	hookdll.cpp hookdll.h 
Log Message:
Make WriteToChannel() a variable argument function. Cleans up the code a lot.
Also add a newline implicitly in the function. It is unsupported to call it
multiple times for one line anyway (because of locking).


Index: hookdll.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** hookdll.cpp	8 Mar 2006 16:55:02 -0000	1.30
--- hookdll.cpp	8 Mar 2006 17:14:42 -0000	1.31
***************
*** 39,49 ****
      char buf [ 256 ];
  
      va_start( argp, format );
!     vsprintf( buf, format, argp );
      va_end( argp );
  
-     WriteToChannel( "DEBUG1," );
      WriteToChannel( buf );
-     WriteToChannel( "\n" );
  }
  
--- 39,50 ----
      char buf [ 256 ];
  
+     sprintf( buf, "DEBUG1," );
+ 
      va_start( argp, format );
!     vsnprintf( buf + sizeof( "DEBUG1," ) - 1,
!                sizeof( buf ) - sizeof( "DEBUG1," ) + 1, format, argp );
      va_end( argp );
  
      WriteToChannel( buf );
  }
  
***************
*** 118,127 ****
              // FIXME: Now, just like create!
              SendDebug("SWP_SHOWWINDOW for %p!", details->hwnd);
! 
!             snprintf( result, sizeof( result ),
!                       "CREATE1,0x%p,0x%x\n",
!                       details->hwnd, 0 );
!             result[ sizeof( result ) - 1 ] = '\0';
!             WriteToChannel( result );
  
              // FIXME: SETSTATE
--- 119,123 ----
              // FIXME: Now, just like create!
              SendDebug("SWP_SHOWWINDOW for %p!", details->hwnd);
!             WriteToChannel( "CREATE1,0x%p,0x%x", details->hwnd, 0 );
  
              // FIXME: SETSTATE
***************
*** 131,155 ****
                  break;
              }
!             snprintf( result, sizeof( result ),
!                       "POSITION1,0x%p,%d,%d,%d,%d,0x%x\n",
!                       details->hwnd,
!                       rect.left, rect.top,
!                       rect.right - rect.left,
!                       rect.bottom - rect.top,
!                       0 );
!             result[ sizeof( result ) - 1 ] = '\0';
!             WriteToChannel( result );
! 
          }
  
  
!         if ( wp->flags & SWP_HIDEWINDOW ) {
!             snprintf( result, sizeof( result ),
!                       "DESTROY1,0x%p,0x%x\n",
!                       details->hwnd, 0 );
!             result[ sizeof( result ) - 1 ] = '\0';
!             WriteToChannel( result );
! 
!         }
  
  
--- 127,141 ----
                  break;
              }
!             WriteToChannel( "POSITION1,0x%p,%d,%d,%d,%d,0x%x",
!                             details->hwnd,
!                             rect.left, rect.top,
!                             rect.right - rect.left,
!                             rect.bottom - rect.top,
!                             0 );
          }
  
  
!         if ( wp->flags & SWP_HIDEWINDOW )
!             WriteToChannel( "DESTROY1,0x%p,0x%x", details->hwnd, 0 );
  
  
***************
*** 165,177 ****
          }
  
!         snprintf( result, sizeof( result ),
!                   "POSITION1,0x%p,%d,%d,%d,%d,0x%x\n",
!                   details->hwnd,
!                   rect.left, rect.top,
!                   rect.right - rect.left,
!                   rect.bottom - rect.top,
!                   0 );
!         result[ sizeof( result ) - 1 ] = '\0';
!         WriteToChannel( result );
  
          break;
--- 151,160 ----
          }
  
!         WriteToChannel( "POSITION1,0x%p,%d,%d,%d,%d,0x%x",
!                         details->hwnd,
!                         rect.left, rect.top,
!                         rect.right - rect.left,
!                         rect.bottom - rect.top,
!                         0 );
  
          break;
***************
*** 193,205 ****
              break;
  
!         if ( !( wp->flags & SWP_NOZORDER ) ) {
!             snprintf( result, sizeof( result ),
!                       "ZCHANGE1,0x%p,0x%p,0x%x\n",
!                       details->hwnd,
!                       wp->flags & SWP_NOACTIVATE ? wp->hwndInsertAfter : 0,
!                       0 );
!             result[ sizeof( result ) - 1 ] = '\0';
!             WriteToChannel( result );
!         }
          break;
  
--- 176,185 ----
              break;
  
!         if ( !( wp->flags & SWP_NOZORDER ) )
!             WriteToChannel( "ZCHANGE1,0x%p,0x%p,0x%x",
!                             details->hwnd,
!                             wp->flags & SWP_NOACTIVATE ? wp->hwndInsertAfter : 0,
!                             0 );
! 
          break;
  
***************
*** 211,219 ****
              break;
  
!         snprintf( result, sizeof( result ),
!                   "DESTROY1,0x%p,0x%x\n",
!                   details->hwnd, 0 );
!         result[ sizeof( result ) - 1 ] = '\0';
!         WriteToChannel( result );
  
          break;
--- 191,195 ----
              break;
  
!         WriteToChannel( "DESTROY1,0x%p,0x%x", details->hwnd, 0 );
  
          break;
***************
*** 249,260 ****
          GetWindowText( ( HWND ) wParam, windowTitle, 150 );
  
!         snprintf( result, sizeof( result ),
!                   "SETSTATE1,0x%p,%s,0x%x,0x%x\n",
!                   ( HWND ) wParam,
!                   windowTitle,
!                   LOWORD( lParam ),
!                   0 );
!         result[ sizeof( result ) - 1 ] = '\0';
!         WriteToChannel( result );
          break;
  
--- 225,233 ----
          GetWindowText( ( HWND ) wParam, windowTitle, 150 );
  
!         WriteToChannel( "SETSTATE1,0x%p,%s,0x%x,0x%x",
!                         ( HWND ) wParam,
!                         windowTitle,
!                         LOWORD( lParam ),
!                         0 );
          break;
  
***************
*** 455,461 ****
  }
  
! int WriteToChannel( PCHAR buffer )
  {
      BOOL result;
      PULONG bytesRead = 0;
      PULONG pBytesWritten = 0;
--- 428,437 ----
  }
  
! int WriteToChannel( char *format, ... )
  {
      BOOL result;
+     va_list argp;
+     char buf [ 1024 ];
+     int size;
      PULONG bytesRead = 0;
      PULONG pBytesWritten = 0;
***************
*** 464,469 ****
          return 1;
  
      WaitForSingleObject( hMutex, INFINITE );
!     result = WTSVirtualChannelWrite( m_vcHandle, buffer, ( ULONG ) strlen( buffer ), pBytesWritten );
      ReleaseMutex( hMutex );
  
--- 440,453 ----
          return 1;
  
+     va_start( argp, format );
+     size = vsnprintf( buf, sizeof( buf ), format, argp );
+     va_end( argp );
+ 
+     if ( size >= sizeof( buf ) )
+         return 0;
+ 
      WaitForSingleObject( hMutex, INFINITE );
!     result = WTSVirtualChannelWrite( m_vcHandle, buf, ( ULONG ) strlen( buf ), pBytesWritten );
!     result = WTSVirtualChannelWrite( m_vcHandle, "\n", ( ULONG ) 1, pBytesWritten );
      ReleaseMutex( hMutex );
  

Index: hookdll.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** hookdll.h	6 Mar 2006 08:01:09 -0000	1.8
--- hookdll.h	8 Mar 2006 17:14:42 -0000	1.9
***************
*** 21,25 ****
  int CloseVirtualChannel();
  int ChannelIsOpen();
! int WriteToChannel( PCHAR buffer );
  
  #endif
--- 21,25 ----
  int CloseVirtualChannel();
  int ChannelIsOpen();
! int WriteToChannel( char *format, ... );
  
  #endif



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
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.