#139 update client tswindowclipper.dll for current seamlessrdp

open
nobody
None
5
2012-11-29
2009-05-22
Anonymous
No

The seamless rdp components of rdesktop includes source for tswindowclipper.dll, a minimally functional prof of concept client dll originally intended designed to allow the predecessor of seamlessrdp to work with XP/W2K/Vista clients running the MS RDP client. However this client dll has not been maintained in tandem with seamlessrdp, and does not currently work with seamlessrdpshell.exe.

It appears that it is possible to modify the clipper client dll to work with the current seamless rdp server-side code, but really making this work well is somewhat beyond my limited novice programming skill-set.

snippets of (poorly) changed/added code for clipper.cpp follow:

void WINAPI VirtualChannelOpenEvent( DWORD openHandle, UINT event,
LPVOID pdata, UINT32 dataLength,
UINT32 totalLength, UINT32 dataFlags )
{
LPDWORD pdwControlCode = ( LPDWORD ) pdata;
CHAR ourData[ 1600 ];
UINT ui = 0;

UNREFERENCED_PARAMETER( openHandle );
UNREFERENCED_PARAMETER( dataFlags );

ZeroMemory( ourData, sizeof( ourData ) );

//copy the send string (with the same lenth of the data)
strncpy( ourData, ( LPSTR ) pdata, dataLength / sizeof( char ) );

if ( OUTPUT_DEBUG_INFO == 1 ) {
OutputDebugString
( " TS WINDOW CLIPPER :: CLIENT DLL :: Info --> Virtual channel data received " );
OutputDebugString( ourData );
}

if ( dataLength == totalLength ) {
switch ( event ) {
case CHANNEL_EVENT_DATA_RECEIVED: {
char *p;
char *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;
//unsigned long id, flags, group, parent;
char *endptr;
p = ourData;

tok1 = Get_Token(&p);
tok2 = Get_Token(&p);
tok3 = Get_Token(&p);
tok4 = Get_Token(&p);
tok5 = Get_Token(&p);
tok6 = Get_Token(&p);
tok7 = Get_Token(&p);
tok8 = Get_Token(&p);

CWindowData* wid=new CWindowData("");

if ( strcmp(tok1, "CREATE" ) == 0 ) {
if ( OUTPUT_DEBUG_INFO == 1 ) {
OutputDebugString
( "TS WINDOW CLIPPER :: CLIENT DLL :: Info --> Message was of type CREATE window title is:" );
OutputDebugString( wid->GetTitle() );
}
if (tok6 != NULL ) {
wid->SetId(tok3);
CStdString s = wid->GetId();
char *ptr;
int length = s.GetLength();
ptr = s.GetBufferSetLength( length );
hash_insert( ptr, wid, &m_ht );
CreateAndShowWindow( wid );
DoClipping( 1 );
}
} else if ( strcmp(tok1, "DESTROY" ) == 0 ) {
if ( OUTPUT_DEBUG_INFO == 1 ) {
OutputDebugString
( "TS WINDOW CLIPPER :: CLIENT DLL :: Info --> Message was of type DESTROY window title is:" );
OutputDebugString( wid->GetTitle() );
}
wid->SetId(tok3);
CStdString s = wid->GetId();
char *ptr;
int length = s.GetLength();
ptr = s.GetBufferSetLength( length );

CWindowData *oldWinData =
( CWindowData * ) hash_del( ptr, &m_ht );

DestroyTaskbarWindow( oldWinData );

delete oldWinData;
delete wid;
DoClipping( 1 );
} else if ( strcmp(tok1, "POSITION" ) == 0 ) {
if ( OUTPUT_DEBUG_INFO == 1 ) {
OutputDebugString
( "TS WINDOW CLIPPER :: CLIENT DLL :: Info --> Message was of type POSITION window title is:" );
OutputDebugString( wid->GetTitle() );
}
wid->SetId(tok3);

// check bounds, coords can be negative if window top left point is moved off the screen.
// we don't care about that since the window can't be see so just use zero.

if (strchr(tok4, '-')==NULL) {
wid->SetX1(atoi(tok4));
} else {
wid->SetX1(0);
}
if (strchr(tok5, '-')==NULL) {
wid->SetY1(atoi(tok5));
} else {
wid->SetY1(0);
}
if (strchr(tok6, '-')==NULL) {
wid->SetX2(atoi(tok4)+atoi(tok6));
} else {
wid->SetX2(0);
}
if (strchr(tok7, '-')==NULL) {
wid->SetY2(atoi(tok5)+atoi(tok7));
} else {
wid->SetY2(0);
}
CStdString s = wid->GetId();
char *ptr;
int length = s.GetLength();
ptr = s.GetBufferSetLength( length );

CWindowData *movedWinData =
( CWindowData * ) hash_lookup( ptr, &m_ht );

if ( movedWinData != NULL ) {
movedWinData->SetX1( wid->GetX1() );
movedWinData->SetX2( wid->GetX2() );
movedWinData->SetY1( wid->GetY1() );
movedWinData->SetY2( wid->GetY2() );

DoClipping( 1 );
}

delete wid;
} else if ( strcmp(tok1, "TITLE" ) == 0 ) {
if ( OUTPUT_DEBUG_INFO == 1 ) {
OutputDebugString
( "TS WINDOW CLIPPER :: CLIENT DLL :: Info --> Message was of type TITLE window title is:" );
OutputDebugString( wid->GetTitle() );
}
if (tok5 != NULL ) {

wid->SetId(tok3);
CStdString s = wid->GetId();
char *ptr;
int length = s.GetLength();
ptr = s.GetBufferSetLength( length );

CWindowData *retitledWinData =
( CWindowData * ) hash_lookup( ptr, &m_ht );
wid->SetTitle(tok4);
SetWindowTitle(retitledWinData, tok4);
}

delete wid;
} else if (strcmp(tok1,"HELLO") == 0) {
//DoClipping( 1 );
}
}
break;

case CHANNEL_EVENT_WRITE_COMPLETE: {}
break;

case CHANNEL_EVENT_WRITE_CANCELLED: {}
break;

default: {}
break;
}
} else {}
}

void SetWindowTitle(CWindowData * wd, const char *title)
{
if ( wd->TaskbarWindowHandle != NULL ) {
SetWindowText( wd->TaskbarWindowHandle , title);
}
}

char* Get_Token(char **s)
{
char *comma, *head;
head = *s;

if (!head)
return NULL;

comma = strchr(head, ',');
if (comma)
{
*comma = '\0';
*s = comma + 1;
}
else
{
*s = NULL;
}

return head;
}

Discussion