diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index e17f91b51..48da95fb1 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -718,7 +718,7 @@ int main(int argc, char* argv[]) chanman = freerdp_chanman_new(); SET_CHANMAN(instance, chanman); - instance->settings->sw_gdi = False; + instance->settings->sw_gdi = True; if (freerdp_parse_args(instance->settings, argc, argv, xf_process_plugin_args, chanman, xf_process_ui_args, NULL) < 0) diff --git a/cunit/test_pcap.c b/cunit/test_pcap.c index 99fb71403..d18856f4d 100644 --- a/cunit/test_pcap.c +++ b/cunit/test_pcap.c @@ -76,7 +76,9 @@ void test_pcap(void) pcap = pcap_open("/tmp/test.pcap", True); pcap_add_record(pcap, test_packet_1, sizeof(test_packet_1)); + pcap_flush(pcap); pcap_add_record(pcap, test_packet_2, sizeof(test_packet_2)); + pcap_flush(pcap); pcap_add_record(pcap, test_packet_3, sizeof(test_packet_3)); pcap_close(pcap); @@ -90,6 +92,8 @@ void test_pcap(void) i++; } + CU_ASSERT(i == 3); + pcap_close(pcap); } diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 861620fc6..cc870e9d9 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -297,6 +297,9 @@ struct rdp_settings uint8 rfx_codec_id; boolean frame_acknowledge; + boolean dump_rfx; + char* dump_rfx_file; + boolean remote_app; uint8 num_icon_caches; uint16 num_icon_cache_entries; diff --git a/include/freerdp/update.h b/include/freerdp/update.h index 591d5bef2..96ae25526 100644 --- a/include/freerdp/update.h +++ b/include/freerdp/update.h @@ -22,6 +22,7 @@ #include #include +#include /* Common */ @@ -1072,6 +1073,9 @@ struct rdp_update void* param1; void* param2; + boolean dump_rfx; + rdpPcap* pcap_rfx; + pcBeginPaint BeginPaint; pcEndPaint EndPaint; pcSetBounds SetBounds; diff --git a/include/freerdp/utils/pcap.h b/include/freerdp/utils/pcap.h index 893ff8589..db840c8d9 100644 --- a/include/freerdp/utils/pcap.h +++ b/include/freerdp/utils/pcap.h @@ -76,5 +76,6 @@ FREERDP_API void pcap_close(rdpPcap* pcap); FREERDP_API void pcap_add_record(rdpPcap* pcap, void* data, uint32 length); FREERDP_API boolean pcap_has_next_record(rdpPcap* pcap); FREERDP_API boolean pcap_get_next_record(rdpPcap* pcap, pcap_record* record); +FREERDP_API void pcap_flush(rdpPcap* pcap); #endif /* __UTILS_PCAP_H */ diff --git a/libfreerdp-core/freerdp.c b/libfreerdp-core/freerdp.c index 504079fc9..4b06392e5 100644 --- a/libfreerdp-core/freerdp.c +++ b/libfreerdp-core/freerdp.c @@ -34,9 +34,19 @@ boolean freerdp_connect(freerdp* instance) rdp = (rdpRdp*) instance->rdp; IFCALL(instance->PreConnect, instance); + status = rdp_client_connect((rdpRdp*) instance->rdp); + if (status) + { + if (instance->settings->dump_rfx) + { + instance->update->dump_rfx = instance->settings->dump_rfx; + instance->update->pcap_rfx = pcap_open(instance->settings->dump_rfx_file, True); + } + IFCALL(instance->PostConnect, instance); + } return status; } diff --git a/libfreerdp-core/surface.c b/libfreerdp-core/surface.c index 6c17e310c..98748cac4 100644 --- a/libfreerdp-core/surface.c +++ b/libfreerdp-core/surface.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#include + #include "surface.h" static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s) @@ -62,6 +64,12 @@ boolean update_recv_surfcmds(rdpUpdate* update, uint16 size, STREAM* s) while (size > 2) { + if (update->dump_rfx) + { + pcap_add_record(update->pcap_rfx, s->p, size); + pcap_flush(update->pcap_rfx); + } + stream_read_uint16(s, cmdType); size -= 2; diff --git a/libfreerdp-utils/args.c b/libfreerdp-utils/args.c index c260c2d28..7e2fbb324 100644 --- a/libfreerdp-utils/args.c +++ b/libfreerdp-utils/args.c @@ -242,6 +242,17 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, settings->performance_flags = PERF_FLAG_NONE; settings->large_pointer = True; } + else if (strcmp("--dump-rfx", argv[index]) == 0) + { + index++; + if (index == argc) + { + printf("missing file name\n"); + return -1; + } + settings->dump_rfx_file = xstrdup(argv[index]); + settings->dump_rfx = True; + } else if (strcmp("-m", argv[index]) == 0) { settings->mouse_motion = 0; diff --git a/libfreerdp-utils/pcap.c b/libfreerdp-utils/pcap.c index 4282971ee..e07f9c244 100644 --- a/libfreerdp-utils/pcap.c +++ b/libfreerdp-utils/pcap.c @@ -80,6 +80,9 @@ void pcap_add_record(rdpPcap* pcap, void* data, uint32 length) pcap->tail = record; } + if (pcap->record == NULL) + pcap->record = record; + record->data = data; record->length = length; record->header.incl_len = length;