hooked up RDP 5 decompression with -z option;

more testing needs to be done
This commit is contained in:
Laxmikant Rashinkar
2011-09-07 22:17:58 -07:00
parent 3b584a8cca
commit e73c54204f
8 changed files with 737 additions and 477 deletions

View File

@@ -203,6 +203,12 @@ static void fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
uint8 compression;
uint8 compressionFlags;
STREAM* update_stream;
rdpRdp *rdp;
uint32 roff;
uint32 rlen;
uint32 i;
rdp = fastpath->rdp;
fastpath_read_update_header(s, &updateCode, &fragmentation, &compression);
@@ -216,9 +222,21 @@ static void fastpath_recv_update_data(rdpFastPath* fastpath, STREAM* s)
if (compressionFlags != 0)
{
printf("FastPath compression is not yet implemented!\n");
stream_seek(s, size);
return;
if (decompress_rdp(rdp, s->data, size,
compressionFlags, &roff, &rlen))
{
/* need more space to insert decompressed data */
i = rlen - size;
stream_extend(s, i);
/* copy decompressed data */
memcpy(s->p, &rdp->mppc->history_buf[roff], rlen);
}
else
{
printf("decompress_rdp() failed\n");
stream_seek(s, size);
}
}
update_stream = NULL;

View File

@@ -495,7 +495,7 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings)
flags |= INFO_REMOTECONSOLEAUDIO;
if (settings->compression)
flags |= INFO_COMPRESSION | PACKET_COMPR_TYPE_64K;
flags |= INFO_COMPRESSION | INFO_PACKET_COMPR_TYPE_64K;
domain = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->domain, &length);
cbDomain = length;

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,14 @@
#include <stdint.h>
#define _MPPC_DEBUG
#ifdef MPPC_DEBUG
#define mprintf(y...) printf(y);
#else
#define mprintf(y...)
#endif
#define RDP5_HISTORY_BUF_SIZE 65536
struct rdp_mppc
@@ -31,6 +39,12 @@ struct rdp_mppc
};
// forward declarations
int decompress_rdp(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_4(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_5(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_6(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
int decompress_rdp_61(rdpRdp *, uint8 *, int, int, uint32 *, uint32 *);
struct rdp_mppc *mppc_new(rdpRdp *rdp);
void mppc_free(rdpRdp *rdp);
#endif

View File

@@ -59,8 +59,11 @@ static boolean peer_recv_data_pdu(rdpPeer* peer, STREAM* s)
uint8 type;
uint16 length;
uint32 share_id;
uint8 compressed_type;
uint16 compressed_len;
if (!rdp_read_share_data_header(s, &length, &type, &share_id))
if (!rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len))
return False;
switch (type)

View File

@@ -113,7 +113,8 @@ void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint1
stream_write_uint16(s, channel_id); /* pduSource */
}
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id)
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id,
uint8 *compressed_type, uint16 *compressed_len)
{
if (stream_get_left(s) < 12)
return False;
@@ -124,8 +125,16 @@ boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint3
stream_seek_uint8(s); /* streamId (1 byte) */
stream_read_uint16(s, *length); /* uncompressedLength (2 bytes) */
stream_read_uint8(s, *type); /* pduType2, Data PDU Type (1 byte) */
stream_seek_uint8(s); /* compressedType (1 byte) */
stream_seek_uint16(s); /* compressedLength (2 bytes) */
if (*type & 0x80)
{
stream_read_uint8(s, *compressed_type); /* compressedType (1 byte) */
stream_read_uint16(s, *compressed_len); /* compressedLength (2 bytes) */
}
else
{
*compressed_type = 0;
*compressed_len = 0;
}
return True;
}
@@ -304,8 +313,10 @@ void rdp_recv_data_pdu(rdpRdp* rdp, STREAM* s)
uint8 type;
uint16 length;
uint32 share_id;
uint8 compressed_type;
uint16 compressed_len;
rdp_read_share_data_header(s, &length, &type, &share_id);
rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len);
if (type != DATA_PDU_TYPE_UPDATE)
printf("recv %s Data PDU (0x%02X), length:%d\n", DATA_PDU_TYPE_STRINGS[type], type, length);
@@ -576,6 +587,7 @@ rdpRdp* rdp_new(freerdp* instance)
rdp->nego = nego_new(rdp->transport);
rdp->mcs = mcs_new(rdp->transport);
rdp->vchan = vchan_new(instance);
rdp->mppc = mppc_new(rdp);
}
return rdp;
@@ -600,6 +612,7 @@ void rdp_free(rdpRdp* rdp)
mcs_free(rdp->mcs);
vchan_free(rdp->vchan);
xfree(rdp);
mppc_free(rdp);
}
}

View File

@@ -124,7 +124,7 @@ struct rdp_rdp
struct rdp_settings* settings;
struct rdp_transport* transport;
struct rdp_vchan* vchan;
struct rdp_mppc* mppc;
struct rdp_mppc* mppc;
};
void rdp_read_security_header(STREAM* s, uint16* flags);
@@ -133,7 +133,9 @@ void rdp_write_security_header(STREAM* s, uint16 flags);
boolean rdp_read_share_control_header(STREAM* s, uint16* length, uint16* type, uint16* channel_id);
void rdp_write_share_control_header(STREAM* s, uint16 length, uint16 type, uint16 channel_id);
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id);
boolean rdp_read_share_data_header(STREAM* s, uint16* length, uint8* type, uint32* share_id,
uint8 *compressed_type, uint16 *compressed_len);
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 type, uint32 share_id);
STREAM* rdp_send_stream_init(rdpRdp* rdp);

View File

@@ -294,13 +294,15 @@ void update_recv(rdpUpdate* update, STREAM* s)
uint16 length;
uint16 source;
uint32 shareId;
uint8 compressed_type;
uint16 compressed_len;
rdp_read_share_control_header(s, &length, &pduType, &source);
if (pduType != PDU_TYPE_DATA)
return;
rdp_read_share_data_header(s, &length, &type, &shareId);
rdp_read_share_data_header(s, &length, &type, &shareId, &compressed_type, &compressed_len);
if (type == DATA_PDU_TYPE_UPDATE)
update_recv(update, s);