libfreerdp-client: initial support for .rdp file parsing

This commit is contained in:
Marc-André Moreau
2012-10-27 20:25:11 -04:00
parent a3192855bb
commit beefa1a21d
19 changed files with 1004 additions and 44 deletions

4
.gitignore vendored
View File

@@ -28,6 +28,10 @@ _CPack_Packages
*.cproject
*.settings
# .rdp files
*.rdp
*.RDP
# Documentation
docs/api
client/X11/xfreerdp.1

View File

@@ -59,6 +59,8 @@
#include <freerdp/client/channels.h>
#include <freerdp/rail.h>
#include <freerdp/client/file.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
@@ -480,6 +482,7 @@ int _xf_error_handler(Display* d, XErrorEvent* ev)
BOOL xf_pre_connect(freerdp* instance)
{
xfInfo* xfi;
rdpFile* file;
BOOL bitmap_cache;
rdpSettings* settings;
int arg_parse_result;
@@ -504,6 +507,17 @@ BOOL xf_pre_connect(freerdp* instance)
}
settings = instance->settings;
if (settings->connection_file)
{
file = (rdpFile*) malloc(sizeof(rdpFile));
ZeroMemory(file, sizeof(rdpFile));
printf("Using connection file: %s\n", settings->connection_file);
freerdp_client_parse_rdp_file(file, settings->connection_file);
}
bitmap_cache = settings->bitmap_cache;
settings->os_major_type = OSMAJORTYPE_UNIX;

View File

