21#include <freerdp/config.h>
22#include <freerdp/version.h>
24#include "../settings.h"
26#include <winpr/assert.h>
29#include <winpr/synch.h>
30#include <winpr/print.h>
31#include <winpr/stream.h>
32#include <winpr/winsock.h>
33#include <winpr/cred.h>
34#include <winpr/bcrypt.h>
36#include <freerdp/log.h>
37#include <freerdp/error.h>
38#include <freerdp/crypto/certificate.h>
39#include <freerdp/utils/ringbuffer.h>
40#include <freerdp/utils/smartcardlogon.h>
41#include <freerdp/utils/aad.h>
47#include "../credssp_auth.h"
50#include "../../crypto/crypto.h"
51#include "../../crypto/certificate.h"
52#include "../../crypto/opensslcompat.h"
55#include "../redirection.h"
57#include <winpr/json.h>
71typedef struct rdp_arm rdpArm;
73#define TAG FREERDP_TAG("core.gateway.arm")
77static BOOL arm_tls_connect(rdpArm* arm, rdpTls* tls, UINT32 timeout)
83 BIO* socketBio =
nullptr;
84 BIO* bufferedBio =
nullptr;
85 rdpSettings* settings = arm->context->settings;
94 const char* proxyUsername =
nullptr;
95 const char* proxyPassword =
nullptr;
96 BOOL isProxyConnection =
97 proxy_prepare(settings, &peerHostname, &peerPort, &proxyUsername, &proxyPassword);
99 sockfd = freerdp_tcp_connect(arm->context, peerHostname, peerPort, timeout);
101 WLog_Print(arm->log, WLOG_DEBUG,
"connecting to %s %d", peerHostname, peerPort);
105 socketBio = BIO_new(BIO_s_simple_socket());
109 closesocket((SOCKET)sockfd);
113 BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
114 bufferedBio = BIO_new(BIO_s_buffered_socket());
118 BIO_free_all(socketBio);
122 bufferedBio = BIO_push(bufferedBio, socketBio);
126 status = BIO_set_nonblock(bufferedBio, TRUE);
128 if (isProxyConnection)
130 if (!proxy_connect(arm->context, bufferedBio, proxyUsername, proxyPassword,
134 BIO_free_all(bufferedBio);
141 BIO_free_all(bufferedBio);
146 tls->port = MIN(UINT16_MAX, WINPR_ASSERTING_INT_CAST(int32_t, settings->GatewayPort));
147 tls->isGatewayTransport = TRUE;
148 status = freerdp_tls_connect(tls, bufferedBio);
151 rdpContext* context = arm->context;
153 freerdp_set_last_error_if_not(context, FREERDP_ERROR_TLS_CONNECT_FAILED);
155 freerdp_set_last_error_if_not(context, FREERDP_ERROR_CONNECT_CANCELLED);
159 return (status >= 1);
163static BOOL arm_fetch_wellknown(rdpArm* arm)
166 WINPR_ASSERT(arm->context);
167 WINPR_ASSERT(arm->context->rdp);
169 rdpRdp* rdp = arm->context->rdp;
175 const BOOL useTenant =
177 const char* tenantid =
"common";
182 rdp->wellknown = freerdp_utils_aad_get_wellknown(arm->log, base, tenantid);
183 return (rdp->wellknown !=
nullptr);
186WINPR_ATTR_MALLOC(Stream_Free, 1)
187static
wStream* arm_build_http_request(rdpArm* arm, const
char* method,
188 TRANSFER_ENCODING transferEncoding, const
char* content_type,
189 size_t content_length)
194 WINPR_ASSERT(method);
195 WINPR_ASSERT(content_type);
197 WINPR_ASSERT(arm->context);
198 WINPR_ASSERT(arm->context->rdp);
200 const char* uri = http_context_get_uri(arm->http);
201 HttpRequest* request = http_request_new();
206 rdpSettings* settings = arm->context->settings;
208 if (!http_request_set_method(request, method) || !http_request_set_uri(request, uri))
213 pGetCommonAccessToken GetCommonAccessToken = freerdp_get_common_access_token(arm->context);
214 if (!GetCommonAccessToken)
216 WLog_Print(arm->log, WLOG_ERROR,
"No authorization token provided");
220 if (!arm_fetch_wellknown(arm))
223 char* token =
nullptr;
224 if (!GetCommonAccessToken(arm->context, ACCESS_TOKEN_TYPE_AVD, &token, 0))
227 WLog_Print(arm->log, WLOG_ERROR,
"Unable to obtain access token");
238 if (!http_request_set_auth_scheme(request,
"Bearer") ||
239 !http_request_set_auth_param(
243 if (!http_request_set_transfer_encoding(request, transferEncoding) ||
244 !http_request_set_content_length(request, content_length) ||
245 !http_request_set_content_type(request, content_type))
248 s = http_request_write(arm->http, request);
250 http_request_free(request);
253 Stream_SealLength(s);
259static BOOL arm_send_http_request(rdpArm* arm, rdpTls* tls,
const char* method,
260 const char* content_type,
const char* data,
size_t content_length)
264 arm_build_http_request(arm, method, TransferEncodingIdentity, content_type, content_length);
269 const size_t sz = Stream_Length(s);
270 WLog_Print(arm->log, WLOG_TRACE,
"header [%" PRIuz
"]: %s", sz, Stream_Buffer(s));
271 WLog_Print(arm->log, WLOG_TRACE,
"body [%" PRIuz
"]: %s", content_length, data);
272 status = freerdp_tls_write_all(tls, Stream_Buffer(s), sz);
274 Stream_Free(s, TRUE);
275 if (status >= 0 && content_length > 0 && data)
276 status = freerdp_tls_write_all(tls, (
const BYTE*)data, content_length);
278 return (status >= 0);
281static void arm_free(rdpArm* arm)
286 freerdp_tls_free(arm->tls);
287 http_context_free(arm->http);
292WINPR_ATTR_MALLOC(arm_free, 1)
293static rdpArm* arm_new(rdpContext* context)
295 WINPR_ASSERT(context);
297 rdpArm* arm = (rdpArm*)calloc(1,
sizeof(rdpArm));
301 arm->log = WLog_Get(TAG);
302 arm->context = context;
303 arm->tls = freerdp_tls_new(context);
307 arm->http = http_context_new();
319WINPR_ATTR_MALLOC(arm_free, 1)
320static
char* arm_create_request_json(rdpArm* arm,
size_t* pLen)
326 char* message =
nullptr;
333 goto arm_create_cleanup;
337 goto arm_create_cleanup;
341 lbi = calloc(len + 1ull,
sizeof(
char));
343 goto arm_create_cleanup;
349 goto arm_create_cleanup;
351 goto arm_create_cleanup;
353 goto arm_create_cleanup;
359 winpr_znfree(lbi, lbiLen);
361 *pLen = strlen(message);
379WINPR_ATTR_MALLOC(winpr_Cipher_Free, 1)
380static WINPR_CIPHER_CTX* treatAuthBlob(wLog* log, const BYTE* pbInput,
size_t cbInput,
383 WINPR_CIPHER_CTX* ret =
nullptr;
384 char algoName[100] = WINPR_C_ARRAY_INIT;
386 WINPR_ASSERT(pBlockSize);
387 SSIZE_T algoSz = ConvertWCharNToUtf8(WINPR_PACKED_ALIGN_CAST(
const WCHAR*, pbInput),
388 cbInput /
sizeof(WCHAR), algoName,
sizeof(algoName) - 1);
391 WLog_Print(log, WLOG_ERROR,
"invalid algoName");
395 if (strcmp(algoName,
"AES") != 0)
397 WLog_Print(log, WLOG_ERROR,
"only AES is supported for now");
401 *pBlockSize = WINPR_AES_BLOCK_SIZE;
402 const size_t algoLen = WINPR_ASSERTING_INT_CAST(
size_t, (algoSz + 1)) *
sizeof(WCHAR);
403 if (cbInput < algoLen)
405 WLog_Print(log, WLOG_ERROR,
"invalid AuthBlob size");
412 wStream staticStream = WINPR_C_ARRAY_INIT;
413 wStream* s = Stream_StaticConstInit(&staticStream, &pbInput[algoLen], cbInput);
415 if (!Stream_CheckAndLogRequiredLengthWLog(log, s, 12))
418 const UINT32 dwMagic = Stream_Get_UINT32(s);
419 if (dwMagic != BCRYPT_KEY_DATA_BLOB_MAGIC)
421 WLog_Print(log, WLOG_ERROR,
"unsupported authBlob type");
425 const UINT32 dwVersion = Stream_Get_UINT32(s);
426 if (dwVersion != BCRYPT_KEY_DATA_BLOB_VERSION1)
428 WLog_Print(log, WLOG_ERROR,
"unsupported authBlob version %" PRIu32
", expecting %d",
429 dwVersion, BCRYPT_KEY_DATA_BLOB_VERSION1);
433 const UINT32 cbKeyData = Stream_Get_UINT32(s);
434 if (!Stream_CheckAndLogRequiredLengthWLog(log, s, cbKeyData))
436 WLog_Print(log, WLOG_ERROR,
"invalid authBlob size");
440 WINPR_CIPHER_TYPE cipherType = WINPR_CIPHER_NONE;
444 cipherType = WINPR_CIPHER_AES_128_CBC;
447 cipherType = WINPR_CIPHER_AES_192_CBC;
450 cipherType = WINPR_CIPHER_AES_256_CBC;
453 WLog_Print(log, WLOG_ERROR,
"invalid authBlob cipher size");
457 ret = winpr_Cipher_NewEx(cipherType, WINPR_ENCRYPT, Stream_Pointer(s), cbKeyData,
nullptr, 0);
460 WLog_Print(log, WLOG_ERROR,
"error creating cipher");
464 if (!winpr_Cipher_SetPadding(ret, TRUE))
466 WLog_Print(log, WLOG_ERROR,
"unable to enable padding on cipher");
467 winpr_Cipher_Free(ret);
475static BOOL arm_stringEncodeW(
const BYTE* pin,
size_t cbIn, BYTE** ppOut,
size_t* pcbOut)
482 char* b64encoded = crypto_base64_encode_ex_len(pin, cbIn, TRUE, &b64len);
488 *ppOut = (BYTE*)ConvertUtf8NToWCharAlloc(b64encoded, b64len, &outSz);
494 *pcbOut = (outSz + 1) *
sizeof(WCHAR);
499static BOOL arm_encodeRedirectPasswd(wLog* log, rdpSettings* settings,
const rdpCertificate* cert,
500 WINPR_CIPHER_CTX* cipher,
size_t blockSize)
503 BYTE* output =
nullptr;
504 BYTE* finalOutput =
nullptr;
510 size_t wpasswdLen = 0;
514 WLog_Print(log, WLOG_ERROR,
"error when converting password to UTF16");
518 const size_t wpasswdBytes = (wpasswdLen + 1) *
sizeof(WCHAR);
519 BYTE* encryptedPass = calloc(1, wpasswdBytes + blockSize);
525 size_t encryptedPassLen = 0;
526 if (!winpr_Cipher_Update(cipher, wpasswd, wpasswdBytes, encryptedPass, &encryptedPassLen))
529 if (encryptedPassLen > wpasswdBytes)
534 if (!winpr_Cipher_Final(cipher, &encryptedPass[encryptedPassLen], &finalLen))
536 WLog_Print(log, WLOG_ERROR,
"error when ciphering password");
539 encryptedPassLen += finalLen;
544 size_t output_length = 0;
545 if (!freerdp_certificate_publickey_encrypt(cert, encryptedPass, encryptedPassLen,
546 &output, &output_length))
548 WLog_Print(log, WLOG_ERROR,
"unable to encrypt with the server's public key");
553 size_t finalOutputLen = 0;
554 if (!arm_stringEncodeW(output, output_length, &finalOutput, &finalOutputLen))
556 WLog_Print(log, WLOG_ERROR,
"unable to base64+utf16 final blob");
561 finalOutput, finalOutputLen))
563 WLog_Print(log, WLOG_ERROR,
564 "unable to set the redirection password in settings");
584 LB_PASSWORD_IS_PK_ENCRYPTED))
600static BOOL arm_pick_base64Utf16Field(wLog* log,
const WINPR_JSON* json,
const char* name,
601 BYTE** poutput,
size_t* plen)
614 BYTE* output1 =
nullptr;
616 crypto_base64_decode(nodeValue, strlen(nodeValue), &output1, &len1);
617 if (!output1 || !len1)
619 WLog_Print(log, WLOG_ERROR,
"error when first unbase64 for %s", name);
625 char* output2 = ConvertWCharNToUtf8Alloc(WINPR_PACKED_ALIGN_CAST(WCHAR*, output1),
626 len1 /
sizeof(WCHAR), &len2);
628 if (!output2 || !len2)
630 WLog_Print(log, WLOG_ERROR,
"error when decode('utf-16') for %s", name);
635 BYTE* output =
nullptr;
636 crypto_base64_decode(output2, len2, &output, plen);
638 if (!output || !*plen)
640 WLog_Print(log, WLOG_ERROR,
"error when second unbase64 for %s", name);
669static size_t arm_parse_ipvx_count(WINPR_JSON* ipvX)
681static BOOL arm_parse_ipv6(rdpSettings* settings, WINPR_JSON* ipv6,
size_t* pAddressIdx)
683 WINPR_ASSERT(settings);
685 WINPR_ASSERT(pAddressIdx);
695 for (
size_t j = 0; j < naddresses; j++)
702 if (utils_str_is_empty(addr))
705 if (*pAddressIdx >= count)
707 WLog_ERR(TAG,
"Exceeded TargetNetAddresses, parsing failed");
711 if (!winpr_str_is_valid_url(addr))
713 WLog_ERR(TAG,
"TargetNetAddress[%" PRIuz
"]: %s not an URL or IP", j, addr);
717 if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetAddresses,
718 (*pAddressIdx)++, addr))
725static BOOL arm_parse_ipv4(rdpSettings* settings, WINPR_JSON* ipv4,
size_t* pAddressIdx)
727 WINPR_ASSERT(settings);
729 WINPR_ASSERT(pAddressIdx);
737 for (
size_t j = 0; j < naddresses; j++)
743 WINPR_JSON* publicIpNode =
748 if (!utils_str_is_empty(publicIp))
750 if (*pAddressIdx >= count)
752 WLog_ERR(TAG,
"Exceeded TargetNetAddresses, parsing failed");
756 if (!utils_is_valid_ip(publicIp))
758 WLog_ERR(TAG,
"publicIpAddress value %s: not a valid IP", publicIp);
762 if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetAddresses,
763 (*pAddressIdx)++, publicIp))
768 WINPR_JSON* privateIpNode =
773 if (!utils_str_is_empty(privateIp))
775 if (*pAddressIdx >= count)
777 WLog_ERR(TAG,
"Exceeded TargetNetAddresses, parsing failed");
780 if (!utils_is_valid_ip(privateIp))
782 WLog_ERR(TAG,
"privateIpAddress value %s: not a valid IP", privateIp);
786 if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetAddresses,
787 (*pAddressIdx)++, privateIp))
796static BOOL arm_treat_azureInstanceNetworkMetadata(wLog* log,
const char* metadata,
797 rdpSettings* settings)
801 WINPR_ASSERT(settings);
803 if (!freerdp_target_net_adresses_reset(settings, 0))
809 WLog_Print(log, WLOG_ERROR,
"invalid azureInstanceNetworkMetadata");
822 WLog_Print(log, WLOG_ERROR,
"expecting interface to be an Array");
828 if (interfaceSz == 0)
830 WLog_WARN(TAG,
"no addresses in azure instance metadata");
837 for (
size_t i = 0; i < interfaceSz; i++)
845 count += arm_parse_ipvx_count(ipv6);
849 count += arm_parse_ipvx_count(ipv4);
852 if (!freerdp_target_net_adresses_reset(settings, count))
857 size_t addressIdx = 0;
858 for (
size_t i = 0; i < interfaceSz; i++)
867 if (!arm_parse_ipv6(settings, ipv6, &addressIdx))
874 if (!arm_parse_ipv4(settings, ipv4, &addressIdx))
878 if (addressIdx > UINT32_MAX)
885 ret = addressIdx > 0;
895static BOOL arm_fill_rdstls(rdpArm* arm, rdpSettings* settings,
const WINPR_JSON* json,
896 const rdpCertificate* redirectedServerCert)
899 WINPR_ASSERT(settings);
902 if (!redirectedServerCert)
906 BYTE* authBlob =
nullptr;
907 WCHAR* wGUID =
nullptr;
935 WINPR_ASSERT(arm->context);
936 WINPR_ASSERT(arm->context->instance);
938 char* username =
nullptr;
939 char* password =
nullptr;
940 char* domain =
nullptr;
943 domain = _strdup(ddomain);
945 username = _strdup(duser);
948 IFCALLRESULT(FALSE, arm->context->instance->AuthenticateEx, arm->context->instance,
949 &username, &password, &domain, AUTH_RDSTLS);
954 winpr_zfree(username);
955 winpr_zfree(password);
957 if (!rc || !rc1 || !rc2 || !rc3)
964 WINPR_JSON* redirectedAuthGuidNode =
971 if (!redirectedAuthGuid)
975 size_t wGUID_len = 0;
976 wGUID = ConvertUtf8ToWCharAlloc(redirectedAuthGuid, &wGUID_len);
977 if (!wGUID || (wGUID_len == 0))
979 WLog_Print(arm->log, WLOG_ERROR,
980 "unable to allocate space for redirectedAuthGuid");
986 settings, FreeRDP_RedirectionGuid, wGUID, (wGUID_len + 1) *
sizeof(WCHAR));
990 WLog_Print(arm->log, WLOG_ERROR,
"unable to set RedirectionGuid");
1000 size_t authBlobLen = 0;
1001 if (!arm_pick_base64Utf16Field(arm->log, json,
"redirectedAuthBlob", &authBlob,
1006 size_t blockSize = 0;
1007 WINPR_CIPHER_CTX* cipher = treatAuthBlob(arm->log, authBlob, authBlobLen, &blockSize);
1012 const BOOL rerp = arm_encodeRedirectPasswd(arm->log, settings, redirectedServerCert,
1014 winpr_Cipher_Free(cipher);
1030static BOOL arm_fill_gateway_parameters(rdpArm* arm,
const char* message,
size_t len)
1033 WINPR_ASSERT(arm->context);
1034 WINPR_ASSERT(message);
1036 rdpCertificate* redirectedServerCert =
nullptr;
1038 BOOL status = FALSE;
1041 WLog_Print(arm->log, WLOG_ERROR,
"Response data is not valid JSON: %s",
1046 if (WLog_IsLevelActive(arm->log, WLOG_DEBUG))
1049 WLog_Print(arm->log, WLOG_DEBUG,
"Got HTTP Response data: %s", str);
1053 rdpSettings* settings = arm->context->settings;
1058 if (gwurlstr !=
nullptr)
1060 WLog_Print(arm->log, WLOG_DEBUG,
"extracted target url %s", gwurlstr);
1066 WINPR_JSON* serverNameNode =
1080 const char key[] =
"redirectedUsername";
1083 const char* userName =
nullptr;
1093 WINPR_JSON* azureMeta =
1097 if (!arm_treat_azureInstanceNetworkMetadata(
1100 WLog_Print(arm->log, WLOG_ERROR,
1101 "error when treating azureInstanceNetworkMetadata");
1110 BYTE* cert =
nullptr;
1111 if (arm_pick_base64Utf16Field(arm->log, json,
"redirectedServerCert", &cert, &certLen))
1113 const BOOL rc = rdp_redirection_read_target_cert(&redirectedServerCert, cert, certLen);
1117 else if (!rdp_set_target_certificate(settings, redirectedServerCert))
1125 status = arm_fill_rdstls(arm, settings, json, redirectedServerCert);
1129 freerdp_certificate_free(redirectedServerCert);
1134static BOOL arm_handle_request_ok(rdpArm* arm,
const HttpResponse* response)
1136 const size_t len = http_response_get_body_length(response);
1137 const char* msg = http_response_get_body(response);
1138 if ((len == 0) || !msg)
1140 WLog_Print(arm->log, WLOG_ERROR,
"Got HTTP Response data with empty body");
1143 const size_t alen = strnlen(msg, len + 1);
1146 WLog_Print(arm->log, WLOG_ERROR,
"Got HTTP Response data with invalid termination");
1150 return arm_fill_gateway_parameters(arm, msg, len);
1154static BOOL arm_handle_bad_request(rdpArm* arm,
const HttpResponse* response, BOOL* retry)
1156 WINPR_ASSERT(response);
1157 WINPR_ASSERT(retry);
1163 http_response_log_error_status(WLog_Get(TAG), WLOG_ERROR, response);
1165 const size_t len = http_response_get_body_length(response);
1166 const char* msg = http_response_get_body(response);
1167 if (msg && (strnlen(msg, len + 1) > len))
1169 WLog_Print(arm->log, WLOG_ERROR,
"Got HTTP Response data, but length is invalid");
1174 WLog_Print(arm->log, WLOG_DEBUG,
"Got HTTP Response data: %s", msg);
1177 if (json ==
nullptr)
1180 WLog_Print(arm->log, WLOG_ERROR,
"WINPR_JSON_ParseWithLength: %s", error_ptr);
1188 if (gw_code_str ==
nullptr)
1190 WLog_Print(arm->log, WLOG_ERROR,
"Response has no \"Code\" property");
1194 if (strcmp(gw_code_str,
"E_PROXY_ORCHESTRATION_LB_SESSIONHOST_DEALLOCATED") == 0)
1200 WLog_WARN(TAG,
"Starting your VM. It may take up to 5 minutes");
1202 WLog_WARN(TAG,
"%s", msgstr);
1203 freerdp_set_last_error_if_not(arm->context, FREERDP_ERROR_CONNECT_TARGET_BOOTING);
1218static BOOL arm_handle_request(rdpArm* arm, BOOL* retry, DWORD timeout)
1220 WINPR_ASSERT(retry);
1222 if (!arm_fetch_wellknown(arm))
1230 size_t messageLen = 0;
1231 char* message =
nullptr;
1234 HttpResponse* response =
nullptr;
1235 long StatusCode = 0;
1237 const char* useragent =
1239 const char* msuseragent =
1241 if (!http_context_set_uri(arm->http,
"/api/arm/v2/connections") ||
1242 !http_context_set_accept(arm->http,
"*/*") ||
1243 !http_context_set_cache_control(arm->http,
"no-cache") ||
1244 !http_context_set_pragma(arm->http,
"no-cache") ||
1245 !http_context_set_connection(arm->http,
"Keep-Alive") ||
1246 !http_context_set_user_agent(arm->http, useragent) ||
1247 !http_context_set_x_ms_user_agent(arm->http, msuseragent) ||
1249 FreeRDP_GatewayHostname)))
1252 if (!arm_tls_connect(arm, arm->tls, timeout))
1255 message = arm_create_request_json(arm, &messageLen);
1259 if (!arm_send_http_request(arm, arm->tls,
"POST",
"application/json", message, messageLen))
1262 response = http_response_recv(arm->tls, TRUE);
1266 StatusCode = http_response_get_status_code(response);
1267 if (StatusCode == HTTP_STATUS_OK)
1269 if (!arm_handle_request_ok(arm, response))
1272 else if (StatusCode == HTTP_STATUS_BAD_REQUEST)
1274 if (!arm_handle_bad_request(arm, response, retry))
1279 http_response_log_error_status(WLog_Get(TAG), WLOG_ERROR, response);
1285 http_response_free(response);
1286 winpr_znfree(message, messageLen);
1292BOOL arm_resolve_endpoint(wLog* log, rdpContext* context, DWORD timeout)
1295 WLog_Print(log, WLOG_ERROR,
"arm gateway support not compiled in");
1302 if (!context->settings)
1309 WLog_Print(log, WLOG_ERROR,
"loadBalanceInfo and RemoteApplicationProgram needed");
1313 rdpArm* arm = arm_new(context);
1323 freerdp* instance = context->instance;
1324 WINPR_ASSERT(instance);
1325 SSIZE_T delay = IFCALLRESULT(-1, instance->RetryDialog, instance,
"arm-transport",
1326 arm->gateway_retry, arm);
1327 arm->gateway_retry++;
1332 WLog_Print(arm->log, WLOG_DEBUG,
"Delay for %" PRIdz
"ms before next attempt",
1336 DWORD slp = (UINT32)delay;
1337 if (delay > UINT32_MAX)
1344 rc = arm_handle_request(arm, &retry, timeout);
1346 }
while (retry && rc);
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_CreateObject(void)
WINPR_JSON_CreateObject.
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON *object, const char *string)
Check if JSON has an object matching the name.
WINPR_ATTR_NODISCARD WINPR_API size_t WINPR_JSON_GetArraySize(const WINPR_JSON *array)
Get the number of arrayitems from an array.
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON *object, const char *string)
Same as WINPR_JSON_GetObjectItem but with case sensitive matching.
WINPR_API WINPR_JSON * WINPR_JSON_ParseWithLength(const char *value, size_t buffer_length)
Parse a JSON string.
WINPR_ATTR_NODISCARD WINPR_API const char * WINPR_JSON_GetErrorPtr(void)
Return an error string.
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON *item)
Check if JSON item is of type String.
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_GetArrayItem(const WINPR_JSON *array, size_t index)
Return a pointer to an item in the array.
WINPR_API char * WINPR_JSON_PrintUnformatted(WINPR_JSON *item)
Serialize a JSON instance to string without formatting for human readable formatted output see WINPR_...
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_IsArray(const WINPR_JSON *item)
Check if JSON item is of type Array.
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_AddNullToObject(WINPR_JSON *object, const char *name)
WINPR_JSON_AddNullToObject.
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_AddStringToObject(WINPR_JSON *object, const char *name, const char *string)
WINPR_JSON_AddStringToObject.
WINPR_API void WINPR_JSON_Delete(WINPR_JSON *item)
Delete a WinPR JSON wrapper object.
WINPR_ATTR_NODISCARD WINPR_API const char * WINPR_JSON_GetStringValue(WINPR_JSON *item)
Return the String value of a JSON item.
WINPR_API WINPR_JSON * WINPR_JSON_Parse(const char *value)
Parse a '\0' terminated JSON string.
WINPR_ATTR_NODISCARD FREERDP_API const void * freerdp_settings_get_pointer(const rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a immutable pointer settings value.
WINPR_ATTR_NODISCARD FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL val)
Sets a BOOL settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 val)
Sets a UINT32 settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_pointer_len(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id, const void *data, size_t len)
Set a pointer to value data.
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API WCHAR * freerdp_settings_get_string_as_utf16(const rdpSettings *settings, FreeRDP_Settings_Keys_String id, size_t *pCharLen)
Return an allocated UTF16 string.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *val)
Sets a string settings value. The param is copied.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.