2021-09-23 15:52:03 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
*
|
2022-10-06 17:03:31 +03:00
|
|
|
* RDP session stream dump interface
|
|
|
|
*
|
|
|
|
* Copyright 2022 Armin Novak
|
|
|
|
* Copyright 2022 Thincast Technologies GmbH
|
2021-09-23 15:52:03 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-09-15 09:01:36 +03:00
|
|
|
#include <time.h>
|
|
|
|
|
2021-09-23 15:52:03 +03:00
|
|
|
#include <winpr/sysinfo.h>
|
|
|
|
#include <winpr/path.h>
|
|
|
|
#include <winpr/string.h>
|
|
|
|
|
2023-03-14 12:39:18 +03:00
|
|
|
#include <freerdp/freerdp.h>
|
2021-09-23 15:52:03 +03:00
|
|
|
#include <freerdp/streamdump.h>
|
|
|
|
#include <freerdp/transport_io.h>
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
#include "streamdump.h"
|
|
|
|
|
2024-05-21 12:41:59 +03:00
|
|
|
#define TAG FREERDP_TAG("streamdump")
|
|
|
|
|
2021-09-23 15:52:03 +03:00
|
|
|
struct stream_dump_context
|
|
|
|
{
|
|
|
|
rdpTransportIo io;
|
|
|
|
size_t writeDumpOffset;
|
|
|
|
size_t readDumpOffset;
|
|
|
|
size_t replayOffset;
|
|
|
|
UINT64 replayTime;
|
|
|
|
CONNECTION_STATE state;
|
2022-10-06 17:03:31 +03:00
|
|
|
BOOL isServer;
|
2024-05-17 11:30:36 +03:00
|
|
|
BOOL nodelay;
|
2024-05-21 12:41:59 +03:00
|
|
|
wLog* log;
|
2021-09-23 15:52:03 +03:00
|
|
|
};
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
static UINT32 crc32b(const BYTE* data, size_t length)
|
|
|
|
{
|
|
|
|
UINT32 crc = 0xFFFFFFFF;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (size_t x = 0; x < length; x++)
|
2022-10-06 17:03:31 +03:00
|
|
|
{
|
|
|
|
const UINT32 d = data[x] & 0xFF;
|
|
|
|
crc = crc ^ d;
|
|
|
|
for (int j = 7; j >= 0; j--)
|
|
|
|
{
|
2023-07-28 09:49:16 +03:00
|
|
|
UINT32 mask = ~(crc & 1);
|
2022-10-06 17:03:31 +03:00
|
|
|
crc = (crc >> 1) ^ (0xEDB88320 & mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ~crc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(BUILD_TESTING)
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
BOOL
|
|
|
|
stream_dump_read_line(FILE* fp, wStream* s, UINT64* pts, size_t* pOffset, UINT32* flags)
|
2021-09-23 15:52:03 +03:00
|
|
|
{
|
|
|
|
BOOL rc = FALSE;
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT64 ts = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
UINT64 size = 0;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t r = 0;
|
|
|
|
UINT32 crc32 = 0;
|
|
|
|
BYTE received = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
if (!fp || !s || !flags)
|
2021-09-23 15:52:03 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (pOffset)
|
|
|
|
_fseeki64(fp, *pOffset, SEEK_SET);
|
|
|
|
|
|
|
|
r = fread(&ts, 1, sizeof(ts), fp);
|
|
|
|
if (r != sizeof(ts))
|
|
|
|
goto fail;
|
2022-10-06 17:03:31 +03:00
|
|
|
r = fread(&received, 1, sizeof(received), fp);
|
|
|
|
if (r != sizeof(received))
|
|
|
|
goto fail;
|
|
|
|
r = fread(&crc32, 1, sizeof(crc32), fp);
|
|
|
|
if (r != sizeof(crc32))
|
|
|
|
goto fail;
|
2021-09-23 15:52:03 +03:00
|
|
|
r = fread(&size, 1, sizeof(size), fp);
|
|
|
|
if (r != sizeof(size))
|
|
|
|
goto fail;
|
2022-10-06 17:03:31 +03:00
|
|
|
if (received)
|
|
|
|
*flags = STREAM_MSG_SRV_RX;
|
|
|
|
else
|
|
|
|
*flags = STREAM_MSG_SRV_TX;
|
2021-09-23 15:52:03 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(s, size))
|
|
|
|
goto fail;
|
|
|
|
r = fread(Stream_Pointer(s), 1, size, fp);
|
|
|
|
if (r != size)
|
|
|
|
goto fail;
|
2023-06-07 16:38:21 +03:00
|
|
|
if (crc32 != crc32b(Stream_ConstPointer(s), size))
|
2022-10-06 17:03:31 +03:00
|
|
|
goto fail;
|
2021-09-23 15:52:03 +03:00
|
|
|
Stream_Seek(s, size);
|
|
|
|
|
|
|
|
if (pOffset)
|
|
|
|
{
|
|
|
|
INT64 tmp = _ftelli64(fp);
|
|
|
|
if (tmp < 0)
|
|
|
|
goto fail;
|
|
|
|
*pOffset = (size_t)tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pts)
|
|
|
|
*pts = ts;
|
|
|
|
rc = TRUE;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
Stream_SealLength(s);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
#if !defined(BUILD_TESTING)
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
BOOL
|
|
|
|
stream_dump_write_line(FILE* fp, UINT32 flags, wStream* s)
|
2021-09-23 15:52:03 +03:00
|
|
|
{
|
|
|
|
BOOL rc = FALSE;
|
|
|
|
const UINT64 t = GetTickCount64();
|
|
|
|
const BYTE* data = Stream_Buffer(s);
|
|
|
|
const UINT64 size = Stream_Length(s);
|
|
|
|
|
|
|
|
if (!fp || !s)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
{
|
2022-10-06 17:03:31 +03:00
|
|
|
const UINT32 crc32 = crc32b(data, size);
|
|
|
|
const BYTE received = flags & STREAM_MSG_SRV_RX;
|
2021-09-23 15:52:03 +03:00
|
|
|
size_t r = fwrite(&t, 1, sizeof(t), fp);
|
|
|
|
if (r != sizeof(t))
|
|
|
|
goto fail;
|
2022-10-06 17:03:31 +03:00
|
|
|
r = fwrite(&received, 1, sizeof(received), fp);
|
|
|
|
if (r != sizeof(received))
|
|
|
|
goto fail;
|
|
|
|
r = fwrite(&crc32, 1, sizeof(crc32), fp);
|
|
|
|
if (r != sizeof(crc32))
|
|
|
|
goto fail;
|
2021-09-23 15:52:03 +03:00
|
|
|
r = fwrite(&size, 1, sizeof(size), fp);
|
|
|
|
if (r != sizeof(size))
|
|
|
|
goto fail;
|
|
|
|
r = fwrite(data, 1, size, fp);
|
|
|
|
if (r != size)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = TRUE;
|
|
|
|
fail:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
static FILE* stream_dump_get_file(const rdpSettings* settings, const char* mode)
|
2021-09-23 15:52:03 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
const char* cfolder = NULL;
|
2021-09-23 15:52:03 +03:00
|
|
|
char* file = NULL;
|
|
|
|
FILE* fp = NULL;
|
|
|
|
|
|
|
|
if (!settings || !mode)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cfolder = freerdp_settings_get_string(settings, FreeRDP_TransportDumpFile);
|
|
|
|
if (!cfolder)
|
2022-10-06 17:03:31 +03:00
|
|
|
file = GetKnownSubPath(KNOWN_PATH_TEMP, "freerdp-transport-dump");
|
2021-09-23 15:52:03 +03:00
|
|
|
else
|
2022-10-06 17:03:31 +03:00
|
|
|
file = _strdup(cfolder);
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
if (!file)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
fp = winpr_fopen(file, mode);
|
|
|
|
fail:
|
|
|
|
free(file);
|
|
|
|
return fp;
|
|
|
|
}
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
SSIZE_T stream_dump_append(const rdpContext* context, UINT32 flags, wStream* s, size_t* offset)
|
2021-09-23 15:52:03 +03:00
|
|
|
{
|
|
|
|
SSIZE_T rc = -1;
|
2023-04-27 10:23:51 +03:00
|
|
|
FILE* fp = NULL;
|
2022-10-06 17:03:31 +03:00
|
|
|
const UINT32 mask = STREAM_MSG_SRV_RX | STREAM_MSG_SRV_TX;
|
2021-09-23 15:52:03 +03:00
|
|
|
CONNECTION_STATE state = freerdp_get_state(context);
|
2024-01-23 18:49:54 +03:00
|
|
|
int r = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
if (!context || !s || !offset)
|
|
|
|
return -1;
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
if ((flags & STREAM_MSG_SRV_RX) && (flags & STREAM_MSG_SRV_TX))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((flags & mask) == 0)
|
|
|
|
return -1;
|
|
|
|
|
2021-09-23 15:52:03 +03:00
|
|
|
if (state < context->dump->state)
|
|
|
|
return 0;
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
fp = stream_dump_get_file(context->settings, "ab");
|
2021-09-23 15:52:03 +03:00
|
|
|
if (!fp)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
r = _fseeki64(fp, *offset, SEEK_SET);
|
|
|
|
if (r < 0)
|
|
|
|
goto fail;
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
if (!stream_dump_write_line(fp, flags, s))
|
2021-09-23 15:52:03 +03:00
|
|
|
goto fail;
|
|
|
|
rc = _ftelli64(fp);
|
|
|
|
if (rc < 0)
|
|
|
|
goto fail;
|
|
|
|
*offset = (size_t)rc;
|
|
|
|
fail:
|
2023-04-27 10:23:51 +03:00
|
|
|
if (fp)
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)fclose(fp);
|
2021-09-23 15:52:03 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
SSIZE_T stream_dump_get(const rdpContext* context, UINT32* flags, wStream* s, size_t* offset,
|
2021-09-23 15:52:03 +03:00
|
|
|
UINT64* pts)
|
|
|
|
{
|
|
|
|
SSIZE_T rc = -1;
|
2023-04-27 10:23:51 +03:00
|
|
|
FILE* fp = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
int r = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
if (!context || !s || !offset)
|
|
|
|
return -1;
|
2022-10-06 17:03:31 +03:00
|
|
|
fp = stream_dump_get_file(context->settings, "rb");
|
2021-09-23 15:52:03 +03:00
|
|
|
if (!fp)
|
|
|
|
return -1;
|
|
|
|
r = _fseeki64(fp, *offset, SEEK_SET);
|
|
|
|
if (r < 0)
|
|
|
|
goto fail;
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
if (!stream_dump_read_line(fp, s, pts, offset, flags))
|
2021-09-23 15:52:03 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
rc = _ftelli64(fp);
|
|
|
|
fail:
|
2023-04-27 10:23:51 +03:00
|
|
|
if (fp)
|
2024-08-26 16:39:33 +03:00
|
|
|
(void)fclose(fp);
|
2021-09-23 15:52:03 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stream_dump_transport_write(rdpTransport* transport, wStream* s)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
SSIZE_T r = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
rdpContext* ctx = transport_get_context(transport);
|
|
|
|
|
|
|
|
WINPR_ASSERT(ctx);
|
|
|
|
WINPR_ASSERT(ctx->dump);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
r = stream_dump_append(ctx, ctx->dump->isServer ? STREAM_MSG_SRV_TX : STREAM_MSG_SRV_RX, s,
|
|
|
|
&ctx->dump->writeDumpOffset);
|
2021-09-23 15:52:03 +03:00
|
|
|
if (r < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
WINPR_ASSERT(ctx->dump->io.WritePdu);
|
|
|
|
return ctx->dump->io.WritePdu(transport, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stream_dump_transport_read(rdpTransport* transport, wStream* s)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
int rc = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
rdpContext* ctx = transport_get_context(transport);
|
|
|
|
|
|
|
|
WINPR_ASSERT(ctx);
|
|
|
|
WINPR_ASSERT(ctx->dump);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
|
|
|
WINPR_ASSERT(ctx->dump->io.ReadPdu);
|
|
|
|
rc = ctx->dump->io.ReadPdu(transport, s);
|
|
|
|
if (rc > 0)
|
|
|
|
{
|
2022-10-06 17:03:31 +03:00
|
|
|
SSIZE_T r =
|
|
|
|
stream_dump_append(ctx, ctx->dump->isServer ? STREAM_MSG_SRV_RX : STREAM_MSG_SRV_TX, s,
|
|
|
|
&ctx->dump->readDumpOffset);
|
2021-09-23 15:52:03 +03:00
|
|
|
if (r < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL stream_dump_register_write_handlers(rdpContext* context)
|
|
|
|
{
|
2024-05-21 12:41:59 +03:00
|
|
|
rdpTransportIo dump = { 0 };
|
2021-09-23 15:52:03 +03:00
|
|
|
const rdpTransportIo* dfl = freerdp_get_io_callbacks(context);
|
|
|
|
|
|
|
|
if (!freerdp_settings_get_bool(context->settings, FreeRDP_TransportDump))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
WINPR_ASSERT(dfl);
|
|
|
|
dump = *dfl;
|
|
|
|
|
|
|
|
/* Remember original callbacks for later */
|
|
|
|
WINPR_ASSERT(context->dump);
|
|
|
|
context->dump->io.ReadPdu = dfl->ReadPdu;
|
|
|
|
context->dump->io.WritePdu = dfl->WritePdu;
|
|
|
|
|
|
|
|
/* Set our dump wrappers */
|
|
|
|
dump.WritePdu = stream_dump_transport_write;
|
|
|
|
dump.ReadPdu = stream_dump_transport_read;
|
|
|
|
return freerdp_set_io_callbacks(context, &dump);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stream_dump_replay_transport_write(rdpTransport* transport, wStream* s)
|
|
|
|
{
|
|
|
|
rdpContext* ctx = transport_get_context(transport);
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t size = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(ctx);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
|
|
|
size = Stream_Length(s);
|
2024-05-21 12:41:59 +03:00
|
|
|
WLog_Print(ctx->dump->log, WLOG_TRACE, "replay write %" PRIuz, size);
|
2021-09-23 15:52:03 +03:00
|
|
|
// TODO: Compare with write file
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stream_dump_replay_transport_read(rdpTransport* transport, wStream* s)
|
|
|
|
{
|
|
|
|
rdpContext* ctx = transport_get_context(transport);
|
|
|
|
|
|
|
|
size_t size = 0;
|
|
|
|
time_t slp = 0;
|
|
|
|
UINT64 ts = 0;
|
2022-10-06 17:03:31 +03:00
|
|
|
UINT32 flags = 0;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(ctx);
|
|
|
|
WINPR_ASSERT(ctx->dump);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
|
2024-05-17 10:54:01 +03:00
|
|
|
const size_t start = Stream_GetPosition(s);
|
2022-10-06 17:03:31 +03:00
|
|
|
do
|
|
|
|
{
|
2024-05-17 10:54:01 +03:00
|
|
|
Stream_SetPosition(s, start);
|
2022-10-06 17:03:31 +03:00
|
|
|
if (stream_dump_get(ctx, &flags, s, &ctx->dump->replayOffset, &ts) < 0)
|
|
|
|
return -1;
|
|
|
|
} while (flags & STREAM_MSG_SRV_RX);
|
2021-09-23 15:52:03 +03:00
|
|
|
|
2024-05-17 11:30:36 +03:00
|
|
|
if (!ctx->dump->nodelay)
|
|
|
|
{
|
|
|
|
if ((ctx->dump->replayTime > 0) && (ts > ctx->dump->replayTime))
|
|
|
|
slp = ts - ctx->dump->replayTime;
|
|
|
|
}
|
2021-09-23 15:52:03 +03:00
|
|
|
ctx->dump->replayTime = ts;
|
|
|
|
|
|
|
|
size = Stream_Length(s);
|
|
|
|
Stream_SetPosition(s, 0);
|
2024-05-21 12:41:59 +03:00
|
|
|
WLog_Print(ctx->dump->log, WLOG_TRACE, "replay read %" PRIuz, size);
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
if (slp > 0)
|
2023-07-28 10:06:53 +03:00
|
|
|
{
|
|
|
|
size_t duration = slp;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const DWORD actual = (DWORD)MIN(duration, UINT32_MAX);
|
|
|
|
Sleep(actual);
|
|
|
|
duration -= actual;
|
|
|
|
} while (duration > 0);
|
|
|
|
}
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stream_dump_replay_transport_tcp_connect(rdpContext* context, rdpSettings* settings,
|
|
|
|
const char* hostname, int port, DWORD timeout)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
WINPR_ASSERT(hostname);
|
|
|
|
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
|
2024-09-05 15:59:21 +03:00
|
|
|
static rdpTransportLayer* stream_dump_replay_transport_connect_layer(rdpTransport* transport,
|
|
|
|
const char* hostname, int port,
|
|
|
|
DWORD timeout)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(transport);
|
|
|
|
WINPR_ASSERT(hostname);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-09-23 15:52:03 +03:00
|
|
|
static BOOL stream_dump_replay_transport_tls_connect(rdpTransport* transport)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(transport);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL stream_dump_replay_transport_accept(rdpTransport* transport)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(transport);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL stream_dump_register_read_handlers(rdpContext* context)
|
|
|
|
{
|
|
|
|
const rdpTransportIo* dfl = freerdp_get_io_callbacks(context);
|
|
|
|
|
|
|
|
if (!freerdp_settings_get_bool(context->settings, FreeRDP_TransportDumpReplay))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
WINPR_ASSERT(dfl);
|
2024-05-17 11:30:36 +03:00
|
|
|
rdpTransportIo dump = *dfl;
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
/* Remember original callbacks for later */
|
|
|
|
WINPR_ASSERT(context->dump);
|
2024-05-17 11:30:36 +03:00
|
|
|
context->dump->nodelay =
|
|
|
|
freerdp_settings_get_bool(context->settings, FreeRDP_TransportDumpReplayNodelay);
|
2021-09-23 15:52:03 +03:00
|
|
|
context->dump->io.ReadPdu = dfl->ReadPdu;
|
|
|
|
context->dump->io.WritePdu = dfl->WritePdu;
|
|
|
|
|
|
|
|
/* Set our dump wrappers */
|
|
|
|
dump.WritePdu = stream_dump_transport_write;
|
|
|
|
dump.ReadPdu = stream_dump_transport_read;
|
|
|
|
|
|
|
|
/* Set our dump wrappers */
|
|
|
|
dump.WritePdu = stream_dump_replay_transport_write;
|
|
|
|
dump.ReadPdu = stream_dump_replay_transport_read;
|
|
|
|
dump.TCPConnect = stream_dump_replay_transport_tcp_connect;
|
|
|
|
dump.TLSAccept = stream_dump_replay_transport_accept;
|
|
|
|
dump.TLSConnect = stream_dump_replay_transport_tls_connect;
|
2024-09-05 15:59:21 +03:00
|
|
|
dump.ConnectLayer = stream_dump_replay_transport_connect_layer;
|
2024-05-17 10:54:01 +03:00
|
|
|
if (!freerdp_set_io_callbacks(context, &dump))
|
|
|
|
return FALSE;
|
|
|
|
return freerdp_io_callback_set_event(context, TRUE);
|
2021-09-23 15:52:03 +03:00
|
|
|
}
|
|
|
|
|
2022-10-06 17:03:31 +03:00
|
|
|
BOOL stream_dump_register_handlers(rdpContext* context, CONNECTION_STATE state, BOOL isServer)
|
2021-09-23 15:52:03 +03:00
|
|
|
{
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
WINPR_ASSERT(context->dump);
|
|
|
|
context->dump->state = state;
|
2022-10-06 17:03:31 +03:00
|
|
|
context->dump->isServer = isServer;
|
2021-09-23 15:52:03 +03:00
|
|
|
if (!stream_dump_register_write_handlers(context))
|
|
|
|
return FALSE;
|
|
|
|
return stream_dump_register_read_handlers(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stream_dump_free(rdpStreamDumpContext* dump)
|
|
|
|
{
|
|
|
|
free(dump);
|
|
|
|
}
|
|
|
|
|
|
|
|
rdpStreamDumpContext* stream_dump_new(void)
|
|
|
|
{
|
|
|
|
rdpStreamDumpContext* dump = calloc(1, sizeof(rdpStreamDumpContext));
|
|
|
|
if (!dump)
|
|
|
|
return NULL;
|
2024-05-21 12:41:59 +03:00
|
|
|
dump->log = WLog_Get(TAG);
|
2021-09-23 15:52:03 +03:00
|
|
|
|
|
|
|
return dump;
|
|
|
|
}
|