@@ -38,9 +38,19 @@ set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION_FULL}
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS}
${FREERDP_CHANNELS_CLIENT_LIBS})
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD}
MODULE winpr
MODULES winpr-crt)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
set_target_properties(${MODULE_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Common")
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -30,3 +30,365 @@
* RDP Settings for Remote Desktop Services in Windows Server 2008 R2:
* http://technet.microsoft.com/en-us/library/ff393699/
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <winpr/crt.h>
#include <freerdp/utils/hexdump.h>
static BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE };
static WCHAR CR_LF_STR_W[] = { '\r', '\n', '\0' };
BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, char* name, int value)
{
if (_stricmp(name, "use multimon") == 0)
file->UseMultiMon = value;
else if (_stricmp(name, "screen mode id") == 0)
file->ScreenModeId = value;
else if (_stricmp(name, "span monitors") == 0)
file->SpanMonitors = value;
else if (_stricmp(name, "smartsizing") == 0)
file->SmartSizing = value;
else if (_stricmp(name, "enablesuperpan") == 0)
file->EnableSuperSpan = value;
else if (_stricmp(name, "superpanaccelerationfactor") == 0)
file->SuperSpanAccelerationFactor = value;
else if (_stricmp(name, "desktopwidth") == 0)
file->DesktopWidth = value;
else if (_stricmp(name, "desktopheight") == 0)
file->DesktopHeight = value;
else if (_stricmp(name, "desktop size id") == 0)
file->DesktopSizeId = value;
else if (_stricmp(name, "session bpp") == 0)
file->SessionBpp = value;
else if (_stricmp(name, "compression") == 0)
file->Compression = value;
else if (_stricmp(name, "keyboardhook") == 0)
file->KeyboardHook = value;
else if (_stricmp(name, "disable ctrl+alt+del") == 0)
file->DisableCtrlAltDel = value;
else if (_stricmp(name, "audiomode") == 0)
file->AudioMode = value;
else if (_stricmp(name, "audioqualitymode") == 0)
file->AudioQualityMode = value;
else if (_stricmp(name, "audiocapturemode") == 0)
file->AudioCaptureMode = value;
else if (_stricmp(name, "videoplaybackmode") == 0)
file->VideoPlaybackMode = value;
else if (_stricmp(name, "connection type") == 0)
file->ConnectionType = value;
else if (_stricmp(name, "networkautodetect") == 0)
file->NetworkAutoDetect = value;
else if (_stricmp(name, "bandwidthautodetect") == 0)
file->BandwidthAutoDetect = value;
else if (_stricmp(name, "pinconnectionbar") == 0)
file->PinConnectionBar = value;
else if (_stricmp(name, "displayconnectionbar") == 0)
file->DisplayConnectionBar = value;
else if (_stricmp(name, "workspaceid") == 0)
file->WorkspaceId = value;
else if (_stricmp(name, "enableworkspacereconnect") == 0)
file->EnableWorkspaceReconnect = value;
else if (_stricmp(name, "disable wallpaper") == 0)
file->DisableWallpaper = value;
else if (_stricmp(name, "allow font smoothing") == 0)
file->AllowFontSmoothing = value;
else if (_stricmp(name, "allow desktop composition") == 0)
file->AllowDesktopComposition = value;
else if (_stricmp(name, "disable full window drag") == 0)
file->DisableFullWindowDrag = value;
else if (_stricmp(name, "disable menu anims") == 0)
file->DisableMenuAnims = value;
else if (_stricmp(name, "disable themes") == 0)
file->DisableThemes = value;
else if (_stricmp(name, "disable cursor setting") == 0)
file->DisableCursorSetting = value;
else if (_stricmp(name, "bitmapcachesize") == 0)
file->BitmapCacheSize = value;
else if (_stricmp(name, "bitmapcachepersistenable") == 0)
file->BitmapCachePersistEnable = value;
else if (_stricmp(name, "server port") == 0)
file->ServerPort = value;
else if (_stricmp(name, "redirectdrives") == 0)
file->RedirectDrives = value;
else if (_stricmp(name, "redirectprinters") == 0)
file->RedirectPrinters = value;
else if (_stricmp(name, "redirectcomports") == 0)
file->RedirectComPorts = value;
else if (_stricmp(name, "redirectsmartcards") == 0)
file->RedirectSmartCards = value;
else if (_stricmp(name, "redirectclipboard") == 0)
file->RedirectClipboard = value;
else if (_stricmp(name, "redirectposdevices") == 0)
file->RedirectPosDevices = value;
else if (_stricmp(name, "redirectdirectx") == 0)
file->RedirectDirectX = value;
else if (_stricmp(name, "disableprinterredirection") == 0)
file->DisablePrinterRedirection = value;
else if (_stricmp(name, "disableclipboardredirection") == 0)
file->DisableClipboardRedirection = value;
else if (_stricmp(name, "connect to console") == 0)
file->ConnectToConsole = value;
else if (_stricmp(name, "administrative session") == 0)
file->AdministrativeSession = value;
else if (_stricmp(name, "autoreconnection enabled") == 0)
file->AutoReconnectionEnabled = value;
else if (_stricmp(name, "autoreconnect max retries") == 0)
file->AutoReconnectMaxRetries = value;
else if (_stricmp(name, "public mode") == 0)
file->PublicMode = value;
else if (_stricmp(name, "authentication level") == 0)
file->AuthenticationLevel = value;
else if (_stricmp(name, "promptcredentialonce") == 0)
file->PromptCredentialOnce = value;
else if (_stricmp(name, "prompt for credentials") == 0)
file->PromptForCredentials = value;
else if (_stricmp(name, "promptcredentialonce") == 0)
file->PromptForCredentialsOnce = value;
else if (_stricmp(name, "negotiate security layer") == 0)
file->NegotiateSecurityLayer = value;
else if (_stricmp(name, "enablecredsspsupport") == 0)
file->EnableCredSSPSupport = value;
else if (_stricmp(name, "remoteapplicationmode") == 0)
file->RemoteApplicationMode = value;
else if (_stricmp(name, "remoteapplicationexpandcmdline") == 0)
file->RemoteApplicationExpandCmdLine = value;
else if (_stricmp(name, "remoteapplicationexpandworkingdir") == 0)
file->RemoteApplicationExpandWorkingDir = value;
else if (_stricmp(name, "disableconnectionsharing") == 0)
file->DisableConnectionSharing = value;
else if (_stricmp(name, "disableremoteappcapscheck") == 0)
file->DisableRemoteAppCapsCheck = value;
else if (_stricmp(name, "gatewayusagemethod") == 0)
file->GatewayUsageMethod = value;
else if (_stricmp(name, "gatewayprofileusagemethod") == 0)
file->GatewayProfileUsageMethod = value;
else if (_stricmp(name, "gatewaycredentialssource") == 0)
file->GatewayCredentialsSource = value;
else if (_stricmp(name, "use redirection server name") == 0)
file->UseRedirectionServerName = value;
else if (_stricmp(name, "rdgiskdcproxy") == 0)
file->RdgIsKdcProxy = value;
else
return FALSE;
return TRUE;
}
void freerdp_client_parse_rdp_file_integer_unicode(rdpFile* file, WCHAR* name, WCHAR* value)
{
int length;
int ivalue;
char* nameA;
char* valueA;
length = _wcslen(name);
nameA = (char*) malloc(length + 1);
WideCharToMultiByte(CP_UTF8, 0, name, length, nameA, length, NULL, NULL);
nameA[length] = '\0';
length = _wcslen(value);
valueA = (char*) malloc(length + 1);
WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL);
valueA[length] = '\0';
ivalue = atoi(valueA);
freerdp_client_rdp_file_set_integer(file, nameA, ivalue);
free(nameA);
free(valueA);
}
BOOL freerdp_client_rdp_file_set_string(rdpFile* file, char* name, char* value)
{
if (_stricmp(name, "username") == 0)
file->Username = value;
else if (_stricmp(name, "domain") == 0)
file->Domain = value;
else if (_stricmp(name, "full address") == 0)
file->FullAddress = value;
else if (_stricmp(name, "alternate full address") == 0)
file->AlternateFullAddress = value;
else if (_stricmp(name, "usbdevicestoredirect") == 0)
file->UsbDevicesToRedirect = value;
else if (_stricmp(name, "loadbalanceinfo") == 0)
file->LoadBalanceInfo = value;
else if (_stricmp(name, "remoteapplicationname") == 0)
file->RemoteApplicationName = value;
else if (_stricmp(name, "remoteapplicationicon") == 0)
file->RemoteApplicationIcon = value;
else if (_stricmp(name, "remoteapplicationprogram") == 0)
file->RemoteApplicationProgram = value;
else if (_stricmp(name, "remoteapplicationfile") == 0)
file->RemoteApplicationFile = value;
else if (_stricmp(name, "remoteapplicationcmdline") == 0)
file->RemoteApplicationCmdLine = value;
else if (_stricmp(name, "alternate shell") == 0)
file->AlternateShell = value;
else if (_stricmp(name, "shell working directory") == 0)
file->ShellWorkingDirectory = value;
else if (_stricmp(name, "gatewayhostname") == 0)
file->GatewayHostname = value;
else if (_stricmp(name, "kdcproxyname") == 0)
file->KdcProxyName = value;
else if (_stricmp(name, "drivestoredirect") == 0)
file->DrivesToRedirect = value;
else if (_stricmp(name, "devicestoredirect") == 0)
file->DevicesToRedirect = value;
else if (_stricmp(name, "winposstr") == 0)
file->WinPosStr = value;
else
return FALSE;
return TRUE;
}
void freerdp_client_parse_rdp_file_string_unicode(rdpFile* file, WCHAR* name, WCHAR* value)
{
int length;
char* nameA;
char* valueA;
length = _wcslen(name);
nameA = (char*) malloc(length + 1);
WideCharToMultiByte(CP_UTF8, 0, name, length, nameA, length, NULL, NULL);
nameA[length] = '\0';
length = _wcslen(value);
valueA = (char*) malloc(length + 1);
WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL);
valueA[length] = '\0';
if (!freerdp_client_rdp_file_set_string(file, nameA, valueA))
free(valueA);
free(nameA);
}
BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, BYTE* buffer, size_t size)
{
return FALSE;
}
BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, BYTE* buffer, size_t size)
{
int length;
WCHAR* line;
WCHAR* type;
WCHAR* context;
WCHAR *d1, *d2;
WCHAR *beg, *end;
WCHAR *name, *value;
line = wcstok_s((WCHAR*) buffer, CR_LF_STR_W, &context);
while (line != NULL)
{
length = _wcslen(line);
if (length > 1)
{
beg = line;
end = &line[length - 1];
d1 = _wcschr(line, ':');
if (!d1)
goto next_line; /* not first delimiter */
type = &d1[1];
d2 = _wcschr(type, ':');
if (!d2)
goto next_line; /* no second delimiter */
if ((d2 - d1) != 2)
goto next_line; /* improper type length */
if (d2 == end)
goto next_line; /* no value */
*d1 = 0;
*d2 = 0;
name = beg;
value = &d2[1];
if (*type == 'i')
{
/* integer type */
freerdp_client_parse_rdp_file_integer_unicode(file, name, value);
}
else if (*type == 's')
{
/* string type */
freerdp_client_parse_rdp_file_string_unicode(file, name, value);
}
else if (*type == 'b')
{
/* binary type */
}
}
next_line:
line = wcstok_s(NULL, CR_LF_STR_W, &context);
}
return TRUE;
}
BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, BYTE* buffer, size_t size)
{
if (size < 2)
return FALSE;
if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
return freerdp_client_parse_rdp_file_buffer_unicode(file, &buffer[2], size - 2);
return freerdp_client_parse_rdp_file_buffer_ascii(file, buffer, size);
}
BOOL freerdp_client_parse_rdp_file(rdpFile* file, char* name)
{
BYTE* buffer;
FILE* fp = NULL;
size_t read_size;
long int file_size;
fp = fopen(name, "r");
if (!fp)
return FALSE;
fseek(fp, 0, SEEK_END);
file_size = ftell(fp);
fseek(fp, 0, SEEK_SET);
if (file_size < 1)
return FALSE;
buffer = (BYTE*) malloc(file_size);
read_size = fread(buffer, file_size, 1, fp);
if (!read_size)
{
if (!ferror(fp))
read_size = file_size;
}
if (read_size < 1)
{
free(buffer);
buffer = NULL;
return FALSE;
}
return freerdp_client_parse_rdp_file_buffer(file, buffer, file_size);
}

