CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/vncdll/winvnc/common.h
Views: 11779
1
#ifndef _COMMON_H
2
#define _COMMON_H
3
4
#define WIN32_LEAN_AND_MEAN
5
#include <winsock2.h>
6
#include <windows.h>
7
#include <stdio.h>
8
9
//#define DEBUGTRACE
10
11
#ifdef DEBUGTRACE
12
#include <stdlib.h>
13
#define dprintf(...) real_dprintf(__VA_ARGS__)
14
#ifndef DPRINTF
15
#define DPRINTF
16
static void real_dprintf(char *format, ...) {
17
va_list args;
18
char buffer[1024];
19
FILE * fp = fopen("c:\\debug_log_vncdll.txt","a");
20
va_start(args,format);
21
vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer)-3, format,args);
22
strcat_s(buffer, sizeof(buffer), "\r\n\x00");
23
if(fp)
24
{
25
fputs( buffer, fp );
26
fclose(fp);
27
}
28
OutputDebugString(buffer);
29
}
30
#endif
31
#else
32
#define dprintf(...) do{}while(0);
33
#endif
34
35
// Simple macro to close a handle and set the handle to NULL.
36
#define CLOSE_HANDLE( h ) if( h ) { CloseHandle( h ); h = NULL; }
37
38
#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }
39
#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d", str, dwResult ); break; }
40
#define BREAK_ON_WSAERROR( str ) { dwResult = WSAGetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }
41
42
typedef struct _PIXELFORMAT
43
{
44
BYTE bpp;
45
BYTE depth;
46
BYTE bigendian;
47
BYTE truecolour;
48
WORD redmax;
49
WORD greenmax;
50
WORD bluemax;
51
BYTE redshift;
52
BYTE greenshift;
53
BYTE blueshift;
54
BYTE pad1;
55
WORD pad2;
56
} PIXELFORMAT;
57
58
/*typedef struct _DICTMSG
59
{
60
DWORD dwId;
61
DWORD dwDictLength;
62
BYTE bDictBuffer[1];
63
} DICTMSG;*/
64
65
/*
66
* The context used for the agent to keep the vnc stream back to the client consistent during session switching.
67
*/
68
typedef struct _AGENT_CTX
69
{
70
// The WSAPROTOCOL_INFO structure for the socket back to the client.
71
WSAPROTOCOL_INFO info;
72
// Flag to disable the creation of a courtesy shell on the input desktop.
73
BOOL bDisableCourtesyShell;
74
// The event to terminate the vnc agent.
75
HANDLE hCloseEvent;
76
// A flag to force only the first agent instance to perform the RFB initilization.
77
BOOL bInit;
78
// The encoding used by the last agent, we can then force the next agent to keep using
79
// the last known encoding in order to keep the remote client's RFB stream consistent.
80
DWORD dwEncoding;
81
// A hex value used for the loaders pipe server
82
DWORD dwPipeName;
83
// The rfb streams current pixel format.
84
PIXELFORMAT PixelFormat;
85
// Various settings for the rfb stream.
86
DWORD dwCompressLevel;
87
DWORD dwQualityLevel;
88
BOOL bUseCopyRect;
89
BOOL bEncodingRichCursor;
90
BOOL bEncodingPointerPos;
91
BOOL bEncodingLastRect;
92
BOOL bEncodingNewfbSize;
93
BOOL bEncodingXCursor;
94
//DICTMSG * dictionaries[4];
95
} AGENT_CTX, * LPAGENT_CTX;
96
97
#define MESSAGE_SETENCODING 0x28471649
98
#define MESSAGE_SETPIXELFORMAT 0x92785926
99
#define MESSAGE_SETCOMPRESSLEVEL 0x82658926
100
#define MESSAGE_SETQUALITYLEVEL 0x31857295
101
#define MESSAGE_SETCOPYRECTUSE 0x91748275
102
#define MESSAGE_SETENCODINGRICHCURSOR 0x39185037
103
#define MESSAGE_SETENCODINGPOINTERPOS 0x47295620
104
#define MESSAGE_SETENCODINGLASTRECT 0x11984659
105
#define MESSAGE_SETENCODINGNEWFBSIZE 0x94856345
106
#define MESSAGE_SETENCODINGXCURSOR 0x81659265
107
#define MESSAGE_SETZLIBDICTIONARY 0x91601668
108
109
#endif
110