Get diff for files in chglist.txt --- C:\DTEMP\UltraVNC-102-Src\UltraVNC\vncviewer\ClientConnection.cpp Thu Jun 08 16:35:36 2006 +++ UltraVNC\vncviewer\ClientConnection.cpp Tue May 01 15:42:22 2007 @@ -68,6 +68,9 @@ #include #include // sf@2002 +#ifndef NDEBUG +#define ADD_PRINT_HEX // ONLY ON, IFF NDEBUG NOT DEFINED +#endif // #ifndef NDEBUG #define INITIALNETBUFSIZE 4096 #define MAX_ENCODINGS (LASTENCODING+10) @@ -273,6 +276,7 @@ m_proxyport = -1; // m_proxy = 0; m_serverInitiated = false; + m_onlyOneFormMsg = 0; // grm@20070430 - this need to be RESET on each connection m_netbuf = NULL; m_netbufsize = 0; m_zlibbuf = NULL; @@ -467,9 +471,11 @@ Save_Latest_Connection(); } // Connect if we're not already connected - if (m_sock == INVALID_SOCKET) + if (m_sock == INVALID_SOCKET) { if (strcmp(m_proxyhost,"")!=NULL && m_fUseProxy)ConnectProxy(); else Connect(); + m_onlyOneFormMsg = 0; // grm@20070430 - this need to be RESET on each connection + } SetSocketOptions(); @@ -1345,11 +1351,11 @@ if (!m_opts.m_NoStatus) GTGBS_ShowConnectWindow(); m_sock = socket(PF_INET, SOCK_STREAM, 0); - if (m_hwndStatus) SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L43); - if (m_sock == INVALID_SOCKET) {if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L44);throw WarningException(sz_L44);} + SetStatusText(sz_L43); // grm@20070428 + if (m_sock == INVALID_SOCKET) { SetStatusText(sz_L44);throw WarningException(sz_L44);} int one = 1; - if (m_hwndStatus) SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L45); + SetStatusText(sz_L45); // grm@20070428 if (m_hwndStatus) UpdateWindow(m_hwndStatus); // The host may be specified as a dotted address "a.b.c.d" @@ -1363,13 +1369,13 @@ if (lphost == NULL) { //if(myDialog!=0)DestroyWindow(myDialog); - if (m_hwndStatus) SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L46); + SetStatusText(sz_L46); // grm@20070428 throw WarningException(sz_L46); }; thataddr.sin_addr.s_addr = ((LPIN_ADDR) lphost->h_addr)->s_addr; }; - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L47); + SetStatusText(sz_L47); if (m_hwndStatus)ShowWindow(m_hwndStatus,SW_SHOW); if (m_hwndStatus)UpdateWindow(m_hwndStatus); if (m_hwndStatus)SetDlgItemInt(m_hwndStatus,IDC_PORT,m_port,FALSE); @@ -1379,12 +1385,12 @@ res = connect(m_sock, (LPSOCKADDR) &thataddr, sizeof(thataddr)); if (res == SOCKET_ERROR) { - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L48); + SetStatusText(sz_L48); // grm@20070428 if (!Pressed_Cancel) throw WarningException(sz_L48); else throw QuietException(sz_L48); } vnclog.Print(0, _T("Connected to %s port %d\n"), m_host, m_port); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L49); + SetStatusText(sz_L49); if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_VNCSERVER,m_host); if (m_hwndStatus)ShowWindow(m_hwndStatus,SW_SHOW); if (m_hwndStatus)UpdateWindow(m_hwndStatus); @@ -1397,11 +1403,11 @@ if (!m_opts.m_NoStatus) GTGBS_ShowConnectWindow(); m_sock = socket(PF_INET, SOCK_STREAM, 0); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L43); - if (m_sock == INVALID_SOCKET) {if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L44);throw WarningException(sz_L44);} + SetStatusText(sz_L43); // grm@20070428 + if (m_sock == INVALID_SOCKET) {SetStatusText(sz_L44);throw WarningException(sz_L44);} int one = 1; - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L45); + SetStatusText(sz_L45); if (m_hwndStatus)UpdateWindow(m_hwndStatus); // The host may be specified as a dotted address "a.b.c.d" @@ -1415,13 +1421,13 @@ if (lphost == NULL) { //if(myDialog!=0)DestroyWindow(myDialog); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L46); + SetStatusText(sz_L46); throw WarningException(sz_L46); }; thataddr.sin_addr.s_addr = ((LPIN_ADDR) lphost->h_addr)->s_addr; }; - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L47); + SetStatusText(sz_L47); if (m_hwndStatus)ShowWindow(m_hwndStatus,SW_SHOW); if (m_hwndStatus)UpdateWindow(m_hwndStatus); if (m_hwndStatus)SetDlgItemInt(m_hwndStatus,IDC_PORT,m_proxyport,FALSE); @@ -1429,9 +1435,9 @@ thataddr.sin_port = htons(m_proxyport); res = connect(m_sock, (LPSOCKADDR) &thataddr, sizeof(thataddr)); - if (res == SOCKET_ERROR) {if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L48);throw WarningException(sz_L48);} + if (res == SOCKET_ERROR) {SetStatusText(sz_L48);throw WarningException(sz_L48);} vnclog.Print(0, _T("Connected to %s port %d\n"), m_proxyhost, m_proxyport); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L49); + SetStatusText(sz_L49); if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_VNCSERVER,m_proxyhost); if (m_hwndStatus)ShowWindow(m_hwndStatus,SW_SHOW); if (m_hwndStatus)UpdateWindow(m_hwndStatus); @@ -1456,7 +1462,7 @@ /* if the connection is immediately closed, don't report anything, so that pmw's monitor can make test connections */ - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L89); + SetStatusText(sz_L89); try { ReadExact(pv, sz_rfbProtocolVersionMsg); @@ -1568,6 +1574,7 @@ { int size; ReadExact((char *)&size,sizeof(int)); + char mytext[1024]; //10k ReadExact(mytext,size); mytext[size]=0; @@ -1602,7 +1609,7 @@ /* if the connection is immediately closed, don't report anything, so that pmw's monitor can make test connections */ - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L89); + SetStatusText(sz_L89); try { ReadExactProxy(pv, sz_rfbProtocolVersionMsg); @@ -1690,8 +1697,9 @@ CARD8 challengems[CHALLENGESIZEMS]; ReadExact((char *)&authScheme, 4); + authScheme = Swap32IfLE(authScheme); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L90); + SetStatusText(sz_L90); // grm@20070428 switch (authScheme) { case rfbConnFailed: @@ -1702,12 +1710,12 @@ ReadString(m_netbuf, reasonLen); vnclog.Print(0, _T("RFB connection failed, reason: %s\n"), m_netbuf); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L91); + SetStatusText(sz_L91); throw WarningException(m_netbuf); break; case rfbNoAuth: - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L92); + SetStatusText(sz_L92); vnclog.Print(0, _T("No authentication needed\n")); break; @@ -1884,14 +1892,14 @@ switch (authResult) { case rfbVncAuthOK: - if (m_hwndStatus)vnclog.Print(0, _T("VNC authentication succeeded\n")); - SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L55); + vnclog.Print(0, _T("VNC authentication succeeded\n")); + SetStatusText(sz_L55); g_passwordfailed=false; break; case rfbVncAuthFailed: - vnclog.Print(0, _T("VNC authentication failed!")); + vnclog.Print(0, _T("VNC authentication failed!\n")); g_passwordfailed=true; - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L56); + SetStatusText(sz_L56); // if (flash) {flash->Killflash();} throw WarningException(sz_L57); case rfbVncAuthTooMany: @@ -1971,12 +1979,12 @@ switch (authResult) { case rfbVncAuthOK: vnclog.Print(0, _T("MS-Logon (DH) authentication succeeded.\n")); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L55); + SetStatusText(sz_L55); g_passwordfailed=false; break; case rfbVncAuthFailed: vnclog.Print(0, _T("MS-Logon (DH) authentication failed!\n")); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L56); + SetStatusText(sz_L56); g_passwordfailed=true; throw WarningException(sz_L57); case rfbVncAuthTooMany: @@ -2305,7 +2313,13 @@ void ClientConnection::SetFormatAndEncodings() { // Set pixel format to myFormat - + if( m_onlyOneFormMsg ) { + m_onlyOneFormMsg++; + vnclog.Print(0, _T("Avoided send %d of Format and Encoding to server.\n"), m_onlyOneFormMsg); + return; + } + m_onlyOneFormMsg++; // grm@20070430 - this need to be RESET on each connection + rfbSetPixelFormatMsg spf; spf.type = rfbSetPixelFormat; @@ -2314,6 +2328,8 @@ spf.format.greenMax = Swap16IfLE(spf.format.greenMax); spf.format.blueMax = Swap16IfLE(spf.format.blueMax); + vnclog.Print(0, _T("Sending Pixel Format (%d) to Server\n"), rfbSetPixelFormat ); + WriteExact((char *)&spf, sz_rfbSetPixelFormatMsg, rfbSetPixelFormat); // The number of bytes required to hold at least one pixel. @@ -2417,6 +2433,8 @@ int nEncodings = se->nEncodings; se->nEncodings = Swap16IfLE(se->nEncodings); // WriteExact((char *)buf, len); + + vnclog.Print(0, _T("Sending Encodings %d to Server\n"), nEncodings); WriteExact((char *)buf, sz_rfbSetEncodingsMsg, rfbSetEncodings); for (int x = 0; x < nEncodings; x++) { @@ -2429,6 +2447,8 @@ TempDC hdc(m_hwnd); BitmapInfo bi; UINT iUsage; + int i; + memset(&bi, 0, sizeof(bi)); iUsage = m_myFormat.trueColour ? DIB_RGB_COLORS : DIB_PAL_COLORS; @@ -2471,7 +2491,7 @@ delete [] pLogPal;*/ - for (int i=0; i < (1<<(m_myFormat.depth)); i++) { + for (i=0; i < (1<<(m_myFormat.depth)); i++) { rgbQ[i].b = ((((i >> m_myFormat.blueShift) & m_myFormat.blueMax) * 65535) + m_myFormat.blueMax/2) / m_myFormat.blueMax; rgbQ[i].g = ((((i >> m_myFormat.greenShift) & m_myFormat.greenMax) * 65535) + m_myFormat.greenMax/2) / m_myFormat.greenMax; rgbQ[i].r = ((((i >> m_myFormat.redShift) & m_myFormat.redMax) * 65535) + m_myFormat.redMax/2) / m_myFormat.redMax; @@ -3244,9 +3264,9 @@ } default: - vnclog.Print(3, _T("Unknown message type x%02x\n"), msgType ); - throw WarningException(sz_L64); - break; + vnclog.Print(3, _T("Unknown message type x%02x\n"), msgType ); + throw WarningException(sz_L64); + break; /* default: @@ -3925,6 +3945,10 @@ SetDlgItemInt(m_hwndStatus, IDC_RECEIVED, m_BytesRead, false); SetDlgItemInt(m_hwndStatus, IDC_SPEED, kbitsPerSecond, false); */ +#ifndef NDEBUG + vnclog.Print(10, "ReadExact: wanted %d bytes\n", wanted ); +#endif // #ifndef NDEBUG + try { // sf@2002 - DSM Plugin @@ -3990,7 +4014,7 @@ catch (rdr::Exception& e) { vnclog.Print(0, "rdr::Exception (2): %s\n",e.str()); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L67); + SetStatusText(sz_L67); throw QuietException(e.str()); } @@ -4006,6 +4030,10 @@ ReleaseDC(m_TrafficMonitor,hdcX); } */ +#ifdef ADD_PRINT_HEX + //vnclog.Print(10, "OUT: ReadExact: wanted %d bytes\n", wanted ); + vnclog.PrintHex( inbuf, wanted ); +#endif // #ifdef ADD_PRINT_HEX } @@ -4024,8 +4052,8 @@ } catch (rdr::Exception& e) { - vnclog.Print(0, "rdr::Exception (2): %s\n",e.str()); - if (m_hwndStatus)SetDlgItemText(m_hwndStatus,IDC_STATUS,sz_L67); + vnclog.Print(0, "rdr::Exception (2): %s (REP)\n",e.str()); + SetStatusText(sz_L67); throw QuietException(e.str()); } @@ -4078,7 +4106,18 @@ */ omni_mutex_lock l(m_writeMutex); - //vnclog.Print(10, _T(" writing %d bytes\n"), bytes); +#ifndef NDEBUG + { + static int _s_dnplugin = 0; + if( _s_dnplugin == 0 ) { + _s_dnplugin = 1; + vnclog.Print(10, _T("WriteExact: Plugin %s\n"), + ((m_fUsePlugin && m_pDSMPlugin->IsEnabled()) ? _T("DSMPlugin") : _T("NONE")) ); + } + } + vnclog.Print(10, _T("WriteExact: %d bytes\n"), bytes ); + vnclog.PrintHex( buf, bytes ); +#endif // !NDEBUG m_BytesSend += bytes; /* @@ -4146,7 +4185,9 @@ if (bytes == 0) return; omni_mutex_lock l(m_writeMutex); - //vnclog.Print(10, _T(" writing %d bytes\n"), bytes); +#ifndef NDEBUG + vnclog.Print(10, _T("Writing proxy %d bytes\n"), bytes); +#endif // #ifndef NDEBUG m_BytesSend += bytes; /* @@ -4202,7 +4243,7 @@ delete [] m_netbuf; m_netbuf = newbuf; m_netbufsize=bufsize + 256; - vnclog.Print(4, _T("bufsize expanded to %d\n"), m_netbufsize); + vnclog.Print(4, _T("bufsize expanded to %d (%X)\n"), m_netbufsize, bufsize); } @@ -4230,7 +4271,7 @@ delete [] m_zipbuf; m_zipbuf = newbuf; m_zipbufsize = bufsize + 256; - vnclog.Print(4, _T("zipbufsize expanded to %d\n"), m_zipbufsize); + vnclog.Print(4, _T("zipbufsize expanded to %d (%X)\n"), m_zipbufsize, bufsize); } @@ -4254,7 +4295,7 @@ delete [] m_filezipbuf; m_filezipbuf = newbuf; m_filezipbufsize = bufsize + 256; - vnclog.Print(4, _T("zipbufsize expanded to %d\n"), m_filezipbufsize); + vnclog.Print(4, _T("zipbufsize expanded to %d (%X)\n"), m_filezipbufsize, bufsize); } void ClientConnection::CheckFileChunkBufferSize(int bufsize) @@ -4363,13 +4404,13 @@ } else if( Size > (1024*1024) ) { - unsigned long lRest = (Size % (1024*1024)); + unsigned long lRest = (unsigned long)(Size % (1024*1024)); Size /= (1024*1024); wsprintf(szText,"%u.%3.3lu Mb", (unsigned long)Size, (unsigned long)((__int64)(lRest) * 1000 / 1024 / 1024)); } else if ( Size > 1024 ) { - unsigned long lRest = Size % (1024); + unsigned long lRest = (unsigned long)(Size % (1024)); Size /= 1024; wsprintf(szText,"%u.%2.2lu Kb", (unsigned long)Size, lRest * 100 / 1024); } @@ -4556,8 +4597,8 @@ char wt[MAX_PATH]; ClientConnection *_this = (ClientConnection *)lParam; SetWindowLong(hwnd, GWL_USERDATA, (LONG) _this); - SetDlgItemInt(hwnd,IDC_RECEIVED,_this->m_BytesRead,false); - SetDlgItemInt(hwnd,IDC_SEND,_this->m_BytesSend,false); + SetDlgItemInt(hwnd,IDC_RECEIVED,(UINT)_this->m_BytesRead,false); + SetDlgItemInt(hwnd,IDC_SEND,(UINT)_this->m_BytesSend,false); if (_this->m_host != NULL) { SetDlgItemText(hwnd,IDC_VNCSERVER,_this->m_host); @@ -6208,5 +6249,23 @@ if (y+h= 0x7f)) + c = '.'; + pasc[casc++] = c; + } + phex[chex] = 0; + pasc[casc] = 0; + strcat(phex,pasc); + strcat(phex,"\n"); + // could use Print(...), but for speed, pump it only to the file from here + WriteFile(hlogfile, phex, _tcslen(phex)*sizeof(TCHAR), &byteswritten, NULL); + // skip lines inbetween, and only output the last, up to 16 bytes + if( len > 16 ) { + int rem = len - 16; + if( rem > 16 ) { + i += rem - 16; + rem = 16; + } + chex = 0; + casc = 0; + for( j = 0; j < rem; j++ ) + { + c = pData[i+j]; + chex += sprintf( &phex[chex], "%02X ", c ); + if(( c < ' ' )||(c >= 0x7f)) + c = '.'; + pasc[casc++] = c; + } + phex[chex] = 0; + pasc[casc] = 0; + strcat(phex,pasc); + strcat(phex,"\n"); + WriteFile(hlogfile, phex, _tcslen(phex)*sizeof(TCHAR), &byteswritten, NULL); + } + } +} +#endif // #ifndef NDEBUG + Log::~Log() { --- C:\DTEMP\UltraVNC-102-Src\UltraVNC\vncviewer\Log.h Sun Feb 13 02:36:48 2005 +++ UltraVNC\vncviewer\Log.h Tue May 01 14:51:55 2007 @@ -66,6 +66,10 @@ va_end(ap); } +#ifndef NDEBUG // ensure this does NOT happen in Release + void PrintHex( PTSTR pData, int len ); +#endif // #ifndef NDEBUG + // Change the log level void SetLevel(int level); --- C:\DTEMP\UltraVNC-102-Src\UltraVNC\vncviewer\res\vncviewer.rc Sun Jun 18 13:08:02 2006 +++ UltraVNC\vncviewer\res\vncviewer.rc Fri Apr 27 19:40:26 2007 @@ -49,13 +49,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// 24 -// - -IDR_MANIFEST 24 DISCARDABLE "vncviewer.exe.manifest" - -///////////////////////////////////////////////////////////////////////////// -// // Icon // --- C:\DTEMP\UltraVNC-102-Src\UltraVNC\vncviewer\stdhdrs.h Thu Oct 03 23:21:00 2002 +++ UltraVNC\vncviewer\stdhdrs.h Sat Apr 28 12:41:40 2007 @@ -23,6 +23,11 @@ #define VC_EXTRALEAN +#ifdef _MSC_VER +#if (_MSC_VER > 1310) // if MSVC8 = 1400 +#pragma warning( disable:4996 ) // This function or variable may be unsafe +#endif // #if (_MSC_VER > 1310) +#endif // #ifdef _MSC_VER #include #include --- C:\DTEMP\UltraVNC-102-Src\UltraVNC\vncviewer\VNCviewerApp.cpp Sun Mar 06 18:23:40 2005 +++ UltraVNC\vncviewer\VNCviewerApp.cpp Mon Apr 30 16:50:23 2007 @@ -43,7 +43,19 @@ // Read the command line m_options.SetFromCommandLine(szCmdLine); - + + // =================================== +#ifndef NDEBUG // JUST FOR DEBUGGING + // default to FILE LOGGING + if( !m_options.m_logToFile ) { + m_options.m_logToFile = true; + if( strlen(m_options.m_logFilename) == 0 ) { + strcpy(m_options.m_logFilename, _T("templog.txt")); + } + m_options.m_logLevel = 120; // largest number seen was 100, but ... + } +#endif // NDEBUG + // Logging info vnclog.SetLevel(m_options.m_logLevel); if (m_options.m_logToConsole) {