2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/error.h>
|
|
|
|
#include <winpr/wtsapi.h>
|
|
|
|
|
2015-02-10 20:05:40 +03:00
|
|
|
int TestWtsApiExtraDynamicVirtualChannel(int argc, char* argv[])
|
2014-03-01 09:32:23 +04:00
|
|
|
{
|
|
|
|
BOOL bSuccess;
|
|
|
|
ULONG length;
|
|
|
|
ULONG bytesRead;
|
|
|
|
ULONG bytesWritten;
|
|
|
|
BYTE buffer[1024];
|
|
|
|
HANDLE hVirtualChannel;
|
|
|
|
|
|
|
|
length = sizeof(buffer);
|
|
|
|
|
2015-02-10 20:05:40 +03:00
|
|
|
hVirtualChannel = WTSVirtualChannelOpenEx( WTS_CURRENT_SESSION, "ECHO",WTS_CHANNEL_OPTION_DYNAMIC);
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2015-02-10 20:05:40 +03:00
|
|
|
|
|
|
|
if (hVirtualChannel == INVALID_HANDLE_VALUE)
|
2014-03-01 09:32:23 +04:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("WTSVirtualChannelOpen failed: %"PRIu32"\n", GetLastError());
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2015-02-10 20:05:40 +03:00
|
|
|
printf("WTSVirtualChannelOpen opend");
|
2014-03-01 09:32:23 +04:00
|
|
|
bytesWritten = 0;
|
|
|
|
bSuccess = WTSVirtualChannelWrite(hVirtualChannel, (PCHAR) buffer, length, &bytesWritten);
|
|
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("WTSVirtualChannelWrite failed: %"PRIu32"\n", GetLastError());
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2015-02-10 20:05:40 +03:00
|
|
|
printf("WTSVirtualChannelWrite written");
|
2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
bytesRead = 0;
|
|
|
|
bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, (PCHAR) buffer, length, &bytesRead);
|
|
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("WTSVirtualChannelRead failed: %"PRIu32"\n", GetLastError());
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2015-02-10 20:05:40 +03:00
|
|
|
printf("WTSVirtualChannelRead read");
|
2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
if (!WTSVirtualChannelClose(hVirtualChannel))
|
|
|
|
{
|
|
|
|
printf("WTSVirtualChannelClose failed\n");
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|