1 /**
2  * FreeRDP: A Remote Desktop Protocol Implementation
3  * Error Info
4  *
5  * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include <stdio.h>
25 
26 #include <freerdp/log.h>
27 
28 #include "errinfo.h"
29 
30 #define TAG FREERDP_TAG("core")
31 
32 #define ERRINFO_DEFINE(_code, category)                                        \
33 	{                                                                          \
34 		ERRINFO_##_code, "ERRINFO_" #_code, ERRINFO_##_code##_STRING, category \
35 	}
36 
37 #if !defined(DEFINE_NO_DEPRECATED)
38 int connectErrorCode;
39 #endif
40 
41 /* Protocol-independent codes */
42 
43 #define ERRINFO_RPC_INITIATED_DISCONNECT_STRING \
44 	"The disconnection was initiated by an administrative tool on the server in another session."
45 
46 #define ERRINFO_RPC_INITIATED_LOGOFF_STRING                                                    \
47 	"The disconnection was due to a forced logoff initiated by an administrative tool on the " \
48 	"server in another session."
49 
50 #define ERRINFO_IDLE_TIMEOUT_STRING "The idle session limit timer on the server has elapsed."
51 
52 #define ERRINFO_LOGON_TIMEOUT_STRING "The active session limit timer on the server has elapsed."
53 
54 #define ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION_STRING \
55 	"Another user connected to the server, forcing the disconnection of the current connection."
56 
57 #define ERRINFO_OUT_OF_MEMORY_STRING "The server ran out of available memory resources."
58 
59 #define ERRINFO_SERVER_DENIED_CONNECTION_STRING "The server denied the connection."
60 
61 #define ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES_STRING \
62 	"The user cannot connect to the server due to insufficient access privileges."
63 
64 #define ERRINFO_SERVER_FRESH_CREDENTIALS_REQUIRED_STRING                                        \
65 	"The server does not accept saved user credentials and requires that the user enter their " \
66 	"credentials for each connection."
67 
68 #define ERRINFO_RPC_INITIATED_DISCONNECT_BY_USER_STRING                                       \
69 	"The disconnection was initiated by an administrative tool on the server running in the " \
70 	"user's session."
71 
72 #define ERRINFO_LOGOFF_BY_USER_STRING \
73 	"The disconnection was initiated by the user logging off their session on the server."
74 
75 #define ERRINFO_CLOSE_STACK_ON_DRIVER_NOT_READY_STRING                                             \
76 	"The display driver in the remote session did not report any status within the time allotted " \
77 	"for startup."
78 
79 #define ERRINFO_SERVER_DWM_CRASH_STRING \
80 	"The DWM process running in the remote session terminated unexpectedly."
81 
82 #define ERRINFO_CLOSE_STACK_ON_DRIVER_FAILURE_STRING                                              \
83 	"The display driver in the remote session was unable to complete all the tasks required for " \
84 	"startup."
85 
86 #define ERRINFO_CLOSE_STACK_ON_DRIVER_IFACE_FAILURE_STRING                                   \
87 	"The display driver in the remote session started up successfully, but due to internal " \
88 	"failures was not usable by the remoting stack."
89 
90 #define ERRINFO_SERVER_WINLOGON_CRASH_STRING \
91 	"The Winlogon process running in the remote session terminated unexpectedly."
92 
93 #define ERRINFO_SERVER_CSRSS_CRASH_STRING \
94 	"The CSRSS process running in the remote session terminated unexpectedly."
95 
96 /* Protocol-independent codes generated by the Connection Broker */
97 
98 #define ERRINFO_CB_DESTINATION_NOT_FOUND_STRING "The target endpoint could not be found."
99 
100 #define ERRINFO_CB_LOADING_DESTINATION_STRING                                                \
101 	"The target endpoint to which the client is being redirected is disconnecting from the " \
102 	"Connection Broker."
103 
104 #define ERRINFO_CB_REDIRECTING_TO_DESTINATION_STRING \
105 	"An error occurred while the connection was being redirected to the target endpoint."
106 
107 #define ERRINFO_CB_SESSION_ONLINE_VM_WAKE_STRING \
108 	"An error occurred while the target endpoint (a virtual machine) was being awakened."
109 
110 #define ERRINFO_CB_SESSION_ONLINE_VM_BOOT_STRING \
111 	"An error occurred while the target endpoint (a virtual machine) was being started."
112 
113 #define ERRINFO_CB_SESSION_ONLINE_VM_NO_DNS_STRING \
114 	"The IP address of the target endpoint (a virtual machine) cannot be determined."
115 
116 #define ERRINFO_CB_DESTINATION_POOL_NOT_FREE_STRING \
117 	"There are no available endpoints in the pool managed by the Connection Broker."
118 
119 #define ERRINFO_CB_CONNECTION_CANCELLED_STRING "Processing of the connection has been cancelled."
120 
121 #define ERRINFO_CB_CONNECTION_ERROR_INVALID_SETTINGS_STRING                                 \
122 	"The settings contained in the routingToken field of the X.224 Connection Request PDU " \
123 	"(section 2.2.1.1) cannot be validated."
124 
125 #define ERRINFO_CB_SESSION_ONLINE_VM_BOOT_TIMEOUT_STRING \
126 	"A time-out occurred while the target endpoint (a virtual machine) was being started."
127 
128 #define ERRINFO_CB_SESSION_ONLINE_VM_SESSMON_FAILED_STRING                                         \
129 	"A session monitoring error occurred while the target endpoint (a virtual machine) was being " \
130 	"started."
131 
132 /* Protocol-independent licensing codes */
133 
134 #define ERRINFO_LICENSE_INTERNAL_STRING \
135 	"An internal error has occurred in the Terminal Services licensing component."
136 
137 #define ERRINFO_LICENSE_NO_LICENSE_SERVER_STRING                                                 \
138 	"A Remote Desktop License Server ([MS-RDPELE] section 1.1) could not be found to provide a " \
139 	"license."
140 
141 #define ERRINFO_LICENSE_NO_LICENSE_STRING                                                     \
142 	"There are no Client Access Licenses ([MS-RDPELE] section 1.1) available for the target " \
143 	"remote computer."
144 
145 #define ERRINFO_LICENSE_BAD_CLIENT_MSG_STRING \
146 	"The remote computer received an invalid licensing message from the client."
147 
148 #define ERRINFO_LICENSE_HWID_DOESNT_MATCH_LICENSE_STRING \
149 	"The Client Access License ([MS-RDPELE] section 1.1) stored by the client has been modified."
150 
151 #define ERRINFO_LICENSE_BAD_CLIENT_LICENSE_STRING                                                \
152 	"The Client Access License ([MS-RDPELE] section 1.1) stored by the client is in an invalid " \
153 	"format."
154 
155 #define ERRINFO_LICENSE_CANT_FINISH_PROTOCOL_STRING                                          \
156 	"Network problems have caused the licensing protocol ([MS-RDPELE] section 1.3.3) to be " \
157 	"terminated."
158 
159 #define ERRINFO_LICENSE_CLIENT_ENDED_PROTOCOL_STRING \
160 	"The client prematurely ended the licensing protocol ([MS-RDPELE] section 1.3.3)."
161 
162 #define ERRINFO_LICENSE_BAD_CLIENT_ENCRYPTION_STRING \
163 	"A licensing message ([MS-RDPELE] sections 2.2 and 5.1) was incorrectly encrypted."
164 
165 #define ERRINFO_LICENSE_CANT_UPGRADE_LICENSE_STRING                                          \
166 	"The Client Access License ([MS-RDPELE] section 1.1) stored by the client could not be " \
167 	"upgraded or renewed."
168 
169 #define ERRINFO_LICENSE_NO_REMOTE_CONNECTIONS_STRING \
170 	"The remote computer is not licensed to accept remote connections."
171 
172 /* RDP specific codes */
173 
174 #define ERRINFO_UNKNOWN_DATA_PDU_TYPE_STRING \
175 	"Unknown pduType2 field in a received Share Data Header (section 2.2.8.1.1.1.2)."
176 
177 #define ERRINFO_UNKNOWN_PDU_TYPE_STRING \
178 	"Unknown pduType field in a received Share Control Header (section 2.2.8.1.1.1.1)."
179 
180 #define ERRINFO_DATA_PDU_SEQUENCE_STRING \
181 	"An out-of-sequence Slow-Path Data PDU (section 2.2.8.1.1.1.1) has been received."
182 
183 #define ERRINFO_CONTROL_PDU_SEQUENCE_STRING \
184 	"An out-of-sequence Slow-Path Non-Data PDU (section 2.2.8.1.1.1.1) has been received."
185 
186 #define ERRINFO_INVALID_CONTROL_PDU_ACTION_STRING                                              \
187 	"A Control PDU (sections 2.2.1.15 and 2.2.1.16) has been received with an invalid action " \
188 	"field."
189 
190 #define ERRINFO_INVALID_INPUT_PDU_TYPE_STRING                                                  \
191 	"(a) A Slow-Path Input Event (section 2.2.8.1.1.3.1.1) has been received with an invalid " \
192 	"messageType field.\n"                                                                     \
193 	"(b) A Fast-Path Input Event (section 2.2.8.1.2.2) has been received with an invalid "     \
194 	"eventCode field."
195 
196 #define ERRINFO_INVALID_INPUT_PDU_MOUSE_STRING                                               \
197 	"(a) A Slow-Path Mouse Event (section 2.2.8.1.1.3.1.1.3) or Extended Mouse Event "       \
198 	"(section 2.2.8.1.1.3.1.1.4) has been received with an invalid pointerFlags field.\n"    \
199 	"(b) A Fast-Path Mouse Event (section 2.2.8.1.2.2.3) or Fast-Path Extended Mouse Event " \
200 	"(section 2.2.8.1.2.2.4) has been received with an invalid pointerFlags field."
201 
202 #define ERRINFO_INVALID_REFRESH_RECT_PDU_STRING \
203 	"An invalid Refresh Rect PDU (section 2.2.11.2) has been received."
204 
205 #define ERRINFO_CREATE_USER_DATA_FAILED_STRING                                              \
206 	"The server failed to construct the GCC Conference Create Response user data (section " \
207 	"2.2.1.4)."
208 
209 #define ERRINFO_CONNECT_FAILED_STRING                                                \
210 	"Processing during the Channel Connection phase of the RDP Connection Sequence " \
211 	"(see section 1.3.1.1 for an overview of the RDP Connection Sequence phases) has failed."
212 
213 #define ERRINFO_CONFIRM_ACTIVE_HAS_WRONG_SHAREID_STRING                                       \
214 	"A Confirm Active PDU (section 2.2.1.13.2) was received from the client with an invalid " \
215 	"shareId field."
216 
217 #define ERRINFO_CONFIRM_ACTIVE_HAS_WRONG_ORIGINATOR_STRING                                    \
218 	"A Confirm Active PDU (section 2.2.1.13.2) was received from the client with an invalid " \
219 	"originatorId field."
220 
221 #define ERRINFO_PERSISTENT_KEY_PDU_BAD_LENGTH_STRING \
222 	"There is not enough data to process a Persistent Key List PDU (section 2.2.1.17)."
223 
224 #define ERRINFO_PERSISTENT_KEY_PDU_ILLEGAL_FIRST_STRING                                    \
225 	"A Persistent Key List PDU (section 2.2.1.17) marked as PERSIST_PDU_FIRST (0x01) was " \
226 	"received after the reception "                                                        \
227 	"of a prior Persistent Key List PDU also marked as PERSIST_PDU_FIRST."
228 
229 #define ERRINFO_PERSISTENT_KEY_PDU_TOO_MANY_TOTAL_KEYS_STRING                                      \
230 	"A Persistent Key List PDU (section 2.2.1.17) was received which specified a total number of " \
231 	"bitmap cache entries larger than 262144."
232 
233 #define ERRINFO_PERSISTENT_KEY_PDU_TOO_MANY_CACHE_KEYS_STRING                                     \
234 	"A Persistent Key List PDU (section 2.2.1.17) was received which specified an invalid total " \
235 	"number of keys for a bitmap cache "                                                          \
236 	"(the number of entries that can be stored within each bitmap cache is specified in the "     \
237 	"Revision 1 or 2 Bitmap Cache Capability Set "                                                \
238 	"(section 2.2.7.1.4) that is sent from client to server)."
239 
240 #define ERRINFO_INPUT_PDU_BAD_LENGTH_STRING                                                  \
241 	"There is not enough data to process Input Event PDU Data (section 2.2.8.1.1.3.1) or a " \
242 	"Fast-Path Input Event PDU (section 2.2.8.1.2)."
243 
244 #define ERRINFO_BITMAP_CACHE_ERROR_PDU_BAD_LENGTH_STRING                       \
245 	"There is not enough data to process the shareDataHeader, NumInfoBlocks, " \
246 	"Pad1, and Pad2 fields of the Bitmap Cache Error PDU Data ([MS-RDPEGDI] section 2.2.2.3.1.1)."
247 
248 #define ERRINFO_SECURITY_DATA_TOO_SHORT_STRING                                                    \
249 	"(a) The dataSignature field of the Fast-Path Input Event PDU (section 2.2.8.1.2) does not "  \
250 	"contain enough data.\n"                                                                      \
251 	"(b) The fipsInformation and dataSignature fields of the Fast-Path Input Event PDU (section " \
252 	"2.2.8.1.2) do not contain enough data."
253 
254 #define ERRINFO_VCHANNEL_DATA_TOO_SHORT_STRING                                                 \
255 	"(a) There is not enough data in the Client Network Data (section 2.2.1.3.4) to read the " \
256 	"virtual channel configuration data.\n"                                                    \
257 	"(b) There is not enough data to read a complete Channel PDU Header (section 2.2.6.1.1)."
258 
259 #define ERRINFO_SHARE_DATA_TOO_SHORT_STRING                                                      \
260 	"(a) There is not enough data to process Control PDU Data (section 2.2.1.15.1).\n"           \
261 	"(b) There is not enough data to read a complete Share Control Header (section "             \
262 	"2.2.8.1.1.1.1).\n"                                                                          \
263 	"(c) There is not enough data to read a complete Share Data Header (section 2.2.8.1.1.1.2) " \
264 	"of a Slow-Path Data PDU (section 2.2.8.1.1.1.1).\n"                                         \
265 	"(d) There is not enough data to process Font List PDU Data (section 2.2.1.18.1)."
266 
267 #define ERRINFO_BAD_SUPPRESS_OUTPUT_PDU_STRING                                                   \
268 	"(a) There is not enough data to process Suppress Output PDU Data (section 2.2.11.3.1).\n"   \
269 	"(b) The allowDisplayUpdates field of the Suppress Output PDU Data (section 2.2.11.3.1) is " \
270 	"invalid."
271 
272 #define ERRINFO_CONFIRM_ACTIVE_PDU_TOO_SHORT_STRING                                               \
273 	"(a) There is not enough data to read the shareControlHeader, shareId, originatorId, "        \
274 	"lengthSourceDescriptor, "                                                                    \
275 	"and lengthCombinedCapabilities fields of the Confirm Active PDU Data (section "              \
276 	"2.2.1.13.2.1).\n"                                                                            \
277 	"(b) There is not enough data to read the sourceDescriptor, numberCapabilities, pad2Octets, " \
278 	"and capabilitySets "                                                                         \
279 	"fields of the Confirm Active PDU Data (section 2.2.1.13.2.1)."
280 
281 #define ERRINFO_CAPABILITY_SET_TOO_SMALL_STRING                                                    \
282 	"There is not enough data to read the capabilitySetType and the lengthCapability fields in a " \
283 	"received Capability Set (section 2.2.1.13.1.1.1)."
284 
285 #define ERRINFO_CAPABILITY_SET_TOO_LARGE_STRING                                            \
286 	"A Capability Set (section 2.2.1.13.1.1.1) has been received with a lengthCapability " \
287 	"field that contains a value greater than the total length of the data received."
288 
289 #define ERRINFO_NO_CURSOR_CACHE_STRING                                                          \
290 	"(a) Both the colorPointerCacheSize and pointerCacheSize fields in the Pointer Capability " \
291 	"Set (section 2.2.7.1.5) are set to zero.\n"                                                \
292 	"(b) The pointerCacheSize field in the Pointer Capability Set (section 2.2.7.1.5) is not "  \
293 	"present, and the colorPointerCacheSize field is set to zero."
294 
295 #define ERRINFO_BAD_CAPABILITIES_STRING                                                         \
296 	"The capabilities received from the client in the Confirm Active PDU (section 2.2.1.13.2) " \
297 	"were not accepted by the server."
298 
299 #define ERRINFO_VIRTUAL_CHANNEL_DECOMPRESSION_STRING                                             \
300 	"An error occurred while using the bulk compressor (section 3.1.8 and [MS-RDPEGDI] section " \
301 	"3.1.8) to decompress a Virtual Channel PDU (section 2.2.6.1)"
302 
303 #define ERRINFO_INVALID_VC_COMPRESSION_TYPE_STRING                                             \
304 	"An invalid bulk compression package was specified in the flags field of the Channel PDU " \
305 	"Header (section 2.2.6.1.1)."
306 
307 #define ERRINFO_INVALID_CHANNEL_ID_STRING                                                     \
308 	"An invalid MCS channel ID was specified in the mcsPdu field of the Virtual Channel PDU " \
309 	"(section 2.2.6.1)."
310 
311 #define ERRINFO_VCHANNELS_TOO_MANY_STRING                                                          \
312 	"The client requested more than the maximum allowed 31 static virtual channels in the Client " \
313 	"Network Data (section 2.2.1.3.4)."
314 
315 #define ERRINFO_REMOTEAPP_NOT_ENABLED_STRING                                                      \
316 	"The INFO_RAIL flag (0x00008000) MUST be set in the flags field of the Info Packet (section " \
317 	"2.2.1.11.1.1) "                                                                              \
318 	"as the session on the remote server can only host remote applications."
319 
320 #define ERRINFO_CACHE_CAP_NOT_SET_STRING                                                  \
321 	"The client sent a Persistent Key List PDU (section 2.2.1.17) without including the " \
322 	"prerequisite Revision 2 Bitmap Cache "                                               \
323 	"Capability Set (section 2.2.7.1.4.2) in the Confirm Active PDU (section 2.2.1.13.2)."
324 
325 #define ERRINFO_BITMAP_CACHE_ERROR_PDU_BAD_LENGTH2_STRING                                         \
326 	"The NumInfoBlocks field in the Bitmap Cache Error PDU Data is inconsistent with the amount " \
327 	"of data in the "                                                                             \
328 	"Info field ([MS-RDPEGDI] section 2.2.2.3.1.1)."
329 
330 #define ERRINFO_OFFSCREEN_CACHE_ERROR_PDU_BAD_LENGTH_STRING                                  \
331 	"There is not enough data to process an Offscreen Bitmap Cache Error PDU ([MS-RDPEGDI] " \
332 	"section 2.2.2.3.2)."
333 
334 #define ERRINFO_DRAWNINEGRID_CACHE_ERROR_PDU_BAD_LENGTH_STRING                                  \
335 	"There is not enough data to process a DrawNineGrid Cache Error PDU ([MS-RDPEGDI] section " \
336 	"2.2.2.3.3)."
337 
338 #define ERRINFO_GDIPLUS_PDU_BAD_LENGTH_STRING \
339 	"There is not enough data to process a GDI+ Error PDU ([MS-RDPEGDI] section 2.2.2.3.4)."
340 
341 #define ERRINFO_SECURITY_DATA_TOO_SHORT2_STRING \
342 	"There is not enough data to read a Basic Security Header (section 2.2.8.1.1.2.1)."
343 
344 #define ERRINFO_SECURITY_DATA_TOO_SHORT3_STRING                                                    \
345 	"There is not enough data to read a Non-FIPS Security Header (section 2.2.8.1.1.2.2) or FIPS " \
346 	"Security Header (section 2.2.8.1.1.2.3)."
347 
348 #define ERRINFO_SECURITY_DATA_TOO_SHORT4_STRING                                                   \
349 	"There is not enough data to read the basicSecurityHeader and length fields of the Security " \
350 	"Exchange PDU Data (section 2.2.1.10.1)."
351 
352 #define ERRINFO_SECURITY_DATA_TOO_SHORT5_STRING                                                    \
353 	"There is not enough data to read the CodePage, flags, cbDomain, cbUserName, cbPassword, "     \
354 	"cbAlternateShell, "                                                                           \
355 	"cbWorkingDir, Domain, UserName, Password, AlternateShell, and WorkingDir fields in the Info " \
356 	"Packet (section 2.2.1.11.1.1)."
357 
358 #define ERRINFO_SECURITY_DATA_TOO_SHORT6_STRING                                                \
359 	"There is not enough data to read the CodePage, flags, cbDomain, cbUserName, cbPassword, " \
360 	"cbAlternateShell, "                                                                       \
361 	"and cbWorkingDir fields in the Info Packet (section 2.2.1.11.1.1)."
362 
363 #define ERRINFO_SECURITY_DATA_TOO_SHORT7_STRING                                                   \
364 	"There is not enough data to read the clientAddressFamily and cbClientAddress fields in the " \
365 	"Extended Info Packet (section 2.2.1.11.1.1.1)."
366 
367 #define ERRINFO_SECURITY_DATA_TOO_SHORT8_STRING                                             \
368 	"There is not enough data to read the clientAddress field in the Extended Info Packet " \
369 	"(section 2.2.1.11.1.1.1)."
370 
371 #define ERRINFO_SECURITY_DATA_TOO_SHORT9_STRING                                                    \
372 	"There is not enough data to read the cbClientDir field in the Extended Info Packet (section " \
373 	"2.2.1.11.1.1.1)."
374 
375 #define ERRINFO_SECURITY_DATA_TOO_SHORT10_STRING                                                 \
376 	"There is not enough data to read the clientDir field in the Extended Info Packet (section " \
377 	"2.2.1.11.1.1.1)."
378 
379 #define ERRINFO_SECURITY_DATA_TOO_SHORT11_STRING                                             \
380 	"There is not enough data to read the clientTimeZone field in the Extended Info Packet " \
381 	"(section 2.2.1.11.1.1.1)."
382 
383 #define ERRINFO_SECURITY_DATA_TOO_SHORT12_STRING                                              \
384 	"There is not enough data to read the clientSessionId field in the Extended Info Packet " \
385 	"(section 2.2.1.11.1.1.1)."
386 
387 #define ERRINFO_SECURITY_DATA_TOO_SHORT13_STRING                                               \
388 	"There is not enough data to read the performanceFlags field in the Extended Info Packet " \
389 	"(section 2.2.1.11.1.1.1)."
390 
391 #define ERRINFO_SECURITY_DATA_TOO_SHORT14_STRING                                                 \
392 	"There is not enough data to read the cbAutoReconnectLen field in the Extended Info Packet " \
393 	"(section 2.2.1.11.1.1.1)."
394 
395 #define ERRINFO_SECURITY_DATA_TOO_SHORT15_STRING                                                  \
396 	"There is not enough data to read the autoReconnectCookie field in the Extended Info Packet " \
397 	"(section 2.2.1.11.1.1.1)."
398 
399 #define ERRINFO_SECURITY_DATA_TOO_SHORT16_STRING                                                  \
400 	"The cbAutoReconnectLen field in the Extended Info Packet (section 2.2.1.11.1.1.1) contains " \
401 	"a value "                                                                                    \
402 	"which is larger than the maximum allowed length of 128 bytes."
403 
404 #define ERRINFO_SECURITY_DATA_TOO_SHORT17_STRING                                                  \
405 	"There is not enough data to read the clientAddressFamily and cbClientAddress fields in the " \
406 	"Extended Info Packet (section 2.2.1.11.1.1.1)."
407 
408 #define ERRINFO_SECURITY_DATA_TOO_SHORT18_STRING                                            \
409 	"There is not enough data to read the clientAddress field in the Extended Info Packet " \
410 	"(section 2.2.1.11.1.1.1)."
411 
412 #define ERRINFO_SECURITY_DATA_TOO_SHORT19_STRING                                                   \
413 	"There is not enough data to read the cbClientDir field in the Extended Info Packet (section " \
414 	"2.2.1.11.1.1.1)."
415 
416 #define ERRINFO_SECURITY_DATA_TOO_SHORT20_STRING                                                 \
417 	"There is not enough data to read the clientDir field in the Extended Info Packet (section " \
418 	"2.2.1.11.1.1.1)."
419 
420 #define ERRINFO_SECURITY_DATA_TOO_SHORT21_STRING                                             \
421 	"There is not enough data to read the clientTimeZone field in the Extended Info Packet " \
422 	"(section 2.2.1.11.1.1.1)."
423 
424 #define ERRINFO_SECURITY_DATA_TOO_SHORT22_STRING                                              \
425 	"There is not enough data to read the clientSessionId field in the Extended Info Packet " \
426 	"(section 2.2.1.11.1.1.1)."
427 
428 #define ERRINFO_SECURITY_DATA_TOO_SHORT23_STRING \
429 	"There is not enough data to read the Client Info PDU Data (section 2.2.1.11.1)."
430 
431 #define ERRINFO_BAD_MONITOR_DATA_STRING \
432 	"The monitorCount field in the Client Monitor Data (section 2.2.1.3.6) is invalid."
433 
434 #define ERRINFO_VC_DECOMPRESSED_REASSEMBLE_FAILED_STRING                                        \
435 	"The server-side decompression buffer is invalid, or the size of the decompressed VC data " \
436 	"exceeds "                                                                                  \
437 	"the chunking size specified in the Virtual Channel Capability Set (section 2.2.7.1.10)."
438 
439 #define ERRINFO_VC_DATA_TOO_LONG_STRING                                                       \
440 	"The size of a received Virtual Channel PDU (section 2.2.6.1) exceeds the chunking size " \
441 	"specified "                                                                              \
442 	"in the Virtual Channel Capability Set (section 2.2.7.1.10)."
443 
444 #define ERRINFO_BAD_FRAME_ACK_DATA_STRING \
445 	"There is not enough data to read a TS_FRAME_ACKNOWLEDGE_PDU ([MS-RDPRFX] section 2.2.3.1)."
446 
447 #define ERRINFO_GRAPHICS_MODE_NOT_SUPPORTED_STRING \
448 	"The graphics mode requested by the client is not supported by the server."
449 
450 #define ERRINFO_GRAPHICS_SUBSYSTEM_RESET_FAILED_STRING \
451 	"The server-side graphics subsystem failed to reset."
452 
453 #define ERRINFO_GRAPHICS_SUBSYSTEM_FAILED_STRING                                               \
454 	"The server-side graphics subsystem is in an error state and unable to continue graphics " \
455 	"encoding."
456 
457 #define ERRINFO_TIMEZONE_KEY_NAME_LENGTH_TOO_SHORT_STRING                                          \
458 	"There is not enough data to read the cbDynamicDSTTimeZoneKeyName field in the Extended Info " \
459 	"Packet (section 2.2.1.11.1.1.1)."
460 
461 #define ERRINFO_TIMEZONE_KEY_NAME_LENGTH_TOO_LONG_STRING                                        \
462 	"The length reported in the cbDynamicDSTTimeZoneKeyName field of the Extended Info Packet " \
463 	"(section 2.2.1.11.1.1.1) is too long."
464 
465 #define ERRINFO_DYNAMIC_DST_DISABLED_FIELD_MISSING_STRING                                        \
466 	"The dynamicDaylightTimeDisabled field is not present in the Extended Info Packet (section " \
467 	"2.2.1.11.1.1.1)."
468 
469 #define ERRINFO_VC_DECODING_ERROR_STRING \
470 	"An error occurred when processing dynamic virtual channel data ([MS-RDPEDYC] section 3.3.5)."
471 
472 #define ERRINFO_VIRTUALDESKTOPTOOLARGE_STRING                                                 \
473 	"The width or height of the virtual desktop defined by the monitor layout in the Client " \
474 	"Monitor Data "                                                                           \
475 	"(section 2.2.1.3.6) is larger than the maximum allowed value of 32,766."
476 
477 #define ERRINFO_MONITORGEOMETRYVALIDATIONFAILED_STRING \
478 	"The monitor geometry defined by the Client Monitor Data (section 2.2.1.3.6) is invalid."
479 
480 #define ERRINFO_INVALIDMONITORCOUNT_STRING \
481 	"The monitorCount field in the Client Monitor Data(section 2.2.1.3.6) is too large."
482 
483 #define ERRINFO_UPDATE_SESSION_KEY_FAILED_STRING                                                   \
484 	"An attempt to update the session keys while using Standard RDP Security mechanisms (section " \
485 	"5.3.7) failed."
486 
487 #define ERRINFO_DECRYPT_FAILED_STRING                                                 \
488 	"(a) Decryption using Standard RDP Security mechanisms (section 5.3.6) failed.\n" \
489 	"(b) Session key creation using Standard RDP Security mechanisms (section 5.3.5) failed."
490 
491 #define ERRINFO_ENCRYPT_FAILED_STRING \
492 	"Encryption using Standard RDP Security mechanisms (section 5.3.6) failed."
493 
494 #define ERRINFO_ENCRYPTION_PACKAGE_MISMATCH_STRING                                                 \
495 	"Failed to find a usable Encryption Method (section 5.3.2) in the encryptionMethods field of " \
496 	"the Client Security Data (section 2.2.1.4.3)."
497 
498 #define ERRINFO_DECRYPT_FAILED2_STRING                                                           \
499 	"Unencrypted data was encountered in a protocol stream which is meant to be encrypted with " \
500 	"Standard RDP Security mechanisms (section 5.3.6)."
501 
502 #define ERRINFO_PEER_DISCONNECTED_STRING "The peer connection was lost."
503 
504 /* Special codes */
505 #define ERRINFO_SUCCESS_STRING "Success."
506 #define ERRINFO_NONE_STRING ""
507 
508 static const ERRINFO ERRINFO_CODES[] = {
509 	ERRINFO_DEFINE(SUCCESS, CAT_NONE),
510 
511 	/* Protocol-independent codes */
512 	ERRINFO_DEFINE(RPC_INITIATED_DISCONNECT, CAT_ADMIN),
513 	ERRINFO_DEFINE(RPC_INITIATED_LOGOFF, CAT_ADMIN), ERRINFO_DEFINE(IDLE_TIMEOUT, CAT_ADMIN),
514 	ERRINFO_DEFINE(LOGON_TIMEOUT, CAT_ADMIN),
515 	ERRINFO_DEFINE(DISCONNECTED_BY_OTHER_CONNECTION, CAT_USE),
516 	ERRINFO_DEFINE(OUT_OF_MEMORY, CAT_ADMIN), ERRINFO_DEFINE(SERVER_DENIED_CONNECTION, CAT_ADMIN),
517 	ERRINFO_DEFINE(SERVER_INSUFFICIENT_PRIVILEGES, CAT_ADMIN),
518 	ERRINFO_DEFINE(SERVER_FRESH_CREDENTIALS_REQUIRED, CAT_ADMIN),
519 	ERRINFO_DEFINE(RPC_INITIATED_DISCONNECT_BY_USER, CAT_ADMIN),
520 	ERRINFO_DEFINE(LOGOFF_BY_USER, CAT_USE),
521 	ERRINFO_DEFINE(CLOSE_STACK_ON_DRIVER_NOT_READY, CAT_SERVER),
522 	ERRINFO_DEFINE(SERVER_DWM_CRASH, CAT_SERVER),
523 	ERRINFO_DEFINE(CLOSE_STACK_ON_DRIVER_FAILURE, CAT_SERVER),
524 	ERRINFO_DEFINE(CLOSE_STACK_ON_DRIVER_IFACE_FAILURE, CAT_SERVER),
525 	ERRINFO_DEFINE(SERVER_WINLOGON_CRASH, CAT_SERVER),
526 	ERRINFO_DEFINE(SERVER_CSRSS_CRASH, CAT_SERVER),
527 
528 	/* Protocol-independent licensing codes */
529 	ERRINFO_DEFINE(LICENSE_INTERNAL, CAT_LICENSING),
530 	ERRINFO_DEFINE(LICENSE_NO_LICENSE_SERVER, CAT_LICENSING),
531 	ERRINFO_DEFINE(LICENSE_NO_LICENSE, CAT_LICENSING),
532 	ERRINFO_DEFINE(LICENSE_BAD_CLIENT_MSG, CAT_LICENSING),
533 	ERRINFO_DEFINE(LICENSE_HWID_DOESNT_MATCH_LICENSE, CAT_LICENSING),
534 	ERRINFO_DEFINE(LICENSE_BAD_CLIENT_LICENSE, CAT_LICENSING),
535 	ERRINFO_DEFINE(LICENSE_CANT_FINISH_PROTOCOL, CAT_LICENSING),
536 	ERRINFO_DEFINE(LICENSE_CLIENT_ENDED_PROTOCOL, CAT_LICENSING),
537 	ERRINFO_DEFINE(LICENSE_BAD_CLIENT_ENCRYPTION, CAT_LICENSING),
538 	ERRINFO_DEFINE(LICENSE_CANT_UPGRADE_LICENSE, CAT_LICENSING),
539 	ERRINFO_DEFINE(LICENSE_NO_REMOTE_CONNECTIONS, CAT_LICENSING),
540 
541 	/* Protocol-independent codes generated by the Connection Broker */
542 	ERRINFO_DEFINE(CB_DESTINATION_NOT_FOUND, CAT_BROKER),
543 	ERRINFO_DEFINE(CB_LOADING_DESTINATION, CAT_BROKER),
544 	ERRINFO_DEFINE(CB_REDIRECTING_TO_DESTINATION, CAT_BROKER),
545 	ERRINFO_DEFINE(CB_SESSION_ONLINE_VM_WAKE, CAT_BROKER),
546 	ERRINFO_DEFINE(CB_SESSION_ONLINE_VM_BOOT, CAT_BROKER),
547 	ERRINFO_DEFINE(CB_SESSION_ONLINE_VM_NO_DNS, CAT_BROKER),
548 	ERRINFO_DEFINE(CB_DESTINATION_POOL_NOT_FREE, CAT_BROKER),
549 	ERRINFO_DEFINE(CB_CONNECTION_CANCELLED, CAT_BROKER),
550 	ERRINFO_DEFINE(CB_CONNECTION_ERROR_INVALID_SETTINGS, CAT_BROKER),
551 	ERRINFO_DEFINE(CB_SESSION_ONLINE_VM_BOOT_TIMEOUT, CAT_BROKER),
552 	ERRINFO_DEFINE(CB_SESSION_ONLINE_VM_SESSMON_FAILED, CAT_BROKER),
553 
554 	/* RDP specific codes */
555 	ERRINFO_DEFINE(UNKNOWN_DATA_PDU_TYPE, CAT_PROTOCOL),
556 	ERRINFO_DEFINE(UNKNOWN_PDU_TYPE, CAT_PROTOCOL), ERRINFO_DEFINE(DATA_PDU_SEQUENCE, CAT_PROTOCOL),
557 	ERRINFO_DEFINE(CONTROL_PDU_SEQUENCE, CAT_PROTOCOL),
558 	ERRINFO_DEFINE(INVALID_CONTROL_PDU_ACTION, CAT_PROTOCOL),
559 	ERRINFO_DEFINE(INVALID_INPUT_PDU_TYPE, CAT_PROTOCOL),
560 	ERRINFO_DEFINE(INVALID_INPUT_PDU_MOUSE, CAT_PROTOCOL),
561 	ERRINFO_DEFINE(INVALID_REFRESH_RECT_PDU, CAT_PROTOCOL),
562 	ERRINFO_DEFINE(CREATE_USER_DATA_FAILED, CAT_PROTOCOL), ERRINFO_DEFINE(CONNECT_FAILED, CAT_USE),
563 	ERRINFO_DEFINE(CONFIRM_ACTIVE_HAS_WRONG_SHAREID, CAT_PROTOCOL),
564 	ERRINFO_DEFINE(CONFIRM_ACTIVE_HAS_WRONG_ORIGINATOR, CAT_PROTOCOL),
565 	ERRINFO_DEFINE(PERSISTENT_KEY_PDU_BAD_LENGTH, CAT_PROTOCOL),
566 	ERRINFO_DEFINE(PERSISTENT_KEY_PDU_ILLEGAL_FIRST, CAT_PROTOCOL),
567 	ERRINFO_DEFINE(PERSISTENT_KEY_PDU_TOO_MANY_TOTAL_KEYS, CAT_PROTOCOL),
568 	ERRINFO_DEFINE(PERSISTENT_KEY_PDU_TOO_MANY_CACHE_KEYS, CAT_PROTOCOL),
569 	ERRINFO_DEFINE(INPUT_PDU_BAD_LENGTH, CAT_PROTOCOL),
570 	ERRINFO_DEFINE(BITMAP_CACHE_ERROR_PDU_BAD_LENGTH, CAT_PROTOCOL),
571 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT, CAT_PROTOCOL),
572 	ERRINFO_DEFINE(VCHANNEL_DATA_TOO_SHORT, CAT_PROTOCOL),
573 	ERRINFO_DEFINE(SHARE_DATA_TOO_SHORT, CAT_PROTOCOL),
574 	ERRINFO_DEFINE(BAD_SUPPRESS_OUTPUT_PDU, CAT_PROTOCOL),
575 	ERRINFO_DEFINE(CONFIRM_ACTIVE_PDU_TOO_SHORT, CAT_PROTOCOL),
576 	ERRINFO_DEFINE(CAPABILITY_SET_TOO_SMALL, CAT_PROTOCOL),
577 	ERRINFO_DEFINE(CAPABILITY_SET_TOO_LARGE, CAT_PROTOCOL),
578 	ERRINFO_DEFINE(NO_CURSOR_CACHE, CAT_PROTOCOL), ERRINFO_DEFINE(BAD_CAPABILITIES, CAT_PROTOCOL),
579 	ERRINFO_DEFINE(VIRTUAL_CHANNEL_DECOMPRESSION, CAT_PROTOCOL),
580 	ERRINFO_DEFINE(INVALID_VC_COMPRESSION_TYPE, CAT_PROTOCOL),
581 	ERRINFO_DEFINE(INVALID_CHANNEL_ID, CAT_PROTOCOL),
582 	ERRINFO_DEFINE(VCHANNELS_TOO_MANY, CAT_PROTOCOL),
583 	ERRINFO_DEFINE(REMOTEAPP_NOT_ENABLED, CAT_ADMIN),
584 	ERRINFO_DEFINE(CACHE_CAP_NOT_SET, CAT_PROTOCOL),
585 	ERRINFO_DEFINE(BITMAP_CACHE_ERROR_PDU_BAD_LENGTH2, CAT_PROTOCOL),
586 	ERRINFO_DEFINE(OFFSCREEN_CACHE_ERROR_PDU_BAD_LENGTH, CAT_PROTOCOL),
587 	ERRINFO_DEFINE(DRAWNINEGRID_CACHE_ERROR_PDU_BAD_LENGTH, CAT_PROTOCOL),
588 	ERRINFO_DEFINE(GDIPLUS_PDU_BAD_LENGTH, CAT_PROTOCOL),
589 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT2, CAT_PROTOCOL),
590 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT3, CAT_PROTOCOL),
591 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT4, CAT_PROTOCOL),
592 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT5, CAT_PROTOCOL),
593 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT6, CAT_PROTOCOL),
594 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT7, CAT_PROTOCOL),
595 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT8, CAT_PROTOCOL),
596 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT9, CAT_PROTOCOL),
597 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT10, CAT_PROTOCOL),
598 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT11, CAT_PROTOCOL),
599 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT12, CAT_PROTOCOL),
600 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT13, CAT_PROTOCOL),
601 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT14, CAT_PROTOCOL),
602 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT15, CAT_PROTOCOL),
603 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT16, CAT_PROTOCOL),
604 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT17, CAT_PROTOCOL),
605 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT18, CAT_PROTOCOL),
606 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT19, CAT_PROTOCOL),
607 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT20, CAT_PROTOCOL),
608 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT21, CAT_PROTOCOL),
609 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT22, CAT_PROTOCOL),
610 	ERRINFO_DEFINE(SECURITY_DATA_TOO_SHORT23, CAT_PROTOCOL),
611 	ERRINFO_DEFINE(BAD_MONITOR_DATA, CAT_PROTOCOL),
612 	ERRINFO_DEFINE(VC_DECOMPRESSED_REASSEMBLE_FAILED, CAT_PROTOCOL),
613 	ERRINFO_DEFINE(VC_DATA_TOO_LONG, CAT_PROTOCOL),
614 	ERRINFO_DEFINE(BAD_FRAME_ACK_DATA, CAT_PROTOCOL),
615 	ERRINFO_DEFINE(GRAPHICS_MODE_NOT_SUPPORTED, CAT_SERVER),
616 	ERRINFO_DEFINE(GRAPHICS_SUBSYSTEM_RESET_FAILED, CAT_SERVER),
617 	ERRINFO_DEFINE(GRAPHICS_SUBSYSTEM_FAILED, CAT_SERVER),
618 	ERRINFO_DEFINE(TIMEZONE_KEY_NAME_LENGTH_TOO_SHORT, CAT_PROTOCOL),
619 	ERRINFO_DEFINE(TIMEZONE_KEY_NAME_LENGTH_TOO_LONG, CAT_PROTOCOL),
620 	ERRINFO_DEFINE(DYNAMIC_DST_DISABLED_FIELD_MISSING, CAT_PROTOCOL),
621 	ERRINFO_DEFINE(VC_DECODING_ERROR, CAT_PROTOCOL),
622 	ERRINFO_DEFINE(VIRTUALDESKTOPTOOLARGE, CAT_SERVER),
623 	ERRINFO_DEFINE(MONITORGEOMETRYVALIDATIONFAILED, CAT_PROTOCOL),
624 	ERRINFO_DEFINE(INVALIDMONITORCOUNT, CAT_PROTOCOL),
625 	ERRINFO_DEFINE(UPDATE_SESSION_KEY_FAILED, CAT_PROTOCOL),
626 	ERRINFO_DEFINE(DECRYPT_FAILED, CAT_PROTOCOL), ERRINFO_DEFINE(ENCRYPT_FAILED, CAT_PROTOCOL),
627 	ERRINFO_DEFINE(ENCRYPTION_PACKAGE_MISMATCH, CAT_PROTOCOL),
628 	ERRINFO_DEFINE(DECRYPT_FAILED2, CAT_PROTOCOL), ERRINFO_DEFINE(PEER_DISCONNECTED, CAT_USE),
629 
630 	ERRINFO_DEFINE(NONE, CAT_NONE)
631 };
632 
freerdp_get_error_info_string(UINT32 code)633 const char* freerdp_get_error_info_string(UINT32 code)
634 {
635 	const ERRINFO* errInfo;
636 	errInfo = &ERRINFO_CODES[0];
637 
638 	while (errInfo->code != ERRINFO_NONE)
639 	{
640 		if (code == errInfo->code)
641 		{
642 			return errInfo->info;
643 		}
644 
645 		errInfo++;
646 	}
647 
648 	return "Unknown error.";
649 }
650 
freerdp_get_error_info_category(UINT32 code)651 const char* freerdp_get_error_info_category(UINT32 code)
652 {
653 	const ERRINFO* errInfo;
654 	errInfo = &ERRINFO_CODES[0];
655 
656 	while (errInfo->code != ERRINFO_NONE)
657 	{
658 		if (code == errInfo->code)
659 		{
660 			return errInfo->category;
661 		}
662 
663 		errInfo++;
664 	}
665 
666 	return "ERRINFO_UNKNOWN";
667 }
668 
freerdp_get_error_info_name(UINT32 code)669 const char* freerdp_get_error_info_name(UINT32 code)
670 {
671 	const ERRINFO* errInfo;
672 	errInfo = &ERRINFO_CODES[0];
673 
674 	while (errInfo->code != ERRINFO_NONE)
675 	{
676 		if (code == errInfo->code)
677 		{
678 			return errInfo->name;
679 		}
680 
681 		errInfo++;
682 	}
683 
684 	return "ERRINFO_UNKNOWN";
685 }
686 
rdp_print_errinfo(UINT32 code)687 void rdp_print_errinfo(UINT32 code)
688 {
689 	const ERRINFO* errInfo;
690 	errInfo = &ERRINFO_CODES[0];
691 
692 	while (errInfo->code != ERRINFO_NONE)
693 	{
694 		if (code == errInfo->code)
695 		{
696 			WLog_INFO(TAG, "%s (0x%08" PRIX32 "):%s", errInfo->name, code, errInfo->info);
697 			return;
698 		}
699 
700 		errInfo++;
701 	}
702 
703 	WLog_ERR(TAG, "ERRINFO_UNKNOWN 0x%08" PRIX32 ": Unknown error.", code);
704 }
705