FreeRDP/libfreerdp/core/display.c
akallabeth 73cdcdfe09
Logging and parser fixes (#7796)
* Fixed remdesk settings pointer

* Fixed sign warnings in display_write_monitor_layout_pdu

* Use freerdp_abort_connect_context and freerdp_shall_disconnect_context

* Added and updates settings

* info assert/dynamic timezone

* mcs assert/log/flags

* Fixed and added assertions for wStream

* Unified stream length checks

* Added new function to check for lenght and log
* Replace all usages with this new function

* Cleaned up PER, added parser logging

* Cleaned up BER, added parser logging

* log messages

* Modified Stream_CheckAndLogRequiredLengthEx

* Allow custom format and options
* Add Stream_CheckAndLogRequiredLengthExVa for prepared va_list

* Improved Stream_CheckAndLogRequiredLength

* Now have log level adjustable
* Added function equivalents for existing logger
* Added a backtrace in case of a failure is detected

* Fixed public API input checks
2022-04-19 14:29:17 +02:00

86 lines
2.8 KiB
C

/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Display update notifications
*
* Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "display.h"
static BOOL display_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount,
const MONITOR_DEF* monitorDefArray)
{
UINT32 index;
if (!Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20)))
return FALSE;
Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */
for (index = 0; index < monitorCount; index++)
{
const MONITOR_DEF* monitor = &monitorDefArray[index];
Stream_Write_INT32(s, monitor->left); /* left (4 bytes) */
Stream_Write_INT32(s, monitor->top); /* top (4 bytes) */
Stream_Write_INT32(s, monitor->right); /* right (4 bytes) */
Stream_Write_INT32(s, monitor->bottom); /* bottom (4 bytes) */
Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
}
return TRUE;
}
BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount,
const rdpMonitor* monitorDefArray,
MONITOR_DEF** result)
{
UINT32 index;
const rdpMonitor* monitor;
if (!monitorDefArray || !(*result))
return FALSE;
for (index = 0, monitor = monitorDefArray; index < monitorCount; index++, monitor++)
{
MONITOR_DEF* current = (*result + index);
current->left = monitor->x; /* left (4 bytes) */
current->top = monitor->y; /* top (4 bytes) */
current->right = monitor->x + monitor->width - 1; /* right (4 bytes) */
current->bottom = monitor->y + monitor->height - 1; /* bottom (4 bytes) */
current->flags = monitor->is_primary ? MONITOR_PRIMARY : 0x0; /* flags (4 bytes) */
}
return TRUE;
}
BOOL freerdp_display_send_monitor_layout(rdpContext* context, UINT32 monitorCount,
const MONITOR_DEF* monitorDefArray)
{
rdpRdp* rdp = context->rdp;
wStream* st = rdp_data_pdu_init(rdp);
if (!st)
return FALSE;
if (!display_write_monitor_layout_pdu(st, monitorCount, monitorDefArray))
{
Stream_Release(st);
return FALSE;
}
return rdp_send_data_pdu(rdp, st, DATA_PDU_TYPE_MONITOR_LAYOUT, 0);
}