3
client/common/test/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
TestClient
TestClient.c

View File

@@ -0,0 +1,28 @@
set(MODULE_NAME "TestClient")
set(MODULE_PREFIX "TEST_CLIENT")
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(${MODULE_PREFIX}_TESTS
TestClientRdpFile.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_DRIVER}
${${MODULE_PREFIX}_TESTS})
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
foreach(test ${${MODULE_PREFIX}_TESTS})
get_filename_component(TestName ${test} NAME_WE)
add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
endforeach()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/Client/Test")

View File

@@ -0,0 +1,296 @@
#include <stdio.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
#include <freerdp/client/file.h>
static BYTE testRdpFileUTF16[] =
{
0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00,
0x6e, 0x00, 0x20, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
0x20, 0x00, 0x69, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00, 0x73, 0x00, 0x65, 0x00,
0x20, 0x00, 0x6d, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x74, 0x00, 0x69, 0x00,
0x6d, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00,
0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x77, 0x00, 0x69, 0x00,
0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x31, 0x00, 0x39, 0x00, 0x32, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00,
0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00,
0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 0x00,
0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00,
0x38, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x73, 0x00, 0x65, 0x00,
0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00,
0x62, 0x00, 0x70, 0x00, 0x70, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x33, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x77, 0x00, 0x69, 0x00,
0x6e, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x73, 0x00, 0x74, 0x00,
0x72, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x2c, 0x00,
0x31, 0x00, 0x2c, 0x00, 0x35, 0x00, 0x35, 0x00, 0x33, 0x00, 0x2c, 0x00,
0x32, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2c, 0x00, 0x31, 0x00, 0x33, 0x00,
0x35, 0x00, 0x33, 0x00, 0x2c, 0x00, 0x38, 0x00, 0x31, 0x00, 0x31, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00,
0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6f, 0x00,
0x6e, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x6b, 0x00, 0x65, 0x00, 0x79, 0x00, 0x62, 0x00, 0x6f, 0x00,
0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6f, 0x00,
0x6b, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6f, 0x00,
0x63, 0x00, 0x61, 0x00, 0x70, 0x00, 0x74, 0x00, 0x75, 0x00, 0x72, 0x00,
0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x76, 0x00,
0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x6c, 0x00,
0x61, 0x00, 0x79, 0x00, 0x62, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00,
0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00,
0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x63, 0x00, 0x6f, 0x00,
0x6e, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x74, 0x00, 0x79, 0x00, 0x70, 0x00,
0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x37, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x74, 0x00, 0x77, 0x00, 0x6f, 0x00,
0x72, 0x00, 0x6b, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00,
0x64, 0x00, 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00,
0x62, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x77, 0x00, 0x69, 0x00,
0x64, 0x00, 0x74, 0x00, 0x68, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00,
0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x74, 0x00, 0x65, 0x00, 0x63, 0x00,
0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6c, 0x00,
0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00,
0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
0x62, 0x00, 0x61, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00,
0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00,
0x6b, 0x00, 0x73, 0x00, 0x70, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00,
0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00,
0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00,
0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x77, 0x00,
0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x70, 0x00, 0x61, 0x00, 0x70, 0x00,
0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
0x77, 0x00, 0x20, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x74, 0x00,
0x20, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
0x68, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00, 0x69, 0x00,
0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x6c, 0x00,
0x6c, 0x00, 0x6f, 0x00, 0x77, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00,
0x73, 0x00, 0x6b, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x20, 0x00,
0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x73, 0x00,
0x69, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
0x20, 0x00, 0x66, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00,
0x77, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x77, 0x00,
0x20, 0x00, 0x64, 0x00, 0x72, 0x00, 0x61, 0x00, 0x67, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
0x20, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x75, 0x00, 0x20, 0x00,
0x61, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x73, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00,
0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00,
0x20, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00,
0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x62, 0x00,
0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00,
0x73, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00,
0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x62, 0x00,
0x69, 0x00, 0x74, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x70, 0x00, 0x63, 0x00,
0x61, 0x00, 0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x70, 0x00, 0x65, 0x00,
0x72, 0x00, 0x73, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00,
0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x66, 0x00,
0x75, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x61, 0x00, 0x64, 0x00,
0x64, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x3a, 0x00,
0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00, 0x41, 0x00, 0x42, 0x00, 0x31, 0x00,
0x2d, 0x00, 0x57, 0x00, 0x37, 0x00, 0x2d, 0x00, 0x44, 0x00, 0x4d, 0x00,
0x2d, 0x00, 0x30, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00,
0x62, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00,
0x6b, 0x00, 0x65, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00,
0x61, 0x00, 0x6c, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00,
0x64, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00,
0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x72, 0x00, 0x69, 0x00,
0x6e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00,
0x65, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00,
0x74, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x6f, 0x00,
0x72, 0x00, 0x74, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x73, 0x00,
0x6d, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x63, 0x00, 0x61, 0x00,
0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x63, 0x00,
0x6c, 0x00, 0x69, 0x00, 0x70, 0x00, 0x62, 0x00, 0x6f, 0x00, 0x61, 0x00,
0x72, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00, 0x69, 0x00,
0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x70, 0x00, 0x6f, 0x00,
0x73, 0x00, 0x64, 0x00, 0x65, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00,
0x65, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x6f, 0x00,
0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x6e, 0x00,
0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00,
0x20, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6c, 0x00,
0x65, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00, 0x75, 0x00, 0x74, 0x00, 0x68, 0x00,
0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x63, 0x00, 0x61, 0x00,
0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x6c, 0x00,
0x65, 0x00, 0x76, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x69, 0x00,
0x3a, 0x00, 0x32, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00,
0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x20, 0x00, 0x66, 0x00,
0x6f, 0x00, 0x72, 0x00, 0x20, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00,
0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
0x6c, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6f, 0x00,
0x74, 0x00, 0x69, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00,
0x73, 0x00, 0x65, 0x00, 0x63, 0x00, 0x75, 0x00, 0x72, 0x00, 0x69, 0x00,
0x74, 0x00, 0x79, 0x00, 0x20, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x79, 0x00,
0x65, 0x00, 0x72, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x6f, 0x00,
0x74, 0x00, 0x65, 0x00, 0x61, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6c, 0x00,
0x69, 0x00, 0x63, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00,
0x6e, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x61, 0x00,
0x6c, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00,
0x6c, 0x00, 0x6c, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00,
0x0a, 0x00, 0x73, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00,
0x20, 0x00, 0x77, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x6b, 0x00, 0x69, 0x00,
0x6e, 0x00, 0x67, 0x00, 0x20, 0x00, 0x64, 0x00, 0x69, 0x00, 0x72, 0x00,
0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x79, 0x00,
0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00,
0x61, 0x00, 0x74, 0x00, 0x65, 0x00, 0x77, 0x00, 0x61, 0x00, 0x79, 0x00,
0x68, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6e, 0x00, 0x61, 0x00,
0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x2d, 0x00, 0x57, 0x00, 0x32, 0x00,
0x4b, 0x00, 0x38, 0x00, 0x52, 0x00, 0x32, 0x00, 0x2d, 0x00, 0x47, 0x00,
0x57, 0x00, 0x2e, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x62, 0x00, 0x31, 0x00,
0x2e, 0x00, 0x61, 0x00, 0x77, 0x00, 0x61, 0x00, 0x6b, 0x00, 0x65, 0x00,
0x2e, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x63, 0x00, 0x61, 0x00, 0x6c, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00,
0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x75, 0x00, 0x73, 0x00, 0x61, 0x00,
0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00, 0x68, 0x00,
0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x31, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00,
0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00,
0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
0x6c, 0x00, 0x73, 0x00, 0x73, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x72, 0x00,
0x63, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x67, 0x00, 0x61, 0x00, 0x74, 0x00, 0x65, 0x00,
0x77, 0x00, 0x61, 0x00, 0x79, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
0x66, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x75, 0x00, 0x73, 0x00,
0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x74, 0x00,
0x68, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6f, 0x00,
0x6d, 0x00, 0x70, 0x00, 0x74, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00,
0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x69, 0x00, 0x61, 0x00,
0x6c, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x63, 0x00, 0x65, 0x00, 0x3a, 0x00,
0x69, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x75, 0x00,
0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x64, 0x00,
0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00,
0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x6e, 0x00, 0x61, 0x00,
0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00, 0x30, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x72, 0x00, 0x64, 0x00, 0x67, 0x00, 0x69, 0x00,
0x73, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00, 0x70, 0x00, 0x72, 0x00,
0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x3a, 0x00, 0x69, 0x00, 0x3a, 0x00,
0x30, 0x00, 0x0d, 0x00, 0x0a, 0x00, 0x6b, 0x00, 0x64, 0x00, 0x63, 0x00,
0x70, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x78, 0x00, 0x79, 0x00, 0x6e, 0x00,
0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00,
0x0d, 0x00, 0x0a, 0x00, 0x64, 0x00, 0x72, 0x00, 0x69, 0x00, 0x76, 0x00,
0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x65, 0x00,
0x64, 0x00, 0x69, 0x00, 0x72, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00,
0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x2a, 0x00, 0x0d, 0x00, 0x0a, 0x00,
0x75, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6e, 0x00, 0x61, 0x00,
0x6d, 0x00, 0x65, 0x00, 0x3a, 0x00, 0x73, 0x00, 0x3a, 0x00, 0x4c, 0x00,
0x41, 0x00, 0x42, 0x00, 0x31, 0x00, 0x5c, 0x00, 0x4a, 0x00, 0x6f, 0x00,
0x68, 0x00, 0x6e, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x65, 0x00, 0x0d, 0x00,
0x0a, 0x00
};
/*
screen mode id:i:2
use multimon:i:0
desktopwidth:i:1920
desktopheight:i:1080
session bpp:i:32
winposstr:s:0,1,553,211,1353,811
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:7
networkautodetect:i:1
bandwidthautodetect:i:1
displayconnectionbar:i:1
enableworkspacereconnect:i:0
disable wallpaper:i:0
allow font smoothing:i:0
allow desktop composition:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:LAB1-W7-DM-01.lab1.awake.local
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:2
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local
gatewayusagemethod:i:1
gatewaycredentialssource:i:0
gatewayprofileusagemethod:i:1
promptcredentialonce:i:1
use redirection server name:i:0
rdgiskdcproxy:i:0
kdcproxyname:s:
drivestoredirect:s:*
username:s:LAB1\JohnDoe
*/
int TestClientRdpFile(int argc, char* argv[])
{
rdpFile* file;
file = (rdpFile*) malloc(sizeof(rdpFile));
ZeroMemory(file, sizeof(rdpFile));
freerdp_client_parse_rdp_file_buffer(file, testRdpFileUTF16, sizeof(testRdpFileUTF16));
if (file->UseMultiMon != 0)
{
printf("UseMultiMon mismatch: Actual: %d, Expected: %d\n", file->UseMultiMon, 0);
return -1;
}
if (file->ScreenModeId != 2)
{
printf("ScreenModeId mismatch: Actual: %d, Expected: %d\n", file->ScreenModeId, 2);
return -1;
}
if (file->GatewayProfileUsageMethod != 1)
{
printf("GatewayProfileUsageMethod mismatch: Actual: %d, Expected: %d\n", file->GatewayProfileUsageMethod, 1);
return -1;
}
if (strcmp(file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local");
}
return 0;
}

View File

@@ -20,6 +20,7 @@
#ifndef FREERDP_CLIENT_RDP_FILE
#define FREERDP_CLIENT_RDP_FILE
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
struct rdp_file
@@ -98,7 +99,7 @@ struct rdp_file
DWORD PromptForCredentialsOnce; /* promptcredentialonce */
DWORD NegotiateSecurityLayer; /* negotiate security layer */
DWORD EnableCredSSPSupport; /* enablecredsspsupport */
LPSTR LoadBalanceInfo; /* LoadBalanceInfo */
LPSTR LoadBalanceInfo; /* loadbalanceinfo */
DWORD RemoteApplicationMode; /* remoteapplicationmode */
LPSTR RemoteApplicationName; /* remoteapplicationname */
@@ -115,14 +116,14 @@ struct rdp_file
LPSTR ShellWorkingDirectory; /* shell working directory */
LPSTR GatewayHostname; /* gatewayhostname */
LPSTR GatewayUsageMethod; /* gatewayusagemethod */
LPSTR GatewayProfileUsageMethod; /* gatewayprofileusagemethod */
LPSTR GatewayCredentialsSource; /* gatewaycredentialssource */
DWORD GatewayUsageMethod; /* gatewayusagemethod */
DWORD GatewayProfileUsageMethod; /* gatewayprofileusagemethod */
DWORD GatewayCredentialsSource; /* gatewaycredentialssource */
DWORD UseRedirectionServerName; /* use redirection server name */
DWORD RdgIsKdcProxy; /* rdgiskdcproxy */
DWORD KdcProxyName; /* kdcproxyname */
LPSTR KdcProxyName; /* kdcproxyname */
LPSTR DrivesToRedirect; /* drivestoredirect */
LPSTR DevicesToRedirect; /* devicestoredirect */
@@ -131,4 +132,7 @@ struct rdp_file
typedef struct rdp_file rdpFile;
FREERDP_API BOOL freerdp_client_parse_rdp_file(rdpFile* file, char* name);
FREERDP_API BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, BYTE* buffer, size_t size);
#endif /* FREERDP_CLIENT_RDP_FILE */

