📄 clientconnection.h
字号:
// Buffer for network operations
void CheckBufferSize(int bufsize);
char *m_netbuf;
int m_netbufsize;
omni_mutex m_bufferMutex, m_zlibBufferMutex,
m_bitmapdcMutex, m_clipMutex,
m_writeMutex, m_sockMutex,m_cursorMutex, m_readMutex ;
// Buffer for zlib decompression.
void CheckZlibBufferSize(int bufsize);
unsigned char *m_zlibbuf;
int m_zlibbufsize;
// zlib decompression state
bool m_decompStreamInited;
z_stream m_decompStream;
z_stream m_decompStreamRaw;
z_stream m_decompStreamEncoded;
void CheckZipBufferSize(int bufsize);
unsigned char *m_zipbuf;
int m_zipbufsize;
// sf@2002 - v1.1.0 - Buffer for zip decompression (FileTransfer)
void CheckFileZipBufferSize(int bufsize);
unsigned char *m_filezipbuf;
int m_filezipbufsize;
void CheckFileChunkBufferSize(int bufsize);
unsigned char *m_filechunkbuf;
int m_filechunkbufsize;
// Variables used by tight encoding:
// Separate buffer for tight-compressed data.
char m_tightbuf[TIGHT_ZLIB_BUFFER_SIZE];
// Four independent compression streams for zlib library.
z_stream m_tightZlibStream[4];
bool m_tightZlibStreamActive[4];
// Tight filter stuff. Should be initialized by filter initialization code.
tightFilterFunc m_tightCurrentFilter;
bool m_tightCutZeros;
int m_tightRectWidth, m_tightRectColors;
COLORREF m_tightPalette[256];
CARD8 m_tightPrevRow[2048*3*sizeof(CARD16)];
//
// Bitmap for local copy of screen, and DC for writing to it.
HBITMAP m_hBitmap;
HDC m_hBitmapDC;
HPALETTE m_hPalette;
// Bitmap for cache copy of screen, and DC for writing to it.
HBITMAP m_hCacheBitmap;
HDC m_hCacheBitmapDC;
#ifdef UNDER_CE
// Under WinCE this points to the DIB pixels.
BYTE* m_bits;
#endif
// Keyboard mapper
KeyMap m_keymap;
// RFB settings
VNCOptions m_opts;
TextChatViewer *m_pTextChat; // Modif sf@2002 - Text Chat
// Modif sf@2002 - Data Stream Modification Plugin handling
int m_nTO;
bool m_fUsePlugin;
BYTE* m_pNetRectBuf;
bool m_fReadFromNetRectBuf; //
int m_nNetRectBufOffset;
int m_nReadSize;
int m_nNetRectBufSize;
BYTE* m_pZRLENetRectBuf;
bool m_fReadFromZRLENetRectBuf; //
int m_nZRLENetRectBufOffset;
int m_nZRLEReadSize;
int m_nZRLENetRectBufSize;
omni_mutex m_NetRectBufferMutex;
omni_mutex m_ZRLENetRectBufferMutex;
omni_mutex m_ZipBufferMutex;
omni_mutex m_FileZipBufferMutex;
omni_mutex m_FileChunkBufferMutex;
omni_mutex m_ZlibBufferMutex;
TCHAR *m_desktopName;
unsigned char m_encPasswd[8];
unsigned char m_encPasswdMs[32];
char m_clearPasswd[256]; // Modif sf@2002
rfbServerInitMsg m_si;
rfbPixelFormat m_myFormat, m_pendingFormat, m_newFormat;
// protocol version in use.
int m_majorVersion, m_minorVersion;
bool m_threadStarted, m_running;
// mid-connection format change requested
// sf@2002 - v1.1.0
bool m_pendingFormatChange;
bool m_pendingScaleChange;
bool m_pendingCacheInit;
// Window may be scrollable - these control the scroll position
int m_hScrollPos, m_hScrollMax, m_vScrollPos, m_vScrollMax;
// The current window size
int m_winwidth, m_winheight;
// connection throughput estimation
__int64 m_BytesSend;
int minKB;
int maxKB;
__int64 sumKB;
int nrKB;
//HANDLE m_bitmapFRONT,m_bitmapBACK,m_bitmapNONE,m_logo_min;
// The size of the current client area
int m_cliwidth, m_cliheight;
// The size of a window needed to hold entire screen without scrollbars
int m_fullwinwidth, m_fullwinheight;
// The size of the CE CommandBar
int m_barheight;
// Dormant basically means minimized; updates will not be requested
// while dormant.
void SetDormant(bool newstate);
bool m_dormant;
// The number of bytes required to hold at least one pixel.
unsigned int m_minPixelBytes;
// Next window in clipboard chain
HWND m_hwndNextViewer;
bool m_initialClipboardSeen;
// Are we waiting on a timer for emulating three buttons?
bool m_waitingOnEmulateTimer;
// Or are we emulating the middle button now?
bool m_emulatingMiddleButton;
// Emulate 3 buttons mouse timer:
UINT m_emulate3ButtonsTimer;
// Buttons pressed, waiting for timer in emulating 3 buttons:
DWORD m_emulateKeyFlags;
int m_emulateButtonPressedX;
int m_emulateButtonPressedY;
#ifndef ROVNC
// BmpFlasher *flash;
#endif
// ms logon
BOOL m_ms_logon;
char m_ad_passwd[256];
char m_ad_domain[256];
char m_ad_user[256];
// sf@2002 - FileTRansfer on server
BOOL m_fServerIsUltra;
BOOL m_fServerKnowsFileTransfer;
bool m_ClosedByRemote;
// sf@2002 - Auto mode
int m_nConfig;
// sf@2002 - Options Window flag
BOOL m_fOptionsOpen;
int m_nStatusTimer;
int oldPointerX, oldPointerY, oldButtonMask;
int kbitsPerSecond;
DWORD m_lLastChangeTime; // sf@2003 - Last time the Auto mode has changed the encoding
bool m_fScalingDone; // sf@2003 - Auto Scaling flag
rdr::FdInStream* fis;
rdr::ZlibInStream* zis;
void zrleDecode(int x, int y, int w, int h);
void zrleDecode8(int x, int y, int w, int h, rdr::InStream* is,
rdr::ZlibInStream* zis, rdr::U8* buf);
void zrleDecode16(int x, int y, int w, int h, rdr::InStream* is,
rdr::ZlibInStream* zis, rdr::U16* buf);
void zrleDecode24A(int x, int y, int w, int h, rdr::InStream* is,
rdr::ZlibInStream* zis, rdr::U32* buf);
void zrleDecode24B(int x, int y, int w, int h, rdr::InStream* is,
rdr::ZlibInStream* zis, rdr::U32* buf);
void zrleDecode32(int x, int y, int w, int h, rdr::InStream* is,
rdr::ZlibInStream* zis, rdr::U32* buf);
// TR@2003
BOOL m_ServerKnowsModeChange;
BOOL modeChangeRequested; // Ab Anforderung Richtungswechsel werden wg. Syncronisation keine Kommandos mehr verschickt
BOOL keepSocket; // Bei 躡ergabe der Verbindung durch Richtungswechsel Socket nicht schlie遝n
//UltraFast
void ConvertAll(int width, int height, int xx, int yy,int bytes_per_pixel,BYTE* source,BYTE* dest,int framebufferWidth);
void SolidColor(int width, int height, int xx, int yy,int bytes_per_pixel,BYTE* source,BYTE* dest,int framebufferWidth);
HDC m_hmemdc;
HBITMAP m_membitmap;
VOID *m_DIBbits;
bool UltraFast;
void ClientConnection::Createdib();
bool Check_Rectangle_borders(int x,int y,int w,int h);
BOOL m_BigToolbar;
DWORD newtick;
DWORD oldtick;
bool Pressed_Cancel;
ConnectionType m_ConnectionType;
// Lizard - stall avoidance
// MousePointerMotionDelayThread *mpmd_thread;
// End Lizard
HBITMAP m_bmpToolbarBackground;
HBITMAP m_bmpToolbarHandle;
HBITMAP m_bmpToolbarHandleClosed;
string GetRemoteIdentity();
bool m_fHasSingleWindow;
string m_WindowTitle;
int m_moveToolbar;
HINSTANCE m_msimg;
AlphaBlendFn m_AlphaBlend;
HWND m_SecureDesktopDialog;
void CenterSecureDesktopDialog();
};
// Some handy classes for temporary GDI object selection
// These select objects when constructed and automatically release them when destructed.
class ObjectSelector {
public:
ObjectSelector(HDC hdc, HGDIOBJ hobj) { m_hdc = hdc; m_hOldObj = SelectObject(hdc, hobj); }
~ObjectSelector() { m_hOldObj = SelectObject(m_hdc, m_hOldObj); }
HGDIOBJ m_hOldObj;
HDC m_hdc;
};
class PaletteSelector {
public:
PaletteSelector(HDC hdc, HPALETTE hpal) {
m_hdc = hdc;
if (hpal)
{
m_hOldPal = SelectPalette(hdc, hpal, FALSE);
RealizePalette(hdc);
}
else
m_hOldPal = NULL;
}
~PaletteSelector() {
if(m_hOldPal)
{
m_hOldPal = SelectPalette(m_hdc, m_hOldPal, FALSE);
RealizePalette(m_hdc);
}
}
HPALETTE m_hOldPal;
HDC m_hdc;
};
class TempDC {
public:
TempDC(HWND hwnd) { m_hdc = GetDC(hwnd); m_hwnd = hwnd; }
~TempDC() { ReleaseDC(m_hwnd, m_hdc); }
operator HDC() {return m_hdc;};
HDC m_hdc;
HWND m_hwnd;
};
// Colour decoding utility functions
// Define rs,rm, bs,bm, gs & gm before using, eg with the following:
// read a pixel from the given address, and return a color value
#define SETUP_COLOR_SHORTCUTS \
CARD8 rs = m_myFormat.redShift; CARD16 rm = m_myFormat.redMax; \
CARD8 gs = m_myFormat.greenShift; CARD16 gm = m_myFormat.greenMax; \
CARD8 bs = m_myFormat.blueShift; CARD16 bm = m_myFormat.blueMax; \
#define COLOR_FROM_PIXEL8_ADDRESS(p) (PALETTERGB( \
(int) (((*(CARD8 *)(p) >> rs) & rm) * 255 / rm), \
(int) (((*(CARD8 *)(p) >> gs) & gm) * 255 / gm), \
(int) (((*(CARD8 *)(p) >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL16_ADDRESS(p) (PALETTERGB( \
(int) ((( *(CARD16 *)(p) >> rs) & rm) * 255 / rm), \
(int) ((( *(CARD16 *)(p) >> gs) & gm) * 255 / gm), \
(int) ((( *(CARD16 *)(p) >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL24_ADDRESS(p) (PALETTERGB( \
(int) (((CARD8 *)(p))[0]), \
(int) (((CARD8 *)(p))[1]), \
(int) (((CARD8 *)(p))[2]) ))
#define COLOR_FROM_PIXEL32_ADDRESS(p) (PALETTERGB( \
(int) ((( *(CARD32 *)(p) >> rs) & rm) * 255 / rm), \
(int) ((( *(CARD32 *)(p) >> gs) & gm) * 255 / gm), \
(int) ((( *(CARD32 *)(p) >> bs) & bm) * 255 / bm) ))
// The following may be faster if you already have a pixel value of the appropriate size
#define COLOR_FROM_PIXEL8(p) (PALETTERGB( \
(int) (((p >> rs) & rm) * 255 / rm), \
(int) (((p >> gs) & gm) * 255 / gm), \
(int) (((p >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL16(p) (PALETTERGB( \
(int) ((( p >> rs) & rm) * 255 / rm), \
(int) ((( p >> gs) & gm) * 255 / gm), \
(int) ((( p >> bs) & bm) * 255 / bm) ))
#define COLOR_FROM_PIXEL32(p) (PALETTERGB( \
(int) (((p >> rs) & rm) * 255 / rm), \
(int) (((p >> gs) & gm) * 255 / gm), \
(int) (((p >> bs) & bm) * 255 / bm) ))
#ifdef UNDER_CE
#define SETPIXEL(b,x,y,c) SetPixel((b),(x),(y),(c))
#else
#define SETPIXEL(b,x,y,c) SetPixelV((b),(x),(y),(c))
#endif
#define SETPIXELS(buffer, bpp, x, y, w, h) \
{ \
CARD##bpp *p = (CARD##bpp *) buffer; \
register CARD##bpp pix; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
pix = *p; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix)); \
p++; \
} \
} \
}
#define SETPIXELS_NOCONV(buffer, x, y, w, h) \
{ \
CARD32 *p = (CARD32 *) buffer; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
SETPIXEL(m_hBitmapDC, j,k, *p); \
p++; \
} \
} \
}
#define SETXORPIXELS(mask,buffer, bpp, x, y, w, h,aantal) \
{ \
CARD##bpp *p = (CARD##bpp *) buffer; \
register CARD##bpp pix; \
int i=0; \
bool result; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
MYMASK(mask,i,result); \
if (result) \
{ \
pix = *p; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix)); \
p++; \
aantal++; \
} \
i++; \
} \
} \
}
#define SETXORSOLPIXELS(mask,buffer, color, bpp, x, y, w, h) \
{ \
CARD##bpp *p = (CARD##bpp *) buffer; \
CARD##bpp *pc = (CARD##bpp *) color; \
register CARD##bpp pix; \
int i=0; \
bool result; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
MYMASK(mask,i,result); \
if (result) \
{ \
pix = *p; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix)); \
p++; \
} \
else \
{ \
pix = *pc; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix));\
} \
i++; \
} \
} \
}
#define SETXORMONOPIXELS(mask,color2, color, bpp, x, y, w, h) \
{ \
CARD##bpp *pc2 = (CARD##bpp *) color2; \
CARD##bpp *pc = (CARD##bpp *) color; \
register CARD##bpp pix; \
int i=0; \
bool result; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
MYMASK(mask,i,result); \
if (result) \
{ \
pix = *pc2; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix)); \
} \
else \
{ \
pix = *pc; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix));\
} \
i++; \
} \
} \
}
#define SETSOLPIXELS(color, bpp, x, y, w, h) \
{ \
CARD##bpp *pc = (CARD##bpp *) color; \
register CARD##bpp pix; \
int i=0; \
for (int k = y; k < y+h; k++) { \
for (int j = x; j < x+w; j++) { \
pix = *pc; \
SETPIXEL(m_hBitmapDC, j,k, COLOR_FROM_PIXEL##bpp##(pix));\
i++; \
} \
} \
}
#define MYMASK(mask,i,result) \
{ \
int byte_nr,bit_nr; \
byte_nr=i/8; \
bit_nr=i%8; \
if (bit_nr==0) result=mask[byte_nr].b0; \
if (bit_nr==1) result=mask[byte_nr].b1; \
if (bit_nr==2) result=mask[byte_nr].b2; \
if (bit_nr==3) result=mask[byte_nr].b3; \
if (bit_nr==4) result=mask[byte_nr].b4; \
if (bit_nr==5) result=mask[byte_nr].b5; \
if (bit_nr==6) result=mask[byte_nr].b6; \
if (bit_nr==7) result=mask[byte_nr].b7; \
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -