├── .gitignore ├── AC.cpp ├── AC.h ├── Backup └── RD.sln ├── BufferedFile.cpp ├── BufferedFile.h ├── Common.cpp ├── Common.h ├── DIBFrame.cpp ├── DIBFrame.h ├── Hash.h ├── Packet.cpp ├── Packet.h ├── RD.sln ├── RDS ├── RDS.cpp ├── RDS.h ├── RDS.manifest ├── RDS.rc ├── RDS.vcproj ├── RDS.vcxproj ├── RDS.vcxproj.filters ├── RDSDlg.cpp ├── RDSDlg.h ├── ReadMe.txt ├── RefreshThread.cpp ├── RefreshThread.h ├── Service.cpp ├── Service.h ├── TrayIcon.cpp ├── TrayIcon.h ├── VideoDriver.cpp ├── VideoDriver.h ├── Win32 │ └── Release │ │ └── RDS.exe ├── icon1.ico ├── res │ ├── RDS.ico │ ├── RDS.manifest │ ├── RDS.rc2 │ ├── desktop.ini │ └── main.ico ├── resource.h ├── stdafx.cpp ├── stdafx.h └── x64 │ └── Release │ └── RDS.exe ├── RDV ├── ChildFrm.cpp ├── ChildFrm.h ├── MainFrm.cpp ├── MainFrm.h ├── NewConnectionDlg.cpp ├── NewConnectionDlg.h ├── RDV.cpp ├── RDV.h ├── RDV.rc ├── RDV.reg ├── RDV.vcproj ├── RDV.vcxproj ├── RDV.vcxproj.filters ├── RDVDoc.cpp ├── RDVDoc.h ├── RDVView.cpp ├── RDVView.h ├── ReadMe.txt ├── Win32 │ └── Release │ │ └── RDV.exe ├── res │ ├── RDV.ico │ ├── RDV.rc2 │ ├── RDVDoc.ico │ ├── Toolbar.bmp │ └── icon1.ico ├── resource.h ├── stdafx.cpp ├── stdafx.h └── x64 │ └── Release │ └── RDV.exe ├── README.md ├── Registry.cpp ├── Registry.h ├── TCPSocket.cpp ├── TCPSocket.h ├── UpgradeLog.htm ├── WndSink.cpp ├── WndSink.h ├── ZLib ├── UpgradeLog.XML ├── ZLib.sln ├── ZLib.vcproj ├── ZLib.vcxproj ├── ZLib.vcxproj.filters ├── adler32.c ├── compress.c ├── crc32.c ├── crc32.h ├── deflate.c ├── deflate.h ├── example.c ├── gzio.c ├── infback.c ├── inffast.c ├── inffast.h ├── inffixed.h ├── inflate.c ├── inflate.h ├── inftrees.c ├── inftrees.h ├── minigzip.c ├── trees.c ├── trees.h ├── uncompr.c ├── zconf.h ├── zconf.in.h ├── zlib.def ├── zlib.h ├── zutil.c └── zutil.h ├── rd.html ├── zconf.h └── zlib.h /.gitignore: -------------------------------------------------------------------------------- 1 | /RDV/Win32/Debug 2 | /RDS/Win32/Debug 3 | /ZLib/Debug 4 | /ZLib/Debug/ZLib.log 5 | /RD.opensdf 6 | 7 | /ZLib32d.lib 8 | /RD.sdf 9 | /RD.v12.suo 10 | -------------------------------------------------------------------------------- /AC.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include "Common.h" 20 | 21 | // CArithmeticEncoding (high level implementation) 22 | #define BITMASK 0x80 23 | #define MSB 0x8000 24 | #define NSB 0x4000 25 | #define USB 0x3FFF 26 | 27 | class CArithmeticEncoder 28 | { 29 | public: 30 | CArithmeticEncoder(); 31 | bool EncodeBuffer(char * pBufferIn,unsigned long ulnSrcCount,char * & pBufferOut,unsigned long & ulnDestCount); 32 | bool DecodeBuffer(char * pBufferIn,unsigned long ulnSrcCount,char ** ppBufferOut,unsigned long * pulnDestCount,BOOL bAlloc = TRUE); 33 | 34 | CArithmeticEncoder(char * pBufferIn,unsigned long ulnSrcCount); 35 | void SetBuffer(char * pBufferIn,unsigned long ulnSrcCount); 36 | void GetBuffer(char * & pBufferOut,unsigned long & ulnDestCount); 37 | bool EncodeBuffer(); 38 | bool DecodeBuffer(); 39 | 40 | ~CArithmeticEncoder(); 41 | 42 | protected: 43 | void InitModel(); 44 | void ScaleCounts(); 45 | unsigned int RangeCounts(); 46 | void BuildMap(); 47 | void OutputBit(unsigned short int usiBit,unsigned char & ucOutSymbol,unsigned char & ucBitMask,unsigned long & ulDestCount,char * pBuffer); 48 | void OutputUnderflowBits(unsigned short int usiBit,unsigned long & ulUnderflowBits,unsigned char & ucOutSymbol,unsigned char & ucBitMask,unsigned long & ulDestCount,char * pBuffer); 49 | void FlushBitMask(unsigned char & ucBitMask,unsigned char & ucOutSymbol,unsigned long & ulDestCount,char * pBuffer); 50 | 51 | protected: 52 | char * m_pBufferIn; 53 | unsigned long m_ulnSrcCount; 54 | char * m_pBufferOut; 55 | unsigned long m_ulnDestCount; 56 | unsigned long m_ulnLastBuffer; 57 | 58 | private: 59 | unsigned long m_ac[256]; 60 | unsigned long m_ac2[256]; 61 | unsigned short int m_ar[257]; 62 | unsigned int m_aMap[16384]; 63 | }; 64 | 65 | class CZLib 66 | { 67 | public: 68 | CZLib(); 69 | int EncodeBuffer(char * pBufferIn,unsigned long ulnSrcCount,char * & pBufferOut,unsigned long & ulnDestCount); 70 | int DecodeBuffer(char * pBufferIn,unsigned long ulnSrcCount,char * & pBufferOut,unsigned long & ulnDestCount,BOOL bAlloc = TRUE); 71 | 72 | CZLib(char * pBufferIn,unsigned long ulnSrcCount); 73 | void SetBuffer(char * pBufferIn,unsigned long ulnSrcCount,BOOL bEncode); 74 | void GetBuffer(char * & pBufferOut,unsigned long & ulnDestCount); 75 | int EncodeBuffer(); 76 | int DecodeBuffer(); 77 | 78 | ~CZLib(); 79 | 80 | protected: 81 | char * m_pBufferIn; 82 | unsigned long m_ulnSrcCount; 83 | char * m_pBufferOut; 84 | unsigned long m_ulnDestCount; 85 | unsigned long m_ulnLastBuffer; 86 | 87 | protected: 88 | int ZLIBCompress(Byte * Dest, uLong & DestLen, Byte * Src, uLong SrcLen); 89 | int ZLIBUncompress(Byte * Dest, uLong & DestLen, Byte * Src, uLong SrcLen); 90 | }; 91 | 92 | // Worker thread that carries out the multi-threaded arithmetic encoder 93 | class CMultiThreadedCompression : public CWinThread 94 | { 95 | DECLARE_DYNCREATE(CMultiThreadedCompression) 96 | 97 | private: 98 | CMultiThreadedCompression() : m_phHandle(NULL), m_pAC(NULL) {}; 99 | 100 | public: 101 | CMultiThreadedCompression(HANDLE * phHandle,CArithmeticEncoder * pAC,CZLib * pZLib); 102 | virtual ~CMultiThreadedCompression(); 103 | virtual BOOL InitInstance(); 104 | virtual int ExitInstance(); 105 | CArithmeticEncoder * GetAC() {return m_pAC;} 106 | CZLib * GetZLib() {return m_pZLib;} 107 | 108 | protected: 109 | HANDLE * m_phHandle; 110 | CArithmeticEncoder * m_pAC; 111 | CZLib * m_pZLib; 112 | 113 | protected: 114 | DECLARE_MESSAGE_MAP() 115 | 116 | protected: 117 | afx_msg void OnProcessBuffer(WPARAM wParam,LPARAM lParam); 118 | afx_msg void OnEndThread(WPARAM wParam,LPARAM lParam); 119 | }; 120 | 121 | // Driver that carries out the work of arithmetic encoding 122 | class CDriveMultiThreadedCompression 123 | { 124 | CDriveMultiThreadedCompression() throw(...) {throw;} 125 | public: 126 | CDriveMultiThreadedCompression(int nTotalThreads); 127 | ~CDriveMultiThreadedCompression(); 128 | void SetEncoder(BOOL bAC); 129 | void SetBuffer(char * pBuffer,DWORD dwTotalBytes,BOOL bEncode); 130 | void GetBuffer(char ** ppBuffer,DWORD * pdwBytes,BOOL bEncode,BOOL bAlloc = TRUE); 131 | void GetBufferSize(BOOL bEncode,DWORD & dwBytes); 132 | bool Encode(); 133 | bool Decode(); 134 | 135 | protected: 136 | bool ProcessBuffer(BOOL bEncode); 137 | 138 | protected: 139 | HANDLE m_arrhAC[MAXTHREADS]; 140 | int m_nTotalThreads; 141 | DWORD m_dwBytesPerThread; 142 | CMultiThreadedCompression ** m_ppMultiThreadedCompression; 143 | BOOL m_bAC; 144 | DWORD m_dwLastBytes; 145 | std::auto_ptr m_Buffer; 146 | char * m_pBuffer; 147 | }; -------------------------------------------------------------------------------- /Backup/RD.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RDS", "RDS\RDS.vcproj", "{636A6E84-6021-4A0A-B554-1AD52DA41CC8}" 4 | ProjectSection(ProjectDependencies) = postProject 5 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A} = {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A} 6 | EndProjectSection 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RDV", "RDV\RDV.vcproj", "{791FFCDF-33C1-4191-A574-65B3DB6C50DA}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A} = {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "ZLib\ZLib.vcproj", "{BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Win32 = Debug|Win32 18 | Debug|x64 = Debug|x64 19 | Release|Win32 = Release|Win32 20 | Release|x64 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|Win32.Build.0 = Debug|Win32 25 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|x64.ActiveCfg = Debug|x64 26 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|x64.Build.0 = Debug|x64 27 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|Win32.ActiveCfg = Release|Win32 28 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|Win32.Build.0 = Release|Win32 29 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|x64.ActiveCfg = Release|x64 30 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|x64.Build.0 = Release|x64 31 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|Win32.ActiveCfg = Debug|Win32 32 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|Win32.Build.0 = Debug|Win32 33 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|x64.ActiveCfg = Debug|x64 34 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|x64.Build.0 = Debug|x64 35 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|Win32.ActiveCfg = Release|Win32 36 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|Win32.Build.0 = Release|Win32 37 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|x64.ActiveCfg = Release|x64 38 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|x64.Build.0 = Release|x64 39 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|Win32.ActiveCfg = Debug|Win32 40 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|Win32.Build.0 = Debug|Win32 41 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|x64.ActiveCfg = Debug|x64 42 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|x64.Build.0 = Debug|x64 43 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|Win32.ActiveCfg = Release|Win32 44 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|Win32.Build.0 = Release|Win32 45 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|x64.ActiveCfg = Release|x64 46 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|x64.Build.0 = Release|x64 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | GlobalSection(DPCodeReviewSolutionGUID) = preSolution 52 | DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} 53 | EndGlobalSection 54 | EndGlobal 55 | -------------------------------------------------------------------------------- /BufferedFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define CREAT _O_CREAT 10 | #define TRUNC _O_TRUNC 11 | #define RDONLY _O_RDONLY 12 | #define WRONLY _O_WRONLY 13 | #define RDWR _O_RDWR 14 | #define BINARY _O_BINARY 15 | 16 | // Optional call back functions for when the file is opened and closed 17 | typedef void (__stdcall * pFNOpenFile)(int hFile); 18 | typedef void (__stdcall * pFNCloseFile)(int hFile); 19 | 20 | // Memory Allocator Class 21 | class CBufferedMemory 22 | { 23 | public: 24 | CBufferedMemory(); 25 | virtual ~CBufferedMemory(); 26 | 27 | public: 28 | bool AllocBuffer(unsigned long ulBytes); 29 | bool ReallocBuffer(unsigned long ulBytes,unsigned long ulPos); 30 | void FreeBuffer(); 31 | const char * GetBuffer() {return (const char *)m_lpBuffer;} 32 | 33 | protected: 34 | char * Alloc(unsigned long ulBytes); 35 | void Free(char * pbMem = 0); 36 | 37 | protected: 38 | char * m_lpBuffer; 39 | unsigned long m_ulBytes; 40 | }; 41 | 42 | // Buffered I/O File Class 43 | class CBufferedFile : virtual public CBufferedMemory 44 | { 45 | public: 46 | CBufferedFile(const char * pszFilename = 0,unsigned int uiInitial = 1024,unsigned int uiMaxBufferSize = 65536,unsigned int uiGrowBy = 4096,int iMode = BINARY|RDONLY,pFNOpenFile lpfnOpenFile = 0,pFNCloseFile lpfnCloseFile = 0); 47 | virtual ~CBufferedFile(); 48 | 49 | public: 50 | void SetFilename(const char * pszFilename = 0); 51 | void SetMode(int iMode = BINARY|RDONLY); 52 | void Open(const char * pszFilename = 0,int iMode = 0); 53 | void Close(); 54 | unsigned long GetLength(); 55 | unsigned long Rewind(); 56 | unsigned long FastForward(); 57 | bool MovePosition(long lBytes,bool bRelative); 58 | void ResetBuffer(); 59 | 60 | public: 61 | template CBufferedFile & operator >> (TYPE & rhs); 62 | unsigned int Read(const void * lpBuffer,unsigned int uiCount); 63 | template CBufferedFile & operator << (const TYPE & rhs); 64 | unsigned int Write(const void * lpBuffer,unsigned int uiCount); 65 | 66 | public: 67 | bool IsOpen() const {return m_bOpened;} 68 | operator bool () const {return !m_bEOF;} 69 | bool IsEOF() const {return m_bEOF;} 70 | bool IsErr() const {return m_bErr;} 71 | 72 | protected: 73 | bool IsReading() const {return ((m_iMode & WRONLY) == 0) || ((m_iMode & RDWR) == RDWR);} 74 | bool IsWriting() const {return ((m_iMode & WRONLY) == WRONLY) || ((m_iMode & RDWR) == RDWR);} 75 | 76 | protected: 77 | int Flush(); 78 | void FillBuffer(); 79 | 80 | protected: 81 | // File and Access mode 82 | char * m_pszFilename; 83 | int m_hFile,m_iMode; 84 | 85 | // Flags 86 | bool m_bOpened,m_bEOF,m_bErr; 87 | 88 | // File position 89 | long m_lFilePosBeg,m_lFilePosEnd; 90 | 91 | // The length of the file 92 | unsigned long m_ulLength; 93 | 94 | // Buffering 95 | unsigned int m_uiDefBufferSize,m_uiBufferPosition,m_uiBufferSize,m_uiMaxBufferSize,m_uiGrowBytes; 96 | 97 | // Read buffering 98 | bool m_bReadExceeded; 99 | unsigned int m_uiEOBPosition; 100 | 101 | // Write buffering 102 | bool m_bWriteExceeded,m_bOpenWriteFile; 103 | 104 | protected: 105 | pFNOpenFile m_lpfnOpenFile; 106 | pFNCloseFile m_lpfnCloseFile; 107 | }; 108 | 109 | // Read data (overloaded right shift) 110 | template CBufferedFile & CBufferedFile::operator >> (TYPE & rhs) 111 | { 112 | // Do a buffered read 113 | memset(&rhs,0,sizeof(TYPE)); 114 | Read(&rhs,sizeof(TYPE)); 115 | return *this; 116 | } 117 | 118 | // Write data (overloaded left shift) 119 | template CBufferedFile & CBufferedFile::operator << (const TYPE & rhs) 120 | { 121 | Write(&rhs,sizeof(TYPE)); 122 | return *this; 123 | } 124 | 125 | // Read Buffered I/O File Class 126 | class CReadBufferedFile : virtual public CBufferedFile 127 | { 128 | public: 129 | CReadBufferedFile(const char * pszFilename = 0,unsigned int uiInitial = 1024,unsigned int uiMaxBufferSize = 65536,unsigned int uiGrowBy = 4096,pFNOpenFile lpfnOpenFile = 0,pFNCloseFile lpfnCloseFile = 0); 130 | void Open(const char * pszFilename = 0); 131 | }; 132 | 133 | // Write Buffered I/O File Class 134 | class CWriteBufferedFile : virtual public CBufferedFile 135 | { 136 | public: 137 | CWriteBufferedFile(const char * pszFilename = 0,unsigned int uiInitial = 1024,unsigned int uiMaxBufferSize = 65536,unsigned int uiGrowBy = 4096,pFNOpenFile lpfnOpenFile = 0,pFNCloseFile lpfnCloseFile = 0); 138 | void Open(const char * pszFilename = 0); 139 | }; 140 | 141 | // Write Read and Write Buffered I/O File Class 142 | class CReadWriteBufferedFile : virtual public CReadBufferedFile, virtual public CWriteBufferedFile 143 | { 144 | public: 145 | CReadWriteBufferedFile(const char * pszFilename = 0,unsigned int uiInitial = 1024,unsigned int uiMaxBufferSize = 65536,unsigned int uiGrowBy = 4096,pFNOpenFile lpfnOpenFile = 0,pFNCloseFile lpfnCloseFile = 0); 146 | void Open(const char * pszFilename = 0); 147 | void TruncOpen(const char * pszFilename = 0); 148 | }; -------------------------------------------------------------------------------- /Common.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "Common.h" 19 | #include 20 | 21 | // Debugging 22 | void DebugMsg(const TCHAR * pwszFormat,...) 23 | { 24 | TCHAR buf[1024] = {'\0'}; 25 | va_list arglist; 26 | va_start(arglist, pwszFormat); 27 | int nBufSize = _vsctprintf(pwszFormat,arglist) + 1; 28 | if (nBufSize) 29 | { 30 | std::auto_ptr Buffer(new TCHAR[nBufSize]); 31 | TCHAR * pBuffer = Buffer.get(); 32 | _vstprintf_s(pBuffer,nBufSize,pwszFormat,arglist); 33 | va_end(arglist); 34 | OutputDebugString(pBuffer); 35 | } 36 | } 37 | 38 | // Breaks down "GetLastError" 39 | void DebugLastError() 40 | { 41 | LPVOID lpMsgBuf; 42 | DWORD dwLastError = GetLastError(); 43 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,dwLastError,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR)&lpMsgBuf,0,NULL); 44 | DebugMsg(_T("%s\n"), lpMsgBuf); 45 | LocalFree(lpMsgBuf); 46 | } 47 | 48 | static OSVERSIONINFO g_osversioninfo; 49 | static DWORD g_dwPlatformId; 50 | static DWORD g_dwMajorVersion; 51 | static DWORD g_dwMinorVersion; 52 | 53 | void InitVersion() 54 | { 55 | // Get the current OS version 56 | g_osversioninfo.dwOSVersionInfoSize = sizeof(g_osversioninfo); 57 | if (!GetVersionEx(&g_osversioninfo)) 58 | g_dwPlatformId = 0; 59 | g_dwPlatformId = g_osversioninfo.dwPlatformId; 60 | g_dwMajorVersion = g_osversioninfo.dwMajorVersion; 61 | g_dwMinorVersion = g_osversioninfo.dwMinorVersion; 62 | } 63 | 64 | BOOL IsNtVer(ULONG mj,ULONG mn) 65 | { 66 | if (!IsWinNT()) 67 | return FALSE; 68 | return (VersionMajor() == mj && VersionMinor() == mn); 69 | } 70 | 71 | BOOL IsWinNT() 72 | { 73 | return (g_dwPlatformId == VER_PLATFORM_WIN32_NT); 74 | } 75 | 76 | BOOL IsWinVerOrHigher(ULONG mj,ULONG mn) 77 | { 78 | return (VersionMajor() > mj || (VersionMajor() == mj && VersionMinor() >= mn)); 79 | } 80 | 81 | DWORD VersionMajor() 82 | { 83 | return g_dwMajorVersion; 84 | } 85 | 86 | DWORD VersionMinor() 87 | { 88 | return g_dwMinorVersion; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Common.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include "zlib.h" 22 | 23 | #if defined(_DEBUG) 24 | #if !defined(X64) 25 | #pragma comment(lib,"..\\Zlib32d.lib") 26 | #else 27 | #pragma comment(lib,"..\\Zlib64d.lib") 28 | #endif 29 | #else 30 | #if !defined(X64) 31 | #pragma comment(lib,"..\\Zlib32.lib") 32 | #else 33 | #pragma comment(lib,"..\\Zlib64.lib") 34 | #endif 35 | #endif 36 | 37 | #define MAXTHREADS 64 38 | #define WM_ENDTHREAD (WM_APP + 100) 39 | #define WM_PROCESSBUFFER (WM_APP + 101) 40 | #define WM_IMAGEREFRESH (WM_APP + 102) 41 | #define WM_IMAGECOMPRESS (WM_APP + 103) 42 | #define WM_IMAGESEND (WM_APP + 104) 43 | #define WM_IMAGERENEW (WM_APP + 105) 44 | #define WM_CONNECTSERVER (WM_APP + 106) 45 | 46 | #define SERVICE_CONTROL_USER 128 47 | 48 | void DebugMsg(const TCHAR * pwszFormat,...); 49 | void DebugLastError(); 50 | 51 | // Debugging timer used for detecting the duration of an operation 52 | class CDuration 53 | { 54 | const TCHAR * p; 55 | clock_t start; 56 | clock_t finish; 57 | public: 58 | CDuration(const TCHAR * sz) : p(sz),start(clock()),finish(start) {}; 59 | ~CDuration() 60 | { 61 | finish = clock(); 62 | double duration = (double)(finish - start) / CLOCKS_PER_SEC; 63 | DebugMsg(_T("%s Duration = %f seconds\n"), p, duration); 64 | } 65 | }; 66 | 67 | // CPU id helper structure 68 | struct CPU 69 | { 70 | CPU() : m_r1(0), m_r2(0), m_nProc(0), m_r3(0), m_r4(0), m_r5(0) {Init();} 71 | CPU(int nProc) : m_r1(0), m_r2(0), m_nProc(nProc), m_r3(0), m_r4(0), m_r5(0) {Init();} 72 | ~CPU() {}; 73 | CPU(const CPU & rhs) {*this = rhs;} 74 | CPU & operator = (const CPU & rhs) 75 | { 76 | if (this != &rhs) 77 | { 78 | m_r1 = rhs.m_r1; 79 | m_r2 = rhs.m_r2; 80 | m_nProc = rhs.m_nProc; 81 | m_r3 = rhs.m_r3; 82 | m_r4 = rhs.m_r4; 83 | m_r5 = rhs.m_r5; 84 | } 85 | return *this; 86 | } 87 | void Init() {__cpuid((int*)this,1);} 88 | int GetNbProcs() {return m_nProc;} 89 | int GetNbThreads() {return min(GetNbProcs() * 4,MAXTHREADS);} 90 | 91 | unsigned m_r1 : 32; 92 | unsigned m_r2 : 16; 93 | unsigned m_nProc : 8; // Number of logical processors 94 | unsigned m_r3 : 32; 95 | unsigned m_r4 : 32; 96 | unsigned m_r5 : 4; 97 | unsigned m_HT : 1; // multi-threading / hyperthreading bit 98 | unsigned m_r6 : 3; 99 | }; 100 | 101 | // Compression helper structure 102 | struct CompressionInfo 103 | { 104 | char * m_pInBuffer; 105 | DWORD m_dwSrcBytes; 106 | char ** m_ppOutBuffer; 107 | DWORD * m_pdwOutBytes; 108 | }; 109 | 110 | void InitVersion(); 111 | BOOL IsNtVer(ULONG mj,ULONG mn); 112 | BOOL IsWinNT(); 113 | BOOL IsWinVerOrHigher(ULONG mj, ULONG mn); 114 | DWORD VersionMajor(); 115 | DWORD VersionMinor(); -------------------------------------------------------------------------------- /DIBFrame.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "DIBFrame.h" 19 | 20 | // Construct the frame 21 | CDIBFrame::CDIBFrame() : m_x(0), m_y(0), m_nBitCount(32), 22 | m_hBkgFrame(NULL), m_pBkgBits(NULL), m_hLastBkgFrame(NULL), 23 | m_pBitmapInfo(NULL), m_pBitmapInfoHdr(NULL), m_dwBkgImageBytes(0) 24 | { 25 | } 26 | 27 | // Construct the frame 28 | CDIBFrame::CDIBFrame(int x,int y,int nBitCount) : m_x(x), m_y(y), m_nBitCount(nBitCount), 29 | m_hBkgFrame(NULL), m_pBkgBits(NULL), m_hLastBkgFrame(NULL), 30 | m_pBitmapInfo(NULL), m_pBitmapInfoHdr(NULL), m_dwBkgImageBytes(0) 31 | { 32 | // Create the frame 33 | CreateFrame(); 34 | } 35 | 36 | // Construct the frame from the buffer 37 | CDIBFrame::CDIBFrame(BYTE * pBuffer,DWORD dwLen) 38 | { 39 | // Create the frame 40 | CreateFrame(pBuffer,dwLen); 41 | } 42 | 43 | // Copy/Assignment constructor 44 | CDIBFrame::CDIBFrame(const CDIBFrame & rhs) 45 | { 46 | *this = rhs; 47 | } 48 | 49 | // Deconstruct the frame 50 | CDIBFrame::~CDIBFrame() 51 | { 52 | // Delete the frame 53 | DeleteFrame(); 54 | } 55 | 56 | // Copy/Assignment operator 57 | CDIBFrame & CDIBFrame::operator = (const CDIBFrame & rhs) 58 | { 59 | if (this != &rhs) 60 | { 61 | // Copy the dimensions 62 | m_x = rhs.m_x; 63 | m_y = rhs.m_y; 64 | m_nBitCount = rhs.m_nBitCount; 65 | 66 | // Create this frame from this others buffer 67 | const std::vector & Buffer = rhs.m_Buffer; 68 | const BYTE * pBuffer = NULL; 69 | DWORD dwLen = (DWORD)Buffer.size(); 70 | if (dwLen) 71 | pBuffer = &Buffer[0]; 72 | CreateFrame(pBuffer,dwLen); 73 | } 74 | return *this; 75 | } 76 | 77 | // Set the dimensions and create the frame 78 | void CDIBFrame::Init(int x,int y,int nBitCount) 79 | { 80 | // Test the dimensions 81 | if (x < 1 || y < 1) 82 | return; 83 | 84 | // Test for already being initialized 85 | if (m_FrameDC && m_x == x && m_y == y) 86 | return; 87 | 88 | // Set the new dimensions 89 | m_x = x; 90 | m_y = y; 91 | m_nBitCount = nBitCount; 92 | 93 | // Create the frame 94 | CreateFrame(); 95 | } 96 | 97 | // Create the frame 98 | void CDIBFrame::CreateFrame(const BYTE * pBuffer,DWORD dwLen) 99 | { 100 | // Cleanup the last frame 101 | DeleteFrame(); 102 | 103 | // Create a DC for the compatible display 104 | CDC DisplayDC; 105 | DisplayDC.Attach(GetDC(GetDesktopWindow())); 106 | 107 | // Create the last frame DC 108 | m_FrameDC.CreateCompatibleDC(&DisplayDC); 109 | if (m_FrameDC) 110 | { 111 | if (!pBuffer) 112 | { 113 | // Calculate the size of the bitmap info structure (header + color table) 114 | DWORD dwLen = (DWORD)((WORD)sizeof(BITMAPINFOHEADER) + (m_nBitCount == 32 ? 0 : (m_nBitCount == 8 ? 256 : 16)) * sizeof(RGBQUAD)); 115 | 116 | // Allocate the bitmap structure 117 | m_Buffer.resize(dwLen,0); 118 | BYTE * pBuffer = &m_Buffer[0]; 119 | 120 | // Set up the bitmap info structure for the DIB section 121 | m_pBitmapInfo = (BITMAPINFO*)pBuffer; 122 | m_pBitmapInfoHdr = (BITMAPINFOHEADER*)&(m_pBitmapInfo->bmiHeader); 123 | m_pBitmapInfoHdr->biSize = sizeof(BITMAPINFOHEADER); 124 | m_pBitmapInfoHdr->biWidth = m_x; 125 | m_pBitmapInfoHdr->biHeight = m_y; 126 | m_pBitmapInfoHdr->biPlanes = 1; 127 | m_pBitmapInfoHdr->biBitCount = m_nBitCount; 128 | m_pBitmapInfoHdr->biCompression = BI_RGB; 129 | 130 | 131 | if (m_nBitCount == 8) 132 | { 133 | // 256 color gray scale color table embedded in the DIB 134 | RGBQUAD Colors; 135 | for (int iColor = 0;iColor < 256;iColor++) 136 | { 137 | Colors.rgbBlue = Colors.rgbGreen = Colors.rgbRed = Colors.rgbReserved = iColor; 138 | m_pBitmapInfo->bmiColors[iColor] = Colors; 139 | } 140 | m_pBitmapInfo->bmiHeader.biClrUsed = 256; 141 | } 142 | else if (m_nBitCount == 4) 143 | { 144 | // 16 color gray scale color for low bandwidth 145 | RGBQUAD Colors; 146 | for (int iColor = 0;iColor < 16;iColor++) 147 | { 148 | Colors.rgbBlue = Colors.rgbGreen = Colors.rgbRed = Colors.rgbReserved = iColor * 16; 149 | m_pBitmapInfo->bmiColors[iColor] = Colors; 150 | } 151 | m_pBitmapInfo->bmiHeader.biClrUsed = 16; 152 | } 153 | 154 | // Create the DIB for the frame 155 | m_hBkgFrame = CreateDIBSection(m_FrameDC,m_pBitmapInfo,DIB_RGB_COLORS,(void**)&m_pBkgBits,NULL,0); 156 | 157 | // Prepare the frame DIB for painting 158 | m_hLastBkgFrame = (HBITMAP)m_FrameDC.SelectObject(m_hBkgFrame); 159 | 160 | // Initialize the DIB to black 161 | m_FrameDC.PatBlt(0,0,m_x,m_y,BLACKNESS); 162 | } 163 | else 164 | { 165 | // Copy the buffer 166 | m_Buffer.resize(dwLen,0); 167 | memcpy(&m_Buffer[0],pBuffer,dwLen); 168 | 169 | // Create the DIB from the buffer 170 | m_pBitmapInfo = (BITMAPINFO *)pBuffer; 171 | m_pBitmapInfoHdr = &m_pBitmapInfo->bmiHeader; 172 | m_hBkgFrame = CreateDIBSection(m_FrameDC,m_pBitmapInfo,DIB_RGB_COLORS,(void**)&m_pBkgBits,NULL,0); 173 | m_hLastBkgFrame = (HBITMAP)m_FrameDC.SelectObject(m_hBkgFrame); 174 | memcpy(m_pBkgBits,pBuffer + m_pBitmapInfoHdr->biSize,m_pBitmapInfoHdr->biSizeImage); 175 | } 176 | 177 | // Get the byte storage amount for the DIB bits 178 | BITMAP bmMask; 179 | GetObject(m_hBkgFrame,sizeof(BITMAP),&bmMask); 180 | m_dwBkgImageBytes = bmMask.bmWidthBytes * bmMask.bmHeight; 181 | } 182 | 183 | // Delete the dc's 184 | ReleaseDC(GetDesktopWindow(),DisplayDC.Detach()); 185 | } 186 | 187 | // Delete the frame 188 | void CDIBFrame::DeleteFrame() 189 | { 190 | // Check for a frame to cleanup 191 | if (m_FrameDC) 192 | { 193 | // UnSelect the DIB 194 | m_FrameDC.SelectObject(m_hLastBkgFrame); 195 | 196 | // Delete the DIB for the frame 197 | DeleteObject(m_hBkgFrame); 198 | m_pBkgBits = NULL; 199 | 200 | // Delete the last frame DC 201 | m_FrameDC.DeleteDC(); 202 | } 203 | } -------------------------------------------------------------------------------- /DIBFrame.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | // Wrapper class for the Cursor 23 | class CCursor 24 | { 25 | public: 26 | CCursor() : m_hCursor(NULL) {} 27 | ~CCursor() 28 | { 29 | Destroy(); 30 | } 31 | operator HCURSOR() {return m_hCursor;} 32 | void CreateCursor(DWORD dwXHotSpot,DWORD dwYHotSpot,int nWidth,int nHeight,WORD bmMaskPlanes,WORD bmMaskBitsPixel,WORD bmColorPlanes,WORD bmColorBitsPixel,BYTE * pMaskBits,BYTE * pColorBits) 33 | { 34 | // Clean up 35 | Destroy(); 36 | 37 | // Create a mask bitmap 38 | HBITMAP hMask = NULL; 39 | CBitmap Mask; 40 | if (pMaskBits) 41 | { 42 | Mask.CreateBitmap(nWidth,nHeight,bmMaskPlanes,bmMaskBitsPixel,pMaskBits); 43 | hMask = (HBITMAP)Mask; 44 | } 45 | 46 | // Create a color bitmap 47 | HBITMAP hColor = NULL; 48 | CBitmap Color; 49 | if (pColorBits) 50 | { 51 | Color.CreateBitmap(nWidth,nHeight,bmColorPlanes,bmColorBitsPixel,pColorBits); 52 | hColor = (HBITMAP)Color; 53 | } 54 | 55 | // Create an Icon from the "color" and "mask" bitmaps 56 | ICONINFO IconInfo; 57 | IconInfo.fIcon = FALSE; 58 | IconInfo.xHotspot = dwXHotSpot; 59 | IconInfo.yHotspot = dwYHotSpot; 60 | IconInfo.hbmMask = hMask; 61 | IconInfo.hbmColor = hColor; 62 | 63 | // Create the cursor 64 | m_hCursor = CreateIconIndirect(&IconInfo); 65 | } 66 | 67 | protected: 68 | void Destroy() 69 | { 70 | if (m_hCursor) 71 | { 72 | DestroyCursor(m_hCursor); 73 | m_hCursor = NULL; 74 | } 75 | } 76 | 77 | private: 78 | HCURSOR m_hCursor; 79 | }; 80 | 81 | class CDIBFrame 82 | { 83 | public: 84 | CDIBFrame(); 85 | CDIBFrame(int x,int y,int nBitCount); 86 | CDIBFrame(BYTE * pBuffer,DWORD dwLen); 87 | CDIBFrame(const CDIBFrame & rhs); 88 | ~CDIBFrame(); 89 | 90 | public: 91 | CDIBFrame & operator = (const CDIBFrame & rhs); 92 | operator HBITMAP () {return m_hBkgFrame;} 93 | operator HDC () {return (HDC)m_FrameDC;} 94 | operator CDC * () {return &m_FrameDC;} 95 | operator CDC & () {return m_FrameDC;} 96 | operator LPSTR () {return m_pBkgBits;} 97 | operator LPSTR * () {return &m_pBkgBits;} 98 | operator BITMAPINFO * () {return m_pBitmapInfo;} 99 | operator BITMAPINFOHEADER * () {return m_pBitmapInfoHdr;} 100 | 101 | public: 102 | void Init(int x,int y,int nBitCount); 103 | void CreateFrame(const BYTE * pBuffer = NULL,DWORD dwLen = 0); 104 | void DeleteFrame(); 105 | 106 | public: 107 | int m_x,m_y,m_nBitCount; 108 | DWORD m_dwBkgImageBytes; 109 | 110 | protected: 111 | CDC m_FrameDC; 112 | HBITMAP m_hBkgFrame; 113 | LPSTR m_pBkgBits; 114 | HBITMAP m_hLastBkgFrame; 115 | std::vector m_Buffer; 116 | BITMAPINFO * m_pBitmapInfo; 117 | BITMAPINFOHEADER * m_pBitmapInfoHdr; 118 | }; -------------------------------------------------------------------------------- /Hash.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | class CHash 22 | { 23 | public: 24 | CHash() : m_hCryptProv(NULL), m_hHash(NULL), m_hKey(NULL) 25 | { 26 | // Get handle to the default provider. 27 | if (!CryptAcquireContext(&m_hCryptProv,NULL,MS_ENHANCED_PROV,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT)) 28 | { 29 | if (!CryptAcquireContext(&m_hCryptProv,NULL,MS_ENHANCED_PROV,PROV_RSA_FULL,CRYPT_NEWKEYSET|CRYPT_VERIFYCONTEXT)) 30 | { 31 | // If creating a new key container and an error code indicates it existed then some user information changed 32 | // delete the key container and re-create it 33 | if (!CryptAcquireContext(&m_hCryptProv,NULL,MS_ENHANCED_PROV,PROV_RSA_FULL,CRYPT_DELETEKEYSET|CRYPT_VERIFYCONTEXT)) 34 | return; 35 | if (!CryptAcquireContext(&m_hCryptProv,NULL,MS_ENHANCED_PROV,PROV_RSA_FULL,CRYPT_NEWKEYSET|CRYPT_VERIFYCONTEXT)) 36 | return; 37 | } 38 | } 39 | } 40 | 41 | ~CHash() 42 | { 43 | // Destroy the Hash 44 | if (m_hHash) 45 | { 46 | CryptDestroyHash(m_hHash); 47 | m_hHash = NULL; 48 | } 49 | 50 | // Destroy the cryptographic session 51 | if (m_hKey) 52 | { 53 | CryptDestroyKey(m_hKey); 54 | m_hKey = NULL; 55 | } 56 | 57 | // Release the cryptographic provider 58 | if (m_hCryptProv) 59 | { 60 | CryptReleaseContext(m_hCryptProv,0); 61 | m_hCryptProv = NULL; 62 | } 63 | } 64 | 65 | bool HashData(BYTE * pData,DWORD dwLen) 66 | { 67 | if (!m_hHash) 68 | { 69 | // Test for a good initialization 70 | if (!m_hCryptProv) 71 | return false; 72 | 73 | // Create the cryptographic hash 74 | if (!CryptCreateHash(m_hCryptProv,CALG_MD5,0,0,&m_hHash)) 75 | return false; 76 | } 77 | 78 | // Add the data to the hash 79 | return CryptHashData(m_hHash,pData,dwLen,0) ? true : false; 80 | } 81 | 82 | // Get the hash 83 | bool GetHash(CString & csHash) 84 | { 85 | bool bRet = false; 86 | if (m_hHash) 87 | { 88 | DWORD dwHashSize = 0; 89 | if (CryptGetHashParam(m_hHash,HP_HASHSIZE,NULL,&dwHashSize,0)) 90 | { 91 | DWORD dwHashLen = 0; 92 | if (CryptGetHashParam(m_hHash,HP_HASHVAL,NULL,&dwHashLen,0)) 93 | { 94 | std::auto_ptr Hash(new BYTE[dwHashLen]); 95 | BYTE * pbHash = Hash.get();; 96 | if (CryptGetHashParam(m_hHash,HP_HASHVAL,pbHash,&dwHashLen,0)) 97 | { 98 | // Create the string hash value 99 | for(DWORD i = 0;i < dwHashLen;i++) // P#1089 DWORD was int 100 | { 101 | char sz[3] = {'\0'}; 102 | sprintf_s(sz,"%2.2x",pbHash[i]); 103 | csHash += sz; 104 | } 105 | 106 | // Destroy the Hash since no more data can be added to it 107 | CryptDestroyHash(m_hHash); 108 | m_hHash = NULL; 109 | bRet = true; 110 | } 111 | } 112 | } 113 | } 114 | return bRet; 115 | } 116 | 117 | protected: 118 | bool m_bError; 119 | HCRYPTPROV m_hCryptProv; 120 | HCRYPTHASH m_hHash; 121 | HCRYPTKEY m_hKey; 122 | }; -------------------------------------------------------------------------------- /Packet.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include "AC.h" 20 | #include "DIBFrame.h" 21 | #include 22 | 23 | // Class for containing the keyboard message 24 | class CKBMsg 25 | { 26 | public: 27 | CKBMsg() {}; 28 | CKBMsg(WORD wWM,UINT nChar,UINT nRepCnt,UINT nFlags) : m_wWM(wWM), m_nChar(nChar), m_nRepCnt(nRepCnt), m_nFlags(nFlags) {} 29 | CKBMsg(const CKBMsg & KBMsg) {*this = KBMsg;} 30 | CKBMsg & operator = (const CKBMsg & KBMsg) 31 | { 32 | if (this != &KBMsg) 33 | { 34 | m_wWM = KBMsg.m_wWM; 35 | m_nChar = KBMsg.m_nChar; 36 | m_nRepCnt = KBMsg.m_nRepCnt; 37 | m_nFlags = KBMsg.m_nFlags; 38 | } 39 | return *this; 40 | } 41 | bool operator == (const CKBMsg & rhs) const 42 | { 43 | if (this != &rhs) 44 | { 45 | return m_wWM == rhs.m_wWM && 46 | m_nChar == rhs.m_nChar && 47 | m_nRepCnt == rhs.m_nRepCnt && 48 | m_nFlags == rhs.m_nFlags; 49 | } 50 | return true; 51 | } 52 | 53 | WORD m_wWM; 54 | UINT m_nChar; 55 | UINT m_nRepCnt; 56 | UINT m_nFlags; 57 | }; 58 | 59 | // Class for containing the mouse message 60 | class CMouseMsg 61 | { 62 | public: 63 | CMouseMsg() {}; 64 | CMouseMsg(WORD wWM,UINT nFlags,CPoint MousePosition,short zDelta) : m_wWM(wWM), m_nFlags(nFlags), m_MousePosition(MousePosition), m_zDelta(zDelta) {} 65 | CMouseMsg(const CMouseMsg & MouseMsg) {*this = MouseMsg;} 66 | CMouseMsg & operator = (const CMouseMsg & MouseMsg) 67 | { 68 | if (this != &MouseMsg) 69 | { 70 | m_wWM = MouseMsg.m_wWM; 71 | m_nFlags = MouseMsg.m_nFlags; 72 | m_MousePosition = MouseMsg.m_MousePosition; 73 | m_zDelta = MouseMsg.m_zDelta; 74 | } 75 | return *this; 76 | } 77 | bool operator == (const CMouseMsg & rhs) const 78 | { 79 | if (this != &rhs) 80 | { 81 | return m_wWM == rhs.m_wWM && 82 | m_nFlags == rhs.m_nFlags && 83 | m_MousePosition.x == rhs.m_MousePosition.x && 84 | m_MousePosition.y == rhs.m_MousePosition.y && 85 | m_zDelta == rhs.m_zDelta; 86 | } 87 | return true; 88 | } 89 | 90 | WORD m_wWM; 91 | UINT m_nFlags; 92 | CPoint m_MousePosition; 93 | short m_zDelta; 94 | }; 95 | 96 | // A packet makes up the information that will be sent and received 97 | class CPacket 98 | { 99 | public: 100 | CPacket(); 101 | CPacket(const CPacket & rhs); 102 | CPacket(CString csPassword,UINT nSessionId); 103 | CPacket(int nCompThreads,UINT nSessionId); 104 | CPacket(int cxScreen,int cyScreen,int nBitCount,int nGridThreads); 105 | CPacket(CRect Rect,char * pBuffer,DWORD dwBytes,DWORD dwSrcBytes,int nCompThreads,BOOL bImgDIB,BOOL bUseCompression,BOOL bAC,BOOL bXOR,BOOL bDIB); 106 | CPacket(std::vector vKBMsg); 107 | CPacket(std::vector vMouseMsg); 108 | CPacket(DWORD dwFlags,DWORD dwXHotSpot,DWORD dwYHotSpot,int bmWidth,int bmHeight,WORD bmMaskPlanes,WORD bmMaskBitsPixel,WORD bmColorPlanes,WORD bmColorBitsPixel,std::vector MaskBits,std::vector ColorBits); 109 | CPacket & operator = (const CPacket & rhs); 110 | virtual ~CPacket(); 111 | bool operator == (const CPacket & rhs) const; 112 | 113 | // Send the packet 114 | void SerializePacket(CAsyncSocket * pSocket,bool bSend); 115 | 116 | // Type of packet 117 | unsigned char m_ucPacketType; 118 | 119 | // m_ucPacketType = 1 120 | CString m_csPasswordHash; 121 | 122 | // m_ucPacketType = 10 123 | int m_nCompThreads; 124 | UINT m_nSessionId; 125 | 126 | // m_ucPacketType = 2 127 | int m_cxScreen; 128 | int m_cyScreen; 129 | int m_nBitCount; 130 | int m_nGridThreads; 131 | 132 | // m_ucPacketType = 7 133 | CRect m_Rect; 134 | DWORD m_dwSrcBytes,m_dwBytes; 135 | BOOL m_bImgDIB; 136 | BOOL m_bDIB; 137 | BOOL m_bUseCompression; 138 | BOOL m_bAC; 139 | BOOL m_bXOR; 140 | DWORD m_dwBufferSize; 141 | char * m_pBuffer; 142 | std::auto_ptr m_Buffer; 143 | bool m_bDeleteBuffer; 144 | 145 | // Mouse and Keyboard windows message 146 | WORD m_wWM; 147 | UINT m_nFlags; 148 | 149 | // m_ucPacketType = 4 150 | std::vector m_vKBMsg; 151 | 152 | // m_ucPacketType = 5 153 | std::vector m_vMouseMsg; 154 | 155 | // m_ucPacketType = 3 156 | DWORD m_dwFlags; 157 | DWORD m_dwXHotSpot; 158 | DWORD m_dwYHotSpot; 159 | int m_bmWidth; 160 | int m_bmHeight; 161 | WORD m_bmMaskPlanes; 162 | WORD m_bmMaskBitsPixel; 163 | WORD m_bmColorPlanes; 164 | WORD m_bmColorBitsPixel; 165 | std::vector m_MaskBits; 166 | std::vector m_ColorBits; 167 | }; -------------------------------------------------------------------------------- /RD.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2013 3 | VisualStudioVersion = 12.0.21005.1 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RDS", "RDS\RDS.vcxproj", "{636A6E84-6021-4A0A-B554-1AD52DA41CC8}" 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RDV", "RDV\RDV.vcxproj", "{791FFCDF-33C1-4191-A574-65B3DB6C50DA}" 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "ZLib\ZLib.vcxproj", "{BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}" 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Debug|x64 = Debug|x64 15 | Release|Win32 = Release|Win32 16 | Release|x64 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|Win32.Build.0 = Debug|Win32 21 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|x64.ActiveCfg = Debug|x64 22 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Debug|x64.Build.0 = Debug|x64 23 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|Win32.ActiveCfg = Release|Win32 24 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|Win32.Build.0 = Release|Win32 25 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|x64.ActiveCfg = Release|x64 26 | {636A6E84-6021-4A0A-B554-1AD52DA41CC8}.Release|x64.Build.0 = Release|x64 27 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|Win32.Build.0 = Debug|Win32 29 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|x64.ActiveCfg = Debug|x64 30 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Debug|x64.Build.0 = Debug|x64 31 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|Win32.ActiveCfg = Release|Win32 32 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|Win32.Build.0 = Release|Win32 33 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|x64.ActiveCfg = Release|x64 34 | {791FFCDF-33C1-4191-A574-65B3DB6C50DA}.Release|x64.Build.0 = Release|x64 35 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|Win32.ActiveCfg = Debug|Win32 36 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|Win32.Build.0 = Debug|Win32 37 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|x64.ActiveCfg = Debug|x64 38 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|x64.Build.0 = Debug|x64 39 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|Win32.ActiveCfg = Release|Win32 40 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|Win32.Build.0 = Release|Win32 41 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|x64.ActiveCfg = Release|x64 42 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|x64.Build.0 = Release|x64 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | GlobalSection(DPCodeReviewSolutionGUID) = preSolution 48 | DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /RDS/RDS.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // RDS.cpp : Defines the class behaviors for the application. 18 | // 19 | 20 | #include "stdafx.h" 21 | #include "..\Common.h" 22 | #include "RDS.h" 23 | #include "RDSDlg.h" 24 | 25 | #ifdef _DEBUG 26 | #define new DEBUG_NEW 27 | #endif 28 | 29 | 30 | // CRDSApp 31 | 32 | BEGIN_MESSAGE_MAP(CRDSApp, CWinApp) 33 | ON_COMMAND(ID_HELP, CWinApp::OnHelp) 34 | END_MESSAGE_MAP() 35 | 36 | 37 | // CRDSApp construction 38 | 39 | CRDSApp::CRDSApp() 40 | { 41 | // Initialize the O/S version information 42 | InitVersion(); 43 | 44 | // Output the licensing disclaimer 45 | DebugMsg(_T("Remote Desktop System, Copyright (C) 2000-2009 GravyLabs LLC\n")); 46 | DebugMsg(_T("GravyLabs LLC can be reached at jones.gravy@gmail.com\n")); 47 | DebugMsg(_T("Remote Desktop System comes with ABSOLUTELY NO WARRANTY\n")); 48 | DebugMsg(_T("This is free software, and you are welcome to redistribute it\n")); 49 | DebugMsg(_T("under of the GNU General Public License as published by\n")); 50 | DebugMsg(_T("the Free Software Foundation; version 2 of the License.\n")); 51 | } 52 | 53 | CRDSApp::~CRDSApp() 54 | { 55 | } 56 | // The one and only CRDSApp object 57 | 58 | CRDSApp theApp; 59 | 60 | 61 | // CRDSApp initialization 62 | 63 | BOOL CRDSApp::InitInstance() 64 | { 65 | // InitCommonControls() is required on Windows XP if an application 66 | // manifest specifies use of ComCtl32.dll version 6 or later to enable 67 | // visual styles. Otherwise, any window creation will fail. 68 | InitCommonControls(); 69 | 70 | CWinApp::InitInstance(); 71 | 72 | if (!AfxSocketInit()) 73 | { 74 | AfxMessageBox(IDP_SOCKETS_INIT_FAILED); 75 | return FALSE; 76 | } 77 | 78 | // Standard initialization 79 | // If you are not using these features and wish to reduce the size 80 | // of your final executable, you should remove from the following 81 | // the specific initialization routines you do not need 82 | // Change the registry key under which our settings are stored 83 | // TODO: You should modify this string to be something appropriate 84 | // such as the name of your company or organization 85 | SetRegistryKey(_T("Local AppWizard-Generated Applications")); 86 | 87 | // Test the O/S version information for XP or later 88 | if (IsWinNT() && IsWinVerOrHigher(5,1)) 89 | { 90 | CRDSDlg dlg; 91 | m_pMainWnd = &dlg; 92 | dlg.DoModal(); 93 | } 94 | else 95 | AfxMessageBox(_T("Requires Windows XP or later")); 96 | 97 | // Since the dialog has been closed, return FALSE so that we exit the 98 | // application, rather than start the application's message pump. 99 | return FALSE; 100 | } -------------------------------------------------------------------------------- /RDS/RDS.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // RDS.h : main header file for the PROJECT_NAME application 18 | // 19 | 20 | #pragma once 21 | 22 | #ifndef __AFXWIN_H__ 23 | #error include 'stdafx.h' before including this file for PCH 24 | #endif 25 | 26 | #include "resource.h" // main symbols 27 | 28 | // CRDSApp: 29 | // See RDS.cpp for the implementation of this class 30 | // 31 | 32 | class CRDSApp : public CWinApp 33 | { 34 | public: 35 | CRDSApp(); 36 | ~CRDSApp(); 37 | 38 | // Overrides 39 | public: 40 | virtual BOOL InitInstance(); 41 | 42 | // Implementation 43 | DECLARE_MESSAGE_MAP() 44 | }; 45 | 46 | extern CRDSApp theApp; -------------------------------------------------------------------------------- /RDS/RDS.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /RDS/RDS.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""afxres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "#define _AFX_NO_SPLITTER_RESOURCES\r\n" 42 | "#define _AFX_NO_OLE_RESOURCES\r\n" 43 | "#define _AFX_NO_TRACKER_RESOURCES\r\n" 44 | "#define _AFX_NO_PROPERTY_RESOURCES\r\n" 45 | "\r\n" 46 | "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" 47 | "LANGUAGE 9, 1\r\n" 48 | "#pragma code_page(1252)\r\n" 49 | "#include ""res\\RDS.rc2"" // non-Microsoft Visual C++ edited resources\r\n" 50 | "#include ""afxres.rc"" // Standard components\r\n" 51 | "#endif\r\n" 52 | "\0" 53 | END 54 | 55 | #endif // APSTUDIO_INVOKED 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | VS_VERSION_INFO VERSIONINFO 64 | FILEVERSION 1,0,0,1 65 | PRODUCTVERSION 1,0,0,1 66 | FILEFLAGSMASK 0x3fL 67 | #ifdef _DEBUG 68 | FILEFLAGS 0x1L 69 | #else 70 | FILEFLAGS 0x0L 71 | #endif 72 | FILEOS 0x4L 73 | FILETYPE 0x1L 74 | FILESUBTYPE 0x0L 75 | BEGIN 76 | BLOCK "StringFileInfo" 77 | BEGIN 78 | BLOCK "040904e4" 79 | BEGIN 80 | VALUE "CompanyName", "GravyLabs LLC" 81 | VALUE "FileDescription", "Remote Desktop Server" 82 | VALUE "FileVersion", "1.0.0.1" 83 | VALUE "InternalName", "RDS.exe" 84 | VALUE "LegalCopyright", "(c) GravyLabs LLC. All rights reserved." 85 | VALUE "OriginalFilename", "RDS.exe" 86 | VALUE "ProductName", "Remote Desktop System" 87 | VALUE "ProductVersion", "1.0.0.1" 88 | END 89 | END 90 | BLOCK "VarFileInfo" 91 | BEGIN 92 | VALUE "Translation", 0x409, 1252 93 | END 94 | END 95 | 96 | 97 | ///////////////////////////////////////////////////////////////////////////// 98 | // 99 | // DESIGNINFO 100 | // 101 | 102 | #ifdef APSTUDIO_INVOKED 103 | GUIDELINES DESIGNINFO 104 | BEGIN 105 | IDD_RDS_DIALOG, DIALOG 106 | BEGIN 107 | LEFTMARGIN, 7 108 | RIGHTMARGIN, 274 109 | TOPMARGIN, 6 110 | BOTTOMMARGIN, 93 111 | END 112 | END 113 | #endif // APSTUDIO_INVOKED 114 | 115 | 116 | ///////////////////////////////////////////////////////////////////////////// 117 | // 118 | // Menu 119 | // 120 | 121 | IDR_MAINFRAME MENU 122 | BEGIN 123 | POPUP "RDS" 124 | BEGIN 125 | MENUITEM "Restore", ID_RDS_RESTORE 126 | END 127 | END 128 | 129 | 130 | ///////////////////////////////////////////////////////////////////////////// 131 | // 132 | // Icon 133 | // 134 | 135 | // Icon with lowest ID value placed first to ensure application icon 136 | // remains consistent on all systems. 137 | IDR_MAINFRAME ICON "icon1.ico" 138 | 139 | ///////////////////////////////////////////////////////////////////////////// 140 | // 141 | // Dialog 142 | // 143 | 144 | IDD_RDS_DIALOG DIALOGEX 0, 0, 281, 100 145 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 146 | EXSTYLE WS_EX_APPWINDOW 147 | CAPTION "Desktop Server" 148 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 149 | BEGIN 150 | LTEXT "Pwd",IDC_STATIC_PWD,7,31,24,8,SS_CENTERIMAGE | WS_DISABLED 151 | EDITTEXT IDC_PWD,31,29,24,12,ES_AUTOHSCROLL | WS_DISABLED 152 | LTEXT "Port",IDC_STATIC_PORT,69,31,14,8,SS_CENTERIMAGE | WS_DISABLED 153 | EDITTEXT IDC_PORT,87,29,24,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED 154 | CONTROL "RGB",IDC_RGB,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_GROUP,119,31,29,10 155 | CONTROL "BW",IDC_BW,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,149,31,24,10 156 | LTEXT "X Scale",IDC_STATIC_XSCALE,7,54,24,12,SS_CENTERIMAGE | WS_DISABLED 157 | EDITTEXT IDC_XSCALE,31,54,24,14,ES_AUTOHSCROLL | WS_DISABLED 158 | LTEXT "Y Scale",IDC_STATIC_YSCALE,63,54,24,12,SS_CENTERIMAGE | WS_DISABLED 159 | EDITTEXT IDC_YSCALE,87,54,24,14,ES_AUTOHSCROLL | WS_DISABLED 160 | LTEXT "Threads",IDC_STATIC_GRIDTHREADS,139,53,30,12,SS_CENTERIMAGE | WS_DISABLED 161 | EDITTEXT IDC_GRIDTHREADS,169,53,29,14,ES_AUTOHSCROLL | WS_DISABLED 162 | CONTROL "Use Compression",IDC_COMPRESSION,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,73,71,10 163 | CONTROL "ZLIB",IDC_ZLIB,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_GROUP,77,73,30,10 164 | CONTROL "AC",IDC_AC,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,105,73,25,10 165 | LTEXT "Threads",IDC_STATIC_ACTHREADS,139,71,30,12,SS_CENTERIMAGE | WS_DISABLED 166 | EDITTEXT IDC_ACTHREADS,169,71,30,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED 167 | PUSHBUTTON "Start",IDC_START,217,21,50,16,WS_DISABLED 168 | PUSHBUTTON "Stop",IDC_STOP,218,41,50,16,WS_DISABLED 169 | DEFPUSHBUTTON "Quit",IDOK,219,68,50,16 170 | CONTROL "DIB",IDC_IMGDIB,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_GROUP,119,41,27,10 171 | CONTROL "PNG",IDC_IMGPNG,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,149,41,25,10 172 | CONTROL "Low BW",IDC_LBW,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_DISABLED | WS_TABSTOP,177,31,30,18 173 | LTEXT "IP Addresses",IDC_STATIC,7,6,43,8 174 | COMBOBOX IDC_COMBO_IP,54,6,171,57,CBS_DROPDOWNLIST | CBS_SORT | CBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP 175 | END 176 | 177 | 178 | ///////////////////////////////////////////////////////////////////////////// 179 | // 180 | // String Table 181 | // 182 | 183 | STRINGTABLE 184 | BEGIN 185 | IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed." 186 | END 187 | 188 | STRINGTABLE 189 | BEGIN 190 | IDR_MAINFRAME "Remote Desktop Server" 191 | END 192 | 193 | #endif // English (United States) resources 194 | ///////////////////////////////////////////////////////////////////////////// 195 | 196 | 197 | 198 | #ifndef APSTUDIO_INVOKED 199 | ///////////////////////////////////////////////////////////////////////////// 200 | // 201 | // Generated from the TEXTINCLUDE 3 resource. 202 | // 203 | #define _AFX_NO_SPLITTER_RESOURCES 204 | #define _AFX_NO_OLE_RESOURCES 205 | #define _AFX_NO_TRACKER_RESOURCES 206 | #define _AFX_NO_PROPERTY_RESOURCES 207 | 208 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 209 | LANGUAGE 9, 1 210 | #pragma code_page(1252) 211 | #include "res\RDS.rc2" // non-Microsoft Visual C++ edited resources 212 | #include "afxres.rc" // Standard components 213 | #endif 214 | 215 | ///////////////////////////////////////////////////////////////////////////// 216 | #endif // not APSTUDIO_INVOKED 217 | 218 | -------------------------------------------------------------------------------- /RDS/RDS.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | 100 | 101 | Resource Files 102 | 103 | 104 | Resource Files 105 | 106 | 107 | Resource Files 108 | 109 | 110 | 111 | 112 | Resource Files 113 | 114 | 115 | 116 | 117 | Resource Files 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /RDS/RDSDlg.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // RDSDlg.h : header file 18 | // 19 | 20 | #pragma once 21 | 22 | // CPU Info 23 | #include 24 | 25 | // Socket 26 | #include "..\TCPSocket.h" 27 | 28 | // UI components 29 | #include "..\DIBFrame.h" 30 | #include "..\Common.h" 31 | #include "RefreshThread.h" 32 | #include "TrayIcon.h" 33 | 34 | // STL includes 35 | #include 36 | #include 37 | #include 38 | 39 | // MFC includes 40 | #include 41 | #include 42 | 43 | // CRDSDlg dialog 44 | class CRDSDlg : public CDialog 45 | { 46 | // Construction 47 | public: 48 | CRDSDlg(CWnd* pParent = NULL); // standard constructor 49 | ~CRDSDlg(); 50 | 51 | // Dialog Data 52 | enum { IDD = IDD_RDS_DIALOG }; 53 | 54 | CString m_csPassword; 55 | int m_nBitCount; 56 | int m_nCompThreads; 57 | BOOL m_bAcceptUpdate; 58 | int m_nIncoming; 59 | BOOL m_bUseCompression; 60 | CButton m_Start; 61 | CButton m_Stop; 62 | CStatic m_StaticPassword; 63 | CEdit m_Password; 64 | CStatic m_StaticPort; 65 | CEdit m_Port; 66 | int m_iPort; 67 | CButton m_Colors; 68 | CButton m_BW; 69 | CButton m_LBW; 70 | CButton m_ImgDIB; 71 | CButton m_ImgPNG; 72 | BOOL m_bColors; 73 | BOOL m_bBW; 74 | BOOL m_bLBW; 75 | BOOL m_bImgDIB; 76 | BOOL m_bImgPNG; 77 | CButton m_UseCompression; 78 | CButton m_AC; 79 | BOOL m_bAC; 80 | CButton m_ZLib; 81 | BOOL m_bZLib; 82 | CEdit m_ACThreads; 83 | CStatic m_StaticACThreads; 84 | CStatic m_StaticXScale; 85 | CEdit m_XScale; 86 | int m_iXScale; 87 | CStatic m_StaticYScale; 88 | CEdit m_YScale; 89 | int m_iYScale; 90 | CStatic m_StaticGridThreads; 91 | CEdit m_GridThreads; 92 | int m_nGridThreads; 93 | BOOL m_bStarted; 94 | 95 | // Handle arrays 96 | std::vector m_vRefreshThread; 97 | DWORD m_nThreads; 98 | 99 | // Multithreaded compression 100 | CDriveMultiThreadedCompression * m_pMTC; 101 | 102 | // Single threaded compression 103 | CArithmeticEncoder m_AE; 104 | CZLib m_ZL; 105 | 106 | protected: 107 | virtual void OnOK(); 108 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 109 | 110 | // Data 111 | protected: 112 | 113 | // Dialog and Tray icons 114 | HICON m_hIcon; 115 | CTrayIcon m_TrayIcon; 116 | 117 | // The "operator" socket 118 | CTCPSocket m_Operator; 119 | 120 | // The connected socket 121 | std::set m_setAccept; 122 | 123 | // Dib dimensions 124 | int m_cxStart,m_cyStart,m_cxWidth,m_cyHeight; 125 | double m_dxWidthScalar,m_dyHeightScalar; 126 | std::map m_mapRect; 127 | 128 | // Session Id 129 | UINT m_nSessionId; 130 | 131 | // UAC 132 | DWORD m_dwEnableLUA; 133 | 134 | // Implementation 135 | protected: 136 | 137 | DECLARE_MESSAGE_MAP() 138 | 139 | // Generated message map functions 140 | virtual BOOL OnInitDialog(); 141 | afx_msg void OnPaint(); 142 | afx_msg HCURSOR OnQueryDragIcon(); 143 | 144 | // Socket event callback methods 145 | afx_msg LRESULT OnAcceptConn(WPARAM wParam,LPARAM lParam); 146 | afx_msg LRESULT OnReceiveData(WPARAM wParam,LPARAM lParam); 147 | afx_msg LRESULT OnCloseConn(WPARAM wParam,LPARAM lParam); 148 | 149 | // Image compress event callback method 150 | afx_msg LRESULT OnImageCompress(WPARAM wParam,LPARAM lParam); 151 | 152 | // Image refresh event callback method 153 | afx_msg LRESULT OnImageRefresh(WPARAM wParam,LPARAM lParam); 154 | 155 | // Image renew event callback method 156 | afx_msg LRESULT OnImageRenew(WPARAM wParam,LPARAM lParam); 157 | 158 | // Tray icon event callback method 159 | afx_msg LRESULT OnNotifyTray(WPARAM wParam,LPARAM lParam); 160 | 161 | // Methods for the tray icon 162 | afx_msg void OnClose(); 163 | afx_msg void OnRestore(); 164 | 165 | // Start and stop the server 166 | afx_msg void OnStart(); 167 | afx_msg void OnStop(); 168 | 169 | // Compression UI 170 | afx_msg void OnCompression(); 171 | afx_msg void OnCompressionChoice(); 172 | afx_msg void OnBW(); 173 | afx_msg void OnLBW(); 174 | 175 | // UI Stuff 176 | void EnableControls(BOOL bOffline = TRUE); 177 | 178 | // Initialize 179 | void CreateRefreshThreads(); 180 | void DeleteRefreshThreads(); 181 | 182 | // Helper for virtual key codes embedded in mouse messages 183 | void SetMouseMessage(WORD wMM,CPoint MousePosition,UINT nFlags,short zDelta); 184 | void SetKBMessage(WORD wMM,UINT nChar,UINT nRepCnt,UINT nFlags); 185 | void SetMouseKB(INPUT & KeyBoardInput,WORD wVk,bool bDown); 186 | public: 187 | CComboBox m_ComboIPAddresses; 188 | private: 189 | // Get a list of local IP addresses and attach them to the Combo List 190 | int GetIPAddresses(); 191 | }; -------------------------------------------------------------------------------- /RDS/RefreshThread.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // RDSDlg.h : header file 18 | // 19 | 20 | #pragma once 21 | 22 | // Socket 23 | #include "..\TCPSocket.h" 24 | 25 | // GDI+ images 26 | #include "ATLImage.h" 27 | 28 | // STL 29 | #include 30 | 31 | // DIB Refresh 32 | class CRefreshThread : public CWinThread 33 | { 34 | DECLARE_DYNCREATE(CRefreshThread) 35 | 36 | CRefreshThread(); 37 | 38 | public: 39 | CRefreshThread(HWND hWndParent,std::vector vDIBRect,int nBitCount,BOOL bImgDIB,BOOL bUseCompression,BOOL bAC,DWORD dwThread,int nCompThreads); 40 | virtual ~CRefreshThread(); 41 | virtual BOOL InitInstance(); 42 | virtual BOOL PumpMessage(); 43 | virtual int ExitInstance(); 44 | 45 | // Event synchronization 46 | protected: 47 | HWND m_hWndParent; 48 | HANDLE m_hEvent; 49 | 50 | // Client connection 51 | protected: 52 | std::set m_setAccept; 53 | std::map m_mapAcceptEvent; 54 | 55 | // DIB 56 | protected: 57 | HDC m_hDisplayDC; 58 | std::vector m_vDIB,m_vDIBLast; 59 | std::vector m_vDIBRect; 60 | std::vector m_vComp; 61 | std::vector m_vInit; 62 | std::vector m_vDIBPacket; 63 | DWORD m_dwSleep; 64 | int m_iCurDIB; 65 | int m_nDIB; 66 | int m_nBitCount; 67 | 68 | // Thread and compression settings 69 | DWORD m_dwThread; 70 | int m_nCompThreads; 71 | BOOL m_bImgDIB; 72 | BOOL m_bUseCompression; 73 | BOOL m_bAC; 74 | 75 | // Compression output buffer (initially sized to the source size) 76 | std::auto_ptr m_OutBuffer; 77 | 78 | // GDI+ Image support 79 | CImage m_ImageDIB; 80 | 81 | // Cursor data 82 | CPacket m_Cursor; 83 | 84 | // Intialization 85 | private: 86 | bool m_bPumpMessage; 87 | 88 | protected: 89 | DECLARE_MESSAGE_MAP() 90 | afx_msg void OnAcceptConn(WPARAM wParam,LPARAM lParam); 91 | afx_msg void OnImageRefresh(WPARAM wParam,LPARAM lParam); 92 | afx_msg void OnImageSend(WPARAM wParam,LPARAM lParam); 93 | afx_msg void OnEndThread(WPARAM wParam,LPARAM lParam); 94 | afx_msg void OnCloseConn(WPARAM wParam,LPARAM lParam); 95 | }; 96 | 97 | -------------------------------------------------------------------------------- /RDS/Service.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "..\Common.h" 3 | #include "Service.h" 4 | #include 5 | 6 | CControlService::CControlService(const TCHAR * pszServiceName) : m_hSCM(NULL), m_hService(NULL) 7 | { 8 | // Open the SCM 9 | m_hSCM = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); 10 | if (m_hSCM) 11 | { 12 | if (pszServiceName) 13 | Open(pszServiceName); 14 | } 15 | } 16 | 17 | CControlService::~CControlService() 18 | { 19 | Close(); 20 | } 21 | 22 | bool CControlService::Open(const TCHAR * pszServiceName) 23 | { 24 | try 25 | { 26 | if (IsOpen()) 27 | Close(); 28 | if (m_hSCM && pszServiceName) 29 | { 30 | // Open the service 31 | m_hService = OpenService(m_hSCM,pszServiceName,SC_MANAGER_ALL_ACCESS | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL); 32 | if (m_hService) 33 | return true; 34 | } 35 | } 36 | catch (...) 37 | { 38 | } 39 | return false; 40 | } 41 | 42 | void CControlService::Close() 43 | { 44 | try 45 | { 46 | // Close the service 47 | if (m_hService) 48 | { 49 | CloseServiceHandle(m_hService); 50 | m_hService = NULL; 51 | } 52 | } 53 | catch (...) 54 | { 55 | } 56 | } 57 | 58 | // Test for the service being open and available for controlling or querying 59 | bool CControlService::IsOpen() 60 | { 61 | return m_hService != NULL ? true : false; 62 | } 63 | 64 | // Test the service for availability 65 | bool CControlService::IsAvailable() 66 | { 67 | bool bFlag = false; 68 | if (IsOpen()) 69 | { 70 | // Query the service 71 | DWORD dwQuery = Query(); 72 | switch (dwQuery) 73 | { 74 | case ERROR_SERVICE_NOT_ACTIVE: 75 | case SERVICE_STOPPED: 76 | case SERVICE_START_PENDING: 77 | case SERVICE_STOP_PENDING: 78 | case SERVICE_RUNNING: 79 | case SERVICE_CONTINUE_PENDING: 80 | case SERVICE_PAUSE_PENDING: 81 | case SERVICE_PAUSED: 82 | bFlag = true; 83 | break; 84 | default: 85 | break; 86 | } 87 | } 88 | return bFlag; 89 | } 90 | 91 | // Test the service for being in a running state 92 | bool CControlService::IsRunning() 93 | { 94 | bool bFlag = false; 95 | if (IsOpen()) 96 | { 97 | // Query the service 98 | DWORD dwQuery = Query(); 99 | switch (dwQuery) 100 | { 101 | case SERVICE_RUNNING: 102 | bFlag = true; 103 | break; 104 | default: 105 | break; 106 | } 107 | } 108 | return bFlag; 109 | } 110 | 111 | // Test the service for being in a paused state 112 | bool CControlService::IsPaused() 113 | { 114 | bool bFlag = false; 115 | if (IsOpen()) 116 | { 117 | // Query the service 118 | DWORD dwQuery = Query(); 119 | switch (dwQuery) 120 | { 121 | case SERVICE_PAUSED: 122 | bFlag = true; 123 | break; 124 | default: 125 | break; 126 | } 127 | } 128 | return bFlag; 129 | } 130 | 131 | // Test the service for being in a stopped state 132 | bool CControlService::IsStopped() 133 | { 134 | bool bFlag = false; 135 | if (IsOpen()) 136 | { 137 | // Query the service 138 | DWORD dwQuery = Query(); 139 | switch (dwQuery) 140 | { 141 | case SERVICE_STOPPED: 142 | case ERROR_SERVICE_NOT_ACTIVE: 143 | bFlag = true; 144 | break; 145 | default: 146 | break; 147 | } 148 | } 149 | return bFlag; 150 | } 151 | 152 | // Test the service for being in a pending state 153 | bool CControlService::IsPending() 154 | { 155 | bool bFlag = false; 156 | if (IsOpen()) 157 | { 158 | // Query the service 159 | DWORD dwQuery = Query(); 160 | switch (dwQuery) 161 | { 162 | case SERVICE_START_PENDING: 163 | case SERVICE_STOP_PENDING: 164 | case SERVICE_CONTINUE_PENDING: 165 | case SERVICE_PAUSE_PENDING: 166 | bFlag = true; 167 | break; 168 | default: 169 | break; 170 | } 171 | } 172 | return bFlag; 173 | } 174 | 175 | // Start the service 176 | bool CControlService::Start() 177 | { 178 | bool bFlag = false; 179 | if (IsOpen()) 180 | { 181 | // Start the service 182 | bFlag = StartService(m_hService,0,NULL) ? true : false; 183 | } 184 | return bFlag; 185 | } 186 | 187 | // Stop the service 188 | DWORD CControlService::Stop() 189 | { 190 | return Control(SERVICE_CONTROL_STOP); 191 | } 192 | 193 | // Pause the service 194 | DWORD CControlService::Pause() 195 | { 196 | return Control(SERVICE_CONTROL_PAUSE); 197 | } 198 | 199 | // Continue the service 200 | DWORD CControlService::Continue() 201 | { 202 | return Control(SERVICE_CONTROL_CONTINUE); 203 | } 204 | 205 | // Synchronize the service to receive a named pipe connection 206 | DWORD CControlService::UserSync(DWORD dwOp) 207 | { 208 | return Control(SERVICE_CONTROL_USER + dwOp); 209 | } 210 | 211 | // Query the service status 212 | DWORD CControlService::Query() 213 | { 214 | return Control(SERVICE_CONTROL_INTERROGATE); 215 | } 216 | 217 | // Control or query the service 218 | DWORD CControlService::Control(DWORD dwControl) 219 | { 220 | DWORD dwRet = ERROR_ACCESS_DENIED; 221 | try 222 | { 223 | if (IsOpen()) 224 | { 225 | // Intialize the service status 226 | SERVICE_STATUS ServiceStatus; 227 | memset(&ServiceStatus,0,sizeof(ServiceStatus)); 228 | if (ControlService(m_hService,dwControl,&ServiceStatus)) 229 | { 230 | dwRet = ServiceStatus.dwCurrentState; 231 | switch (dwRet) 232 | { 233 | case SERVICE_STOPPED: 234 | DebugMsg(_T("The service is not running\n")); 235 | break; 236 | case SERVICE_START_PENDING: 237 | DebugMsg(_T("The service is starting\n")); 238 | break; 239 | case SERVICE_STOP_PENDING: 240 | DebugMsg(_T("The service is stopping\n")); 241 | break; 242 | case SERVICE_RUNNING: 243 | DebugMsg(_T("The service is running\n")); 244 | break; 245 | case SERVICE_CONTINUE_PENDING: 246 | DebugMsg(_T("The service continue is pending\n")); 247 | break; 248 | case SERVICE_PAUSE_PENDING: 249 | DebugMsg(_T("The service pause is pending\n")); 250 | break; 251 | case SERVICE_PAUSED: 252 | DebugMsg(_T("The service is paused\n")); 253 | break; 254 | case ERROR_SERVICE_NOT_ACTIVE: 255 | DebugMsg(_T("The service is not active\n")); 256 | break; 257 | default: 258 | DebugMsg(_T("The service returned code %d\n"), dwRet); 259 | break; 260 | } 261 | } 262 | else 263 | { 264 | dwRet = GetLastError(); 265 | DebugLastError(); 266 | } 267 | } 268 | } 269 | catch (...) 270 | { 271 | } 272 | return dwRet; 273 | } 274 | 275 | // Install the service 276 | bool CControlService::Install(const TCHAR * pszServiceName, const TCHAR * pszDescription, const TCHAR * pszFileName) 277 | { 278 | bool bInstall = false; 279 | if (m_hSCM && !IsOpen()) 280 | { 281 | // Create the service 282 | m_hService = CreateService(m_hSCM,pszServiceName,pszServiceName,SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,pszFileName,NULL,NULL,NULL,NULL,NULL); 283 | if (m_hService) 284 | { 285 | // Set the description of the service 286 | SERVICE_DESCRIPTION Desc; 287 | Desc.lpDescription = (LPWSTR)pszDescription; 288 | ChangeServiceConfig2(m_hService,SERVICE_CONFIG_DESCRIPTION,&Desc); 289 | bInstall = true; 290 | } 291 | } 292 | return bInstall; 293 | } 294 | 295 | // Remove the service 296 | bool CControlService::Remove(const TCHAR * pszServiceName) 297 | { 298 | bool bRemove = false; 299 | if (m_hSCM) 300 | { 301 | if (!IsOpen()) 302 | Open(pszServiceName); 303 | if (IsOpen()) 304 | { 305 | if (DeleteService(m_hService)) 306 | { 307 | Close(); 308 | bRemove = true; 309 | } 310 | } 311 | } 312 | return bRemove; 313 | } -------------------------------------------------------------------------------- /RDS/Service.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class CControlService 6 | { 7 | public: 8 | CControlService(const TCHAR * pszServiceName = NULL); 9 | ~CControlService(); 10 | 11 | public: 12 | bool Open(const TCHAR * pszServiceName); 13 | void Close(); 14 | bool IsOpen(); 15 | bool IsAvailable(); 16 | bool IsRunning(); 17 | bool IsPaused(); 18 | bool IsStopped(); 19 | bool IsPending(); 20 | bool Start(); 21 | DWORD Stop(); 22 | DWORD Pause(); 23 | DWORD Continue(); 24 | DWORD UserSync(DWORD dwOp = 0); 25 | bool Install(const TCHAR * pszServiceName,const TCHAR * pszDescription,const TCHAR * pszFileName); 26 | bool Remove(const TCHAR * pszServiceName); 27 | 28 | protected: 29 | DWORD Query(); 30 | DWORD Control(DWORD dwControl); 31 | 32 | protected: 33 | SC_HANDLE m_hSCM; 34 | SC_HANDLE m_hService; 35 | }; 36 | -------------------------------------------------------------------------------- /RDS/TrayIcon.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop Server and Client 2 | // CTrayIcon Copyright 1996 Microsoft Systems Journal, by Paul DiLascia 3 | 4 | #include "stdafx.h" 5 | #include "trayicon.h" 6 | #include // for AfxLoadString 7 | 8 | IMPLEMENT_DYNAMIC(CTrayIcon, CCmdTarget) 9 | 10 | CTrayIcon::CTrayIcon(UINT uID) 11 | { 12 | // Initialize NOTIFYICONDATA 13 | memset(&m_nid,0,sizeof(m_nid)); 14 | m_nid.cbSize = sizeof(m_nid); 15 | m_nid.uID = uID; 16 | 17 | // Use resource string as tip if there is one 18 | AfxLoadString(uID,m_nid.szTip,sizeof(m_nid.szTip)); 19 | } 20 | 21 | CTrayIcon::~CTrayIcon() 22 | { 23 | // Remove icon from system tray 24 | SetIcon(0); 25 | } 26 | 27 | // Set notification window. It must created already. 28 | void CTrayIcon::SetNotificationWnd(CWnd* pNotifyWnd, UINT uCbMsg) 29 | { 30 | // If the following assert fails, you're probably 31 | // calling me before you created your window. Oops. 32 | ASSERT(pNotifyWnd==NULL || ::IsWindow(pNotifyWnd->GetSafeHwnd())); 33 | m_nid.hWnd = pNotifyWnd->GetSafeHwnd(); 34 | 35 | ASSERT(uCbMsg==0 || uCbMsg>=WM_USER); 36 | m_nid.uCallbackMessage = uCbMsg; 37 | } 38 | 39 | // Sets both the icon and tooltip from resource ID, to remove the icon, call SetIcon(0) 40 | BOOL CTrayIcon::SetIcon(UINT uID) 41 | { 42 | HICON hicon = NULL; 43 | if (uID) 44 | { 45 | AfxLoadString(uID, m_nid.szTip, sizeof(m_nid.szTip)); 46 | hicon = AfxGetApp()->LoadIcon(uID); 47 | } 48 | return SetIcon(hicon, NULL); 49 | } 50 | 51 | // Common SetIcon for all overloads. 52 | BOOL CTrayIcon::SetIcon(HICON hicon, LPCSTR lpTip) 53 | { 54 | UINT msg; 55 | m_nid.uFlags = 0; 56 | 57 | // Set the icon 58 | if (hicon) 59 | { 60 | // Add or replace icon in system tray 61 | msg = m_nid.hIcon ? NIM_MODIFY : NIM_ADD; 62 | m_nid.hIcon = hicon; 63 | m_nid.uFlags |= NIF_ICON; 64 | } 65 | else 66 | { 67 | // remove icon from tray 68 | if (m_nid.hIcon==NULL) 69 | return TRUE; 70 | msg = NIM_DELETE; 71 | } 72 | 73 | // Use the tip, if any 74 | if (lpTip) 75 | strncpy(reinterpret_cast(m_nid.szTip), reinterpret_cast(lpTip), sizeof(m_nid.szTip)); 76 | if (m_nid.szTip[0]) 77 | m_nid.uFlags |= NIF_TIP; 78 | 79 | // Use callback if any 80 | if (m_nid.uCallbackMessage && m_nid.hWnd) 81 | m_nid.uFlags |= NIF_MESSAGE; 82 | 83 | // Do it 84 | BOOL bRet = Shell_NotifyIcon(msg, &m_nid); 85 | if (msg==NIM_DELETE || !bRet) 86 | m_nid.hIcon = NULL; // failed 87 | return bRet; 88 | } 89 | 90 | BOOL CTrayIcon::SetIcon(LPCTSTR lpResName,LPCSTR lpTip) 91 | { 92 | return SetIcon(lpResName ? AfxGetApp()->LoadIcon(lpResName) : NULL, lpTip); 93 | } 94 | 95 | // Default event handler handles right-menu and doubleclick. 96 | LRESULT CTrayIcon::OnNotifyTray(WPARAM wID, LPARAM lEvent) 97 | { 98 | if (wID!=m_nid.uID || (lEvent!=WM_RBUTTONUP && lEvent!=WM_LBUTTONDBLCLK)) 99 | return 0; 100 | 101 | // If there's a resource menu with the same ID as the icon, use it as 102 | // the right-button popup menu. CTrayIcon will interprets the first 103 | // item in the menu as the default command for WM_LBUTTONDBLCLK 104 | // 105 | CMenu menu; 106 | if (!menu.LoadMenu(m_nid.uID)) 107 | return 0; 108 | CMenu* pSubMenu = menu.GetSubMenu(0); 109 | if (!pSubMenu) 110 | return 0; 111 | 112 | if (lEvent==WM_RBUTTONUP) 113 | { 114 | // Make first menu item the default (bold font) 115 | ::SetMenuDefaultItem(pSubMenu->m_hMenu, 0, TRUE); 116 | 117 | // Display the menu at the current mouse location. There's a "bug" 118 | // (Microsoft calls it a feature) in Windows 95 that requires calling 119 | // SetForegroundWindow. To find out more, search for Q135788 in MSDN. 120 | // 121 | CPoint mouse; 122 | GetCursorPos(&mouse); 123 | ::SetForegroundWindow(m_nid.hWnd); 124 | ::TrackPopupMenu(pSubMenu->m_hMenu, 0, mouse.x, mouse.y, 0, 125 | m_nid.hWnd, NULL); 126 | } 127 | else // double click: execute first menu item 128 | ::SendMessage(m_nid.hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0); 129 | 130 | return 1; // handled 131 | } -------------------------------------------------------------------------------- /RDS/TrayIcon.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop Server and Client 2 | // CTrayIcon Copyright 1996 Microsoft Systems Journal, by Paul DiLascia 3 | 4 | #ifndef _TRAYICON_H 5 | #define _TRAYICON_H 6 | 7 | #define WM_NOTIFY_TRAY WM_APP + 10 8 | 9 | // CTrayIcon class 10 | class CTrayIcon : public CCmdTarget 11 | { 12 | protected: 13 | DECLARE_DYNAMIC(CTrayIcon) 14 | NOTIFYICONDATA m_nid;// Shell_NotifyIcon args 15 | 16 | public: 17 | CTrayIcon(UINT uID); 18 | ~CTrayIcon(); 19 | 20 | virtual LRESULT OnNotifyTray(WPARAM uID, LPARAM lEvent); 21 | 22 | // Call this to receive tray notifications 23 | void SetNotificationWnd(CWnd * pNotifyWnd,UINT uCbMsg); 24 | 25 | // SetIcon functions. To remove icon, call SetIcon(0) 26 | BOOL SetIcon(UINT uID); 27 | 28 | protected: 29 | BOOL SetIcon(HICON hicon, LPCSTR lpTip); 30 | BOOL SetIcon(LPCTSTR lpResName,LPCSTR lpTip); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /RDS/VideoDriver.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005-2006 Lev Kazarkin. All Rights Reserved. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; version 2 of the License. 6 | 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | #pragma once 17 | 18 | #define ESC_QVI 1026 19 | 20 | #define MAP1 1030 21 | #define UNMAP1 1031 22 | #define TESTMAPPED 1051 23 | 24 | #define MAXCHANGES_BUF 20000 25 | 26 | typedef enum 27 | { 28 | dmf_dfo_IGNORE = 0, 29 | dmf_dfo_FROM_SCREEN = 1, 30 | dmf_dfo_FROM_DIB = 2, 31 | dmf_dfo_TO_SCREEN = 3, 32 | 33 | dmf_dfo_SCREEN_SCREEN = 11, 34 | dmf_dfo_BLIT = 12, 35 | dmf_dfo_SOLIDFILL = 13, 36 | dmf_dfo_BLEND = 14, 37 | dmf_dfo_TRANS = 15, 38 | dmf_dfo_PLG = 17, 39 | dmf_dfo_TEXTOUT = 18, 40 | 41 | dmf_dfo_Ptr_Engage = 48, // point is used with this record 42 | dmf_dfo_Ptr_Avert = 49, 43 | 44 | // 1.0.9.0 45 | // mode-assert notifications to manifest PDEV limbo status 46 | dmf_dfn_assert_on = 64, // DrvAssert(TRUE): PDEV reenabled 47 | dmf_dfn_assert_off = 65, // DrvAssert(FALSE): PDEV disabled 48 | 49 | } dmf_UpdEvent; 50 | 51 | 52 | #define CDS_UPDATEREGISTRY 0x00000001 53 | #define CDS_TEST 0x00000002 54 | #define CDS_FULLSCREEN 0x00000004 55 | #define CDS_GLOBAL 0x00000008 56 | #define CDS_SET_PRIMARY 0x00000010 57 | #define CDS_RESET 0x40000000 58 | #define CDS_SETRECT 0x20000000 59 | #define CDS_NORESET 0x10000000 60 | 61 | typedef BOOL (WINAPI* pEnumDisplayDevices)(PVOID,DWORD,PVOID,DWORD); 62 | typedef LONG (WINAPI* pChangeDisplaySettingsEx)(LPCTSTR, LPDEVMODE, HWND, DWORD, LPVOID); 63 | 64 | //********************************************************************* 65 | 66 | typedef struct _CHANGES_RECORD 67 | { 68 | ULONG type; //screen_to_screen, blit, newcache,oldcache 69 | RECT rect; 70 | RECT origrect; 71 | POINT point; 72 | ULONG color; //number used in cache array 73 | ULONG refcolor; //slot used to pase btimap data 74 | }CHANGES_RECORD; 75 | typedef CHANGES_RECORD *PCHANGES_RECORD; 76 | typedef struct _CHANGES_BUF 77 | { 78 | ULONG counter; 79 | CHANGES_RECORD pointrect[MAXCHANGES_BUF]; 80 | }CHANGES_BUF; 81 | typedef CHANGES_BUF *PCHANGES_BUF; 82 | 83 | typedef struct _GETCHANGESBUF 84 | { 85 | PCHANGES_BUF buffer; 86 | PVOID Userbuffer; 87 | }GETCHANGESBUF; 88 | typedef GETCHANGESBUF *PGETCHANGESBUF; 89 | 90 | #define DMF_VERSION_DEFINE(_ver_0,_ver_1,_ver_2,_ver_3) ((_ver_0<<24) | (_ver_1<<16) | (_ver_2<<8) | _ver_3) 91 | 92 | #define DMF_PROTO_VER_CURRENT DMF_VERSION_DEFINE(1,2,0,0) 93 | #define DMF_PROTO_VER_MINCOMPAT DMF_VERSION_DEFINE(0,9,0,1) 94 | 95 | struct Esc_dmf_Qvi_IN 96 | { 97 | ULONG cbSize; 98 | 99 | ULONG app_actual_version; 100 | ULONG display_minreq_version; 101 | 102 | ULONG connect_options; // reserved. must be 0. 103 | }; 104 | 105 | enum 106 | { 107 | esc_qvi_prod_name_max = 16, 108 | }; 109 | 110 | #define ESC_QVI_PROD_MIRAGE "MIRAGE" 111 | 112 | struct Esc_dmf_Qvi_OUT 113 | { 114 | ULONG cbSize; 115 | 116 | ULONG display_actual_version; 117 | ULONG miniport_actual_version; 118 | ULONG app_minreq_version; 119 | ULONG display_buildno; 120 | ULONG miniport_buildno; 121 | 122 | char prod_name[esc_qvi_prod_name_max]; 123 | }; 124 | 125 | void InitVersion(); 126 | BOOL IsWinNT(); 127 | BOOL IsWinVerOrHigher(ULONG mj, ULONG mn); 128 | DWORD VersionMajor(); 129 | DWORD VersionMinor(); 130 | 131 | class vncVideoDriver 132 | { 133 | public: 134 | vncVideoDriver(); 135 | ~vncVideoDriver(); 136 | 137 | // Methods 138 | public: 139 | // Make the desktop thread & window proc friends 140 | BOOL Activate(BOOL fForDirectAccess, const RECT *prcltarget); 141 | void Deactivate(); 142 | BOOL Activate_NT50(BOOL fForDirectAccess, const RECT *prcltarget); 143 | void Deactivate_NT50(); 144 | BOOL Activate_NT46(BOOL fForDirectAccess); 145 | void Deactivate_NT46(); 146 | BOOL CheckVersion(); 147 | BOOL MapSharedbuffers(BOOL fForDirectScreenAccess); 148 | void UnMapSharedbuffers(); 149 | BOOL TestMapped(); 150 | void HandleDriverChanges(int xoffset,int yoffset); 151 | void HandleDriverChangesSeries(int xoffset,int yoffset,const CHANGES_RECORD *first,const CHANGES_RECORD *last); 152 | void ResetCounter() { oldCounter = bufdata.buffer->counter; } 153 | 154 | BYTE *GetScreenView(void) { return (BYTE*)bufdata.Userbuffer; } 155 | 156 | BOOL IsActive(void) { return m_fIsActive; } 157 | BOOL IsDirectAccessInEffect(void) { return m_fDirectAccessInEffect; } 158 | BOOL IsHandlingScreen2ScreenBlt(void) { return m_fHandleScreen2ScreenBlt; } 159 | 160 | protected: 161 | 162 | static BOOL LookupVideoDeviceAlt( 163 | LPCTSTR szDevStr, 164 | LPCTSTR szDevStrAlt, 165 | INT &devNum, 166 | DISPLAY_DEVICE *pDd); 167 | static HKEY CreateDeviceKey(LPCTSTR szMpName); 168 | 169 | char m_devname[32]; 170 | ULONG m_drv_ver_mj; 171 | ULONG m_drv_ver_mn; 172 | 173 | GETCHANGESBUF bufdata; 174 | ULONG oldCounter; 175 | HDC m_gdc; 176 | 177 | bool m_fIsActive; 178 | bool m_fDirectAccessInEffect; 179 | bool m_fHandleScreen2ScreenBlt; 180 | 181 | static char vncVideoDriver::szDriverString[]; 182 | static char vncVideoDriver::szDriverStringAlt[]; 183 | static char vncVideoDriver::szMiniportName[]; 184 | }; 185 | 186 | -------------------------------------------------------------------------------- /RDS/Win32/Release/RDS.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDS/Win32/Release/RDS.exe -------------------------------------------------------------------------------- /RDS/icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDS/icon1.ico -------------------------------------------------------------------------------- /RDS/res/RDS.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDS/res/RDS.ico -------------------------------------------------------------------------------- /RDS/res/RDS.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | Your app description here 10 | 11 | 12 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /RDS/res/RDS.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // RDS.RC2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /RDS/res/desktop.ini: -------------------------------------------------------------------------------- 1 | [ViewState] 2 | Mode= 3 | Vid= 4 | FolderType=NotSpecified 5 | -------------------------------------------------------------------------------- /RDS/res/main.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDS/res/main.ico -------------------------------------------------------------------------------- /RDS/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by RDS.rc 4 | // 5 | #define IDOK 1 6 | #define IDD_RDS_DIALOG 102 7 | #define IDP_SOCKETS_INIT_FAILED 103 8 | #define IDR_MAINFRAME 128 9 | #define IDC_START 1001 10 | #define IDC_STOP 1002 11 | #define IDC_PWD 1003 12 | #define IDC_STATIC_PWD 1005 13 | #define IDC_COMBO_IP 1006 14 | #define IDC_DISPLAY_BANDS 1007 15 | #define IDC_STATIC_BANDS 1008 16 | #define IDC_STATIC_PORT 1009 17 | #define IDC_PORT 1010 18 | #define IDC_CHECK1 1011 19 | #define IDC_COMPRESSION 1011 20 | #define IDC_CAPTUREDEVICE 1012 21 | #define IDC_STATIC_ACTHREADS 1012 22 | #define IDC_ACTHREADS 1013 23 | #define IDC_COMPRESSION2 1014 24 | #define IDC_LBW 1014 25 | #define IDC_AC 1015 26 | #define IDC_ZLIB 1016 27 | #define IDC_XSCALE 1017 28 | #define IDC_EDIT2 1018 29 | #define IDC_YSCALE 1018 30 | #define IDC_STATIC_XSCALE 1019 31 | #define IDC_STATIC_YSCALE 1020 32 | #define IDC_RGB 1021 33 | #define IDC_BW 1022 34 | #define IDC_STATIC_GRIDTHREADS 1023 35 | #define IDC_GRIDTHREADS 1024 36 | #define IDC_IMGDIB 1025 37 | #define IDC_IMGPNG 1026 38 | #define ID_RDS_RESTORE 32771 39 | 40 | // Next default values for new objects 41 | // 42 | #ifdef APSTUDIO_INVOKED 43 | #ifndef APSTUDIO_READONLY_SYMBOLS 44 | #define _APS_NEXT_RESOURCE_VALUE 131 45 | #define _APS_NEXT_COMMAND_VALUE 32772 46 | #define _APS_NEXT_CONTROL_VALUE 1021 47 | #define _APS_NEXT_SYMED_VALUE 105 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /RDS/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // stdafx.cpp : source file that includes just the standard includes 18 | // RDS.pch will be the pre-compiled header 19 | // stdafx.obj will contain the pre-compiled type information 20 | 21 | #include "stdafx.h" 22 | -------------------------------------------------------------------------------- /RDS/stdafx.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // stdafx.h : include file for standard system include files, 18 | // or project specific include files that are used frequently, 19 | // but are changed infrequently 20 | 21 | #pragma once 22 | #define _CRT_SECURE_NO_WARNINGS 23 | #ifndef VC_EXTRALEAN 24 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 25 | #endif 26 | 27 | // Modify the following defines if you have to target a platform prior to the ones specified below. 28 | // Refer to MSDN for the latest info on corresponding values for different platforms. 29 | #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. 30 | #define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. 31 | #endif 32 | 33 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 34 | 35 | // turns off MFC's hiding of some common and often safely ignored warning messages 36 | #define _AFX_ALL_WARNINGS 37 | 38 | #include // MFC core and standard components 39 | #include // MFC extensions 40 | 41 | #include // MFC support for Internet Explorer 4 Common Controls 42 | #ifndef _AFX_NO_AFXCMN_SUPPORT 43 | #include // MFC support for Windows Common Controls 44 | #endif // _AFX_NO_AFXCMN_SUPPORT 45 | 46 | #include // MFC socket extensions 47 | -------------------------------------------------------------------------------- /RDS/x64/Release/RDS.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDS/x64/Release/RDS.exe -------------------------------------------------------------------------------- /RDV/ChildFrm.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "RDV.h" 19 | #include "ChildFrm.h" 20 | 21 | #ifdef _DEBUG 22 | #define new DEBUG_NEW 23 | #endif 24 | 25 | 26 | // CChildFrame 27 | 28 | IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) 29 | 30 | BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) 31 | END_MESSAGE_MAP() 32 | 33 | 34 | // CChildFrame construction/destruction 35 | 36 | CChildFrame::CChildFrame() 37 | { 38 | // TODO: add member initialization code here 39 | } 40 | 41 | CChildFrame::~CChildFrame() 42 | { 43 | } 44 | 45 | 46 | BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) 47 | { 48 | // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs 49 | if( !CMDIChildWnd::PreCreateWindow(cs) ) 50 | return FALSE; 51 | 52 | return TRUE; 53 | } 54 | 55 | 56 | // CChildFrame diagnostics 57 | 58 | #ifdef _DEBUG 59 | void CChildFrame::AssertValid() const 60 | { 61 | CMDIChildWnd::AssertValid(); 62 | } 63 | 64 | void CChildFrame::Dump(CDumpContext& dc) const 65 | { 66 | CMDIChildWnd::Dump(dc); 67 | } 68 | 69 | #endif //_DEBUG 70 | 71 | 72 | // CChildFrame message handlers 73 | -------------------------------------------------------------------------------- /RDV/ChildFrm.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | class CChildFrame : public CMDIChildWnd 20 | { 21 | DECLARE_DYNCREATE(CChildFrame) 22 | public: 23 | CChildFrame(); 24 | 25 | // Attributes 26 | public: 27 | 28 | // Operations 29 | public: 30 | 31 | // Overrides 32 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 33 | 34 | // Implementation 35 | public: 36 | virtual ~CChildFrame(); 37 | #ifdef _DEBUG 38 | virtual void AssertValid() const; 39 | virtual void Dump(CDumpContext& dc) const; 40 | #endif 41 | 42 | // Generated message map functions 43 | protected: 44 | DECLARE_MESSAGE_MAP() 45 | }; 46 | -------------------------------------------------------------------------------- /RDV/MainFrm.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "RDV.h" 19 | #include "MainFrm.h" 20 | 21 | #ifdef _DEBUG 22 | #define new DEBUG_NEW 23 | #endif 24 | 25 | 26 | // CMainFrame 27 | 28 | IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) 29 | 30 | BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) 31 | ON_WM_CREATE() 32 | END_MESSAGE_MAP() 33 | 34 | static UINT indicators[] = 35 | { 36 | ID_SEPARATOR, // status line indicator 37 | ID_INDICATOR_CAPS, 38 | ID_INDICATOR_NUM, 39 | ID_INDICATOR_SCRL, 40 | }; 41 | 42 | 43 | // CMainFrame construction/destruction 44 | 45 | CMainFrame::CMainFrame() 46 | { 47 | } 48 | 49 | CMainFrame::~CMainFrame() 50 | { 51 | } 52 | 53 | 54 | int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 55 | { 56 | if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) 57 | return -1; 58 | if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP 59 | | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)) 60 | { 61 | TRACE0("Failed to create toolbar\n"); 62 | return -1; // fail to create 63 | } 64 | 65 | // Load the images into the toolbar 66 | if (!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) 67 | { 68 | TRACE0("Failed to create toolbar\n"); 69 | return -1; // fail to create 70 | } 71 | 72 | // Make the Zoom button a check button 73 | m_wndToolBar.SetButtonStyle(3,TBBS_CHECKBOX); 74 | 75 | // Set the button to depressed 76 | m_wndToolBar.GetToolBarCtrl().SetState(ID_VIEW_ZOOM,TBSTATE_CHECKED); 77 | 78 | if (!m_wndStatusBar.Create(this) || 79 | !m_wndStatusBar.SetIndicators(indicators, 80 | sizeof(indicators)/sizeof(UINT))) 81 | { 82 | TRACE0("Failed to create status bar\n"); 83 | return -1; // fail to create 84 | } 85 | 86 | return 0; 87 | } 88 | 89 | BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 90 | { 91 | if( !CMDIFrameWnd::PreCreateWindow(cs) ) 92 | return FALSE; 93 | // TODO: Modify the Window class or styles here by modifying 94 | // the CREATESTRUCT cs 95 | 96 | return TRUE; 97 | } 98 | 99 | 100 | // CMainFrame diagnostics 101 | 102 | #ifdef _DEBUG 103 | void CMainFrame::AssertValid() const 104 | { 105 | CMDIFrameWnd::AssertValid(); 106 | } 107 | 108 | void CMainFrame::Dump(CDumpContext& dc) const 109 | { 110 | CMDIFrameWnd::Dump(dc); 111 | } 112 | 113 | #endif //_DEBUG 114 | 115 | 116 | // CMainFrame message handlers 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /RDV/MainFrm.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | class CMainFrame : public CMDIFrameWnd 20 | { 21 | DECLARE_DYNAMIC(CMainFrame) 22 | public: 23 | CMainFrame(); 24 | 25 | // Attributes 26 | public: 27 | 28 | // Operations 29 | public: 30 | 31 | // Overrides 32 | public: 33 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 34 | 35 | // Implementation 36 | public: 37 | virtual ~CMainFrame(); 38 | #ifdef _DEBUG 39 | virtual void AssertValid() const; 40 | virtual void Dump(CDumpContext& dc) const; 41 | #endif 42 | 43 | protected: // control bar embedded members 44 | CStatusBar m_wndStatusBar; 45 | CToolBar m_wndToolBar; 46 | 47 | // Generated message map functions 48 | protected: 49 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 50 | DECLARE_MESSAGE_MAP() 51 | }; 52 | 53 | 54 | -------------------------------------------------------------------------------- /RDV/NewConnectionDlg.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // NewConnectionDlg.cpp : implementation file 18 | // 19 | 20 | #include "stdafx.h" 21 | #include "RDV.h" 22 | #include "NewConnectionDlg.h" 23 | 24 | 25 | // CNewConnectionDlg dialog 26 | 27 | IMPLEMENT_DYNAMIC(CNewConnectionDlg, CDialog) 28 | CNewConnectionDlg::CNewConnectionDlg(CWnd* pParent /*=NULL*/) 29 | : CDialog(CNewConnectionDlg::IDD, pParent) 30 | , m_csIp(_T("localhost")) 31 | , m_csPort(_T("8370")) 32 | , m_csPassword(_T("pass")) 33 | { 34 | } 35 | 36 | CNewConnectionDlg::~CNewConnectionDlg() 37 | { 38 | } 39 | 40 | void CNewConnectionDlg::DoDataExchange(CDataExchange* pDX) 41 | { 42 | CDialog::DoDataExchange(pDX); 43 | DDX_Text(pDX, IDC_IP, m_csIp); 44 | DDV_MaxChars(pDX, m_csIp, 255); 45 | DDX_Text(pDX, IDC_PORT, m_csPort); 46 | DDV_MaxChars(pDX, m_csPort, 6); 47 | DDX_Text(pDX, IDC_PASSWORD, m_csPassword); 48 | DDV_MaxChars(pDX, m_csPassword, 255); 49 | } 50 | 51 | 52 | BEGIN_MESSAGE_MAP(CNewConnectionDlg, CDialog) 53 | END_MESSAGE_MAP() 54 | 55 | 56 | // CNewConnectionDlg message handlers 57 | -------------------------------------------------------------------------------- /RDV/NewConnectionDlg.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | // CNewConnectionDlg dialog 20 | 21 | class CNewConnectionDlg : public CDialog 22 | { 23 | DECLARE_DYNAMIC(CNewConnectionDlg) 24 | 25 | public: 26 | CNewConnectionDlg(CWnd* pParent = NULL); // standard constructor 27 | virtual ~CNewConnectionDlg(); 28 | 29 | // Dialog Data 30 | enum { IDD = IDD_NEWCONNECTION }; 31 | 32 | protected: 33 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 34 | 35 | DECLARE_MESSAGE_MAP() 36 | public: 37 | // The server ip or name 38 | CString m_csIp; 39 | // The negotiating port on the server 40 | CString m_csPort; 41 | // Password for the server 42 | CString m_csPassword; 43 | }; 44 | -------------------------------------------------------------------------------- /RDV/RDV.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "RDV.h" 19 | #include "MainFrm.h" 20 | #include "ChildFrm.h" 21 | #include "RDVDoc.h" 22 | #include "RDVView.h" 23 | #include 24 | 25 | #pragma comment(lib, "iphlpapi.lib") 26 | #pragma comment(lib, "mpr.lib") 27 | 28 | #ifdef _DEBUG 29 | #define new DEBUG_NEW 30 | #endif 31 | 32 | // CRDVApp 33 | 34 | BEGIN_MESSAGE_MAP(CRDVApp, CWinApp) 35 | ON_COMMAND(ID_APP_ABOUT, &CRDVApp::OnAppAbout) 36 | // Standard file based document commands 37 | ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew) 38 | ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen) 39 | // Standard print setup command 40 | ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup) 41 | ON_COMMAND(ID_VIEW_PEERS, &CRDVApp::OnViewNeighbors) 42 | END_MESSAGE_MAP() 43 | 44 | 45 | // CRDVApp construction 46 | 47 | CRDVApp::CRDVApp() 48 | { 49 | // Initialize the O/S version information 50 | InitVersion(); 51 | 52 | // Output the licensing disclaimer 53 | DebugMsg(_T("Remote Desktop System, Copyright (C) 2000-2009 GravyLabs LLC\n")); 54 | DebugMsg(_T("GravyLabs LLC can be reached at jones.gravy@gmail.com\n")); 55 | DebugMsg(_T("Remote Desktop System comes with ABSOLUTELY NO WARRANTY\n")); 56 | DebugMsg(_T("This is free software, and you are welcome to redistribute it\n")); 57 | DebugMsg(_T("under of the GNU General Public License as published by\n")); 58 | DebugMsg(_T("the Free Software Foundation; version 2 of the License.\n")); 59 | } 60 | 61 | // The one and only CRDVApp object 62 | CRDVApp theApp; 63 | 64 | // CRDVApp initialization 65 | BOOL CRDVApp::InitInstance() 66 | { 67 | // InitCommonControlsEx() is required on Windows XP if an application 68 | // manifest specifies use of ComCtl32.dll version 6 or later to enable 69 | // visual styles. Otherwise, any window creation will fail. 70 | INITCOMMONCONTROLSEX InitCtrls; 71 | InitCtrls.dwSize = sizeof(InitCtrls); 72 | 73 | // Set this to include all the common control classes you want to use 74 | // in your application. 75 | InitCtrls.dwICC = ICC_WIN95_CLASSES; 76 | InitCommonControlsEx(&InitCtrls); 77 | 78 | CWinApp::InitInstance(); 79 | 80 | if (!AfxSocketInit()) 81 | { 82 | AfxMessageBox(IDP_SOCKETS_INIT_FAILED); 83 | return FALSE; 84 | } 85 | 86 | // Test the O/S version information for XP or later 87 | if (!IsWinNT() || !IsWinVerOrHigher(5,1)) 88 | { 89 | AfxMessageBox(_T("Requires Windows XP or later")); 90 | return FALSE; 91 | } 92 | 93 | // Initialize OLE libraries 94 | if (!AfxOleInit()) 95 | { 96 | AfxMessageBox(IDP_OLE_INIT_FAILED); 97 | return FALSE; 98 | } 99 | AfxEnableControlContainer(); 100 | 101 | // Standard initialization 102 | // If you are not using these features and wish to reduce the size 103 | // of your final executable, you should remove from the following 104 | // the specific initialization routines you do not need 105 | // Change the registry key under which our settings are stored 106 | // TODO: You should modify this string to be something appropriate 107 | // such as the name of your company or organization 108 | SetRegistryKey(_T("Remote Desktop System")); 109 | LoadStdProfileSettings(4); // Load standard INI file options (including MRU) 110 | 111 | // Register the application's document templates. Document templates 112 | // serve as the connection between documents, frame windows and views 113 | CMultiDocTemplate* pDocTemplate; 114 | pDocTemplate = new CMultiDocTemplate(IDR_RDVTYPE, 115 | RUNTIME_CLASS(CRDVDoc), 116 | RUNTIME_CLASS(CChildFrame), // custom MDI child frame 117 | RUNTIME_CLASS(CRDVView)); 118 | if (!pDocTemplate) 119 | return FALSE; 120 | AddDocTemplate(pDocTemplate); 121 | 122 | // create main MDI Frame window 123 | CMainFrame* pMainFrame = new CMainFrame; 124 | if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) 125 | { 126 | delete pMainFrame; 127 | return FALSE; 128 | } 129 | m_pMainWnd = pMainFrame; 130 | 131 | // call DragAcceptFiles only if there's a suffix 132 | // In an MDI app, this should occur immediately after setting m_pMainWnd 133 | // Enable drag/drop open 134 | m_pMainWnd->DragAcceptFiles(); 135 | 136 | // Enable DDE Execute open 137 | EnableShellOpen(); 138 | RegisterShellFileTypes(TRUE); 139 | 140 | // Parse command line for standard shell commands, DDE, file open 141 | CCommandLineInfo cmdInfo; 142 | ParseCommandLine(cmdInfo); 143 | 144 | // Prevent an initial document from being created 145 | cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; 146 | 147 | // Dispatch commands specified on the command line. Will return FALSE if 148 | // app was launched with /RegServer, /Register, /Unregserver or /Unregister. 149 | if (!ProcessShellCommand(cmdInfo)) 150 | return FALSE; 151 | // The main window has been initialized, so show and update it 152 | pMainFrame->ShowWindow(m_nCmdShow); 153 | pMainFrame->UpdateWindow(); 154 | 155 | return TRUE; 156 | } 157 | 158 | 159 | // CAboutDlg dialog used for App About 160 | 161 | class CAboutDlg : public CDialog 162 | { 163 | public: 164 | CAboutDlg(); 165 | 166 | // Dialog Data 167 | enum { IDD = IDD_ABOUTBOX }; 168 | 169 | protected: 170 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 171 | 172 | // Implementation 173 | protected: 174 | DECLARE_MESSAGE_MAP() 175 | }; 176 | 177 | CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 178 | { 179 | } 180 | 181 | void CAboutDlg::DoDataExchange(CDataExchange* pDX) 182 | { 183 | CDialog::DoDataExchange(pDX); 184 | } 185 | 186 | BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 187 | END_MESSAGE_MAP() 188 | 189 | // App command to run the dialog 190 | void CRDVApp::OnAppAbout() 191 | { 192 | CAboutDlg aboutDlg; 193 | aboutDlg.DoModal(); 194 | } 195 | 196 | // CRDVApp message handlers 197 | 198 | // View a list of neighbor machines with their host names and ip addresses 199 | afx_msg void CRDVApp::OnViewNeighbors() 200 | { 201 | NETRESOURCE *pNetResource; 202 | HANDLE hEnum; 203 | DWORD dwResult; 204 | DWORD dwSize = 16386; 205 | DWORD dwNum; 206 | struct hostent* host = NULL; 207 | WSADATA wsaData; 208 | 209 | CString msg; 210 | 211 | dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, RESOURCEDISPLAYTYPE_SERVER, NULL, &hEnum); 212 | if (dwResult != 0) 213 | { 214 | AfxMessageBox(_T("WNetOpenEnum failed.\n")); 215 | return; 216 | } 217 | 218 | pNetResource = (LPNETRESOURCE)GlobalAlloc(GPTR, dwSize); 219 | if (pNetResource == NULL) 220 | { 221 | AfxMessageBox(_T("GlobalAlloc failed.\n")); 222 | return; 223 | } 224 | 225 | dwNum = -1; 226 | 227 | dwResult = WNetEnumResource(hEnum, &dwNum, pNetResource, &dwSize); 228 | if (dwResult != 0) 229 | { 230 | AfxMessageBox(_T("WNetEnumResource failed.\n")); 231 | return; 232 | } 233 | 234 | for (DWORD i = 0; i < dwNum; i++) 235 | { 236 | if (pNetResource[i].lpRemoteName == NULL) 237 | continue; 238 | 239 | CString RemoteName = CString(pNetResource[i].lpRemoteName); 240 | 241 | AfxMessageBox(RemoteName); 242 | 243 | if (0 == RemoteName.Left(2).Compare(CString("\\\\"))) 244 | { 245 | RemoteName = RemoteName.Right(RemoteName.GetLength() - 2); 246 | 247 | host = gethostbyname((char*)(LPCTSTR)RemoteName); 248 | 249 | if (host != NULL) 250 | { 251 | msg.Format(_T("%s - %s\n"), host->h_name, inet_ntoa(*(in_addr *)host->h_addr)); 252 | 253 | AfxMessageBox(msg); 254 | } 255 | } 256 | } 257 | 258 | GlobalFree(pNetResource); 259 | WNetCloseEnum(hEnum); 260 | } 261 | -------------------------------------------------------------------------------- /RDV/RDV.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #ifndef __AFXWIN_H__ 20 | #error "include 'stdafx.h' before including this file for PCH" 21 | #endif 22 | 23 | #include "..\Packet.h" 24 | #include 25 | #include "resource.h" // main symbols 26 | 27 | // CRDVApp: 28 | // See RDV.cpp for the implementation of this class 29 | // 30 | 31 | class CRDVApp : public CWinApp 32 | { 33 | public: 34 | CRDVApp(); 35 | 36 | // Overrides 37 | public: 38 | virtual BOOL InitInstance(); 39 | 40 | // Implementation 41 | afx_msg void OnAppAbout(); 42 | 43 | DECLARE_MESSAGE_MAP() 44 | // View a list of neighbor machines with their host names and ip addresses 45 | afx_msg void OnViewNeighbors(); 46 | }; 47 | 48 | extern CRDVApp theApp; -------------------------------------------------------------------------------- /RDV/RDV.reg: -------------------------------------------------------------------------------- 1 | REGEDIT 2 | ; This .REG file may be used by your SETUP program. 3 | ; If a SETUP program is not available, the entries below will be 4 | ; registered in your InitInstance automatically with a call to 5 | ; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll. 6 | 7 | HKEY_CLASSES_ROOT\.RDS = RDV.Document 8 | HKEY_CLASSES_ROOT\RDV.Document\shell\open\command = RDV.EXE %1 9 | HKEY_CLASSES_ROOT\RDV.Document\shell\open\ddeexec = [open("%1")] 10 | HKEY_CLASSES_ROOT\RDV.Document\shell\open\ddeexec\application = RDV 11 | ; note: the application is optional 12 | ; (it defaults to the app name in "command") 13 | 14 | HKEY_CLASSES_ROOT\RDV.Document = RDV.Document 15 | 16 | -------------------------------------------------------------------------------- /RDV/RDV.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | 100 | 101 | Resource Files 102 | 103 | 104 | 105 | 106 | Resource Files 107 | 108 | 109 | 110 | 111 | 112 | Resource Files 113 | 114 | 115 | Resource Files 116 | 117 | 118 | Resource Files 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /RDV/RDVDoc.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "RDV.h" 19 | #include "RDVDoc.h" 20 | #include "RDVView.h" 21 | #include "NewConnectionDlg.h" 22 | 23 | #ifdef _DEBUG 24 | #define new DEBUG_NEW 25 | #endif 26 | 27 | // CRDVDoc 28 | 29 | IMPLEMENT_DYNCREATE(CRDVDoc, CDocument) 30 | 31 | BEGIN_MESSAGE_MAP(CRDVDoc, CDocument) 32 | END_MESSAGE_MAP() 33 | 34 | 35 | // CRDVDoc construction/destruction 36 | 37 | CRDVDoc::CRDVDoc() 38 | { 39 | } 40 | 41 | CRDVDoc::~CRDVDoc() 42 | { 43 | } 44 | 45 | // Return the view 46 | CRDVView * CRDVDoc::GetView() 47 | { 48 | CRDVView * pView = NULL; 49 | POSITION Pos = GetFirstViewPosition(); 50 | if (Pos) 51 | pView = (CRDVView *)GetNextView(Pos); 52 | return pView; 53 | } 54 | 55 | BOOL CRDVDoc::OnNewDocument() 56 | { 57 | if (!CDocument::OnNewDocument()) 58 | return FALSE; 59 | 60 | // Display the connection dialog 61 | CNewConnectionDlg NewConnection; 62 | if (NewConnection.DoModal() != IDOK) 63 | return FALSE; 64 | 65 | // Set the connection specifics for a successful connection 66 | m_csIp = NewConnection.m_csIp; 67 | m_csPort = NewConnection.m_csPort; 68 | m_csPassword = NewConnection.m_csPassword; 69 | 70 | // Connect to the server 71 | GetView()->ConnectServer(); 72 | 73 | return TRUE; 74 | } 75 | 76 | void CRDVDoc::OnCloseDocument() 77 | { 78 | // Close all active connections 79 | CRDVView * pView = GetView(); 80 | if (pView) 81 | pView->DisconnectServer(); 82 | 83 | // Close the document 84 | CDocument::OnCloseDocument(); 85 | } 86 | 87 | // CRDVDoc serialization 88 | 89 | void CRDVDoc::Serialize(CArchive & ar) 90 | { 91 | if (ar.IsStoring()) 92 | { 93 | // Save the connection information 94 | ar << m_csIp; 95 | ar << m_csPort; 96 | ar << m_csPassword; 97 | } 98 | else 99 | { 100 | // Load the connection information 101 | ar >> m_csIp; 102 | ar >> m_csPort; 103 | ar >> m_csPassword; 104 | 105 | // Connect to the server 106 | GetView()->ConnectServer(); 107 | } 108 | } 109 | 110 | // CRDVDoc diagnostics 111 | 112 | #ifdef _DEBUG 113 | void CRDVDoc::AssertValid() const 114 | { 115 | CDocument::AssertValid(); 116 | } 117 | 118 | void CRDVDoc::Dump(CDumpContext& dc) const 119 | { 120 | CDocument::Dump(dc); 121 | } 122 | #endif //_DEBUG 123 | 124 | // CRDVDoc commands 125 | -------------------------------------------------------------------------------- /RDV/RDVDoc.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | class CRDVView; 19 | 20 | class CRDVDoc : public CDocument 21 | { 22 | protected: // create from serialization only 23 | CRDVDoc(); 24 | CRDVView * GetView(); 25 | DECLARE_DYNCREATE(CRDVDoc) 26 | 27 | // Attributes 28 | public: 29 | CString m_csIp; 30 | CString m_csPort; 31 | CString m_csPassword; 32 | 33 | // Operations 34 | public: 35 | 36 | // Overrides 37 | public: 38 | virtual BOOL OnNewDocument(); 39 | virtual void OnCloseDocument(); 40 | virtual void Serialize(CArchive & ar); 41 | 42 | // Implementation 43 | public: 44 | virtual ~CRDVDoc(); 45 | #ifdef _DEBUG 46 | virtual void AssertValid() const; 47 | virtual void Dump(CDumpContext& dc) const; 48 | #endif 49 | 50 | // Generated message map functions 51 | protected: 52 | DECLARE_MESSAGE_MAP() 53 | }; 54 | 55 | 56 | -------------------------------------------------------------------------------- /RDV/RDVView.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include "..\Common.h" 20 | #include "..\TCPSocket.h" 21 | #include "..\DIBFrame.h" 22 | #include "ATLImage.h" 23 | #include 24 | 25 | class CRDVView : public CScrollView 26 | { 27 | protected: // create from serialization only 28 | CRDVView(); 29 | DECLARE_DYNCREATE(CRDVView) 30 | 31 | // Attributes 32 | public: 33 | CRDVDoc* GetDocument() const; 34 | 35 | // Operations 36 | public: 37 | void ConnectServer(); 38 | void DisconnectServer(); 39 | 40 | // Overrides 41 | public: 42 | virtual void OnDraw(CDC * pDC); // overridden to draw this view 43 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 44 | 45 | protected: 46 | virtual void OnInitialUpdate(); 47 | virtual BOOL DestroyWindow(); 48 | virtual BOOL OnPreparePrinting(CPrintInfo * pInfo); 49 | virtual void OnBeginPrinting(CDC * pDC, CPrintInfo * pInfo); 50 | virtual void OnPrint(CDC * pDC,CPrintInfo * pInfo); 51 | virtual void OnEndPrinting(CDC * pDC, CPrintInfo * pInfo); 52 | virtual void OnUpdate(CView * pSender,LPARAM lHint,CObject * pHint); 53 | 54 | // Implementation 55 | public: 56 | virtual ~CRDVView(); 57 | #ifdef _DEBUG 58 | virtual void AssertValid() const; 59 | virtual void Dump(CDumpContext& dc) const; 60 | #endif 61 | 62 | // Internal helpers 63 | protected: 64 | void SetupGDI(); 65 | void CleanupGDI(); 66 | void DeleteSinkThreads(); 67 | void SendMouseMessage(WORD wWM,UINT nFlags,CPoint Point,short zDelta = 0); 68 | void SendKeyBoardMessage(WORD wWM,UINT nChar,UINT nRepCnt,UINT nFlags); 69 | 70 | // Generated message map functions 71 | protected: 72 | DECLARE_MESSAGE_MAP() 73 | 74 | // Handled socket event callbacks 75 | afx_msg LRESULT OnMakeConn(WPARAM wParam,LPARAM lParam); 76 | afx_msg LRESULT OnReceiveData(WPARAM wParam,LPARAM lParam); 77 | afx_msg LRESULT OnCloseConn(WPARAM wParam,LPARAM lParam); 78 | 79 | // Capture UI events and send them to the server 80 | afx_msg void OnLButtonDblClk(UINT nFlags,CPoint Point); 81 | afx_msg void OnLButtonDown(UINT nFlags,CPoint Point); 82 | afx_msg void OnLButtonUp(UINT nFlags,CPoint Point); 83 | afx_msg void OnMButtonDblClk(UINT nFlags,CPoint Point); 84 | afx_msg void OnMButtonDown(UINT nFlags,CPoint Point); 85 | afx_msg void OnMButtonUp(UINT nFlags,CPoint Point); 86 | afx_msg BOOL OnMouseWheel(UINT nFlags,short zDelta,CPoint Point); 87 | afx_msg void OnMouseMove(UINT nFlags,CPoint Point); 88 | afx_msg void OnRButtonDblClk(UINT nFlags,CPoint Point); 89 | afx_msg void OnRButtonDown(UINT nFlags,CPoint Point); 90 | afx_msg void OnRButtonUp(UINT nFlags,CPoint Point); 91 | afx_msg void OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags); 92 | afx_msg void OnKeyUp(UINT nChar,UINT nRepCnt,UINT nFlags); 93 | 94 | // Handle the cursor 95 | afx_msg BOOL OnSetCursor(CWnd * pWnd,UINT nHitTest,UINT message); 96 | 97 | // Timer for closing the document 98 | afx_msg void OnTimer(UINT_PTR nIDEvent); 99 | 100 | // For resizing 101 | afx_msg void OnSize(UINT nType,int cx,int cy); 102 | 103 | // For zooming 104 | afx_msg void OnViewZoom(); 105 | afx_msg void OnUpdateViewZoom(CCmdUI *pCmdUI); 106 | 107 | // Data 108 | protected: 109 | // The client connectiun 110 | CTCPSocket m_Socket; 111 | 112 | // Handle arrays 113 | HANDLE m_arrSinkHandles[MAXTHREADS]; 114 | std::vector m_vecSinkThreads; 115 | 116 | // Number of update threads on the server 117 | int m_nGridThreads; 118 | int m_iGridThread; 119 | 120 | // Connection 121 | bool m_bConnected; 122 | 123 | // Dib bit count 124 | int m_nBitCount; 125 | 126 | // Dib dimensions 127 | int m_cxWidth; 128 | int m_cyHeight; 129 | DWORD m_dwDibSize; 130 | 131 | // Desktop DIB 132 | CDIBFrame m_DIB; 133 | CDIBFrame m_XOR; 134 | 135 | // GDI+ Image support 136 | CImage m_ImageDIB; 137 | 138 | // Cursor 139 | CCursor m_Cursor; 140 | 141 | // Multithreaded arithmetic encoder/decoder 142 | int m_nCompThreads; 143 | CDriveMultiThreadedCompression * m_pMTC; 144 | 145 | // Single threaded compression 146 | CArithmeticEncoder m_AC; 147 | CZLib m_ZLib; 148 | 149 | // Queue of keyboard messages 150 | std::vector m_vKBMsg; 151 | std::vector m_vMouseMsg; 152 | 153 | // For zooming 154 | CSize m_ViewSize; 155 | BOOL m_bViewZoom; 156 | 157 | // Session Id 158 | UINT m_nSessionId; 159 | }; 160 | 161 | #ifndef _DEBUG // debug version in RDVView.cpp 162 | inline CRDVDoc* CRDVView::GetDocument() const 163 | { return reinterpret_cast(m_pDocument); } 164 | #endif 165 | 166 | -------------------------------------------------------------------------------- /RDV/Win32/Release/RDV.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDV/Win32/Release/RDV.exe -------------------------------------------------------------------------------- /RDV/res/RDV.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDV/res/RDV.ico -------------------------------------------------------------------------------- /RDV/res/RDV.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // RDV.RC2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /RDV/res/RDVDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDV/res/RDVDoc.ico -------------------------------------------------------------------------------- /RDV/res/Toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDV/res/Toolbar.bmp -------------------------------------------------------------------------------- /RDV/res/icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDV/res/icon1.ico -------------------------------------------------------------------------------- /RDV/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by RDV.rc 4 | // 5 | #define VS_VERSION_INFO 1 6 | #define IDD_ABOUTBOX 100 7 | #define IDP_OLE_INIT_FAILED 100 8 | #define IDP_SOCKETS_INIT_FAILED 104 9 | #define IDR_MAINFRAME 128 10 | #define IDR_RDVTYPE 129 11 | #define IDD_NEWCONNECTION 130 12 | #define IDI_ICON1 131 13 | #define IDC_IP 1001 14 | #define IDC_PORT 1002 15 | #define IDC_PASSWORD 1003 16 | #define ID_VIEW_ZOOM 32779 17 | #define ID_VIEW_PEERS 32780 18 | 19 | // Next default values for new objects 20 | // 21 | #ifdef APSTUDIO_INVOKED 22 | #ifndef APSTUDIO_READONLY_SYMBOLS 23 | #define _APS_NEXT_RESOURCE_VALUE 132 24 | #define _APS_NEXT_COMMAND_VALUE 32781 25 | #define _APS_NEXT_CONTROL_VALUE 1000 26 | #define _APS_NEXT_SYMED_VALUE 101 27 | #endif 28 | #endif 29 | -------------------------------------------------------------------------------- /RDV/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | 19 | 20 | -------------------------------------------------------------------------------- /RDV/stdafx.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #ifndef _SECURE_ATL 20 | #define _SECURE_ATL 1 21 | #endif 22 | 23 | #ifndef VC_EXTRALEAN 24 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 25 | #endif 26 | 27 | // Modify the following defines if you have to target a platform prior to the ones specified below. 28 | // Refer to MSDN for the latest info on corresponding values for different platforms. 29 | #ifndef WINVER // Allow use of features specific to Windows XP or later. 30 | #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. 31 | #endif 32 | 33 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 34 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 35 | #endif 36 | 37 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 38 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 39 | #endif 40 | 41 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. 42 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. 43 | #endif 44 | 45 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 46 | 47 | // turns off MFC's hiding of some common and often safely ignored warning messages 48 | #define _AFX_ALL_WARNINGS 49 | 50 | #include // MFC core and standard components 51 | #include // MFC extensions 52 | 53 | 54 | #include // MFC Automation classes 55 | 56 | 57 | 58 | #ifndef _AFX_NO_OLE_SUPPORT 59 | #include // MFC support for Internet Explorer 4 Common Controls 60 | #endif 61 | #ifndef _AFX_NO_AFXCMN_SUPPORT 62 | #include // MFC support for Windows Common Controls 63 | #endif // _AFX_NO_AFXCMN_SUPPORT 64 | 65 | 66 | #include // MFC socket extensions 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | #ifdef _UNICODE 75 | #if defined _M_IX86 76 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 77 | #elif defined _M_IA64 78 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") 79 | #elif defined _M_X64 80 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 81 | #else 82 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 83 | #endif 84 | #endif 85 | 86 | 87 | -------------------------------------------------------------------------------- /RDV/x64/Release/RDV.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/RDV/x64/Release/RDV.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RemoteDesktopControl 2 | ==================== 3 | 4 | A remote desktop control suite 5 | 6 | This suite is forked from http://www.codeproject.com/Articles/565/Remote-Control-PCs to add new functionlities. 7 | -------------------------------------------------------------------------------- /Registry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | ///////////////////////////////////////////////////////////////////////////// 3 | // Copyright (C) 1998 by Shane Martin 4 | // All rights reserved 5 | // 6 | // Distribute freely, except: don't remove my name from the source or 7 | // documentation (don't take credit for my work), mark your changes (don't 8 | // get me blamed for your possible bugs), don't alter or remove this 9 | // notice. 10 | // No warrantee of any kind, express or implied, is included with this 11 | // software; use at your own risk, responsibility for damages (if any) to 12 | // anyone resulting from the use of this software rests entirely with the 13 | // user. 14 | // 15 | // Send bug reports, bug fixes, enhancements, requests, flames, etc., and 16 | // I'll try to keep a version up to date. I can be reached as follows: 17 | // shane.kim@kaiserslautern.netsurf.de 18 | ///////////////////////////////////////////////////////////////////////////// 19 | #include 20 | 21 | #define REG_RECT 0x0001 22 | #define REG_POINT 0x0002 23 | 24 | class CRegistry : public CObject 25 | { 26 | // Construction 27 | public: 28 | CRegistry (BOOL bAdmin, BOOL bReadOnly); 29 | virtual ~CRegistry(); 30 | 31 | struct REGINFO 32 | { 33 | LONG lMessage; 34 | DWORD dwType; 35 | DWORD dwSize; 36 | } 37 | m_Info; 38 | 39 | // Operations 40 | public: 41 | void Attach(HKEY hKey); 42 | HKEY Detach(); 43 | BOOL EnumKey(int index, CString& keyName); 44 | BOOL RecursiveDeleteKey(LPCTSTR pszPath, BOOL bAdmin = FALSE); 45 | 46 | BOOL VerifyKey (LPCTSTR pszPath); 47 | BOOL VerifyValue (LPCTSTR pszValue); 48 | BOOL CreateKey (LPCTSTR pszPath); 49 | BOOL Open (LPCTSTR pszPath); 50 | void Close(); 51 | 52 | BOOL DeleteValue (LPCTSTR pszValue); 53 | BOOL DeleteKey (LPCTSTR pszPath, BOOL bAdmin = FALSE); 54 | 55 | BOOL Write (LPCTSTR pszKey, int iVal); 56 | BOOL Write (LPCTSTR pszKey, DWORD dwVal); 57 | BOOL Write (LPCTSTR pszKey, LPCTSTR pszVal); 58 | BOOL Write (LPCTSTR pszKey, CStringList& scStringList); 59 | BOOL Write (LPCTSTR pszKey, CByteArray& bcArray); 60 | BOOL Write (LPCTSTR pszKey, CStringArray& scArray); 61 | BOOL Write (LPCTSTR pszKey, CDWordArray& dwcArray); 62 | BOOL Write (LPCTSTR pszKey, CWordArray& wcArray); 63 | BOOL Write (LPCTSTR pszKey, const CRect& rect); 64 | BOOL Write (LPCTSTR pszKey, LPPOINT& lpPoint); 65 | BOOL Write (LPCTSTR pszKey, LPBYTE pData, UINT nBytes); 66 | BOOL Write (LPCTSTR pszKey, CObList& list); 67 | BOOL Write (LPCTSTR pszKey, CObject& obj); 68 | 69 | BOOL Read (LPCTSTR pszKey, int& iVal); 70 | BOOL Read (LPCTSTR pszKey, DWORD& dwVal); 71 | BOOL Read (LPCTSTR pszKey, CString& sVal); 72 | BOOL Read (LPCTSTR pszKey, CStringList& scStringList); 73 | BOOL Read (LPCTSTR pszKey, CStringArray& scArray); 74 | BOOL Read (LPCTSTR pszKey, CDWordArray& dwcArray); 75 | BOOL Read (LPCTSTR pszKey, CWordArray& wcArray); 76 | BOOL Read (LPCTSTR pszKey, CByteArray& bcArray); 77 | BOOL Read (LPCTSTR pszKey, LPPOINT& lpPoint); 78 | BOOL Read (LPCTSTR pszKey, CRect& rect); 79 | BOOL Read (LPCTSTR pszKey, BYTE** ppData, UINT* pBytes); 80 | BOOL Read (LPCTSTR pszKey, CObList& list); 81 | BOOL Read (LPCTSTR pszKey, CObject& obj); 82 | 83 | protected: 84 | 85 | HKEY m_hKey; 86 | CString m_sPath; 87 | const BOOL m_bReadOnly; 88 | }; -------------------------------------------------------------------------------- /TCPSocket.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include 20 | #include "afxsock.h" 21 | #include "Packet.h" 22 | #include "Common.h" 23 | 24 | #define WM_ACCEPTCONN (WM_APP + 1) 25 | #define WM_MAKECONN (WM_APP + 2) 26 | #define WM_RECEIVEDATA (WM_APP + 3) 27 | #define WM_CLOSECONN (WM_APP + 4) 28 | 29 | // TCP stream socket class 30 | class CTCPSocket : public CAsyncSocket 31 | { 32 | typedef CAsyncSocket baseclass; 33 | private: 34 | CTCPSocket(const CTCPSocket & rhs); // no 35 | void operator=(const CTCPSocket & rhs); // no 36 | 37 | public: 38 | CTCPSocket(); 39 | virtual ~CTCPSocket(); 40 | 41 | BOOL Create(int nSocketPort = 0); 42 | BOOL Connect(LPCTSTR lpszHostAddress,UINT nHostPort); 43 | void SetParent(HWND hWndParent); 44 | BOOL ShutDown(int nHow = CSocket::both); 45 | BOOL InitTP(); 46 | 47 | // Helper to send a packet 48 | CTCPSocket & operator << (CPacket & rhs); 49 | 50 | // Helper to receive a packet 51 | CTCPSocket & operator >> (CPacket & rhs); 52 | 53 | // Helper for sorting 54 | bool operator < (const CTCPSocket & rhs); 55 | 56 | protected: 57 | // Low-level socket event callbacks, reposted to parent via WM_APP messages 58 | virtual void OnAccept(int nErrorCode); 59 | virtual void OnConnect(int nErrorCode); 60 | virtual void OnReceive(int nErrorCode); 61 | virtual void OnClose(int nErrorCode); 62 | 63 | // Low-level methods to send and receieve data over the socket 64 | virtual int Send(const void * lpBuf,int nBufLen,int nFlags = 0); 65 | virtual int Receive(void * lpBuf,int nBufLen,int nFlags = 0); 66 | 67 | private: 68 | LPFN_TRANSMITPACKETS TransmitPackets; 69 | BOOL m_bListening; 70 | HWND m_hWndParent; 71 | }; 72 | 73 | //////////////////////////////////////////////////////////////////////////// 74 | // Window sink message class 75 | class CSocketWndSink : public CWnd 76 | { 77 | // Construction 78 | public: 79 | CSocketWndSink(HWND hWndParent = NULL); 80 | ~CSocketWndSink(); 81 | 82 | void Connect(CString csIp,CString csPort); 83 | BOOL IsConnected(); 84 | void ShutDown(); 85 | 86 | // Generated message map functions 87 | protected: 88 | //{{AFX_MSG(CSocketWndSink) 89 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 90 | afx_msg void OnPaint(); 91 | //}}AFX_MSG 92 | 93 | protected: 94 | // The parent dialog 95 | HWND m_hWndParent; 96 | 97 | // The client connectiun 98 | CTCPSocket m_Socket; 99 | BOOL m_bConnected; 100 | 101 | DECLARE_MESSAGE_MAP() 102 | 103 | // Handled socket event callbacks 104 | afx_msg LRESULT OnMakeConn(WPARAM wParam,LPARAM lParam); 105 | afx_msg LRESULT OnReceiveData(WPARAM wParam,LPARAM lParam); 106 | afx_msg LRESULT OnCloseConn(WPARAM wParam,LPARAM lParam); 107 | }; 108 | 109 | // Connection to the server that receives DIB updates 110 | class CSocketWndSinkThread : public CWinThread 111 | { 112 | DECLARE_DYNCREATE(CSocketWndSinkThread) 113 | 114 | CSocketWndSinkThread(); 115 | 116 | public: 117 | CSocketWndSinkThread(HANDLE * phWork,HWND hWndParent,CString csIp,CString csPort); 118 | virtual ~CSocketWndSinkThread(); 119 | virtual BOOL InitInstance(); 120 | virtual BOOL PumpMessage(); 121 | virtual int ExitInstance(); 122 | BOOL IsConnected(); 123 | 124 | // Event synchronization 125 | public: 126 | HANDLE m_hPumpMessage; 127 | 128 | // Intialization 129 | private: 130 | bool m_bPumpMessage; 131 | 132 | protected: 133 | HANDLE * m_phWork; 134 | HWND m_hWndParent; 135 | CString m_csIp; 136 | CString m_csPort; 137 | CSocketWndSink * m_pSocketWnd; 138 | 139 | protected: 140 | DECLARE_MESSAGE_MAP() 141 | afx_msg void OnConnectServer(WPARAM wParam,LPARAM lParam); 142 | afx_msg void OnEndThread(WPARAM wParam,LPARAM lParam); 143 | }; 144 | 145 | //////////////////////////////////////////////////////////////////////////// 146 | // Socket message event sink 147 | class CSocketEvent : public CWnd 148 | { 149 | // Construction 150 | public: 151 | CSocketEvent(CWinThread * pThread); 152 | ~CSocketEvent(); 153 | BOOL IsClosed(); 154 | 155 | // Generated message map functions 156 | protected: 157 | //{{AFX_MSG(CSocketEvent) 158 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 159 | afx_msg void OnPaint(); 160 | //}}AFX_MSG 161 | 162 | protected: 163 | 164 | DECLARE_MESSAGE_MAP() 165 | 166 | // Socket events 167 | afx_msg LRESULT OnReceiveData(WPARAM wParam,LPARAM lParam); 168 | afx_msg LRESULT OnCloseConn(WPARAM wParam,LPARAM lParam); 169 | 170 | // Back pointers 171 | CWinThread * m_pThread; 172 | BOOL m_bClosed; 173 | }; 174 | -------------------------------------------------------------------------------- /UpgradeLog.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoryXie/RemoteDesktopControl/3afe58a120cadfb3dc78de11330de7ca77d7b504/UpgradeLog.htm -------------------------------------------------------------------------------- /WndSink.cpp: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #include "stdafx.h" 18 | #include "WndSink.h" 19 | 20 | // Handle the socket notifications as well as the basic initialization 21 | BEGIN_MESSAGE_MAP(CWndSink,CWnd) 22 | ON_WM_CREATE() 23 | ON_WM_PAINT() 24 | END_MESSAGE_MAP() 25 | 26 | // Constructor 27 | CWndSink::CWndSink() : CWnd() 28 | { 29 | // Create the window 30 | if (!CreateEx(0,AfxRegisterWndClass(0),_T("Window Notification Sink"),WS_OVERLAPPED,0,0,0,0,NULL,NULL)) 31 | DebugMsg("%s\n",TEXT("Failed to create a Window Notification Sink")); 32 | } 33 | 34 | // Destructor 35 | CWndSink::~CWndSink() 36 | { 37 | } 38 | 39 | // Create the window 40 | int CWndSink::OnCreate(LPCREATESTRUCT lpCreateStruct) 41 | { 42 | if (CWnd::OnCreate(lpCreateStruct) == -1) 43 | return -1; 44 | MoveWindow(0,0,0,0); 45 | return 0; 46 | } 47 | 48 | // Paint the window 49 | void CWndSink::OnPaint() 50 | { 51 | CPaintDC dc(this); 52 | } -------------------------------------------------------------------------------- /WndSink.h: -------------------------------------------------------------------------------- 1 | // Remote Desktop System - remote controlling of multiple PC's 2 | // Copyright (C) 2000-2009 GravyLabs LLC 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; version 2 of the License. 7 | 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | #pragma once 18 | 19 | #include "TCPSocket.h" 20 | #include "Common.h" 21 | 22 | //////////////////////////////////////////////////////////////////////////// 23 | // Window sink message class 24 | class CWndSink : public CWnd 25 | { 26 | // Construction 27 | public: 28 | CWndSink(); 29 | ~CWndSink(); 30 | 31 | // Generated message map functions 32 | protected: 33 | //{{AFX_MSG(CWndSink) 34 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 35 | afx_msg void OnPaint(); 36 | //}}AFX_MSG 37 | 38 | protected: 39 | // The client connectiun 40 | CTCPSocket m_Socket; 41 | 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | -------------------------------------------------------------------------------- /ZLib/UpgradeLog.XML: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ZLib/ZLib.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "ZLib.vcproj", "{BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|Win32.Build.0 = Debug|Win32 16 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|x64.ActiveCfg = Debug|x64 17 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Debug|x64.Build.0 = Debug|x64 18 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|Win32.ActiveCfg = Release|Win32 19 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|Win32.Build.0 = Release|Win32 20 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|x64.ActiveCfg = Release|x64 21 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /ZLib/ZLib.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {BF10D6F6-DC8A-48B7-BE94-F25B60CB6D5A} 23 | ZLib 24 | Win32Proj 25 | 26 | 27 | 28 | StaticLibrary 29 | v120 30 | Unicode 31 | true 32 | 33 | 34 | StaticLibrary 35 | v120 36 | Unicode 37 | 38 | 39 | StaticLibrary 40 | v120 41 | Unicode 42 | true 43 | 44 | 45 | StaticLibrary 46 | v120 47 | Unicode 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | <_ProjectFileVersion>12.0.21005.1 67 | 68 | 69 | $(SolutionDir)$(Configuration)\ 70 | $(Configuration)\ 71 | 72 | 73 | $(SolutionDir)$(Platform)\$(Configuration)\ 74 | $(Platform)\$(Configuration)\ 75 | 76 | 77 | $(SolutionDir)$(Configuration)\ 78 | $(Configuration)\ 79 | 80 | 81 | $(SolutionDir)$(Platform)\$(Configuration)\ 82 | $(Platform)\$(Configuration)\ 83 | 84 | 85 | 86 | Disabled 87 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 88 | true 89 | EnableFastChecks 90 | MultiThreadedDebug 91 | 92 | Level3 93 | EditAndContinue 94 | 95 | 96 | $(SolutionDir)\$(ProjectName)32d.lib 97 | 98 | 99 | 100 | 101 | X64 102 | 103 | 104 | Disabled 105 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 106 | true 107 | EnableFastChecks 108 | MultiThreadedDebug 109 | 110 | Level3 111 | ProgramDatabase 112 | 113 | 114 | $(SolutionDir)\$(ProjectName)64d.lib 115 | 116 | 117 | 118 | 119 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 120 | MultiThreaded 121 | 122 | Level3 123 | ProgramDatabase 124 | 125 | 126 | $(SolutionDir)\$(ProjectName)32.lib 127 | 128 | 129 | 130 | 131 | X64 132 | 133 | 134 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 135 | MultiThreaded 136 | 137 | Level3 138 | ProgramDatabase 139 | 140 | 141 | $(SolutionDir)\$(ProjectName)64.lib 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /ZLib/ZLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | -------------------------------------------------------------------------------- /ZLib/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2004 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | #define BASE 65521UL /* largest prime smaller than 65536 */ 12 | #define NMAX 5552 13 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 14 | 15 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 16 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 17 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 18 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 19 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 20 | 21 | /* use NO_DIVIDE if your processor does not do division in hardware */ 22 | #ifdef NO_DIVIDE 23 | # define MOD(a) \ 24 | do { \ 25 | if (a >= (BASE << 16)) a -= (BASE << 16); \ 26 | if (a >= (BASE << 15)) a -= (BASE << 15); \ 27 | if (a >= (BASE << 14)) a -= (BASE << 14); \ 28 | if (a >= (BASE << 13)) a -= (BASE << 13); \ 29 | if (a >= (BASE << 12)) a -= (BASE << 12); \ 30 | if (a >= (BASE << 11)) a -= (BASE << 11); \ 31 | if (a >= (BASE << 10)) a -= (BASE << 10); \ 32 | if (a >= (BASE << 9)) a -= (BASE << 9); \ 33 | if (a >= (BASE << 8)) a -= (BASE << 8); \ 34 | if (a >= (BASE << 7)) a -= (BASE << 7); \ 35 | if (a >= (BASE << 6)) a -= (BASE << 6); \ 36 | if (a >= (BASE << 5)) a -= (BASE << 5); \ 37 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 38 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 39 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 40 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 41 | if (a >= BASE) a -= BASE; \ 42 | } while (0) 43 | # define MOD4(a) \ 44 | do { \ 45 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 46 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 47 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 48 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 49 | if (a >= BASE) a -= BASE; \ 50 | } while (0) 51 | #else 52 | # define MOD(a) a %= BASE 53 | # define MOD4(a) a %= BASE 54 | #endif 55 | 56 | /* ========================================================================= */ 57 | uLong ZEXPORT adler32(adler, buf, len) 58 | uLong adler; 59 | const Bytef *buf; 60 | uInt len; 61 | { 62 | unsigned long sum2; 63 | unsigned n; 64 | 65 | /* split Adler-32 into component sums */ 66 | sum2 = (adler >> 16) & 0xffff; 67 | adler &= 0xffff; 68 | 69 | /* in case user likes doing a byte at a time, keep it fast */ 70 | if (len == 1) { 71 | adler += buf[0]; 72 | if (adler >= BASE) 73 | adler -= BASE; 74 | sum2 += adler; 75 | if (sum2 >= BASE) 76 | sum2 -= BASE; 77 | return adler | (sum2 << 16); 78 | } 79 | 80 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 81 | if (buf == Z_NULL) 82 | return 1L; 83 | 84 | /* in case short lengths are provided, keep it somewhat fast */ 85 | if (len < 16) { 86 | while (len--) { 87 | adler += *buf++; 88 | sum2 += adler; 89 | } 90 | if (adler >= BASE) 91 | adler -= BASE; 92 | MOD4(sum2); /* only added so many BASE's */ 93 | return adler | (sum2 << 16); 94 | } 95 | 96 | /* do length NMAX blocks -- requires just one modulo operation */ 97 | while (len >= NMAX) { 98 | len -= NMAX; 99 | n = NMAX / 16; /* NMAX is divisible by 16 */ 100 | do { 101 | DO16(buf); /* 16 sums unrolled */ 102 | buf += 16; 103 | } while (--n); 104 | MOD(adler); 105 | MOD(sum2); 106 | } 107 | 108 | /* do remaining bytes (less than NMAX, still just one modulo) */ 109 | if (len) { /* avoid modulos if none remaining */ 110 | while (len >= 16) { 111 | len -= 16; 112 | DO16(buf); 113 | buf += 16; 114 | } 115 | while (len--) { 116 | adler += *buf++; 117 | sum2 += adler; 118 | } 119 | MOD(adler); 120 | MOD(sum2); 121 | } 122 | 123 | /* return recombined sums */ 124 | return adler | (sum2 << 16); 125 | } 126 | 127 | /* ========================================================================= */ 128 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) 129 | uLong adler1; 130 | uLong adler2; 131 | z_off_t len2; 132 | { 133 | unsigned long sum1; 134 | unsigned long sum2; 135 | unsigned rem; 136 | 137 | /* the derivation of this formula is left as an exercise for the reader */ 138 | rem = (unsigned)(len2 % BASE); 139 | sum1 = adler1 & 0xffff; 140 | sum2 = rem * sum1; 141 | MOD(sum2); 142 | sum1 += (adler2 & 0xffff) + BASE - 1; 143 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 144 | if (sum1 > BASE) sum1 -= BASE; 145 | if (sum1 > BASE) sum1 -= BASE; 146 | if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); 147 | if (sum2 > BASE) sum2 -= BASE; 148 | return sum1 | (sum2 << 16); 149 | } 150 | -------------------------------------------------------------------------------- /ZLib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; 79 | } 80 | -------------------------------------------------------------------------------- /ZLib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /ZLib/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. It 6 | is part of the implementation of the compression library and 7 | is subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /ZLib/inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2004 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD, /* i: waiting for magic header */ 22 | FLAGS, /* i: waiting for method and flags (gzip) */ 23 | TIME, /* i: waiting for modification time (gzip) */ 24 | OS, /* i: waiting for extra flags and operating system (gzip) */ 25 | EXLEN, /* i: waiting for extra length (gzip) */ 26 | EXTRA, /* i: waiting for extra bytes (gzip) */ 27 | NAME, /* i: waiting for end of file name (gzip) */ 28 | COMMENT, /* i: waiting for end of comment (gzip) */ 29 | HCRC, /* i: waiting for header crc (gzip) */ 30 | DICTID, /* i: waiting for dictionary check value */ 31 | DICT, /* waiting for inflateSetDictionary() call */ 32 | TYPE, /* i: waiting for type bits, including last-flag bit */ 33 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 34 | STORED, /* i: waiting for stored size (length and complement) */ 35 | COPY, /* i/o: waiting for input or output to copy stored block */ 36 | TABLE, /* i: waiting for dynamic block table lengths */ 37 | LENLENS, /* i: waiting for code length code lengths */ 38 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 39 | LEN, /* i: waiting for length/lit code */ 40 | LENEXT, /* i: waiting for length extra bits */ 41 | DIST, /* i: waiting for distance code */ 42 | DISTEXT, /* i: waiting for distance extra bits */ 43 | MATCH, /* o: waiting for output space to copy string */ 44 | LIT, /* o: waiting for output space to write literal */ 45 | CHECK, /* i: waiting for 32-bit check value */ 46 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 47 | DONE, /* finished check, done -- remain here until reset */ 48 | BAD, /* got a data error -- remain here until reset */ 49 | MEM, /* got an inflate() memory error -- remain here until reset */ 50 | SYNC /* looking for synchronization bytes to restart inflate() */ 51 | } inflate_mode; 52 | 53 | /* 54 | State transitions between above modes - 55 | 56 | (most modes can go to the BAD or MEM mode -- not shown for clarity) 57 | 58 | Process header: 59 | HEAD -> (gzip) or (zlib) 60 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME 61 | NAME -> COMMENT -> HCRC -> TYPE 62 | (zlib) -> DICTID or TYPE 63 | DICTID -> DICT -> TYPE 64 | Read deflate blocks: 65 | TYPE -> STORED or TABLE or LEN or CHECK 66 | STORED -> COPY -> TYPE 67 | TABLE -> LENLENS -> CODELENS -> LEN 68 | Read deflate codes: 69 | LEN -> LENEXT or LIT or TYPE 70 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 71 | LIT -> LEN 72 | Process trailer: 73 | CHECK -> LENGTH -> DONE 74 | */ 75 | 76 | /* state maintained between inflate() calls. Approximately 7K bytes. */ 77 | struct inflate_state { 78 | inflate_mode mode; /* current inflate mode */ 79 | int last; /* true if processing last block */ 80 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 81 | int havedict; /* true if dictionary provided */ 82 | int flags; /* gzip header method and flags (0 if zlib) */ 83 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 84 | unsigned long check; /* protected copy of check value */ 85 | unsigned long total; /* protected copy of output count */ 86 | gz_headerp head; /* where to save gzip header information */ 87 | /* sliding window */ 88 | unsigned wbits; /* log base 2 of requested window size */ 89 | unsigned wsize; /* window size or zero if not using window */ 90 | unsigned whave; /* valid bytes in the window */ 91 | unsigned write; /* window write index */ 92 | unsigned char FAR *window; /* allocated sliding window, if needed */ 93 | /* bit accumulator */ 94 | unsigned long hold; /* input bit accumulator */ 95 | unsigned bits; /* number of bits in "in" */ 96 | /* for string and stored block copying */ 97 | unsigned length; /* literal or length of data to copy */ 98 | unsigned offset; /* distance back to copy string from */ 99 | /* for table and code decoding */ 100 | unsigned extra; /* extra bits needed */ 101 | /* fixed and dynamic code tables */ 102 | code const FAR *lencode; /* starting table for length/literal codes */ 103 | code const FAR *distcode; /* starting table for distance codes */ 104 | unsigned lenbits; /* index bits for lencode */ 105 | unsigned distbits; /* index bits for distcode */ 106 | /* dynamic table building */ 107 | unsigned ncode; /* number of code length code lengths */ 108 | unsigned nlen; /* number of length code lengths */ 109 | unsigned ndist; /* number of distance code lengths */ 110 | unsigned have; /* number of code lengths in lens[] */ 111 | code FAR *next; /* next available space in codes[] */ 112 | unsigned short lens[320]; /* temporary storage for code lengths */ 113 | unsigned short work[288]; /* work area for code table building */ 114 | code codes[ENOUGH]; /* space for code tables */ 115 | }; 116 | -------------------------------------------------------------------------------- /ZLib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- 39 | exhaustive search was 1444 code structures (852 for length/literals 40 | and 592 for distances, the latter actually the result of an 41 | exhaustive search). The true maximum is not known, but the value 42 | below is more than safe. */ 43 | #define ENOUGH 2048 44 | #define MAXD 592 45 | 46 | /* Type of code to build for inftable() */ 47 | typedef enum { 48 | CODES, 49 | LENS, 50 | DISTS 51 | } codetype; 52 | 53 | extern int inflate_table OF((codetype type, unsigned short FAR *lens, 54 | unsigned codes, code FAR * FAR *table, 55 | unsigned FAR *bits, unsigned short FAR *work)); 56 | -------------------------------------------------------------------------------- /ZLib/trees.h: -------------------------------------------------------------------------------- 1 | /* header created automatically with -DGEN_TREES_H */ 2 | 3 | local const ct_data static_ltree[L_CODES+2] = { 4 | {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, 5 | {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, 6 | {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, 7 | {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, 8 | {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, 9 | {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, 10 | {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, 11 | {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, 12 | {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, 13 | {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, 14 | {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, 15 | {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, 16 | {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, 17 | {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, 18 | {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, 19 | {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, 20 | {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, 21 | {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, 22 | {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, 23 | {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, 24 | {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, 25 | {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, 26 | {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, 27 | {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, 28 | {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, 29 | {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, 30 | {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, 31 | {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, 32 | {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, 33 | {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, 34 | {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, 35 | {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, 36 | {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, 37 | {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, 38 | {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, 39 | {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, 40 | {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, 41 | {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, 42 | {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, 43 | {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, 44 | {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, 45 | {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, 46 | {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, 47 | {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, 48 | {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, 49 | {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, 50 | {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, 51 | {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, 52 | {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, 53 | {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, 54 | {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, 55 | {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, 56 | {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, 57 | {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, 58 | {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, 59 | {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, 60 | {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, 61 | {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} 62 | }; 63 | 64 | local const ct_data static_dtree[D_CODES] = { 65 | {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, 66 | {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, 67 | {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, 68 | {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, 69 | {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, 70 | {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} 71 | }; 72 | 73 | const uch _dist_code[DIST_CODE_LEN] = { 74 | 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 75 | 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 76 | 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 77 | 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 78 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 79 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 80 | 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 81 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 82 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 83 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 84 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 85 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 86 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 87 | 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 88 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 89 | 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 90 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 91 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 92 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 93 | 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 94 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 95 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 96 | 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 97 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 98 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 99 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 100 | }; 101 | 102 | const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { 103 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 104 | 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 105 | 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 106 | 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 107 | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 108 | 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 109 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 110 | 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 111 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 112 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 113 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 114 | 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 115 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 116 | }; 117 | 118 | local const int base_length[LENGTH_CODES] = { 119 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 120 | 64, 80, 96, 112, 128, 160, 192, 224, 0 121 | }; 122 | 123 | local const int base_dist[D_CODES] = { 124 | 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 125 | 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 126 | 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 127 | }; 128 | 129 | -------------------------------------------------------------------------------- /ZLib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | This function can be used to decompress a whole file at once if the 20 | input file is mmap'ed. 21 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 23 | enough memory, Z_BUF_ERROR if there was not enough room in the output 24 | buffer, or Z_DATA_ERROR if the input data was corrupted. 25 | */ 26 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 27 | Bytef *dest; 28 | uLongf *destLen; 29 | const Bytef *source; 30 | uLong sourceLen; 31 | { 32 | z_stream stream; 33 | int err; 34 | 35 | stream.next_in = (Bytef*)source; 36 | stream.avail_in = (uInt)sourceLen; 37 | /* Check for source > 64K on 16-bit machine: */ 38 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 39 | 40 | stream.next_out = dest; 41 | stream.avail_out = (uInt)*destLen; 42 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 43 | 44 | stream.zalloc = (alloc_func)0; 45 | stream.zfree = (free_func)0; 46 | 47 | err = inflateInit(&stream); 48 | if (err != Z_OK) return err; 49 | 50 | err = inflate(&stream, Z_FINISH); 51 | if (err != Z_STREAM_END) { 52 | inflateEnd(&stream); 53 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 54 | return Z_DATA_ERROR; 55 | return err; 56 | } 57 | *destLen = stream.total_out; 58 | 59 | err = inflateEnd(&stream); 60 | return err; 61 | } 62 | -------------------------------------------------------------------------------- /ZLib/zlib.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; zlib data compression library 3 | 4 | EXPORTS 5 | ; basic functions 6 | zlibVersion 7 | deflate 8 | deflateEnd 9 | inflate 10 | inflateEnd 11 | ; advanced functions 12 | deflateSetDictionary 13 | deflateCopy 14 | deflateReset 15 | deflateParams 16 | deflateBound 17 | deflatePrime 18 | inflateSetDictionary 19 | inflateSync 20 | inflateCopy 21 | inflateReset 22 | inflateBack 23 | inflateBackEnd 24 | zlibCompileFlags 25 | ; utility functions 26 | compress 27 | compress2 28 | compressBound 29 | uncompress 30 | gzopen 31 | gzdopen 32 | gzsetparams 33 | gzread 34 | gzwrite 35 | gzprintf 36 | gzputs 37 | gzgets 38 | gzputc 39 | gzgetc 40 | gzungetc 41 | gzflush 42 | gzseek 43 | gzrewind 44 | gztell 45 | gzeof 46 | gzclose 47 | gzerror 48 | gzclearerr 49 | ; checksum functions 50 | adler32 51 | crc32 52 | ; various hacks, don't look :) 53 | deflateInit_ 54 | deflateInit2_ 55 | inflateInit_ 56 | inflateInit2_ 57 | inflateBackInit_ 58 | inflateSyncPoint 59 | get_crc_table 60 | zError 61 | -------------------------------------------------------------------------------- /ZLib/zutil.c: -------------------------------------------------------------------------------- 1 | /* zutil.c -- target dependent utility functions for the compression library 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #ifndef NO_DUMMY_DECL 11 | struct internal_state {int dummy;}; /* for buggy compilers */ 12 | #endif 13 | 14 | const char * const z_errmsg[10] = { 15 | "need dictionary", /* Z_NEED_DICT 2 */ 16 | "stream end", /* Z_STREAM_END 1 */ 17 | "", /* Z_OK 0 */ 18 | "file error", /* Z_ERRNO (-1) */ 19 | "stream error", /* Z_STREAM_ERROR (-2) */ 20 | "data error", /* Z_DATA_ERROR (-3) */ 21 | "insufficient memory", /* Z_MEM_ERROR (-4) */ 22 | "buffer error", /* Z_BUF_ERROR (-5) */ 23 | "incompatible version",/* Z_VERSION_ERROR (-6) */ 24 | ""}; 25 | 26 | 27 | const char * ZEXPORT zlibVersion() 28 | { 29 | return ZLIB_VERSION; 30 | } 31 | 32 | uLong ZEXPORT zlibCompileFlags() 33 | { 34 | uLong flags; 35 | 36 | flags = 0; 37 | switch (sizeof(uInt)) { 38 | case 2: break; 39 | case 4: flags += 1; break; 40 | case 8: flags += 2; break; 41 | default: flags += 3; 42 | } 43 | switch (sizeof(uLong)) { 44 | case 2: break; 45 | case 4: flags += 1 << 2; break; 46 | case 8: flags += 2 << 2; break; 47 | default: flags += 3 << 2; 48 | } 49 | switch (sizeof(voidpf)) { 50 | case 2: break; 51 | case 4: flags += 1 << 4; break; 52 | case 8: flags += 2 << 4; break; 53 | default: flags += 3 << 4; 54 | } 55 | switch (sizeof(z_off_t)) { 56 | case 2: break; 57 | case 4: flags += 1 << 6; break; 58 | case 8: flags += 2 << 6; break; 59 | default: flags += 3 << 6; 60 | } 61 | #ifdef DEBUG 62 | flags += 1 << 8; 63 | #endif 64 | #if defined(ASMV) || defined(ASMINF) 65 | flags += 1 << 9; 66 | #endif 67 | #ifdef ZLIB_WINAPI 68 | flags += 1 << 10; 69 | #endif 70 | #ifdef BUILDFIXED 71 | flags += 1 << 12; 72 | #endif 73 | #ifdef DYNAMIC_CRC_TABLE 74 | flags += 1 << 13; 75 | #endif 76 | #ifdef NO_GZCOMPRESS 77 | flags += 1L << 16; 78 | #endif 79 | #ifdef NO_GZIP 80 | flags += 1L << 17; 81 | #endif 82 | #ifdef PKZIP_BUG_WORKAROUND 83 | flags += 1L << 20; 84 | #endif 85 | #ifdef FASTEST 86 | flags += 1L << 21; 87 | #endif 88 | #ifdef STDC 89 | # ifdef NO_vsnprintf 90 | flags += 1L << 25; 91 | # ifdef HAS_vsprintf_void 92 | flags += 1L << 26; 93 | # endif 94 | # else 95 | # ifdef HAS_vsnprintf_void 96 | flags += 1L << 26; 97 | # endif 98 | # endif 99 | #else 100 | flags += 1L << 24; 101 | # ifdef NO_snprintf 102 | flags += 1L << 25; 103 | # ifdef HAS_sprintf_void 104 | flags += 1L << 26; 105 | # endif 106 | # else 107 | # ifdef HAS_snprintf_void 108 | flags += 1L << 26; 109 | # endif 110 | # endif 111 | #endif 112 | return flags; 113 | } 114 | 115 | #ifdef DEBUG 116 | 117 | # ifndef verbose 118 | # define verbose 0 119 | # endif 120 | int z_verbose = verbose; 121 | 122 | void z_error (m) 123 | char *m; 124 | { 125 | fprintf(stderr, "%s\n", m); 126 | exit(1); 127 | } 128 | #endif 129 | 130 | /* exported to allow conversion of error code to string for compress() and 131 | * uncompress() 132 | */ 133 | const char * ZEXPORT zError(err) 134 | int err; 135 | { 136 | return ERR_MSG(err); 137 | } 138 | 139 | #if defined(_WIN32_WCE) 140 | /* The Microsoft C Run-Time Library for Windows CE doesn't have 141 | * errno. We define it as a global variable to simplify porting. 142 | * Its value is always 0 and should not be used. 143 | */ 144 | int errno = 0; 145 | #endif 146 | 147 | #ifndef HAVE_MEMCPY 148 | 149 | void zmemcpy(dest, source, len) 150 | Bytef* dest; 151 | const Bytef* source; 152 | uInt len; 153 | { 154 | if (len == 0) return; 155 | do { 156 | *dest++ = *source++; /* ??? to be unrolled */ 157 | } while (--len != 0); 158 | } 159 | 160 | int zmemcmp(s1, s2, len) 161 | const Bytef* s1; 162 | const Bytef* s2; 163 | uInt len; 164 | { 165 | uInt j; 166 | 167 | for (j = 0; j < len; j++) { 168 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; 169 | } 170 | return 0; 171 | } 172 | 173 | void zmemzero(dest, len) 174 | Bytef* dest; 175 | uInt len; 176 | { 177 | if (len == 0) return; 178 | do { 179 | *dest++ = 0; /* ??? to be unrolled */ 180 | } while (--len != 0); 181 | } 182 | #endif 183 | 184 | 185 | #ifdef SYS16BIT 186 | 187 | #ifdef __TURBOC__ 188 | /* Turbo C in 16-bit mode */ 189 | 190 | # define MY_ZCALLOC 191 | 192 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes 193 | * and farmalloc(64K) returns a pointer with an offset of 8, so we 194 | * must fix the pointer. Warning: the pointer must be put back to its 195 | * original form in order to free it, use zcfree(). 196 | */ 197 | 198 | #define MAX_PTR 10 199 | /* 10*64K = 640K */ 200 | 201 | local int next_ptr = 0; 202 | 203 | typedef struct ptr_table_s { 204 | voidpf org_ptr; 205 | voidpf new_ptr; 206 | } ptr_table; 207 | 208 | local ptr_table table[MAX_PTR]; 209 | /* This table is used to remember the original form of pointers 210 | * to large buffers (64K). Such pointers are normalized with a zero offset. 211 | * Since MSDOS is not a preemptive multitasking OS, this table is not 212 | * protected from concurrent access. This hack doesn't work anyway on 213 | * a protected system like OS/2. Use Microsoft C instead. 214 | */ 215 | 216 | voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) 217 | { 218 | voidpf buf = opaque; /* just to make some compilers happy */ 219 | ulg bsize = (ulg)items*size; 220 | 221 | /* If we allocate less than 65520 bytes, we assume that farmalloc 222 | * will return a usable pointer which doesn't have to be normalized. 223 | */ 224 | if (bsize < 65520L) { 225 | buf = farmalloc(bsize); 226 | if (*(ush*)&buf != 0) return buf; 227 | } else { 228 | buf = farmalloc(bsize + 16L); 229 | } 230 | if (buf == NULL || next_ptr >= MAX_PTR) return NULL; 231 | table[next_ptr].org_ptr = buf; 232 | 233 | /* Normalize the pointer to seg:0 */ 234 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; 235 | *(ush*)&buf = 0; 236 | table[next_ptr++].new_ptr = buf; 237 | return buf; 238 | } 239 | 240 | void zcfree (voidpf opaque, voidpf ptr) 241 | { 242 | int n; 243 | if (*(ush*)&ptr != 0) { /* object < 64K */ 244 | farfree(ptr); 245 | return; 246 | } 247 | /* Find the original pointer */ 248 | for (n = 0; n < next_ptr; n++) { 249 | if (ptr != table[n].new_ptr) continue; 250 | 251 | farfree(table[n].org_ptr); 252 | while (++n < next_ptr) { 253 | table[n-1] = table[n]; 254 | } 255 | next_ptr--; 256 | return; 257 | } 258 | ptr = opaque; /* just to make some compilers happy */ 259 | Assert(0, "zcfree: ptr not found"); 260 | } 261 | 262 | #endif /* __TURBOC__ */ 263 | 264 | 265 | #ifdef M_I86 266 | /* Microsoft C in 16-bit mode */ 267 | 268 | # define MY_ZCALLOC 269 | 270 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) 271 | # define _halloc halloc 272 | # define _hfree hfree 273 | #endif 274 | 275 | voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) 276 | { 277 | if (opaque) opaque = 0; /* to make compiler happy */ 278 | return _halloc((long)items, size); 279 | } 280 | 281 | void zcfree (voidpf opaque, voidpf ptr) 282 | { 283 | if (opaque) opaque = 0; /* to make compiler happy */ 284 | _hfree(ptr); 285 | } 286 | 287 | #endif /* M_I86 */ 288 | 289 | #endif /* SYS16BIT */ 290 | 291 | 292 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ 293 | 294 | #ifndef STDC 295 | extern voidp malloc OF((uInt size)); 296 | extern voidp calloc OF((uInt items, uInt size)); 297 | extern void free OF((voidpf ptr)); 298 | #endif 299 | 300 | voidpf zcalloc (opaque, items, size) 301 | voidpf opaque; 302 | unsigned items; 303 | unsigned size; 304 | { 305 | if (opaque) items += size - size; /* make compiler happy */ 306 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : 307 | (voidpf)calloc(items, size); 308 | } 309 | 310 | void zcfree (opaque, ptr) 311 | voidpf opaque; 312 | voidpf ptr; 313 | { 314 | free(ptr); 315 | if (opaque) return; /* make compiler happy */ 316 | } 317 | 318 | #endif /* MY_ZCALLOC */ 319 | -------------------------------------------------------------------------------- /ZLib/zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #define ZLIB_INTERNAL 17 | #include "zlib.h" 18 | 19 | #ifdef STDC 20 | # ifndef _WIN32_WCE 21 | # include 22 | # endif 23 | # include 24 | # include 25 | #endif 26 | #ifdef NO_ERRNO_H 27 | # ifdef _WIN32_WCE 28 | /* The Microsoft C Run-Time Library for Windows CE doesn't have 29 | * errno. We define it as a global variable to simplify porting. 30 | * Its value is always 0 and should not be used. We rename it to 31 | * avoid conflict with other libraries that use the same workaround. 32 | */ 33 | # define errno z_errno 34 | # endif 35 | extern int errno; 36 | #else 37 | # ifndef _WIN32_WCE 38 | # include 39 | # endif 40 | #endif 41 | 42 | #ifndef local 43 | # define local static 44 | #endif 45 | /* compile with -Dlocal if your debugger can't find static symbols */ 46 | 47 | typedef unsigned char uch; 48 | typedef uch FAR uchf; 49 | typedef unsigned short ush; 50 | typedef ush FAR ushf; 51 | typedef unsigned long ulg; 52 | 53 | extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 54 | /* (size given to avoid silly warnings with Visual C++) */ 55 | 56 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 57 | 58 | #define ERR_RETURN(strm,err) \ 59 | return (strm->msg = (char*)ERR_MSG(err), (err)) 60 | /* To be used only when the state is known to be valid */ 61 | 62 | /* common constants */ 63 | 64 | #ifndef DEF_WBITS 65 | # define DEF_WBITS MAX_WBITS 66 | #endif 67 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 68 | 69 | #if MAX_MEM_LEVEL >= 8 70 | # define DEF_MEM_LEVEL 8 71 | #else 72 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 73 | #endif 74 | /* default memLevel */ 75 | 76 | #define STORED_BLOCK 0 77 | #define STATIC_TREES 1 78 | #define DYN_TREES 2 79 | /* The three kinds of block type */ 80 | 81 | #define MIN_MATCH 3 82 | #define MAX_MATCH 258 83 | /* The minimum and maximum match lengths */ 84 | 85 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 86 | 87 | /* target dependencies */ 88 | 89 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 90 | # define OS_CODE 0x00 91 | # if defined(__TURBOC__) || defined(__BORLANDC__) 92 | # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 93 | /* Allow compilation with ANSI keywords only enabled */ 94 | void _Cdecl farfree( void *block ); 95 | void *_Cdecl farmalloc( unsigned long nbytes ); 96 | # else 97 | # include 98 | # endif 99 | # else /* MSC or DJGPP */ 100 | # include 101 | # endif 102 | #endif 103 | 104 | #ifdef AMIGA 105 | # define OS_CODE 0x01 106 | #endif 107 | 108 | #if defined(VAXC) || defined(VMS) 109 | # define OS_CODE 0x02 110 | # define F_OPEN(name, mode) \ 111 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 112 | #endif 113 | 114 | #if defined(ATARI) || defined(atarist) 115 | # define OS_CODE 0x05 116 | #endif 117 | 118 | #ifdef OS2 119 | # define OS_CODE 0x06 120 | # ifdef M_I86 121 | #include 122 | # endif 123 | #endif 124 | 125 | #if defined(MACOS) || defined(TARGET_OS_MAC) 126 | # define OS_CODE 0x07 127 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 128 | # include /* for fdopen */ 129 | # else 130 | # ifndef fdopen 131 | # define fdopen(fd,mode) NULL /* No fdopen() */ 132 | # endif 133 | # endif 134 | #endif 135 | 136 | #ifdef TOPS20 137 | # define OS_CODE 0x0a 138 | #endif 139 | 140 | #ifdef WIN32 141 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 142 | # define OS_CODE 0x0b 143 | # endif 144 | #endif 145 | 146 | #ifdef __50SERIES /* Prime/PRIMOS */ 147 | # define OS_CODE 0x0f 148 | #endif 149 | 150 | #if defined(_BEOS_) || defined(RISCOS) 151 | # define fdopen(fd,mode) NULL /* No fdopen() */ 152 | #endif 153 | 154 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) 155 | # if defined(_WIN32_WCE) 156 | # define fdopen(fd,mode) NULL /* No fdopen() */ 157 | # ifndef _PTRDIFF_T_DEFINED 158 | typedef int ptrdiff_t; 159 | # define _PTRDIFF_T_DEFINED 160 | # endif 161 | # else 162 | # define fdopen(fd,type) _fdopen(fd,type) 163 | # endif 164 | #endif 165 | 166 | /* common defaults */ 167 | 168 | #ifndef OS_CODE 169 | # define OS_CODE 0x03 /* assume Unix */ 170 | #endif 171 | 172 | #ifndef F_OPEN 173 | # define F_OPEN(name, mode) fopen((name), (mode)) 174 | #endif 175 | 176 | /* functions */ 177 | 178 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 179 | # ifndef HAVE_VSNPRINTF 180 | # define HAVE_VSNPRINTF 181 | # endif 182 | #endif 183 | #if defined(__CYGWIN__) 184 | # ifndef HAVE_VSNPRINTF 185 | # define HAVE_VSNPRINTF 186 | # endif 187 | #endif 188 | #ifndef HAVE_VSNPRINTF 189 | # ifdef MSDOS 190 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 191 | but for now we just assume it doesn't. */ 192 | # define NO_vsnprintf 193 | # endif 194 | # ifdef __TURBOC__ 195 | # define NO_vsnprintf 196 | # endif 197 | # ifdef WIN32 198 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 199 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 200 | # define vsnprintf _vsnprintf 201 | # endif 202 | # endif 203 | # ifdef __SASC 204 | # define NO_vsnprintf 205 | # endif 206 | #endif 207 | #ifdef VMS 208 | # define NO_vsnprintf 209 | #endif 210 | 211 | #if defined(pyr) 212 | # define NO_MEMCPY 213 | #endif 214 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 215 | /* Use our own functions for small and medium model with MSC <= 5.0. 216 | * You may have to use the same strategy for Borland C (untested). 217 | * The __SC__ check is for Symantec. 218 | */ 219 | # define NO_MEMCPY 220 | #endif 221 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 222 | # define HAVE_MEMCPY 223 | #endif 224 | #ifdef HAVE_MEMCPY 225 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 226 | # define zmemcpy _fmemcpy 227 | # define zmemcmp _fmemcmp 228 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 229 | # else 230 | # define zmemcpy memcpy 231 | # define zmemcmp memcmp 232 | # define zmemzero(dest, len) memset(dest, 0, len) 233 | # endif 234 | #else 235 | extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 236 | extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 237 | extern void zmemzero OF((Bytef* dest, uInt len)); 238 | #endif 239 | 240 | /* Diagnostic functions */ 241 | #ifdef DEBUG 242 | # include 243 | extern int z_verbose; 244 | extern void z_error OF((char *m)); 245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 248 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 249 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 250 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 251 | #else 252 | # define Assert(cond,msg) 253 | # define Trace(x) 254 | # define Tracev(x) 255 | # define Tracevv(x) 256 | # define Tracec(c,x) 257 | # define Tracecv(c,x) 258 | #endif 259 | 260 | 261 | voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); 262 | void zcfree OF((voidpf opaque, voidpf ptr)); 263 | 264 | #define ZALLOC(strm, items, size) \ 265 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 266 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 267 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 268 | 269 | #endif /* ZUTIL_H */ 270 | --------------------------------------------------------------------------------