2011-08-23 17:01:19 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* Surface Commands
|
|
|
|
*
|
|
|
|
* Copyright 2011 Vic Lee
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-08-27 04:26:40 +04:00
|
|
|
#include <freerdp/utils/pcap.h>
|
|
|
|
|
2011-08-23 17:01:19 +04:00
|
|
|
#include "surface.h"
|
|
|
|
|
|
|
|
static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s)
|
|
|
|
{
|
|
|
|
int pos;
|
2011-08-27 05:44:37 +04:00
|
|
|
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
|
2011-08-23 17:01:19 +04:00
|
|
|
|
|
|
|
stream_read_uint16(s, cmd->destLeft);
|
|
|
|
stream_read_uint16(s, cmd->destTop);
|
|
|
|
stream_read_uint16(s, cmd->destRight);
|
|
|
|
stream_read_uint16(s, cmd->destBottom);
|
|
|
|
stream_read_uint8(s, cmd->bpp);
|
|
|
|
stream_seek(s, 2); /* reserved1, reserved2 */
|
|
|
|
stream_read_uint8(s, cmd->codecID);
|
|
|
|
stream_read_uint16(s, cmd->width);
|
|
|
|
stream_read_uint16(s, cmd->height);
|
|
|
|
stream_read_uint32(s, cmd->bitmapDataLength);
|
|
|
|
pos = stream_get_pos(s) + cmd->bitmapDataLength;
|
|
|
|
cmd->bitmapData = stream_get_tail(s);
|
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
IFCALL(update->SurfaceBits, update->context, cmd);
|
2011-08-23 17:01:19 +04:00
|
|
|
|
|
|
|
stream_set_pos(s, pos);
|
|
|
|
|
|
|
|
return 20 + cmd->bitmapDataLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int update_recv_surfcmd_frame_marker(rdpUpdate* update, STREAM* s)
|
|
|
|
{
|
2011-11-25 20:30:15 +04:00
|
|
|
SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker;
|
2011-08-23 17:01:19 +04:00
|
|
|
|
2011-11-25 20:30:15 +04:00
|
|
|
stream_read_uint16(s, marker->frameAction);
|
|
|
|
stream_read_uint32(s, marker->frameId);
|
2011-08-23 17:01:19 +04:00
|
|
|
|
2011-11-25 20:30:15 +04:00
|
|
|
IFCALL(update->SurfaceFrameMarker, update->context, marker);
|
2011-11-25 14:48:51 +04:00
|
|
|
|
2011-08-23 17:01:19 +04:00
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
|
2011-08-28 23:12:33 +04:00
|
|
|
boolean update_recv_surfcmds(rdpUpdate* update, uint32 size, STREAM* s)
|
2011-08-23 17:01:19 +04:00
|
|
|
{
|
2011-08-28 01:11:20 +04:00
|
|
|
uint8* mark;
|
2011-08-23 17:01:19 +04:00
|
|
|
uint16 cmdType;
|
2011-08-28 23:12:33 +04:00
|
|
|
uint32 cmdLength;
|
2011-08-27 04:26:40 +04:00
|
|
|
|
2011-08-27 05:44:37 +04:00
|
|
|
while (size > 2)
|
|
|
|
{
|
2011-08-28 01:11:20 +04:00
|
|
|
stream_get_mark(s, mark);
|
|
|
|
|
2011-08-23 17:01:19 +04:00
|
|
|
stream_read_uint16(s, cmdType);
|
|
|
|
size -= 2;
|
|
|
|
|
|
|
|
switch (cmdType)
|
|
|
|
{
|
|
|
|
case CMDTYPE_SET_SURFACE_BITS:
|
|
|
|
case CMDTYPE_STREAM_SURFACE_BITS:
|
2011-08-28 01:11:20 +04:00
|
|
|
cmdLength = update_recv_surfcmd_surface_bits(update, s);
|
2011-08-23 17:01:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMDTYPE_FRAME_MARKER:
|
2011-08-28 01:11:20 +04:00
|
|
|
cmdLength = update_recv_surfcmd_frame_marker(update, s);
|
2011-08-23 17:01:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DEBUG_WARN("unknown cmdType 0x%X", cmdType);
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-23 17:01:19 +04:00
|
|
|
}
|
2011-08-28 01:11:20 +04:00
|
|
|
|
|
|
|
size -= cmdLength;
|
|
|
|
|
|
|
|
if (update->dump_rfx)
|
|
|
|
{
|
|
|
|
pcap_add_record(update->pcap_rfx, mark, cmdLength + 2);
|
|
|
|
pcap_flush(update->pcap_rfx);
|
|
|
|
}
|
2011-08-23 17:01:19 +04:00
|
|
|
}
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-23 17:01:19 +04:00
|
|
|
}
|
|
|
|
|
2011-08-24 06:07:06 +04:00
|
|
|
void update_write_surfcmd_surface_bits_header(STREAM* s, SURFACE_BITS_COMMAND* cmd)
|
2011-08-23 19:28:28 +04:00
|
|
|
{
|
2011-08-24 06:07:06 +04:00
|
|
|
stream_check_size(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH);
|
2011-08-23 19:28:28 +04:00
|
|
|
|
|
|
|
stream_write_uint16(s, CMDTYPE_STREAM_SURFACE_BITS);
|
|
|
|
|
|
|
|
stream_write_uint16(s, cmd->destLeft);
|
|
|
|
stream_write_uint16(s, cmd->destTop);
|
|
|
|
stream_write_uint16(s, cmd->destRight);
|
|
|
|
stream_write_uint16(s, cmd->destBottom);
|
|
|
|
stream_write_uint8(s, cmd->bpp);
|
|
|
|
stream_write_uint16(s, 0); /* reserved1, reserved2 */
|
|
|
|
stream_write_uint8(s, cmd->codecID);
|
|
|
|
stream_write_uint16(s, cmd->width);
|
|
|
|
stream_write_uint16(s, cmd->height);
|
|
|
|
stream_write_uint32(s, cmd->bitmapDataLength);
|
|
|
|
}
|
|
|
|
|
2011-08-24 06:07:06 +04:00
|
|
|
void update_write_surfcmd_frame_marker(STREAM* s, uint16 frameAction, uint32 frameId)
|
2011-08-23 19:28:28 +04:00
|
|
|
{
|
2011-08-24 06:07:06 +04:00
|
|
|
stream_check_size(s, SURFCMD_FRAME_MARKER_LENGTH);
|
2011-08-23 19:28:28 +04:00
|
|
|
|
|
|
|
stream_write_uint16(s, CMDTYPE_FRAME_MARKER);
|
|
|
|
|
|
|
|
stream_write_uint16(s, frameAction);
|
|
|
|
stream_write_uint32(s, frameId);
|
|
|
|
}
|
|
|
|
|