View File

@@ -302,7 +302,8 @@ struct rdp_settings
ALIGN64 UINT32 preconnection_id; /* 73 */
ALIGN64 char* preconnection_blob; /* 74 */
ALIGN64 char* computer_name; /* 75 */
UINT64 paddingC[80 - 76]; /* 76 */
ALIGN64 char* connection_file; /* 76 */
UINT64 paddingC[80 - 77]; /* 77 */
/* User Interface Parameters */
ALIGN64 BOOL sw_gdi; /* 80 */

View File

@@ -149,24 +149,6 @@ void http_request_set_auth_param(HttpRequest* http_request, char* auth_param)
http_request->AuthParam = _strdup(auth_param);
}
#ifndef _WIN32
errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int radix)
{
int length;
length = snprintf(NULL, 0, "%d", value);
if (sizeInCharacters < length)
return -1;
snprintf(buffer, length + 1, "%d", value);
return 0;
}
#endif
char* http_encode_body_line(char* param, char* value)
{
char* line;

View File

@@ -100,16 +100,31 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
while (index < argc)
{
if (index == 1)
{
p = strstr(argv[index], ".rdp");
if (!p)
p = strstr(argv[index], ".RDP");
if (p)
{
settings->connection_file = _strdup(argv[index]);
index++;
continue;
}
}
if ((strcmp("-h", argv[index]) == 0 ) || (strcmp("--help", argv[index]) == 0 ))
{
printf("\n"
"FreeRDP - A Free Remote Desktop Protocol Client\n"
"See http://www.freerdp.com for more information\n"
"\n"
"Usage: %s [options] server:port\n"
"Usage: %s [file] [options] server:port\n"
" -0: connect to console session\n"
" -a: set color depth in bit, default is 16\n"
" -c: initial working directory\n"
" -c: shell working directory\n"
" -D: hide window decorations\n"
" -T: window title\n"
" -d: domain\n"
@@ -869,58 +884,76 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
You can prompt for username, password, domain and hostname to avoid disclosing
these settings to ps. */
if (settings->from_stdin) {
if (settings->from_stdin)
{
/* username */
if (NULL == settings->username) {
if (NULL == settings->username)
{
char input[512];
input[0] = '\0';
printf("username: ");
if (scanf("%511s", input) > 0) {
if (scanf("%511s", input) > 0)
{
settings->username = _strdup(input);
}
}
/* password */
if (NULL == settings->password) {
if (NULL == settings->password)
{
settings->password = malloc(512 * sizeof(char));
if (isatty(STDIN_FILENO))
{
freerdp_passphrase_read("password: ", settings->password, 512, settings->from_stdin);
else {
}
else
{
printf("password: ");
if (scanf("%511s", settings->password) <= 0) {
if (scanf("%511s", settings->password) <= 0)
{
free(settings->password);
settings->password = NULL;
}
}
}
/* domain */
if (NULL == settings->domain) {
if (NULL == settings->domain)
{
char input[512];
input[0] = '\0';
printf("domain (control-D to skip): ");
if (scanf("%511s", input) > 0) {
/* Try to catch the cases where the string is NULL-ish right
at the get go */
if (input[0] != '\0' && !(input[0] == '.' && input[1] == '\0')) {
if (scanf("%511s", input) > 0)
{
/* Try to catch the cases where the string is NULL-ish right at the get go */
if (input[0] != '\0' && !(input[0] == '.' && input[1] == '\0'))
settings->domain = _strdup(input);
}
}
}
/* hostname */
if (NULL == settings->hostname) {
if (NULL == settings->hostname)
{
char input[512];
input[0] = '\0';
printf("hostname: ");
if (scanf("%511s", input) > 0) {
if (scanf("%511s", input) > 0)
freerdp_parse_hostname(settings, input);
}
}
}
/* Must have a hostname. Do you? */
if (NULL == settings->hostname) {
if (NULL == settings->hostname)
{
printf("missing server name\n");
return FREERDP_ARGS_PARSE_FAILURE;
} else {
}
else
{
return index;
}

View File

@@ -50,6 +50,10 @@ WINPR_API size_t _aligned_msize(void* memblock, size_t alignment, size_t offset)
WINPR_API void _aligned_free(void* memblock);
/* Data Conversion */
WINPR_API errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int radix);
/* Buffer Manipulation */
WINPR_API errno_t memmove_s(void* dest, size_t numberOfElements, const void* src, size_t count);

View File

@@ -49,7 +49,11 @@ WINPR_API WCHAR* _wcsdup(const WCHAR* strSource);
WINPR_API int _stricmp(const char* string1, const char* string2);
WINPR_API size_t _wcslen(const WCHAR* str);
WINPR_API WCHAR* _wcschr(const WCHAR* str, WCHAR c);
WINPR_API char* strtok_s(char* strToken, const char* strDelimit, char** context);
WINPR_API WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context);
WINPR_API LPSTR CharUpperA(LPSTR lpsz);
WINPR_API LPWSTR CharUpperW(LPWSTR lpsz);
@@ -149,6 +153,11 @@ WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2);
#define sprintf_s snprintf
#else
#define _wcslen wcslen
#define _wcschr wcschr
#endif
#endif /* WINPR_CRT_STRING_H */

View File

@@ -20,6 +20,7 @@ set(MODULE_PREFIX "WINPR_CRT")
set(${MODULE_PREFIX}_SRCS
alignment.c
conversion.c
buffer.c
memory.c
string.c)

View File

@@ -0,0 +1,45 @@
/**
* WinPR: Windows Portable Runtime
* Data Conversion
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/crt.h>
/* Data Conversion: http://msdn.microsoft.com/en-us/library/0heszx3w/ */
#ifndef _WIN32
errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int radix)
{
int length;
length = snprintf(NULL, 0, "%d", value);
if (sizeInCharacters < length)
return -1;
snprintf(buffer, length + 1, "%d", value);
return 0;
}
#endif

View File

@@ -74,11 +74,61 @@ int _stricmp(const char* string1, const char* string2)
return strcasecmp(string1, string2);
}
/* _wcslen -> wcslen */
size_t _wcslen(const WCHAR* str)
{
WCHAR* p = (WCHAR*) str;
while (*p)
p++;
return (p - str);
}
/* _wcschr -> wcschr */
WCHAR* _wcschr(const WCHAR* str, WCHAR c)
{
WCHAR* p = (WCHAR*) str;
while (*p && (*p != c))
p++;
return ((*p == c) ? p : NULL);
}
char* strtok_s(char* strToken, const char* strDelimit, char** context)
{
return strtok_r(strToken, strDelimit, context);
}
WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context)
{
WCHAR* nextToken;
if (!strToken)
strToken = *context;
while (*strToken && _wcschr(strDelimit, *strToken))
strToken++;
if (!*strToken)
return NULL;
nextToken = strToken++;
while (*strToken && !(_wcschr(strDelimit, *strToken)))
strToken++;
if (*strToken)
*strToken++ = 0;
*context = strToken;
return nextToken;
}
/* Windows API Sets - api-ms-win-core-string-l2-1-0.dll
* http://msdn.microsoft.com/en-us/library/hh802935/
*/

View File

@@ -5,7 +5,8 @@ set(MODULE_PREFIX "TEST_CRT")
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(${MODULE_PREFIX}_TESTS
TestAlignment.c)
TestAlignment.c
TestString.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_DRIVER}

View File

@@ -0,0 +1,109 @@
#include <stdio.h>
#include <winpr/crt.h>
#include <winpr/windows.h>
static WCHAR testStringW[] =
{
'T', 'h', 'e', ' ', 'q', 'u', 'i', 'c', 'k', ' ', 'b', 'r', 'o', 'w', 'n', ' ',
'f', 'o', 'x', ' ', 'j', 'u', 'm', 'p', 's', ' ', 'o', 'v', 'e', 'r', ' ',
't', 'h', 'e', ' ', 'l', 'a', 'z', 'y', ' ', 'd', 'o', 'g', '\0'
};
#define testStringW_Length ((sizeof(testStringW) / sizeof(WCHAR)) - 1)
static WCHAR testToken1W[] = { 'q', 'u', 'i', 'c', 'k', '\0' };
static WCHAR testToken2W[] = { 'b', 'r', 'o', 'w', 'n', '\0' };
static WCHAR testToken3W[] = { 'f', 'o', 'x', '\0' };
static WCHAR testTokensW[] =
{
'q', 'u', 'i', 'c', 'k', '\r', '\n',
'b', 'r', 'o', 'w', 'n', '\r', '\n',
'f', 'o', 'x', '\r', '\n', '\0'
};
static WCHAR testDelimiter[] = { '\r', '\n', '\0' };
int TestString(int argc, char* argv[])
{
WCHAR* p;
size_t pos;
size_t length;
WCHAR* context;
/* _wcslen */
length = _wcslen(testStringW);
if (length != testStringW_Length)
{
printf("_wcslen error: length mismatch: Actual: %d, Expected: %d\n", length, testStringW_Length);
return -1;
}
/* _wcschr */
p = _wcschr(testStringW, 'r');
pos = (p - testStringW);
if (pos != 11)
{
printf("_wcschr error: position mismatch: Actual: %d, Expected: %d\n", pos, 11);
return -1;
}
p = _wcschr(&testStringW[pos + 1], 'r');
pos = (p - testStringW);
if (pos != 29)
{
printf("_wcschr error: position mismatch: Actual: %d, Expected: %d\n", pos, 29);
return -1;
}
p = _wcschr(&testStringW[pos + 1], 'r');
if (p != NULL)
{
printf("_wcschr error: return value mismatch: Actual: 0x%08X, Expected: 0x%08X\n", (size_t) p, (size_t) NULL);
return -1;
}
/* wcstok_s */
p = wcstok_s(testTokensW, testDelimiter, &context);
if (memcmp(p, testToken1W, sizeof(testToken1W)) != 0)
{
printf("wcstok_s error: token #1 mismatch\n");
return -1;
}
p = wcstok_s(NULL, testDelimiter, &context);
if (memcmp(p, testToken2W, sizeof(testToken2W)) != 0)
{
printf("wcstok_s error: token #2 mismatch\n");
return -1;
}
p = wcstok_s(NULL, testDelimiter, &context);
if (memcmp(p, testToken3W, sizeof(testToken3W)) != 0)
{
printf("wcstok_s error: token #3 mismatch\n");
return -1;
}
p = wcstok_s(NULL, testDelimiter, &context);
if (p != NULL)
{
printf("wcstok_s error: return value is not NULL\n");
return -1;
}
return 0;
}

View File

@@ -29,6 +29,10 @@
#include <winpr/sam.h>
#include <winpr/print.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#define WINPR_SAM_FILE "C:\\SAM"
#else