Exemple #1
0
void bulk_free(rdpBulk* bulk)
{
    if (!bulk)
        return;

    mppc_context_free(bulk->mppcSend);
    mppc_context_free(bulk->mppcRecv);
    ncrush_context_free(bulk->ncrushRecv);
    ncrush_context_free(bulk->ncrushSend);
    xcrush_context_free(bulk->xcrushRecv);
    xcrush_context_free(bulk->xcrushSend);
    free(bulk);
}
int test_NCrushDecompressBells()
{
    int status;
    UINT32 Flags;
    BYTE* pSrcData;
    UINT32 SrcSize;
    UINT32 DstSize;
    UINT32 expectedSize;
    BYTE* pDstData = NULL;
    NCRUSH_CONTEXT* ncrush;
    ncrush = ncrush_context_new(FALSE);
    SrcSize = sizeof(TEST_BELLS_NCRUSH) - 1;
    pSrcData = (BYTE*) TEST_BELLS_NCRUSH;
    Flags = PACKET_COMPRESSED | 2;
    expectedSize = sizeof(TEST_BELLS_DATA) - 1;
    status = ncrush_decompress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, Flags);
    printf("Flags: 0x%08"PRIX32" DstSize: %"PRIu32"\n", Flags, DstSize);

    if (DstSize != expectedSize)
    {
        printf("NCrushDecompressBells: output size mismatch: Actual: %"PRIu32", Expected: %"PRIu32"\n", DstSize, expectedSize);
        return -1;
    }

    if (memcmp(pDstData, TEST_BELLS_DATA, DstSize) != 0)
    {
        printf("NCrushDecompressBells: output mismatch\n");
        return -1;
    }

    ncrush_context_free(ncrush);
    return 1;
}
int test_NCrushCompressBells()
{
	int status;
	UINT32 Flags;
	UINT32 SrcSize;
	BYTE* pSrcData;
	UINT32 DstSize;
	BYTE* pDstData;
	UINT32 expectedSize;
	BYTE OutputBuffer[65536];
	NCRUSH_CONTEXT* ncrush;

	ncrush = ncrush_context_new(TRUE);

	SrcSize = sizeof(TEST_BELLS_DATA) - 1;
	pSrcData = (BYTE*) TEST_BELLS_DATA;
	expectedSize = sizeof(TEST_BELLS_NCRUSH) - 1;

	pDstData = OutputBuffer;
	DstSize = sizeof(OutputBuffer);
	ZeroMemory(OutputBuffer, sizeof(OutputBuffer));

	status = ncrush_compress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);

	printf("status: %d Flags: 0x%04X DstSize: %d\n", status, Flags, DstSize);

	if (DstSize != expectedSize)
	{
		printf("NCrushCompressBells: output size mismatch: Actual: %d, Expected: %d\n", DstSize, expectedSize);

		printf("Actual\n");
		BitDump(pDstData, DstSize * 8, 0);

		printf("Expected\n");
		BitDump(TEST_BELLS_NCRUSH, expectedSize * 8, 0);

		return -1;
	}

	if (memcmp(pDstData, TEST_BELLS_NCRUSH, DstSize) != 0)
	{
		printf("NCrushCompressBells: output mismatch\n");

		printf("Actual\n");
		BitDump(pDstData, DstSize * 8, 0);

		printf("Expected\n");
		BitDump(TEST_BELLS_NCRUSH, expectedSize * 8, 0);

		return -1;
	}

	ncrush_context_free(ncrush);

	return 1;
}
static BOOL test_NCrushCompressBells(void)
{
	BOOL rc = FALSE;
	int status;
	UINT32 Flags;
	UINT32 SrcSize;
	BYTE* pSrcData;
	UINT32 DstSize;
	BYTE* pDstData;
	UINT32 expectedSize;
	BYTE OutputBuffer[65536];
	NCRUSH_CONTEXT* ncrush = ncrush_context_new(TRUE);

	if (!ncrush)
		return rc;

	SrcSize = sizeof(TEST_BELLS_DATA) - 1;
	pSrcData = (BYTE*) TEST_BELLS_DATA;
	expectedSize = sizeof(TEST_BELLS_NCRUSH) - 1;
	pDstData = OutputBuffer;
	DstSize = sizeof(OutputBuffer);
	ZeroMemory(OutputBuffer, sizeof(OutputBuffer));
	status = ncrush_compress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, &Flags);

	if (status < 0)
		goto fail;

	printf("status: %d Flags: 0x%08"PRIX32" DstSize: %"PRIu32"\n", status, Flags, DstSize);

	if (DstSize != expectedSize)
	{
		printf("NCrushCompressBells: output size mismatch: Actual: %"PRIu32", Expected: %"PRIu32"\n",
		       DstSize, expectedSize);
		printf("Actual\n");
		BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
		printf("Expected\n");
		BitDump(__FUNCTION__, WLOG_INFO, TEST_BELLS_NCRUSH, expectedSize * 8, 0);
		goto fail;
	}

	if (memcmp(pDstData, TEST_BELLS_NCRUSH, DstSize) != 0)
	{
		printf("NCrushCompressBells: output mismatch\n");
		printf("Actual\n");
		BitDump(__FUNCTION__, WLOG_INFO, pDstData, DstSize * 8, 0);
		printf("Expected\n");
		BitDump(__FUNCTION__, WLOG_INFO, TEST_BELLS_NCRUSH, expectedSize * 8, 0);
		goto fail;
	}

	rc = TRUE;
fail:
	ncrush_context_free(ncrush);
	return rc;
}